From b0ae2774a17407c941d9018868649dbc44225196 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 29 Sep 2022 11:10:16 +0200 Subject: [PATCH] ads-game:: 'pick the game' screen, also dS restarts correctly --- rogueviz/ads/ads-game.cpp | 50 +++++++++++++++++++++++++++++++------ rogueviz/ads/ds-game.cpp | 41 ++++++++++++++++++------------ rogueviz/ads/ds-texture.cpp | 4 +++ rogueviz/ads/globals.cpp | 5 ++++ rogueviz/ads/menu.cpp | 29 +++++++++++++++++++++ 5 files changed, 106 insertions(+), 23 deletions(-) diff --git a/rogueviz/ads/ads-game.cpp b/rogueviz/ads/ads-game.cpp index 5a890ea0..7f24ef32 100644 --- a/rogueviz/ads/ads-game.cpp +++ b/rogueviz/ads/ads-game.cpp @@ -1,3 +1,24 @@ +/* Main file of Relative Hell. */ +/* Best run with -ads-menu; more detailed options are available too */ + +#ifdef RELHELL + +#define CUSTOM_CAPTION "Relative Hell 0.9" +#define MAXMDIM 4 +#define CAP_INV 0 +#define CAP_COMPLEX2 0 +#define CAP_EDIT 0 +#define CAP_BT 0 +#define CAP_SOLV 0 +#define CAP_THREAD 0 +#define CAP_FILES 1 +#define CAP_CONFIG 1 +#define CAP_CRYSTAL 0 +#define CAP_ARCM 0 +#define CAP_HISTORY 0 +#define CAP_STARTANIM 0 +#endif + #include "../rogueviz.h" #include "math.cpp" @@ -59,8 +80,6 @@ void restart() { void run_ads_game() { - set_default_keys(); - if(!sl2) set_geometry(gRotSpace); if(hybrid::csteps) { stop_game(); @@ -92,14 +111,19 @@ void run_ads_game() { pmodel = mdDisk; cwt.at = centerover = currentmap->gamestart(); - rogueviz::rv_change(nohelp, true); - rogueviz::rv_change(nomenukey, true); - rogueviz::rv_change(nomap, true); - rogueviz::rv_change(no_find_player, true); - restart(); } +void set_config() { + set_default_keys(); + + nohelp = true; + nomenukey = true; + nomap = true; + no_find_player = true; + showstartmenu = false; + } + void run_ads_game_std() { set_geometry(gNormal); set_variation(eVariation::pure); @@ -123,6 +147,8 @@ void change_scale(ld s) { auto shot_hooks = arg::add3("-ads-game1", run_ads_game) + arg::add3("-ads-game", run_ads_game_std) ++ arg::add3("-ads-zero", set_config) ++ arg::add3("-ads-menu", [] { set_config(); pushScreen(pick_the_game); }) + arg::add3("-ads-scale", [] { arg::shift(); ld s = arg::argf(); change_scale(s); }) + arg::add3("-ads-restart", restart) + addHook(hooks_configfile, 100, [] { @@ -199,5 +225,15 @@ auto shot_hooks = rsrc_config(); }); +#ifdef RELHELL +auto hook1= + addHook(hooks_config, 100, [] { + set_config(); + if(arg::curphase == 1) + conffile = "relhell.ini"; + if(arg::curphase == 3) pushScreen(pick_the_game); + }); +#endif + } } diff --git a/rogueviz/ads/ds-game.cpp b/rogueviz/ads/ds-game.cpp index 620700bd..c8fbe779 100644 --- a/rogueviz/ads/ds-game.cpp +++ b/rogueviz/ads/ds-game.cpp @@ -213,12 +213,10 @@ auto future_shown = 2 * TAU; void init_ds_game() { - init_textures(); - pick_textures(); - dynamicval g(geometry, gSpace435); rockgen.cshift = 0; + rsrcgen.cshift = 0; /* create the main rock first */ main_rock = rockgen.add(Id); @@ -575,15 +573,10 @@ void view_ds_game() { } } -void run_ds_game() { +void ds_restart() { - set_default_keys(); - init_ds_game(); + main_rock = nullptr; - rogueviz::rv_hook(hooks_frame, 100, view_ds_game); - rogueviz::rv_hook(shmup::hooks_turn, 0, ds_turn); - rogueviz::rv_hook(hooks_prestats, 100, display_rsrc); - if(true) { dynamicval g(geometry, gSpace435); current = cspin(0, 2, 0.2 * ds_scale); @@ -591,13 +584,29 @@ void run_ds_game() { } ship_pt = 0; + + rocks.clear(); + history.clear(); + init_ds_game(); + reset_textures(); + pick_textures(); init_rsrc(); - - rogueviz::rv_change(nohelp, true); - rogueviz::rv_change(nomenukey, true); - rogueviz::rv_change(nomap, true); - rogueviz::rv_change(no_find_player, true); - rogueviz::rv_change(showstartmenu, false); + } + +void run_ds_game() { + + stop_game(); + set_geometry(gSphere); + start_game(); + + init_textures(); + pick_textures(); + + ds_restart(); + + rogueviz::rv_hook(hooks_frame, 100, view_ds_game); + rogueviz::rv_hook(shmup::hooks_turn, 0, ds_turn); + rogueviz::rv_hook(hooks_prestats, 100, display_rsrc); rogueviz::rv_hook(hooks_handleKey, 0, handleKey); } diff --git a/rogueviz/ads/ds-texture.cpp b/rogueviz/ads/ds-texture.cpp index f2d88a1e..ea558b89 100644 --- a/rogueviz/ads/ds-texture.cpp +++ b/rogueviz/ads/ds-texture.cpp @@ -19,6 +19,10 @@ struct texture_to_use { vector textures_to_use; +void reset_textures() { + textures_to_use.clear(); + } + void init_textures() { earth_textures.clear(); string dir = "ds-images/"; diff --git a/rogueviz/ads/globals.cpp b/rogueviz/ads/globals.cpp index 48351006..add5daf8 100644 --- a/rogueviz/ads/globals.cpp +++ b/rogueviz/ads/globals.cpp @@ -117,4 +117,9 @@ int talpha = 32; void init_textures(); void pick_textures(); void draw_textures(); +void reset_textures(); + +void ds_restart(); +void run_ads_game_std(); +void run_ds_game(); }} diff --git a/rogueviz/ads/menu.cpp b/rogueviz/ads/menu.cpp index 7f72c05f..f3cd1506 100644 --- a/rogueviz/ads/menu.cpp +++ b/rogueviz/ads/menu.cpp @@ -131,4 +131,33 @@ void game_menu() { dialog::display(); } +void pick_the_game() { + cmode = sm::NOSCR; + clearMessages(); + gamescreen(); + + dialog::init(XLAT("Relative Hell"), 0xC02020, 200, 0); + dialog::addInfo(XLAT("abandon all hope of going faster than light")); + dialog::addBreak(200); + + dialog::addBigItem("anti-de Sitter space", '1'); + dialog::add_action([] { popScreen(); run_ads_game_std(); clearMessages(); }); + dialog::addInfo(XLAT("shoot asteroids, mine resources, collect gold")); + + dialog::addBreak(100); + + dialog::addBigItem("de Sitter space", '2'); + dialog::add_action([] { popScreen(); run_ds_game(); clearMessages(); }); + dialog::addInfo(XLAT("avoid energy balls, but do not let the main star run away!")); + + dialog::addBreak(100); + + dialog::addItem("not now", '3'); + dialog::add_action([] { quitmainloop = true; }); + + dialog::display(); + /* do not let the user exit this dialog */ + keyhandler = [] (int a, int b) { dialog::handleNavigation(a,b); }; + } + }}