From 6075228e5bc8f2f9e82f21cba9670daf6648f555 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 2 Mar 2025 22:05:19 +0100 Subject: [PATCH] rogueviz:: adapted to new atscreenpos --- rogueviz/ads/resources.cpp | 44 ++++++++--------- rogueviz/gobot.cpp | 16 +++---- rogueviz/graphs.cpp | 8 ++-- rogueviz/nilrider/planning.cpp | 10 ++-- rogueviz/nilrider/timestamp.cpp | 84 +++++++++++++++------------------ rogueviz/presentation.cpp | 15 +++--- rogueviz/statshot.cpp | 4 +- 7 files changed, 86 insertions(+), 95 deletions(-) diff --git a/rogueviz/ads/resources.cpp b/rogueviz/ads/resources.cpp index f6f69af1..cb6e7884 100644 --- a/rogueviz/ads/resources.cpp +++ b/rogueviz/ads/resources.cpp @@ -74,8 +74,6 @@ string get_resource_name(eResourceType id); string get_resource_help(eResourceType id, bool help); void display(int id, int y, ld val, ld maxv, ld tank, ld unit) { - auto sId = shiftless(Id); - // ld pix = 1 / (2 * cgi.hcrossf / cgi.crossf); color_t col = rsrc_color[id]; @@ -87,10 +85,12 @@ void display(int id, int y, ld val, ld maxv, ld tank, ld unit) { ld sta = max(20, current_display->xcenter - current_display->radius + 20); if(true) ctr = 20*y+10, sta = 20; + + auto ASP = atscreenpos(0,0); - for(int i=0; i 0) { ld end = sta + siz * val / maxv; - curvepoint(atscreenpos(sta, top, 1) * C0); - curvepoint(atscreenpos(end, top, 1) * C0); - curvepoint(atscreenpos(end, bot, 1) * C0); - curvepoint(atscreenpos(sta, bot, 1) * C0); - curvepoint(atscreenpos(sta, top, 1) * C0); - queuecurve(sId, col, col, PPR::ZERO); + curvepoint(eupoint(sta, top)); + curvepoint(eupoint(end, top)); + curvepoint(eupoint(end, bot)); + curvepoint(eupoint(sta, bot)); + curvepoint(eupoint(sta, top)); + queuecurve(ASP, col, col, PPR::ZERO); } if(unit > 0 && maxv / unit <= siz/2 + 1e-6) for(ld u=unit; u 0 && maxv / tank <= siz/2 + 1e-6) for(ld u=tank; u 0) { - shiftmatrix V = shiftless(atscreenpos(rad, rad, rad)); + shiftmatrix V = atscreenpos(rad, rad, rad); queuepolyat(V, cgi.shHugeDisk, player_colors[0], PPR::SUPERLINE); write_in_space(V, max_glfont_size, .8, its(sc.stones[0]), player_colors[1], 1); } if(current.captures[0] > 0) { - shiftmatrix V = shiftless(atscreenpos(rad * 3, rad, rad)); + shiftmatrix V = atscreenpos(rad * 3, rad, rad); write_in_space(V, max_glfont_size, .8, its(current.captures[0]), player_colors[1], 1); } if(sc.owned_by[0] > 0) { - shiftmatrix V = shiftless(atscreenpos(rad, rad * 3, rad)); + shiftmatrix V = atscreenpos(rad, rad * 3, rad); write_in_space(V, max_glfont_size, .8, its(sc.owned_by[0]), player_colors[1], 1); } if(sc.stones[1] > 0) { - shiftmatrix V = shiftless(atscreenpos(vid.xres-rad, rad, rad)); + shiftmatrix V = atscreenpos(vid.xres-rad, rad, rad); queuepolyat(V, cgi.shHugeDisk, player_colors[1], PPR::SUPERLINE); write_in_space(V, max_glfont_size, .8, its(sc.stones[1]), player_colors[0], 1); } if(current.captures[1] > 0) { - shiftmatrix V = shiftless(atscreenpos(vid.xres - rad * 3, rad, rad)); + shiftmatrix V = atscreenpos(vid.xres - rad * 3, rad, rad); write_in_space(V, max_glfont_size, .8, its(current.captures[1]), player_colors[0], 1); } if(sc.owned_by[1] > 0) { - shiftmatrix V = shiftless(atscreenpos(vid.xres - rad, rad * 3, rad)); + shiftmatrix V = atscreenpos(vid.xres - rad, rad * 3, rad); write_in_space(V, max_glfont_size, .8, its(sc.owned_by[1]), player_colors[1], 1); } if(sc.owned_by[2] > 0) { - shiftmatrix V = shiftless(atscreenpos(rad, vid.yres - rad, rad)); + shiftmatrix V = atscreenpos(rad, vid.yres - rad, rad); write_in_space(V, max_glfont_size, .8, its(sc.owned_by[2]), player_colors[2], 1); } if(sc.owned_by[3] > 0) { - shiftmatrix V = shiftless(atscreenpos(rad, vid.yres - rad, rad)); + shiftmatrix V = atscreenpos(rad, vid.yres - rad, rad); write_in_space(V, max_glfont_size, .8, its(sc.owned_by[3]), player_colors[3], 1); } diff --git a/rogueviz/graphs.cpp b/rogueviz/graphs.cpp index a1ab00fb..89128ab0 100644 --- a/rogueviz/graphs.cpp +++ b/rogueviz/graphs.cpp @@ -728,10 +728,10 @@ bool rogueviz_hud() { ld y = (current_display->radius * (i+.5)) / legit * 2 - current_display->radius + vid.yres/2; - transmatrix V = atscreenpos(x, y, current_display->radius/4); + shiftmatrix V = atscreenpos(x, y, current_display->radius/4); poly_outline = OUTLINE_NONE; - queuedisk(shiftless(V), vd.cp, true, NULL, i); + queuedisk(V, vd.cp, true, NULL, i); poly_outline = OUTLINE_DEFAULT; queuestr(int(x-rad), int(y), 0, rad*(svg::in?5:3)/4, vd.name, legend_color, 0, 16); } @@ -741,10 +741,10 @@ bool rogueviz_hud() { ld y = (current_display->radius * (i+isize(legend)+.5)) / legit * 2 - current_display->radius + vid.yres/2; - transmatrix V = atscreenpos(x, y, current_display->radius/8); + shiftmatrix V = atscreenpos(x, y, current_display->radius/8); poly_outline = t->color | 0xFF; - queuepolyat(shiftless(V), cgi.shTriangle, 0, PPR::MONSTER_HEAD); + queuepolyat(V, cgi.shTriangle, 0, PPR::MONSTER_HEAD); poly_outline = OUTLINE_DEFAULT; queuestr(int(x-rad), int(y), 0, rad*(svg::in?5:3)/4, t->name, legend_color, 0, 16); diff --git a/rogueviz/nilrider/planning.cpp b/rogueviz/nilrider/planning.cpp index 6068208a..5aa2e0e6 100644 --- a/rogueviz/nilrider/planning.cpp +++ b/rogueviz/nilrider/planning.cpp @@ -102,12 +102,10 @@ void level::compute_plan_transform() { dynamicval ga(vid.always3, false); dynamicval gi(ginf[gEuclid].g, giEuclid2); auto& cd = current_display; - auto sId = shiftless(Id); - ld pix = 1 / (2 * cgi.hcrossf / cgi.crossf); ld scale_x = (vid.xres - 2 * vid.fsize) / abs(real_maxx-real_minx); ld scale_y = (vid.yres - 2 * vid.fsize) / abs(real_maxy-real_miny); ld scale = min(scale_x, scale_y); - plan_transform = sId * atscreenpos(cd->xcenter, cd->ycenter, pix * scale) * eupush(-(real_minx+real_maxx)/2, (real_miny+real_maxy)/2) * MirrorY; + plan_transform = atscreenpos(cd->xcenter, cd->ycenter) * euscalexx(scale) * eupush(-(real_minx+real_maxx)/2, (real_miny+real_maxy)/2) * MirrorY; } bool restored = false; @@ -141,7 +139,7 @@ void level::draw_planning_screen() { auto& T = plan_transform; auto scr_to_map = [&] (hyperpoint h) { - transmatrix mousef = inverse(unshift(T)) * atscreenpos(h[0], h[1], 1); + transmatrix mousef = inverse_shift(T, atscreenpos(h[0], h[1])); h = mousef * C0; h /= h[2]; return h; @@ -246,12 +244,12 @@ int move_id = -1, move_dir = 0; bool level::handle_planning(int sym, int uni) { if(sym == PSEUDOKEY_WHEELUP || sym == SDLK_PAGEUP) { dynamicval g(geometry, gEuclid); - plan_transform.T = atscreenpos(mousex, mousey, 1.2) * inverse(atscreenpos(mousex, mousey, 1)) * plan_transform.T; + plan_transform = atscreenpos(mousex, mousey, 1.2) * inverse_shift(atscreenpos(mousex, mousey, 1), plan_transform); return true; } if(sym == PSEUDOKEY_WHEELDOWN || sym == SDLK_PAGEDOWN) { dynamicval g(geometry, gEuclid); - plan_transform.T = atscreenpos(mousex, mousey, 1) * inverse(atscreenpos(mousex, mousey, 1.2)) * plan_transform.T; + plan_transform = atscreenpos(mousex, mousey, 1) * inverse_shift(atscreenpos(mousex, mousey, 1.2), plan_transform); return true; } for(auto& b: buttons) if(uni == b.first) { diff --git a/rogueviz/nilrider/timestamp.cpp b/rogueviz/nilrider/timestamp.cpp index 16c197ce..5b27ca83 100644 --- a/rogueviz/nilrider/timestamp.cpp +++ b/rogueviz/nilrider/timestamp.cpp @@ -368,59 +368,53 @@ void timestamp::draw_instruments(level* l) { ld cx = rad * 2; ld cy = rad * 2; - auto sId = shiftless(Id); - - ld pix = 1 / (2 * cgi.hcrossf / cgi.crossf); - // clinometer cx += rad * 1.2; + auto ASP = atscreenpos(0, 0); + for(int i=-90; i<=90; i++) - curvepoint(atscreenpos(cx+cos(i * degree)*rad, cy-sin(i*degree)*rad, 1) * C0); + curvepoint(eupoint(cx+cos(i * degree)*rad, cy-sin(i*degree)*rad)); - curvepoint(atscreenpos(cx, cy+rad, 1) * C0); - queuecurve(sId, 0x000000FF, 0xFFFFFF80, PPR::ZERO); + curvepoint(eupoint(cx, cy+rad)); + queuecurve(ASP, 0x000000FF, 0xFFFFFF80, PPR::ZERO); - curvepoint(hpxy(0, 0)); - curvepoint(hpxy(rad, 0)); - /* curvepoint(hpxy(rad/4, 0)); - curvepoint(hpxy(0, rad)); - curvepoint(hpxy(-rad/4, 0)); - curvepoint(hpxy(rad/4, 0)); */ - queuecurve(sId * atscreenpos(cx, cy, pix) * spin(min_gfx_slope), 0x40, 0x40, PPR::ZERO); + curvepoint(eupoint(0, 0)); + curvepoint(eupoint(rad, 0)); + queuecurve(atscreenpos(cx, cy) * spin(min_gfx_slope), 0x40, 0x40, PPR::ZERO); - curvepoint(hpxy(rad/4, 0)); - curvepoint(hpxy(0, rad)); - curvepoint(hpxy(-rad/4, 0)); - curvepoint(hpxy(rad/4, 0)); - queuecurve(sId * atscreenpos(cx, cy, pix) * spin(90._deg + slope), 0xFF, 0x40C040FF, PPR::ZERO); + curvepoint(eupoint(rad/4, 0)); + curvepoint(eupoint(0, rad)); + curvepoint(eupoint(-rad/4, 0)); + curvepoint(eupoint(rad/4, 0)); + queuecurve(atscreenpos(cx, cy) * spin(90._deg + slope), 0xFF, 0x40C040FF, PPR::ZERO); // compass cx -= rad * 1.2; for(int i=0; i<360; i++) - curvepoint(atscreenpos(cx-cos(i * degree)*rad, cy-sin(i*degree)*rad, 1) * C0); + curvepoint(eupoint(cx-cos(i * degree)*rad, cy-sin(i*degree)*rad)); - queuecurve(sId, 0x000000FF, 0xFFFFFF80, PPR::ZERO); + queuecurve(ASP, 0x000000FF, 0xFFFFFF80, PPR::ZERO); for(int d: {1}) { // d == +1: direction arrow // d == -1: compass - curvepoint(hpxy(rad/4, 0)); - curvepoint(hpxy(0, rad)); - curvepoint(hpxy(-rad/4, 0)); + curvepoint(eupoint(rad/4, 0)); + curvepoint(eupoint(0, rad)); + curvepoint(eupoint(-rad/4, 0)); - queuecurve(sId * atscreenpos(cx, cy, pix) * spin(d * (90*degree + heading_angle)), 0xFF, d > 0 ? 0x0000FFFF : 0xFF0000FF, PPR::ZERO); + queuecurve(atscreenpos(cx, cy) * spin(d * (90*degree + heading_angle)), 0xFF, d > 0 ? 0x0000FFFF : 0xFF0000FF, PPR::ZERO); - curvepoint(hpxy(rad/4, 0)); - curvepoint(hpxy(0, -rad)); - curvepoint(hpxy(-rad/4, 0)); - curvepoint(hpxy(rad/4, 0)); - queuecurve(sId * atscreenpos(cx, cy, pix) * spin(d * (90*degree + heading_angle)), 0xFF, 0xFFFFFFFF, PPR::ZERO); + curvepoint(eupoint(rad/4, 0)); + curvepoint(eupoint(0, -rad)); + curvepoint(eupoint(-rad/4, 0)); + curvepoint(eupoint(rad/4, 0)); + queuecurve(atscreenpos(cx, cy) * spin(d * (90*degree + heading_angle)), 0xFF, 0xFFFFFFFF, PPR::ZERO); } // speed meter @@ -428,8 +422,8 @@ void timestamp::draw_instruments(level* l) { cx += rad * 3.4; for(int i=0; i<360; i++) - curvepoint(atscreenpos(cx-cos(i * degree)*rad, cy-sin(i*degree)*rad, 1) * C0); - queuecurve(sId, 0x000000FF, 0xFFFFFF80, PPR::ZERO); + curvepoint(eupoint(cx-cos(i * degree)*rad, cy-sin(i*degree)*rad)); + queuecurve(ASP, 0x000000FF, 0xFFFFFF80, PPR::ZERO); auto e_to_angle = [] (ld energy) { return 135*degree - 3 * atan(energy/10); @@ -439,26 +433,26 @@ void timestamp::draw_instruments(level* l) { for(auto h: short_lines) { auto a = e_to_angle(h); - curvepoint(hpxy(-sin(a)*rad*.95, -cos(a)*rad*.95)); - curvepoint(hpxy(-sin(a)*rad*.85, -cos(a)*rad*.85)); - queuecurve(sId * atscreenpos(cx, cy, pix), 0xFF, 0, PPR::ZERO); + curvepoint(eupoint(-sin(a)*rad*.95, -cos(a)*rad*.95)); + curvepoint(eupoint(-sin(a)*rad*.85, -cos(a)*rad*.85)); + queuecurve(atscreenpos(cx, cy), 0xFF, 0, PPR::ZERO); } vector long_lines = {0, 1, 5, 10, 20, 50}; for(auto h: long_lines) { auto a = e_to_angle(h); - curvepoint(hpxy(-sin(a)*rad*.95, -cos(a)*rad*.95)); - curvepoint(hpxy(-sin(a)*rad*.75, -cos(a)*rad*.75)); - queuecurve(sId * atscreenpos(cx, cy, pix), 0xFF, 0, PPR::ZERO); + curvepoint(eupoint(-sin(a)*rad*.95, -cos(a)*rad*.95)); + curvepoint(eupoint(-sin(a)*rad*.75, -cos(a)*rad*.75)); + queuecurve(atscreenpos(cx, cy), 0xFF, 0, PPR::ZERO); displaystr(cx -sin(a)*rad*.65, cy -cos(a)*rad*.65, 0, 8, its(h), 0, 8); } - curvepoint(hpxy(rad/4, 0)); - curvepoint(hpxy(0, -rad)); - curvepoint(hpxy(-rad/4, 0)); - curvepoint(hpxy(rad/4, 0)); - queuecurve(sId * atscreenpos(cx, cy, pix) * spin(e_to_angle(energy_in_squares())), 0xFF, 0xFF8080FF, PPR::ZERO); + curvepoint(eupoint(rad/4, 0)); + curvepoint(eupoint(0, -rad)); + curvepoint(eupoint(-rad/4, 0)); + curvepoint(eupoint(rad/4, 0)); + queuecurve(atscreenpos(cx, cy) * spin(e_to_angle(energy_in_squares())), 0xFF, 0xFF8080FF, PPR::ZERO); cx += rad; @@ -475,7 +469,7 @@ void timestamp::draw_instruments(level* l) { f = 0x40; } - queuepoly(sId * atscreenpos(cx+rad/2, cy+(tid&1?1:-1)*rad/3, pix * rad * 1.2) * spin(90*degree), cgi.shTriangle, f); + queuepoly(atscreenpos(cx+rad/2, cy+(tid&1?1:-1)*rad/3) * euscalexx(rad * 1.2) * spin(90*degree), cgi.shTriangle, f); tid++; if(tid == 2) { tid = 0; cx += rad/1.4; } } @@ -486,7 +480,7 @@ void timestamp::draw_instruments(level* l) { for(auto& g: l->goals) { bool gfailed = failed & Flag(gid); bool gsuccess = goals & Flag(gid); - shiftmatrix T = sId * atscreenpos(cx+rad/2, cy+(gid-1)*rad/1.2, pix * rad * 1.2); + shiftmatrix T = atscreenpos(cx+rad/2, cy+(gid-1)*rad/1.2) * euscalexx(rad * 1.2); poly_outline = 0xFF; color_t f = darkena(g.color, 0, 0xFF); if(gsuccess) { queuepoly(T * spin(90*degree), cgi.shGrail, f); diff --git a/rogueviz/presentation.cpp b/rogueviz/presentation.cpp index 2702401c..1a894d60 100644 --- a/rogueviz/presentation.cpp +++ b/rogueviz/presentation.cpp @@ -20,15 +20,16 @@ grapher::grapher(ld _minx, ld _miny, ld _maxx, ld _maxy) : minx(_minx), miny(_mi ld medx = (minx + maxx) / 2; ld medy = (miny + maxy) / 2; - hyperpoint zero = atscreenpos(cd.xcenter - sca * medx, cd.ycenter + sca * medy, 1) * C0; + shiftpoint zero = atscreenpos(cd.xcenter - sca * medx, cd.ycenter + sca * medy) * C0; - hyperpoint zero10 = atscreenpos(cd.xcenter - sca * medx + sca, cd.ycenter + sca * medy, 1) * C0; - hyperpoint zero01 = atscreenpos(cd.xcenter - sca * medx, cd.ycenter + sca * medy - sca, 1) * C0; + shiftpoint zero10 = atscreenpos(cd.xcenter - sca * medx + sca, cd.ycenter + sca * medy) * C0; + shiftpoint zero01 = atscreenpos(cd.xcenter - sca * medx, cd.ycenter + sca * medy - sca) * C0; T = shiftless(Id); - T.T[LDIM] = zero; - T.T[0] = zero10 - zero; - T.T[1] = zero01 - zero; + T.shift = zero.shift; + T.T[LDIM] = zero.h; + T.T[0] = zero10.h - zero.h; + T.T[1] = zero01.h - zero.h; T.T = transpose(T.T); } @@ -274,7 +275,7 @@ void dialog_add_latex(string s, color_t col, int size, flagtype flags) { rtver[i].texture[1] = (tex.base_y + (cy[i] ? tex.stry : 0.)) / tex.theight; ld x = dialog::dcenter + (cx[i]*2-1) * scale * tx; ld y = (dialog::top + dialog::tothei)/2 + (cy[i]*2-1) * scale * ty; - rtver[i].coords = glhr::pointtogl( atscreenpos(x, y, 1) * C0 ); + rtver[i].coords = glhr::pointtogl( atscreenpos(x, y).T * C0 ); } glhr::be_textured(); diff --git a/rogueviz/statshot.cpp b/rogueviz/statshot.cpp index 8535b4b3..33c4d772 100644 --- a/rogueviz/statshot.cpp +++ b/rogueviz/statshot.cpp @@ -7,14 +7,12 @@ namespace statshot { void fadeout(ld val) { flat_model_enabler fme; initquickqueue(); - ld pix = 1 / (2 * cgi.hcrossf / cgi.crossf); curvepoint(hyperpoint(-10, -10, 1, 1)); curvepoint(hyperpoint(vid.xres + 10, -10, 1, 1)); curvepoint(hyperpoint(vid.xres + 10, vid.yres + 10, 1, 1)); curvepoint(hyperpoint(-10, vid.yres + 10, 1, 1)); curvepoint(hyperpoint(-10, -10, 1, 1)); - shiftmatrix V = shiftless(atscreenpos(0, 0, pix)); - queuecurve(V, 0, (backcolor << 8) | int(val * 255), PPR::LINE); + queuecurve(atscreenpos(0, 0), 0, (backcolor << 8) | int(val * 255), PPR::LINE); quickqueue(); }