1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-02-02 12:19:18 +00:00

highlight buttons on overview/PTM screens; improved zoom feature; fixed a bug with zoom spilling to the inventory screen

This commit is contained in:
Zeno Rogue 2018-07-22 12:54:05 +02:00
parent 329a2fa783
commit 5b41f5d157
5 changed files with 64 additions and 53 deletions

View File

@ -31,35 +31,46 @@ namespace dialog {
namespace zoom { namespace zoom {
int zoomf = 1, shiftx, shifty; int zoomf = 1, shiftx, shifty;
bool zoomoff = false; bool zoomoff = false;
void nozoom() {
zoomf = 1; shiftx = 0; shifty = 0; zoomoff = false;
}
void initzoom() {
zoomf = 3;
shiftx = -2*mousex;
if(mousex < vid.xres / 6) shiftx = 0;
if(mousex > vid.xres * 5 / 6) shiftx = -2 * vid.xres;
shifty = -2*mousey;
if(mousey < vid.yres / 6) shifty = 0;
if(mousey > vid.yres * 5 / 6) shifty = -2 * vid.yres;
}
void stopzoom() { zoomoff = true; }
bool displayfr(int x, int y, int b, int size, const string &s, int color, int align) {
return hr::displayfr(x * zoomf + shiftx, y * zoomf + shifty, b, size * zoomf, s, color, align);
}
bool displayfr_highlight(int x, int y, int b, int size, const string &s, int color, int align, int hicolor) {
bool clicked = hr::displayfr(x * zoomf + shiftx, y * zoomf + shifty, b, size * zoomf, s, color, align);
if(clicked) hr::displayfr(x * zoomf + shiftx, y * zoomf + shifty, b, size * zoomf, s, hicolor, align);
return clicked;
}
}; };
#if CAP_MENUSCALING #if CAP_MENUSCALING && CAP_SDL
#if CAP_SDL
void handleZooming(SDL_Event &ev) { void handleZooming(SDL_Event &ev) {
using namespace zoom; using namespace zoom;
if(zoomoff || (cmode != emOverview && cmode != emTactic)) { if(zoomoff || !(cmode & sm::ZOOMABLE)) {
zoomf = 1; shiftx = shifty = 0; zoomoff = false; return; nozoom(); return;
}
if(ev.type == SDL_MOUSEBUTTONDOWN) {
zoomf = 3;
}
if(zoomf == 3) {
shiftx = -2*mousex;
shifty = -2*mousey;
}
if(ev.type == SDL_MOUSEBUTTONUP && zoomf > 1) {
zoomoff = true;
} }
if(ev.type == SDL_MOUSEBUTTONDOWN) initzoom();
if(ev.type == SDL_MOUSEBUTTONUP && zoomf > 1) stopzoom();
} }
#endif
#else #else
inline void handleZooming(SDL_Event &ev) {} inline void handleZooming(SDL_Event &ev) {}
#endif #endif
bool displayzoom(int x, int y, int b, int size, const string &s, int color, int align) {
using namespace zoom;
return displayfr(x * zoomf + shiftx, y * zoomf + shifty, b, size * zoomf, s, color, align);
}
vector<item> items; vector<item> items;
@ -855,15 +866,15 @@ namespace dialog {
void displayPageButtons(int i, bool pages) { void displayPageButtons(int i, bool pages) {
int i0 = vid.yres - vid.fsize; int i0 = vid.yres - vid.fsize;
int xr = vid.xres / 80; int xr = vid.xres / 80;
if(pages) if(displayfrZ(xr*8, i0, 1, vid.fsize, IFM("1 - ") + XLAT("page") + " 1", nlpage == 1 ? 0xD8D8C0 : 0xC0C0C0, 8)) if(pages) if(displayfrZH(xr*8, i0, 1, vid.fsize, IFM("1 - ") + XLAT("page") + " 1", nlpage == 1 ? 0xD8D8C0 : 0xC0C0C0, 8))
getcstat = '1'; getcstat = '1';
if(pages) if(displayfrZ(xr*24, i0, 1, vid.fsize, IFM("2 - ") + XLAT("page") + " 2", nlpage == 1 ? 0xD8D8C0 : 0xC0C0C0, 8)) if(pages) if(displayfrZH(xr*24, i0, 1, vid.fsize, IFM("2 - ") + XLAT("page") + " 2", nlpage == 1 ? 0xD8D8C0 : 0xC0C0C0, 8))
getcstat = '2'; getcstat = '2';
if(pages) if(displayfrZ(xr*40, i0, 1, vid.fsize, IFM("3 - ") + XLAT("all"), nlpage == 1 ? 0xD8D8C0 : 0xC0C0C0, 8)) if(pages) if(displayfrZH(xr*40, i0, 1, vid.fsize, IFM("3 - ") + XLAT("all"), nlpage == 1 ? 0xD8D8C0 : 0xC0C0C0, 8))
getcstat = '3'; getcstat = '3';
if(i&1) if(displayfrZ(xr*56, i0, 1, vid.fsize, IFM(keyname(SDLK_ESCAPE) + " - ") + XLAT("go back"), 0xC0C0C0, 8)) if(i&1) if(displayfrZH(xr*56, i0, 1, vid.fsize, IFM(keyname(SDLK_ESCAPE) + " - ") + XLAT("go back"), 0xC0C0C0, 8))
getcstat = '0'; getcstat = '0';
if(i&2) if(displayfrZ(xr*72, i0, 1, vid.fsize, IFM("F1 - ") + XLAT("help"), 0xC0C0C0, 8)) if(i&2) if(displayfrZH(xr*72, i0, 1, vid.fsize, IFM("F1 - ") + XLAT("help"), 0xC0C0C0, 8))
getcstat = SDLK_F1; getcstat = SDLK_F1;
} }

10
hyper.h
View File

@ -1474,7 +1474,8 @@ extern bool timerghost;
#define CAP_MENUSCALING (ISPANDORA || ISMOBILE) #define CAP_MENUSCALING (ISPANDORA || ISMOBILE)
#if CAP_MENUSCALING #if CAP_MENUSCALING
#define displayfrZ dialog::displayzoom #define displayfrZ dialog::zoom::displayfr
#define displayfrZH dialog::zoom::displayfr_highlight
#else #else
#define displayfrZ displayfr #define displayfrZ displayfr
#endif #endif
@ -1538,7 +1539,12 @@ namespace dialog {
void scaleLog(); void scaleLog();
void scaleSinh(); void scaleSinh();
void handleNavigation(int &sym, int &uni); void handleNavigation(int &sym, int &uni);
bool displayzoom(int x, int y, int b, int size, const string &s, int color, int align);
namespace zoom {
bool displayfr(int x, int y, int b, int size, const string &s, int color, int align);
bool displayfr_highlight(int x, int y, int b, int size, const string &s, int color, int align, int hicolor = 0xFFFF00);
}
bool editingDetail(); bool editingDetail();
int handlePage(int& nl, int& nlm, int perpage); int handlePage(int& nl, int& nlm, int perpage);

View File

@ -310,21 +310,15 @@ void mobile_draw(MOBPAR_FORMAL) {
if(inmenu && !clicked && !lclicked) inmenu = false; if(inmenu && !clicked && !lclicked) inmenu = false;
bool keyreact = lclicked && !clicked; bool keyreact = lclicked && !clicked;
if(cmode & sm::ZOOMABLE) { #if CAP_MENUSCALING
if(true) {
using namespace dialog::zoom; using namespace dialog::zoom;
if(zoomoff) { if(zoomoff || !(cmode & sm::ZOOMABLE)) nozoom();
zoomf = 1; shiftx = shifty = 0; zoomoff = false; return; else if(clicked && !lclicked) initzoom();
} else if(!clicked && zoomf > 1) stopzoom();
if(clicked && !lclicked) { }
zoomf = 3; #endif
}
if(zoomf == 3) {
shiftx = -2*mousex;
shifty = -2*mousey;
}
if(!clicked && zoomf > 1) { zoomoff = true; }
}
if(inslider) keyreact = true; if(inslider) keyreact = true;

View File

@ -77,7 +77,7 @@ void showOverview() {
if(landUnlocked(l)) col = linf[l].color; else col = 0x404040; if(landUnlocked(l)) col = linf[l].color; else col = 0x404040;
if(l == curland) if(l == curland)
displayfrZ(1, i0, 1, vf-4, "*", forecolor, 0); displayfrZ(1, i0, 1, vf-4, "*", forecolor, 0);
if(displayfrZ(xr*1, i0, 1, vf-4, XLAT1(linf[l].name), col, 0)) if(displayfrZH(xr*1, i0, 1, vf-4, XLAT1(linf[l].name), col, 0))
getcstat = 1000 + l; getcstat = 1000 + l;
eItem it = treasureType(l); eItem it = treasureType(l);
int lv = items[it] * landMultiplier(l); int lv = items[it] * landMultiplier(l);
@ -86,20 +86,20 @@ void showOverview() {
else if(items[it]) col = 0xC0C0C0; else if(items[it]) col = 0xC0C0C0;
else col = BLACKISH; else col = BLACKISH;
int c8 = (vf+2)/3; int c8 = (vf+2)/3;
if(displayfrZ(xr*24-c8*6, i0, 1, vf-4, its(items[it]), col, 16)) if(displayfrZH(xr*24-c8*6, i0, 1, vf-4, its(items[it]), col, 16))
getcstat = 2000+it; getcstat = 2000+it;
if(!cheater) if(!cheater)
if(displayfrZ(xr*24, i0, 1, vf-4, its(hiitems[modecode()][it]), col, 16)) if(displayfrZH(xr*24, i0, 1, vf-4, its(hiitems[modecode()][it]), col, 16))
getcstat = 2000+it; getcstat = 2000+it;
if(items[it]) col = iinf[it].color; else col = BLACKISH; if(items[it]) col = iinf[it].color; else col = BLACKISH;
if(displayfrZ(xr*24+c8*4, i0, 1, vf-4, s0 + iinf[it].glyph, col, 16)) if(displayfrZH(xr*24+c8*4, i0, 1, vf-4, s0 + iinf[it].glyph, col, 16))
getcstat = 2000+it; getcstat = 2000+it;
if(displayfrZ(xr*24+c8*5, i0, 1, vf-4, XLAT1(iinf[it].name), col, 0)) if(displayfrZH(xr*24+c8*5, i0, 1, vf-4, XLAT1(iinf[it].name), col, 0))
getcstat = 2000+it; getcstat = 2000+it;
eItem io = nativeOrbType(l); eItem io = nativeOrbType(l);
if(io == itShard) { if(io == itShard) {
if(items[it] >= 10) col = winf[waMirror].color; else col = BLACKISH; if(items[it] >= 10) col = winf[waMirror].color; else col = BLACKISH;
if(displayfrZ(xr*46, i0, 1, vf-4, XLAT1(winf[waMirror].name), col, 0)) if(displayfrZH(xr*46, i0, 1, vf-4, XLAT1(winf[waMirror].name), col, 0))
getcstat = 3000+waMirror; getcstat = 3000+waMirror;
if(getcstat == 3000+waMirror) if(getcstat == 3000+waMirror)
mouseovers = XLAT( mouseovers = XLAT(
@ -109,12 +109,12 @@ void showOverview() {
if(lv >= 25) col = 0xFFD500; if(lv >= 25) col = 0xFFD500;
else if(lv >= 10) col = 0xC0C0C0; else if(lv >= 10) col = 0xC0C0C0;
else col = BLACKISH; else col = BLACKISH;
if(displayfrZ(xr*46-c8*4, i0, 1, vf-4, its(items[io]), col, 16)) if(displayfrZH(xr*46-c8*4, i0, 1, vf-4, its(items[io]), col, 16))
getcstat = 2000+io; getcstat = 2000+io;
if(lv >= 10) col = iinf[io].color; else col = BLACKISH; if(lv >= 10) col = iinf[io].color; else col = BLACKISH;
if(displayfrZ(xr*46-c8, i0, 1, vf-4, s0 + iinf[io].glyph, col, 16)) if(displayfrZH(xr*46-c8, i0, 1, vf-4, s0 + iinf[io].glyph, col, 16))
getcstat = 2000+io; getcstat = 2000+io;
if(displayfrZ(xr*46, i0, 1, vf-4, XLAT1(iinf[io].name), col, 0)) if(displayfrZH(xr*46, i0, 1, vf-4, XLAT1(iinf[io].name), col, 0))
getcstat = 2000+io; getcstat = 2000+io;
if(getcstat == 2000+io) if(getcstat == 2000+io)
mouseovers = XLAT( mouseovers = XLAT(

View File

@ -712,16 +712,16 @@ namespace tactic {
if(unlocked) col = linf[l].color; else col = 0x202020; if(unlocked) col = linf[l].color; else col = 0x202020;
if(displayfrZ(xr*1, i0, 1, vf-4, XLAT1(linf[l].name), col, 0) && unlocked) { if(displayfrZH(xr*1, i0, 1, vf-4, XLAT1(linf[l].name), col, 0) && unlocked) {
getcstat = 1000 + i1; getcstat = 1000 + i1;
} }
if(unlocked || autocheat) { if(unlocked || autocheat) {
for(int ii=0; ii<ch; ii++) for(int ii=0; ii<ch; ii++)
if(displayfrZ(xr*(24+2*ii), i0, 1, (vf-4)*4/5, lsc[xc][l][ii] > 0 ? its(lsc[xc][l][ii]) : "-", col, 16)) if(displayfrZH(xr*(24+2*ii), i0, 1, (vf-4)*4/5, lsc[xc][l][ii] > 0 ? its(lsc[xc][l][ii]) : "-", col, 16))
getcstat = 1000 + i1; getcstat = 1000 + i1;
if(displayfrZ(xr*(24+2*10), i0, 1, (vf-4)*4/5, if(displayfrZH(xr*(24+2*10), i0, 1, (vf-4)*4/5,
its(recordsum[xc][l]) + " x" + its(tacmultiplier(l)), col, 0)) its(recordsum[xc][l]) + " x" + its(tacmultiplier(l)), col, 0))
getcstat = 1000 + i1; getcstat = 1000 + i1;
} }