-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmodulesPropertiesPage.tscript
More file actions
289 lines (230 loc) · 10.8 KB
/
modulesPropertiesPage.tscript
File metadata and controls
289 lines (230 loc) · 10.8 KB
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
function CreateNewModule(%source)
{
$CurrentModule = new ScriptObject();
$CurrentModule.isLocalOrGit = %source;
$creatingNew = true;
MainMenuGui.goToPage("NewModulePage");
}
function populateModuleProperties()
{
if($creatingNew)
updateBreadcrumbList("ModulesPage;NewModulePage");
else
updateBreadcrumbList("ModulesPage;ModulePropertiesPage");
MainMenuGui.setActionBarVisible(!$creatingNew);
MainMenuSearchBar.hidden = true;
MainMenuSearchClearBtn.hidden = true;
MainViewStack.hidden = false;
MainViewStack.clear();
if($creatingNew)
{
if($CurrentModule.isLocalOrGit $= "Git Repository")
{
$CurrentModule.localPath = "";
$CurrentModule.dependencies = "";
}
else if($CurrentModule.isLocalOrGit $= "Local Path")
{
$CurrentModule.gitPath = "";
$CurrentModule.branchName = "";
}
if($CurrentModule.isLocalOrGit $= "Git Repository")
{
MainViewStack.add(createEditCard("Git URL Path", "TextEdit", "$CurrentModule.gitPath", "What URL for the git repo this module is from", ""));
MainViewStack.add(createEditCard("Git Branch", "TextEdit", "$CurrentModule.branchName", "What branch name for the git repo this module is from. Leave blank to use the repository default", ""));
MainViewStack.add(createEditCard("Module Name", "TextEdit", "$CurrentModule.moduleName", "The name of this engine build", ""));
MainViewStack.add(createEditCard("Description", "TextEdit", "$CurrentModule.description", "A description of what the module does", ""));
}
else if($CurrentModule.isLocalOrGit $= "Local Path")
{
MainViewStack.add(createEditCard("Local Directory Path", "ModuleFile", "$CurrentModule.localPath", "What local directory path this module is from on the current machine", ""));
$CurrentModule.localPath = makeFullPath($CurrentModule.localPath);
if(fileExt($CurrentModule.localPath) $= ".module")
{
%moduleDefFile = loadFileText($CurrentModule.localPath);
%moduleIdPos = strpos(%moduleDefFile, "ModuleId=\"", 0);
if(%moduleIdPos != -1)
{
%moduleIdPos += 10;
%moduleIdEndPos = strpos(%moduleDefFile, "\"", %moduleIdPos);
$CurrentModule.moduleName = getSubStr(%moduleDefFile, %moduleIdPos, %moduleIdEndPos - %moduleIdPos);
}
%descPos = strpos(%moduleDefFile, "Description=\"", 0);
if(%descPos != -1)
{
%descPos += 13;
%descEndPos = strpos(%moduleDefFile, "\"", %descPos);
$CurrentModule.description = getSubStr(%moduleDefFile, %descPos, %descEndPos - %descPos);
}
%dependenciesPos = strpos(%moduleDefFile, "Dependencies=\"", 0);
if(%dependenciesPos != -1)
{
%dependenciesPos += 14;
%dependenciesEndPos = strpos(%moduleDefFile, "\"", %dependenciesPos);
$CurrentModule.dependencies = getSubStr(%moduleDefFile, %dependenciesPos, %dependenciesEndPos - %dependenciesPos);
}
}
%moduleNameField = createEditCard("Module Name", "TextEdit", "$CurrentModule.moduleName", "The name of this engine build", "");
%moduleNameField.callonChildren("setActive", false);
MainViewStack.add(%moduleNameField);
%moduleDescriptionField = createEditCard("Description", "TextEdit", "$CurrentModule.description", "A description of what the module does", "");
%moduleDescriptionField.callonChildren("setActive", false);
MainViewStack.add(%moduleDescriptionField);
}
}
else
{
%moduleNameField = createEditCard("Module Name", "TextEdit", "$CurrentModule.moduleName", "The name of this engine build", "");
MainViewStack.add(%moduleNameField);
%moduleDescriptionField = createEditCard("Description", "TextEdit", "$CurrentModule.description", "A description of what the module does", "");
MainViewStack.add(%moduleDescriptionField);
%gitPathField = createEditCard("Git URL Path", "TextEdit", "$CurrentModule.gitPath", "What URL for the git repo this module is from", "");
%gitPathField.callonChildren("setActive", false);
MainViewStack.add(%gitPathField);
%gitBranchField = createEditCard("Git Branch", "TextEdit", "$CurrentModule.branchName", "What branch name for the git repo this module is from. Leave blank to use the repository default", "");
%gitBranchField.callonChildren("setActive", false);
MainViewStack.add(%gitBranchField);
MainViewStack.add(createEditCard("Local Directory Path", "Folder", "$CurrentModule.localPath", "What local directory path this module is from on the current machine", ""));
if(isModuleDownloaded($CurrentModule))
{
%moduleNameField.callonChildren("setActive", false);
%moduleDescriptionField.callonChildren("setActive", false);
}
}
if($CurrentModule.isDefault)
{
for(%i=0; %i < MainViewStack.getCount(); %i++)
{
%child = MainViewStack.getObject(%i);
//we'll skip local directory path stuff as we need to be able to change the local install
//even on default builds
if(%child-->label.text !$= "Local Directory Path")
{
%child.callOnChildren("setActive", false);
}
}
}
if($CurrentModule.dependencies !$= "")
{
%depRoll = new GuiRolloutCtrl() {
caption = "Dependencies";
extent = MainViewStack.extent.x SPC 40;
profile = GuiMenuRolloutProfile;
margin = "5 5 5 5";
new GuiStackControl() {
internalName = "stack";
padding = "5";
};
};
MainViewStack.add(%depRoll);
buildModuleDependencyCard(%depRoll, $CurrentModule);
}
if($creatingNew)
{
MainPanelFooter.setupButtons("Create", "Cancel", "saveNewModule();", "MainMenuGUI.goToPage(\"ModulesPage\");");
%valid = true;
if($CurrentModule.moduleName $= "")
{
%valid = false;
MainPanelFooter.setText("Must define Module name");
}
if($CurrentModule.isLocalOrGit $= "")
{
%valid = false;
MainPanelFooter.setText("Must define if sourced from Git or Local directory");
}
if($CurrentModule.isLocalOrGit $= "Git Repository" && $CurrentModule.gitPath $= "")
{
%valid = false;
MainPanelFooter.setText("If Git Repository build, Git Path required");
}
if($CurrentModule.isLocalOrGit $= "Local Path" && !isModuleDownloaded($CurrentModule))
{
%valid = false;
MainPanelFooter.setText("Local path provided does not contain valid Module definition");
}
MainPanelFooter.setOKButtonActive(%valid);
}
else
{
MainPanelFooter.setupButtons("", "Save", "", "saveModule($CurrentModule);");
}
//
//Now add our action panel buttons
ActionButtonPanelList.clear();
if(!$creatingNew)
{
if(isModuleDownloaded($CurrentModule))
{
AddActionButton("ManagerUI:card_add_image", "Install in Project", "openInstallModuleWizard(\"\", " @ $CurrentModule @ ");", "");
if($CurrentModule.gitPath !$= "" && !$TorqueManager::gitNotFound)
AddActionButton("ManagerUI:download_image", "Pull Updates", "pullUpdateModule($CurrentModule);", "");
AddActionButton("ManagerUI:cards_seek_top_image", "View Files", "openFileLocation($CurrentModule.localPath);", "");
AddActionButton("ManagerUI:trashcan_image", "Delete Local Copy", "deleteModule($CurrentModule);", "");
}
else if(!$TorqueManager::gitNotFound)
AddActionButton("ManagerUI:download_image", "Download", "downloadModule($CurrentModule);", "");
if(!$CurrentModule.isDefault)
AddActionButton("ManagerUI:trashcan_image", "Remove From List", "removeModuleFromListing($CurrentModule);", "");
if($CurrentModule.gitPath !$= "")
{
AddActionButton("ManagerUI:share1_image", "Visit Repo Page", "openModuleGitPage($CurrentModule);",
"Visit the repository page of this module.");
AddActionButton("ManagerUI:share1_image", "Visit Issues Page", "openModuleIssuesPage($CurrentModule);",
"Visit the issues page of this module.");
}
}
/*if($CurrentEngineBuild.localPath !$= "")
{
AddActionButton("ManagerUI:plus_image", "New Project", "$ResetForm=true;$NewProjectTargetEngineBuild=$CurrentEngineBuild;MainMenuGui.gotoPage(\"NewProjectPage\");", "");
if($CurrentEngineBuild.gitPath !$= "")
AddActionButton("ManagerUI:download_image", "Pull Updates", "pullUpdateEngineBuild($CurrentEngineBuild);", "");
AddActionButton("ManagerUI:trashcan_image", "Delete Local Copy", "", "");
}
else
AddActionButton("ManagerUI:download_image", "Download", "downloadEngineBuild($CurrentEngineBuild);", "");
if(!$CurrentEngineBuild.isDefault)
AddActionButton("ManagerUI:trashcan_image", "Remove From List", "", "");
if($CurrentEngineBuild.gitPath !$= "")
{
AddActionButton("ManagerUI:share1_image", "Visit Repo Page", "openEngineBuildGitPage($CurrentEngineBuild);",
"Visit the repository page of this engine build.");
AddActionButton("ManagerUI:share1_image", "Visit Issues Page", "openEngineBuildIssuesPage($CurrentEngineBuild);",
"Visit the issues page of this engine build.");
}*/
}
function saveCurrentModule()
{
if(!isObject($CurrentModule))
return;
saveModule($CurrentModule);
}
function saveNewModule()
{
if(!isObject($CurrentModule))
return;
incrementModuleCount();
%newModuleId = getModuleCount();
$CurrentModule.moduleId = %newModuleId;
saveModule($CurrentModule);
MainMenuGUI.goToPage("ModulesPage");
}
function buildModuleDependencyCard(%rollout, %module, %depth)
{
if(%depth $= "")
%depth = 0;
%depCount = getTokenCount(%module.dependencies, ",;");
for(%i=0; %i < %depCount; %i++)
{
%depName = getToken(%module.dependencies, ",;", %i);
%depModuleId = findModuleByName(%depName);
if(%depModuleId != 0)
{
%depModule = getModule(%depModuleId);
%subtext = %depModule.localPath !$= "" ? "(Downloaded)" : "(Not Downloaded)";
%depModuleCard = createCard(%depModule.moduleName, %subtext, "", "", false, "", "", "", "", "", "", %depth);
%rollout-->stack.add(%depModuleCard);
buildModuleDependencyCard(%rollout, %depModule, %depth+1);
}
}
}