]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
quest work
authorClyne Sullivan <tullivan99@gmail.com>
Thu, 1 Dec 2016 02:34:43 +0000 (21:34 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Thu, 1 Dec 2016 02:34:43 +0000 (21:34 -0500)
include/common.hpp
src/components.cpp
src/quest.cpp
src/ui.cpp

index 249b9eb1ef7571fcc0fdb986e75e3d1b207c2755..7b98ea928533f9d9cd86122e6ed25ebb1c58ca09 100644 (file)
@@ -59,9 +59,9 @@ typedef unsigned int uint;
 #define BREAKPOINT __asm__("int $3")
 
 template<typename T>
-inline const T * const& coalesce(const T * const &p1, const T * const &p2)
+inline const T * const& coalesce(const void * &p1, const void * &p2)
 {
-       return ((p1 == nullptr) ? p2 : p1);
+       return ((p1 == nullptr) ? reinterpret_cast<T*>(p2) : p1);
 }
 
 /**
index eb9fb0e70ad7690c53b1e07d199372b4fa14433e..a398bece24c3a12fa8b51ef6933b48cb26e3fc16 100644 (file)
@@ -93,7 +93,7 @@ void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev,
                if (entity.has_component<Animate>()) {
                        sprite.sprite = entity.component<Animate>().get()->nextFrame();
                }
-               
+
                for (auto &S : sprite.sprite) {
                        float width = HLINES(S.first.size.x);
                        float height = HLINES(S.first.size.y);
@@ -115,9 +115,9 @@ void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev,
                                float flashAmt = 1-(hitDuration/maxHitDuration);
                                glUniform4f(Render::worldShader.uniform[WU_tex_color], 1.0, flashAmt, flashAmt, 1.0);
                        }*/
-                       
+
                        glBindTexture(GL_TEXTURE_2D, S.first.pic);
-                       
+
                        glUniform1i(Render::worldShader.uniform[WU_texture], 0);
                        Render::worldShader.enable();
 
@@ -187,24 +187,29 @@ void DialogSystem::receive(const MouseClickEvent &mce)
 
                                        auto qxml = exml->FirstChildElement("quest");
                                        if (qxml != nullptr) {
-                                               std::string qname;
+                                               const char *qname;
                                                auto qsys = game::engine.getSystem<QuestSystem>();
 
                                                do {
                                                        // assign quest
-                                                       qname = qxml->StrAttribute("assign");
-                                                       if (!qname.empty()) {
+                                                       qname = qxml->Attribute("assign");
+                                                       if (qname != nullptr) {
                                                                questAssignedText = qname;
-                                                               qsys->assign(qname, qxml->StrAttribute("desc"), "req"); // gettext() for req
+                                                               auto req = qxml->GetText();
+                                                               qsys->assign(qname, qxml->StrAttribute("desc"), req ? req : "");
                                                        }
 
                                                        // check / finish quest
                                                        else {
-                                                               qname = qxml->StrAttribute("check");
-                                                               if (!(qname.empty() && qsys->hasQuest(qname) && qsys->finish(qname))) {
-                                                                       ui::dialogBox(name.name, "", false, "Finish my quest u nug");
-                                                                       ui::waitForDialog();
-                                                                       return;
+                                                               qname = qxml->Attribute("check");
+                                                               if (qname != nullptr) {
+                                                                       if (qname != nullptr && qsys->hasQuest(qname) && qsys->finish(qname) == 0) {
+                                                                               d.index = 9999;
+                                                                       } else {
+                                                                               ui::dialogBox(name.name, "", false, "Finish my quest u nug");
+                                                                               ui::waitForDialog();
+                                                                               return;
+                                                                       }
                                                                //      oldidx = d.index;
                                                                //      d.index = qxml->UnsignedAttribute("fail");
                                                                //      goto COMMONAIFUNC;
@@ -226,7 +231,7 @@ void DialogSystem::receive(const MouseClickEvent &mce)
                                        ui::waitForDialog();
 
                                        if (!questAssignedText.empty())
-                                               ui::passiveImportantText(4000, ("Quest assigned:\n\"" + questAssignedText + "\"").c_str());
+                                               ui::passiveImportantText(5000, ("Quest assigned:\n\"" + questAssignedText + "\"").c_str());
 
                                        if (exml->QueryIntAttribute("nextid", &newIndex) == XML_NO_ERROR)
                                                d.index = newIndex;
@@ -272,7 +277,7 @@ std::vector<Frame> developFrame(XMLElement* xml)
                        tmp.push_back(tmpf);
                }
                // if it's not a frame we don't care
-               
+
                // parse next frame
                framexml = framexml->NextSiblingElement();
        }
index f7548d2505b5e7928adb49d59d46713ca65027a6..1e343a661ed099622d329a28d5439e90da78bb84 100644 (file)
@@ -1,4 +1,5 @@
 #include <quest.hpp>
+#include <common.hpp>
 
 #include <algorithm>
 
@@ -11,14 +12,17 @@ void QuestSystem::update(entityx::EntityManager &en, entityx::EventManager &ev,
 
 int QuestSystem::assign(std::string title, std::string desc, std::string req)
 {
-       (void)req;
+       const auto& reqs = StringTokenizer(req, ',');
+       for (const auto& s : reqs)
+               std::cout << s << '\n';
+
        current.emplace_back(title, desc);
        return 0;
 }
 
 int QuestSystem::drop(std::string title)
 {
-       current.erase(std::remove_if(std::begin(current), std::end(current), 
+       current.erase(std::remove_if(std::begin(current), std::end(current),
                [&title](const Quest& q) { return (q.name == title); }));
        return 0;
 }
@@ -43,4 +47,3 @@ bool QuestSystem::hasQuest(std::string title)
        return (std::find_if(std::begin(current), std::end(current),
                [&title](const Quest& q) { return (q.name == title); }) != std::end(current));
 }
-
index 1652f10cbe88c93c23ae44407106bfdcba51917a..1994382b3cf882baa0e4ce055b955d9460b938f2 100644 (file)
@@ -899,7 +899,7 @@ namespace ui {
                        if (dialogImportant) {
                                setFontColor(255,255,255);
                                if (dialogPassive) {
-                                       dialogPassiveTime -= game::time::getDeltaTime();
+                                       dialogPassiveTime -= game::time::getDeltaTime() * 12;
                                        if (dialogPassiveTime < 0) {
                                                dialogPassive = false;
                                                dialogImportant = false;