mirror of https://github.com/OpenTTD/OpenTTD
(svn r14390) -Codechange: replace magic constants with symbolic constants.
parent
ff76ef6a0a
commit
6a931d67cd
|
@ -216,7 +216,7 @@ struct CheatWindow : Window {
|
||||||
|
|
||||||
if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
|
if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
|
||||||
|
|
||||||
flags4 |= 5 << WF_TIMEOUT_SHL;
|
this->flags4 |= WF_TIMEOUT_BEGIN;
|
||||||
|
|
||||||
SetDirty();
|
SetDirty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,7 +403,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
|
||||||
case GLAND_START_DATE_DOWN:
|
case GLAND_START_DATE_DOWN:
|
||||||
case GLAND_START_DATE_UP: // Year buttons
|
case GLAND_START_DATE_UP: // Year buttons
|
||||||
/* Don't allow too fast scrolling */
|
/* Don't allow too fast scrolling */
|
||||||
if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
|
if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
|
||||||
this->HandleButtonClick(widget);
|
this->HandleButtonClick(widget);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
|
||||||
case GLAND_SNOW_LEVEL_DOWN:
|
case GLAND_SNOW_LEVEL_DOWN:
|
||||||
case GLAND_SNOW_LEVEL_UP: // Snow line buttons
|
case GLAND_SNOW_LEVEL_UP: // Snow line buttons
|
||||||
/* Don't allow too fast scrolling */
|
/* Don't allow too fast scrolling */
|
||||||
if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
|
if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
|
||||||
this->HandleButtonClick(widget);
|
this->HandleButtonClick(widget);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
|
||||||
|
@ -697,7 +697,7 @@ struct CreateScenarioWindow : public Window
|
||||||
case CSCEN_START_DATE_DOWN:
|
case CSCEN_START_DATE_DOWN:
|
||||||
case CSCEN_START_DATE_UP: // Year buttons
|
case CSCEN_START_DATE_UP: // Year buttons
|
||||||
/* Don't allow too fast scrolling */
|
/* Don't allow too fast scrolling */
|
||||||
if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
|
if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
|
||||||
this->HandleButtonClick(widget);
|
this->HandleButtonClick(widget);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
|
||||||
|
@ -715,7 +715,7 @@ struct CreateScenarioWindow : public Window
|
||||||
case CSCEN_FLAT_LAND_HEIGHT_DOWN:
|
case CSCEN_FLAT_LAND_HEIGHT_DOWN:
|
||||||
case CSCEN_FLAT_LAND_HEIGHT_UP: // Height level buttons
|
case CSCEN_FLAT_LAND_HEIGHT_UP: // Height level buttons
|
||||||
/* Don't allow too fast scrolling */
|
/* Don't allow too fast scrolling */
|
||||||
if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
|
if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
|
||||||
this->HandleButtonClick(widget);
|
this->HandleButtonClick(widget);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
|
||||||
|
|
|
@ -598,7 +598,7 @@ public:
|
||||||
|
|
||||||
UpdateIndustryProduction(i);
|
UpdateIndustryProduction(i);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
this->flags4 |= 5 << WF_TIMEOUT_SHL;
|
this->flags4 |= WF_TIMEOUT_BEGIN;
|
||||||
this->clicked_line = line + 1;
|
this->clicked_line = line + 1;
|
||||||
this->clicked_button = (x < 15 ? 1 : 2);
|
this->clicked_button = (x < 15 ? 1 : 2);
|
||||||
} else if (IsInsideMM(x, 34, 160)) {
|
} else if (IsInsideMM(x, 34, 160)) {
|
||||||
|
|
|
@ -855,7 +855,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
|
||||||
case NSSW_COMPANIES_BTND: case NSSW_COMPANIES_BTNU: // Click on up/down button for number of companies
|
case NSSW_COMPANIES_BTND: case NSSW_COMPANIES_BTNU: // Click on up/down button for number of companies
|
||||||
case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU: // Click on up/down button for number of spectators
|
case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU: // Click on up/down button for number of spectators
|
||||||
/* Don't allow too fast scrolling */
|
/* Don't allow too fast scrolling */
|
||||||
if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
|
if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
|
||||||
this->HandleButtonClick(widget);
|
this->HandleButtonClick(widget);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
|
|
|
@ -890,8 +890,8 @@ struct PatchesSelectionWindow : Window {
|
||||||
uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval;
|
uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval;
|
||||||
if (step == 0) step = 1;
|
if (step == 0) step = 1;
|
||||||
|
|
||||||
// don't allow too fast scrolling
|
/* don't allow too fast scrolling */
|
||||||
if ((this->flags4 & WF_TIMEOUT_MASK) > 2 << WF_TIMEOUT_SHL) {
|
if ((this->flags4 & WF_TIMEOUT_MASK) > WF_TIMEOUT_TRIGGER) {
|
||||||
_left_button_clicked = false;
|
_left_button_clicked = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -908,7 +908,7 @@ struct PatchesSelectionWindow : Window {
|
||||||
/* 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)) {
|
||||||
this->click = btn * 2 + 1 + ((x >= 10) ? 1 : 0);
|
this->click = btn * 2 + 1 + ((x >= 10) ? 1 : 0);
|
||||||
this->flags4 |= 5 << WF_TIMEOUT_SHL;
|
this->flags4 |= WF_TIMEOUT_BEGIN;
|
||||||
_left_button_clicked = false;
|
_left_button_clicked = false;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -1168,7 +1168,7 @@ struct CustomCurrencyWindow : Window {
|
||||||
ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, 250, this, afilter, QSF_NONE);
|
ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, 250, this, afilter, QSF_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->flags4 |= 5 << WF_TIMEOUT_SHL;
|
this->flags4 |= WF_TIMEOUT_BEGIN;
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -434,7 +434,7 @@ public:
|
||||||
|
|
||||||
case SLW_SORTBY: // flip sorting method asc/desc
|
case SLW_SORTBY: // flip sorting method asc/desc
|
||||||
this->stations.ToggleSortOrder();
|
this->stations.ToggleSortOrder();
|
||||||
this->flags4 |= 5 << WF_TIMEOUT_SHL;
|
this->flags4 |= WF_TIMEOUT_BEGIN;
|
||||||
this->LowerWidget(SLW_SORTBY);
|
this->LowerWidget(SLW_SORTBY);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -747,7 +747,7 @@ static void ToolbarSwitchClick(Window *w)
|
||||||
static void ToolbarScenDateBackward(Window *w)
|
static void ToolbarScenDateBackward(Window *w)
|
||||||
{
|
{
|
||||||
/* don't allow too fast scrolling */
|
/* don't allow too fast scrolling */
|
||||||
if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
|
if ((w->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
|
||||||
w->HandleButtonClick(TBSE_DATEBACKWARD);
|
w->HandleButtonClick(TBSE_DATEBACKWARD);
|
||||||
w->SetDirty();
|
w->SetDirty();
|
||||||
|
|
||||||
|
@ -760,7 +760,7 @@ static void ToolbarScenDateBackward(Window *w)
|
||||||
static void ToolbarScenDateForward(Window *w)
|
static void ToolbarScenDateForward(Window *w)
|
||||||
{
|
{
|
||||||
/* don't allow too fast scrolling */
|
/* don't allow too fast scrolling */
|
||||||
if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
|
if ((w->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
|
||||||
w->HandleButtonClick(TBSE_DATEFORWARD);
|
w->HandleButtonClick(TBSE_DATEFORWARD);
|
||||||
w->SetDirty();
|
w->SetDirty();
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ public:
|
||||||
|
|
||||||
case BTW_MANY_RANDOM: // place trees randomly over the landscape
|
case BTW_MANY_RANDOM: // place trees randomly over the landscape
|
||||||
this->LowerWidget(BTW_MANY_RANDOM);
|
this->LowerWidget(BTW_MANY_RANDOM);
|
||||||
this->flags4 |= 5 << WF_TIMEOUT_SHL;
|
this->flags4 |= WF_TIMEOUT_BEGIN;
|
||||||
SndPlayFx(SND_15_BEEP);
|
SndPlayFx(SND_15_BEEP);
|
||||||
PlaceTreesRandomly();
|
PlaceTreesRandomly();
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
|
|
|
@ -116,7 +116,7 @@ void Window::InvalidateWidget(byte widget_index) const
|
||||||
void Window::HandleButtonClick(byte widget)
|
void Window::HandleButtonClick(byte widget)
|
||||||
{
|
{
|
||||||
this->LowerWidget(widget);
|
this->LowerWidget(widget);
|
||||||
this->flags4 |= 5 << WF_TIMEOUT_SHL;
|
this->flags4 |= WF_TIMEOUT_BEGIN;
|
||||||
this->InvalidateWidget(widget);
|
this->InvalidateWidget(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -487,8 +487,9 @@ enum WindowWidgetTypes {
|
||||||
* Window flags
|
* Window flags
|
||||||
*/
|
*/
|
||||||
enum WindowFlags {
|
enum WindowFlags {
|
||||||
WF_TIMEOUT_SHL = 0, ///< Window timeout counter shift
|
WF_TIMEOUT_TRIGGER = 2, ///< When the timeout should start triggering
|
||||||
WF_TIMEOUT_MASK = 7, ///< Window timeout counter bit mask (3 bits), @see WF_TIMEOUT_SHL
|
WF_TIMEOUT_BEGIN = 5, ///< The initial value for the timeout
|
||||||
|
WF_TIMEOUT_MASK = 7, ///< Window timeout counter bit mask (3 bits)
|
||||||
WF_DRAGGING = 1 << 3, ///< Window is being dragged
|
WF_DRAGGING = 1 << 3, ///< Window is being dragged
|
||||||
WF_SCROLL_UP = 1 << 4, ///< Upper scroll button has been pressed, @see ScrollbarClickHandler()
|
WF_SCROLL_UP = 1 << 4, ///< Upper scroll button has been pressed, @see ScrollbarClickHandler()
|
||||||
WF_SCROLL_DOWN = 1 << 5, ///< Lower scroll button has been pressed, @see ScrollbarClickHandler()
|
WF_SCROLL_DOWN = 1 << 5, ///< Lower scroll button has been pressed, @see ScrollbarClickHandler()
|
||||||
|
|
Loading…
Reference in New Issue