local fileName ui_radial_wnd -- name of xml file local __commands -- s

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
local fileName = "ui_radial_wnd"; -- name of xml file
local __commands =
{
-- static_name in xml file = function which called when window closing
['static_name'] = function()
-- your action
end
};
-- struct of xml file
--[[
...
<background ...>
...
</background>
<static_name ...>
<text ...>...<text/>
<texture ...>...<texture/>
<hightlight ...>
<texture ...>...<texture/>
</hightlight>
</static_name>
...
]]--
class 'ui_radial' (CUIScriptWnd);
function ui_radial:__init( keyId) super()
self.keyId = keyId
self:SetWndRect( Frect():set( 0, 0, 1024, 768));
local xml = CScriptXmlInit();
xml:ParseFile( fileName);
xml:InitStatic( "background", self);
table.foreach( __commands, function( name, functor)
local st = xml:InitStatic( name, self);
local hl = xml:InitStatic( name .. ':highlight', self);
hl:Show( false);
self:Register( st, name);
-- callback on window mouse focus
self:AddCallback( name, ui_events.WINDOW_FOCUS_RECEIVED, function()
hl:Show( true);
self.functor = functor;
end)
-- callback on window lost mouse focus
self:AddCallback( name, ui_events.WINDOW_FOCUS_LOST function()
self.functor = nil;
hl:Show( false);
end)
end);
end
function ui_radial:Hide()
if self.functor then
self.functor();
end
self:HideDialog();
end
function ui_radial:OnKeyboard( dik, keyboard_action)
if keyboard_action == ui_events.WINDOW_KEY_RELEASED then
if dik == self.keyId then
self:Hide();
end
end
end
-- call of radial
function main()
-- argument - key id. on released this key window will be closed and function will be called
file_name.ui_radial():ShowDialog( DIK_keys.DIK_F1);
end