1
0
Fork 0

(svn r11643) -Codechange: conform with the coding style for the WP macro uses.

release/0.6
rubidium 2007-12-16 10:54:08 +00:00
parent acf6e08f78
commit ec90ce7e98
14 changed files with 155 additions and 155 deletions

View File

@ -240,7 +240,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
Player *p = GetPlayer(_local_player); Player *p = GetPlayer(_local_player);
EngineID selected_id[2]; 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[0] = WP(w, replaceveh_d).sel_engine[0];
selected_id[1] = WP(w, replaceveh_d).sel_engine[1]; selected_id[1] = WP(w, replaceveh_d).sel_engine[1];

View File

@ -171,7 +171,7 @@ static void DrawVehicleInDepot(Window *w, const Vehicle *v, int x, int y)
switch (v->type) { switch (v->type) {
case VEH_TRAIN: 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) */ /* Number of wagons relative to a standard length wagon (rounded up) */
SetDParam(0, (v->u.rail.cached_total_length + 7) / 8); 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 *v = WP(w, depot_d).wagon_list[num - WP(w, depot_d).engine_count];
const Vehicle *u; 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); DrawString(x, y + 2, STR_8816, TC_FROMSTRING);
/*Draw the train counter */ /*Draw the train counter */
@ -429,7 +429,7 @@ static void DepotClick(Window *w, int x, int y)
VehicleID sel = WP(w, depot_d).sel; VehicleID sel = WP(w, depot_d).sel;
if (WP(w, depot_d).type == VEH_TRAIN && sel != INVALID_VEHICLE) { 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); TrainDepotMoveVehicle(v, sel, gdvp.head);
} else if (v != NULL) { } else if (v != NULL) {
int image = v->GetImage(DIR_W); int image = v->GetImage(DIR_W);

View File

@ -468,7 +468,7 @@ static void MenuWndProc(Window *w, WindowEvent *e)
case WE_DESTROY: { case WE_DESTROY: {
Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0); 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); SetWindowDirty(v);
return; return;
} }
@ -480,11 +480,11 @@ static void MenuWndProc(Window *w, WindowEvent *e)
if (index < 0) { if (index < 0) {
Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,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) 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; 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); DeleteWindow(w);
if (index >= 0) { if (index >= 0) {
@ -498,9 +498,9 @@ static void MenuWndProc(Window *w, WindowEvent *e)
case WE_POPUPMENU_OVER: { case WE_POPUPMENU_OVER: {
int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); 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); SetWindowDirty(w);
return; return;
} }
@ -538,10 +538,10 @@ static void UpdatePlayerMenuHeight(Window *w)
byte num = ActivePlayerCount(); byte num = ActivePlayerCount();
/* Increase one to fit in PlayerList in the menu when in network */ /* 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) { if (WP(w, menu_d).item_count != num) {
WP(w,menu_d).item_count = num; WP(w, menu_d).item_count = num;
SetWindowDirty(w); SetWindowDirty(w);
num = num * 10 + 2; num = num * 10 + 2;
w->height = num; w->height = num;
@ -565,11 +565,11 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e)
x = 1; x = 1;
y = 1; y = 1;
sel = WP(w,menu_d).sel_index; sel = WP(w, menu_d).sel_index;
chk = WP(w,menu_d).checked_items; // let this mean gray items. chk = WP(w, menu_d).checked_items; // let this mean gray items.
/* 9 = playerlist */ /* 9 = playerlist */
if (_networking && WP(w,menu_d).main_button == 9) { if (_networking && WP(w, menu_d).main_button == 9) {
if (sel == 0) { if (sel == 0) {
GfxFillRect(x, y, x + 238, y + 9, 0); GfxFillRect(x, y, x + 238, y + 9, 0);
} }
@ -603,18 +603,18 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e)
case WE_DESTROY: { case WE_DESTROY: {
Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0); 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); SetWindowDirty(v);
return; return;
} }
case WE_POPUPMENU_SELECT: { case WE_POPUPMENU_SELECT: {
int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); 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 /* We have a new entry at the top of the list of menu 9 when networking
* so keep that in count */ * 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; if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
} else { } else {
index = GetPlayerIndexFromMenu(index); index = GetPlayerIndexFromMenu(index);
@ -622,8 +622,8 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e)
if (index < 0) { if (index < 0) {
Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,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) 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; index = WP(w, menu_d).sel_index;
} }
DeleteWindow(w); 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 /* We have a new entry at the top of the list of menu 9 when networking
* so keep that in count */ * 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; if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
} else { } else {
index = GetPlayerIndexFromMenu(index); 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); SetWindowDirty(w);
return; return;
} }
@ -722,13 +722,13 @@ static Window *PopupMainToolbMenu(Window *w, uint16 parent_button, StringID base
w->widget[0].bottom = item_count * 10 + 1; w->widget[0].bottom = item_count * 10 + 1;
w->flags4 &= ~WF_WHITE_BORDER_MASK; w->flags4 &= ~WF_WHITE_BORDER_MASK;
WP(w,menu_d).item_count = item_count; WP(w, menu_d).item_count = item_count;
WP(w,menu_d).sel_index = 0; WP(w, menu_d).sel_index = 0;
WP(w,menu_d).main_button = GB(parent_button, 0, 8); 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).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).string_id = base_string;
WP(w,menu_d).checked_items = 0; WP(w, menu_d).checked_items = 0;
WP(w,menu_d).disabled_items = disabled_mask; WP(w, menu_d).disabled_items = disabled_mask;
_popup_menu_active = true; _popup_menu_active = true;
@ -746,20 +746,20 @@ static Window *PopupMainPlayerToolbMenu(Window *w, int main_button, int gray)
DeleteWindowById(WC_TOOLBAR_MENU, 0); DeleteWindowById(WC_TOOLBAR_MENU, 0);
w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets); w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
w->flags4 &= ~WF_WHITE_BORDER_MASK; w->flags4 &= ~WF_WHITE_BORDER_MASK;
WP(w,menu_d).item_count = 0; 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).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
if (_networking && main_button == 9) { if (_networking && main_button == 9) {
if (_local_player != PLAYER_SPECTATOR) { if (_local_player != PLAYER_SPECTATOR) {
WP(w,menu_d).sel_index++; WP(w, menu_d).sel_index++;
} else { } else {
/* Select client list by default for spectators */ /* 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).action_id = main_button;
WP(w,menu_d).main_button = main_button; WP(w, menu_d).main_button = main_button;
WP(w,menu_d).checked_items = gray; WP(w, menu_d).checked_items = gray;
WP(w,menu_d).disabled_items = 0; WP(w, menu_d).disabled_items = 0;
_popup_menu_active = true; _popup_menu_active = true;
SndPlayFx(SND_15_BEEP); SndPlayFx(SND_15_BEEP);
return w; return w;
@ -876,19 +876,19 @@ bool DoZoomInOutWindow(int how, Window *w)
vp->virtual_width >>= 1; vp->virtual_width >>= 1;
vp->virtual_height >>= 1; vp->virtual_height >>= 1;
WP(w,vp_d).scrollpos_x += vp->virtual_width >> 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).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_x = WP(w,vp_d).scrollpos_x;
WP(w,vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y; WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y;
break; break;
case ZOOM_OUT: case ZOOM_OUT:
if (vp->zoom == ZOOM_LVL_MAX) return false; if (vp->zoom == ZOOM_LVL_MAX) return false;
vp->zoom = (ZoomLevel)((byte)vp->zoom + 1); vp->zoom = (ZoomLevel)((byte)vp->zoom + 1);
WP(w,vp_d).scrollpos_x -= vp->virtual_width >> 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).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_x = WP(w,vp_d).scrollpos_x;
WP(w,vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y; WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y;
vp->virtual_width <<= 1; vp->virtual_width <<= 1;
vp->virtual_height <<= 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 (HasBit(_display_opt, DO_FULL_DETAIL)) SetBit(x, 11);
if (IsTransparencySet(TO_HOUSES) && IsTransparencySet(TO_TREES)) SetBit(x, 12); if (IsTransparencySet(TO_HOUSES) && IsTransparencySet(TO_TREES)) SetBit(x, 12);
if (IsTransparencySet(TO_SIGNS)) SetBit(x, 13); 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); DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING);
} else if (_pause_game) { } else if (_pause_game) {
DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_0319_PAUSED, TC_FROMSTRING); 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 */ /* 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)) { 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; WP(w, def_d).data_1 = -1280;
if (p != NULL) { if (p != NULL) {
/* This is the default text */ /* This is the default text */
SetDParam(0, p->index); SetDParam(0, p->index);
@ -2402,7 +2402,7 @@ void ShowVitalWindows()
w = AllocateWindowDesc(&_main_status_desc); w = AllocateWindowDesc(&_main_status_desc);
CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
WP(w,def_d).data_1 = -1280; WP(w, def_d).data_1 = -1280;
} }
void GameSizeChanged() void GameSizeChanged()

View File

@ -343,8 +343,8 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e)
DrawWindowWidgets(w); DrawWindowWidgets(w);
WP(w,tree_d).base = i = _tree_base_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]; WP(w, tree_d).count = count = _tree_count_by_landscape[_opt.landscape];
x = 18; x = 18;
y = 54; y = 54;
@ -369,10 +369,10 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e)
case 3: case 4: case 5: case 6: case 3: case 4: case 5: case 6:
case 7: case 8: case 9: case 10: case 7: case 8: case 9: case 10:
case 11:case 12: case 13: case 14: 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)) 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; break;
case 15: // tree of random type. case 15: // tree of random type.
@ -1856,7 +1856,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e)
{ {
switch (e->event) { switch (e->event) {
case WE_PAINT: { case WE_PAINT: {
int clk = WP(w,def_d).data_1; int clk = WP(w, def_d).data_1;
int x, y; int x, y;
int i; int i;
@ -1935,7 +1935,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e)
switch (ce->type) { switch (ce->type) {
case SLE_BOOL: 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; value ^= 1;
if (ce->proc != NULL) ce->proc(value, 0); if (ce->proc != NULL) ce->proc(value, 0);
break; break;
@ -1953,7 +1953,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e)
value = ce->proc(value, (x >= 30) ? 1 : -1); value = ce->proc(value, (x >= 30) ? 1 : -1);
if (value != oldvalue) { 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; } break;
} }
@ -1969,7 +1969,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e)
} }
break; break;
case WE_TIMEOUT: case WE_TIMEOUT:
WP(w,def_d).data_1 = 0; WP(w, def_d).data_1 = 0;
SetWindowDirty(w); SetWindowDirty(w);
break; break;
} }

View File

@ -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->widget[0].right = w->widget[0].left + 150;
w->flags4 &= ~WF_WHITE_BORDER_MASK; w->flags4 &= ~WF_WHITE_BORDER_MASK;
WP(w,menu_d).item_count = 0; WP(w, menu_d).item_count = 0;
// Save our client // Save our client
WP(w,menu_d).main_button = client_no; WP(w, menu_d).main_button = client_no;
WP(w,menu_d).sel_index = 0; WP(w, menu_d).sel_index = 0;
// We are a popup // We are a popup
_popup_menu_active = true; _popup_menu_active = true;
@ -1424,7 +1424,7 @@ static void ClientListPopupWndProc(Window *w, WindowEvent *e)
DrawWindowWidgets(w); DrawWindowWidgets(w);
// Draw the actions // Draw the actions
sel = WP(w,menu_d).sel_index; sel = WP(w, menu_d).sel_index;
y = 1; y = 1;
for (i = 0; i < MAX_CLIENTLIST_ACTION; i++, y += CLNWND_ROWSIZE) { for (i = 0; i < MAX_CLIENTLIST_ACTION; i++, y += CLNWND_ROWSIZE) {
if (_clientlist_action[i][0] == '\0') continue; 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; 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); HandleClientListPopupClick(index, WP(w, menu_d).main_button);
DeleteWindowById(WC_TOOLBAR_MENU, 0); DeleteWindowById(WC_TOOLBAR_MENU, 0);
} break; } break;
@ -1455,9 +1455,9 @@ static void ClientListPopupWndProc(Window *w, WindowEvent *e)
// 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; 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); SetWindowDirty(w);
} break; } break;

View File

@ -1055,8 +1055,8 @@ static void ScrollMainViewport(int x, int y)
Window *w = FindWindowById(WC_MAIN_WINDOW, 0); Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
assert(w); assert(w);
WP(w,vp_d).dest_scrollpos_x += ScaleByZoom(x, 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); WP(w, vp_d).dest_scrollpos_y += ScaleByZoom(y, w->viewport->zoom);
} }
} }
/** /**

View File

@ -58,7 +58,7 @@ enum OrderWindowWidgets {
static int OrderGetSel(const Window *w) static int OrderGetSel(const Window *w)
{ {
const Vehicle *v = GetVehicle(w->window_number); 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; return (num >= 0 && num < v->num_orders) ? num : v->num_orders;
} }
@ -242,7 +242,7 @@ static void DrawOrdersWindow(Window *w)
} }
SetDParam(0, i + 1); 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; y += 10;
} }
@ -253,7 +253,7 @@ static void DrawOrdersWindow(Window *w)
if (i - w->vscroll.pos < w->vscroll.cap) { if (i - w->vscroll.pos < w->vscroll.cap) {
str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS; 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, 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))) { _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(); ResetObjectToPlace();
} }
@ -387,7 +387,7 @@ static void OrdersPlaceObj(const Vehicle *v, TileIndex tile, Window *w)
if (!cmd.IsValid()) return; 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 (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(); ResetObjectToPlace();
} }
} }
@ -494,9 +494,9 @@ static void OrderClick_Refit(Window *w, const Vehicle *v)
{ {
if (_ctrl_pressed) { if (_ctrl_pressed) {
/* Cancel refitting */ /* 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 { } 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) { if (sel == INVALID_ORDER) {
/* This was a click on an empty part of the orders window, so /* This was a click on an empty part of the orders window, so
* deselect the currently selected order. */ * deselect the currently selected order. */
WP(w,order_d).sel = -1; WP(w, order_d).sel = -1;
SetWindowDirty(w); SetWindowDirty(w);
return; return;
} }
@ -585,12 +585,12 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
if (xy != 0) ScrollMainWindowToTile(xy); if (xy != 0) ScrollMainWindowToTile(xy);
return; return;
} else { } else {
if (sel == WP(w,order_d).sel) { if (sel == WP(w, order_d).sel) {
/* Deselect clicked order */ /* Deselect clicked order */
WP(w,order_d).sel = -1; WP(w, order_d).sel = -1;
} else { } else {
/* Select clicked order */ /* Select clicked order */
WP(w,order_d).sel = sel; WP(w, order_d).sel = sel;
if (v->owner == _local_player) { if (v->owner == _local_player) {
/* Activate drag and drop */ /* Activate drag and drop */
@ -870,6 +870,6 @@ void ShowOrdersWindow(const Vehicle *v)
w->caption_color = v->owner; w->caption_color = v->owner;
w->vscroll.cap = 6; w->vscroll.cap = 6;
w->resize.step_height = 10; w->resize.step_height = 10;
WP(w,order_d).sel = -1; WP(w, order_d).sel = -1;
} }
} }

View File

@ -810,7 +810,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
case WE_PAINT: { case WE_PAINT: {
int x, y; 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; uint i;
/* Set up selected category */ /* Set up selected category */
@ -843,7 +843,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
value = (int32)ReadValue(var, sd->save.conv); value = (int32)ReadValue(var, sd->save.conv);
/* Draw [<][>] boxes for settings of an integer-type */ /* 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); disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
if (disabled) { if (disabled) {
@ -868,7 +868,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
case WE_CLICK: case WE_CLICK:
switch (e->we.click.widget) { switch (e->we.click.widget) {
case 3: { 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; const SettingDesc *sd;
void *var; void *var;
int32 value; int32 value;
@ -927,7 +927,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
/* Set up scroller timeout for numeric values */ /* Set up scroller timeout for numeric values */
if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) { 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; w->flags4 |= 5 << WF_TIMEOUT_SHL;
_left_button_clicked = false; _left_button_clicked = false;
} }
@ -945,7 +945,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
/* Show the correct currency-translated value */ /* Show the correct currency-translated value */
if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate; 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); SetDParam(0, value);
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, w, CS_NUMERAL); 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; break;
case WE_TIMEOUT: case WE_TIMEOUT:
WP(w,def_d).data_2 = 0; WP(w, def_d).data_2 = 0;
SetWindowDirty(w); SetWindowDirty(w);
break; break;
case WE_ON_EDIT_TEXT: { case WE_ON_EDIT_TEXT: {
if (e->we.edittext.str != NULL) { 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; const SettingDesc *sd = pe->setting;
int32 value = atoi(e->we.edittext.str); int32 value = atoi(e->we.edittext.str);
@ -1052,7 +1052,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
case WE_PAINT: { case WE_PAINT: {
int x; int x;
int y = 20; int y = 20;
int clk = WP(w,def_d).data_1; int clk = WP(w, def_d).data_1;
DrawWindowWidgets(w); DrawWindowWidgets(w);
// exchange rate // exchange rate
@ -1105,10 +1105,10 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
if (IsInsideMM(x, 10, 30)) { // clicked buttons if (IsInsideMM(x, 10, 30)) { // clicked buttons
if (x < 20) { if (x < 20) {
if (_custom_currency.rate > 1) _custom_currency.rate--; 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 { } else {
if (_custom_currency.rate < 5000) _custom_currency.rate++; 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 } else { // enter text
SetDParam(0, _custom_currency.rate); SetDParam(0, _custom_currency.rate);
@ -1120,7 +1120,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
case 1: // separator case 1: // separator
if (IsInsideMM(x, 10, 30)) { // clicked button 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); str = BindCString(_str_separator);
len = 1; len = 1;
@ -1128,7 +1128,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
case 2: // prefix case 2: // prefix
if (IsInsideMM(x, 10, 30)) { // clicked button 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); str = BindCString(_custom_currency.prefix);
len = 12; len = 12;
@ -1136,7 +1136,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
case 3: // suffix case 3: // suffix
if (IsInsideMM(x, 10, 30)) { // clicked button 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); str = BindCString(_custom_currency.suffix);
len = 12; len = 12;
@ -1147,11 +1147,11 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
if (x < 20) { if (x < 20) {
_custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? _custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ?
CF_NOEURO : _custom_currency.to_euro - 1; 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 { } else {
_custom_currency.to_euro = _custom_currency.to_euro =
Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR); 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 } else { // enter text
SetDParam(0, _custom_currency.to_euro); SetDParam(0, _custom_currency.to_euro);
@ -1175,7 +1175,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
case WE_ON_EDIT_TEXT: { case WE_ON_EDIT_TEXT: {
const char *b = e->we.edittext.str; 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 */ case 0: /* Exchange rate */
_custom_currency.rate = Clamp(atoi(b), 1, 5000); _custom_currency.rate = Clamp(atoi(b), 1, 5000);
break; break;
@ -1206,7 +1206,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
} }
case WE_TIMEOUT: case WE_TIMEOUT:
WP(w,def_d).data_1 = 0; WP(w, def_d).data_1 = 0;
SetWindowDirty(w); SetWindowDirty(w);
break; break;

View File

@ -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_x = WP(w, smallmap_d).scroll_x / TILE_SIZE;
tile_y = WP(w,smallmap_d).scroll_y / 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_x -= dx / 4;
tile_y += dx / 4; tile_y += dx / 4;
dx &= 3; dx &= 3;
@ -689,8 +689,8 @@ skip_column:
(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) { (v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) {
/* Remap into flat coordinates. */ /* Remap into flat coordinates. */
Point pt = RemapCoords( 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->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->y_pos / TILE_SIZE - WP(w, smallmap_d).scroll_y / TILE_SIZE, // dtto
0); 0);
x = pt.x; x = pt.x;
y = pt.y; y = pt.y;
@ -703,7 +703,7 @@ skip_column:
skip = false; skip = false;
/* Offset X coordinate */ /* 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 < 0) {
/* if x+1 is 0, that means we're on the very left edge, /* 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)(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, (int)(TileY(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_y) / TILE_SIZE,
0); 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; y = pt.y;
/* Check if the town sign is within bounds */ /* Check if the town sign is within bounds */
@ -766,8 +766,8 @@ skip_column:
x /= TILE_SIZE; x /= TILE_SIZE;
y /= TILE_SIZE; y /= TILE_SIZE;
x -= WP(w,smallmap_d).subscroll; x -= WP(w, smallmap_d).subscroll;
x2 -= WP(w,smallmap_d).subscroll; x2 -= WP(w, smallmap_d).subscroll;
DrawVertMapIndicator(x, y, x, y2); DrawVertMapIndicator(x, y, x, y2);
DrawVertMapIndicator(x2, y, x2, y2); DrawVertMapIndicator(x2, y, x2, y2);
@ -878,7 +878,7 @@ static void SmallMapWindowProc(Window *w, WindowEvent *e)
*/ */
_left_button_clicked = false; _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_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); WP(w2, vp_d).dest_scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1);

View File

@ -48,7 +48,7 @@ static inline void SetTimetableParams(int param1, int param2, uint32 time)
static void DrawTimetableWindow(Window *w) static void DrawTimetableWindow(Window *w)
{ {
const Vehicle *v = GetVehicle(w->window_number); 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); SetVScrollCount(w, v->num_orders * 2);
@ -221,17 +221,17 @@ static void TimetableWndProc(Window *w, WindowEvent *we)
case 3: { /* Main panel. */ case 3: { /* Main panel. */
int selected = GetOrderFromTimetableWndPt(w, we->we.click.pt.y, v); 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 */ /* Deselect clicked order */
WP(w,order_d).sel = -1; WP(w, order_d).sel = -1;
} else { } else {
/* Select clicked order */ /* Select clicked order */
WP(w,order_d).sel = selected; WP(w, order_d).sel = selected;
} }
} break; } break;
case 6: { /* "Wait For" button. */ case 6: { /* "Wait For" button. */
int selected = WP(w,order_d).sel; int selected = WP(w, order_d).sel;
VehicleOrderID real = (selected + 1) / 2; VehicleOrderID real = (selected + 1) / 2;
if (real >= v->num_orders) real = 0; if (real >= v->num_orders) real = 0;
@ -253,7 +253,7 @@ static void TimetableWndProc(Window *w, WindowEvent *we)
} break; } break;
case 7: { /* Clear waiting time button. */ 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)); DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
} break; } break;
@ -272,7 +272,7 @@ static void TimetableWndProc(Window *w, WindowEvent *we)
case WE_ON_EDIT_TEXT: { case WE_ON_EDIT_TEXT: {
const Vehicle *v = GetVehicle(w->window_number); 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); uint64 time = StrEmpty(we->we.edittext.str) ? 0 : strtoul(we->we.edittext.str, NULL, 10);
if (!_patches.timetable_in_ticks) time *= DAY_TICKS; if (!_patches.timetable_in_ticks) time *= DAY_TICKS;
@ -327,6 +327,6 @@ void ShowTimetableWindow(const Vehicle *v)
w->caption_color = v->owner; w->caption_color = v->owner;
w->vscroll.cap = 8; w->vscroll.cap = 8;
w->resize.step_height = 10; w->resize.step_height = 10;
WP(w,order_d).sel = -1; WP(w, order_d).sel = -1;
} }
} }

View File

@ -140,8 +140,8 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e)
SetVScrollCount(w, numact + 1); SetVScrollCount(w, numact + 1);
if (WP(w,def_d).data_1 != -1 && !HasBit(buttons, WP(w,def_d).data_1)) if (WP(w, def_d).data_1 != -1 && !HasBit(buttons, WP(w,def_d).data_1))
WP(w,def_d).data_1 = -1; WP(w, def_d).data_1 = -1;
w->SetWidgetDisabledState(6, 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) { if (i != -1) {
SetDParam(1, (_price.build_industry >> 8) * _town_action_costs[i]); 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); y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_player, t), y + w->vscroll.pos - 1);
if (y >= 0) { if (y >= 0) {
WP(w,def_d).data_1 = y; WP(w, def_d).data_1 = y;
SetWindowDirty(w); SetWindowDirty(w);
} }
/* Fall through to clicking in case we are double-clicked */ /* Fall through to clicking in case we are double-clicked */
@ -236,7 +236,7 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e)
} }
case TWA_EXECUTE: { 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; break;
} }
} }
@ -262,7 +262,7 @@ static void ShowTownAuthorityWindow(uint town)
if (w != NULL) { if (w != NULL) {
w->vscroll.cap = 5; w->vscroll.cap = 5;
WP(w,def_d).data_1 = -1; WP(w, def_d).data_1 = -1;
} }
} }

View File

@ -1680,7 +1680,7 @@ void UpdateViewportPosition(Window *w)
const ViewPort *vp = w->viewport; const ViewPort *vp = w->viewport;
if (WP(w, vp_d).follow_vehicle != INVALID_VEHICLE) { 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); Point pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos);
SetViewportPosition(w, pt.x, pt.y); SetViewportPosition(w, pt.x, pt.y);

View File

@ -503,12 +503,12 @@ static int GetDropdownItem(const Window *w)
return - 1; return - 1;
item = y / 10; 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; return - 1;
/* Skip hidden items -- +1 for each hidden item before the clicked item. */ /* Skip hidden items -- +1 for each hidden item before the clicked item. */
for (counter = 0; item >= counter; ++counter) 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; return item;
} }
@ -527,19 +527,19 @@ static void DropdownMenuWndProc(Window *w, WindowEvent *e)
x = 1; x = 1;
y = 2 - w->vscroll.pos * 10; 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; width = w->widget[0].right - 3;
height = w->widget[0].bottom - 3; height = w->widget[0].bottom - 3;
for (i = 0; WP(w,dropdown_d).items[i] != INVALID_STRING_ID; i++, sel--) { 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 (HasBit(WP(w, dropdown_d).hidden_state, i)) continue;
if (y >= 0 && y <= height) { 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); 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, GfxFillRect(x, y, x + width, y + 9,
(1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[_dropdown_menu_widgets[0].color][5] (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; if (e->we.click.widget != 0) break;
item = GetDropdownItem(w); item = GetDropdownItem(w);
if (item >= 0) { if (item >= 0) {
WP(w,dropdown_d).click_delay = 4; WP(w, dropdown_d).click_delay = 4;
WP(w,dropdown_d).selected_index = item; WP(w, dropdown_d).selected_index = item;
SetWindowDirty(w); SetWindowDirty(w);
} }
} break; } break;
case WE_MOUSELOOP: { 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) { if (w2 == NULL) {
DeleteWindow(w); DeleteWindow(w);
return; 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; WindowEvent e;
e.event = WE_DROPDOWN_SELECT; e.event = WE_DROPDOWN_SELECT;
e.we.dropdown.button = WP(w,dropdown_d).parent_button; e.we.dropdown.button = WP(w, dropdown_d).parent_button;
e.we.dropdown.index = WP(w,dropdown_d).selected_index; e.we.dropdown.index = WP(w, dropdown_d).selected_index;
w2->wndproc(w2, &e); w2->wndproc(w2, &e);
DeleteWindow(w); DeleteWindow(w);
return; return;
} }
if (WP(w,dropdown_d).drag_mode) { if (WP(w, dropdown_d).drag_mode) {
item = GetDropdownItem(w); item = GetDropdownItem(w);
if (!_left_button_clicked) { if (!_left_button_clicked) {
WP(w,dropdown_d).drag_mode = false; WP(w, dropdown_d).drag_mode = false;
if (item < 0) return; if (item < 0) return;
WP(w,dropdown_d).click_delay = 2; WP(w, dropdown_d).click_delay = 2;
} else { } else {
if (item < 0) return; if (item < 0) return;
} }
WP(w,dropdown_d).selected_index = item; WP(w, dropdown_d).selected_index = item;
SetWindowDirty(w); SetWindowDirty(w);
} }
} break; } break;
case WE_DESTROY: { 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) { if (w2 != NULL) {
w2->RaiseWidget(WP(w,dropdown_d).parent_button); w2->RaiseWidget(WP(w, dropdown_d).parent_button);
w2->InvalidateWidget(WP(w,dropdown_d).parent_button); w2->InvalidateWidget(WP(w, dropdown_d).parent_button);
} }
} break; } break;
} }
@ -696,19 +696,19 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt
w2->desc_flags = WDF_DEF_WIDGET; w2->desc_flags = WDF_DEF_WIDGET;
w2->flags4 &= ~WF_WHITE_BORDER_MASK; w2->flags4 &= ~WF_WHITE_BORDER_MASK;
WP(w2,dropdown_d).disabled_state = disabled_mask; WP(w2, dropdown_d).disabled_state = disabled_mask;
WP(w2,dropdown_d).hidden_state = hidden_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_class = w->window_class;
WP(w2,dropdown_d).parent_wnd_num = w->window_number; WP(w2, dropdown_d).parent_wnd_num = w->window_number;
WP(w2,dropdown_d).parent_button = button; WP(w2, dropdown_d).parent_button = button;
WP(w2,dropdown_d).num_items = i; WP(w2, dropdown_d).num_items = i;
WP(w2,dropdown_d).selected_index = selected; WP(w2, dropdown_d).selected_index = selected;
WP(w2,dropdown_d).items = strings; WP(w2, dropdown_d).items = strings;
WP(w2,dropdown_d).click_delay = 0; WP(w2, dropdown_d).click_delay = 0;
WP(w2,dropdown_d).drag_mode = true; WP(w2, dropdown_d).drag_mode = true;
} }

View File

@ -237,7 +237,7 @@ struct Textbuf {
uint16 caretxoffs; ///< the current position of the caret in pixels 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 /* You cannot 100% reliably calculate the biggest custom struct as
* the number of pointers in it and alignment will have a huge impact. * the number of pointers in it and alignment will have a huge impact.
* 96 is the largest window-size for 64-bit machines currently */ * 96 is the largest window-size for 64-bit machines currently */