aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-11-30 21:34:43 -0500
committerClyne Sullivan <tullivan99@gmail.com>2016-11-30 21:34:43 -0500
commitcc2a768ff19e9fc83661a51d4cb4fef9b354ff30 (patch)
tree36a29f6c442c9e1386d00348b3db93fd12ab4979
parent1024fe8305e5b0a7bb1f660a1cee077172d84534 (diff)
quest work
-rw-r--r--include/common.hpp4
-rw-r--r--src/components.cpp33
-rw-r--r--src/quest.cpp9
-rw-r--r--src/ui.cpp2
4 files changed, 28 insertions, 20 deletions
diff --git a/include/common.hpp b/include/common.hpp
index 249b9eb..7b98ea9 100644
--- a/include/common.hpp
+++ b/include/common.hpp
@@ -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);
}
/**
diff --git a/src/components.cpp b/src/components.cpp
index eb9fb0e..a398bec 100644
--- a/src/components.cpp
+++ b/src/components.cpp
@@ -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();
}
diff --git a/src/quest.cpp b/src/quest.cpp
index f7548d2..1e343a6 100644
--- a/src/quest.cpp
+++ b/src/quest.cpp
@@ -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));
}
-
diff --git a/src/ui.cpp b/src/ui.cpp
index 1652f10..1994382 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -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;