record and replay mods on startup buttons. fix #394
This commit is contained in:
@@ -669,11 +669,7 @@ void cDialog::handle_one_event(const sf::Event& currentEvent) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case sf::Event::MouseButtonPressed:
|
case sf::Event::MouseButtonPressed:
|
||||||
key.mod = mod_none;
|
key.mod = current_key_mod();
|
||||||
if(kb.isCtrlPressed()) key.mod += mod_ctrl;
|
|
||||||
if(kb.isMetaPressed()) key.mod += mod_ctrl;
|
|
||||||
if(kb.isAltPressed()) key.mod += mod_alt;
|
|
||||||
if(kb.isShiftPressed()) key.mod += mod_shift;
|
|
||||||
where = {(int)(currentEvent.mouseButton.x / ui_scale()), (int)(currentEvent.mouseButton.y / ui_scale())};
|
where = {(int)(currentEvent.mouseButton.x / ui_scale()), (int)(currentEvent.mouseButton.y / ui_scale())};
|
||||||
process_click(where, key.mod);
|
process_click(where, key.mod);
|
||||||
break;
|
break;
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
//#include "mathutil.hpp"
|
//#include "mathutil.hpp"
|
||||||
//#include "prefs.hpp"
|
//#include "prefs.hpp"
|
||||||
//#include "cursors.hpp"
|
//#include "cursors.hpp"
|
||||||
|
#include "keymods.hpp"
|
||||||
|
|
||||||
eKeyMod operator + (eKeyMod lhs, eKeyMod rhs){
|
eKeyMod operator + (eKeyMod lhs, eKeyMod rhs){
|
||||||
if(lhs == rhs) return lhs;
|
if(lhs == rhs) return lhs;
|
||||||
@@ -116,3 +117,12 @@ unsigned char removeShift(unsigned char c){
|
|||||||
};
|
};
|
||||||
return afterUnShift[c - ' '];
|
return afterUnShift[c - ' '];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eKeyMod current_key_mod() {
|
||||||
|
eKeyMod mod = mod_none;
|
||||||
|
if(kb.isCtrlPressed()) mod += mod_ctrl;
|
||||||
|
if(kb.isMetaPressed()) mod += mod_ctrl;
|
||||||
|
if(kb.isAltPressed()) mod += mod_alt;
|
||||||
|
if(kb.isShiftPressed()) mod += mod_shift;
|
||||||
|
return mod;
|
||||||
|
}
|
||||||
|
@@ -91,4 +91,6 @@ unsigned char applyShift(unsigned char c);
|
|||||||
/// Removes the shift key from the given character (assumes US keyboard layout)
|
/// Removes the shift key from the given character (assumes US keyboard layout)
|
||||||
unsigned char removeShift(unsigned char c);
|
unsigned char removeShift(unsigned char c);
|
||||||
|
|
||||||
|
eKeyMod current_key_mod();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <SFML/Window/Event.hpp>
|
#include <SFML/Window/Event.hpp>
|
||||||
#include "location.hpp"
|
#include "location.hpp"
|
||||||
|
#include "dialogxml/keycodes.hpp"
|
||||||
|
|
||||||
void init_screen_locs();
|
void init_screen_locs();
|
||||||
bool prime_time();
|
bool prime_time();
|
||||||
@@ -36,7 +37,7 @@ 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();
|
||||||
|
|
||||||
void handle_startup_button_click(eStartButton btn);
|
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);
|
||||||
void handle_switch_pc_items(short which_pc, bool& need_redraw);
|
void handle_switch_pc_items(short which_pc, bool& need_redraw);
|
||||||
void handle_equip_item(short item_hit, bool& need_redraw);
|
void handle_equip_item(short item_hit, bool& need_redraw);
|
||||||
|
@@ -264,8 +264,10 @@ void replay_next_action() {
|
|||||||
std::string t = next_action.Value();
|
std::string t = next_action.Value();
|
||||||
|
|
||||||
if(overall_mode == MODE_STARTUP && t == "startup_button_click"){
|
if(overall_mode == MODE_STARTUP && t == "startup_button_click"){
|
||||||
eStartButton btn = static_cast<eStartButton>(std::stoi(next_action.GetText()));
|
auto info = info_from_action(next_action);
|
||||||
handle_startup_button_click(btn);
|
eStartButton btn = static_cast<eStartButton>(std::stoi(info["btn"]));
|
||||||
|
eKeyMod mods = static_cast<eKeyMod>(std::stoi(info["mods"]));
|
||||||
|
handle_startup_button_click(btn, mods);
|
||||||
}else if(t == "load_party"){
|
}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);
|
||||||
|
@@ -9,6 +9,7 @@ int main(int argc, char* argv[]);
|
|||||||
void update_everything();
|
void update_everything();
|
||||||
void redraw_everything();
|
void redraw_everything();
|
||||||
void Mouse_Pressed(const sf::Event&);
|
void Mouse_Pressed(const sf::Event&);
|
||||||
|
eKeyMod current_key_mod();
|
||||||
void close_program();
|
void close_program();
|
||||||
void change_cursor(location where_curs);
|
void change_cursor(location where_curs);
|
||||||
void set_up_apple_events();
|
void set_up_apple_events();
|
||||||
|
@@ -40,11 +40,19 @@ extern sf::View mainView;
|
|||||||
|
|
||||||
enum_map(eStartButton, rectangle) startup_button;
|
enum_map(eStartButton, rectangle) startup_button;
|
||||||
|
|
||||||
void handle_startup_button_click(eStartButton btn) {
|
void handle_startup_button_click(eStartButton btn, eKeyMod mods) {
|
||||||
if(recording){
|
if(recording){
|
||||||
|
std::map<std::string, std::string> info;
|
||||||
|
|
||||||
std::ostringstream sstr;
|
std::ostringstream sstr;
|
||||||
sstr << btn;
|
sstr << btn;
|
||||||
record_action("startup_button_click", sstr.str());
|
info["btn"] = sstr.str();
|
||||||
|
|
||||||
|
sstr.str("");
|
||||||
|
sstr << mods;
|
||||||
|
info["mods"] = sstr.str();
|
||||||
|
|
||||||
|
record_action("startup_button_click", info);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string scen_name;
|
std::string scen_name;
|
||||||
@@ -78,7 +86,7 @@ void handle_startup_button_click(eStartButton btn) {
|
|||||||
|
|
||||||
case STARTBTN_JOIN:
|
case STARTBTN_JOIN:
|
||||||
if(!party_in_memory) {
|
if(!party_in_memory) {
|
||||||
if(kb.isAltPressed()) {
|
if(mod_contains(mods, mod_alt)) {
|
||||||
force_party = true;
|
force_party = true;
|
||||||
start_new_game(true);
|
start_new_game(true);
|
||||||
} else {
|
} else {
|
||||||
@@ -114,7 +122,7 @@ bool handle_startup_press(location the_point) {
|
|||||||
for(auto btn : startup_button.keys()) {
|
for(auto btn : startup_button.keys()) {
|
||||||
if(btn == eStartButton::STARTBTN_SCROLL) continue;
|
if(btn == eStartButton::STARTBTN_SCROLL) continue;
|
||||||
if(the_point.in(startup_button[btn])) {
|
if(the_point.in(startup_button[btn])) {
|
||||||
handle_startup_button_click(btn);
|
handle_startup_button_click(btn, current_key_mod());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user