From 451593cfffddfbecb3900623e9211a5cb68ee72c Mon Sep 17 00:00:00 2001 From: AngryBeaver Date: Sun, 12 Mar 2023 15:31:10 +0100 Subject: [PATCH 1/9] add type --- lang/en.json | 5 ++++- src/Recipe.ts | 8 +++++++- src/apps/ToolConfig.ts | 2 -- src/types.ts | 1 + templates/recipe-main.hbs | 17 ++++++++++++++--- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/lang/en.json b/lang/en.json index 593f1aa..baaee6b 100644 --- a/lang/en.json +++ b/lang/en.json @@ -40,7 +40,10 @@ "attendants": "Attendants", "macro": { "button": "save" - } + }, + "folder": "Folder", + "folderHint": "You can create subfolder by separating words with ':>' e.g. Folder:>Subfolder", + "folderPlaceHolder":"Folder:>Subfolder" }, "anyOf": { "dropItem": "drop item", diff --git a/src/Recipe.ts b/src/Recipe.ts index b3ffe9c..83de1ec 100644 --- a/src/Recipe.ts +++ b/src/Recipe.ts @@ -23,6 +23,7 @@ export class Recipe implements RecipeData { [key: string]: Component } macro: string + folder?: string; _trash: { ingredients: {}; results: {}; @@ -75,6 +76,7 @@ export class Recipe implements RecipeData { this.tool = data.tool; this.attendants = deserializeComponents(data.attendants || {}); this.macro = data.macro || ""; + this.folder = data.folder; this._trash = { ingredients: {}, results: {}, @@ -96,7 +98,8 @@ export class Recipe implements RecipeData { currency: this.currency, tool: this.tool, attendants: this.serializeAttendants(), - macro: this.macro + macro: this.macro, + folder: this.folder } if (!this.tool) { serialized["-=tool"] = null; @@ -113,6 +116,9 @@ export class Recipe implements RecipeData { if (!this.macro) { serialized["-=macro"] = null; } + if(!this.folder) { + serialized["-=folder"] = null; + } return serialized; } diff --git a/src/apps/ToolConfig.ts b/src/apps/ToolConfig.ts index 626a567..ff6ef13 100644 --- a/src/apps/ToolConfig.ts +++ b/src/apps/ToolConfig.ts @@ -81,8 +81,6 @@ export class ToolConfig extends FormApplication { } } - - export async function getToolConfig(): Promise{ if(components.length === 0) { await _setToolConfig(); diff --git a/src/types.ts b/src/types.ts index e6a1313..353cdb8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -167,4 +167,5 @@ interface RecipeData { [key: string]: ComponentData }, macro?: string + folder?: string } \ No newline at end of file diff --git a/templates/recipe-main.hbs b/templates/recipe-main.hbs index f2893c1..d56f5a0 100644 --- a/templates/recipe-main.hbs +++ b/templates/recipe-main.hbs @@ -45,12 +45,23 @@ {{/if}} {{/if}} +
+
+
{{localize "beaversCrafting.recipe.folder"}}
+ {{#if editable}} +
+ {{/if}} +
+ {{#if editable}} + + {{/if}} +
{{#if useAttendants}}
{{localize "beaversCrafting.recipe.attendants"}}
{{#if editable}} -
-
+
{{/if}}
{{#each recipe.attendants}} @@ -132,7 +143,7 @@
{{localize "beaversCrafting.recipe.ingredients"}}
{{localize "beaversCrafting.recipe.quantity"}}
{{#if editable}} -
-
+
{{/if}}
{{#each recipe.ingredients}} @@ -363,7 +374,7 @@
{{localize "beaversCrafting.recipe.results"}}
{{localize "beaversCrafting.recipe.quantity"}}
{{#if editable}} -
-
+
{{/if}} {{#each recipe.results}} From 513bcafe3d0b04db7aa6e66d1030b45d0ab2a976 Mon Sep 17 00:00:00 2001 From: AngryBeaver Date: Fri, 24 Mar 2023 07:29:20 +0100 Subject: [PATCH 2/9] as is --- css/crafting.css | 22 +++++++++++-- lang/en.json | 4 +-- src/apps/CraftingApp.ts | 47 ++++++++++++++++++++++++++- templates/crafting-app.hbs | 66 ++++++++++++++++++++++---------------- templates/recipe-main.hbs | 2 +- 5 files changed, 107 insertions(+), 34 deletions(-) diff --git a/css/crafting.css b/css/crafting.css index fd9e642..d5de14f 100644 --- a/css/crafting.css +++ b/css/crafting.css @@ -139,11 +139,13 @@ } .beavers-crafting.crafting-app aside.sidebar{ - flex: 0 0 140px; + flex: 0 0 200px; height: 100%; - width: 140px; + width: 200px; border-right: 1px solid var(--color-border-light-primary); font-size: var(--font-size-12); +} +.beavers-crafting.crafting-app .sidebar .content{ overflow-y: scroll; } @@ -341,4 +343,20 @@ } .beavers-crafting .fa-check{ color:#468847 +} +.beavers-crafting .folderContent { + margin-left:10px +} + +.beavers-crafting .folder .name{ + line-height:22px; + height:22px; + border-bottom: 1px solid dimgrey; +} +.beavers-crafting .folderContent .folder .name{ + border-left: 1px solid dimgrey; +} + +.beavers-crafting .folderContent .recipeItem{ + border-left: 1px solid dimgrey; } \ No newline at end of file diff --git a/lang/en.json b/lang/en.json index baaee6b..01689db 100644 --- a/lang/en.json +++ b/lang/en.json @@ -42,8 +42,8 @@ "button": "save" }, "folder": "Folder", - "folderHint": "You can create subfolder by separating words with ':>' e.g. Folder:>Subfolder", - "folderPlaceHolder":"Folder:>Subfolder" + "folderHint": "You can create subfolder by separating words with '.' e.g. Folder.Subfolder", + "folderPlaceHolder":"Folder.Subfolder" }, "anyOf": { "dropItem": "drop item", diff --git a/src/apps/CraftingApp.ts b/src/apps/CraftingApp.ts index c721d78..43acf9a 100644 --- a/src/apps/CraftingApp.ts +++ b/src/apps/CraftingApp.ts @@ -12,6 +12,12 @@ export class CraftingApp extends Application { actor, filter, recipes:Recipe[], + folders:{ + [key: string]: { + folders: string[], + recipes: Recipe[] + } + } index, filterItems:{}, recipe?:Recipe, @@ -26,7 +32,8 @@ export class CraftingApp extends Application { filter: FilterType.available, recipes: [], index: 0, - filterItems: {} + filterItems: {}, + folders: {}, }; if(this.element.length > 0){ this.bringToTop(); @@ -56,6 +63,44 @@ export class CraftingApp extends Application { if(Object.values(data.filterItems).length != 0){ recipes = await RecipeCompendium.filterForItems(recipes,Object.values(data.filterItems)); } + recipes.sort( + (a,b)=>{ + if(a.folder == undefined){ + if(b.folder != undefined){ + return -1 + } + return 0 + }else{ + if(b.folder == undefined){ + return 1 + }else{ + if(a.folder < b.folder){ + return -1 + }else if(a.folder > b.folder){ + return 1; + }else { + if(a.name < b.name){ + return -1 + } + if(a.name > b.name){ + return 1; + } + return 0 + } + } + } + }); + + recipes.forEach(recipe=>{ + const folder = recipe.folder || ""; + if(!data.folders[folder]){ + data.folders[folder] = { + folders: folder.split("."), + recipes:[] + }; + } + data.folders[folder].recipes.push(recipe); + }); data.recipes = recipes; data.recipe = data.recipes[data.index]; data.content = null; diff --git a/templates/crafting-app.hbs b/templates/crafting-app.hbs index a77bc39..d384354 100644 --- a/templates/crafting-app.hbs +++ b/templates/crafting-app.hbs @@ -1,34 +1,44 @@
-
-
- -
-
filter by item:
-
- {{#each filterItems}} - - {{this.name}} - - {{/each}} -
-
diff --git a/templates/recipe-main.hbs b/templates/recipe-main.hbs index d56f5a0..2d2fa43 100644 --- a/templates/recipe-main.hbs +++ b/templates/recipe-main.hbs @@ -53,7 +53,7 @@ {{/if}}
{{#if editable}} - + {{/if}}
{{#if useAttendants}} From 0a60f75ac225729384e67457dd19b7f6a9d40ec5 Mon Sep 17 00:00:00 2001 From: AngryBeaver Date: Sat, 1 Apr 2023 10:32:57 +0200 Subject: [PATCH 3/9] ui adaptions --- changelog.md | 10 ++ css/crafting.css | 228 +++++++++++++++++++------ lang/en.json | 14 +- src/Crafting.ts | 31 ++-- src/Result.ts | 13 ++ src/apps/CraftingApp.ts | 149 +++++++++------- src/apps/RecipeSheet.ts | 10 ++ src/main.js | 13 +- src/types.ts | 2 +- templates/beavers-recipe-component.hbs | 16 ++ templates/beavers-recipe-folders.hbs | 33 ++++ templates/beavers-recipe-test.hbs | 41 +++++ templates/crafting-app-main.hbs | 114 +++++++++++++ templates/crafting-app.hbs | 42 +---- templates/recipe-main.hbs | 11 +- 15 files changed, 566 insertions(+), 161 deletions(-) create mode 100644 templates/beavers-recipe-component.hbs create mode 100644 templates/beavers-recipe-folders.hbs create mode 100644 templates/beavers-recipe-test.hbs create mode 100644 templates/crafting-app-main.hbs diff --git a/changelog.md b/changelog.md index 46fc04b..7e430be 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,14 @@ # Changelog +## 3.1.0 +- add folder structure +- ui redesign beavers recipe compendium add responsiveness +- add precast currency +- add hit progression text +- fix wsiwyg type selection does not change type-sub selection. +- todo add instruction text +- todo add searchlist +- todo fix more then two tests + ## 3.0.x progress tracking and multiple tests ## 3.0.2 - fix consume on failed check diff --git a/css/crafting.css b/css/crafting.css index d5de14f..d04320f 100644 --- a/css/crafting.css +++ b/css/crafting.css @@ -123,7 +123,7 @@ } .beavers-crafting.crafting-app .window-content { - overflow-y:auto; + overflow-y:hidden; height:100%; } @@ -138,46 +138,6 @@ flex: 0 0 40px; } -.beavers-crafting.crafting-app aside.sidebar{ - flex: 0 0 200px; - height: 100%; - width: 200px; - border-right: 1px solid var(--color-border-light-primary); - font-size: var(--font-size-12); -} -.beavers-crafting.crafting-app .sidebar .content{ - overflow-y: scroll; -} - -.beavers-crafting.crafting-app nav .item{ - height:30px; - line-height:30px; - margin:5px; - border-radius: 5px; -} - -.beavers-crafting.crafting-app nav .item img{ - flex:0 0 30px; - height: 30px; - margin-right:5px; - border-radius: 5px; -} - -.beavers-crafting.crafting-app nav .item span{ - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} - -.beavers-crafting.crafting-app .sheet-body{ - padding:5px; -} - -.beavers-crafting.crafting-app nav .item.selected{ - box-shadow: 6px 6px 10px hsl(300deg 15% 25% / 30%) inset; - background-color: rgba(0, 0, 0, 0.05); -} - .beavers-crafting .dialog-button { flex:0; } @@ -339,24 +299,192 @@ } .beavers-crafting .fa-times{ - color:#b94a48 + color:#b94a48; + margin: auto; + width: 14px; + padding: 0px 0px 0px 3px; } .beavers-crafting .fa-check{ - color:#468847 + color:#468847; + margin: auto; +} + +.beavers-crafting.crafting-app aside.sidebar{ + flex: 0 0 200px; + height: 100%; + width: 200px; + border-right: 2px groove #fff; + font-size: var(--font-size-12); +} +.beavers-crafting.crafting-app .sidebar .content{ + overflow-y: scroll; + border-top: 2px groove #fff; + margin-top: 2px; +} + +.beavers-crafting.crafting-app .sheet-body { + height:100%; } -.beavers-crafting .folderContent { - margin-left:10px + +.beavers-crafting.crafting-app .sheet-body .main{ + overflow-y: scroll; + border-top: 2px groove #fff; + margin-top: 2px; + height:calc( 100% - 64px ); +} + +.beavers-crafting.crafting-app .folderContent { + padding-left:10px; } -.beavers-crafting .folder .name{ +.beavers-crafting.crafting-app .folderContent .folderContent { + padding-left:12px; + border-left: 1px solid dimgrey; +} +.beavers-crafting.crafting-app img { + border: 1px solid transparent; +} + +.beavers-crafting.crafting-app .folderName{ line-height:22px; height:22px; - border-bottom: 1px solid dimgrey; } -.beavers-crafting .folderContent .folder .name{ - border-left: 1px solid dimgrey; + +.beavers-crafting.crafting-app .recipeItem { + line-height: 34px; + flex-wrap:nowrap; } -.beavers-crafting .folderContent .recipeItem{ +.beavers-crafting.crafting-app .recipeItem span.name { + color: #4b4a44; + font-weight: 700; + font-size: 16px; + font-family: "Modesto Condensed", "Palatino Linotype", serif; + overflow:hidden; + text-overflow: ellipsis; +} + +.beavers-crafting.crafting-app .recipeItem img { + height: 30px; + width: 30px; + flex: 0; + border-radius: 5px; + margin: 2px; +} + + +.beavers-crafting.crafting-app .recipeItem.selected a { + box-shadow: inset 0px 0px 10px; + border-radius: 5px; +} + +.beavers-crafting.crafting-app .folderContent span.border { border-left: 1px solid dimgrey; + width:5px; +} +.beavers-crafting.crafting-app .folderContent span.border.top { + border-bottom: 1px solid dimgrey; +} + +.beavers-crafting.crafting-app .folder.close>.folderContent { + display:none; +} + +.beavers-crafting.crafting-app .folder.close>.folderName .fa-folder-open { + display:none; +} + +.beavers-crafting.crafting-app .folder.open>.folderName .fa-folder { + display:none; +} + +.beavers-crafting.crafting-app .folder.open>.folderName .fa-clipboard { + display:none; +} +.beavers-crafting.crafting-app .folder.close>.folderName .fa-clipboard-list-check { + display:none; +} + +.beavers-crafting.crafting-app .main .header { + height: 22px; + align-items: center; + background: rgba(0, 0, 0, 0.05); + border: 2px groove #eeede0; + font-weight: bold; + padding-left: 5px; + font-family: "Modesto Condensed", "Palatino Linotype", serif; + text-align: left; + line-height:20px; + color: dimgrey; + flex:0; + min-width:200px; +} + +.beavers-crafting.crafting-app .main .section { + border: 2px groove #eeede0; + padding: 2px; +} + +.beavers-crafting.crafting-app .test-description { + line-height: 22px; + flex-wrap:nowrap; +} + +.beavers-crafting.crafting-app .test-description .name, .beavers-crafting.crafting-app .component .name { + overflow:hidden; + text-overflow: ellipsis; + white-space:nowrap; + width:0px; +} + +.beavers-crafting.crafting-app .test-description img { + height: 18px; + width: 18px; + flex: 0; + border-radius: 4px; + margin: 2px; +} +.beavers-crafting.crafting-app .test-description .attribute { + flex:0; + padding-left:5px; +} + +.beavers-crafting.crafting-app .test-section { + background-color: rgba(0, 0, 0, 0.1); + border: 1px solid grey; + border-radius: 5px; + margin: 2px; + padding: 1px; +} + +.beavers-crafting.crafting-app .test-header { + text-align: right; + flex-direction: row-reverse; + font-size: x-small; + color: white; +} + +.beavers-crafting .seperator{ + border-bottom: 1px solid rgba(0, 0, 0, 0.3); + border-left: 60px solid transparent; + border-right: 60px solid transparent; + flex:0; +} + +.beavers-crafting.crafting-app .component { + line-height: 32px; + flex-wrap:nowrap; + flex:0; +} + +.beavers-crafting.crafting-app .component img { + height: 28px; + width: 28px; + flex: 0; + border-radius: 4px; + margin: 2px; +} +.beavers-crafting.crafting-app .component .attribute { + flex:0; + padding-left:5px; } \ No newline at end of file diff --git a/lang/en.json b/lang/en.json index 12234b6..93db70d 100644 --- a/lang/en.json +++ b/lang/en.json @@ -29,7 +29,9 @@ "consume": "consume", "consumeHint": "consumes cost on failed tests", "andTestHint": "add additional Test", - "orTestHint": "add alternative Test" + "orTestHint": "add alternative Test", + "skill":"Skill:", + "ability": "Ability:" }, "tools": "Tool", "dc": "DC", @@ -59,12 +61,18 @@ }, "crafting-app": { "title": "Beaver's Recipe Compendium", - "button": "Craft", + "button": "Start", "errors": { "tableNotFound": "RollTable not found for : ", "tableNotValid": "RollTable return invalid Object : ", "itemNotFound": "Item not found in RollTable for :" - } + }, + "cost": "Cost", + "instruction": "Instruction", + "required": "Required", + "result": "Result", + "pass": "pass", + "before": "before" }, "settings": { "createItemTitle": { diff --git a/src/Crafting.ts b/src/Crafting.ts index a9e741f..4f01848 100644 --- a/src/Crafting.ts +++ b/src/Crafting.ts @@ -80,7 +80,7 @@ export class Crafting implements CraftingData { await this.checkAttendants(); await this.evaluateAnyOf(); RecipeCompendium.validateRecipeToItemList(Object.values(this.recipe.ingredients), this.actor.items, this.result); - await this.checkCurrency(); + await this.payCurrency(); await this.addOutput(); await this.executeMacro(); await this.processInput(); @@ -208,6 +208,12 @@ export class Crafting implements CraftingData { } async checkCurrency() { + if (this.recipe.currency) { + await this.result.checkCurrency(this.recipe.currency); + } + } + + async payCurrency() { if (this.recipe.currency) { await this.result.payCurrency(this.recipe.currency); } @@ -400,14 +406,7 @@ export class Crafting implements CraftingData { components.push(...Object.values(this.result._chatAddition).filter(s=>s.component.type !== "Currency")); if(this.result._currencyResult) { - const configCurrency = beaversSystemInterface.configCurrencies.find(c=>c.id===this.result._currencyResult?.name); - const component = configCurrency?.component?configCurrency.component:beaversSystemInterface.componentCreate( - { - type:"Currency", - name:configCurrency?.label, - img:'icons/commodities/currency/coins-assorted-mix-copper-silver-gold.webp' - }); - component.quantity = this.result._currencyResult.value * -1; + const component = getCurrencyComponent(this.result._currencyResult?.name,this.result._currencyResult.value * -1) components.push({ component: component, hasError: this.result._currencyResult.hasError, @@ -527,6 +526,16 @@ export class Crafting implements CraftingData { this.restore = []; this.endAt = game["time"].worldTime; } - - } + +export function getCurrencyComponent(id:string, quantity:number): Component{ + const configCurrency = beaversSystemInterface.configCurrencies.find(c=>c.id===id); + const component = configCurrency?.component?configCurrency.component:beaversSystemInterface.componentCreate( + { + type:"Currency", + name:configCurrency?.label, + img:'icons/commodities/currency/coins-assorted-mix-copper-silver-gold.webp' + }); + component.quantity = quantity; + return component; +} \ No newline at end of file diff --git a/src/Result.ts b/src/Result.ts index 6e7ac3c..1c38611 100644 --- a/src/Result.ts +++ b/src/Result.ts @@ -183,6 +183,11 @@ export class Result implements ResultApi, ResultData { void await this._currencyResult.pay(this._actor); } + async checkCurrency(currency: Currency) { + this._currencyResult = new CurrencyResult(currency); + void await this._currencyResult.canPay(this._actor); + } + async revertPayedCurrency() { if(this._currencyResult== undefined){ return; @@ -351,6 +356,14 @@ export class CurrencyResult implements CurrencyResultData { this.hasError = config.hasError; } + async canPay(actor) { + const currencies = {}; + currencies[this.name] = this.value*-1; + const canPay = await beaversSystemInterface.actorCurrenciesCanAdd(actor, currencies); + this.hasError = canPay; + return canPay; + } + async pay(actor,revert:boolean= false) { if ((!this.isConsumed && !revert) || (revert && this.isConsumed)) { const currencies = {}; diff --git a/src/apps/CraftingApp.ts b/src/apps/CraftingApp.ts index 43acf9a..5a86292 100644 --- a/src/apps/CraftingApp.ts +++ b/src/apps/CraftingApp.ts @@ -1,11 +1,12 @@ import {FilterType, RecipeCompendium} from "./RecipeCompendium.js"; -import {Crafting} from "../Crafting.js"; +import {Crafting, getCurrencyComponent} from "../Crafting.js"; import {getDataFrom, sanitizeUuid} from "../helpers/Utility.js"; import {Settings} from "../Settings.js"; import {getToolConfig} from "./ToolConfig.js"; import {AnyOf} from "../AnyOf.js"; import {Recipe} from "../Recipe.js"; import {Result} from "../Result.js"; +import {TestHandler} from "../TestHandler.js"; export class CraftingApp extends Application { data: { @@ -18,8 +19,8 @@ export class CraftingApp extends Application { recipes: Recipe[] } } - index, filterItems:{}, + selected?, recipe?:Recipe, content?, result?:Result, @@ -31,7 +32,6 @@ export class CraftingApp extends Application { actor: actor, filter: FilterType.available, recipes: [], - index: 0, filterItems: {}, folders: {}, }; @@ -60,53 +60,47 @@ export class CraftingApp extends Application { async getData(options = {}) { const data: any = mergeObject(this.data, await super.getData(options)); let recipes = await RecipeCompendium.filterForActor(data.actor, data.filter); - if(Object.values(data.filterItems).length != 0){ - recipes = await RecipeCompendium.filterForItems(recipes,Object.values(data.filterItems)); + if(Object.values(data.filterItems).length != 0) { + recipes = await RecipeCompendium.filterForItems(recipes, Object.values(data.filterItems)); } recipes.sort( - (a,b)=>{ - if(a.folder == undefined){ - if(b.folder != undefined){ - return -1 - } - return 0 + (a,b)=> { + return recursiveSort(a, a.folder, b, b.folder) + }); + + function recursiveFolder(data,folder,recipe){ + if(folder === undefined){ + data[''] = data[''] || []; + data[''].push(recipe); }else{ - if(b.folder == undefined){ - return 1 - }else{ - if(a.folder < b.folder){ - return -1 - }else if(a.folder > b.folder){ - return 1; - }else { - if(a.name < b.name){ - return -1 - } - if(a.name > b.name){ - return 1; - } - return 0 - } - } + const parts = folder.split(/\.(.*)/s); + data[parts[0]] = data[parts[0]] || {folders:{}} + recursiveFolder(data[parts[0]].folders,parts[1],recipe); } - }); + } recipes.forEach(recipe=>{ - const folder = recipe.folder || ""; - if(!data.folders[folder]){ - data.folders[folder] = { - folders: folder.split("."), - recipes:[] - }; - } - data.folders[folder].recipes.push(recipe); + recursiveFolder(data.folders,recipe.folder,recipe); }); data.recipes = recipes; - data.recipe = data.recipes[data.index]; + if(!data.selected){ + data.selected = data.recipes[0]?.uuid; + } + this.selectRecipe(data.selected); data.content = null; return data; } + selectRecipe(uuid: string){ + this.data.selected = uuid; + this.data.recipes.forEach(r=>{ + if(r.uuid === uuid){ + this.data.recipe = Recipe.clone(r); + return; + } + }); + } + async renderRecipeSheet() { if (this.data.recipe === undefined || this.element === null) { return; @@ -115,18 +109,19 @@ export class CraftingApp extends Application { RecipeCompendium.validateRecipeToItemList(Object.values(this.data.recipe.ingredients), this.data.actor.items,crafting.result); await crafting.checkTool(); await crafting.checkAttendants(); + await crafting.checkCurrency(); this.data.result = crafting.result; - this.data.content = await renderTemplate('modules/beavers-crafting/templates/recipe-main.hbs', + this.data.content = await renderTemplate('modules/beavers-crafting/templates/crafting-app-main.hbs', { recipe: this.data.recipe, - currencies: beaversSystemInterface.configCurrencies, + currencyComponent: this.data.recipe.currency?getCurrencyComponent(this.data.recipe.currency.name,this.data.recipe.currency.value):undefined, skills: beaversSystemInterface.configSkills, abilities: beaversSystemInterface.configCanRollAbility?beaversSystemInterface.configAbilities:[], - editable: false, + tools: await getToolConfig(), precast: await this.getPrecastFromResult(this.data.result,this.data.recipe), + maxHits: this.data.recipe.tests?TestHandler.getMaxHits(this.data.recipe.tests):0, displayResults:Settings.get(Settings.DISPLAY_RESULTS), displayIngredients:Settings.get(Settings.DISPLAY_RESULTS), - tools: await getToolConfig(), useTool: Settings.get(Settings.USE_TOOL), useAttendants: Settings.get(Settings.USE_ATTENDANTS) }); @@ -138,10 +133,11 @@ export class CraftingApp extends Application { activateListeners(html) { super.activateListeners(html); - html.find(".header .entry-filter select.search").on("change", (e) => { + html.find(".sidebar select.search").on("change", (e) => { this.data.filter = $(e.target).val(); - this.data.index = 0; + this.data.selected = null; this.data.content = null; + this.data.folders = {}; this.render(); }); html.find(".dialog-button").on("click", (e) => { @@ -155,35 +151,39 @@ export class CraftingApp extends Application { this.close(); }); }); - html.find(".header .drop-area .item").on("click", (e) => { - const uuid = $(e.currentTarget).data("id"); - delete this.data.filterItems[uuid]; - this.render(); - }); - html.find(".sidebar a.item").on("click", (e) => { - const index = $(e.currentTarget).data().id; - this.data.index = index; - this.data.recipe = Recipe.clone(this.data.recipes[index]); - html.find(".sidebar a.item.selected").removeClass("selected"); - html.find(".sidebar a.item[data-id =" + index + "]").addClass("selected"); + html.find(".sidebar .navigation .recipeItem").on("click", (e) => { + const id = $(e.currentTarget).data().id; + this.selectRecipe(id); + html.find(".sidebar .navigation .selected").removeClass("selected"); + html.find(".sidebar .navigation .recipeItem[data-id='" + id + "']").addClass("selected"); void this.renderRecipeSheet(); }); + + html.find(".folderName").on("click", (e)=>{ + $(e.currentTarget).parent(".folder").toggleClass(["open","close"]); + }); + html.find(".sidebar .fa-sort-amount-up").on("click", (e)=>{ + html.find(".navigation .folder").removeClass("open").addClass("close"); + }); void this.renderRecipeSheet(); } activateRecipeSheetListener(html) { - html.find('.results .flexrow').on("click",e=>{ + html.find('.results .clickable').on("click",e=>{ const uuid = $(e.currentTarget).data("id"); if(Settings.get(Settings.DISPLAY_RESULTS)) { beaversSystemInterface.uuidToDocument(uuid).then(i=>i.sheet._render(true)); } }); - html.find('.ingredients .flexrow').on("click",e=>{ + html.find('.ingredients .clickable').on("click",e=>{ const uuid = $(e.currentTarget).data("id"); if(Settings.get(Settings.DISPLAY_INGREDIENTS)) { beaversSystemInterface.uuidToDocument(uuid).then(i=>i.sheet._render(true)); } }); + html.find(".main .folderName").on("click", (e)=>{ + $(e.currentTarget).parent(".folder").toggleClass(["open","close"]); + }); this.addDragDrop(html); } @@ -276,10 +276,13 @@ export class CraftingApp extends Application { async getPrecastFromResult(result: Result, recipe: Recipe): Promise{ const preCastData:PreCastData = { attendants: {}, - currencies: !result._currencyResult?.hasError, ingredients: {}, tool: false, } + if(result._currencyResult){ + preCastData.currencies = {isAvailable: !result._currencyResult.hasError}; + } + for(const key in recipe.ingredients){ const component = recipe.ingredients[key]; preCastData.ingredients[key]={ @@ -301,3 +304,33 @@ export class CraftingApp extends Application { } } + +function recursiveSort(a, afolder:string|undefined,b, bfolder:string|undefined){ + if(afolder === undefined){ + if(bfolder !== undefined){ + return 1 + }else{ + if(a.name < b.name){ + return -1 + } + if(a.name > b.name){ + return 1; + } + return 0 + } + }else{ + if(bfolder === undefined){ + return -1 + }else{ + const aparts = afolder.split(/\.(.*)/s); + const bparts = bfolder.split(/\.(.*)/s); + if(aparts[0] < bparts[0]){ + return -1 + }else if(aparts[0] > bparts[0]){ + return 1; + }else { + return recursiveSort(a, aparts[1],b, bparts[1]) + } + } + } +} \ No newline at end of file diff --git a/src/apps/RecipeSheet.ts b/src/apps/RecipeSheet.ts index ea1e6dd..184378e 100644 --- a/src/apps/RecipeSheet.ts +++ b/src/apps/RecipeSheet.ts @@ -185,6 +185,16 @@ export class RecipeSheet { this.update(); }); + this.recipeElement.find("select.test-type").on("change",e=>{ + const and = $(e.currentTarget).data("and"); + const or = $(e.currentTarget).data("or"); + if( this.recipe.tests?.ands[and]?.ors[or]?.uuid !== undefined){ + this.recipe.tests.ands[and].ors[or].uuid = ""; + this.recipe.tests.ands[and].ors[or].type = "hit"; + this.recipeElement.find("[name='flags.beavers-crafting.recipe.tests.ands."+and+".ors."+or+".uuid']").val(""); + } + }) + this.recipeElement.find('.results .crafting-item-img').on("click",e=>{ const uuid = $(e.currentTarget).data("id"); if(Settings.get(Settings.DISPLAY_RESULTS)) { diff --git a/src/main.js b/src/main.js index d7a8223..d27a494 100644 --- a/src/main.js +++ b/src/main.js @@ -105,7 +105,15 @@ Hooks.once("beavers-system-interface.ready", async function(){ }) } }); - + getTemplate('modules/beavers-crafting/templates/beavers-recipe-folders.hbs').then(t=>{ + Handlebars.registerPartial('beavers-recipe-folders', t); + }); + getTemplate('modules/beavers-crafting/templates/beavers-recipe-test.hbs').then(t=>{ + Handlebars.registerPartial('beavers-recipe-test', t); + }); + getTemplate('modules/beavers-crafting/templates/beavers-recipe-component.hbs').then(t=>{ + Handlebars.registerPartial('beavers-recipe-component', t); + }) }); //fucking stupid handlebars !!! @@ -114,4 +122,7 @@ Handlebars.registerHelper('hasKey', function (param1, key, options) { return options.fn(this); } return options.inverse(this); +}); +Handlebars.registerHelper('isEmpty', function (object, options) { + return Object.keys(object).length === 0; }); \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index 91adf55..7d40ea1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -104,7 +104,7 @@ interface PreCastData { } } tool?: boolean; - currencies?: boolean; + currencies?: { isAvailable: boolean } } interface Tests { diff --git a/templates/beavers-recipe-component.hbs b/templates/beavers-recipe-component.hbs new file mode 100644 index 0000000..14126a1 --- /dev/null +++ b/templates/beavers-recipe-component.hbs @@ -0,0 +1,16 @@ +
+
+ + {{component.name}} +
+
+ {{component.quantity}} +
+
+ {{#if (eq check.isAvailable true) }} + + {{else if (eq check.isAvailable false) }} + + {{/if}} +
+
\ No newline at end of file diff --git a/templates/beavers-recipe-folders.hbs b/templates/beavers-recipe-folders.hbs new file mode 100644 index 0000000..3167412 --- /dev/null +++ b/templates/beavers-recipe-folders.hbs @@ -0,0 +1,33 @@ +{{#each folders}} + {{#if (eq @key '')}} + {{#each this}} +
+ + + {{#if @last}}{{else}}{{/if}} + + + + {{this.name}} + +
+ {{/each}} + {{else}} +
+
+ + + {{#if @last}}{{else}}{{/if}} + + + + + {{@key}} + +
+
+ {{>beavers-recipe-folders selected=../selected}} +
+
+ {{/if}} +{{/each}} \ No newline at end of file diff --git a/templates/beavers-recipe-test.hbs b/templates/beavers-recipe-test.hbs new file mode 100644 index 0000000..7151eed --- /dev/null +++ b/templates/beavers-recipe-test.hbs @@ -0,0 +1,41 @@ +
+{{#if (eq this.type "skill")}} + {{#each skills}} + {{#if (eq ../this.uuid this.id)}} +
+ {{localize "beaversCrafting.recipe.tests.skill"}} + {{this.label}} +
+ {{/if}} + {{/each}} +{{/if}} +{{#if (eq this.type "ability")}} + {{#each abilities}} + {{#if (eq ../this.uuid this.id)}} +
+ {{localize "beaversCrafting.recipe.tests.ability"}} + {{this.label}} +
+ {{/if}} + {{/each}} +{{/if}} +{{#if (eq this.type "tool")}} + {{#each tools}} + {{#if (eq ../this.uuid this.uuid)}} +
+ + {{this.name}} +
+ {{/if}} + {{/each}} +{{/if}} +{{#if (eq this.type "hit")}} +
+ {{this.uuid}} +
+{{else if this.check}} +
+ {{localize "beaversCrafting.recipe.tests.dc"}}:{{this.check}} +
+{{/if}} +
diff --git a/templates/crafting-app-main.hbs b/templates/crafting-app-main.hbs new file mode 100644 index 0000000..ae2367e --- /dev/null +++ b/templates/crafting-app-main.hbs @@ -0,0 +1,114 @@ +{{#if recipe}} +
+
+ + + {{recipe.name}} + +
+
+
+
+ {{#if (or recipe.tests recipe.instruction)}} +
+ {{localize "beaversCrafting.crafting-app.instruction"}} +
+
+ {{#if recipe.instruction}} +
+                            {{recipe.instruction}}
+                        
+ {{/if}} + {{#if recipe.tests}} +
+ +
+ {{#each recipe.tests.ands}} +
+ + + {{#if @last}}{{else}}{{/if}} + +
+
+ {{hits}} times +
+ {{#each this.ors}} +
+ {{>beavers-recipe-test abilities=../../abilities skills=../../skills tools=../../tools}} +
+ {{#unless @last}} +
+ {{/unless}} + {{/each}} +
+
+ {{/each}} +
+
+ {{/if}} +
+ {{/if}} + {{#if (not (isEmpty recipe.attendants))}} +
+ {{localize "beaversCrafting.crafting-app.required"}} +
+
+ {{#each recipe.attendants}} + {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients check=(lookup ../precast.attendants @key)}} + {{#unless @last}} +
+ {{/unless}} + {{/each}} +
+ {{/if}} +
+
+ {{#if (or currencyComponent (not (isEmpty recipe.ingredients)))}} +
+ {{localize "beaversCrafting.crafting-app.cost"}} +
+
+ {{#if currencyComponent}} + {{>beavers-recipe-component component=currencyComponent check=precast.currencies}} + {{#if (not (isEmpty recipe.ingredients))}} +
+ {{/if}} + {{/if}} + {{#if (not (isEmpty recipe.ingredients))}} + {{#each recipe.ingredients}} + {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients check=(lookup ../precast.ingredients @key)}} + {{#unless @last}} +
+ {{/unless}} + {{/each}} + {{/if}} +
+ {{/if}} + {{#if (not (isEmpty recipe.results))}} +
+ {{localize "beaversCrafting.crafting-app.result"}} +
+
+ {{#each recipe.results}} + {{>beavers-recipe-component component=this key=@key clickable=../displayResults }} + {{#unless @last}} +
+ {{/unless}} + {{/each}} +
+ {{/if}} +
+
+ +{{/if}} \ No newline at end of file diff --git a/templates/crafting-app.hbs b/templates/crafting-app.hbs index d384354..697bfa9 100644 --- a/templates/crafting-app.hbs +++ b/templates/crafting-app.hbs @@ -1,7 +1,7 @@
-
-
- {{#if content}} - {{{content}}} - {{/if}} -
- +
+
diff --git a/templates/recipe-main.hbs b/templates/recipe-main.hbs index 2d2fa43..2470dc4 100644 --- a/templates/recipe-main.hbs +++ b/templates/recipe-main.hbs @@ -244,6 +244,7 @@ {{#select this.uuid}} + {{#each ../../abilities}} {{/each}} @@ -265,6 +267,7 @@ {{else}}
{{localize "beaversCrafting.recipe.tests.dc"}}: @@ -290,7 +297,7 @@
- +
+
+
+
+ {{localize "beaversCrafting.crafting-app.instruction"}} +
+
+ {{editor recipe.instruction engine="prosemirror" target="flags.beavers-crafting.recipe.instruction" editable=editable}} +
+
+
+ \ No newline at end of file diff --git a/templates/recipe-main.hbs b/templates/recipe-main.hbs index 2470dc4..ed81471 100644 --- a/templates/recipe-main.hbs +++ b/templates/recipe-main.hbs @@ -1,5 +1,5 @@ -
-
+
+
{{#if recipe.tool}}
@@ -45,147 +45,83 @@ {{/if}}
{{/if}} -
-
-
{{localize "beaversCrafting.recipe.folder"}}
- {{#if editable}} -
- {{/if}} -
- {{#if editable}} - - {{/if}} -
{{#if useAttendants}}
-
{{localize "beaversCrafting.recipe.attendants"}}
+
{{localize "beaversCrafting.crafting-app.required"}}
+
+
+ {{#each recipe.attendants}} + {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients editable=../editable}} +
+ {{/each}} {{#if editable}} -
+
+
{{localize "beaversCrafting.recipe.dropItem"}}
+
{{/if}}
- {{#each recipe.attendants}} -
-
- {{this.name}} -
- {{#if ../precast}} - {{#with (lookup ../precast.attendants @key) as |attendant|}} - {{#if attendant.isAvailable }} - - {{else}} - - {{/if}} - {{/with}} - {{/if}} -
- {{#if ../editable}} -
- - - -
- {{/if}} -
- {{/each}} - {{#if editable}} -
-
{{localize "beaversCrafting.recipe.dropItem"}}
-
- {{/if}}
{{/if}} -
+
-
{{localize "beaversCrafting.recipe.currency"}}
-
{{localize "beaversCrafting.recipe.quantity"}}
+
{{localize "beaversCrafting.crafting-app.cost"}}
{{#if editable}}
{{#unless recipe.currency}} - + {{/unless}}
{{/if}}
- {{#if recipe.currency}} -
- -
- +
+ + {{#if recipe.currency}} +
+
+ +
+ +
+ {{#if editable}} +
+ + + +
+ {{/if}} +
+
+ {{/if}} +
+ {{#each recipe.ingredients}} + {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients editable=../editable}} +
+ {{/each}} {{#if editable}} -
- - - +
+
{{localize "beaversCrafting.recipe.dropItem"}}
{{/if}}
- {{/if}} -
-
-
-
{{localize "beaversCrafting.recipe.ingredients"}}
-
{{localize "beaversCrafting.recipe.quantity"}}
- {{#if editable}} -
- {{/if}}
- {{#each recipe.ingredients}} -
-
- {{this.name}} -
- -
- {{#if ../precast}} -
- {{#with (lookup ../precast.ingredients @key) as |ingredient|}} - {{#if ingredient.isAvailable }} - - {{else}} - - {{/if}} - {{/with}} -
- {{/if}} - {{#if ../editable}} -
- - - -
- {{/if}} -
- {{/each}} - {{#if editable}} -
-
{{localize "beaversCrafting.recipe.dropItem"}}
-
- {{/if}}
-
+
{{localize "beaversCrafting.recipe.tests.tests"}}
@@ -214,12 +150,13 @@
{{/if}}
+
{{#if recipe.tests}} {{#each recipe.tests.ands}}
{{localize "beaversCrafting.recipe.tests.test"}}
-
{{localize "beaversCrafting.recipe.tests.hits"}}: {{/if}}
-
+
{{#each this.ors}} -
-
+
+
{{#if (eq this.type "skill")}} {{#select this.uuid}} - + {{#each ../../abilities}} {{/each}} @@ -267,7 +204,7 @@ {{/if}}
-
-
- {{#select this.type}} @@ -308,9 +245,8 @@ {{/select}} -
{{#if ../../editable}} -
+
@@ -318,11 +254,15 @@ {{/if}}
+ {{#unless @last}} +
+ {{/unless}} {{/each}}
{{/each}} {{/if}} +
{{#if recipe.skill}}
@@ -339,6 +279,7 @@
{{/if}}
+
{{#if recipe.skill}}
-
- {{#if ../editable}} -
- - - -
- {{/if}} -
+ {{>beavers-recipe-component component=this key=@key clickable=../displayResults editable=../editable}} +
{{/each}} {{#if editable}}
{{localize "beaversCrafting.recipe.dropItem"}}
{{/if}} +
\ No newline at end of file diff --git a/templates/recipe-sheet.hbs b/templates/recipe-sheet.hbs index 6679f99..2d4f421 100644 --- a/templates/recipe-sheet.hbs +++ b/templates/recipe-sheet.hbs @@ -1,9 +1,13 @@
+
+ {{{description}}} +
{{{main}}}
From 8eadfe549a8e542819ca03a9cfc57fb5c126f85c Mon Sep 17 00:00:00 2001 From: AngryBeaver Date: Thu, 6 Apr 2023 14:07:30 +0200 Subject: [PATCH 5/9] ui adaptions actor-tab --- changelog.md | 11 +- css/crafting.css | 262 ++++++++++++++++++--------- lang/en.json | 8 +- src/Crafting.ts | 19 ++ src/Recipe.ts | 3 +- src/apps/ActorSheetTab.ts | 31 +++- src/apps/CraftingApp.ts | 4 +- src/main.js | 3 + templates/actor-sheet-tab.hbs | 197 +++++++------------- templates/beavers-recipe-folders.hbs | 6 +- templates/beavers-recipe-test.hbs | 28 ++- templates/beavers-recipe.hbs | 116 ++++++++++++ templates/crafting-app-main.hbs | 108 +---------- 13 files changed, 450 insertions(+), 346 deletions(-) create mode 100644 templates/beavers-recipe.hbs diff --git a/changelog.md b/changelog.md index 1fc0d79..ad65b8c 100644 --- a/changelog.md +++ b/changelog.md @@ -4,11 +4,14 @@ - ui redesign beavers recipe compendium add responsiveness - add precast currency - add hit progression text -- fix wsiwyg type selection does not change type-sub selection. -- todo ui redesing recipe configuration -- todo add instruction text +- fix type selection does not change type-sub selection. +- ui redesing recipe configuration +- add instruction text +- fix rescale create Item +- fix more then two tests +- todo ui redesing crafting tab on actor - todo add searchlist -- todo fix more then two tests +- todo create video ## 3.0.x progress tracking and multiple tests ## 3.0.2 diff --git a/css/crafting.css b/css/crafting.css index 928c273..7d8ee4a 100644 --- a/css/crafting.css +++ b/css/crafting.css @@ -215,27 +215,22 @@ .beavers-crafting select { margin: auto; } - -.beavers-crafting.actor-tab .header{ - background-color: dimgrey; - color: white; - text-shadow: 1px 1px var(--color-shadow-dark); - font-weight: bold; - flex: 30px; - line-height: 30px; - text-align: center; - } - -.beavers-crafting.actor-tab .scale{ - flex:1 0 100px; - width:100px; +/* + common + */ +.beavers-crafting .beavers-seperator{ + border-bottom: 1px solid rgba(0, 0, 0, 0.3); + border-left: 60px solid transparent; + border-right: 60px solid transparent; + flex:0; } - -.beavers-crafting.actor-tab .status{ - flex:0 0 80px +.beavers-crafting .clickable{ + cursor: pointer; } -.beavers-crafting.actor-tab .option{ - flex:0 0 30px; + +.beavers-crafting .beavers-line .attribute { + flex:0; + padding-left:5px; } .beavers-crafting .fa-times{ @@ -248,25 +243,21 @@ color:#468847; margin: auto; } -/* - common - */ -.beavers-crafting .beavers-seperator{ - border-bottom: 1px solid rgba(0, 0, 0, 0.3); - border-left: 60px solid transparent; - border-right: 60px solid transparent; - flex:0; -} +/**************** +beaver-component + ****************/ .beavers-crafting .beavers-component { - line-height: 32px; flex-wrap:nowrap; flex:0; + line-height: 32px; + height: 32px; + max-height:32px; } .beavers-crafting .beavers-component img { - height: 28px; - width: 28px; + height: calc( 100% - 4px); + width: calc( 100% - 4px); flex: 0; border-radius: 4px; margin: 2px; @@ -276,14 +267,35 @@ flex:0; padding-left:5px; } -.beavers-crafting .clickable{ - cursor: pointer; +/**************** +beaver-recipe-test + ****************/ + +.beavers-crafting .beavers-recipe-test { + line-height: 22px; + flex-wrap:nowrap; + white-space:nowrap; } -.beavers-crafting .beavers-line .attribute { +.beavers-crafting .beavers-recipe-test .name { + overflow:hidden; + text-overflow: ellipsis; + white-space:nowrap; + width:0px; +} + +.beavers-crafting .beavers-recipe-test img { + height: 18px; + width: 18px; + flex: 0; + border-radius: 4px; + margin: 2px; +} +.beavers-crafting .beavers-recipe-test .attribute { flex:0; padding-left:5px; } + /* crafting-app */ .beavers-crafting.crafting-app aside.sidebar{ @@ -303,36 +315,48 @@ height:100%; } -.beavers-crafting.crafting-app .sheet-body .main{ +.beavers-crafting.crafting-app .sheet-body .beavers-recipe{ overflow-y: scroll; border-top: 2px groove #fff; margin-top: 2px; height:calc( 100% - 64px ); } -.beavers-crafting.crafting-app .folderContent { +.beavers-crafting.crafting-app .beavers-crafting-header .beavers-component { + line-height: 34px; + height: 34px; + max-height:34px; + color: #4b4a44; + font-weight: 700; + font-size: 16px; + font-family: "Modesto Condensed", "Palatino Linotype", serif; +} +/**************** +beaver-folder + ****************/ +.beavers-crafting .beavers-folder .folderContent { padding-left:10px; } -.beavers-crafting.crafting-app .folderContent .folderContent { +.beavers-crafting .beavers-folder .folderContent .folderContent { padding-left:12px; border-left: 1px solid dimgrey; } -.beavers-crafting.crafting-app img { +.beavers-crafting .beavers-folder img { border: 1px solid transparent; } -.beavers-crafting.crafting-app .folderName{ +.beavers-crafting .beavers-folder .folderName{ line-height:22px; height:22px; } -.beavers-crafting.crafting-app .recipeItem { +.beavers-crafting .beavers-folder .beavers-folder-item { line-height: 34px; flex-wrap:nowrap; } -.beavers-crafting.crafting-app .recipeItem span.name { +.beavers-crafting .beavers-folder .beavers-folder-item span.name { color: #4b4a44; font-weight: 700; font-size: 16px; @@ -341,48 +365,49 @@ text-overflow: ellipsis; } -.beavers-crafting.crafting-app .recipeItem img { +.beavers-crafting .beavers-folder .beavers-folder-item img { height: 30px; width: 30px; flex: 0; border-radius: 5px; margin: 2px; } - - -.beavers-crafting.crafting-app .recipeItem.selected a { +.beavers-crafting .beavers-folder .beavers-folder-item.selected a { box-shadow: inset 0px 0px 10px; border-radius: 5px; } -.beavers-crafting.crafting-app .folderContent span.border { +.beavers-crafting .beavers-folder .folderContent span.border { border-left: 1px solid dimgrey; width:5px; } -.beavers-crafting.crafting-app .folderContent span.border.top { +.beavers-crafting .beavers-folder .folderContent span.border.top { border-bottom: 1px solid dimgrey; } -.beavers-crafting.crafting-app .folder.close>.folderContent { +.beavers-crafting .beavers-folder .folder.close>.folderContent { display:none; } -.beavers-crafting.crafting-app .folder.close>.folderName .fa-folder-open { +.beavers-crafting .beavers-folder .folder.close>.folderName .fa-folder-open { display:none; } -.beavers-crafting.crafting-app .folder.open>.folderName .fa-folder { +.beavers-crafting .beavers-folder .folder.open>.folderName .fa-folder { display:none; } -.beavers-crafting.crafting-app .folder.open>.folderName .fa-clipboard { +/************ +beavers-recipe + */ +.beavers-crafting .beavers-recipe .folder.open>.folderName .fa-clipboard { display:none; } -.beavers-crafting.crafting-app .folder.close>.folderName .fa-clipboard-list-check { +.beavers-crafting .beavers-recipe .folder.close>.folderName .fa-clipboard-list-check { display:none; } -.beavers-crafting.crafting-app .main .header { +.beavers-crafting .beavers-recipe .header { height: 22px; align-items: center; background: rgba(0, 0, 0, 0.05); @@ -397,36 +422,12 @@ min-width:200px; } -.beavers-crafting.crafting-app .main .section { +.beavers-crafting .beavers-recipe .section { border: 2px groove #eeede0; padding: 2px; } -.beavers-crafting.crafting-app .test-description { - line-height: 22px; - flex-wrap:nowrap; -} - -.beavers-crafting.crafting-app .test-description .name, .beavers-crafting.crafting-app .component .name { - overflow:hidden; - text-overflow: ellipsis; - white-space:nowrap; - width:0px; -} - -.beavers-crafting.crafting-app .test-description img { - height: 18px; - width: 18px; - flex: 0; - border-radius: 4px; - margin: 2px; -} -.beavers-crafting.crafting-app .test-description .attribute { - flex:0; - padding-left:5px; -} - -.beavers-crafting.crafting-app .test-section { +.beavers-crafting .beavers-recipe .test-section { background-color: rgba(0, 0, 0, 0.1); border: 1px solid grey; border-radius: 5px; @@ -434,13 +435,13 @@ padding: 1px; } -.beavers-crafting.crafting-app .test-header { +.beavers-crafting .beavers-recipe .text-section .test-header { text-align: right; flex-direction: row-reverse; font-size: x-small; color: white; } -/* recipe */ +/* recipe-sheet */ .beavers-crafting .recipe .sheet-left{ min-width:305px } @@ -462,6 +463,9 @@ flex:0; } +/** +todo check this + */ .beavers-crafting .header input { font-size: 14px;line-height: 14px;text-align: center; } @@ -485,4 +489,100 @@ border-left: 1px solid #c9c7b8; justify-content: right; line-height:15px +} +/**** +actor-sheet + */ +.beavers-crafting.actor-tab .statusbar { + margin: 2px; + max-height:20px; + width:50px; + color:white; + line-height:16px; + text-align:center; + padding:2px; + border-radius:5px; + border:1px solid darkgreen; +} +.beavers-crafting.actor-tab .statusbar.success { + border-color:darkgreen; +} +.beavers-crafting.actor-tab .statusbar.error { + border-color:darkred; +} +.beavers-crafting.actor-tab .statusbar .fill { + text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; + width: 100%; + height: 100%; +} +.beavers-crafting.actor-tab .test-description { + line-height: 22px; + flex-wrap:nowrap; +} + +.beavers-crafting.actor-tab .test-description .flexrow{ + flex-wrap:nowrap; +} + +.beavers-crafting.actor-tab .header1{ + background-color: dimgrey; + color: white; + text-shadow: 1px 1px var(--color-shadow-dark); + font-weight: bold; + flex: 30px; + line-height: 30px; + text-align: center; + margin-right:1px; +} + +.beavers-crafting.actor-tab .header { + height: 22px; + align-items: center; + background: rgba(0, 0, 0, 0.05); + border: 2px groove #eeede0; + font-weight: bold; + padding-left: 5px; + font-family: "Modesto Condensed", "Palatino Linotype", serif; + text-align: left; + line-height:20px; + color: dimgrey; + flex:0; + min-width:200px; +} + +.beavers-crafting.actor-tab .scale{ + flex:1 0 100px; + width:100px; + flex-wrap: nowrap; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.beavers-crafting.actor-tab .status{ + flex:0 0 80px +} +.beavers-crafting.actor-tab .option{ + flex:0 0 30px; +} +.beavers-crafting.actor-tab .crafting-description{ + margin: 0px 30px; + display:none; +} +.beavers-crafting.actor-tab .describe .crafting-description{ + display:block; +} +.beavers-crafting.actor-tab .describe .describeCrafting .fa-square-chevron-down{ + display:none; +} +.beavers-crafting.actor-tab .describeCrafting .fa-square-chevron-up{ + display:none; +} +.beavers-crafting.actor-tab .describe .describeCrafting .fa-square-chevron-up{ + display:inline +} + +.beavers-crafting.actor-tab .addCrafting { + font-size:12px; + line-height:12px; } \ No newline at end of file diff --git a/lang/en.json b/lang/en.json index 93db70d..4deb8b6 100644 --- a/lang/en.json +++ b/lang/en.json @@ -6,8 +6,8 @@ "table": { "name": "Name", "status": "Status", - "input": "Resources", - "output": "Results" + "progress": "Progress", + "add": "Add" } }, "inventory": { @@ -72,7 +72,9 @@ "required": "Required", "result": "Result", "pass": "pass", - "before": "before" + "before": "before", + "fails": "fails", + "checks": "Checklist" }, "settings": { "createItemTitle": { diff --git a/src/Crafting.ts b/src/Crafting.ts index 4f01848..119db91 100644 --- a/src/Crafting.ts +++ b/src/Crafting.ts @@ -75,6 +75,25 @@ export class Crafting implements CraftingData { return Crafting.fromRecipe(actorId, Recipe.fromItem(item)); } + get nextTest():TestOr{ + let result:TestOr = { + check: 0, + type: "hit", + uuid: "progress" + } + if(this.recipe.tests){ + const testHandler = new TestHandler(this.recipe.tests,this.result,this.actor); + try { + const currentTest = testHandler.getCurrentTestAnd(); + if(Object.keys(currentTest.ors).length == 1){ + return Object.values(currentTest.ors)[0]; + } + }catch(e){ + } + } + return result + } + async startCrafting() { await this.checkTool(); await this.checkAttendants(); diff --git a/src/Recipe.ts b/src/Recipe.ts index 9663967..93234e8 100644 --- a/src/Recipe.ts +++ b/src/Recipe.ts @@ -213,7 +213,7 @@ export class Recipe implements RecipeData { if(this.tests == undefined){ this.tests = new DefaultTest(); }else{ - const sorted = Object.keys(this.tests).sort(); + const sorted = Object.keys(this.tests.ands).sort(); // @ts-ignore const nextId = sorted[sorted.length-1]-1+2; this.tests.ands[nextId] = new DefaultAndTest; @@ -310,7 +310,6 @@ export class Recipe implements RecipeData { }); } } - } export class DefaultTest implements Tests { diff --git a/src/apps/ActorSheetTab.ts b/src/apps/ActorSheetTab.ts index 94006a1..d74d846 100644 --- a/src/apps/ActorSheetTab.ts +++ b/src/apps/ActorSheetTab.ts @@ -1,12 +1,16 @@ import {CraftingApp} from "./CraftingApp.js"; import {Crafting} from "../Crafting.js"; import {Settings} from "../Settings.js"; +import {getToolConfig} from "./ToolConfig.js"; export class ActorSheetTab { app; html; data; system:System; + craftingFolder: { + [key:string]:{id:string, crafting:Crafting,chatData:{}}[] + } = {} craftingList:{ [key:string]:Crafting } = {}; @@ -23,14 +27,35 @@ export class ActorSheetTab { async init() { const label = game["i18n"].localize("beaversCrafting.actorSheet.tab"); const flag = this.app.actor.flags["beavers-crafting"]?.crafting || {}; - const chatList = {}; + const unsortedFolders = {}; for(const [x,y] of Object.entries(flag)){ const craftingData = (y as CraftingData); const crafting = new Crafting(craftingData,this.app.actor); + let folder = ""; + if(crafting.recipe.folder){ + folder = crafting.recipe.folder.split(".")[0]; + } this.craftingList[x] = crafting; - chatList[x] = crafting.getChatData(); + if(!unsortedFolders[folder] ){ + unsortedFolders[folder] = []; + } + unsortedFolders[folder].push({id:x,crafting:crafting, chatData: crafting.getChatData()}); } - const tabBody = $(await renderTemplate('modules/beavers-crafting/templates/actor-sheet-tab.hbs', {craftingList:this.craftingList,chatList:chatList})); + Object.keys(unsortedFolders).sort().forEach((k)=> { + if (k !== "") { + this.craftingFolder[k] = unsortedFolders[k]; + } + }) + if(unsortedFolders[""]){ + this.craftingFolder[""] = unsortedFolders[""]; + } + const tabBody = $(await renderTemplate('modules/beavers-crafting/templates/actor-sheet-tab.hbs', + { + craftingFolder:this.craftingFolder, + skills: beaversSystemInterface.configSkills, + abilities: beaversSystemInterface.configCanRollAbility?beaversSystemInterface.configAbilities:[], + tools: await getToolConfig() + })); beaversSystemInterface.actorSheetAddTab(this.app, this.html, this.data.actor, { id: Settings.ACTOR_TAB_ID, label: label, html: "" }, tabBody); this.activateListeners(tabBody); } diff --git a/src/apps/CraftingApp.ts b/src/apps/CraftingApp.ts index 98a67eb..8ec09d5 100644 --- a/src/apps/CraftingApp.ts +++ b/src/apps/CraftingApp.ts @@ -140,11 +140,11 @@ export class CraftingApp extends Application { this.data.folders = {}; this.render(); }); - html.find(".sidebar .navigation .recipeItem").on("click", (e) => { + html.find(".sidebar .navigation .beavers-folder-item").on("click", (e) => { const id = $(e.currentTarget).data().id; this.selectRecipe(id); html.find(".sidebar .navigation .selected").removeClass("selected"); - html.find(".sidebar .navigation .recipeItem[data-id='" + id + "']").addClass("selected"); + html.find(".sidebar .navigation .beavers-folder-item[data-id='" + id + "']").addClass("selected"); void this.renderRecipeSheet(); }); diff --git a/src/main.js b/src/main.js index d27a494..6d75f47 100644 --- a/src/main.js +++ b/src/main.js @@ -113,6 +113,9 @@ Hooks.once("beavers-system-interface.ready", async function(){ }); getTemplate('modules/beavers-crafting/templates/beavers-recipe-component.hbs').then(t=>{ Handlebars.registerPartial('beavers-recipe-component', t); + }); + getTemplate('modules/beavers-crafting/templates/beavers-recipe.hbs').then(t=>{ + Handlebars.registerPartial('beavers-recipe', t); }) }); diff --git a/templates/actor-sheet-tab.hbs b/templates/actor-sheet-tab.hbs index 825f535..f2a1018 100644 --- a/templates/actor-sheet-tab.hbs +++ b/templates/actor-sheet-tab.hbs @@ -1,146 +1,85 @@
-
-
-
{{localize "beaversCrafting.actorSheet.table.name"}}
-
{{localize - "beaversCrafting.actorSheet.table.input"}}
-
{{localize - "beaversCrafting.actorSheet.table.output"}}
-
{{localize - "beaversCrafting.actorSheet.table.status"}}
-
- + +
+
+
+
+
- {{#each chatList as |chatData| }} -
-
- {{#if (eq chatData.status "active")}} - - {{this.title}} - - {{else}} -
- {{this.title}} -
- {{/if}} + {{#each craftingFolder}} +
+
{{@key}}{{#if (eq @key "")}}...{{/if}}
+
{{localize + "beaversCrafting.actorSheet.table.progress"}}
+
{{localize + "beaversCrafting.actorSheet.table.status"}}
+
+
-
- {{#each chatData.components}} - {{#if (eq type "required")}} -
-
- {{this.component.name}} -
- {{#if this.hasError }} - - {{else}} - {{#if this.isProcessed }} - {{#if (eq ../status "active") }} - - {{else}} - - {{/if}} - {{/if}} - {{/if}} -
-
- {{/if}} - {{/each}} - {{#each chatData.components}} - {{#if (eq type "consumed")}} -
-
- {{this.component.quantity}} {{this.component.name}} -
- {{#if this.hasError }} - - {{else}} - {{#if this.isProcessed }} - {{#if (eq ../status "active") }} - - {{else}} - - {{/if}} - {{/if}} - {{/if}} -
+
+ {{#each this}} +
+
+
+
+ {{this.chatData.title}}
- {{/if}} - {{/each}} -
-
- {{#each chatData.components}} - {{#if (eq type "produced")}} -
-
- {{this.component.quantity}} {{this.component.name}} -
- {{#if this.hasError }} - - {{else}} - {{#if (eq ../status "active") }} - - {{else}} - {{#if this.isProcessed }} - - {{/if}} - {{/if}} - {{/if}} -
+
+ {{#if (eq this.chatData.status "active") }} + {{/if}} - {{/each}} -
-
- <{{#if (eq this.status "active") }}a{{else}}div{{/if}} class="flexrow advanceCrafting" - style="flex:0 0 auto;display: flex;flex-direction: row;flex-wrap: wrap;justify-content: flex-start; " data-id="{{@key}}"> -
{{#if (not (eq this.status "error"))}} -
-
{{this.tests.hitPer}} - % +
+ {{#if (and (not (eq this.chatData.status "success")) (gt this.crafting.recipe.tests.fails 0)) }} +
+
+ {{this.chatData.tests.failPer}}% +
-
- {{/if}} - {{#if (not (eq this.status "success"))}} -
-
{{this.tests.failPer}} - % + {{/if}} + {{#if (not (eq this.chatData.status "error"))}} +
+
+ {{this.chatData.tests.hitPer}}%
{{/if}}
-
- {{#if (eq this.status "active") }} - - {{else if (eq this.status "success") }} - - {{else if (eq this.status "error") }} - - {{/if}} + - -
-
- - - +
+ + + +
+
+
+ {{>beavers-recipe recipe=this.crafting.recipe tools=../../tools skills=../../skills abilities=../../abilities}} +
-
+ {{#if (not @last)}} +
+ {{/if}} + {{/each}} {{/each}}
\ No newline at end of file diff --git a/templates/beavers-recipe-folders.hbs b/templates/beavers-recipe-folders.hbs index 2484af0..8a38e39 100644 --- a/templates/beavers-recipe-folders.hbs +++ b/templates/beavers-recipe-folders.hbs @@ -1,7 +1,8 @@ +
{{#each folders}} {{#if (eq @key '')}} {{#each this}} -
+
{{#if @last}}{{else}}{{/if}} @@ -30,4 +31,5 @@
{{/if}} -{{/each}} \ No newline at end of file +{{/each}} +
\ No newline at end of file diff --git a/templates/beavers-recipe-test.hbs b/templates/beavers-recipe-test.hbs index 7151eed..3b14415 100644 --- a/templates/beavers-recipe-test.hbs +++ b/templates/beavers-recipe-test.hbs @@ -1,27 +1,25 @@ -
-{{#if (eq this.type "skill")}} +
+{{#if (eq test.type "skill")}} {{#each skills}} - {{#if (eq ../this.uuid this.id)}} + {{#if (eq ../test.uuid this.id)}}
- {{localize "beaversCrafting.recipe.tests.skill"}} - {{this.label}} + {{localize "beaversCrafting.recipe.tests.skill"}} {{this.label}}
{{/if}} {{/each}} {{/if}} -{{#if (eq this.type "ability")}} +{{#if (eq test.type "ability")}} {{#each abilities}} - {{#if (eq ../this.uuid this.id)}} + {{#if (eq ../test.uuid this.id)}}
- {{localize "beaversCrafting.recipe.tests.ability"}} - {{this.label}} + {{localize "beaversCrafting.recipe.tests.ability"}} {{this.label}}
{{/if}} {{/each}} {{/if}} -{{#if (eq this.type "tool")}} +{{#if (eq test.type "tool")}} {{#each tools}} - {{#if (eq ../this.uuid this.uuid)}} + {{#if (eq ../test.uuid this.uuid)}}
{{this.name}} @@ -29,13 +27,13 @@ {{/if}} {{/each}} {{/if}} -{{#if (eq this.type "hit")}} +{{#if (eq test.type "hit")}}
- {{this.uuid}} + {{test.uuid}}
-{{else if this.check}} +{{else if test.check}}
- {{localize "beaversCrafting.recipe.tests.dc"}}:{{this.check}} + {{localize "beaversCrafting.recipe.tests.dc"}}:{{test.check}}
{{/if}}
diff --git a/templates/beavers-recipe.hbs b/templates/beavers-recipe.hbs new file mode 100644 index 0000000..55a7c2d --- /dev/null +++ b/templates/beavers-recipe.hbs @@ -0,0 +1,116 @@ +
+
+ {{#if (or recipe.tests recipe.instruction)}} + {{#if recipe.instruction}} +
+
+ {{localize "beaversCrafting.crafting-app.instruction"}} +
+
+ {{{recipe.instruction}}} +
+
+ {{/if}} + {{#if recipe.tests}} +
+
+ {{localize "beaversCrafting.crafting-app.checks"}} +
+
+
+
+
+ + + {{localize "beaversCrafting.crafting-app.pass"}} {{maxHits}} + {{#if (gt recipe.tests.fails 1)}} + {{localize "beaversCrafting.crafting-app.before"}} {{recipe.tests.fails}} + {{localize "beaversCrafting.crafting-app.fails"}} + {{/if}} +
+
+
+ {{#each recipe.tests.ands}} +
+ + + {{#if @last}}{{else}}{{/if}} + +
+
+ {{hits}} times +
+ {{#each this.ors}} +
+ {{>beavers-recipe-test test=this abilities=../../abilities skills=../../skills tools=../../tools}} +
+ {{#unless @last}} +
+ {{/unless}} + {{/each}} +
+
+ {{/each}} +
+
+
+
+ {{/if}} + {{/if}} +
+
+ {{#if (not (isEmpty recipe.attendants))}} +
+
+ {{localize "beaversCrafting.crafting-app.required"}} +
+
+ {{#each recipe.attendants}} + {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients check=(lookup ../precast.attendants @key)}} + {{#unless @last}} +
+ {{/unless}} + {{/each}} +
+
+ {{/if}} + {{#if (or currencyComponent (not (isEmpty recipe.ingredients)))}} +
+
+ {{localize "beaversCrafting.crafting-app.cost"}} +
+
+ {{#if currencyComponent}} + {{>beavers-recipe-component component=currencyComponent check=precast.currencies}} + {{#if (not (isEmpty recipe.ingredients))}} +
+ {{/if}} + {{/if}} + {{#if (not (isEmpty recipe.ingredients))}} + {{#each recipe.ingredients}} + {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients check=(lookup ../precast.ingredients @key)}} + {{#unless @last}} +
+ {{/unless}} + {{/each}} + {{/if}} +
+
+ {{/if}} + {{#if (not (isEmpty recipe.results))}} +
+
+ {{localize "beaversCrafting.crafting-app.result"}} +
+
+ {{#each recipe.results}} + {{>beavers-recipe-component component=this key=@key clickable=../displayResults }} + {{#unless @last}} +
+ {{/unless}} + {{/each}} +
+
+ {{/if}} +
+
\ No newline at end of file diff --git a/templates/crafting-app-main.hbs b/templates/crafting-app-main.hbs index 40dcf7c..a0515a8 100644 --- a/templates/crafting-app-main.hbs +++ b/templates/crafting-app-main.hbs @@ -1,110 +1,8 @@ {{#if recipe}} -
-
- - - {{recipe.name}} - -
-
-
-
- {{#if (or recipe.tests recipe.instruction)}} -
- {{localize "beaversCrafting.crafting-app.instruction"}} -
-
- {{#if recipe.instruction}} - {{{recipe.instruction}}} - {{/if}} - {{#if recipe.tests}} -
- -
- {{#each recipe.tests.ands}} -
- - - {{#if @last}}{{else}}{{/if}} - -
-
- {{hits}} times -
- {{#each this.ors}} -
- {{>beavers-recipe-test abilities=../../abilities skills=../../skills tools=../../tools}} -
- {{#unless @last}} -
- {{/unless}} - {{/each}} -
-
- {{/each}} -
-
- {{/if}} -
- {{/if}} - {{#if (not (isEmpty recipe.attendants))}} -
- {{localize "beaversCrafting.crafting-app.required"}} -
-
- {{#each recipe.attendants}} - {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients check=(lookup ../precast.attendants @key)}} - {{#unless @last}} -
- {{/unless}} - {{/each}} -
- {{/if}} -
-
- {{#if (or currencyComponent (not (isEmpty recipe.ingredients)))}} -
- {{localize "beaversCrafting.crafting-app.cost"}} -
-
- {{#if currencyComponent}} - {{>beavers-recipe-component component=currencyComponent check=precast.currencies}} - {{#if (not (isEmpty recipe.ingredients))}} -
- {{/if}} - {{/if}} - {{#if (not (isEmpty recipe.ingredients))}} - {{#each recipe.ingredients}} - {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients check=(lookup ../precast.ingredients @key)}} - {{#unless @last}} -
- {{/unless}} - {{/each}} - {{/if}} -
- {{/if}} - {{#if (not (isEmpty recipe.results))}} -
- {{localize "beaversCrafting.crafting-app.result"}} -
-
- {{#each recipe.results}} - {{>beavers-recipe-component component=this key=@key clickable=../displayResults }} - {{#unless @last}} -
- {{/unless}} - {{/each}} -
- {{/if}} -
+
+ {{>beavers-recipe-component component=recipe}}
+ {{>beavers-recipe}}
- {{#if (eq check.isAvailable true) }} + {{#if (eq status 'success') }} - {{else if (eq check.isAvailable false) }} + {{else if (eq status 'error') }} + {{else if (eq status 'locked') }} + {{/if}}
{{#if editable}} diff --git a/templates/beavers-recipe-folders.hbs b/templates/beavers-recipe-folders.hbs index 8a38e39..aee75d8 100644 --- a/templates/beavers-recipe-folders.hbs +++ b/templates/beavers-recipe-folders.hbs @@ -7,7 +7,7 @@ {{#if @last}}{{else}}{{/if}} - + {{this.name}} diff --git a/templates/beavers-recipe.hbs b/templates/beavers-recipe.hbs index 55a7c2d..1fa21c4 100644 --- a/templates/beavers-recipe.hbs +++ b/templates/beavers-recipe.hbs @@ -66,7 +66,7 @@
{{#each recipe.attendants}} - {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients check=(lookup ../precast.attendants @key)}} + {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients status=(lookup ../precast.attendants @key)}} {{#unless @last}}
{{/unless}} @@ -81,14 +81,14 @@
{{#if currencyComponent}} - {{>beavers-recipe-component component=currencyComponent check=precast.currencies}} + {{>beavers-recipe-component component=currencyComponent status=precast.currencies.status}} {{#if (not (isEmpty recipe.ingredients))}}
{{/if}} {{/if}} {{#if (not (isEmpty recipe.ingredients))}} {{#each recipe.ingredients}} - {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients check=(lookup ../precast.ingredients @key)}} + {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients status=(lookup ../precast.ingredients @key)}} {{#unless @last}}
{{/unless}} diff --git a/templates/crafting-chat.hbs b/templates/crafting-chat.hbs index 7c53f57..aff0bd4 100644 --- a/templates/crafting-chat.hbs +++ b/templates/crafting-chat.hbs @@ -1,75 +1,41 @@
-
-
-
{{data.title}}
-
-
-
- {{#if (not (eq data.status "error"))}} -
-
{{data.tests.hitPer}} - % -
+
+ {{>beavers-recipe-component component=data}} +
+
+ {{#if (not (eq data.status "error"))}} +
+
+ {{data.tests.hitPer}}%
- {{/if}} - {{#if (not (eq data.status "success"))}} -
-
{{data.tests.failPer}} - % -
+
+ {{/if}} + {{#if (not (eq data.status "success"))}} +
+
+ {{data.tests.failPer}}%
- {{/if}} -
-
- {{#if (eq data.status "active") }} - - {{else if (eq data.status "success") }} - - {{else if (eq data.status "error") }} - - {{/if}} -
+
+ {{/if}} +
+
+ {{#if (eq data.status "active") }} + + {{else if (eq data.status "success") }} + + {{else if (eq data.status "error") }} + + {{/if}}
-
+
- {{#each data.components}} - {{#if (eq type "required")}} -
-
- {{this.component.name}} - -
- {{#if this.hasError }} - - {{else}} - - {{/if}} -
-
- {{/if}} - {{/each}} {{#each data.components}} {{#if (eq type "consumed")}} -
-
- {{this.component.quantity}} {{this.component.name}} - -
- {{#if this.hasError }} - - {{else}} - - {{/if}} -
-
+ {{>beavers-recipe-component component=this.component status=this.status }} {{/if}} {{/each}}
@@ -81,14 +47,7 @@
{{#each data.components}} {{#if (eq type "produced")}} -
-
-
- {{this.component.quantity}} {{this.component.name}} -
-
+ {{>beavers-recipe-component component=this.component status=this.status }} {{/if}} {{/each}}
diff --git a/templates/recipe-main.hbs b/templates/recipe-main.hbs index ed81471..ee80559 100644 --- a/templates/recipe-main.hbs +++ b/templates/recipe-main.hbs @@ -151,29 +151,28 @@ {{/if}}
- {{#if recipe.tests}} - {{#each recipe.tests.ands}} -
-
-
{{localize "beaversCrafting.recipe.tests.test"}}
-
- {{localize "beaversCrafting.recipe.tests.hits"}}: - -
- {{#if ../editable}} -
- - - + {{#if recipe.tests}} + {{#each recipe.tests.ands}} +
+
+
{{localize "beaversCrafting.recipe.tests.test"}}
+
+ {{localize "beaversCrafting.recipe.tests.hits"}}: +
- {{/if}} -
-
+ {{#if ../editable}} +
+ + + +
+ {{/if}} +
{{#each this.ors}}
@@ -233,18 +232,18 @@ {{/if}}
- + {{#if ../../editable}} -
- {{/each}} - {{/if}} + {{/each}} + {{/if}}
{{#if recipe.skill}} @@ -280,41 +278,41 @@ {{/if}}
- {{#if recipe.skill}} -
- -
- - -
- {{#if editable}} -
- - - + {{#if recipe.skill}} +
+ +
+ +
- {{/if}} -
- {{/if}} + {{#if editable}} +
+ + + +
+ {{/if}} +
+ {{/if}}
{{/if}} @@ -327,15 +325,15 @@ {{/if}}
- {{#each recipe.results}} + {{#each recipe.results}} {{>beavers-recipe-component component=this key=@key clickable=../displayResults editable=../editable}}
- {{/each}} - {{#if editable}} -
-
{{localize "beaversCrafting.recipe.dropItem"}}
-
- {{/if}} + {{/each}} + {{#if editable}} +
+
{{localize "beaversCrafting.recipe.dropItem"}}
+
+ {{/if}}
From a6c951db93d6aef7b6818a0314251e51ef884292 Mon Sep 17 00:00:00 2001 From: AngryBeaver Date: Sat, 8 Apr 2023 18:40:41 +0200 Subject: [PATCH 8/9] ui adaptions chat --- css/crafting.css | 7 ++ lang/en.json | 2 +- src/Crafting.ts | 46 ++++++--- src/Result.ts | 2 +- src/types.ts | 8 +- templates/actor-sheet-tab.hbs | 2 +- templates/beavers-recipe-component.hbs | 2 +- templates/beavers-recipe.hbs | 132 +++++++++++++++++-------- templates/crafting-chat.hbs | 10 +- 9 files changed, 140 insertions(+), 71 deletions(-) diff --git a/css/crafting.css b/css/crafting.css index 736e668..7256209 100644 --- a/css/crafting.css +++ b/css/crafting.css @@ -262,6 +262,10 @@ color:#468847; margin: auto; } +.beavers-crafting .fa-lock{ + color:darkorange; + margin: auto; +} /**************** beaver-component ****************/ @@ -313,6 +317,7 @@ beaver-component flex: 0; border-radius: 4px; margin: 2px; + border: 0px solid transparent; } .beavers-crafting .beavers-component .name { @@ -424,6 +429,8 @@ beaver-folder font-family: "Modesto Condensed", "Palatino Linotype", serif; overflow:hidden; text-overflow: ellipsis; + flex-wrap:nowrap; + white-space:nowrap; } .beavers-crafting .beavers-folder .beavers-folder-item img { diff --git a/lang/en.json b/lang/en.json index 4deb8b6..c861b22 100644 --- a/lang/en.json +++ b/lang/en.json @@ -99,7 +99,7 @@ }, "currencyExchange": { "name": "Exchange currencies", - "hint": "if disabled you need to poses the exact currency in order to pay the recipe cost" + "hint": "if disabled you need to possess the exact currency in order to pay the recipe cost" }, "toolButton": { "name": "Configure tools available", diff --git a/src/Crafting.ts b/src/Crafting.ts index b5cf5c9..72be0ca 100644 --- a/src/Crafting.ts +++ b/src/Crafting.ts @@ -392,22 +392,43 @@ export class Crafting implements CraftingData { } } } + get chatData(): ChatData { + return this.getChatData(); + } getChatData(): ChatData { - const components: ComponentChatData[] = []; + const components: { + required:ComponentChatData[], + consumed:ComponentChatData[], + produced:ComponentChatData[] + } = { + required:[], + consumed:[], + produced:[] + }; const hasError = this.result.hasError(); for (const componentResult of this.result._components.required._data) { const status = componentResult.hasError()?'error':!componentResult.isProcessed?'undefined':this.isFinished?'success':'locked'; - components.push({ + components.required.push({ component: componentResult.component, status: status, type: "required", isProcessed: componentResult.isProcessed }) } + if(this.result._currencyResult) { + const component = getCurrencyComponent(this.result._currencyResult?.name,this.result._currencyResult.value * -1) + const status = this.result._currencyResult.hasError?'error':!this.result._currencyResult.isConsumed?'undefined':this.isFinished?'success':'locked'; + components.consumed.push({ + component: component, + status: status, + type: "consumed", + isProcessed: this.result._currencyResult.isConsumed, + }); + } for (const componentResult of this.result._components.consumed._data) { const status = componentResult.hasError()?'error':!componentResult.isProcessed?'undefined':this.isFinished?'success':'locked'; - components.push({ + components.consumed.push({ component: componentResult.component, status: status, type: "consumed", @@ -417,7 +438,7 @@ export class Crafting implements CraftingData { for (const componentResult of this.result._components.produced._data) { if (componentResult.userInteraction === "always" || (componentResult.userInteraction === "onSuccess" && !hasError)) { const status = componentResult.hasError()?'error':!componentResult.isProcessed?'undefined':this.isFinished?'success':'locked'; - components.push({ + components.produced.push({ component: componentResult.component, status: status, type: "produced", @@ -425,18 +446,11 @@ export class Crafting implements CraftingData { }) } } - components.push(...Object.values(this.result._chatAddition).filter(s=>s.component.type !== "Currency")); - - if(this.result._currencyResult) { - const component = getCurrencyComponent(this.result._currencyResult?.name,this.result._currencyResult.value * -1) - const status = this.result._currencyResult.hasError?'error':!this.result._currencyResult.isConsumed?'undefined':this.isFinished?'success':'locked'; - components.push({ - component: component, - status: status, - type: "consumed", - isProcessed: this.result._currencyResult.isConsumed, + Object.values(this.result._chatAddition) + .filter(s=>s.component.type !== "Currency")//legacy + .forEach(c=>{ + components[c.type].push(c); }); - } const tests = {maxHits:1,maxFails:1,hits:0,fails:0,hitPer:0,failPer:0} @@ -462,7 +476,6 @@ export class Crafting implements CraftingData { status = "success"; tests.hitPer = 100; } - return { name: this.recipe.name, img: this.recipe.img, @@ -471,6 +484,7 @@ export class Crafting implements CraftingData { tests:tests, components: components, } + } async _sendToChat() { diff --git a/src/Result.ts b/src/Result.ts index 1c38611..831bf62 100644 --- a/src/Result.ts +++ b/src/Result.ts @@ -205,7 +205,7 @@ export class Result implements ResultApi, ResultData { component.quantity = this._currencyResult.value * -1 this.addChatComponent({ component: component, - hasError: this._currencyResult.hasError, + status: this._currencyResult.hasError?'error':'undefined', type: "consumed", isProcessed: false, }); diff --git a/src/types.ts b/src/types.ts index 262f5c6..bff94fa 100644 --- a/src/types.ts +++ b/src/types.ts @@ -54,9 +54,9 @@ interface ComponentResultsData { interface ComponentResultData { component: ComponentData, + isProcessed: boolean, originalQuantity: number, userInteraction: UserInteraction - isProcessed: boolean, } type UserInteraction = "always" | "never" | "onSuccess"; @@ -78,7 +78,11 @@ interface ComponentChatData { interface ChatData { name: string; img: string; - components:ComponentChatData[] + components:{ + required:ComponentChatData[], + consumed:ComponentChatData[], + produced:ComponentChatData[] + } status: string; skill?: { name: string, diff --git a/templates/actor-sheet-tab.hbs b/templates/actor-sheet-tab.hbs index d87ff3a..eacbf93 100644 --- a/templates/actor-sheet-tab.hbs +++ b/templates/actor-sheet-tab.hbs @@ -73,7 +73,7 @@
- {{>beavers-recipe recipe=this.crafting.recipe tools=../../tools skills=../../skills abilities=../../abilities}} + {{>beavers-recipe chatData=this.chatData recipe=this.crafting.recipe tools=../../tools skills=../../skills abilities=../../abilities}}
{{#if (not @last)}} diff --git a/templates/beavers-recipe-component.hbs b/templates/beavers-recipe-component.hbs index 6da51d8..8b5534b 100644 --- a/templates/beavers-recipe-component.hbs +++ b/templates/beavers-recipe-component.hbs @@ -12,7 +12,7 @@ {{else if (eq status 'error') }} {{else if (eq status 'locked') }} - + {{/if}}
{{#if editable}} diff --git a/templates/beavers-recipe.hbs b/templates/beavers-recipe.hbs index 1fa21c4..9a19be2 100644 --- a/templates/beavers-recipe.hbs +++ b/templates/beavers-recipe.hbs @@ -59,58 +59,106 @@ {{/if}}
- {{#if (not (isEmpty recipe.attendants))}} -
-
- {{localize "beaversCrafting.crafting-app.required"}} + {{#if chatData}} + {{#if (not isEmpty chatData.components.required)}} +
+
+ {{localize "beaversCrafting.crafting-app.required"}} +
+
+ {{#each chatData.components.required}} + {{>beavers-recipe-component component=this.component key=@key clickable=../displayIngredients status=this.status}} + {{#unless @last}} +
+ {{/unless}} + {{/each}} +
-
- {{#each recipe.attendants}} - {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients status=(lookup ../precast.attendants @key)}} - {{#unless @last}} -
- {{/unless}} - {{/each}} + {{/if}} + {{#if (not isEmpty chatData.components.consumed)}} +
+
+ {{localize "beaversCrafting.crafting-app.cost"}} +
+
+ {{#each chatData.components.consumed}} + {{>beavers-recipe-component component=this.component key=@key clickable=../displayIngredients status=this.status}} + {{#unless @last}} +
+ {{/unless}} + {{/each}} +
-
- {{/if}} - {{#if (or currencyComponent (not (isEmpty recipe.ingredients)))}} -
-
- {{localize "beaversCrafting.crafting-app.cost"}} + {{/if}} + {{#if (not isEmpty chatData.components.produced)}} +
+
+ {{localize "beaversCrafting.crafting-app.result"}} +
+
+ {{#each chatData.components.produced}} + {{>beavers-recipe-component component=this.component key=@key clickable=../displayIngredients status=this.status}} + {{#unless @last}} +
+ {{/unless}} + {{/each}} +
-
- {{#if currencyComponent}} - {{>beavers-recipe-component component=currencyComponent status=precast.currencies.status}} - {{#if (not (isEmpty recipe.ingredients))}} -
- {{/if}} - {{/if}} - {{#if (not (isEmpty recipe.ingredients))}} - {{#each recipe.ingredients}} - {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients status=(lookup ../precast.ingredients @key)}} + {{/if}} + {{else}} + {{#if (not (isEmpty recipe.attendants))}} +
+
+ {{localize "beaversCrafting.crafting-app.required"}} +
+
+ {{#each recipe.attendants}} + {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients status=(lookup ../precast.attendants @key)}} {{#unless @last}}
{{/unless}} {{/each}} - {{/if}} +
-
- {{/if}} - {{#if (not (isEmpty recipe.results))}} -
-
- {{localize "beaversCrafting.crafting-app.result"}} + {{/if}} + {{#if (or currencyComponent (not (isEmpty recipe.ingredients)))}} +
+
+ {{localize "beaversCrafting.crafting-app.cost"}} +
+
+ {{#if currencyComponent}} + {{>beavers-recipe-component component=currencyComponent status=precast.currencies.status}} + {{#if (not (isEmpty recipe.ingredients))}} +
+ {{/if}} + {{/if}} + {{#if (not (isEmpty recipe.ingredients))}} + {{#each recipe.ingredients}} + {{>beavers-recipe-component component=this key=@key clickable=../displayIngredients status=(lookup ../precast.ingredients @key)}} + {{#unless @last}} +
+ {{/unless}} + {{/each}} + {{/if}} +
-
- {{#each recipe.results}} - {{>beavers-recipe-component component=this key=@key clickable=../displayResults }} - {{#unless @last}} -
- {{/unless}} - {{/each}} + {{/if}} + {{#if (not (isEmpty recipe.results))}} +
+
+ {{localize "beaversCrafting.crafting-app.result"}} +
+
+ {{#each recipe.results}} + {{>beavers-recipe-component component=this key=@key clickable=../displayResults }} + {{#unless @last}} +
+ {{/unless}} + {{/each}} +
-
+ {{/if}} {{/if}}
\ No newline at end of file diff --git a/templates/crafting-chat.hbs b/templates/crafting-chat.hbs index aff0bd4..38b0c15 100644 --- a/templates/crafting-chat.hbs +++ b/templates/crafting-chat.hbs @@ -33,10 +33,8 @@
- {{#each data.components}} - {{#if (eq type "consumed")}} - {{>beavers-recipe-component component=this.component status=this.status }} - {{/if}} + {{#each data.components.consumed}} + {{>beavers-recipe-component component=this.component status=this.status }} {{/each}}
@@ -45,10 +43,8 @@
{{localize "beaversCrafting.recipe.results"}}
- {{#each data.components}} - {{#if (eq type "produced")}} + {{#each data.components.produced}} {{>beavers-recipe-component component=this.component status=this.status }} - {{/if}} {{/each}}
From 14fcbd79bf7bcad55a61905e68668c04d83ae9f0 Mon Sep 17 00:00:00 2001 From: AngryBeaver Date: Sat, 8 Apr 2023 18:42:50 +0200 Subject: [PATCH 9/9] ui adaptions chat --- README.md | 2 ++ module.json | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8554c00..42c5b62 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ by: ## Features ![img.gif](pictures/video.gif) +### demoVideo +https://www.youtube.com/watch?v=t3YGk8uFK0w ### Loot subtype Recipe ![img.png](pictures/newItem.png) For this to work you must go to your settings and enter the name of the create Item Dialog. diff --git a/module.json b/module.json index 4d64a9a..7e27da8 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "title": "Beaver's Crafting Module", "description": "A Crafting Module for DnD", "id": "beavers-crafting", - "version": "3.0.2", + "version": "3.1.0", "authors": [ { "name": "angryBeaver", diff --git a/package.json b/package.json index 056781a..1bce987 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "beavers-crafting", "title": "Beaver's Crafting", - "version": "3.0.2", + "version": "3.1.0", "description": "Crafting", "devDir": "C:\\Users\\Riess\\AppData\\Local\\FoundryVTT\\Data\\modules", "#devDir": "C:\\data\\Data\\modules",