WmMouseEvent GuiWindow::OnMouseButtonEvent(uint8 state) { if (!IsLeftClick(state) || this->mouse_pos.x < 0) return WMME_NONE; BaseWidget *bw = this->tree->GetWidgetByPosition(this->mouse_pos); if (bw == nullptr) return WMME_NONE; if (bw->wtype == WT_TITLEBAR) return WMME_MOVE_WINDOW; if (bw->wtype == WT_CLOSEBOX) return WMME_CLOSE_WINDOW; Point16 widget_pos(static_cast<int16>(this->mouse_pos.x - bw->pos.base.x), static_cast<int16>(this->mouse_pos.y - bw->pos.base.y)); LeafWidget *lw = dynamic_cast<LeafWidget *>(bw); if (lw != nullptr) { if (lw->IsShaded()) return WMME_NONE; if (bw->wtype == WT_TEXT_PUSHBUTTON || bw->wtype == WT_IMAGE_PUSHBUTTON) { /* For mono-stable buttons, 'press' the button, and set a timeout for 'releasing' it again. */ lw->SetPressed(true); this->timeout = 4; lw->MarkDirty(this->rect.base); } ScrollbarWidget *sw = dynamic_cast<ScrollbarWidget *>(bw); if (sw != nullptr) { sw->OnClick(this->rect.base, widget_pos); return WMME_NONE; } } if (bw->number >= 0) this->OnClick(bw->number, widget_pos); return WMME_NONE; }
void FenceGui::SelectorMouseButtonEvent(uint8 state) { if (!IsLeftClick(state)) return; if (this->fence_sel.area.width != 1 || this->fence_sel.area.height != 1) return; if (this->fence_edge == INVALID_EDGE) return; if (_game_mode_mgr.InPlayMode() && _world.GetTileOwner(this->fence_base.x, this->fence_base.y) != OWN_PARK) return; VoxelStack *vs = _world.GetModifyStack(this->fence_base.x, this->fence_base.y); uint16 fences = GetGroundFencesFromMap(vs, this->fence_base.z); fences = SetFenceType(fences, this->fence_edge, this->fence_type); AddGroundFencesToMap(fences, vs, this->fence_base.z); MarkVoxelDirty(this->fence_base); }
void RideBuildWindow::SelectorMouseButtonEvent(uint8 state) { if (!IsLeftClick(state)) return; if (this->selector.area.width != 1 || this->selector.area.height != 1) return; ShopInstance *si = static_cast<ShopInstance *>(this->instance); SmallRideInstance inst_number = static_cast<SmallRideInstance>(this->instance->GetIndex()); uint8 entrances = si->GetEntranceDirections(si->vox_pos); Voxel *v = _world.GetCreateVoxel(si->vox_pos, true); assert(v != nullptr && v->GetInstance() == SRI_FREE); v->SetInstance(inst_number); v->SetInstanceData(entrances); _rides_manager.NewInstanceAdded(inst_number); AddRemovePathEdges(si->vox_pos, PATH_EMPTY, entrances, false, PAS_QUEUE_PATH); this->instance = nullptr; // Delete this window, and si = nullptr; // (Also clean the copy of the pointer.) delete this; ShowShopManagementGui(inst_number); // Open gui for the new shop. }