Skip to content

Commit

Permalink
feat(renamer): permit custom icons
Browse files Browse the repository at this point in the history
  • Loading branch information
wrycu committed Oct 8, 2023
1 parent 2ec53fa commit 7a9dcc4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
"ffg-star-wars-enhancements.controls.new-journal-template.title": "New Datapad Journal",
"ffg-star-wars-enhancements.rename.auto": "Auto-rename combat actors",
"ffg-star-wars-enhancements.rename.auto-hint": "Tokens owned by a player will be named PC; any other token will be named NPC. Light/dark side is determined by token disposition.",
"ffg-star-wars-enhancements.rename.auto-friendly": "Friendly actor icon",
"ffg-star-wars-enhancements.rename.auto-hint-friendly": "Friendly actors will use this image",
"ffg-star-wars-enhancements.rename.auto-enemy": "Enemy actor icon",
"ffg-star-wars-enhancements.rename.auto-hint-enemy": "Enemy actors will use this image",
"ffg-star-wars-enhancements.rename.auto-neutral": "Neutral actor icon",
"ffg-star-wars-enhancements.rename.auto-hint-neutral": "Neutral actors will use this image",
"ffg-star-wars-enhancements.opening-crawl.title": "Opening Crawl",
"ffg-star-wars-enhancements.opening-crawl.opening-crawl-folder": "Folder container opening crawl journals",
"ffg-star-wars-enhancements.opening-crawl.opening-crawl-folder-hint": "Provide the name of the folder that contains your opening crawl journals.",
Expand Down
1 change: 1 addition & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Add Brazilian translation (thanks `neour#4842`!)
- FIX: Correct Melee animation looking squished ([#102](https://github.com/wrycu/StarWarsFFG-Enhancements/issues/102)) (thanks `tim-bersau` for reporting and `SourTarte` for providing a fix!)
- IMPROVEMENT: Combat actors can now have custom images set ([#168](https://github.com/wrycu/StarWarsFFG-Enhancements/issues/168))

`2.0.3` - 2023-03-01

Expand Down
38 changes: 36 additions & 2 deletions scripts/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,33 @@ export function init() {
type: Boolean,
default: true,
});
game.settings.register("ffg-star-wars-enhancements", "auto-rename-actors_friendly", {
name: game.i18n.localize("ffg-star-wars-enhancements.rename.auto-friendly"),
hint: game.i18n.localize("ffg-star-wars-enhancements.rename.auto-hint-friendly"),
scope: "world",
config: true,
type: String,
default: "systems/starwarsffg/images/dice/starwars/lightside.png",
filePicker: "Image",
});
game.settings.register("ffg-star-wars-enhancements", "auto-rename-actors_enemy", {
name: game.i18n.localize("ffg-star-wars-enhancements.rename.auto-enemy"),
hint: game.i18n.localize("ffg-star-wars-enhancements.rename.auto-hint-enemy"),
scope: "world",
config: true,
type: String,
default: "systems/starwarsffg/images/dice/starwars/darkside.png",
filePicker: "Image",
});
game.settings.register("ffg-star-wars-enhancements", "auto-rename-actors_neutral", {
name: game.i18n.localize("ffg-star-wars-enhancements.rename.auto-neutral"),
hint: game.i18n.localize("ffg-star-wars-enhancements.rename.auto-hint-neutral"),
scope: "world",
config: true,
type: String,
default: "systems/starwarsffg/images/dice/starwars/lightside.png",
filePicker: "Image",
});
log("attack_rename", "Initialized");
}

Expand All @@ -24,11 +51,18 @@ export function rename_combatant(combatant) {
// actor, fall back to neutral if both are undefined.
const disposition = combatant.token?.disposition ?? combatant.actor?.token.disposition ?? 0;
// Determine side based on disposition.
const side = disposition === CONST.TOKEN_DISPOSITIONS.FRIENDLY ? "lightside" : "darkside";
let img;
if (disposition === CONST.TOKEN_DISPOSITIONS.FRIENDLY) {
img = game.settings.get("ffg-star-wars-enhancements", "auto-rename-actors_friendly");
} else if (disposition === CONST.TOKEN_DISPOSITIONS.HOSTILE) {
img = game.settings.get("ffg-star-wars-enhancements", "auto-rename-actors_enemy");
} else {
img = game.settings.get("ffg-star-wars-enhancements", "auto-rename-actors_neutral");
}
log("attack_rename", "Renaming token");
// Updates the data before it's sent to the DB, preventing names and icons from resetting on reload
combatant.updateSource({
name: combatant.isNPC ? "NPC" : "PC",
img: `systems/starwarsffg/images/dice/starwars/${side}.png`,
img: img,
});
}

0 comments on commit 7a9dcc4

Please sign in to comment.