Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Planet z-index #246

Merged
merged 4 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## In progress

- Derelict/vault/settlement token images ([#244](https://github.com/ben/foundry-ironsworn/pull/244))
- Ensure planets are drawn behind their neighbors ([#246](https://github.com/ben/foundry-ironsworn/pull/246))

## 1.10.28

Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { activateChangelogListeners } from './module/features/changelog'
import { maybePromptForDependencies } from './module/features/dependencies'
import { activateDragDropListeners } from './module/features/dragdrop'
import { activateSceneButtonListeners } from './module/features/sceneButtons'
import { registerZIndexHook } from './module/features/z-index'
import { IronswornHandlebarsHelpers } from './module/helpers/handlebars'
import { runDataMigrations } from './module/helpers/migrations'
import { IronswornSettings } from './module/helpers/settings'
Expand Down Expand Up @@ -164,6 +165,7 @@ Hooks.once('init', async () => {
IronswornHandlebarsHelpers.registerHelpers()
IronswornChatCard.registerHooks()
activateSceneButtonListeners()
registerZIndexHook()
})

Hooks.once('ready', async () => {
Expand Down
8 changes: 5 additions & 3 deletions src/module/features/dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
export async function maybePromptForDependencies() {
const dlopen = game.modules.get('dlopen')
const vueport = game.modules.get('vueport')
const libwrapper = game.modules.get('lib-wrapper')

const gm = game.user?.isGM
const prompt = true // TODO: game.settings.get('archmage', 'dependencyPrompt')

// If the modules don't exist, warn the user.
if (!dlopen || !vueport) {
if (!dlopen || !vueport || !libwrapper) {
if (gm) {
ui.notifications?.error('This system requires the dlopen and vueport modules to be installed.')
}
} else {
// If the modules exist but aren't enabled, prompt the user.
if ((dlopen && !dlopen.active) || (vueport && !vueport.active)) {
if (!dlopen.active || !vueport.active || !libwrapper.active) {
if (prompt && gm) {
Dialog.confirm({
title: 'Enable dependencies?', // TODO: game.i18n.format('ARCHMAGE.UI.enableDependencies'),
content: 'This system requires the VuePort and dlopen modules to be enabled. Would you like to enable them now?', // TODO: game.i18n.format('ARCHMAGE.UI.dependencyContent'),
content: 'This system requires the VuePort, dlopen, and libwrapper modules to be enabled. Would you like to enable them now?', // TODO: game.i18n.format('ARCHMAGE.UI.dependencyContent'),
yes: async () => {
const moduleSettings = game.settings.get('core', 'moduleConfiguration') as any
moduleSettings['dlopen'] = true
moduleSettings['vueport'] = true
moduleSettings['lib-wrapper'] = true
await game.settings.set('core', 'moduleConfiguration', moduleSettings)
window.location.reload()
},
Expand Down
11 changes: 11 additions & 0 deletions src/module/features/z-index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

function fixZIndex(wrapped, ...args) {
wrapped(...args)
if (this.actor?.type === 'location' && this.actor?.data.data.subtype === 'planet') {
this.zIndex -= 100
}
}

export function registerZIndexHook() {
global.libWrapper.register('foundry-ironsworn', 'Token.prototype.refresh', fixZIndex, 'WRAPPER')
}
5 changes: 5 additions & 0 deletions system/system.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
"name": "vueport",
"type": "module",
"manifest": "https://raw.githubusercontent.com/ForgeVTT/fvtt-module-vueport/master/module.json"
},
{
"name": "lib-wrapper",
"type": "module",
"manifest": "https://github.com/ruipin/fvtt-lib-wrapper/releases/latest/download/module.json"
}
],
"packs": [
Expand Down