Skip to content

Commit

Permalink
Add cheat option to go forward 1 day or week
Browse files Browse the repository at this point in the history
Useful for debugging.
  • Loading branch information
JonnyH committed Sep 5, 2019
1 parent adec1c5 commit ca10194
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
27 changes: 10 additions & 17 deletions data/forms/cheatoptions.form
Expand Up @@ -8,21 +8,18 @@
<image>xcom3/ufodata/fundadj.pcx</image>
<position x="0" y="0"/>
<size width="640" height="480"/>

<label text="CHEATS">
<position x="113" y="0"/>
<size width="420" height="32"/>
<alignment horizontal="centre" vertical="centre"/>
<font>bigfont</font>
</label>

<label id="TEXT_FUNDS">
<position x="572" y="11"/>
<size width="60" height="10"/>
<alignment horizontal="left" vertical="centre"/>
<font>smalfont</font>
</label>

<textbutton text="Give all research" id="BUTTON_GIVE_ALL_RESEARCH">
<font>smalfont</font>
<position x="290" y="100"/>
Expand All @@ -48,7 +45,16 @@
<position x="290" y="226"/>
<size width="140" height="28"/>
</textbutton>

<textbutton text="Go forward 1 day" id="BUTTON_FAST_FORWARD_DAY">
<font>smalfont</font>
<position x="290" y="254"/>
<size width="140" height="28"/>
</textbutton>
<textbutton text="Go forward 1 week" id="BUTTON_FAST_FORWARD_WEEK">
<font>smalfont</font>
<position x="290" y="282"/>
<size width="140" height="28"/>
</textbutton>
<checkbox id="CHECKBOX_INFINITE_AMMO">
<position x="440" y="100"/>
<size width="150" height="16"/>
Expand All @@ -60,7 +66,6 @@
<size width="120" height="16"/>
</label>
</checkbox>

<textbutton id="BUTTON_MODIFY_FUNDS" text="Modify funds">
<font>smalfont</font>
<position x="56" y="102"/>
Expand All @@ -70,7 +75,6 @@
<position x="42" y="122"/>
<size width="224" height="18"/>
<image>PCK:xcom3/ufodata/newbut.pck:xcom3/ufodata/newbut.tab:61:xcom3/ufodata/research.pcx</image>

<scroll id="MODIFY_FUNDS">
<position x="14" y="2"/>
<size width="148" height="15"/>
Expand All @@ -95,7 +99,6 @@
<font>smalfont</font>
</label>
</graphic>

<label text="Damage Inflicted">
<position x="56" y="166"/>
<font>smalfont</font>
Expand All @@ -106,7 +109,6 @@
<position x="42" y="182"/>
<size width="224" height="18"/>
<image>PCK:xcom3/ufodata/newbut.pck:xcom3/ufodata/newbut.tab:61:xcom3/ufodata/research.pcx</image>

<scroll id="DAMAGE_INFLICTED_MULT">
<position x="14" y="2"/>
<size width="148" height="15"/>
Expand All @@ -131,7 +133,6 @@
<font>smalfont</font>
</label>
</graphic>

<label text="Damage Received">
<position x="56" y="226"/>
<font>smalfont</font>
Expand All @@ -142,7 +143,6 @@
<position x="42" y="242"/>
<size width="224" height="18"/>
<image>PCK:xcom3/ufodata/newbut.pck:xcom3/ufodata/newbut.tab:61:xcom3/ufodata/research.pcx</image>

<scroll id="DAMAGE_RECEIVED_MULT">
<position x="14" y="2"/>
<size width="148" height="16"/>
Expand All @@ -167,8 +167,6 @@
<font>smalfont</font>
</label>
</graphic>


<label text="Hostiles multiplier">
<position x="56" y="286"/>
<font>smalfont</font>
Expand All @@ -179,7 +177,6 @@
<position x="42" y="302"/>
<size width="224" height="18"/>
<image>PCK:xcom3/ufodata/newbut.pck:xcom3/ufodata/newbut.tab:61:xcom3/ufodata/research.pcx</image>

<scroll id="HOSTILES_MULT">
<position x="14" y="2"/>
<size width="148" height="16"/>
Expand All @@ -204,8 +201,6 @@
<font>smalfont</font>
</label>
</graphic>


<label text="Agent Stat Growth">
<position x="56" y="346"/>
<font>smalfont</font>
Expand All @@ -216,7 +211,6 @@
<position x="42" y="362"/>
<size width="224" height="18"/>
<image>PCK:xcom3/ufodata/newbut.pck:xcom3/ufodata/newbut.tab:61:xcom3/ufodata/research.pcx</image>

<scroll id="STAT_GROWTH_MULT">
<position x="14" y="2"/>
<size width="148" height="16"/>
Expand All @@ -241,7 +235,6 @@
<font>smalfont</font>
</label>
</graphic>

<graphicbutton id="BUTTON_OK">
<position x="602" y="443"/>
<size width="35" height="34"/>
Expand Down
19 changes: 12 additions & 7 deletions game/state/gametime.h
Expand Up @@ -6,13 +6,13 @@
namespace OpenApoc
{

static const unsigned VANILLA_TICKS_PER_SECOND = 36;
static const unsigned TICKS_MULTIPLIER = 4;
static const unsigned TICKS_PER_SECOND = VANILLA_TICKS_PER_SECOND * TICKS_MULTIPLIER;
static const unsigned TICKS_PER_MINUTE = TICKS_PER_SECOND * 60;
static const unsigned TICKS_PER_HOUR = TICKS_PER_MINUTE * 60;
static const unsigned TICKS_PER_DAY = TICKS_PER_HOUR * 24;
static const unsigned TURBO_TICKS = 5 * 60 * TICKS_PER_SECOND;
static constexpr unsigned VANILLA_TICKS_PER_SECOND = 36;
static constexpr unsigned TICKS_MULTIPLIER = 4;
static constexpr unsigned TICKS_PER_SECOND = VANILLA_TICKS_PER_SECOND * TICKS_MULTIPLIER;
static constexpr unsigned TICKS_PER_MINUTE = TICKS_PER_SECOND * 60;
static constexpr unsigned TICKS_PER_HOUR = TICKS_PER_MINUTE * 60;
static constexpr unsigned TICKS_PER_DAY = TICKS_PER_HOUR * 24;
static constexpr unsigned TURBO_TICKS = 5 * 60 * TICKS_PER_SECOND;

class GameTime
{
Expand Down Expand Up @@ -57,18 +57,23 @@ class GameTime

// set at end of each second
bool secondPassed() const;
void setSecondPassed(bool newValue) { secondPassedFlag = newValue; }

// set at end of each 5 minutes
bool fiveMinutesPassed() const;
void setFiveMinutesPassed(bool newValue) { fiveMinutesPassedFlag = newValue; }

// set at end of each hour
bool hourPassed() const;
void setHourPassed(bool newValue) { hourPassedFlag = newValue; }

// set at midnight
bool dayPassed() const;
void setDayPassed(bool newValue) { dayPassedFlag = newValue; }

// set at sunday midnight
bool weekPassed() const;
void setWeekPassed(bool newValue) { weekPassedFlag = newValue; }

void clearFlags();

Expand Down
12 changes: 12 additions & 0 deletions game/ui/general/cheatoptions.cpp
Expand Up @@ -182,6 +182,18 @@ void CheatOptions::eventOccurred(Event *e)
menuform->findControlTyped<ScrollBar>("MODIFY_FUNDS")->getValue() * 1000;
menuform->findControlTyped<Label>("TEXT_FUNDS")->setText(state->getPlayerBalance());
}
else if (e->forms().RaisedBy->Name == "BUTTON_FAST_FORWARD_DAY")
{
state->gameTime.addTicks(TICKS_PER_DAY);
// state->gameTime.setDayPassed( true);
LogWarning("Scheduling end of day");
}
else if (e->forms().RaisedBy->Name == "BUTTON_FAST_FORWARD_WEEK")
{
state->gameTime.addTicks(TICKS_PER_DAY * 7);
// state->gameTime.setWeekPassed( true);
LogWarning("Scheduling end of week");
}
}
if (e->type() == EVENT_FORM_INTERACTION &&
e->forms().EventFlag == FormEventType::ScrollBarChange)
Expand Down

0 comments on commit ca10194

Please sign in to comment.