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

Commit a9002ce

Browse files
committed
update ver check, more restructuring, fix dialogs
1 parent 8b28158 commit a9002ce

File tree

5 files changed

+122
-88
lines changed

5 files changed

+122
-88
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Creates GMAs, addon.json, and uploads it to the Workshop.
1111
Download a [release](https://github.com/Leeous/gmod-addon-tool/releases) and run `gmod-addon-tool.exe`.
1212

1313
### Have an issue?
14-
Make sure you [follow the wiki's directions](https://wiki.garrysmod.com/page/Workshop_Addon_Creation), this tool doesn't tell you if you did something incorrectly.
14+
Make sure you [follow the wiki's directions](https://wiki.garrysmod.com/page/Workshop_Addon_Creation).
1515

16-
Even if it's as simple as trying to upload a `.png` as your addon's icon instead of a `.jpg` image, it will fail. Maybe I'll add error checking in the future, but honestly it's more work that what's it's worth.
16+
Settings are saved at `%APPDATA%/gmod-addon-tool`, delete this folder to reset any settings created.
1717

1818
Otherwise,
1919
[create an issue](https://github.com/Leeous/gmod-addon-tool/issues/new) or send me a tweet/DM [@LeeTheCoder](https://twitter.com/LeeTheCoder).

app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function createWindow() {
2424
// Create the browser window.
2525
mainWindow = new BrowserWindow({
2626
width: 500,
27-
height: 250,
27+
height: 225,
2828
resizable: false,
2929
fullscreenable: false,
3030
backgroundColor: "#262626",
@@ -39,7 +39,7 @@ function createWindow() {
3939
mainWindow.loadFile('index.html')
4040

4141
// Open the DevTools.
42-
// mainWindow.webContents.openDevTools()
42+
mainWindow.webContents.openDevTools()
4343

4444
// Emitted when the window is closed.
4545
mainWindow.on('closed', function() {

index.html

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
<div id="directory_selection">
2424
<div id="gmodDirSelect">
2525
<h3 id="dir_select_prompt">Please select your Garry's Mod directory</h3>
26-
<button class="button_normal fake_select" data-buttonclick="#gmod_dir_folder">Choose Directory</button>
27-
<input id="gmod_dir_folder" class="real_select" type="file" webkitdirectory />
26+
<button id="gmod_dir_folder" class="button_normal">Choose Directory</button>
2827
<h4 style="font-weight: 300; margin: 10px">Steam <b>must</b> be open!</h4>
2928
</div>
3029
<p id="status_of_dir"></p>
@@ -36,29 +35,28 @@ <h4 style="font-weight: 300; margin: 10px">Steam <b>must</b> be open!</h4>
3635
<div id="addon_management_prompt">
3736
<h3>What would you like to do?</h3>
3837
<div id="addon_mgt_btn_grid">
39-
<button id="create_new_addon_button" class="button_normal medium-text" style="margin: 10px;">Create a new addon</button>
40-
<button id="update_existing_addon_button" class="button_normal medium-text" style="margin: 10px;">Loading...</button>
41-
<button class="button_normal medium-text" style="margin: 10px;">Extract Addon</button>
42-
<button class="button_normal medium-text" style="margin: 10px;">Download Addon</button>
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>
4342
</div>
4443
</div>
45-
<div id="update_existing_addon">
44+
<div id="update_existing_addon" class="path_div">
4645
<div class="top">
47-
<button id="back_button_existing_addon" class="back_button" data-backwards="#addon_management_prompt" data-forwards="#update_existing_addon" data-resize="500, 200">◀ Back</button>
46+
<button class="back_button transition_button" data-divtoshow="#addon_management_prompt" data-divtohide="#update_existing_addon" data-resize="500, 200">◀ Back</button>
4847
<h3>Your addons</h3>
4948
</div>
5049
<div id="yourAddons"></div>
5150
</div>
52-
<div id="create_new_addon">
51+
<div id="create_new_addon" class="path_div">
5352
<div class="top">
5453
<button id="back_button_addon_creation" class="back_button" data-backwards="#addon_management_prompt" data-forwards="#create_new_addon" data-resize="500, 200">◀ Back</button>
5554
<h3>Addon creation</h3>
5655
</div>
5756
<div id="addon_creation">
5857
<div id="addonDirPrompt">
5958
<p>Please select your addon's folder</p>
60-
<button class="button_normal fake_select" data-buttonclick="#addon_dir_folder">Choose Directory</button>
61-
<input id="addon_dir_folder" class="real_select" type="button"/>
59+
<button id="addon_dir_folder" class="button_normal">Choose Directory</button>
6260
<p id="addonDir"><b></b></p>
6361
<div class="next_prompt">
6462
<button id="addonDirCheck" class="transition_button" data-divtoshow="#addonIconPrompt" data-divtohide="#addonDirPrompt" data-resize="500, 250" disabled>Next</button>
@@ -67,8 +65,7 @@ <h3>Addon creation</h3>
6765
<div id="addonIconPrompt">
6866
<p>Please select an icon for your addon</p>
6967
<p style="font-size: 0.8em">Must be a JPEG/JPG</p>
70-
<button class="button_normal fake_select" data-buttonclick="#addon_icon">Choose Directory</button>
71-
<input id="addon_icon" class="real_select" type="file"/>
68+
<button id="addon_icon" class="button_normal">Choose Directory</button>
7269
<div class="next_prompt">
7370
<button id="addonIconCheck" class="transition_button" data-divtoshow="#addonjsonPrompt" data-divtohide="#addonIconPrompt" data-resize="500, 175" disabled>Next</button>
7471
</div>
@@ -188,15 +185,18 @@ <h3>Uploaded!</h3>
188185
</div>
189186
</div>
190187
</div>
191-
<div id="extract_addon">
188+
<div id="extract_addon" class="path_div">
192189
<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>
191+
<h3>Addon Extraction</h3>
192+
</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>
193197
<h3>Addon Extraction</h3>
194198
</div>
195199
</div>
196-
</div>
197-
<div id="errorNote">
198-
<p>Error: <span id="error"></span></p>
199-
<button class="button_normal">Okay</button>
200200
</div>
201201
<div id="checkmarkNote">
202202
<img src="src/img/checkmark.png" alt="">

src/css/style.css

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ header {
4242
/* IDs */
4343
#addon_mgt_btn_grid {
4444
display: grid;
45-
grid-row: 2;
4645
grid-template-columns: auto auto;
46+
margin: 10px 20px;
4747
}
4848

4949
#addon_management_prompt .button_normal {
@@ -170,31 +170,26 @@ header {
170170
text-align: center;
171171
}
172172

173-
#addon_management {
174-
display: none;
175-
text-align: center;
176-
}
177-
178-
#update_existing_addon, #directory_selection, #create_new_addon, #jsonCreator, #gmaPrep, #addonjsonPrompt, #addon_management_prompt, #createGMA, #uploadToWorkshopPrompt, #addonIconPrompt, #uploading, #new_addon, #errorNote, #extract_addon {
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 {
179174
display: none;
180175
}
181176

182177
/* Views styles */
183178

184-
#update_existing_addon .top, #create_new_addon .top {
179+
.path_div .top {
185180
background-color: #0f0f0f;
186181
text-align: left;
187182
padding: 15px 10px;
188183
}
189184

190-
#create_new_addon .top h3 {
185+
.path_div .top h3 {
191186
display: inline-block;
192187
margin: 0;
193188
font-weight: 300;
194189
transform: translateY(2px)
195190
}
196191

197-
#update_existing_addon .top button, #create_new_addon .top button {
192+
.path_div .top button {
198193
display: inline-block;
199194
background-color: rgb(219, 68, 68);
200195
margin-right: 5px;
@@ -214,11 +209,7 @@ header {
214209
font-weight: 300;
215210
}
216211

217-
#update_existing_addon .top button {
218-
/* display: inline-block; */
219-
background-color: rgb(219, 68, 68);
220-
margin-right: 5px;
221-
}
212+
222213

223214
#refresh_addons {
224215
margin-left: auto;

src/js/script.js

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

45+
let fileDialogOptions = {
46+
title : "Select your addon's icon",
47+
buttonLabel : "Select icon",
48+
filters :[
49+
{name: 'Image', extensions: ['jpeg', 'jpg']}
50+
],
51+
properties: ['openFile']
52+
}
53+
54+
55+
4556
// Make links open in enternal browser
4657
$(document).on("click", "a[href^='http']", function(event) {
4758
event.preventDefault();
@@ -67,12 +78,33 @@ $(document).ready(() => {
6778
dataType: "json"
6879
}).done((data) => {
6980
if (data.tag_name != currentAppVersion) {
70-
var open = confirm("Update " + data.tag_name + " available.");
71-
if (open) {
72-
shell.openExternal("https://github.com/Leeous/gmod-addon-tool/releases");
73-
}
81+
newUpdate(data.tag_name);
82+
// var open = confirm("Update " + data.tag_name + " available.");
83+
// if (open) {
84+
// shell.openExternal("https://github.com/Leeous/gmod-addon-tool/releases");
85+
// }
7486
}
7587
})
88+
89+
function newUpdate(ver) {
90+
if (settings.get('remindUpdate') == null || settings.get('remindUpdate')) {
91+
dialog.showMessageBox(win, {
92+
type: "info",
93+
buttons: ['Cancel', 'Open'],
94+
message: "Update " + ver + " is available for download.",
95+
title: "New update available!",
96+
checkboxLabel: "Don't remind me again",
97+
}).then(response => {
98+
if (response.response == 1) {
99+
shell.openExternal("https://github.com/Leeous/gmod-addon-tool/releases");
100+
}
101+
if (response.checkboxChecked) {
102+
console.log("Will no longer remind user about updates.")
103+
settings.set('remindUpdate', false);
104+
}
105+
}).catch(err => {});
106+
}
107+
}
76108

77109
function getAddonInfoFromSteam(message) {
78110
arrayOfAddonIds = message;
@@ -128,37 +160,45 @@ $(document).ready(() => {
128160
remote.getCurrentWindow().minimize();
129161
})
130162

131-
// Used to "fake click" the input[type="file"]
132-
$('.fake_select').click((event) => {
133-
var fakeButton = event.target;
134-
var realButton = $(fakeButton).data('buttonclick');
135-
$(realButton).click();
163+
$('#helpApp').click(() => {
164+
alert('no')
136165
})
137166

167+
// Used to "fake click" the input[type="file"]
168+
// $('.fake_select').click((event) => {
169+
// var fakeButton = event.target;
170+
// var realButton = $(fakeButton).data('buttonclick');
171+
// $(realButton).click();
172+
// })
173+
138174
// Validate that we have read/write access to the users Garrysmod directory so we can use gmad & gmpublish
139-
$('#gmod_dir_folder').change(() => {
140-
var filePath = document.getElementById("gmod_dir_folder").files[0].path;
141-
var desName = filePath.substring(filePath.length - 9, filePath.length);
142-
ipcRenderer.send('checkIfDirectoryExists', filePath + "\\bin\\gmad.exe");
143-
ipcRenderer.send('checkIfDirectoryExists', filePath + "\\bin\\gmpublish.exe");
144-
if (desName == "GarrysMod") {
145-
$('#status_of_dir').css('color', 'lightgreen');
146-
$('#status_of_dir').text('Found gmad.exe and gmpublish.exe!');
147-
$('#dir_prompt_next button').css('background-color', '#56bd56');
148-
$('#dir_prompt_next button').prop('disabled', false);
149-
$('#dir_prompt_next button').css('cursor', 'pointer');
150-
$('#checkmarkNote').fadeIn(() => {
151-
$('#checkmarkNote').delay(1000).fadeOut();
152-
})
153-
settings.set('gmodDirectory', filePath);
154-
ipcRenderer.send('getAddonInfo');
155-
} else {
156-
$('#status_of_dir').css('color', 'red');
157-
$('#status_of_dir').text("Can't find gmad.exe or gmpublish.exe!");
158-
console.log(filePath);
159-
$('#dir_prompt_next button').prop('disabled', true);
160-
$('#dir_prompt_next button').css('cursor', 'not-allowed');
161-
}
175+
$('#gmod_dir_folder').click(() => {
176+
dialog.showOpenDialog(win, dirDialogOptions).then(result => {
177+
var filePath = result.filePaths[0]
178+
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');
198+
}
199+
}).catch(err => {
200+
console.log("dialog error")
201+
});
162202
})
163203

164204
// If directory exists (and is writable/readable) allow user to procede
@@ -179,27 +219,30 @@ $(document).ready(() => {
179219
});
180220
});
181221

182-
$('#addon_icon').change(() => {
183-
addonIcon = document.getElementById("addon_icon").files[0].path;
184-
sizeIsOkay = true;
185-
ipcRenderer.send('checkIfDirectoryExists', addonIcon);
186-
var jpegCheck = addonIcon.substring(addonIcon.length - 4);
187-
var sizeOf = require('image-size');
188-
var dimensions = sizeOf(addonIcon);
189-
if (jpegCheck == "jpeg" || jpegCheck == ".jpg") {
190-
if (dimensions.height == 512 && dimensions.width == 512) {
191-
$('#addonIconCheck').css('background-color', '#56bd56');
192-
$('#addonIconCheck').prop('disabled', false);
193-
$('#addonIconCheck').css('cursor', 'pointer');
222+
$('#addon_icon').click(() => {
223+
dialog.showOpenDialog(win, fileDialogOptions).then(result => {
224+
addonIcon = result.filePaths[0];
225+
ipcRenderer.send('checkIfDirectoryExists', addonIcon);
226+
var jpegCheck = addonIcon.substring(addonIcon.length - 4);
227+
var sizeOf = require('image-size');
228+
var dimensions = sizeOf(addonIcon);
229+
if (jpegCheck == "jpeg" || jpegCheck == ".jpg") {
230+
if (dimensions.height == 512 && dimensions.width == 512) {
231+
$('#addonIconCheck').css('background-color', '#56bd56');
232+
$('#addonIconCheck').prop('disabled', false);
233+
$('#addonIconCheck').css('cursor', 'pointer');
234+
} else {
235+
alert("Image must be 512x512.")
236+
}
194237
} else {
195-
alert("Image must be 512x512.")
238+
$('#addonIconCheck').css('background-color', '#0f0f0f');
239+
$('#addonIconCheck').prop('disabled', true);
240+
$('#addonIconCheck').css('cursor', 'not-allowed');
241+
alert("Doesn't seem like a JPEG image.");
196242
}
197-
} else {
198-
$('#addonIconCheck').css('background-color', '#0f0f0f');
199-
$('#addonIconCheck').prop('disabled', true);
200-
$('#addonIconCheck').css('cursor', 'not-allowed');
201-
alert("Doesn't seem like a JPEG image.");
202-
}
243+
}).catch(err => {
244+
245+
});
203246
})
204247

205248
$('#dir_prompt_next button').click(() => {

0 commit comments

Comments
 (0)