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 showWelcome();
void handle_startup_button_click(eStartButton btn);
#ifdef __APPLE__
eMenuChoice menuChoice=eMenuChoice::MENU_CHOICE_NONE;
short menuChoiceId=-1;
@@ -257,11 +259,15 @@ void replay_next_action() {
auto next_action = pop_next_action();
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");
load_party(tempDir / "temp.exg", univ);
finish_load_party();
} else if(t == "move") {
}else if(t == "move"){
location l;
std::stringstream sstr(next_action->GetText());
sstr >> l;

View File

@@ -24,10 +24,14 @@
#include "tools/cursors.hpp"
#include "gfx/render_image.hpp"
#include "tools/enum_map.hpp"
#include "replay.hpp"
#include <vector>
using std::vector;
#include <sstream>
using std::stringstream;
extern bool party_in_memory;
extern long register_flag;
extern sf::RenderWindow mainPtr;
@@ -37,16 +41,16 @@ extern sf::View mainView;
enum_map(eStartButton, rectangle) startup_button;
// TODO: Always returns false, so make it void
bool handle_startup_press(location the_point) {
void handle_startup_button_click(eStartButton btn) {
if(recording){
stringstream sstr;
sstr << btn;
record_action("startup_button_click", sstr.str());
}
std::string scen_name;
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);
mainPtr.display(); // TODO: I suspect this won't work
play_sound(37, time_in_ticks(5));
@@ -102,6 +106,16 @@ bool handle_startup_press(location the_point) {
party_in_memory = false;
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;