Skip to content

Commit

Permalink
Improve UI for issuing commands with context menus
Browse files Browse the repository at this point in the history
Merge branch 'feature/wall-building' into develop
  • Loading branch information
DomWilliams0 committed Jan 25, 2022
2 parents 6fb8142 + 00f7d8e commit 5fa08dc
Show file tree
Hide file tree
Showing 98 changed files with 3,081 additions and 1,258 deletions.
2 changes: 1 addition & 1 deletion .build/test_count.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"schemaVersion": 1, "label": "tests", "message": "188", "color": "blue"}
{"schemaVersion": 1, "label": "tests", "message": "192", "color": "blue"}
13 changes: 8 additions & 5 deletions .planning/backlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ An unorganized, unordered list of tasks to eventually get to. Tasks are deleted
* graph for fps/tps history
* measure ticks per second in perf window
* better tile selection
* live updating selection region
* selection shows if selected blocks are occluded
* depth selection
* show dimensions in-world
* arbitrary polygon that can be added to/subtracted from with $modifier+drag
* button to expand outwards/inwards by 1 block
* better entity selection
* click and drag to select multiple
* multiple clicks in the same place to iterate through overlapping entities
Expand Down Expand Up @@ -75,14 +77,14 @@ An unorganized, unordered list of tasks to eventually get to. Tasks are deleted
### Society-oriented behaviours
* more society level jobs
* place blocks, destroying what's currently there (DAG for dependencies)
* place walls (hollow rectangle)
* specify wall thickness and height
* specify thickness for wall building
* ai filtering at the job level on high-level requirements before considering all its subtasks
* preserve info about completed society jobs/tasks to show in the ui
* etiquette/morality "meters" that vary based on personality and mood. if low, they take things reserved for work items, take other's food, consider items stored inside other people's personal containers
* specify a limit on job reservations per task, e.g. 2 maximum on sawing a tree trunk
* expand concept of "society" to just be a gathering/group of related entities that emits jobs, e.g. family, guild, village
* allow multiple societies, e.g. someone has their family and village, a wild animal has its family/herd
* when issuing a society command, remove any that conflict (e.g. multiple hauls for the same thing)

#### Jobs and tools
* tool requirements for a job
Expand All @@ -92,6 +94,7 @@ An unorganized, unordered list of tasks to eventually get to. Tasks are deleted
* equip from storage on the way to the work location when all materials are available
* already held or equipped
* will need a better way of choosing the best person for a job, currently the first person to consider it will reserve it. possibly a voting phase/stage where each candidate volunteers via AI weight system, then the best candidate is chosen from them
* extend material reservation to include the specific materials in transit for a build, to avoid others considering hauling more when it's already on the way
* personality affects the desiribility of jobs - lazy/weak/injured people dont want to do physical work, selfish people dont want to work on society jobs, only things for themselves

##### Building
Expand All @@ -109,6 +112,7 @@ An unorganized, unordered list of tasks to eventually get to. Tasks are deleted
* allow smooth changing of material gathering target job without dropping the current haul
* prioritise material gathering for the most complete job, rather than random/round robin
* better handle a build job being set in a non-air position
* overlapping vertical builds need to be clearer, maybe collapse ui elements together


### Item stacks
Expand Down Expand Up @@ -198,7 +202,7 @@ An unorganized, unordered list of tasks to eventually get to. Tasks are deleted
* unchecked_unwrap
* inventory and physical body lookups/searches could be expensive, cache unchanged
* biggy: consider using separate ECS universes for long and short living entities, if having multiple geneations alive at a time has large memory usage
* dynstack for ai dses and considerations, to avoid the huge amount of boxing
* consider dynstack for ai dses and considerations, to avoid the huge amount of boxing
* experiment with PGO
* consider replacing expensive area link checking (extending into neighbour to check each block) with simple global lookup of (blockpos, direction, length)
* physics system is unnecessarily checking the bounds of every entity every tick - skip this expensive check if stationary and slab hasn't changed
Expand Down Expand Up @@ -229,7 +233,6 @@ An unorganized, unordered list of tasks to eventually get to. Tasks are deleted
* bug: occlusion flickers after world changes, updates are probably being queued for too long
* bug: occlusion shadows above a 9 block drop
* bug: occlusion shadows cast by blocks above current viewing slice (like treetops) look very weird
* bug: entities not rendered on a particular laptop (ticket #90)

## Building and testing
* fuzzing
Expand Down
33 changes: 33 additions & 0 deletions .planning/history/2022-01-25-wall-building.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Active tasks

* [X] fix over reserving of materials
* [~] pre-filled society stores of bricks
* [X] show ui block selection as it is dragged
* [~] block selection can be added to with ctrl+drag
* [~] show selection dimensions in world
* popups and ui selection changes
* [X] test popups with an invisible imgui window
* [X] selection-sensitive right click context menu
* [X] close popup on camera move
* [X] escape for clearing tile and entity selection (rebind quit)
* [X] improved ui for ordering people about and issuing society commands via popup
* [X] close popup after button pressed
* [X] build command
* [X] remove old command tabs
* [X] ui for creating jobs for building many blocks
* [X] ui for wall outline specifically?
* hovering over button should show outline preview
* [~] can specify thickness of wall
* [~] can shrink/expand selection by 1 block
* [~] extend material reservation to include the specific materials in transit for a build,
to avoid others considering hauling more when it's already on the way
* [X] register builds in data
* [X] validate build material definition exists?
* [X] cache build templates intead of iterating all each time
* [X] used cache strings for component names too
* [X] central registry of all builds including a unique identifier to refer to it in ui and its
requests
* [X] update controls in readme
* [X] display basic info about multiple entity selection in ui
* [~] when issuing a society command, remove any existing that conflict

Binary file added .screenshots/context-menu-build-orders.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 25 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ A one man effort to produce an **open source**, **intuitive** and **high perform

## Progress log

* 25 Jan 2022: <em>A better UI for selecting entities with a dragged selection, and for issuing commands via a right-click context menu. </em>
<p style="margin: auto">
<img src=".screenshots/context-menu-build-orders.gif" width="500"/>
</p>

* 08 Jan 2022: <em>In-world text labels to show entity types and names, job progress and item stack information.</em>
<p style="margin: auto">
<img src=".screenshots/stack-split-labelled.gif" width="500"/>
Expand Down Expand Up @@ -83,12 +88,12 @@ The `--scenario` parameter chooses a specific situation to spawn entities in, fo

*Note: the "game" is currently very much a demo and not very playable in the slightest. Abandon all expectations!*

* <kbd>Esc</kbd> to exit (most importantly)
* <kbd>R</kbd> to restart
* <kbd>Left-click</kbd> to select an entity and view their stats in the debug menu
* Command them to go to or break a selected block via `Divine control`
* Select an item and order it to be hauled to the tile selection in the `Society` menu
* <kbd>Alt</kbd>+<kbd>Esc</kbd> to exit (most importantly)
* <kbd>Alt</kbd>+<kbd>R</kbd> to restart
* <kbd>Right-click</kbd> to drag a selection over blocks in the world
* Command them to collaborate to break blocks via the `Society` menu
* Set and place blocks via the `Selection` menu
* Then <kbd>Right-click</kbd> in the bottom right corner to build there/destroy the blocks
* Move the selection up and down with buttons in the `World` tab
* <kbd>Left-click</kbd> (or drag) to select entities
* Then <kbd>Right-click</kbd> a location in the world, or another entity to order them around
* <kbd>Escape</kbd> to clear the current entity and world selections
* Move the camera sideways with <kbd>WASD</kbd>, and vertically with the <kbd>Arrow keys</kbd>
27 changes: 18 additions & 9 deletions TODOS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TODOs (401)
# TODOs (408)
* [.build/build-release.sh](.build/build-release.sh) (1)
* `# TODO declare sdl version somewhere else`
* [.build/run-tests.sh](.build/run-tests.sh) (1)
Expand Down Expand Up @@ -186,8 +186,6 @@
* `// TODO dont return a new vec of boxes, have some dignity`
* `let mut applicable_tasks = Vec::new(); // TODO reuse allocation`
* `// TODO collect jobs from society directly, which can filter them from the applicable work items too`
* [game/simulation/src/build/builds.rs](game/simulation/src/build/builds.rs) (1)
* `// TODO can this somehow return an iterator of build materials?`
* [game/simulation/src/build/material.rs](game/simulation/src/build/material.rs) (1)
* `// TODO flexible list of reqs based on components`
* [game/simulation/src/build/world_helper.rs](game/simulation/src/build/world_helper.rs) (1)
Expand Down Expand Up @@ -228,10 +226,19 @@
* `// TODO move this into Tick`
* `// TODO sort by elapsed() bool instead`
* `// TODO might be better to just insert sorted`
* [game/simulation/src/input/system.rs](game/simulation/src/input/system.rs) (3)
* [game/simulation/src/input/command.rs](game/simulation/src/input/command.rs) (2)
* `// TODO expand/contract in a direction`
* `// TODO only allocate uiresponse for those that need it`
* [game/simulation/src/input/popup.rs](game/simulation/src/input/popup.rs) (4)
* `// TODO bump alloc`
* `// TODO prioritise job`
* `// TODO support disabled buttons?`
* `// TODO too easy to forget checks here - consider having each declare true/false/ignore needed for every button`
* [game/simulation/src/input/system.rs](game/simulation/src/input/system.rs) (4)
* `// TODO multiple clicks in the same place should iterate through all entities in selection range`
* `// TODO spatial lookup for ui elements too`
* `// TODO select multiple entities`
* `// TODO spatial lookup for all entities contained in the given range`
* `// TODO additive tile selection`
* [game/simulation/src/item/component.rs](game/simulation/src/item/component.rs) (7)
* `// TODO proper nutritional value`
* `// TODO food debris - the last X fuel/proportion is inedible and has to be disposed of`
Expand Down Expand Up @@ -332,12 +339,11 @@
* `/// TODO provide size hint that could be used as an optimisation for a small number of tasks (e.g. smallvec)`
* [game/simulation/src/society/job/jobs/break_blocks.rs](game/simulation/src/society/job/jobs/break_blocks.rs) (1)
* `// TODO add display impl for WorldPositionRange`
* [game/simulation/src/society/job/jobs/build.rs](game/simulation/src/society/job/jobs/build.rs) (11)
* [game/simulation/src/society/job/jobs/build.rs](game/simulation/src/society/job/jobs/build.rs) (10)
* `// TODO build requirement engine for generic material combining`
* `// TODO support builds spanning multiple blocks/range`
* `// TODO fewer temporary allocations`
* `// TODO ensure this doesn't happen, or just handle it properly`
* `// TODO avoid this case`
* `// TODO allow "building" of a non-air block, and automatically emit a break task first?`
* `// TODO job is destined to fail...`
* `// TODO dont run this every tick, only when something changes or intermittently`
Expand Down Expand Up @@ -375,6 +381,8 @@
* `// TODO show actual steering direction alongside velocity`
* [game/simulation/src/steer/system.rs](game/simulation/src/steer/system.rs) (1)
* `// TODO cache allocation in system`
* [game/simulation/src/string.rs](game/simulation/src/string.rs) (1)
* `// TODO report panic when cache is empty`
* [game/world/src/block.rs](game/world/src/block.rs) (5)
* `// TODO store sparse block data in the slab instead of inline in the block`
* `// TODO define block types in data instead of code`
Expand Down Expand Up @@ -492,7 +500,8 @@
* `let _no_depth = Capability::DepthTest.scoped_disable(); // TODO clear depth mask instead`
* [renderer/engine/src/render/sdl/ui/windows/debug_renderer.rs](renderer/engine/src/render/sdl/ui/windows/debug_renderer.rs) (1)
* `// TODO proper default script path`
* [renderer/engine/src/render/sdl/ui/windows/selection.rs](renderer/engine/src/render/sdl/ui/windows/selection.rs) (9)
* [renderer/engine/src/render/sdl/ui/windows/selection.rs](renderer/engine/src/render/sdl/ui/windows/selection.rs) (10)
* `// TODO better support for multiple entity selection`
* `// TODO maintain own arena allocator to maintain UI after an entity dies`
* `// TODO component-specific widget`
* `// TODO list components on item that are relevant (i.e. not transform etc)`
Expand All @@ -501,7 +510,7 @@
* `// TODO switch to table API when available`
* `// TODO use the arena for this`
* `// TODO other job tabs`
* `// TODO proper way of checking if an entity is living`
* `// TODO proper way of checking if an entity is living e.g. separate component for container ownership`
* [renderer/engine/src/render/sdl/ui/windows/society.rs](renderer/engine/src/render/sdl/ui/windows/society.rs) (2)
* `// TODO preserve finished jobs and tasks for a bit and display them in the ui too`
* `// TODO use table API when available`
Expand Down
16 changes: 12 additions & 4 deletions game/ai/src/decision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ pub trait Dse<C: Context> {
name.strip_suffix("Dse").unwrap_or(name)
}

fn as_debug(&self) -> Option<&dyn Debug> {
None
}

fn weight(&self) -> DecisionWeight {
DecisionWeight::Plain(self.weight_type())
}
Expand Down Expand Up @@ -192,10 +196,6 @@ impl<C: Context, D: Dse<C>> WeightedDse<C, D> {
}

impl<C: Context, D: Dse<C>> Dse<C> for WeightedDse<C, D> {
fn name(&self) -> &'static str {
self.dse.name()
}

fn considerations(&self, out: &mut Considerations<C>) {
self.dse.considerations(out)
}
Expand All @@ -208,6 +208,14 @@ impl<C: Context, D: Dse<C>> Dse<C> for WeightedDse<C, D> {
self.dse.action(blackboard)
}

fn name(&self) -> &'static str {
self.dse.name()
}

fn as_debug(&self) -> Option<&dyn Debug> {
self.dse.as_debug()
}

fn weight(&self) -> DecisionWeight {
DecisionWeight::Weighted(self.dse.weight_type(), self.additional_weight)
}
Expand Down
Loading

0 comments on commit 5fa08dc

Please sign in to comment.