Changeset - r19772:e6f38e18a8e8
[Not reviewed]
master
0 3 0
frosch - 12 years ago 2012-11-13 21:46:37
frosch@openttd.org
(svn r24727) -Fix: In various windows the OSK looked shiny but using it had no effect whatsoever.
3 files changed with 43 insertions and 16 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_gui.cpp
Show inline comments
 
@@ -1339,15 +1339,13 @@ struct AIDebugWindow : public QueryStrin
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 
		switch (this->HandleEditBoxKey(WID_AID_BREAK_STR_EDIT_BOX, key, keycode, state)) {
 
			case HEBR_EDITING:
 
				/* Save the current string to static member so it can be restored next time the window is opened. */
 
				strecpy(this->break_string, this->edit_str_buf, lastof(this->break_string));
 
				break_string_filter.SetFilterTerm(this->break_string);
 
				this->OnOSKInput(WID_AID_BREAK_STR_EDIT_BOX);
 
				break;
 

	
 
			case HEBR_CANCEL:
 
				/* Unfocus the text box. */
 
				this->UnfocusFocusedWidget();
 
				break;
 
@@ -1370,12 +1368,21 @@ struct AIDebugWindow : public QueryStrin
 
			default:
 
				break;
 
		}
 
		return state;
 
	}
 

	
 
	virtual void OnOSKInput(int wid)
 
	{
 
		if (wid == WID_AID_BREAK_STR_EDIT_BOX) {
 
			/* Save the current string to static member so it can be restored next time the window is opened. */
 
			strecpy(this->break_string, this->edit_str_buf, lastof(this->break_string));
 
			break_string_filter.SetFilterTerm(this->break_string);
 
		}
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
src/genworld_gui.cpp
Show inline comments
 
@@ -694,21 +694,27 @@ struct GenerateLandscapeWindow : public 
 
		}
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 
		this->HandleEditBoxKey(WID_GL_RANDOM_EDITBOX, key, keycode, state);
 
		/* the seed is unsigned, therefore atoi cannot be used.
 
		 * As UINT32_MAX is a 'magic' value (use random seed) it
 
		 * should not be possible to be entered into the input
 
		 * field; the generate seed button can be used instead. */
 
		_settings_newgame.game_creation.generation_seed = minu(strtoul(this->edit_str_buf, NULL, 10), UINT32_MAX - 1);
 
		if (this->HandleEditBoxKey(WID_GL_RANDOM_EDITBOX, key, keycode, state) == HEBR_EDITING) this->OnOSKInput(WID_GL_RANDOM_EDITBOX);
 
		return state;
 
	}
 

	
 
	virtual void OnOSKInput(int wid)
 
	{
 
		if (wid == WID_GL_RANDOM_EDITBOX) {
 
			/* the seed is unsigned, therefore atoi cannot be used.
 
			 * As UINT32_MAX is a 'magic' value (use random seed) it
 
			 * should not be possible to be entered into the input
 
			 * field; the generate seed button can be used instead. */
 
			_settings_newgame.game_creation.generation_seed = minu(strtoul(this->edit_str_buf, NULL, 10), UINT32_MAX - 1);
 
		}
 
	}
 

	
 
	virtual void OnDropdownSelect(int widget, int index)
 
	{
 
		switch (widget) {
 
			case WID_GL_MAPSIZE_X_PULLDOWN:     _settings_newgame.game_creation.map_x = index; break;
 
			case WID_GL_MAPSIZE_Y_PULLDOWN:     _settings_newgame.game_creation.map_y = index; break;
 
			case WID_GL_TREE_PULLDOWN:          _settings_newgame.game_creation.tree_placer = index; break;
src/network/network_gui.cpp
Show inline comments
 
@@ -848,24 +848,31 @@ public:
 
				break;
 

	
 
			case HEBR_CONFIRM:
 
				break;
 

	
 
			default:
 
				/* The name is only allowed when it starts with a letter! */
 
				if (!StrEmpty(this->edit_str_buf) && this->edit_str_buf[0] != ' ') {
 
					strecpy(_settings_client.network.client_name, this->edit_str_buf, lastof(_settings_client.network.client_name));
 
				} else {
 
					strecpy(_settings_client.network.client_name, "Player", lastof(_settings_client.network.client_name));
 
				}
 
				this->OnOSKInput(WID_NG_CLIENT);
 
				break;
 
		}
 

	
 
		return state;
 
	}
 

	
 
	virtual void OnOSKInput(int wid)
 
	{
 
		if (wid == WID_NG_CLIENT) {
 
			/* The name is only allowed when it starts with a letter! */
 
			if (!StrEmpty(this->edit_str_buf) && this->edit_str_buf[0] != ' ') {
 
				strecpy(_settings_client.network.client_name, this->edit_str_buf, lastof(_settings_client.network.client_name));
 
			} else {
 
				strecpy(_settings_client.network.client_name, "Player", lastof(_settings_client.network.client_name));
 
			}
 
		}
 
	}
 

	
 
	virtual void OnQueryTextFinished(char *str)
 
	{
 
		if (!StrEmpty(str)) NetworkAddServer(str);
 
	}
 

	
 
	virtual void OnResize()
 
@@ -1180,19 +1187,26 @@ struct NetworkStartServerWindow : public
 
		switch (this->HandleEditBoxKey(WID_NSS_GAMENAME, key, keycode, state)) {
 
			case HEBR_CONFIRM:
 
			case HEBR_NOT_FOCUSED:
 
				break;
 

	
 
			default:
 
				strecpy(_settings_client.network.server_name, this->text.buf, lastof(_settings_client.network.server_name));
 
				this->OnOSKInput(WID_NSS_GAMENAME);
 
				break;
 
		}
 

	
 
		return state;
 
	}
 

	
 
	virtual void OnOSKInput(int wid)
 
	{
 
		if (wid == WID_NSS_GAMENAME) {
 
			strecpy(_settings_client.network.server_name, this->text.buf, lastof(_settings_client.network.server_name));
 
		}
 
	}
 

	
 
	virtual void OnTimeout()
 
	{
 
		static const int raise_widgets[] = {WID_NSS_CLIENTS_BTND, WID_NSS_CLIENTS_BTNU, WID_NSS_COMPANIES_BTND, WID_NSS_COMPANIES_BTNU, WID_NSS_SPECTATORS_BTND, WID_NSS_SPECTATORS_BTNU, WIDGET_LIST_END};
 
		for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) {
 
			if (this->IsWidgetLowered(*widget)) {
 
				this->RaiseWidget(*widget);
0 comments (0 inline, 0 general)