allow interrupting replay
This commit is contained in:
9
rsrc/dialogs/confirm-interrupt-replay.xml
Normal file
9
rsrc/dialogs/confirm-interrupt-replay.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||||
|
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
|
||||||
|
<dialog defbtn='cancel'>
|
||||||
|
<pict type='dlog' num='23' top='9' left='9'/>
|
||||||
|
<text top='5' left='51' width='255' height='72'>
|
||||||
|
Are you sure you wish to stop this replay?</text>
|
||||||
|
<button name='quit' type='regular' top='86' left='178'>Stop</button>
|
||||||
|
<button name='cancel' type='regular' def-key='esc' top='86' left='248'>Cancel</button>
|
||||||
|
</dialog>
|
||||||
@@ -45,6 +45,8 @@ cDialog* cDialog::topWindow = nullptr;
|
|||||||
void (*cDialog::redraw_everything)() = nullptr;
|
void (*cDialog::redraw_everything)() = nullptr;
|
||||||
std::mt19937 cDialog::ui_rand;
|
std::mt19937 cDialog::ui_rand;
|
||||||
|
|
||||||
|
extern bool check_for_interrupt(std::string);
|
||||||
|
|
||||||
std::string cDialog::generateRandomString(){
|
std::string cDialog::generateRandomString(){
|
||||||
// Not bothering to seed, because it doesn't actually matter if it's truly random.
|
// Not bothering to seed, because it doesn't actually matter if it's truly random.
|
||||||
int n_chars = ui_rand() % 100;
|
int n_chars = ui_rand() % 100;
|
||||||
@@ -564,7 +566,10 @@ void cDialog::handle_events() {
|
|||||||
cFramerateLimiter fps_limiter;
|
cFramerateLimiter fps_limiter;
|
||||||
|
|
||||||
while(dialogNotToast) {
|
while(dialogNotToast) {
|
||||||
if(replaying && has_next_action("click_control")){
|
if(replaying && check_for_interrupt("confirm-interrupt-replay")){
|
||||||
|
replaying = false;
|
||||||
|
return;
|
||||||
|
}else if(replaying && has_next_action("click_control")){
|
||||||
Element& next_action = pop_next_action();
|
Element& next_action = pop_next_action();
|
||||||
auto info = info_from_action(next_action);
|
auto info = info_from_action(next_action);
|
||||||
if(info["id"].empty()) continue;
|
if(info["id"].empty()) continue;
|
||||||
|
|||||||
@@ -3757,11 +3757,11 @@ bool is_sign(ter_num_t ter) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_for_interrupt(){
|
bool check_for_interrupt(std::string confirm_dialog){
|
||||||
using kb = sf::Keyboard;
|
using kb = sf::Keyboard;
|
||||||
bool interrupt = false;
|
bool interrupt = false;
|
||||||
sf::Event evt;
|
sf::Event evt;
|
||||||
if(replaying && has_next_action() && next_action_type() == "handle_interrupt"){
|
if(replaying && confirm_dialog == "confirm-interrupt-special" && has_next_action() && next_action_type() == "handle_interrupt"){
|
||||||
pop_next_action();
|
pop_next_action();
|
||||||
interrupt = true;
|
interrupt = true;
|
||||||
}
|
}
|
||||||
@@ -3778,7 +3778,7 @@ bool check_for_interrupt(){
|
|||||||
if(recording){
|
if(recording){
|
||||||
record_action("handle_interrupt", "");
|
record_action("handle_interrupt", "");
|
||||||
}
|
}
|
||||||
cChoiceDlog confirm("confirm-interrupt", {"quit","cancel"});
|
cChoiceDlog confirm(confirm_dialog, {"quit","cancel"});
|
||||||
if(confirm.show() == "quit") return true;
|
if(confirm.show() == "quit") return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ void setup_outdoors(location where);
|
|||||||
short get_outdoor_num();
|
short get_outdoor_num();
|
||||||
short count_walls(location loc);
|
short count_walls(location loc);
|
||||||
bool is_sign(ter_num_t ter);
|
bool is_sign(ter_num_t ter);
|
||||||
bool check_for_interrupt();
|
bool check_for_interrupt(std::string confirm_dialog = "confirm-interrupt-special");
|
||||||
|
|
||||||
void handle_startup_button_click(eStartButton btn, eKeyMod mods);
|
void handle_startup_button_click(eStartButton btn, eKeyMod mods);
|
||||||
void handle_switch_pc(short which_pc, bool& need_redraw, bool& need_reprint);
|
void handle_switch_pc(short which_pc, bool& need_redraw, bool& need_reprint);
|
||||||
|
|||||||
@@ -863,6 +863,10 @@ void handle_events() {
|
|||||||
|
|
||||||
while(!All_Done) {
|
while(!All_Done) {
|
||||||
if(replaying && has_next_action()){
|
if(replaying && has_next_action()){
|
||||||
|
if(check_for_interrupt("confirm-interrupt-replay")){
|
||||||
|
replaying = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
replay_next_action();
|
replay_next_action();
|
||||||
}else{
|
}else{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ extern rectangle name_rect;
|
|||||||
extern rectangle pc_race_rect;
|
extern rectangle pc_race_rect;
|
||||||
extern rectangle edit_rect[5];
|
extern rectangle edit_rect[5];
|
||||||
|
|
||||||
|
bool check_for_interrupt(std::string) {}
|
||||||
|
|
||||||
bool handle_action(const sf::Event & event) {
|
bool handle_action(const sf::Event & event) {
|
||||||
location the_point = translate_mouse_coordinates({event.mouseButton.x, event.mouseButton.y});
|
location the_point = translate_mouse_coordinates({event.mouseButton.x, event.mouseButton.y});
|
||||||
|
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ short special_to_paste = -1;
|
|||||||
bool monst_on_space(location loc,short m_num);
|
bool monst_on_space(location loc,short m_num);
|
||||||
static bool terrain_matches(unsigned char x, unsigned char y, ter_num_t ter);
|
static bool terrain_matches(unsigned char x, unsigned char y, ter_num_t ter);
|
||||||
|
|
||||||
|
bool check_for_interrupt(std::string) {}
|
||||||
|
|
||||||
void init_screen_locs() {
|
void init_screen_locs() {
|
||||||
for(short i = 0; i < 4; i++)
|
for(short i = 0; i < 4; i++)
|
||||||
border_rect[i] = terrain_rect;
|
border_rect[i] = terrain_rect;
|
||||||
|
|||||||
Reference in New Issue
Block a user