mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-05-08 10:14:08 +00:00
rogueviz::ads:: help system
This commit is contained in:
parent
609064579c
commit
526cebd79c
@ -41,6 +41,7 @@ namespace rogueviz { std::vector<hr::reaction_t> cleanup; }
|
||||
#include "ds-texture.cpp"
|
||||
#include "views.cpp"
|
||||
#include "tour.cpp"
|
||||
#include "help.cpp"
|
||||
|
||||
namespace hr {
|
||||
|
||||
@ -86,6 +87,8 @@ void restart() {
|
||||
}
|
||||
|
||||
void run_ads_game_hooks() {
|
||||
rogueviz::rv_hook(hooks_global_mouseover, 100, ads_mouseover);
|
||||
rogueviz::rv_change<color_t>(titlecolor, 0);
|
||||
rogueviz::rv_hook(hooks_frame, 100, view_ads_game);
|
||||
rogueviz::rv_hook(hooks_prestats, 100, display_rsrc);
|
||||
rogueviz::rv_hook(hooks_handleKey, 150, handleKey);
|
||||
|
@ -46,6 +46,30 @@ color_t empty_outline(cell *c) {
|
||||
}
|
||||
}
|
||||
|
||||
color_t help_color(cell *c) {
|
||||
switch(c->land) {
|
||||
case laBarrier:
|
||||
return 0xFFFFFF;
|
||||
default:
|
||||
return empty_outline(c) >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
string land_name(cell *c) {
|
||||
switch(c->land) {
|
||||
case laCrossroads:
|
||||
return "Space Roads";
|
||||
case laCaves:
|
||||
return "Asteroid Field";
|
||||
case laHunting:
|
||||
return "War Zone";
|
||||
case laJungle:
|
||||
return "Gate Zone";
|
||||
default:
|
||||
return dnameof(c->land);
|
||||
}
|
||||
}
|
||||
|
||||
int wall_frequency(cell *c) {
|
||||
switch(c->land) {
|
||||
case laCrossroads:
|
||||
|
@ -90,6 +90,10 @@ bool handleKey(int sym, int uni) {
|
||||
if(t[sym] >= 16 && t[sym] < 32) return true;
|
||||
if(sym == 'v') pushScreen(game_menu);
|
||||
if(sym == SDLK_ESCAPE) pushScreen(game_menu);
|
||||
if(sym == SDLK_F1) {
|
||||
if(help == "@") help = "help not known";
|
||||
gotoHelp(help);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -20,6 +20,9 @@ void apply_duality(shiftmatrix& S) {
|
||||
}
|
||||
}
|
||||
|
||||
vector<ads_object*> under_mouse;
|
||||
hyperpoint mousetester;
|
||||
|
||||
void draw_game_cell(const cell_to_draw& cd) {
|
||||
bool hv = mtwisted;
|
||||
using cellptr = cell*;
|
||||
@ -141,6 +144,8 @@ void draw_game_cell(const cell_to_draw& cd) {
|
||||
});
|
||||
}
|
||||
|
||||
if(rock.type != oParticle && pointcrash(mousetester, rock.pts)) under_mouse.push_back(&rock);
|
||||
|
||||
if(hv) {
|
||||
ld t = rock.life_start;
|
||||
if(t < -100) t = 0;
|
||||
@ -264,6 +269,8 @@ void view_footer() {
|
||||
void view_ads_game() {
|
||||
displayed.clear();
|
||||
cds_last = std::move(cds); cds.clear();
|
||||
mousetester = kleinize(unshift(mouseh));
|
||||
under_mouse.clear();
|
||||
|
||||
bool hv = mhybrid;
|
||||
|
||||
|
146
rogueviz/ads/help.cpp
Normal file
146
rogueviz/ads/help.cpp
Normal file
@ -0,0 +1,146 @@
|
||||
namespace hr {
|
||||
namespace ads_game {
|
||||
|
||||
string rsrc_name[rtGUARD] = {"", "Hull", "Ammo", "Fuel", "Air", "Platinum", "Plasteel", "Uranium" };
|
||||
|
||||
string get_resource_name(eResourceType id) {
|
||||
if(id == rtGoldRocks && main_rock) {
|
||||
return "main star history";
|
||||
}
|
||||
else return rsrc_name[id];
|
||||
}
|
||||
|
||||
string get_resource_help(eResourceType id, bool with_title) {
|
||||
string s = with_title ? helptitle(get_resource_name(id), rsrc_color[id] >> 8) : "";
|
||||
switch(id) {
|
||||
case rtHull:
|
||||
return s + "Your hull is damaged when you are hit by something. You lose immediately when the Hull reaches 0.";
|
||||
case rtAmmo:
|
||||
return s + "You use up a single unit of ammo every time you shoot.";
|
||||
case rtFuel:
|
||||
return s + "You use up fuel when you accelerate.";
|
||||
case rtOxygen:
|
||||
return s + "You use up oxygen constantly, and lose immediately when it reaches 0. Oxygen is lost according to your proper time, "
|
||||
"so you might conserve some oxygen by changing your speed, but, would that be ever worth it?";
|
||||
case rtGoldRocks:
|
||||
if(main_rock) return s + "Your goal is to always remain close to the home star, to see how it evolves. This is your current score.";
|
||||
return s + "Platinum is a precious resource mined from asteroids. Mine it to increase your score.";
|
||||
case rtGoldGate:
|
||||
return s + "Plasteel is a rare resource used in gates. Collect it to increase your score.";
|
||||
case rtGoldTurret:
|
||||
return s + "Uranium is a rare material found in war zones. Collect it to increase your score.";
|
||||
default:
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
string get_land_help(cell *c) {
|
||||
string s = helptitle(land_name(c), help_color(c));
|
||||
switch(c->land) {
|
||||
case laJungle:
|
||||
s +=
|
||||
"For an unknown purpose, an ancient civilization has filled this space with gates. These gates periodically shut down, potentially damaging the ships which explore this zone. "
|
||||
"The whole gate shuts down at exactly the same time... but, of course, according to the gate's clock, not your ship's clock.";
|
||||
break;
|
||||
case laCaves:
|
||||
s += "An asteroid field, filled with some stationary rocks, as well as dangerous but beautiful asteroids, containing precious uranium.";
|
||||
break;
|
||||
case laHunting:
|
||||
s += "A dangerous zone filled with enemy turrets.";
|
||||
break;
|
||||
case laCrossroads:
|
||||
s += "A mostly empty zone that leads to other zones.";
|
||||
break;
|
||||
case laBarrier:
|
||||
s += "Just a great ancient wall separating different zones.";
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void explain_undermouse() {
|
||||
for(auto m: under_mouse) switch(m->type) {
|
||||
case oRock: {
|
||||
mouseovers += ", asteroid";
|
||||
if(!m->resource) {
|
||||
help = "Asteroids just fly freely, they will damage your ship if they hit you. You can shoot them to detroy them; sometimes they contain resources, but this particular one does not.";
|
||||
break;
|
||||
}
|
||||
help = "Asteroids just fly freely, they will damage your ship if they hit you. You can shoot them to detroy them and release resources. This one contains the resource " + get_resource_name(m->resource) + ":\n\n" + get_resource_help(m->resource, false);
|
||||
mouseovers += " (" + rsrc_name[m->resource] + ")";
|
||||
break;
|
||||
}
|
||||
case oResource: {
|
||||
help = get_resource_help(m->resource, true);
|
||||
if(m->resource) mouseovers += ", " + rsrc_name[m->resource];
|
||||
break;
|
||||
}
|
||||
case oTurret: {
|
||||
help = "An enemy turret. They shoot at you with perfect accuracy... but of course, due to the limited speed of light, they see where you were in the past, and hopefully you changed your route since then.";
|
||||
mouseovers += ", turret";
|
||||
break;
|
||||
}
|
||||
case oTurretMissile: {
|
||||
help = "A missile shot at you by an enemy turret.";
|
||||
mouseovers += ", enemy missile";
|
||||
break;
|
||||
}
|
||||
case oMissile: {
|
||||
help = "A missile shot by you. Destroys asteroids and enemy turrets.";
|
||||
mouseovers += ", missile";
|
||||
break;
|
||||
}
|
||||
case oMainRock: {
|
||||
help = "Your goal is to always remain close to the home star.";
|
||||
mouseovers += ", home star";
|
||||
break;
|
||||
}
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
||||
int ads_mouseover() {
|
||||
titlecolor = 0xFFFFFF;
|
||||
|
||||
if(!paused) {
|
||||
int v = -1;
|
||||
for(int i=0; i<multi::SCANCODES; i++) if(multi::scfg_default.keyaction[i] == 16+pcPause) v = i;
|
||||
if(v >= 0) mouseovers = "press " + dialog::keyname(v) + " to pause";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(outofmap(mouseh.h)) return 2;
|
||||
|
||||
hyperpoint h1 = normalize(unshift(mouseh));
|
||||
hybrid::in_actual([&] {
|
||||
h1[3] = h1[2]; h1[2] = 0;
|
||||
ads_point rel = ads_inverse(current * vctrV) * ads_point(h1, 0);
|
||||
cell *c = hybrid::get_at(vctr, 0);
|
||||
virtualRebase(c, rel.h);
|
||||
optimize_shift(rel);
|
||||
auto w = hybrid::get_where(c);
|
||||
auto& ci = ci_at[w.first];
|
||||
mouseovers = land_name(w.first);
|
||||
titlecolor = help_color(w.first);
|
||||
help = get_land_help(c);
|
||||
|
||||
switch(ci.type) {
|
||||
case wtDestructible: case wtSolid:
|
||||
mouseovers += ", rock";
|
||||
break;
|
||||
case wtGate:
|
||||
mouseovers += ", gate";
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
});
|
||||
|
||||
explain_undermouse();
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -70,6 +70,9 @@ void init_rsrc() {
|
||||
game_over = false;
|
||||
}
|
||||
|
||||
string get_resource_name(eResourceType id);
|
||||
string get_resource_help(eResourceType id, bool help);
|
||||
|
||||
void display(int id, int y, ld val, ld maxv, ld tank, ld unit) {
|
||||
auto sId = shiftless(Id);
|
||||
|
||||
@ -93,6 +96,14 @@ void display(int id, int y, ld val, ld maxv, ld tank, ld unit) {
|
||||
ld fen = sta + siz;
|
||||
ld top = ctr-5;
|
||||
ld bot = ctr+5;
|
||||
|
||||
if(mousey > top && mousey < bot && mousex < fen && mousex > sta - 20) {
|
||||
mouseovers = get_resource_name(eResourceType(id));
|
||||
if(maxv == 0) mouseovers += ": " + its(val);
|
||||
else if(unit == 1) mouseovers += " (" + its(val) + "/" + its(maxv) + ")";
|
||||
else mouseovers += " (" + fts(val/unit) + "/" + fts(maxv/unit) + ")";
|
||||
help = get_resource_help(eResourceType(id), true);
|
||||
}
|
||||
|
||||
if(maxv == 0) {
|
||||
string s;
|
||||
|
Loading…
x
Reference in New Issue
Block a user