File size: 7,903 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
-- ========== GENERATED BY XTemplate Editor (Alt-F3) DO NOT EDIT MANUALLY! ==========

PlaceObj('XTemplate', {
	__is_kind_of = "XListItem",
	group = "ModManager",
	id = "ModManagerBrowseListItem",
	save_in = "Common",
	PlaceObj('XTemplateWindow', {
		'__class', "XListItem",
		'Padding', box(3, 3, 3, 3),
		'HAlign', "left",
		'VAlign', "center",
		'BorderColor', RGBA(0, 0, 0, 255),
		'Background', RGBA(255, 255, 255, 255),
		'RolloverOnFocus', true,
		'HandleMouse', true,
		'OnContextUpdate', function (self, context, ...)
			XListItem.OnContextUpdate(self, context, ...)
			self.idModTitle:SetText(context.DisplayName or "")
			self.idAuthor:SetText(context.Author or "")
			local mod_id = context.BackendID
			local uninstalling = g_UninstallingMods[mod_id]
			self.idListSpinner:SetVisible(not context.InfoRetrieved or g_DownloadingMods[mod_id] or uninstalling)
			local obj = GetDialog(self).context
			if context.InfoRetrieved then
				if context.Thumbnail then
					self.idImage:SetImage(context.Thumbnail)
				end
				if obj.installed_retrieved then
					local enabled = obj.enabled[mod_id]
					local installed = obj.installed[mod_id] and not g_DownloadingMods[mod_id]
					if installed then
						local corrupted, warning, warning_id = context.Corrupted, context.Warning, context.Warning_id
						if corrupted == nil then
							local mod_def = obj.mod_defs[mod_id]
							if mod_def then
								corrupted, warning, warning_id = ModsUIGetModCorruptedStatus(mod_def)
								context.Corrupted, context.Warning, context.Warning_id = corrupted, warning, warning_id
							end
						end
						self.idWarning:SetText(warning or "")
						self.idWarning:SetVisible((warning or "") ~= "")
						if not corrupted then
							self.idEnabled:SetCheck(enabled)
							self.idEnabled:SetVisible(not uninstalling)
							self.idEnabled.idEnabled:SetVisible(enabled)
							self.idEnabled.idDisabled:SetVisible(not enabled)
						end
					end
					if rawget(self, "idInstall") then
						self.idInstall:SetVisible(not installed and not g_DownloadingMods[mod_id])
						self.idRemove:SetVisible(installed and not uninstalling)
					end
				end
				if self.selected and self:IsFocused() and obj.selected_mod_id ~= mod_id then
					self:SetSelected(true)
				end
				local current_rating_win = self:ResolveId("idCurrentRating")
				if context.Rating and current_rating_win then
					for i = 1, context.Rating do
						current_rating_win[i]:SetImage("UI/Mods/rate-orange.tga")
					end
					current_rating_win:SetVisible(true)
					local ratings_total = self:ResolveId("idRatingsTotal")
					ratings_total:SetText("(" .. context.RatingsCount .. ")")
					ratings_total:SetVisible(true)
				end
				local size = self:ResolveId("idFileSize")
				if size then
					local context = self.context
					size:SetVisible(context.FileSize)
					if context.FileSize then
						size:SetText(T(10487, "<FormatSize(FileSize, 2)>"))
					end
				end
			elseif obj.counted then
				ModsUILoadModInfo(context.ModPosition)
			end
		end,
	}, {
		PlaceObj('XTemplateFunc', {
			'name', "SetSelected(self, selected)",
			'func', function (self, selected)
				XListItem.SetSelected(self, selected)
				if selected then
					local changed = ModsUISetSelectedMod(self.context.ModID)
					if changed and GetUIStyleGamepad() then
						local dlg = GetDialog(self)
						dlg:UpdateActionViews(dlg)
					end
					if not self:IsFocused() then
						self:SetFocus()
					end
				end
			end,
		}),
		PlaceObj('XTemplateFunc', {
			'name', "OnMouseButtonDown(self, pos, button)",
			'func', function (self, pos, button)
				if button == "L" then
					ModsUISetDialogMode(GetDialog(self), "details", self.context)
					return "break"
				end
			end,
		}),
		PlaceObj('XTemplateWindow', nil, {
			PlaceObj('XTemplateWindow', {
				'comment', "mod image",
				'__class', "XImage",
				'Id', "idImage",
				'Dock', "box",
				'ImageFit', "largest",
			}),
			PlaceObj('XTemplateWindow', {
				'Id', "idListSpinner",
				'Dock', "box",
				'FoldWhenHidden', true,
			}, {
				PlaceObj('XTemplateTemplate', {
					'__template', "ModManagerLoadingAnim",
					'Dock', "box",
					'HAlign', "center",
					'VAlign', "center",
				}),
				}),
			PlaceObj('XTemplateWindow', {
				'VAlign', "top",
				'MinHeight', 47,
				'LayoutMethod', "HList",
				'LayoutHSpacing', 5,
			}, {
				PlaceObj('XTemplateWindow', {
					'__class', "XText",
					'Id', "idWarning",
					'VAlign', "center",
					'Visible', false,
					'FoldWhenHidden', true,
					'HandleMouse', false,
					'Translate', true,
				}),
				PlaceObj('XTemplateWindow', {
					'__class', "XTextButton",
					'Id', "idInstall",
					'Dock', "right",
					'HAlign', "center",
					'VAlign', "center",
					'Visible', false,
					'FoldWhenHidden', true,
					'OnPress', function (self, gamepad)
						if not g_ModsBackendObj:IsLoggedIn() then
							local host = GetDialog(self)
							ModsUIOpenLoginPopup(host.idContentWrapper)
						else
							ModsUIInstallMod(self.context)
							self:SetVisible(false)
							self:ResolveId("idDarkOverlay"):SetVisible(true)
						end
					end,
				}),
				PlaceObj('XTemplateWindow', {
					'__class', "XCheckButton",
					'Id', "idEnabled",
					'Dock', "left",
					'VAlign', "center",
					'Visible', false,
					'FoldWhenHidden', true,
					'OnPress', function (self, gamepad)
						ModsUIToggleEnabled(self.context, self)
					end,
					'Check', true,
				}, {
					PlaceObj('XTemplateFunc', {
						'name', "OnChange(self, check)",
						'func', function (self, check)
							self.idEnabled:SetVisible(check)
							self.idDisabled:SetVisible(not check)
						end,
					}),
					PlaceObj('XTemplateWindow', {
						'__class', "XLabel",
						'Id', "idEnabled",
						'HAlign', "center",
						'VAlign', "center",
						'Visible', false,
						'FoldWhenHidden', true,
						'Translate', true,
						'Text', T(390494073411, --[[XTemplate ModManagerBrowseListItem Text]] "Enabled"),
					}),
					PlaceObj('XTemplateWindow', {
						'__class', "XLabel",
						'Id', "idDisabled",
						'HAlign', "center",
						'VAlign', "center",
						'Visible', false,
						'FoldWhenHidden', true,
						'Translate', true,
						'Text', T(362027600090, --[[XTemplate ModManagerBrowseListItem Text]] "Disabled"),
					}),
					}),
				PlaceObj('XTemplateWindow', {
					'__class', "XTextButton",
					'Id', "idRemove",
					'Dock', "right",
					'HAlign', "center",
					'VAlign', "center",
					'Visible', false,
					'FoldWhenHidden', true,
					'OnPress', function (self, gamepad)
						ModsUIUninstallMod(self.context)
					end,
				}),
				}),
			PlaceObj('XTemplateWindow', {
				'Margins', box(20, 0, 0, 20),
				'VAlign', "bottom",
				'LayoutMethod', "VList",
			}, {
				PlaceObj('XTemplateWindow', {
					'__class', "XText",
					'Id', "idModTitle",
					'VAlign', "bottom",
					'HandleMouse', false,
					'TextStyle', "GedTitle",
				}),
				PlaceObj('XTemplateWindow', {
					'__class', "XLabel",
					'Id', "idAuthor",
					'VAlign', "bottom",
				}),
				PlaceObj('XTemplateWindow', {
					'comment', "current rating",
					'VAlign', "bottom",
					'LayoutMethod', "HList",
					'LayoutHSpacing', 10,
				}, {
					PlaceObj('XTemplateWindow', {
						'Id', "idCurrentRating",
						'VAlign', "center",
						'LayoutMethod', "HList",
						'LayoutHSpacing', 4,
						'Visible', false,
						'FoldWhenHidden', true,
					}, {
						PlaceObj('XTemplateForEach', {
							'array', function (parent, context) return nil, 1, 5 end,
						}, {
							PlaceObj('XTemplateWindow', {
								'__class', "XImage",
								'Image', "CommonAssets/UI/Icons/outline star",
								'ImageScale', point(230, 230),
							}),
							}),
						}),
					PlaceObj('XTemplateWindow', {
						'__class', "XLabel",
						'Id', "idRatingsTotal",
						'VAlign', "center",
						'Visible', false,
						'FoldWhenHidden', true,
					}),
					}),
				}),
			}),
		}),
})