2026-02-02 12:24:50 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "auth/auth_handler.hpp"
|
|
|
|
|
#include <imgui.h>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
|
|
namespace wowee { namespace ui {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Realm selection screen UI
|
|
|
|
|
*
|
|
|
|
|
* Displays available realms and allows user to select one
|
|
|
|
|
*/
|
|
|
|
|
class RealmScreen {
|
|
|
|
|
public:
|
|
|
|
|
RealmScreen();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Render the UI
|
|
|
|
|
* @param authHandler Reference to auth handler
|
|
|
|
|
*/
|
|
|
|
|
void render(auth::AuthHandler& authHandler);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set callback for realm selection
|
|
|
|
|
* @param callback Function to call when realm is selected (receives realm name and address)
|
|
|
|
|
*/
|
|
|
|
|
void setOnRealmSelected(std::function<void(const std::string&, const std::string&)> callback) {
|
|
|
|
|
onRealmSelected = callback;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-17 03:50:36 -08:00
|
|
|
void setOnBack(std::function<void()> cb) { onBack = std::move(cb); }
|
|
|
|
|
|
2026-02-14 19:24:31 -08:00
|
|
|
/**
|
|
|
|
|
* Reset selection state (e.g., when switching servers)
|
|
|
|
|
*/
|
|
|
|
|
void reset() {
|
|
|
|
|
selectedRealmIndex = -1;
|
|
|
|
|
realmSelected = false;
|
2026-02-17 03:50:36 -08:00
|
|
|
autoSelectAttempted = false;
|
2026-02-14 19:24:31 -08:00
|
|
|
selectedRealmName.clear();
|
|
|
|
|
selectedRealmAddress.clear();
|
|
|
|
|
statusMessage.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
/**
|
|
|
|
|
* Check if a realm has been selected
|
|
|
|
|
*/
|
|
|
|
|
bool hasSelection() const { return realmSelected; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get selected realm info
|
|
|
|
|
*/
|
|
|
|
|
const std::string& getSelectedName() const { return selectedRealmName; }
|
|
|
|
|
const std::string& getSelectedAddress() const { return selectedRealmAddress; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// UI state
|
|
|
|
|
int selectedRealmIndex = -1;
|
|
|
|
|
bool realmSelected = false;
|
2026-02-17 03:50:36 -08:00
|
|
|
bool autoSelectAttempted = false;
|
2026-02-02 12:24:50 -08:00
|
|
|
std::string selectedRealmName;
|
|
|
|
|
std::string selectedRealmAddress;
|
|
|
|
|
|
|
|
|
|
// Status
|
|
|
|
|
std::string statusMessage;
|
|
|
|
|
|
|
|
|
|
// Callbacks
|
|
|
|
|
std::function<void(const std::string&, const std::string&)> onRealmSelected;
|
2026-02-17 03:50:36 -08:00
|
|
|
std::function<void()> onBack;
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update status message
|
|
|
|
|
*/
|
|
|
|
|
void setStatus(const std::string& message);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get realm status text
|
|
|
|
|
*/
|
|
|
|
|
const char* getRealmStatus(uint8_t flags) const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get population color
|
|
|
|
|
*/
|
|
|
|
|
ImVec4 getPopulationColor(float population) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}} // namespace wowee::ui
|