Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into Foundry-VTT-v12-u…
Browse files Browse the repository at this point in the history
…pdate
  • Loading branch information
marvin9257 committed Jan 4, 2024
2 parents d88dea6 + 04f9651 commit b0da01a
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 8 deletions.
49 changes: 49 additions & 0 deletions src/module/settings/RulsetSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ export default class RulesetSettings extends AdvancedSettings {
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("shortSTR", "TWODSIX.Items.Skills.STR", false, "world", updateSTRShortLabel, true));
settings.characteristics.push(stringSetting("shortDEX", "TWODSIX.Items.Skills.DEX", false, "world", updateDEXShortLabel, true));
settings.characteristics.push(stringSetting("shortEND", "TWODSIX.Items.Skills.END", false, "world", updateENDShortLabel, true));
settings.characteristics.push(stringSetting("shortINT", "TWODSIX.Items.Skills.INT", false, "world", updateINTShortLabel, true));
settings.characteristics.push(stringSetting("shortEDU", "TWODSIX.Items.Skills.EDU", false, "world", updateEDUShortLabel, true));
settings.characteristics.push(stringSetting("shortSOC", "TWODSIX.Items.Skills.SOC", false, "world", updateSOCShortLabel, true));
settings.characteristics.push(stringSetting("shortPSI", "TWODSIX.Items.Skills.PSI", false, "world", updatePSIShortLabel, true));
settings.characteristics.push(stringSetting("alternativeShort1", "ALT1"));
settings.characteristics.push(stringSetting("alternativeShort2", "ALT2"));
settings.ship.push(numberSetting('maxComponentHits', 3));
Expand Down Expand Up @@ -115,3 +122,45 @@ export const checkManualDamageSetting = function () {
ui.notifications.warn(game.i18n.localize("TWODSIX.Warnings.ResetEffectForManualDamage"));
}
};

export const updateSTRShortLabel = function (value:string) {
if (!value) {
game.settings.set('twodsix', "shortSTR", "TWODSIX.Items.Skills.STR");
}
};

export const updateDEXShortLabel = function (value:string) {
if (!value) {
game.settings.set('twodsix', "shortDEX", "TWODSIX.Items.Skills.DEX");
}
};

export const updateENDShortLabel = function (value:string) {
if (!value) {
game.settings.set('twodsix', "shortEND", "TWODSIX.Items.Skills.END");
}
};

export const updateINTShortLabel = function (value:string) {
if (!value) {
game.settings.set('twodsix', "shortINT", "TWODSIX.Items.Skills.INT");
}
};

export const updateEDUShortLabel = function (value:string) {
if (!value) {
game.settings.set('twodsix', "shortEDU", "TWODSIX.Items.Skills.EDU");
}
};

export const updateSOCShortLabel = function (value:string) {
if (!value) {
game.settings.set('twodsix', "shortSOC", "TWODSIX.Items.Skills.SOC");
}
};

export const updatePSIShortLabel = function (value:string) {
if (!value) {
game.settings.set('twodsix', "shortPSI", "TWODSIX.Items.Skills.PSI");
}
};
8 changes: 4 additions & 4 deletions src/module/settings/settingsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

function registerSetting(key, scope, config, defaultValue, type, onChange, choices?, localize?) {
const settingData = {
name: game.i18n.localize(`TWODSIX.Settings.${key}.name`),
name: game.i18n.localize(`TWODSIX.Settings.${key}.name`), //localization doesn't function at this point FVTT automatically localizes later
hint: game.i18n.localize(`TWODSIX.Settings.${key}.hint`),
scope: scope,
config: config,
default: defaultValue,
default: localize ? game.i18n.localize(defaultValue) : defaultValue,
type: type,
onChange: onChange,
choices: choices,
Expand All @@ -31,8 +31,8 @@ export function stringChoiceSetting(key: string, defaultValue: string, localize
return key;
}

export function stringSetting(key: string, defaultValue: string, config = false, scope = 'world', onChange?: ((value: string) => void) | undefined): string {
registerSetting(key.replace('.', ''), scope, config, defaultValue, String, onChange);
export function stringSetting(key: string, defaultValue: string, config = false, scope = 'world', onChange?: ((value: string) => void) | undefined, localize?:boolean): string {
registerSetting(key.replace('.', ''), scope, config, defaultValue, String, onChange, undefined, localize);
return key;
}

Expand Down
2 changes: 1 addition & 1 deletion src/module/utils/enrichers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function displayTable(uuid: string, table:any, tableName: string): string {
}
}
html += `</td>
<td>${subTable?.description} @DisplayTable[RollTable.${result.documentId}]{${subTableName}}</td>
<td>${subTable?.description} @UUID[RollTable.${result.documentId}]{${subTableName}}</td>
</tr>`;
} else {
html += `</td>
Expand Down
6 changes: 5 additions & 1 deletion src/module/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ export function getCharShortName(char: string): string {
return game.settings.get('twodsix', 'alternativeShort1');
case "ALT2":
return game.settings.get('twodsix', 'alternativeShort2');
default:
case "LFB":
case "STA":
case "HIT":
return game.i18n.localize("TWODSIX.Items.Skills." + char);
default:
return game.i18n.localize(game.settings.get('twodsix', 'short' + char));
}
}

Expand Down
30 changes: 29 additions & 1 deletion static/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@
"ValueCr": "Value in Cr"
},
"Component": {
"Ammunition":"Ammuniton",
"Ammunition":"Ammunition",
"componentName": "Component",
"accomodations": "accommodations",
"armament": "armament",
Expand Down Expand Up @@ -857,6 +857,34 @@
"hint": "Defaults to 99, which means that effect is ignored.",
"name": "What effect is required for a throw to be considered a critical success/failure (i.e. be colored green/red)."
},
"shortSTR": {
"hint": "Short name for strength characteristic. It should be four characters or fewer.",
"name": "Short name for strength characteristic"
},
"shortDEX": {
"hint": "Short name for dexterity characteristic. It should be four characters or fewer.",
"name": "Short name for dexterity characteristic"
},
"shortEND": {
"hint": "Short name for endurance characteristic. It should be four characters or fewer.",
"name": "Short name for endurance characteristic"
},
"shortINT": {
"hint": "Short name for intelligence characteristic. It should be four characters or fewer.",
"name": "Short name for intelligence characteristic"
},
"shortSOC": {
"hint": "Short name for social standing characteristic. It should be four characters or fewer.",
"name": "Short name for social standing characteristic"
},
"shortEDU": {
"hint": "Short name for education characteristic. It should be four characters or fewer.",
"name": "Short name for education characteristic"
},
"shortPSI": {
"hint": "Short name for psionic strength characteristic. It should be four characters or fewer.",
"name": "Short name for psionic strength characteristic"
},
"alternativeShort1": {
"hint": "Short name for first alternative characteristic. It should be four characters or fewer.",
"name": "Short name for alternative characteristic 1"
Expand Down
6 changes: 5 additions & 1 deletion static/templates/misc/setting-partial.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
<input type="number" name="{{key}}" value="{{setting.value}}" data-dtype="Number" step="0.01">
{{/iff}}
{{#iff setting.htmlType "===" "String"}}
<input type="text" name="{{key}}" value="{{setting.value}}" data-dtype="String">
{{#if setting.localize}}
<input type="text" name="{{key}}" value="{{localize setting.value}}" data-dtype="String">
{{else}}
<input type="text" name="{{key}}" value="{{setting.value}}" data-dtype="String">
{{/if}}
{{/iff}}

{{#iff setting.htmlType "===" "Textarea"}}
Expand Down

0 comments on commit b0da01a

Please sign in to comment.