将部分枚举类型替换为强枚举类型
This commit is contained in:
parent
52bfa595ad
commit
245a6c6e71
|
|
@ -141,25 +141,25 @@ void Input::__updateDeviceState()
|
|||
ScreenToClient(Window::getHWnd(), &s_MousePosition);
|
||||
}
|
||||
|
||||
bool Input::isKeyDown(int nKeyCode)
|
||||
bool Input::isKeyDown(KeyCode key)
|
||||
{
|
||||
if (s_KeyBuffer[static_cast<int>(nKeyCode)] & 0x80)
|
||||
if (s_KeyBuffer[static_cast<int>(key)] & 0x80)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Input::isKeyPress(int nKeyCode)
|
||||
bool Input::isKeyPress(KeyCode key)
|
||||
{
|
||||
if ((s_KeyBuffer[static_cast<int>(nKeyCode)] & 0x80) &&
|
||||
!(s_KeyRecordBuffer[static_cast<int>(nKeyCode)] & 0x80))
|
||||
if ((s_KeyBuffer[static_cast<int>(key)] & 0x80) &&
|
||||
!(s_KeyRecordBuffer[static_cast<int>(key)] & 0x80))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Input::isKeyRelease(int nKeyCode)
|
||||
bool Input::isKeyRelease(KeyCode key)
|
||||
{
|
||||
if (!(s_KeyBuffer[static_cast<int>(nKeyCode)] & 0x80) &&
|
||||
(s_KeyRecordBuffer[static_cast<int>(nKeyCode)] & 0x80))
|
||||
if (!(s_KeyBuffer[static_cast<int>(key)] & 0x80) &&
|
||||
(s_KeyRecordBuffer[static_cast<int>(key)] & 0x80))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ void e2d::Collider::_render()
|
|||
}
|
||||
}
|
||||
|
||||
int e2d::Collider::getRelationWith(Collider * pCollider) const
|
||||
e2d::Relation e2d::Collider::getRelationWith(Collider * pCollider) const
|
||||
{
|
||||
if (m_pTransformedGeometry && pCollider->m_pTransformedGeometry)
|
||||
{
|
||||
|
|
@ -74,7 +74,7 @@ int e2d::Collider::getRelationWith(Collider * pCollider) const
|
|||
&relation
|
||||
);
|
||||
|
||||
return relation;
|
||||
return Relation(relation);
|
||||
}
|
||||
}
|
||||
return Relation::UNKNOWN;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ e2d::TextStyle::TextStyle()
|
|||
, color(Color::WHITE)
|
||||
, fontWeight(FontWeight::NORMAL)
|
||||
, italic(false)
|
||||
, alignment(TextAlign::LEFT)
|
||||
, wrapping(false)
|
||||
, wrappingWidth(0.0)
|
||||
, lineSpacing(0.0)
|
||||
, hasUnderline(false)
|
||||
, hasStrikethrough(false)
|
||||
, hasOutline(true)
|
||||
|
|
@ -19,19 +23,27 @@ e2d::TextStyle::TextStyle(
|
|||
double fontSize,
|
||||
Color color,
|
||||
UINT32 fontWeight,
|
||||
bool italic,
|
||||
bool italic,
|
||||
TextAlign alignment,
|
||||
bool wrapping,
|
||||
double wrappingWidth,
|
||||
double lineSpacing,
|
||||
bool hasUnderline,
|
||||
bool hasStrikethrough,
|
||||
bool hasOutline,
|
||||
Color outlineColor,
|
||||
double outlineWidth,
|
||||
int outlineJoin
|
||||
LineJoin outlineJoin
|
||||
)
|
||||
: fontFamily(fontFamily)
|
||||
, fontSize(fontSize)
|
||||
, color(color)
|
||||
, fontWeight(fontWeight)
|
||||
, italic(italic)
|
||||
, alignment(alignment)
|
||||
, wrapping(wrapping)
|
||||
, wrappingWidth(wrappingWidth)
|
||||
, lineSpacing(lineSpacing)
|
||||
, hasUnderline(hasUnderline)
|
||||
, hasStrikethrough(hasStrikethrough)
|
||||
, hasOutline(hasOutline)
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ void e2d::ColliderManager::__updateCollider(e2d::Collider * pActiveCollider)
|
|||
if (IsCollideWith(pActiveNode, pPassiveNode))
|
||||
{
|
||||
// 判断两碰撞体交集情况
|
||||
int relation = pActiveCollider->getRelationWith(pPassiveCollider);
|
||||
Relation relation = pActiveCollider->getRelationWith(pPassiveCollider);
|
||||
// 忽略 UNKNOWN 和 DISJOINT 情况
|
||||
if (relation != Relation::UNKNOWN && relation != Relation::DISJOINT)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
e2d::Button::Button()
|
||||
: m_Callback(nullptr)
|
||||
, m_eBtnState(Button::NORMAL)
|
||||
, m_eBtnState(ButtonState::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
|
|
@ -18,7 +18,7 @@ e2d::Button::Button()
|
|||
|
||||
e2d::Button::Button(Node * normal, Function func)
|
||||
: m_Callback(nullptr)
|
||||
, m_eBtnState(Button::NORMAL)
|
||||
, m_eBtnState(ButtonState::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
|
|
@ -32,7 +32,7 @@ e2d::Button::Button(Node * normal, Function func)
|
|||
|
||||
e2d::Button::Button(Node * normal, Node * selected, Function func)
|
||||
: m_Callback(nullptr)
|
||||
, m_eBtnState(Button::NORMAL)
|
||||
, m_eBtnState(ButtonState::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
|
|
@ -47,7 +47,7 @@ e2d::Button::Button(Node * normal, Node * selected, Function func)
|
|||
|
||||
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Function func)
|
||||
: m_Callback(nullptr)
|
||||
, m_eBtnState(Button::NORMAL)
|
||||
, m_eBtnState(ButtonState::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
|
|
@ -63,7 +63,7 @@ e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Function f
|
|||
|
||||
e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, Function func)
|
||||
: m_Callback(nullptr)
|
||||
, m_eBtnState(Button::NORMAL)
|
||||
, m_eBtnState(ButtonState::NORMAL)
|
||||
, m_bEnable(true)
|
||||
, m_bIsSelected(false)
|
||||
, m_pNormal(nullptr)
|
||||
|
|
@ -210,21 +210,21 @@ void e2d::Button::onFixedUpdate()
|
|||
{
|
||||
if (m_pNormal->isPointIn(Input::getMousePos()))
|
||||
{
|
||||
_setState(Button::SELECTED);
|
||||
_setState(ButtonState::SELECTED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (m_pNormal->isPointIn(Input::getMousePos()))
|
||||
{
|
||||
_setState(Button::MOUSEOVER);
|
||||
_setState(ButtonState::MOUSEOVER);
|
||||
return;
|
||||
}
|
||||
|
||||
_setState(Button::NORMAL);
|
||||
_setState(ButtonState::NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Button::_setState(BTN_STATE state)
|
||||
void e2d::Button::_setState(ButtonState state)
|
||||
{
|
||||
if (m_eBtnState != state)
|
||||
{
|
||||
|
|
@ -242,11 +242,11 @@ void e2d::Button::_updateVisiable()
|
|||
|
||||
if (m_bEnable)
|
||||
{
|
||||
if (m_eBtnState == Button::SELECTED && m_pSelected)
|
||||
if (m_eBtnState == ButtonState::SELECTED && m_pSelected)
|
||||
{
|
||||
m_pSelected->setVisiable(true);
|
||||
}
|
||||
else if (m_eBtnState == Button::MOUSEOVER && m_pMouseover)
|
||||
else if (m_eBtnState == ButtonState::MOUSEOVER && m_pMouseover)
|
||||
{
|
||||
m_pMouseover->setVisiable(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -561,7 +561,7 @@ void e2d::Node::setProperty(NodeProperty prop)
|
|||
this->setSkew(prop.skewAngleX, prop.skewAngleY);
|
||||
}
|
||||
|
||||
void e2d::Node::setCollider(int nColliderType)
|
||||
void e2d::Node::setCollider(ColliderType nColliderType)
|
||||
{
|
||||
switch (nColliderType)
|
||||
{
|
||||
|
|
@ -960,7 +960,7 @@ bool e2d::Node::isIntersectWith(const Node * pNode) const
|
|||
// 如果存在碰撞体,用碰撞体判断
|
||||
if (this->m_pCollider && pNode->m_pCollider)
|
||||
{
|
||||
int relation = this->m_pCollider->getRelationWith(pNode->m_pCollider);
|
||||
Relation relation = this->m_pCollider->getRelationWith(pNode->m_pCollider);
|
||||
if ((relation != Relation::UNKNOWN) &&
|
||||
(relation != Relation::DISJOINT))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ double e2d::Shape::getStrokeWidth() const
|
|||
return m_fStrokeWidth;
|
||||
}
|
||||
|
||||
int e2d::Shape::getStyle() const
|
||||
e2d::ShapeStyle e2d::Shape::getStyle() const
|
||||
{
|
||||
return m_nStyle;
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ void e2d::Shape::setStrokeWidth(double strokeWidth)
|
|||
m_fStrokeWidth = static_cast<float>(strokeWidth);
|
||||
}
|
||||
|
||||
void e2d::Shape::setStyle(int style)
|
||||
void e2d::Shape::setStyle(ShapeStyle style)
|
||||
{
|
||||
m_nStyle = style;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,22 +2,14 @@
|
|||
|
||||
|
||||
e2d::Text::Text()
|
||||
: m_bWrappingEnable(false)
|
||||
, m_TextStyle()
|
||||
, m_nAlign(TextAlign::LEFT)
|
||||
, m_fLineSpacing(0.0f)
|
||||
, m_fWrappingWidth(0.0f)
|
||||
: m_TextStyle()
|
||||
, m_pDWriteTextLayout(nullptr)
|
||||
, m_pDWriteTextFormat(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::Text::Text(String text)
|
||||
: m_bWrappingEnable(false)
|
||||
, m_TextStyle()
|
||||
, m_nAlign(TextAlign::LEFT)
|
||||
, m_fLineSpacing(0.0f)
|
||||
, m_fWrappingWidth(0.0f)
|
||||
: m_TextStyle()
|
||||
, m_pDWriteTextLayout(nullptr)
|
||||
, m_pDWriteTextFormat(nullptr)
|
||||
, m_sText(text)
|
||||
|
|
@ -26,11 +18,7 @@ e2d::Text::Text(String text)
|
|||
}
|
||||
|
||||
e2d::Text::Text(TextStyle textStyle)
|
||||
: m_bWrappingEnable(false)
|
||||
, m_TextStyle(textStyle)
|
||||
, m_nAlign(TextAlign::LEFT)
|
||||
, m_fLineSpacing(0.0f)
|
||||
, m_fWrappingWidth(0.0f)
|
||||
: m_TextStyle(textStyle)
|
||||
, m_pDWriteTextLayout(nullptr)
|
||||
, m_pDWriteTextFormat(nullptr)
|
||||
{
|
||||
|
|
@ -38,11 +26,7 @@ e2d::Text::Text(TextStyle textStyle)
|
|||
}
|
||||
|
||||
e2d::Text::Text(String text, TextStyle textStyle)
|
||||
: m_bWrappingEnable(false)
|
||||
, m_TextStyle(textStyle)
|
||||
, m_nAlign(TextAlign::LEFT)
|
||||
, m_fLineSpacing(0.0f)
|
||||
, m_fWrappingWidth(0.0f)
|
||||
: m_TextStyle(textStyle)
|
||||
, m_pDWriteTextLayout(nullptr)
|
||||
, m_pDWriteTextFormat(nullptr)
|
||||
, m_sText(text)
|
||||
|
|
@ -57,28 +41,32 @@ e2d::Text::Text(
|
|||
UINT32 color,
|
||||
UINT32 fontWeight,
|
||||
bool italic,
|
||||
TextAlign alignment,
|
||||
bool wrapping,
|
||||
double wrappingWidth,
|
||||
double lineSpacing,
|
||||
bool hasUnderline,
|
||||
bool hasStrikethrough,
|
||||
bool hasOutline,
|
||||
UINT32 outlineColor,
|
||||
UINT32 outlineWidth
|
||||
)
|
||||
: m_bWrappingEnable(false)
|
||||
, m_TextStyle(
|
||||
: m_TextStyle(
|
||||
fontFamily,
|
||||
fontSize,
|
||||
color,
|
||||
fontWeight,
|
||||
italic,
|
||||
alignment,
|
||||
wrapping,
|
||||
wrappingWidth,
|
||||
lineSpacing,
|
||||
hasUnderline,
|
||||
hasStrikethrough,
|
||||
hasOutline,
|
||||
outlineColor,
|
||||
outlineWidth
|
||||
)
|
||||
, m_nAlign(TextAlign::LEFT)
|
||||
, m_fLineSpacing(0.0f)
|
||||
, m_fWrappingWidth(0.0f)
|
||||
, m_pDWriteTextLayout(nullptr)
|
||||
, m_pDWriteTextFormat(nullptr)
|
||||
, m_sText(text)
|
||||
|
|
@ -132,7 +120,7 @@ double e2d::Text::getOutlineWidth() const
|
|||
return m_TextStyle.outlineWidth;
|
||||
}
|
||||
|
||||
int e2d::Text::getOutlineJoin() const
|
||||
e2d::LineJoin e2d::Text::getOutlineJoin() const
|
||||
{
|
||||
return m_TextStyle.outlineJoin;
|
||||
}
|
||||
|
|
@ -191,7 +179,7 @@ void e2d::Text::setFontFamily(String fontFamily)
|
|||
|
||||
void e2d::Text::setFontSize(double fontSize)
|
||||
{
|
||||
m_TextStyle.fontSize = static_cast<float>(fontSize);
|
||||
m_TextStyle.fontSize = fontSize;
|
||||
_reset();
|
||||
}
|
||||
|
||||
|
|
@ -212,30 +200,42 @@ void e2d::Text::setItalic(bool value)
|
|||
_reset();
|
||||
}
|
||||
|
||||
void e2d::Text::setWrapping(bool wrapping)
|
||||
{
|
||||
if (m_TextStyle.wrapping != wrapping)
|
||||
{
|
||||
m_TextStyle.wrapping = wrapping;
|
||||
_reset();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Text::setWrappingWidth(double fWrappingWidth)
|
||||
{
|
||||
if (m_fWrappingWidth != fWrappingWidth)
|
||||
if (m_TextStyle.wrappingWidth != fWrappingWidth)
|
||||
{
|
||||
m_fWrappingWidth = max(static_cast<float>(fWrappingWidth), 0);
|
||||
m_bWrappingEnable = (m_fWrappingWidth > FLT_MIN);
|
||||
_reset();
|
||||
m_TextStyle.wrappingWidth = max(fWrappingWidth, 0);
|
||||
|
||||
if (m_TextStyle.wrapping)
|
||||
{
|
||||
_reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Text::setLineSpacing(double fLineSpacing)
|
||||
{
|
||||
if (m_fLineSpacing != fLineSpacing)
|
||||
if (m_TextStyle.lineSpacing != fLineSpacing)
|
||||
{
|
||||
m_fLineSpacing = static_cast<float>(fLineSpacing);
|
||||
m_TextStyle.lineSpacing = fLineSpacing;
|
||||
_reset();
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Text::setAlignment(int nAlign)
|
||||
void e2d::Text::setAlignment(TextAlign align)
|
||||
{
|
||||
if (m_nAlign != nAlign)
|
||||
if (m_TextStyle.alignment != align)
|
||||
{
|
||||
m_nAlign = nAlign;
|
||||
m_TextStyle.alignment = align;
|
||||
_reset();
|
||||
}
|
||||
}
|
||||
|
|
@ -277,7 +277,7 @@ void e2d::Text::setOutlineWidth(double outlineWidth)
|
|||
m_TextStyle.outlineWidth = outlineWidth;
|
||||
}
|
||||
|
||||
void e2d::Text::setOutlineJoin(int outlineJoin)
|
||||
void e2d::Text::setOutlineJoin(LineJoin outlineJoin)
|
||||
{
|
||||
m_TextStyle.outlineJoin = outlineJoin;
|
||||
}
|
||||
|
|
@ -331,9 +331,9 @@ void e2d::Text::_createFormat()
|
|||
if (m_pDWriteTextFormat)
|
||||
{
|
||||
// 设置文字对齐方式
|
||||
m_pDWriteTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT(m_nAlign));
|
||||
m_pDWriteTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT(m_TextStyle.alignment));
|
||||
// 设置行间距
|
||||
if (m_fLineSpacing == 0.0f)
|
||||
if (m_TextStyle.lineSpacing == 0.0)
|
||||
{
|
||||
m_pDWriteTextFormat->SetLineSpacing(DWRITE_LINE_SPACING_METHOD_DEFAULT, 0, 0);
|
||||
}
|
||||
|
|
@ -341,12 +341,12 @@ void e2d::Text::_createFormat()
|
|||
{
|
||||
m_pDWriteTextFormat->SetLineSpacing(
|
||||
DWRITE_LINE_SPACING_METHOD_UNIFORM,
|
||||
m_fLineSpacing,
|
||||
m_fLineSpacing * 0.8f
|
||||
static_cast<FLOAT>(m_TextStyle.lineSpacing),
|
||||
static_cast<FLOAT>(m_TextStyle.lineSpacing) * 0.8f
|
||||
);
|
||||
}
|
||||
// 打开文本自动换行时,设置换行属性
|
||||
if (m_bWrappingEnable)
|
||||
if (m_TextStyle.wrapping)
|
||||
{
|
||||
m_pDWriteTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP);
|
||||
}
|
||||
|
|
@ -379,13 +379,13 @@ void e2d::Text::_createLayout()
|
|||
// 创建 TextLayout
|
||||
HRESULT hr;
|
||||
// 对文本自动换行情况下进行处理
|
||||
if (m_bWrappingEnable)
|
||||
if (m_TextStyle.wrapping)
|
||||
{
|
||||
hr = Renderer::getIDWriteFactory()->CreateTextLayout(
|
||||
m_sText,
|
||||
length,
|
||||
m_pDWriteTextFormat,
|
||||
m_fWrappingWidth,
|
||||
static_cast<FLOAT>(m_TextStyle.wrappingWidth),
|
||||
0,
|
||||
&m_pDWriteTextLayout
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "..\e2dtransition.h"
|
||||
#include "..\e2dnode.h"
|
||||
|
||||
e2d::TransitionMove::TransitionMove(double duration, int direct)
|
||||
e2d::TransitionMove::TransitionMove(double duration, Direct direct)
|
||||
: Transition(duration)
|
||||
, m_Direct(direct)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -157,17 +157,17 @@ class Input
|
|||
public:
|
||||
// 检测键盘某按键是否正被按下
|
||||
static bool isKeyDown(
|
||||
int nKeyCode
|
||||
KeyCode key
|
||||
);
|
||||
|
||||
// 检测键盘某按键是否被点击
|
||||
static bool isKeyPress(
|
||||
int nKeyCode
|
||||
KeyCode key
|
||||
);
|
||||
|
||||
// 检测键盘某按键是否正在松开
|
||||
static bool isKeyRelease(
|
||||
int nKeyCode
|
||||
KeyCode key
|
||||
);
|
||||
|
||||
// 检测鼠标左键是否正被按下
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public:
|
|||
virtual ~Collider();
|
||||
|
||||
// 判断两碰撞体的交集关系
|
||||
virtual int getRelationWith(
|
||||
virtual Relation getRelationWith(
|
||||
Collider * pCollider
|
||||
) const;
|
||||
|
||||
|
|
|
|||
230
core/e2dcommon.h
230
core/e2dcommon.h
|
|
@ -334,166 +334,142 @@ public:
|
|||
|
||||
|
||||
// 文本对齐方式
|
||||
class TextAlign
|
||||
enum class TextAlign : int
|
||||
{
|
||||
public:
|
||||
enum : int
|
||||
{
|
||||
LEFT, /* 左对齐 */
|
||||
RIGHT, /* 右对齐 */
|
||||
CENTER /* 居中对齐 */
|
||||
};
|
||||
LEFT, /* 左对齐 */
|
||||
RIGHT, /* 右对齐 */
|
||||
CENTER /* 居中对齐 */
|
||||
};
|
||||
|
||||
|
||||
// 键值集合
|
||||
class KeyCode
|
||||
enum class KeyCode : int
|
||||
{
|
||||
public:
|
||||
enum : int
|
||||
{
|
||||
UP = 0xC8,
|
||||
LEFT = 0xCB,
|
||||
RIGHT = 0xCD,
|
||||
DOWN = 0xD0,
|
||||
ENTER = 0x1C,
|
||||
SPACE = 0x39,
|
||||
ESC = 0x01,
|
||||
BACK = 0x0E,
|
||||
TAB = 0x0F,
|
||||
PAUSE = 0xC5,
|
||||
Q = 0x10,
|
||||
W = 0x11,
|
||||
E = 0x12,
|
||||
R = 0x13,
|
||||
T = 0x14,
|
||||
Y = 0x15,
|
||||
U = 0x16,
|
||||
I = 0x17,
|
||||
O = 0x18,
|
||||
P = 0x19,
|
||||
A = 0x1E,
|
||||
S = 0x1F,
|
||||
D = 0x20,
|
||||
F = 0x21,
|
||||
G = 0x22,
|
||||
H = 0x23,
|
||||
J = 0x24,
|
||||
K = 0x25,
|
||||
L = 0x26,
|
||||
Z = 0x2C,
|
||||
X = 0x2D,
|
||||
C = 0x2E,
|
||||
V = 0x2F,
|
||||
B = 0x30,
|
||||
N = 0x31,
|
||||
M = 0x32,
|
||||
NUM1 = 0x02,
|
||||
NUM2 = 0x03,
|
||||
NUM3 = 0x04,
|
||||
NUM4 = 0x05,
|
||||
NUM5 = 0x06,
|
||||
NUM6 = 0x07,
|
||||
NUM7 = 0x08,
|
||||
NUM8 = 0x09,
|
||||
NUM9 = 0x0A,
|
||||
NUM0 = 0x0B,
|
||||
NUMPAD7 = 0x47,
|
||||
NUMPAD8 = 0x48,
|
||||
NUMPAD9 = 0x49,
|
||||
NUMPAD4 = 0x4B,
|
||||
NUMPAD5 = 0x4C,
|
||||
NUMPAD6 = 0x4D,
|
||||
NUMPAD1 = 0x4F,
|
||||
NUMPAD2 = 0x50,
|
||||
NUMPAD3 = 0x51,
|
||||
NUMPAD0 = 0x52
|
||||
};
|
||||
UP = 0xC8,
|
||||
LEFT = 0xCB,
|
||||
RIGHT = 0xCD,
|
||||
DOWN = 0xD0,
|
||||
ENTER = 0x1C,
|
||||
SPACE = 0x39,
|
||||
ESC = 0x01,
|
||||
BACK = 0x0E,
|
||||
TAB = 0x0F,
|
||||
PAUSE = 0xC5,
|
||||
Q = 0x10,
|
||||
W = 0x11,
|
||||
E = 0x12,
|
||||
R = 0x13,
|
||||
T = 0x14,
|
||||
Y = 0x15,
|
||||
U = 0x16,
|
||||
I = 0x17,
|
||||
O = 0x18,
|
||||
P = 0x19,
|
||||
A = 0x1E,
|
||||
S = 0x1F,
|
||||
D = 0x20,
|
||||
F = 0x21,
|
||||
G = 0x22,
|
||||
H = 0x23,
|
||||
J = 0x24,
|
||||
K = 0x25,
|
||||
L = 0x26,
|
||||
Z = 0x2C,
|
||||
X = 0x2D,
|
||||
C = 0x2E,
|
||||
V = 0x2F,
|
||||
B = 0x30,
|
||||
N = 0x31,
|
||||
M = 0x32,
|
||||
NUM1 = 0x02,
|
||||
NUM2 = 0x03,
|
||||
NUM3 = 0x04,
|
||||
NUM4 = 0x05,
|
||||
NUM5 = 0x06,
|
||||
NUM6 = 0x07,
|
||||
NUM7 = 0x08,
|
||||
NUM8 = 0x09,
|
||||
NUM9 = 0x0A,
|
||||
NUM0 = 0x0B,
|
||||
NUMPAD7 = 0x47,
|
||||
NUMPAD8 = 0x48,
|
||||
NUMPAD9 = 0x49,
|
||||
NUMPAD4 = 0x4B,
|
||||
NUMPAD5 = 0x4C,
|
||||
NUMPAD6 = 0x4D,
|
||||
NUMPAD1 = 0x4F,
|
||||
NUMPAD2 = 0x50,
|
||||
NUMPAD3 = 0x51,
|
||||
NUMPAD0 = 0x52
|
||||
};
|
||||
|
||||
|
||||
// 方向
|
||||
class Direct
|
||||
enum class Direct : int
|
||||
{
|
||||
public:
|
||||
enum : int
|
||||
{
|
||||
UP, /* 上 */
|
||||
DOWN, /* 下 */
|
||||
LEFT, /* 左 */
|
||||
RIGHT /* 右 */
|
||||
};
|
||||
UP, /* 上 */
|
||||
DOWN, /* 下 */
|
||||
LEFT, /* 左 */
|
||||
RIGHT /* 右 */
|
||||
};
|
||||
|
||||
|
||||
// 碰撞体交集关系
|
||||
class Relation
|
||||
// 物体交集关系
|
||||
enum class Relation : int
|
||||
{
|
||||
public:
|
||||
enum : int
|
||||
{
|
||||
UNKNOWN = 0, /* 关系不确定 */
|
||||
DISJOINT = 1, /* 没有交集 */
|
||||
IS_CONTAINED = 2, /* 完全被包含 */
|
||||
CONTAINS = 3, /* 完全包含 */
|
||||
OVERLAP = 4 /* 部分重叠 */
|
||||
};
|
||||
UNKNOWN = 0, /* 关系不确定 */
|
||||
DISJOINT = 1, /* 没有交集 */
|
||||
IS_CONTAINED = 2, /* 完全被包含 */
|
||||
CONTAINS = 3, /* 完全包含 */
|
||||
OVERLAP = 4 /* 部分重叠 */
|
||||
};
|
||||
|
||||
|
||||
// 线条相交样式
|
||||
class LineJoin
|
||||
enum class LineJoin : int
|
||||
{
|
||||
public:
|
||||
enum : int
|
||||
{
|
||||
MITER = 0,
|
||||
BEVEL = 1,
|
||||
ROUND = 2
|
||||
};
|
||||
MITER = 0,
|
||||
BEVEL = 1,
|
||||
ROUND = 2
|
||||
};
|
||||
|
||||
|
||||
// 形状样式
|
||||
class ShapeStyle
|
||||
enum class ShapeStyle : int
|
||||
{
|
||||
public:
|
||||
enum : int
|
||||
{
|
||||
SOLID, /* 填充 */
|
||||
ROUND, /* 轮廓 */
|
||||
FILL, /* 轮廓 + 填充 */
|
||||
};
|
||||
SOLID, /* 填充 */
|
||||
ROUND, /* 轮廓 */
|
||||
FILL, /* 轮廓 + 填充 */
|
||||
};
|
||||
|
||||
|
||||
// 碰撞体类别
|
||||
class ColliderType
|
||||
enum class ColliderType : int
|
||||
{
|
||||
public:
|
||||
enum : int
|
||||
{
|
||||
RECT, /* 矩形 */
|
||||
CIRCLE, /* 圆形 */
|
||||
ELLIPSE /* 椭圆形 */
|
||||
};
|
||||
RECT, /* 矩形 */
|
||||
CIRCLE, /* 圆形 */
|
||||
ELLIPSE /* 椭圆形 */
|
||||
};
|
||||
|
||||
|
||||
// 文本样式
|
||||
struct TextStyle
|
||||
{
|
||||
String fontFamily; // 字体
|
||||
double fontSize; // 字号
|
||||
Color color; // 颜色
|
||||
UINT32 fontWeight; // 粗细值
|
||||
bool italic; // 斜体
|
||||
bool hasUnderline; // 下划线
|
||||
bool hasStrikethrough; // 删除线
|
||||
bool hasOutline; // 显示描边
|
||||
Color outlineColor; // 描边颜色
|
||||
double outlineWidth; // 描边线宽
|
||||
int outlineJoin; // 描边线相交样式
|
||||
String fontFamily; // 字体
|
||||
double fontSize; // 字号
|
||||
Color color; // 颜色
|
||||
UINT32 fontWeight; // 粗细值
|
||||
bool italic; // 斜体
|
||||
TextAlign alignment; // 对齐方式
|
||||
bool wrapping; // 打开自动换行
|
||||
double wrappingWidth; // 自动换行宽度
|
||||
double lineSpacing; // 行间距
|
||||
bool hasUnderline; // 下划线
|
||||
bool hasStrikethrough; // 删除线
|
||||
bool hasOutline; // 显示描边
|
||||
Color outlineColor; // 描边颜色
|
||||
double outlineWidth; // 描边线宽
|
||||
LineJoin outlineJoin; // 描边线相交样式
|
||||
|
||||
/* 构造函数 */
|
||||
TextStyle();
|
||||
|
|
@ -504,12 +480,16 @@ struct TextStyle
|
|||
Color color = Color::WHITE,
|
||||
UINT32 fontWeight = FontWeight::NORMAL,
|
||||
bool italic = false,
|
||||
TextAlign alignment = TextAlign::LEFT,
|
||||
bool wrapping = false,
|
||||
double wrappingWidth = 0.0,
|
||||
double lineSpacing = 0.0,
|
||||
bool hasUnderline = false,
|
||||
bool hasStrikethrough = false,
|
||||
bool hasOutline = true,
|
||||
Color outlineColor = Color(Color::BLACK, 0.5),
|
||||
double outlineWidth = 1.0,
|
||||
int outlineJoin = LineJoin::ROUND
|
||||
LineJoin outlineJoin = LineJoin::ROUND
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ public:
|
|||
|
||||
// 设置碰撞体
|
||||
virtual void setCollider(
|
||||
int nColliderType
|
||||
ColliderType nColliderType
|
||||
);
|
||||
|
||||
// 设置碰撞体
|
||||
|
|
@ -566,6 +566,10 @@ public:
|
|||
UINT32 color = Color::WHITE, /* 颜色 */
|
||||
UINT32 fontWeight = FontWeight::NORMAL, /* 粗细值 */
|
||||
bool italic = false, /* 斜体 */
|
||||
TextAlign alignment = TextAlign::LEFT, /* 对齐方式 */
|
||||
bool wrapping = false, /* 打开自动换行 */
|
||||
double wrappingWidth = 0.0, /* 自动换行宽度 */
|
||||
double lineSpacing = 0.0, /* 行间距 */
|
||||
bool hasUnderline = false, /* 下划线 */
|
||||
bool hasStrikethrough = false, /* 删除线 */
|
||||
bool hasOutline = true, /* 显示描边 */
|
||||
|
|
@ -600,7 +604,7 @@ public:
|
|||
double getOutlineWidth() const;
|
||||
|
||||
// 获取描边线相交样式
|
||||
int getOutlineJoin() const;
|
||||
LineJoin getOutlineJoin() const;
|
||||
|
||||
// 获取文本显示行数
|
||||
int getLineCount() const;
|
||||
|
|
@ -652,7 +656,12 @@ public:
|
|||
bool value
|
||||
);
|
||||
|
||||
// 设置文本自动换行的宽度(设置为 0 时关闭自动换行,默认为 0)
|
||||
// 打开或关闭文本自动换行(默认为关闭)
|
||||
void setWrapping(
|
||||
bool wrapping
|
||||
);
|
||||
|
||||
// 设置文本自动换行的宽度(默认为 0)
|
||||
void setWrappingWidth(
|
||||
double fWrappingWidth
|
||||
);
|
||||
|
|
@ -664,7 +673,7 @@ public:
|
|||
|
||||
// 设置对齐方式(默认为 TextAlign::LEFT)
|
||||
void setAlignment(
|
||||
int nAlign
|
||||
TextAlign align
|
||||
);
|
||||
|
||||
// 设置下划线(默认值为 false)
|
||||
|
|
@ -694,7 +703,7 @@ public:
|
|||
|
||||
// 设置描边线相交样式
|
||||
void setOutlineJoin(
|
||||
int outlineJoin
|
||||
LineJoin outlineJoin
|
||||
);
|
||||
|
||||
// 渲染文字
|
||||
|
|
@ -712,11 +721,7 @@ protected:
|
|||
|
||||
protected:
|
||||
String m_sText;
|
||||
bool m_bWrappingEnable;
|
||||
float m_fWrappingWidth;
|
||||
float m_fLineSpacing;
|
||||
int m_nAlign;
|
||||
TextStyle m_TextStyle;
|
||||
TextStyle m_TextStyle;
|
||||
IDWriteTextFormat * m_pDWriteTextFormat;
|
||||
IDWriteTextLayout * m_pDWriteTextLayout;
|
||||
};
|
||||
|
|
@ -797,10 +802,10 @@ public:
|
|||
|
||||
protected:
|
||||
// 按钮状态枚举
|
||||
enum BTN_STATE { NORMAL, MOUSEOVER, SELECTED };
|
||||
enum class ButtonState { NORMAL, MOUSEOVER, SELECTED };
|
||||
|
||||
// 设置按钮状态
|
||||
virtual void _setState(BTN_STATE state);
|
||||
virtual void _setState(ButtonState state);
|
||||
|
||||
// 刷新按钮显示
|
||||
virtual void _updateVisiable();
|
||||
|
|
@ -815,7 +820,7 @@ protected:
|
|||
Node * m_pDisabled;
|
||||
bool m_bEnable;
|
||||
bool m_bIsSelected;
|
||||
BTN_STATE m_eBtnState;
|
||||
ButtonState m_eBtnState;
|
||||
Function m_Callback;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public:
|
|||
virtual ~Shape();
|
||||
|
||||
// »ñÈ¡Ñùʽ
|
||||
int getStyle() const;
|
||||
ShapeStyle getStyle() const;
|
||||
|
||||
// »ñÈ¡Ìî³äÑÕÉ«
|
||||
Color getFillColor() const;
|
||||
|
|
@ -42,7 +42,7 @@ public:
|
|||
);
|
||||
|
||||
// ÉèÖÃÑùʽ
|
||||
void setStyle(int style);
|
||||
void setStyle(ShapeStyle style);
|
||||
|
||||
// äÖȾÐÎ×´
|
||||
virtual void onRender() override;
|
||||
|
|
@ -55,7 +55,7 @@ protected:
|
|||
virtual void _renderFill() = 0;
|
||||
|
||||
protected:
|
||||
int m_nStyle;
|
||||
ShapeStyle m_nStyle;
|
||||
float m_fStrokeWidth;
|
||||
Color m_nLineColor;
|
||||
Color m_nFillColor;
|
||||
|
|
|
|||
|
|
@ -121,8 +121,8 @@ class TransitionMove :
|
|||
public:
|
||||
// 创建移动式的场景切换动画
|
||||
TransitionMove(
|
||||
double moveDuration, /* 场景移动动画持续时长 */
|
||||
int direct = Direct::LEFT /* 场景移动方向 */
|
||||
double moveDuration, /* 场景移动动画持续时长 */
|
||||
Direct direct = Direct::LEFT /* 场景移动方向 */
|
||||
);
|
||||
|
||||
protected:
|
||||
|
|
@ -137,7 +137,7 @@ protected:
|
|||
virtual void _reset() override;
|
||||
|
||||
protected:
|
||||
int m_Direct;
|
||||
Direct m_Direct;
|
||||
Vector m_Vector;
|
||||
Point m_NextPos;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue