(svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
--- a/src/aircraft_gui.cpp Tue Feb 13 22:58:31 2007 +0000
+++ b/src/aircraft_gui.cpp Tue Feb 13 23:07:54 2007 +0000
@@ -346,9 +346,9 @@
/* Widget 7 (send to hangar) must be hidden if the plane is already stopped in hangar.
* Widget 11 (clone) should then be shown, since cloning is allowed only while in hangar and stopped.
* This sytem allows to have two buttons, on top of each other*/
- if (plane_stopped != IsWindowWidgetHidden(w, 7) || plane_stopped == IsWindowWidgetHidden(w, 11)) {
- SetWindowWidgetHiddenState(w, 7, plane_stopped); // send to hangar
- SetWindowWidgetHiddenState(w, 11, !plane_stopped); // clone
+ if (plane_stopped != w->IsWidgetHidden(7) || plane_stopped == w->IsWidgetHidden(11)) {
+ w->SetWidgetHiddenState( 7, plane_stopped); // send to hangar
+ w->SetWidgetHiddenState(11, !plane_stopped); // clone
w->SetDirty();
}
} break;
--- a/src/network/network_gui.cpp Tue Feb 13 22:58:31 2007 +0000
+++ b/src/network/network_gui.cpp Tue Feb 13 23:07:54 2007 +0000
@@ -250,7 +250,7 @@
sel->info.clients_on >= sel->info.clients_max || // Server full
!sel->info.compatible); // Revision mismatch
- SetWindowWidgetHiddenState(w, 18, sel == NULL ||
+ w->SetWidgetHiddenState(18, sel == NULL ||
!sel->online ||
sel->info.grfconfig == NULL);
--- a/src/order_gui.cpp Tue Feb 13 22:58:31 2007 +0000
+++ b/src/order_gui.cpp Tue Feb 13 23:07:54 2007 +0000
@@ -104,12 +104,12 @@
/* Disable list of vehicles with the same shared orders if there is no list */
w->SetWidgetDisabledState(ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders || v->orders == NULL);
w->SetWidgetDisabledState(ORDER_WIDGET_REFIT, order == NULL); // Refit
- HideWindowWidget(w, ORDER_WIDGET_REFIT); // Refit
+ w->HideWidget(ORDER_WIDGET_REFIT); // Refit
} else {
w->DisableWidget(ORDER_WIDGET_TRANSFER);
}
- ShowWindowWidget(w, ORDER_WIDGET_UNLOAD); // Unload
+ w->ShowWidget(ORDER_WIDGET_UNLOAD); // Unload
if (order != NULL) {
switch (order->type) {
@@ -119,8 +119,8 @@
w->DisableWidget(ORDER_WIDGET_TRANSFER);
/* Remove unload and replace it with refit */
- HideWindowWidget(w, ORDER_WIDGET_UNLOAD);
- ShowWindowWidget(w, ORDER_WIDGET_REFIT);
+ w->HideWidget(ORDER_WIDGET_UNLOAD);
+ w->ShowWidget(ORDER_WIDGET_REFIT);
SetDParam(2,STR_SERVICE);
break;
--- a/src/player_gui.cpp Tue Feb 13 22:58:31 2007 +0000
+++ b/src/player_gui.cpp Tue Feb 13 23:07:54 2007 +0000
@@ -321,8 +321,8 @@
case WE_CREATE:
LowerWindowWidget(w, WP(w, livery_d).livery_class + 2);
if (!_have_2cc) {
- HideWindowWidget(w, 11);
- HideWindowWidget(w, 12);
+ w->HideWidget(11);
+ w->HideWidget(12);
}
break;
@@ -679,17 +679,17 @@
const Player *p = GetPlayer((PlayerID)w->window_number);
bool local = w->window_number == _local_player;
- SetWindowWidgetHiddenState(w, PCW_WIDGET_NEW_FACE, !local);
- SetWindowWidgetHiddenState(w, PCW_WIDGET_COLOR_SCHEME, !local);
- SetWindowWidgetHiddenState(w, PCW_WIDGET_PRESIDENT_NAME, !local);
- SetWindowWidgetHiddenState(w, PCW_WIDGET_COMPANY_NAME, !local);
+ w->SetWidgetHiddenState(PCW_WIDGET_NEW_FACE, !local);
+ w->SetWidgetHiddenState(PCW_WIDGET_COLOR_SCHEME, !local);
+ w->SetWidgetHiddenState(PCW_WIDGET_PRESIDENT_NAME, !local);
+ w->SetWidgetHiddenState(PCW_WIDGET_COMPANY_NAME, !local);
w->widget[PCW_WIDGET_BUILD_VIEW_HQ].data = (local && p->location_of_house == 0) ? STR_706F_BUILD_HQ : STR_7072_VIEW_HQ;
if (local && p->location_of_house != 0) w->widget[PCW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; //HQ is already built.
w->SetWidgetDisabledState(PCW_WIDGET_BUILD_VIEW_HQ, !local && p->location_of_house == 0);
- SetWindowWidgetHiddenState(w, PCW_WIDGET_RELOCATE_HQ, !local || p->location_of_house == 0);
- SetWindowWidgetHiddenState(w, PCW_WIDGET_BUY_SHARE, local);
- SetWindowWidgetHiddenState(w, PCW_WIDGET_SELL_SHARE, local);
- SetWindowWidgetHiddenState(w, PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
+ w->SetWidgetHiddenState(PCW_WIDGET_RELOCATE_HQ, !local || p->location_of_house == 0);
+ w->SetWidgetHiddenState(PCW_WIDGET_BUY_SHARE, local);
+ w->SetWidgetHiddenState(PCW_WIDGET_SELL_SHARE, local);
+ w->SetWidgetHiddenState(PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
if (!local) {
if (_patches.allow_shares) { // Shares are allowed
--- a/src/roadveh_gui.cpp Tue Feb 13 22:58:31 2007 +0000
+++ b/src/roadveh_gui.cpp Tue Feb 13 23:07:54 2007 +0000
@@ -295,11 +295,11 @@
* Widget 11 (clone) should then be shown, since cloning is allowed only while in depot and stopped.
* This sytem allows to have two buttons, on top of each other.
* The same system applies to widget 8 and 12, force turn around and refit. */
- if (rv_stopped != IsWindowWidgetHidden(w, 7) || rv_stopped == IsWindowWidgetHidden(w, 11)) {
- SetWindowWidgetHiddenState(w, 7, rv_stopped); // send to depot
- SetWindowWidgetHiddenState(w, 8, rv_stopped); // force turn around
- SetWindowWidgetHiddenState(w, 11, !rv_stopped); // clone
- SetWindowWidgetHiddenState(w, 12, !rv_stopped); // refit
+ if (rv_stopped != w->IsWidgetHidden(7) || rv_stopped == w->IsWidgetHidden(11)) {
+ w->SetWidgetHiddenState( 7, rv_stopped); // send to depot
+ w->SetWidgetHiddenState( 8, rv_stopped); // force turn around
+ w->SetWidgetHiddenState(11, !rv_stopped); // clone
+ w->SetWidgetHiddenState(12, !rv_stopped); // refit
w->SetDirty();
}
}
--- a/src/ship_gui.cpp Tue Feb 13 22:58:31 2007 +0000
+++ b/src/ship_gui.cpp Tue Feb 13 23:07:54 2007 +0000
@@ -299,9 +299,9 @@
/* Widget 7 (send to depot) must be hidden if the ship is already stopped in depot.
* Widget 11 (clone) should then be shown, since cloning is allowed only while in depot and stopped.
* This sytem allows to have two buttons, on top of each otherother*/
- if (ship_stopped != IsWindowWidgetHidden(w, 7) || ship_stopped == IsWindowWidgetHidden(w, 11)) {
- SetWindowWidgetHiddenState(w, 7, ship_stopped); // send to depot
- SetWindowWidgetHiddenState(w, 11, !ship_stopped); // clone
+ if (ship_stopped != w->IsWidgetHidden(7) || ship_stopped == w->IsWidgetHidden(11)) {
+ w->SetWidgetHiddenState( 7, ship_stopped); // send to depot
+ w->SetWidgetHiddenState(11, !ship_stopped); // clone
w->SetDirty();
}
}
--- a/src/train_gui.cpp Tue Feb 13 22:58:31 2007 +0000
+++ b/src/train_gui.cpp Tue Feb 13 23:07:54 2007 +0000
@@ -291,11 +291,11 @@
* Widget 13 (clone) should then be shown, since cloning is allowed only while in depot and stopped.
* This sytem allows to have two buttons, on top of each other.
* The same system applies to widget 9 and 12, reverse direction and refit*/
- if (train_stopped != IsWindowWidgetHidden(w, 7) || train_stopped == IsWindowWidgetHidden(w, 13)) {
- SetWindowWidgetHiddenState(w, 7, train_stopped); // send to depot
- SetWindowWidgetHiddenState(w, 9, train_stopped); // reverse direction
- SetWindowWidgetHiddenState(w, 12, !train_stopped); // refit
- SetWindowWidgetHiddenState(w, 13, !train_stopped); // clone
+ if (train_stopped != w->IsWidgetHidden(7) || train_stopped == w->IsWidgetHidden(13)) {
+ w->SetWidgetHiddenState( 7, train_stopped); // send to depot
+ w->SetWidgetHiddenState( 9, train_stopped); // reverse direction
+ w->SetWidgetHiddenState(12, !train_stopped); // refit
+ w->SetWidgetHiddenState(13, !train_stopped); // clone
w->SetDirty();
}
break;
--- a/src/vehicle_gui.cpp Tue Feb 13 22:58:31 2007 +0000
+++ b/src/vehicle_gui.cpp Tue Feb 13 23:07:54 2007 +0000
@@ -815,7 +815,7 @@
/* Hide the widgets that we will not use in this window
* Some windows contains actions only fit for the owner */
if (player == _local_player) {
- HideWindowWidget(w, VLW_WIDGET_OTHER_PLAYER_FILLER);
+ w->HideWidget(VLW_WIDGET_OTHER_PLAYER_FILLER);
w->SetWidgetDisabledState(VLW_WIDGET_AVAILABLE_VEHICLES, window_type != VLW_STANDARD);
} else {
w->SetWidgetsHiddenState(true,
--- a/src/widget.cpp Tue Feb 13 22:58:31 2007 +0000
+++ b/src/widget.cpp Tue Feb 13 23:07:54 2007 +0000
@@ -140,7 +140,7 @@
if (wi->type == WWT_EMPTY || wi->type == WWT_FRAME) continue;
if (x >= wi->left && x <= wi->right && y >= wi->top && y <= wi->bottom &&
- !IsWindowWidgetHidden(this, index)) {
+ !IsWidgetHidden(index)) {
found_index = index;
}
}
@@ -195,7 +195,7 @@
dpi->left + dpi->width <= (r.left=wi->left/* + w->left*/) ||
dpi->top > (r.bottom=/*w->top +*/ wi->bottom) ||
dpi->top + dpi->height <= (r.top = /*w->top +*/ wi->top) ||
- IsWindowWidgetHidden(this, i)) {
+ IsWidgetHidden(i)) {
continue;
}
@@ -664,7 +664,7 @@
w1->widget[0].right = wi->right - wi[-1].left;
w1->widget[0].bottom = menu_height - 1;
- SetWindowWidgetHiddenState(w1, 1, !scroll);
+ w1->SetWidgetHiddenState(1, !scroll);
if (scroll) {
/* We're scrolling, so enable the scroll bar and shrink the list by
--- a/src/window.cpp Tue Feb 13 22:58:31 2007 +0000
+++ b/src/window.cpp Tue Feb 13 23:07:54 2007 +0000
@@ -285,7 +285,7 @@
va_start(wdg_list, widgets);
while (widgets != WIDGET_LIST_END) {
- SetWindowWidgetHiddenState(this, widgets, hidden_stat);
+ SetWidgetHiddenState(widgets, hidden_stat);
widgets = va_arg(wdg_list, int);
}
@@ -1866,7 +1866,7 @@
const Widget *wi = &widget[widget_index];
/* Don't redraw the window if the widget is invisible or of no-type */
- if (wi->type == WWT_EMPTY || IsWindowWidgetHidden(this, widget_index)) return;
+ if (wi->type == WWT_EMPTY || IsWidgetHidden(widget_index)) return;
SetDirtyBlocks(left + wi->left, top + wi->top, left + wi->right + 1, top + wi->bottom + 1);
}
--- a/src/window.h Tue Feb 13 22:58:31 2007 +0000
+++ b/src/window.h Tue Feb 13 23:07:54 2007 +0000
@@ -446,6 +446,10 @@
/*inline*/ void DisableWidget(byte widget_index);
/*inline*/ void EnableWidget(byte widget_index);
/*inline*/ bool IsWidgetDisabled(byte widget_index) const;
+ /*inline*/ void SetWidgetHiddenState(byte widget_index, bool hidden_stat);
+ /*inline*/ void HideWidget(byte widget_index);
+ /*inline*/ void ShowWidget(byte widget_index);
+ /*inline*/ bool IsWidgetHidden(byte widget_index) const;
//int32 AddRef()
//{
@@ -833,10 +837,10 @@
* @param widget_index index of this widget in the window
* @param hidden_stat status to use ie. hidden = true, visible = false
*/
-static inline void SetWindowWidgetHiddenState(Window *w, byte widget_index, bool hidden_stat)
+inline void Window::SetWidgetHiddenState(byte widget_index, bool hidden_stat)
{
- assert(widget_index < w->widget_count);
- SB(w->widget[widget_index].display_flags, WIDG_HIDDEN, 1, !!hidden_stat);
+ assert(widget_index < widget_count);
+ SB(widget[widget_index].display_flags, WIDG_HIDDEN, 1, !!hidden_stat);
}
/**
@@ -844,9 +848,9 @@
* @param w : Window on which the widget is located
* @param widget_index : index of this widget in the window
*/
-static inline void HideWindowWidget(Window *w, byte widget_index)
+inline void Window::HideWidget(byte widget_index)
{
- SetWindowWidgetHiddenState(w, widget_index, true);
+ SetWidgetHiddenState(widget_index, true);
}
/**
@@ -854,9 +858,9 @@
* @param w : Window on which the widget is located
* @param widget_index : index of this widget in the window
*/
-static inline void ShowWindowWidget(Window *w, byte widget_index)
+inline void Window::ShowWidget(byte widget_index)
{
- SetWindowWidgetHiddenState(w, widget_index, false);
+ SetWidgetHiddenState(widget_index, false);
}
/**
@@ -865,10 +869,10 @@
* @param widget_index : index of this widget in the window
* @return status of the widget ie: hidden = true, visible = false
*/
-static inline bool IsWindowWidgetHidden(const Window *w, byte widget_index)
+inline bool Window::IsWidgetHidden(byte widget_index) const
{
- assert(widget_index < w->widget_count);
- return HASBIT(w->widget[widget_index].display_flags, WIDG_HIDDEN);
+ assert(widget_index < widget_count);
+ return HASBIT(widget[widget_index].display_flags, WIDG_HIDDEN);
}
/**