Skip to content
This repository was archived by the owner on May 11, 2025. It is now read-only.

Commit 012af2f

Browse files
committed
close to release, various fixes and changes
1 parent 100caff commit 012af2f

File tree

4 files changed

+64
-41
lines changed

4 files changed

+64
-41
lines changed

index.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ <h3>What would you like to do?</h3>
4242
<div class="top">
4343
<button id="back_button_existing_addon" class="back_button" data-backwards="#addon_management_prompt" data-forwards="#update_existing_addon" data-resize="500, 175">◀ Back</button>
4444
<h3>Your addons</h3>
45-
<p id="refresh_addons"><a href="#">Refresh</a></p>
4645
</div>
4746
<div id="yourAddons"></div>
4847
</div>
@@ -161,7 +160,7 @@ <h3>Addon creation</h3>
161160
<div id="gmaPrep">
162161
<!-- <p>Created <span style="font-weight: 700">addon.json</span>!</p> -->
163162
<h3>Create GMA for uploading to the Workshop?</h3>
164-
<button style="width: 100px;" class="button_normal transition_button" id="resetAddonCreation" data-divtohide="#create_new_addon" data-divtoshow="#addon_management_prompt" data-resize="500, 175">No</button>
163+
<button style="width: 100px;" class="button_normal transition_button resetAddonCreation" data-divtohide="#create_new_addon" data-divtoshow="#addon_management_prompt" data-resize="500, 175">No</button>
165164
<button style="width: 100px;" id="createGMAFile" class="button_normal transition_button">Yes</button>
166165
<!-- <img src="src/img/loading.gif" style="display: block; margin-left: auto; margin-right: auto; width: 64px;" alt=""> -->
167166
</div>
@@ -179,9 +178,9 @@ <h3>Upload to the Workshop?</h3>
179178
<img src="src/img/loading.gif" style="width: 64px; display: block; margin-left: auto; margin-right: auto; margin-top: 35px;" alt="">
180179
</div>
181180
<div id="new_addon">
182-
<p>Uploaded!</p>
181+
<h3>Uploaded!</h3>
183182
<p><a id="new_addon_link" style="color: white;" href="#">View on Steam</a></p>
184-
<button class="button_normal" style="width: 100px;">Done</button>
183+
<button class="button_normal transition_button resetAddonCreation" data-divtohide="#create_new_addon" data-divtoshow="#addon_management_prompt" data-resize="500, 175" style="width: 100px;">Done</button>
185184
</div>
186185
</div>
187186
</div>

index.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,29 @@ ipcMain.on('createGMAFile', (event, addonDir) => {
124124
});
125125
});
126126

127-
ipcMain.on('uploadToWorkshop', (event, gmaDir, iconDir) => {
128-
const gmpublish = spawn(settings.get('gmodDirectory') + '\\bin\\gmpublish.exe', ['create', '-icon', iconDir, '-addon', gmaDir]);
129-
gmpublish.stdout.on('data', (data) => {
130-
var arrayOfOutput = data.toString().split('\n')
131-
var fixedArray = arrayOfOutput.slice(arrayOfOutput.length - 8, arrayOfOutput.length - 7)
132-
fixedArray = fixedArray[0].replace(/\D/, '')
133-
fixedArray = fixedArray.substr(5, fixedArray.length)
134-
console.log(fixedArray)
135-
mainWindow.webContents.send('currentAddonID', fixedArray);
136-
})
127+
ipcMain.on('uploadToWorkshop', (event, gmaDir, iconDir, addonId) => {
128+
if (addonId != null) {
129+
const gmpublish = spawn(settings.get('gmodDirectory') + '\\bin\\gmpublish.exe', ['update', '-id', addonId, '-icon', iconDir, '-addon', gmaDir]);
130+
gmpublish.stdout.on('data', (data) => {
131+
var arrayOfOutput = data.toString().split('\n')
132+
var fixedArray = arrayOfOutput.slice(arrayOfOutput.length - 8, arrayOfOutput.length - 7)
133+
fixedArray = fixedArray[0].replace(/\D/, '')
134+
fixedArray = fixedArray.substr(5, fixedArray.length)
135+
console.log(fixedArray)
136+
mainWindow.webContents.send('currentAddonID', fixedArray);
137+
});
138+
} else {
139+
const gmpublish = spawn(settings.get('gmodDirectory') + '\\bin\\gmpublish.exe', ['create', '-icon', iconDir, '-addon', gmaDir]);
140+
gmpublish.stdout.on('data', (data) => {
141+
var arrayOfOutput = data.toString().split('\n')
142+
var fixedArray = arrayOfOutput.slice(arrayOfOutput.length - 8, arrayOfOutput.length - 7)
143+
fixedArray = fixedArray[0].replace(/\D/, '')
144+
fixedArray = fixedArray.substr(5, fixedArray.length)
145+
console.log(fixedArray)
146+
mainWindow.webContents.send('currentAddonID', fixedArray);
147+
});
148+
};
149+
137150
})
138151

139152

src/css/style.css

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ header {
191191

192192
#update_existing_addon .top {
193193
background-color: #0f0f0f;
194-
padding: 5px 10px;
195194
display: flex;
196195
align-items: center;
197196
}
@@ -257,15 +256,19 @@ header {
257256
padding: 15px 0;
258257
}
259258

260-
.addon_existing p {
261-
margin: 0
259+
.addon_existing .title {
260+
margin: 0;
261+
cursor: default;
262262
}
263263

264264
.addon_link {
265265
display: none;
266+
margin-top: 5px;
267+
margin-bottom: 0;
266268
}
267269

268270
.addon_link a {
271+
padding: 3px;
269272
color: white;
270273
}
271274

src/js/script.js

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jsonCheckboxCount = 0;
1919
jsonChecks = [false, false];
2020
apiError = 0;
2121
addonGMADir = "";
22+
existingAddonId = null;
2223
var addonTitle;
2324
var addonTags;
2425
var addonType;
@@ -75,7 +76,6 @@ $(document).ready(() => {
7576
}
7677
}
7778
// console.log(data.response);
78-
var addon = data.response.publishedfiledetails["0"];
7979
okToProcessAddonList = true;
8080
$('#update_existing_addon_button').text('Update existing addon');
8181
});
@@ -182,6 +182,7 @@ $(document).ready(() => {
182182
$('#create_new_addon_button').click(() => {
183183
$('#addon_management_prompt').fadeOut(() => {
184184
win.setBounds({height: 250})
185+
185186
$('#create_new_addon, #addonDirPrompt').fadeIn()
186187
})
187188
})
@@ -190,6 +191,7 @@ $(document).ready(() => {
190191
var target = event.target;
191192
var divToGoBack = $(target).data('forwards');
192193
var divToShow = $(target).data('backwards');
194+
resetAddonCreation()
193195
if ($(target).data('resize') != null) {
194196
var resizeInfo = JSON.parse("[" + $(target).data('resize') + "]");
195197
}
@@ -209,7 +211,7 @@ $(document).ready(() => {
209211
})
210212

211213
$('.removeBackOption').click(() => {
212-
$('#back_button_addon_creation').fadeOut();
214+
// $('#back_button_addon_creation').fadeOut();
213215
})
214216

215217
// General function for transitioning between div tags (with a shitty name)
@@ -225,24 +227,13 @@ $(document).ready(() => {
225227
})
226228
}
227229

228-
// Check if user needs to refresh their addons
229-
// TODO: Hopefully I can remove this later on as it really isn't needed (except in the case of Steam being down)
230-
$('#refresh_addons').click(() => {
231-
console.log("Attempting to refresh addons...");
232-
$('#yourAddons').children().remove();
233-
getAddonInfoFromSteam();
234-
populateAddonList();
235-
236-
});
237-
238-
// Get array of addon infomation and append their names to #yourAddons
230+
// Get array of addon infomation and append their info to #yourAddons
239231
function populateAddonList() {
240232
// This check is done to make sure this only gets executed once
241233
if (!donePopulatingAddonList) {
242234
for (let i = 0; i < addon_data.length; i++) {
243-
$('#yourAddons').append("<div class='addon_existing'><p>" + addon_data[i].title + "</p><p class='addon_link'><a href='steam://url/CommunityFilePage/" + addon_data[i].id + "'>View</a> <a href='#'>Update</a></p></div>");
235+
$('#yourAddons').append("<div class='addon_existing'><p class='title'>" + addon_data[i].title + "</p><p class='addon_link'><a href='steam://url/CommunityFilePage/" + addon_data[i].id + "'>View</a> <a href='#' class='updateAddon' data-id='" + addon_data[i].id + "'>Update</a></p></div>");
244236
donePopulatingAddonList = true;
245-
246237
}
247238
// Make sure if nothing is returned to let the user know
248239
// TODO: Allow for multiple error codes such as 429 (too many requests)
@@ -342,7 +333,7 @@ $(document).ready(() => {
342333
}
343334
}
344335

345-
$("#resetAddonCreation").click(() => {
336+
$(".resetAddonCreation").click(() => {
346337
resetAddonCreation();
347338
});
348339

@@ -366,40 +357,57 @@ $(document).ready(() => {
366357
// Clear the addon name on directory selection
367358
$("#addonDir b").text('');
368359

369-
// Set the input to null
360+
// Set the file inputs to null
370361
$("#addon_dir_folder").val(null);
362+
$("#addon_icon").val(null);
371363

372364
// Reset directory validation
373365
$('#addonDirCheck').css({backgroundColor: "#0f0f0f", cursor: "not-allowed"});
374366
$('#addonDirCheck').prop('disabled', true);
375367

368+
// Reset icon validation
369+
$('#addonIconCheck').css({backgroundColor: "#0f0f0f", cursor: "not-allowed"});
370+
$('#addonIconCheck').prop('disabled', true);
371+
376372
// Reset validation checks
377373
jsonChecks = [false, false];
378374
validateJsonForm();
379375

376+
// Reset existingAddonId if user was updating instead of creating
377+
existingAddonId = null;
378+
380379
// Hide any div that may still be displayed
381-
$('#addonjsonPrompt, #jsonCreator, #gmaPrep, #createGMA').css('display', 'none');
380+
$('#addonjsonPrompt, #addonIconPrompt, #jsonCreator, #gmaPrep, #createGMA, #new_addon, #uploading, #uploadToWorkshopPrompt').css('display', 'none');
382381
}
383382

383+
$("#yourAddons").on('click', '.updateAddon', (event) => {
384+
var target = event.target;
385+
existingAddonId = $(target).data('id');
386+
$("#update_existing_addon").fadeOut(() => {
387+
$("#create_new_addon .top h3").text('Updating addon');
388+
$("#create_new_addon, #addonDirPrompt").fadeIn();
389+
});
390+
});
391+
384392
$("#createGMAFile").click(() => {
385393
$('#gmaPrep').fadeOut(() => {
386-
win.setBounds({height: 225})
394+
win.setBounds({height: 250});
387395
$('#createGMA').fadeIn();
388-
ipcRenderer.send('createGMAFile', currentNewAddon);
396+
ipcRenderer.send('createGMAFile', currentNewAddon);
389397
});
390-
})
398+
});
391399

392400
$("#uploadCurrentGMA").click(() => {
393-
ipcRenderer.send('uploadToWorkshop', addonGMADir, addonIcon);
401+
ipcRenderer.send('uploadToWorkshop', addonGMADir, addonIcon, existingAddonId);
394402
$('#uploadToWorkshopPrompt').fadeOut(() => {
395-
win.setBounds({height: 225})
403+
win.setBounds({height: 250})
396404
$('#uploading').fadeIn();
397405
})
398406
})
399407

400408
ipcRenderer.on('currentAddonID', (event, newAddonID) => {
401409
$('#uploading').fadeOut(() => {
402-
win.setBounds({height: 200})
410+
win.setBounds({height: 225})
403411
$('#new_addon_link').attr('href', 'steam://url/CommunityFilePage/' + newAddonID)
404412
$('#new_addon').fadeIn()
405413
});

0 commit comments

Comments
 (0)