| 1 | /* |
| 2 | * OpenTyrian: A modern cross-platform port of Tyrian |
| 3 | * Copyright (C) 2007-2009 The OpenTyrian Development Team |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | #include "opentyr.h"cxx . . $ `<file>/src/opentyr.h`/ |
| 20 | |
| 21 | #include "config.h"cxx . . $ `<file>/src/config.h`/ |
| 22 | #include "destruct.h"cxx . . $ `<file>/src/destruct.h`/ |
| 23 | #include "editship.h"cxx . . $ `<file>/src/editship.h`/ |
| 24 | #include "episodes.h"cxx . . $ `<file>/src/episodes.h`/ |
| 25 | #include "file.h"cxx . . $ `<file>/src/file.h`/ |
| 26 | #include "font.h"cxx . . $ `<file>/src/font.h`/ |
| 27 | #include "fonthand.h"cxx . . $ `<file>/src/fonthand.h`/ |
| 28 | #include "helptext.h"cxx . . $ `<file>/src/helptext.h`/ |
| 29 | #include "joystick.h"cxx . . $ `<file>/src/joystick.h`/ |
| 30 | #include "jukebox.h"cxx . . $ `<file>/src/jukebox.h`/ |
| 31 | #include "keyboard.h"cxx . . $ `<file>/src/keyboard.h`/ |
| 32 | #include "loudness.h"cxx . . $ `<file>/src/loudness.h`/ |
| 33 | #include "mainint.h"cxx . . $ `<file>/src/mainint.h`/ |
| 34 | #include "mouse.h"cxx . . $ `<file>/src/mouse.h`/ |
| 35 | #include "mtrand.h"cxx . . $ `<file>/src/mtrand.h`/ |
| 36 | #include "network.h"cxx . . $ `<file>/src/network.h`/ |
| 37 | #include "nortsong.h"cxx . . $ `<file>/src/nortsong.h`/ |
| 38 | #include "nortvars.h"cxx . . $ `<file>/src/nortvars.h`/ |
| 39 | #include "opentyrian_version.h"cxx . . $ `<file>/src/opentyrian_version.h`/ |
| 40 | #include "palette.h"cxx . . $ `<file>/src/palette.h`/ |
| 41 | #include "params.h"cxx . . $ `<file>/src/params.h`/ |
| 42 | #include "picload.h"cxx . . $ `<file>/src/picload.h`/ |
| 43 | #include "sprite.h"cxx . . $ `<file>/src/sprite.h`/ |
| 44 | #include "tyrian2.h"cxx . . $ `<file>/src/tyrian2.h`/ |
| 45 | #include "varz.h"cxx . . $ `<file>/src/varz.h`/ |
| 46 | #include "vga256d.h"cxx . . $ `<file>/src/vga256d.h`/ |
| 47 | #include "video.h"cxx . . $ `<file>/src/video.h`/ |
| 48 | #include "video_scale.h"cxx . . $ `<file>/src/video_scale.h`/ |
| 49 | #include "xmas.h"cxx . . $ `<file>/src/xmas.h`/ |
| 50 | |
| 51 | #include "SDL.h" |
| 52 | |
| 53 | #include <assert.h> |
| 54 | #include <stdio.h> |
| 55 | #include <stdlib.h> |
| 56 | #include <string.h> |
| 57 | #include <time.h> |
| 58 | |
| 59 | const char *opentyrian_strcxx . . $ opentyrian_str. = "OpenTyrian"; |
| 60 | const char *opentyrian_versioncxx . . $ opentyrian_version. = OPENTYRIAN_VERSIONcxx . . $ `src/opentyrian_version.h:5:9`!; |
| 61 | |
| 62 | static size_t getDisplayPickerItemsCountcxx . . $ getDisplayPickerItemsCount(f708dce9a8856c70).(void) |
| 63 | { |
| 64 | return 1 + (size_t)SDL_GetNumVideoDisplayscxx . . $ SDL_GetNumVideoDisplays(b126dc7c1de90089).(); |
| 65 | } |
| 66 | |
| 67 | static const char *getDisplayPickerItemcxx . . $ getDisplayPickerItem(e9712774763a065c).(size_t i, char *buffer, size_t bufferSize) |
| 68 | { |
| 69 | if (i == 0) |
| 70 | return "Window"; |
| 71 | |
| 72 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(buffer, bufferSize, "Display %d", (int)i); |
| 73 | return buffer; |
| 74 | } |
| 75 | |
| 76 | static size_t getScalerPickerItemsCountcxx . . $ getScalerPickerItemsCount(f708dce9a8856c70).(void) |
| 77 | { |
| 78 | return (size_t)scalers_countcxx . . $ scalers_count.; |
| 79 | } |
| 80 | |
| 81 | static const char *getScalerPickerItemcxx . . $ getScalerPickerItem(e9712774763a065c).(size_t i, char *buffer, size_t bufferSize) |
| 82 | { |
| 83 | (void)buffer, (void)bufferSize; |
| 84 | |
| 85 | return scalerscxx . . $ scalers.[i].namecxx . . $ Scalers#name.; |
| 86 | } |
| 87 | |
| 88 | static size_t getScalingModePickerItemsCountcxx . . $ getScalingModePickerItemsCount(f708dce9a8856c70).(void) |
| 89 | { |
| 90 | return (size_t)ScalingMode_MAXcxx . . $ ScalingMode_MAX.; |
| 91 | } |
| 92 | |
| 93 | static const char *getScalingModePickerItemcxx . . $ getScalingModePickerItem(e9712774763a065c).(size_t i, char *buffer, size_t bufferSize) |
| 94 | { |
| 95 | (void)buffer, (void)bufferSize; |
| 96 | |
| 97 | return scaling_mode_namescxx . . $ scaling_mode_names.[i]; |
| 98 | } |
| 99 | |
| 100 | void setupMenucxx . . $ setupMenu(49f6e7a06ebc5aa8).(void) |
| 101 | { |
| 102 | typedef enumcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_0# |
| 103 | { |
| 104 | MENU_ITEM_NONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_NONE. = 0, |
| 105 | MENU_ITEM_DONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_DONE., |
| 106 | MENU_ITEM_GRAPHICScxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_GRAPHICS., |
| 107 | MENU_ITEM_SOUNDcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SOUND., |
| 108 | MENU_ITEM_JUKEBOXcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_JUKEBOX., |
| 109 | MENU_ITEM_DESTRUCTcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_DESTRUCT., |
| 110 | MENU_ITEM_DISPLAYcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_DISPLAY., |
| 111 | MENU_ITEM_SCALERcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SCALER., |
| 112 | MENU_ITEM_SCALING_MODEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SCALING_MODE., |
| 113 | MENU_ITEM_MUSIC_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_MUSIC_VOLUME., |
| 114 | MENU_ITEM_SOUND_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SOUND_VOLUME., |
| 115 | } MenuItemIdcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuItemId#; |
| 116 | |
| 117 | typedef enumcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_1# |
| 118 | { |
| 119 | MENU_NONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_NONE. = 0, |
| 120 | MENU_SETUPcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_SETUP., |
| 121 | MENU_GRAPHICScxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_GRAPHICS., |
| 122 | MENU_SOUNDcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_SOUND., |
| 123 | } MenuIdcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuId#; |
| 124 | |
| 125 | typedef structcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2# |
| 126 | { |
| 127 | MenuItemIdcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuItemId# idcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#id.; |
| 128 | const char *namecxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#name.; |
| 129 | const char *descriptioncxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#description.; |
| 130 | size_t (*getPickerItemsCountcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#getPickerItemsCount.)(void); |
| 131 | const char *(*getPickerItemcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#getPickerItem.)(size_t i, char *buffer, size_t bufferSize); |
| 132 | } MenuItemcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuItem#; |
| 133 | |
| 134 | typedef structcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_3# |
| 135 | { |
| 136 | const char *headercxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_3#header.; |
| 137 | const MenuItemcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuItem# itemscxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_3#items.[6]; |
| 138 | } Menucxx . . $ setupMenu(49f6e7a06ebc5aa8).Menu#; |
| 139 | |
| 140 | static const Menucxx . . $ setupMenu(49f6e7a06ebc5aa8).Menu# menus[] = { |
| 141 | [MENU_SETUPcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_SETUP.] = { |
| 142 | .header = "Setup", |
| 143 | .items = { |
| 144 | { MENU_ITEM_GRAPHICScxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_GRAPHICS., "Graphics...", "Change the graphics settings." }, |
| 145 | { MENU_ITEM_SOUNDcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SOUND., "Sound...", "Change the sound settings." }, |
| 146 | { MENU_ITEM_JUKEBOXcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_JUKEBOX., "Jukebox", "Listen to the music of Tyrian." }, |
| 147 | // { MENU_ITEM_DESTRUCT, "Destruct", "Play a bonus mini-game." }, |
| 148 | { MENU_ITEM_DONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_DONE., "Done", "Return to the main menu." }, |
| 149 | { -1 } |
| 150 | }, |
| 151 | }, |
| 152 | [MENU_GRAPHICScxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_GRAPHICS.] = { |
| 153 | .header = "Graphics", |
| 154 | .items = { |
| 155 | { MENU_ITEM_DISPLAYcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_DISPLAY., "Display:", "Change the display mode.", getDisplayPickerItemsCountcxx . . $ getDisplayPickerItemsCount(f708dce9a8856c70)., getDisplayPickerItemcxx . . $ getDisplayPickerItem(e9712774763a065c). }, |
| 156 | { MENU_ITEM_SCALERcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SCALER., "Scaler:", "Change the pixel art scaling algorithm.", getScalerPickerItemsCountcxx . . $ getScalerPickerItemsCount(f708dce9a8856c70)., getScalerPickerItemcxx . . $ getScalerPickerItem(e9712774763a065c). }, |
| 157 | { MENU_ITEM_SCALING_MODEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SCALING_MODE., "Scaling Mode:", "Change the scaling mode.", getScalingModePickerItemsCountcxx . . $ getScalingModePickerItemsCount(f708dce9a8856c70)., getScalingModePickerItemcxx . . $ getScalingModePickerItem(e9712774763a065c). }, |
| 158 | { MENU_ITEM_DONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_DONE., "Done", "Return to the previous menu." }, |
| 159 | { -1 } |
| 160 | }, |
| 161 | }, |
| 162 | [MENU_SOUNDcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_SOUND.] = { |
| 163 | .header = "Sound", |
| 164 | .items = { |
| 165 | { MENU_ITEM_MUSIC_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_MUSIC_VOLUME., "Music Volume", "Change volume with the left/right arrow keys." }, |
| 166 | { MENU_ITEM_SOUND_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SOUND_VOLUME., "Sound Volume", "Change volume with the left/right arrow keys." }, |
| 167 | { MENU_ITEM_DONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_DONE., "Done", "Return to the previous menu." }, |
| 168 | { -1 } |
| 169 | }, |
| 170 | }, |
| 171 | }; |
| 172 | |
| 173 | char buffer[100]; |
| 174 | |
| 175 | if (shopSpriteSheetcxx . . $ shopSpriteSheet..datacxx . . $ $anonymous_type_297934740aeafb7d_2#data. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 176 | JE_loadCompShapescxx . . $ JE_loadCompShapes(676db0deaa5c5c40).(&shopSpriteSheetcxx . . $ shopSpriteSheet., '1'); // need mouse pointer sprites |
| 177 | |
| 178 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! restart = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 179 | |
| 180 | MenuIdcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuId# menuParents[COUNTOFcxx . . $ `src/opentyr.h:27:9`!(menus)] = { MENU_NONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_NONE. }; |
| 181 | size_t selectedMenuItemIndexes[COUNTOFcxx . . $ `src/opentyr.h:27:9`!(menus)] = { 0 }; |
| 182 | MenuIdcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuId# currentMenu = MENU_SETUPcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_SETUP.; |
| 183 | MenuItemIdcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuItemId# currentPicker = MENU_ITEM_NONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_NONE.; |
| 184 | size_t pickerSelectedIndex = 0; |
| 185 | |
| 186 | const int xCenter = 320 / 2; |
| 187 | const int yMenuHeader = 4; |
| 188 | const int xMenuItem = 45; |
| 189 | const int xMenuItemName = xMenuItem; |
| 190 | const int wMenuItemName = 135; |
| 191 | const int xMenuItemValue = xMenuItemName + wMenuItemName; |
| 192 | const int wMenuItemValue = 95; |
| 193 | const int wMenuItem = wMenuItemName + wMenuItemValue; |
| 194 | const int yMenuItems = 37; |
| 195 | const int dyMenuItems = 21; |
| 196 | const int hMenuItem = 13; |
| 197 | |
| 198 | for (; ; ) |
| 199 | { |
| 200 | if (restart) |
| 201 | { |
| 202 | JE_loadPiccxx . . $ JE_loadPic(4846ed2ea5b0a844).(VGAScreen2cxx . . $ VGAScreen2., 2, falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 203 | fill_rectangle_whcxx . . $ fill_rectangle_wh(2ff783435439505a).(VGAScreen2cxx . . $ VGAScreen2., 0, 192, 320, 8, 0); |
| 204 | } |
| 205 | |
| 206 | // Restore background. |
| 207 | memcpycxx . . $ memcpy(cc817cb175f282d).(VGAScreencxx . . $ VGAScreen.->pixelscxx . . $ SDL_Surface#pixels., VGAScreen2cxx . . $ VGAScreen2.->pixelscxx . . $ SDL_Surface#pixels., (size_t)VGAScreencxx . . $ VGAScreen.->pitchcxx . . $ SDL_Surface#pitch. * VGAScreencxx . . $ VGAScreen.->hcxx . . $ SDL_Surface#h.); |
| 208 | |
| 209 | const Menucxx . . $ setupMenu(49f6e7a06ebc5aa8).Menu# *menu = &menus[currentMenu]; |
| 210 | |
| 211 | // Draw header. |
| 212 | draw_font_hv_shadowcxx . . $ draw_font_hv_shadow(198b4ac5940c9e46).(VGAScreencxx . . $ VGAScreen., xCenter, yMenuHeader, menu->headercxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_3#header., large_fontcxx . . $ large_font., centeredcxx . . $ centered., 15, -3, falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, 2); |
| 213 | |
| 214 | int yPicker = 0; |
| 215 | const int dyPickerItem = 15; |
| 216 | const int dyPickerItemPadding = 2; |
| 217 | const int hPickerItem = dyPickerItem - dyPickerItemPadding; |
| 218 | |
| 219 | size_t *const selectedMenuItemIndex = &selectedMenuItemIndexes[currentMenu]; |
| 220 | const MenuItemcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuItem# *const menuItems = menu->itemscxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_3#items.; |
| 221 | |
| 222 | // Draw menu items. |
| 223 | |
| 224 | size_t menuItemsCount = 0; |
| 225 | for (size_t i = 0; menuItems[i].idcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#id. != (MenuItemIdcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuItemId#)-1; ++i) |
| 226 | { |
| 227 | menuItemsCount += 1; |
| 228 | |
| 229 | const MenuItemcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuItem# *const menuItem = &menuItems[i]; |
| 230 | |
| 231 | const int y = yMenuItems + dyMenuItems * i; |
| 232 | |
| 233 | const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! selected = i == *selectedMenuItemIndex; |
| 234 | const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! disabled = currentPicker != MENU_ITEM_NONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_NONE. && !selected; |
| 235 | |
| 236 | if (selected) |
| 237 | yPicker = y; |
| 238 | |
| 239 | const char *const name = menuItem->namecxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#name.; |
| 240 | |
| 241 | draw_font_hv_shadowcxx . . $ draw_font_hv_shadow(198b4ac5940c9e46).(VGAScreencxx . . $ VGAScreen., xMenuItemName, y, name, normal_fontcxx . . $ normal_font., left_alignedcxx . . $ left_aligned., 15, -3 + (selected ? 2 : 0) + (disabled ? -4 : 0), falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, 2); |
| 242 | |
| 243 | switch (menuItem->idcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#id.) |
| 244 | { |
| 245 | case MENU_ITEM_DISPLAYcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_DISPLAY.:; |
| 246 | const char *value = "Window"; |
| 247 | if (fullscreen_displaycxx . . $ fullscreen_display. >= 0) |
| 248 | { |
| 249 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(buffer, sizeof(buffer), "Display %d", fullscreen_displaycxx . . $ fullscreen_display. + 1); |
| 250 | value = buffer; |
| 251 | } |
| 252 | |
| 253 | draw_font_hv_shadowcxx . . $ draw_font_hv_shadow(198b4ac5940c9e46).(VGAScreencxx . . $ VGAScreen., xMenuItemValue, y, value, normal_fontcxx . . $ normal_font., left_alignedcxx . . $ left_aligned., 15, -3 + (selected ? 2 : 0) + (disabled ? -4 : 0), falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, 2); |
| 254 | break; |
| 255 | |
| 256 | case MENU_ITEM_SCALERcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SCALER.: |
| 257 | draw_font_hv_shadowcxx . . $ draw_font_hv_shadow(198b4ac5940c9e46).(VGAScreencxx . . $ VGAScreen., xMenuItemValue, y, scalerscxx . . $ scalers.[scalercxx . . $ scaler.].namecxx . . $ Scalers#name., normal_fontcxx . . $ normal_font., left_alignedcxx . . $ left_aligned., 15, -3 + (selected ? 2 : 0) + (disabled ? -4 : 0), falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, 2); |
| 258 | break; |
| 259 | |
| 260 | case MENU_ITEM_SCALING_MODEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SCALING_MODE.: |
| 261 | draw_font_hv_shadowcxx . . $ draw_font_hv_shadow(198b4ac5940c9e46).(VGAScreencxx . . $ VGAScreen., xMenuItemValue, y, scaling_mode_namescxx . . $ scaling_mode_names.[scaling_modecxx . . $ scaling_mode.], normal_fontcxx . . $ normal_font., left_alignedcxx . . $ left_aligned., 15, -3 + (selected ? 2 : 0) + (disabled ? -4 : 0), falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, 2); |
| 262 | break; |
| 263 | |
| 264 | case MENU_ITEM_MUSIC_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_MUSIC_VOLUME.: |
| 265 | JE_barDrawShadowcxx . . $ JE_barDrawShadow(2b5d735fb21d70c8).(VGAScreencxx . . $ VGAScreen., xMenuItemValue, y, 1, music_disabledcxx . . $ music_disabled. ? 170 : 174, (tyrMusicVolumecxx . . $ tyrMusicVolume. + 4) / 8, 2, 10); |
| 266 | JE_rectanglecxx . . $ JE_rectangle(fa5faf37b232239e).(VGAScreencxx . . $ VGAScreen., xMenuItemValue - 2, y - 2, xMenuItemValue + 96, y + 11, 242); |
| 267 | break; |
| 268 | |
| 269 | case MENU_ITEM_SOUND_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SOUND_VOLUME.: |
| 270 | JE_barDrawShadowcxx . . $ JE_barDrawShadow(2b5d735fb21d70c8).(VGAScreencxx . . $ VGAScreen., xMenuItemValue, y, 1, samples_disabledcxx . . $ samples_disabled. ? 170 : 174, (fxVolumecxx . . $ fxVolume. + 4) / 8, 2, 10); |
| 271 | JE_rectanglecxx . . $ JE_rectangle(fa5faf37b232239e).(VGAScreencxx . . $ VGAScreen., xMenuItemValue - 2, y - 2, xMenuItemValue + 96, y + 11, 242); |
| 272 | break; |
| 273 | |
| 274 | default: |
| 275 | break; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | // Draw status text. |
| 280 | JE_textShadecxx . . $ JE_textShade(bb6cf87f29d3df77).(VGAScreencxx . . $ VGAScreen., xMenuItemName, 190, menuItems[*selectedMenuItemIndex].descriptioncxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#description., 15, 4, PART_SHADEcxx . . $ `src/fonthand.h:26:9`!); |
| 281 | |
| 282 | // Draw picker box and items. |
| 283 | |
| 284 | if (currentPicker != MENU_ITEM_NONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_NONE.) |
| 285 | { |
| 286 | const MenuItemcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuItem# *selectedMenuItem = &menuItems[*selectedMenuItemIndex]; |
| 287 | const size_t pickerItemsCount = selectedMenuItem->getPickerItemsCountcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#getPickerItemsCount.(); |
| 288 | |
| 289 | const int hPicker = dyPickerItem * pickerItemsCount - dyPickerItemPadding; |
| 290 | yPicker = MINcxx . . $ `src/opentyr.h:28:9`!(yPicker, 200 - 10 - (hPicker + 5 + 2)); |
| 291 | |
| 292 | JE_rectanglecxx . . $ JE_rectangle(fa5faf37b232239e).(VGAScreencxx . . $ VGAScreen., xMenuItemValue - 5, yPicker- 3, xMenuItemValue + wMenuItemValue + 5 - 1, yPicker + hPicker + 3 - 1, 248); |
| 293 | JE_rectanglecxx . . $ JE_rectangle(fa5faf37b232239e).(VGAScreencxx . . $ VGAScreen., xMenuItemValue - 4, yPicker- 4, xMenuItemValue + wMenuItemValue + 4 - 1, yPicker + hPicker + 4 - 1, 250); |
| 294 | JE_rectanglecxx . . $ JE_rectangle(fa5faf37b232239e).(VGAScreencxx . . $ VGAScreen., xMenuItemValue - 3, yPicker- 5, xMenuItemValue + wMenuItemValue + 3 - 1, yPicker + hPicker + 5 - 1, 248); |
| 295 | fill_rectangle_whcxx . . $ fill_rectangle_wh(2ff783435439505a).(VGAScreencxx . . $ VGAScreen., xMenuItemValue - 2, yPicker - 2, wMenuItemValue + 2 + 2, hPicker + 2 + 2, 224); |
| 296 | |
| 297 | for (size_t i = 0; i < pickerItemsCount; ++i) |
| 298 | { |
| 299 | const int y = yPicker + dyPickerItem * (int)i; |
| 300 | |
| 301 | const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! selected = i == pickerSelectedIndex; |
| 302 | |
| 303 | const char *value = selectedMenuItem->getPickerItemcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#getPickerItem.(i, buffer, sizeof buffer); |
| 304 | |
| 305 | draw_font_hv_shadowcxx . . $ draw_font_hv_shadow(198b4ac5940c9e46).(VGAScreencxx . . $ VGAScreen., xMenuItemValue, y, value, normal_fontcxx . . $ normal_font., left_alignedcxx . . $ left_aligned., 15, -3 + (selected ? 2 : 0), falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!, 2); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | if (restart) |
| 310 | { |
| 311 | mouseCursorcxx . . $ mouseCursor. = MOUSE_POINTER_NORMALcxx . . $ MOUSE_POINTER_NORMAL.; |
| 312 | |
| 313 | fade_palettecxx . . $ fade_palette(59ab901998e00635).(colorscxx . . $ colors., 10, 0, 255); |
| 314 | |
| 315 | restart = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 316 | } |
| 317 | |
| 318 | service_SDL_eventscxx . . $ service_SDL_events(b45ddcbc8423892c).(truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!); |
| 319 | |
| 320 | JE_mouseStartcxx . . $ JE_mouseStart(49f6e7a06ebc5aa8).(); |
| 321 | JE_showVGAcxx . . $ JE_showVGA(49f6e7a06ebc5aa8).(); |
| 322 | JE_mouseReplacecxx . . $ JE_mouseReplace(49f6e7a06ebc5aa8).(); |
| 323 | |
| 324 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! mouseMoved = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 325 | int oldFullscreenDisplay = fullscreen_displaycxx . . $ fullscreen_display.; |
| 326 | do |
| 327 | { |
| 328 | SDL_Delaycxx . . $ SDL_Delay(cb2f890c2fdad230).(16); |
| 329 | |
| 330 | Uint16cxx . . $ Uint16# oldMouseX = mouse_xcxx . . $ mouse_x.; |
| 331 | Uint16cxx . . $ Uint16# oldMouseY = mouse_ycxx . . $ mouse_y.; |
| 332 | |
| 333 | push_joysticks_as_keyboardcxx . . $ push_joysticks_as_keyboard(49f6e7a06ebc5aa8).(); |
| 334 | service_SDL_eventscxx . . $ service_SDL_events(b45ddcbc8423892c).(falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 335 | |
| 336 | mouseMoved = mouse_xcxx . . $ mouse_x. != oldMouseX || mouse_ycxx . . $ mouse_y. != oldMouseY; |
| 337 | } while (!(newkeycxx . . $ newkey. || newmousecxx . . $ newmouse. || mouseMoved || fullscreen_displaycxx . . $ fullscreen_display. != oldFullscreenDisplay)); |
| 338 | |
| 339 | if (currentPicker == MENU_ITEM_NONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_NONE.) |
| 340 | { |
| 341 | // Handle menu item interaction. |
| 342 | |
| 343 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! action = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 344 | |
| 345 | if (mouseMoved || newmousecxx . . $ newmouse.) |
| 346 | { |
| 347 | // Find menu item name or value that was hovered or clicked. |
| 348 | if (mouse_xcxx . . $ mouse_x. >= xMenuItem && mouse_xcxx . . $ mouse_x. < xMenuItem + wMenuItem) |
| 349 | { |
| 350 | for (size_t i = 0; i < menuItemsCount; ++i) |
| 351 | { |
| 352 | const int yMenuItem = yMenuItems + dyMenuItems * i; |
| 353 | if (mouse_ycxx . . $ mouse_y. >= yMenuItem && mouse_ycxx . . $ mouse_y. < yMenuItem + hMenuItem) |
| 354 | { |
| 355 | if (*selectedMenuItemIndex != i) |
| 356 | { |
| 357 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CURSORcxx . . $ S_CURSOR.); |
| 358 | |
| 359 | *selectedMenuItemIndex = i; |
| 360 | } |
| 361 | |
| 362 | if (newmousecxx . . $ newmouse. && lastmouse_butcxx . . $ lastmouse_but. == SDL_BUTTON_LEFTcxx . . $ `<external>/13849749812924280863/SDL_mouse.h:445:9`! && |
| 363 | lastmouse_ycxx . . $ lastmouse_y. >= yMenuItem && lastmouse_ycxx . . $ lastmouse_y. < yMenuItem + hMenuItem) |
| 364 | { |
| 365 | // Act on menu item via name. |
| 366 | if (lastmouse_xcxx . . $ lastmouse_x. >= xMenuItemName && lastmouse_xcxx . . $ lastmouse_x. < xMenuItemName + wMenuItemName) |
| 367 | { |
| 368 | action = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 369 | } |
| 370 | |
| 371 | // Act on menu item via value. |
| 372 | else if (lastmouse_xcxx . . $ lastmouse_x. >= xMenuItemValue && lastmouse_xcxx . . $ lastmouse_x. < xMenuItemValue + wMenuItemValue) |
| 373 | { |
| 374 | switch (menuItems[*selectedMenuItemIndex].idcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#id.) |
| 375 | { |
| 376 | case MENU_ITEM_DISPLAYcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_DISPLAY.: |
| 377 | case MENU_ITEM_SCALERcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SCALER.: |
| 378 | case MENU_ITEM_SCALING_MODEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SCALING_MODE.: |
| 379 | { |
| 380 | action = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 381 | break; |
| 382 | } |
| 383 | case MENU_ITEM_MUSIC_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_MUSIC_VOLUME.: |
| 384 | { |
| 385 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CURSORcxx . . $ S_CURSOR.); |
| 386 | |
| 387 | int value = (lastmouse_xcxx . . $ lastmouse_x. - xMenuItemValue) * 255 / (wMenuItemValue - 1); |
| 388 | tyrMusicVolumecxx . . $ tyrMusicVolume. = MINcxx . . $ `src/opentyr.h:28:9`!(MAXcxx . . $ `src/opentyr.h:29:9`!(0, value), 255); |
| 389 | |
| 390 | set_volumecxx . . $ set_volume(8fbe6856f5410d23).(tyrMusicVolumecxx . . $ tyrMusicVolume., fxVolumecxx . . $ fxVolume.); |
| 391 | break; |
| 392 | } |
| 393 | case MENU_ITEM_SOUND_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SOUND_VOLUME.: |
| 394 | { |
| 395 | int value = (lastmouse_xcxx . . $ lastmouse_x. - xMenuItemValue) * 255 / (wMenuItemValue - 1); |
| 396 | fxVolumecxx . . $ fxVolume. = MINcxx . . $ `src/opentyr.h:28:9`!(MAXcxx . . $ `src/opentyr.h:29:9`!(0, value), 255); |
| 397 | |
| 398 | set_volumecxx . . $ set_volume(8fbe6856f5410d23).(tyrMusicVolumecxx . . $ tyrMusicVolume., fxVolumecxx . . $ fxVolume.); |
| 399 | |
| 400 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CURSORcxx . . $ S_CURSOR.); |
| 401 | break; |
| 402 | } |
| 403 | default: |
| 404 | break; |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | break; |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | if (newmousecxx . . $ newmouse.) |
| 416 | { |
| 417 | if (lastmouse_butcxx . . $ lastmouse_but. == SDL_BUTTON_RIGHTcxx . . $ `<external>/13849749812924280863/SDL_mouse.h:447:9`!) |
| 418 | { |
| 419 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_SPRINGcxx . . $ S_SPRING.); |
| 420 | |
| 421 | currentMenu = menuParents[currentMenu]; |
| 422 | } |
| 423 | } |
| 424 | else if (newkeycxx . . $ newkey.) |
| 425 | { |
| 426 | switch (lastkey_scancxx . . $ lastkey_scan.) |
| 427 | { |
| 428 | case SDL_SCANCODE_UPcxx . . $ SDL_SCANCODE_UP.: |
| 429 | { |
| 430 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CURSORcxx . . $ S_CURSOR.); |
| 431 | |
| 432 | *selectedMenuItemIndex = *selectedMenuItemIndex == 0 |
| 433 | ? menuItemsCount - 1 |
| 434 | : *selectedMenuItemIndex - 1; |
| 435 | break; |
| 436 | } |
| 437 | case SDL_SCANCODE_DOWNcxx . . $ SDL_SCANCODE_DOWN.: |
| 438 | { |
| 439 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CURSORcxx . . $ S_CURSOR.); |
| 440 | |
| 441 | *selectedMenuItemIndex = *selectedMenuItemIndex == menuItemsCount - 1 |
| 442 | ? 0 |
| 443 | : *selectedMenuItemIndex + 1; |
| 444 | break; |
| 445 | } |
| 446 | case SDL_SCANCODE_LEFTcxx . . $ SDL_SCANCODE_LEFT.: |
| 447 | { |
| 448 | switch (menuItems[*selectedMenuItemIndex].idcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#id.) |
| 449 | { |
| 450 | case MENU_ITEM_MUSIC_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_MUSIC_VOLUME.: |
| 451 | { |
| 452 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CURSORcxx . . $ S_CURSOR.); |
| 453 | |
| 454 | JE_changeVolumecxx . . $ JE_changeVolume(b690d98fa3ee2e89).(&tyrMusicVolumecxx . . $ tyrMusicVolume., -8, &fxVolumecxx . . $ fxVolume., 0); |
| 455 | break; |
| 456 | } |
| 457 | case MENU_ITEM_SOUND_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SOUND_VOLUME.: |
| 458 | { |
| 459 | JE_changeVolumecxx . . $ JE_changeVolume(b690d98fa3ee2e89).(&tyrMusicVolumecxx . . $ tyrMusicVolume., 0, &fxVolumecxx . . $ fxVolume., -8); |
| 460 | |
| 461 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CURSORcxx . . $ S_CURSOR.); |
| 462 | break; |
| 463 | } |
| 464 | default: |
| 465 | break; |
| 466 | } |
| 467 | break; |
| 468 | } |
| 469 | case SDL_SCANCODE_RIGHTcxx . . $ SDL_SCANCODE_RIGHT.: |
| 470 | { |
| 471 | switch (menuItems[*selectedMenuItemIndex].idcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#id.) |
| 472 | { |
| 473 | case MENU_ITEM_MUSIC_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_MUSIC_VOLUME.: |
| 474 | { |
| 475 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CURSORcxx . . $ S_CURSOR.); |
| 476 | |
| 477 | JE_changeVolumecxx . . $ JE_changeVolume(b690d98fa3ee2e89).(&tyrMusicVolumecxx . . $ tyrMusicVolume., 8, &fxVolumecxx . . $ fxVolume., 0); |
| 478 | break; |
| 479 | } |
| 480 | case MENU_ITEM_SOUND_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SOUND_VOLUME.: |
| 481 | { |
| 482 | JE_changeVolumecxx . . $ JE_changeVolume(b690d98fa3ee2e89).(&tyrMusicVolumecxx . . $ tyrMusicVolume., 0, &fxVolumecxx . . $ fxVolume., 8); |
| 483 | |
| 484 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CURSORcxx . . $ S_CURSOR.); |
| 485 | break; |
| 486 | } |
| 487 | default: |
| 488 | break; |
| 489 | } |
| 490 | break; |
| 491 | } |
| 492 | case SDL_SCANCODE_SPACEcxx . . $ SDL_SCANCODE_SPACE.: |
| 493 | case SDL_SCANCODE_RETURNcxx . . $ SDL_SCANCODE_RETURN.: |
| 494 | { |
| 495 | action = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 496 | break; |
| 497 | } |
| 498 | case SDL_SCANCODE_ESCAPEcxx . . $ SDL_SCANCODE_ESCAPE.: |
| 499 | { |
| 500 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_SPRINGcxx . . $ S_SPRING.); |
| 501 | |
| 502 | currentMenu = menuParents[currentMenu]; |
| 503 | break; |
| 504 | } |
| 505 | default: |
| 506 | break; |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | if (action) |
| 511 | { |
| 512 | const MenuItemIdcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuItemId# selectedMenuItemId = menuItems[*selectedMenuItemIndex].idcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#id.; |
| 513 | |
| 514 | switch (selectedMenuItemId) |
| 515 | { |
| 516 | case MENU_ITEM_DONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_DONE.: |
| 517 | { |
| 518 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_SELECTcxx . . $ S_SELECT.); |
| 519 | |
| 520 | currentMenu = menuParents[currentMenu]; |
| 521 | break; |
| 522 | } |
| 523 | case MENU_ITEM_GRAPHICScxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_GRAPHICS.: |
| 524 | { |
| 525 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_SELECTcxx . . $ S_SELECT.); |
| 526 | |
| 527 | menuParents[MENU_GRAPHICScxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_GRAPHICS.] = currentMenu; |
| 528 | currentMenu = MENU_GRAPHICScxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_GRAPHICS.; |
| 529 | selectedMenuItemIndexes[currentMenu] = 0; |
| 530 | break; |
| 531 | } |
| 532 | case MENU_ITEM_SOUNDcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SOUND.: |
| 533 | { |
| 534 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_SELECTcxx . . $ S_SELECT.); |
| 535 | |
| 536 | menuParents[MENU_SOUNDcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_SOUND.] = currentMenu; |
| 537 | currentMenu = MENU_SOUNDcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_SOUND.; |
| 538 | selectedMenuItemIndexes[currentMenu] = 0; |
| 539 | break; |
| 540 | } |
| 541 | case MENU_ITEM_JUKEBOXcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_JUKEBOX.: |
| 542 | { |
| 543 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_SELECTcxx . . $ S_SELECT.); |
| 544 | |
| 545 | fade_blackcxx . . $ fade_black(d4f767463ce0a6b3).(10); |
| 546 | |
| 547 | jukeboxcxx . . $ jukebox(49f6e7a06ebc5aa8).(); |
| 548 | |
| 549 | restart = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 550 | break; |
| 551 | } |
| 552 | case MENU_ITEM_DESTRUCTcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_DESTRUCT.: |
| 553 | { |
| 554 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_SELECTcxx . . $ S_SELECT.); |
| 555 | |
| 556 | fade_blackcxx . . $ fade_black(d4f767463ce0a6b3).(10); |
| 557 | |
| 558 | JE_destructGamecxx . . $ JE_destructGame(49f6e7a06ebc5aa8).(); |
| 559 | |
| 560 | restart = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 561 | break; |
| 562 | } |
| 563 | case MENU_ITEM_DISPLAYcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_DISPLAY.: |
| 564 | { |
| 565 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CLICKcxx . . $ S_CLICK.); |
| 566 | |
| 567 | currentPicker = selectedMenuItemId; |
| 568 | pickerSelectedIndex = (size_t)(fullscreen_displaycxx . . $ fullscreen_display. + 1); |
| 569 | break; |
| 570 | } |
| 571 | case MENU_ITEM_SCALERcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SCALER.: |
| 572 | { |
| 573 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CLICKcxx . . $ S_CLICK.); |
| 574 | |
| 575 | currentPicker = selectedMenuItemId; |
| 576 | pickerSelectedIndex = scalercxx . . $ scaler.; |
| 577 | break; |
| 578 | } |
| 579 | case MENU_ITEM_SCALING_MODEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SCALING_MODE.: |
| 580 | { |
| 581 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CLICKcxx . . $ S_CLICK.); |
| 582 | |
| 583 | currentPicker = selectedMenuItemId; |
| 584 | pickerSelectedIndex = scaling_modecxx . . $ scaling_mode.; |
| 585 | break; |
| 586 | } |
| 587 | case MENU_ITEM_MUSIC_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_MUSIC_VOLUME.: |
| 588 | { |
| 589 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CLICKcxx . . $ S_CLICK.); |
| 590 | |
| 591 | music_disabledcxx . . $ music_disabled. = !music_disabledcxx . . $ music_disabled.; |
| 592 | if (!music_disabledcxx . . $ music_disabled.) |
| 593 | restart_songcxx . . $ restart_song(49f6e7a06ebc5aa8).(); |
| 594 | break; |
| 595 | } |
| 596 | case MENU_ITEM_SOUND_VOLUMEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SOUND_VOLUME.: |
| 597 | { |
| 598 | samples_disabledcxx . . $ samples_disabled. = !samples_disabledcxx . . $ samples_disabled.; |
| 599 | |
| 600 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CLICKcxx . . $ S_CLICK.); |
| 601 | break; |
| 602 | } |
| 603 | default: |
| 604 | break; |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | if (currentMenu == MENU_NONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_NONE.) |
| 609 | { |
| 610 | fade_blackcxx . . $ fade_black(d4f767463ce0a6b3).(10); |
| 611 | |
| 612 | return; |
| 613 | } |
| 614 | } |
| 615 | else |
| 616 | { |
| 617 | const MenuItemcxx . . $ setupMenu(49f6e7a06ebc5aa8).MenuItem# *selectedMenuItem = &menuItems[*selectedMenuItemIndex]; |
| 618 | |
| 619 | // Handle picker interaction. |
| 620 | |
| 621 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! action = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 622 | |
| 623 | if (mouseMoved || newmousecxx . . $ newmouse.) |
| 624 | { |
| 625 | const size_t pickerItemsCount = selectedMenuItem->getPickerItemsCountcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#getPickerItemsCount.(); |
| 626 | |
| 627 | // Find picker item that was hovered clicked. |
| 628 | if (mouse_xcxx . . $ mouse_x. >= xMenuItemValue && mouse_xcxx . . $ mouse_x. < xMenuItemValue + wMenuItemValue) |
| 629 | { |
| 630 | for (size_t i = 0; i < pickerItemsCount; ++i) |
| 631 | { |
| 632 | const int yPickerItem = yPicker + dyPickerItem * i; |
| 633 | |
| 634 | if (mouse_ycxx . . $ mouse_y. >= yPickerItem && mouse_ycxx . . $ mouse_y. < yPickerItem + hPickerItem) |
| 635 | { |
| 636 | if (pickerSelectedIndex != i) |
| 637 | { |
| 638 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CURSORcxx . . $ S_CURSOR.); |
| 639 | |
| 640 | pickerSelectedIndex = i; |
| 641 | } |
| 642 | |
| 643 | // Act on picker item. |
| 644 | if (newmousecxx . . $ newmouse. && lastmouse_butcxx . . $ lastmouse_but. == SDL_BUTTON_LEFTcxx . . $ `<external>/13849749812924280863/SDL_mouse.h:445:9`! && |
| 645 | lastmouse_xcxx . . $ lastmouse_x. >= xMenuItemValue && lastmouse_ycxx . . $ lastmouse_y. < xMenuItemValue + wMenuItemName && |
| 646 | lastmouse_ycxx . . $ lastmouse_y. >= yPickerItem && lastmouse_ycxx . . $ lastmouse_y. < yPickerItem + hPickerItem) |
| 647 | { |
| 648 | action = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 649 | } |
| 650 | } |
| 651 | } |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | if (newmousecxx . . $ newmouse.) |
| 656 | { |
| 657 | if (lastmouse_butcxx . . $ lastmouse_but. == SDL_BUTTON_RIGHTcxx . . $ `<external>/13849749812924280863/SDL_mouse.h:447:9`!) |
| 658 | { |
| 659 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_SPRINGcxx . . $ S_SPRING.); |
| 660 | |
| 661 | currentPicker = MENU_ITEM_NONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_NONE.; |
| 662 | } |
| 663 | } |
| 664 | else if (newkeycxx . . $ newkey.) |
| 665 | { |
| 666 | switch (lastkey_scancxx . . $ lastkey_scan.) |
| 667 | { |
| 668 | case SDL_SCANCODE_UPcxx . . $ SDL_SCANCODE_UP.: |
| 669 | { |
| 670 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CURSORcxx . . $ S_CURSOR.); |
| 671 | |
| 672 | const size_t pickerItemsCount = selectedMenuItem->getPickerItemsCountcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#getPickerItemsCount.(); |
| 673 | |
| 674 | pickerSelectedIndex = pickerSelectedIndex == 0 |
| 675 | ? pickerItemsCount - 1 |
| 676 | : pickerSelectedIndex - 1; |
| 677 | break; |
| 678 | } |
| 679 | case SDL_SCANCODE_DOWNcxx . . $ SDL_SCANCODE_DOWN.: |
| 680 | { |
| 681 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CURSORcxx . . $ S_CURSOR.); |
| 682 | |
| 683 | const size_t pickerItemsCount = selectedMenuItem->getPickerItemsCountcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#getPickerItemsCount.(); |
| 684 | |
| 685 | pickerSelectedIndex = pickerSelectedIndex == pickerItemsCount - 1 |
| 686 | ? 0 |
| 687 | : pickerSelectedIndex + 1; |
| 688 | break; |
| 689 | } |
| 690 | case SDL_SCANCODE_SPACEcxx . . $ SDL_SCANCODE_SPACE.: |
| 691 | case SDL_SCANCODE_RETURNcxx . . $ SDL_SCANCODE_RETURN.: |
| 692 | { |
| 693 | action = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 694 | break; |
| 695 | } |
| 696 | case SDL_SCANCODE_ESCAPEcxx . . $ SDL_SCANCODE_ESCAPE.: |
| 697 | { |
| 698 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_SPRINGcxx . . $ S_SPRING.); |
| 699 | |
| 700 | currentPicker = MENU_ITEM_NONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_NONE.; |
| 701 | break; |
| 702 | } |
| 703 | default: |
| 704 | break; |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | if (action) |
| 709 | { |
| 710 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_CLICKcxx . . $ S_CLICK.); |
| 711 | |
| 712 | switch (selectedMenuItem->idcxx . . $ setupMenu(49f6e7a06ebc5aa8).$anonymous_type_2#id.) |
| 713 | { |
| 714 | case MENU_ITEM_DISPLAYcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_DISPLAY.: |
| 715 | { |
| 716 | if ((int)pickerSelectedIndex - 1 != fullscreen_displaycxx . . $ fullscreen_display.) |
| 717 | reinit_fullscreencxx . . $ reinit_fullscreen(d4f767463ce0a6b3).((int)pickerSelectedIndex - 1); |
| 718 | break; |
| 719 | } |
| 720 | case MENU_ITEM_SCALERcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SCALER.: |
| 721 | { |
| 722 | if (pickerSelectedIndex != scalercxx . . $ scaler.) |
| 723 | { |
| 724 | const int oldScaler = scalercxx . . $ scaler.; |
| 725 | if (!init_scalercxx . . $ init_scaler(dfa6e707f7696010).(pickerSelectedIndex) && // try new scaler |
| 726 | !init_scalercxx . . $ init_scaler(dfa6e707f7696010).(oldScaler)) // revert on fail |
| 727 | { |
| 728 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!); |
| 729 | } |
| 730 | } |
| 731 | break; |
| 732 | } |
| 733 | case MENU_ITEM_SCALING_MODEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_SCALING_MODE.: |
| 734 | { |
| 735 | scaling_modecxx . . $ scaling_mode. = pickerSelectedIndex; |
| 736 | break; |
| 737 | } |
| 738 | default: |
| 739 | break; |
| 740 | } |
| 741 | |
| 742 | currentPicker = MENU_ITEM_NONEcxx . . $ setupMenu(49f6e7a06ebc5aa8).MENU_ITEM_NONE.; |
| 743 | } |
| 744 | } |
| 745 | } |
| 746 | } |
| 747 | |
| 748 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) |
| 749 | { |
| 750 | mt_srandcxx . . $ mt_srand(2c44cd906ae4e829).(timecxx . . $ time(7f38134db6521d23).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)); |
| 751 | |
| 752 | printfcxx . . $ printf(581fddd72a8db8fc).("\nWelcome to... >> %s %s <<\n\n", opentyrian_strcxx . . $ opentyrian_str., opentyrian_versioncxx . . $ opentyrian_version.); |
| 753 | |
| 754 | printfcxx . . $ printf(581fddd72a8db8fc).("Copyright (C) 2022 The OpenTyrian Development Team\n\n"); |
| 755 | |
| 756 | printfcxx . . $ printf(581fddd72a8db8fc).("This program comes with ABSOLUTELY NO WARRANTY.\n"); |
| 757 | printfcxx . . $ printf(581fddd72a8db8fc).("This is free software, and you are welcome to redistribute it\n"); |
| 758 | printfcxx . . $ printf(581fddd72a8db8fc).("under certain conditions. See the file COPYING for details.\n\n"); |
| 759 | |
| 760 | if (SDL_Initcxx . . $ SDL_Init(4c679297bf94b9eb).(0)) |
| 761 | { |
| 762 | printfcxx . . $ printf(581fddd72a8db8fc).("Failed to initialize SDL: %s\n", SDL_GetErrorcxx . . $ SDL_GetError(33a1f659e94feb42).()); |
| 763 | return -1; |
| 764 | } |
| 765 | |
| 766 | JE_loadConfigurationcxx . . $ JE_loadConfiguration(49f6e7a06ebc5aa8).(); |
| 767 | |
| 768 | xmascxx . . $ xmas. = xmas_timecxx . . $ xmas_time(c9857a73d68e59ba).(); // arg handler may override |
| 769 | |
| 770 | JE_paramCheckcxx . . $ JE_paramCheck(c759356ac01a31e7).(argc, argv); |
| 771 | |
| 772 | JE_scanForEpisodescxx . . $ JE_scanForEpisodes(49f6e7a06ebc5aa8).(); |
| 773 | |
| 774 | init_videocxx . . $ init_video(49f6e7a06ebc5aa8).(); |
| 775 | init_keyboardcxx . . $ init_keyboard(49f6e7a06ebc5aa8).(); |
| 776 | init_joystickscxx . . $ init_joysticks(49f6e7a06ebc5aa8).(); |
| 777 | printfcxx . . $ printf(581fddd72a8db8fc).("assuming mouse detected\n"); // SDL can't tell us if there isn't one |
| 778 | |
| 779 | if (xmascxx . . $ xmas. && (!dir_file_existscxx . . $ dir_file_exists(b7a7aa4a824b7595).(data_dircxx . . $ data_dir(33a1f659e94feb42).(), "tyrianc.shp") || !dir_file_existscxx . . $ dir_file_exists(b7a7aa4a824b7595).(data_dircxx . . $ data_dir(33a1f659e94feb42).(), "voicesc.snd"))) |
| 780 | { |
| 781 | xmascxx . . $ xmas. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 782 | |
| 783 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "warning: Christmas is missing.\n"); |
| 784 | } |
| 785 | |
| 786 | JE_loadPalscxx . . $ JE_loadPals(49f6e7a06ebc5aa8).(); |
| 787 | JE_loadMainShapeTablescxx . . $ JE_loadMainShapeTables(85c52e162fed56f9).(xmascxx . . $ xmas. ? "tyrianc.shp" : "tyrian.shp"); |
| 788 | |
| 789 | if (xmascxx . . $ xmas. && !xmas_promptcxx . . $ xmas_prompt(c9857a73d68e59ba).()) |
| 790 | { |
| 791 | xmascxx . . $ xmas. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 792 | |
| 793 | free_main_shape_tablescxx . . $ free_main_shape_tables(49f6e7a06ebc5aa8).(); |
| 794 | JE_loadMainShapeTablescxx . . $ JE_loadMainShapeTables(85c52e162fed56f9).("tyrian.shp"); |
| 795 | } |
| 796 | |
| 797 | /* Default Options */ |
| 798 | youAreCheatingcxx . . $ youAreCheating. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 799 | smoothScrollcxx . . $ smoothScroll. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 800 | loadDestructcxx . . $ loadDestruct. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 801 | |
| 802 | if (!audio_disabledcxx . . $ audio_disabled.) |
| 803 | { |
| 804 | printfcxx . . $ printf(581fddd72a8db8fc).("initializing SDL audio...\n"); |
| 805 | |
| 806 | init_audiocxx . . $ init_audio(c9857a73d68e59ba).(); |
| 807 | |
| 808 | load_musiccxx . . $ load_music(49f6e7a06ebc5aa8).(); |
| 809 | |
| 810 | loadSndFilecxx . . $ loadSndFile(b45ddcbc8423892c).(xmascxx . . $ xmas.); |
| 811 | } |
| 812 | else |
| 813 | { |
| 814 | printfcxx . . $ printf(581fddd72a8db8fc).("audio disabled\n"); |
| 815 | } |
| 816 | |
| 817 | if (record_democxx . . $ record_demo.) |
| 818 | printfcxx . . $ printf(581fddd72a8db8fc).("demo recording enabled (input limited to keyboard)\n"); |
| 819 | |
| 820 | JE_loadExtraShapescxx . . $ JE_loadExtraShapes(49f6e7a06ebc5aa8).(); /*Editship*/ |
| 821 | |
| 822 | JE_loadHelpTextcxx . . $ JE_loadHelpText(49f6e7a06ebc5aa8).(); |
| 823 | /*debuginfo("Help text complete");*/ |
| 824 | |
| 825 | if (isNetworkGamecxx . . $ isNetworkGame.) |
| 826 | { |
| 827 | #ifdef WITH_NETWORKcxx . . $ `<built-in>:413:9`! |
| 828 | if (network_initcxx . . $ network_init(b126dc7c1de90089).()) |
| 829 | { |
| 830 | network_tyrian_haltcxx . . $ network_tyrian_halt(ee2069353d7cc01f).(3, falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 831 | } |
| 832 | #else |
| 833 | fprintf(stderr, "OpenTyrian was compiled without networking support."); |
| 834 | JE_tyrianHalt(5); |
| 835 | #endif |
| 836 | } |
| 837 | |
| 838 | #ifdef NDEBUGcxx . . $ `<built-in>:416:9`! |
| 839 | if (!isNetworkGamecxx . . $ isNetworkGame.) |
| 840 | intro_logoscxx . . $ intro_logos(49f6e7a06ebc5aa8).(); |
| 841 | #endif |
| 842 | |
| 843 | for (; ; ) |
| 844 | { |
| 845 | JE_initPlayerDatacxx . . $ JE_initPlayerData(49f6e7a06ebc5aa8).(); |
| 846 | JE_sortHighScorescxx . . $ JE_sortHighScores(49f6e7a06ebc5aa8).(); |
| 847 | |
| 848 | play_democxx . . $ play_demo. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 849 | stopped_democxx . . $ stopped_demo. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 850 | |
| 851 | gameLoadedcxx . . $ gameLoaded. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 852 | jumpSectioncxx . . $ jumpSection. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 853 | |
| 854 | #ifdef WITH_NETWORKcxx . . $ `<built-in>:413:9`! |
| 855 | if (isNetworkGamecxx . . $ isNetworkGame.) |
| 856 | { |
| 857 | networkStartScreencxx . . $ networkStartScreen(49f6e7a06ebc5aa8).(); |
| 858 | } |
| 859 | else |
| 860 | #endif |
| 861 | { |
| 862 | if (!titleScreencxx . . $ titleScreen(c9857a73d68e59ba).()) |
| 863 | { |
| 864 | // Player quit from title screen. |
| 865 | break; |
| 866 | } |
| 867 | } |
| 868 | |
| 869 | if (loadDestructcxx . . $ loadDestruct.) |
| 870 | { |
| 871 | JE_destructGamecxx . . $ JE_destructGame(49f6e7a06ebc5aa8).(); |
| 872 | |
| 873 | loadDestructcxx . . $ loadDestruct. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 874 | } |
| 875 | else |
| 876 | { |
| 877 | JE_maincxx . . $ JE_main(49f6e7a06ebc5aa8).(); |
| 878 | |
| 879 | if (trentWincxx . . $ trentWin.) |
| 880 | { |
| 881 | // Player beat SuperTyrian. |
| 882 | break; |
| 883 | } |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | JE_tyrianHaltcxx . . $ JE_tyrianHalt(ac50b47256ae7414).(0); |
| 888 | |
| 889 | return 0; |
| 890 | } |