virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { case WID_SIL_LIST: { uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SIL_LIST, WD_FRAMERECT_TOP); if (id_v == INT_MAX) return; const Sign *si = this->signs[id_v]; ScrollMainWindowToTile(TileVirtXY(si->x, si->y)); break; } case WID_SIL_FILTER_ENTER_BTN: if (this->signs.Length() >= 1) { const Sign *si = this->signs[0]; ScrollMainWindowToTile(TileVirtXY(si->x, si->y)); } break; case WID_SIL_FILTER_MATCH_CASE_BTN: SignList::match_case = !SignList::match_case; // Toggle match case this->SetWidgetLoweredState(WID_SIL_FILTER_MATCH_CASE_BTN, SignList::match_case); // Toggle button pushed state this->InvalidateData(); // Rebuild the list of signs break; } }
/** * Show a new Extra Viewport window. * Center it on the tile under the cursor, if the cursor is inside a viewport. * If that fails, center it on main viewport center. */ void ShowExtraViewPortWindowForTileUnderCursor() { /* Use tile under mouse as center for new viewport. * Do this before creating the window, it might appear just below the mouse. */ Point pt = GetTileBelowCursor(); ShowExtraViewPortWindow(pt.x != -1 ? TileVirtXY(pt.x, pt.y) : INVALID_TILE); }
virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { case WID_QES_PREVIOUS: case WID_QES_NEXT: { const Sign *si = this->PrevNextSign(widget == WID_QES_NEXT); /* Rebuild the sign list */ this->signs.ForceRebuild(); this->signs.NeedResort(); this->BuildSignsList(); this->SortSignsList(); /* Scroll to sign and reopen window */ ScrollMainWindowToTile(TileVirtXY(si->x, si->y)); UpdateSignEditWindow(si); break; } case WID_QES_DELETE: /* Only need to set the buffer to null, the rest is handled as the OK button */ RenameSign(this->cur_sign, ""); /* don't delete this, we are deleted in Sign::~Sign() -> DeleteRenameSignWindow() */ break; case WID_QES_OK: if (RenameSign(this->cur_sign, this->name_editbox.text.buf)) break; /* FALL THROUGH */ case WID_QES_CANCEL: delete this; break; } }
static void SetDisasterVehiclePos(DisasterVehicle *v, int x, int y, byte z) { v->x_pos = x; v->y_pos = y; v->z_pos = z; v->tile = TileVirtXY(x, y); DisasterVehicleUpdateImage(v); VehicleMove(v, true); DisasterVehicle *u = v->Next(); if (u != NULL) { int safe_x = Clamp(x, 0, MapMaxX() * TILE_SIZE); int safe_y = Clamp(y - 1, 0, MapMaxY() * TILE_SIZE); u->x_pos = x; u->y_pos = y - 1 - (max(z - GetSlopeZ(safe_x, safe_y), 0U) >> 3); safe_y = Clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE); u->z_pos = GetSlopeZ(safe_x, safe_y); u->direction = v->direction; DisasterVehicleUpdateImage(u); VehicleMove(u, true); if ((u = u->Next()) != NULL) { u->x_pos = x; u->y_pos = y; u->z_pos = z + 5; VehicleMove(u, true); } }
static bool BubbleTick(EffectVehicle *v) { uint anim_state; v->progress++; if ((v->progress & 3) != 0) return true; if (v->spritenum == 0) { v->cur_image++; if (v->cur_image < SPR_BUBBLE_GENERATE_3) { v->UpdatePositionAndViewport(); return true; } if (v->animation_substate != 0) { v->spritenum = GB(Random(), 0, 2) + 1; } else { v->spritenum = 6; } anim_state = 0; } else { anim_state = v->animation_state + 1; } const BubbleMovement *b = &_bubble_movement[v->spritenum - 1][anim_state]; if (b->y == 4 && b->x == 0) { delete v; return false; } if (b->y == 4 && b->x == 1) { if (v->z_pos > 180 || Chance16I(1, 96, Random())) { v->spritenum = 5; if (_settings_client.sound.ambient) SndPlayVehicleFx(SND_2F_POP, v); } anim_state = 0; } if (b->y == 4 && b->x == 2) { TileIndex tile; anim_state++; if (_settings_client.sound.ambient) SndPlayVehicleFx(SND_31_EXTRACT, v); tile = TileVirtXY(v->x_pos, v->y_pos); if (IsTileType(tile, MP_INDUSTRY) && GetIndustryGfx(tile) == GFX_BUBBLE_CATCHER) AddAnimatedTile(tile); } v->animation_state = anim_state; b = &_bubble_movement[v->spritenum - 1][anim_state]; v->x_pos += b->x; v->y_pos += b->y; v->z_pos += b->z; v->cur_image = SPR_BUBBLE_0 + b->image; v->UpdatePositionAndViewport(); return true; }
/** * Initialize a disaster vehicle. These vehicles are of type VEH_DISASTER, are unclickable * and owned by nobody */ static void InitializeDisasterVehicle(DisasterVehicle *v, int x, int y, int z, Direction direction, byte subtype) { v->x_pos = x; v->y_pos = y; v->z_pos = z; v->tile = TileVirtXY(x, y); v->direction = direction; v->subtype = subtype; v->UpdateDeltaXY(INVALID_DIR); v->owner = OWNER_NONE; v->vehstatus = VS_UNCLICKABLE; v->image_override = 0; v->current_order.Free(); DisasterVehicleUpdateImage(v); VehicleUpdatePositionAndViewport(v); }
static bool ChimneySmokeTick(EffectVehicle *v) { if (v->progress > 0) { v->progress--; } else { TileIndex tile = TileVirtXY(v->x_pos, v->y_pos); if (!IsTileType(tile, MP_INDUSTRY)) { delete v; return false; } if (v->cur_image != SPR_CHIMNEY_SMOKE_7) { v->cur_image++; } else { v->cur_image = SPR_CHIMNEY_SMOKE_0; } v->progress = 7; v->UpdatePositionAndViewport(); } return true; }
virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { case WID_SIL_LIST: { uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SIL_LIST, WD_FRAMERECT_TOP); if (id_v == INT_MAX) return; const Sign *si = this->signs[id_v]; ScrollMainWindowToTile(TileVirtXY(si->x, si->y)); break; } case WID_SIL_FILTER_CLEAR_BTN: this->ClearFilterTextWidget(); // Empty the text in the EditBox widget this->SetFilterString(""); // Use empty text as filter text (= view all signs) break; case WID_SIL_FILTER_MATCH_CASE_BTN: SignList::match_case = !SignList::match_case; // Toggle match case this->SetWidgetLoweredState(WID_SIL_FILTER_MATCH_CASE_BTN, SignList::match_case); // Toggle button pushed state this->InvalidateData(); // Rebuild the list of signs break; } }
virtual EventState OnKeyPress(uint16 key, uint16 keycode) { EventState state = ES_NOT_HANDLED; switch (this->HandleEditBoxKey(WID_SIL_FILTER_TEXT, key, keycode, state)) { case HEBR_EDITING: this->SetFilterString(this->text.buf); break; case HEBR_CONFIRM: // Enter pressed -> goto first sign in list if (this->signs.Length() >= 1) { const Sign *si = this->signs[0]; ScrollMainWindowToTile(TileVirtXY(si->x, si->y)); } return state; case HEBR_CANCEL: // ESC pressed, clear filter. this->OnClick(Point(), WID_SIL_FILTER_CLEAR_BTN, 1); // Simulate click on clear button. this->UnfocusFocusedWidget(); // Unfocus the text box. return state; case HEBR_NOT_FOCUSED: // The filter text box is not globaly focused. if (CheckHotkeyMatch(signlist_hotkeys, keycode, this) == SLHK_FOCUS_FILTER_BOX) { this->SetFocusedWidget(WID_SIL_FILTER_TEXT); SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused. state = ES_HANDLED; } break; default: NOT_REACHED(); } if (state == ES_HANDLED) OnOSKInput(WID_SIL_FILTER_TEXT); return state; }