mirror of https://github.com/OpenTTD/OpenTTD
(svn r12426) -Cleanup: sprinkle some coding style over a few files.
parent
327e870962
commit
f241b0acd4
125
src/misc_gui.cpp
125
src/misc_gui.cpp
|
@ -92,26 +92,20 @@ static const WindowDesc _land_info_desc = {
|
|||
|
||||
static void Place_LandInfo(TileIndex tile)
|
||||
{
|
||||
Player *p;
|
||||
Window *w;
|
||||
Town *t;
|
||||
Money old_money;
|
||||
CommandCost costclear;
|
||||
AcceptedCargo ac;
|
||||
TileDesc td;
|
||||
StringID str;
|
||||
|
||||
DeleteWindowById(WC_LAND_INFO, 0);
|
||||
|
||||
w = AllocateWindowDesc(&_land_info_desc);
|
||||
Window *w = AllocateWindowDesc(&_land_info_desc);
|
||||
WP(w, void_d).data = &_landinfo_data;
|
||||
|
||||
p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST);
|
||||
t = ClosestTownFromTile(tile, _patches.dist_local_authority);
|
||||
Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST);
|
||||
Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
|
||||
|
||||
old_money = p->player_money;
|
||||
Money old_money = p->player_money;
|
||||
p->player_money = INT64_MAX;
|
||||
costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
|
||||
CommandCost costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
|
||||
p->player_money = old_money;
|
||||
|
||||
/* Because build_date is not set yet in every TileDesc, we make sure it is empty */
|
||||
|
@ -126,7 +120,7 @@ static void Place_LandInfo(TileIndex tile)
|
|||
if (td.owner != OWNER_NONE && td.owner != OWNER_WATER) GetNameOfOwner(td.owner, tile);
|
||||
GetString(_landinfo_data[1], STR_01A7_OWNER, lastof(_landinfo_data[1]));
|
||||
|
||||
str = STR_01A4_COST_TO_CLEAR_N_A;
|
||||
StringID str = STR_01A4_COST_TO_CLEAR_N_A;
|
||||
if (CmdSucceeded(costclear)) {
|
||||
SetDParam(0, costclear.GetCost());
|
||||
str = STR_01A5_COST_TO_CLEAR;
|
||||
|
@ -147,16 +141,15 @@ static void Place_LandInfo(TileIndex tile)
|
|||
}
|
||||
GetString(_landinfo_data[4], STR_01A8_LOCAL_AUTHORITY, lastof(_landinfo_data[4]));
|
||||
|
||||
{
|
||||
char *p = GetString(_landinfo_data[5], STR_01CE_CARGO_ACCEPTED, lastof(_landinfo_data[5]));
|
||||
char *strp = GetString(_landinfo_data[5], STR_01CE_CARGO_ACCEPTED, lastof(_landinfo_data[5]));
|
||||
bool found = false;
|
||||
|
||||
for (CargoID i = 0; i < NUM_CARGO; ++i) {
|
||||
if (ac[i] > 0) {
|
||||
/* Add a comma between each item. */
|
||||
if (found) {
|
||||
*p++ = ',';
|
||||
*p++ = ' ';
|
||||
*strp++ = ',';
|
||||
*strp++ = ' ';
|
||||
}
|
||||
found = true;
|
||||
|
||||
|
@ -164,15 +157,13 @@ static void Place_LandInfo(TileIndex tile)
|
|||
if (ac[i] < 8) {
|
||||
SetDParam(0, ac[i]);
|
||||
SetDParam(1, GetCargo(i)->name);
|
||||
p = GetString(p, STR_01D1_8, lastof(_landinfo_data[5]));
|
||||
strp = GetString(strp, STR_01D1_8, lastof(_landinfo_data[5]));
|
||||
} else {
|
||||
p = GetString(p, GetCargo(i)->name, lastof(_landinfo_data[5]));
|
||||
strp = GetString(strp, GetCargo(i)->name, lastof(_landinfo_data[5]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) _landinfo_data[5][0] = '\0';
|
||||
}
|
||||
|
||||
if (td.build_date != 0) {
|
||||
SetDParam(0, td.build_date);
|
||||
|
@ -269,8 +260,8 @@ static void AboutWindowProc(Window *w, WindowEvent *e)
|
|||
WP(w, scroller_d).counter = 5;
|
||||
WP(w, scroller_d).height = w->height - 40;
|
||||
break;
|
||||
|
||||
case WE_PAINT: {
|
||||
uint i;
|
||||
int y = WP(w, scroller_d).height;
|
||||
DrawWindowWidgets(w);
|
||||
|
||||
|
@ -279,7 +270,7 @@ static void AboutWindowProc(Window *w, WindowEvent *e)
|
|||
DrawStringCentered(210, 17 + 10, STR_00B7_VERSION, TC_FROMSTRING);
|
||||
|
||||
/* Show all scrolling credits */
|
||||
for (i = 0; i < lengthof(credits); i++) {
|
||||
for (uint i = 0; i < lengthof(credits); i++) {
|
||||
if (y >= 50 && y < (w->height - 40)) {
|
||||
DoDrawString(credits[i], 10, y, TC_BLACK);
|
||||
}
|
||||
|
@ -292,6 +283,7 @@ static void AboutWindowProc(Window *w, WindowEvent *e)
|
|||
DoDrawStringCentered(210, w->height - 25, "Website: http://www.openttd.org", TC_BLACK);
|
||||
DrawStringCentered(210, w->height - 15, STR_00BA_COPYRIGHT_OPENTTD, TC_FROMSTRING);
|
||||
} break;
|
||||
|
||||
case WE_TICK: // Timer to scroll the text and adjust the new top
|
||||
if (--WP(w, scroller_d).counter == 0) {
|
||||
WP(w, scroller_d).counter = 5;
|
||||
|
@ -344,7 +336,6 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e)
|
|||
{
|
||||
switch (e->event) {
|
||||
case WE_PAINT: {
|
||||
int x,y;
|
||||
int i, count;
|
||||
|
||||
DrawWindowWidgets(w);
|
||||
|
@ -352,8 +343,8 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e)
|
|||
WP(w, tree_d).base = i = _tree_base_by_landscape[_opt.landscape];
|
||||
WP(w, tree_d).count = count = _tree_count_by_landscape[_opt.landscape];
|
||||
|
||||
x = 18;
|
||||
y = 54;
|
||||
int x = 18;
|
||||
int y = 54;
|
||||
do {
|
||||
DrawSprite(_tree_sprites[i].sprite, _tree_sprites[i].pal, x, y);
|
||||
x += 35;
|
||||
|
@ -377,13 +368,15 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e)
|
|||
case 11:case 12: case 13: case 14:
|
||||
if (wid - 3 >= WP(w, tree_d).count) break;
|
||||
|
||||
if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, VHM_RECT, NULL))
|
||||
if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, VHM_RECT, NULL)) {
|
||||
_tree_to_plant = WP(w, tree_d).base + wid - 3;
|
||||
}
|
||||
break;
|
||||
|
||||
case 15: // tree of random type.
|
||||
if (HandlePlacePushButton(w, 15, SPR_CURSOR_TREE, VHM_RECT, NULL))
|
||||
if (HandlePlacePushButton(w, 15, SPR_CURSOR_TREE, VHM_RECT, NULL)) {
|
||||
_tree_to_plant = -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 16: // place trees randomly over the landscape
|
||||
|
@ -530,12 +523,13 @@ static void ErrmsgWndProc(Window *w, WindowEvent *e)
|
|||
(_errmsg_message_1 == INVALID_STRING_ID ? 25 : 15),
|
||||
_errmsg_message_2,
|
||||
w->width - 2);
|
||||
if (_errmsg_message_1 != INVALID_STRING_ID)
|
||||
if (_errmsg_message_1 != INVALID_STRING_ID) {
|
||||
DrawStringMultiCenter(
|
||||
120,
|
||||
30,
|
||||
_errmsg_message_1,
|
||||
w->width - 2);
|
||||
}
|
||||
} else {
|
||||
const Player *p = GetPlayer((PlayerID)GetDParamX(_errmsg_decode_params,2));
|
||||
DrawPlayerFace(p->face, p->player_color, 2, 16);
|
||||
|
@ -545,13 +539,14 @@ static void ErrmsgWndProc(Window *w, WindowEvent *e)
|
|||
(_errmsg_message_1 == INVALID_STRING_ID ? 65 : 45),
|
||||
_errmsg_message_2,
|
||||
w->width - 2);
|
||||
if (_errmsg_message_1 != INVALID_STRING_ID)
|
||||
if (_errmsg_message_1 != INVALID_STRING_ID) {
|
||||
DrawStringMultiCenter(
|
||||
214,
|
||||
90,
|
||||
_errmsg_message_1,
|
||||
w->width - 2);
|
||||
}
|
||||
}
|
||||
|
||||
/* Switch back to the normal text ref. stack for NewGRF texts */
|
||||
SwitchToNormalRefStack();
|
||||
|
@ -588,8 +583,7 @@ void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
|
|||
|
||||
DeleteWindowById(WC_ERRMSG, 0);
|
||||
|
||||
//assert(msg_2);
|
||||
if (msg_2 == 0) msg_2 = STR_EMPTY;
|
||||
if (msg_2 == STR_NULL) msg_2 = STR_EMPTY;
|
||||
|
||||
_errmsg_message_1 = msg_1;
|
||||
_errmsg_message_2 = msg_2;
|
||||
|
@ -598,7 +592,6 @@ void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
|
|||
if (!_errmsg_duration) return;
|
||||
|
||||
if (_errmsg_message_1 != STR_013B_OWNED_BY || GetDParamX(_errmsg_decode_params,2) >= 8) {
|
||||
|
||||
if ((x | y) != 0) {
|
||||
pt = RemapCoords2(x, y);
|
||||
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
|
||||
|
@ -699,17 +692,15 @@ static const Widget _tooltips_widgets[] = {
|
|||
static void TooltipsWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch (e->event) {
|
||||
case WE_PAINT: {
|
||||
uint arg;
|
||||
case WE_PAINT:
|
||||
GfxFillRect(0, 0, w->width - 1, w->height - 1, 0);
|
||||
GfxFillRect(1, 1, w->width - 2, w->height - 2, 0x44);
|
||||
|
||||
for (arg = 0; arg < WP(w, tooltips_d).paramcount; arg++) {
|
||||
for (uint arg = 0; arg < WP(w, tooltips_d).paramcount; arg++) {
|
||||
SetDParam(arg, WP(w, tooltips_d).params[arg]);
|
||||
}
|
||||
DrawStringMultiCenter((w->width >> 1), (w->height >> 1) - 5, WP(w, tooltips_d).string_id, w->width - 2);
|
||||
break;
|
||||
}
|
||||
|
||||
case WE_MOUSELOOP:
|
||||
/* We can show tooltips while dragging tools. These are shown as long as
|
||||
|
@ -731,21 +722,16 @@ static void TooltipsWndProc(Window *w, WindowEvent *e)
|
|||
* added to a tooltip; currently only supports parameters of {NUM} (integer) */
|
||||
void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[])
|
||||
{
|
||||
char buffer[512];
|
||||
Dimension br;
|
||||
Window *w;
|
||||
uint i;
|
||||
int x, y;
|
||||
|
||||
DeleteWindowById(WC_TOOLTIPS, 0);
|
||||
|
||||
/* We only show measurement tooltips with patch setting on */
|
||||
if (str == STR_NULL || (paramcount != 0 && !_patches.measure_tooltip)) return;
|
||||
|
||||
for (i = 0; i != paramcount; i++) SetDParam(i, params[i]);
|
||||
for (uint i = 0; i != paramcount; i++) SetDParam(i, params[i]);
|
||||
char buffer[512];
|
||||
GetString(buffer, str, lastof(buffer));
|
||||
|
||||
br = GetStringBoundingBox(buffer);
|
||||
Dimension br = GetStringBoundingBox(buffer);
|
||||
br.width += 6; br.height += 4; // increase slightly to have some space around the box
|
||||
|
||||
/* Cut tooltip length to 200 pixels max, wrap to new line if longer */
|
||||
|
@ -757,11 +743,11 @@ void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[
|
|||
/* Correctly position the tooltip position, watch out for window and cursor size
|
||||
* Clamp value to below main toolbar and above statusbar. If tooltip would
|
||||
* go below window, flip it so it is shown above the cursor */
|
||||
y = Clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12);
|
||||
int y = Clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12);
|
||||
if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5;
|
||||
x = Clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width);
|
||||
int x = Clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width);
|
||||
|
||||
w = AllocateWindow(x, y, br.width, br.height, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets);
|
||||
Window *w = AllocateWindow(x, y, br.width, br.height, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets);
|
||||
|
||||
WP(w, tooltips_d).string_id = str;
|
||||
assert(sizeof(WP(w, tooltips_d).params[0]) == sizeof(params[0]));
|
||||
|
@ -863,14 +849,12 @@ void SetHScrollCount(Window *w, int num)
|
|||
static void DelChar(Textbuf *tb, bool backspace)
|
||||
{
|
||||
WChar c;
|
||||
uint width;
|
||||
size_t len;
|
||||
char *s = tb->buf + tb->caretpos;
|
||||
|
||||
if (backspace) s = Utf8PrevChar(s);
|
||||
|
||||
len = Utf8Decode(&c, s);
|
||||
width = GetCharacterWidth(FS_NORMAL, c);
|
||||
size_t len = Utf8Decode(&c, s);
|
||||
uint width = GetCharacterWidth(FS_NORMAL, c);
|
||||
|
||||
tb->width -= width;
|
||||
if (backspace) {
|
||||
|
@ -960,6 +944,7 @@ bool MoveTextBufferPos(Textbuf *tb, int navmode)
|
|||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case WKC_RIGHT:
|
||||
if (tb->caretpos < tb->length) {
|
||||
WChar c;
|
||||
|
@ -970,10 +955,12 @@ bool MoveTextBufferPos(Textbuf *tb, int navmode)
|
|||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case WKC_HOME:
|
||||
tb->caretpos = 0;
|
||||
tb->caretxoffs = 0;
|
||||
return true;
|
||||
|
||||
case WKC_END:
|
||||
tb->caretpos = tb->length;
|
||||
tb->caretxoffs = tb->width;
|
||||
|
@ -1030,28 +1017,29 @@ int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *e)
|
|||
|
||||
switch (e->we.keypress.keycode) {
|
||||
case WKC_ESC: return 2;
|
||||
|
||||
case WKC_RETURN: case WKC_NUM_ENTER: return 1;
|
||||
|
||||
case (WKC_CTRL | 'V'):
|
||||
if (InsertTextBufferClipboard(&string->text))
|
||||
w->InvalidateWidget(wid);
|
||||
if (InsertTextBufferClipboard(&string->text)) w->InvalidateWidget(wid);
|
||||
break;
|
||||
|
||||
case (WKC_CTRL | 'U'):
|
||||
DeleteTextBufferAll(&string->text);
|
||||
w->InvalidateWidget(wid);
|
||||
break;
|
||||
|
||||
case WKC_BACKSPACE: case WKC_DELETE:
|
||||
if (DeleteTextBufferChar(&string->text, e->we.keypress.keycode))
|
||||
w->InvalidateWidget(wid);
|
||||
if (DeleteTextBufferChar(&string->text, e->we.keypress.keycode)) w->InvalidateWidget(wid);
|
||||
break;
|
||||
|
||||
case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
|
||||
if (MoveTextBufferPos(&string->text, e->we.keypress.keycode))
|
||||
w->InvalidateWidget(wid);
|
||||
if (MoveTextBufferPos(&string->text, e->we.keypress.keycode)) w->InvalidateWidget(wid);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (IsValidChar(e->we.keypress.key, string->afilter)) {
|
||||
if (InsertTextBufferChar(&string->text, e->we.keypress.key)) {
|
||||
w->InvalidateWidget(wid);
|
||||
}
|
||||
if (InsertTextBufferChar(&string->text, e->we.keypress.key)) w->InvalidateWidget(wid);
|
||||
} else { // key wasn't caught. Continue only if standard entry specified
|
||||
e->we.keypress.cont = (string->afilter == CS_ALPHANUMERAL);
|
||||
}
|
||||
|
@ -1093,8 +1081,9 @@ void DrawEditBox(Window *w, querystr_d *string, int wid)
|
|||
wi->left + 4,
|
||||
wi->top + 1,
|
||||
wi->right - wi->left - 4,
|
||||
wi->bottom - wi->top - 1)
|
||||
) return;
|
||||
wi->bottom - wi->top - 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
old_dpi = _cur_dpi;
|
||||
_cur_dpi = &dpi;
|
||||
|
@ -1222,7 +1211,6 @@ char _orig_str_buf[lengthof(_edit_str_buf)];
|
|||
* @param afilter filters out unwanted character input */
|
||||
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter)
|
||||
{
|
||||
Window *w;
|
||||
uint realmaxlen = maxlen & ~0x1000;
|
||||
|
||||
assert(realmaxlen < lengthof(_edit_str_buf));
|
||||
|
@ -1230,7 +1218,7 @@ void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth,
|
|||
DeleteWindowById(WC_QUERY_STRING, 0);
|
||||
DeleteWindowById(WC_SAVELOAD, 0);
|
||||
|
||||
w = AllocateWindowDesc(&_query_string_desc);
|
||||
Window *w = AllocateWindowDesc(&_query_string_desc);
|
||||
w->parent = parent;
|
||||
|
||||
GetString(_edit_str_buf, str, lastof(_edit_str_buf));
|
||||
|
@ -1601,22 +1589,25 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
|
|||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_MOUSELOOP:
|
||||
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
|
||||
HandleEditBox(w, &WP(w, querystr_d), 10);
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_KEYPRESS:
|
||||
if (e->we.keypress.keycode == WKC_ESC) {
|
||||
DeleteWindow(w);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) {
|
||||
if (HandleEditBoxKey(w, &WP(w, querystr_d), 10, e) == 1) // Press Enter
|
||||
if ((_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) &&
|
||||
HandleEditBoxKey(w, &WP(w, querystr_d), 10, e) == 1) { // Press Enter
|
||||
w->HandleButtonClick(12);
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_TIMEOUT:
|
||||
/* This test protects against using widgets 11 and 12 which are only available
|
||||
* in those two saveload mode */
|
||||
|
@ -1641,6 +1632,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
|
|||
if (_game_mode == GM_EDITOR) StartupEngines();
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_DESTROY:
|
||||
/* pause is only used in single-player, non-editor mode, non menu mode */
|
||||
if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
|
||||
|
@ -1649,6 +1641,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
|
|||
FiosFreeSavegameList();
|
||||
ClrBit(_no_scroll, SCROLL_SAVE);
|
||||
break;
|
||||
|
||||
case WE_RESIZE: {
|
||||
/* Widget 2 and 3 have to go with halve speed, make it so obiwan */
|
||||
uint diff = e->we.sizing.diff.x / 2;
|
||||
|
|
|
@ -306,7 +306,6 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
|
|||
case NGWW_INFO - NGWW_NAME: DrawSortButtonState(w, NGWW_INFO, arrow); break;
|
||||
}
|
||||
|
||||
{ // draw list of games
|
||||
uint16 y = NET_PRC__OFFSET_TOP_WIDGET + 3;
|
||||
int32 n = 0;
|
||||
int32 pos = w->vscroll.pos;
|
||||
|
@ -347,7 +346,6 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
|
|||
y += NET_PRC__SIZE_OF_ROW;
|
||||
if (++n == w->vscroll.cap) break; // max number of games in the window
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw the right menu */
|
||||
GfxFillRect(w->widget[NGWW_DETAILS].left + 1, 43, w->widget[NGWW_DETAILS].right - 1, 92, 157);
|
||||
|
@ -429,12 +427,15 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
|
|||
case NGWW_PLAYER:
|
||||
ShowOnScreenKeyboard(w, &WP(w, network_ql_d).q, NGWW_PLAYER, 0, 0);
|
||||
break;
|
||||
|
||||
case NGWW_CANCEL: // Cancel button
|
||||
DeleteWindowById(WC_NETWORK_WINDOW, 0);
|
||||
break;
|
||||
|
||||
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
|
||||
case NGWW_CLIENTS: // Sort by connected clients
|
||||
case NGWW_INFO: // Connectivity (green dot)
|
||||
|
@ -446,6 +447,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
|
|||
_ng_sorting.criteria = ld->sort_type;
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
|
||||
case NGWW_MATRIX: { // Matrix to show networkgames
|
||||
NetworkGameList *cur_item;
|
||||
uint32 id_v = (e->we.click.pt.y - NET_PRC__OFFSET_TOP_WIDGET) / NET_PRC__SIZE_OF_ROW;
|
||||
|
@ -459,23 +461,27 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
|
|||
nd->server = cur_item;
|
||||
SetWindowDirty(w);
|
||||
} break;
|
||||
|
||||
case NGWW_FIND: // Find server automatically
|
||||
switch (_network_lan_internet) {
|
||||
case 0: NetworkUDPSearchGame(); break;
|
||||
case 1: NetworkUDPQueryMasterServer(); break;
|
||||
}
|
||||
break;
|
||||
case NGWW_ADD: { // Add a server
|
||||
|
||||
case NGWW_ADD: // Add a server
|
||||
ShowQueryString(
|
||||
BindCString(_network_default_ip),
|
||||
STR_NETWORK_ENTER_IP,
|
||||
31 | 0x1000, // maximum number of characters OR
|
||||
250, // characters up to this width pixels, whichever is satisfied first
|
||||
w, CS_ALPHANUMERAL);
|
||||
} break;
|
||||
break;
|
||||
|
||||
case NGWW_START: // Start server
|
||||
ShowNetworkStartServerWindow();
|
||||
break;
|
||||
|
||||
case NGWW_JOIN: // Join Game
|
||||
if (nd->server != NULL) {
|
||||
snprintf(_network_last_host, sizeof(_network_last_host), "%s", inet_ntoa(*(struct in_addr *)&nd->server->ip));
|
||||
|
@ -483,21 +489,23 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
|
|||
ShowNetworkLobbyWindow(nd->server);
|
||||
}
|
||||
break;
|
||||
|
||||
case NGWW_REFRESH: // Refresh
|
||||
if (nd->server != NULL)
|
||||
NetworkUDPQueryServer(nd->server->info.hostname, nd->server->port);
|
||||
if (nd->server != NULL) NetworkUDPQueryServer(nd->server->info.hostname, nd->server->port);
|
||||
break;
|
||||
|
||||
case NGWW_NEWGRF: // NewGRF Settings
|
||||
if (nd->server != NULL) ShowNewGRFSettings(false, false, false, &nd->server->info.grfconfig);
|
||||
break;
|
||||
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_DROPDOWN_SELECT: // we have selected a dropdown item in the list
|
||||
switch (e->we.dropdown.button) {
|
||||
case NGWW_CONN_BTN:
|
||||
_network_lan_internet = e->we.dropdown.index;
|
||||
break;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
|
@ -617,7 +625,6 @@ static const WindowDesc _network_game_window_desc = {
|
|||
void ShowNetworkGameWindow()
|
||||
{
|
||||
static bool first = true;
|
||||
Window *w;
|
||||
DeleteWindowById(WC_NETWORK_WINDOW, 0);
|
||||
|
||||
/* Only show once */
|
||||
|
@ -634,7 +641,7 @@ void ShowNetworkGameWindow()
|
|||
_ng_sorting.order = 0; // sort ascending by default
|
||||
}
|
||||
|
||||
w = AllocateWindowDesc(&_network_game_window_desc);
|
||||
Window *w = AllocateWindowDesc(&_network_game_window_desc);
|
||||
if (w != NULL) {
|
||||
querystr_d *querystr = &WP(w, network_ql_d).q;
|
||||
|
||||
|
@ -739,9 +746,11 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
|
|||
case NSSW_CANCEL: // Cancel button
|
||||
ShowNetworkGameWindow();
|
||||
break;
|
||||
|
||||
case NSSW_GAMENAME:
|
||||
ShowOnScreenKeyboard(w, &WP(w, network_ql_d).q, NSSW_GAMENAME, 0, 0);
|
||||
break;
|
||||
|
||||
case NSSW_SETPWD: // Set password button
|
||||
nd->widget_id = NSSW_SETPWD;
|
||||
ShowQueryString(BindCString(_network_server_password), STR_NETWORK_SET_PASSWORD, 20, 250, w, CS_ALPHANUMERAL);
|
||||
|
@ -756,9 +765,11 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
|
|||
nd->map = (y == 0) ? NULL : _fios_list + y - 1;
|
||||
SetWindowDirty(w);
|
||||
} break;
|
||||
|
||||
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
|
||||
case NSSW_COMPANIES_BTND: case NSSW_COMPANIES_BTNU: // Click on up/down button for number of companies
|
||||
case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU: // Click on up/down button for number of spectators
|
||||
|
@ -781,21 +792,25 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
|
|||
}
|
||||
_left_button_clicked = false;
|
||||
break;
|
||||
|
||||
case NSSW_CLIENTS_TXT: // Click on number of players
|
||||
nd->widget_id = NSSW_CLIENTS_TXT;
|
||||
SetDParam(0, _network_game_info.clients_max);
|
||||
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_CLIENTS, 3, 50, w, CS_NUMERAL);
|
||||
break;
|
||||
|
||||
case NSSW_COMPANIES_TXT: // Click on number of companies
|
||||
nd->widget_id = NSSW_COMPANIES_TXT;
|
||||
SetDParam(0, _network_game_info.companies_max);
|
||||
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_NETWORK_NUMBER_OF_COMPANIES, 3, 50, w, CS_NUMERAL);
|
||||
break;
|
||||
|
||||
case NSSW_SPECTATORS_TXT: // Click on number of spectators
|
||||
nd->widget_id = NSSW_SPECTATORS_TXT;
|
||||
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_BTN: { // Language
|
||||
uint sel = 0;
|
||||
for (uint i = 0; i < lengthof(_language_dropdown) - 1; i++) {
|
||||
|
@ -805,8 +820,8 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
|
|||
}
|
||||
}
|
||||
ShowDropDownMenu(w, _language_dropdown, sel, NSSW_LANGUAGE_BTN, 0, 0);
|
||||
break;
|
||||
}
|
||||
} break;
|
||||
|
||||
case NSSW_START: // Start game
|
||||
_is_network_server = true;
|
||||
|
||||
|
@ -825,6 +840,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NSSW_LOAD: // Load game
|
||||
_is_network_server = true;
|
||||
/* XXX - WC_NETWORK_WINDOW (this window) should stay, but if it stays, it gets
|
||||
|
@ -940,10 +956,9 @@ static const WindowDesc _network_start_server_window_desc = {
|
|||
|
||||
static void ShowNetworkStartServerWindow()
|
||||
{
|
||||
Window *w;
|
||||
DeleteWindowById(WC_NETWORK_WINDOW, 0);
|
||||
|
||||
w = AllocateWindowDesc(&_network_start_server_window_desc);
|
||||
Window *w = AllocateWindowDesc(&_network_start_server_window_desc);
|
||||
ttd_strlcpy(_edit_str_net_buf, _network_server_name, lengthof(_edit_str_net_buf));
|
||||
|
||||
_saveload_mode = SLD_NEW_GAME;
|
||||
|
@ -957,11 +972,8 @@ static void ShowNetworkStartServerWindow()
|
|||
|
||||
static PlayerID NetworkLobbyFindCompanyIndex(byte pos)
|
||||
{
|
||||
PlayerID i;
|
||||
|
||||
/* Scroll through all _network_player_info and get the 'pos' item
|
||||
that is not empty */
|
||||
for (i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
|
||||
/* Scroll through all _network_player_info and get the 'pos' item that is not empty */
|
||||
for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
|
||||
if (_network_player_info[i].company_name[0] != '\0') {
|
||||
if (pos-- == 0) return i;
|
||||
}
|
||||
|
@ -1101,6 +1113,7 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
|
|||
case NLWW_CANCEL: // Cancel button
|
||||
ShowNetworkGameWindow();
|
||||
break;
|
||||
|
||||
case NLWW_MATRIX: { // Company list
|
||||
uint32 id_v = (e->we.click.pt.y - NET_PRC__OFFSET_TOP_WIDGET_COMPANY) / NET_PRC__SIZE_OF_ROW;
|
||||
|
||||
|
@ -1110,24 +1123,29 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
|
|||
nd->company = (id_v >= nd->server->info.companies_on) ? INVALID_PLAYER : NetworkLobbyFindCompanyIndex(id_v);
|
||||
SetWindowDirty(w);
|
||||
} break;
|
||||
|
||||
case NLWW_JOIN: // Join company
|
||||
/* Button can be clicked only when it is enabled */
|
||||
_network_playas = nd->company;
|
||||
NetworkClientConnectGame(_network_last_host, _network_last_port);
|
||||
break;
|
||||
|
||||
case NLWW_NEW: // New company
|
||||
_network_playas = PLAYER_NEW_COMPANY;
|
||||
NetworkClientConnectGame(_network_last_host, _network_last_port);
|
||||
break;
|
||||
|
||||
case NLWW_SPECTATE: // Spectate game
|
||||
_network_playas = PLAYER_SPECTATOR;
|
||||
NetworkClientConnectGame(_network_last_host, _network_last_port);
|
||||
break;
|
||||
|
||||
case NLWW_REFRESH: // Refresh
|
||||
NetworkTCPQueryServer(_network_last_host, _network_last_port); // company info
|
||||
NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data
|
||||
break;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_MESSAGE:
|
||||
SetWindowDirty(w);
|
||||
|
@ -1171,13 +1189,12 @@ static const WindowDesc _network_lobby_window_desc = {
|
|||
* @param ngl Selected game pointer which is passed to the new window */
|
||||
static void ShowNetworkLobbyWindow(NetworkGameList *ngl)
|
||||
{
|
||||
Window *w;
|
||||
DeleteWindowById(WC_NETWORK_WINDOW, 0);
|
||||
|
||||
NetworkTCPQueryServer(_network_last_host, _network_last_port); // company info
|
||||
NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data
|
||||
|
||||
w = AllocateWindowDesc(&_network_lobby_window_desc);
|
||||
Window *w = AllocateWindowDesc(&_network_lobby_window_desc);
|
||||
if (w != NULL) {
|
||||
WP(w, network_ql_d).n.server = ngl;
|
||||
strcpy(_edit_str_net_buf, "");
|
||||
|
@ -1254,37 +1271,40 @@ static void ClientList_Kick(byte client_no)
|
|||
|
||||
static void ClientList_Ban(byte client_no)
|
||||
{
|
||||
uint i;
|
||||
uint32 ip = NetworkFindClientInfo(client_no)->client_ip;
|
||||
|
||||
for (i = 0; i < lengthof(_network_ban_list); i++) {
|
||||
for (uint i = 0; i < lengthof(_network_ban_list); i++) {
|
||||
if (_network_ban_list[i] == NULL) {
|
||||
_network_ban_list[i] = strdup(inet_ntoa(*(struct in_addr *)&ip));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (client_no < MAX_PLAYERS)
|
||||
if (client_no < MAX_PLAYERS) {
|
||||
SEND_COMMAND(PACKET_SERVER_ERROR)(DEREF_CLIENT(client_no), NETWORK_ERROR_KICKED);
|
||||
}
|
||||
}
|
||||
|
||||
static void ClientList_GiveMoney(byte client_no)
|
||||
{
|
||||
if (NetworkFindClientInfo(client_no) != NULL)
|
||||
if (NetworkFindClientInfo(client_no) != NULL) {
|
||||
ShowNetworkGiveMoneyWindow(NetworkFindClientInfo(client_no)->client_playas);
|
||||
}
|
||||
}
|
||||
|
||||
static void ClientList_SpeakToClient(byte client_no)
|
||||
{
|
||||
if (NetworkFindClientInfo(client_no) != NULL)
|
||||
if (NetworkFindClientInfo(client_no) != NULL) {
|
||||
ShowNetworkChatQueryWindow(DESTTYPE_CLIENT, NetworkFindClientInfo(client_no)->client_index);
|
||||
}
|
||||
}
|
||||
|
||||
static void ClientList_SpeakToCompany(byte client_no)
|
||||
{
|
||||
if (NetworkFindClientInfo(client_no) != NULL)
|
||||
if (NetworkFindClientInfo(client_no) != NULL) {
|
||||
ShowNetworkChatQueryWindow(DESTTYPE_TEAM, NetworkFindClientInfo(client_no)->client_playas);
|
||||
}
|
||||
}
|
||||
|
||||
static void ClientList_SpeakToAll(byte client_no)
|
||||
{
|
||||
|
@ -1293,34 +1313,38 @@ static void ClientList_SpeakToAll(byte client_no)
|
|||
|
||||
static void ClientList_None(byte client_no)
|
||||
{
|
||||
// No action ;)
|
||||
/* No action ;) */
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Help, a action is clicked! What do we do?
|
||||
/**
|
||||
* An action is clicked! What do we do?
|
||||
*/
|
||||
static void HandleClientListPopupClick(byte index, byte clientno)
|
||||
{
|
||||
// A click on the Popup of the ClientList.. handle the command
|
||||
/* A click on the Popup of the ClientList.. handle the command */
|
||||
if (index < MAX_CLIENTLIST_ACTION && _clientlist_proc[index] != NULL) {
|
||||
_clientlist_proc[index](clientno);
|
||||
}
|
||||
}
|
||||
|
||||
// Finds the amount of clients and set the height correct
|
||||
/**
|
||||
* Finds the amount of clients and set the height correct
|
||||
*/
|
||||
static bool CheckClientListHeight(Window *w)
|
||||
{
|
||||
int num = 0;
|
||||
const NetworkClientInfo *ci;
|
||||
|
||||
// Should be replaced with a loop through all clients
|
||||
/* Should be replaced with a loop through all clients */
|
||||
FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
|
||||
num++;
|
||||
}
|
||||
|
||||
num *= CLNWND_ROWSIZE;
|
||||
|
||||
// If height is changed
|
||||
/* If height is changed */
|
||||
if (w->height != CLNWND_OFFSET + num + 1) {
|
||||
// XXX - magic unfortunately; (num + 2) has to be one bigger than heigh (num + 1)
|
||||
SetWindowDirty(w);
|
||||
|
@ -1332,13 +1356,15 @@ static bool CheckClientListHeight(Window *w)
|
|||
return true;
|
||||
}
|
||||
|
||||
// Finds the amount of actions in the popup and set the height correct
|
||||
/**
|
||||
* Finds the amount of actions in the popup and set the height correct
|
||||
*/
|
||||
static uint ClientListPopupHeight()
|
||||
{
|
||||
int i, num = 0;
|
||||
int num = 0;
|
||||
|
||||
// Find the amount of actions
|
||||
for (i = 0; i < MAX_CLIENTLIST_ACTION; i++) {
|
||||
for (int i = 0; i < MAX_CLIENTLIST_ACTION; i++) {
|
||||
if (_clientlist_action[i][0] == '\0') continue;
|
||||
if (_clientlist_proc[i] == NULL) continue;
|
||||
num++;
|
||||
|
@ -1349,21 +1375,25 @@ static uint ClientListPopupHeight()
|
|||
return num + 1;
|
||||
}
|
||||
|
||||
// Show the popup (action list)
|
||||
/**
|
||||
* Show the popup (action list)
|
||||
*/
|
||||
static Window *PopupClientList(Window *w, int client_no, int x, int y)
|
||||
{
|
||||
int i, h;
|
||||
int i;
|
||||
const NetworkClientInfo *ci;
|
||||
DeleteWindowById(WC_TOOLBAR_MENU, 0);
|
||||
|
||||
// Clean the current actions
|
||||
/* Clean the current actions */
|
||||
for (i = 0; i < MAX_CLIENTLIST_ACTION; i++) {
|
||||
_clientlist_action[i][0] = '\0';
|
||||
_clientlist_proc[i] = NULL;
|
||||
}
|
||||
|
||||
// Fill the actions this client has
|
||||
// Watch is, max 50 chars long!
|
||||
/*
|
||||
* Fill the actions this client has.
|
||||
* Watch is, max 50 chars long!
|
||||
*/
|
||||
|
||||
ci = NetworkFindClientInfo(client_no);
|
||||
if (ci == NULL) return NULL;
|
||||
|
@ -1389,7 +1419,7 @@ static Window *PopupClientList(Window *w, int client_no, int x, int y)
|
|||
}
|
||||
}
|
||||
|
||||
// A server can kick clients (but not himself)
|
||||
/* A server can kick clients (but not himself) */
|
||||
if (_network_server && _network_own_client_index != ci->client_index) {
|
||||
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_KICK, lastof(_clientlist_action[i]));
|
||||
_clientlist_proc[i++] = &ClientList_Kick;
|
||||
|
@ -1404,9 +1434,9 @@ static Window *PopupClientList(Window *w, int client_no, int x, int y)
|
|||
}
|
||||
|
||||
/* Calculate the height */
|
||||
h = ClientListPopupHeight();
|
||||
int h = ClientListPopupHeight();
|
||||
|
||||
// Allocate the popup
|
||||
/* Allocate the popup */
|
||||
w = AllocateWindow(x, y, 150, h + 1, ClientListPopupWndProc, WC_TOOLBAR_MENU, _client_list_popup_widgets);
|
||||
w->widget[0].bottom = w->widget[0].top + h;
|
||||
w->widget[0].right = w->widget[0].left + 150;
|
||||
|
@ -1428,17 +1458,16 @@ static void ClientListPopupWndProc(Window *w, WindowEvent *e)
|
|||
{
|
||||
switch (e->event) {
|
||||
case WE_PAINT: {
|
||||
int i, y, sel;
|
||||
TextColour colour;
|
||||
DrawWindowWidgets(w);
|
||||
|
||||
// Draw the actions
|
||||
sel = WP(w, menu_d).sel_index;
|
||||
y = 1;
|
||||
for (i = 0; i < MAX_CLIENTLIST_ACTION; i++, y += CLNWND_ROWSIZE) {
|
||||
/* Draw the actions */
|
||||
int sel = WP(w, menu_d).sel_index;
|
||||
int y = 1;
|
||||
for (int i = 0; i < MAX_CLIENTLIST_ACTION; i++, y += CLNWND_ROWSIZE) {
|
||||
if (_clientlist_action[i][0] == '\0') continue;
|
||||
if (_clientlist_proc[i] == NULL) continue;
|
||||
|
||||
TextColour colour;
|
||||
if (sel-- == 0) { // Selected item, highlight it
|
||||
GfxFillRect(1, y, 150 - 2, y + CLNWND_ROWSIZE - 1, 0);
|
||||
colour = TC_WHITE;
|
||||
|
@ -1451,17 +1480,18 @@ static void ClientListPopupWndProc(Window *w, WindowEvent *e)
|
|||
} break;
|
||||
|
||||
case WE_POPUPMENU_SELECT: {
|
||||
// We selected an action
|
||||
/* We selected an action */
|
||||
int index = (e->we.popupmenu.pt.y - w->top) / CLNWND_ROWSIZE;
|
||||
|
||||
if (index >= 0 && e->we.popupmenu.pt.y >= w->top)
|
||||
if (index >= 0 && e->we.popupmenu.pt.y >= w->top) {
|
||||
HandleClientListPopupClick(index, WP(w, menu_d).main_button);
|
||||
}
|
||||
|
||||
DeleteWindowById(WC_TOOLBAR_MENU, 0);
|
||||
} break;
|
||||
|
||||
case WE_POPUPMENU_OVER: {
|
||||
// Our mouse hoovers over an action? Select it!
|
||||
/* Our mouse hoovers over an action? Select it! */
|
||||
int index = (e->we.popupmenu.pt.y - w->top) / CLNWND_ROWSIZE;
|
||||
|
||||
if (index == -1 || index == WP(w, menu_d).sel_index) return;
|
||||
|
@ -1469,27 +1499,28 @@ static void ClientListPopupWndProc(Window *w, WindowEvent *e)
|
|||
WP(w, menu_d).sel_index = index;
|
||||
SetWindowDirty(w);
|
||||
} break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Main handle for clientlist
|
||||
/**
|
||||
* Main handle for clientlist
|
||||
*/
|
||||
static void ClientListWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch (e->event) {
|
||||
case WE_PAINT: {
|
||||
NetworkClientInfo *ci;
|
||||
int y, i = 0;
|
||||
TextColour colour;
|
||||
int i = 0;
|
||||
|
||||
// Check if we need to reset the height
|
||||
/* Check if we need to reset the height */
|
||||
if (!CheckClientListHeight(w)) break;
|
||||
|
||||
DrawWindowWidgets(w);
|
||||
|
||||
y = CLNWND_OFFSET;
|
||||
int y = CLNWND_OFFSET;
|
||||
|
||||
FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
|
||||
TextColour colour;
|
||||
if (_selected_clientlist_item == i++) { // Selected item, highlight it
|
||||
GfxFillRect(1, y, 248, y + CLNWND_ROWSIZE - 1, 0);
|
||||
colour = TC_WHITE;
|
||||
|
@ -1503,7 +1534,7 @@ static void ClientListWndProc(Window *w, WindowEvent *e)
|
|||
DrawString(4, y, STR_NETWORK_CLIENT, colour);
|
||||
}
|
||||
|
||||
// Filter out spectators
|
||||
/* Filter out spectators */
|
||||
if (IsValidPlayer(ci->client_playas)) DrawPlayerIcon(ci->client_playas, 64, y + 1);
|
||||
|
||||
DoDrawString(ci->client_name, 81, y, colour);
|
||||
|
@ -1513,25 +1544,24 @@ static void ClientListWndProc(Window *w, WindowEvent *e)
|
|||
} break;
|
||||
|
||||
case WE_CLICK:
|
||||
// Show the popup with option
|
||||
/* Show the popup with option */
|
||||
if (_selected_clientlist_item != 255) {
|
||||
PopupClientList(w, _selected_clientlist_item, e->we.click.pt.x + w->left, e->we.click.pt.y + w->top);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case WE_MOUSEOVER:
|
||||
// -1 means we left the current window
|
||||
/* -1 means we left the current window */
|
||||
if (e->we.mouseover.pt.y == -1) {
|
||||
_selected_clientlist_y = 0;
|
||||
_selected_clientlist_item = 255;
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
}
|
||||
// It did not change.. no update!
|
||||
/* It did not change.. no update! */
|
||||
if (e->we.mouseover.pt.y == _selected_clientlist_y) break;
|
||||
|
||||
// Find the new selected item (if any)
|
||||
/* Find the new selected item (if any) */
|
||||
_selected_clientlist_y = e->we.mouseover.pt.y;
|
||||
if (e->we.mouseover.pt.y > CLNWND_OFFSET) {
|
||||
_selected_clientlist_item = (e->we.mouseover.pt.y - CLNWND_OFFSET) / CLNWND_ROWSIZE;
|
||||
|
@ -1539,12 +1569,12 @@ static void ClientListWndProc(Window *w, WindowEvent *e)
|
|||
_selected_clientlist_item = 255;
|
||||
}
|
||||
|
||||
// Repaint
|
||||
/* Repaint */
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
|
||||
case WE_DESTROY: case WE_CREATE:
|
||||
// When created or destroyed, data is reset
|
||||
/* When created or destroyed, data is reset */
|
||||
_selected_clientlist_item = 255;
|
||||
_selected_clientlist_y = 0;
|
||||
break;
|
||||
|
@ -1606,13 +1636,11 @@ static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e)
|
|||
} break;
|
||||
|
||||
case WE_CLICK:
|
||||
switch (e->we.click.widget) {
|
||||
case 2: /* Disconnect button */
|
||||
if (e->we.click.widget == 2) { //Disconnect button
|
||||
NetworkDisconnect();
|
||||
DeleteWindow(w);
|
||||
SwitchMode(SM_MENU);
|
||||
ShowNetworkGameWindow();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1645,9 +1673,8 @@ static const WindowDesc _network_join_status_window_desc = {
|
|||
|
||||
void ShowJoinStatusWindow()
|
||||
{
|
||||
Window *w;
|
||||
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
|
||||
w = AllocateWindowDesc(&_network_join_status_window_desc);
|
||||
Window *w = AllocateWindowDesc(&_network_join_status_window_desc);
|
||||
/* Parent the status window to the lobby */
|
||||
if (w != NULL) w->parent = FindWindowById(WC_NETWORK_WINDOW, 0);
|
||||
}
|
||||
|
@ -1877,14 +1904,12 @@ static const WindowDesc _chat_window_desc = {
|
|||
|
||||
void ShowNetworkChatQueryWindow(DestType type, int dest)
|
||||
{
|
||||
Window *w;
|
||||
|
||||
DeleteWindowById(WC_SEND_NETWORK_MSG, 0);
|
||||
|
||||
_edit_str_net_buf[0] = '\0';
|
||||
_chat_tab_completion_active = false;
|
||||
|
||||
w = AllocateWindowDesc(&_chat_window_desc);
|
||||
Window *w = AllocateWindowDesc(&_chat_window_desc);
|
||||
|
||||
w->LowerWidget(2);
|
||||
WP(w, chatquerystr_d).dtype = type;
|
||||
|
|
Loading…
Reference in New Issue