mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-11-16 05:37:11 +00:00
Add support for pinning glyphs to a consistent spot in the HUD
This commit is contained in:
38
hud.cpp
38
hud.cpp
@@ -58,6 +58,8 @@ enum eGlyphsortorder {
|
||||
#endif
|
||||
|
||||
EX eGlyphsortorder glyphsortorder;
|
||||
EX string pinnedglyphs;
|
||||
EX bool glyphpinned[int(ittypes) + int(motypes)];
|
||||
|
||||
int zero = 0;
|
||||
|
||||
@@ -80,6 +82,27 @@ int glyphorder[glyphs];
|
||||
int glyphphase[glyphs];
|
||||
int glyph_lastticks;
|
||||
|
||||
EX void updateglyphpinned() {
|
||||
for(int i=0; i<glyphs; i++) glyphpinned[i] = false;
|
||||
if(!pinnedglyphs.empty()) {
|
||||
exp_parser ep;
|
||||
ep.s = pinnedglyphs;
|
||||
do {
|
||||
int i = ep.iparse();
|
||||
if(i >= 0 && i < glyphs) glyphpinned[i] = true;
|
||||
} while(ep.eat(","));
|
||||
}
|
||||
}
|
||||
|
||||
EX void updatepinnedglyphs() {
|
||||
std::stringstream ss;
|
||||
for(int i=0; i<glyphs; i++) {
|
||||
if(glyphpinned[i]) ss << i << ",";
|
||||
}
|
||||
pinnedglyphs = ss.str();
|
||||
if(!pinnedglyphs.empty()) pinnedglyphs.pop_back();
|
||||
}
|
||||
|
||||
void updatesort() {
|
||||
for(int i=0; i<glyphs; i++) {
|
||||
int ik = ikmerge(i);
|
||||
@@ -123,6 +146,8 @@ int glyphcorner(int i) {
|
||||
}
|
||||
|
||||
bool glyphsort(int i, int j) {
|
||||
if(glyphpinned[i] != glyphpinned[j])
|
||||
return glyphpinned[i] > glyphpinned[j];
|
||||
if(subclass(i) != subclass(j))
|
||||
return subclass(i) < subclass(j);
|
||||
if(glyphsortorder == gsoFirstTop)
|
||||
@@ -560,7 +585,7 @@ EX void drawStats() {
|
||||
else if(cornermode) {
|
||||
int bycorner[4];
|
||||
for(int u=0; u<4; u++) bycorner[u] = 0;
|
||||
for(int i=0; i<glyphs; i++) if(ikappear(i) && (glyphflags(i) & GLYPH_INSQUARE))
|
||||
for(int i=0; i<glyphs; i++) if((ikappear(i) || glyphpinned[i]) && (glyphflags(i) & GLYPH_INSQUARE))
|
||||
bycorner[glyphcorner(i)]++;
|
||||
updatesort();
|
||||
stable_sort(glyphorder, glyphorder+glyphs, glyphsort);
|
||||
@@ -579,7 +604,7 @@ EX void drawStats() {
|
||||
vector<int> glyphstoshow;
|
||||
for(int i=0; i<glyphs; i++) {
|
||||
int g = glyphorder[i];
|
||||
if(ikappear(g) && (glyphflags(g) & GLYPH_INSQUARE) && glyphcorner(g) == cor)
|
||||
if((ikappear(g) || glyphpinned[g]) && (glyphflags(g) & GLYPH_INSQUARE) && glyphcorner(g) == cor)
|
||||
glyphstoshow.push_back(g);
|
||||
}
|
||||
for(int u=vid.fsize; u<vid.xres/2-s; u += s)
|
||||
@@ -592,7 +617,8 @@ EX void drawStats() {
|
||||
if(cor&1) cx = vid.xres-1-s-cx;
|
||||
if(cor&2) cy = vid.yres-1-cy;
|
||||
|
||||
displayglyph2(cx, cy, s, glyphstoshow[next++]);
|
||||
int g = glyphstoshow[next++];
|
||||
if(ikappear(g)) displayglyph2(cx, cy, s, g);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -616,7 +642,7 @@ EX void drawStats() {
|
||||
|
||||
flagtype flag = portrait ? GLYPH_INPORTRAIT : GLYPH_INLANDSCAPE;
|
||||
|
||||
for(int i=0; i<glyphs; i++) if(ikappear(i))
|
||||
for(int i=0; i<glyphs; i++) if(ikappear(i) || glyphpinned[i])
|
||||
if(glyphflags(i) & flag)
|
||||
maxbyclass[glyphclass(i)]++;
|
||||
int buttonsize;
|
||||
@@ -651,7 +677,7 @@ EX void drawStats() {
|
||||
|
||||
for(int i0=0; i0<glyphs; i0++) {
|
||||
int i = glyphorder[i0];
|
||||
if(!ikappear(i)) continue;
|
||||
if(!ikappear(i) && !glyphpinned[i]) continue;
|
||||
int z = glyphclass(i);
|
||||
int imp = glyphflags(i);
|
||||
if(!(imp & flag)) continue;
|
||||
@@ -667,7 +693,7 @@ EX void drawStats() {
|
||||
|
||||
rowid[z]++; if(rowid[z] >= rows) rowid[z] = 0, colid[z]++;
|
||||
|
||||
displayglyph2(cx, cy, buttonsize, i);
|
||||
if(ikappear(i)) displayglyph2(cx, cy, buttonsize, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user