Skip to content

Commit

Permalink
marvin 'toggle desktop' (AKA photo mode)
Browse files Browse the repository at this point in the history
  • Loading branch information
Black_Fox committed Jun 25, 2023
1 parent 3feccbc commit 7820bdd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
4 changes: 4 additions & 0 deletions game/gothic.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class Gothic final {
bool isGodMode() const { return godMode; }
void setGodMode(bool g) { godMode = g; }

void toggleDesktop() { desktop = !desktop; }
bool isDesktop() { return desktop; }

bool doHideFocus () const { return hideFocus; }
bool doFrate() const { return showFpsCounter; }
void setFRate(bool f) { showFpsCounter = f; }
Expand Down Expand Up @@ -166,6 +169,7 @@ class Gothic final {
uint16_t pauseSum=0;
bool isMarvin = false;
bool godMode = false;
bool desktop = false;
bool showFpsCounter = false;
bool showTime = false;
bool hideFocus = false;
Expand Down
36 changes: 20 additions & 16 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 (!Gothic::inst().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 All @@ -234,7 +236,7 @@ void MainWindow::paintEvent(PaintEvent& event) {

renderer.dbgDraw(p);

if(Gothic::inst().doFrate()) {
if(Gothic::inst().doFrate() && !Gothic::inst().isDesktop()) {
char fpsT[64]={};
std::snprintf(fpsT,sizeof(fpsT),"fps = %.2f",fps.get());
//string_frm fpsT("fps = ", fps.get(), " ", info);
Expand All @@ -244,11 +246,13 @@ void MainWindow::paintEvent(PaintEvent& event) {
}

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);
if (!Gothic::inst().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
6 changes: 5 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,10 @@ bool Marvin::exec(std::string_view v) {
c->setInertiaTargetEnable(!c->isInertiaTargetEnabled());
return true;
}
case C_ToggleDesktop: {
Gothic::inst().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 7820bdd

Please sign in to comment.