Skip to content

Commit

Permalink
marvin 'toggle desktop'
Browse files Browse the repository at this point in the history
- hides framerate, clock, HP bar, mana bar, oxygen bar from UI
  • Loading branch information
Black_Fox committed Jun 25, 2023
1 parent ba27c66 commit 13250e6
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 21 deletions.
8 changes: 8 additions & 0 deletions game/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ void Camera::toggleDebug() {
dbg = !dbg;
}

void Camera::toggleDesktop() {
desktop = !desktop;
}

bool Camera::isDesktop() {
return desktop;
}

void Camera::setSpin(const PointF &p) {
dst.spin = Vec3(p.x,p.y,0);
src.spin = dst.spin;
Expand Down
3 changes: 3 additions & 0 deletions game/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class Camera final {
void setLookBack(bool lb);

void toggleDebug();
void togglePDesktop();
bool isDesktop();

void tick(uint64_t dt);
void debugDraw(DbgPainter& p);
Expand Down Expand Up @@ -142,6 +144,7 @@ class Camera final {
uint32_t vpHeight=0;

bool dbg = false;
bool desktop = false;
bool tgEnable = true;
bool fpEnable = false;
bool lbEnable = false;
Expand Down
54 changes: 34 additions & 20 deletions game/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,18 @@ void MainWindow::paintEvent(PaintEvent& event) {
paintFocus(p,focus,vp);

if(auto pl = Gothic::inst().player()){
float hp = float(pl->attribute(ATR_HITPOINTS))/float(pl->attribute(ATR_HITPOINTSMAX));
float mp = float(pl->attribute(ATR_MANA)) /float(pl->attribute(ATR_MANAMAX));
drawBar(p,barHp, 10, h()-10, hp, AlignLeft | AlignBottom);
drawBar(p,barMana,w()-10,h()-10, mp, AlignRight | AlignBottom);
if(pl->isDive()) {
uint32_t gl = pl->guild();
auto v = float(pl->world().script().guildVal().dive_time[gl]);
if(v>0) {
auto t = float(pl->diveTime())/1000.f;
drawBar(p,barMisc,w()/2,h()-10, (v-t)/(v), AlignHCenter | AlignBottom);
if (!camera.isDesktop()) {
float hp = float(pl->attribute(ATR_HITPOINTS))/float(pl->attribute(ATR_HITPOINTSMAX));
float mp = float(pl->attribute(ATR_MANA)) /float(pl->attribute(ATR_MANAMAX));
drawBar(p,barHp, 10, h()-10, hp, AlignLeft | AlignBottom);
drawBar(p,barMana,w()-10,h()-10, mp, AlignRight | AlignBottom);
if(pl->isDive()) {
uint32_t gl = pl->guild();
auto v = float(pl->world().script().guildVal().dive_time[gl]);
if(v>0) {
auto t = float(pl->diveTime())/1000.f;
drawBar(p,barMisc,w()/2,h()-10, (v-t)/(v), AlignHCenter | AlignBottom);
}
}
}
}
Expand Down Expand Up @@ -235,20 +237,32 @@ void MainWindow::paintEvent(PaintEvent& event) {
renderer.dbgDraw(p);

if(Gothic::inst().doFrate()) {
char fpsT[64]={};
std::snprintf(fpsT,sizeof(fpsT),"fps = %.2f",fps.get());
//string_frm fpsT("fps = ", fps.get(), " ", info);
bool printFrate = true;
if (world!=nullptr) {
auto& camera = *Gothic::inst().camera();
if (camera.isDesktop()) {
printFrate = false;
}
}
if (printFrate) {
char fpsT[64]={};
std::snprintf(fpsT,sizeof(fpsT),"fps = %.2f",fps.get());
//string_frm fpsT("fps = ", fps.get(), " ", info);

auto& fnt = Resources::font();
fnt.drawText(p,5,fnt.pixelSize()+5,fpsT);
auto& fnt = Resources::font();
fnt.drawText(p,5,fnt.pixelSize()+5,fpsT);
}
}

if(Gothic::inst().doClock() && world!=nullptr) {
auto hour = world->time().hour();
auto min = world->time().minute();
auto& fnt = Resources::font();
string_frm clockT(int(hour),":",int(min));
fnt.drawText(p,w()-fnt.textSize(clockT).w-5,fnt.pixelSize()+5,clockT);
auto& camera = *Gothic::inst().camera();
if (!camera.isDesktop()) {
auto hour = world->time().hour();
auto min = world->time().minute();
auto& fnt = Resources::font();
string_frm clockT(int(hour),":",int(min));
fnt.drawText(p,w()-fnt.textSize(clockT).w-5,fnt.pixelSize()+5,clockT);
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion game/marvin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Marvin::Marvin() {
{"set time %d %d", C_SetTime},
{"spawnmass %d", C_Invalid},
{"spawnmass giga %d", C_Invalid},
{"toggle desktop", C_Invalid},
{"toggle desktop", C_ToggleDesktop},
{"toggle freepoints", C_Invalid},
{"toggle screen", C_Invalid},
{"toggle time", C_ToggleTime},
Expand Down Expand Up @@ -328,6 +328,11 @@ bool Marvin::exec(std::string_view v) {
c->setInertiaTargetEnable(!c->isInertiaTargetEnabled());
return true;
}
case C_ToggleDesktop: {
if(auto c = Gothic::inst().camera())
c->toggleDesktop();
return true;
}
case C_Insert: {
World* world = Gothic::inst().world();
Npc* player = Gothic::inst().player();
Expand Down
2 changes: 2 additions & 0 deletions game/marvin.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class Marvin {
// rendering
C_ToggleFrame,
C_ToggleTime,
// game
C_ToggleDesktop,
// npc
C_CheatFull,
C_CheatGod,
Expand Down

0 comments on commit 13250e6

Please sign in to comment.