- gr2: BitKnit2 decompression, 64-bit LE files, compressed curves - net: remaining GamePhase handlers, generated GC packet table - python: event/chat/chr/minimap/guild/quest/messenger/shop-search and other native modules ported against the AVA2 Windows client - render: D3D8 fixed-function lighting in Gr2ModelRenderer, terrain without baked shade; cape/NPC equipment attachment - tests + audits updated; docs/PORT-PLAN.md and WINDOWS-PARITY.md Batch 4 (render pipeline: background.*, app.RenderGame/UpdateGame, camera bindings, main.cpp fake-content removal) is still in progress. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
159 lines
6.0 KiB
C++
159 lines
6.0 KiB
C++
#pragma once
|
|
|
|
#include "Gr2ModelRenderer.h"
|
|
#include <SDL3/SDL.h>
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <unordered_map>
|
|
#include <memory>
|
|
|
|
namespace ava2 {
|
|
|
|
struct TextTailItem {
|
|
uint32_t dwVirtualID = 0;
|
|
std::string name;
|
|
std::string title;
|
|
std::string level;
|
|
std::string guildName;
|
|
uint32_t guildID = 0;
|
|
|
|
uint32_t color = 0xFFFFFFFF; // ARGB (white by default)
|
|
uint32_t titleColor = 0xFFFFD700; // Gold default
|
|
uint32_t levelColor = 0xFF98FF33; // Lime green default
|
|
|
|
// Screen projected position
|
|
float x = 0.0f;
|
|
float y = 0.0f;
|
|
float z = 0.0f;
|
|
|
|
// Height offset in 3D world (above character origin)
|
|
float fHeight = 10.0f;
|
|
float fDistanceFromPlayer = 0.0f;
|
|
|
|
// 2D Bounding box relative to (x, y) for picking and overlap checks
|
|
float xStart = 0.0f;
|
|
float yStart = 0.0f;
|
|
float xEnd = 0.0f;
|
|
float yEnd = 0.0f;
|
|
|
|
// Item specifics
|
|
bool isItem = false;
|
|
int ownerTime = 0; // seconds left
|
|
std::string ownerName;
|
|
bool isMineItem = false;
|
|
bool isSelected = false;
|
|
|
|
// Visibility flags
|
|
bool bNameFlag = true;
|
|
bool isShowing = false;
|
|
|
|
// Chat / Speech Bubble
|
|
std::string chatText;
|
|
float chatTimer = 0.0f;
|
|
float chatMaxDuration = 4.0f;
|
|
bool hasChat = false;
|
|
|
|
// World position (fallback or explicit coordinates)
|
|
float worldX = 0.0f;
|
|
float worldY = 0.0f;
|
|
float worldZ = 0.0f;
|
|
bool hasWorldPos = false;
|
|
};
|
|
|
|
/**
|
|
* TextTailManager:
|
|
* Full cross-platform implementation of Metin2 / AVA2 CPythonTextTail.
|
|
* Manages overhead character nameplates, guild titles, level tags,
|
|
* dropped ground item text boxes (with mouse picking and overlap resolution),
|
|
* and comic-style chat speech bubbles.
|
|
*/
|
|
class TextTailManager {
|
|
public:
|
|
static TextTailManager& Instance();
|
|
|
|
TextTailManager();
|
|
~TextTailManager() = default;
|
|
|
|
void Clear();
|
|
|
|
// Character TextTails
|
|
void RegisterCharacterTextTail(uint32_t guildID, uint32_t vid, uint32_t color = 0xFFFFFFFF, float fAddHeight = 10.0f);
|
|
void SetCharacterPosition(uint32_t vid, float worldX, float worldY, float worldZ);
|
|
void SetCharacterName(uint32_t vid, const std::string& name);
|
|
void SetCharacterTextTailColor(uint32_t vid, uint32_t color);
|
|
void AttachTitle(uint32_t vid, const std::string& title, uint32_t color = 0xFFFFD700);
|
|
void DetachTitle(uint32_t vid);
|
|
void AttachLevel(uint32_t vid, const std::string& levelText, uint32_t color = 0xFF98FF33);
|
|
void DetachLevel(uint32_t vid);
|
|
void SetGuildName(uint32_t vid, const std::string& guildName, uint32_t guildID = 0);
|
|
void DeleteCharacterTextTail(uint32_t vid);
|
|
void ShowCharacterTextTail(uint32_t vid);
|
|
|
|
// Item TextTails
|
|
void RegisterItemTextTail(uint32_t vid, const std::string& text, float worldX = 0.0f, float worldY = 0.0f, float worldZ = 0.0f, int ownerTime = 0, const std::string& ownerName = "", bool isMine = false, uint32_t color = 0xFFFFFFFF);
|
|
void SetItemPosition(uint32_t vid, float worldX, float worldY, float worldZ);
|
|
void SetItemTextTailOwner(uint32_t vid, const std::string& ownerName, bool isMine = false);
|
|
void DeleteItemTextTail(uint32_t vid);
|
|
void ShowItemTextTail(uint32_t vid);
|
|
|
|
// Chat / Info Speech Bubbles
|
|
void RegisterChatTail(uint32_t vid, const std::string& chatText);
|
|
void RegisterInfoTail(uint32_t vid, const std::string& infoText);
|
|
bool IsChatTextTail(uint32_t vid) const;
|
|
|
|
// Visibility & Control
|
|
void ShowAllTextTail();
|
|
void HideAllTextTail();
|
|
void EnablePKTitle(bool bFlag) { m_pkTitleEnable = bFlag; }
|
|
|
|
// Screen Position & Mouse Picking
|
|
int Pick(int ixMouse, int iyMouse);
|
|
void SelectItemName(uint32_t vid);
|
|
bool GetTextTailPosition(uint32_t vid, float& x, float& y, float& z) const;
|
|
|
|
// Simulation & Layout
|
|
void Update(float dt);
|
|
void UpdateAllTextTail(float playerX = 0.0f, float playerY = 0.0f, float playerZ = 0.0f, const Gr2SceneRenderer* sceneRenderer = nullptr);
|
|
void UpdateShowingTextTail(const Gr2SceneRenderer* sceneRenderer = nullptr);
|
|
void ArrangeTextTail();
|
|
|
|
// Rendering
|
|
void Render(SDL_Renderer* renderer, const Gr2SceneRenderer* sceneRenderer = nullptr);
|
|
|
|
// Queries & Getters
|
|
size_t GetCharacterCount() const { return m_characterMap.size(); }
|
|
size_t GetItemCount() const { return m_itemMap.size(); }
|
|
size_t GetShowingCharacterCount() const { return m_characterList.size(); }
|
|
size_t GetShowingItemCount() const { return m_itemList.size(); }
|
|
bool HasCharacter(uint32_t vid) const { return m_characterMap.find(vid) != m_characterMap.end(); }
|
|
bool HasItem(uint32_t vid) const { return m_itemMap.find(vid) != m_itemMap.end(); }
|
|
|
|
const std::shared_ptr<TextTailItem> GetCharacterTail(uint32_t vid) const;
|
|
const std::shared_ptr<TextTailItem> GetItemTail(uint32_t vid) const;
|
|
|
|
// Active renderer reference for Python bindings
|
|
void SetCurrentSceneRenderer(const Gr2SceneRenderer* renderer) { m_currentSceneRenderer = renderer; }
|
|
const Gr2SceneRenderer* GetCurrentSceneRenderer() const { return m_currentSceneRenderer; }
|
|
void SetCurrentRenderer(SDL_Renderer* renderer) { m_currentRenderer = renderer; }
|
|
|
|
private:
|
|
bool isIn(const TextTailItem& src, const TextTailItem& tgt) const;
|
|
void RenderTextTailBox(SDL_Renderer* renderer, const TextTailItem& tail);
|
|
void RenderText(SDL_Renderer* renderer, float x, float y, const std::string& text, uint32_t color, float scale = 1.0f, bool shadow = true);
|
|
void RenderChatBubble(SDL_Renderer* renderer, const TextTailItem& tail);
|
|
|
|
std::unordered_map<uint32_t, std::shared_ptr<TextTailItem>> m_characterMap;
|
|
std::unordered_map<uint32_t, std::shared_ptr<TextTailItem>> m_itemMap;
|
|
std::vector<std::shared_ptr<TextTailItem>> m_characterList; // list of currently showing character tails
|
|
std::vector<std::shared_ptr<TextTailItem>> m_itemList; // list of currently showing item tails
|
|
|
|
bool m_pkTitleEnable = true;
|
|
uint32_t m_selectedItemVID = 0;
|
|
|
|
const Gr2SceneRenderer* m_currentSceneRenderer = nullptr;
|
|
SDL_Renderer* m_currentRenderer = nullptr;
|
|
};
|
|
|
|
} // namespace ava2
|