1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-01-20 06:03:01 +00:00

filename for history band can be changed now

This commit is contained in:
Zeno Rogue 2021-02-04 17:13:33 +01:00
parent 67ff42c37a
commit 7c29dd49c8
2 changed files with 44 additions and 26 deletions

View File

@ -386,9 +386,12 @@ EX namespace history {
void restore();
void restoreBack();
string band_format_now = "bandmodel-$DATE-$ID" IMAGEEXT;
string band_format_auto = "bandmodel-$DATE-$ID" IMAGEEXT;
#if CAP_SDL
EX void createImage(bool dospiral) {
EX void createImage(const string& name_format, bool dospiral) {
int segid = 1;
if(includeHistory) restore();
@ -421,6 +424,18 @@ EX namespace history {
SDL_Surface *band = SDL_CreateRGBSurface(SDL_SWSURFACE, seglen, bandfull,32,0,0,0,0);
auto save_band_segment = [&] {
string fname = name_format;
replace_str(fname, "$DATE", timebuf);
replace_str(fname, "$ID", format("%03d", segid++));
IMAGESAVE(band, fname.c_str());
if(dospiral)
bands.push_back(band);
else
SDL_FreeSurface(band);
};
if(!band) {
addMessage("Could not create an image of that size.");
}
@ -468,15 +483,7 @@ EX namespace history {
xpos = bwidth * (extra_line_steps - bonus);
if(xpos+bwidth > bandsegment) {
char buf[154];
sprintf(buf, "bandmodel-%s-%03d" IMAGEEXT, timebuf, segid++);
IMAGESAVE(band, buf);
if(dospiral)
bands.push_back(band);
else
SDL_FreeSurface(band);
save_band_segment();
len -= bandsegment; xpos -= bandsegment;
seglen = min(int(len), bandsegment);
@ -491,15 +498,7 @@ EX namespace history {
}
}
char buf[154];
sprintf(buf, "bandmodel-%s-%03d" IMAGEEXT, timebuf, segid++);
IMAGESAVE(band, buf);
addMessage(XLAT("Saved the band image as: ") + buf);
if(dospiral)
bands.push_back(band);
else
SDL_FreeSurface(band);
save_band_segment();
}
rbuf.reset();
@ -511,6 +510,13 @@ EX namespace history {
for(int i=0; i<isize(bands); i++) SDL_FreeSurface(bands[i]);
}
}
EX void open_filedialog_to_create_image(bool ds) {
dialog::openFileDialog(band_format_now, XLAT("rendered band ($ID=segment, $DATE=date)"), ".png", [ds] () {
createImage(band_format_now, ds);
return true;
});
}
#endif
EX bool band_renderable_now() {
@ -558,6 +564,12 @@ EX namespace history {
if(band_renderable_now())
dialog::addItem(XLAT("render now (length: %1)", fts(measureLength())), 'f');
}
else if(!on) ;
else if(!hyperbolic)
dialog::addInfo(XLAT("more options in hyperbolic geometry"));
else if(!among(pmodel, mdBand, mdBandEquiarea, mdBandEquidistant))
dialog::addInfo(XLAT("more options in band projections"));
#endif
dialog::addBack();
@ -582,8 +594,11 @@ EX namespace history {
else create_playerpath();
}
}
else if(uni == 'o')
else if(uni == 'o') {
autoband = !autoband;
if(autoband)
dialog::openFileDialog(band_format_auto, XLAT("filename format to use ($ID=segment, $DATE=date)"), ".png", [] () { return true; });
}
else if(uni == 'm')
pushScreen(models::model_menu);
else if(uni == 'a')
@ -611,11 +626,11 @@ EX namespace history {
includeHistory = !includeHistory;
}
#if CAP_SDL
else if(uni == 'f' && band_renderable_now()) createImage(dospiral);
#endif
else if(uni == 'j') {
else if(uni == 'f' && band_renderable_now())
open_filedialog_to_create_image(dospiral);
else if(uni == 'j')
autobandhistory = !autobandhistory;
}
#endif
else if(doexiton(sym, uni)) popScreen();
}
@ -667,7 +682,7 @@ EX namespace history {
includeHistory = autobandhistory;
pmodel = mdBand;
create_playerpath();
createImage(dospiral);
createImage(band_format_auto, dospiral);
clear();
pmodel = spm;
includeHistory = ih;
@ -709,6 +724,9 @@ EX namespace history {
addsaver(autoband, "automatic band");
addsaver(autobandhistory, "automatic band history");
addsaver(dospiral, "do spiral");
addsaver(band_format_auto, "band_format_auto");
addsaver(band_format_now, "band_format_now");
});
}

View File

@ -946,7 +946,7 @@ EX slide default_slides[] = {
}
#if CAP_SDL
slidecommand = "render spiral";
if(mode == 4) history::createImage(true);
if(mode == 4) history::open_filedialog_to_create_image(true);
if(mode == 11) history::create_playerpath();
if(mode == 13) history::clear();
#endif