Skip to content

Commit

Permalink
Foundry logo customization
Browse files Browse the repository at this point in the history
  • Loading branch information
saif-ellafi committed Mar 27, 2021
1 parent 0ef8cbf commit 1c75260
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 0.4.5
* Enhancement: Foundry Logo can be optionally shown in small, standard size or hidden!
* Enhancement: Foundry Logo can be used to Toggle the UI - Including or not the Chat! (Thanks QuantumFunks)
* Enhancement: The Scene Navigation should adjust to optimize available space based on the Foundry Logo configuration (Thanks SalieriC)

### 0.4.4
* Compatibility: DnD-UI Module is now tested and supported
* Bugfix: Effectively this time thumbnail preview is only valid for GMs (Thanks CasualTerror)
Expand Down
6 changes: 5 additions & 1 deletion minimalui.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
:root {
--logovis: hidden;
--logoh: 50px;
--logow: 100px;

--navivis: hidden;
--navixpos: 75px;
--navixpos: 125px;
--navilh: 20px;
--navifs: 14px;
--navibuttonsize: 23px;
Expand Down Expand Up @@ -42,6 +44,8 @@

#logo {
visibility: var(--logovis);
height: var(--logoh);
width: var(--logow);
}

/** MACRO HOTBAR **/
Expand Down
123 changes: 118 additions & 5 deletions minimalui.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class MinimalUI {

static hiddenInterface = false;

static hotbarLocked = false;
static controlsLocked = false;
static cssControlsLastPos = '0px';
Expand Down Expand Up @@ -36,6 +38,9 @@ class MinimalUI {
static cssHotbarAutoHideHeight = '1px';
static cssHotbarControlsMargin = '-10px';

static cssSceneNavNoLogoStart = '5px';
static cssSceneNavSmallLogoStart = '75px';
static cssSceneNavStandardLogoStart = '125px';
static cssSceneNavBullseyeStart = '125px';

static cssMinimumMacroBarX = 170;
Expand All @@ -57,6 +62,30 @@ class MinimalUI {
target.click();
}
}

static hideAll(alsoChat) {
$('#logo').click(_ => {
if (!MinimalUI.hiddenInterface) {
if (alsoChat) {
$('#sidebar').hide();
};
$('#navigation').hide();
$('#controls').hide();
$('#players').hide();
$('#hotbar').hide();
MinimalUI.hiddenInterface = true;
} else {
if (alsoChat) {
$('#sidebar').show();
};
$('#navigation').show();
$('#controls').show();
$('#players').show();
$('#hotbar').show();
MinimalUI.hiddenInterface = false;
}
});
}

static lockControls(unlock) {
let rootStyle = document.querySelector(':root').style;
Expand Down Expand Up @@ -123,6 +152,40 @@ class MinimalUI {
}

Hooks.on('init', () => {

game.settings.register('minimal-ui', 'foundryLogoSize', {
name: "Foundry Logo Size",
hint: "Foundry logo visibility and size",
scope: 'world',
config: true,
type: String,
choices: {
"hidden": "Hide",
"small": "Small",
"standard": "Standard"
},
default: "hidden",
onChange: value => {
window.location.reload()
}
});

game.settings.register('minimal-ui', 'foundryLogoBehaviour', {
name: "Foundry Logo Behaviour",
hint: "Use the Foundry Logo to toggle visual elements (when visible, of course).",
scope: 'world',
config: true,
type: String,
choices: {
"toggleAll": "Logo toggles Hide ALL UI",
"toggleButChat": "Logo toggles Hide ALL UI except Chat"
},
default: "toggleButChat",
onChange: value => {
window.location.reload()
}
});

game.settings.register('minimal-ui', 'sceneNavigation', {
name: "Scene Navigation Style",
hint: "Customize scene navigation behaviour. Consider 'DF Scene Enhancement' when hidden.",
Expand Down Expand Up @@ -314,6 +377,43 @@ Hooks.on('init', () => {

Hooks.once('ready', async function() {

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

if (game.settings.get('minimal-ui', 'foundryLogoSize') != 'hidden') {
switch(game.settings.get('minimal-ui', 'foundryLogoBehaviour')) {
case 'toggleAll': {
MinimalUI.hideAll(true);
break;
}
case 'toggleButChat': {
MinimalUI.hideAll(false);
break;
}
}
}

switch(game.settings.get('minimal-ui', 'foundryLogoSize')) {
case 'small': {
rootStyle.setProperty('--logovis', 'visible');
rootStyle.setProperty('--navixpos', MinimalUI.cssSceneNavSmallLogoStart);
rootStyle.setProperty('--logoh', '25px');
rootStyle.setProperty('--logow', '50px');
break;
}
case 'standard': {
rootStyle.setProperty('--logovis', 'visible');
break;
}
}

// Compatibility Workaround for bullseye module
if (game.modules.has('bullseye') && game.modules.get('bullseye').active) {
rootStyle.setProperty('--navixpos', MinimalUI.cssSceneNavBullseyeStart);
rootStyle.setProperty('--logovis', 'visible');
rootStyle.setProperty('--logoh', '50px');
rootStyle.setProperty('--logow', '100px');
}

});

Hooks.on('renderPlayerList', async function() {
Expand Down Expand Up @@ -423,17 +523,30 @@ Hooks.on('renderSceneNavigation', async function() {
}
}

});

Hooks.once('renderSceneNavigation', async function() {

let rootStyle = document.querySelector(':root').style;
switch(game.settings.get('minimal-ui', 'foundryLogoSize')) {
case 'hidden': {
rootStyle.setProperty('--navixpos', MinimalUI.cssSceneNavNoLogoStart);
break;
}
case 'small': {
rootStyle.setProperty('--navixpos', MinimalUI.cssSceneNavSmallLogoStart);
break;
}
}

// Compatibility Workaround for bullseye module
if (game.modules.has('bullseye') && game.modules.get('bullseye').active) {
rootStyle.setProperty('--navixpos', MinimalUI.cssSceneNavBullseyeStart);
rootStyle.setProperty('--logovis', 'visible');
rootStyle.setProperty('--logoh', '50px');
rootStyle.setProperty('--logow', '100px');
}

});

Hooks.once('renderSceneNavigation', async function() {

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

switch(game.settings.get('minimal-ui', 'sceneNavigation')) {
case 'collapsed': {
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.4.4",
"version": "0.4.5",
"minimumCoreVersion": "0.7.9",
"compatibleCoreVersion": "0.7.9",
"esmodules": [ "lib/colorsettings/colorSetting.js" ],
Expand Down

0 comments on commit 1c75260

Please sign in to comment.