2017-05-27 19:40:40 +00:00
|
|
|
// Hyperbolic Rogue
|
|
|
|
// Copyright (C) 2011-2016 Zeno Rogue, see 'hyper.cpp' for details
|
|
|
|
|
|
|
|
// Hyperbolic geometry is a good tool to visualize data,
|
|
|
|
// especially trees and scale-free networks. This file
|
|
|
|
// uses HyperRogue to browse such vizualizations.
|
|
|
|
|
|
|
|
// Since it is not of use for general HyperRogue players,
|
|
|
|
// it is disabled by default -- compile with the ROGUEVIZ flag to enable this.
|
|
|
|
|
|
|
|
// How to use:
|
|
|
|
|
|
|
|
// hyper -embed <start of filename> -- visualize a social network
|
|
|
|
// embedded into hyperbolic plane, see:
|
|
|
|
// https://bitbucket.org/HaiZhung/hyperbolic-embedder/overview
|
|
|
|
// (it uses the same format)
|
|
|
|
|
|
|
|
// hyper -tess <parameter file> -- visualize a horocyclic tesselation,
|
|
|
|
|
2018-07-09 19:03:46 +00:00
|
|
|
#include "rogueviz.h"
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
namespace rogueviz {
|
|
|
|
|
2020-03-29 14:03:31 +00:00
|
|
|
string weight_label;
|
|
|
|
|
2019-04-23 10:49:07 +00:00
|
|
|
ld fat_edges = 0;
|
2019-06-01 15:08:27 +00:00
|
|
|
ld ggamma = 1;
|
2019-04-23 10:49:07 +00:00
|
|
|
|
2018-06-10 23:58:31 +00:00
|
|
|
using namespace hr;
|
|
|
|
|
2019-06-01 15:09:50 +00:00
|
|
|
edgetype default_edgetype = { .1, .1, .1, DEFAULT_COLOR, 0xFF0000FF, "default" };
|
2018-07-09 16:17:40 +00:00
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
bool showlabels = false;
|
|
|
|
bool specialmark = false;
|
2018-09-08 11:43:10 +00:00
|
|
|
bool edge_legend = false;
|
2017-05-27 19:40:40 +00:00
|
|
|
|
|
|
|
bool rog3 = false;
|
2018-07-04 12:34:58 +00:00
|
|
|
int vertex_shape = 1;
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2018-07-09 16:17:40 +00:00
|
|
|
string edgename;
|
2017-05-27 19:40:40 +00:00
|
|
|
string fname;
|
|
|
|
|
|
|
|
// const char *fname;
|
|
|
|
// const char *cfname;
|
|
|
|
|
2018-09-25 01:47:42 +00:00
|
|
|
vector<shared_ptr<edgetype>> edgetypes;
|
|
|
|
|
2018-07-09 16:17:40 +00:00
|
|
|
edgetype *add_edgetype(const string& name) {
|
|
|
|
auto e = make_shared<edgetype> (default_edgetype);
|
|
|
|
e->name = name;
|
|
|
|
edgetypes.push_back(e);
|
|
|
|
return &*e;
|
|
|
|
}
|
|
|
|
|
2019-04-23 10:03:29 +00:00
|
|
|
map<color_t, array<color_t, 16> > next_hue;
|
|
|
|
|
|
|
|
color_t parse1(const string& s) {
|
|
|
|
// color can be given as RRGGBB
|
|
|
|
// or as 'Rmax,min,alpha,step,start', for rainbow Collatz
|
|
|
|
if(s[0] == 'R') {
|
Silence some pedantic format warnings from Clang.
rogueviz/rogueviz.cpp: In function ‘hr::color_t rogueviz::parse1(const string&)’:
rogueviz/rogueviz.cpp:76:75: error: format ‘%x’ expects argument
of type ‘unsigned int*’, but argument 3 has type ‘int*’ [-Werror=format=]
sscanf(s.c_str(), "R%x,%x,%x,%d,%d", &mh, &minh, &alpha, &step, &start);
^
I believe these three variables should have been `color_t` all along.
I think this fix doesn't change any of the arithmetic, but I could be wrong.
2020-02-23 03:49:26 +00:00
|
|
|
color_t mh = 192, minh = 0, alpha = 255;
|
|
|
|
int step = 50, start = 0;
|
2019-04-23 10:03:29 +00:00
|
|
|
sscanf(s.c_str(), "R%x,%x,%x,%d,%d", &mh, &minh, &alpha, &step, &start);
|
|
|
|
vector<color_t> hues;
|
|
|
|
color_t difh = mh - minh;
|
|
|
|
color_t base = alpha + minh * 0x1010100;
|
|
|
|
|
|
|
|
for(unsigned y=0; y<difh; y++)
|
|
|
|
hues.push_back(base + 0x1000000*mh + 0x10000 * y);
|
|
|
|
for(unsigned y=0; y<difh; y++)
|
|
|
|
hues.push_back(base + 0x1010000*mh - 0x1000000 * y);
|
|
|
|
for(unsigned y=0; y<difh; y++)
|
|
|
|
hues.push_back(base + 0x0010000*mh + 0x100 * y);
|
|
|
|
for(unsigned y=0; y<difh; y++)
|
|
|
|
hues.push_back(base + 0x0010100*mh - 0x10000 * y);
|
|
|
|
for(unsigned y=0; y<difh; y++)
|
|
|
|
hues.push_back(base + 0x0000100*mh + 0x1000000 * y);
|
|
|
|
for(unsigned y=0; y<difh; y++)
|
|
|
|
hues.push_back(base + 0x1000100*mh - 0x100 * y);
|
|
|
|
|
|
|
|
for(int t=0; t<isize(hues); t++)
|
|
|
|
for(int a=0; a<16; a++)
|
|
|
|
next_hue[hues[t]][a] = hues[gmod(t + rand() % step - rand() % step, isize(hues))];
|
|
|
|
|
|
|
|
return hues[gmod(start, isize(hues))];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
color_t res;
|
|
|
|
sscanf(s.c_str(), "%x", &res);
|
|
|
|
return res;
|
|
|
|
}
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-23 08:42:06 +00:00
|
|
|
color_t perturb(color_t c) {
|
2019-04-23 10:03:29 +00:00
|
|
|
if(!next_hue.count(c)) return c;
|
|
|
|
return next_hue[c][rand() % 16];
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
colorpair perturb(colorpair cp) {
|
|
|
|
cp.color1 = perturb(cp.color1);
|
|
|
|
cp.color2 = perturb(cp.color2);
|
|
|
|
return cp;
|
|
|
|
}
|
|
|
|
|
2019-06-01 15:06:15 +00:00
|
|
|
colorpair parse(string s) {
|
2019-04-23 10:03:29 +00:00
|
|
|
colorpair cp;
|
2019-06-01 15:06:15 +00:00
|
|
|
auto pospng = s.find(":PNG:");
|
|
|
|
if(pospng != string::npos) {
|
|
|
|
string fname = s.substr(pospng+5);
|
|
|
|
s = s.substr(0, pospng);
|
|
|
|
#if CAP_TEXTURE
|
|
|
|
cp.img = make_shared<rvimage>();
|
|
|
|
auto& i = *cp.img;
|
|
|
|
i.tdata.twidth = 1024;
|
|
|
|
if(!(i.tdata.readtexture(fname) && i.tdata.loadTextureGL())) {
|
|
|
|
println(hlog, "failed to load: ", fname);
|
|
|
|
cp.img = NULL;
|
|
|
|
return cp;
|
|
|
|
}
|
|
|
|
println(hlog, "loaded texture: ", fname);
|
|
|
|
for(int x=0; x<16; x++)
|
|
|
|
for(int y=0; y<16; y++) {
|
|
|
|
auto addv = [&] (ld x, ld y) {
|
|
|
|
x -= 8;
|
|
|
|
y -= 8;
|
|
|
|
x /= 16.;
|
|
|
|
y /= 16.;
|
|
|
|
ld r = max(abs(x), abs(y)) / hypot(x, y);
|
|
|
|
if(x || y) {
|
|
|
|
x *= r;
|
|
|
|
y *= r;
|
|
|
|
}
|
|
|
|
i.tinf.tvertices.push_back(glhr::makevertex(x + .5, y + .5, 0));
|
|
|
|
i.vertices.push_back(hpxy(x * .4, y * .4));
|
|
|
|
};
|
|
|
|
addv(x, y);
|
|
|
|
addv(x, y+1);
|
|
|
|
addv(x+1, y);
|
|
|
|
addv(x, y+1);
|
|
|
|
addv(x+1, y);
|
|
|
|
addv(x+1, y+1);
|
|
|
|
}
|
|
|
|
i.tinf.texture_id = i.tdata.textureid;
|
|
|
|
#endif
|
|
|
|
}
|
2019-04-23 10:03:29 +00:00
|
|
|
auto pos = s.find(":");
|
|
|
|
if(pos != string::npos) {
|
|
|
|
cp.color1 = parse1(s.substr(0, pos));
|
|
|
|
cp.shade = s[pos+1];
|
|
|
|
cp.color2 = parse1(s.substr(pos+2));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cp.shade = 0; cp.color2 = 0;
|
|
|
|
cp.color1 = parse1(s);
|
|
|
|
}
|
|
|
|
return cp;
|
|
|
|
}
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
vector<vertexdata> vdata;
|
|
|
|
|
|
|
|
map<string, int> labeler;
|
|
|
|
|
|
|
|
int getid(const string& s) {
|
|
|
|
if(labeler.count(s)) return labeler[s];
|
|
|
|
else {
|
2018-06-25 21:02:41 +00:00
|
|
|
int id = isize(vdata);
|
|
|
|
vdata.resize(isize(vdata) + 1);
|
2017-05-27 19:40:40 +00:00
|
|
|
vdata[id].name = s;
|
|
|
|
return labeler[s] = id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int getnewid(string s) {
|
|
|
|
while(labeler.count(s)) s += "'";
|
|
|
|
return getid(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void addedge0(int i, int j, edgeinfo *ei) {
|
|
|
|
vdata[i].edges.push_back(make_pair(j, ei));
|
|
|
|
vdata[j].edges.push_back(make_pair(i, ei));
|
|
|
|
}
|
|
|
|
|
|
|
|
void createViz(int id, cell *c, transmatrix at) {
|
|
|
|
vertexdata& vd(vdata[id]);
|
|
|
|
vd.m = new shmup::monster;
|
|
|
|
vd.m->pid = id;
|
|
|
|
vd.m->type = moRogueviz;
|
|
|
|
vd.m->base = c;
|
|
|
|
vd.m->at = at;
|
2019-06-01 15:09:14 +00:00
|
|
|
vd.m->isVirtual = false;
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
2017-07-04 13:38:33 +00:00
|
|
|
void notimpl() {
|
|
|
|
printf("Not implemented\n"); exit(1);
|
|
|
|
}
|
|
|
|
|
2018-07-05 07:56:44 +00:00
|
|
|
hyperpoint where(int i, cell *base) {
|
2017-07-04 13:38:33 +00:00
|
|
|
auto m = vdata[i].m;
|
2018-07-05 07:56:44 +00:00
|
|
|
if(m->base == base) return tC0(m->at);
|
2018-11-27 01:32:11 +00:00
|
|
|
else if(confusingGeometry()) {
|
2018-08-17 14:47:06 +00:00
|
|
|
return calc_relative_matrix(m->base, base, C0) * tC0(m->at);
|
2018-07-05 07:56:44 +00:00
|
|
|
}
|
|
|
|
else {
|
2017-12-14 01:53:39 +00:00
|
|
|
// notimpl(); // actually probably that's a buug
|
2020-07-29 21:34:00 +00:00
|
|
|
return inverse_shift(ggmatrix(currentmap->gamestart()), ggmatrix(m->base) * tC0(m->at));
|
2017-07-04 13:38:33 +00:00
|
|
|
}
|
|
|
|
}
|
2018-07-05 07:56:44 +00:00
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
void addedge(int i, int j, edgeinfo *ei) {
|
2018-07-05 07:56:44 +00:00
|
|
|
cell *base =
|
2018-11-27 01:32:11 +00:00
|
|
|
confusingGeometry() ? vdata[i].m->base : currentmap->gamestart();
|
2018-07-05 07:56:44 +00:00
|
|
|
hyperpoint hi = where(i, base);
|
|
|
|
hyperpoint hj = where(j, base);
|
2017-07-04 13:38:33 +00:00
|
|
|
double d = hdist(hi, hj);
|
2017-05-27 19:40:40 +00:00
|
|
|
if(d >= 4) {
|
2017-07-04 13:38:33 +00:00
|
|
|
hyperpoint h = mid(hi, hj);
|
2018-06-22 12:47:24 +00:00
|
|
|
int id = isize(vdata);
|
2017-05-27 19:40:40 +00:00
|
|
|
vdata.resize(id+1);
|
|
|
|
vertexdata& vd(vdata[id]);
|
|
|
|
vd.cp = colorpair(0x400000FF);
|
|
|
|
vd.virt = ei;
|
|
|
|
|
2018-07-05 07:56:44 +00:00
|
|
|
createViz(id, base, rgpushxto0(h));
|
2018-07-09 17:32:34 +00:00
|
|
|
vd.m->no_targetting = true;
|
2017-05-27 19:40:40 +00:00
|
|
|
|
|
|
|
addedge(i, id, ei);
|
|
|
|
addedge(id, j, ei);
|
2019-11-14 19:26:07 +00:00
|
|
|
virtualRebase(vdata[i].m);
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
else addedge0(i, j, ei);
|
|
|
|
}
|
|
|
|
|
|
|
|
vector<edgeinfo*> edgeinfos;
|
|
|
|
|
2018-07-09 16:17:40 +00:00
|
|
|
void addedge(int i, int j, double wei, bool subdiv, edgetype *t) {
|
|
|
|
edgeinfo *ei = new edgeinfo(t);
|
2017-05-27 19:40:40 +00:00
|
|
|
edgeinfos.push_back(ei);
|
|
|
|
ei->i = i;
|
|
|
|
ei->j = j;
|
|
|
|
ei->weight = wei;
|
|
|
|
if(subdiv) addedge(i, j, ei);
|
|
|
|
else addedge0(i, j, ei);
|
|
|
|
}
|
|
|
|
|
2018-07-05 07:55:11 +00:00
|
|
|
void storeall(int from) {
|
|
|
|
for(int i=from; i<isize(vdata); i++)
|
2017-05-27 19:40:40 +00:00
|
|
|
if(vdata[i].m)
|
|
|
|
vdata[i].m->store();
|
|
|
|
}
|
|
|
|
|
2019-04-22 12:46:33 +00:00
|
|
|
colorpair dftcolor = 0x282828FF;
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2019-05-21 22:05:58 +00:00
|
|
|
int readLabel(fhstream& f) {
|
|
|
|
string s = scan<string>(f);
|
2017-07-04 13:38:33 +00:00
|
|
|
if(s == "") return -1;
|
|
|
|
return getid(s);
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace anygraph {
|
|
|
|
double R, alpha, T;
|
|
|
|
vector<pair<double, double> > coords;
|
2017-07-04 13:38:33 +00:00
|
|
|
|
2018-07-09 16:17:40 +00:00
|
|
|
edgetype *any;
|
2020-03-29 13:14:23 +00:00
|
|
|
|
|
|
|
int vzid;
|
2018-07-09 16:17:40 +00:00
|
|
|
|
2017-07-04 13:38:33 +00:00
|
|
|
int N;
|
|
|
|
|
|
|
|
void fixedges() {
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=N; i<isize(vdata); i++) if(vdata[i].m) vdata[i].m->dead = true;
|
|
|
|
for(int i=0; i<isize(vdata); i++) vdata[i].edges.clear();
|
2017-07-04 13:38:33 +00:00
|
|
|
vdata.resize(N);
|
|
|
|
for(auto e: edgeinfos) {
|
|
|
|
e->orig = NULL;
|
|
|
|
addedge(e->i, e->j, e);
|
|
|
|
}
|
|
|
|
}
|
2019-05-21 22:05:58 +00:00
|
|
|
|
|
|
|
void tst() {}
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2017-12-01 23:24:07 +00:00
|
|
|
void read(string fn, bool subdiv, bool doRebase, bool doStore) {
|
2020-03-29 13:14:23 +00:00
|
|
|
init(&vzid, RV_GRAPH);
|
2018-07-09 16:17:40 +00:00
|
|
|
any = add_edgetype("embedded edges");
|
2017-05-27 19:40:40 +00:00
|
|
|
fname = fn;
|
2019-05-21 22:05:58 +00:00
|
|
|
fhstream f(fn + "-coordinates.txt", "rt");
|
|
|
|
if(!f.f) {
|
2017-05-27 19:40:40 +00:00
|
|
|
printf("Missing file: %s-coordinates.txt\n", fname.c_str());
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
printf("Reading coordinates...\n");
|
2019-05-21 22:05:58 +00:00
|
|
|
string ignore;
|
|
|
|
if(!scan(f, ignore, ignore, ignore, ignore, N, anygraph::R, anygraph::alpha, anygraph::T)) {
|
|
|
|
printf("Error: incorrect format of the first line\n"); exit(1);
|
|
|
|
}
|
2017-05-27 19:40:40 +00:00
|
|
|
vdata.reserve(N);
|
|
|
|
while(true) {
|
2019-05-21 22:05:58 +00:00
|
|
|
string s = scan<string>(f);
|
|
|
|
println(hlog, "s: ", s.c_str());
|
|
|
|
if(s == "D11.11") tst();
|
2017-12-14 01:53:39 +00:00
|
|
|
if(s == "" || s == "#ROGUEVIZ_ENDOFDATA") break;
|
2017-07-04 13:38:33 +00:00
|
|
|
int id = getid(s);
|
2017-05-27 19:40:40 +00:00
|
|
|
vertexdata& vd(vdata[id]);
|
2017-07-04 13:38:33 +00:00
|
|
|
vd.name = s;
|
2017-05-27 19:40:40 +00:00
|
|
|
vd.cp = colorpair(dftcolor);
|
|
|
|
|
|
|
|
double r, alpha;
|
2019-05-21 22:05:58 +00:00
|
|
|
if(!scan(f, r, alpha)) { printf("Error: incorrect format of r/alpha\n"); exit(1); }
|
2017-05-27 19:40:40 +00:00
|
|
|
coords.push_back(make_pair(r, alpha));
|
|
|
|
|
2018-11-08 17:18:25 +00:00
|
|
|
transmatrix h = spin(alpha * degree) * xpush(r);
|
2017-05-27 19:40:40 +00:00
|
|
|
|
|
|
|
createViz(id, currentmap->gamestart(), h);
|
|
|
|
}
|
|
|
|
|
2019-05-21 22:05:58 +00:00
|
|
|
fhstream g(fn + "-links.txt", "rt");
|
|
|
|
if(!g.f) {
|
|
|
|
println(hlog, "Missing file: ", fname, "-links.txt");
|
2017-05-27 19:40:40 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2019-05-21 22:05:58 +00:00
|
|
|
println(hlog, "Reading links...");
|
2017-05-27 19:40:40 +00:00
|
|
|
int qlink = 0;
|
|
|
|
while(true) {
|
2019-05-21 22:05:58 +00:00
|
|
|
int i = readLabel(g), j = readLabel(g);
|
2017-05-27 19:40:40 +00:00
|
|
|
if(i == -1 || j == -1) break;
|
2018-09-27 19:52:37 +00:00
|
|
|
addedge(i, j, 1, subdiv, any);
|
2017-05-27 19:40:40 +00:00
|
|
|
qlink++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(doRebase) {
|
|
|
|
printf("Rebasing...\n");
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(vdata); i++) {
|
|
|
|
if(i % 10000 == 0) printf("%d/%d\n", i, isize(vdata));
|
2019-11-14 19:26:07 +00:00
|
|
|
if(vdata[i].m) virtualRebase(vdata[i].m);
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
printf("Done.\n");
|
|
|
|
}
|
2017-07-04 13:38:33 +00:00
|
|
|
|
|
|
|
if(doStore) storeall();
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ld maxweight;
|
|
|
|
|
|
|
|
bool edgecmp(edgeinfo *e1, edgeinfo *e2) {
|
|
|
|
return e1->weight > e2->weight;
|
|
|
|
}
|
|
|
|
|
2018-09-05 13:41:57 +00:00
|
|
|
bool which_weight = false;
|
|
|
|
|
|
|
|
void rogueviz_help(int id, int pagenumber) {
|
|
|
|
|
|
|
|
vertexdata& vd = vdata[id];
|
|
|
|
int noedges = isize(vd.edges);
|
|
|
|
help = helptitle(vd.name, vd.cp.color1 >> 8);
|
|
|
|
|
|
|
|
if(vd.info) {
|
|
|
|
#if CAP_URL
|
|
|
|
help_extension hex;
|
|
|
|
hex.key = 'L';
|
|
|
|
hex.text = "open link";
|
|
|
|
hex.subtext = *vd.info;
|
|
|
|
hex.action = [&vd] () { open_url(*vd.info); };
|
|
|
|
help_extensions.push_back(hex);
|
|
|
|
#else
|
|
|
|
help += "\n\nlink: " + *vd.info;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
vector<edgeinfo*> alledges;
|
|
|
|
|
|
|
|
for(int j=0; j<isize(vd.edges); j++)
|
|
|
|
alledges.push_back(vd.edges[j].second);
|
|
|
|
|
|
|
|
sort(alledges.begin(), alledges.end(), edgecmp);
|
|
|
|
|
|
|
|
for(int i=0; i<10 && i+pagenumber < noedges; i++) {
|
|
|
|
help_extension hex;
|
|
|
|
hex.key = 'a' + i;
|
|
|
|
|
|
|
|
edgeinfo *ei = alledges[pagenumber + i];
|
2019-06-01 15:09:50 +00:00
|
|
|
if(ei->weight < ei->type->visible_from_help) continue;
|
2018-09-05 13:41:57 +00:00
|
|
|
int k = ei->i ^ ei->j ^ id;
|
|
|
|
hex.text = vdata[k].name;
|
|
|
|
hex.color = vdata[k].cp.color1 >> 8;
|
2020-03-29 13:14:23 +00:00
|
|
|
if(vizflags & RV_WHICHWEIGHT) {
|
2018-09-05 13:41:57 +00:00
|
|
|
if(which_weight)
|
|
|
|
hex.subtext = fts(ei->weight2);
|
|
|
|
else
|
|
|
|
hex.subtext = fts(ei->weight);
|
|
|
|
}
|
|
|
|
|
|
|
|
hex.action = [k] () { help_extensions.clear(); rogueviz_help(k, 0); };
|
|
|
|
help_extensions.push_back(hex);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(noedges > pagenumber + 10) {
|
|
|
|
help_extension hex;
|
|
|
|
hex.key = 'z';
|
|
|
|
hex.text = "next page";
|
|
|
|
hex.subtext = its(pagenumber+10) + "/" + its(noedges) + " edges";
|
|
|
|
hex.action = [id, pagenumber] () { help_extensions.clear(); rogueviz_help(id, pagenumber + 10); };
|
|
|
|
help_extensions.push_back(hex);
|
|
|
|
}
|
|
|
|
|
2020-03-29 13:14:23 +00:00
|
|
|
if((vizflags & RV_WHICHWEIGHT) && noedges) {
|
2018-09-05 13:41:57 +00:00
|
|
|
help_extension hex;
|
|
|
|
hex.key = 'w';
|
|
|
|
hex.text = "displayed weight";
|
|
|
|
hex.subtext = which_weight ? "attraction force" : "weight from the data";
|
|
|
|
hex.action = [id, pagenumber] () { which_weight = !which_weight; help_extensions.clear(); rogueviz_help(id, pagenumber); };
|
|
|
|
help_extensions.push_back(hex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-09 17:32:34 +00:00
|
|
|
bool describe_monster(shmup::monster *m, string& out) {
|
|
|
|
|
|
|
|
if(m->type != moRogueviz) return false;
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
int i = m->pid;
|
|
|
|
vertexdata& vd = vdata[i];
|
|
|
|
|
2018-07-09 19:14:29 +00:00
|
|
|
string o = vd.name + ", "+its(isize(vd.edges))+" edges";
|
2018-06-22 12:47:24 +00:00
|
|
|
/* if(isize(vd.edges) < 10) {
|
|
|
|
for(int i=0; i<isize(vd.edges); i++)
|
2017-05-27 19:40:40 +00:00
|
|
|
o += " " + its(snakedist(vd.snakeid, vd.edges[i]->snakeid));
|
|
|
|
} */
|
|
|
|
|
2018-09-05 13:41:57 +00:00
|
|
|
help = bygen([i] () { rogueviz_help(i, 0); });
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2018-07-09 19:14:29 +00:00
|
|
|
if(out == XLATN("Canvas")) out = o;
|
|
|
|
else out = out + ", " + o;
|
|
|
|
|
2018-07-09 17:32:34 +00:00
|
|
|
return true;
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
2018-07-09 17:32:34 +00:00
|
|
|
bool activate(shmup::monster *m) {
|
|
|
|
if(m->type != moRogueviz) return false;
|
2017-05-27 19:40:40 +00:00
|
|
|
int i = m->pid;
|
|
|
|
vertexdata& vd = vdata[i];
|
|
|
|
|
|
|
|
vd.cp = colorpair(rand() & 0xFFFFFFFF);
|
|
|
|
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(vd.edges); i++)
|
2017-05-27 19:40:40 +00:00
|
|
|
vd.edges[i].second->orig = NULL;
|
|
|
|
|
2018-07-09 17:32:34 +00:00
|
|
|
return true;
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
/* if(ealpha == 1) ealpha = 8;
|
|
|
|
else if(ealpha == 8) ealpha = 32;
|
|
|
|
else if(ealpha == 32) ealpha = 255;
|
|
|
|
else ealpha = 1; */
|
|
|
|
}
|
|
|
|
|
2018-04-21 10:17:22 +00:00
|
|
|
void storevertex(vector<glvertex>& tab, const hyperpoint& h) {
|
|
|
|
tab.push_back(glhr::pointtogl(h));
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double linequality = .1;
|
|
|
|
|
2018-04-21 10:17:22 +00:00
|
|
|
void storelineto(vector<glvertex>& tab, const hyperpoint& h1, const hyperpoint& h2) {
|
2017-05-27 19:40:40 +00:00
|
|
|
if(intval(h1, h2) < linequality)
|
|
|
|
storevertex(tab, h2);
|
|
|
|
else {
|
|
|
|
hyperpoint h3 = mid(h1, h2);
|
|
|
|
storelineto(tab, h1, h3);
|
|
|
|
storelineto(tab, h3, h2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-21 10:17:22 +00:00
|
|
|
void storeline(vector<glvertex>& tab, const hyperpoint& h1, const hyperpoint& h2) {
|
2017-05-27 19:40:40 +00:00
|
|
|
storevertex(tab, h1);
|
|
|
|
storelineto(tab, h1, h2);
|
|
|
|
}
|
|
|
|
|
2018-09-05 13:20:43 +00:00
|
|
|
color_t darken_a(color_t c) {
|
|
|
|
for(int p=0; p<3; p++)
|
|
|
|
for(int i=0; i<darken; i++) part(c, i+1) = (part(c, i+1) + part(backcolor, i)) >> 1;
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2019-05-06 23:08:49 +00:00
|
|
|
#if CAP_SVG
|
|
|
|
#define SVG_LINK(x) svg::link = (x)
|
|
|
|
#else
|
|
|
|
#define SVG_LINK(x)
|
|
|
|
#endif
|
|
|
|
|
2020-07-29 21:34:00 +00:00
|
|
|
void queuedisk(const shiftmatrix& V, const colorpair& cp, bool legend, const string* info, int i) {
|
2017-05-27 19:40:40 +00:00
|
|
|
if(legend && (int) cp.color1 == (int) 0x000000FF && backcolor == 0)
|
|
|
|
poly_outline = 0x606060FF;
|
|
|
|
else
|
2018-09-05 13:20:43 +00:00
|
|
|
poly_outline = (bordcolor << 8) | 0xFF;
|
2019-06-01 15:06:15 +00:00
|
|
|
|
|
|
|
if(cp.img) {
|
|
|
|
for(hyperpoint h: cp.img->vertices)
|
2020-07-29 21:34:00 +00:00
|
|
|
curvepoint(h);
|
|
|
|
auto& qc = queuecurve(V, 0, 0xFFFFFFFF, PPR::MONSTER_HEAD);
|
2019-06-01 15:06:15 +00:00
|
|
|
qc.tinf = &cp.img->tinf;
|
|
|
|
qc.flags |= POLY_TRIANGLES;
|
|
|
|
return;
|
|
|
|
}
|
2018-07-04 12:34:58 +00:00
|
|
|
|
2020-07-29 21:34:00 +00:00
|
|
|
shiftmatrix V1;
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2019-05-27 05:18:18 +00:00
|
|
|
auto& sh =
|
|
|
|
vertex_shape == 2 ? cgi.shHeptaMarker :
|
|
|
|
vertex_shape == 3 ? cgi.shSnowball :
|
|
|
|
cgi.shDisk;
|
2018-07-04 12:34:58 +00:00
|
|
|
|
|
|
|
if(vertex_shape == 0) ;
|
2019-08-15 13:05:43 +00:00
|
|
|
else if(GDIM == 3 && among(cp.shade, 'b', 'f', 'g', 'B', 'F', 'G')) {
|
2019-04-21 18:52:57 +00:00
|
|
|
V1 = V;
|
|
|
|
}
|
2019-08-15 13:05:43 +00:00
|
|
|
else if(GDIM == 3) {
|
2019-04-03 18:35:12 +00:00
|
|
|
V1 = face_the_player(V);
|
2019-05-06 23:08:49 +00:00
|
|
|
if(info) queueaction(PPR::MONSTER_HEAD, [info] () { SVG_LINK(*info); });
|
2019-04-03 18:35:12 +00:00
|
|
|
queuepolyat(V1, sh, darken_a(cp.color1), PPR::MONSTER_HEAD);
|
2019-05-06 23:08:49 +00:00
|
|
|
if(info) queueaction(PPR::MONSTER_HEAD, [] () { SVG_LINK(""); });
|
2019-04-21 18:52:57 +00:00
|
|
|
V1 = V;
|
2019-04-03 18:35:12 +00:00
|
|
|
}
|
2018-07-04 12:34:58 +00:00
|
|
|
else if(rog3) {
|
2017-05-27 19:40:40 +00:00
|
|
|
int p = poly_outline; poly_outline = OUTLINE_TRANS;
|
2018-08-28 12:27:23 +00:00
|
|
|
queuepolyat(V, sh, 0x80, PPR::MONSTER_SHADOW);
|
2017-05-27 19:40:40 +00:00
|
|
|
poly_outline = p;
|
2019-05-06 23:08:49 +00:00
|
|
|
if(info) queueaction(PPR::MONSTER_HEAD, [info] () { SVG_LINK(*info); });
|
2019-05-27 05:18:18 +00:00
|
|
|
queuepolyat(V1 = mscale(V, cgi.BODY), sh, darken_a(cp.color1), PPR::MONSTER_HEAD);
|
2019-05-06 23:08:49 +00:00
|
|
|
if(info) queueaction(PPR::MONSTER_HEAD, [] () { SVG_LINK(""); });
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
else {
|
2019-05-06 23:08:49 +00:00
|
|
|
if(info) queueaction(PPR::MONSTER_HEAD, [info] () { SVG_LINK(*info); });
|
2018-09-05 13:20:43 +00:00
|
|
|
queuepoly(V1 = V, sh, darken_a(cp.color1));
|
2019-05-06 23:08:49 +00:00
|
|
|
if(info) queueaction(PPR::MONSTER_HEAD, [] () { SVG_LINK(""); });
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
2019-04-21 18:52:57 +00:00
|
|
|
switch(cp.shade) {
|
2019-05-27 05:18:18 +00:00
|
|
|
case 't': queuepoly(V1, cgi.shDiskT, darken_a(cp.color2)); return;
|
|
|
|
case 's': queuepoly(V1, cgi.shDiskS, darken_a(cp.color2)); return;
|
|
|
|
case 'q': queuepoly(V1, cgi.shDiskSq, darken_a(cp.color2)); return;
|
|
|
|
case 'm': queuepoly(V1, cgi.shDiskM, darken_a(cp.color2)); return;
|
2019-08-15 13:05:43 +00:00
|
|
|
case 'b': queuepoly(V1, GDIM == 3 ? cgi.shAnimatedTinyEagle[wingphase(200)] : cgi.shTinyBird, darken_a(cp.color2)); return;
|
2019-05-27 05:18:18 +00:00
|
|
|
case 'f': queuepoly(V1, cgi.shTinyShark, darken_a(cp.color2)); return;
|
|
|
|
case 'g': queuepoly(V1, cgi.shMiniGhost, darken_a(cp.color2)); return;
|
2019-08-15 13:05:43 +00:00
|
|
|
case 'B': queuepoly(V1, GDIM == 3 ? cgi.shAnimatedEagle[wingphase(100)] : cgi.shEagle, darken_a(cp.color2)); return;
|
2019-05-27 05:18:18 +00:00
|
|
|
case 'F': queuepoly(V1, cgi.shShark, darken_a(cp.color2)); return;
|
|
|
|
case 'G': queuepoly(V1, cgi.shGhost, darken_a(cp.color2)); return;
|
2019-04-21 18:52:57 +00:00
|
|
|
}
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 07:57:58 +00:00
|
|
|
unordered_map<pair<edgeinfo*, int>, int> drawn_edges;
|
|
|
|
|
2018-07-09 16:56:51 +00:00
|
|
|
map<pair<cell*, cell*>, transmatrix> relmatrices;
|
|
|
|
|
|
|
|
transmatrix& memo_relative_matrix(cell *c1, cell *c2) {
|
|
|
|
auto& p = relmatrices[make_pair(c1, c2)];
|
|
|
|
if(p[2][2] == 0)
|
2018-08-17 14:47:06 +00:00
|
|
|
p = calc_relative_matrix(c1, c2, C0);
|
2018-07-09 16:56:51 +00:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2020-07-29 21:34:00 +00:00
|
|
|
void queue_prec(const shiftmatrix& V, edgeinfo*& ei, color_t col) {
|
2019-04-23 10:49:07 +00:00
|
|
|
if(!fat_edges)
|
|
|
|
queuetable(V, ei->prec, isize(ei->prec), col, 0, PPR::STRUCT0);
|
2019-05-06 23:08:49 +00:00
|
|
|
#if MAXMDIM >= 4
|
2019-04-23 10:49:07 +00:00
|
|
|
else {
|
|
|
|
auto& t = queuetable(V, ei->prec, isize(ei->prec), 0, col | 0x000000FF, PPR::STRUCT0);
|
|
|
|
t.flags |= (1<<22), // poly triangles
|
|
|
|
t.offset_texture = 0,
|
|
|
|
t.tinf = &ei->tinf;
|
|
|
|
t.tinf->texture_id = floor_textures->renderedTexture;
|
|
|
|
}
|
2019-05-06 23:08:49 +00:00
|
|
|
#endif
|
2019-04-23 10:49:07 +00:00
|
|
|
}
|
|
|
|
|
2020-07-29 21:34:00 +00:00
|
|
|
bool drawVertex(const shiftmatrix &V, cell *c, shmup::monster *m) {
|
2018-07-09 17:32:34 +00:00
|
|
|
if(m->dead) return true;
|
2019-09-22 23:05:59 +00:00
|
|
|
if(m->type != moRogueviz) return false;
|
2017-05-27 19:40:40 +00:00
|
|
|
int i = m->pid;
|
|
|
|
vertexdata& vd = vdata[i];
|
|
|
|
|
2019-07-03 02:57:52 +00:00
|
|
|
// bool ghilite = false;
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2019-07-03 02:57:52 +00:00
|
|
|
// if(vd.special && specialmark) ghilite = true;
|
2017-05-27 19:40:40 +00:00
|
|
|
|
|
|
|
if(!gmatrix.count(m->base)) printf("base not in gmatrix\n");
|
|
|
|
|
|
|
|
int lid = shmup::lmousetarget ? shmup::lmousetarget->pid : -2;
|
|
|
|
|
2020-04-22 12:15:50 +00:00
|
|
|
if(!lshiftclick) for(int j=0; j<isize(vd.edges); j++) {
|
2017-05-27 19:40:40 +00:00
|
|
|
edgeinfo *ei = vd.edges[j].second;
|
|
|
|
vertexdata& vd1 = vdata[ei->i];
|
|
|
|
vertexdata& vd2 = vdata[ei->j];
|
|
|
|
|
|
|
|
int oi = ei->i, oj = ei->j;
|
|
|
|
bool hilite = false;
|
|
|
|
if(vdata[oi].special && vdata[oj].special && specialmark) hilite = true;
|
|
|
|
else if(svg::in || inHighQual) hilite = false;
|
|
|
|
else if(vd1.m == shmup::lmousetarget) hilite = true;
|
|
|
|
else if(vd2.m == shmup::lmousetarget) hilite = true;
|
|
|
|
else if(oi == lid || oj == lid) hilite = true;
|
|
|
|
|
2019-06-01 15:09:50 +00:00
|
|
|
if(ei->weight < (hilite ? ei->type->visible_from_hi : ei->type->visible_from)) continue;
|
|
|
|
|
2019-07-03 02:57:52 +00:00
|
|
|
// if(hilite) ghilite = true;
|
2018-07-05 05:33:09 +00:00
|
|
|
|
2019-11-30 17:52:24 +00:00
|
|
|
bool multidraw = quotient;
|
2018-07-05 07:57:58 +00:00
|
|
|
|
2018-07-05 05:33:09 +00:00
|
|
|
if(ei->lastdraw < frameid || multidraw) {
|
2017-05-27 19:40:40 +00:00
|
|
|
ei->lastdraw = frameid;
|
|
|
|
|
2019-06-01 15:09:50 +00:00
|
|
|
color_t col = (hilite ? ei->type->color_hi : ei->type->color);
|
2018-07-09 16:17:40 +00:00
|
|
|
auto& alpha = part(col, 0);
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2020-03-29 13:14:23 +00:00
|
|
|
if(vizflags & RV_AUTO_MAXWEIGHT) {
|
2017-05-27 19:40:40 +00:00
|
|
|
if(ei->weight2 > maxweight) maxweight = ei->weight2;
|
2019-06-01 15:08:27 +00:00
|
|
|
alpha *= pow(ei->weight2 / maxweight, ggamma);
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
2019-06-01 15:09:50 +00:00
|
|
|
// if(hilite || hiliteclick) alpha = (alpha + 256) / 2;
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2018-09-05 01:51:42 +00:00
|
|
|
if(svg::in && alpha < 16) continue;
|
2018-09-04 21:50:50 +00:00
|
|
|
|
2018-09-05 01:51:42 +00:00
|
|
|
if(ISWEB) {
|
|
|
|
if(alpha >= 128) alpha |= 15;
|
|
|
|
else if(alpha >= 64) alpha |= 7;
|
|
|
|
else if(alpha >= 32) alpha |= 3;
|
|
|
|
else if(alpha >= 16) alpha |= 1;
|
|
|
|
}
|
2018-09-05 13:20:43 +00:00
|
|
|
|
|
|
|
alpha >>= darken;
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2020-07-29 21:34:00 +00:00
|
|
|
shiftmatrix gm1 =
|
2018-09-08 11:42:47 +00:00
|
|
|
(multidraw || elliptic) ? V * memo_relative_matrix(vd1.m->base, c) :
|
2018-08-17 14:47:06 +00:00
|
|
|
ggmatrix(vd1.m->base);
|
2020-07-29 21:34:00 +00:00
|
|
|
shiftmatrix gm2 =
|
2018-09-08 11:42:47 +00:00
|
|
|
(multidraw || elliptic) ? V * memo_relative_matrix(vd2.m->base, c) :
|
2018-08-17 14:47:06 +00:00
|
|
|
ggmatrix(vd2.m->base);
|
2017-07-04 13:38:33 +00:00
|
|
|
|
2020-07-29 21:34:00 +00:00
|
|
|
shiftpoint h1 = gm1 * vd1.m->at * C0;
|
|
|
|
shiftpoint h2 = gm2 * vd2.m->at * C0;
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2020-07-29 21:34:00 +00:00
|
|
|
if(elliptic && hdist(h1, h2) > hdist(h1.h, centralsym * h2.h))
|
|
|
|
h2.h = centralsym * h2.h;
|
2018-09-08 11:42:47 +00:00
|
|
|
|
2018-07-05 07:57:58 +00:00
|
|
|
if(multidraw) {
|
|
|
|
int code = int(h1[0]) + int(h1[1]) * 12789117 + int(h2[0]) * 126081253 + int(h2[1]) * 126891531;
|
|
|
|
int& lastdraw = drawn_edges[make_pair(ei, code)];
|
|
|
|
if(lastdraw == frameid) continue;
|
|
|
|
lastdraw = frameid;
|
|
|
|
}
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
/* if(hdist0(h1) < .001 || hdist0(h2) < .001) {
|
|
|
|
printf("h1 = %s\n", display(h1));
|
|
|
|
printf("h2 = %s\n", display(h2));
|
|
|
|
display(m->at);
|
|
|
|
display(vd2.m->at);
|
|
|
|
display(V);
|
|
|
|
display(gmatrix[vd2.m->base]);
|
|
|
|
display(shmup::calc_gmatrix(vd2.m->base));
|
|
|
|
} */
|
|
|
|
|
2019-06-01 15:09:50 +00:00
|
|
|
if((col >> 8) == (DEFAULT_COLOR >> 8)) {
|
2018-07-09 16:17:40 +00:00
|
|
|
col &= 0xFF;
|
|
|
|
col |= (forecolor << 8);
|
|
|
|
}
|
2020-03-29 13:36:43 +00:00
|
|
|
|
|
|
|
if(callhandlers(false, hooks_alt_edges, ei, false)) ;
|
2017-07-04 13:38:33 +00:00
|
|
|
|
2020-03-29 13:36:43 +00:00
|
|
|
else if(pmodel && !fat_edges) {
|
|
|
|
queueline(h1, h2, col, 2 + vid.linequality).prio = PPR::STRUCT0;
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
2019-11-14 19:26:07 +00:00
|
|
|
cell *center = multidraw ? c : centerover;
|
2018-07-05 07:59:06 +00:00
|
|
|
|
|
|
|
if(!multidraw && ei->orig && ei->orig != center && celldistance(ei->orig, center) > 3)
|
|
|
|
ei->orig = NULL;
|
2017-05-27 19:40:40 +00:00
|
|
|
if(!ei->orig) {
|
2018-08-17 22:46:45 +00:00
|
|
|
ei->orig = center; // cwt.at;
|
2017-05-27 19:40:40 +00:00
|
|
|
ei->prec.clear();
|
2017-07-04 13:38:33 +00:00
|
|
|
|
2020-07-29 21:34:00 +00:00
|
|
|
shiftmatrix T = ggmatrix(ei->orig);
|
2019-04-23 10:49:07 +00:00
|
|
|
|
2020-03-29 13:36:43 +00:00
|
|
|
if(callhandlers(false, hooks_alt_edges, ei, true)) ;
|
|
|
|
else if(fat_edges) {
|
2019-04-23 10:49:07 +00:00
|
|
|
ei->tinf.tvertices.clear();
|
2020-07-29 21:34:00 +00:00
|
|
|
shiftmatrix T1 = gm1 * vd1.m->at;
|
|
|
|
hyperpoint goal = inverse_shift(T1, h2);
|
|
|
|
transmatrix S = inverse_shift(T, gm1) * vd1.m->at * rspintox(goal);
|
2019-04-23 10:49:07 +00:00
|
|
|
ld d = hdist0(goal);
|
|
|
|
for(int a=0; a<360; a+=30) {
|
|
|
|
auto store = [&] (ld a, ld b) {
|
|
|
|
storevertex(ei->prec, S * cpush(0, b) * hr::cspin(1, 2, a * degree) * cpush(1, fat_edges) * C0);
|
|
|
|
ei->tinf.tvertices.push_back(glhr::makevertex(0,(3+cos(a * degree))/4,0));
|
|
|
|
};
|
|
|
|
store(a, 0);
|
|
|
|
store(a+30, 0);
|
|
|
|
store(a, d);
|
|
|
|
store(a+30, 0);
|
|
|
|
store(a, d);
|
|
|
|
store(a+30, d);
|
|
|
|
}
|
|
|
|
}
|
2017-07-04 13:38:33 +00:00
|
|
|
else
|
2020-07-29 21:34:00 +00:00
|
|
|
storeline(ei->prec, inverse_shift(T, h1), inverse_shift(T, h2));
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
2019-04-23 10:49:07 +00:00
|
|
|
queue_prec(multidraw ? V : ggmatrix(ei->orig), ei, col);
|
2020-07-29 21:34:00 +00:00
|
|
|
if(elliptic) queue_prec(ggmatrix(ei->orig) * centralsym, ei, col);
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!vd.virt) {
|
2019-06-01 15:09:50 +00:00
|
|
|
queuedisk(V * m->at, vd.cp, false, vd.info, i);
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(showlabels) {
|
|
|
|
bool doshow = true;
|
2020-03-29 13:14:23 +00:00
|
|
|
if((vizflags & RV_COMPRESS_LABELS) && i > 0 && !vd.virt) {
|
2017-05-27 19:40:40 +00:00
|
|
|
vertexdata& vdp = vdata[vd.data];
|
2020-07-29 21:34:00 +00:00
|
|
|
shiftpoint h2 = ggmatrix(vdp.m->base) * vdp.m->at * C0;
|
2017-05-27 19:40:40 +00:00
|
|
|
if(hdist(h2, V * m->at * C0) < 0.1) doshow = false;
|
|
|
|
}
|
|
|
|
|
2020-07-29 21:34:00 +00:00
|
|
|
shiftpoint h = tC0(V * m->at);
|
|
|
|
shiftmatrix V2 = GDIM == 3 ? V * m->at : rgpushxto0(h) * ypush(PURE ? .3 : .2); // todo-variation
|
2018-07-05 07:59:06 +00:00
|
|
|
if(doshow && !behindsphere(V2)) {
|
2018-09-04 17:53:42 +00:00
|
|
|
auto info = vd.info;
|
2019-05-06 23:08:49 +00:00
|
|
|
if(info) queueaction(PPR::MONSTER_HEAD, [info] () { SVG_LINK(*info); });
|
2019-05-27 05:18:18 +00:00
|
|
|
queuestr(V2, (svg::in ? .28 : .2) * cgi.crossf / cgi.hcrossf, vd.name, forecolor, (svg::in || ISWEB) ? 0 : 1);
|
2019-05-06 23:08:49 +00:00
|
|
|
if(info) queueaction(PPR::MONSTER_HEAD, [] () { SVG_LINK(""); });
|
2018-07-05 07:59:06 +00:00
|
|
|
}
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
2020-03-29 12:41:24 +00:00
|
|
|
callhooks(hooks_drawvertex, vd, c, m, i);
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2018-07-09 17:32:34 +00:00
|
|
|
return true;
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vector<int> legend;
|
|
|
|
|
|
|
|
vector<cell*> named;
|
|
|
|
|
2019-10-06 22:10:42 +00:00
|
|
|
color_t chosen_legend_color = DEFAULT_COLOR;
|
|
|
|
|
2018-07-09 16:39:34 +00:00
|
|
|
bool rogueviz_hud() {
|
2019-10-06 22:10:42 +00:00
|
|
|
color_t legend_color = chosen_legend_color == DEFAULT_COLOR ? forecolor : chosen_legend_color;
|
2020-03-29 13:14:23 +00:00
|
|
|
if(!vizid) return false;
|
2018-07-09 16:39:34 +00:00
|
|
|
if(cmode & sm::DRAW) return false;
|
|
|
|
|
|
|
|
int qet = isize(edgetypes);
|
2018-09-08 11:43:10 +00:00
|
|
|
if(qet == 1 || !edge_legend) qet = 0;
|
|
|
|
|
2018-07-09 16:39:34 +00:00
|
|
|
int legit = qet + isize(legend);
|
|
|
|
|
2018-09-08 11:43:10 +00:00
|
|
|
if(legit == 0) return true;
|
2020-07-29 21:34:00 +00:00
|
|
|
|
2018-09-08 11:43:10 +00:00
|
|
|
initquickqueue();
|
|
|
|
|
2018-11-17 18:24:02 +00:00
|
|
|
int rad = current_display->radius/10;
|
2018-07-09 16:39:34 +00:00
|
|
|
ld x = vid.xres - rad;
|
|
|
|
|
|
|
|
for(int i=0; i<isize(legend); i++) {
|
|
|
|
int k = legend[i];
|
|
|
|
vertexdata& vd = vdata[k];
|
|
|
|
|
2018-11-17 18:24:02 +00:00
|
|
|
ld y = (current_display->radius * (i+.5)) / legit * 2 - current_display->radius + vid.yres/2;
|
2018-07-09 16:39:34 +00:00
|
|
|
|
2018-11-17 18:24:02 +00:00
|
|
|
transmatrix V = atscreenpos(x, y, current_display->radius/4);
|
2018-07-09 16:39:34 +00:00
|
|
|
|
|
|
|
poly_outline = OUTLINE_NONE;
|
2020-07-30 00:30:07 +00:00
|
|
|
queuedisk(shiftless(V), vd.cp, true, NULL, i);
|
2018-07-09 16:39:34 +00:00
|
|
|
poly_outline = OUTLINE_DEFAULT;
|
2019-10-06 22:10:42 +00:00
|
|
|
queuestr(int(x-rad), int(y), 0, rad*(svg::in?5:3)/4, vd.name, legend_color, 0, 16);
|
2018-07-09 16:39:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<qet; i++) {
|
|
|
|
auto t = edgetypes[i];
|
|
|
|
|
2018-11-17 18:24:02 +00:00
|
|
|
ld y = (current_display->radius * (i+isize(legend)+.5)) / legit * 2 - current_display->radius + vid.yres/2;
|
2018-07-09 16:39:34 +00:00
|
|
|
|
2018-11-17 18:24:02 +00:00
|
|
|
transmatrix V = atscreenpos(x, y, current_display->radius/8);
|
2018-07-09 16:39:34 +00:00
|
|
|
|
|
|
|
poly_outline = t->color | 0xFF;
|
2020-07-29 21:34:00 +00:00
|
|
|
queuepolyat(shiftless(V), cgi.shTriangle, 0, PPR::MONSTER_HEAD);
|
|
|
|
|
2018-07-09 16:39:34 +00:00
|
|
|
poly_outline = OUTLINE_DEFAULT;
|
2019-10-06 22:10:42 +00:00
|
|
|
queuestr(int(x-rad), int(y), 0, rad*(svg::in?5:3)/4, t->name, legend_color, 0, 16);
|
2018-07-09 16:39:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
quickqueue();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-04-21 10:17:22 +00:00
|
|
|
void readcolor(const string& cfname) {
|
|
|
|
FILE *f = fopen(cfname.c_str(), "rt");
|
2017-05-27 19:40:40 +00:00
|
|
|
if(!f) { printf("color file missing\n"); exit(1); }
|
|
|
|
while(true) {
|
|
|
|
string lab = "";
|
|
|
|
while(true) {
|
|
|
|
int c = fgetc(f);
|
|
|
|
if(c == EOF) { fclose(f); return; }
|
|
|
|
else if(c == 10 || c == 13 || c == 32 || c == 9) ;
|
|
|
|
else if(c == ',' || c == ';') break;
|
|
|
|
else lab += c;
|
|
|
|
}
|
|
|
|
|
|
|
|
colorpair x;
|
|
|
|
int c2 = fgetc(f);
|
2018-07-05 05:31:27 +00:00
|
|
|
int known_id = -1;
|
|
|
|
|
2020-03-29 12:37:04 +00:00
|
|
|
if(callhandlers(false, hooks_readcolor, c2, lab, f)) continue;
|
|
|
|
|
2017-09-01 20:13:41 +00:00
|
|
|
if(c2 == '#') {
|
|
|
|
while(c2 != 10 && c2 != 13 && c2 != -1) c2 = fgetc(f);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(c2 == '=') {
|
2017-05-27 19:40:40 +00:00
|
|
|
string lab2 = "";
|
|
|
|
while(true) {
|
|
|
|
int c = fgetc(f);
|
|
|
|
if(c == 10 || c == 13 || c == 32 || c == 9 || c == ',' || c == ';' || c == EOF) break;
|
|
|
|
else lab2 += c;
|
|
|
|
}
|
|
|
|
x = vdata[getid(lab2)].cp;
|
|
|
|
}
|
|
|
|
else if(c2 == '@') {
|
2018-07-05 05:31:27 +00:00
|
|
|
legend.push_back(known_id == -1 ? getid(lab) : known_id);
|
2017-05-27 19:40:40 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if(c2 == '/') {
|
|
|
|
char buf[600];
|
|
|
|
int err = fscanf(f, "%500s", buf);
|
|
|
|
if(err > 0)
|
|
|
|
vdata[getid(lab)].info = new string(buf); // replace with std::shared_ptr in C++111
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ungetc(c2, f);
|
2019-06-01 15:06:15 +00:00
|
|
|
char buf[600];
|
|
|
|
int err = fscanf(f, "%500s", buf);
|
2017-05-27 19:40:40 +00:00
|
|
|
if(err > 0) x = parse(buf);
|
|
|
|
}
|
|
|
|
|
2018-06-22 12:47:24 +00:00
|
|
|
if(isize(lab) && lab[0] == '*') {
|
2017-05-27 19:40:40 +00:00
|
|
|
lab = lab.substr(1);
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(vdata); i++)
|
2017-06-09 01:41:33 +00:00
|
|
|
if(vdata[i].name.find(lab) != string::npos) {
|
2017-05-27 19:40:40 +00:00
|
|
|
vdata[i].cp = x;
|
2017-06-09 01:41:33 +00:00
|
|
|
}
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
2020-03-29 12:37:04 +00:00
|
|
|
else if(isize(lab) && lab[0] == '!') {
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(vdata); i++)
|
2017-09-01 20:13:41 +00:00
|
|
|
if(vdata[i].name == lab) {
|
|
|
|
vdata[i].cp = x;
|
|
|
|
}
|
|
|
|
}
|
2017-05-27 19:40:40 +00:00
|
|
|
else {
|
|
|
|
int i = getid(lab);
|
|
|
|
again: vdata[i].cp = x;
|
|
|
|
|
2020-03-29 13:14:23 +00:00
|
|
|
if(vizflags & RV_COLOR_TREE) {
|
2017-05-27 19:40:40 +00:00
|
|
|
i = vdata[i].data;
|
|
|
|
if(i >= 0) goto again;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-29 13:14:23 +00:00
|
|
|
void init(void *_vizid, flagtype _vizflags) {
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
autocheat = true;
|
2017-08-15 15:39:30 +00:00
|
|
|
showstartmenu = false;
|
2017-07-22 23:33:27 +00:00
|
|
|
#if !ISWEB
|
2017-05-27 19:40:40 +00:00
|
|
|
mapeditor::drawplayer = false;
|
2018-07-11 10:25:19 +00:00
|
|
|
stop_game();
|
2017-08-06 12:50:16 +00:00
|
|
|
firstland = specialland = laCanvas;
|
2018-06-10 22:58:38 +00:00
|
|
|
restart_game(shmup::on ? rg::shmup : rg::nothing);
|
2017-05-27 19:40:40 +00:00
|
|
|
#else
|
2018-07-11 10:25:19 +00:00
|
|
|
stop_game();
|
2017-08-06 12:50:16 +00:00
|
|
|
firstland = specialland = laCanvas;
|
2018-06-10 22:58:38 +00:00
|
|
|
restart_game(rg::nothing);
|
2017-05-27 19:40:40 +00:00
|
|
|
#endif
|
2018-07-09 17:58:13 +00:00
|
|
|
autocheat = true;
|
2017-05-27 19:40:40 +00:00
|
|
|
items[itOrbLife] = 0;
|
|
|
|
timerghost = false;
|
|
|
|
|
|
|
|
gmatrix.clear();
|
2018-05-18 11:57:55 +00:00
|
|
|
calcparam();
|
2017-05-27 19:40:40 +00:00
|
|
|
drawthemap();
|
|
|
|
gmatrix0 = gmatrix;
|
2020-03-29 13:24:37 +00:00
|
|
|
|
|
|
|
vizid = _vizid;
|
|
|
|
vizflags = _vizflags;
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
2018-09-06 20:35:13 +00:00
|
|
|
int search_for = -1;
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
void close() {
|
2018-09-06 20:35:13 +00:00
|
|
|
search_for = -1;
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(vdata); i++)
|
2017-05-27 19:40:40 +00:00
|
|
|
if(vdata[i].m) vdata[i].m->dead = true;
|
|
|
|
vdata.clear();
|
|
|
|
labeler.clear();
|
|
|
|
legend.clear();
|
2018-06-22 12:47:24 +00:00
|
|
|
for(int i=0; i<isize(edgeinfos); i++) delete edgeinfos[i];
|
2017-05-27 19:40:40 +00:00
|
|
|
edgeinfos.clear();
|
|
|
|
anygraph::coords.clear();
|
2020-03-29 11:09:10 +00:00
|
|
|
callhooks(hooks_close);
|
2018-07-09 16:17:40 +00:00
|
|
|
edgetypes.clear();
|
2020-03-29 13:14:23 +00:00
|
|
|
vizid = nullptr;
|
2018-07-09 16:56:51 +00:00
|
|
|
relmatrices.clear();
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
2017-12-01 23:24:07 +00:00
|
|
|
#if CAP_COMMANDLINE
|
2017-05-27 19:40:40 +00:00
|
|
|
int readArgs() {
|
|
|
|
using namespace arg;
|
|
|
|
|
|
|
|
// options before reading
|
|
|
|
if(0) ;
|
|
|
|
else if(argis("-dftcolor")) {
|
2019-04-22 12:46:33 +00:00
|
|
|
shift(); dftcolor = parse(args());
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// graph visualizer
|
|
|
|
//------------------
|
|
|
|
|
|
|
|
// this visualizes the data from: https://hpi.de/friedrich/research/hyperbolic
|
|
|
|
|
|
|
|
else if(argis("-graph")) {
|
|
|
|
PHASE(3); shift(); anygraph::read(args());
|
|
|
|
}
|
|
|
|
|
|
|
|
// graphical parameters
|
|
|
|
//------------------
|
|
|
|
|
|
|
|
// read the color/legend file
|
|
|
|
else if(argis("-color")) {
|
|
|
|
PHASE(3); shift(); readcolor(args());
|
|
|
|
}
|
|
|
|
else if(argis("-lab")) {
|
|
|
|
showlabels = true;
|
|
|
|
}
|
2018-07-05 07:59:14 +00:00
|
|
|
else if(argis("-lab-off")) {
|
|
|
|
showlabels = false;
|
|
|
|
}
|
2017-05-27 19:40:40 +00:00
|
|
|
else if(argis("-rog3")) {
|
|
|
|
rog3 = true;
|
|
|
|
}
|
2018-07-04 12:35:45 +00:00
|
|
|
else if(argis("-rvedge")) {
|
2019-06-01 15:08:27 +00:00
|
|
|
shift(); default_edgetype.color = default_edgetype.color_hi = arghex();
|
|
|
|
}
|
|
|
|
else if(argis("-rvedgehi")) {
|
|
|
|
shift(); default_edgetype.color_hi = arghex();
|
2018-07-09 16:17:40 +00:00
|
|
|
}
|
2019-04-23 10:49:07 +00:00
|
|
|
else if(argis("-rvfat")) {
|
|
|
|
shift();
|
|
|
|
fat_edges = argf();
|
|
|
|
}
|
2019-10-06 22:10:42 +00:00
|
|
|
else if(argis("-lcol")) {
|
|
|
|
shift();
|
|
|
|
chosen_legend_color = arghex();
|
|
|
|
}
|
2018-07-09 16:17:40 +00:00
|
|
|
else if(argis("-ggamma")) {
|
2019-06-01 15:08:27 +00:00
|
|
|
shift(); ggamma = argf();
|
2018-07-04 12:35:45 +00:00
|
|
|
}
|
2017-05-27 19:40:40 +00:00
|
|
|
else if(argis("-rvwarp")) {
|
2017-12-09 02:48:30 +00:00
|
|
|
patterns::whichShape = '8';
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
else if(argis("-lq")) {
|
2018-11-09 13:26:31 +00:00
|
|
|
shift_arg_formula(linequality);
|
2017-05-27 19:40:40 +00:00
|
|
|
}
|
|
|
|
else if(argis("-nolegend")) {
|
|
|
|
legend.clear();
|
|
|
|
}
|
2018-09-08 11:43:10 +00:00
|
|
|
else if(argis("-edgelegend")) {
|
|
|
|
edge_legend = true;
|
|
|
|
}
|
2018-07-04 12:34:58 +00:00
|
|
|
else if(argis("-rvshape")) {
|
|
|
|
shift(); vertex_shape = argi() & 3;
|
|
|
|
}
|
2017-05-27 19:40:40 +00:00
|
|
|
|
|
|
|
// graphical output
|
|
|
|
//------------------
|
|
|
|
|
|
|
|
// shmup::turn might be necessary when saving screenshots
|
|
|
|
else if(argis("-TURN")) {
|
|
|
|
PHASE(3); shmup::turn(100);
|
|
|
|
}
|
|
|
|
else return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
2017-12-01 23:24:07 +00:00
|
|
|
#endif
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2018-07-09 16:17:40 +00:00
|
|
|
void configure_edge_display() {
|
|
|
|
cmode = sm::SIDE | sm::MAYDARK | sm::DIALOG_STRICT_X;
|
|
|
|
static int mode = 0;
|
|
|
|
gamescreen(0);
|
|
|
|
dialog::init(XLAT("rogueviz edges"));
|
|
|
|
for(int i=0; i<isize(edgetypes); i++) {
|
|
|
|
auto t = edgetypes[i];
|
|
|
|
switch(mode) {
|
|
|
|
case 0:
|
|
|
|
dialog::addSelItem(t->name, itsh(t->color), 'a' + i);
|
2018-07-09 16:24:11 +00:00
|
|
|
dialog::lastItem().colorv = t->color >> 8;
|
2018-07-09 16:17:40 +00:00
|
|
|
dialog::add_action([t] {
|
|
|
|
dialog::openColorDialog(t->color, NULL);
|
|
|
|
dialog::dialogflags |= sm::MAYDARK | sm::SIDE;
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-03-29 13:14:23 +00:00
|
|
|
if(!(vizflags & RV_INVERSE_WEIGHT)) {
|
2018-07-09 16:17:40 +00:00
|
|
|
dialog::addSelItem(t->name, fts(t->visible_from), 'a'+i);
|
|
|
|
dialog::add_action([t] {
|
|
|
|
dialog::editNumber(t->visible_from, 0.001, 1000, .1, .1, "min weight", "");
|
|
|
|
dialog::scaleLog();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dialog::addSelItem(t->name, its(1 / t->visible_from), 'a'+i);
|
2020-03-29 13:14:23 +00:00
|
|
|
dialog::add_action([t] {
|
2018-07-09 16:17:40 +00:00
|
|
|
static int i;
|
|
|
|
i = 1 / t->visible_from;
|
2020-03-29 13:14:23 +00:00
|
|
|
dialog::editNumber(i, 1, 1000000, 1, 500, weight_label, "");
|
2018-07-09 16:17:40 +00:00
|
|
|
dialog::reaction = [t] () { t->visible_from = i ? 1. / i : 5; };
|
2018-07-11 10:38:06 +00:00
|
|
|
dialog::scaleLog(); dialog::ne.step = .2;
|
2018-07-09 16:17:40 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dialog::addBreak(100);
|
2020-03-29 13:14:23 +00:00
|
|
|
if(vizflags & RV_HAVE_WEIGHT) {
|
2019-05-03 10:11:40 +00:00
|
|
|
dialog::addBoolItem_choice("color/alpha", mode, 0, '1');
|
2020-03-29 13:14:23 +00:00
|
|
|
dialog::addBoolItem_choice(weight_label, mode, 1, '2');
|
2018-07-09 16:17:40 +00:00
|
|
|
}
|
|
|
|
else mode = 0;
|
|
|
|
|
|
|
|
dialog::addBreak(50);
|
|
|
|
dialog::addBack();
|
|
|
|
dialog::display();
|
|
|
|
}
|
|
|
|
|
2018-09-06 20:35:13 +00:00
|
|
|
void search_marker() {
|
|
|
|
if(search_for >= 0 && search_for < isize(vdata)) {
|
|
|
|
auto& vd = vdata[search_for];
|
|
|
|
auto& m = vd.m;
|
|
|
|
if(!m) return;
|
2020-07-29 21:34:00 +00:00
|
|
|
shiftpoint H = ggmatrix(m->base) * tC0(m->at);
|
2019-12-27 11:50:56 +00:00
|
|
|
queuestr(H, 2*vid.fsize, "X", 0x10101 * int(128 + 100 * sin(ticks / 150.)));
|
2018-09-06 20:35:13 +00:00
|
|
|
addauraspecial(H, iinf[itOrbYendor].color, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void showVertexSearch() {
|
|
|
|
cmode = sm::SIDE | sm::MAYDARK | sm::DIALOG_STRICT_X;
|
|
|
|
gamescreen(0); search_for = -1;
|
|
|
|
|
|
|
|
dialog::init(XLAT("vertex search"));
|
|
|
|
dialog::v.clear();
|
|
|
|
if(dialog::infix != "") mouseovers = dialog::infix;
|
|
|
|
|
|
|
|
for(int i=0; i<isize(vdata); i++) if(vdata[i].name != "") dialog::vpush(i, vdata[i].name.c_str());
|
|
|
|
|
|
|
|
for(int i=0; i<9; i++) {
|
|
|
|
if(i < isize(dialog::v)) {
|
|
|
|
int id = dialog::v[i].second;
|
|
|
|
dialog::addItem(dialog::v[i].first, '1'+i);
|
|
|
|
dialog::add_action([id] () {
|
|
|
|
search_for = id;
|
|
|
|
popScreenAll();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else dialog::addBreak(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog::addSelItem("matching items", its(isize(dialog::v)), 0);
|
|
|
|
dialog::display();
|
|
|
|
|
|
|
|
keyhandler = [] (int sym, int uni) {
|
|
|
|
dialog::handleNavigation(sym, uni);
|
|
|
|
if(dialog::editInfix(uni)) ;
|
|
|
|
else if(doexiton(sym, uni)) popScreen();
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
void showMenu() {
|
2020-03-29 12:10:50 +00:00
|
|
|
if(callhandlers(false, hooks_rvmenu_replace)) return;
|
2018-01-14 02:00:24 +00:00
|
|
|
cmode = sm::SIDE | sm::MAYDARK | sm::DIALOG_STRICT_X;
|
|
|
|
gamescreen(0);
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
dialog::init(XLAT("rogueviz configuration"));
|
|
|
|
|
2020-03-29 11:09:10 +00:00
|
|
|
dialog::addBoolItem_action(XLAT("show labels"), showlabels, 'l');
|
|
|
|
dialog::addBoolItem_action(XLAT("mark special vertices"), specialmark, 'x');
|
2017-05-27 19:40:40 +00:00
|
|
|
dialog::addSelItem(XLAT("background color"), itsh(backcolor), 'b');
|
2020-03-29 11:09:10 +00:00
|
|
|
dialog::add_action_push([] {backcolor ^= 0xFFFFFF, bordcolor ^= 0xFFFFFF, forecolor ^= 0xFFFFFF; });
|
|
|
|
if(isize(edgetypes)) {
|
2018-07-09 16:17:40 +00:00
|
|
|
dialog::addSelItem(XLAT("edge types"), its(isize(edgetypes)), 'g');
|
2020-03-29 11:09:10 +00:00
|
|
|
dialog::add_action_push(configure_edge_display);
|
|
|
|
}
|
|
|
|
dialog::addBoolItem_action(XLAT("vertices in 3D"), rog3, 'v');
|
2018-07-04 12:34:58 +00:00
|
|
|
dialog::addSelItem(XLAT("vertex shape"), its(vertex_shape), 'w');
|
2020-03-29 11:09:10 +00:00
|
|
|
dialog::add_action_push([] { vertex_shape = (1 + vertex_shape) & 3; });
|
|
|
|
|
|
|
|
dialog::add_key_action('z', [] {
|
|
|
|
for(int i=0; i<isize(named)-1; i++) if(named[i] == cwt.at)
|
|
|
|
swap(named[i], named[i+1]);
|
|
|
|
if(!isize(named) || named[isize(named)-1] != cwt.at) named.push_back(cwt.at);
|
|
|
|
printf("named = %d\n", isize(named));
|
|
|
|
popScreen();
|
|
|
|
});
|
2018-09-06 20:35:13 +00:00
|
|
|
|
|
|
|
dialog::addItem(XLAT("vertex search"), '/');
|
2019-03-30 22:59:51 +00:00
|
|
|
dialog::add_action_push(showVertexSearch);
|
2017-06-09 01:41:33 +00:00
|
|
|
|
2020-03-29 11:09:10 +00:00
|
|
|
dialog::addBreak(50);
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2020-03-29 11:09:10 +00:00
|
|
|
callhooks(hooks_rvmenu);
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
dialog::addBreak(50);
|
2018-06-12 22:00:01 +00:00
|
|
|
dialog::addBack();
|
2017-05-27 19:40:40 +00:00
|
|
|
|
|
|
|
dialog::display();
|
|
|
|
}
|
|
|
|
|
2018-07-09 18:09:56 +00:00
|
|
|
bool default_help() {
|
2020-03-29 13:14:23 +00:00
|
|
|
if(!vizid) return false;
|
2018-07-09 18:09:56 +00:00
|
|
|
|
|
|
|
help =
|
|
|
|
"This is RogueViz, a visualization engine based on HyperRogue.\n\nUse WASD to move, v for menu.\n\n"
|
|
|
|
"Read more about RogueViz on : http://roguetemple.com/z/hyper/rogueviz.php\n\n";
|
|
|
|
|
|
|
|
help_extensions.push_back(help_extension{'u', XLAT("RogueViz menu"), [] () { popScreen(); pushScreen(showMenu); }});
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-05-15 13:53:29 +00:00
|
|
|
void o_key(o_funcs& v) {
|
|
|
|
if(vizid) v.push_back(named_dialog(XLAT("rogueviz menu"), rogueviz::showMenu));
|
2018-11-17 18:24:02 +00:00
|
|
|
}
|
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
auto hooks =
|
2017-12-01 23:24:07 +00:00
|
|
|
#if CAP_COMMANDLINE
|
2017-07-10 18:47:38 +00:00
|
|
|
addHook(hooks_args, 100, readArgs) +
|
2017-12-01 23:24:07 +00:00
|
|
|
#endif
|
2020-04-11 18:40:12 +00:00
|
|
|
addHook(hooks_clearmemory, 0, close) +
|
2018-07-09 16:59:12 +00:00
|
|
|
addHook(hooks_prestats, 100, rogueviz_hud) +
|
2018-07-09 17:32:34 +00:00
|
|
|
addHook(shmup::hooks_draw, 100, drawVertex) +
|
|
|
|
addHook(shmup::hooks_describe, 100, describe_monster) +
|
|
|
|
addHook(shmup::hooks_kill, 100, activate) +
|
2018-11-17 18:24:02 +00:00
|
|
|
addHook(hooks_o_key, 100, o_key) +
|
2020-03-29 11:31:22 +00:00
|
|
|
|
2019-09-08 08:08:25 +00:00
|
|
|
addHook(dialog::hooks_display_dialog, 100, [] () {
|
|
|
|
if(current_screen_cfunction() == showMainMenu) {
|
|
|
|
dialog::addItem(XLAT("rogueviz menu"), 'u');
|
|
|
|
dialog::add_action_push(rogueviz::showMenu);
|
|
|
|
}
|
2018-07-09 17:55:56 +00:00
|
|
|
}) +
|
|
|
|
addHook(hooks_welcome_message, 100, [] () {
|
2020-03-29 13:14:23 +00:00
|
|
|
if(vizid) addMessage(XLAT("Welcome to RogueViz!"));
|
|
|
|
return bool(vizid);
|
2018-07-09 17:55:56 +00:00
|
|
|
}) +
|
2018-07-09 18:09:56 +00:00
|
|
|
addHook(hooks_default_help, 100, default_help) +
|
2018-09-06 20:35:13 +00:00
|
|
|
addHook(hooks_markers, 100, search_marker) +
|
2018-07-09 18:09:56 +00:00
|
|
|
0;
|
2017-07-10 18:47:38 +00:00
|
|
|
|
2020-02-23 01:51:27 +00:00
|
|
|
}
|