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

Commit 04df256

Browse files
committed
Resize polish and some other stuff
1 parent 330c45d commit 04df256

File tree

6 files changed

+69
-24
lines changed

6 files changed

+69
-24
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Garry's Mod Addon Tool

index.html

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ <h3>Addon creation</h3>
6262
</div>
6363
<div id="addonIconPrompt">
6464
<p>Please select an icon for your addon</p>
65+
<p style="font-size: 0.8em">Must be a JPEG/JPG</p>
6566
<button class="button_normal fake_select" data-buttonclick="#addon_icon">Choose Directory</button>
6667
<input id="addon_icon" class="real_select" type="file"/>
6768
<div class="next_prompt">
@@ -72,7 +73,7 @@ <h3>Addon creation</h3>
7273
<p>Do you already have a addon.json?</p>
7374
<div>
7475
<button class="button_normal transition_button removeBackOption" data-divtoshow="#jsonCreator" data-divtohide="#addonjsonPrompt" data-resize="500, 350">No</button>
75-
<button class="button_normal transition_button removeBackOption" data-divtoshow="#gmaPrep" data-divtohide="#addonjsonPrompt" data-resize="500, 250">Yes</button>
76+
<button class="button_normal transition_button removeBackOption" data-divtoshow="#gmaPrep" data-divtohide="#addonjsonPrompt" data-resize="500, 200">Yes</button>
7677
</div>
7778
</div>
7879
<div id="jsonCreator">
@@ -152,30 +153,42 @@ <h3>Addon creation</h3>
152153
<p><span style="font-size: .7em; color: grey; font-weight:500;">(file names seprated by a comma)</span></p>
153154
</div>
154155
<div class="next_prompt">
155-
<button id="jsonAddonValidate" class="transition_button" data-divtoshow="#gmaPrep" data-divtohide="#jsonCreator" data-resize="500, 250" disabled>Next</button>
156+
<button id="jsonAddonValidate" class="transition_button" data-divtoshow="#gmaPrep" data-divtohide="#jsonCreator" data-resize="500, 200" disabled>Next</button>
156157
</div>
157158
</div>
158159
</div>
159160
<div id="gmaPrep">
160-
<p>Created <span style="font-weight: 700">addon.json</span>!</p>
161+
<!-- <p>Created <span style="font-weight: 700">addon.json</span>!</p> -->
161162
<h3>Create GMA for uploading to the Workshop?</h3>
162-
<button style="width: 150px;" 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: 150px;" id="createGMAFile" class="button_normal transition_button">Yes</button>
163+
<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>
164+
<button style="width: 100px;" id="createGMAFile" class="button_normal transition_button">Yes</button>
164165
<!-- <img src="src/img/loading.gif" style="display: block; margin-left: auto; margin-right: auto; width: 64px;" alt=""> -->
165166
</div>
166167
<div id="createGMA">
167168
<p>Creating GMA...</p>
168169
<img src="src/img/loading.gif" style="width: 64px; display: block; margin-left: auto; margin-right: auto; margin-top: 35px;" alt="">
169170
</div>
170171
<div id="uploadToWorkshopPrompt">
171-
<p>Upload to the Workshop?</p>
172-
<button class="button_normal">No</button>
173-
<button id="uploadCurrentGMA" class="button_normal">Yes</button>
172+
<h3>Upload to the Workshop?</h3>
173+
<button style="width: 100px;" class="button_normal">No</button>
174+
<button style="width: 100px;" id="uploadCurrentGMA" class="button_normal">Yes</button>
175+
</div>
176+
<div id="uploading">
177+
<p>Uploading to the workshop...</p>
178+
<img src="src/img/loading.gif" style="width: 64px; display: block; margin-left: auto; margin-right: auto; margin-top: 35px;" alt="">
179+
</div>
180+
<div id="new_addon">
181+
<p>Uploaded!</p>
182+
<p><a id="new_addon_link" style="color: white;" href="#">View on Steam</a></p>
183+
<button class="button_normal" style="width: 100px;">Done</button>
174184
</div>
175-
176185
</div>
177186
</div>
178187
</div>
188+
<div id="errorNote">
189+
<p>Error: <span id="error"></span></p>
190+
<button class="button_normal">Okay</button>
191+
</div>
179192
<div id="checkmarkNote">
180193
<img src="src/img/checkmark.png" alt="">
181194
<p>Saved!</p>

index.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function createWindow() {
3030
backgroundColor: "#262626",
3131
titleBarStyle: "hidden",
3232
frame: false,
33+
icon: "src/img/icon.png",
3334
webPreferences: {
3435
nodeIntegration: true
3536
}
@@ -77,9 +78,9 @@ ipcMain.on('checkIfDirectoryExists', (event, file) => {
7778
})
7879

7980
ipcMain.on('getAddonInfo', () => {
80-
console.log('trying to get addon info')
81+
console.log('Trying to get addon info...')
8182
sendClientAddonInfo()
82-
console.log(settings.get('gmodDirectory'))
83+
console.log("User's Gmod Directory:" + settings.get('gmodDirectory'))
8384
})
8485

8586
var ADDON_IDS = []
@@ -95,8 +96,7 @@ function sendClientAddonInfo() {
9596
fixedArray[i] = fixedArray[i].replace('/r', '');
9697
ADDON_IDS.push([fixedArray[i].substr(0, 11).replace(/\s/g, '').toString()])
9798
}
98-
99-
console.log('sent to client!')
99+
console.log('Sent to client!')
100100
mainWindow.webContents.send('message', ADDON_IDS);
101101
});
102102
}
@@ -105,6 +105,7 @@ ipcMain.on('createJsonFile', (event, json, dir) => {
105105
console.log(json, dir)
106106
fs.writeFileSync(dir + "\\addon.json", json, 'utf8', (err) => {
107107
console.log("An error occured while writing JSON Object to File.\n", err);
108+
mainWindow.webContents.send('error', "Error writing directory.");
108109
})
109110
})
110111

@@ -118,16 +119,23 @@ ipcMain.on('createGMAFile', (event, addonDir) => {
118119
var addonGMADir = fixedArray;
119120
console.log("GMA location: " + addonGMADir);
120121
mainWindow.webContents.send('addonGMALocation', addonGMADir);
121-
})
122-
})
122+
});
123+
});
123124

124125
ipcMain.on('uploadToWorkshop', (event, gmaDir, iconDir) => {
125126
const gmpublish = spawn(settings.get('gmodDirectory') + '\\bin\\gmpublish.exe', ['create', '-icon', iconDir, '-addon', gmaDir]);
126127
gmpublish.stdout.on('data', (data) => {
127-
console.log(data.toString());
128+
var arrayOfOutput = data.toString().split('\n')
129+
var fixedArray = arrayOfOutput.slice(arrayOfOutput.length - 8, arrayOfOutput.length - 7)
130+
fixedArray = fixedArray[0].replace(/\D/, '')
131+
fixedArray = fixedArray.substr(5, fixedArray.length)
132+
console.log(fixedArray)
133+
mainWindow.webContents.send('currentAddonID', fixedArray);
128134
})
129135
})
130136

131137

132138

139+
140+
133141
// gmpublish.exe create -icon path/to/image512x512.jpg -addon path/to/gma.gma

src/css/style.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ header {
164164
text-align: center;
165165
}
166166

167-
#update_existing_addon, #directory_selection, #create_new_addon, #jsonCreator, #gmaPrep, #addonjsonPrompt, #addon_management_prompt, #createGMA, #uploadToWorkshopPrompt, #addonIconPrompt {
167+
#update_existing_addon, #directory_selection, #create_new_addon, #jsonCreator, #gmaPrep, #addonjsonPrompt, #addon_management_prompt, #createGMA, #uploadToWorkshopPrompt, #addonIconPrompt, #uploading, #new_addon, #errorNote {
168168
display: none;
169169
}
170170

@@ -232,6 +232,11 @@ header {
232232
margin: 0
233233
}
234234

235+
.addon_existing a {
236+
color: white;
237+
display: none;
238+
}
239+
235240
.removeBackOption {
236241
width: 100px;
237242
}

src/img/icon.png

19.8 KB
Loading

src/js/script.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ $(document).ready(() => {
144144
$('#addonIconCheck').css('background-color', '#56bd56');
145145
$('#addonIconCheck').prop('disabled', false);
146146
$('#addonIconCheck').css('cursor', 'pointer');
147-
win.setBounds({
148-
height: 350
149-
})
150147
} else {
151148
$('#addonIconCheck').css('background-color', '#0f0f0f');
152149
$('#addonIconCheck').prop('disabled', true);
@@ -193,6 +190,7 @@ $(document).ready(() => {
193190
var divToGoBack = $(target).data('divtohide');
194191
var divToShow = $(target).data('divtoshow');
195192
console.log(divToGoBack, divToShow)
193+
// Checks for resize data, if it exists, pass it to goBack()
196194
if ($(target).data('resize') != null) {
197195
var resizeInfo = JSON.parse("[" + $(target).data('resize') + "]");
198196
}
@@ -203,7 +201,7 @@ $(document).ready(() => {
203201
$('#back_button_addon_creation').fadeOut();
204202
})
205203

206-
// General function for transitioning between div tags
204+
// General function for transitioning between div tags (with a shitty name)
207205
function goBack(divToFadeOut, divToFadeIn, resizeInfo) {
208206
$(divToFadeOut).fadeOut(() => {
209207
if (resizeInfo != null) {
@@ -221,7 +219,7 @@ $(document).ready(() => {
221219
// This check is done to make sure this only gets executed once
222220
if (!donePopulatingAddonList) {
223221
for (let i = 0; i < addon_data.length; i++) {
224-
$('#yourAddons').append("<div class='addon_existing'><p>" + addon_data[i].title + "</p></div>");
222+
$('#yourAddons').append("<div class='addon_existing'><p>" + addon_data[i].title + "</p><a href='steam://url/CommunityFilePage/" + addon_data[i].id + "'>View on Steam</a></div>");
225223
donePopulatingAddonList = true;
226224
}
227225
// Make sure if nothing is returned to let the user know
@@ -237,6 +235,12 @@ $(document).ready(() => {
237235
}
238236
}
239237

238+
// $('.addon_existing').hover((event) => {
239+
// console.log('hello')
240+
// var target = $(event.target);
241+
// $(this).find('a:last').fadeIn();
242+
// })
243+
240244
$('.typeCheckbox').on('click', (event) => {
241245
var target = $(event.target);
242246
if (jsonCheckboxCount < 2 && target.is(":checked")) {
@@ -347,18 +351,32 @@ $(document).ready(() => {
347351

348352
$("#createGMAFile").click(() => {
349353
$('#gmaPrep').fadeOut(() => {
354+
win.setBounds({height: 225})
350355
$('#createGMA').fadeIn();
351356
ipcRenderer.send('createGMAFile', currentNewAddon);
352357
});
353358
})
354-
359+
355360
$("#uploadCurrentGMA").click(() => {
356361
ipcRenderer.send('uploadToWorkshop', addonGMADir, addonIcon);
362+
$('#uploadToWorkshopPrompt').fadeOut(() => {
363+
win.setBounds({height: 225})
364+
$('#uploading').fadeIn();
365+
})
357366
})
358-
367+
368+
ipcRenderer.on('currentAddonID', (event, newAddonID) => {
369+
$('#uploading').fadeOut(() => {
370+
win.setBounds({height: 200})
371+
$('#new_addon_link').attr('href', 'steam://url/CommunityFilePage/' + newAddonID)
372+
$('#new_addon').fadeIn()
373+
})
374+
})
375+
359376
ipcRenderer.on('addonGMALocation', (event, addonGMA) => {
360377
addonGMADir = addonGMA;
361378
$('#createGMA').fadeOut(() => {
379+
win.setBounds({height: 200})
362380
$("#uploadToWorkshopPrompt").fadeIn();
363381
})
364382
})

0 commit comments

Comments
 (0)