Skip to content

Commit

Permalink
Merge pull request #1222 from Kurtsley/debug-menu
Browse files Browse the repository at this point in the history
Add an optional visible debug menu to all relevant screens
  • Loading branch information
FilmBoy84 committed Jun 1, 2023
2 parents 7aaad34 + d5a6d0d commit c21e322
Show file tree
Hide file tree
Showing 11 changed files with 311 additions and 7 deletions.
106 changes: 106 additions & 0 deletions data/forms/battle/debugoverlay_battle.form
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<openapoc>
<!-- Debug Overlay -->
<form id="DEBUGOVERLAY_BATTLE">
<style minwidth="250" minheight="480">
<position x="left" y="top"/>
<size width="250" height="480"/>
<label id="F1" text="F1 = Toggle Debug Mode">
<position x="left" y="0"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="MidClick" text="MidClick = Teleportation Mode">
<position x="left" y="14"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="E" text="E = End Turn">
<position x="left" y="28"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="R" text="R = Reveal Map">
<position x="left" y="42"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="S" text="S = Stun Mode">
<position x="left" y="56"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="K" text="K = Remove Units">
<position x="left" y="70"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="P" text="P = Lower Morale">
<position x="left" y="84"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="Shift+P" text="Shift+P = Give 0 Psi Defense and 100 Psi Attack">
<position x="left" y="98"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="H" text="H = Heal Units">
<position x="left" y="112"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="T" text="T = Restore Time Units">
<position x="left" y="126"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F" text="F = Re-link Support Lines">
<position x="left" y="140"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="Num0" text="Num0 = Spawn Vortex Mine Explosion">
<position x="left" y="154"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="Num19" text="Num1-9 = Spawn Shot in Specified Direction">
<position x="left" y="168"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F6" text="F6 = Dump Voxelmap LOS">
<position x="left" y="182"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F7" text="F7 = Dump Voxelmap LOS(Fast)">
<position x="left" y="196"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F8" text="F8 = Dump Voxelmap LOF">
<position x="left" y="210"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
</style>
</form>
</openapoc>
154 changes: 154 additions & 0 deletions data/forms/city/debugoverlay_city.form
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<openapoc>
<!-- Debug Overlay -->
<form id="DEBUGOVERLAY_CITY">
<style minwidth="640" minheight="480">
<position x="left" y="top"/>
<size width="640" height="480"/>
<label id="F1" text="F1 = Toggle Debug Mode">
<position x="left" y="0"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="CtrlAltShiftLeft" text="Ctrl+Alt+Shift+LeftClick = Destroy Scenery">
<position x="left" y="14"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="CtrlAltShiftRight" text="Ctrl+Alt+Shift+RightClick = Collapse Building">
<position x="left" y="28"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="A" text="A = Gives Every Vehicle Ammo">
<position x="left" y="42"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="W" text="W = Warp to Alien Dimension and Back">
<position x="left" y="56"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="R" text="R = Repair All Scenery">
<position x="left" y="70"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="B" text="B = Spawn UFO on Assualt Mission">
<position x="left" y="84"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="U" text="U = Spawn Three Crashed UFOs">
<position x="left" y="98"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="X" text="X = Crash All Vehicles">
<position x="left" y="112"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="PgUpPgDn" text="PgUp / PgDown = Display One Map Layer">
<position x="left" y="126"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F2" text="F2 = Show Road Pathfinding">
<position x="left" y="140"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F3" text="F3 = Highlight Walkmode, Collapsing Tiles, Basement Tiles">
<position x="left" y="154"/>
<size width="400" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F4" text="F4 = Show Aliens on Strategy Map">
<position x="left" y="168"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F5" text="F5 = Show Vehicles Paths">
<position x="left" y="182"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F6" text="F6 = Dump Voxelmap LOS">
<position x="left" y="196"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F7" text="F7 = Dump Voxelmap LOS (Fast)">
<position x="left" y="210"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F8" text="F8 = Dump Voxelmap LOF">
<position x="left" y="224"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F9" text="F9 = Dump Voxelmap LOF (Fast)">
<position x="left" y="238"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F10" text="F10 = Highlight Tubes">
<position x="left" y="252"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F11" text="F11 = Highlight Roads">
<position x="left" y="266"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="F12" text="F12 = Highlight Hills">
<position x="left" y="280"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="Num" text="Show Roads / Tubes Num1379 = Direction, Num28 = Up / Down, Num0 = Show All, Num5 = Switch Views">
<position x="left" y="294"/>
<size width="640" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="Base" text="Base Screen - F10 = Finish All Facilities">
<position x="left" y="308"/>
<size width="250" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
<label id="Research" text="Research Screen - F10 = Complete Project at Next Update (With at least two Scientists Assigned)">
<position x="left" y="322"/>
<size width="640" height="14"/>
<alignment horizontal="left" vertical="top"/>
<font>smalfont</font>
</label>
</style>
</form>
</openapoc>
3 changes: 3 additions & 0 deletions framework/options.cpp
Expand Up @@ -94,6 +94,7 @@ void dumpOptionsToLog()
dumpOption(optionPauseOnAgentPsiControlled);
dumpOption(optionPauseOnAgentPsiOver);

dumpOption(optionDebugCommandsVisible);
dumpOption(optionUFODamageModel);
dumpOption(optionInstantExplosionDamage);
dumpOption(optionGravliftSounds);
Expand Down Expand Up @@ -334,6 +335,8 @@ ConfigOptionBool optionPauseOnAgentPsiControlled("Notifications.Battle", "AgentP
ConfigOptionBool optionPauseOnAgentPsiOver("Notifications.Battle", "AgentPsiOver",
"Unit freed from Psionic control", true);

ConfigOptionBool optionDebugCommandsVisible("OpenApoc.NewFeature", "DebugCommandsVisible",
"Show the debug commands on screen", true);
ConfigOptionBool optionUFODamageModel("OpenApoc.NewFeature", "UFODamageModel",
"X-Com 1 Damage model (0-200%)", false);
ConfigOptionBool optionInstantExplosionDamage("OpenApoc.NewFeature", "InstantExplosionDamage",
Expand Down
1 change: 1 addition & 0 deletions framework/options.h
Expand Up @@ -72,6 +72,7 @@ extern ConfigOptionBool optionPauseOnAgentPsiAttacked;
extern ConfigOptionBool optionPauseOnAgentPsiControlled;
extern ConfigOptionBool optionPauseOnAgentPsiOver;

extern ConfigOptionBool optionDebugCommandsVisible;
extern ConfigOptionBool optionUFODamageModel;
extern ConfigOptionBool optionInstantExplosionDamage;
extern ConfigOptionBool optionGravliftSounds;
Expand Down
1 change: 1 addition & 0 deletions game/ui/general/ingameoptions.cpp
Expand Up @@ -72,6 +72,7 @@ std::list<std::pair<UString, UString>> cityNotificationList = {
};

std::list<std::pair<UString, UString>> openApocList = {
{"OpenApoc.NewFeature", "DebugCommandsVisible"},
{"OpenApoc.NewFeature", "UFODamageModel"},
{"OpenApoc.NewFeature", "InstantExplosionDamage"},
{"OpenApoc.NewFeature", "GravliftSounds"},
Expand Down
3 changes: 2 additions & 1 deletion game/ui/tileview/battletileview.cpp
Expand Up @@ -1580,7 +1580,8 @@ void BattleTileView::render()
{
auto font = ui().getFont("smallset");
auto cursorPositionString = font->getString(format("Cursor at %s", selectedTilePosition));
r.draw(cursorPositionString, {0, 0});
int ypos = (config().getBool("OpenApoc.NewFeature.DebugCommandsVisible")) ? 224 : 0;
r.draw(cursorPositionString, {0, ypos});
}
}

Expand Down
23 changes: 21 additions & 2 deletions game/ui/tileview/battleview.cpp
Expand Up @@ -79,8 +79,10 @@ BattleView::BattleView(sp<GameState> gameState)
Vec3<int>{TILE_X_BATTLE, TILE_Y_BATTLE, TILE_Z_BATTLE},
Vec2<int>{STRAT_TILE_X, STRAT_TILE_Y}, TileViewMode::Isometric,
gameState->current_battle->battleViewScreenCenter, *gameState),
baseForm(ui().getForm("battle/battle")), state(gameState), battle(*state->current_battle),
followAgent(false), selectionState(BattleSelectionState::Normal)
baseForm(ui().getForm("battle/battle")),
debugOverlay(ui().getForm("battle/debugoverlay_battle")), state(gameState),
battle(*state->current_battle), followAgent(false),
selectionState(BattleSelectionState::Normal)
{
motionScannerDirectionIcons.push_back(
fw().data->loadImage(format("PCK:xcom3/tacdata/icons.pck:xcom3/tacdata/"
Expand Down Expand Up @@ -1354,6 +1356,7 @@ void BattleView::render()
}

baseForm->render();
debugOverlay->render();

int pauseIconOffsetX = 0;

Expand Down Expand Up @@ -1429,6 +1432,17 @@ void BattleView::update()
// Parent update
BattleTileView::update();

// Update debug menu
if (!config().getBool("OpenApoc.NewFeature.DebugCommandsVisible"))
{
debugVisible = false;
}
else if (debugHotkeyMode)
{
debugVisible = true;
}
debugOverlay->setVisible(debugVisible);

// Update turn based stuff
if (!realTime)
{
Expand Down Expand Up @@ -3085,6 +3099,11 @@ bool BattleView::handleKeyDown(Event *e)
else
setUpdateSpeed(lastSpeed);
return true;
case SDLK_F1:
if (config().getBool("OpenApoc.NewFeature.DebugCommandsVisible"))
{
debugVisible = !debugVisible;
}
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion game/ui/tileview/battleview.h
Expand Up @@ -109,7 +109,7 @@ class BattleView : public BattleTileView
};
const Colour ammoColour = {158, 24, 12};

sp<Form> activeTab, mainTab, psiTab, primingTab, notMyTurnTab, baseForm;
sp<Form> activeTab, mainTab, psiTab, primingTab, notMyTurnTab, baseForm, debugOverlay;
sp<BattleTurnBasedConfirmBox> executePlanPopup;
std::vector<sp<Form>> uiTabsRT;
std::vector<sp<Form>> uiTabsTB;
Expand Down

0 comments on commit c21e322

Please sign in to comment.