mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-29 04:18:49 -04:00
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:
@@ -231,8 +231,10 @@ inline Image shrink_mask(const Image& m, uint32_t f) {
|
||||
/// (OptionBtnThinCursorGlow, a wider ramp) shows outside the line. The band is measured from the game's own cursor on its
|
||||
/// Options screen (1920 x 1080: the line 13 layout units thick, its inner edge a box of 809 x 114 units in the 960 x 260
|
||||
/// pane: the ramp from 0.34 to 0.65; about 20 units of blue-white glow outside it, nothing inside).
|
||||
/// *line and *glow: white, their strength in alpha (the glow is tinted and breathes at the draw)
|
||||
inline void make_cursor(const Image& ramp, const Image& wide, Image* line, Image* glow) {
|
||||
/// *line and *glow: white, their strength in alpha (the glow is tinted and breathes at the draw). ((Triforce, 11-26) falloff:
|
||||
/// how the glow dies away outside the line, fitted to the game's own cursors in the lab's SDR shots (ui083_cursor_fit): the
|
||||
/// Options rows' 1.35, the System list's buttons' 1.25; it was 1.6, a glow narrower and fainter than the game's)
|
||||
inline void make_cursor(const Image& ramp, const Image& wide, Image* line, Image* glow, float falloff = 1.35f) {
|
||||
auto step = [](float v, float a, float b) {
|
||||
const float t = std::clamp((v - a) / (b - a), 0.0f, 1.0f);
|
||||
return t * t * (3 - 2 * t);
|
||||
@@ -242,12 +244,100 @@ inline void make_cursor(const Image& ramp, const Image& wide, Image* line, Image
|
||||
const float l = ramp.rgba[i * 4 + 3] / 255.0f;
|
||||
const float g = i < (size_t)wide.w * wide.h ? wide.rgba[i * 4 + 3] / 255.0f : 0;
|
||||
const float la = step(l, 0.31f, 0.37f) * (1 - step(l, 0.62f, 0.69f));
|
||||
const float outside = std::pow(std::clamp(g / 0.36f, 0.0f, 1.0f), 1.6f) * (1 - step(l, 0.31f, 0.37f));
|
||||
const float outside = std::pow(std::clamp(g / 0.36f, 0.0f, 1.0f), falloff) * (1 - step(l, 0.31f, 0.37f));
|
||||
line->rgba[i * 4 + 3] = (unsigned char)(la * 255 + 0.5f);
|
||||
glow->rgba[i * 4 + 3] = (unsigned char)(outside * 255 + 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- ((Triforce, 11-25) the file select's cards, as the game's own Load list draws its saves (vk_menu.cpp draw_files). The
|
||||
// owner, of our file select at 21:9: "It is very broken and it's only optimized for 16:9 ... improve the design, fix up the
|
||||
// UI, use the in-game assets". The card is BtnDataFileBase_00 (its shape, white: the layout colours it), BtnDataFileFrame_01
|
||||
// (its frame and the line between the picture and the text) and BtnDataFileFrame_00 (the same with the rule under the place
|
||||
// and its curl), 997 x 283 texels; the game's card on a 1440-line screen is 1442 x 246 pixels of which the texture's is
|
||||
// 973 x 246, so the layout stretches it between the picture and the curl, the rest at its own size (the lab's capture of the
|
||||
// game's Load screen, 3440 x 1440: the picture 426 wide, the curl 235 from the right edge, as in the texture). Its colours
|
||||
// are measured there: the fill 143,102,46 to 160,116,55 in a fine grain, the frame 188,156,84, the rule a little darker
|
||||
constexpr uint32_t kFileCardKeepL = 470, kFileCardKeepR = 715; // (texels of the source: [0, 470) and [715, 997) keep their size)
|
||||
constexpr uint32_t kFileCardMore = 469; // (texels added between them)
|
||||
constexpr unsigned char kFileCardLo[3] = {143, 102, 46}, kFileCardHi[3] = {160, 116, 55};
|
||||
constexpr unsigned char kFileCardLine[3] = {188, 156, 84}, kFileCardRule[3] = {182, 148, 78};
|
||||
// (the rule and its curl, in Frame_00 only: this box of it; the frame's own lines are Frame_01's)
|
||||
constexpr uint32_t kFileRuleX0 = 470, kFileRuleX1 = 760, kFileRuleY0 = 128, kFileRuleY1 = 180;
|
||||
/// The card, the game's three textures in one picture as wide as the game draws it (kFileCardMore texels wider than they
|
||||
/// are): the fill in the shape, its grain from DecoNoise_00 (noise; none: the fill's middle colour), the frame, the rule.
|
||||
/// sRGB, not a mask: drawn white
|
||||
inline Image make_file_card(const Image& base, const Image& frame, const Image& ruled, const Image* noise) {
|
||||
Image out;
|
||||
out.w = base.w + kFileCardMore, out.h = base.h, out.srgb = true;
|
||||
out.rgba.assign((size_t)out.w * out.h * 4, 0);
|
||||
const auto source_x = [&](uint32_t x) -> uint32_t { // (the stretch: the source texel each of the card's comes from)
|
||||
if (x < kFileCardKeepL) return x;
|
||||
if (x >= kFileCardKeepR + kFileCardMore) return x - kFileCardMore;
|
||||
const float t = (float)(x - kFileCardKeepL) / (float)(kFileCardKeepR + kFileCardMore - kFileCardKeepL);
|
||||
return kFileCardKeepL + (uint32_t)(t * (float)(kFileCardKeepR - kFileCardKeepL));
|
||||
};
|
||||
const auto alpha_at = [](const Image& m, uint32_t x, uint32_t y) {
|
||||
return x < m.w && y < m.h ? m.rgba[((size_t)y * m.w + x) * 4 + 3] / 255.0f : 0.0f;
|
||||
};
|
||||
for (uint32_t y = 0; y < out.h; y++)
|
||||
for (uint32_t x = 0; x < out.w; x++) {
|
||||
const uint32_t sx = source_x(x);
|
||||
const float a_base = alpha_at(base, sx, y), a_line = alpha_at(frame, sx, y);
|
||||
const bool rule_box = sx >= kFileRuleX0 && sx < kFileRuleX1 && y >= kFileRuleY0 && y < kFileRuleY1;
|
||||
const float a_rule = rule_box ? alpha_at(ruled, sx, y) : 0.0f;
|
||||
const float a = std::max(a_base, a_line);
|
||||
if (a <= 0) continue;
|
||||
const float g = noise && noise->w && noise->h ? alpha_at(*noise, x % noise->w, y % noise->h) : 0.5f;
|
||||
float c[3];
|
||||
for (int k = 0; k < 3; k++) {
|
||||
c[k] = kFileCardLo[k] + (kFileCardHi[k] - kFileCardLo[k]) * g;
|
||||
c[k] += (kFileCardRule[k] - c[k]) * a_rule;
|
||||
c[k] += (kFileCardLine[k] - c[k]) * std::min(1.0f, a_line / a);
|
||||
}
|
||||
unsigned char* o = out.rgba.data() + ((size_t)y * out.w + x) * 4;
|
||||
for (int k = 0; k < 3; k++) o[k] = (unsigned char)std::clamp(c[k] + 0.5f, 0.0f, 255.0f);
|
||||
o[3] = (unsigned char)(a * 255 + 0.5f);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
/// The tag at the right of a card's first line (the game's "Autosave"; ours names the file): NumBaseAutoSave_00 its plate,
|
||||
/// NumBaseAutoSaveDeco_00 the line round it, both masks, in the colours measured on the game's (a dark olive, a light rim)
|
||||
constexpr unsigned char kFileTagFill[3] = {112, 86, 38}, kFileTagRim[3] = {176, 138, 72};
|
||||
inline Image make_file_tag(const Image& plate, const Image& rim) {
|
||||
Image out;
|
||||
out.w = plate.w, out.h = plate.h, out.srgb = true;
|
||||
out.rgba.assign((size_t)out.w * out.h * 4, 0);
|
||||
for (size_t i = 0; i < (size_t)out.w * out.h; i++) {
|
||||
const float ap = plate.rgba[i * 4 + 3] / 255.0f, ar = i < (size_t)rim.w * rim.h ? rim.rgba[i * 4 + 3] / 255.0f : 0.0f;
|
||||
const float a = std::max(ap, ar);
|
||||
if (a <= 0) continue;
|
||||
for (int k = 0; k < 3; k++) out.rgba[i * 4 + k] = (unsigned char)(kFileTagFill[k] + (kFileTagRim[k] - kFileTagFill[k]) * std::min(1.0f, ar / a) + 0.5f);
|
||||
out.rgba[i * 4 + 3] = (unsigned char)(a * 255 + 0.5f);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
/// The file select's pieces from the archive, added to the skin: "file_card", "file_tag", and the cursor round a card,
|
||||
/// "file_cursor_line" and "file_cursor_glow" (DataFileBtnCursorLine_00 and _Glow_00 are the same ramps as the options'
|
||||
/// cursor's, at the card's size: make_cursor). Each only when its textures are there; the page draws its own without them
|
||||
inline void make_file_skin(const Bntx& bntx, Skin& skin) {
|
||||
const auto read = [&](const char* name, Image& img) {
|
||||
const Bntx::Entry* e = bntx.find(name);
|
||||
return e && bntx.decode(*e, img);
|
||||
};
|
||||
Image base, frame, ruled, tag, rim, line, glow;
|
||||
if (read("BtnDataFileBase_00", base) && read("BtnDataFileFrame_01", frame) && read("BtnDataFileFrame_00", ruled) && frame.mask &&
|
||||
frame.w == base.w && ruled.w == base.w && base.w > kFileRuleX1 && base.w > kFileCardKeepR)
|
||||
skin.images.push_back({"file_card", make_file_card(base, frame, ruled, skin.get("DecoNoise_00"))});
|
||||
if (read("NumBaseAutoSave_00", tag) && read("NumBaseAutoSaveDeco_00", rim) && tag.mask && rim.mask)
|
||||
skin.images.push_back({"file_tag", make_file_tag(tag, rim)});
|
||||
if (read("DataFileBtnCursorLine_00", line) && read("DataFileBtnCursorGlow_00", glow) && line.mask && glow.mask) {
|
||||
Skin::Entry l{"file_cursor_line", {}}, g{"file_cursor_glow", {}};
|
||||
make_cursor(line, glow, &l.img, &g.img);
|
||||
skin.images.push_back(std::move(l)), skin.images.push_back(std::move(g));
|
||||
}
|
||||
}
|
||||
|
||||
/// The skin from the archive's bytes (a BNTX): false when it is not the game's (a texture of the list missing). (Triforce)
|
||||
/// The optional ones are the standalone menu's background (SystemBG_00's shade and noise): one missing is left out, and the
|
||||
/// menu draws its plain dim there instead (vk_ui.h system_bg); the skin stays
|
||||
@@ -287,13 +377,17 @@ inline bool make_skin(std::vector<unsigned char>&& bntx_bytes, Skin& skin) {
|
||||
"DataFileImportantIcon_05", "DataFileImportantIcon_06", "DataFileImportantIcon_07", "DataFileImportantIcon_08",
|
||||
"HeartBase_00", "HeartFrame_00", "NumBaseAutoSave_00",
|
||||
// (and for the achievements' icons, vk_menu.cpp ach_icon: a song's, a Gold Skulltula's mark, a rupee)
|
||||
"OcarinaMelodyIcon_00", "MapIconCollectSkullSign_00", "RupeeIconNew_00"};
|
||||
"OcarinaMelodyIcon_00", "MapIconCollectSkullSign_00", "RupeeIconNew_00",
|
||||
// ((Triforce, 11-25) the plates the stones and the medallions sit in on the game's Load list: the three stones' alone
|
||||
// (_00), the six medallions round the three stones (_01); the archive spells them so)
|
||||
"DataFileImportantStateBase_DataDileImportantStateBase_00", "DataFileImportantStateBase_DataDileImportantStateBase_01"};
|
||||
for (const char* n : more) {
|
||||
const Bntx::Entry* e = bntx.find(n);
|
||||
Skin::Entry out;
|
||||
out.name = n;
|
||||
if (e && bntx.decode(*e, out.img)) skin.images.push_back(std::move(out));
|
||||
}
|
||||
make_file_skin(bntx, skin); // ((Triforce, 11-25) the file select's cards, their tag and their cursor)
|
||||
const Image *shape = skin.get("BtnThinBase_00"), *grain = skin.get("BtnThinBase_05");
|
||||
Skin::Entry row{"plate_row", make_plate(*shape, *grain, skin.get("BtnThinBase_04"), kPlateBlack, kPlateWhite, kPlateLine)};
|
||||
Skin::Entry row_sel{"plate_row_sel", row.img}; // (the selected row's plate is the same: the game marks it with the cursor alone)
|
||||
@@ -306,8 +400,18 @@ inline bool make_skin(std::vector<unsigned char>&& bntx_bytes, Skin& skin) {
|
||||
Skin::Entry tab_sel{"tab_select", make_tinted(*tab, kTabBlack, kTabWhite)};
|
||||
skin.images.push_back(std::move(value)), skin.images.push_back(std::move(value_on)), skin.images.push_back(std::move(tab_sel));
|
||||
Skin::Entry line{"cursor_line", {}}, glow{"cursor_glow", {}};
|
||||
make_cursor(*skin.get("OptionBtnThinCursorLine_00"), *skin.get("OptionBtnThinCursorGlow_00"), &line.img, &glow.img);
|
||||
make_cursor(*skin.get("OptionBtnThinCursorLine_00"), *skin.get("OptionBtnThinCursorGlow_00"), &line.img, &glow.img, 1.35f);
|
||||
skin.images.push_back(std::move(line)), skin.images.push_back(std::move(glow));
|
||||
// ((Triforce, 11-26) the System list's buttons' own cursor (PaCommonBtnThin_00's N_Cursor_00: CmnBtnCursorLine_00 and
|
||||
// CmnBtnCursorGlow_00, its line hand drawn, uneven), for our buttons (vk_ui.h button): the owner's "use the in-game's
|
||||
// outline". Without them the Options rows' as before
|
||||
Image cmn_line, cmn_glow;
|
||||
const Bntx::Entry *el = bntx.find("CmnBtnCursorLine_00"), *eg = bntx.find("CmnBtnCursorGlow_00");
|
||||
if (el && eg && bntx.decode(*el, cmn_line) && bntx.decode(*eg, cmn_glow) && cmn_line.mask && cmn_glow.mask) {
|
||||
Skin::Entry cl{"cmn_cursor_line", {}}, cg{"cmn_cursor_glow", {}};
|
||||
make_cursor(cmn_line, cmn_glow, &cl.img, &cg.img, 1.25f);
|
||||
skin.images.push_back(std::move(cl)), skin.images.push_back(std::move(cg));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user