Explanations:
- Removed all the redundant constructor initializers
- Don't initialize the color members.
(Otherwise what's the point of it being an optional?)
- Some collapsing of stuff like ? true : false and similar cases
- Use operator* and operator-> instead of get() for optionals
-
It turns out that I had misunderstood the purpose of widget::layout_size_.
It's not a cache, it's an override. It's only set for widgets which have
been shrunk or whose sizes have otherwise been changed from the preferred
size.
As a result, commit c4be6a7ec881d74a0d46f3b068053b86bc1c7e17 ended up skipping relayout way too often.
This is pretty hacky and you can see the bars and numbers flicker purple during advancement, so this can be removed if a better way to achieve the same thing is implemented.
although stacked_widget supports similar functionality this is currently
not easily doable from the lua gui2 api. In particular
1) stacked_widget cannot add pages dynamically
2) multi_page can only contain one type of widget.
3) a stacked_widget inside a multi_page is ineffective since it
generates many unused widgets
4) a multi_page inside a stacked_widget is just unhandy to use
- Call shared_from_this() instead of taking the address
- Don't use raw pointers to attack_type
- Change some cases of attack_type objects that weren't owned by a shared_ptr
(either owned by another object or allocated directly on the stack)
List of files that currently call attack_type constructors:
- game_events/conditional_wml.cpp
- gui/dialogs/unit_attack.cpp
- scripting/lua_unit_attacks.cpp
- units/types.cpp
- units/unit.cpp
Each of these has been individually considered and made safe for use with
enable_shared_from_this. (Most of them already were safe.)
I was performing a value check on fade_step in the timer, and then multiplying it fivefold in the alpha
calculation, meaning full alpha was reached long before the fade in sequence stopped and the duration timer
was initialized.
Since all the floating images' data was set with a formula that relied on a canvas-wide variable whose value
was constantly changing and no serialization was done, the formulas all evaluated to the same location.
To fix this, we do away with the use of the variables and insert the necessary values directly into the formula
string.