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

Commit 330c45d

Browse files
committed
achieved first upload
1 parent d067ae3 commit 330c45d

File tree

4 files changed

+83
-11
lines changed

4 files changed

+83
-11
lines changed

index.html

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,15 @@ <h3>Addon creation</h3>
5757
<input id="addon_dir_folder" class="real_select" type="file" webkitdirectory />
5858
<p id="addonDir"><b></b></p>
5959
<div class="next_prompt">
60-
<button id="addonDirCheck" class="transition_button" data-divtoshow="#addonjsonPrompt" data-divtohide="#addonDirPrompt" data-resize="500, 175" disabled>Next</button>
60+
<button id="addonDirCheck" class="transition_button" data-divtoshow="#addonIconPrompt" data-divtohide="#addonDirPrompt" data-resize="500, 250" disabled>Next</button>
61+
</div>
62+
</div>
63+
<div id="addonIconPrompt">
64+
<p>Please select an icon for your addon</p>
65+
<button class="button_normal fake_select" data-buttonclick="#addon_icon">Choose Directory</button>
66+
<input id="addon_icon" class="real_select" type="file"/>
67+
<div class="next_prompt">
68+
<button id="addonIconCheck" class="transition_button" data-divtoshow="#addonjsonPrompt" data-divtohide="#addonIconPrompt" data-resize="500, 175" disabled>Next</button>
6169
</div>
6270
</div>
6371
<div id="addonjsonPrompt">
@@ -151,12 +159,20 @@ <h3>Addon creation</h3>
151159
<div id="gmaPrep">
152160
<p>Created <span style="font-weight: 700">addon.json</span>!</p>
153161
<h3>Create GMA for uploading to the Workshop?</h3>
154-
<button style="width: 200px;" class="button_normal transition_button" data-divtohide="" data-divtoshow="" data-resize="">Yes</button>
155-
<button style="width: 200px;" class="button_normal transition_button" id="resetAddonCreation" data-divtohide="#create_new_addon" data-divtoshow="#addon_management_prompt" data-resize="500, 175">No</button>
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>
156164
<!-- <img src="src/img/loading.gif" style="display: block; margin-left: auto; margin-right: auto; width: 64px;" alt=""> -->
157165
</div>
158166
<div id="createGMA">
167+
<p>Creating GMA...</p>
168+
<img src="src/img/loading.gif" style="width: 64px; display: block; margin-left: auto; margin-right: auto; margin-top: 35px;" alt="">
169+
</div>
170+
<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>
159174
</div>
175+
160176
</div>
161177
</div>
162178
</div>

index.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,26 @@ ipcMain.on('createJsonFile', (event, json, dir) => {
108108
})
109109
})
110110

111-
// ipcMain.on('createGmaFile', (addonDir) => {
112-
// // var gmaLocation = addonDir +
113-
// })
111+
ipcMain.on('createGMAFile', (event, addonDir) => {
112+
console.log("Addon's Directory: " + addonDir.toString())
113+
const gmad = spawn(settings.get('gmodDirectory') + '\\bin\\gmad.exe', ['create', '-folder', addonDir]);
114+
gmad.stdout.on('data', (data) => {
115+
var arrayOfOutput = data.toString().split('\n')
116+
var fixedArray = arrayOfOutput.slice(arrayOfOutput.length - 2, arrayOfOutput.length - 1)
117+
fixedArray = fixedArray[0].match(/(?:"[^"]*"|^[^"]*$)/)[0].replace(/"/g, "")
118+
var addonGMADir = fixedArray;
119+
console.log("GMA location: " + addonGMADir);
120+
mainWindow.webContents.send('addonGMALocation', addonGMADir);
121+
})
122+
})
123+
124+
ipcMain.on('uploadToWorkshop', (event, gmaDir, iconDir) => {
125+
const gmpublish = spawn(settings.get('gmodDirectory') + '\\bin\\gmpublish.exe', ['create', '-icon', iconDir, '-addon', gmaDir]);
126+
gmpublish.stdout.on('data', (data) => {
127+
console.log(data.toString());
128+
})
129+
})
130+
131+
114132

115-
// function
133+
// gmpublish.exe create -icon path/to/image512x512.jpg -addon path/to/gma.gma

src/css/style.css

Lines changed: 1 addition & 4 deletions
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 {
167+
#update_existing_addon, #directory_selection, #create_new_addon, #jsonCreator, #gmaPrep, #addonjsonPrompt, #addon_management_prompt, #createGMA, #uploadToWorkshopPrompt, #addonIconPrompt {
168168
display: none;
169169
}
170170

@@ -252,9 +252,6 @@ header {
252252
padding: 5px;
253253
}
254254

255-
#jsonTags, #jsonTitle, #jsonType, #jsonIgnore {
256-
}
257-
258255
#jsonTags .type > * {
259256
display: inline-block;
260257
}

src/js/script.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ currentNewAddon = "";
1515
jsonCheckboxCount = 0;
1616
jsonChecks = [false, false];
1717
apiError = 0;
18+
addonGMADir = "";
1819
var addonTitle;
1920
var addonTags;
2021
var addonType;
22+
addonIcon = "";
2123
addonToCreateData = {
2224
"title": "",
2325
"type": "",
@@ -133,6 +135,26 @@ $(document).ready(() => {
133135
$('#addonDirCheck').css('cursor', 'pointer');
134136
})
135137

138+
$('#addon_icon').change(() => {
139+
addonIcon = document.getElementById("addon_icon").files[0].path;
140+
ipcRenderer.send('checkIfDirectoryExists', addonIcon);
141+
var jpegCheck = addonIcon.substring(addonIcon.length - 4);
142+
console.log(jpegCheck)
143+
if (jpegCheck == "jpeg" || jpegCheck == ".jpg") {
144+
$('#addonIconCheck').css('background-color', '#56bd56');
145+
$('#addonIconCheck').prop('disabled', false);
146+
$('#addonIconCheck').css('cursor', 'pointer');
147+
win.setBounds({
148+
height: 350
149+
})
150+
} else {
151+
$('#addonIconCheck').css('background-color', '#0f0f0f');
152+
$('#addonIconCheck').prop('disabled', true);
153+
$('#addonIconCheck').css('cursor', 'not-allowed');
154+
alert("Doesn't seem like a JPEG image.")
155+
}
156+
})
157+
136158
$('#dir_prompt_next button').click(() => {
137159
$('#directory_selection').fadeOut(() => {
138160
$('#addon_management').fadeIn();
@@ -321,5 +343,24 @@ $(document).ready(() => {
321343

322344
// Hide any div that may still be displayed
323345
$('#addonjsonPrompt, #jsonCreator, #gmaPrep, #createGMA').css('display', 'none');
346+
});
347+
348+
$("#createGMAFile").click(() => {
349+
$('#gmaPrep').fadeOut(() => {
350+
$('#createGMA').fadeIn();
351+
ipcRenderer.send('createGMAFile', currentNewAddon);
352+
});
353+
})
354+
355+
$("#uploadCurrentGMA").click(() => {
356+
ipcRenderer.send('uploadToWorkshop', addonGMADir, addonIcon);
324357
})
358+
359+
ipcRenderer.on('addonGMALocation', (event, addonGMA) => {
360+
addonGMADir = addonGMA;
361+
$('#createGMA').fadeOut(() => {
362+
$("#uploadToWorkshopPrompt").fadeIn();
363+
})
364+
})
365+
325366
});

0 commit comments

Comments
 (0)