1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-10-18 06:30:41 +00:00

nilrider:: do not switch level on saving a usergen level

This commit is contained in:
Zeno Rogue 2024-08-20 19:13:28 +02:00
parent 88b927e4b1
commit da5ba2bf2b
3 changed files with 9 additions and 7 deletions

View File

@ -579,7 +579,7 @@ void cleanup_textures() {
cleanup_texture(castle_texture);
}
void load_level(const string& fname) {
void load_level(const string& fname, bool init) {
fhstream f(fname, "r");
if(!f.f) throw hr_exception("could not open file ");
level lev("Untitled", '1', nrlUserCreated, "", -1, 1, 1, -1, {}, 0, 0, {}, rot_plane, { goal{0x40FF40, "Collect all the triangles", basic_check(999, 999)} });
@ -659,9 +659,11 @@ void load_level(const string& fname) {
}
else throw hr_exception("cannot use the same name as an official level");
}
curlev = new level(lev);
all_levels.emplace_back(curlev);
if(on) curlev->init();
if(init) {
curlev = new level(lev);
all_levels.emplace_back(curlev);
if(on) curlev->init();
}
}
}

View File

@ -317,7 +317,7 @@ void pick_level() {
dialog::add_action([] {
dialog::openFileDialog(fname, XLAT("level to load:"), ".nrl", [] () {
try {
load_level(fname);
load_level(fname, true);
return true;
}
catch(hr_exception& e) {
@ -771,7 +771,7 @@ auto celldemo = arg::add3("-unilcycle", initialize) + arg::add3("-unilplan", []
if(on) curlev->init();
})
+ arg::add3("-load-level", [] {
arg::shift(); load_level(arg::args());
arg::shift(); load_level(arg::args(), true);
})
+ arg::add3("-simplemodel", [] {
nisot::geodesic_movement = false;

View File

@ -100,7 +100,7 @@ void load() {
if(s == "*RLE") { have_rle = true; continue; }
if(s == "*FILE") {
string s1 = scanline_noblank(f);
try { load_level(s1); }
try { load_level(s1, false); }
catch(hr_exception& e) { println(hlog, "error: could not load level ", s1, ", reason: ", e.what()); }
}
if(s == "*MANUAL") {