mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 09:33:51 +00:00
Add character creation screen with race/class/appearance customization
Implements a full character creation UI integrated into the existing flow. In single-player mode, auth screen now goes to character creation before entering the world. In online mode, a "Create Character" button on the character selection screen sends CMSG_CHAR_CREATE to the server. Includes WoW 3.3.5a race/class combo validation and appearance range limits.
This commit is contained in:
parent
f19c060078
commit
cf54db4554
16 changed files with 611 additions and 30 deletions
|
|
@ -20,6 +20,7 @@ namespace core {
|
|||
enum class AppState {
|
||||
AUTHENTICATION,
|
||||
REALM_SELECTION,
|
||||
CHARACTER_CREATION,
|
||||
CHARACTER_SELECTION,
|
||||
IN_GAME,
|
||||
DISCONNECTED
|
||||
|
|
|
|||
|
|
@ -110,6 +110,14 @@ struct Character {
|
|||
bool hasPet() const { return pet.exists(); }
|
||||
};
|
||||
|
||||
// Race/class combo and appearance range validation (WoW 3.3.5a)
|
||||
bool isValidRaceClassCombo(Race race, Class cls);
|
||||
uint8_t getMaxSkin(Race race, Gender gender);
|
||||
uint8_t getMaxFace(Race race, Gender gender);
|
||||
uint8_t getMaxHairStyle(Race race, Gender gender);
|
||||
uint8_t getMaxHairColor(Race race, Gender gender);
|
||||
uint8_t getMaxFacialFeature(Race race, Gender gender);
|
||||
|
||||
/**
|
||||
* Get human-readable race name
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -102,6 +102,11 @@ public:
|
|||
*/
|
||||
const std::vector<Character>& getCharacters() const { return characters; }
|
||||
|
||||
void createCharacter(const CharCreateData& data);
|
||||
|
||||
using CharCreateCallback = std::function<void(bool success, const std::string& message)>;
|
||||
void setCharCreateCallback(CharCreateCallback cb) { charCreateCallback_ = std::move(cb); }
|
||||
|
||||
/**
|
||||
* Select and log in with a character
|
||||
* @param characterGuid GUID of character to log in with
|
||||
|
|
@ -210,6 +215,7 @@ public:
|
|||
// Single-player mode
|
||||
void setSinglePlayerMode(bool sp) { singlePlayerMode_ = sp; }
|
||||
bool isSinglePlayerMode() const { return singlePlayerMode_; }
|
||||
void simulateMotd(const std::vector<std::string>& lines);
|
||||
|
||||
// NPC death callback (single-player)
|
||||
using NpcDeathCallback = std::function<void(uint64_t guid)>;
|
||||
|
|
@ -375,6 +381,9 @@ private:
|
|||
void handleGroupUninvite(network::Packet& packet);
|
||||
void handlePartyCommandResult(network::Packet& packet);
|
||||
|
||||
// ---- Character creation handler ----
|
||||
void handleCharCreateResponse(network::Packet& packet);
|
||||
|
||||
// ---- XP handler ----
|
||||
void handleXpGain(network::Packet& packet);
|
||||
|
||||
|
|
@ -515,6 +524,7 @@ private:
|
|||
// Callbacks
|
||||
WorldConnectSuccessCallback onSuccess;
|
||||
WorldConnectFailureCallback onFailure;
|
||||
CharCreateCallback charCreateCallback_;
|
||||
|
||||
// ---- XP tracking ----
|
||||
uint32_t playerXp_ = 0;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ enum class Opcode : uint16_t {
|
|||
// ---- Client to Server (Core) ----
|
||||
CMSG_PING = 0x1DC,
|
||||
CMSG_AUTH_SESSION = 0x1ED,
|
||||
CMSG_CHAR_CREATE = 0x036,
|
||||
CMSG_CHAR_ENUM = 0x037,
|
||||
CMSG_PLAYER_LOGIN = 0x03D,
|
||||
|
||||
|
|
@ -35,6 +36,7 @@ enum class Opcode : uint16_t {
|
|||
// ---- Server to Client (Core) ----
|
||||
SMSG_AUTH_CHALLENGE = 0x1EC,
|
||||
SMSG_AUTH_RESPONSE = 0x1EE,
|
||||
SMSG_CHAR_CREATE = 0x03A,
|
||||
SMSG_CHAR_ENUM = 0x03B,
|
||||
SMSG_PONG = 0x1DD,
|
||||
SMSG_LOGIN_VERIFY_WORLD = 0x236,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "network/packet.hpp"
|
||||
#include "game/opcodes.hpp"
|
||||
#include "game/character.hpp"
|
||||
#include "game/entity.hpp"
|
||||
#include "game/spell_defines.hpp"
|
||||
#include "game/group_defines.hpp"
|
||||
|
|
@ -167,6 +168,47 @@ public:
|
|||
static bool parse(network::Packet& packet, CharEnumResponse& response);
|
||||
};
|
||||
|
||||
// ============================================================
|
||||
// Character Creation
|
||||
// ============================================================
|
||||
|
||||
enum class CharCreateResult : uint8_t {
|
||||
SUCCESS = 0x00,
|
||||
ERROR = 0x01,
|
||||
FAILED = 0x02,
|
||||
NAME_IN_USE = 0x03,
|
||||
DISABLED = 0x04,
|
||||
PVP_TEAMS_VIOLATION = 0x05,
|
||||
SERVER_LIMIT = 0x06,
|
||||
ACCOUNT_LIMIT = 0x07,
|
||||
};
|
||||
|
||||
struct CharCreateData {
|
||||
std::string name;
|
||||
Race race;
|
||||
Class characterClass;
|
||||
Gender gender;
|
||||
uint8_t skin = 0;
|
||||
uint8_t face = 0;
|
||||
uint8_t hairStyle = 0;
|
||||
uint8_t hairColor = 0;
|
||||
uint8_t facialHair = 0;
|
||||
};
|
||||
|
||||
class CharCreatePacket {
|
||||
public:
|
||||
static network::Packet build(const CharCreateData& data);
|
||||
};
|
||||
|
||||
struct CharCreateResponseData {
|
||||
CharCreateResult result;
|
||||
};
|
||||
|
||||
class CharCreateResponseParser {
|
||||
public:
|
||||
static bool parse(network::Packet& packet, CharCreateResponseData& data);
|
||||
};
|
||||
|
||||
/**
|
||||
* CMSG_PLAYER_LOGIN packet builder
|
||||
*
|
||||
|
|
|
|||
42
include/ui/character_create_screen.hpp
Normal file
42
include/ui/character_create_screen.hpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#pragma once
|
||||
|
||||
#include "game/character.hpp"
|
||||
#include "game/world_packets.hpp"
|
||||
#include <imgui.h>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace game { class GameHandler; }
|
||||
|
||||
namespace ui {
|
||||
|
||||
class CharacterCreateScreen {
|
||||
public:
|
||||
CharacterCreateScreen();
|
||||
|
||||
void render(game::GameHandler& gameHandler);
|
||||
void setOnCreate(std::function<void(const game::CharCreateData&)> cb) { onCreate = std::move(cb); }
|
||||
void setOnCancel(std::function<void()> cb) { onCancel = std::move(cb); }
|
||||
void setStatus(const std::string& msg, bool isError = false);
|
||||
void reset();
|
||||
|
||||
private:
|
||||
char nameBuffer[13] = {}; // WoW max name = 12 chars + null
|
||||
int raceIndex = 0;
|
||||
int classIndex = 0;
|
||||
int genderIndex = 0;
|
||||
int skin = 0, face = 0, hairStyle = 0, hairColor = 0, facialHair = 0;
|
||||
std::string statusMessage;
|
||||
bool statusIsError = false;
|
||||
|
||||
std::vector<game::Class> availableClasses;
|
||||
void updateAvailableClasses();
|
||||
|
||||
std::function<void(const game::CharCreateData&)> onCreate;
|
||||
std::function<void()> onCancel;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
} // namespace wowee
|
||||
|
|
@ -30,6 +30,8 @@ public:
|
|||
onCharacterSelected = callback;
|
||||
}
|
||||
|
||||
void setOnCreateCharacter(std::function<void()> cb) { onCreateCharacter = std::move(cb); }
|
||||
|
||||
/**
|
||||
* Check if a character has been selected
|
||||
*/
|
||||
|
|
@ -51,6 +53,7 @@ private:
|
|||
|
||||
// Callbacks
|
||||
std::function<void(uint64_t)> onCharacterSelected;
|
||||
std::function<void()> onCreateCharacter;
|
||||
|
||||
/**
|
||||
* Update status message
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "ui/auth_screen.hpp"
|
||||
#include "ui/realm_screen.hpp"
|
||||
#include "ui/character_create_screen.hpp"
|
||||
#include "ui/character_screen.hpp"
|
||||
#include "ui/game_screen.hpp"
|
||||
#include <memory>
|
||||
|
|
@ -64,6 +65,7 @@ public:
|
|||
*/
|
||||
AuthScreen& getAuthScreen() { return *authScreen; }
|
||||
RealmScreen& getRealmScreen() { return *realmScreen; }
|
||||
CharacterCreateScreen& getCharacterCreateScreen() { return *characterCreateScreen; }
|
||||
CharacterScreen& getCharacterScreen() { return *characterScreen; }
|
||||
GameScreen& getGameScreen() { return *gameScreen; }
|
||||
|
||||
|
|
@ -73,6 +75,7 @@ private:
|
|||
// UI Screens
|
||||
std::unique_ptr<AuthScreen> authScreen;
|
||||
std::unique_ptr<RealmScreen> realmScreen;
|
||||
std::unique_ptr<CharacterCreateScreen> characterCreateScreen;
|
||||
std::unique_ptr<CharacterScreen> characterScreen;
|
||||
std::unique_ptr<GameScreen> gameScreen;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue