mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-06-12 03:14:07 +00:00
filename for history band can be changed now
This commit is contained in:
parent
67ff42c37a
commit
7c29dd49c8
68
history.cpp
68
history.cpp
@ -387,8 +387,11 @@ EX namespace history {
|
|||||||
void restore();
|
void restore();
|
||||||
void restoreBack();
|
void restoreBack();
|
||||||
|
|
||||||
|
string band_format_now = "bandmodel-$DATE-$ID" IMAGEEXT;
|
||||||
|
string band_format_auto = "bandmodel-$DATE-$ID" IMAGEEXT;
|
||||||
|
|
||||||
#if CAP_SDL
|
#if CAP_SDL
|
||||||
EX void createImage(bool dospiral) {
|
EX void createImage(const string& name_format, bool dospiral) {
|
||||||
int segid = 1;
|
int segid = 1;
|
||||||
if(includeHistory) restore();
|
if(includeHistory) restore();
|
||||||
|
|
||||||
@ -421,6 +424,18 @@ EX namespace history {
|
|||||||
|
|
||||||
SDL_Surface *band = SDL_CreateRGBSurface(SDL_SWSURFACE, seglen, bandfull,32,0,0,0,0);
|
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) {
|
if(!band) {
|
||||||
addMessage("Could not create an image of that size.");
|
addMessage("Could not create an image of that size.");
|
||||||
}
|
}
|
||||||
@ -468,15 +483,7 @@ EX namespace history {
|
|||||||
xpos = bwidth * (extra_line_steps - bonus);
|
xpos = bwidth * (extra_line_steps - bonus);
|
||||||
|
|
||||||
if(xpos+bwidth > bandsegment) {
|
if(xpos+bwidth > bandsegment) {
|
||||||
char buf[154];
|
save_band_segment();
|
||||||
sprintf(buf, "bandmodel-%s-%03d" IMAGEEXT, timebuf, segid++);
|
|
||||||
|
|
||||||
IMAGESAVE(band, buf);
|
|
||||||
|
|
||||||
if(dospiral)
|
|
||||||
bands.push_back(band);
|
|
||||||
else
|
|
||||||
SDL_FreeSurface(band);
|
|
||||||
|
|
||||||
len -= bandsegment; xpos -= bandsegment;
|
len -= bandsegment; xpos -= bandsegment;
|
||||||
seglen = min(int(len), bandsegment);
|
seglen = min(int(len), bandsegment);
|
||||||
@ -491,15 +498,7 @@ EX namespace history {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[154];
|
save_band_segment();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rbuf.reset();
|
rbuf.reset();
|
||||||
@ -511,6 +510,13 @@ EX namespace history {
|
|||||||
for(int i=0; i<isize(bands); i++) SDL_FreeSurface(bands[i]);
|
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
|
#endif
|
||||||
|
|
||||||
EX bool band_renderable_now() {
|
EX bool band_renderable_now() {
|
||||||
@ -558,6 +564,12 @@ EX namespace history {
|
|||||||
if(band_renderable_now())
|
if(band_renderable_now())
|
||||||
dialog::addItem(XLAT("render now (length: %1)", fts(measureLength())), 'f');
|
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
|
#endif
|
||||||
|
|
||||||
dialog::addBack();
|
dialog::addBack();
|
||||||
@ -582,8 +594,11 @@ EX namespace history {
|
|||||||
else create_playerpath();
|
else create_playerpath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(uni == 'o')
|
else if(uni == 'o') {
|
||||||
autoband = !autoband;
|
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')
|
else if(uni == 'm')
|
||||||
pushScreen(models::model_menu);
|
pushScreen(models::model_menu);
|
||||||
else if(uni == 'a')
|
else if(uni == 'a')
|
||||||
@ -611,11 +626,11 @@ EX namespace history {
|
|||||||
includeHistory = !includeHistory;
|
includeHistory = !includeHistory;
|
||||||
}
|
}
|
||||||
#if CAP_SDL
|
#if CAP_SDL
|
||||||
else if(uni == 'f' && band_renderable_now()) createImage(dospiral);
|
else if(uni == 'f' && band_renderable_now())
|
||||||
#endif
|
open_filedialog_to_create_image(dospiral);
|
||||||
else if(uni == 'j') {
|
else if(uni == 'j')
|
||||||
autobandhistory = !autobandhistory;
|
autobandhistory = !autobandhistory;
|
||||||
}
|
#endif
|
||||||
else if(doexiton(sym, uni)) popScreen();
|
else if(doexiton(sym, uni)) popScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,7 +682,7 @@ EX namespace history {
|
|||||||
includeHistory = autobandhistory;
|
includeHistory = autobandhistory;
|
||||||
pmodel = mdBand;
|
pmodel = mdBand;
|
||||||
create_playerpath();
|
create_playerpath();
|
||||||
createImage(dospiral);
|
createImage(band_format_auto, dospiral);
|
||||||
clear();
|
clear();
|
||||||
pmodel = spm;
|
pmodel = spm;
|
||||||
includeHistory = ih;
|
includeHistory = ih;
|
||||||
@ -709,6 +724,9 @@ EX namespace history {
|
|||||||
addsaver(autoband, "automatic band");
|
addsaver(autoband, "automatic band");
|
||||||
addsaver(autobandhistory, "automatic band history");
|
addsaver(autobandhistory, "automatic band history");
|
||||||
addsaver(dospiral, "do spiral");
|
addsaver(dospiral, "do spiral");
|
||||||
|
|
||||||
|
addsaver(band_format_auto, "band_format_auto");
|
||||||
|
addsaver(band_format_now, "band_format_now");
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
2
tour.cpp
2
tour.cpp
@ -946,7 +946,7 @@ EX slide default_slides[] = {
|
|||||||
}
|
}
|
||||||
#if CAP_SDL
|
#if CAP_SDL
|
||||||
slidecommand = "render spiral";
|
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 == 11) history::create_playerpath();
|
||||||
if(mode == 13) history::clear();
|
if(mode == 13) history::clear();
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user