diff --git a/README.md b/README.md index 8c6e196..7b76c66 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ The roll tables added to generate operation code names comes from Reddit user /u - Spanish Translation submitted by [CthulhuRol](https://github.com/CthulhuRol) - Catalonian Translation submitted by [trombonecot](https://github.com/trombonecot) - French Translation submitted by [Hrunh](https://github.com/Hrunh) +- Japanese Translation submitted by [ryotai-trpg](https://github.com/ryotai-trpg) ## Fonts (Some in use, others that I would like to use at some point) diff --git a/css/deltagreen.css b/css/deltagreen.css index 4e5c568..43e224f 100644 --- a/css/deltagreen.css +++ b/css/deltagreen.css @@ -457,7 +457,7 @@ explicitly define a number of rows, rather than columns. */ } .deltagreen .skill-and-training-controls { - flex: 0 0 80px; + flex: 0 0 35px; } .deltagreen .action-pill { @@ -525,6 +525,7 @@ input.percentile-skill-input { margin-left: 5px; height: unset; align-self: center; + text-align: center !important; } input.checkbox-skill-input { diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index c5790bc..cad0e04 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -70,26 +70,43 @@ export default class DeltaGreenActorSheet extends ActorSheet { // Make it easy for the sheet handlebars to understand how to sort the skills. data.sortSkillsSetting = game.settings.get("deltagreen", "sortSkills"); - let sortedSkills = []; - for (const [key, skill] of Object.entries(this.actor.system.skills)) { - skill.key = key; - skill.sortLabel = game.i18n.localize(`DG.Skills.${key}`); + if (this.actor.type !== "vehicle") { + // fill an array that is sorted based on the appropriate localized entry + let sortedSkills = []; + for (const [key, skill] of Object.entries(this.actor.system.skills)) { + skill.key = key; + skill.sortLabel = game.i18n.localize(`DG.Skills.${key}`); - if (skill.sortLabel === "" || skill.sortLabel === `DG.Skills.${key}`) { - skill.sortLabel = skill.label; + if (skill.sortLabel === "" || skill.sortLabel === `DG.Skills.${key}`) { + skill.sortLabel = skill.label; + } + + // if the actor is an NPC or Unnatural, and they have 'hide untrained skills' active, + // it will break the sorting logic, so we have to skip over these + if ( + !( + (this.actor.type == "npc" || this.actor.type == "unnatural") && + this.actor.system.showUntrainedSkills == true && + skill.proficiency < 1 + ) + ) { + sortedSkills.push(skill); + } } - sortedSkills.push(skill); + sortedSkills.sort(function (a, b) { + return a.sortLabel.localeCompare(b.sortLabel, game.i18n.lang); + }); + + // if sorting by columns, re-arrange the array to be columns first, then rows + if (game.settings.get("deltagreen", "sortSkills")) { + let columnSortedSkills = this.reorderForColumnSorting(sortedSkills, 3); + + this.actor.system.sortedSkills = columnSortedSkills; + } else { + this.actor.system.sortedSkills = sortedSkills; + } } - - //console.log(sortedSkills); - - sortedSkills.sort(function (a, b) { - return a.sortLabel.localeCompare(b.sortLabel, game.i18n.lang); - }); - - this.actor.system.sortedSkills = sortedSkills; - // Prepare a simplified version of the special training for display on sheet. if (this.actor.type !== "vehicle") { const specialTraining = this.actor.system.specialTraining.map( @@ -129,6 +146,53 @@ export default class DeltaGreenActorSheet extends ActorSheet { data.specialTraining = specialTraining; } + // try to make a combined array of both typed skills and special trainings, + // so that it can be sorted together neatly on the sheet + if (this.actor.type !== "vehicle") { + let sortedCustomSkills = []; + + for (const [key, skill] of Object.entries( + this.actor.system.typedSkills + )) { + skill.type = "typeSkill"; + skill.key = key; + skill.sortLabel = skill.group + "." + skill.label; + skill.sortLabel = skill.sortLabel.toUpperCase(); + skill.actorType = this.actor.type; + + if (skill.sortLabel === "" || skill.sortLabel === `DG.Skills.${key}`) { + skill.sortLabel = skill.label; + } + + sortedCustomSkills.push(skill); + } + + for (var i = 0; i < data.specialTraining.length; i++) { + let training = data.specialTraining[i]; + + training.type = "training"; + training.sortLabel = training.name.toUpperCase(); + training.actorType = this.actor.type; + + sortedCustomSkills.push(training); + } + + sortedCustomSkills.sort(function (a, b) { + return a.sortLabel.localeCompare(b.sortLabel, game.i18n.lang); + }); + + if (game.settings.get("deltagreen", "sortSkills")) { + let columnSortedSkills = this.reorderForColumnSorting( + sortedCustomSkills, + 2 + ); + + this.actor.system.sortedCustomSkills = columnSortedSkills; + } else { + this.actor.system.sortedCustomSkills = sortedCustomSkills; + } + } + switch (this.actor.type) { case "agent": data.enrichedDescription = await TextEditor.enrichHTML( @@ -155,6 +219,21 @@ export default class DeltaGreenActorSheet extends ActorSheet { return data; } + reorderForColumnSorting(arr, numCols) { + let numRows = Math.ceil(arr.length / numCols); + let reordered = new Array(arr.length); + + for (let i = 0; i < arr.length; i++) { + let row = i % numRows; + let col = Math.floor(i / numRows); + let newIndex = row * numCols + col; + + reordered[newIndex] = arr[i]; + } + + return reordered; + } + // some handlers may wish to avoid leading players to think they should be seeking out magic // so control whether an actor sheet shows the hypergeometry (rituals and tomes) section shouldShowHyperGeometrySection(actor) { diff --git a/templates/actor/actor-sheet.html b/templates/actor/actor-sheet.html index 3dba891..8f6ffb7 100644 --- a/templates/actor/actor-sheet.html +++ b/templates/actor/actor-sheet.html @@ -96,9 +96,9 @@ {{localize "DG.Sheet.BlockHeaders.SkillsAndTraining"}} -