876 lines
33 KiB
C++
876 lines
33 KiB
C++
#pragma once
|
|
|
|
#include "shared/common/Win32Types.h"
|
|
#include "shared/common/EterBaseUtils.h"
|
|
#include "shared/common/PythonUtils.h"
|
|
#include <string>
|
|
#include <vector>
|
|
#include <list>
|
|
#include <map>
|
|
#include <algorithm>
|
|
|
|
#include "src/eter_image/GrpImageInstance.h"
|
|
#include "src/eter_image/GrpExpandedImageInstance.h"
|
|
#include "src/eter_image/GrpMarkInstance.h"
|
|
#include "src/eter_resource/ResourceManager.h"
|
|
#include "Font.h"
|
|
|
|
namespace UI
|
|
{
|
|
class CSlotWindow;
|
|
|
|
class CGraphicTextInstance {
|
|
public:
|
|
enum {
|
|
HORIZONTAL_ALIGN_LEFT = 0x01,
|
|
HORIZONTAL_ALIGN_CENTER = 0x02,
|
|
HORIZONTAL_ALIGN_RIGHT = 0x03,
|
|
VERTICAL_ALIGN_TOP = 0x10,
|
|
VERTICAL_ALIGN_CENTER = 0x20,
|
|
VERTICAL_ALIGN_BOTTOM = 0x30
|
|
};
|
|
CGraphicTextInstance() = default;
|
|
~CGraphicTextInstance() = default;
|
|
void SetText(const char* text) { if (text) m_text = text; }
|
|
const char* GetText() const { return m_text.c_str(); }
|
|
void SetValue(const char* text) { SetText(text); }
|
|
void SetValueString(const std::string& text) { m_text = text; }
|
|
void SetHorizonalAlign(int align) { m_hAlign = align; }
|
|
int GetHorizontalAlign() const { return m_hAlign; }
|
|
// EterLib CGraphicTextInstance::SetColor(r, g, b): alpha 1.
|
|
void SetColor(float r, float g, float b) {
|
|
auto c = [](float v) { return DWORD(std::clamp(v, 0.0f, 1.0f) * 255.0f + 0.5f); };
|
|
m_color = 0xff000000 | (c(r) << 16) | (c(g) << 8) | c(b);
|
|
}
|
|
// EterLib CGraphicTextInstance::SetColor(const D3DXCOLOR&) / SetColor(DWORD): alpha kept.
|
|
void SetColor(const D3DXCOLOR& color) { m_color = DWORD(color); }
|
|
DWORD GetColor() const { return m_color; }
|
|
// EterLib CGraphicTextInstance::Destroy: back to an empty, left-aligned instance.
|
|
void Destroy() { *this = CGraphicTextInstance(); }
|
|
void SetVerticalAlign(int align) { m_vAlign = align; }
|
|
void SetMax(int max) { m_max = max; }
|
|
void SetFontName(const char* name) { if (name) m_font = name; }
|
|
void SetFontColor(DWORD color) { m_color = color; }
|
|
void SetLimitWidth(float w) { m_limitWidth = w; }
|
|
void SetSecret(BOOL b) { m_secret = b; }
|
|
void SetOutline(BOOL b) { m_outline = b; }
|
|
void SetFeather(BOOL b) { m_feather = b; }
|
|
void SetMultiLine(BOOL b) { m_multiLine = b; }
|
|
void SetLineHeight(int h) { m_lineHeight = h; }
|
|
int GetLineHeight() const { return m_lineHeight; }
|
|
int GetTextLineCount() const { return 1; }
|
|
void DisableEnterToken() {}
|
|
void ShowCursor() { m_showCursor = true; }
|
|
void HideCursor() { m_showCursor = false; }
|
|
int GetCursorPosition() const { return (int)m_text.length(); }
|
|
void GetTextSize(int* w, int* h) {
|
|
const int size = TextFontSize(m_font);
|
|
if (w) *w = int(std::ceil(MeasureText(m_secret ? std::string(m_text.length(), '*') : m_text, size)));
|
|
if (h) *h = size;
|
|
}
|
|
void SetOutLineColor(float r, float g, float b, float a) {
|
|
auto c = [](float v) { return DWORD(std::clamp(v, 0.0f, 1.0f) * 255.0f + 0.5f); };
|
|
m_outlineColor = (c(a) << 24) | (c(r) << 16) | (c(g) << 8) | c(b);
|
|
}
|
|
int PixelPositionToCharacterPosition(int pixelPos) const {
|
|
if (pixelPos <= 0) return 0;
|
|
for (size_t i = 0; i < m_text.size(); ++i)
|
|
if (MeasureText(m_text.substr(0, i + 1), TextFontSize(m_font)) > pixelPos) return int(i);
|
|
return int(m_text.size());
|
|
}
|
|
void SetPosition(float fx, float fy) { m_v2Position.x = fx; m_v2Position.y = fy; }
|
|
D3DXVECTOR2 GetPosition() const { return m_v2Position; }
|
|
void Update() {}
|
|
void Render();
|
|
// Render(RECT* pClipRect): the clip rectangle is not applied by this text stand-in.
|
|
void Render(const RECT*) { Render(); }
|
|
static const char* Hyperlink_GetText(const std::string&, int, int*) { return ""; }
|
|
private:
|
|
D3DXVECTOR2 m_v2Position = D3DXVECTOR2(0.0f, 0.0f);
|
|
std::string m_text;
|
|
std::string m_font;
|
|
DWORD m_color = 0xffffffff;
|
|
DWORD m_outlineColor = 0xff000000;
|
|
int m_hAlign = HORIZONTAL_ALIGN_LEFT;
|
|
int m_vAlign = VERTICAL_ALIGN_TOP;
|
|
int m_max = 0;
|
|
int m_lineHeight = 12;
|
|
float m_limitWidth = 0.0f;
|
|
BOOL m_secret = FALSE;
|
|
BOOL m_outline = FALSE;
|
|
BOOL m_feather = FALSE;
|
|
BOOL m_multiLine = FALSE;
|
|
bool m_showCursor = false;
|
|
};
|
|
|
|
class CWindow
|
|
{
|
|
public:
|
|
typedef std::list<CWindow *> TWindowContainer;
|
|
|
|
static DWORD Type();
|
|
BOOL IsType(DWORD dwType);
|
|
|
|
enum EHorizontalAlign
|
|
{
|
|
HORIZONTAL_ALIGN_LEFT = 0,
|
|
HORIZONTAL_ALIGN_CENTER = 1,
|
|
HORIZONTAL_ALIGN_RIGHT = 2,
|
|
};
|
|
|
|
enum EVerticalAlign
|
|
{
|
|
VERTICAL_ALIGN_TOP = 0,
|
|
VERTICAL_ALIGN_CENTER = 1,
|
|
VERTICAL_ALIGN_BOTTOM = 2,
|
|
};
|
|
|
|
enum EFlags
|
|
{
|
|
FLAG_MOVABLE = (1 << 0),
|
|
FLAG_LIMIT = (1 << 1),
|
|
FLAG_SNAP = (1 << 2),
|
|
FLAG_DRAGABLE = (1 << 3),
|
|
FLAG_ATTACH = (1 << 4),
|
|
FLAG_RESTRICT_X = (1 << 5),
|
|
FLAG_RESTRICT_Y = (1 << 6),
|
|
FLAG_NOT_CAPTURE = (1 << 7),
|
|
FLAG_FLOAT = (1 << 8),
|
|
FLAG_NOT_PICK = (1 << 9),
|
|
FLAG_IGNORE_SIZE = (1 << 10),
|
|
FLAG_RTL = (1 << 11),
|
|
};
|
|
|
|
public:
|
|
CWindow(PyObject * ppyObject);
|
|
virtual ~CWindow();
|
|
|
|
void AddChild(CWindow * pWin);
|
|
void Clear();
|
|
void DestroyHandle();
|
|
void Update();
|
|
void Render();
|
|
|
|
void SetName(const char * c_szName);
|
|
const char * GetName() { return m_strName.c_str(); }
|
|
PyObject * GetHandler() { return m_poHandler; }
|
|
void SetSize(long width, long height);
|
|
long GetWidth() { return m_lWidth; }
|
|
long GetHeight() { return m_lHeight; }
|
|
|
|
void SetHorizontalAlign(DWORD dwAlign);
|
|
void SetVerticalAlign(DWORD dwAlign);
|
|
void SetPosition(long x, long y);
|
|
void GetPosition(long * plx, long * ply);
|
|
long GetPositionX( void ) const { return m_x; }
|
|
long GetPositionY( void ) const { return m_y; }
|
|
RECT & GetRect() { return m_rect; }
|
|
void GetLocalPosition(long & rlx, long & rly);
|
|
void GetMouseLocalPosition(long & rlx, long & rly);
|
|
long UpdateRect();
|
|
|
|
RECT & GetLimitBias() { return m_limitBiasRect; }
|
|
void SetLimitBias(long l, long r, long t, long b) { m_limitBiasRect.left = l; m_limitBiasRect.right = r; m_limitBiasRect.top = t; m_limitBiasRect.bottom = b; }
|
|
|
|
void Show();
|
|
void Hide();
|
|
bool IsShow() { return m_bShow; }
|
|
bool IsRendering();
|
|
|
|
bool HasParent() { return m_pParent ? true : false; }
|
|
bool HasChild() { return !m_pChildList.empty(); }
|
|
int GetChildCount() { return (int)m_pChildList.size(); }
|
|
|
|
CWindow * GetRoot();
|
|
CWindow * GetParent();
|
|
bool IsChild(CWindow * pWin);
|
|
void DeleteChild(CWindow * pWin);
|
|
void SetTop(CWindow * pWin);
|
|
|
|
bool IsIn(long x, long y);
|
|
bool IsIn();
|
|
CWindow * PickWindow(long x, long y);
|
|
CWindow * PickTopWindow(long x, long y);
|
|
|
|
void __RemoveReserveChildren();
|
|
|
|
void AddFlag(DWORD flag) { SET_BIT(m_dwFlag, flag); }
|
|
void RemoveFlag(DWORD flag) { REMOVE_BIT(m_dwFlag, flag); }
|
|
bool IsFlag(DWORD flag) { return (m_dwFlag & flag) ? true : false; }
|
|
|
|
virtual void OnRender();
|
|
virtual void OnUpdate();
|
|
virtual void OnChangePosition(){}
|
|
|
|
virtual void OnSetFocus();
|
|
virtual void OnKillFocus();
|
|
|
|
virtual void OnMouseDrag(long lx, long ly);
|
|
virtual void OnMouseOverIn();
|
|
virtual void OnMouseOverOut();
|
|
virtual void OnMouseOver();
|
|
virtual void OnDrop();
|
|
virtual void OnTop();
|
|
virtual void OnIMEUpdate();
|
|
|
|
virtual void OnMoveWindow(long x, long y);
|
|
|
|
BOOL RunIMETabEvent();
|
|
BOOL RunIMEReturnEvent();
|
|
BOOL RunIMEKeyDownEvent(int ikey);
|
|
|
|
CWindow * RunKeyDownEvent(int ikey);
|
|
BOOL RunKeyUpEvent(int ikey);
|
|
BOOL RunPressEscapeKeyEvent();
|
|
BOOL RunPressExitKeyEvent();
|
|
|
|
virtual BOOL OnIMETabEvent();
|
|
virtual BOOL OnIMEReturnEvent();
|
|
virtual BOOL OnIMEKeyDownEvent(int ikey);
|
|
|
|
virtual BOOL OnIMEChangeCodePage();
|
|
virtual BOOL OnIMEOpenCandidateListEvent();
|
|
virtual BOOL OnIMECloseCandidateListEvent();
|
|
virtual BOOL OnIMEOpenReadingWndEvent();
|
|
virtual BOOL OnIMECloseReadingWndEvent();
|
|
|
|
virtual BOOL OnMouseLeftButtonDown();
|
|
virtual BOOL OnMouseLeftButtonUp();
|
|
virtual BOOL OnMouseLeftButtonDoubleClick();
|
|
virtual BOOL OnMouseRightButtonDown();
|
|
virtual BOOL OnMouseRightButtonUp();
|
|
virtual BOOL OnMouseRightButtonDoubleClick();
|
|
virtual BOOL OnMouseMiddleButtonDown();
|
|
virtual BOOL OnMouseMiddleButtonUp();
|
|
virtual BOOL OnMouseWheelScroll(short wDelta);
|
|
virtual void SetScrollable() { m_bIsScrollable = true; }
|
|
virtual BOOL OnMouseWheel(int nLen);
|
|
virtual BOOL RunMouseWheelEvent(long nLen);
|
|
|
|
virtual BOOL OnKeyDown(int ikey);
|
|
virtual BOOL OnKeyUp(int ikey);
|
|
virtual BOOL OnPressEscapeKey();
|
|
virtual BOOL OnPressExitKey();
|
|
|
|
virtual void SetColor(DWORD dwColor){}
|
|
virtual BOOL OnIsType(DWORD dwType);
|
|
|
|
virtual BOOL IsWindow() { return TRUE; }
|
|
|
|
protected:
|
|
std::string m_strName;
|
|
EHorizontalAlign m_HorizontalAlign;
|
|
EVerticalAlign m_VerticalAlign;
|
|
long m_x, m_y;
|
|
long m_lWidth, m_lHeight;
|
|
RECT m_rect;
|
|
RECT m_limitBiasRect;
|
|
bool m_bMovable;
|
|
bool m_bShow;
|
|
DWORD m_dwFlag;
|
|
PyObject * m_poHandler;
|
|
CWindow * m_pParent;
|
|
TWindowContainer m_pChildList;
|
|
BOOL m_isUpdatingChildren;
|
|
TWindowContainer m_pReserveChildList;
|
|
bool m_bIsScrollable = false;
|
|
};
|
|
|
|
class CLayer : public CWindow
|
|
{
|
|
public:
|
|
CLayer(PyObject * ppyObject) : CWindow(ppyObject) {}
|
|
virtual ~CLayer() {}
|
|
BOOL IsWindow() override { return FALSE; }
|
|
};
|
|
|
|
class CBox : public CWindow
|
|
{
|
|
public:
|
|
CBox(PyObject * ppyObject) : CWindow(ppyObject), m_dwColor(0) {}
|
|
virtual ~CBox() {}
|
|
void SetColor(DWORD dwColor) override { m_dwColor = dwColor; }
|
|
protected:
|
|
void OnRender() override;
|
|
DWORD m_dwColor;
|
|
};
|
|
|
|
class CBar : public CWindow
|
|
{
|
|
public:
|
|
CBar(PyObject * ppyObject) : CWindow(ppyObject), m_dwColor(0) {}
|
|
virtual ~CBar() {}
|
|
void SetColor(DWORD dwColor) override { m_dwColor = dwColor; }
|
|
protected:
|
|
void OnRender() override;
|
|
DWORD m_dwColor;
|
|
};
|
|
|
|
class CLine : public CWindow
|
|
{
|
|
public:
|
|
CLine(PyObject * ppyObject) : CWindow(ppyObject), m_dwColor(0) {}
|
|
virtual ~CLine() {}
|
|
void SetColor(DWORD dwColor) override { m_dwColor = dwColor; }
|
|
protected:
|
|
void OnRender() override;
|
|
DWORD m_dwColor;
|
|
};
|
|
|
|
class CBar3D : public CWindow
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CBar3D(PyObject * ppyObject) : CWindow(ppyObject), m_dwLeftColor(0xFF333333), m_dwRightColor(0xFFB2B2B2), m_dwCenterColor(0xFF000000) {}
|
|
virtual ~CBar3D() {}
|
|
void SetColor(DWORD l, DWORD r, DWORD c) { m_dwLeftColor = l; m_dwRightColor = r; m_dwCenterColor = c; }
|
|
protected:
|
|
void OnRender() override;
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
DWORD m_dwLeftColor, m_dwRightColor, m_dwCenterColor;
|
|
};
|
|
|
|
// Mobile HUD (docs/MOBILE-ARCHITECTURE.md step 4): a round frame drawn with geometry instead of
|
|
// textures. A disc filled with a radial gradient, a bevelled rim (top colour fading to bottom
|
|
// colour) and an optional clockwise pie from 12 o'clock for cooldowns and gauges.
|
|
class CDisc : public CWindow
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CDisc(PyObject * ppyObject) : CWindow(ppyObject) {}
|
|
virtual ~CDisc() {}
|
|
void SetDiscColors(DWORD inner, DWORD outer, DWORD rimTop, DWORD rimBottom, float rimWidth)
|
|
{ m_dwInner = inner; m_dwOuter = outer; m_dwRimTop = rimTop; m_dwRimBottom = rimBottom; m_fRimWidth = rimWidth; }
|
|
void SetDiscArc(float fraction, DWORD color) { m_fArc = fraction; m_dwArc = color; }
|
|
protected:
|
|
void OnRender() override;
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
DWORD m_dwInner = 0xC0202028, m_dwOuter = 0xC0101014, m_dwRimTop = 0xFFC8A060, m_dwRimBottom = 0xFF604020, m_dwArc = 0xA0000000;
|
|
float m_fRimWidth = 3.0f, m_fArc = 0.0f;
|
|
};
|
|
|
|
class CTextLine : public CWindow
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CTextLine(PyObject * ppyObject);
|
|
virtual ~CTextLine();
|
|
void SetMax(int iMax) { m_TextInstance.SetMax(iMax); }
|
|
void SetHorizontalAlign(int iType) { m_TextInstance.SetHorizonalAlign(iType); }
|
|
void SetVerticalAlign(int iType) { m_TextInstance.SetVerticalAlign(iType); }
|
|
void SetSecret(BOOL bFlag) { m_TextInstance.SetSecret(bFlag); }
|
|
void SetOutline(BOOL bFlag) { m_TextInstance.SetOutline(bFlag); }
|
|
void SetFeather(BOOL bFlag) { m_TextInstance.SetFeather(bFlag); }
|
|
void SetMultiLine(BOOL bFlag) { m_TextInstance.SetMultiLine(bFlag); }
|
|
void SetFontName(const char * c_szFontName) { m_TextInstance.SetFontName(c_szFontName); }
|
|
void SetFontColor(DWORD dwColor) { m_TextInstance.SetFontColor(dwColor); }
|
|
DWORD GetFontColor() const { return m_TextInstance.GetColor(); }
|
|
void SetLimitWidth(float fWidth) { m_TextInstance.SetLimitWidth(fWidth); }
|
|
void ShowCursor() { m_TextInstance.ShowCursor(); }
|
|
void HideCursor() { m_TextInstance.HideCursor(); }
|
|
int GetCursorPosition() { return m_TextInstance.GetCursorPosition(); }
|
|
void SetText(const char * c_szText);
|
|
const char * GetText() { return m_TextInstance.GetText(); }
|
|
void GetTextSize(int* pnWidth, int* pnHeight) { m_TextInstance.GetTextSize(pnWidth, pnHeight); }
|
|
int GetTextLineCount() { return m_TextInstance.GetTextLineCount(); }
|
|
void DisableEnterToken() { m_TextInstance.DisableEnterToken(); }
|
|
void SetLineHeight(int iHeight) { m_TextInstance.SetLineHeight(iHeight); }
|
|
int GetLineHeight() { return m_TextInstance.GetLineHeight(); }
|
|
protected:
|
|
void OnRender() override;
|
|
void OnChangePosition() override;
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
CGraphicTextInstance m_TextInstance;
|
|
};
|
|
|
|
class CNumberLine : public CWindow
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CNumberLine(PyObject * ppyObject);
|
|
CNumberLine(CWindow * pParent);
|
|
virtual ~CNumberLine();
|
|
void SetPath(const char * c_szPath);
|
|
void SetHorizontalAlign(int iType);
|
|
void SetNumber(const char * c_szNumber);
|
|
protected:
|
|
void ClearNumber();
|
|
void OnRender() override;
|
|
void OnChangePosition() override;
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
|
|
std::string m_strPath;
|
|
std::string m_strNumber;
|
|
std::vector<CGraphicImageInstance *> m_ImageInstanceVector;
|
|
int m_iHorizontalAlign;
|
|
DWORD m_dwWidthSummary;
|
|
};
|
|
|
|
class CImageBox : public CWindow
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CImageBox(PyObject * ppyObject);
|
|
virtual ~CImageBox();
|
|
|
|
void LeftRightReverse();
|
|
BOOL LoadImage(CGraphicImageInstance* imageInstance);
|
|
BOOL LoadImage(const char * c_szFileName);
|
|
void SetDiffuseColor(float fr, float fg, float fb, float fa);
|
|
|
|
void Clear();
|
|
int GetWidth();
|
|
int GetHeight();
|
|
void SetScale(float sx, float sy);
|
|
void SetCoolTime(float fCoolTime) { m_fCoolTime = fCoolTime; }
|
|
void SetCoolTimeStart(float fCoolTimeStart) { m_fCoolTimeStart = fCoolTimeStart; }
|
|
|
|
protected:
|
|
virtual void OnCreateInstance();
|
|
virtual void OnDestroyInstance();
|
|
|
|
void OnUpdate() override;
|
|
void OnRender() override;
|
|
void OnChangePosition() override;
|
|
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
|
|
protected:
|
|
CGraphicImageInstance * m_pImageInstance;
|
|
float m_fCoolTime;
|
|
float m_fCoolTimeStart;
|
|
};
|
|
|
|
class CMarkBox : public CWindow
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CMarkBox(PyObject * ppyObject);
|
|
virtual ~CMarkBox();
|
|
|
|
void LoadImage(const char * c_szFilename);
|
|
void SetDiffuseColor(float fr, float fg, float fb, float fa);
|
|
void SetIndex(UINT uIndex);
|
|
void SetScale(FLOAT fScale);
|
|
|
|
protected:
|
|
virtual void OnCreateInstance();
|
|
virtual void OnDestroyInstance();
|
|
|
|
void OnUpdate() override;
|
|
void OnRender() override;
|
|
void OnChangePosition() override;
|
|
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
|
|
protected:
|
|
CGraphicMarkInstance * m_pMarkInstance;
|
|
};
|
|
|
|
class CExpandedImageBox : public CImageBox
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CExpandedImageBox(PyObject * ppyObject);
|
|
virtual ~CExpandedImageBox();
|
|
|
|
void SetScale(float fx, float fy);
|
|
void SetOrigin(float fx, float fy);
|
|
void SetRotation(float fRotation);
|
|
void SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom);
|
|
void SetRenderingMode(int iMode);
|
|
void SetImageClipRect(float fLeft, float fTop, float fRight, float fBottom, bool bIsVertical = false);
|
|
|
|
protected:
|
|
void OnCreateInstance() override;
|
|
void OnDestroyInstance() override;
|
|
|
|
void OnUpdate() override;
|
|
void OnRender() override;
|
|
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
};
|
|
|
|
class CAniImageBox : public CWindow
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CAniImageBox(PyObject * ppyObject);
|
|
virtual ~CAniImageBox();
|
|
|
|
void SetDelay(int iDelay);
|
|
void AppendImage(const char * c_szFileName, float r = 1.0, float g = 1.0, float b = 1.0, float a = 1.0);
|
|
void SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom);
|
|
void SetRenderingMode(int iMode);
|
|
void AppendImageScale(const char * c_szFileName, float scale_x, float scale_y);
|
|
void ResetFrame();
|
|
void SetRotation(float fRotation);
|
|
void SetMoveStatus(bool bFlag);
|
|
void SetMoveSpeed(float speed);
|
|
void SetMovePos(float directionX, float directionY);
|
|
float GetRotation();
|
|
void CheckMove();
|
|
void OnMoveDone();
|
|
|
|
protected:
|
|
void OnUpdate() override;
|
|
void OnRender() override;
|
|
void OnChangePosition() override;
|
|
virtual void OnEndFrame();
|
|
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
|
|
protected:
|
|
BYTE m_bycurDelay;
|
|
BYTE m_byDelay;
|
|
BYTE m_bycurIndex;
|
|
float nextX;
|
|
float nextY;
|
|
float fSpeed;
|
|
bool moveStart;
|
|
std::vector<CGraphicExpandedImageInstance*> m_ImageVector;
|
|
};
|
|
|
|
class CButton : public CWindow
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CButton(PyObject * ppyObject);
|
|
virtual ~CButton();
|
|
|
|
void LeftRightReverse();
|
|
|
|
BOOL SetUpVisual(const char * c_szFileName);
|
|
BOOL SetOverVisual(const char * c_szFileName);
|
|
BOOL SetDownVisual(const char * c_szFileName);
|
|
BOOL SetDisableVisual(const char * c_szFileName);
|
|
void SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom);
|
|
|
|
const char * GetUpVisualFileName();
|
|
const char * GetOverVisualFileName();
|
|
const char * GetDownVisualFileName();
|
|
|
|
void FlashEx() { m_isFlashEx = TRUE; }
|
|
void Flash(bool bFlash = true) { m_isFlash = bFlash; }
|
|
void Enable();
|
|
void Disable();
|
|
|
|
void SetUp();
|
|
void Up();
|
|
void Over();
|
|
void Down();
|
|
|
|
BOOL IsDisable() { return m_bEnable; }
|
|
BOOL IsPressed() { return m_isPressed; }
|
|
BOOL IsEnable() { return m_bEnable; }
|
|
|
|
protected:
|
|
void OnUpdate() override;
|
|
void OnRender() override;
|
|
void OnChangePosition() override;
|
|
|
|
BOOL OnMouseLeftButtonDown() override;
|
|
BOOL OnMouseLeftButtonUp() override;
|
|
void OnMouseOverIn() override;
|
|
void OnMouseOverOut() override;
|
|
|
|
void SetCurrentVisual(CGraphicImageInstance* pVisual);
|
|
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
|
|
protected:
|
|
BOOL m_bEnable;
|
|
BOOL m_isPressed;
|
|
BOOL m_isFlashEx;
|
|
BOOL m_isFlash;
|
|
CGraphicImageInstance* m_pcurVisual;
|
|
CGraphicImageInstance m_upVisual;
|
|
CGraphicImageInstance m_overVisual;
|
|
CGraphicImageInstance m_downVisual;
|
|
CGraphicImageInstance m_disableVisual;
|
|
};
|
|
|
|
class CRadioButton : public CButton
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CRadioButton(PyObject* ppyObject);
|
|
virtual ~CRadioButton();
|
|
protected:
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
BOOL OnMouseLeftButtonDown() override;
|
|
BOOL OnMouseLeftButtonUp() override;
|
|
void OnMouseOverIn() override;
|
|
void OnMouseOverOut() override;
|
|
};
|
|
|
|
class CToggleButton : public CButton
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CToggleButton(PyObject* ppyObject);
|
|
virtual ~CToggleButton();
|
|
protected:
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
BOOL OnMouseLeftButtonDown() override;
|
|
BOOL OnMouseLeftButtonUp() override;
|
|
void OnMouseOverIn() override;
|
|
void OnMouseOverOut() override;
|
|
};
|
|
|
|
class CDragButton : public CButton
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CDragButton(PyObject * ppyObject);
|
|
virtual ~CDragButton();
|
|
void SetRestrictMovementArea(int ix, int iy, int iwidth, int iheight);
|
|
protected:
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
void OnChangePosition() override;
|
|
void OnMouseOverIn() override;
|
|
RECT m_restrictArea;
|
|
};
|
|
|
|
class CUiRenderTarget : public CWindow
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CUiRenderTarget(PyObject* ppyObject);
|
|
virtual ~CUiRenderTarget();
|
|
bool SetRenderTarget(int index);
|
|
void SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom);
|
|
protected:
|
|
void OnRender() override;
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
DWORD m_dwIndex;
|
|
RECT rect_ex;
|
|
};
|
|
|
|
class CSlotButton : public CButton
|
|
{
|
|
public:
|
|
CSlotButton(PyObject* ppy = nullptr);
|
|
CSlotButton(DWORD dwSlotNumber, CSlotWindow* pParent);
|
|
virtual ~CSlotButton();
|
|
void SetSlotNumber(DWORD dwSlotNumber) { m_dwSlotNumber = dwSlotNumber; }
|
|
DWORD GetSlotNumber() const { return m_dwSlotNumber; }
|
|
void SetParentSlotWindow(CSlotWindow* pParent) { m_pParent = pParent; }
|
|
protected:
|
|
DWORD m_dwSlotNumber;
|
|
CSlotWindow* m_pParent;
|
|
};
|
|
|
|
class CCoverButton : public CSlotButton
|
|
{
|
|
public:
|
|
CCoverButton(PyObject* ppy = nullptr);
|
|
CCoverButton(DWORD dwSlotNumber, CSlotWindow* pParent);
|
|
virtual ~CCoverButton();
|
|
void SetLeftButtonEnable(BOOL b) { m_bLeftButtonEnable = b; }
|
|
void SetRightButtonEnable(BOOL b) { m_bRightButtonEnable = b; }
|
|
void RenderButton();
|
|
void OnRender() override {}
|
|
BOOL OnMouseLeftButtonDown() override;
|
|
protected:
|
|
BOOL m_bLeftButtonEnable;
|
|
BOOL m_bRightButtonEnable;
|
|
};
|
|
|
|
class CSlotWindow : public CWindow
|
|
{
|
|
public:
|
|
enum ESlotState
|
|
{
|
|
SLOT_STATE_LOCK = (1 << 0),
|
|
SLOT_STATE_CANT_USE = (1 << 1),
|
|
SLOT_STATE_DISABLE = (1 << 2),
|
|
SLOT_STATE_ALWAYS_RENDER_COVER = (1 << 3),
|
|
SLOT_STATE_CANT_MOUSE_EVENT = (1 << 4),
|
|
SLOT_STATE_UNUSABLE = (1 << 5),
|
|
};
|
|
|
|
enum ESlotStyle
|
|
{
|
|
SLOT_STYLE_NONE = 0,
|
|
SLOT_STYLE_PICK_UP = 1,
|
|
SLOT_STYLE_SELECT = 2,
|
|
};
|
|
|
|
struct SStoreCoolDown
|
|
{
|
|
float fCoolTime;
|
|
float fElapsedTime;
|
|
bool bActive;
|
|
};
|
|
|
|
struct SSlot
|
|
{
|
|
DWORD dwIndex = 0;
|
|
DWORD dwState = 0;
|
|
DWORD dwSlotNumber = 0;
|
|
DWORD dwCenterSlotNumber = 0;
|
|
int ixPosition = 0;
|
|
int iyPosition = 0;
|
|
int ixCellSize = 32;
|
|
int iyCellSize = 32;
|
|
BYTE byWidth = 1;
|
|
BYTE byHeight = 1;
|
|
BYTE byxPlacedItemSize = 1;
|
|
BYTE byyPlacedItemSize = 1;
|
|
bool bRenderBaseSlotImage = true;
|
|
bool isItem = false;
|
|
DWORD dwItemIndex = 0;
|
|
DWORD dwItemID = 0;
|
|
CGraphicImageInstance* pInstance = nullptr;
|
|
CGraphicImageInstance* pCoverInstance = nullptr;
|
|
CNumberLine* pNumberLine = nullptr;
|
|
CCoverButton* pCoverButton = nullptr;
|
|
CSlotButton* pSlotButton = nullptr;
|
|
CImageBox* pSignImage = nullptr;
|
|
CAniImageBox* pFinishCoolTimeEffect = nullptr;
|
|
CAniImageBox* pActiveSlotEffect[3]{};
|
|
DWORD dwItemCount = 0;
|
|
DWORD dwGrade = 0;
|
|
bool bActive = false;
|
|
bool bLocked = false;
|
|
float fCoolTime = 0.0f;
|
|
float fStartCoolTime = 0.0f;
|
|
};
|
|
|
|
static DWORD Type();
|
|
CSlotWindow(PyObject * ppyObject);
|
|
virtual ~CSlotWindow();
|
|
void Destroy();
|
|
void SetSlotID(DWORD dwIndex, DWORD dwID);
|
|
void SetSlotType(DWORD dwType) { m_dwSlotType = dwType; }
|
|
void SetSlotStyle(DWORD dwStyle) { m_dwSlotStyle = dwStyle; }
|
|
void AppendSlot(DWORD dwIndex, int ix, int iy, int iw, int ih);
|
|
void SetCoverButton(DWORD dwIndex, const char* c_szUpImageName, const char* c_szOverImageName, const char* c_szDownImageName, const char* c_szDisableImageName, BOOL bLeftButtonEnable, BOOL bRightButtonEnable);
|
|
void SetSlotBaseImage(const char* szFileName, float fr = 1.0f, float fg = 1.0f, float fb = 1.0f, float fa = 1.0f);
|
|
void AppendSlotButton(const char* c_szUpImageName, const char* c_szOverImageName, const char* c_szDownImageName);
|
|
void AppendRequirementSignImage(const char* c_szImageName);
|
|
void SetSlotBaseImageScale(const char* szFileName, float fr, float fg, float fb, float fa, float sx, float sy);
|
|
void SetSlotScale(DWORD dwIndex, DWORD dwItemIndex, BYTE byWidth, BYTE byHeight, CGraphicImage* pImage, float sx, float sy, const D3DXCOLOR& diffuseColor);
|
|
void EnableCoverButton(DWORD dwIndex);
|
|
void DisableCoverButton(DWORD dwIndex);
|
|
void SetAlwaysRenderCoverButton(DWORD dwIndex, bool bAlways = false);
|
|
void ShowSlotBaseImage(DWORD dwIndex);
|
|
void HideSlotBaseImage(DWORD dwIndex);
|
|
BOOL IsDisableCoverButton(DWORD dwIndex);
|
|
BOOL HasSlot(DWORD dwIndex);
|
|
void ClearAllSlot();
|
|
void ClearSlot(DWORD dwIndex);
|
|
void SetSlot(DWORD dwIndex, DWORD dwItemIndex, BYTE byWidth, BYTE byHeight, CGraphicImage* pImage, const D3DXCOLOR& diffuseColor);
|
|
void SetCardSlot(DWORD dwIndex, DWORD, BYTE, BYTE, const char*, DWORD) { if (!HasSlot(dwIndex)) AppendSlot(dwIndex, 0, 0, 32, 32); }
|
|
void SetSlotCount(DWORD dwIndex, DWORD dwCount);
|
|
void SetSlotCountNew(DWORD dwIndex, DWORD dwGrade, DWORD dwCount);
|
|
void SetSlotCoolTime(DWORD dwIndex, float fCoolTime, float fElapsedTime = 0.0f);
|
|
bool IsSlotCoolTime(DWORD dwIndex);
|
|
float GetSlotCoolTime(DWORD dwIndex);
|
|
float GetSlotRemainingCoolTime(DWORD dwIndex);
|
|
void StoreSlotCoolTime(DWORD dwKey, DWORD dwSlotIndex, float fCoolTime, float fElapsedTime = 0.0f);
|
|
void RestoreSlotCoolTime(DWORD dwKey);
|
|
void ActivateSlot(DWORD dwIndex);
|
|
void DeactivateSlot(DWORD dwIndex);
|
|
void RefreshSlot();
|
|
DWORD GetSlotCount() { return (DWORD)m_slotMap.size(); }
|
|
void LockSlot(DWORD dwIndex);
|
|
void UnlockSlot(DWORD dwIndex);
|
|
BOOL IsLockSlot(DWORD dwIndex);
|
|
void SetCantUseSlot(DWORD dwIndex);
|
|
void SetUseSlot(DWORD dwIndex);
|
|
BOOL IsCantUseSlot(DWORD dwIndex);
|
|
void EnableSlot(DWORD dwIndex);
|
|
void DisableSlot(DWORD dwIndex);
|
|
BOOL IsEnableSlot(DWORD dwIndex);
|
|
void SetCanMouseEventSlot(DWORD dwIndex);
|
|
void SetCantMouseEventSlot(DWORD dwIndex);
|
|
void SetUsableSlotOnTopWnd(DWORD dwIndex);
|
|
void SetUnusableSlotOnTopWnd(DWORD dwIndex);
|
|
void ClearSelected() { m_dwSelectedSlotIndexList.clear(); }
|
|
void SelectSlot(DWORD dwIndex);
|
|
BOOL isSelectedSlot(DWORD dwIndex);
|
|
DWORD GetSelectedSlotCount() { return (DWORD)m_dwSelectedSlotIndexList.size(); }
|
|
DWORD GetSelectedSlotNumber(DWORD dwIndex);
|
|
void ShowSlotButton(DWORD dwIndex);
|
|
void HideAllSlotButton();
|
|
void ShowRequirementSign(DWORD dwIndex);
|
|
void HideRequirementSign(DWORD dwIndex);
|
|
void SetUseMode(BOOL bFlag) { m_isUseMode = bFlag; }
|
|
void SetUsableItem(BOOL bFlag) { m_isUsableItem = bFlag; }
|
|
void ActivateEffect(DWORD dwIndex, float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f);
|
|
void DeactivateEffect(DWORD dwIndex);
|
|
|
|
BOOL GetSlotPointer(DWORD dwIndex, SSlot** ppSlot);
|
|
BOOL GetSelectedSlotPointer(SSlot** ppSlot);
|
|
// The slot under the mouse (EterPythonLib/PythonSlotWindow.cpp GetPickedSlotPointer).
|
|
virtual BOOL GetPickedSlotPointer(SSlot** ppSlot);
|
|
|
|
// Mouse events and their Python callbacks (EterPythonLib/PythonSlotWindow.cpp).
|
|
BOOL OnMouseLeftButtonDown() override;
|
|
BOOL OnMouseLeftButtonUp() override;
|
|
BOOL OnMouseRightButtonDown() override;
|
|
BOOL OnMouseLeftButtonDoubleClick() override;
|
|
void OnMouseOverOut() override;
|
|
void OnMouseOver() override;
|
|
|
|
void OnSelectEmptySlot(int iSlotNumber);
|
|
void OnSelectItemSlot(int iSlotNumber);
|
|
void OnUnselectEmptySlot(int iSlotNumber);
|
|
void OnUnselectItemSlot(int iSlotNumber);
|
|
void OnUseSlot();
|
|
BOOL OnOverIn(DWORD dwSlotNumber);
|
|
void OnOverOut();
|
|
BOOL OnOverInItem(DWORD dwSlotNumber);
|
|
void OnOverOutItem();
|
|
|
|
static constexpr DWORD SLOT_NUMBER_NONE = 0xffffffff;
|
|
|
|
protected:
|
|
void OnRender() override;
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
virtual void OnRefreshSlot() {}
|
|
virtual void OnRenderPickingSlot();
|
|
virtual void OnRenderSelectedSlot();
|
|
void RenderSlotBaseImage();
|
|
void RenderLockedSlot();
|
|
|
|
protected:
|
|
DWORD m_dwSlotType;
|
|
DWORD m_dwSlotStyle;
|
|
BOOL m_isUseMode;
|
|
BOOL m_isUsableItem;
|
|
DWORD m_dwToolTipSlotNumber = SLOT_NUMBER_NONE;
|
|
DWORD m_dwOverInSlotNumber = SLOT_NUMBER_NONE;
|
|
std::vector<DWORD> m_slots;
|
|
std::vector<DWORD> m_dwSelectedSlotIndexList;
|
|
std::map<DWORD, SSlot> m_slotMap;
|
|
std::map<DWORD, std::map<DWORD, SStoreCoolDown>> m_CoolDownStore;
|
|
CGraphicImageInstance* m_pBaseImageInstance;
|
|
CAniImageBox* m_apSlotActiveEffect[3]{};
|
|
};
|
|
|
|
class CGridSlotWindow : public CSlotWindow
|
|
{
|
|
public:
|
|
static DWORD Type();
|
|
CGridSlotWindow(PyObject * ppyObject);
|
|
virtual ~CGridSlotWindow();
|
|
void ArrangeGridSlot(DWORD dwStartIndex, DWORD dwxCount, DWORD dwyCount, int ixSlotSize, int iySlotSize, int ixTemporarySize, int iyTemporarySize);
|
|
BOOL GetPickedSlotList(BYTE byWidth, BYTE byHeight, std::vector<SSlot*>* pSlotList);
|
|
BOOL GetPickedSlotPointer(SSlot** ppSlot) override;
|
|
BOOL CheckMoving(DWORD dwSlotNumber, DWORD dwItemIndex, const std::vector<SSlot*>& slotList);
|
|
protected:
|
|
void OnRenderPickingSlot() override;
|
|
BOOL OnIsType(DWORD dwType) override;
|
|
void OnRefreshSlot() override;
|
|
BOOL GetGridSlotPointer(int ix, int iy, SSlot** ppSlot);
|
|
BOOL GetPickedGridSlotPosition(int ixLocal, int iyLocal, int* pix, int* piy);
|
|
|
|
DWORD m_dwxCount = 0, m_dwyCount = 0;
|
|
// Slot numbers by grid cell x + y * m_dwxCount (the original keeps slot pointers).
|
|
std::vector<DWORD> m_SlotVector;
|
|
};
|
|
}
|