File size: 9,635 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
-- ========== GENERATED BY XTemplate Editor (Alt-F3) DO NOT EDIT MANUALLY! ==========

PlaceObj('XTemplate', {
	__is_kind_of = "XDialog",
	group = "Common",
	id = "OptionsDialog",
	save_in = "Common",
	PlaceObj('XTemplateWindow', {
		'__context', function (parent, context) OptionsObj = OptionsObj or OptionsCreateAndLoad() return OptionsObj end,
		'__class', "XDialog",
		'HandleMouse', true,
		'InitialMode', "categories",
		'InternalModes', "categories,properties,items",
	}, {
		PlaceObj('XTemplateFunc', {
			'name', "OnDelete",
			'func', function (self, ...)
				OptionsObj = false
				OptionsObjOriginal = false
			end,
		}),
		PlaceObj('XTemplateFunc', {
			'name', "GetCategoryId",
			'func', function (self, ...)
				local mode_param = GetDialogModeParam(self)
				return  mode_param.id
			end,
		}),
		PlaceObj('XTemplateTemplate', {
			'__template', "DialogTitle",
			'Id', "idTitle",
			'Text', T(328054656910, --[[XTemplate OptionsDialog Text]] "OPTIONS"),
		}),
		PlaceObj('XTemplateWindow', {
			'HAlign', "center",
			'VAlign', "center",
			'LayoutMethod', "VList",
			'LayoutVSpacing', 20,
		}, {
			PlaceObj('XTemplateWindow', nil, {
				PlaceObj('XTemplateWindow', {
					'__class', "XContentTemplateList",
					'Id', "idList",
					'BorderWidth', 0,
					'Padding', box(0, 0, 0, 0),
					'LayoutVSpacing', 20,
					'UniformRowHeight', true,
					'Clip', false,
					'Background', RGBA(0, 0, 0, 0),
					'FocusedBackground', RGBA(0, 0, 0, 0),
					'VScroll', "idScroll",
					'ShowPartialItems', false,
					'MouseScroll', true,
					'RespawnOnContext', false,
				}, {
					PlaceObj('XTemplateMode', {
						'mode', "categories",
					}, {
						PlaceObj('XTemplateCode', {
							'run', function (self, parent, context)
								parent:ResolveId("idTitle"):SetText(T(477176115039, "OPTIONS"))
							end,
						}),
						PlaceObj('XTemplateForEach', {
							'comment', "categories",
							'array', function (parent, context) return OptionsCategories end,
							'condition', function (parent, context, item, i) return not prop_eval(item.no_edit, context, item) end,
							'__context', function (parent, context, item, i, n) return item end,
						}, {
							PlaceObj('XTemplateTemplate', {
								'__template', "MenuButton",
								'OnPress', function (self, gamepad)
									if type(self.context.run) == "function" then
										self.context.run()
									else
										SetDialogMode(self, "properties", self.context)
									end
								end,
								'Text', T(613640636043, --[[XTemplate OptionsDialog Text]] "<display_name>"),
							}),
							}),
						PlaceObj('XTemplateAction', {
							'ActionId', "Back",
							'ActionName', T(987308914761, --[[XTemplate OptionsDialog ActionName]] "BACK"),
							'ActionToolbar', "ActionBar",
							'ActionShortcut', "Escape",
							'ActionGamepad', "ButtonB",
							'OnActionEffect', "back",
						}),
						}),
					PlaceObj('XTemplateMode', {
						'mode', "properties",
					}, {
						PlaceObj('XTemplateCode', {
							'run', function (self, parent, context)
								parent:ResolveId("idTitle"):SetText(GetDialogModeParam(parent).caps_name)
							end,
						}),
						PlaceObj('XTemplateForEach', {
							'comment', "properties",
							'array', function (parent, context) return context:GetProperties() end,
							'condition', function (parent, context, item, i) item.items = prop_eval(item.items, nil, item) or OptionsData.Options[item.id] return item.category == GetDialogModeParam(parent).id and not prop_eval(item.no_edit, context, item) end,
							'item_in_context', "prop_meta",
						}, {
							PlaceObj('XTemplateTemplate', {
								'__template', "PropEntry",
							}),
							}),
						PlaceObj('XTemplateAction', {
							'ActionId', "cancelOptions",
							'ActionName', T(277023742051, --[[XTemplate OptionsDialog ActionName]] "CANCEL"),
							'ActionToolbar', "ActionBar",
							'ActionShortcut', "Escape",
							'ActionGamepad', "ButtonB",
							'OnAction', function (self, host, source, ...)
								CancelOptions(host)
							end,
							'__condition', function (parent, context) return GetDialogModeParam(parent).id ~= "Display" end,
						}),
						PlaceObj('XTemplateAction', {
							'ActionId', "cancelDisplayOptions",
							'ActionName', T(277023742051, --[[XTemplate OptionsDialog ActionName]] "CANCEL"),
							'ActionToolbar', "ActionBar",
							'ActionShortcut', "Escape",
							'ActionGamepad', "ButtonB",
							'OnAction', function (self, host, source, ...)
								CancelDisplayOptions(host)
							end,
							'__condition', function (parent, context) return GetDialogModeParam(parent).id == "Display" end,
						}),
						PlaceObj('XTemplateAction', {
							'ActionId', "autoDetect",
							'ActionName', T(616811979339, --[[XTemplate OptionsDialog ActionName]] "AUTO DETECT"),
							'ActionToolbar', "ActionBar",
							'ActionGamepad', "ButtonY",
							'OnAction', function (self, host, source, ...)
								Options.Autodetect(EngineOptions)
								local obj = ResolvePropObj(host.context)
								obj:SetVideoPreset(EngineOptions.VideoPreset)
								ObjModified(obj)
							end,
							'__condition', function (parent, context) return GetDialogModeParam(parent).id == "Video" and not Platform.console end,
						}),
						PlaceObj('XTemplateAction', {
							'ActionId', "restoreDefaults",
							'ActionName', T(519784994957, --[[XTemplate OptionsDialog ActionName]] "RESET"),
							'ActionToolbar', "ActionBar",
							'ActionGamepad', "ButtonY",
							'OnAction', function (self, host, source, ...)
								local obj = ResolvePropObj(host.context)
								obj:ResetOptionsByCategory(GetDialogModeParam(host).id)
								ObjModified(obj)
							end,
							'__condition', function (parent, context) return GetDialogModeParam(parent).id == "Keybindings" end,
						}),
						PlaceObj('XTemplateAction', {
							'ActionId', "resetToDefaults",
							'ActionName', T(519784994957, --[[XTemplate OptionsDialog ActionName]] "RESET"),
							'ActionToolbar', "ActionBar",
							'ActionGamepad', "ButtonY",
							'OnAction', function (self, host, source, ...)
								local obj = ResolvePropObj(host.context)
								obj:ResetOptionsByCategory(GetDialogModeParam(host).id)
								ObjModified(obj)
							end,
							'__condition', function (parent, context) local category = GetDialogModeParam(parent).id return category == "Audio" or category == "Controls" or category == "Gameplay" or category == "Display" end,
						}),
						PlaceObj('XTemplateAction', {
							'ActionId', "applyOptions",
							'ActionName', T(148605689666, --[[XTemplate OptionsDialog ActionName]] "APPLY"),
							'ActionToolbar', "ActionBar",
							'ActionGamepad', "ButtonX",
							'OnAction', function (self, host, source, ...)
								ApplyOptions(host)
							end,
							'__condition', function (parent, context) return GetDialogModeParam(parent).id ~= "Display" end,
						}),
						PlaceObj('XTemplateAction', {
							'ActionId', "applyDisplayOptions",
							'ActionName', T(148605689666, --[[XTemplate OptionsDialog ActionName]] "APPLY"),
							'ActionToolbar', "ActionBar",
							'ActionGamepad', "ButtonX",
							'OnAction', function (self, host, source, ...)
								ApplyDisplayOptions(host)
							end,
							'__condition', function (parent, context) return GetDialogModeParam(parent).id == "Display" end,
						}),
						}),
					PlaceObj('XTemplateMode', {
						'mode', "items",
					}, {
						PlaceObj('XTemplateCode', {
							'run', function (self, parent, context)
								parent:ResolveId("idTitle"):SetText(GetDialogModeParam(parent).name)
							end,
						}),
						PlaceObj('XTemplateForEach', {
							'comment', "items",
							'array', function (parent, context) return GetDialogModeParam(parent).items end,
							'condition', function (parent, context, item, i)
								local ns = item.not_selectable
								if type(ns) == "function" then 
									ns = OptionsObj and ns(item, OptionsObj) 
								end 
								return not ns
							end,
							'__context', function (parent, context, item, i, n) return item end,
						}, {
							PlaceObj('XTemplateTemplate', {
								'__template', "MenuButton",
								'OnPress', function (self, gamepad)
									local prop_meta = GetDialogModeParam(self)
									SetProperty(GetDialogContext(self), prop_meta.id, self.context.value)
									SetBackDialogMode(self)
								end,
								'Text', T(326989843349, --[[XTemplate OptionsDialog Text]] "<text>"),
							}),
							}),
						PlaceObj('XTemplateAction', {
							'ActionId', "cancel",
							'ActionName', T(277023742051, --[[XTemplate OptionsDialog ActionName]] "CANCEL"),
							'ActionToolbar', "ActionBar",
							'ActionShortcut', "Escape",
							'ActionGamepad', "ButtonB",
							'OnActionEffect', "back",
						}),
						}),
					}),
				PlaceObj('XTemplateWindow', {
					'__class', "XSleekScroll",
					'Id', "idScroll",
					'Margins', box(20, 0, 0, 0),
					'Dock', "right",
					'Target', "idList",
					'SnapToItems', true,
					'AutoHide', true,
				}),
				}),
			PlaceObj('XTemplateWindow', {
				'__class', "XToolBar",
				'Id', "idToolbar",
				'Margins', box(0, 60, 0, 0),
				'Dock', "bottom",
				'HAlign', "center",
				'VAlign', "center",
				'LayoutHSpacing', 20,
				'Background', RGBA(0, 0, 0, 0),
				'Toolbar', "ActionBar",
				'Show', "text",
				'ButtonTemplate', "MenuButton",
			}),
			}),
		PlaceObj('XTemplateWindow', {
			'__context', function (parent, context) OptionsObjOriginal = OptionsCreateAndLoad() return OptionsObjOriginal end,
			'__class', "XContextWindow",
			'Id', "idOriginalOptions",
			'Dock', "ignore",
		}),
		}),
})