Skip to content

Commit

Permalink
Fixed issues with img and name (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddbrown30 authored Aug 6, 2024
1 parent b5e93a3 commit 519688e
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 103 deletions.
140 changes: 70 additions & 70 deletions succ/config/condition-config.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions succ/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
"title": "SWADE Ultimate Condition Changer",
"description": "<p>A module to change status icons in the SWADE system on Foundry VTT.</p><p><a href=\"https://ko-fi.com/salieric\">Please consider donating.</a></p>",
"compatibility": {
"minimum": "11",
"verified": "12.325"
"minimum": "12",
"verified": "12.330"
},
"version": "3.3.2",
"version": "4.0.0",
"relationships": {
"systems": [
{
"id": "swade",
"type": "system",
"manifest": "https://gitlab.com/api/v4/projects/16269883/packages/generic/swade/latest/system.json",
"compatibility": {
"minimum": "3.3.8",
"verified": "4.0.0"
"minimum": "4.0.0",
"verified": "4.0.5"
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions succ/modules/enhanced-conditions/condition-lab.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class ConditionLab extends FormApplication {
const condition = {
id,
name,
icon: icons[i],
img: icons[i],
referenceId: references[i],
activeEffect,
macros,
Expand Down Expand Up @@ -264,7 +264,7 @@ export class ConditionLab extends FormApplication {
}

if (!resetIcons) {
newCondition.icon = oldCondition.icon;
newCondition.img = oldCondition.img;
}

if (!resetAes) {
Expand Down
36 changes: 18 additions & 18 deletions succ/modules/enhanced-conditions/enhanced-conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ export class EnhancedConditions {
effectIcons.each((index, element) => {
const url = new URL(element.src);
const path = url?.pathname?.substring(1);
const conditions = EnhancedConditions.getConditionsByIcon(path);
const statusEffect = CONFIG.statusEffects.find(e => e.icon === path);
const conditions = EnhancedConditions.getConditionsByImg(path);
const statusEffect = CONFIG.statusEffects.find(e => e.img === path);

if (conditions?.length) {
element.title = conditions[0];
} else if (statusEffect?.label) {
element.title = statusEffect.label;
} else if (statusEffect?.name) {
element.title = statusEffect.name;
}
element.title = game.i18n.localize(element.title);
});
Expand Down Expand Up @@ -379,7 +379,7 @@ export class EnhancedConditions {
async function applySharedOptions(options) {
let updates = activeEffect.toObject();
foundry.utils.mergeObject(updates.flags, options.flags, { overwrite: false });
if (options.icon) { updates.icon = options.icon; }
if (options.img) { updates.img = options.img; }
await activeEffect.update(updates);
}

Expand Down Expand Up @@ -744,8 +744,8 @@ export class EnhancedConditions {
//If the condition doesn't exist in the full map, it must be something new that was added to the system, so we need to add it
let newCondition = {
id: statusEffect.id,
name: statusEffect.label,
icon: statusEffect.icon
name: statusEffect.name,
img: statusEffect.img
};

if (statusEffect.changes) {
Expand All @@ -757,7 +757,7 @@ export class EnhancedConditions {
}
game.succ.conditionConfigMap.push(newCondition);
} else if (useSystemIcons) {
conditionConfig.icon = statusEffect.icon;
conditionConfig.img = statusEffect.img;
}
}

Expand Down Expand Up @@ -823,7 +823,7 @@ export class EnhancedConditions {
}

if (condition.activeEffect) {
condition.activeEffect.label = game.i18n.localize(condition.name);
condition.activeEffect.name = game.i18n.localize(condition.name);
}
}
}
Expand Down Expand Up @@ -883,12 +883,12 @@ export class EnhancedConditions {
if (!condition) preparedMap.splice(i, 1);

if (!condition.name) {
condition.name = condition.label ?? (condition.icon ? Sidekick.getNameFromFilePath(condition.icon) : "");
condition.name = condition.name ?? (condition.img ? Sidekick.getNameFromFilePath(condition.img) : "");
}

//If this condition matches something in our default status effects, copy its id
let statusEffects = CONFIG.defaultStatusEffects ? CONFIG.defaultStatusEffects : CONFIG.statusEffects;
const statusEffect = statusEffects.find(e => e.label === condition.name);
const statusEffect = statusEffects.find(e => e.name === condition.name);
if (statusEffect) {
condition.id = statusEffect.id;
} else if (!condition.id) {
Expand Down Expand Up @@ -1055,8 +1055,8 @@ export class EnhancedConditions {
[BUTLER.FLAGS.enhancedConditions.overlay]: c?.options?.overlay ?? false
}
},
label: c.name,
icon: c.icon,
name: c.name,
img: c.img,
changes: c.activeEffect?.changes || [],
duration: c.duration || c.activeEffect?.duration || {},
description: c.activeEffect?.description || '',
Expand Down Expand Up @@ -1105,7 +1105,7 @@ export class EnhancedConditions {
}

if (conditionMap instanceof Array) {
return conditionMap.map(mapEntry => mapEntry.icon);
return conditionMap.map(mapEntry => mapEntry.img);
}

return [];
Expand All @@ -1123,7 +1123,7 @@ export class EnhancedConditions {
}

if (conditionMap instanceof Array) {
const filteredConditions = conditionMap.filter(c => c.name === condition).map(c => c.icon);
const filteredConditions = conditionMap.filter(c => c.name === condition).map(c => c.img);
if (!filteredConditions.length) {
return;
}
Expand All @@ -1138,15 +1138,15 @@ export class EnhancedConditions {
* Retrieves a condition name by its mapped icon
* @param {*} icon
*/
static getConditionsByIcon(icon, { firstOnly = false } = {}) {
static getConditionsByImg(img, { firstOnly = false } = {}) {
const conditionMap = Sidekick.getSetting(BUTLER.SETTING_KEYS.enhancedConditions.map);

if (!conditionMap || !icon) {
if (!conditionMap || !img) {
return;
}

if (conditionMap instanceof Array && conditionMap.length) {
const filteredIcons = conditionMap.filter(c => c.icon === icon).map(c => c.name);
const filteredIcons = conditionMap.filter(c => c.img === img).map(c => c.name);
if (!filteredIcons.length) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion succ/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export function registerSettings() {
for (const condition of game.succ.conditions) {
const conditionConfig = game.succ.conditionConfigMap.find(c => c.id === condition.id);
if (conditionConfig) {
condition.icon = conditionConfig.icon;
condition.img = conditionConfig.img;
}
}
Sidekick.setSetting(BUTLER.SETTING_KEYS.enhancedConditions.map, game.succ.conditions);
Expand Down
2 changes: 1 addition & 1 deletion succ/templates/boost-lower-dialog.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2><img src={{condition.icon}} width="30" height="30" style="border:0;" />
<h2><img src={{condition.img}} width="30" height="30" style="border:0;" />
{{#if boost}}
{{{localize "ENHANCED_CONDITIONS.Dialog.BoostBuilder.Name"}}}
{{else}}
Expand Down
2 changes: 1 addition & 1 deletion succ/templates/deflection-dialog.hbs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<h2><img src={{condition.icon}} width="30" height="30" style="border:0;" /> {{{localize "ENHANCED_CONDITIONS.Dialog.DeflectionBuilder.Name"}}}</h2>
<h2><img src={{condition.img}} width="30" height="30" style="border:0;" /> {{{localize "ENHANCED_CONDITIONS.Dialog.DeflectionBuilder.Name"}}}</h2>
{{{localize "ENHANCED_CONDITIONS.Dialog.DeflectionBuilder.Body"}}}
2 changes: 1 addition & 1 deletion succ/templates/partials/chat-card-condition-list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>
{{/if}}
<div class="condition-icon">
<img src="{{condition.icon}}" class="condition-icon chat-message" title="{{condition.name}}">
<img src="{{condition.img}}" class="condition-icon chat-message" title="{{condition.name}}">
</div>
{{#if condition.hasReference}}
<div class="condition-reference">
Expand Down
4 changes: 2 additions & 2 deletions succ/templates/partials/condition-lab-row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="flexrow">
<!--row 1 col 1 icon-->
<div class="flexcol icon">
<img name="icon-{{@index}}" src="{{condition.icon}}" title="Status Icon" class="icon" />
<img name="icon-{{@index}}" src="{{condition.img}}" title="Status Icon" class="icon" />
</div>
<!--row 1 col 2 text-entry-->
<div class="flexcol text-entry">
Expand All @@ -33,7 +33,7 @@
<div class="flexrow path">
<div class="wrapper-rel">
<label for="icon-path-{{@index}}" class="inset-label">{{localize "succ.WORDS.Icon"}}</label>
<input type="text" name="icon-path-{{@index}}" title="Status Icon Path" class="icon-path condition-text-input" value="{{condition.icon}}" placeholder="/icons/example.svg" data-dtype="String" {{#if isDefault}}disabled{{/if}}>
<input type="text" name="icon-path-{{@index}}" title="Status Icon Path" class="icon-path condition-text-input" value="{{condition.img}}" placeholder="/icons/example.svg" data-dtype="String" {{#if isDefault}}disabled{{/if}}>
</div>
<button type="button" name="file-picker-{{@index}}" class="file-picker" data-type="image" data-target="icon-path-{{@index}}" title="Browse Files" tabindex="-1" {{#if isDefault}}hidden{{/if}}>
<i class="fas fa-file-import fa-fw"></i>
Expand Down
2 changes: 1 addition & 1 deletion succ/templates/protection-dialog.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2><img src={{condition.icon}} width="30" height="30" style="border:0;" /> {{{localize "ENHANCED_CONDITIONS.Dialog.ProtectionBuilder.Name"}}}</h2>
<h2><img src={{condition.img}} width="30" height="30" style="border:0;" /> {{{localize "ENHANCED_CONDITIONS.Dialog.ProtectionBuilder.Name"}}}</h2>
{{{localize "ENHANCED_CONDITIONS.Dialog.ProtectionBuilder.Body"}}}
<div style="display:flex">
<p style="flex:3">{{{localize "ENHANCED_CONDITIONS.Dialog.AmountToIncrease"}}}</p>
Expand Down
2 changes: 1 addition & 1 deletion succ/templates/smite-dialog.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2><img src={{condition.icon}} width="30" height="30" style="border:0;" /> {{{localize "ENHANCED_CONDITIONS.Dialog.SmiteBuilder.Name"}}}</h2>
<h2><img src={{condition.img}} width="30" height="30" style="border:0;" /> {{{localize "ENHANCED_CONDITIONS.Dialog.SmiteBuilder.Name"}}}</h2>
{{{localize "ENHANCED_CONDITIONS.Dialog.SmiteBuilder.Body"}}}
<div style="display:flex">
<p style="flex:3">{{{localize "ENHANCED_CONDITIONS.Dialog.WeaponToAffect"}}}</p>
Expand Down

0 comments on commit 519688e

Please sign in to comment.