Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,14 @@ EX void initConfig() {

param_b(keybd_subdir_enabled, "keybd_subdir_enabled", 0)->editable("control the pushing direction with TAB", 'P')->help("If set, you control the off-heptagon pushing direction with TAB. Otherwise, you control it by rotating the screen.");

param_str(pinnedglyphs, "pinned_glyphs", "")
->set_standard_editor(true)
->editable("pinned glyphs",
"A list of glyphs to always sort at the front, "
"and reserve space for even when they're not being displayed.",
'p')
->set_reaction(updateglyphpinned);

param_enum(glyphsortorder, parameter_names("glyph_sort", "glyph sort order"), glyphsortorder)
->editable({
{"first on top", ""},
Expand Down
38 changes: 32 additions & 6 deletions hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ enum eGlyphsortorder {
#endif

EX eGlyphsortorder glyphsortorder;
EX string pinnedglyphs;
EX bool glyphpinned[int(ittypes) + int(motypes)];

int zero = 0;

Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ EX void showOverview() {
}
else if(udiv == 2 && umod < ittypes) {
gotoHelp(generateHelpForItem(eItem(umod)));
help_extensions.push_back(help_extension{'p', glyphpinned[umod] ? XLAT("unpin from HUD") : XLAT("pin to HUD"), [umod] () {
glyphpinned[umod] ^= true;
updatepinnedglyphs();
popScreen();
}});
if(cheater) {
dialog::helpToEdit(items[umod], 0, 200, 10, 10);
dialog::get_ne().reaction = [] () {
Expand Down