mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
DJUI: Make cursor movement more predictable
This commit is contained in:
parent
2a4817b29b
commit
fc1db575bd
1 changed files with 4 additions and 4 deletions
|
|
@ -50,12 +50,12 @@ void djui_cursor_input_controlled_center(struct DjuiBase* base) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static f32 djui_cursor_base_distance(struct DjuiBase* base) {
|
static f32 djui_cursor_base_distance(struct DjuiBase* base, f32 xScale, f32 yScale) {
|
||||||
f32 x, y;
|
f32 x, y;
|
||||||
djui_cursor_base_hover_location(base, &x, &y);
|
djui_cursor_base_hover_location(base, &x, &y);
|
||||||
x -= gCursorX;
|
x -= gCursorX;
|
||||||
y -= gCursorY;
|
y -= gCursorY;
|
||||||
return sqrtf((x * x) + (y * y));
|
return sqrtf((x * x) * xScale + (y * y) * yScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void djui_cursor_move_check(s8 xDir, s8 yDir, struct DjuiBase** pick, struct DjuiBase* base) {
|
static void djui_cursor_move_check(s8 xDir, s8 yDir, struct DjuiBase** pick, struct DjuiBase* base) {
|
||||||
|
|
@ -74,8 +74,8 @@ static void djui_cursor_move_check(s8 xDir, s8 yDir, struct DjuiBase** pick, str
|
||||||
if (*pick == NULL) {
|
if (*pick == NULL) {
|
||||||
*pick = base;
|
*pick = base;
|
||||||
} else {
|
} else {
|
||||||
f32 pickDist = djui_cursor_base_distance(*pick);
|
f32 pickDist = djui_cursor_base_distance(*pick, xDir ? 1.0f : 10.0f, yDir ? 1.0f : 10.0f);
|
||||||
f32 baseDist = djui_cursor_base_distance(base);
|
f32 baseDist = djui_cursor_base_distance(base, xDir ? 1.0f : 10.0f, yDir ? 1.0f : 10.0f);
|
||||||
if (baseDist < pickDist) {
|
if (baseDist < pickDist) {
|
||||||
*pick = base;
|
*pick = base;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue