1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-09-29 22:40:41 +00:00

removed refs to kohonen from readcolor

This commit is contained in:
Zeno Rogue 2020-03-29 14:37:04 +02:00
parent dc7b19ebc8
commit 9cae1cce92
2 changed files with 19 additions and 14 deletions

View File

@ -1531,10 +1531,23 @@ bool turn(int delta) {
// shmup::pc[0]->rebase(); // shmup::pc[0]->rebase();
} }
bool kohonen_color(int& c2, string& lab, FILE *f) {
if(c2 == '+') {
int known_id = kohonen::showsample(lab);
c2 = fgetc(f);
if(c2 == '@') {
legend.push_back(known_id);
return true;
}
}
return false;
}
auto hooks2 = addHook(hooks_frame, 50, levelline::draw) auto hooks2 = addHook(hooks_frame, 50, levelline::draw)
+ addHook(hooks_mouseover, 100, describe_cell) + addHook(hooks_mouseover, 100, describe_cell)
+ addHook(shmup::hooks_turn, 100, turn) + addHook(shmup::hooks_turn, 100, turn)
+ addHook(rogueviz::hooks_rvmenu, 100, showMenu); + addHook(rogueviz::hooks_rvmenu, 100, showMenu)
+ addHook(hooks_readcolor, 100, kohonen_color);
void clear() { void clear() {
printf("clearing Kohonen...\n"); printf("clearing Kohonen...\n");

View File

@ -910,6 +910,8 @@ void drawExtra() {
} }
} }
inline hookset<bool(int&, string&, FILE*)> *hooks_readcolor;
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); }
@ -926,19 +928,9 @@ void readcolor(const string& cfname) {
colorpair x; colorpair x;
int c2 = fgetc(f); int c2 = fgetc(f);
int known_id = -1; int known_id = -1;
bool force = false;
if(kohonen::samples && c2 == '!') { if(callhandlers(false, hooks_readcolor, c2, lab, f)) continue;
force = true;
c2 = fgetc(f);
if(c2 == 10 || c2 == 13) continue;
}
if(kohonen::samples && c2 == '+') {
known_id = kohonen::showsample(lab);
c2 = fgetc(f);
if(c2 == 10 || c2 == 13) continue;
}
if(c2 == '#') { if(c2 == '#') {
while(c2 != 10 && c2 != 13 && c2 != -1) c2 = fgetc(f); while(c2 != 10 && c2 != 13 && c2 != -1) c2 = fgetc(f);
continue; continue;
@ -977,7 +969,7 @@ void readcolor(const string& cfname) {
vdata[i].cp = x; vdata[i].cp = x;
} }
} }
else if(kohonen::samples && !force) { else if(isize(lab) && lab[0] == '!') {
for(int i=0; i<isize(vdata); i++) for(int i=0; i<isize(vdata); i++)
if(vdata[i].name == lab) { if(vdata[i].name == lab) {
vdata[i].cp = x; vdata[i].cp = x;