From 893af13c71f6a22d238c0d43a035048c41e090b6 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 3 Mar 2025 20:48:36 +0100 Subject: [PATCH] rogueviz::seuphorica:: render onboard tile details --- rogueviz/seuphorica.cpp | 155 +++++++++++++++++++++++++++++++--------- 1 file changed, 121 insertions(+), 34 deletions(-) diff --git a/rogueviz/seuphorica.cpp b/rogueviz/seuphorica.cpp index deec4ba8..3ade2ef2 100644 --- a/rogueviz/seuphorica.cpp +++ b/rogueviz/seuphorica.cpp @@ -72,18 +72,6 @@ string fix(string s) { return s; } -bool draw(cell *c, const shiftmatrix& V) { - auto sco = from(c); - if(!board.count(sco)) { c->wall = waNone; c->landparam = 0x202020; } - else { - auto& t = board.at(sco); - c->wall = waNone; c->landparam = gsp(t).background; - write_in_space(V /* ** ddspin(c,cdir,0)*/, 72, 1, t.letter, darkena(gsp(t).text_color, 0, 0xFF), 0, 8); - } - - return false; - } - int hold_mode; /* 1 = from board, 2 = from set, 3 = drag size */ const tile *tile_moved; vector* box_moved; @@ -91,25 +79,125 @@ int tile_boxid; cell *tile_moved_from; int *drag_what; -void render_tile(const shiftmatrix& V, const tile& t, vector* origbox, int boxid) { - curvepoint(eupoint(-1, -1)); - curvepoint(eupoint(-1, +1)); - curvepoint(eupoint(+1, +1)); - curvepoint(eupoint(+1, -1)); - curvepoint(eupoint(-1, -1)); - queuecurve(V, 0xFF, darkena(gsp(t).background, 0, 0xFF), PPR::ZERO); - write_in_space(V, 72, 2, t.letter, darkena(gsp(t).text_color, 0, 0xFF), 0, 8); - - auto h1 = inverse_shift_any(atscreenpos(0, 0), V * eupoint(-1, -1)); - auto h2 = inverse_shift_any(atscreenpos(0, 0), V * eupoint(+1, +1)); - if(mousex >= h1[0] && mousex <= h2[0] && mousey >= h1[1] && mousey <= h2[1] && !holdmouse) { - mouseovers = fix(tile_desc(t)); - getcstat = dialog::list_fake_key++; - dialog::add_key_action(getcstat, [&t, origbox, boxid] { - holdmouse = true; hold_mode = 2; - tile_moved = &t; box_moved = origbox; tile_boxid = boxid; - }); +bool tiles3 = true; + +struct wider { + dynamicval lw; + wider(ld x) : lw(vid.linewidth, vid.linewidth * x) {} + }; + +/** for tiles on the map, only (V,t,c) are defined; for tiles in boxes, (V,t,origbox,boxid) are defined */ +void render_tile(const shiftmatrix& V, const tile& t, cell *c, vector* origbox, int boxid) { + + auto pt0 = [&] (int id, ld r) { + if(c) return currentmap->get_corner(c, id+1, r); + return spin(-90._deg * id) * eupoint(-3/r, -3/r); + }; + + auto pt = [&] (ld id, ld r) { + int id0 = int(id); + if(id == id0) return pt0(id0, r); + auto p1 = pt0(id0, r), p2 = pt0(id0+1, r); + return lerp(p1, p2, id-id0); + }; + + int corners = c ? c->type : 4; + + color_t back = darkena(gsp(t).background, 0, 0xFF); + + auto V1 = V; + + color_t lines = 0x000000FF; + int wide = 1; + if(t.rarity == 2) lines = 0xFF4040FF, wide = 2; + if(t.rarity == 3) lines = 0xFFFF80FF, wide = 2; + if(t.rarity >= 4) lines = 0x40FF80FF, wide = 2; + if(t.special >= sp::first_artifact) lines = 0xFFD500FF, wide = 2; + dynamicval co(poly_outline, lines); + + if(c && tiles3) { + wider w(wide); + set_floor(cgi.shFullFloor); + for(int i=0; itype; i++) + if(!board.count(from(c->move(i)))) placeSidewall(c, i, SIDE_SLEV, V, back); + V1 = orthogonal_move_fol(V, cgi.SLEV[1]); + draw_qfi(c, V1, back, PPR::WALL3A); } + else { + wider w(wide); + for(int i=0; i<=corners; i++) curvepoint(pt(i, 3)); + queuecurve(V, lines, back, PPR::ITEM); + } + + const ld nearco = 4; + + if(has_power(t, sp::bending)) { + wider w(3); + queueline(V1 * pt0(0, nearco), V1 * pt0(corners/2, nearco), 0xC0C0FFFF, 2); + } + + if(has_power(t, sp::portal)) { + wider w(3); + queueline(V1 * pt0(1, nearco), V1 * pt0(1+corners/2, nearco), 0xFF8000FF, 2); + } + + if(has_power(t, sp::horizontal)) { + wider w(3); + queueline(V1 * pt0(0, nearco), V1 * pt0(1, nearco), 0xFFFFFFFF, 2); + queueline(V1 * pt0(3, nearco), V1 * pt0(2, nearco), 0xFFFFFFFF, 2); + } + + if(has_power(t, sp::vertical)) { + wider w(3); + queueline(V1 * pt0(0, nearco), V1 * pt0(3, nearco), 0xFFFFFFFF, 2); + queueline(V1 * pt0(1, nearco), V1 * pt0(2, nearco), 0xFFFFFFFF, 2); + } + + if(has_power(t, sp::initial)) { + wider w(3); + queueline(V1 * pt0(0, nearco), V1 * pt0(1, nearco), 0x000000FF, 2); + queueline(V1 * pt0(0, nearco), V1 * pt0(corners-1, nearco), 0x000000FF, 2); + } + + if(has_power(t, sp::final)) { + int ch = corners/2; + wider w(3); + queueline(V1 * pt(ch-0.3, nearco), V1 * pt0(ch-1, nearco), 0x000000FF, 2); + queueline(V1 * pt(ch+0.3, nearco), V1 * pt0(ch+1, nearco), 0x000000FF, 2); + } + + if(has_power(t, sp::symmetric)) { + wider w(2); + for(int i=0; i= h1[0] && mousex <= h2[0] && mousey >= h1[1] && mousey <= h2[1] && !holdmouse) { + mouseovers = fix(tile_desc(t)); + getcstat = dialog::list_fake_key++; + dialog::add_key_action(getcstat, [&t, origbox, boxid] { + holdmouse = true; hold_mode = 2; + tile_moved = &t; box_moved = origbox; tile_boxid = boxid; + }); + } + } + } + +bool draw(cell *c, const shiftmatrix& V) { + auto sco = from(c); + c->wall = waNone; c->landparam = 0x202020; + if(board.count(sco)) { + auto& t = board.at(sco); + render_tile(V, t, c, nullptr, -1); + } + + return false; } map where_is_tile; @@ -177,18 +265,17 @@ struct tilebox { } if(1) { - dynamicval lw(vid.linewidth, vid.linewidth * 5); + wider wid(5); queuecurve(ASP, darkena(col, 0, 0xFF), darkena(col, 0, 0x80), PPR::ZERO); write_in_space(ASP * eupush(*x2 - 10, *y1 + 20), 72, 50, title, darkena(col, 0, 0xFF), 16, 16); } int idx = 0; for(auto& t: *ptset) { - dynamicval lw(vid.linewidth, vid.linewidth * 3); dynamicval cs(cgi.scalefactor, 1); auto lt = locate_tile(t); if(&t == tile_moved && holdmouse) { idx++; continue; } - render_tile(ASP * eupush(lt) * euscalexx(20), t, ptset, idx++); + render_tile(ASP * eupush(lt) * euscalexx(20), t, nullptr, ptset, idx++); } } }; @@ -255,7 +342,7 @@ void seuphorica_screen() { } } - if(holdmouse && among(hold_mode, 1, 2)) render_tile(atscreenpos(mousex, mousey) * euscalexx(20), *tile_moved, nullptr, 0); + if(holdmouse && among(hold_mode, 1, 2)) render_tile(atscreenpos(mousex, mousey) * euscalexx(20), *tile_moved, nullptr, nullptr, 0); quickqueue(); }