Triforce v0.8.5

A Randomizer page in the launcher, a new title screen with Mods and Save Select tabs, scaling changes applied in game, the Jabu-Jabu bars fixed, renderer frame-time work and the brightness-flash fix, and fixes from the 0.8.4 reports.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-28 10:54:41 -06:00
parent 2df08c751e
commit b527e29adb
203 changed files with 18821 additions and 2051 deletions

View File

@@ -1,6 +1,7 @@
// The Insert menu's mouse: what a point over it is on. The menu records each control's rectangle as it draws it (Map::add, in
// the window image's pixels), and the next frame's mouse is tested against them (Map::at): the picture and the hit-test cannot
// drift apart, at any size. Plain arithmetic, no Vulkan or ImGui: tests/test_menu_hit.cpp checks it.
// drift apart, at any size. Plain arithmetic, no Vulkan or ImGui: tests/test_menu_hit.cpp checks it, and
// tests/test_menu_page_slider.py the page sliders (Bar: the scroll bar beside a list, held and drawn along by the mouse).
#pragma once
namespace mkwvk::menu_hit {
@@ -22,6 +23,7 @@ enum Part {
kButton, // the restart question's buttons: index 0 Later, 1 Restart now
kSearch, // ((Triforce) the Mods screen's search bar)
kKey, // ((Triforce) a key of its on-screen keyboard: index row * 10 + column, the wide keys' row 4 by their first column)
kScroll, // ((Triforce) a list's page slider, the scroll bar beside it: index the list's number, Map::bar_of(index) the bar)
};
struct Hit {
Part part = kNone;
@@ -51,6 +53,43 @@ inline int slider_permille(int v, int lo, int hi) {
return p < 0 ? 0 : p > 1000 ? 1000 : p;
}
/// ((Triforce) A list's page slider, the scroll bar beside it, as it was drawn: its track from y0 down to y1, beside a list n
/// long of which `shown` is in view, the first of it in view at `first` (rows, or pixels: the same unit for the three). Its
/// thumb is the part of the track the view is of the list. The mouse takes it as a touch slider: the thumb held with the
/// left button is drawn along with the cursor (grab at the press, drag while it is held), a press on the track off the
/// thumb brings the thumb's middle under the cursor first, so the list jumps to there, and is held the same way
struct Bar {
int id = -1; // (the list's number: the menu's own, vk_menu.cpp; -1 none)
float y0 = 0, y1 = 0; // (the track)
float n = 0, shown = 0, first = 0; // (the list)
float reach = 0; // (a short thumb is taken hold of this far either side of its middle, in pixels)
/// (a list longer than its view, on a track that has a length: there is somewhere to scroll to)
bool scrolls() const { return y1 > y0 && shown > 0 && n > shown; }
/// (the furthest the first in view can go: the list's end at the view's)
float most() const { return scrolls() ? n - shown : 0; }
/// The thumb's top with f the first in view, and the thumb's length
float thumb(float f) const { return scrolls() ? y0 + (y1 - y0) * f / n : y0; }
float length() const { return scrolls() ? (y1 - y0) * shown / n : y1 - y0; }
/// The first in view with the thumb's top at y, held to the list's ends
float first_at(float y) const {
if (!scrolls()) return 0;
const float f = (y - y0) * n / (y1 - y0), m = most();
return f < 0 ? 0 : f > m ? m : f;
}
/// A press at y: how far under the thumb's top the cursor has hold of it. On the thumb (a short one: within reach of its
/// middle), where the cursor is, so that the press alone moves nothing; elsewhere on the track, the thumb's middle, so
/// that the thumb comes under the cursor
float grab(float y) const {
const float top = thumb(first), len = length();
float a = top, b = top + len;
if (len < 2 * reach) a = top + len / 2 - reach, b = top + len / 2 + reach;
return y >= a && y < b ? y - top : len / 2;
}
/// Held by `grab`, the cursor at y: the first in view, held to the list's ends wherever the cursor went
float drag(float y, float grab) const { return first_at(y - grab); }
};
/// The controls as last drawn
struct Map {
struct Box {
@@ -64,15 +103,32 @@ struct Map {
};
static constexpr int kMax = 96;
static constexpr float kGrab = 6; // (a click this far past either end of a track still takes the end, in pixels)
static constexpr int kBars = 4; // ((Triforce) the page sliders a page can have: the Mods screen has two)
Box box[kMax];
int n = 0;
float ax0 = 0, ay0 = 0, ax1 = 0, ay1 = 0; // (the menu's area: off it, kOutside)
Bar bar[kBars]; // ((Triforce) the page sliders drawn: add_bar, bar_of)
int bars = 0;
void clear(float x0, float y0, float x1, float y1) { n = 0, ax0 = x0, ay0 = y0, ax1 = x1, ay1 = y1; }
void clear(float x0, float y0, float x1, float y1) { n = 0, bars = 0, ax0 = x0, ay0 = y0, ax1 = x1, ay1 = y1; }
void add(float x0, float y0, float x1, float y1, Part part, int index, float v0 = 0, float v1 = 0, float t0 = 0, float t1 = 0,
int side = 0, float vm = 0) {
if (n < kMax) box[n++] = {x0, y0, x1, y1, part, index, v0, v1, t0, t1, side, vm};
}
/// ((Triforce) A page slider as drawn: its box from x0 to x1 (the track, and room either side of it to take hold of it:
/// the track is thin), `past` pixels past the track's ends too (a press there takes the end), a kScroll of the bar's
/// number; and the bar, for the drag. One with nowhere to scroll to, or with no number, is not recorded: no hit
void add_bar(float x0, float x1, const Bar& b, float past = kGrab) {
if (b.id < 0 || !b.scrolls() || bars >= kBars || n >= kMax) return;
bar[bars++] = b;
add(x0, b.y0 - past, x1, b.y1 + past, kScroll, b.id);
}
/// (the page slider of that number as last drawn; null when the page drew none)
const Bar* bar_of(int id) const {
for (int i = 0; i < bars; i++)
if (bar[i].id == id) return &bar[i];
return nullptr;
}
Hit at(float x, float y) const {
Hit hit;
if (x < ax0 || y < ay0 || x >= ax1 || y >= ay1) return hit.part = kOutside, hit;