Skip to content

Commit

Permalink
Monks scene navigation compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
saif-ellafi committed Apr 23, 2021
1 parent bce7f1f commit 4d9b0b9
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 51 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 0.8.3
* Compatibility: Monks Scene Navigation thanks to a contribution from ironmonk88
* Bugfix: Disabled scene preview animation for better compatibility and less strange behaviour
* Bugfix: Adjusted position of active tokens indicators in list navigation based on navigation size
* Bugfix: Adjusted spacing for scene previous based on navigation size

### 0.8.2
* Localization: Gracias a @lozalojo por Minimal UI en Español!!!
* Localization: Fixed english missing texts
Expand Down
6 changes: 3 additions & 3 deletions 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 allows customizing Foundry interface, by hiding, collapsing or resizing specific parts.",
"version": "0.8.2",
"version": "0.8.3",
"minimumCoreVersion": "0.7.9",
"compatibleCoreVersion": "0.7.9",
"dependencies": [
Expand All @@ -25,6 +25,6 @@
}
],
"url": "https://github.com/saif-ellafi/foundryvtt-minimal-ui.git",
"manifest": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/download/0.8.2/module.json",
"download": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/download/0.8.2/foundryvtt-minimal-ui_0.8.2.zip"
"manifest": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/latest/download/module.json",
"download": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/latest/download/foundryvtt-minimal-ui_0.8.3.zip"
}
100 changes: 58 additions & 42 deletions modules/component/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,50 @@ export default class MinimalUINavigation {
target.click();
}
}

static prepareScenePreview(i, sceneTab, sceneId) {
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}' alt="Scene Preview">
</div>
`
);
$(sceneTab).hover(
function() {
if (!$(sceneTab).hasClass('view')) {
const minimized = game.settings.get('minimal-ui', 'organizedMinimize');
$(`#hover_preview_${i}`).show();
if (['top', 'topBar'].includes(minimized)) {
$("#minimized-bar")?.hide();
$(".minimized").hide();
}
}
},
function() {
if (!$(sceneTab).hasClass('view')) {
const minimized = game.settings.get('minimal-ui', 'organizedMinimize');
$(`#hover_preview_${i}`).hide();
if (['top', 'topBar'].includes(minimized)) {
const minimized = $(".minimized");
if (minimized.length > 0) {
$("#minimized-bar")?.show();
minimized.show();
}
}
}
}
);
}
}
}

static initSettings() {

Expand Down Expand Up @@ -102,12 +146,14 @@ export default class MinimalUINavigation {
case 'standard': {
rootStyle.setProperty('--navilh', '32px');
rootStyle.setProperty('--navifs', '16px');
rootStyle.setProperty('--navilisttop', '24px');
rootStyle.setProperty('--navibuttonsize', '34px');
break;
}
case 'big': {
rootStyle.setProperty('--navilh', '40px');
rootStyle.setProperty('--navifs', '20px');
rootStyle.setProperty('--navilisttop', '30px');
rootStyle.setProperty('--navibuttonsize', '43px');
break;
}
Expand All @@ -120,51 +166,21 @@ export default class MinimalUINavigation {
switch(game.settings.get('minimal-ui', 'sceneNavigationPreview')) {
case 'hover': {
if (game.user.isGM) {
// Compatibility: Includes class type scene list for compatibility with Monks Scene Navigation
let sceneTabs = $("#scene-list li,.scene-list li");
rootStyle.setProperty('--navithumbmarg', '10px');
if (game.modules.get('monks-scene-navigation')?.active) {
if (game.settings.get('minimal-ui', 'sceneNavigationSize') === 'small')
rootStyle.setProperty('--navithumbmarg', '15px');
else if (game.settings.get('minimal-ui', 'sceneNavigationSize') === 'standard')
rootStyle.setProperty('--navithumbmarg', '26px');
else
rootStyle.setProperty('--navithumbmarg', '32px');
} else {
rootStyle.setProperty('--navithumbmarg', '10px');
}
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}' alt="Scene Preview">
</div>
`
);
$(sceneTab).hover(
function() {
if (!$(sceneTab).hasClass('view')) {
const minimized = game.settings.get('minimal-ui', 'organizedMinimize');
$(`#hover_preview_${i}`).show(200);
if (['top', 'topBar'].includes(minimized)) {
$("#minimized-bar")?.hide();
$(".minimized").hide();
}
}
},
function() {
if (!$(sceneTab).hasClass('view')) {
const minimized = game.settings.get('minimal-ui', 'organizedMinimize');
$(`#hover_preview_${i}`).fadeOut(10);
if (['top', 'topBar'].includes(minimized)) {
const minimized = $(".minimized");
if (minimized.length > 0) {
$("#minimized-bar")?.show();
minimized.show();
}
}
}
}
);
}
}
MinimalUINavigation.prepareScenePreview(i, sceneTab, sceneId);
});
}
break;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "foundryvtt-minimal-ui",
"version": "0.8.2",
"version": "0.8.3",
"description": "Minimal UI allows customizing Foundry interface, by hiding, collapsing or resizing specific parts.",
"main": "minimalui.js",
"scripts": {
Expand Down
15 changes: 10 additions & 5 deletions styles/component/navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
--navixpos: 125px;
--navilh: 20px;
--navifs: 14px;
--navilisttop: 16px;
--navibuttonsize: 23px;
--navithumbmarg: 10px;
}
Expand All @@ -23,7 +24,7 @@
}

#navigation #scene-list .scene ul.scene-players {
top: 16px;
top: var(--navilisttop);
}

#navigation #scene-list .scene.view, #navigation #scene-list .scene.context {
Expand All @@ -42,6 +43,8 @@
box-shadow: 0 0 var(--shadowstrength) var(--shadowcolor);
}

/** COMPATIBILITY: Monks Scene Navigation */

#navigation .monks-scene-navigation{
flex: 0 0 var(--navilh);
height: var(--navilh);
Expand All @@ -55,15 +58,15 @@
line-height: var(--navilh);
height: var(--navilh);
font-size: var(--navifs);
padding:0px 4px;
padding:0 4px;
}

#navigation .monks-scene-navigation .scene-list > li.nav-item ul.scene-players{
top:16px;
top: var(--navilisttop);
}

#navigation .monks-scene-navigation .scene-list > li.nav-item.folder a{
padding-top:0px;
padding-top:0;
border-top:1px;
}

Expand All @@ -77,4 +80,6 @@

#navigation .monks-scene-navigation .scene-list > li.nav-item .navi-preview{
top: calc(var(--navithumbmarg) + 15px);
}
}

/** --------------- */

0 comments on commit 4d9b0b9

Please sign in to comment.