Skip to content

Commit

Permalink
Added option to show/hide pause button (issue #84)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aioros committed Aug 13, 2024
1 parent c4409d0 commit 882942e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/config/TouchSettings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {MODULE_NAME, MODULE_DISPLAY_NAME} from './ModuleConstants.js'
import {updateButtonSize} from '../tools/EnlargeButtonsTool'
import {toggleUtilityControls} from '../tools/UtilityControls.js'

export const CORE_FUNCTIONALITY = "core"

Expand All @@ -14,6 +15,8 @@ export const DIRECTIONAL_ARROWS_ON = "on"

export const LARGE_BUTTONS_SETTING = "largeButtons"

export const PAUSE_BUTTON_SETTING = "pauseButton"

export const EASY_TARGET_SETTING = "easyTarget"
export const EASY_TARGET_OFF = "off"
export const EASY_TARGET_SINGLE = "single"
Expand Down Expand Up @@ -196,6 +199,20 @@ export function registerTouchSettings() {
default: "override_off",
})

game.settings.register(MODULE_NAME, PAUSE_BUTTON_SETTING + "_override", {
name: "Show a play/pause button",
hint: "Adds a play/pause button to the UI controls",
scope: "world",
config: false,
type: String,
choices: {
["on"]: "On",
["off"]: "Off",
["override_off"]: "Don't override"
},
default: "override_off",
})

// Client settings

game.settings.register(MODULE_NAME, CORE_FUNCTIONALITY, {
Expand Down Expand Up @@ -287,6 +304,16 @@ export function registerTouchSettings() {
onChange: enabled => updateButtonSize(enabled),
})

game.settings.register(MODULE_NAME, PAUSE_BUTTON_SETTING, {
name: "Show a play/pause button" + (game.settings.get(MODULE_NAME, PAUSE_BUTTON_SETTING + "_override") == "override_off" ? "" : " *"),
hint: "Adds a play/pause button to the UI controls",
scope: "client",
config: true,
type: Boolean,
default: true,
onChange: enabled => toggleUtilityControls(enabled),
})

game.settings.register(MODULE_NAME, DEBUG_MODE_SETTING, {
name: "Enable Debug Mode",
hint: "Sends additional log messages to the developer console",
Expand Down
9 changes: 8 additions & 1 deletion src/tools/UtilityControls.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import {getSetting, PAUSE_BUTTON_SETTING} from '../config/TouchSettings'

export function installUtilityControls() {
$("#touch-vtt-controls").remove()

var controls = $("<div>")
const controls = $("<div>")
.attr("id", "touch-vtt-controls")
controls.toggleClass("hidden", !getSetting(PAUSE_BUTTON_SETTING))

// Pause button (GM only)
if (game.user.isGM) {
Expand All @@ -21,4 +24,8 @@ export function installUtilityControls() {
}

$("#controls").prepend(controls)
}

export function toggleUtilityControls(enabled) {
$("#touch-vtt-controls").toggleClass("hidden", !enabled)
}
4 changes: 4 additions & 0 deletions style/touch-vtt.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
width: 100%;
}

#touch-vtt-controls.hidden {
display: none;
}

#touch-vtt-controls button {
line-height: 18px;
font-size: var(--font-size-10);
Expand Down

0 comments on commit 882942e

Please sign in to comment.