feat(iggy-shim): LCE-style selection bar + fixed list-item sizing
- translucent blue selection bar drawn behind the focused control (LCE's menu highlight); focused label tinted yellow - FJ_List items render at a fixed font size and lay out in screen pixels from the list origin instead of inheriting the list's large bundle scale Menus now read like the real game: compact list rows with a highlight.
This commit is contained in:
Binary file not shown.
@@ -9,3 +9,6 @@
|
||||
1 972 1783450570988894511 CMakeFiles/iggy_shim.dir/src/ui_renderer.cpp.obj a0824e5e1d5925f
|
||||
972 1221 1783450572191715761 iggy_shim_w64.dll 54dc552610f77fab
|
||||
972 1221 1783450572191715761 iggy_shim_w64.lib 54dc552610f77fab
|
||||
3 1223 1783451017557865198 CMakeFiles/iggy_shim.dir/src/ui_renderer.cpp.obj a0824e5e1d5925f
|
||||
1223 1472 1783451019009884485 iggy_shim_w64.dll 54dc552610f77fab
|
||||
1223 1472 1783451019009884485 iggy_shim_w64.lib 54dc552610f77fab
|
||||
|
||||
Binary file not shown.
@@ -214,6 +214,9 @@ static std::string frameFile(const IggyObjectNode &n) {
|
||||
static void drawNode(GDrawFunctions *gd, IggyObjectNode &n, float ox, float oy,
|
||||
float sx, float sy, float alpha) {
|
||||
if (!n.visible || n.alpha <= 0.001) return;
|
||||
// list items are laid out in screen pixels from the list origin, so they
|
||||
// don't inherit the (often large) bundle scale of the list container.
|
||||
if (n.props.count(u"__listItem")) { sx = 1.f; sy = 1.f; }
|
||||
float nx = ox + (float)n.x * sx;
|
||||
float ny = oy + (float)n.y * sy;
|
||||
float nsx = sx * (float)n.scaleX;
|
||||
@@ -228,22 +231,32 @@ static void drawNode(GDrawFunctions *gd, IggyObjectNode &n, float ox, float oy,
|
||||
drawQuadRaw(tex, nx, ny, tex->w * nsx, tex->h * nsy, na);
|
||||
}
|
||||
|
||||
// focus highlight for buttons without distinct frame art
|
||||
auto focusedIt = n.props.find(u"__focused");
|
||||
bool focused = focusedIt != n.props.end() && focusedIt->second.asBool();
|
||||
bool isListItem = n.props.count(u"__listItem") != 0;
|
||||
|
||||
// label text (set by the game via Init/SetLabel)
|
||||
auto labelIt = n.props.find(u"label");
|
||||
if (labelIt != n.props.end() && labelIt->second.type == shim::Value::Type::String &&
|
||||
!labelIt->second.str.empty() && textHaveFont()) {
|
||||
float fontPx = 22.0f * nsy;
|
||||
// list items use a fixed size (they inherit the list's large bundle
|
||||
// scale otherwise); regular controls scale with the display.
|
||||
float fontPx = isListItem ? 26.0f : 22.0f * nsy;
|
||||
float tw = textMeasure(labelIt->second.str, fontPx);
|
||||
float boxW = tex && tex->w ? tex->w * nsx : 0.f;
|
||||
float boxH = tex && tex->h ? tex->h * nsy : fontPx;
|
||||
float tx = nx + (boxW > tw ? (boxW - tw) / 2 : 0);
|
||||
float ty = ny + (boxH - fontPx) * 0.5f;
|
||||
float white[4] = {1, 1, 1, na};
|
||||
float yellow[4] = {1, 1, 0.35f, na};
|
||||
|
||||
// LCE-style selection bar behind the focused control
|
||||
if (focused) {
|
||||
float barX = tx - 14, barY = ty - 6;
|
||||
float barW = tw + 28, barH = fontPx + 12;
|
||||
float bar[4] = {0.28f * na, 0.42f * na, 0.75f * na, 0.65f * na}; // premult blue
|
||||
rawQuad(nullptr, barX, barY, barW, barH, bar, false);
|
||||
}
|
||||
float white[4] = {na, na, na, na};
|
||||
float yellow[4] = {na, na, 0.32f * na, na};
|
||||
textDraw(gd, labelIt->second.str, tx, ty, fontPx, focused ? yellow : white);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user