Kelsidavis-WoWee/include/rendering/world_map/view_state_machine.hpp
Pavel Okhlopkov fff06fc932 refactor: decompose world map into modular component architecture
Break the monolithic 1360-line world_map.cpp into 16 focused modules
under src/rendering/world_map/:

Architecture:
- world_map_facade: public API composing all components (PIMPL)
- world_map_types: Vulkan-free domain types (Zone, ViewLevel, etc.)
- data_repository: DBC zone loading, ZMP pixel map, POI/overlay storage
- coordinate_projection: UV projection, zone/continent lookups
- composite_renderer: Vulkan tile pipeline + off-screen compositing
- exploration_state: server mask + local exploration tracking
- view_state_machine: COSMIC→WORLD→CONTINENT→ZONE navigation
- input_handler: keyboard/mouse input → InputAction mapping
- overlay_renderer: layer-based ImGui overlay system (OCP)
- map_resolver: cross-map navigation (Outland, Northrend, etc.)
- zone_metadata: level ranges and faction data

Overlay layers (each an IOverlayLayer):
- player_marker, party_dot, taxi_node, poi_marker, quest_poi,
  corpse_marker, zone_highlight, coordinate_display, subzone_tooltip

Fixes:
- Player marker no longer bleeds across continents (only shown when
  player is in a zone belonging to the displayed continent)
- Zone hover uses DBC-projected AABB rectangles (restored from
  original working behavior)
- Exploration overlay rendering for zone view subzones

Tests:
- 6 new test files covering coordinate projection, exploration state,
  map resolver, view state machine, zone metadata, and integration

Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
2026-04-12 09:52:51 +03:00

65 lines
2.2 KiB
C++

// view_state_machine.hpp — Navigation state and transitions for the world map.
// Extracted from WorldMap zoom/enter methods (Phase 6 of refactoring plan).
// SRP — pure state machine, no rendering or input code.
#pragma once
#include "rendering/world_map/world_map_types.hpp"
namespace wowee {
namespace rendering {
namespace world_map {
/// Manages the current view level and transitions between views.
class ViewStateMachine {
public:
ViewLevel currentLevel() const { return level_; }
const TransitionState& transition() const { return transition_; }
int continentIdx() const { return continentIdx_; }
int currentZoneIdx() const { return currentIdx_; }
bool cosmicEnabled() const { return cosmicEnabled_; }
void setContinentIdx(int idx) { continentIdx_ = idx; }
void setCurrentZoneIdx(int idx) { currentIdx_ = idx; }
void setCosmicEnabled(bool enabled) { cosmicEnabled_ = enabled; }
void setLevel(ViewLevel level) { level_ = level; }
/// Result of a zoom/navigate operation.
struct ZoomResult {
bool changed = false;
ViewLevel newLevel = ViewLevel::ZONE;
int targetIdx = -1; // zone index to load/composite
};
/// Attempt to zoom in. hoveredZoneIdx is the zone under the cursor (-1 if none).
/// playerZoneIdx is the zone the player is standing in (-1 if none).
ZoomResult zoomIn(int hoveredZoneIdx, int playerZoneIdx);
/// Attempt to zoom out one level.
ZoomResult zoomOut();
/// Navigate to world view. Returns the root/fallback continent index to composite.
ZoomResult enterWorldView();
/// Navigate to cosmic view.
ZoomResult enterCosmicView();
/// Navigate directly into a zone from continent view.
ZoomResult enterZone(int zoneIdx);
/// Advance transition animation. Returns true while animating.
bool updateTransition(float deltaTime);
private:
void startTransition(ViewLevel from, ViewLevel to, float duration = 0.3f);
ViewLevel level_ = ViewLevel::CONTINENT;
TransitionState transition_;
int continentIdx_ = -1;
int currentIdx_ = -1;
bool cosmicEnabled_ = true;
};
} // namespace world_map
} // namespace rendering
} // namespace wowee