Skip to content

Commit

Permalink
achieved first upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Leeous committed May 4, 2019
1 parent d067ae3 commit 330c45d
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 11 deletions.
22 changes: 19 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ <h3>Addon creation</h3>
<input id="addon_dir_folder" class="real_select" type="file" webkitdirectory />
<p id="addonDir"><b></b></p>
<div class="next_prompt">
<button id="addonDirCheck" class="transition_button" data-divtoshow="#addonjsonPrompt" data-divtohide="#addonDirPrompt" data-resize="500, 175" disabled>Next</button>
<button id="addonDirCheck" class="transition_button" data-divtoshow="#addonIconPrompt" data-divtohide="#addonDirPrompt" data-resize="500, 250" disabled>Next</button>
</div>
</div>
<div id="addonIconPrompt">
<p>Please select an icon for your addon</p>
<button class="button_normal fake_select" data-buttonclick="#addon_icon">Choose Directory</button>
<input id="addon_icon" class="real_select" type="file"/>
<div class="next_prompt">
<button id="addonIconCheck" class="transition_button" data-divtoshow="#addonjsonPrompt" data-divtohide="#addonIconPrompt" data-resize="500, 175" disabled>Next</button>
</div>
</div>
<div id="addonjsonPrompt">
Expand Down Expand Up @@ -151,12 +159,20 @@ <h3>Addon creation</h3>
<div id="gmaPrep">
<p>Created <span style="font-weight: 700">addon.json</span>!</p>
<h3>Create GMA for uploading to the Workshop?</h3>
<button style="width: 200px;" class="button_normal transition_button" data-divtohide="" data-divtoshow="" data-resize="">Yes</button>
<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>
<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>
<button style="width: 150px;" id="createGMAFile" class="button_normal transition_button">Yes</button>
<!-- <img src="src/img/loading.gif" style="display: block; margin-left: auto; margin-right: auto; width: 64px;" alt=""> -->
</div>
<div id="createGMA">
<p>Creating GMA...</p>
<img src="src/img/loading.gif" style="width: 64px; display: block; margin-left: auto; margin-right: auto; margin-top: 35px;" alt="">
</div>
<div id="uploadToWorkshopPrompt">
<p>Upload to the Workshop?</p>
<button class="button_normal">No</button>
<button id="uploadCurrentGMA" class="button_normal">Yes</button>
</div>

</div>
</div>
</div>
Expand Down
26 changes: 22 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,26 @@ ipcMain.on('createJsonFile', (event, json, dir) => {
})
})

// ipcMain.on('createGmaFile', (addonDir) => {
// // var gmaLocation = addonDir +
// })
ipcMain.on('createGMAFile', (event, addonDir) => {
console.log("Addon's Directory: " + addonDir.toString())
const gmad = spawn(settings.get('gmodDirectory') + '\\bin\\gmad.exe', ['create', '-folder', addonDir]);
gmad.stdout.on('data', (data) => {
var arrayOfOutput = data.toString().split('\n')
var fixedArray = arrayOfOutput.slice(arrayOfOutput.length - 2, arrayOfOutput.length - 1)
fixedArray = fixedArray[0].match(/(?:"[^"]*"|^[^"]*$)/)[0].replace(/"/g, "")
var addonGMADir = fixedArray;
console.log("GMA location: " + addonGMADir);
mainWindow.webContents.send('addonGMALocation', addonGMADir);
})
})

ipcMain.on('uploadToWorkshop', (event, gmaDir, iconDir) => {
const gmpublish = spawn(settings.get('gmodDirectory') + '\\bin\\gmpublish.exe', ['create', '-icon', iconDir, '-addon', gmaDir]);
gmpublish.stdout.on('data', (data) => {
console.log(data.toString());
})
})



// function
// gmpublish.exe create -icon path/to/image512x512.jpg -addon path/to/gma.gma
5 changes: 1 addition & 4 deletions src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ header {
text-align: center;
}

#update_existing_addon, #directory_selection, #create_new_addon, #jsonCreator, #gmaPrep, #addonjsonPrompt, #addon_management_prompt {
#update_existing_addon, #directory_selection, #create_new_addon, #jsonCreator, #gmaPrep, #addonjsonPrompt, #addon_management_prompt, #createGMA, #uploadToWorkshopPrompt, #addonIconPrompt {
display: none;
}

Expand Down Expand Up @@ -252,9 +252,6 @@ header {
padding: 5px;
}

#jsonTags, #jsonTitle, #jsonType, #jsonIgnore {
}

#jsonTags .type > * {
display: inline-block;
}
Expand Down
41 changes: 41 additions & 0 deletions src/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ currentNewAddon = "";
jsonCheckboxCount = 0;
jsonChecks = [false, false];
apiError = 0;
addonGMADir = "";
var addonTitle;
var addonTags;
var addonType;
addonIcon = "";
addonToCreateData = {
"title": "",
"type": "",
Expand Down Expand Up @@ -133,6 +135,26 @@ $(document).ready(() => {
$('#addonDirCheck').css('cursor', 'pointer');
})

$('#addon_icon').change(() => {
addonIcon = document.getElementById("addon_icon").files[0].path;
ipcRenderer.send('checkIfDirectoryExists', addonIcon);
var jpegCheck = addonIcon.substring(addonIcon.length - 4);
console.log(jpegCheck)
if (jpegCheck == "jpeg" || jpegCheck == ".jpg") {
$('#addonIconCheck').css('background-color', '#56bd56');
$('#addonIconCheck').prop('disabled', false);
$('#addonIconCheck').css('cursor', 'pointer');
win.setBounds({
height: 350
})
} else {
$('#addonIconCheck').css('background-color', '#0f0f0f');
$('#addonIconCheck').prop('disabled', true);
$('#addonIconCheck').css('cursor', 'not-allowed');
alert("Doesn't seem like a JPEG image.")
}
})

$('#dir_prompt_next button').click(() => {
$('#directory_selection').fadeOut(() => {
$('#addon_management').fadeIn();
Expand Down Expand Up @@ -321,5 +343,24 @@ $(document).ready(() => {

// Hide any div that may still be displayed
$('#addonjsonPrompt, #jsonCreator, #gmaPrep, #createGMA').css('display', 'none');
});

$("#createGMAFile").click(() => {
$('#gmaPrep').fadeOut(() => {
$('#createGMA').fadeIn();
ipcRenderer.send('createGMAFile', currentNewAddon);
});
})

$("#uploadCurrentGMA").click(() => {
ipcRenderer.send('uploadToWorkshop', addonGMADir, addonIcon);
})

ipcRenderer.on('addonGMALocation', (event, addonGMA) => {
addonGMADir = addonGMA;
$('#createGMA').fadeOut(() => {
$("#uploadToWorkshopPrompt").fadeIn();
})
})

});

0 comments on commit 330c45d

Please sign in to comment.