From 98edbb9f489dac189915413a6bd4e75dd882cfd8 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 27 Apr 2025 01:55:03 +0200 Subject: [PATCH] ru:: hints --- rogueviz/ru/classes.cpp | 11 +++++++++++ rogueviz/ru/entity.cpp | 8 ++++++++ rogueviz/ru/save.cpp | 6 ++++++ 3 files changed, 25 insertions(+) diff --git a/rogueviz/ru/classes.cpp b/rogueviz/ru/classes.cpp index 4c1166a8..85ffcc37 100644 --- a/rogueviz/ru/classes.cpp +++ b/rogueviz/ru/classes.cpp @@ -191,6 +191,17 @@ struct npc : public entity { void act() override; }; +struct hint : public entity { + string hint_text; + int state; + int width, height; + double sx() override { return width; } + double sy() override { return height; } + string glyph() override { return " "; } + color_t color() override { return 0; } + void act() override; + }; + struct item : public entity { int id; string pickup_message; diff --git a/rogueviz/ru/entity.cpp b/rogueviz/ru/entity.cpp index e03a91a5..a65b7d4f 100644 --- a/rogueviz/ru/entity.cpp +++ b/rogueviz/ru/entity.cpp @@ -194,4 +194,12 @@ void npc::act() { } } +void hint::act() { + bool cur = intersect(get_pixel_bbox(), m.get_pixel_bbox()); + if(cur && !state) { + addMessage(hint_text); + } + state = cur; + } + } diff --git a/rogueviz/ru/save.cpp b/rogueviz/ru/save.cpp index cc7c0a01..48ef3152 100644 --- a/rogueviz/ru/save.cpp +++ b/rogueviz/ru/save.cpp @@ -127,6 +127,12 @@ void load_room(fhstream& f, cell *c) { b->text = scanline_noblank(f); r.entities.emplace_back(std::move(b)); } + else if(cap == "HINT") { + auto b = std::make_unique(); + sscanf(param.c_str(), "%lf%lf%d%d", &b->where_x, &b->where_y, &b->width, &b->height); + b->hint_text = scanline_noblank(f); + r.entities.emplace_back(std::move(b)); + } else println(hlog, "unknown mapline ", s); } else println(hlog, "unknown mapline ", s);