record and replay startup button clicks
This commit is contained in:
@@ -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;
|
||||
|
@@ -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,71 +41,81 @@ 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;
|
||||
|
||||
|
||||
draw_start_button(btn,5);
|
||||
mainPtr.display(); // TODO: I suspect this won't work
|
||||
play_sound(37, time_in_ticks(5));
|
||||
draw_start_button(btn,0);
|
||||
switch(btn) {
|
||||
case STARTBTN_LOAD:
|
||||
do_load();
|
||||
break;
|
||||
|
||||
case STARTBTN_NEW:
|
||||
draw_startup(0);
|
||||
start_new_game();
|
||||
set_cursor(sword_curs);
|
||||
draw_startup(0);
|
||||
break;
|
||||
|
||||
case STARTBTN_ORDER:
|
||||
pick_preferences();
|
||||
break;
|
||||
|
||||
case STARTBTN_CUSTOM: break; // Currently unused
|
||||
|
||||
case STARTBTN_SCROLL: case MAX_eStartButton:
|
||||
// These aren't buttons
|
||||
break;
|
||||
|
||||
case STARTBTN_JOIN:
|
||||
if(!party_in_memory) {
|
||||
if(kb.isAltPressed()) {
|
||||
force_party = true;
|
||||
start_new_game(true);
|
||||
} else {
|
||||
cChoiceDlog("need-party").show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto scen = pick_a_scen();
|
||||
if(scen.file.empty()) {
|
||||
if(force_party)
|
||||
party_in_memory = false;
|
||||
break;
|
||||
}
|
||||
if(scen.prog_make_ver[0] > 2 || scen.prog_make_ver[1] > 0) {
|
||||
if(force_party)
|
||||
party_in_memory = false;
|
||||
cChoiceDlog("scen-version-mismatch").show();
|
||||
break;
|
||||
}
|
||||
scen_name = scen.file;
|
||||
put_party_in_scen(scen_name);
|
||||
if(force_party && scen_name != univ.party.scen_name)
|
||||
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])) {
|
||||
draw_start_button(btn,5);
|
||||
mainPtr.display(); // TODO: I suspect this won't work
|
||||
play_sound(37, time_in_ticks(5));
|
||||
draw_start_button(btn,0);
|
||||
switch(btn) {
|
||||
case STARTBTN_LOAD:
|
||||
do_load();
|
||||
break;
|
||||
|
||||
case STARTBTN_NEW:
|
||||
draw_startup(0);
|
||||
start_new_game();
|
||||
set_cursor(sword_curs);
|
||||
draw_startup(0);
|
||||
break;
|
||||
|
||||
case STARTBTN_ORDER:
|
||||
pick_preferences();
|
||||
break;
|
||||
|
||||
case STARTBTN_CUSTOM: break; // Currently unused
|
||||
|
||||
case STARTBTN_SCROLL: case MAX_eStartButton:
|
||||
// These aren't buttons
|
||||
break;
|
||||
|
||||
case STARTBTN_JOIN:
|
||||
if(!party_in_memory) {
|
||||
if(kb.isAltPressed()) {
|
||||
force_party = true;
|
||||
start_new_game(true);
|
||||
} else {
|
||||
cChoiceDlog("need-party").show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto scen = pick_a_scen();
|
||||
if(scen.file.empty()) {
|
||||
if(force_party)
|
||||
party_in_memory = false;
|
||||
break;
|
||||
}
|
||||
if(scen.prog_make_ver[0] > 2 || scen.prog_make_ver[1] > 0) {
|
||||
if(force_party)
|
||||
party_in_memory = false;
|
||||
cChoiceDlog("scen-version-mismatch").show();
|
||||
break;
|
||||
}
|
||||
scen_name = scen.file;
|
||||
put_party_in_scen(scen_name);
|
||||
if(force_party && scen_name != univ.party.scen_name)
|
||||
party_in_memory = false;
|
||||
break;
|
||||
}
|
||||
handle_startup_button_click(btn);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user