mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-02 04:09:16 +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:
parent
329a2fa783
commit
5b41f5d157
61
dialogs.cpp
61
dialogs.cpp
@ -31,35 +31,46 @@ namespace dialog {
|
||||
namespace zoom {
|
||||
int zoomf = 1, shiftx, shifty;
|
||||
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_SDL
|
||||
#if CAP_MENUSCALING && CAP_SDL
|
||||
void handleZooming(SDL_Event &ev) {
|
||||
using namespace zoom;
|
||||
if(zoomoff || (cmode != emOverview && cmode != emTactic)) {
|
||||
zoomf = 1; shiftx = shifty = 0; zoomoff = false; 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(zoomoff || !(cmode & sm::ZOOMABLE)) {
|
||||
nozoom(); return;
|
||||
}
|
||||
if(ev.type == SDL_MOUSEBUTTONDOWN) initzoom();
|
||||
if(ev.type == SDL_MOUSEBUTTONUP && zoomf > 1) stopzoom();
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
inline void handleZooming(SDL_Event &ev) {}
|
||||
#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;
|
||||
|
||||
@ -855,15 +866,15 @@ namespace dialog {
|
||||
void displayPageButtons(int i, bool pages) {
|
||||
int i0 = vid.yres - vid.fsize;
|
||||
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';
|
||||
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';
|
||||
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';
|
||||
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';
|
||||
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;
|
||||
}
|
||||
|
||||
|
10
hyper.h
10
hyper.h
@ -1474,7 +1474,8 @@ extern bool timerghost;
|
||||
#define CAP_MENUSCALING (ISPANDORA || ISMOBILE)
|
||||
|
||||
#if CAP_MENUSCALING
|
||||
#define displayfrZ dialog::displayzoom
|
||||
#define displayfrZ dialog::zoom::displayfr
|
||||
#define displayfrZH dialog::zoom::displayfr_highlight
|
||||
#else
|
||||
#define displayfrZ displayfr
|
||||
#endif
|
||||
@ -1538,7 +1539,12 @@ namespace dialog {
|
||||
void scaleLog();
|
||||
void scaleSinh();
|
||||
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();
|
||||
|
||||
int handlePage(int& nl, int& nlm, int perpage);
|
||||
|
22
init.cpp
22
init.cpp
@ -310,21 +310,15 @@ void mobile_draw(MOBPAR_FORMAL) {
|
||||
if(inmenu && !clicked && !lclicked) inmenu = false;
|
||||
|
||||
bool keyreact = lclicked && !clicked;
|
||||
|
||||
if(cmode & sm::ZOOMABLE) {
|
||||
|
||||
#if CAP_MENUSCALING
|
||||
if(true) {
|
||||
using namespace dialog::zoom;
|
||||
if(zoomoff) {
|
||||
zoomf = 1; shiftx = shifty = 0; zoomoff = false; return;
|
||||
}
|
||||
if(clicked && !lclicked) {
|
||||
zoomf = 3;
|
||||
}
|
||||
if(zoomf == 3) {
|
||||
shiftx = -2*mousex;
|
||||
shifty = -2*mousey;
|
||||
}
|
||||
if(!clicked && zoomf > 1) { zoomoff = true; }
|
||||
}
|
||||
if(zoomoff || !(cmode & sm::ZOOMABLE)) nozoom();
|
||||
else if(clicked && !lclicked) initzoom();
|
||||
else if(!clicked && zoomf > 1) stopzoom();
|
||||
}
|
||||
#endif
|
||||
|
||||
if(inslider) keyreact = true;
|
||||
|
||||
|
18
menus.cpp
18
menus.cpp
@ -77,7 +77,7 @@ void showOverview() {
|
||||
if(landUnlocked(l)) col = linf[l].color; else col = 0x404040;
|
||||
if(l == curland)
|
||||
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;
|
||||
eItem it = treasureType(l);
|
||||
int lv = items[it] * landMultiplier(l);
|
||||
@ -86,20 +86,20 @@ void showOverview() {
|
||||
else if(items[it]) col = 0xC0C0C0;
|
||||
else col = BLACKISH;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
eItem io = nativeOrbType(l);
|
||||
if(io == itShard) {
|
||||
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;
|
||||
if(getcstat == 3000+waMirror)
|
||||
mouseovers = XLAT(
|
||||
@ -109,12 +109,12 @@ void showOverview() {
|
||||
if(lv >= 25) col = 0xFFD500;
|
||||
else if(lv >= 10) col = 0xC0C0C0;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
if(getcstat == 2000+io)
|
||||
mouseovers = XLAT(
|
||||
|
@ -712,16 +712,16 @@ namespace tactic {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if(unlocked || autocheat) {
|
||||
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;
|
||||
|
||||
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))
|
||||
getcstat = 1000 + i1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user