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

feat: add settings divisions and tabs #1443

Merged
merged 6 commits into from
Aug 10, 2023
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
37 changes: 37 additions & 0 deletions src/module/handlebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,43 @@ export default function registerHandlebarsHelpers(): void {
}
});

Handlebars.registerHelper('twodsix_getSettingIcon', (componentType: string) => {
switch (componentType) {
case 'general':
return "fa-solid fa-gear";
case 'roll':
return "fa-solid fa-dice-six";
case 'characteristics':
return "fa-solid fa-clipboard-user";
case 'formulas':
return "fa-solid fa-calculator";
case 'damage':
return "fa-solid fa-burst";
case 'movement':
return "fa-solid fa-person-walking";
case 'encumbrance':
return "fa-solid fa-weight-scale";
case 'wounds':
return "fa-solid fa-user-injured";
case 'ship':
return "fa-solid fa-rocket";
case 'animals_robots':
return "fa-solid fa-ghost";
case 'weapon':
return "fa-solid fa-gun";
case 'token':
return "fa-solid fa-chess-pawn";
case 'actor':
return "fa-regular fa-person";
case "dragDrop":
return "fa-solid fa-square-caret-down";
case "style":
return "fa-solid fa-file-code";
default:
return "fa-solid fa-circle-question";
}
});

Handlebars.registerHelper('twodsix_showTimeframe', () => {
return game.settings.get('twodsix', 'showTimeframe');
});
Expand Down
44 changes: 27 additions & 17 deletions src/module/settings/AdvancedSettings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck This turns off *all* typechecking, make sure to remove this once foundry-vtt-types are updated to cover v10.

export default class AdvancedSettings extends FormApplication {
settings: string[];
static settings:string[];
settings: any;
static settings:any;

constructor(object, settings:string[], options?) {
constructor(object, settings:any, options?) {
super(object, options);
this.settings = settings;
}
Expand All @@ -12,26 +15,33 @@ export default class AdvancedSettings extends FormApplication {
return mergeObject(super.defaultOptions, {
classes: ["twodsix"],
template: "systems/twodsix/templates/misc/advanced-settings.html",
width: 600
tabs: [{navSelector: ".tabs", contentSelector: ".sheet-body", initial: "description"}],
resizable: true,
width: 675,
height: 'auto'
});
}

/** @override */
getData(): any {
const data: any = super.getData();
const settings = this.settings.map((settingName) => {
const setting: any = game.settings.settings.get("twodsix." + settingName);
setting.value = game.settings.get(setting.namespace ?? setting.module, settingName);
if (setting.choices === "Color") {
setting.htmlType = "Color";
} else if (setting.choices) {
setting.htmlType = "Select";
} else {
setting.htmlType = setting.type.name;
}
return [settingName, setting];
});
data.settings = Object.fromEntries(settings);
data.useTabbedViews = game.settings.get('twodsix', 'useTabbedViews');
data.settings = {};
for(const group in this.settings) {
const settings = this.settings[group].map((settingName) => {
const setting: any = game.settings.settings.get("twodsix." + settingName);
setting.value = game.settings.get(setting.namespace ?? setting.module, settingName);
if (setting.choices === "Color") {
setting.htmlType = "Color";
} else if (setting.choices) {
setting.htmlType = "Select";
} else {
setting.htmlType = setting.type.name;
}
return [settingName, setting];
});
data.settings[group] = Object.fromEntries(settings);
}
return data;
}

Expand Down
24 changes: 14 additions & 10 deletions src/module/settings/DebugSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@ export default class DebugSettings extends AdvancedSettings {
return data;
}

static registerSettings(): string[] {
const settings: string[] = [];
settings.push(booleanSetting('ExperimentalFeatures', false));
settings.push(stringSetting('systemMigrationVersion', game.system.version));
settings.push(booleanSetting('useModuleFixStyle', false, false, 'world', refreshWindow));
settings.push(booleanSetting('useShipAutoCalcs', false, false, 'world', refreshWindow));
settings.push(booleanSetting('useProseMirror', false));
settings.push(booleanSetting('allowDropOnIcon', false));
settings.push(booleanSetting('allowDragDropOfLists', false));
settings.push(booleanSetting('useItemActiveEffects', false, false, 'world', deactivateActorAE));
static registerSettings(): any {
const settings = {
general: [],
style: [],
dragDrop: []
};
settings.general.push(booleanSetting('ExperimentalFeatures', false));
settings.general.push(stringSetting('systemMigrationVersion', game.system.version));
settings.style.push(booleanSetting('useModuleFixStyle', false, false, 'world', refreshWindow));
settings.general.push(booleanSetting('useShipAutoCalcs', false, false, 'world', refreshWindow));
settings.style.push(booleanSetting('useProseMirror', false));
settings.dragDrop.push(booleanSetting('allowDropOnIcon', false));
settings.dragDrop.push(booleanSetting('allowDragDropOfLists', false));
settings.general.push(booleanSetting('useItemActiveEffects', false, false, 'world', deactivateActorAE));
return settings;
}
}
Expand Down
56 changes: 31 additions & 25 deletions src/module/settings/DisplaySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,38 @@ export default class DisplaySettings extends AdvancedSettings {
return data;
}

static registerSettings(): string[] {
static registerSettings(): any {

const settings: string[] = [];
settings.push(booleanSetting('defaultTokenSettings', true));
settings.push(booleanSetting('useSystemDefaultTokenIcon', false));
settings.push(booleanSetting('showSingleComponentColumn', false));
settings.push(booleanSetting('showBandwidth', false));
settings.push(booleanSetting('useFoundryStandardStyle', false, false, 'world', refreshWindow));
settings.push(booleanSetting('useWoundedStatusIndicators', false));
settings.push(booleanSetting('useEncumbranceStatusIndicators', false));
settings.push(booleanSetting('showWeightUsage', false));
settings.push(booleanSetting('usePDFPagerForRefs', false));
settings.push(booleanSetting('showIcons', false));
settings.push(booleanSetting('useEncumbrance', false));
settings.push(booleanSetting('showStatusIcons', true));
settings.push(booleanSetting('showRangeSpeedNoUnits', false));
settings.push(booleanSetting('showInitiativeButton', false));
settings.push(booleanSetting('showSkillCountsRanks', true));
settings.push(booleanSetting('showComponentSummaryIcons', false));
settings.push(booleanSetting('showSpells', false));
settings.push(booleanSetting('showModifierDetails', false));
settings.push(booleanSetting('showFeaturesInChat', false));
settings.push(colorSetting('defaultColor', "#29aae1", "Color", false, 'world', changeDefaultColor));
settings.push(colorSetting('lightColor', "#00e5ff", "Color", false, 'world', changeLightColor));
settings.push(booleanSetting('showHitsChangesInChat', false));
settings.push(booleanSetting('reduceStatusIcons', false, false, "world", updateStatusIcons));
const settings = {
general: [],
token: [],
actor: [],
ship: []
};
settings.token.push(booleanSetting('defaultTokenSettings', true));
settings.token.push(booleanSetting('useSystemDefaultTokenIcon', false));
settings.ship.push(booleanSetting('showSingleComponentColumn', false));
settings.ship.push(booleanSetting('showBandwidth', false));
settings.general.push(booleanSetting('useFoundryStandardStyle', false, false, 'world', refreshWindow));
settings.actor.push(booleanSetting('useWoundedStatusIndicators', false));
settings.actor.push(booleanSetting('useEncumbranceStatusIndicators', false));
settings.ship.push(booleanSetting('showWeightUsage', false));
settings.general.push(booleanSetting('usePDFPagerForRefs', false));
settings.actor.push(booleanSetting('showIcons', false));
settings.actor.push(booleanSetting('useEncumbrance', false));
settings.actor.push(booleanSetting('showStatusIcons', true));
settings.actor.push(booleanSetting('showRangeSpeedNoUnits', false));
settings.actor.push(booleanSetting('showInitiativeButton', false));
settings.actor.push(booleanSetting('showSkillCountsRanks', true));
settings.ship.push(booleanSetting('showComponentSummaryIcons', false));
settings.actor.push(booleanSetting('showSpells', false));
settings.general.push(booleanSetting('showModifierDetails', false));
settings.general.push(booleanSetting('showFeaturesInChat', false));
settings.general.push(colorSetting('defaultColor', "#29aae1", "Color", false, 'world', changeDefaultColor));
settings.general.push(colorSetting('lightColor', "#00e5ff", "Color", false, 'world', changeLightColor));
settings.general.push(booleanSetting('showHitsChangesInChat', false));
settings.token.push(booleanSetting('reduceStatusIcons', false, false, "world", updateStatusIcons));
settings.general.push(booleanSetting('useTabbedViews', false));
return settings;
}
}
Expand Down
27 changes: 14 additions & 13 deletions src/module/settings/ItemSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ export default class ItemSettings extends AdvancedSettings {
return data;
}

static registerSettings(): string[] {
const settings: string[] = [];
settings.push(booleanSetting('ShowLawLevel', false));
settings.push(booleanSetting('ShowRangeBandAndHideRange', false));
settings.push(booleanSetting('ShowWeaponType', false));
settings.push(booleanSetting('ShowDamageType', false));
settings.push(booleanSetting('ShowRateOfFire', true));
settings.push(booleanSetting('ShowRecoil', false));
settings.push(booleanSetting('ShowDoubleTap', false));
settings.push(booleanSetting('addEffectToManualDamage', false));
settings.push(booleanSetting('showComponentRating', true));
settings.push(booleanSetting('showComponentDM', true));
settings.push(booleanSetting('useTabbedViews', false));
static registerSettings(): any {
const settings = {
weapon: [],
ship: []
};
settings.weapon.push(booleanSetting('ShowLawLevel', false));
settings.weapon.push(booleanSetting('ShowRangeBandAndHideRange', false));
settings.weapon.push(booleanSetting('ShowWeaponType', false));
settings.weapon.push(booleanSetting('ShowDamageType', false));
settings.weapon.push(booleanSetting('ShowRateOfFire', true));
settings.weapon.push(booleanSetting('ShowRecoil', false));
settings.weapon.push(booleanSetting('ShowDoubleTap', false));
settings.ship.push(booleanSetting('showComponentRating', true));
settings.ship.push(booleanSetting('showComponentDM', true));
return settings;
}
}
111 changes: 61 additions & 50 deletions src/module/settings/RulsetSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,61 +30,72 @@ export default class RulesetSettings extends AdvancedSettings {
return data;
}

static registerSettings(): string[] {
static registerSettings(): any {
const DEFAULT_INITIATIVE_FORMULA = "2d6 + @characteristics.dexterity.mod";
// TODO: With the new ship positions this should be changed to take the pilot's piloting skill into consideration.
const DEFAULT_SHIP_INITIATIVE_FORMULA = "2d6";
const DEFAULT_MAX_ENCUMBRANCE_FORMULA = "12 * @characteristics.strength.current";

const settings: string[] = [];
settings.push(stringSetting('initiativeFormula', DEFAULT_INITIATIVE_FORMULA, false, 'world'));
settings.push(stringSetting('armorDamageFormula', "@damage - @effectiveArmor", false, 'world'));
settings.push(stringSetting('shipInitiativeFormula', DEFAULT_SHIP_INITIATIVE_FORMULA, false, 'world'));
settings.push(stringChoiceSetting('difficultyListUsed', TWODSIX.RULESETS.CE.key, false, TWODSIX.VARIANTS));
settings.push(booleanSetting('difficultiesAsTargetNumber', false));
settings.push(stringChoiceSetting('autofireRulesUsed', TWODSIX.RULESETS.CE.key, false, TWODSIX.VARIANTS));
settings.push(numberSetting('modifierForZeroCharacteristic', -2));
settings.push(stringSetting('termForAdvantage', 'advantage'));
settings.push(stringSetting('termForDisadvantage', 'disadvantage'));
settings.push(numberSetting('absoluteBonusValueForEachTimeIncrement', -1));
settings.push(numberSetting('maxSkillLevel', 9));
settings.push(booleanSetting('criticalNaturalAffectsEffect', false));
settings.push(numberSetting('absoluteCriticalEffectValue', 99));
settings.push(booleanSetting('showLifebloodStamina', false));
settings.push(numberSetting('minorWoundsRollModifier', 0));
settings.push(numberSetting('seriousWoundsRollModifier', 0));
settings.push(booleanSetting('lifebloodInsteadOfCharacteristics', false));
settings.push(booleanSetting('showContaminationBelowLifeblood', true));
settings.push(booleanSetting('showHeroPoints', false));
settings.push(stringChoiceSetting('showAlternativeCharacteristics', "base", false, TWODSIX.CharacteristicDisplayTypes));
settings.push(stringSetting("alternativeShort1", "ALT1"));
settings.push(stringSetting("alternativeShort2", "ALT2"));
settings.push(numberSetting('maxComponentHits', 3));
settings.push(numberSetting('mortgagePayment', 240, false));
settings.push(stringSetting('massProductionDiscount', "0.10", false)); //Should be a number setting, but FVTT unhappy with values other than 0.5
settings.push(booleanSetting('reverseHealingOrder', false));
settings.push(stringSetting("maxEncumbrance", DEFAULT_MAX_ENCUMBRANCE_FORMULA, false, "world"));
settings.push(stringSetting('encumbranceFraction', "0.5", false)); //Should be a number setting, but FVTT unhappy with values other than 0.5
settings.push(numberSetting('encumbranceModifier', -1, false));
settings.push(stringSetting('encumbFractionOneSquare', "0.5")); //Should be a number setting, but FVTT unhappy with values other than 0.5
settings.push(stringSetting('encumbFraction75pct', "0.33")); //Should be a number setting, but FVTT unhappy with values other than 0.5
settings.push(numberSetting('defaultMovement', 10));
settings.push(stringChoiceSetting('defaultMovementUnits', "m", true, TWODSIX.MovementUnits));
settings.push(booleanSetting('addEffectForShipDamage', false));
settings.push(stringSetting("unarmedDamage", "1d6", false, "world"));
settings.push(booleanSetting("showTimeframe", false));
settings.push(stringChoiceSetting('showHullAndArmor', "armorOnly", true, TWODSIX.VehicleProtection));
settings.push(stringSetting("sorcerySkill", "Sorcery", false, "world"));
settings.push(booleanSetting("useNationality", false));
settings.push(booleanSetting("animalsUseHits", false));
settings.push(booleanSetting("robotsUseHits", false));
settings.push(booleanSetting("animalsUseLocations", false));
settings.push(booleanSetting("animalTypesIndependentofNiche", false));
settings.push(booleanSetting("displayReactionMorale", false));
settings.push(booleanSetting("useDodgeParry", false));
settings.push(stringSetting("damageTypeOptions", "", false, "world"));
settings.push(stringChoiceSetting('useDegreesOfSuccess', "none", true, TWODSIX.SuccessTypes));
settings.push(booleanSetting("overrideSuccessWithNaturalCrit", false));
const settings = {
general: [],
roll: [],
characteristics: [],
damage: [],
movement: [],
encumbrance: [],
wounds: [],
ship: [],
animals_robots: []
};
settings.general.push(stringSetting('initiativeFormula', DEFAULT_INITIATIVE_FORMULA, false, 'world'));
settings.damage.push(stringSetting('armorDamageFormula', "@damage - @effectiveArmor", false, 'world'));
settings.ship.push(stringSetting('shipInitiativeFormula', DEFAULT_SHIP_INITIATIVE_FORMULA, false, 'world'));
settings.roll.push(stringChoiceSetting('difficultyListUsed', TWODSIX.RULESETS.CE.key, false, TWODSIX.VARIANTS));
settings.roll.push(booleanSetting('difficultiesAsTargetNumber', false));
settings.general.push(stringChoiceSetting('autofireRulesUsed', TWODSIX.RULESETS.CE.key, false, TWODSIX.VARIANTS));
settings.characteristics.push(numberSetting('modifierForZeroCharacteristic', -2));
settings.roll.push(stringSetting('termForAdvantage', 'advantage'));
settings.roll.push(stringSetting('termForDisadvantage', 'disadvantage'));
settings.roll.push(numberSetting('absoluteBonusValueForEachTimeIncrement', -1));
settings.general.push(numberSetting('maxSkillLevel', 9));
settings.roll.push(booleanSetting('criticalNaturalAffectsEffect', false));
settings.roll.push(numberSetting('absoluteCriticalEffectValue', 99));
settings.characteristics.push(booleanSetting('showLifebloodStamina', false));
settings.wounds.push(numberSetting('minorWoundsRollModifier', 0));
settings.wounds.push(numberSetting('seriousWoundsRollModifier', 0));
settings.characteristics.push(booleanSetting('lifebloodInsteadOfCharacteristics', false));
settings.characteristics.push(booleanSetting('showContaminationBelowLifeblood', true));
settings.characteristics.push(booleanSetting('showHeroPoints', false));
settings.characteristics.push(stringChoiceSetting('showAlternativeCharacteristics', "base", false, TWODSIX.CharacteristicDisplayTypes));
settings.characteristics.push(stringSetting("alternativeShort1", "ALT1"));
settings.characteristics.push(stringSetting("alternativeShort2", "ALT2"));
settings.ship.push(numberSetting('maxComponentHits', 3));
settings.ship.push(numberSetting('mortgagePayment', 240, false));
settings.ship.push(stringSetting('massProductionDiscount', "0.10", false)); //Should be a number setting, but FVTT unhappy with values other than 0.5
settings.wounds.push(booleanSetting('reverseHealingOrder', false));
settings.encumbrance.push(stringSetting("maxEncumbrance", DEFAULT_MAX_ENCUMBRANCE_FORMULA, false, "world"));
settings.encumbrance.push(stringSetting('encumbranceFraction', "0.5", false)); //Should be a number setting, but FVTT unhappy with values other than 0.5
settings.encumbrance.push(numberSetting('encumbranceModifier', -1, false));
settings.movement.push(numberSetting('defaultMovement', 10));
settings.movement.push(stringChoiceSetting('defaultMovementUnits', "m", true, TWODSIX.MovementUnits));
settings.movement.push(stringSetting('encumbFractionOneSquare', "0.5")); //Should be a number setting, but FVTT unhappy with values other than 0.5
settings.movement.push(stringSetting('encumbFraction75pct', "0.33")); //Should be a number setting, but FVTT unhappy with values other than 0.5
settings.ship.push(booleanSetting('addEffectForShipDamage', false));
settings.damage.push(stringSetting("unarmedDamage", "1d6", false, "world"));
settings.roll.push(booleanSetting("showTimeframe", false));
settings.general.push(stringChoiceSetting('showHullAndArmor', "armorOnly", true, TWODSIX.VehicleProtection));
settings.general.push(stringSetting("sorcerySkill", "Sorcery", false, "world"));
settings.general.push(booleanSetting("useNationality", false));
settings.animals_robots.push(booleanSetting("animalsUseHits", false));
settings.animals_robots.push(booleanSetting("robotsUseHits", false));
settings.animals_robots.push(booleanSetting("animalsUseLocations", false));
settings.animals_robots.push(booleanSetting("animalTypesIndependentofNiche", false));
settings.animals_robots.push(booleanSetting("displayReactionMorale", false));
settings.damage.push(booleanSetting("useDodgeParry", false));
settings.damage.push(stringSetting("damageTypeOptions", "", false, "world"));
settings.damage.push(booleanSetting('addEffectToManualDamage', false));
settings.roll.push(stringChoiceSetting('useDegreesOfSuccess', "none", true, TWODSIX.SuccessTypes));
settings.roll.push(booleanSetting("overrideSuccessWithNaturalCrit", false));
return settings;
}
}
Loading
Loading