mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
Initial commit: wowee native WoW 3.3.5a client
This commit is contained in:
commit
ce6cb8f38e
147 changed files with 32347 additions and 0 deletions
144
src/ui/ui_manager.cpp
Normal file
144
src/ui/ui_manager.cpp
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
#include "ui/ui_manager.hpp"
|
||||
#include "core/window.hpp"
|
||||
#include "core/application.hpp"
|
||||
#include "core/logger.hpp"
|
||||
#include "auth/auth_handler.hpp"
|
||||
#include "game/game_handler.hpp"
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_sdl2.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
|
||||
namespace wowee {
|
||||
namespace ui {
|
||||
|
||||
UIManager::UIManager() {
|
||||
// Create screen instances
|
||||
authScreen = std::make_unique<AuthScreen>();
|
||||
realmScreen = std::make_unique<RealmScreen>();
|
||||
characterScreen = std::make_unique<CharacterScreen>();
|
||||
gameScreen = std::make_unique<GameScreen>();
|
||||
}
|
||||
|
||||
UIManager::~UIManager() = default;
|
||||
|
||||
bool UIManager::initialize(core::Window* win) {
|
||||
window = win;
|
||||
LOG_INFO("Initializing UI manager");
|
||||
|
||||
// Initialize ImGui
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
|
||||
|
||||
// Setup ImGui style
|
||||
ImGui::StyleColorsDark();
|
||||
|
||||
// Customize style for better WoW feel
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.WindowRounding = 6.0f;
|
||||
style.FrameRounding = 4.0f;
|
||||
style.GrabRounding = 4.0f;
|
||||
style.WindowBorderSize = 1.0f;
|
||||
style.FrameBorderSize = 1.0f;
|
||||
|
||||
// WoW-inspired colors
|
||||
ImVec4* colors = style.Colors;
|
||||
colors[ImGuiCol_WindowBg] = ImVec4(0.08f, 0.08f, 0.12f, 0.94f);
|
||||
colors[ImGuiCol_TitleBg] = ImVec4(0.10f, 0.10f, 0.15f, 1.00f);
|
||||
colors[ImGuiCol_TitleBgActive] = ImVec4(0.15f, 0.15f, 0.25f, 1.00f);
|
||||
colors[ImGuiCol_Button] = ImVec4(0.20f, 0.25f, 0.40f, 1.00f);
|
||||
colors[ImGuiCol_ButtonHovered] = ImVec4(0.25f, 0.30f, 0.50f, 1.00f);
|
||||
colors[ImGuiCol_ButtonActive] = ImVec4(0.15f, 0.20f, 0.35f, 1.00f);
|
||||
colors[ImGuiCol_Header] = ImVec4(0.20f, 0.25f, 0.40f, 0.55f);
|
||||
colors[ImGuiCol_HeaderHovered] = ImVec4(0.25f, 0.30f, 0.50f, 0.80f);
|
||||
colors[ImGuiCol_HeaderActive] = ImVec4(0.20f, 0.25f, 0.45f, 1.00f);
|
||||
|
||||
// Initialize ImGui for SDL2 and OpenGL3
|
||||
ImGui_ImplSDL2_InitForOpenGL(window->getSDLWindow(), window->getGLContext());
|
||||
ImGui_ImplOpenGL3_Init("#version 330 core");
|
||||
|
||||
imguiInitialized = true;
|
||||
|
||||
LOG_INFO("UI manager initialized successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
void UIManager::shutdown() {
|
||||
if (imguiInitialized) {
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
imguiInitialized = false;
|
||||
}
|
||||
LOG_INFO("UI manager shutdown");
|
||||
}
|
||||
|
||||
void UIManager::update(float deltaTime) {
|
||||
if (!imguiInitialized) return;
|
||||
|
||||
// Start ImGui frame
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
}
|
||||
|
||||
void UIManager::render(core::AppState appState, auth::AuthHandler* authHandler, game::GameHandler* gameHandler) {
|
||||
if (!imguiInitialized) return;
|
||||
|
||||
// Render appropriate screen based on application state
|
||||
switch (appState) {
|
||||
case core::AppState::AUTHENTICATION:
|
||||
if (authHandler) {
|
||||
authScreen->render(*authHandler);
|
||||
}
|
||||
break;
|
||||
|
||||
case core::AppState::REALM_SELECTION:
|
||||
if (authHandler) {
|
||||
realmScreen->render(*authHandler);
|
||||
}
|
||||
break;
|
||||
|
||||
case core::AppState::CHARACTER_SELECTION:
|
||||
if (gameHandler) {
|
||||
characterScreen->render(*gameHandler);
|
||||
}
|
||||
break;
|
||||
|
||||
case core::AppState::IN_GAME:
|
||||
if (gameHandler) {
|
||||
gameScreen->render(*gameHandler);
|
||||
}
|
||||
break;
|
||||
|
||||
case core::AppState::DISCONNECTED:
|
||||
// Show disconnected message
|
||||
ImGui::SetNextWindowSize(ImVec2(400, 150), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x * 0.5f - 200,
|
||||
ImGui::GetIO().DisplaySize.y * 0.5f - 75),
|
||||
ImGuiCond_Always);
|
||||
ImGui::Begin("Disconnected", nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize);
|
||||
ImGui::TextWrapped("You have been disconnected from the server.");
|
||||
ImGui::Spacing();
|
||||
if (ImGui::Button("Return to Login", ImVec2(-1, 0))) {
|
||||
// Will be handled by application
|
||||
}
|
||||
ImGui::End();
|
||||
break;
|
||||
}
|
||||
|
||||
// Render ImGui
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
|
||||
void UIManager::processEvent(const SDL_Event& event) {
|
||||
if (imguiInitialized) {
|
||||
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue