Skip to content

Commit 8cab653

Browse files
committed
add key screen
1 parent 408e4ef commit 8cab653

11 files changed

Lines changed: 488 additions & 50 deletions

CMakeLists.txt

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ if(OPENFODDER_ENABLE_NETWORK AND NOT EMSCRIPTEN)
146146
# immediately available for add_library (avoids FetchContent subbuild
147147
# issues with CMake 4.x and GGPO's outdated CMakeLists.txt).
148148
set(GGPO_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/ggpo-src")
149+
find_package(Git REQUIRED)
149150

150151
# Use .git presence as the reliable "fully cloned" marker.
151152
# If it's missing (never cloned or partial), wipe and re-clone.
152153
if(NOT EXISTS "${GGPO_SOURCE_DIR}/.git")
153-
find_package(Git REQUIRED)
154154
file(REMOVE_RECURSE "${GGPO_SOURCE_DIR}")
155155
message(STATUS "[GGPO] Cloning pond3r/ggpo...")
156156
execute_process(
@@ -165,11 +165,42 @@ if(OPENFODDER_ENABLE_NETWORK AND NOT EMSCRIPTEN)
165165
endif()
166166
endif()
167167

168+
if(NOT WIN32)
169+
set(GGPO_LINUX_PATCH "${CMAKE_CURRENT_LIST_DIR}/cmake/ggpo-linux-compat.patch")
170+
execute_process(
171+
COMMAND "${GIT_EXECUTABLE}" -C "${GGPO_SOURCE_DIR}" apply --check "${GGPO_LINUX_PATCH}"
172+
RESULT_VARIABLE _ggpo_patch_check
173+
ERROR_VARIABLE _ggpo_patch_error
174+
)
175+
if(_ggpo_patch_check EQUAL 0)
176+
message(STATUS "[GGPO] Applying Linux compatibility patch...")
177+
execute_process(
178+
COMMAND "${GIT_EXECUTABLE}" -C "${GGPO_SOURCE_DIR}" apply "${GGPO_LINUX_PATCH}"
179+
RESULT_VARIABLE _ggpo_patch_result
180+
ERROR_VARIABLE _ggpo_patch_apply_error
181+
)
182+
if(_ggpo_patch_result)
183+
message(FATAL_ERROR "Failed to apply GGPO Linux compatibility patch: ${_ggpo_patch_apply_error}")
184+
endif()
185+
else()
186+
execute_process(
187+
COMMAND "${GIT_EXECUTABLE}" -C "${GGPO_SOURCE_DIR}" apply --reverse --check "${GGPO_LINUX_PATCH}"
188+
RESULT_VARIABLE _ggpo_patch_reverse_check
189+
ERROR_QUIET
190+
)
191+
if(NOT _ggpo_patch_reverse_check EQUAL 0)
192+
message(FATAL_ERROR "GGPO Linux compatibility patch no longer applies: ${_ggpo_patch_error}")
193+
endif()
194+
endif()
195+
endif()
196+
168197
# Auto-discover all GGPO .cpp files (robust to repo layout changes).
169198
set(GGPO_SRC_DIR "${GGPO_SOURCE_DIR}/src/lib/ggpo")
170199
file(GLOB_RECURSE GGPO_SOURCES "${GGPO_SRC_DIR}/*.cpp")
171200
if(WIN32)
172201
list(FILTER GGPO_SOURCES EXCLUDE REGEX "platform_linux\\.cpp$")
202+
else()
203+
list(FILTER GGPO_SOURCES EXCLUDE REGEX "platform_windows\\.cpp$")
173204
endif()
174205
if(NOT GGPO_SOURCES)
175206
message(FATAL_ERROR

Source/About.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ cAbout::cAbout() {
6060
{ TEXTPOS_THANKS + 20, "STOO CAMBRIDGE"},
6161
{ TEXTPOS_THANKS + 30, "CLAIRE CROSSFIELD"},
6262
{ TEXTPOS_THANKS + 40, "LACHIE CROSSFIELD"},
63-
{ TEXTPOS_THANKS + 50, "RILEY ELLETT"},
64-
{ TEXTPOS_THANKS + 60, "SCUMMVM"},
63+
{ TEXTPOS_THANKS + 50, "HAMISH CROSSFIELD"},
64+
{ TEXTPOS_THANKS + 60, "AUDREY CROSSFIELD"},
65+
{ TEXTPOS_THANKS + 70, "RILEY ELLETT"},
66+
{ TEXTPOS_THANKS + 80, "SCUMMVM"},
6567

6668
{ TEXTPOS_POWERED + 0, "POWERED BY"},
6769
{ TEXTPOS_POWERED + 10, "CPP17"},

Source/CampaignSelect.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ void cFodder::Campaign_Select_DrawMenu(const char* pTitle, const char* pSubTitle
116116
GUI_Button_Setup(&cFodder::GUI_Button_Show_Multiplayer);
117117
#endif
118118

119+
GUI_Button_Draw_SmallAt("KEYS", 0xA, 0x6E + YOffset);
120+
GUI_Button_Setup(&cFodder::GUI_Button_Show_Shortcuts);
121+
119122
int16 ItemCount = 0;
120123

121124
auto FileIT = mCampaignList.begin() + mGUI_Select_File_CurrentIndex;
@@ -453,6 +456,15 @@ void cFodder::Campaign_Select_File_Cycle(const char* pTitle, const char* pSubTit
453456
mSurface->Save();
454457
}
455458

459+
if (mGUI_SaveLoadAction == GUI_MENU_SHORTCUTS) {
460+
KeyboardShortcuts();
461+
mGUI_SaveLoadAction = 0;
462+
mMouse_Button_Left_Toggle = 0;
463+
mGraphics->PaletteSet();
464+
mSurface->palette_FadeTowardNew();
465+
mSurface->Save();
466+
}
467+
456468
#ifdef OPENFODDER_ENABLE_NETWORK
457469
if (mGUI_SaveLoadAction == 6) {
458470
auto* mp = dynamic_cast<cFodderMultiplayer*>(this);

Source/Fodder.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3743,6 +3743,20 @@ void cFodder::About()
37433743
g_Fodder->mPhase_Aborted = false;
37443744
}
37453745

3746+
void cFodder::KeyboardShortcuts()
3747+
{
3748+
const auto PreviousInterruptCallback = mInterruptCallback;
3749+
mInterruptCallback = []() {};
3750+
3751+
cKeyboardShortcuts KeyboardShortcuts;
3752+
while (KeyboardShortcuts.Cycle())
3753+
{
3754+
}
3755+
3756+
mInterruptCallback = PreviousInterruptCallback;
3757+
g_Fodder->mPhase_Aborted = false;
3758+
}
3759+
37463760
void cFodder::CreateRandom(sMapParams pParams)
37473761
{
37483762
mSurface->clearBuffer();

Source/Fodder.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct sSavedGame {
7777

7878
static const int16 GUI_SAVELOAD_DELETE = 7;
7979
static const int16 GUI_SAVELOAD_SELECT_SAVE = 8;
80+
static const int16 GUI_MENU_SHORTCUTS = 10;
8081

8182
struct sService_Draw {
8283
int16 mSpriteType;
@@ -1266,6 +1267,7 @@ class cFodder {
12661267
void GUI_Button_Show_About();
12671268
void GUI_Button_Show_Options();
12681269
void GUI_Button_Show_Multiplayer();
1270+
void GUI_Button_Show_Shortcuts();
12691271
void GUI_Button_Filename();
12701272
void GUI_Button_Save_Filename();
12711273
void GUI_Button_Save_Dialog_Filename();
@@ -1462,6 +1464,7 @@ class cFodder {
14621464
void Playground();
14631465

14641466
void About();
1467+
void KeyboardShortcuts();
14651468
void CreateRandom(sMapParams pParams);
14661469
virtual void Start();
14671470
void Exit(unsigned int pExitCode);

Source/GUI_Element.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,12 @@ void cFodder::GUI_Button_Show_Multiplayer()
18971897
mGUI_SaveLoadAction = 6;
18981898
}
18991899

1900+
void cFodder::GUI_Button_Show_Shortcuts()
1901+
{
1902+
mGUI_Select_File_String_Input_Callback = 0;
1903+
mGUI_SaveLoadAction = GUI_MENU_SHORTCUTS;
1904+
}
1905+
19001906
void cFodder::GUI_Input_CheckKey()
19011907
{
19021908
mKeyCodeAscii = 0;

Source/KeyboardShortcuts.cpp

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
* Open Fodder
3+
* ---------------
4+
*
5+
* Copyright (C) 2008-2026 Open Fodder
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License along
18+
* with this program; if not, write to the Free Software Foundation, Inc.,
19+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
*/
22+
23+
#include "stdafx.hpp"
24+
25+
struct sShortcutLine {
26+
size_t mY;
27+
const char* mKey;
28+
const char* mAction;
29+
};
30+
31+
static void KeyboardShortcuts_DrawHeading(const char* pText, size_t pX, size_t pY)
32+
{
33+
g_Fodder->String_Print_Small(pText, pX, pY);
34+
}
35+
36+
static void KeyboardShortcuts_DrawLine(size_t pX, const sShortcutLine& pLine)
37+
{
38+
g_Fodder->String_Print_Small_LeftInBox(pLine.mKey, pX, pX + 0x28, pLine.mY, 0);
39+
g_Fodder->String_Print_Small_LeftInBox(pLine.mAction, pX + 0x2E, pX + 0x86, pLine.mY, 0);
40+
}
41+
42+
cKeyboardShortcuts::cKeyboardShortcuts()
43+
{
44+
mSurface = new cSurface(0, 0);
45+
mSurface->LoadPng(g_ResourceMan->GetAboutFile());
46+
47+
g_Fodder->mGUI_SaveLoadAction = 0;
48+
g_Fodder->mMouse_Button_Left_Toggle = 0;
49+
g_Fodder->mPhase_Aborted = false;
50+
g_Fodder->mGraphics->PaletteSet();
51+
g_Fodder->mMouseSpriteNew = eSprite_pStuff_Mouse_Target;
52+
g_Fodder->mGraphics->SetActiveSpriteSheet(eGFX_BRIEFING);
53+
g_Fodder->mGraphics->PaletteSet();
54+
}
55+
56+
cKeyboardShortcuts::~cKeyboardShortcuts()
57+
{
58+
delete mSurface;
59+
}
60+
61+
bool cKeyboardShortcuts::Cycle()
62+
{
63+
static const sShortcutLine SystemLines[] = {
64+
{ 0x46, "F1", "AMIGA VERSION" },
65+
{ 0x54, "F2", "PC VERSION" },
66+
{ 0x62, "F11", "FULLSCREEN" },
67+
{ 0x70, "F12", "MOUSE LOCK" },
68+
{ 0x7E, "PLUS", "WINDOW LARGER" },
69+
{ 0x8C, "MINUS", "WINDOW SMALLER" },
70+
{ 0x9A, "ESC", "BACK OR ABORT" }
71+
};
72+
73+
static const sShortcutLine MissionLines[] = {
74+
{ 0x46, "P", "PAUSE" },
75+
{ 0x54, "M", "MAP" },
76+
{ 0x62, "SPACE", "SWITCH WEAPON" },
77+
{ 0x70, "1 2 3", "SELECT SQUAD" },
78+
{ 0x8C, "F5", "AUTOSAVE CHEATS" },
79+
{ 0x9A, "F9", "LOAD OR INVINCIBLE" },
80+
{ 0xA8, "F10", "COMPLETE MISSION" }
81+
};
82+
83+
g_Fodder->GUI_Element_Reset();
84+
85+
g_Fodder->mSurface->palette_FadeTowardNew();
86+
g_Fodder->mSurface->clearBuffer();
87+
88+
g_Fodder->mGraphics->SetActiveSpriteSheet(eGFX_BRIEFING);
89+
90+
g_Fodder->mString_GapCharID = 0x25;
91+
g_Fodder->String_Print_Large("Keyboard Shortcuts", true, 0x01);
92+
g_Fodder->mString_GapCharID = 0x00;
93+
94+
g_Fodder->Briefing_DrawBox(0x08, 0x2A, 0x88, 0x84, 0xF3);
95+
g_Fodder->Briefing_DrawBox(0x07, 0x29, 0x88, 0x84, 0xF2);
96+
g_Fodder->Briefing_DrawBox(0x9A, 0x2A, 0x98, 0x84, 0xF3);
97+
g_Fodder->Briefing_DrawBox(0x99, 0x29, 0x98, 0x84, 0xF2);
98+
99+
KeyboardShortcuts_DrawHeading("SYSTEM", 0x30, 0x34);
100+
for (const auto& Line : SystemLines)
101+
KeyboardShortcuts_DrawLine(0x18, Line);
102+
103+
KeyboardShortcuts_DrawHeading("MISSION", 0xC0, 0x34);
104+
for (const auto& Line : MissionLines)
105+
KeyboardShortcuts_DrawLine(0xA8, Line);
106+
107+
g_Fodder->GUI_Button_Draw_Small("BACK", 0xB3 + PLATFORM_BASED(0, 25));
108+
g_Fodder->GUI_Button_Setup(&cFodder::GUI_Button_Load_Exit);
109+
110+
if (g_Fodder->mPhase_Aborted)
111+
g_Fodder->GUI_Button_Load_Exit();
112+
113+
if (g_Fodder->mMouse_Button_Left_Toggle) {
114+
g_Fodder->GUI_Handle_Element_Mouse_Check(g_Fodder->mGUI_Elements);
115+
116+
if (g_Fodder->mGUI_SaveLoadAction == 1) {
117+
g_Fodder->mSurface->paletteNew_SetToBlack();
118+
g_Fodder->mSurface->palette_FadeTowardNew();
119+
}
120+
}
121+
122+
g_Fodder->Mouse_DrawCursor();
123+
124+
g_Fodder->mSurface->draw();
125+
g_Fodder->Video_Sleep(mSurface, true);
126+
g_Fodder->mWindow->RenderAt(g_Fodder->mSurface);
127+
128+
if (g_Fodder->mGUI_SaveLoadAction == 1 && !g_Fodder->mSurface->isPaletteAdjusting())
129+
return false;
130+
131+
return true;
132+
}

Source/KeyboardShortcuts.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Open Fodder
3+
* ---------------
4+
*
5+
* Copyright (C) 2008-2026 Open Fodder
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License along
18+
* with this program; if not, write to the Free Software Foundation, Inc.,
19+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
*/
22+
23+
class cKeyboardShortcuts {
24+
25+
cSurface* mSurface;
26+
27+
public:
28+
cKeyboardShortcuts();
29+
~cKeyboardShortcuts();
30+
31+
bool Cycle();
32+
};

0 commit comments

Comments
 (0)