chore(application): extract appearance controller and unify UI flow

- Refactor UI application architecture: extracted appearance controller into ui_services.hpp + implementation updates
- Update UI components and managers to use new service layer:
  - `action_bar_panel`, `auth_screen`, `character_screen`, `chat_panel`, `combat_ui`, `dialog_manager`, `game_screen`, `settings_panel`, `social_panel`, `toast_manager`, `ui_manager`, `window_manager`
- Adjust core application entrypoints:
  - application.cpp
- Update component implementations for new controller flow:
  - action_bar_panel.cpp, `chat_panel.cpp`, `combat_ui.cpp`, `dialog_manager.cpp`, `game_screen.cpp`, `settings_panel.cpp`, `social_panel.cpp`, `toast_manager.cpp`, `window_manager.cpp`

These staged changes implement a major architectural refactor for UI/appearance controller separation
This commit is contained in:
Paul 2026-04-01 20:59:17 +03:00
parent d43397163e
commit 1c0e9dd1df
23 changed files with 315 additions and 134 deletions

View file

@ -4,6 +4,7 @@
// XP bar, reputation bar, macro resolution.
// ============================================================
#pragma once
#include "ui/ui_services.hpp"
#include <cstdint>
#include <unordered_map>
#include <functional>
@ -70,7 +71,11 @@ public:
std::unordered_map<uint32_t, uint32_t> macroPrimarySpellCache_;
size_t macroCacheSpellCount_ = 0;
// Section 3.5: UIServices injection (Phase B singleton breaking)
void setServices(const UIServices& services) { services_ = services; }
private:
UIServices services_;
uint32_t resolveMacroPrimarySpellId(uint32_t macroId, game::GameHandler& gameHandler);
};

View file

@ -1,5 +1,6 @@
#pragma once
#include "ui/ui_services.hpp"
#include "auth/auth_handler.hpp"
#include <vulkan/vulkan.h>
#include <string>
@ -30,6 +31,9 @@ public:
*/
void setOnSuccess(std::function<void()> callback) { onSuccess = callback; }
/// Set services (dependency injection)
void setServices(const UIServices& services) { services_ = services; }
/**
* Check if authentication is in progress
@ -44,6 +48,8 @@ public:
const std::string& getStatusMessage() const { return statusMessage; }
private:
UIServices services_; // Injected service references
struct ServerProfile {
std::string hostname;
int port = 3724;

View file

@ -1,5 +1,6 @@
#pragma once
#include "ui/ui_services.hpp"
#include "game/game_handler.hpp"
#include <imgui.h>
#include <string>
@ -48,6 +49,9 @@ public:
void setOnBack(std::function<void()> cb) { onBack = std::move(cb); }
void setOnDeleteCharacter(std::function<void(uint64_t)> cb) { onDeleteCharacter = std::move(cb); }
/// Set services (dependency injection)
void setServices(const UIServices& services) { services_ = services; }
/**
* Reset selection state (e.g., when switching servers)
*/
@ -89,6 +93,8 @@ public:
void selectCharacterByName(const std::string& name);
private:
UIServices services_; // Injected service references
// UI state
int selectedCharacterIndex = -1;
bool characterSelected = false;

View file

@ -1,6 +1,7 @@
#pragma once
#include "game/game_handler.hpp"
#include "ui/ui_services.hpp"
#include <vulkan/vulkan.h>
#include <imgui.h>
#include <string>
@ -109,10 +110,16 @@ public:
/** Reset all chat settings to defaults. */
void restoreDefaults();
// Section 3.5: UIServices injection (Phase B singleton breaking)
void setServices(const UIServices& services) { services_ = services; }
/** Replace $g/$G and $n/$N gender/name placeholders in quest/chat text. */
std::string replaceGenderPlaceholders(const std::string& text, game::GameHandler& gameHandler);
private:
// Section 3.5: Injected UI services (Phase B singleton breaking)
UIServices services_;
// ---- Chat input state ----
char chatInputBuffer_[512] = "";
char whisperTargetBuffer_[256] = "";

View file

@ -1,5 +1,6 @@
#pragma once
#include "ui/ui_services.hpp"
#include <imgui.h>
#include <vulkan/vulkan.h>
#include <string>
@ -70,6 +71,12 @@ public:
SpellbookScreen& spellbookScreen);
void renderThreatWindow(game::GameHandler& gameHandler);
void renderBgScoreboard(game::GameHandler& gameHandler);
// Section 3.5: UIServices injection (Phase B singleton breaking)
void setServices(const UIServices& services) { services_ = services; }
private:
UIServices services_;
};
} // namespace ui

View file

@ -1,5 +1,6 @@
#pragma once
#include "ui/ui_services.hpp"
#include <imgui.h>
#include <string>
#include <cstdint>
@ -34,7 +35,12 @@ public:
/// called in render() after reclaim corpse button
void renderLateDialogs(game::GameHandler& gameHandler);
// Section 3.5: UIServices injection (Phase B singleton breaking)
void setServices(const UIServices& services) { services_ = services; }
private:
// Section 3.5: Injected UI services
UIServices services_;
// Common ImGui window flags for popup dialogs
static constexpr ImGuiWindowFlags kDialogFlags =
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize;

View file

@ -17,6 +17,7 @@
#include "ui/social_panel.hpp"
#include "ui/action_bar_panel.hpp"
#include "ui/window_manager.hpp"
#include "ui/ui_services.hpp"
#include <vulkan/vulkan.h>
#include <imgui.h>
#include <string>
@ -54,8 +55,13 @@ public:
// Dependency injection for extracted classes (Phase A singleton breaking)
void setAppearanceComposer(core::AppearanceComposer* ac) { appearanceComposer_ = ac; }
// Section 3.5: UIServices injection (Phase B singleton breaking)
void setServices(const UIServices& services);
private:
// Injected dependencies (replaces getInstance() calls)
// Injected UI services (Section 3.5 Phase B - replaces getInstance() calls)
UIServices services_;
// Legacy pointer for Phase A compatibility (will be removed when all callsites migrate)
core::AppearanceComposer* appearanceComposer_ = nullptr;
// Chat panel (extracted from GameScreen — owns all chat state and rendering)
ChatPanel chatPanel_;

View file

@ -1,5 +1,6 @@
#pragma once
#include "ui/ui_services.hpp"
#include <vulkan/vulkan.h>
#include <string>
#include <functional>
@ -149,7 +150,12 @@ public:
/// Return the platform-specific settings file path
static std::string getSettingsPath();
/// Set services (dependency injection)
void setServices(const UIServices& services) { services_ = services; }
private:
UIServices services_; // Injected service references
// Keybinding customization (private — only used in Controls tab)
int pendingRebindAction_ = -1; // -1 = not rebinding, otherwise action index
bool awaitingKeyPress_ = false;

View file

@ -1,5 +1,6 @@
#pragma once
#include "ui/ui_services.hpp"
#include <imgui.h>
#include <vulkan/vulkan.h>
#include <string>
@ -71,6 +72,12 @@ public:
ChatPanel& chatPanel);
void renderInspectWindow(game::GameHandler& gameHandler,
InventoryScreen& inventoryScreen);
// Section 3.5: UIServices injection (Phase B singleton breaking)
void setServices(const UIServices& services) { services_ = services; }
private:
UIServices services_;
};
} // namespace ui

View file

@ -1,5 +1,6 @@
#pragma once
#include "ui/ui_services.hpp"
#include <vulkan/vulkan.h>
#include <imgui.h>
#include <string>
@ -40,11 +41,17 @@ public:
/// Fire achievement earned toast + sound
void triggerAchievementToast(uint32_t achievementId, std::string name = {});
// Section 3.5: UIServices injection (Phase B singleton breaking)
void setServices(const UIServices& services) { services_ = services; }
// --- public state consumed by GameScreen for the golden burst overlay ---
float levelUpFlashAlpha = 0.0f;
uint32_t levelUpDisplayLevel = 0;
private:
// Section 3.5: Injected UI services
UIServices services_;
// ---- Ding effect (own level-up) ----
static constexpr float DING_DURATION = 4.0f;
float dingTimer_ = 0.0f;

View file

@ -5,6 +5,7 @@
#include "ui/character_create_screen.hpp"
#include "ui/character_screen.hpp"
#include "ui/game_screen.hpp"
#include "ui/ui_services.hpp"
#include <memory>
// Forward declare SDL_Event
@ -74,8 +75,18 @@ public:
if (gameScreen) gameScreen->setAppearanceComposer(ac);
}
// Section 3.5: UIServices injection (Phase B singleton breaking)
void setServices(const UIServices& services) {
services_ = services;
if (gameScreen) gameScreen->setServices(services);
if (authScreen) authScreen->setServices(services);
if (characterScreen) characterScreen->setServices(services);
}
const UIServices& getServices() const { return services_; }
private:
core::Window* window = nullptr;
UIServices services_; // Section 3.5: Injected services
// UI Screens
std::unique_ptr<AuthScreen> authScreen;

View file

@ -0,0 +1,55 @@
#pragma once
namespace wowee {
// Forward declarations
namespace core {
class Window;
class EntitySpawner;
class AppearanceComposer;
class WorldLoader;
}
namespace rendering { class Renderer; }
namespace pipeline { class AssetManager; }
namespace game {
class GameHandler;
class ExpansionRegistry;
}
namespace addons { class AddonManager; }
namespace audio { class AudioCoordinator; }
namespace ui {
/**
* UI Services - Dependency injection container for UI components.
*
* Section 3.5: Break the singleton Phase B
*
* Replaces Application::getInstance() calls throughout UI code.
* Application creates this struct and injects it into UIManager,
* which propagates it to GameScreen and all child UI components.
*
* Owned by Application, shared as const pointers (non-owning).
*/
struct UIServices {
core::Window* window = nullptr;
rendering::Renderer* renderer = nullptr;
pipeline::AssetManager* assetManager = nullptr;
game::GameHandler* gameHandler = nullptr;
game::ExpansionRegistry* expansionRegistry = nullptr;
addons::AddonManager* addonManager = nullptr;
audio::AudioCoordinator* audioCoordinator = nullptr;
// Extracted classes (also available individually for Phase A compatibility)
core::EntitySpawner* entitySpawner = nullptr;
core::AppearanceComposer* appearanceComposer = nullptr;
core::WorldLoader* worldLoader = nullptr;
// Helper to check if core services are wired
bool isValid() const {
return window && renderer && assetManager && gameHandler;
}
};
} // namespace ui
} // namespace wowee

View file

@ -7,6 +7,7 @@
// equipment sets, skills.
// ============================================================
#pragma once
#include "ui/ui_services.hpp"
#include <cstdint>
#include <string>
#include <unordered_map>
@ -173,7 +174,11 @@ public:
std::unordered_map<uint32_t, ExtendedCostEntry> extendedCostCache_;
bool extendedCostDbLoaded_ = false;
// Section 3.5: UIServices injection (Phase B singleton breaking)
void setServices(const UIServices& services) { services_ = services; }
private:
UIServices services_;
void loadExtendedCostDBC();
std::string formatExtendedCost(uint32_t extendedCostId, game::GameHandler& gameHandler);
};