Skip to content

Commit

Permalink
Graphics: add option to hide top menu after quick save
Browse files Browse the repository at this point in the history
  • Loading branch information
themitosan committed May 31, 2023
1 parent e3380bd commit 2b5cf65
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion App/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ label {
Main divs
*/
.DIV_CHECKBOX {
margin: 14px 0px 14px 0px;
margin: 6px 0px 6px 0px;
}
.DIV_TITLE {
font-size: 16px;
Expand Down
7 changes: 6 additions & 1 deletion App/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<input type="button" title="Global Shortcut: Ctrl+Shift+S" value="Save Map" onclick="APP.options.saveMap();" class="BTN_OPTIONS">
<input type="button" value="Load Map" onclick="APP.options.loadMapFile();" class="BTN_OPTIONS">
<input type="button" title="Global Shortcut: Ctrl+F10" value="[F10] Reload Map" onclick="APP.options.loadLatestFile();" class="BTN_OPTIONS" id="BTN_MAP_RELOAD" disabled="disabled">
<input type="button" title="Global Shortcut: Ctrl+Del" value="[Del] Clear game saves" onclick="APP.options.delGameSaveFiles();" class="BTN_OPTIONS" id="BTN_DEL_GAME_SAVES" disabled="disabled">
<input type="button" title="Global Shortcut: Ctrl+Del" value="[Del] Clear game save" onclick="APP.options.delGameSaveFiles();" class="BTN_OPTIONS" id="BTN_DEL_GAME_SAVES" disabled="disabled">

<!-- Run config -->
<input type="button" value="App Setup" onclick="APP.options.getGamePath();" class="BTN_OPTIONS" id="BTN_SELECT_EXE"><br>
Expand All @@ -60,6 +60,11 @@
<label class="cursor-pointer" title="Set this checkbox active if you are playing BioRand mod." onclick="APP.tools.processCheckbox('CHECKBOX_isBioRand');"> - Is BioRand?</label>
</div>

<div class="DIV_CHECKBOX">
<input type="checkbox" id="CHECKBOX_hideTopMenu">
<label class="cursor-pointer" title="Set this checkbox active if you want hide top menu after save." onclick="APP.tools.processCheckbox('CHECKBOX_hideTopMenu');APP.options.togglehideTopMenuOnSave();"> - Hide top menu after quick-save</label>
</div>

<input type="button" value="[F1] About" onclick="APP.about();" class="BTN_OPTIONS">

<!-- Room types -->
Expand Down
6 changes: 6 additions & 0 deletions App/js/graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,12 @@ temp_GRAPHICS = {
var labelStatus = 'INACTIVE',
pos = APP.graphics.enabledDragList.indexOf('APP_MAP_CANVAS');

// Reset top menu size
if (APP.options.hideTopMenuOnSave === !1){
TMS.css('MENU_TOP', {'height': '30px'});
}

// Check enable canvas drag
switch (APP.graphics.enableCanvasDrag){

case !1:
Expand Down
29 changes: 28 additions & 1 deletion App/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,22 @@ temp_OPTIONS = {
*/
latestFile: '',
isMapLoading: !1,
hideTopMenuOnSave: !1,
adjustFontSizeTimeout: void 0,

/*
Functions
*/

// Toggle hide top menu on quick-save
togglehideTopMenuOnSave: function(){

// Set var data and save on localstorage
this.hideTopMenuOnSave = JSON.parse(document.getElementById('CHECKBOX_hideTopMenu').checked);
localStorage.setItem('hideTopMenu', APP.options.hideTopMenuOnSave);

},

// Adjust room font size
adjustFontSize: function(mode){

Expand Down Expand Up @@ -141,7 +151,7 @@ temp_OPTIONS = {
history: APP.graphics.addedMapHistory,
});

// Check if "is BioRand" is active
// Check if "is BioRand" option is active
var checkBioRand = document.getElementById('CHECKBOX_isBioRand').checked;
if (checkBioRand === !0){

Expand All @@ -166,10 +176,14 @@ temp_OPTIONS = {
APP.graphics.updatePlayerPos();

// Set message
TMS.css('MENU_TOP', {'height': '30px'});
var msg = document.getElementById('LABEL_mapDragStatus').innerHTML;
document.getElementById('LABEL_mapDragStatus').innerHTML = ' - Map file was updated successfully! (' + fileName + ')';
setTimeout(function(){
document.getElementById('LABEL_mapDragStatus').innerHTML = msg;
if (APP.options.hideTopMenuOnSave === !0){
TMS.css('MENU_TOP', {'height': '0px'});
}
}, 1700);

} catch (err) {
Expand All @@ -179,6 +193,11 @@ temp_OPTIONS = {

} else {

// Reset top menu
if (APP.options.hideTopMenuOnSave === !1){
TMS.css('MENU_TOP', {'height': '30px'});
}

// Open save dialog
APP.filemanager.saveFile({
ext: '.json',
Expand Down Expand Up @@ -319,6 +338,13 @@ temp_OPTIONS = {
document.getElementById('BTN_DEL_GAME_SAVES').disabled = '';
}

// Update hide top menu checkbox
if (localStorage.getItem('hideTopMenu') === null){
localStorage.setItem('hideTopMenu', APP.options.hideTopMenuOnSave);
}
this.hideTopMenuOnSave = JSON.parse(localStorage.getItem('hideTopMenu'));
document.getElementById('CHECKBOX_hideTopMenu').checked = this.hideTopMenuOnSave;

// Update canvas
TMS.css('APP_MAP_CANVAS', {'font-size': (this.settingsData.fontSize + 13) + 'px'});
document.getElementById('APP_STYLE').innerHTML = '.DIV_ROOM {padding: ' + (10 + this.settingsData.fontSize) + 'px;}';
Expand All @@ -329,6 +355,7 @@ temp_OPTIONS = {
saveSettings: function(){

try {
localStorage.setItem('hideTopMenu', APP.options.hideTopMenuOnSave);
APP.fs.writeFileSync(APP.tools.fixPath(APP.path.parse(process.execPath).dir) + '/Settings.json', JSON.stringify(this.settingsData), 'utf8');
} catch (err) {
window.alert('ERROR - Unable to save settings!\n' + err);
Expand Down

0 comments on commit 2b5cf65

Please sign in to comment.