Skip to content

Commit

Permalink
Fixed camera issues
Browse files Browse the repository at this point in the history
  • Loading branch information
saif-ellafi committed Oct 25, 2023
1 parent 6bc6d42 commit 331cb47
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 70 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 1.6.6
* Bugfix: Fixed several issues with Minimal UI when using Camera views
* Compatibility: Fixed player list overlapping with other mods in general

### 1.6.4
* Bugfix: Fixed an issue in Foundry that top buttons shadows are cut-off
* Bugfix: Fixed alternating colors when locking hotbar macros
Expand Down
6 changes: 3 additions & 3 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
}
],
"description": "Minimal UI allows customizing Foundry interface, by hiding, collapsing or resizing specific parts.",
"version": "1.6.5",
"version": "1.6.6",
"compatibility": {
"minimum": "10",
"verified": "11.305",
"verified": "11.313",
"maximum": "11"
},
"minimumCoreVersion": "10",
Expand Down Expand Up @@ -49,7 +49,7 @@
],
"url": "https://github.com/saif-ellafi/foundryvtt-minimal-ui.git",
"manifest": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/latest/download/module.json",
"download": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/download/1.6.5/foundryvtt-minimal-ui_1.6.5.zip",
"download": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/download/1.6.6/foundryvtt-minimal-ui_1.6.6.zip",
"readme": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/blob/main/README.md",
"license": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/blob/main/LICENSE.md",
"changelog": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/blob/main/CHANGELOG.md"
Expand Down
93 changes: 41 additions & 52 deletions modules/component/hotbar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {debouncedReload, rootStyle} from '../util.js';
import '../../styles/component/hotbar.css';
import MinimalUIPlayers from "./players";

export default class MinimalUIHotbar {

Expand All @@ -17,14 +18,7 @@ export default class MinimalUIHotbar {
static cssHotbarControlsMargin = '0px';
static cssHotbarCustomHotbarCompatHover = '10px';

static cssHotbarPlayerBottom = '-5px';
static cssHotbarPlayerBottomAdj = '60px'

static cssHotbarPlayerBottomWinTop = '1px';
static cssHotbarPlayerBottomAdjWinTop = '65px'

static cssHotbarPlayerBottomWinBottom = '33px'
static cssHotbarPlayerBottomAdjWinBottom = '95px'
static cssHotbarBottomWinBottom = '33px'

static htmlHotbarLockButton =
`
Expand All @@ -34,7 +28,7 @@ export default class MinimalUIHotbar {
`

static lockHotbar(unlock) {
if ((game.modules.get("custom-hotbar")?.active) || (game.modules.get('monks-hotbar-expansion')?.active))
if ((game.modules.get("custom-hotbar")?.active) || (game.modules.get('monks-hotbar-expansion')?.active) || (game.webrtc.mode > 0 && game.webrtc.settings.client.dockPosition === 'bottom'))
return;
const barLock = $("#bar-lock > i");
if (MinimalUIHotbar.hotbarLocked && unlock) {
Expand All @@ -54,76 +48,67 @@ export default class MinimalUIHotbar {
let availableWidth = canvas.app?.screen.width;
if (!availableWidth)
return;
let webtrcAdjust = 0;
if (game.webrtc.mode > 0)
webtrcAdjust = (ui.webrtc.hidden ? 0 : ui.webrtc.position.width)
else if (game.webrtc?.mode === 0 || ui.webrtc?.hidden)
if (game.modules.get('window-controls')?.active &&
game.settings.get('window-controls', 'organizedMinimize') === 'persistentTop')
rootStyle.setProperty('--playerbot', MinimalUIHotbar.cssHotbarPlayerBottomWinTop);
else if (game.modules.get('window-controls')?.active &&
game.settings.get('window-controls', 'organizedMinimize') === 'persistentBottom')
rootStyle.setProperty('--playerbot', MinimalUIHotbar.cssHotbarPlayerBottomWinBottom);
else
rootStyle.setProperty('--playerbot', MinimalUIHotbar.cssHotbarPlayerBottom);
else
if (game.modules.get('window-controls')?.active &&
game.settings.get('window-controls', 'organizedMinimize') === 'persistentTop')
rootStyle.setProperty('--playerbot', MinimalUIHotbar.cssHotbarPlayerBottomAdjWinTop);
else if (game.modules.get('window-controls')?.active &&
game.settings.get('window-controls', 'organizedMinimize') === 'persistentBottom')
rootStyle.setProperty('--playerbot', MinimalUIHotbar.cssHotbarPlayerBottomAdjWinBottom);
let webrtcAdjust = 0;
let webrtcVAdjust = 0;

if (game.webrtc.mode > 0 && !ui.webrtc.element.hasClass('hidden')) {
if (game.webrtc.settings.client.dockPosition === 'left')
webrtcAdjust = (ui.webrtc.hidden ? 0 : ui.webrtc.position.width)
if (game.webrtc.settings.client.dockPosition === 'bottom') {
webrtcVAdjust = 187;
}
}

const autoHideOrLock = !game.settings.get('minimal-ui', 'hotbar') === 'autohide' || ((game.webrtc.mode > 0 && game.webrtc.settings.client.dockPosition === 'bottom') ||
(game.modules.get('window-controls')?.active &&
game.settings.get('window-controls', 'organizedMinimize') === 'persistentBottom'));

if (game.modules.get('window-controls')?.active && autoHideOrLock)
if (game.settings.get('window-controls', 'organizedMinimize') === 'persistentBottom')
rootStyle.setProperty('--hotbarypos', webrtcVAdjust + 40 + 'px');
else if (game.settings.get('window-controls', 'organizedMinimize') === 'persistentTop')
rootStyle.setProperty('--hotbarypos', webrtcVAdjust + 5 + 'px');
else
rootStyle.setProperty('--playerbot', MinimalUIHotbar.cssHotbarPlayerBottomAdj);
rootStyle.setProperty('--hotbarypos', webrtcVAdjust + 'px');

switch (game.settings.get('minimal-ui', 'hotbarPosition')) {
case 'default': {
rootStyle.setProperty('--hotbarxpos', (330 - webtrcAdjust)+'px');
rootStyle.setProperty('--hotbarxpos', (330 + webrtcAdjust)+'px');
break;
}
case 'extremeLeft': {
if (
!(game.modules.get("custom-hotbar")?.active) &&
availableWidth >= 1200
) {
rootStyle.setProperty('--hotbarxpos', '8px');
if (!(game.modules.get('sidebar-macros')?.active && game.settings.get('sidebar-macros', 'hideMacroHotbar')))
if (game.modules.get('window-controls')?.active &&
game.settings.get('window-controls', 'organizedMinimize') === 'persistentTop')
rootStyle.setProperty('--playerbot', MinimalUIHotbar.cssHotbarPlayerBottomAdjWinTop);
else if (game.modules.get('window-controls')?.active &&
game.settings.get('window-controls', 'organizedMinimize') === 'persistentBottom')
rootStyle.setProperty('--playerbot', MinimalUIHotbar.cssHotbarPlayerBottomAdjWinBottom);
else
rootStyle.setProperty('--playerbot', MinimalUIHotbar.cssHotbarPlayerBottomAdj);
}
)
rootStyle.setProperty('--hotbarxpos', 8 + webrtcAdjust + 'px');
break;
}
case 'left': {
rootStyle.setProperty('--hotbarxpos', ((availableWidth / 2.5) - (availableWidth / 9) - (availableWidth / 9) - webtrcAdjust) + 'px');
rootStyle.setProperty('--hotbarxpos', ((availableWidth / 2.5) - (availableWidth / 9) - (availableWidth / 9) + webrtcAdjust) + 'px');
break;
}
case 'center': {
rootStyle.setProperty('--hotbarxpos', ((availableWidth / 2.5) - (availableWidth / 9) - webtrcAdjust) + 'px');
rootStyle.setProperty('--hotbarxpos', ((availableWidth / 2.5) - (availableWidth / 9) + webrtcAdjust) + 'px');
break;
}
case 'right': {
rootStyle.setProperty('--hotbarxpos', ((availableWidth / 2.5) - webtrcAdjust) + 'px');
rootStyle.setProperty('--hotbarxpos', ((availableWidth / 2.5) + webrtcAdjust) + 'px');
break;
}
case 'manual': {
rootStyle.setProperty('--hotbarxpos', (game.settings.get('minimal-ui', 'hotbarPixelPosition') - webtrcAdjust) + 'px');
rootStyle.setProperty('--hotbarxpos', (game.settings.get('minimal-ui', 'hotbarPixelPosition') + webrtcAdjust) + 'px');
break;
}
}

MinimalUIPlayers.positionPlayers();
}

static configureHotbar() {
if (game.modules.get('window-controls')?.active &&
game.settings.get('window-controls', 'organizedMinimize') === 'persistentBottom') {
rootStyle.setProperty('--hotbarypos', MinimalUIHotbar.cssHotbarPlayerBottomWinBottom);
rootStyle.setProperty('--hotbarhv', MinimalUIHotbar.cssHotbarPlayerBottomWinBottom);
} else if (game.settings.get('minimal-ui', 'hotbar') === 'autohide') {
const autoHideBlocked = (game.webrtc.mode > 0 && game.webrtc.settings.client.dockPosition === 'bottom') ||
(game.modules.get('window-controls')?.active &&
game.settings.get('window-controls', 'organizedMinimize') === 'persistentBottom');
if (game.settings.get('minimal-ui', 'hotbar') === 'autohide' && !autoHideBlocked) {
if (!(game.modules.get("custom-hotbar")?.active || game.modules.get('monks-hotbar-expansion')?.active)) {
rootStyle.setProperty('--hotbarypos', MinimalUIHotbar.cssHotbarHidden);
rootStyle.setProperty('--hotbarlh1', MinimalUIHotbar.cssHotbarLeftControlsLineHeight);
Expand Down Expand Up @@ -222,6 +207,10 @@ export default class MinimalUIHotbar {
}
});

Hooks.on('renderCameraViews', function() {
MinimalUIHotbar.positionHotbar();
})

Hooks.once('renderHotbar', function() {
const hotbarSetting = game.settings.get('minimal-ui', 'hotbar');
if (hotbarSetting === 'collapsed')
Expand Down
20 changes: 14 additions & 6 deletions modules/component/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ export default class MinimalUINavigation {
await ui.nav.collapse();
}

static positionNav() {
if (game.webrtc.mode > 0 && !ui.webrtc.element.hasClass('hidden'))
rootStyle.setProperty('--navixpos', MinimalUINavigation.cssSceneNavNoLogoStartRtc);
else if (game.system.id === 'sfrpg') // starfinder has something, ugly fix
rootStyle.setProperty('--navixpos', MinimalUINavigation.cssSceneNavNoLogoStartStarfinder);
else
rootStyle.setProperty('--navixpos', MinimalUINavigation.cssSceneNavNoLogoStart);
}

static initSettings() {

game.settings.register('minimal-ui', 'sceneNavigation', {
Expand Down Expand Up @@ -95,18 +104,17 @@ export default class MinimalUINavigation {

switch (game.settings.get('minimal-ui', 'foundryLogoSize')) {
case 'hidden': {
if (ui.webrtc?.rendered && game.webrtc.settings.client.dockPosition === 'left')
rootStyle.setProperty('--navixpos', MinimalUINavigation.cssSceneNavNoLogoStartRtc);
else if (game.system.id === 'sfrpg') // starfinder has something, ugly fix
rootStyle.setProperty('--navixpos', MinimalUINavigation.cssSceneNavNoLogoStartStarfinder);
else
rootStyle.setProperty('--navixpos', MinimalUINavigation.cssSceneNavNoLogoStart);
MinimalUINavigation.positionNav();
break;
}
}

});

Hooks.on('renderCameraViews', function () {
MinimalUINavigation.positionNav();
});

}

}
23 changes: 21 additions & 2 deletions modules/component/players.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {debouncedReload, rootStyle} from '../util.js';
import '../../styles/component/players.css';
import MinimalUIHotbar from "./hotbar";

export default class MinimalUIPlayers {

Expand All @@ -10,6 +9,9 @@ export default class MinimalUIPlayers {
static cssPlayersStandardFontSize = 'inherit';
static cssPlayersStandardWidth = '200px';

static cssHotbarPlayerBottom = 5;
static cssHotbarPlayerBottomAdj = 70;

static initSettings() {
game.settings.register('minimal-ui', 'playerList', {
name: game.i18n.localize("MinimalUI.PlayersBehaviourName"),
Expand Down Expand Up @@ -59,6 +61,24 @@ export default class MinimalUIPlayers {
}
}

static positionPlayers() {
if (!(game.modules.get('sidebar-macros')?.active && game.settings.get('sidebar-macros', 'hideMacroHotbar'))) {
let playerbot = 0;

if (!(game.settings.get('minimal-ui', 'hotbar') === 'hidden') && game.settings.get('minimal-ui', 'hotbarPosition') === 'extremeLeft')
playerbot = MinimalUIPlayers.cssHotbarPlayerBottomAdj;
else
playerbot = MinimalUIPlayers.cssHotbarPlayerBottom;

if (game.modules.get('window-controls')?.active &&
game.settings.get('window-controls', 'organizedMinimize') === 'persistentTop')
rootStyle.setProperty('--playerbot', (playerbot - 5) + 'px');
else
rootStyle.setProperty('--playerbot', playerbot + 'px');

}
}

static initHooks() {

Hooks.on('renderPlayerList', async function () {
Expand All @@ -72,7 +92,6 @@ export default class MinimalUIPlayers {
plSize = 'standard';
plSetting = 'default';
}
MinimalUIHotbar.positionHotbar();
}

switch (plSetting) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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": "1.6.5",
"version": "1.6.6",
"description": "Minimal UI allows customizing Foundry interface, by hiding, collapsing or resizing specific parts.",
"main": "minimalui.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion styles/component/hotbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
--hotbarxpos: 510px;
--hotbarlh1: 24px;
--hotbarlh2: 8px;
--hotbarhv: -5px;
--hotbarhv: var(--hotbarypos);
--hotbarmg: 0px;
--hotbarhh: 100%;
--hotbarshp: 0px;
Expand Down
5 changes: 2 additions & 3 deletions styles/component/players.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
--playerslh: 20px;
--playerbennies: none;
--playerh3w: unset;
--playerbot: -5px;
--playerbot: 5px;
--playerleft: -5px;
--playerpingdisplay: initial;
}

#players {
bottom: var(--playerbot);
margin-bottom: var(--playerbot);
left: var(--playerleft);
font-size: var(--playerfsize);
visibility: var(--playervis);
opacity: var(--opacity);
box-shadow: 0 var(--hotbarshp) var(--shadowstrength) 2px var(--shadowcolor);
position: fixed;
border: 1px solid var(--bordercolor);
}

Expand Down

0 comments on commit 331cb47

Please sign in to comment.