Skip to content

Commit

Permalink
add an option to choose where to put magic item spells/feats on main …
Browse files Browse the repository at this point in the history
…character sheet
  • Loading branch information
PwQt committed Jun 26, 2024
1 parent fc795cd commit 8d6f552
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"MAGICITEMS.SettingScaleSpellDamageHint": "Some spells (like Acid Splash) have their damage scale with character levels, when this setting is on, the scaling will work",
"MAGICITEMS.SettingShowLeftChargesInChat": "Show charges left",
"MAGICITEMS.SettingShowLeftChargesInChatHint": "Shows the amount of charges left on item/spell in a chat message",
"MAGICITEMS.SettingDisplayMainSheetItem": "Item Display Location",
"MAGICITEMS.SettingDisplayMainSheetItemHint": "Where to display Magic Item Spells/Feats on their respective sheets (only for Main Sheet)",
"MAGICITEMS.SettingDisplayMainSheetItemBottom": "Bottom",
"MAGICITEMS.SettingDisplayMainSheetItemTop": "Top",
"MAGICITEMS.SheetActivation": "Activation Options",
"MAGICITEMS.SheetActivationEquipped": "Equipped",
"MAGICITEMS.SheetActivationAttuned": "Attuned",
Expand Down
14 changes: 14 additions & 0 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ Hooks.once("init", () => {
config: true,
});

game.settings.register(CONSTANTS.MODULE_ID, "optionDisplayMainSheetItems", {
name: "MAGICITEMS.SettingDisplayMainSheetItem",
hint: "MAGICITEMS.SettingDisplayMainSheetItemHint",
scope: "client",
type: Number,
default: CONSTANTS.DISPLAY_OPTIONS.BOTTOM,
requiresReload: true,
choices: {
0: "MAGICITEMS.SettingDisplayMainSheetItemBottom",
1: "MAGICITEMS.SettingDisplayMainSheetItemTop",
},
config: true,
});

if (typeof Babele !== "undefined") {
Babele.get().register({
module: CONSTANTS.MODULE_ID,
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const CONSTANTS = {
WEIGHT_PROPERTY_PATH: "system.weight",
PRICE_PROPERTY_PATH: "system.price",
SPELL_LEVEL_PROPERTY_PATH: "system.level",
DISPLAY_OPTIONS: {
BOTTOM: 0,
TOP: 1,
},
};
CONSTANTS.PATH = `modules/${CONSTANTS.MODULE_NAME}/`;

Expand Down
8 changes: 7 additions & 1 deletion src/scripts/magicitemsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ export class MagicItemSheet {
if (el.length) {
el.replaceWith(template);
} else {
this.html.find(`.${tab} .${listName}`).append(template);
if (game.settings.get(CONSTANTS.MODULE_ID, "optionDisplayMainSheetItems") === CONSTANTS.DISPLAY_OPTIONS.BOTTOM) {
this.html.find(`.${tab} .${listName}`).append(template);
} else if (
game.settings.get(CONSTANTS.MODULE_ID, "optionDisplayMainSheetItems") === CONSTANTS.DISPLAY_OPTIONS.TOP
) {
this.html.find(`.${tab} .${listName}`).prepend(template);
}
}
}

Expand Down

0 comments on commit 8d6f552

Please sign in to comment.