1
1
#include " pch.hpp"
2
2
#include " UIBtnHint.h"
3
3
#include " Static/UIStatic.h"
4
+ #include " Windows/UIFrameLineWnd.h"
4
5
#include " XML/UIXmlInitBase.h"
5
6
6
7
CUIButtonHint* g_btnHint = nullptr ;
7
8
CUIButtonHint* g_statHint = nullptr ;
8
9
9
- CUIButtonHint::CUIButtonHint ()
10
- : CUIFrameWindow(CUIButtonHint::GetDebugType()),
11
- m_ownerWnd(nullptr ),
12
- m_enabledOnFrame(false )
10
+ CUIButtonHint::CUIButtonHint () : CUIFrameWindow(CUIButtonHint::GetDebugType())
13
11
{
14
12
CUIXml uiXml;
15
13
uiXml.Load (CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, " hint_item.xml" );
16
- CUIXmlInitBase::InitFrameWindow (uiXml, " button_hint" , 0 , this );
14
+
15
+ if (uiXml.NavigateToNode (" button_hint:texture" )) // COP
16
+ CUIXmlInitBase::InitFrameWindow (uiXml, " button_hint" , 0 , this );
17
+ else // CS
18
+ {
19
+ CUIXmlInitBase::InitWindow (uiXml, " button_hint" , 0 , this );
20
+
21
+ m_border = xr_new<CUIFrameLineWnd>(" Border" );
22
+ m_border->SetAutoDelete (true );
23
+ AttachChild (m_border);
24
+ CUIXmlInitBase::InitFrameLine (uiXml, " button_hint:frame_line" , 0 , m_border);
25
+ }
17
26
18
27
m_text = xr_new<CUIStatic>(" Text" );
19
28
m_text->SetAutoDelete (true );
@@ -26,7 +35,14 @@ void CUIButtonHint::OnRender()
26
35
if (m_enabledOnFrame)
27
36
{
28
37
m_text->Update ();
29
- SetTextureColor (color_rgba (255 , 255 , 255 , color_get_A (m_text->GetTextColor ())));
38
+
39
+ const u32 color = color_rgba (255 , 255 , 255 , color_get_A (m_text->GetTextColor ()));
40
+
41
+ if (m_border)
42
+ m_border->SetTextureColor (color);
43
+ else
44
+ SetTextureColor (color);
45
+
30
46
Draw ();
31
47
m_enabledOnFrame = false ;
32
48
}
@@ -37,13 +53,25 @@ void CUIButtonHint::SetHintText(CUIWindow* w, LPCSTR text)
37
53
m_ownerWnd = w;
38
54
m_text->SetTextST (text);
39
55
40
- m_text->AdjustHeightToText ();
56
+ if (m_border)
57
+ {
58
+ m_text->AdjustWidthToText ();
59
+ const float hh = _max (m_text->GetWidth ()+30 .0f , 80 .0f );
60
+ SetWidth (hh);
61
+ m_border->SetWidth (hh); // XXX: CUIFrameLineWnd ignores this. Fix
62
+ }
63
+ else
64
+ {
65
+ m_text->AdjustHeightToText ();
41
66
42
- Fvector2 new_size;
43
- new_size.x = GetWndSize ().x ;
44
- new_size.y = m_text->GetWndSize ().y + 20 .0f ;
67
+ const Fvector2 new_size
68
+ {
69
+ GetWndSize ().x ,
70
+ m_text->GetWndSize ().y + 20 .0f
71
+ };
45
72
46
- SetWndSize (new_size);
73
+ SetWndSize (new_size);
74
+ }
47
75
48
76
m_text->ResetColorAnimation ();
49
77
}
0 commit comments