Opened 10 years ago
Last modified 5 years ago
#2826 new task
Refactor the state machine in input.js
Reported by: | Rolf Sievers | Owned by: | |
---|---|---|---|
Priority: | Should Have | Milestone: | Backlog |
Component: | UI – In-game | Keywords: | |
Cc: | Patch: |
Description (last modified by )
In the binaries/data/mods/public/gui/session/input.js file, there is a comment which reads:
// TODO: it'd probably be nice to have a better state-machine system, with guaranteed // entry/exit functions, since this is a bit broken now
What is there
A rather basic implementation of one concrete state machine. (no abstraction) On closer inspection, it turns out those are actually a bunch of smaller state machines glued together along their entry and exit paths to a „default state.“ There is a second state machine as well, for postGui event processing.
Proposed change
A lightweight abstract system which does not know a lot about it's content. It has a state (Bandboxing, Building, Tribute), such a state describes the mechanics of a „smaller state machine“ from the current code. The outer wrapper is not a state machine (no transitions) as it does not posses any interesting feature. The inner state is not forced to be a state machine, it's internal structure is not inspected by the outer wrapper. As most of the „smaller state machines“ have just a single state, that prevents unnecessary abstraction.
This untangles all the different features contained in that one function.
Furthermore the central code of preEngine event handling and postEngine event handling can be unified.
Interface of a „state“
Without specifying any particular structure yet, a state must allow the following:
- Initializing it (The state receives a quitCallback to terminate itself)
- Processing an event (returns whether it was eaten or not)
- Terminating it
Obvious solutions would be:
- pass three parameters
- pass an object
Change History (6)
comment:1 by , 10 years ago
Description: | modified (diff) |
---|
comment:2 by , 10 years ago
Description: | modified (diff) |
---|
comment:3 by , 10 years ago
Description: | modified (diff) |
---|
comment:4 by , 9 years ago
Description: | modified (diff) |
---|---|
Milestone: | Alpha 18 → Backlog |
Owner: | removed |
Summary: | Refactor the state machine in binaries/data/mods/public/gui/session/input.js → Refactor the state machine in input.js |
comment:5 by , 5 years ago
Description: | modified (diff) |
---|---|
Priority: | If Time Permits → Should Have |
Pretty relevant, as input.js is really clogged and error-prone.
comment:6 by , 5 years ago
Component: | UI & Simulation → In-game UI |
---|
Move tickets to In-game UI
as UI & Simulation
got some sub components.
Backlogging this due to stopped activity.