1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

crosshair option

This commit is contained in:
Zeno Rogue 2019-09-09 16:10:57 +02:00
parent bc76bc472c
commit 5ad1be2962
2 changed files with 35 additions and 0 deletions

View File

@ -388,6 +388,9 @@ EX void initConfig() {
// colors
addsaver(crosshair_size, "size:crosshair");
addsaver(crosshair_color, "color:crosshair");
addsaver(backcolor, "color:background");
addsaver(forecolor, "color:foreground");
addsaver(bordcolor, "color:borders");
@ -1245,6 +1248,19 @@ EX void configureInterface() {
vid.graphglyph = (1+vid.graphglyph)%3;
});
dialog::addSelItem(XLAT("draw crosshair"), crosshair_size > 0 ? fts(crosshair_size) : ONOFF(false), 'x');
dialog::add_action([] () {
dialog::editNumber(crosshair_size, 0, 100, 1, 10, XLAT("crosshair size"), XLAT(
"Display a targetting reticle in the center of the screen. Might be useful when exploring 3D modes, "
"as it precisely shows the direction we are going. However, the option is available in all modes."
));
dialog::bound_low(0);
dialog::extra_options = [] {
dialog::addColorItem(XLAT("crosshair color"), crosshair_color, 'X');
dialog::add_action([] { dialog::openColorDialog(crosshair_color); });
};
});
dialog::addBreak(50);
dialog::addBack();
@ -2175,6 +2191,10 @@ EX int read_color_args() {
else if(argis("-period")) {
PHASEFROM(2); shift(); periodcolor = arghex();
}
else if(argis("-crosshair")) {
PHASEFROM(2); shift(); crosshair_color = arghex();
shift_arg_formula(crosshair_size);
}
else if(argis("-borders")) {
PHASEFROM(2); shift(); bordcolor = arghex();
}

15
hud.cpp
View File

@ -471,6 +471,9 @@ EX void draw_radar(bool cornermode) {
}
}
EX color_t crosshair_color = 0xFFFFFFC0;
EX ld crosshair_size = 0;
EX void drawStats() {
if(nohud || vid.stereo_mode == sLR) return;
if(callhandlers(false, hooks_prestats)) return;
@ -495,8 +498,20 @@ EX void drawStats() {
dynamicval<ld> vc(vid.camera_angle, 0);
if(prod) vid.alpha = 30, vid.scale = 30;
auto& cd = current_display;
auto xc = cd->xcenter;
auto yc = cd->ycenter;
calcparam();
if(crosshair_color && crosshair_size > 0) {
initquickqueue();
vid.linewidth = 1;
queueline(tC0(atscreenpos(xc - crosshair_size, yc, 1)), tC0(atscreenpos(xc + crosshair_size, yc, 1)), crosshair_color).prio = PPR::SUPERLINE;
queueline(tC0(atscreenpos(xc, yc - crosshair_size, 1)), tC0(atscreenpos(xc, yc + crosshair_size, 1)), crosshair_color).prio = PPR::SUPERLINE;
quickqueue();
}
if(vid.radarsize > 0 && h)
#if CAP_RACING
if(!racing::on)