Changeset - r9164:ed127223717e
[Not reviewed]
master
0 12 0
rubidium - 16 years ago 2008-05-10 08:58:52
rubidium@openttd.org
(svn r13027) -Codechange: use StrEmpty instead of arr[0] == '\0' and remove the need for WE_ON_EDIT_TEXT_CANCEL.
12 files changed with 32 insertions and 21 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -24,12 +24,13 @@
 
#include "window_func.h"
 
#include "date_func.h"
 
#include "vehicle_func.h"
 
#include "settings_type.h"
 
#include "gfx_func.h"
 
#include "widgets/dropdown_func.h"
 
#include "string_func.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
struct buildvehicle_d {
 
	VehicleType vehicle_type;
 
@@ -1133,13 +1134,13 @@ static void NewVehicleWndProc(Window *w,
 
				e->we.click.widget = BUILD_VEHICLE_WIDGET_BUILD;
 
				BuildVehicleClickEvent(w, e);
 
			}
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT: {
 
			if (e->we.edittext.str[0] != '\0') {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				StringID str = STR_NULL;
 
				_cmd_text = e->we.edittext.str;
 
				switch (bv->vehicle_type) {
 
					default: NOT_REACHED();
 
					case VEH_TRAIN:    str = STR_886B_CAN_T_RENAME_TRAIN_VEHICLE; break;
 
					case VEH_ROAD:     str = STR_9037_CAN_T_RENAME_ROAD_VEHICLE;  break;
src/genworld_gui.cpp
Show inline comments
 
@@ -522,13 +522,13 @@ static void GenerateLandscapeWndProc(Win
 
					break;
 
			}
 
			w->SetDirty();
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str != NULL) {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				int32 value = atoi(e->we.edittext.str);
 

	
 
				switch (WP(w, generate_d).widget_id) {
 
					case GLAND_START_DATE_TEXT:
 
						w->InvalidateWidget(GLAND_START_DATE_TEXT);
 
						_patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
 
@@ -737,13 +737,13 @@ static void CreateScenarioWndProc(Window
 
				case CSCEN_MAPSIZE_Y_PULLDOWN: _patches_newgame.map_y = e->we.dropdown.index; break;
 
			}
 
			w->SetDirty();
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str != NULL) {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				int32 value = atoi(e->we.edittext.str);
 

	
 
				switch (WP(w, generate_d).widget_id) {
 
					case CSCEN_START_DATE_TEXT:
 
						w->InvalidateWidget(CSCEN_START_DATE_TEXT);
 
						_patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
src/industry_gui.cpp
Show inline comments
 
@@ -22,12 +22,13 @@
 
#include "newgrf_text.h"
 
#include "strings_func.h"
 
#include "map_func.h"
 
#include "player_func.h"
 
#include "settings_type.h"
 
#include "tilehighlight_func.h"
 
#include "string_func.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
bool _ignore_restrictions;
 

	
 
@@ -589,13 +590,13 @@ static void IndustryViewWndProc(Window *
 
			WP(w, indview_d).clicked_line = 0;
 
			WP(w, indview_d).clicked_button = 0;
 
			w->SetDirty();
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str[0] != '\0') {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				Industry* i = GetIndustry(w->window_number);
 
				int line = WP(w, indview_d).editbox_line;
 

	
 
				i->production_rate[line] = ClampU(atoi(e->we.edittext.str), 0, 255);
 
				UpdateIndustryProduction(i);
 
				w->SetDirty();
src/misc_gui.cpp
Show inline comments
 
@@ -1037,13 +1037,14 @@ static void QueryStringWndProc(Window *w
 
		case WE_DESTROY: // Call cancellation of query, if we have not handled it before
 
			if (!qs->handled && w->parent != NULL) {
 
				WindowEvent e;
 
				Window *parent = w->parent;
 

	
 
				qs->handled = true;
 
				e.event = WE_ON_EDIT_TEXT_CANCEL;
 
				e.event = WE_ON_EDIT_TEXT;
 
				e.we.edittext.str = NULL;
 
				parent->HandleWindowEvent(&e);
 
			}
 
			ClrBit(_no_scroll, SCROLL_EDIT);
 
			break;
 
		}
 
}
src/network/network_gui.cpp
Show inline comments
 
@@ -576,14 +576,16 @@ static void NetworkGameWindowWndProc(Win
 
				ttd_strlcpy(_network_player_name, "Player", lengthof(_network_player_name));
 
			}
 

	
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			NetworkAddServer(e->we.edittext.str);
 
			NetworkRebuildHostList();
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				NetworkAddServer(e->we.edittext.str);
 
				NetworkRebuildHostList();
 
			}
 
			break;
 

	
 
		case WE_RESIZE: {
 
			w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height;
 

	
 
			w->widget[NGWW_MATRIX].data = (w->vscroll.cap << 8) + 1;
 
@@ -914,13 +916,13 @@ static void NetworkStartServerWindowWndP
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str == NULL) break;
 

	
 
			if (nd->widget_id == NSSW_SETPWD) {
 
				ttd_strlcpy(_network_server_password, e->we.edittext.str, lengthof(_network_server_password));
 
				_network_game_info.use_password = (_network_server_password[0] != '\0');
 
				_network_game_info.use_password = !StrEmpty(_network_server_password);
 
			} else {
 
				int32 value = atoi(e->we.edittext.str);
 
				w->InvalidateWidget(nd->widget_id);
 
				switch (nd->widget_id) {
 
					default: NOT_REACHED();
 
					case NSSW_CLIENTS_TXT:    _network_game_info.clients_max    = Clamp(value, 2, MAX_CLIENTS); break;
 
@@ -1670,21 +1672,20 @@ static void NetworkJoinStatusWindowWndPr
 
				delete w;
 
				SwitchMode(SM_MENU);
 
				ShowNetworkGameWindow();
 
			}
 
			break;
 

	
 
			/* If the server asks for a password, we need to fill it in */
 
			case WE_ON_EDIT_TEXT_CANCEL:
 
		case WE_ON_EDIT_TEXT:
 
			if (StrEmpty(e->we.edittext.str)) {
 
				NetworkDisconnect();
 
				ShowNetworkGameWindow();
 
				break;
 

	
 
			case WE_ON_EDIT_TEXT:
 
			} else {
 
				SEND_COMMAND(PACKET_CLIENT_PASSWORD)(pw_type, e->we.edittext.str);
 
				break;
 
			}
 
			break;
 
	}
 
}
 

	
 
static const Widget _network_join_status_window_widget[] = {
 
{    WWT_CAPTION,   RESIZE_NONE,    14,     0,   249,     0,    13, STR_NETWORK_CONNECTING, STR_018C_WINDOW_TITLE_DRAG_THIS},
 
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   249,    14,    84, 0x0,                    STR_NULL},
src/newgrf_gui.cpp
Show inline comments
 
@@ -513,14 +513,15 @@ static void NewGRFWndProc(Window *w, Win
 
				/* Parse our new "int list" */
 
				GRFConfig *c = WP(w, newgrf_d).sel;
 
				c->num_params = parse_intlist(e->we.edittext.str, (int*)c->param, lengthof(c->param));
 

	
 
				/* parse_intlist returns -1 on error */
 
				if (c->num_params == (byte)-1) c->num_params = 0;
 

	
 
				w->SetDirty();
 
			}
 
			w->SetDirty();
 
			break;
 

	
 
		case WE_DESTROY:
 
			if (!WP(w, newgrf_d).execute) {
 
				CopyGRFConfigList(WP(w, newgrf_d).orig_list, *WP(w, newgrf_d).list, true);
 
				ResetGRFConfig(false);
src/player_gui.cpp
Show inline comments
 
@@ -976,12 +976,13 @@ static void SelectPlayerFaceWndProc(Wind
 
					}
 
					break;
 
			}
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str == NULL) break;
 
			/* Set a new player face number */
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				*pf = strtoul(e->we.edittext.str, NULL, 10);
 
				ScaleAllPlayerFaceBits(*pf);
 
				ShowErrorMessage(INVALID_STRING_ID, STR_FACE_FACECODE_SET, 0, 0);
 
				w->SetDirty();
 
@@ -1328,13 +1329,13 @@ static void PlayerCompanyWndProc(Window 
 
		case WE_DESTROY:
 
			DeleteWindowById(WC_PLAYER_FACE, w->window_number);
 
			if (w->window_number == _local_player) DeleteWindowById(WC_COMPANY_PASSWORD_WINDOW, 0);
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (StrEmpty(e->we.edittext.str)) return;
 
			if (StrEmpty(e->we.edittext.str)) break;
 

	
 
			_cmd_text = e->we.edittext.str;
 
			switch (WP(w, def_d).byte_1) {
 
				case 0: /* Change president name */
 
					DoCommandP(0, 0, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT));
 
					break;
src/settings_gui.cpp
Show inline comments
 
@@ -1056,13 +1056,13 @@ static void PatchesSelectionWndProc(Wind
 
		case WE_TIMEOUT:
 
			WP(w, def_d).data_2 = 0;
 
			w->SetDirty();
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str != NULL) {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				const PatchEntry *pe = &_patches_page[WP(w, def_d).data_1].entries[WP(w, def_d).data_3];
 
				const SettingDesc *sd = pe->setting;
 
				int32 value = atoi(e->we.edittext.str);
 

	
 
				/* Save the correct currency-translated value */
 
				if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate;
 
@@ -1268,21 +1268,23 @@ static void CustCurrencyWndProc(Window *
 

	
 
			w->flags4 |= 5 << WF_TIMEOUT_SHL;
 
			w->SetDirty();
 
		} break;
 

	
 
		case WE_ON_EDIT_TEXT: {
 
			if (e->we.edittext.str == NULL) break;
 

	
 
			const char *b = e->we.edittext.str;
 

	
 
			switch (WP(w, def_d).data_2) {
 
				case CUSTCURR_EXCHANGERATE:
 
					_custom_currency.rate = Clamp(atoi(b), 1, 5000);
 
					break;
 

	
 
				case CUSTCURR_SEPARATOR: /* Thousands seperator */
 
					_custom_currency.separator = (b[0] == '\0') ? ' ' : b[0];
 
					_custom_currency.separator = StrEmpty(b) ? ' ' : b[0];
 
					ttd_strlcpy(_str_separator, b, lengthof(_str_separator));
 
					break;
 

	
 
				case CUSTCURR_PREFIX:
 
					ttd_strlcpy(_custom_currency.prefix, b, lengthof(_custom_currency.prefix));
 
					break;
src/station_gui.cpp
Show inline comments
 
@@ -22,12 +22,13 @@
 
#include "core/alloc_func.hpp"
 
#include "window_func.h"
 
#include "viewport_func.h"
 
#include "gfx_func.h"
 
#include "widgets/dropdown_func.h"
 
#include "newgrf_cargo.h"
 
#include "string_func.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
typedef int CDECL StationSortListingTypeFunction(const void*, const void*);
 

	
 
@@ -999,13 +1000,13 @@ static void StationViewWndProc(Window *w
 
					break;
 
				}
 
			}
 
			break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str[0] != '\0') {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				_cmd_text = e->we.edittext.str;
 
				DoCommandP(0, w->window_number, 0, NULL,
 
					CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION));
 
			}
 
			break;
 

	
src/timetable_gui.cpp
Show inline comments
 
@@ -246,12 +246,14 @@ static void TimetableWndProc(Window *w, 
 
			}
 

	
 
			w->SetDirty();
 
		} break;
 

	
 
		case WE_ON_EDIT_TEXT: {
 
			if (we->we.edittext.str == NULL) break;
 

	
 
			const Vehicle *v = GetVehicle(w->window_number);
 

	
 
			uint32 p1 = PackTimetableArgs(v, WP(w, timetable_d).sel);
 

	
 
			uint64 time = StrEmpty(we->we.edittext.str) ? 0 : strtoul(we->we.edittext.str, NULL, 10);
 
			if (!_patches.timetable_in_ticks) time *= DAY_TICKS;
src/town_gui.cpp
Show inline comments
 
@@ -20,12 +20,13 @@
 
#include "strings_func.h"
 
#include "sound_func.h"
 
#include "economy_func.h"
 
#include "core/alloc_func.hpp"
 
#include "settings_type.h"
 
#include "tilehighlight_func.h"
 
#include "string_func.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
extern bool GenerateTowns();
 
static int _scengen_town_size = 1; // depress medium-sized towns per default
 
@@ -357,13 +358,13 @@ static void TownViewWndProc(Window *w, W
 
				case TVW_DELETE: /* delete town - only available on Scenario editor */
 
					delete t;
 
					break;
 
			} break;
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (e->we.edittext.str[0] != '\0') {
 
			if (!StrEmpty(e->we.edittext.str)) {
 
				_cmd_text = e->we.edittext.str;
 
				DoCommandP(0, w->window_number, 0, NULL,
 
					CMD_RENAME_TOWN | CMD_MSG(STR_2008_CAN_T_RENAME_TOWN));
 
			}
 
			break;
 
	}
src/window_gui.h
Show inline comments
 
@@ -122,13 +122,12 @@ enum WindowEventCodes {
 
	WE_TICK,         ///< Regularly occurring event (every game tick)
 
	WE_100_TICKS,    ///< Regularly occurring event (every 100 game ticks, approximatelly 3 seconds)
 
	WE_TIMEOUT,
 
	WE_PLACE_OBJ,
 
	WE_ABORT_PLACE_OBJ,
 
	WE_ON_EDIT_TEXT,
 
	WE_ON_EDIT_TEXT_CANCEL,
 
	WE_DRAGDROP,
 
	WE_PLACE_DRAG,
 
	WE_PLACE_MOUSEUP,
 
	WE_PLACE_PRESIZE,
 
	WE_DROPDOWN_SELECT,
 
	WE_RESIZE,          ///< Request to resize the window, @see WindowEvent.we.resize
0 comments (0 inline, 0 general)