Skip to content

Commit

Permalink
dndui support and gm only thumb previews
Browse files Browse the repository at this point in the history
  • Loading branch information
saif-ellafi committed Mar 27, 2021
1 parent bd57e1c commit 0ef8cbf
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 38 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 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)

### 0.4.3
* Compatibility: SWADE Bennies should always show on visible players list (Thanks SalieriC)
* Bugfix: Scene thumbnail preview is now only valid for GMs (Thanks CasualTerror)
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ This includes hiding Foundry's Logo, Players List, Scene Navigation and Macro Ba
* Left controls may be moved vertically and set behavior to auto-hidden
* Colors of borders and shadows and their strength customizeable

## Support with Systems and Modules
MinimalUI is made as agnostic as possible. Yet, it is impossible to ensure maximum compatibility.
I invite you to share any systems or modules that conflict with MinimalUI or do not look correctly.
Also do share systems and modules Minimal UI already works with too!
### So far, these are systems I tested and explicitly Supported:
* DnD 5e
* Savage Worlds
* Dark Heresy
### So far, these are modules I tested and explicitly Supported:
* DnD-UI
* Bullseye
* Custom Hotbar
* Quick Insert / Search Anywhere
* Simple Dice Roller

## Appreciations
* Thanks to ardittristan for the awesome color settings module. The module can be optionally separately installed.
https://github.com/ardittristan/VTTColorSettings
Expand Down
3 changes: 2 additions & 1 deletion minimalui.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
--playervis: hidden;
--playerfsize: 0px;
--playerwidth: 25px;
--playerwidthhv: 150px;
--playerslh: 20px;
--playerbennies: none;

Expand Down Expand Up @@ -98,7 +99,7 @@
/** PLAYERS LIST **/

#players:hover {
width: 150px;
width: var(--playerwidthhv);
font-size: 12px;
}

Expand Down
119 changes: 83 additions & 36 deletions minimalui.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class MinimalUI {

static cssLeftBarSubMenuSmall = '50px';
static cssLeftBarSubMenuStandard = '60px';
static cssLeftBarSubMenuDndUi = '65px';

static cssLeftBarPaddingDefault = '7px';
static cssLeftBarPaddingSmall = '30px';
Expand All @@ -30,6 +31,7 @@ class MinimalUI {

static cssHotbarLeftControlsLineHeight = '12px';
static cssHotbarRightControlsLineHeight = '20px';
static cssHotbarRightControlsLineHeightDnDUi = '10px';
static cssHotbarControlsAutoHideHeight = '120%';
static cssHotbarAutoHideHeight = '1px';
static cssHotbarControlsMargin = '-10px';
Expand All @@ -40,6 +42,7 @@ class MinimalUI {

static cssPlayersDefaultFontSize = '12px';
static cssPlayersDefaultWidth = '150px';
static cssPlayersDefaultWidthDnDUi = '200px';

static htmlHotbarLockButton =
`
Expand Down Expand Up @@ -67,6 +70,12 @@ class MinimalUI {
} else {
rootStyle.setProperty('--leftbarsubstart', MinimalUI.cssLeftBarSubMenuStandard);
}
// Special compatibility DnD-UI
if (game.modules.get("dnd-ui")) {
rootStyle.setProperty('--leftbarsubstart', MinimalUI.cssLeftBarSubMenuDndUi);
rootStyle.setProperty('--leftbarsubhover', MinimalUI.cssLeftBarSubMenuDndUi);
};
// ---
$("#sidebar-lock > i").removeClass("fa-lock-open");
$("#sidebar-lock > i").addClass("fa-lock");
} else if (unlock) {
Expand Down Expand Up @@ -316,15 +325,36 @@ Hooks.on('renderPlayerList', async function() {
case 'default': {
rootStyle.setProperty('--playerfsize', MinimalUI.cssPlayersDefaultFontSize);
rootStyle.setProperty('--playerwidth', MinimalUI.cssPlayersDefaultWidth);
rootStyle.setProperty('--playerbennies', 'inline');
rootStyle.setProperty('--playervis', 'visible');
// DnD UI Special Compatibility
if (game.modules.get("dnd-ui")) {
rootStyle.setProperty('--playerwidth', '200px');
}
// SWADE Special Compatibility
rootStyle.setProperty('--playerbennies', 'inline');
// ---
break;
}
case 'autohide': {
rootStyle.setProperty('--playervis', 'visible');
rootStyle.setProperty('--playerbennies', 'none');
rootStyle.setProperty('--playerslh', '2px');
// DnD UI Special Compatibility
if (game.modules.get("dnd-ui")) {
$("#players").css('border-image', 'none');
$("#players").css('border-color', 'black');
$("#players").hover(
function() {
$("#players").css('border-image', '');
$("#players").css('border-color', '');
},
function() {
$("#players").css('border-image', 'none');
$("#players").css('border-color', 'black');
}
);
}
// SWADE Special Compatibility
rootStyle.setProperty('--playerbennies', 'none');
if (game.system.data.name == 'swade') {
$("#players").hover(
function() {
Expand All @@ -335,9 +365,15 @@ Hooks.on('renderPlayerList', async function() {
}
);
};
// ---
break;
}
}
// DnD UI Special Compatibility
if (game.modules.get("dnd-ui")) {
rootStyle.setProperty('--playerwidthhv', '200px');
}
// ---
});

Hooks.on('renderSceneNavigation', async function() {
Expand All @@ -346,41 +382,43 @@ Hooks.on('renderSceneNavigation', async function() {

switch(game.settings.get('minimal-ui', 'sceneNavigationPreview')) {
case 'hover': {
let previewMargin = game.settings.get('minimal-ui', 'sceneNavigationPreviewMargin');
rootStyle.setProperty('--navithumbmarg', previewMargin + 'px');
let sceneTabs = $("#scene-list li");
sceneTabs.each(function(i, sceneTab) {
let sceneId = $(sceneTab).attr('data-scene-id');
if (sceneId) {
let sceneThumbUrl = game.scenes.get(sceneId).data.thumb;
if (sceneThumbUrl) {
new Image().src = sceneThumbUrl;
$(sceneTab).append(
`
<div style="position: fixed;">
<img
id="hover_preview_${i}"
class="navi-preview"
src='${sceneThumbUrl}'>
</img>
</div>
`
);
$(sceneTab).hover(
function() {
if (!$(sceneTab).hasClass('view')) {
$(`#hover_preview_${i}`).show(200);
}
},
function() {
if (!$(sceneTab).hasClass('view')) {
$(`#hover_preview_${i}`).fadeOut(50);
if (game.user.isGM) {
let sceneTabs = $("#scene-list li");
let previewMargin = game.settings.get('minimal-ui', 'sceneNavigationPreviewMargin');
rootStyle.setProperty('--navithumbmarg', previewMargin + 'px');
sceneTabs.each(function(i, sceneTab) {
let sceneId = $(sceneTab).attr('data-scene-id');
if (sceneId) {
let sceneThumbUrl = game.scenes.get(sceneId).data.thumb;
if (sceneThumbUrl) {
new Image().src = sceneThumbUrl;
$(sceneTab).append(
`
<div style="position: fixed;">
<img
id="hover_preview_${i}"
class="navi-preview"
src='${sceneThumbUrl}'>
</img>
</div>
`
);
$(sceneTab).hover(
function() {
if (!$(sceneTab).hasClass('view')) {
$(`#hover_preview_${i}`).show(200);
}
},
function() {
if (!$(sceneTab).hasClass('view')) {
$(`#hover_preview_${i}`).fadeOut(50);
}
}
}
);
);
}
}
}
});
});
};
break;
}
}
Expand Down Expand Up @@ -468,7 +506,13 @@ Hooks.once('renderSceneControls', async function() {
rootStyle.setProperty('--leftbarsubstart', MinimalUI.cssLeftBarSubMenuStandard);
rootStyle.setProperty('--leftbarsubhover', MinimalUI.cssLeftBarSubMenuStandard);
}

// Special compatibility DnD-UI
if (game.modules.get("dnd-ui")) {
rootStyle.setProperty('--leftbarsubstart', MinimalUI.cssLeftBarSubMenuDndUi);
rootStyle.setProperty('--leftbarsubhover', MinimalUI.cssLeftBarSubMenuDndUi);
};
// ---

switch(game.settings.get('minimal-ui', 'sidePanel')) {
case 'autohide': {
if (!MinimalUI.controlsLocked) {
Expand Down Expand Up @@ -536,6 +580,9 @@ Hooks.on('renderHotbar', async function() {
rootStyle.setProperty('--macrobarypos', MinimalUI.cssHotbarHidden);
rootStyle.setProperty('--macrobarlh1', MinimalUI.cssHotbarLeftControlsLineHeight);
rootStyle.setProperty('--macrobarlh2', MinimalUI.cssHotbarRightControlsLineHeight);
if (game.modules.get("dnd-ui")) {
rootStyle.setProperty('--macrobarlh2', MinimalUI.cssHotbarRightControlsLineHeightDnDUi);
}
rootStyle.setProperty('--macrobarmg', MinimalUI.cssHotbarControlsMargin);
rootStyle.setProperty('--macrobarhh', MinimalUI.cssHotbarControlsAutoHideHeight);
rootStyle.setProperty('--macrobarhv', MinimalUI.cssHotbarAutoHideHeight);
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.3",
"version": "0.4.4",
"minimumCoreVersion": "0.7.9",
"compatibleCoreVersion": "0.7.9",
"esmodules": [ "lib/colorsettings/colorSetting.js" ],
Expand Down

0 comments on commit 0ef8cbf

Please sign in to comment.