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

Commit 40c5d55

Browse files
committed
near completion of extracting GMAs, remove junk
1 parent a9002ce commit 40c5d55

File tree

4 files changed

+148
-45
lines changed

4 files changed

+148
-45
lines changed

app.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const {
33
app,
44
BrowserWindow,
55
ipcMain,
6-
dialog
6+
shell
77
} = require('electron')
88
const fs = require('fs')
99
const { spawn } = require('child_process');
@@ -156,4 +156,11 @@ ipcMain.on('uploadToWorkshop', (event, gmaDir, iconDir, addonId) => {
156156
};
157157
});
158158

159+
ipcMain.on("extractAddon", (e, path) => {
160+
console.log(e, path);
161+
const gmad = spawn(settings.get('gmodDirectory') + '\\bin\\gmad.exe', ['extract', '-file', path]);
162+
mainWindow.webContents.send("finishExtraction");
163+
// shell.openItem('folderpath')
164+
});
165+
159166
// gmpublish.exe create -icon path/to/image512x512.jpg -addon path/to/gma.gma

index.html

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ <h4 style="font-weight: 300; margin: 10px">Steam <b>must</b> be open!</h4>
3535
<div id="addon_management_prompt">
3636
<h3>What would you like to do?</h3>
3737
<div id="addon_mgt_btn_grid">
38-
<button class="button_normal medium-text transition_button" data-divtoshow="#create_new_addon" data-divtohide="#addon_management_prompt" data-resize="500, 250" style="margin: 10px;">Create a new addon</button>
39-
<button id="update_existing_addon_button" class="button_normal medium-text transition_button" data-divtoshow="#update_existing_addon" data-divtohide="#addon_management_prompt" data-resize="500, 250" style="margin: 10px;">Loading... </button>
40-
<button class="button_normal medium-text transition_button" data-divtoshow="#extract_addon" data-divtohide="#addon_management_prompt" data-resize="500, 200" style="margin: 10px;">Extract Addon</button>
41-
<button class="button_normal medium-text transition_button" data-divtoshow="#download_addon" data-divtohide="#addon_management_prompt" style="margin: 10px;">Download Addon</button>
38+
<button id="create_addon_button" class="button_normal medium-text transition_button" data-divtoshow="#create_new_addon" data-divtohide="#addon_management_prompt" data-resize="500, 250" style="margin: 10px;">Create a new addon</button>
39+
<button id="update_existing_addon_button" class="button_normal medium-text transition_button rowtwo" data-divtoshow="#update_existing_addon" data-divtohide="#addon_management_prompt" data-resize="500, 250" style="margin: 10px;">Loading... </button>
40+
<button class="button_normal medium-text transition_button rowtwo" data-divtoshow="#extract_addon" data-divtohide="#addon_management_prompt" data-resize="500, 250" style="margin: 10px;">Extract Addon</button>
4241
</div>
4342
</div>
4443
<div id="update_existing_addon" class="path_div">
@@ -187,14 +186,27 @@ <h3>Uploaded!</h3>
187186
</div>
188187
<div id="extract_addon" class="path_div">
189188
<div class="top">
190-
<button class="back_button transition_button" data-divtoshow="#addon_management_prompt" data-divtohide="#extract_addon" data-resize="500, 200">◀ Back</button>
189+
<button id="extraction_back" class="back_button transition_button" data-divtoshow="#addon_management_prompt" data-divtohide="#extract_addon" data-resize="500, 200">◀ Back</button>
191190
<h3>Addon Extraction</h3>
192191
</div>
193-
</div>
194-
<div id="download_addon" class="path_div">
195-
<div class="top">
196-
<button class="back_button transition_button" data-divtoshow="#addon_management_prompt" data-divtohide="#download_addon" data-resize="500, 200">◀ Back</button>
197-
<h3>Addon Extraction</h3>
192+
<div id="addon_extraction">
193+
<div id="extract_addon_select">
194+
<p>Select the GMA file you'd like to extract</p>
195+
<button id="gmaFileSelection" class="button_normal">Choose GMA file</button>
196+
<p id="currentGMAFile"></p>
197+
<div id="addon_extract_next" class="bottom_btn">
198+
<button disabled class="button_normal" data-divtohide="#extract_addon_select" data-divtoshow="#extracting_addon">Extract</button>
199+
</div>
200+
</div>
201+
<div id="extracting_addon">
202+
<p>Extracting addon...</p>
203+
<img src="src/img/loading.gif" style="width: 64px; display: block; margin-left: auto; margin-right: auto; margin-top: 35px;" alt="">
204+
</div>
205+
<div id="extraction_done">
206+
<h3>Extracted!</h3>
207+
<a id="extractedGMALocation" style="color: white;" href="#">View</a>
208+
<button class="button_normal transition_button" data-divtohide="#extract_addon" data-divtoshow="#addon_management_prompt" data-resize="500, 200" style="width: 100px;">Done</button>
209+
</div>
198210
</div>
199211
</div>
200212
</div>

src/css/style.css

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,20 @@ header {
3939
color: white;
4040
}
4141

42+
.rowtwo {
43+
grid-row: 2;
44+
}
45+
4246
/* IDs */
4347
#addon_mgt_btn_grid {
4448
display: grid;
45-
grid-template-columns: auto auto;
46-
margin: 10px 20px;
49+
grid-template-columns: 50% 50%;
50+
grid-template-rows: auto auto;
51+
margin-top: 10px;
52+
}
53+
54+
#create_addon_button {
55+
grid-column-end: span 2;
4756
}
4857

4958
#addon_management_prompt .button_normal {
@@ -58,6 +67,14 @@ header {
5867
transform: translateY(3px);
5968
}
6069

70+
#addon_management_prompt h3 {
71+
margin-bottom: 0px;
72+
}
73+
74+
#gmaFileSelection {
75+
padding: 5px 20px;
76+
}
77+
6178
#main_titlebar {
6279
display: flex;
6380
justify-content: space-between;
@@ -135,6 +152,25 @@ header {
135152
font-weight: 700;
136153
}
137154

155+
.bottom_btn {
156+
text-align: center;
157+
position: absolute;
158+
bottom: 0;
159+
width: 100%;
160+
}
161+
162+
.bottom_btn button {
163+
width: 100%;
164+
border-radius: 0;
165+
background-color: #0f0f0f;
166+
color: white;
167+
cursor: not-allowed;
168+
border: none;
169+
padding: 10px 0;
170+
transform: ease 0.8s;
171+
font-weight: 700;
172+
}
173+
138174
#gmodDirSelect {
139175
text-align: center;
140176
}
@@ -170,7 +206,7 @@ header {
170206
text-align: center;
171207
}
172208

173-
#update_existing_addon, #directory_selection, #create_new_addon, #jsonCreator, #gmaPrep, #addonjsonPrompt, #addon_management_prompt, #createGMA, #uploadToWorkshopPrompt, #addonIconPrompt, #uploading, #new_addon, #errorNote, #extract_addon, #download_addon {
209+
#update_existing_addon, #directory_selection, #create_new_addon, #jsonCreator, #gmaPrep, #addonjsonPrompt, #addon_management_prompt, #createGMA, #uploadToWorkshopPrompt, #addonIconPrompt, #uploading, #new_addon, #errorNote, #extract_addon, #extracting_addon, #extraction_done {
174210
display: none;
175211
}
176212

src/js/script.js

Lines changed: 79 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let dirDialogOptions = {
4242
properties: ['openDirectory']
4343
}
4444

45-
let fileDialogOptions = {
45+
let imgDialogOptions = {
4646
title : "Select your addon's icon",
4747
buttonLabel : "Select icon",
4848
filters :[
@@ -51,6 +51,16 @@ let fileDialogOptions = {
5151
properties: ['openFile']
5252
}
5353

54+
let fileDialogOptions = {
55+
title : "Select your GMA file",
56+
buttonLabel : "Select GMA",
57+
filters :[
58+
{name: 'Garry\'s Mod Addon File', extensions: ['gma']}
59+
],
60+
properties: ['openFile']
61+
}
62+
63+
5464

5565

5666
// Make links open in enternal browser
@@ -176,53 +186,91 @@ $(document).ready(() => {
176186
dialog.showOpenDialog(win, dirDialogOptions).then(result => {
177187
var filePath = result.filePaths[0]
178188
var desName = filePath.substring(filePath.length - 9, filePath.length);
179-
ipcRenderer.send('checkIfDirectoryExists', filePath + "\\bin\\gmad.exe");
180-
ipcRenderer.send('checkIfDirectoryExists', filePath + "\\bin\\gmpublish.exe");
181-
if (desName == "GarrysMod") {
182-
$('#status_of_dir').css('color', 'lightgreen');
183-
$('#status_of_dir').text('Found gmad.exe and gmpublish.exe!');
184-
$('#dir_prompt_next button').css('background-color', '#56bd56');
185-
$('#dir_prompt_next button').prop('disabled', false);
186-
$('#dir_prompt_next button').css('cursor', 'pointer');
187-
$('#checkmarkNote').fadeIn(() => {
188-
$('#checkmarkNote').delay(1000).fadeOut();
189-
})
190-
settings.set('gmodDirectory', filePath);
191-
ipcRenderer.send('getAddonInfo');
192-
} else {
193-
$('#status_of_dir').css('color', 'red');
194-
$('#status_of_dir').text("Can't find gmad.exe or gmpublish.exe!");
195-
console.log(filePath);
196-
$('#dir_prompt_next button').prop('disabled', true);
197-
$('#dir_prompt_next button').css('cursor', 'not-allowed');
189+
if (filePath != null) {
190+
ipcRenderer.send('checkIfDirectoryExists', filePath + "\\bin\\gmad.exe");
191+
ipcRenderer.send('checkIfDirectoryExists', filePath + "\\bin\\gmpublish.exe");
192+
if (desName == "GarrysMod") {
193+
$('#status_of_dir').css('color', 'lightgreen');
194+
$('#status_of_dir').text('Found gmad.exe and gmpublish.exe!');
195+
$('#dir_prompt_next button').css('background-color', '#56bd56');
196+
$('#dir_prompt_next button').prop('disabled', false);
197+
$('#dir_prompt_next button').css('cursor', 'pointer');
198+
$('#checkmarkNote').fadeIn(() => {
199+
$('#checkmarkNote').delay(1000).fadeOut();
200+
})
201+
settings.set('gmodDirectory', filePath);
202+
ipcRenderer.send('getAddonInfo');
203+
} else {
204+
$('#status_of_dir').css('color', 'red');
205+
$('#status_of_dir').text("Can't find gmad.exe or gmpublish.exe!");
206+
console.log(filePath);
207+
$('#dir_prompt_next button').prop('disabled', true);
208+
$('#dir_prompt_next button').css('cursor', 'not-allowed');
209+
}
198210
}
199211
}).catch(err => {
200212
console.log("dialog error")
201213
});
202-
})
214+
});
215+
216+
$("#gmaFileSelection").click(() => {
217+
dialog.showOpenDialog(win, fileDialogOptions).then(r => {
218+
let addonGMA = r.filePaths[0];
219+
addonPath = r.filePaths[0];
220+
if (addonGMA != null) {
221+
ipcRenderer.send('checkIfDirectoryExists', addonGMA);
222+
var n = addonGMA.lastIndexOf('\\');
223+
var result = addonGMA.substring(n + 1, addonGMA.length);
224+
$("#currentGMAFile").text(result);
225+
$("#addon_extract_next button").prop('disabled', false);
226+
$('#addon_extract_next button').css('background-color', '#56bd56');
227+
$('#addon_extract_next button').css('cursor', 'pointer');
228+
}
229+
}).catch(err => {});
230+
});
231+
232+
$("#addon_extract_next button").click(() => {
233+
$("#extract_addon_select").fadeOut(() => {
234+
$("#extracting_addon").fadeIn(() => {
235+
ipcRenderer.send('extractAddon', addonPath);
236+
});
237+
});
238+
});
239+
240+
ipcRenderer.on('finishExtraction', (e) => {
241+
$('#extracting_addon').fadeOut(() => {
242+
win.setBounds({height: 225})
243+
// $('#extractedGMALocation').attr('href', 'steam://url/CommunityFilePage/' + newAddonID)
244+
$('#extraction_done').fadeIn()
245+
});
246+
});
203247

204248
// If directory exists (and is writable/readable) allow user to procede
205249
$('#addon_dir_folder').click(() => {
206250
dialog.showOpenDialog(win, dirDialogOptions).then(result => {
207251
if (!result.canceled) {
208252
currentNewAddon = result.filePaths[0];
209-
ipcRenderer.send('checkIfDirectoryExists', currentNewAddon);
210-
var n = currentNewAddon.lastIndexOf('\\');
211-
var result = currentNewAddon.substring(n + 1);
212-
$('#addonDir b').text(result);
213-
$('#addonDirCheck').css('background-color', '#56bd56');
214-
$('#addonDirCheck').prop('disabled', false);
215-
$('#addonDirCheck').css('cursor', 'pointer');
253+
if (currentNewAddon != null) {
254+
ipcRenderer.send('checkIfDirectoryExists', currentNewAddon);
255+
var n = currentNewAddon.lastIndexOf('\\');
256+
var result = currentNewAddon.substring(n + 1);
257+
$('#addonDir b').text(result);
258+
$('#addonDirCheck').css('background-color', '#56bd56');
259+
$('#addonDirCheck').prop('disabled', false);
260+
$('#addonDirCheck').css('cursor', 'pointer');
261+
}
216262
}
217263
}).catch(err => {
218264
console.log("dialog error")
219265
});
220266
});
221267

222268
$('#addon_icon').click(() => {
223-
dialog.showOpenDialog(win, fileDialogOptions).then(result => {
269+
dialog.showOpenDialog(win, imgDialogOptions).then(result => {
224270
addonIcon = result.filePaths[0];
225-
ipcRenderer.send('checkIfDirectoryExists', addonIcon);
271+
if (addonIcon != null) {
272+
ipcRenderer.send('checkIfDirectoryExists', addonIcon);
273+
}
226274
var jpegCheck = addonIcon.substring(addonIcon.length - 4);
227275
var sizeOf = require('image-size');
228276
var dimensions = sizeOf(addonIcon);
@@ -296,7 +344,7 @@ $(document).ready(() => {
296344
})
297345

298346
$('.removeBackOption').click(() => {
299-
// $('#back_button_addon_creation').fadeOut();
347+
// $('#extraction_back').fadeOut();
300348
})
301349

302350
// General function for transitioning between div tags (with a shitty name)

0 commit comments

Comments
 (0)