virtual void OnClick(Point pt, int widget, int click_count) { if (widget >= WID_TT_BEGIN && widget < WID_TT_END) { if (_ctrl_pressed) { /* toggle the bit of the transparencies lock variable */ ToggleTransparencyLock((TransparencyOption)(widget - WID_TT_BEGIN)); this->SetDirty(); } else { /* toggle the bit of the transparencies variable and play a sound */ ToggleTransparency((TransparencyOption)(widget - WID_TT_BEGIN)); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); MarkWholeScreenDirty(); } } else if (widget == WID_TT_BUTTONS) { uint i; for (i = WID_TT_BEGIN; i < WID_TT_END; i++) { const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(i); if (IsInsideBS(pt.x, nwid->pos_x, nwid->current_x)) { break; } } if (i == WID_TT_LOADING || i == WID_TT_END) return; ToggleInvisibility((TransparencyOption)(i - WID_TT_BEGIN)); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); /* Redraw whole screen only if transparency is set */ if (IsTransparencySet((TransparencyOption)(i - WID_TT_BEGIN))) { MarkWholeScreenDirty(); } else { this->SetWidgetDirty(WID_TT_BUTTONS); } } }
/** Show news item in the ticker */ static void ShowTicker(const NewsItem *ni) { if (_settings_client.sound.news_ticker) SndPlayFx(SND_16_MORSE); _statusbar_news_item = ni; InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SHOW_TICKER); }
/** Open up an own newspaper window for the news item */ static void ShowNewspaper(const NewsItem *ni) { SoundFx sound = _news_type_data[ni->type].sound; if (sound != 0 && _settings_client.sound.news_full) SndPlayFx(sound); new NewsWindow(GetNewsWindowLayout(ni->flags), ni); }
virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { case WID_BT_TYPE_11: case WID_BT_TYPE_12: case WID_BT_TYPE_13: case WID_BT_TYPE_14: case WID_BT_TYPE_21: case WID_BT_TYPE_22: case WID_BT_TYPE_23: case WID_BT_TYPE_24: case WID_BT_TYPE_31: case WID_BT_TYPE_32: case WID_BT_TYPE_33: case WID_BT_TYPE_34: if (widget - WID_BT_TYPE_11 >= this->count) break; if (HandlePlacePushButton(this, widget, SPR_CURSOR_TREE, HT_RECT)) { this->tree_to_plant = (TreeType)(this->base + widget - WID_BT_TYPE_11); } break; case WID_BT_TYPE_RANDOM: // tree of random type. if (HandlePlacePushButton(this, WID_BT_TYPE_RANDOM, SPR_CURSOR_TREE, HT_RECT)) { this->tree_to_plant = TREE_INVALID; } break; case WID_BT_MANY_RANDOM: // place trees randomly over the landscape if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP); PlaceTreesRandomly(); MarkWholeScreenDirty(); break; } }
/** Open up an own newspaper window for the news item */ static void ShowNewspaper(const NewsItem *ni) { SoundFx sound = _news_type_data[_news_subtype_data[ni->subtype].type].sound; if (sound != 0) SndPlayFx(sound); new NewsWindow(_news_subtype_data[ni->subtype].desc, ni); }
/** * A year has passed, update the economic data of all companies, and perhaps show the * financial overview window of the local company. */ void CompaniesYearlyLoop() { Company *c; /* Copy statistics */ FOR_ALL_COMPANIES(c) { memmove(&c->yearly_expenses[1], &c->yearly_expenses[0], sizeof(c->yearly_expenses) - sizeof(c->yearly_expenses[0])); memset(&c->yearly_expenses[0], 0, sizeof(c->yearly_expenses[0])); SetWindowDirty(WC_FINANCES, c->index); } if (_settings_client.gui.show_finances && _local_company != COMPANY_SPECTATOR) { ShowCompanyFinances(_local_company); c = Company::Get(_local_company); if (c->num_valid_stat_ent > 5 && c->old_economy[0].performance_history < c->old_economy[4].performance_history) { SndPlayFx(SND_01_BAD_YEAR); } else { SndPlayFx(SND_00_GOOD_YEAR); } } }
virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { case BDSW_LT_OFF: case BDSW_LT_ON: this->RaiseWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF); _settings_client.gui.station_show_coverage = (widget != BDSW_LT_OFF); this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; } }
virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { case WID_BDD_X: case WID_BDD_Y: this->RaiseWidget(_ship_depot_direction + WID_BDD_X); _ship_depot_direction = (widget == WID_BDD_X ? AXIS_X : AXIS_Y); this->LowerWidget(_ship_depot_direction + WID_BDD_X); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); UpdateDocksDirection(); this->SetDirty(); break; } }
virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { case BDDW_X: case BDDW_Y: this->RaiseWidget(_ship_depot_direction + BDDW_X); _ship_depot_direction = (widget == BDDW_X ? AXIS_X : AXIS_Y); this->LowerWidget(_ship_depot_direction + BDDW_X); SndPlayFx(SND_15_BEEP); UpdateDocksDirection(); this->SetDirty(); break; } }
/** * This code is shared for the majority of the pushbuttons. * Handles e.g. the pressing of a button (to build things), playing of click sound and sets certain parameters * * @param w Window which called the function * @param widget ID of the widget (=button) that called this function * @param cursor How should the cursor image change? E.g. cursor with depot image in it * @param mode Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground * @return true if the button is clicked, false if it's unclicked */ bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode) { if (w->IsWidgetDisabled(widget)) return false; if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); w->SetDirty(); if (w->IsWidgetLowered(widget)) { ResetObjectToPlace(); return false; } SetObjectToPlace(cursor, PAL_NONE, mode, w->window_class, w->window_number); w->LowerWidget(widget); return true; }
virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { case BAIRW_CLASS_DROPDOWN: ShowDropDownList(this, BuildAirportClassDropDown(), _selected_airport_class, BAIRW_CLASS_DROPDOWN); break; case BAIRW_AIRPORT_LIST: { int num_clicked = this->vscroll->GetPosition() + (pt.y - this->nested_array[widget]->pos_y) / this->line_height; if (num_clicked >= this->vscroll->GetCount()) break; const AirportSpec *as = AirportClass::Get(_selected_airport_class, num_clicked); if (as->IsAvailable()) this->SelectOtherAirport(num_clicked); break; } case BAIRW_BTN_DONTHILIGHT: case BAIRW_BTN_DOHILIGHT: _settings_client.gui.station_show_coverage = (widget != BAIRW_BTN_DONTHILIGHT); this->SetWidgetLoweredState(BAIRW_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage); this->SetWidgetLoweredState(BAIRW_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage); this->SetDirty(); SndPlayFx(SND_15_BEEP); this->UpdateSelectSize(); break; case BAIRW_LAYOUT_DECREASE: _selected_airport_layout--; this->UpdateSelectSize(); this->SetDirty(); break; case BAIRW_LAYOUT_INCREASE: _selected_airport_layout++; this->UpdateSelectSize(); this->SetDirty(); break; } }
virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { case BTW_TYPE_11: case BTW_TYPE_12: case BTW_TYPE_13: case BTW_TYPE_14: case BTW_TYPE_21: case BTW_TYPE_22: case BTW_TYPE_23: case BTW_TYPE_24: case BTW_TYPE_31: case BTW_TYPE_32: case BTW_TYPE_33: case BTW_TYPE_34: if (widget - BTW_TYPE_11 >= this->count) break; if (HandlePlacePushButton(this, widget, SPR_CURSOR_TREE, HT_RECT)) { this->tree_to_plant = (TreeType)(this->base + widget - BTW_TYPE_11); } break; case BTW_TYPE_RANDOM: // tree of random type. if (HandlePlacePushButton(this, BTW_TYPE_RANDOM, SPR_CURSOR_TREE, HT_RECT)) { this->tree_to_plant = TREE_INVALID; } break; case BTW_MANY_RANDOM: // place trees randomly over the landscape this->LowerWidget(BTW_MANY_RANDOM); this->flags4 |= WF_TIMEOUT_BEGIN; SndPlayFx(SND_15_BEEP); PlaceTreesRandomly(); MarkWholeScreenDirty(); break; } }