Skip to content

Commit

Permalink
Invasion window Android updates.
Browse files Browse the repository at this point in the history
* Open on-screen keyboard when clicking in input fields.
* Move creating dir_path out of Container constructor.  This caused
and error on Android as storage had had not been initiated.
  • Loading branch information
pjbroad committed Jan 20, 2024
1 parent 05c8a1b commit 794c0d5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions invasion_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,11 @@ namespace invasion_window
static int common_input_keypress_handler(widget_list *widget, int mx, int my,
SDL_Keycode key_code, Uint32 key_unicode, Uint16 key_mod);
static int common_input_mouseover_handler(widget_list *widget, int mx, int my);
#ifdef ANDROID
// Click handler for Android that opens the on-screen keyboard
static int input_onclick_handler(widget_list *widget, int mx, int my, Uint32 flags)
{ SDL_StartTextInput(); return 1; }
#endif

// Destroy (if needed) and create the widgets.
//
Expand All @@ -881,6 +886,9 @@ namespace invasion_window
1.5 * win->default_font_len_y, P_TEXT, win->current_scale, last_input_buf, buf_size);
widget_set_OnKey(win->window_id, input_id, (int (*)())common_input_keypress_handler);
widget_set_OnMouseover(win->window_id, input_id, (int (*)())&common_input_mouseover_handler);
#ifdef ANDROID
widget_set_OnClick(win->window_id, input_id, (int (*)())&input_onclick_handler);
#endif

width = widget_get_width(win->window_id, label_id) + space + widget_get_width(win->window_id, input_id);

Expand Down Expand Up @@ -1062,8 +1070,7 @@ namespace invasion_window
&monster_widget, &count_widget, &cap_widget }),
char_width(def_char_width), num_lines(def_num_lines), initial_delay(def_delay),
initialised(false), generated_command_valid(true),
add_list_prompt("Enter Command List Name"), monster_total_text({0, 0, 0}), repeats_done(0),
dir_path(std::string(get_path_config_base()) + "invasion_lists/") {}
add_list_prompt("Enter Command List Name"), monster_total_text({0, 0, 0}), repeats_done(0) {}
void init(void);
void destroy(void);
int display_window(window_info *win);
Expand Down Expand Up @@ -1497,6 +1504,8 @@ namespace invasion_window
{
stop_play();

dir_path = std::string(get_path_config_base()) + "invasion_lists/";

// create the invasion config directory if required
if (access(dir_path.c_str(), F_OK) != 0)
{
Expand Down

0 comments on commit 794c0d5

Please sign in to comment.