File size: 23,557 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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
-- ========== GENERATED BY XTemplate Editor (Alt-F3) DO NOT EDIT MANUALLY! ==========

PlaceObj('XTemplate', {
	group = "GedApps",
	id = "ModEditor",
	save_in = "Ged",
	PlaceObj('XTemplateWindow', {
		'__class', "GedApp",
		'Translate', true,
		'Title', "Mod Editor",
		'AppId', "ModEditor",
		'InitialWidth', 1100,
	}, {
		PlaceObj('XTemplateFunc', {
			'name', "Open(self, ...)",
			'func', function (self, ...)
				MountFolder(self.mod_content_path, self.mod_os_path)
				return GedApp.Open(self, ...)
			end,
		}),
		PlaceObj('XTemplateAction', {
			'ActionId', "File",
			'ActionName', T(174683227646, --[[XTemplate ModEditor ActionName]] "File"),
			'ActionMenubar', "main",
			'OnActionEffect', "popup",
		}, {
			PlaceObj('XTemplateAction', {
				'ActionId', "Save",
				'ActionName', T(280146583573, --[[XTemplate ModEditor ActionName]] "Save"),
				'ActionIcon', "CommonAssets/UI/Ged/save.tga",
				'ActionToolbar', "main",
				'ActionShortcut', "Ctrl-S",
				'OnAction', function (self, host, source, ...)
					host:Send("GedSaveMod")
				end,
			}),
			PlaceObj('XTemplateAction', {
				'ActionId', "OpenFolder",
				'ActionName', T(595712252411, --[[XTemplate ModEditor ActionName]] "Open Folder"),
				'ActionIcon', "CommonAssets/UI/Ged/explorer.tga",
				'ActionToolbar', "main",
				'ActionShortcut', "Ctrl-O",
				'OnAction', function (self, host, source, ...)
					host:Op("GedOpOpenModFolder", "root")
				end,
			}),
			PlaceObj('XTemplateAction', {
				'ActionId', "GenTransTbl",
				'ActionName', T(727097690549, --[[XTemplate ModEditor ActionName]] "Export Translation Table"),
				'OnAction', function (self, host, source, ...)
					host:Op("GedOpGenTTableMod", "root")
				end,
			}),
			PlaceObj('XTemplateAction', {
				'ActionId', "PackMod",
				'ActionName', T(906167416126, --[[XTemplate ModEditor ActionName]] "Pack Mod"),
				'OnAction', function (self, host, source, ...)
					host:Op("GedOpPackMod", "root")
				end,
			}),
			PlaceObj('XTemplateCode', {
				'run', function (self, parent, context)
					if XTemplates.ModEditorPlatformActions then
						XTemplates.ModEditorPlatformActions:Eval(parent, context)
					end
				end,
			}),
			PlaceObj('XTemplateGroup', {
				'__condition', function (parent, context) return Platform.steam end,
			}, {
				PlaceObj('XTemplateAction', {
					'RolloverText', T(966025188900, --[[XTemplate ModEditor RolloverText]] "Upload to Steam"),
					'RolloverDisabledText', T(131688119141, --[[XTemplate ModEditor RolloverDisabledText]] "Uploading to Steam is unavailable"),
					'ActionId', "SteamUpload",
					'ActionName', T(740063077677, --[[XTemplate ModEditor ActionName]] "Upload to Steam"),
					'ActionIcon', "CommonAssets/UI/Ged/steam.tga",
					'ActionToolbar', "main",
					'ActionToolbarSplit', true,
					'ActionState', function (self, host)
						return not host.steam_login and "disabled"
					end,
					'OnAction', function (self, host, source, ...)
						host:Op("GedOpUploadModToSteam", "root")
					end,
				}),
				}),
			PlaceObj('XTemplateGroup', {
				'__condition', function (parent, context) return Platform.epic end,
			}, {
				PlaceObj('XTemplateAction', {
					'RolloverText', T(602897019334, --[[XTemplate ModEditor RolloverText]] "Upload to Epic Games"),
					'RolloverDisabledText', T(584040368360, --[[XTemplate ModEditor RolloverDisabledText]] "Uploading to Epic Games is unavailable"),
					'ActionId', "EpicUpload",
					'ActionName', T(848185994514, --[[XTemplate ModEditor ActionName]] "Upload to Epic Games"),
					'ActionIcon', "CommonAssets/UI/Ged/epic_up",
					'ActionToolbar', "main",
					'ActionToolbarSplit', true,
					'ActionState', function (self, host)
						
					end,
					'OnAction', function (self, host, source, ...)
						host:Op("GedOpUploadModToEpic", "root")
					end,
				}),
				}),
			}),
		PlaceObj('XTemplateAction', {
			'ActionId', "Edit",
			'ActionName', T(786174819535, --[[XTemplate ModEditor ActionName]] "Edit"),
			'ActionMenubar', "main",
			'OnActionEffect', "popup",
		}, {
			PlaceObj('XTemplateAction', {
				'ActionId', "Cut",
				'ActionName', T(718930329684, --[[XTemplate ModEditor ActionName]] "Cut"),
				'ActionIcon', "CommonAssets/UI/Ged/cut.tga",
				'ActionToolbar', "main",
				'ActionShortcut', "Ctrl-X",
				'OnAction', function (self, host, source, ...)
					local panel = host:GetLastFocusedPanel()
					if panel == host.idItems then
						host:Op("GedOpCutModItem", panel.context, panel:GetMultiSelection())
					end
				end,
				'ActionContexts', {
					"ContentRootPanelAction",
					"ContentChildPanelAction",
					"PresetsChildAction",
				},
				'replace_matching_id', true,
			}),
			PlaceObj('XTemplateAction', {
				'ActionId', "Copy",
				'ActionName', T(191389011800, --[[XTemplate ModEditor ActionName]] "Copy"),
				'ActionIcon', "CommonAssets/UI/Ged/copy.tga",
				'ActionToolbar', "main",
				'ActionShortcut', "Ctrl-C",
				'OnAction', function (self, host, source, ...)
					local panel = host:GetLastFocusedPanel()
					if panel == host.idItems then
						host:Op("GedOpCopyModItem", panel.context, panel:GetMultiSelection())
					elseif panel == host.idItemProperties then
						host:Op("GedOpPropertyCopy", panel.context, panel:GetSelectedProperties(), panel.context)
					end
				end,
				'ActionContexts', {
					"PresetsChildAction",
					"ContentRootPanelAction",
					"ContentChildPanelAction",
					"PropAction",
				},
				'replace_matching_id', true,
			}),
			PlaceObj('XTemplateAction', {
				'ActionId', "Paste",
				'ActionName', T(749315791356, --[[XTemplate ModEditor ActionName]] "Paste"),
				'ActionIcon', "CommonAssets/UI/Ged/paste.tga",
				'ActionToolbar', "main",
				'ActionShortcut', "Ctrl-V",
				'OnAction', function (self, host, source, ...)
					local panel = host:GetLastFocusedPanel()
					if panel == host.idItems then
						host:Op("GedOpPasteModItem", panel.context, panel:GetMultiSelection())
					elseif panel:IsKindOf("GedPropPanel") then
						host:Op("GedOpPropertyPaste", panel.context)
					end
				end,
				'ActionContexts', {
					"PresetsChildAction",
					"ContentRootPanelAction",
					"ContentChildPanelAction",
					"PropAction",
				},
				'replace_matching_id', true,
			}),
			PlaceObj('XTemplateAction', {
				'ActionId', "Duplicate",
				'ActionName', T(284844710474, --[[XTemplate ModEditor ActionName]] "Duplicate"),
				'ActionIcon', "CommonAssets/UI/Ged/duplicate.tga",
				'ActionToolbar', "main",
				'ActionToolbarSplit', true,
				'ActionShortcut', "Ctrl-D",
				'OnAction', function (self, host, source, ...)
					local panel = host:GetLastFocusedPanel()
					if panel == host.idItems then
						host:Op("GedOpDuplicateModItem", panel.context, panel:GetMultiSelection())
					end
				end,
				'ActionContexts', {
					"PresetsChildAction",
					"ContentRootPanelAction",
					"ContentChildPanelAction",
				},
				'replace_matching_id', true,
			}),
			PlaceObj('XTemplateAction', {
				'ActionName', T(930594708322, --[[XTemplate ModEditor ActionName]] "-----"),
				'ActionMenubar', "Edit",
			}),
			PlaceObj('XTemplateAction', {
				'ActionId', "MoveOutwards",
				'ActionName', T(556803322410, --[[XTemplate ModEditor ActionName]] "Move Out"),
				'ActionIcon', "CommonAssets/UI/Ged/left.tga",
				'ActionMenubar', "Edit",
				'ActionToolbar', "main",
				'ActionShortcut', "Alt-Left",
				'OnAction', function (self, host, source, ...)
					local panel = host:GetLastFocusedPanel()
					if panel == host.idItems then
						host:Op("GedOpTreeMoveItemOutwards", panel.context, panel:GetMultiSelection())
					end
				end,
			}),
			PlaceObj('XTemplateAction', {
				'ActionId', "MoveInwards",
				'ActionName', T(384052770742, --[[XTemplate ModEditor ActionName]] "Move In"),
				'ActionIcon', "CommonAssets/UI/Ged/right.tga",
				'ActionMenubar', "Edit",
				'ActionToolbar', "main",
				'ActionShortcut', "Alt-Right",
				'OnAction', function (self, host, source, ...)
					local panel = host:GetLastFocusedPanel()
					if panel == host.idItems then
						host:Op("GedOpTreeMoveItemInwards", panel.context, panel:GetMultiSelection())
					end
				end,
			}),
			PlaceObj('XTemplateAction', {
				'ActionId', "MoveUp",
				'ActionName', T(459268168316, --[[XTemplate ModEditor ActionName]] "Move Up"),
				'ActionIcon', "CommonAssets/UI/Ged/up.tga",
				'ActionMenubar', "Edit",
				'ActionToolbar', "main",
				'ActionShortcut', "Alt-Up",
				'OnAction', function (self, host, source, ...)
					local panel = host:GetLastFocusedPanel()
					if panel == host.idItems then
						host:Op("GedOpTreeMoveItemUp", panel.context, panel:GetMultiSelection())
					end
				end,
			}),
			PlaceObj('XTemplateAction', {
				'ActionId', "MoveDown",
				'ActionName', T(203305089151, --[[XTemplate ModEditor ActionName]] "Move Down"),
				'ActionIcon', "CommonAssets/UI/Ged/down.tga",
				'ActionMenubar', "Edit",
				'ActionToolbar', "main",
				'ActionShortcut', "Alt-Down",
				'OnAction', function (self, host, source, ...)
					local panel = host:GetLastFocusedPanel()
					if panel == host.idItems then
						host:Op("GedOpTreeMoveItemDown", panel.context, panel:GetMultiSelection())
					end
				end,
			}),
			PlaceObj('XTemplateAction', {
				'ActionId', "DeleteItem",
				'ActionName', T(931048354633, --[[XTemplate ModEditor ActionName]] "Delete Item"),
				'ActionIcon', "CommonAssets/UI/Ged/delete.tga",
				'ActionToolbar', "main",
				'ActionToolbarSplit', true,
				'ActionShortcut', "Delete",
				'OnAction', function (self, host, source, ...)
					host:Op("GedOpDeleteModItem", "root", host.idItems:GetMultiSelection())
				end,
			}),
			PlaceObj('XTemplateAction', {
				'ActionName', T(298776341838, --[[XTemplate ModEditor ActionName]] "-----"),
				'ActionMenubar', "Edit",
			}),
			PlaceObj('XTemplateAction', {
				'ActionId', "Undo",
				'ActionName', T(704182154993, --[[XTemplate ModEditor ActionName]] "Undo"),
				'ActionIcon', "CommonAssets/UI/Ged/undo.tga",
				'ActionToolbar', "main",
				'ActionShortcut', "Ctrl-Z",
				'OnAction', function (self, host, source, ...)
					host:Undo()
				end,
			}),
			PlaceObj('XTemplateAction', {
				'ActionId', "Redo",
				'ActionName', T(825249904824, --[[XTemplate ModEditor ActionName]] "Redo"),
				'ActionIcon', "CommonAssets/UI/Ged/redo.tga",
				'ActionToolbar', "main",
				'ActionToolbarSplit', true,
				'ActionShortcut', "Ctrl-Y",
				'OnAction', function (self, host, source, ...)
					host:Redo()
				end,
			}),
			}),
		PlaceObj('XTemplateAction', {
			'comment', "in file menu",
			'ActionName', T(649145838532, --[[XTemplate ModEditor ActionName]] "-----"),
			'ActionMenubar', "File",
		}),
		PlaceObj('XTemplateAction', {
			'comment', "in file menu",
			'ActionId', "BugReport",
			'ActionName', T(972701350134, --[[XTemplate ModEditor ActionName]] "Report a bug"),
			'ActionIcon', "CommonAssets/UI/Ged/warning_button.png",
			'ActionMenubar', "File",
			'ActionToolbar', "main",
			'ActionShortcut', "Ctrl-F1",
			'OnAction', function (self, host, source, ...)
				CreateRealTimeThread(GedCreateXBugReportDlg)
			end,
			'replace_matching_id', true,
		}),
		PlaceObj('XTemplateAction', {
			'comment', "in file menu",
			'ActionId', "Help",
			'ActionName', T(124350738980, --[[XTemplate ModEditor ActionName]] "Help"),
			'ActionIcon', "CommonAssets/UI/Ged/help.tga",
			'ActionMenubar', "File",
			'ActionToolbar', "main",
			'ActionShortcut', "Ctrl-H",
			'OnAction', function (self, host, source, ...)
				host:Op("GedOpModItemHelp", "root", host.idItems:GetSelection())
			end,
		}),
		PlaceObj('XTemplateAction', {
			'comment', "in file menu",
			'ActionName', T(650063819060, --[[XTemplate ModEditor ActionName]] "-----"),
			'ActionMenubar', "File",
		}),
		PlaceObj('XTemplateAction', {
			'comment', "in file menu",
			'ActionId', "Exit",
			'ActionName', T(874097506037, --[[XTemplate ModEditor ActionName]] "Exit"),
			'ActionMenubar', "File",
			'OnAction', function (self, host, source, ...)
				host:Exit()
			end,
		}),
		PlaceObj('XTemplateAction', {
			'ActionId', "Cheats",
			'ActionName', T(501723542931, --[[XTemplate ModEditor ActionName]] "Cheats"),
			'ActionMenubar', "main",
			'OnActionEffect', "popup",
		}, {
			PlaceObj('XTemplateTemplate', {
				'__template', "ModEditorCheats",
			}),
			}),
		PlaceObj('XTemplateAction', {
			'ActionId', "NewItem",
			'ActionName', T(727038768556, --[[XTemplate ModEditor ActionName]] "New"),
			'ActionMenubar', "main",
			'OnActionEffect', "popup",
			'ActionContexts', {
				"ItemModPanelAction",
			},
		}, {
			PlaceObj('XTemplateCode', {
				'run', function (self, parent, context)
					local submenus = { }
					local standalone_entries = {}
					for i, item in ipairs(context.mod_items) do
						local submenu = item.EditorSubmenu
						if not submenu or submenu == "" then
							table.insert(standalone_entries, item)
							goto continue
						end
						if not submenus[submenu] then
							local items = { item }
							submenus[submenu] = items
							table.insert(submenus, submenu)
						else
							table.insert(submenus[submenu], item)
						end
						::continue::
					end
					table.sort(submenus)
					table.sort(standalone_entries, function (a, b) return a.Class:lower() < b.Class:lower() end)
					table.remove_entry(submenus, "Other")
					table.insert(submenus, "Other")
					for i, item in ipairs(standalone_entries) do
						local action = {
							ActionId = "new" .. item.Class,
							ActionName = Untranslated(item.EditorName or item.Class),
							ActionIcon = item.EditorIcon,
							ActionShortcut = item.EditorShortcut,
							ActionMenubar = "NewItem",
							OnAction = function(self, host, source)
								host:Op("GedOpNewModItem", "root", host.idItems:GetSelection(), item.Class)
							end,
						}
						XAction:new(action, parent, context, true)
					end
					for i, submenu in ipairs(submenus) do
						local items = submenus[submenu]
						local submenu_id = "new" .. submenu .. "Menu"
						local submenu_action = {
							ActionId = submenu_id,
							ActionName = Untranslated(submenu) .. "...",
							OnActionEffect = "popup",
							ActionMenubar = "NewItem",
						}
						XAction:new(submenu_action, parent, context, true)
						
						for i, item in ipairs(items) do
							local action = {
								ActionId = "new" .. item.Class,
								ActionName = Untranslated(item.EditorName or item.Class),
								ActionIcon = item.EditorIcon,
								ActionShortcut = item.EditorShortcut,
								ActionMenubar = submenu_id,
								OnAction = function(self, host, source)
									host:Op("GedOpNewModItem", "root", host.idItems:GetSelection(), item.Class)
								end,
							}
							XAction:new(action, parent, context, true)
						end
					end
				end,
			}),
			}),
		PlaceObj('XTemplateWindow', nil, {
			PlaceObj('XTemplateWindow', {
				'__context', function (parent, context) return "root" end,
				'__class', "GedTreePanel",
				'Id', "idItems",
				'Title', "Mod Items",
				'ActionContext', "ItemModPanelAction",
				'Format', "<EditorView>",
				'SelectionBind', "SelectedItem, SelectedObject",
				'OnSelectionChanged', function (self, selection)  end,
				'OnCtrlClick', function (self, selection)  end,
				'OnAltClick', function (self, selection)
					local gedApp = GetDialog(self)
					if not gedApp.mod_folder_supported then return end
					gedApp:Op("GedOpRelocateModItemToFolder", "root", selection, self:GetSelection())
				end,
				'OnDoubleClick', function (self, selection)  end,
				'DragAndDrop', true,
				'ChildActionContext', "ItemModPanelAction",
			}, {
				PlaceObj('XTemplateWindow', {
					'__condition', function (parent, context) return true end,
					'Id', "idBottomButtons",
					'ZOrder', 2,
					'Margins', box(7, 7, 7, 7),
					'HAlign', "right",
					'VAlign', "bottom",
					'LayoutMethod', "HList",
					'LayoutHSpacing', 7,
				}, {
					PlaceObj('XTemplateWindow', {
						'__class', "XButton",
						'RolloverTemplate', "GedToolbarRollover",
						'RolloverAnchor', "top",
						'RolloverText', T(149723581950, --[[XTemplate ModEditor RolloverText]] "Create new Mod Item"),
						'Id', "idNewModItem",
						'ZOrder', 2,
						'HAlign', "right",
						'VAlign', "center",
						'MinWidth', 45,
						'MinHeight', 45,
						'Background', RGBA(255, 255, 255, 0),
						'FocusedBackground', RGBA(255, 255, 255, 0),
						'RolloverBackground', RGBA(255, 255, 255, 0),
						'PressedBackground', RGBA(255, 255, 255, 0),
					}, {
						PlaceObj('XTemplateFunc', {
							'name', "OnSetRollover(self, rollover)",
							'func', function (self, rollover)
								XButton.OnSetRollover(self, rollover)
								if rollover then
									self[1]:SetBackground(RGB(128, 128, 128))
								else
									self[1]:SetBackground(RGB(105, 105, 105))
								end
							end,
						}),
						PlaceObj('XTemplateFunc', {
							'name', "OnPress(self)",
							'func', function (self)
								local items = {}
								local mod_items = GetDialog(self).mod_items
								for _, entry in ipairs(mod_items) do
									table.insert(items, {
										category = entry.EditorSubmenu or "",
										text = entry.EditorName,
										value = entry.Class,
										documentation = entry.Documentation,
									})
								end
								
								CreateRealTimeThread(function()
									GedOpenCreateItemPopup(g_GedApp.idItems, "New Mod Item", items, self, function(class)
										if self.window_state == "destroying" then return end
										g_GedApp:Op("GedOpNewModItem", "root", g_GedApp.idItems:GetSelection(), class)
									end)
								end)
							end,
						}),
						PlaceObj('XTemplateWindow', {
							'__class', "XFrame",
							'Background', RGBA(105, 105, 105, 255),
							'Image', "CommonAssets/UI/round-frame-20",
							'FrameBox', box(9, 9, 9, 9),
						}),
						PlaceObj('XTemplateWindow', {
							'__class', "XImage",
							'Image', "CommonAssets/UI/Ged/Plus",
						}),
						}),
					PlaceObj('XTemplateWindow', {
						'__condition', function (parent, context) return GetDialog(parent).mod_folder_supported end,
						'__class', "XButton",
						'RolloverTemplate', "GedToolbarRollover",
						'RolloverAnchor', "top",
						'RolloverText', T(976724333601, --[[XTemplate ModEditor RolloverText]] "Add selected items to New Folder"),
						'Id', "idNewModFolder",
						'ZOrder', 2,
						'HAlign', "right",
						'VAlign', "center",
						'MinWidth', 45,
						'MinHeight', 45,
						'Background', RGBA(255, 255, 255, 0),
						'FocusedBackground', RGBA(255, 255, 255, 0),
						'RolloverBackground', RGBA(255, 255, 255, 0),
						'PressedBackground', RGBA(255, 255, 255, 0),
					}, {
						PlaceObj('XTemplateFunc', {
							'name', "OnSetRollover(self, rollover)",
							'func', function (self, rollover)
								XButton.OnSetRollover(self, rollover)
								if rollover then
									self[1]:SetBackground(RGB(128, 128, 128))
								else
									self[1]:SetBackground(RGB(105, 105, 105))
								end
							end,
						}),
						PlaceObj('XTemplateFunc', {
							'name', "OnPress(self)",
							'func', function (self)
								CreateRealTimeThread(function()
									local panel = g_GedApp.idItems
									g_GedApp:Op("GedOpAddModItemsToFolder", panel.context, panel:GetMultiSelection())
								end)
							end,
						}),
						PlaceObj('XTemplateWindow', {
							'__class', "XFrame",
							'Background', RGBA(105, 105, 105, 255),
							'Image', "CommonAssets/UI/round-frame-20",
							'FrameBox', box(9, 9, 9, 9),
						}),
						PlaceObj('XTemplateWindow', {
							'__class', "XImage",
							'Image', "CommonAssets/UI/Ged/NewFolder",
						}),
						}),
					}),
				PlaceObj('XTemplateTemplate', {
					'__template', "GedStatusBar",
					'Background', RGBA(255, 0, 0, 255),
					'FormatFunc', "GedModStatusText",
				}),
				}),
			}),
		PlaceObj('XTemplateWindow', {
			'__context', function (parent, context) return "SelectedItem" end,
			'__class', "GedBindView",
			'BindView', "SubItems",
			'BindRoot', "root",
			'BindFunc', "GedDynamicItemsMenu",
			'ControlId', "idItems",
			'GetBindParams', function (self, control) return "ModItem", control:GetSelection() end,
			'OnViewChanged', function (self, value, control)
				RebuildSubItemsActions(control, value, "New Element", "main", "main")
			end,
		}),
		PlaceObj('XTemplateWindow', {
			'__class', "XPanelSizer",
		}),
		PlaceObj('XTemplateWindow', {
			'__context', function (parent, context) return "SelectedObject" end,
			'__class', "GedPropPanel",
			'Id', "idItemProperties",
			'MinWidth', 300,
			'Title', "Item Properties",
			'HideFirstCategory', true,
			'RootObjectBindName', "SelectedItem",
		}, {
			PlaceObj('XTemplateWindow', {
				'__context', function (parent, context) return "SelectedItem" end,
				'__class', "GedBindView",
				'BindView', "PresetEditor",
				'BindRoot', "SelectedItem",
				'BindFunc', "GedGetModItemDockedActions",
				'ControlId', "idPanelDockedButtons",
				'OnViewChanged', function (self, value, control)
					if not control then return end
					local visible = not not next(value)
					control:SetVisible(visible)
					local list = self:ResolveId("idList")
					list:SetContext(value, true)
				end,
			}),
			PlaceObj('XTemplateWindow', {
				'Id', "idPanelDockedButtons",
				'ZOrder', 2,
				'Margins', box(0, 3, 0, 0),
				'Dock', "bottom",
				'FoldWhenHidden', true,
			}, {
				PlaceObj('XTemplateWindow', {
					'__context', function (parent, context)
						return context
					end,
					'__class', "XContentTemplate",
					'Id', "idList",
					'ZOrder', 2,
					'Padding', box(15, 15, 15, 15),
					'HAlign', "center",
					'VAlign', "center",
					'LayoutMethod', "HWrap",
					'LayoutHSpacing', 15,
					'LayoutVSpacing', 15,
					'FoldWhenHidden', true,
					'OnContextUpdate', function (self, context, ...)
						if self.RespawnOnContext then
							if self.window_state == "open" then
								self:RespawnContent()
							end
						else
							local respawn_value = self:RespawnExpression(context)
							if rawget(self, "respawn_value") ~= respawn_value then
								self.respawn_value = respawn_value
								if self.window_state == "open" then
									self:RespawnContent()
								end
							end
						end
					end,
				}, {
					PlaceObj('XTemplateForEach', {
						'array', function (parent, context)
							if type(context) ~= "table" then return context end
							local result = {}
							for id, data in pairs(context) do
								table.insert(result, { 
									id = id, name = data.name, 
									rolloverText = data.rolloverText, 
									op = data.op 
								})
							end
							return result
						end,
						'map', function (parent, context, array, i)
							return array and array[i]
						end,
						'__context', function (parent, context, item, i, n)
							return context
						end,
						'run_before', function (parent, context, item, i, n, last)
							
						end,
						'run_after', function (child, context, item, i, n, last)
							child:SetText(item.name)
							child:SetRolloverText(item.rolloverText)
							child:SetOnPress(function(child)
								local app = GetParentOfKind(child, "GedApp")
								local panel = app:ResolveId("idItems")
								if panel then
									app:Op(item.op, "SelectedItem")
								end
							end)
						end,
					}, {
						PlaceObj('XTemplateWindow', {
							'__class', "XTextButton",
							'RolloverTemplate', "GedToolbarRollover",
							'RolloverAnchor', "top",
							'Id', "idOpenInPresetEditorButton",
							'BorderWidth', 2,
							'Padding', box(2, 2, 2, 2),
							'HAlign', "center",
						}),
						}),
					}),
				}),
			}),
		}),
})