|
| 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 | +} |
0 commit comments