summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-01-17 20:00:13 +0000
committerpeter1138 <peter1138@openttd.org>2008-01-17 20:00:13 +0000
commitac0fa7f69f43d92bcd117c068774064c00b98528 (patch)
tree5b2e90c2daee827d5f200580397cecd4126d7638
parent822242f4110b6e4188bca31599a23966be0b2dd4 (diff)
downloadopenttd-ac0fa7f69f43d92bcd117c068774064c00b98528.tar.xz
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
-rw-r--r--src/network/network_gui.cpp64
-rw-r--r--src/news_gui.cpp21
-rw-r--r--src/player_gui.cpp21
3 files changed, 41 insertions, 65 deletions
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index bab0b905c..022a0dabd 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -218,22 +218,21 @@ static void SortNetworkGameList(network_ql_d *nqld)
/** Enum for NetworkGameWindow, referring to _network_game_window_widgets */
enum NetworkGameWindowWidgets {
NGWW_CLOSE = 0, ///< Close 'X' button
- NGWW_CONN_TXT = 4, ///< 'Connection' droplist
- NGWW_CONN_BTN = 5, ///< 'Connection' droplist button
- NGWW_PLAYER = 6, ///< Panel with editbox to set player name
+ NGWW_CONN_BTN = 4, ///< 'Connection' droplist button
+ NGWW_PLAYER = 5, ///< Panel with editbox to set player name
- NGWW_NAME = 7, ///< 'Name' button
+ NGWW_NAME = 6, ///< 'Name' button
NGWW_CLIENTS, ///< 'Clients' button
NGWW_INFO, ///< Third button in the game list panel
- NGWW_MATRIX = 10, ///< Panel with list of games
+ NGWW_MATRIX = 9, ///< Panel with list of games
- NGWW_DETAILS = 12, ///< Panel with game details
- NGWW_JOIN = 13, ///< 'Join game' button
- NGWW_REFRESH = 14, ///< 'Refresh server' button
- NGWW_NEWGRF = 15, ///< 'NewGRF Settings' button
+ NGWW_DETAILS = 11, ///< Panel with game details
+ NGWW_JOIN = 12, ///< 'Join game' button
+ NGWW_REFRESH = 13, ///< 'Refresh server' button
+ NGWW_NEWGRF = 14, ///< 'NewGRF Settings' button
- NGWW_FIND = 16, ///< 'Find server' button
+ NGWW_FIND = 15, ///< 'Find server' button
NGWW_ADD, ///< 'Add server' button
NGWW_START, ///< 'Start server' button
NGWW_CANCEL, ///< 'Cancel' button
@@ -429,7 +428,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
case NGWW_CANCEL: // Cancel button
DeleteWindowById(WC_NETWORK_WINDOW, 0);
break;
- case NGWW_CONN_TXT: case NGWW_CONN_BTN: // 'Connection' droplist
+ case NGWW_CONN_BTN: // 'Connection' droplist
ShowDropDownMenu(w, _lan_internet_types_dropdown, _network_lan_internet, NGWW_CONN_BTN, 0, 0); // do it for widget NSSW_CONN_BTN
break;
case NGWW_NAME: // Sort by name
@@ -572,8 +571,7 @@ static const Widget _network_game_window_widgets[] = {
{ WWT_PANEL, RESIZE_RB, BGC, 0, 449, 14, 263, 0x0, STR_NULL},
{ WWT_TEXT, RESIZE_NONE, BGC, 9, 85, 23, 35, STR_NETWORK_CONNECTION, STR_NULL},
-{ WWT_INSET, RESIZE_NONE, BGC, 90, 181, 22, 33, STR_NETWORK_LAN_INTERNET_COMBO, STR_NETWORK_CONNECTION_TIP}, // NGWW_CONN_TXT
-{ WWT_TEXTBTN, RESIZE_NONE, BGC, 170, 180, 23, 32, STR_0225, STR_NETWORK_CONNECTION_TIP}, // NGWW_CONN_BTN
+{ WWT_DROPDOWNIN, RESIZE_NONE, BGC, 90, 181, 22, 33, STR_NETWORK_LAN_INTERNET_COMBO, STR_NETWORK_CONNECTION_TIP}, // NGWW_CONN_BTN
{ WWT_PANEL, RESIZE_LR, BGC, 290, 440, 22, 33, 0x0, STR_NETWORK_ENTER_NAME_TIP}, // NGWW_PLAYER
@@ -655,22 +653,20 @@ enum NetworkStartServerWidgets {
NSSW_GAMENAME = 4, ///< Background for editbox to set game name
NSSW_SETPWD = 5, ///< 'Set password' button
NSSW_SELMAP = 7, ///< 'Select map' list
- NSSW_CONNTYPE_TXT = 10, ///< 'Connection type' droplist
- NSSW_CONNTYPE_BTN = 11, ///< 'Connection type' droplist button
- NSSW_CLIENTS_BTND = 13, ///< 'Max clients' downarrow
- NSSW_CLIENTS_TXT = 14, ///< 'Max clients' text
- NSSW_CLIENTS_BTNU = 15, ///< 'Max clients' uparrow
- NSSW_COMPANIES_BTND = 17, ///< 'Max companies' downarrow
- NSSW_COMPANIES_TXT = 18, ///< 'Max companies' text
- NSSW_COMPANIES_BTNU = 19, ///< 'Max companies' uparrow
- NSSW_SPECTATORS_BTND = 21, ///< 'Max spectators' downarrow
- NSSW_SPECTATORS_TXT = 22, ///< 'Max spectators' text
- NSSW_SPECTATORS_BTNU = 23, ///< 'Max spectators' uparrow
- NSSW_LANGUAGE_TXT = 25, ///< 'Language spoken' droplist
- NSSW_LANGUAGE_BTN = 26, ///< 'Language spoken' droplist button
- NSSW_START = 27, ///< 'Start' button
- NSSW_LOAD = 28, ///< 'Load' button
- NSSW_CANCEL = 29, ///< 'Cancel' button
+ NSSW_CONNTYPE_BTN = 10, ///< 'Connection type' droplist button
+ NSSW_CLIENTS_BTND = 12, ///< 'Max clients' downarrow
+ NSSW_CLIENTS_TXT = 13, ///< 'Max clients' text
+ NSSW_CLIENTS_BTNU = 14, ///< 'Max clients' uparrow
+ NSSW_COMPANIES_BTND = 16, ///< 'Max companies' downarrow
+ NSSW_COMPANIES_TXT = 17, ///< 'Max companies' text
+ NSSW_COMPANIES_BTNU = 18, ///< 'Max companies' uparrow
+ NSSW_SPECTATORS_BTND = 20, ///< 'Max spectators' downarrow
+ NSSW_SPECTATORS_TXT = 21, ///< 'Max spectators' text
+ NSSW_SPECTATORS_BTNU = 22, ///< 'Max spectators' uparrow
+ NSSW_LANGUAGE_BTN = 24, ///< 'Language spoken' droplist button
+ NSSW_START = 25, ///< 'Start' button
+ NSSW_LOAD = 26, ///< 'Load' button
+ NSSW_CANCEL = 27, ///< 'Cancel' button
};
/**
@@ -753,7 +749,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
nd->map = (y == 0) ? NULL : _fios_list + y - 1;
SetWindowDirty(w);
} break;
- case NSSW_CONNTYPE_TXT: case NSSW_CONNTYPE_BTN: // Connection type
+ case NSSW_CONNTYPE_BTN: // Connection type
ShowDropDownMenu(w, _connection_types_dropdown, _network_advertise, NSSW_CONNTYPE_BTN, 0, 0); // do it for widget NSSW_CONNTYPE_BTN
break;
case NSSW_CLIENTS_BTND: case NSSW_CLIENTS_BTNU: // Click on up/down button for number of clients
@@ -793,7 +789,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
SetDParam(0, _network_game_info.spectators_max);
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_SPECTATORS, 3, 50, w, CS_NUMERAL);
break;
- case NSSW_LANGUAGE_TXT: case NSSW_LANGUAGE_BTN: { // Language
+ case NSSW_LANGUAGE_BTN: { // Language
uint sel = 0;
for (uint i = 0; i < lengthof(_language_dropdown) - 1; i++) {
if (_language_dropdown[i] == STR_NETWORK_LANG_ANY + _network_game_info.server_lang) {
@@ -899,8 +895,7 @@ static const Widget _network_start_server_window_widgets[] = {
/* Combo/selection boxes to control Connection Type / Max Clients / Max Companies / Max Observers / Language */
{ WWT_TEXT, RESIZE_NONE, BGC, 280, 419, 63, 75, STR_NETWORK_CONNECTION, STR_NULL},
-{ WWT_INSET, RESIZE_NONE, BGC, 280, 410, 77, 88, STR_NETWORK_LAN_INTERNET_COMBO, STR_NETWORK_CONNECTION_TIP}, // NSSW_CONNTYPE_TXT
-{ WWT_TEXTBTN, RESIZE_NONE, BGC, 399, 409, 78, 87, STR_0225, STR_NETWORK_CONNECTION_TIP}, // NSSW_CONNTYPE_BTN
+{ WWT_DROPDOWNIN, RESIZE_NONE, BGC, 280, 410, 77, 88, STR_NETWORK_LAN_INTERNET_COMBO, STR_NETWORK_CONNECTION_TIP}, // NSSW_CONNTYPE_BTN
{ WWT_TEXT, RESIZE_NONE, BGC, 280, 419, 95, 107, STR_NETWORK_NUMBER_OF_CLIENTS, STR_NULL},
{ WWT_IMGBTN, RESIZE_NONE, BGC, 280, 291, 109, 120, SPR_ARROW_DOWN, STR_NETWORK_NUMBER_OF_CLIENTS_TIP}, // NSSW_CLIENTS_BTND
@@ -918,8 +913,7 @@ static const Widget _network_start_server_window_widgets[] = {
{ WWT_IMGBTN, RESIZE_NONE, BGC, 398, 410, 173, 184, SPR_ARROW_UP, STR_NETWORK_NUMBER_OF_SPECTATORS_TIP}, // NSSW_SPECTATORS_BTNU
{ WWT_TEXT, RESIZE_NONE, BGC, 280, 419, 191, 203, STR_NETWORK_LANGUAGE_SPOKEN, STR_NULL},
-{ WWT_INSET, RESIZE_NONE, BGC, 280, 410, 205, 216, STR_NETWORK_LANGUAGE_COMBO, STR_NETWORK_LANGUAGE_TIP}, // NSSW_LANGUAGE_TXT
-{ WWT_TEXTBTN, RESIZE_NONE, BGC, 399, 409, 206, 215, STR_0225, STR_NETWORK_LANGUAGE_TIP}, // NSSW_LANGUAGE_BTN
+{ WWT_DROPDOWNIN, RESIZE_NONE, BGC, 280, 410, 205, 216, STR_NETWORK_LANGUAGE_COMBO, STR_NETWORK_LANGUAGE_TIP}, // NSSW_LANGUAGE_BTN
/* Buttons Start / Load / Cancel */
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 40, 140, 224, 235, STR_NETWORK_START_GAME, STR_NETWORK_START_GAME_TIP}, // NSSW_START
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 65abc7fe7..1528ee38f 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -786,10 +786,9 @@ void ShowMessageHistory()
/** News settings window widget offset constants */
enum {
- WIDGET_NEWSOPT_BTN_SUMMARY = 4, ///< Button that adjusts at once the level for all settings
- WIDGET_NEWSOPT_DROP_SUMMARY, ///< Drop down button for same upper button
- WIDGET_NEWSOPT_SOUNDTICKER = 7, ///< Button activating sound on events
- WIDGET_NEWSOPT_START_OPTION = 9, ///< First widget that is part of a group [<] .. [.]
+ WIDGET_NEWSOPT_DROP_SUMMARY = 4, ///< Dropdown that adjusts at once the level for all settings
+ WIDGET_NEWSOPT_SOUNDTICKER = 6, ///< Button activating sound on events
+ WIDGET_NEWSOPT_START_OPTION = 8, ///< First widget that is part of a group [<] .. [.]
};
/**
@@ -841,6 +840,8 @@ static void MessageOptionsWndProc(Window *w, WindowEvent *e)
int i, y;
if (_news_ticker_sound) w->LowerWidget(WIDGET_NEWSOPT_SOUNDTICKER);
+
+ w->widget[WIDGET_NEWSOPT_DROP_SUMMARY].data = message_opt[WP(w, def_d).data_1];
DrawWindowWidgets(w);
/* Draw the string of each setting on each button. */
@@ -849,14 +850,10 @@ static void MessageOptionsWndProc(Window *w, WindowEvent *e)
* which will give centered position */
DrawStringCentered(51, y + 1, message_opt[val & 0x3], TC_BLACK);
}
-
- /* Draw the general bottom button string as well */
- DrawStringCentered(51, y + 10, message_opt[WP(w, def_d).data_1], TC_BLACK);
} break;
case WE_CLICK:
switch (e->we.click.widget) {
- case WIDGET_NEWSOPT_BTN_SUMMARY:
case WIDGET_NEWSOPT_DROP_SUMMARY: // Dropdown menu for all settings
ShowDropDownMenu(w, message_opt, WP(w, def_d).data_1, WIDGET_NEWSOPT_DROP_SUMMARY, 0, 0);
break;
@@ -949,14 +946,10 @@ static const Widget _message_options_widgets[] = {
STR_0205_MESSAGE_TYPES, STR_NULL},
/* General drop down and sound button, widgets WIDGET_NEWSOPT_BTN_SUMMARY and WIDGET_NEWSOPT_DROP_SUMMARY */
-{ WWT_PANEL, RESIZE_NONE, COLOUR_YELLOW,
- 4, 86, 34 + NT_END * NEWS_SETTING_BASELINE_SKIP, 45 + NT_END * NEWS_SETTING_BASELINE_SKIP,
+{ WWT_DROPDOWN, RESIZE_NONE, COLOUR_YELLOW,
+ 4, 98, 34 + NT_END * NEWS_SETTING_BASELINE_SKIP, 45 + NT_END * NEWS_SETTING_BASELINE_SKIP,
0x0, STR_NULL},
-{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW,
- 87, 98, 34 + NT_END * NEWS_SETTING_BASELINE_SKIP, 45 + NT_END * NEWS_SETTING_BASELINE_SKIP,
- STR_0225, STR_NULL},
-
{ WWT_TEXT, RESIZE_NONE, COLOUR_YELLOW,
103, 409, 35 + NT_END * NEWS_SETTING_BASELINE_SKIP, 47 + NT_END * NEWS_SETTING_BASELINE_SKIP,
STR_MESSAGES_ALL, STR_NULL},
diff --git a/src/player_gui.cpp b/src/player_gui.cpp
index 781fbbd7b..01fd4e233 100644
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -292,9 +292,7 @@ enum PlayerLiveryWindowWidgets {
PLW_WIDGET_CLASS_SHIP,
PLW_WIDGET_CLASS_AIRCRAFT,
- PLW_WIDGET_PRI_COL_TEXT = 9,
- PLW_WIDGET_PRI_COL_DROPDOWN,
- PLW_WIDGET_SEC_COL_TEXT,
+ PLW_WIDGET_PRI_COL_DROPDOWN = 9,
PLW_WIDGET_SEC_COL_DROPDOWN,
PLW_WIDGET_MATRIX,
};
@@ -329,7 +327,6 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e)
case WE_CREATE:
w->LowerWidget(WP(w, livery_d).livery_class + PLW_WIDGET_CLASS_GENERAL);
if (!_loaded_newgrf_features.has_2CC) {
- w->HideWidget(PLW_WIDGET_SEC_COL_TEXT);
w->HideWidget(PLW_WIDGET_SEC_COL_DROPDOWN);
}
break;
@@ -340,9 +337,7 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e)
int y = 51;
/* Disable dropdown controls if no scheme is selected */
- w->SetWidgetDisabledState(PLW_WIDGET_PRI_COL_TEXT, (WP(w, livery_d).sel == 0));
w->SetWidgetDisabledState(PLW_WIDGET_PRI_COL_DROPDOWN, (WP(w, livery_d).sel == 0));
- w->SetWidgetDisabledState(PLW_WIDGET_SEC_COL_TEXT, (WP(w, livery_d).sel == 0));
w->SetWidgetDisabledState(PLW_WIDGET_SEC_COL_DROPDOWN, (WP(w, livery_d).sel == 0));
if (!(WP(w, livery_d).sel == 0)) {
@@ -410,12 +405,10 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e)
break;
}
- case PLW_WIDGET_PRI_COL_TEXT:
case PLW_WIDGET_PRI_COL_DROPDOWN: /* First colour dropdown */
ShowColourDropDownMenu(w, PLW_WIDGET_PRI_COL_DROPDOWN);
break;
- case PLW_WIDGET_SEC_COL_TEXT:
case PLW_WIDGET_SEC_COL_DROPDOWN: /* Second colour dropdown */
ShowColourDropDownMenu(w, PLW_WIDGET_SEC_COL_DROPDOWN);
break;
@@ -470,10 +463,8 @@ static const Widget _select_player_livery_2cc_widgets[] = {
{ WWT_IMGBTN, RESIZE_NONE, 14, 88, 109, 14, 35, SPR_IMG_AIRPLANESLIST, STR_LIVERY_AIRCRAFT_TIP },
{ WWT_PANEL, RESIZE_NONE, 14, 110, 399, 14, 35, 0x0, STR_NULL },
{ WWT_PANEL, RESIZE_NONE, 14, 0, 149, 36, 47, 0x0, STR_NULL },
-{ WWT_TEXTBTN, RESIZE_NONE, 14, 150, 262, 36, 47, STR_02BD, STR_LIVERY_PRIMARY_TIP },
-{ WWT_TEXTBTN, RESIZE_NONE, 14, 263, 274, 36, 47, STR_0225, STR_LIVERY_PRIMARY_TIP },
-{ WWT_TEXTBTN, RESIZE_NONE, 14, 275, 387, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP },
-{ WWT_TEXTBTN, RESIZE_NONE, 14, 388, 399, 36, 47, STR_0225, STR_LIVERY_SECONDARY_TIP },
+{ WWT_DROPDOWN, RESIZE_NONE, 14, 150, 274, 36, 47, STR_02BD, STR_LIVERY_PRIMARY_TIP },
+{ WWT_DROPDOWN, RESIZE_NONE, 14, 275, 399, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP },
{ WWT_MATRIX, RESIZE_NONE, 14, 0, 399, 48, 48 + 1 * 14, (1 << 8) | 1, STR_LIVERY_PANEL_TIP },
{ WIDGETS_END },
};
@@ -497,10 +488,8 @@ static const Widget _select_player_livery_widgets[] = {
{ WWT_IMGBTN, RESIZE_NONE, 14, 88, 109, 14, 35, SPR_IMG_AIRPLANESLIST, STR_LIVERY_AIRCRAFT_TIP },
{ WWT_PANEL, RESIZE_NONE, 14, 110, 274, 14, 35, 0x0, STR_NULL },
{ WWT_PANEL, RESIZE_NONE, 14, 0, 149, 36, 47, 0x0, STR_NULL },
-{ WWT_TEXTBTN, RESIZE_NONE, 14, 150, 262, 36, 47, STR_02BD, STR_LIVERY_PRIMARY_TIP },
-{ WWT_TEXTBTN, RESIZE_NONE, 14, 263, 274, 36, 47, STR_0225, STR_LIVERY_PRIMARY_TIP },
-{ WWT_TEXTBTN, RESIZE_NONE, 14, 275, 275, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP },
-{ WWT_TEXTBTN, RESIZE_NONE, 14, 275, 275, 36, 47, STR_0225, STR_LIVERY_SECONDARY_TIP },
+{ WWT_DROPDOWN, RESIZE_NONE, 14, 150, 274, 36, 47, STR_02BD, STR_LIVERY_PRIMARY_TIP },
+{ WWT_DROPDOWN, RESIZE_NONE, 14, 275, 275, 36, 47, STR_02E1, STR_LIVERY_SECONDARY_TIP },
{ WWT_MATRIX, RESIZE_NONE, 14, 0, 274, 48, 48 + 1 * 14, (1 << 8) | 1, STR_LIVERY_PANEL_TIP },
{ WIDGETS_END },
};