From 9739ab2f61aba89bc09bffac13733e74cdd26848 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sat, 11 Jan 2025 21:08:21 -0600 Subject: [PATCH] add 2 more launch types --- rsrc/menus/ScenEditor.rc | 5 +++- rsrc/menus/scenedit.xib | 28 ++++++++++++++++++- rsrc/menus/scenresource.h | 6 ++-- src/game/boe.main.cpp | 3 +- src/scenedit/scen.main.cpp | 50 ++++++++++++++++++++++++++++------ src/scenedit/scen.menu.cpp | 18 ++++++------ src/scenedit/scen.menus.hpp | 2 +- src/scenedit/scen.menus.mac.mm | 3 +- 8 files changed, 91 insertions(+), 24 deletions(-) diff --git a/rsrc/menus/ScenEditor.rc b/rsrc/menus/ScenEditor.rc index d0e00cb5..b03ec119 100644 --- a/rsrc/menus/ScenEditor.rc +++ b/rsrc/menus/ScenEditor.rc @@ -86,7 +86,10 @@ BEGIN END POPUP "&Scenario" BEGIN - MENUITEM "Launch Scenario Here", IDM_SCEN_LAUNCH + MENUITEM "Launch From Here", IDM_SCEN_LAUNCH_HERE + MENUITEM "Launch From Start", IDM_SCEN_LAUNCH_START + MENUITEM "Launch From Town Entrance", IDM_SCEN_LAUNCH_ENTRANCE + MENUITEM SEPARATOR MENUITEM "&Create New Town", IDM_SCEN_NEW_TOWN MENUITEM "Resize Outdoors", IDM_SCEN_RESIZE_OUTDOORS MENUITEM SEPARATOR diff --git a/rsrc/menus/scenedit.xib b/rsrc/menus/scenedit.xib index c72ab6e1..3f6d2fa1 100644 --- a/rsrc/menus/scenedit.xib +++ b/rsrc/menus/scenedit.xib @@ -343,7 +343,33 @@ - Launch Scenario Here + Launch From Here + + 2147483647 + + + + + + Launch From Start + + 2147483647 + + + + + + Launch From Town Entrance + + 2147483647 + + + + + + YES + YES + 2147483647 diff --git a/rsrc/menus/scenresource.h b/rsrc/menus/scenresource.h index b46fc430..a01b4ca4 100644 --- a/rsrc/menus/scenresource.h +++ b/rsrc/menus/scenresource.h @@ -72,7 +72,9 @@ #define IDM_SCEN_RESIZE_OUTDOORS 167 #define IDM_SCEN_ADV_IMPORT_OUT 168 #define IDM_GRAYED_LABEL 169 -#define IDM_SCEN_LAUNCH 170 +#define IDM_SCEN_LAUNCH_HERE 170 +#define IDM_SCEN_LAUNCH_START 171 +#define IDM_SCEN_LAUNCH_ENTRANCE 172 // Next default values for new objects // @@ -81,6 +83,6 @@ #define _APS_NEXT_RESOURCE_VALUE 103 #define _APS_NEXT_COMMAND_VALUE 40014 #define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 171 +#define _APS_NEXT_SYMED_VALUE 173 #endif #endif diff --git a/src/game/boe.main.cpp b/src/game/boe.main.cpp index 55ff697f..bcb03315 100644 --- a/src/game/boe.main.cpp +++ b/src/game/boe.main.cpp @@ -460,8 +460,9 @@ static void handle_scenario_args() { town_entrance = *scen_arg_town_entrance; }else if(scen_arg_loc){ town_entrance = 9; + town_location = *scen_arg_loc; } - force_town_enter(*scen_arg_town, *scen_arg_loc); + force_town_enter(*scen_arg_town, town_location); start_town_mode(*scen_arg_town, town_entrance); }else if(scen_arg_out_sec){ if(!party_in_memory || !univ.party.is_in_scenario() || diff --git a/src/scenedit/scen.main.cpp b/src/scenedit/scen.main.cpp index 24cbdf32..759f800a 100644 --- a/src/scenedit/scen.main.cpp +++ b/src/scenedit/scen.main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,7 @@ #include "tools/winutil.hpp" #include "tools/cursors.hpp" #include "dialogxml/dialogs/strdlog.hpp" +#include "dialogxml/dialogs/strchoice.hpp" #include "dialogxml/dialogs/choicedlog.hpp" #include "scen.menus.hpp" #include "fileio/resmgr/res_dialog.hpp" @@ -95,15 +97,24 @@ fs::path game_dir; fs::path game_binary; extern std::string last_load_file; -void launch_scenario() { +enum eLaunchType {LOC,START,ENTRANCE}; + +void launch_scenario(eLaunchType type) { if(boost::ends_with(last_load_file, ".exs")){ showError("The scenario editor cannot launch an unpacked scenario directly. You'll need to re-open the scenario from its .boes archive."); return; } // Make sure scenario is loaded and currently editing the terrain of a town or outdoor section - if(overall_mode >= MODE_MAIN_SCREEN){ - showError("Must be viewing the terrain of a town or outdoor section at the place where you want to put the debug party."); + if(type == LOC){ + if(overall_mode >= MODE_MAIN_SCREEN){ + showError("Must be viewing the terrain of a town or outdoor section at the place where you want to put the debug party."); + return; + } + } + // Make sure scenario is loaded + else if(overall_mode == MODE_INTRO_SCREEN){ + showError("Must have a scenario loaded."); return; } @@ -121,12 +132,27 @@ void launch_scenario() { std::ostringstream command_stream; command_stream << bp::search_path(game_binary, {fs::current_path()}) << " --scenario \"" << last_load_file << "\" "; - if(editing_town){ + if(type == LOC){ + if(editing_town){ + command_stream << "--town " << cur_town; + }else{ + command_stream << "--out-sec (" << cur_out.x << "," << cur_out.y << ")"; + } + command_stream << " --loc (" << cen_x << "," << cen_y << ")"; + }else if(type == ENTRANCE){ command_stream << "--town " << cur_town; - }else{ - command_stream << "--out-sec (" << cur_out.x << "," << cur_out.y << ")"; + std::ostringstream prompt; + prompt << "Launch in " << scenario.towns[cur_town]->name << " at which entrance?"; + std::vector choices = {"North", "East", "South", "West"}; + cStringChoice dlog(choices, prompt.str()); + size_t choice = dlog.show(0); + if(dlog->accepted()){ + command_stream << " --entrance " << choice; + }else{ + // Cancel + return; + } } - command_stream << " --loc (" << cen_x << "," << cen_y << ")"; LOG(command_stream.str()); @@ -475,8 +501,14 @@ void handle_menu_choice(eMenu item_hit) { editKey.k = key_selectall; isEdit = true; break; - case eMenu::LAUNCH: - launch_scenario(); + case eMenu::LAUNCH_HERE: + launch_scenario(LOC); + break; + case eMenu::LAUNCH_START: + launch_scenario(START); + break; + case eMenu::LAUNCH_ENTRANCE: + launch_scenario(ENTRANCE); break; case eMenu::TOWN_CREATE: if(scenario.towns.size() >= 200) { diff --git a/src/scenedit/scen.menu.cpp b/src/scenedit/scen.menu.cpp index 20e8e9ca..337ce08c 100644 --- a/src/scenedit/scen.menu.cpp +++ b/src/scenedit/scen.menu.cpp @@ -74,14 +74,16 @@ void OpenBoESceneditMenu::add_persistent_menu_items(tgui::MenuBar::Ptr& menubar) // { { "Scenario", "Advanced", "Scenario Specials Dump" }, eMenu::NONE }, // { { "Scenario", "Advanced", "Scenario Object Data Dump" }, eMenu::NONE }, - { { "Scenario", "Launch Scenario Here" }, eMenu::LAUNCH }, - { { "Scenario", "Create New Town" }, eMenu::TOWN_CREATE }, - { { "Scenario", "Resize Outdoors" }, eMenu::OUT_RESIZE }, - { { "Scenario", "Scenario Details" }, eMenu::SCEN_DETAILS }, - { { "Scenario", "Scenario Intro Text" }, eMenu::SCEN_INTRO }, - { { "Scenario", "Edit Custom Graphic Sheets" }, eMenu::SCEN_SHEETS }, - { { "Scenario", "Classify Custom Graphics" }, eMenu::SCEN_PICS }, - { { "Scenario", "Edit Custom Sounds" }, eMenu::SCEN_SNDS }, + { { "Scenario", "Launch From Here" }, eMenu::LAUNCH_HERE }, + { { "Scenario", "Launch From Start" }, eMenu::LAUNCH_START }, + { { "Scenario", "Launch From Town Entrance" }, eMenu::LAUNCH_ENTRANCE }, + { { "Scenario", "Create New Town" }, eMenu::TOWN_CREATE }, + { { "Scenario", "Resize Outdoors" }, eMenu::OUT_RESIZE }, + { { "Scenario", "Scenario Details" }, eMenu::SCEN_DETAILS }, + { { "Scenario", "Scenario Intro Text" }, eMenu::SCEN_INTRO }, + { { "Scenario", "Edit Custom Graphic Sheets" }, eMenu::SCEN_SHEETS }, + { { "Scenario", "Classify Custom Graphics" }, eMenu::SCEN_PICS }, + { { "Scenario", "Edit Custom Sounds" }, eMenu::SCEN_SNDS }, { { "Town", "Advanced", "Edit Special Nodes" }, eMenu::TOWN_SPECIALS }, { { "Town", "Advanced", "Edit Town Text" }, eMenu::TOWN_TEXT }, diff --git a/src/scenedit/scen.menus.hpp b/src/scenedit/scen.menus.hpp index c61f2d4c..ed2584c0 100644 --- a/src/scenedit/scen.menus.hpp +++ b/src/scenedit/scen.menus.hpp @@ -19,7 +19,7 @@ enum class eMenu { EDIT_UNDO, EDIT_REDO, EDIT_CUT, EDIT_COPY, EDIT_PASTE, EDIT_DELETE, EDIT_SELECT_ALL, HELP_TOC, HELP_START, HELP_TEST, HELP_DIST, HELP_CONTEST, // Scenario menu - LAUNCH, TOWN_CREATE, OUT_RESIZE, SCEN_DETAILS, SCEN_INTRO, TOWN_START, + LAUNCH_HERE, LAUNCH_START, LAUNCH_ENTRANCE, TOWN_CREATE, OUT_RESIZE, SCEN_DETAILS, SCEN_INTRO, TOWN_START, SCEN_SPECIALS, SCEN_TEXT, SCEN_JOURNALS, TOWN_IMPORT, OUT_IMPORT, SCEN_SAVE_ITEM_RECTS, TOWN_VARYING, SCEN_TIMERS, SCEN_ITEM_SHORTCUTS, TOWN_DELETE, diff --git a/src/scenedit/scen.menus.mac.mm b/src/scenedit/scen.menus.mac.mm index a9a29635..87870f92 100644 --- a/src/scenedit/scen.menus.mac.mm +++ b/src/scenedit/scen.menus.mac.mm @@ -56,7 +56,8 @@ void init_menubar() { eMenu::EDIT_CUT, eMenu::EDIT_COPY, eMenu::EDIT_PASTE, eMenu::EDIT_DELETE, eMenu::EDIT_SELECT_ALL, }; static const eMenu scen_choices[] = { - eMenu::LAUNCH, eMenu::TOWN_CREATE, eMenu::OUT_RESIZE, eMenu::NONE, + eMenu::LAUNCH_HERE, eMenu::LAUNCH_START, eMenu::LAUNCH_ENTRANCE, eMenu::NONE, + eMenu::TOWN_CREATE, eMenu::OUT_RESIZE, eMenu::NONE, eMenu::SCEN_DETAILS, eMenu::SCEN_INTRO, eMenu::SCEN_SHEETS, eMenu::SCEN_PICS, eMenu::SCEN_SNDS, eMenu::NONE, eMenu::NONE, eMenu::SCEN_SPECIALS, eMenu::SCEN_TEXT, eMenu::SCEN_JOURNALS, eMenu::TOWN_IMPORT, eMenu::OUT_IMPORT, eMenu::SCEN_SAVE_ITEM_RECTS, eMenu::TOWN_VARYING, eMenu::SCEN_TIMERS, eMenu::SCEN_ITEM_SHORTCUTS,