mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-09-30 10:58:15 +03:00
PartsEngine: Fix state stuck at CLICKED when target state is uninitialized
parts_set_state silently ignored transitions to uninitialized states, causing parts without a HOVERED state to remain in CLICKED after mouse release. Fall back through CLICKED -> HOVERED -> DEFAULT so the first initialized state is always selected. DEFAULT is accepted unconditionally as the terminal fallback, matching the original engine's behavior.
This commit is contained in:
+3
-1
@@ -881,7 +881,9 @@ bool parts_numeral_set_number(struct parts *parts, struct parts_numeral *num, in
|
||||
|
||||
void parts_set_state(struct parts *parts, enum parts_state_type state)
|
||||
{
|
||||
if (parts->state != state && parts->states[state].type != PARTS_UNINITIALIZED) {
|
||||
while (state > PARTS_STATE_DEFAULT && parts->states[state].type == PARTS_UNINITIALIZED)
|
||||
state--;
|
||||
if (parts->state != state) {
|
||||
parts->state = state;
|
||||
parts_dirty(parts);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user