record and replay startup button clicks

This commit is contained in:
2024-07-05 14:22:29 -06:00
committed by Celtic Minstrel
parent bf724951c5
commit 3744005f68
2 changed files with 80 additions and 60 deletions

View File

@@ -117,6 +117,8 @@ extern long anim_ticks;
static void init_boe(int, char*[]); static void init_boe(int, char*[]);
static void showWelcome(); static void showWelcome();
void handle_startup_button_click(eStartButton btn);
#ifdef __APPLE__ #ifdef __APPLE__
eMenuChoice menuChoice=eMenuChoice::MENU_CHOICE_NONE; eMenuChoice menuChoice=eMenuChoice::MENU_CHOICE_NONE;
short menuChoiceId=-1; short menuChoiceId=-1;
@@ -257,7 +259,11 @@ void replay_next_action() {
auto next_action = pop_next_action(); auto next_action = pop_next_action();
std::string t = next_action->Value(); std::string t = next_action->Value();
if(t == "load_party") {
if(overall_mode == MODE_STARTUP && t == "startup_button_click"){
eStartButton btn = static_cast<eStartButton>(atoi(next_action->GetText().c_str()));
handle_startup_button_click(btn);
}else if(t == "load_party"){
decode_file(next_action->GetText(), tempDir / "temp.exg"); decode_file(next_action->GetText(), tempDir / "temp.exg");
load_party(tempDir / "temp.exg", univ); load_party(tempDir / "temp.exg", univ);
finish_load_party(); finish_load_party();

View File

@@ -24,10 +24,14 @@
#include "tools/cursors.hpp" #include "tools/cursors.hpp"
#include "gfx/render_image.hpp" #include "gfx/render_image.hpp"
#include "tools/enum_map.hpp" #include "tools/enum_map.hpp"
#include "replay.hpp"
#include <vector> #include <vector>
using std::vector; using std::vector;
#include <sstream>
using std::stringstream;
extern bool party_in_memory; extern bool party_in_memory;
extern long register_flag; extern long register_flag;
extern sf::RenderWindow mainPtr; extern sf::RenderWindow mainPtr;
@@ -37,16 +41,16 @@ extern sf::View mainView;
enum_map(eStartButton, rectangle) startup_button; enum_map(eStartButton, rectangle) startup_button;
// TODO: Always returns false, so make it void void handle_startup_button_click(eStartButton btn) {
bool handle_startup_press(location the_point) { if(recording){
stringstream sstr;
sstr << btn;
record_action("startup_button_click", sstr.str());
}
std::string scen_name; std::string scen_name;
bool force_party = false; bool force_party = false;
the_point = mainPtr.mapPixelToCoords(the_point, mainView);
for(auto btn : startup_button.keys()) {
if(btn == eStartButton::STARTBTN_SCROLL) continue;
if(the_point.in(startup_button[btn])) {
draw_start_button(btn,5); draw_start_button(btn,5);
mainPtr.display(); // TODO: I suspect this won't work mainPtr.display(); // TODO: I suspect this won't work
play_sound(37, time_in_ticks(5)); play_sound(37, time_in_ticks(5));
@@ -103,6 +107,16 @@ bool handle_startup_press(location the_point) {
break; break;
} }
} }
// TODO: Always returns false, so make it void
bool handle_startup_press(location the_point) {
the_point = mainPtr.mapPixelToCoords(the_point, mainView);
for(auto btn : startup_button.keys()) {
if(btn == eStartButton::STARTBTN_SCROLL) continue;
if(the_point.in(startup_button[btn])) {
handle_startup_button_click(btn);
}
} }
return false; return false;
} }