Change key bind modification confirmation
Player needs to apply the changes before returning to menumain
parent
d8a84f6881
commit
18064ddf3c
|
@ -37,6 +37,8 @@ static const char* get_action_name(ActionType_t action) {
|
|||
return "Return";
|
||||
case ACTION_LOOKAHEAD:
|
||||
return "Look";
|
||||
case ACTION_RESTART:
|
||||
return "Restart";
|
||||
default:
|
||||
return "Undefined";
|
||||
}
|
||||
|
@ -69,8 +71,16 @@ static void options_scene_render_func(Scene_t* scene)
|
|||
{
|
||||
DrawText(">>", 0, y_offset, 12, WHITE);
|
||||
}
|
||||
if (keybind_info.key == keybind_info.original_key)
|
||||
{
|
||||
sprintf(buffer, "%s : %s", keybind_info.action_name, keybind_info.key_name);
|
||||
DrawText(buffer, 32, y_offset, 12, WHITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(buffer, "%s : %s => %s", keybind_info.action_name, keybind_info.original_key_name, keybind_info.key_name);
|
||||
DrawText(buffer, 32, y_offset, 12, BLUE);
|
||||
}
|
||||
y_offset += 12;
|
||||
line++;
|
||||
}
|
||||
|
@ -79,7 +89,7 @@ static void options_scene_render_func(Scene_t* scene)
|
|||
{
|
||||
DrawText(">>", 0, y_offset, 12, WHITE);
|
||||
}
|
||||
DrawText("OK", 32, y_offset, 12, WHITE);
|
||||
DrawText("Apply", 32, y_offset, 12, WHITE);
|
||||
y_offset += 12;
|
||||
line++;
|
||||
|
||||
|
@ -87,7 +97,7 @@ static void options_scene_render_func(Scene_t* scene)
|
|||
{
|
||||
DrawText(">>", 0, y_offset, 12, WHITE);
|
||||
}
|
||||
DrawText("Cancel", 32, y_offset, 12, WHITE);
|
||||
DrawText("Return", 32, y_offset, 12, WHITE);
|
||||
y_offset += 12;
|
||||
line++;
|
||||
|
||||
|
@ -130,16 +140,6 @@ static void wait_for_keymap_input(Scene_t* scene)
|
|||
return;
|
||||
}
|
||||
|
||||
printf("Key inputted: %d\n", scene->engine->last_input_key);
|
||||
|
||||
ActionType_t selected_action = data->keybinds_info.elems[data->curr_selection - 1].action;
|
||||
|
||||
int last_key = sc_map_get_64(&scene->engine->keybinds, selected_action);
|
||||
assert(sc_map_found(&scene->engine->keybinds));
|
||||
|
||||
// Register immediately only for this scene
|
||||
sc_map_del_64(&scene->action_map, last_key);
|
||||
sc_map_put_64(&scene->action_map, scene->engine->last_input_key, selected_action);
|
||||
data->keybinds_info.elems[data->curr_selection - 1].key = scene->engine->last_input_key;
|
||||
data->keybinds_info.elems[data->curr_selection - 1].key_name = ExtGetKeyName(scene->engine->last_input_key);
|
||||
|
||||
|
@ -174,16 +174,16 @@ static void exec_component_function(Scene_t* scene, uint16_t sel)
|
|||
register_keybind(scene->engine, info.key, info.action);
|
||||
}
|
||||
remap_scene_keys(scene->engine);
|
||||
scene->reset_function(scene);
|
||||
data->curr_selection = sel + n_binds + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Need to reset action map, otherwise will preserve over scene change
|
||||
scene->action_remap_function(scene);
|
||||
}
|
||||
|
||||
|
||||
change_scene(scene->engine, MAIN_MENU_SCENE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Keybind options, but need to wait one frame
|
||||
|
@ -259,6 +259,7 @@ static void reset_options_scene(Scene_t* scene)
|
|||
KeyBindInfo_t keybind = {
|
||||
.action_name = get_action_name(action),
|
||||
.key_name = ExtGetKeyName(key),
|
||||
.original_key_name = ExtGetKeyName(key),
|
||||
.action = action,
|
||||
.original_key = key,
|
||||
.key = key,
|
||||
|
|
|
@ -146,6 +146,7 @@ typedef enum OptionSceneMode {
|
|||
typedef struct KeyBindInfo {
|
||||
const char* action_name;
|
||||
const char* key_name;
|
||||
const char* original_key_name;
|
||||
int action;
|
||||
int key;
|
||||
int original_key;
|
||||
|
|
Loading…
Reference in New Issue