refactor so keystrokes can trigger editor left buttons

This commit is contained in:
2025-05-18 18:44:22 -05:00
parent 829d55fb88
commit 7ff2ff8ccd

View File

@@ -223,12 +223,9 @@ void update_mouse_spot(location the_point) {
if(overall_mode < MODE_MAIN_SCREEN) place_location(); if(overall_mode < MODE_MAIN_SCREEN) place_location();
} }
static bool handle_lb_action(location the_point) { static bool handle_lb_action(int i){
fs::path file_to_load; fs::path file_to_load;
int x; int x;
for(int i = 0; i < NLS; i++)
if(!mouse_button_held && the_point.in(left_buttons[i][0])
&& (left_button_status[i].action != LB_NO_ACTION)) {
draw_lb_slot(i,1); draw_lb_slot(i,1);
play_sound(37); play_sound(37);
mainPtr().display(); mainPtr().display();
@@ -248,7 +245,6 @@ static bool handle_lb_action(location the_point) {
set_up_main_screen(); set_up_main_screen();
} }
break; break;
case LB_LOAD_SCEN: case LB_LOAD_SCEN:
file_to_load = nav_get_scenario(); file_to_load = nav_get_scenario();
if(!file_to_load.empty() && load_scenario(file_to_load, scenario)) { if(!file_to_load.empty() && load_scenario(file_to_load, scenario)) {
@@ -318,7 +314,6 @@ static bool handle_lb_action(location the_point) {
case LB_EDIT_TALK: case LB_EDIT_TALK:
start_dialogue_editing(0); start_dialogue_editing(0);
break; break;
} }
} }
if((overall_mode < MODE_MAIN_SCREEN) && left_button_status[i].action == LB_RETURN) { if((overall_mode < MODE_MAIN_SCREEN) && left_button_status[i].action == LB_RETURN) {
@@ -327,6 +322,13 @@ static bool handle_lb_action(location the_point) {
mouse_button_held = false; mouse_button_held = false;
update_edit_menu(); update_edit_menu();
return true; return true;
}
static bool handle_lb_click(location the_point) {
for(int i = 0; i < NLS; i++)
if(!mouse_button_held && the_point.in(left_buttons[i][0])
&& (left_button_status[i].action != LB_NO_ACTION)) {
return handle_lb_action(i);
} }
return false; return false;
} }
@@ -1635,7 +1637,7 @@ void handle_action(location the_point,sf::Event /*event*/) {
if(kb.isCtrlPressed()) if(kb.isCtrlPressed())
ctrl_hit = true; ctrl_hit = true;
if(handle_lb_action(the_point)) if(handle_lb_click(the_point))
return; return;
if(overall_mode >= MODE_MAIN_SCREEN && overall_mode != MODE_EDIT_TYPES && handle_rb_action(the_point, option_hit)) if(overall_mode >= MODE_MAIN_SCREEN && overall_mode != MODE_EDIT_TYPES && handle_rb_action(the_point, option_hit))