1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-30 15:39:54 +00:00

face/edge/vertex centering

This commit is contained in:
Zeno Rogue 2020-04-01 12:01:55 +02:00
parent dc2658a98c
commit 650604227a
4 changed files with 43 additions and 4 deletions

View File

@ -8,6 +8,12 @@
#include "hyper.h"
namespace hr {
#if HDR
enum eCentering { face, edge, vertex };
#endif
EX eCentering centering;
#if HDR
struct supersaver {
string name;
@ -647,6 +653,8 @@ EX void initConfig() {
addsaver(noshadow, "noshadow");
addsaver(bright, "bright");
addsaver(cblind, "cblind");
addsaverenum(centering, "centering");
callhooks(hooks_configfile);

View File

@ -566,7 +566,9 @@ void cheat_move(char c) {
else if(c == 'r') cheat(), cwt += rev;
else if(c == 'm') cheat(), cwt += wmirror;
else if(c == 'z') cheat(), cwt.spin = 0, cwt.mirrored = false;
else if(c == 'F') fullcenter();
else if(c == 'F') centering = eCentering::face, fullcenter();
else if(c == 'E') centering = eCentering::edge, fullcenter();
else if(c == 'V') centering = eCentering::vertex, fullcenter();
else if(c == 'a') cheat(), history::save_end();
else println(hlog, "unknown move command: ", c);
}

View File

@ -1442,10 +1442,22 @@ EX void resetview() {
View = iddspin(cwt.at, cwt.spin);
if(!flipplayer) View = pispin * View;
if(cwt.mirrored) View = Mirror * View;
if(centering) {
hyperpoint vl = View * get_corner_position(cwt.at, cwt.spin);
hyperpoint vr = View * get_corner_position(cwt.at, (cwt.spin+1) % cwt.at->type);
hyperpoint vm = (centering == eCentering::edge) ? mid(vl, vr) : vl;
transmatrix rm = gpushxto0(vm);
View = spintox(rm*vr) * rm * View;
}
if(GDIM == 2) View = spin(M_PI + vid.fixed_facing_dir * degree) * View;
if(GDIM == 3 && !prod) View = cspin(0, 2, M_PI/2) * View;
if(prod) NLP = cspin(0, 2, M_PI/2);
if(cheater && eqmatrix(View, lView)) {
if(cheater && eqmatrix(View, lView) && !centering) {
View = Id;
static ld cyc = 0;
cyc += 90 * degree;
@ -1483,10 +1495,10 @@ EX void fullcenter() {
bfs();
resetview();
drawthemap();
centerpc(INF);
if(!centering) centerpc(INF);
centerover = cwt.at;
}
playermoved = true;
playermoved = !centering;
}
transmatrix screenpos(ld x, ld y) {

View File

@ -452,6 +452,23 @@ EX void menu() {
dialog::addBoolItem_action(XLAT("disable the HUD"), hide_hud, 'h');
dialog::addBoolItem_action_neg(XLAT("hide the player"), mapeditor::drawplayer, 'H');
if(WDIM == 2) {
dialog::addItem(XLAT("centering"), 'x');
dialog::add_action([] {
dialog::editNumber(vid.fixed_facing_dir, 0, 360, 15, 90, XLAT("centering"),
XLAT("You can pick the angle. Note: the direction the PC is facing matters."));
dialog::reaction = fullcenter;
dialog::extra_options = [] () {
dialog::addBoolItem(XLAT("face"), centering == eCentering::face, 'F');
dialog::add_action([] { centering = eCentering::face; fullcenter(); });
dialog::addBoolItem(XLAT("edge"), centering == eCentering::edge, 'E');
dialog::add_action([] { centering = eCentering::edge; fullcenter(); });
dialog::addBoolItem(XLAT("vertex"), centering == eCentering::vertex, 'V');
dialog::add_action([] { centering = eCentering::vertex; fullcenter(); });
};
});
}
dialog::addItem(XLAT("colors & aura"), 'c');
dialog::add_action_push(show_color_dialog);