From b728e085a6e35f5f03b7583d0ddfd380d3d15436 Mon Sep 17 00:00:00 2001 From: Bronwen Date: Sat, 10 Jul 2021 23:20:51 -0400 Subject: [PATCH] few things idk --- content/core/actions/CoreActions.ts | 6 ++++-- package.json | 2 +- src/World.ts | 11 ++++++++++- src/ui/SelectItem.ts | 14 +++++++++++--- src/ui/UI.ts | 2 +- yarn.lock | 8 ++++---- 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/content/core/actions/CoreActions.ts b/content/core/actions/CoreActions.ts index f45111e..b590016 100644 --- a/content/core/actions/CoreActions.ts +++ b/content/core/actions/CoreActions.ts @@ -18,9 +18,11 @@ registerAction('Gather Flint', () => { Game.current.board.addTask(taskState); }); -registerAction('Create Arrowhead', () => { +registerAction('Create Arrowhead', async () => { // const rock = new ItemState(FLINT_NORMAL, 1, null); - const item = SelectItem.show() + const item = await SelectItem.show((itemState) => { + return true; + }); const task = new TaskState(MAKE_ARROWHEAD, { baseMaterial: rock }); diff --git a/package.json b/package.json index cc0ad15..b848641 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "@types/fs-extra": "^9.0.11", "@types/mocha": "^8.2.2", "@types/uuid": "^8.3.0", - "@types/ws": "^7.4.5", + "@types/ws": "^7.4.6", "bonjour": "^3.5.0", "chai": "^4.3.4", "chalk": "^4.1.1", diff --git a/src/World.ts b/src/World.ts index 0eb8a61..b4c1941 100644 --- a/src/World.ts +++ b/src/World.ts @@ -1,5 +1,14 @@ +import { ItemState } from "@items"; import { Serializable } from "frigid"; export class World extends Serializable { - + +} + +class WorldItemState { + itemState: ItemState + + constructor() { + + } } \ No newline at end of file diff --git a/src/ui/SelectItem.ts b/src/ui/SelectItem.ts index 2e4c912..97493e3 100644 --- a/src/ui/SelectItem.ts +++ b/src/ui/SelectItem.ts @@ -14,8 +14,8 @@ export class SelectItem { items: ItemState[]; selectedIdx: number; - static show(filter: ItemFilterFunction): Promise> { - const si = new SelectItem(filter, 1); + static show(filter: ItemFilterFunction, qty: number = 1): Promise> { + const si = new SelectItem(filter, qty); return new Promise(res => { si.emitter.on('selected', (itemState: ItemState) => { res(itemState); @@ -60,10 +60,18 @@ export class SelectItem { this.emitter.emit('selected', this.selectedItem.take(this.qty)); this.close(); } else if(key.full === 'down') { - + } }); this.items = Game.current.inv.items.filter(filter); + this.update(); this.open(); } + + + + update() { + this.box.setContent('test'); + panels.screen.render(); + } } \ No newline at end of file diff --git a/src/ui/UI.ts b/src/ui/UI.ts index 4dbf920..d248fd2 100644 --- a/src/ui/UI.ts +++ b/src/ui/UI.ts @@ -1,4 +1,3 @@ - import chalk from 'chalk'; import blessed from 'neo-blessed'; import ansi from 'sisteransi'; @@ -99,6 +98,7 @@ export function start() { process.stdout.write(ansi.cursor.hide); + // todo make a real menu screen.key(['C-c'], function() { process.stdout.write(ansi.cursor.show); setTimeout(_ => { diff --git a/yarn.lock b/yarn.lock index 532cbb1..17e473b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -60,10 +60,10 @@ version "8.3.0" resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.0.tgz#215c231dff736d5ba92410e6d602050cce7e273f" -"@types/ws@^7.4.5": - version "7.4.5" - resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.5.tgz#8ff0f7efcd8fea19f51f9dd66cb8b498d172a752" - integrity sha512-8mbDgtc8xpxDDem5Gwj76stBDJX35KQ3YBoayxlqUQcL5BZUthiqP/VQ4PQnLHqM4PmlbyO74t98eJpURO+gPA== +"@types/ws@^7.4.6": + version "7.4.6" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.6.tgz#c4320845e43d45a7129bb32905e28781c71c1fff" + integrity sha512-ijZ1vzRawI7QoWnTNL8KpHixd2b2XVb9I9HAqI3triPsh1EC0xH0Eg6w2O3TKbDCgiNNlJqfrof6j4T2I+l9vw== dependencies: "@types/node" "*"