Skip to content

Commit

Permalink
Configuration fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
saif-ellafi committed Apr 18, 2021
1 parent 0ae0912 commit 1cb5f39
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 36 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.6.1
* Bugfix: Added missing hotbar configurations (Default and Manual). Thanks GametTV
* Bugfix: Fixed wrong default value (Right sidebar should default to shown, not collapsed)

### 0.6.0
* Enhancement: NEW (Optional) Dynamic Minimal UI mode. After 60 seconds of inactivity,
UI will dynamically auto-hide until used or when switching Scenes. Check it out! (Experimental)
Expand Down
97 changes: 62 additions & 35 deletions minimalui.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ class MinimalUI {
let rootStyle = document.querySelector(':root').style;
let availableWidth = parseInt($("#board").css('width'));
switch(game.settings.get('minimal-ui', 'macroBarPosition')) {
case 'default': {
rootStyle.setProperty('--macrobarxpos', '220px');
break;
}
case 'left': {
rootStyle.setProperty('--macrobarxpos', ((availableWidth/2.5)-(availableWidth/9)-(availableWidth/9))+'px');
break;
Expand All @@ -158,6 +162,45 @@ class MinimalUI {
rootStyle.setProperty('--macrobarxpos', ((availableWidth/2.5))+'px');
break;
}
case 'manual': {
rootStyle.setProperty('--macrobarxpos', game.settings.get('minimal-ui', 'macroBarPixelPosition')+'px');
break;
}
}
}

static configureHotbar() {
let rootStyle = document.querySelector(':root').style;
switch(game.settings.get('minimal-ui', 'macroBar')) {
case 'collapsed': {
MinimalUI.collapseById("bar-toggle");
if (game.modules.has("custom-hotbar") && game.modules.get('custom-hotbar').active) {
MinimalUI.collapseById("custom-bar-toggle");
};
break;
}
case 'autohide': {
if (!(game.modules.has("custom-hotbar") && game.modules.get('custom-hotbar').active)) {
rootStyle.setProperty('--macrobarypos', MinimalUI.cssHotbarHidden);
rootStyle.setProperty('--macrobarlh1', MinimalUI.cssHotbarLeftControlsLineHeight);
rootStyle.setProperty('--macrobarlh2', MinimalUI.cssHotbarRightControlsLineHeight);
if (game.modules.get('dnd-ui') && game.modules.get('dnd-ui').active) {
rootStyle.setProperty('--macrobarlh2', MinimalUI.cssHotbarRightControlsLineHeightDnDUi);
}
rootStyle.setProperty('--macrobarmg', MinimalUI.cssHotbarControlsMargin);
rootStyle.setProperty('--macrobarhh', MinimalUI.cssHotbarControlsAutoHideHeight);
rootStyle.setProperty('--macrobarhv', MinimalUI.cssHotbarAutoHideHeight);
rootStyle.setProperty('--macrobarshp', MinimalUI.cssHotbarAutoHideShadow);
$("#hotbar-directory-controls").append(MinimalUI.htmlHotbarLockButton);
$("#macro-directory").click(function() {MinimalUI.lockHotbar(false)});
$("#bar-lock").click(function() {MinimalUI.lockHotbar(true)});
if (MinimalUI.hotbarLocked) {
MinimalUI.lockHotbar(false);
}
}
$("#bar-toggle").remove();
break;
}
}
}

Expand Down Expand Up @@ -209,7 +252,7 @@ Hooks.once('init', () => {
default: "10",
type: String,
onChange: lang => {
window.location.reload()
rootStyle.setProperty('--shadowstrength', game.settings.get('minimal-ui', 'shadowStrength') + 'px');
}
});

Expand Down Expand Up @@ -289,7 +332,7 @@ Hooks.once('init', () => {
"shown": "Shown",
"collapsed": "Collapsed"
},
default: "collapsed",
default: "shown",
onChange: value => {
window.location.reload()
}
Expand Down Expand Up @@ -399,13 +442,27 @@ Hooks.once('init', () => {
config: true,
type: String,
choices: {
"default": "Foundry Default",
"left": "Center Left",
"center": "Center",
"right": "Center Right"
"right": "Center Right",
"manual": "Manual"
},
default: "center",
onChange: value => {
window.location.reload()
MinimalUI.positionHotbar();
}
});

game.settings.register('minimal-ui', 'macroBarPixelPosition', {
name: "Macro Bar Manual Pixel Position",
hint: `Horizontal position in pixels. If Macro Position is 'Manual'`,
scope: 'world',
config: true,
type: String,
default: "400",
onChange: value => {
MinimalUI.positionHotbar();
}
});

Expand Down Expand Up @@ -823,37 +880,7 @@ Hooks.on('renderHotbar', async function() {

let rootStyle = document.querySelector(':root').style;

switch(game.settings.get('minimal-ui', 'macroBar')) {
case 'collapsed': {
MinimalUI.collapseById("bar-toggle");
if (game.modules.has("custom-hotbar") && game.modules.get('custom-hotbar').active) {
MinimalUI.collapseById("custom-bar-toggle");
};
break;
}
case 'autohide': {
if (!(game.modules.has("custom-hotbar") && game.modules.get('custom-hotbar').active)) {
rootStyle.setProperty('--macrobarypos', MinimalUI.cssHotbarHidden);
rootStyle.setProperty('--macrobarlh1', MinimalUI.cssHotbarLeftControlsLineHeight);
rootStyle.setProperty('--macrobarlh2', MinimalUI.cssHotbarRightControlsLineHeight);
if (game.modules.get('dnd-ui') && game.modules.get('dnd-ui').active) {
rootStyle.setProperty('--macrobarlh2', MinimalUI.cssHotbarRightControlsLineHeightDnDUi);
}
rootStyle.setProperty('--macrobarmg', MinimalUI.cssHotbarControlsMargin);
rootStyle.setProperty('--macrobarhh', MinimalUI.cssHotbarControlsAutoHideHeight);
rootStyle.setProperty('--macrobarhv', MinimalUI.cssHotbarAutoHideHeight);
rootStyle.setProperty('--macrobarshp', MinimalUI.cssHotbarAutoHideShadow);
$("#hotbar-directory-controls").append(MinimalUI.htmlHotbarLockButton);
$("#macro-directory").click(function() {MinimalUI.lockHotbar(false)});
$("#bar-lock").click(function() {MinimalUI.lockHotbar(true)});
if (MinimalUI.hotbarLocked) {
MinimalUI.lockHotbar(false);
}
}
$("#bar-toggle").remove();
break;
}
}
MinimalUI.configureHotbar();

switch(game.settings.get('minimal-ui', 'macroBarSize')) {
case "slots_3": {
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Minimal UI",
"author": "JeansenVaars#2857",
"description": "Minimal UI reduces size of Foundry interface and allows hiding or collapsing specific parts.",
"version": "0.6.0",
"version": "0.6.1",
"minimumCoreVersion": "0.7.9",
"compatibleCoreVersion": "0.7.9",
"esmodules": [ "lib/colorsettings/colorSetting.js" ],
Expand Down

0 comments on commit 1cb5f39

Please sign in to comment.