mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-12 02:10:34 +00:00
rogueviz:: graph:: in color reader, patterns work on all, separated 'info' and 'url' commands, and added preliminary 'dot' command
This commit is contained in:
parent
168016287d
commit
c5eebe4d4c
@ -268,16 +268,19 @@ void rogueviz_help(int id, int pagenumber) {
|
|||||||
int noedges = isize(vd.edges);
|
int noedges = isize(vd.edges);
|
||||||
help = helptitle(vd.name, vd.cp.color1 >> 8);
|
help = helptitle(vd.name, vd.cp.color1 >> 8);
|
||||||
|
|
||||||
if(vd.info) {
|
for(auto info: vd.infos)
|
||||||
|
help += "\n\n" + info;
|
||||||
|
|
||||||
|
for(auto url: vd.urls) {
|
||||||
#if CAP_URL
|
#if CAP_URL
|
||||||
help_extension hex;
|
help_extension hex;
|
||||||
hex.key = 'L';
|
hex.key = 'L';
|
||||||
hex.text = "open link";
|
hex.text = "open link";
|
||||||
hex.subtext = *vd.info;
|
hex.subtext = url;
|
||||||
hex.action = [&vd] () { open_url(*vd.info); };
|
hex.action = [&url] () { open_url(url); };
|
||||||
help_extensions.push_back(hex);
|
help_extensions.push_back(hex);
|
||||||
#else
|
#else
|
||||||
help += "\n\nlink: " + *vd.info;
|
help += "\n\nlink: " + url;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +405,7 @@ color_t darken_a(color_t c) {
|
|||||||
#define SVG_LINK(x)
|
#define SVG_LINK(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void queuedisk(const shiftmatrix& V, const colorpair& cp, bool legend, const string* info, int i) {
|
void queuedisk(const shiftmatrix& V, const colorpair& cp, bool legend, const string *url, int i) {
|
||||||
if(legend && (int) cp.color1 == (int) 0x000000FF && backcolor == 0)
|
if(legend && (int) cp.color1 == (int) 0x000000FF && backcolor == 0)
|
||||||
poly_outline = 0x606060FF;
|
poly_outline = 0x606060FF;
|
||||||
else
|
else
|
||||||
@ -412,7 +415,8 @@ void queuedisk(const shiftmatrix& V, const colorpair& cp, bool legend, const str
|
|||||||
if(cp.img) {
|
if(cp.img) {
|
||||||
for(hyperpoint h: cp.img->vertices)
|
for(hyperpoint h: cp.img->vertices)
|
||||||
curvepoint(h);
|
curvepoint(h);
|
||||||
auto& qc = queuecurve(V, 0, 0xFFFFFFFF, PPR::MONSTER_HEAD);
|
auto V1 = V; V1.T = rgpushxto0(V.T * C0);
|
||||||
|
auto& qc = queuecurve(V1, 0, 0xFFFFFFFF, PPR::MONSTER_HEAD);
|
||||||
qc.tinf = &cp.img->tinf;
|
qc.tinf = &cp.img->tinf;
|
||||||
qc.flags |= POLY_TRIANGLES;
|
qc.flags |= POLY_TRIANGLES;
|
||||||
return;
|
return;
|
||||||
@ -432,23 +436,23 @@ void queuedisk(const shiftmatrix& V, const colorpair& cp, bool legend, const str
|
|||||||
}
|
}
|
||||||
else if(GDIM == 3) {
|
else if(GDIM == 3) {
|
||||||
V1 = face_the_player(V);
|
V1 = face_the_player(V);
|
||||||
if(info) queueaction(PPR::MONSTER_HEAD, [info] () { SVG_LINK(*info); });
|
if(url) queueaction(PPR::MONSTER_HEAD, [url] () { SVG_LINK(*url); });
|
||||||
queuepolyat(V1, sh, darken_a(cp.color1), PPR::MONSTER_HEAD);
|
queuepolyat(V1, sh, darken_a(cp.color1), PPR::MONSTER_HEAD);
|
||||||
if(info) queueaction(PPR::MONSTER_HEAD, [] () { SVG_LINK(""); });
|
if(url) queueaction(PPR::MONSTER_HEAD, [] () { SVG_LINK(""); });
|
||||||
V1 = V;
|
V1 = V;
|
||||||
}
|
}
|
||||||
else if(rog3) {
|
else if(rog3) {
|
||||||
int p = poly_outline; poly_outline = OUTLINE_TRANS;
|
int p = poly_outline; poly_outline = OUTLINE_TRANS;
|
||||||
queuepolyat(V, sh, 0x80, PPR::MONSTER_SHADOW);
|
queuepolyat(V, sh, 0x80, PPR::MONSTER_SHADOW);
|
||||||
poly_outline = p;
|
poly_outline = p;
|
||||||
if(info) queueaction(PPR::MONSTER_HEAD, [info] () { SVG_LINK(*info); });
|
if(url) queueaction(PPR::MONSTER_HEAD, [url] () { SVG_LINK(*url); });
|
||||||
queuepolyat(V1 = orthogonal_move_fol(V, cgi.BODY), sh, darken_a(cp.color1), PPR::MONSTER_HEAD);
|
queuepolyat(V1 = orthogonal_move_fol(V, cgi.BODY), sh, darken_a(cp.color1), PPR::MONSTER_HEAD);
|
||||||
if(info) queueaction(PPR::MONSTER_HEAD, [] () { SVG_LINK(""); });
|
if(url) queueaction(PPR::MONSTER_HEAD, [] () { SVG_LINK(""); });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(info) queueaction(PPR::MONSTER_HEAD, [info] () { SVG_LINK(*info); });
|
if(url) queueaction(PPR::MONSTER_HEAD, [url] () { SVG_LINK(*url); });
|
||||||
queuepoly(V1 = V, sh, darken_a(cp.color1));
|
queuepoly(V1 = V, sh, darken_a(cp.color1));
|
||||||
if(info) queueaction(PPR::MONSTER_HEAD, [] () { SVG_LINK(""); });
|
if(url) queueaction(PPR::MONSTER_HEAD, [] () { SVG_LINK(""); });
|
||||||
}
|
}
|
||||||
switch(cp.shade) {
|
switch(cp.shade) {
|
||||||
case 't': queuepoly(V1, cgi.shDiskT, darken_a(cp.color2)); return;
|
case 't': queuepoly(V1, cgi.shDiskT, darken_a(cp.color2)); return;
|
||||||
@ -665,8 +669,10 @@ bool drawVertex(const shiftmatrix &V, cell *c, shmup::monster *m) {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string *url = nullptr; if(vd.urls.size()) url = &vd.urls[0];
|
||||||
|
|
||||||
if(!vd.virt) {
|
if(!vd.virt) {
|
||||||
queuedisk(V * m->at, vd.cp, false, vd.info, i);
|
queuedisk(V * m->at, vd.cp, false, url, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -681,8 +687,7 @@ bool drawVertex(const shiftmatrix &V, cell *c, shmup::monster *m) {
|
|||||||
shiftpoint h = tC0(V * m->at);
|
shiftpoint h = tC0(V * m->at);
|
||||||
shiftmatrix V2 = GDIM == 3 ? V * m->at : rgpushxto0(h) * ypush(cgi.scalefactor * labelshift); // todo-variation
|
shiftmatrix V2 = GDIM == 3 ? V * m->at : rgpushxto0(h) * ypush(cgi.scalefactor * labelshift); // todo-variation
|
||||||
if(doshow && !behindsphere(V2)) {
|
if(doshow && !behindsphere(V2)) {
|
||||||
auto info = vd.info;
|
if(url) queueaction(PPR::MONSTER_HEAD, [url] () { SVG_LINK(*url); });
|
||||||
if(info) queueaction(PPR::MONSTER_HEAD, [info] () { SVG_LINK(*info); });
|
|
||||||
string s;
|
string s;
|
||||||
ld w = hi_weight;
|
ld w = hi_weight;
|
||||||
if(vizflags & RV_INVERSE_WEIGHT) w = 1/w;
|
if(vizflags & RV_INVERSE_WEIGHT) w = 1/w;
|
||||||
@ -690,7 +695,7 @@ bool drawVertex(const shiftmatrix &V, cell *c, shmup::monster *m) {
|
|||||||
else if(showlabels) s = vd.name;
|
else if(showlabels) s = vd.name;
|
||||||
else if(hi_weight) s = fts(w);
|
else if(hi_weight) s = fts(w);
|
||||||
queuestr(V2, labelscale, s, forecolor, (svg::in || ISWEB) ? 0 : 1);
|
queuestr(V2, labelscale, s, forecolor, (svg::in || ISWEB) ? 0 : 1);
|
||||||
if(info) queueaction(PPR::MONSTER_HEAD, [] () { SVG_LINK(""); });
|
if(url) queueaction(PPR::MONSTER_HEAD, [] () { SVG_LINK(""); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,6 +769,15 @@ bool rv_ignore(char c) {
|
|||||||
void readcolor(const string& cfname) {
|
void readcolor(const string& cfname) {
|
||||||
FILE *f = fopen(cfname.c_str(), "rt");
|
FILE *f = fopen(cfname.c_str(), "rt");
|
||||||
if(!f) { printf("color file missing\n"); exit(1); }
|
if(!f) { printf("color file missing\n"); exit(1); }
|
||||||
|
auto str_to_eol = [&] () {
|
||||||
|
string s;
|
||||||
|
while(true) {
|
||||||
|
int c = fgetc(f);
|
||||||
|
if(c == EOF || c == 10 || c == 13) return s;
|
||||||
|
s += c;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
string lab = "";
|
string lab = "";
|
||||||
while(true) {
|
while(true) {
|
||||||
@ -774,14 +788,14 @@ void readcolor(const string& cfname) {
|
|||||||
else lab += c;
|
else lab += c;
|
||||||
}
|
}
|
||||||
|
|
||||||
colorpair x;
|
hr::function<void(vertexdata&)> action;
|
||||||
int c2 = fgetc(f);
|
int c2 = fgetc(f);
|
||||||
int known_id = -1;
|
int known_id = -1;
|
||||||
|
|
||||||
if(callhandlers(false, hooks_readcolor, c2, lab, f)) continue;
|
if(callhandlers(false, hooks_readcolor, c2, lab, f)) continue;
|
||||||
|
|
||||||
if(c2 == '#') {
|
if(c2 == '#') {
|
||||||
while(c2 != 10 && c2 != 13 && c2 != -1) c2 = fgetc(f);
|
str_to_eol();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if(c2 == '=') {
|
else if(c2 == '=') {
|
||||||
@ -791,56 +805,62 @@ void readcolor(const string& cfname) {
|
|||||||
if(rv_ignore(c) || c == ',' || c == ';' || c == EOF) break;
|
if(rv_ignore(c) || c == ',' || c == ';' || c == EOF) break;
|
||||||
else lab2 += c;
|
else lab2 += c;
|
||||||
}
|
}
|
||||||
x = vdata[getid(lab2)].cp;
|
auto x = vdata[getid(lab2)].cp;
|
||||||
|
action = [x] (vertexdata &vd) { vd.cp = x; };
|
||||||
}
|
}
|
||||||
else if(c2 == '@') {
|
else if(c2 == '@') {
|
||||||
legend.push_back(known_id == -1 ? getid(lab) : known_id);
|
legend.push_back(known_id == -1 ? getid(lab) : known_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if(c2 == '.') {
|
||||||
|
color_t col;
|
||||||
|
int err = fscanf(f, "%08x", &col);
|
||||||
|
if(err <= 0) throw hstream_exception("reading dot-color");
|
||||||
|
action = [col] (vertexdata &vd) { vd.m->base->landparam = col >> 8; };
|
||||||
|
continue;
|
||||||
|
}
|
||||||
else if(c2 == '/') {
|
else if(c2 == '/') {
|
||||||
char buf[600];
|
string s = str_to_eol();
|
||||||
int err = fscanf(f, "%500s", buf);
|
action = [s] (vertexdata &vd) { vd.urls.push_back(s); };
|
||||||
if(err > 0)
|
continue;
|
||||||
vdata[getid(lab)].info = new string(buf); // replace with std::shared_ptr in C++111
|
}
|
||||||
|
else if(c2 == '?') {
|
||||||
|
string s = str_to_eol();
|
||||||
|
action = [s] (vertexdata &vd) { vd.infos.push_back(s); };
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if(c2 == '>') {
|
else if(c2 == '>') {
|
||||||
char buf[600];
|
string s = str_to_eol();
|
||||||
int err = fscanf(f, "%500s", buf);
|
action = [s] (vertexdata &vd) { vd.name = s; };
|
||||||
if(err > 0) {
|
|
||||||
vdata[getid(lab)].name = buf;
|
|
||||||
for(char& ch: vdata[getid(lab)].name) if(ch == '_') ch = ' ';
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ungetc(c2, f);
|
ungetc(c2, f);
|
||||||
char buf[600];
|
auto x = parse(str_to_eol());
|
||||||
int err = fscanf(f, "%500s", buf);
|
string s = str_to_eol();
|
||||||
if(err > 0) x = parse(buf);
|
action = [x] (vertexdata &vd) { vd.cp = x; };
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isize(lab) && lab[0] == '*') {
|
if(isize(lab) && lab[0] == '*') {
|
||||||
lab = lab.substr(1);
|
lab = lab.substr(1);
|
||||||
for(int i=0; i<isize(vdata); i++)
|
for(auto& vd: vdata)
|
||||||
if(vdata[i].name.find(lab) != string::npos) {
|
if(vd.name.find(lab) != string::npos)
|
||||||
vdata[i].cp = x;
|
action(vd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(isize(lab) && lab[0] == '!') {
|
else if(isize(lab) && lab[0] == '!') {
|
||||||
for(int i=0; i<isize(vdata); i++)
|
for(auto& vd: vdata)
|
||||||
if(vdata[i].name == lab) {
|
if(vd.name == lab)
|
||||||
vdata[i].cp = x;
|
action(vd);
|
||||||
}
|
}
|
||||||
|
else if(isize(lab) && lab[0] == '^') {
|
||||||
|
int i = getid(lab);
|
||||||
|
while(i >= 0) {
|
||||||
|
action(vdata[i]);
|
||||||
|
i = vdata[i].data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int i = getid(lab);
|
action(vdata[getid(lab)]);
|
||||||
again: vdata[i].cp = x;
|
|
||||||
|
|
||||||
if(vizflags & RV_COLOR_TREE) {
|
|
||||||
i = vdata[i].data;
|
|
||||||
if(i >= 0) goto again;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1075,7 +1095,13 @@ void showVertexSearch() {
|
|||||||
dialog::v.clear();
|
dialog::v.clear();
|
||||||
if(dialog::infix != "") mouseovers = dialog::infix;
|
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<isize(vdata); i++) {
|
||||||
|
string n = vdata[i].name;
|
||||||
|
for(auto& u: vdata[i].infos) n += "||" + u;
|
||||||
|
if(n == "") continue;
|
||||||
|
if(n[0] == '|') n = its(i) + n;
|
||||||
|
dialog::vpush2(i, vdata[i].name, n);
|
||||||
|
}
|
||||||
|
|
||||||
dialog::addBreak(50);
|
dialog::addBreak(50);
|
||||||
dialog::start_list(900, 900, '1');
|
dialog::start_list(900, 900, '1');
|
||||||
|
Loading…
Reference in New Issue
Block a user