-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add setting to allow the default state of the terrain ruler toggle (r…
…esolves #24)
- Loading branch information
Showing
4 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
{ | ||
"terrain-ruler": { | ||
"terrainRuler": "Messe die Entfernung mit schwierigem Gelände" | ||
"terrainRuler": "Messe die Entfernung mit schwierigem Gelände", | ||
"settings": { | ||
"defaultToggleState": { | ||
"name": "Schalterzustand beim Start", | ||
"hint": "Definiert welchen Zustand der Terrain Ruler Schalter beim Start von Foundry haben soll", | ||
"choices": { | ||
"on": "An", | ||
"off": "Aus", | ||
"remember": "Letzten Zustand merken" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
{ | ||
"terrain-ruler": { | ||
"terrainRuler": "Measure Distance with Difficult Terrain" | ||
"terrainRuler": "Measure Distance with Difficult Terrain", | ||
"settings": { | ||
"defaultToggleState": { | ||
"name": "Default Toggle State", | ||
"hint": "The state of the terrian ruler toggle after joining the game", | ||
"choices": { | ||
"on": "On", | ||
"off": "Off", | ||
"remember": "Remember last state" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
export const settingsKey = "terrain-ruler"; | ||
|
||
export const DefaultToggleState = Object.freeze({ | ||
ON: 0, | ||
OFF: 1, | ||
REMEMBER: 2, | ||
}); | ||
|
||
export function registerSettings() { | ||
game.settings.register(settingsKey, "defaultToggleState", { | ||
name: "terrain-ruler.settings.defaultToggleState.name", | ||
hint: "terrain-ruler.settings.defaultToggleState.hint", | ||
scope: "client", | ||
config: true, | ||
type: Number, | ||
default: DefaultToggleState.ON, | ||
choices: { | ||
0: "terrain-ruler.settings.defaultToggleState.choices.on", | ||
1: "terrain-ruler.settings.defaultToggleState.choices.off", | ||
2: "terrain-ruler.settings.defaultToggleState.choices.remember", | ||
}, | ||
onChange: (value) => { | ||
if (value === DefaultToggleState.REMEMBER) | ||
game.settings.set(settingsKey, "lastToggleState", terrainRuler.active); | ||
}, | ||
}); | ||
|
||
game.settings.register(settingsKey, "lastToggleState", { | ||
scope: "client", | ||
config: false, | ||
type: Boolean, | ||
default: true, | ||
}); | ||
} | ||
|
||
export function getDefaultToggleState() { | ||
switch (game.settings.get(settingsKey, "defaultToggleState")) { | ||
case DefaultToggleState.ON: | ||
return true; | ||
case DefaultToggleState.OFF: | ||
return false; | ||
case DefaultToggleState.REMEMBER: | ||
return game.settings.get(settingsKey, "lastToggleState"); | ||
} | ||
} |