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";
|
return "Return";
|
||||||
case ACTION_LOOKAHEAD:
|
case ACTION_LOOKAHEAD:
|
||||||
return "Look";
|
return "Look";
|
||||||
|
case ACTION_RESTART:
|
||||||
|
return "Restart";
|
||||||
default:
|
default:
|
||||||
return "Undefined";
|
return "Undefined";
|
||||||
}
|
}
|
||||||
|
@ -69,8 +71,16 @@ static void options_scene_render_func(Scene_t* scene)
|
||||||
{
|
{
|
||||||
DrawText(">>", 0, y_offset, 12, WHITE);
|
DrawText(">>", 0, y_offset, 12, WHITE);
|
||||||
}
|
}
|
||||||
sprintf(buffer, "%s : %s", keybind_info.action_name, keybind_info.key_name);
|
if (keybind_info.key == keybind_info.original_key)
|
||||||
DrawText(buffer, 32, y_offset, 12, WHITE);
|
{
|
||||||
|
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;
|
y_offset += 12;
|
||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +89,7 @@ static void options_scene_render_func(Scene_t* scene)
|
||||||
{
|
{
|
||||||
DrawText(">>", 0, y_offset, 12, WHITE);
|
DrawText(">>", 0, y_offset, 12, WHITE);
|
||||||
}
|
}
|
||||||
DrawText("OK", 32, y_offset, 12, WHITE);
|
DrawText("Apply", 32, y_offset, 12, WHITE);
|
||||||
y_offset += 12;
|
y_offset += 12;
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
|
@ -87,7 +97,7 @@ static void options_scene_render_func(Scene_t* scene)
|
||||||
{
|
{
|
||||||
DrawText(">>", 0, y_offset, 12, WHITE);
|
DrawText(">>", 0, y_offset, 12, WHITE);
|
||||||
}
|
}
|
||||||
DrawText("Cancel", 32, y_offset, 12, WHITE);
|
DrawText("Return", 32, y_offset, 12, WHITE);
|
||||||
y_offset += 12;
|
y_offset += 12;
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
|
@ -130,16 +140,6 @@ static void wait_for_keymap_input(Scene_t* scene)
|
||||||
return;
|
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 = scene->engine->last_input_key;
|
||||||
data->keybinds_info.elems[data->curr_selection - 1].key_name = ExtGetKeyName(scene->engine->last_input_key);
|
data->keybinds_info.elems[data->curr_selection - 1].key_name = ExtGetKeyName(scene->engine->last_input_key);
|
||||||
|
|
||||||
|
@ -174,15 +174,15 @@ static void exec_component_function(Scene_t* scene, uint16_t sel)
|
||||||
register_keybind(scene->engine, info.key, info.action);
|
register_keybind(scene->engine, info.key, info.action);
|
||||||
}
|
}
|
||||||
remap_scene_keys(scene->engine);
|
remap_scene_keys(scene->engine);
|
||||||
|
scene->reset_function(scene);
|
||||||
|
data->curr_selection = sel + n_binds + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Need to reset action map, otherwise will preserve over scene change
|
// Need to reset action map, otherwise will preserve over scene change
|
||||||
scene->action_remap_function(scene);
|
scene->action_remap_function(scene);
|
||||||
|
change_scene(scene->engine, MAIN_MENU_SCENE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
change_scene(scene->engine, MAIN_MENU_SCENE);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -259,6 +259,7 @@ static void reset_options_scene(Scene_t* scene)
|
||||||
KeyBindInfo_t keybind = {
|
KeyBindInfo_t keybind = {
|
||||||
.action_name = get_action_name(action),
|
.action_name = get_action_name(action),
|
||||||
.key_name = ExtGetKeyName(key),
|
.key_name = ExtGetKeyName(key),
|
||||||
|
.original_key_name = ExtGetKeyName(key),
|
||||||
.action = action,
|
.action = action,
|
||||||
.original_key = key,
|
.original_key = key,
|
||||||
.key = key,
|
.key = key,
|
||||||
|
|
|
@ -146,6 +146,7 @@ typedef enum OptionSceneMode {
|
||||||
typedef struct KeyBindInfo {
|
typedef struct KeyBindInfo {
|
||||||
const char* action_name;
|
const char* action_name;
|
||||||
const char* key_name;
|
const char* key_name;
|
||||||
|
const char* original_key_name;
|
||||||
int action;
|
int action;
|
||||||
int key;
|
int key;
|
||||||
int original_key;
|
int original_key;
|
||||||
|
|
Loading…
Reference in New Issue