File size: 2,897 Bytes
b6a38d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
-- ========== GENERATED BY XTemplate Editor (Alt-F3) DO NOT EDIT MANUALLY! ==========

PlaceObj('XTemplate', {
	__is_kind_of = "XPropControl",
	group = "Common",
	id = "PropBool",
	save_in = "Common",
	PlaceObj('XTemplateWindow', {
		'__class', "XPropControl",
		'BorderWidth', 2,
		'LayoutMethod', "HList",
		'Background', RGBA(255, 255, 255, 255),
		'RolloverOnFocus', true,
		'MouseCursor', "CommonAssets/UI/HandCursor.tga",
		'FocusedBackground', RGBA(170, 170, 170, 255),
		'DisabledBackground', RGBA(170, 170, 170, 255),
	}, {
		PlaceObj('XTemplateWindow', {
			'__class', "XText",
			'Id', "idName",
			'MinWidth', 300,
			'TextStyle', "GedTitle",
			'Translate', true,
		}),
		PlaceObj('XTemplateWindow', {
			'__class', "XText",
			'Id', "idOn",
			'FoldWhenHidden', true,
			'TextStyle', "GedTitle",
			'Translate', true,
			'Text', T(124979663072, --[[XTemplate PropBool Text]] "On"),
		}),
		PlaceObj('XTemplateWindow', {
			'__class', "XText",
			'Id', "idOff",
			'FoldWhenHidden', true,
			'TextStyle', "GedTitle",
			'Translate', true,
			'Text', T(388319833630, --[[XTemplate PropBool Text]] "Off"),
		}),
		PlaceObj('XTemplateFunc', {
			'name', "OnPropUpdate(self, context, prop_meta, value)",
			'func', function (self, context, prop_meta, value)
				if prop_meta.on_value ~= nil then
					self.idOn:SetVisible(value == prop_meta.on_value)
				else
					self.idOn:SetVisible(value)
				end
				if prop_meta.off_value ~= nil then
					self.idOff:SetVisible(value == prop_meta.off_value)
				else
					self.idOff:SetVisible(not value)
				end
				
				self:SetEnabled(not prop_meta.read_only)
				self:SetHandleMouse(self.enabled)
				self:SetChildrenHandleMouse(self.enabled)
			end,
		}),
		PlaceObj('XTemplateFunc', {
			'name', "OnMouseButtonDown(self, pos, button)",
			'func', function (self, pos, button)
				XPropControl.OnMouseButtonDown(self, pos, button)
				if button == "L" then
					local id = self.prop_meta.id
					local value = ResolveValue(self.context, id)
					local on_value, off_value = self.prop_meta.on_value, self.prop_meta.off_value
					if on_value ~= nil and value == on_value and off_value ~= nil then
						value = off_value
					elseif off_value ~= nil and value == off_value and on_value ~= nil then
						value = on_value
					else
						value = not value
					end
					
					local obj = ResolvePropObj(self.context)
					SetProperty(obj, id, value)
					self.value = value
					self:OnPropUpdate(self.context, self.prop_meta, value)
				end
			end,
		}),
		PlaceObj('XTemplateFunc', {
			'name', "OnShortcut(self, shortcut, source, ...)",
			'func', function (self, shortcut, source, ...)
				if shortcut == "ButtonA" then
				  self:OnMouseButtonDown(nil, "L")
				end
			end,
		}),
		PlaceObj('XTemplateFunc', {
			'name', "SetSelected(self, selected)",
			'func', function (self, selected)
				self:SetFocus(selected)
			end,
		}),
		}),
})