SI units: V, A, W, Ω, F, Hz, s, and auto. Others may be added later if needed.
Arithmetic operators/functions: +, -, *, /, √, ^, Others may be added later if needed.
Unknown value, denoted by ?. Allowed only once in the expression.
Grouping elements: (, ). The calculator should do its best to automatically detect the intended use of the expression so that the player doesn't need to make excessive use of grouping elements.
Number + prefix + unit from component: A button 'C' will open a pop-up with a filterable list of all component properties in the level. Each entry should be: LevelComponent.Sprite + LevelComponent.Name + LevelComponent.PropertyN.Name,Multiplier,Value. When the player presses enter or clicks on an entry, its inserted into the expression (just a number followed by the prefix and unit).
All component physical properties in the game should map to one of the supported SI units.
The result of the ? element's unit must always be automatically calculable based on the operations and the units in the expression (even if it doesn't make any sense). (ie. A * Ω = V, V * A = W, Ω * Ω = Ω², A² * Ω = A²Ω, etc...)
It should consist of
Header (title + close button)
Body/frame.
Display, which holds the current expression, and a cursor movable by the arrow keys, or by clicking.
Buttons section, with buttons for all of the arithmetic elements and a keyboard shortcut for each button.
Consider persistence features like 'save/favorite expression', and history.
UI Design
WiP
Implementation
[x] Evaluate expressions with only numbers and a single variable.
[x] Support SI prefixes.
[x] Support SI units.
Create the 4 pop-up search-select menus
[ ] Insert formula.
[ ] Insert SI unit.
[ ] Insert SI prefix.
[ ] Insert numerical value, prefix, and unit from component property.
[x] Make all the buttons interactable.
[ ] Add shortcuts for all the buttons and navigational actions so that the calculator is fully usable by keyboard only.
[x] Add editor behavior and UI button to spawn/destroy/transform the calculator.
@Hazem-Gamall let's say the SI units are fine for now, we'll improve/fix them later. So the remaining tasks are only keyboard shortcuts and the 4 pop-up menus.
[x] Design
p
,n
,μ
,m
,k
,M
,G
.V
,A
,W
,Ω
,F
,Hz
,s
, andauto
. Others may be added later if needed.+
,-
,*
,/
,√
,^
, Others may be added later if needed.?
. Allowed only once in the expression.(
,)
. The calculator should do its best to automatically detect the intended use of the expression so that the player doesn't need to make excessive use of grouping elements.?
element's unit must always be automatically calculable based on the operations and the units in the expression (even if it doesn't make any sense). (ie.A * Ω = V
,V * A = W
,Ω * Ω = Ω²
,A² * Ω = A²Ω
, etc...)Implementation