//======================================================================== void AHexEditorActor::Expand(const S_HexCoordinates& dir) { check(m_SelectedHexTile); S_HexCoordinates expandedCoordinated = m_SelectedHexTile->GetCoordinates() + dir; check(m_Grid.GetElement(expandedCoordinated) == nullptr); auto* tile = GetWorld()->SpawnActor<AHexTileActor>(); tile->Init(expandedCoordinated); m_Grid.InsertElement(expandedCoordinated, tile); if (dir.IsHorizontalDir()) { auto hexDir = dir.ToHexDir(); auto* barrier = m_SelectedHexTile->GetBarrierAt(hexDir); if (barrier) { auto complementDir = T_HexGrid::GetComplementaryNeighborIndex(hexDir); tile->PlaceBarrierAt(*barrier, complementDir); barrier->Place(*m_SelectedHexTile, hexDir, tile, complementDir); } } DeselectTile(); SelectTile(tile); }
void FieldView::MouseDown(BPoint pt) { if (fPauseMode || gGameState == GAME_OVER) return; SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); fTracking = true; GetMouse(&pt, &fButtons, true); if (gGameState == GAME_STOPPED) { Window()->PostMessage(M_START_TIMER); IntPoint tilePt; BRect r(gGameStyle->TileSize()); tilePt.x = uint16(pt.x / (r.Width() + 1.0)); tilePt.y = uint16(pt.y / (r.Height() + 1.0)); if (fButtons == B_PRIMARY_MOUSE_BUTTON) fField->TeleportMine(tilePt); Invalidate(); } if (gPlaySounds && gGameState != GAME_OVER) fClickPlayer->StartPlaying(); SelectTile(pt); fMainWin->SetFace(FACE_WORRY); }
//======================================================================== void AHexEditorActor::ClearAll() { std::vector<AHexTileActor*> toDelete; for (auto& pair: m_Grid.GetStorage()) { if (!pair.first.IsZero()) //delete all but main tile { toDelete.push_back(pair.second); } } while (!toDelete.empty()) { SelectTile(toDelete.back()); DeleteTile(); toDelete.pop_back(); } DeleteAllCompanions(); DeleteAllBlockers(); DeleteAllTurrets(); DeleteAllTeleports(); DeleteFinish(); auto* element = m_Grid.GetElement({ 0,0,0 }); check(element); UnlinkAllFromTile(*element); }
void LevMap::CheckClickTile(int x, int y) { //within bounds of tile selector? if (GfxStuff->CheckSelValidPos(x, y)) { x /= 8; y /= 8; x -= xSize+1; SelectTile(x+GfxStuff->GetSelectorWidth()*(y + GfxStuff->GetSelOffset()) + GfxStuff->GetTileOffset()+ 1); } }
void CMaNGOS_Map::handleClick(const float* s, const float* p, bool shift, bool control) { if (m_tool) m_tool->handleClick(s, p, shift); if (control) SelectTile(p); rcVcopy(m_LastClick, p); }
void FieldView::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg) { if (!fTracking) return; if (Bounds().Contains(pt)) SelectTile(pt); }
void FieldView::MouseUp(BPoint pt) { if (fPauseMode) Window()->PostMessage(M_PAUSE_GAME); if (!fTracking) return; SelectTile(pt); if (Bounds().Contains(pt)) InvokeTile(pt, fButtons); fTracking = false; }
//======================================================================== void AHexEditorActor::ClickOnTile(AHexTileActor& hexTile) { if (m_InputType == InputMode::Expanding) { SelectTile(&hexTile); } else if (m_InputType == InputMode::Barriers) { PlaceBarrier(); } else if (m_InputType == InputMode::Platforms) { PlacePlatform(); } else if (m_InputType == InputMode::Companions) { PlaceCompanion(); } else if (m_InputType == InputMode::Blockers) { PlaceBlocker(hexTile); } else if (m_InputType == InputMode::Bridges) { PlaceBridge(hexTile); } else if (m_InputType == InputMode::Turrets) { PlaceTurret(hexTile); } else if (m_InputType == InputMode::Teleports) { PlaceTeleport(hexTile); } else if (m_InputType == InputMode::Finish) { PlaceFinish(hexTile); } }
//======================================================================== void AHexEditorActor::DeselectTile() { SelectTile(nullptr); m_AttachingPlatform = false; }
/* mouse coords */ void LevMap::CheckSelectTile(int x, int y) { GfxStuff->PosScreenToTile(&x, &y); SelectTile(x, y); }