From 6f13e748c526576198d197ad194f4c1d8fdadec0 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sat, 2 Jul 2016 09:58:12 -0400 Subject: new xml, wip quest menu --- include/ui_quest.hpp | 38 ++++++++++++++++++++++++++++++++++++++ src/entities.cpp | 3 ++- src/ui.cpp | 6 ++++++ xml/!town.xml | 34 ++++++++++++++++++++++++++++++++++ xml/playerSpawnHill1.xml | 37 ------------------------------------- xml/playerSpawnHill1_Building1.xml | 26 -------------------------- xml/playerSpawnHill2.xml | 8 -------- xml/town.xml | 36 ------------------------------------ 8 files changed, 80 insertions(+), 108 deletions(-) create mode 100644 include/ui_quest.hpp create mode 100644 xml/!town.xml delete mode 100644 xml/playerSpawnHill1.xml delete mode 100644 xml/playerSpawnHill1_Building1.xml delete mode 100644 xml/playerSpawnHill2.xml delete mode 100644 xml/town.xml diff --git a/include/ui_quest.hpp b/include/ui_quest.hpp new file mode 100644 index 0000000..a0f3ad4 --- /dev/null +++ b/include/ui_quest.hpp @@ -0,0 +1,38 @@ +#ifndef UI_QUEST_HPP_ +#define UI_QUEST_HPP_ + +#include +#include + +namespace ui { + namespace quest { + bool _toggle = false; + + void toggle(void) { + _toggle ^= true; + } + + void draw(void) { + if (!_toggle) + return; + + float top_y = offset.y + 200; + ui::drawNiceBox(vec2 {offset.x - 200, top_y }, + vec2 {offset.x + 200, offset.y - 200 }, + -0.7f); + + ui::putStringCentered(offset.x, top_y - 40, "Current Quests:"); + + auto y = top_y - 100; + const auto x = offset.x - 180; + for (const auto &q : player->qh.current) { + ui::putText(x, y, q.title.c_str()); + y -= 20; + ui::putText(x + 40, y, q.desc.c_str()); + y -= 40; + } + } + } +} + +#endif // UI_QUEST_HPP_ diff --git a/src/entities.cpp b/src/entities.cpp index e49d0ca..53d3aca 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -711,7 +711,7 @@ COMMONAIFUNC: goto COMMONAIFUNC; } } - } while((oxml = oxml->NextSiblingElement())); + } while((oxml = oxml->NextSiblingElement("quest"))); } // handle give tags @@ -743,6 +743,7 @@ COMMONAIFUNC: } // asdlfkj + auto txml = exml->FirstChildElement("content"); if (txml == nullptr) goto OTHERSTUFF; diff --git a/src/ui.cpp b/src/ui.cpp index d5fc2ad..098f650 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -909,6 +910,9 @@ namespace ui { // will return if not toggled action::draw(vec2 {player->loc.x + player->width / 2, player->loc.y + player->height + game::HLINE}); + // will return if not toggled + quest::draw(); + if (pageTexReady) { GLfloat page_loc[] = {offset.x - 300, SCREEN_HEIGHT - 100, -6.0, @@ -1540,6 +1544,8 @@ EXIT: currentWorld->addObject(item->name, "o shit waddup", player->loc.x + player->width / 2, player->loc.y + player->height / 2); } + } else if (SDL_KEY == SDLK_h) { + quest::toggle(); } else switch (SDL_KEY) { case SDLK_F3: debug ^= true; diff --git a/xml/!town.xml b/xml/!town.xml new file mode 100644 index 0000000..51fc08d --- /dev/null +++ b/xml/!town.xml @@ -0,0 +1,34 @@ + + +