Kelsidavis-WoWee/include/ui/auth_screen.hpp
Paul e58f9b4b40 feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.

Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.

Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.

Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.

Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.

Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00

165 lines
4.9 KiB
C++

#pragma once
#include "ui/ui_services.hpp"
#include "auth/auth_handler.hpp"
#include <vulkan/vulkan.h>
#include <string>
#include <vector>
#include <functional>
namespace wowee { namespace rendering { class VkContext; } }
namespace wowee { namespace ui {
/**
* Authentication screen UI
*
* Allows user to enter credentials and connect to auth server
*/
class AuthScreen {
public:
AuthScreen();
/**
* Render the UI
* @param authHandler Reference to auth handler
*/
void render(auth::AuthHandler& authHandler);
/**
* Set callback for successful authentication
*/
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
*/
bool isAuthenticating() const { return authenticating; }
void stopLoginMusic();
/**
* Get status message
*/
const std::string& getStatusMessage() const { return statusMessage; }
private:
UIServices services_; // Injected service references
struct ServerProfile {
std::string hostname;
int port = 3724;
std::string username;
std::string passwordHash; // SHA1 hex (UPPER(user):UPPER(pass))
std::string expansionId; // "wotlk", "tbc", "classic", "turtle", ...
};
// UI state
char hostname[256] = "localhost";
char username[256] = "";
char password[256] = "";
char pinCode[32] = "";
int port = 3724;
int expansionIndex = 0; // Index into expansion registry profiles
bool authenticating = false;
bool showPassword = false;
bool pinAutoSubmitted_ = false;
// Status
std::string statusMessage;
bool statusIsError = false;
std::string failureReason; // Specific reason from auth handler
float authTimer = 0.0f; // Timeout tracker
static constexpr float AUTH_TIMEOUT = 10.0f;
// Saved password hash (SHA1(UPPER(user):UPPER(pass)) as hex)
std::string savedPasswordHash;
bool usingStoredHash = false;
static constexpr const char* PASSWORD_PLACEHOLDER = "\x01\x01\x01\x01\x01\x01\x01\x01";
// Saved server-specific profiles
std::vector<ServerProfile> servers_;
int selectedServerIndex_ = -1; // -1 = custom/unlisted
// Callbacks
std::function<void()> onSuccess;
/**
* Attempt authentication
*/
void attemptAuth(auth::AuthHandler& authHandler);
/**
* Update status message
*/
void setStatus(const std::string& message, bool isError = false);
/**
* Persist/restore login fields
*/
void saveLoginInfo(bool includePasswordHash);
void loadLoginInfo();
static std::string getConfigPath();
bool loginInfoLoaded = false;
static std::string makeServerKey(const std::string& host, int port);
void selectServerProfile(int index);
void upsertCurrentServerProfile(bool includePasswordHash);
std::string currentExpansionId() const;
// Background image (Vulkan)
bool bgInitAttempted = false;
bool loadBackgroundImage();
void destroyBackgroundImage();
rendering::VkContext* bgVkCtx = nullptr;
VkImage bgImage = VK_NULL_HANDLE;
VkDeviceMemory bgMemory = VK_NULL_HANDLE;
VkImageView bgImageView = VK_NULL_HANDLE;
VkSampler bgSampler = VK_NULL_HANDLE;
VkDescriptorSet bgDescriptorSet = VK_NULL_HANDLE;
int bgWidth = 0;
int bgHeight = 0;
bool musicInitAttempted = false;
bool musicPlaying = false;
bool missingIntroTracksLogged_ = false;
bool introTracksScanned_ = false;
std::vector<std::string> introTracks_;
bool loginMusicVolumeAdjusted_ = false;
int savedMusicVolume_ = 30;
// ----- Login-screen graphics settings popup -----
bool showLoginSettings_ = false;
// Local copies of the settings keys we expose in the login popup.
// Loaded on first open; saved on Apply.
struct LoginGraphicsState {
int preset = 2; // 0=Custom 1=Low 2=Medium 3=High 4=Ultra
bool shadows = true;
float shadowDistance = 300.0f;
int antiAliasing = 0; // 0=Off 1=2x 2=4x 3=8x
bool fxaa = false;
bool normalMapping = true;
bool pom = true;
int pomQuality = 1; // 0=Low 1=Medium 2=High
int upscalingMode = 0; // 0=Off 1=FSR1 2=FSR3
bool waterRefraction = true;
int groundClutter = 100; // 0-150
int brightness = 50; // 0-100
bool vsync = false;
bool fullscreen = false;
};
LoginGraphicsState loginGfx_;
bool loginGfxLoaded_ = false;
void renderLoginSettingsWindow();
void loadLoginGraphicsState();
void saveLoginGraphicsState();
static void applyPresetToState(LoginGraphicsState& s, int preset);
};
}} // namespace wowee::ui