diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/autoreplace_gui.cpp | 2 | ||||
-rw-r--r-- | src/depot_gui.cpp | 6 | ||||
-rw-r--r-- | src/main_gui.cpp | 96 | ||||
-rw-r--r-- | src/misc_gui.cpp | 16 | ||||
-rw-r--r-- | src/network/network_gui.cpp | 14 | ||||
-rw-r--r-- | src/openttd.cpp | 4 | ||||
-rw-r--r-- | src/order_gui.cpp | 24 | ||||
-rw-r--r-- | src/settings_gui.cpp | 34 | ||||
-rw-r--r-- | src/smallmap_gui.cpp | 20 | ||||
-rw-r--r-- | src/timetable_gui.cpp | 16 | ||||
-rw-r--r-- | src/town_gui.cpp | 12 | ||||
-rw-r--r-- | src/viewport.cpp | 2 | ||||
-rw-r--r-- | src/widget.cpp | 62 | ||||
-rw-r--r-- | src/window.h | 2 |
14 files changed, 155 insertions, 155 deletions
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 38362f8f6..b25efa9ff 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -240,7 +240,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e) Player *p = GetPlayer(_local_player); EngineID selected_id[2]; - const GroupID selected_group = WP(w,replaceveh_d).sel_group; + const GroupID selected_group = WP(w, replaceveh_d).sel_group; selected_id[0] = WP(w, replaceveh_d).sel_engine[0]; selected_id[1] = WP(w, replaceveh_d).sel_engine[1]; diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 3e9cf359d..bb222baf2 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -171,7 +171,7 @@ static void DrawVehicleInDepot(Window *w, const Vehicle *v, int x, int y) switch (v->type) { case VEH_TRAIN: - DrawTrainImage(v, x + 21, sprite_y, w->hscroll.cap + 4, w->hscroll.pos, WP(w,depot_d).sel); + DrawTrainImage(v, x + 21, sprite_y, w->hscroll.cap + 4, w->hscroll.pos, WP(w, depot_d).sel); /* Number of wagons relative to a standard length wagon (rounded up) */ SetDParam(0, (v->u.rail.cached_total_length + 7) / 8); @@ -273,7 +273,7 @@ static void DrawDepotWindow(Window *w) const Vehicle *v = WP(w, depot_d).wagon_list[num - WP(w, depot_d).engine_count]; const Vehicle *u; - DrawTrainImage(v, x + 50, y, w->hscroll.cap - 29, 0, WP(w,depot_d).sel); + DrawTrainImage(v, x + 50, y, w->hscroll.cap - 29, 0, WP(w, depot_d).sel); DrawString(x, y + 2, STR_8816, TC_FROMSTRING); /*Draw the train counter */ @@ -429,7 +429,7 @@ static void DepotClick(Window *w, int x, int y) VehicleID sel = WP(w, depot_d).sel; if (WP(w, depot_d).type == VEH_TRAIN && sel != INVALID_VEHICLE) { - WP(w,depot_d).sel = INVALID_VEHICLE; + WP(w, depot_d).sel = INVALID_VEHICLE; TrainDepotMoveVehicle(v, sel, gdvp.head); } else if (v != NULL) { int image = v->GetImage(DIR_W); diff --git a/src/main_gui.cpp b/src/main_gui.cpp index f1d8d447d..d85ec6369 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -468,7 +468,7 @@ static void MenuWndProc(Window *w, WindowEvent *e) case WE_DESTROY: { Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0); - v->RaiseWidget(WP(w,menu_d).main_button); + v->RaiseWidget(WP(w, menu_d).main_button); SetWindowDirty(v); return; } @@ -480,11 +480,11 @@ static void MenuWndProc(Window *w, WindowEvent *e) if (index < 0) { Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); - if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button) - index = WP(w,menu_d).sel_index; + if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button) + index = WP(w, menu_d).sel_index; } - action_id = WP(w,menu_d).action_id; + action_id = WP(w, menu_d).action_id; DeleteWindow(w); if (index >= 0) { @@ -498,9 +498,9 @@ static void MenuWndProc(Window *w, WindowEvent *e) case WE_POPUPMENU_OVER: { int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); - if (index == -1 || index == WP(w,menu_d).sel_index) return; + if (index == -1 || index == WP(w, menu_d).sel_index) return; - WP(w,menu_d).sel_index = index; + WP(w, menu_d).sel_index = index; SetWindowDirty(w); return; } @@ -538,10 +538,10 @@ static void UpdatePlayerMenuHeight(Window *w) byte num = ActivePlayerCount(); /* Increase one to fit in PlayerList in the menu when in network */ - if (_networking && WP(w,menu_d).main_button == 9) num++; + if (_networking && WP(w, menu_d).main_button == 9) num++; - if (WP(w,menu_d).item_count != num) { - WP(w,menu_d).item_count = num; + if (WP(w, menu_d).item_count != num) { + WP(w, menu_d).item_count = num; SetWindowDirty(w); num = num * 10 + 2; w->height = num; @@ -565,11 +565,11 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e) x = 1; y = 1; - sel = WP(w,menu_d).sel_index; - chk = WP(w,menu_d).checked_items; // let this mean gray items. + sel = WP(w, menu_d).sel_index; + chk = WP(w, menu_d).checked_items; // let this mean gray items. /* 9 = playerlist */ - if (_networking && WP(w,menu_d).main_button == 9) { + if (_networking && WP(w, menu_d).main_button == 9) { if (sel == 0) { GfxFillRect(x, y, x + 238, y + 9, 0); } @@ -603,18 +603,18 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e) case WE_DESTROY: { Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0); - v->RaiseWidget(WP(w,menu_d).main_button); + v->RaiseWidget(WP(w, menu_d).main_button); SetWindowDirty(v); return; } case WE_POPUPMENU_SELECT: { int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); - int action_id = WP(w,menu_d).action_id; + int action_id = WP(w, menu_d).action_id; /* We have a new entry at the top of the list of menu 9 when networking * so keep that in count */ - if (_networking && WP(w,menu_d).main_button == 9) { + if (_networking && WP(w, menu_d).main_button == 9) { if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1; } else { index = GetPlayerIndexFromMenu(index); @@ -622,8 +622,8 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e) if (index < 0) { Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); - if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button) - index = WP(w,menu_d).sel_index; + if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button) + index = WP(w, menu_d).sel_index; } DeleteWindow(w); @@ -641,15 +641,15 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e) /* We have a new entry at the top of the list of menu 9 when networking * so keep that in count */ - if (_networking && WP(w,menu_d).main_button == 9) { + if (_networking && WP(w, menu_d).main_button == 9) { if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1; } else { index = GetPlayerIndexFromMenu(index); } - if (index == -1 || index == WP(w,menu_d).sel_index) return; + if (index == -1 || index == WP(w, menu_d).sel_index) return; - WP(w,menu_d).sel_index = index; + WP(w, menu_d).sel_index = index; SetWindowDirty(w); return; } @@ -722,13 +722,13 @@ static Window *PopupMainToolbMenu(Window *w, uint16 parent_button, StringID base w->widget[0].bottom = item_count * 10 + 1; w->flags4 &= ~WF_WHITE_BORDER_MASK; - WP(w,menu_d).item_count = item_count; - WP(w,menu_d).sel_index = 0; - WP(w,menu_d).main_button = GB(parent_button, 0, 8); - WP(w,menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button; - WP(w,menu_d).string_id = base_string; - WP(w,menu_d).checked_items = 0; - WP(w,menu_d).disabled_items = disabled_mask; + WP(w, menu_d).item_count = item_count; + WP(w, menu_d).sel_index = 0; + WP(w, menu_d).main_button = GB(parent_button, 0, 8); + WP(w, menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button; + WP(w, menu_d).string_id = base_string; + WP(w, menu_d).checked_items = 0; + WP(w, menu_d).disabled_items = disabled_mask; _popup_menu_active = true; @@ -746,20 +746,20 @@ static Window *PopupMainPlayerToolbMenu(Window *w, int main_button, int gray) DeleteWindowById(WC_TOOLBAR_MENU, 0); w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets); w->flags4 &= ~WF_WHITE_BORDER_MASK; - WP(w,menu_d).item_count = 0; - WP(w,menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0); + WP(w, menu_d).item_count = 0; + WP(w, menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0); if (_networking && main_button == 9) { if (_local_player != PLAYER_SPECTATOR) { - WP(w,menu_d).sel_index++; + WP(w, menu_d).sel_index++; } else { /* Select client list by default for spectators */ - WP(w,menu_d).sel_index = 0; + WP(w, menu_d).sel_index = 0; } } - WP(w,menu_d).action_id = main_button; - WP(w,menu_d).main_button = main_button; - WP(w,menu_d).checked_items = gray; - WP(w,menu_d).disabled_items = 0; + WP(w, menu_d).action_id = main_button; + WP(w, menu_d).main_button = main_button; + WP(w, menu_d).checked_items = gray; + WP(w, menu_d).disabled_items = 0; _popup_menu_active = true; SndPlayFx(SND_15_BEEP); return w; @@ -876,19 +876,19 @@ bool DoZoomInOutWindow(int how, Window *w) vp->virtual_width >>= 1; vp->virtual_height >>= 1; - WP(w,vp_d).scrollpos_x += vp->virtual_width >> 1; - WP(w,vp_d).scrollpos_y += vp->virtual_height >> 1; - WP(w,vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x; - WP(w,vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y; + WP(w, vp_d).scrollpos_x += vp->virtual_width >> 1; + WP(w, vp_d).scrollpos_y += vp->virtual_height >> 1; + WP(w, vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x; + WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y; break; case ZOOM_OUT: if (vp->zoom == ZOOM_LVL_MAX) return false; vp->zoom = (ZoomLevel)((byte)vp->zoom + 1); - WP(w,vp_d).scrollpos_x -= vp->virtual_width >> 1; - WP(w,vp_d).scrollpos_y -= vp->virtual_height >> 1; - WP(w,vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x; - WP(w,vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y; + WP(w, vp_d).scrollpos_x -= vp->virtual_width >> 1; + WP(w, vp_d).scrollpos_y -= vp->virtual_height >> 1; + WP(w, vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x; + WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y; vp->virtual_width <<= 1; vp->virtual_height <<= 1; @@ -979,7 +979,7 @@ static void ToolbarOptionsClick(Window *w) if (HasBit(_display_opt, DO_FULL_DETAIL)) SetBit(x, 11); if (IsTransparencySet(TO_HOUSES) && IsTransparencySet(TO_TREES)) SetBit(x, 12); if (IsTransparencySet(TO_SIGNS)) SetBit(x, 13); - WP(w,menu_d).checked_items = x; + WP(w, menu_d).checked_items = x; } @@ -2085,10 +2085,10 @@ static void StatusBarWndProc(Window *w, WindowEvent *e) DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING); } else if (_pause_game) { DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_0319_PAUSED, TC_FROMSTRING); - } else if (WP(w,def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) { + } else if (WP(w, def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) { /* Draw the scrolling news text */ - if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w,def_d).data_1, w->widget[1].right - w->widget[1].left - 2)) { - WP(w,def_d).data_1 = -1280; + if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w, def_d).data_1, w->widget[1].right - w->widget[1].left - 2)) { + WP(w, def_d).data_1 = -1280; if (p != NULL) { /* This is the default text */ SetDParam(0, p->index); @@ -2402,7 +2402,7 @@ void ShowVitalWindows() w = AllocateWindowDesc(&_main_status_desc); CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); - WP(w,def_d).data_1 = -1280; + WP(w, def_d).data_1 = -1280; } void GameSizeChanged() diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 4bccbf62f..da0fbb762 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -343,8 +343,8 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e) DrawWindowWidgets(w); - WP(w,tree_d).base = i = _tree_base_by_landscape[_opt.landscape]; - WP(w,tree_d).count = count = _tree_count_by_landscape[_opt.landscape]; + 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; @@ -369,10 +369,10 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e) case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11:case 12: case 13: case 14: - if (wid - 3 >= WP(w,tree_d).count) break; + if (wid - 3 >= WP(w, tree_d).count) break; if (HandlePlacePushButton(w, wid, SPR_CURSOR_TREE, VHM_RECT, NULL)) - _tree_to_plant = WP(w,tree_d).base + wid - 3; + _tree_to_plant = WP(w, tree_d).base + wid - 3; break; case 15: // tree of random type. @@ -1856,7 +1856,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e) { switch (e->event) { case WE_PAINT: { - int clk = WP(w,def_d).data_1; + int clk = WP(w, def_d).data_1; int x, y; int i; @@ -1935,7 +1935,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e) switch (ce->type) { case SLE_BOOL: - if (ce->flags & CE_CLICK) WP(w,def_d).data_1 = btn * 2 + 1; + if (ce->flags & CE_CLICK) WP(w, def_d).data_1 = btn * 2 + 1; value ^= 1; if (ce->proc != NULL) ce->proc(value, 0); break; @@ -1953,7 +1953,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e) value = ce->proc(value, (x >= 30) ? 1 : -1); if (value != oldvalue) { - WP(w,def_d).data_1 = btn * 2 + 1 + ((x >= 30) ? 1 : 0); + WP(w, def_d).data_1 = btn * 2 + 1 + ((x >= 30) ? 1 : 0); } } break; } @@ -1969,7 +1969,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e) } break; case WE_TIMEOUT: - WP(w,def_d).data_1 = 0; + WP(w, def_d).data_1 = 0; SetWindowDirty(w); break; } diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 821114bbb..34b28ec9a 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1403,10 +1403,10 @@ static Window *PopupClientList(Window *w, int client_no, int x, int y) w->widget[0].right = w->widget[0].left + 150; w->flags4 &= ~WF_WHITE_BORDER_MASK; - WP(w,menu_d).item_count = 0; + WP(w, menu_d).item_count = 0; // Save our client - WP(w,menu_d).main_button = client_no; - WP(w,menu_d).sel_index = 0; + WP(w, menu_d).main_button = client_no; + WP(w, menu_d).sel_index = 0; // We are a popup _popup_menu_active = true; @@ -1424,7 +1424,7 @@ static void ClientListPopupWndProc(Window *w, WindowEvent *e) DrawWindowWidgets(w); // Draw the actions - sel = WP(w,menu_d).sel_index; + sel = WP(w, menu_d).sel_index; y = 1; for (i = 0; i < MAX_CLIENTLIST_ACTION; i++, y += CLNWND_ROWSIZE) { if (_clientlist_action[i][0] == '\0') continue; @@ -1446,7 +1446,7 @@ static void ClientListPopupWndProc(Window *w, WindowEvent *e) int index = (e->we.popupmenu.pt.y - w->top) / CLNWND_ROWSIZE; if (index >= 0 && e->we.popupmenu.pt.y >= w->top) - HandleClientListPopupClick(index, WP(w,menu_d).main_button); + HandleClientListPopupClick(index, WP(w, menu_d).main_button); DeleteWindowById(WC_TOOLBAR_MENU, 0); } break; @@ -1455,9 +1455,9 @@ static void ClientListPopupWndProc(Window *w, WindowEvent *e) // 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; + if (index == -1 || index == WP(w, menu_d).sel_index) return; - WP(w,menu_d).sel_index = index; + WP(w, menu_d).sel_index = index; SetWindowDirty(w); } break; diff --git a/src/openttd.cpp b/src/openttd.cpp index 72fd4eb7b..7d841f0bb 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1055,8 +1055,8 @@ static void ScrollMainViewport(int x, int y) Window *w = FindWindowById(WC_MAIN_WINDOW, 0); assert(w); - WP(w,vp_d).dest_scrollpos_x += ScaleByZoom(x, w->viewport->zoom); - WP(w,vp_d).dest_scrollpos_y += ScaleByZoom(y, w->viewport->zoom); + WP(w, vp_d).dest_scrollpos_x += ScaleByZoom(x, w->viewport->zoom); + WP(w, vp_d).dest_scrollpos_y += ScaleByZoom(y, w->viewport->zoom); } } /** diff --git a/src/order_gui.cpp b/src/order_gui.cpp index efb29fb9f..105ee842d 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -58,7 +58,7 @@ enum OrderWindowWidgets { static int OrderGetSel(const Window *w) { const Vehicle *v = GetVehicle(w->window_number); - int num = WP(w,order_d).sel; + int num = WP(w, order_d).sel; return (num >= 0 && num < v->num_orders) ? num : v->num_orders; } @@ -242,7 +242,7 @@ static void DrawOrdersWindow(Window *w) } SetDParam(0, i + 1); - DrawString(2, y, str, (i == WP(w,order_d).sel) ? TC_WHITE : TC_BLACK); + DrawString(2, y, str, (i == WP(w, order_d).sel) ? TC_WHITE : TC_BLACK); y += 10; } @@ -253,7 +253,7 @@ static void DrawOrdersWindow(Window *w) if (i - w->vscroll.pos < w->vscroll.cap) { str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS; - DrawString(2, y, str, (i == WP(w,order_d).sel) ? TC_WHITE : TC_BLACK); + DrawString(2, y, str, (i == WP(w, order_d).sel) ? TC_WHITE : TC_BLACK); } } @@ -367,7 +367,7 @@ static bool HandleOrderVehClick(const Vehicle *v, const Vehicle *u, Window *w) if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? CO_SHARE : CO_COPY, NULL, _ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) { - WP(w,order_d).sel = -1; + WP(w, order_d).sel = -1; ResetObjectToPlace(); } @@ -387,7 +387,7 @@ static void OrdersPlaceObj(const Vehicle *v, TileIndex tile, Window *w) if (!cmd.IsValid()) return; if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), PackOrder(&cmd), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) { - if (WP(w,order_d).sel != -1) WP(w,order_d).sel++; + if (WP(w, order_d).sel != -1) WP(w,order_d).sel++; ResetObjectToPlace(); } } @@ -494,9 +494,9 @@ static void OrderClick_Refit(Window *w, const Vehicle *v) { if (_ctrl_pressed) { /* Cancel refitting */ - DoCommandP(v->tile, v->index, (WP(w,order_d).sel << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT); + DoCommandP(v->tile, v->index, (WP(w, order_d).sel << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT); } else { - ShowVehicleRefitWindow(v, WP(w,order_d).sel); + ShowVehicleRefitWindow(v, WP(w, order_d).sel); } } @@ -566,7 +566,7 @@ static void OrdersWndProc(Window *w, WindowEvent *e) if (sel == INVALID_ORDER) { /* This was a click on an empty part of the orders window, so * deselect the currently selected order. */ - WP(w,order_d).sel = -1; + WP(w, order_d).sel = -1; SetWindowDirty(w); return; } @@ -585,12 +585,12 @@ static void OrdersWndProc(Window *w, WindowEvent *e) if (xy != 0) ScrollMainWindowToTile(xy); return; } else { - if (sel == WP(w,order_d).sel) { + if (sel == WP(w, order_d).sel) { /* Deselect clicked order */ - WP(w,order_d).sel = -1; + WP(w, order_d).sel = -1; } else { /* Select clicked order */ - WP(w,order_d).sel = sel; + WP(w, order_d).sel = sel; if (v->owner == _local_player) { /* Activate drag and drop */ @@ -870,6 +870,6 @@ void ShowOrdersWindow(const Vehicle *v) w->caption_color = v->owner; w->vscroll.cap = 6; w->resize.step_height = 10; - WP(w,order_d).sel = -1; + WP(w, order_d).sel = -1; } } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 4417019ed..46806bfca 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -810,7 +810,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) case WE_PAINT: { int x, y; - const PatchPage *page = &_patches_page[WP(w,def_d).data_1]; + const PatchPage *page = &_patches_page[WP(w, def_d).data_1]; uint i; /* Set up selected category */ @@ -843,7 +843,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) value = (int32)ReadValue(var, sd->save.conv); /* Draw [<][>] boxes for settings of an integer-type */ - DrawArrowButtons(x, y, 3, WP(w,def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max)); + DrawArrowButtons(x, y, 3, WP(w, def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max)); disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED); if (disabled) { @@ -868,7 +868,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) case WE_CLICK: switch (e->we.click.widget) { case 3: { - const PatchPage *page = &_patches_page[WP(w,def_d).data_1]; + const PatchPage *page = &_patches_page[WP(w, def_d).data_1]; const SettingDesc *sd; void *var; int32 value; @@ -927,7 +927,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) /* Set up scroller timeout for numeric values */ if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) { - WP(w,def_d).data_2 = btn * 2 + 1 + ((x >= 10) ? 1 : 0); + WP(w, def_d).data_2 = btn * 2 + 1 + ((x >= 10) ? 1 : 0); w->flags4 |= 5 << WF_TIMEOUT_SHL; _left_button_clicked = false; } @@ -945,7 +945,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) /* Show the correct currency-translated value */ if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate; - WP(w,def_d).data_3 = btn; + WP(w, def_d).data_3 = btn; SetDParam(0, value); ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, w, CS_NUMERAL); } @@ -964,13 +964,13 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) break; case WE_TIMEOUT: - WP(w,def_d).data_2 = 0; + WP(w, def_d).data_2 = 0; SetWindowDirty(w); break; case WE_ON_EDIT_TEXT: { if (e->we.edittext.str != NULL) { - const PatchEntry *pe = &_patches_page[WP(w,def_d).data_1].entries[WP(w,def_d).data_3]; + 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); @@ -1052,7 +1052,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) case WE_PAINT: { int x; int y = 20; - int clk = WP(w,def_d).data_1; + int clk = WP(w, def_d).data_1; DrawWindowWidgets(w); // exchange rate @@ -1105,10 +1105,10 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) if (IsInsideMM(x, 10, 30)) { // clicked buttons if (x < 20) { if (_custom_currency.rate > 1) _custom_currency.rate--; - WP(w,def_d).data_1 = 1 << (line * 2 + 0); + WP(w, def_d).data_1 = 1 << (line * 2 + 0); } else { if (_custom_currency.rate < 5000) _custom_currency.rate++; - WP(w,def_d).data_1 = 1 << (line * 2 + 1); + WP(w, def_d).data_1 = 1 << (line * 2 + 1); } } else { // enter text SetDParam(0, _custom_currency.rate); @@ -1120,7 +1120,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) case 1: // separator if (IsInsideMM(x, 10, 30)) { // clicked button - WP(w,def_d).data_1 = 1 << (line * 2 + 1); + WP(w, def_d).data_1 = 1 << (line * 2 + 1); } str = BindCString(_str_separator); len = 1; @@ -1128,7 +1128,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) case 2: // prefix if (IsInsideMM(x, 10, 30)) { // clicked button - WP(w,def_d).data_1 = 1 << (line * 2 + 1); + WP(w, def_d).data_1 = 1 << (line * 2 + 1); } str = BindCString(_custom_currency.prefix); len = 12; @@ -1136,7 +1136,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) case 3: // suffix if (IsInsideMM(x, 10, 30)) { // clicked button - WP(w,def_d).data_1 = 1 << (line * 2 + 1); + WP(w, def_d).data_1 = 1 << (line * 2 + 1); } str = BindCString(_custom_currency.suffix); len = 12; @@ -1147,11 +1147,11 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) if (x < 20) { _custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? CF_NOEURO : _custom_currency.to_euro - 1; - WP(w,def_d).data_1 = 1 << (line * 2 + 0); + WP(w, def_d).data_1 = 1 << (line * 2 + 0); } else { _custom_currency.to_euro = Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR); - WP(w,def_d).data_1 = 1 << (line * 2 + 1); + WP(w, def_d).data_1 = 1 << (line * 2 + 1); } } else { // enter text SetDParam(0, _custom_currency.to_euro); @@ -1175,7 +1175,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) case WE_ON_EDIT_TEXT: { const char *b = e->we.edittext.str; - switch (WP(w,def_d).data_2) { + switch (WP(w, def_d).data_2) { case 0: /* Exchange rate */ _custom_currency.rate = Clamp(atoi(b), 1, 5000); break; @@ -1206,7 +1206,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) } case WE_TIMEOUT: - WP(w,def_d).data_1 = 0; + WP(w, def_d).data_1 = 0; SetWindowDirty(w); break; diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 02fe6d1c3..bb2ee28bb 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -612,10 +612,10 @@ static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_town } } - tile_x = WP(w,smallmap_d).scroll_x / TILE_SIZE; - tile_y = WP(w,smallmap_d).scroll_y / TILE_SIZE; + tile_x = WP(w, smallmap_d).scroll_x / TILE_SIZE; + tile_y = WP(w, smallmap_d).scroll_y / TILE_SIZE; - dx = dpi->left + WP(w,smallmap_d).subscroll; + dx = dpi->left + WP(w, smallmap_d).subscroll; tile_x -= dx / 4; tile_y += dx / 4; dx &= 3; @@ -689,8 +689,8 @@ skip_column: (v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) { /* Remap into flat coordinates. */ Point pt = RemapCoords( - v->x_pos / TILE_SIZE - WP(w,smallmap_d).scroll_x / TILE_SIZE, // divide each one separately because (a-b)/c != a/c-b/c in integer world - v->y_pos / TILE_SIZE - WP(w,smallmap_d).scroll_y / TILE_SIZE, // dtto + v->x_pos / TILE_SIZE - WP(w, smallmap_d).scroll_x / TILE_SIZE, // divide each one separately because (a-b)/c != a/c-b/c in integer world + v->y_pos / TILE_SIZE - WP(w, smallmap_d).scroll_y / TILE_SIZE, // dtto 0); x = pt.x; y = pt.y; @@ -703,7 +703,7 @@ skip_column: skip = false; /* Offset X coordinate */ - x -= WP(w,smallmap_d).subscroll + 3 + dpi->left; + x -= WP(w, smallmap_d).subscroll + 3 + dpi->left; if (x < 0) { /* if x+1 is 0, that means we're on the very left edge, @@ -735,7 +735,7 @@ skip_column: (int)(TileX(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_x) / TILE_SIZE, (int)(TileY(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_y) / TILE_SIZE, 0); - x = pt.x - WP(w,smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1); + x = pt.x - WP(w, smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1); y = pt.y; /* Check if the town sign is within bounds */ @@ -766,8 +766,8 @@ skip_column: x /= TILE_SIZE; y /= TILE_SIZE; - x -= WP(w,smallmap_d).subscroll; - x2 -= WP(w,smallmap_d).subscroll; + x -= WP(w, smallmap_d).subscroll; + x2 -= WP(w, smallmap_d).subscroll; DrawVertMapIndicator(x, y, x, y2); DrawVertMapIndicator(x2, y, x2, y2); @@ -878,7 +878,7 @@ static void SmallMapWindowProc(Window *w, WindowEvent *e) */ _left_button_clicked = false; - pt = RemapCoords(WP(w,smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0); + pt = RemapCoords(WP(w, smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0); WP(w2, vp_d).dest_scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1); WP(w2, vp_d).dest_scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1); diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 930cedb60..4a3f91927 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -48,7 +48,7 @@ static inline void SetTimetableParams(int param1, int param2, uint32 time) static void DrawTimetableWindow(Window *w) { const Vehicle *v = GetVehicle(w->window_number); - int selected = WP(w,order_d).sel; + int selected = WP(w, order_d).sel; SetVScrollCount(w, v->num_orders * 2); @@ -221,17 +221,17 @@ static void TimetableWndProc(Window *w, WindowEvent *we) case 3: { /* Main panel. */ int selected = GetOrderFromTimetableWndPt(w, we->we.click.pt.y, v); - if (selected == INVALID_ORDER || selected == WP(w,order_d).sel) { + if (selected == INVALID_ORDER || selected == WP(w, order_d).sel) { /* Deselect clicked order */ - WP(w,order_d).sel = -1; + WP(w, order_d).sel = -1; } else { /* Select clicked order */ - WP(w,order_d).sel = selected; + WP(w, order_d).sel = selected; } } break; case 6: { /* "Wait For" button. */ - int selected = WP(w,order_d).sel; + int selected = WP(w, order_d).sel; VehicleOrderID real = (selected + 1) / 2; if (real >= v->num_orders) real = 0; @@ -253,7 +253,7 @@ static void TimetableWndProc(Window *w, WindowEvent *we) } break; case 7: { /* Clear waiting time button. */ - uint32 p1 = PackTimetableArgs(v, WP(w,order_d).sel); + uint32 p1 = PackTimetableArgs(v, WP(w, order_d).sel); DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); } break; @@ -272,7 +272,7 @@ static void TimetableWndProc(Window *w, WindowEvent *we) case WE_ON_EDIT_TEXT: { const Vehicle *v = GetVehicle(w->window_number); - uint32 p1 = PackTimetableArgs(v, WP(w,order_d).sel); + uint32 p1 = PackTimetableArgs(v, WP(w, order_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; @@ -327,6 +327,6 @@ void ShowTimetableWindow(const Vehicle *v) w->caption_color = v->owner; w->vscroll.cap = 8; w->resize.step_height = 10; - WP(w,order_d).sel = -1; + WP(w, order_d).sel = -1; } } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index a9bae18a4..ebfd06278 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -140,8 +140,8 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e) SetVScrollCount(w, numact + 1); - if (WP(w,def_d).data_1 != -1 && !HasBit(buttons, WP(w,def_d).data_1)) - WP(w,def_d).data_1 = -1; + if (WP(w, def_d).data_1 != -1 && !HasBit(buttons, WP(w,def_d).data_1)) + WP(w, def_d).data_1 = -1; w->SetWidgetDisabledState(6, WP(w, def_d).data_1 == -1); @@ -206,7 +206,7 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e) } { - int i = WP(w,def_d).data_1; + int i = WP(w, def_d).data_1; if (i != -1) { SetDParam(1, (_price.build_industry >> 8) * _town_action_costs[i]); @@ -228,7 +228,7 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e) y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_player, t), y + w->vscroll.pos - 1); if (y >= 0) { - WP(w,def_d).data_1 = y; + WP(w, def_d).data_1 = y; SetWindowDirty(w); } /* Fall through to clicking in case we are double-clicked */ @@ -236,7 +236,7 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e) } case TWA_EXECUTE: { - DoCommandP(GetTown(w->window_number)->xy, w->window_number, WP(w,def_d).data_1, NULL, CMD_DO_TOWN_ACTION | CMD_MSG(STR_00B4_CAN_T_DO_THIS)); + DoCommandP(GetTown(w->window_number)->xy, w->window_number, WP(w, def_d).data_1, NULL, CMD_DO_TOWN_ACTION | CMD_MSG(STR_00B4_CAN_T_DO_THIS)); break; } } @@ -262,7 +262,7 @@ static void ShowTownAuthorityWindow(uint town) if (w != NULL) { w->vscroll.cap = 5; - WP(w,def_d).data_1 = -1; + WP(w, def_d).data_1 = -1; } } diff --git a/src/viewport.cpp b/src/viewport.cpp index b9636ca11..aac54aeb3 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1680,7 +1680,7 @@ void UpdateViewportPosition(Window *w) const ViewPort *vp = w->viewport; if (WP(w, vp_d).follow_vehicle != INVALID_VEHICLE) { - const Vehicle* veh = GetVehicle(WP(w,vp_d).follow_vehicle); + const Vehicle* veh = GetVehicle(WP(w, vp_d).follow_vehicle); Point pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos); SetViewportPosition(w, pt.x, pt.y); diff --git a/src/widget.cpp b/src/widget.cpp index 46900d5ed..59ab2433b 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -503,12 +503,12 @@ static int GetDropdownItem(const Window *w) return - 1; item = y / 10; - if (item >= WP(w,dropdown_d).num_items || (HasBit(WP(w,dropdown_d).disabled_state, item) && !HasBit(WP(w,dropdown_d).hidden_state, item)) || WP(w,dropdown_d).items[item] == 0) + if (item >= WP(w, dropdown_d).num_items || (HasBit(WP(w,dropdown_d).disabled_state, item) && !HasBit(WP(w,dropdown_d).hidden_state, item)) || WP(w,dropdown_d).items[item] == 0) return - 1; /* Skip hidden items -- +1 for each hidden item before the clicked item. */ for (counter = 0; item >= counter; ++counter) - if (HasBit(WP(w,dropdown_d).hidden_state, counter)) item++; + if (HasBit(WP(w, dropdown_d).hidden_state, counter)) item++; return item; } @@ -527,19 +527,19 @@ static void DropdownMenuWndProc(Window *w, WindowEvent *e) x = 1; y = 2 - w->vscroll.pos * 10; - sel = WP(w,dropdown_d).selected_index; + sel = WP(w, dropdown_d).selected_index; width = w->widget[0].right - 3; height = w->widget[0].bottom - 3; - for (i = 0; WP(w,dropdown_d).items[i] != INVALID_STRING_ID; i++, sel--) { - if (HasBit(WP(w,dropdown_d).hidden_state, i)) continue; + for (i = 0; WP(w, dropdown_d).items[i] != INVALID_STRING_ID; i++, sel--) { + if (HasBit(WP(w, dropdown_d).hidden_state, i)) continue; if (y >= 0 && y <= height) { - if (WP(w,dropdown_d).items[i] != STR_NULL) { + if (WP(w, dropdown_d).items[i] != STR_NULL) { if (sel == 0) GfxFillRect(x + 1, y, x + width, y + 9, 0); - DrawStringTruncated(x + 2, y, WP(w,dropdown_d).items[i], sel == 0 ? TC_WHITE : TC_BLACK, x + width); + DrawStringTruncated(x + 2, y, WP(w, dropdown_d).items[i], sel == 0 ? TC_WHITE : TC_BLACK, x + width); - if (HasBit(WP(w,dropdown_d).disabled_state, i)) { + if (HasBit(WP(w, dropdown_d).disabled_state, i)) { GfxFillRect(x, y, x + width, y + 9, (1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[_dropdown_menu_widgets[0].color][5] ); @@ -560,50 +560,50 @@ static void DropdownMenuWndProc(Window *w, WindowEvent *e) if (e->we.click.widget != 0) break; item = GetDropdownItem(w); if (item >= 0) { - WP(w,dropdown_d).click_delay = 4; - WP(w,dropdown_d).selected_index = item; + WP(w, dropdown_d).click_delay = 4; + WP(w, dropdown_d).selected_index = item; SetWindowDirty(w); } } break; case WE_MOUSELOOP: { - Window *w2 = FindWindowById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num); + Window *w2 = FindWindowById(WP(w, dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num); if (w2 == NULL) { DeleteWindow(w); return; } - if (WP(w,dropdown_d).click_delay != 0 && --WP(w,dropdown_d).click_delay == 0) { + if (WP(w, dropdown_d).click_delay != 0 && --WP(w,dropdown_d).click_delay == 0) { WindowEvent e; e.event = WE_DROPDOWN_SELECT; - e.we.dropdown.button = WP(w,dropdown_d).parent_button; - e.we.dropdown.index = WP(w,dropdown_d).selected_index; + e.we.dropdown.button = WP(w, dropdown_d).parent_button; + e.we.dropdown.index = WP(w, dropdown_d).selected_index; w2->wndproc(w2, &e); DeleteWindow(w); return; } - if (WP(w,dropdown_d).drag_mode) { + if (WP(w, dropdown_d).drag_mode) { item = GetDropdownItem(w); if (!_left_button_clicked) { - WP(w,dropdown_d).drag_mode = false; + WP(w, dropdown_d).drag_mode = false; if (item < 0) return; - WP(w,dropdown_d).click_delay = 2; + WP(w, dropdown_d).click_delay = 2; } else { if (item < 0) return; } - WP(w,dropdown_d).selected_index = item; + WP(w, dropdown_d).selected_index = item; SetWindowDirty(w); } } break; case WE_DESTROY: { - Window *w2 = FindWindowById(WP(w,dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num); + Window *w2 = FindWindowById(WP(w, dropdown_d).parent_wnd_class, WP(w,dropdown_d).parent_wnd_num); if (w2 != NULL) { - w2->RaiseWidget(WP(w,dropdown_d).parent_button); - w2->InvalidateWidget(WP(w,dropdown_d).parent_button); + w2->RaiseWidget(WP(w, dropdown_d).parent_button); + w2->InvalidateWidget(WP(w, dropdown_d).parent_button); } } break; } @@ -696,19 +696,19 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt w2->desc_flags = WDF_DEF_WIDGET; w2->flags4 &= ~WF_WHITE_BORDER_MASK; - WP(w2,dropdown_d).disabled_state = disabled_mask; - WP(w2,dropdown_d).hidden_state = hidden_mask; + WP(w2, dropdown_d).disabled_state = disabled_mask; + WP(w2, dropdown_d).hidden_state = hidden_mask; - WP(w2,dropdown_d).parent_wnd_class = w->window_class; - WP(w2,dropdown_d).parent_wnd_num = w->window_number; - WP(w2,dropdown_d).parent_button = button; + WP(w2, dropdown_d).parent_wnd_class = w->window_class; + WP(w2, dropdown_d).parent_wnd_num = w->window_number; + WP(w2, dropdown_d).parent_button = button; - WP(w2,dropdown_d).num_items = i; - WP(w2,dropdown_d).selected_index = selected; - WP(w2,dropdown_d).items = strings; + WP(w2, dropdown_d).num_items = i; + WP(w2, dropdown_d).selected_index = selected; + WP(w2, dropdown_d).items = strings; - WP(w2,dropdown_d).click_delay = 0; - WP(w2,dropdown_d).drag_mode = true; + WP(w2, dropdown_d).click_delay = 0; + WP(w2, dropdown_d).drag_mode = true; } diff --git a/src/window.h b/src/window.h index 11086e64b..8765fb428 100644 --- a/src/window.h +++ b/src/window.h @@ -237,7 +237,7 @@ struct Textbuf { uint16 caretxoffs; ///< the current position of the caret in pixels }; -#define WP(ptr,str) (*(str*)(ptr)->custom) +#define WP(ptr, str) (*(str*)(ptr)->custom) /* You cannot 100% reliably calculate the biggest custom struct as * the number of pointers in it and alignment will have a huge impact. * 96 is the largest window-size for 64-bit machines currently */ |