|
7 | 7 | #include <imgui.h> |
8 | 8 | #include "notifications.hpp" |
9 | 9 | #include <array> |
| 10 | +#include <random> |
10 | 11 |
|
11 | 12 | std::array<StageTable_mb, 0x40> CustomStageTable; |
12 | 13 | int CustomStageTableCount = 0; |
13 | 14 |
|
14 | 15 | char ShareCode[256]; |
15 | 16 |
|
| 17 | +const std::vector<GameStage> stages_or2_day = { |
| 18 | + STAGE_PALM_BEACH, |
| 19 | + STAGE_DEEP_LAKE, |
| 20 | + STAGE_INDUSTRIAL_COMPLEX, |
| 21 | + STAGE_ALPINE, |
| 22 | + STAGE_SNOW_MOUNTAIN, |
| 23 | + STAGE_CLOUDY_HIGHLAND, |
| 24 | + STAGE_CASTLE_WALL, |
| 25 | + STAGE_GHOST_FOREST, |
| 26 | + STAGE_CONIFEROUS_FOREST, |
| 27 | + STAGE_DESERT, |
| 28 | + STAGE_TULIP_GARDEN, |
| 29 | + STAGE_METROPOLIS, |
| 30 | + STAGE_ANCIENT_RUINS, |
| 31 | + STAGE_CAPE_WAY, |
| 32 | + STAGE_IMPERIAL_AVENUE |
| 33 | +}; |
| 34 | +const std::vector<GameStage> stages_or2_night = { |
| 35 | + STAGE_PALM_BEACH_BT, |
| 36 | + STAGE_PALM_BEACH_BR, |
| 37 | +}; |
| 38 | +const std::vector<GameStage> stages_or2_reverse = { |
| 39 | + STAGE_PALM_BEACH_R, |
| 40 | + STAGE_DEEP_LAKE_R, |
| 41 | + STAGE_INDUSTRIAL_COMPLEX_R, |
| 42 | + STAGE_ALPINE_R, |
| 43 | + STAGE_SNOW_MOUNTAIN_R, |
| 44 | + STAGE_CLOUDY_HIGHLAND_R, |
| 45 | + STAGE_CASTLE_WALL_R, |
| 46 | + STAGE_GHOST_FOREST_R, |
| 47 | + STAGE_CONIFEROUS_FOREST_R, |
| 48 | + STAGE_DESERT_R, |
| 49 | + STAGE_TULIP_GARDEN_R, |
| 50 | + STAGE_METROPOLIS_R, |
| 51 | + STAGE_ANCIENT_RUINS_R, |
| 52 | + STAGE_CAPE_WAY_R, |
| 53 | + STAGE_IMPERIAL_AVENUE_R, |
| 54 | +}; |
| 55 | +const std::vector<GameStage> stages_or2sp_day = { |
| 56 | + STAGE_BEACH, |
| 57 | + STAGE_SEQUOIA, |
| 58 | + STAGE_NIAGARA, |
| 59 | + STAGE_LAS_VEGAS, |
| 60 | + STAGE_ALASKA, |
| 61 | + STAGE_GRAND_CANYON, |
| 62 | + STAGE_SAN_FRANCISCO, |
| 63 | + STAGE_AMAZON, |
| 64 | + STAGE_MACHU_PICCHU, |
| 65 | + STAGE_YOSEMITE, |
| 66 | + STAGE_MAYA, |
| 67 | + STAGE_NEW_YORK, |
| 68 | + STAGE_PRINCE_EDWARD, |
| 69 | + STAGE_FLORIDA, |
| 70 | + STAGE_EASTER_ISLAND |
| 71 | +}; |
| 72 | +const std::vector<GameStage> stages_or2sp_night = { |
| 73 | + STAGE_BEACH_BT, |
| 74 | + STAGE_BEACH_BR |
| 75 | +}; |
| 76 | +const std::vector<GameStage> stages_or2sp_reverse = { |
| 77 | + STAGE_BEACH_R, |
| 78 | + STAGE_SEQUOIA_R, |
| 79 | + STAGE_NIAGARA_R, |
| 80 | + STAGE_LAS_VEGAS_R, |
| 81 | + STAGE_ALASKA_R, |
| 82 | + STAGE_GRAND_CANYON_R, |
| 83 | + STAGE_SAN_FRANCISCO_R, |
| 84 | + STAGE_AMAZON_R, |
| 85 | + STAGE_MACHU_PICCHU_R, |
| 86 | + STAGE_YOSEMITE_R, |
| 87 | + STAGE_MAYA_R, |
| 88 | + STAGE_NEW_YORK_R, |
| 89 | + STAGE_PRINCE_EDWARD_R, |
| 90 | + STAGE_FLORIDA_R, |
| 91 | + STAGE_EASTER_ISLAND_R, |
| 92 | +}; |
| 93 | + |
16 | 94 | class CourseReplacement : public Hook |
17 | 95 | { |
18 | 96 | inline static SafetyHookMid midhook{}; |
@@ -216,17 +294,17 @@ void Overlay_CourseEditor() |
216 | 294 |
|
217 | 295 | float comboHeight = ImGui::GetFrameHeight(); // Height of a single combobox |
218 | 296 | float verticalSpacing = 10.0f; // Additional spacing between comboboxes |
219 | | - float comboWidth = 200.0f; // Width of comboboxes |
| 297 | + float comboWidth = 225.0f; // Width of comboboxes |
220 | 298 |
|
221 | | - float windowHeight = ceil(ImGui::GetWindowHeight()); |
| 299 | + float windowHeight = ImGui::GetCursorPosY() + floor(comboHeight * 5 + (verticalSpacing * 6)); |
222 | 300 |
|
223 | 301 | bool has_updated = false; |
224 | 302 |
|
225 | 303 | int num = 0; |
226 | 304 | StageTable_mb* curStage = CustomStageTable.data(); |
227 | 305 | for (int col = 0; col < 5; ++col) |
228 | 306 | { |
229 | | - float columnHeight = (comboHeight + verticalSpacing) * (col + 1) - verticalSpacing; |
| 307 | + float columnHeight = floor((comboHeight + verticalSpacing) * (col + 1) - verticalSpacing); |
230 | 308 |
|
231 | 309 | // Start a new column for each level of the pyramid |
232 | 310 | ImGui::BeginGroup(); |
@@ -289,6 +367,68 @@ void Overlay_CourseEditor() |
289 | 367 | if (ImGui::Button("Apply Code")) |
290 | 368 | sharecode_apply(); |
291 | 369 |
|
| 370 | + if (ImGui::TreeNode("Randomizer")) |
| 371 | + { |
| 372 | + static bool or2_day = true; |
| 373 | + static bool or2_night = true; |
| 374 | + static bool or2_reverse = true; |
| 375 | + static bool or2sp_day = true; |
| 376 | + static bool or2sp_night = true; |
| 377 | + static bool or2sp_reverse = true; |
| 378 | + static bool allow_duplicates = false; |
| 379 | + |
| 380 | + ImGui::Checkbox("OutRun2 Day (15 tracks)", &or2_day); |
| 381 | + ImGui::Checkbox("OutRun2 Night (2 tracks)", &or2_night); |
| 382 | + ImGui::Checkbox("OutRun2 Reverse (15 tracks)", &or2_reverse); |
| 383 | + ImGui::Checkbox("OutRun2SP Day (15 tracks)", &or2sp_day); |
| 384 | + ImGui::Checkbox("OutRun2SP Night (2 tracks)", &or2sp_night); |
| 385 | + ImGui::Checkbox("OutRun2SP Reverse (15 tracks)", &or2sp_reverse); |
| 386 | + ImGui::Checkbox("Allow Duplicates", &allow_duplicates); |
| 387 | + |
| 388 | + if (ImGui::Button("Randomize")) |
| 389 | + { |
| 390 | + std::vector<GameStage> chosen; |
| 391 | + if (or2_day) |
| 392 | + chosen.insert(chosen.end(), stages_or2_day.begin(), stages_or2_day.end()); |
| 393 | + if (or2_night) |
| 394 | + chosen.insert(chosen.end(), stages_or2_night.begin(), stages_or2_night.end()); |
| 395 | + if (or2_reverse) |
| 396 | + chosen.insert(chosen.end(), stages_or2_reverse.begin(), stages_or2_reverse.end()); |
| 397 | + if (or2sp_day) |
| 398 | + chosen.insert(chosen.end(), stages_or2sp_day.begin(), stages_or2sp_day.end()); |
| 399 | + if (or2sp_night) |
| 400 | + chosen.insert(chosen.end(), stages_or2sp_night.begin(), stages_or2sp_night.end()); |
| 401 | + if (or2sp_reverse) |
| 402 | + chosen.insert(chosen.end(), stages_or2sp_reverse.begin(), stages_or2sp_reverse.end()); |
| 403 | + |
| 404 | + // Randomize selection |
| 405 | + if (!chosen.empty()) |
| 406 | + { |
| 407 | + std::random_device rd; |
| 408 | + std::mt19937 gen(rd()); |
| 409 | + std::uniform_int_distribution<> dist(0, chosen.size() - 1); |
| 410 | + |
| 411 | + std::vector<GameStage> seen; |
| 412 | + for (int i = 0; i < 15; i++) |
| 413 | + { |
| 414 | + GameStage random_stage = chosen[dist(gen)]; |
| 415 | + if (!allow_duplicates && chosen.size() >= 15) |
| 416 | + { |
| 417 | + while (std::find(seen.begin(), seen.end(), random_stage) != seen.end()) |
| 418 | + { |
| 419 | + // Regenerate stage if it's been seen before |
| 420 | + random_stage = chosen[dist(gen)]; |
| 421 | + } |
| 422 | + } |
| 423 | + |
| 424 | + update_stage(&CustomStageTable[i], random_stage, i > 9); |
| 425 | + seen.push_back(random_stage); |
| 426 | + } |
| 427 | + } |
| 428 | + } |
| 429 | + ImGui::TreePop(); |
| 430 | + } |
| 431 | + |
292 | 432 | if (editor_disabled) |
293 | 433 | { |
294 | 434 | ImGui::EndDisabled(); |
|
0 commit comments