From 9cae1cce923b3a9a913b95bf98147a62748de0c0 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 29 Mar 2020 14:37:04 +0200 Subject: [PATCH] removed refs to kohonen from readcolor --- rogueviz/kohonen.cpp | 15 ++++++++++++++- rogueviz/rogueviz.cpp | 18 +++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/rogueviz/kohonen.cpp b/rogueviz/kohonen.cpp index 0a891a8d..28d7ce7d 100644 --- a/rogueviz/kohonen.cpp +++ b/rogueviz/kohonen.cpp @@ -1531,10 +1531,23 @@ bool turn(int delta) { // 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) + addHook(hooks_mouseover, 100, describe_cell) + 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() { printf("clearing Kohonen...\n"); diff --git a/rogueviz/rogueviz.cpp b/rogueviz/rogueviz.cpp index 6825862f..806eb0f0 100644 --- a/rogueviz/rogueviz.cpp +++ b/rogueviz/rogueviz.cpp @@ -910,6 +910,8 @@ void drawExtra() { } } +inline hookset *hooks_readcolor; + void readcolor(const string& cfname) { FILE *f = fopen(cfname.c_str(), "rt"); if(!f) { printf("color file missing\n"); exit(1); } @@ -926,19 +928,9 @@ void readcolor(const string& cfname) { colorpair x; int c2 = fgetc(f); int known_id = -1; - bool force = false; - - if(kohonen::samples && c2 == '!') { - 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(callhandlers(false, hooks_readcolor, c2, lab, f)) continue; + if(c2 == '#') { while(c2 != 10 && c2 != 13 && c2 != -1) c2 = fgetc(f); continue; @@ -977,7 +969,7 @@ void readcolor(const string& cfname) { vdata[i].cp = x; } } - else if(kohonen::samples && !force) { + else if(isize(lab) && lab[0] == '!') { for(int i=0; i