From e285c26e0527c07a3f724a42978b486d693eff32 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Thu, 9 Jul 2015 01:12:52 +0200 Subject: [PATCH] Add world map gem Lua functions: setGemName() to change texture setGemBlink() to allow blinking other gems than only the first added one --- Aquaria/DSQ.h | 5 +++-- Aquaria/ScriptInterface.cpp | 40 +++++++++++++++++++++++++++++++++++++ Aquaria/WorldMapRender.cpp | 2 +- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Aquaria/DSQ.h b/Aquaria/DSQ.h index 4115ec0..7acb2be 100644 --- a/Aquaria/DSQ.h +++ b/Aquaria/DSQ.h @@ -620,12 +620,13 @@ class Path; struct GemData { - GemData() { canMove=false; } + GemData() { canMove=false; blink = false; } std::string name; std::string userString; std::string mapName; - bool canMove; Vector pos; + bool canMove; + bool blink; // not saved }; struct BeaconData diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 424e630..783826e 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -8466,6 +8466,44 @@ luaFunc(setGemPosition) luaReturnBool(result); } +luaFunc(setGemName) +{ + int gemId = lua_tointeger(L, 1); + bool result = false; + + if(gemId >= 0 && gemId < dsq->continuity.gems.size()) + { + Continuity::Gems::iterator it = dsq->continuity.gems.begin(); + std::advance(it, gemId); + GemData& gem = *it; + gem.name = getString(L, 2); + result = true; + } + else + debugLog("setGemName: invalid index"); + + luaReturnBool(result); +} + +luaFunc(setGemBlink) +{ + int gemId = lua_tointeger(L, 1); + bool result = false; + + if(gemId >= 0 && gemId < dsq->continuity.gems.size()) + { + Continuity::Gems::iterator it = dsq->continuity.gems.begin(); + std::advance(it, gemId); + GemData& gem = *it; + gem.blink = getBool(L, 2); + result = true; + } + else + debugLog("setGemBlink: invalid index"); + + luaReturnBool(result); +} + luaFunc(removeGem) { int gemId = lua_tointeger(L, 1); @@ -9762,6 +9800,8 @@ static const struct { luaRegister(pickupGem), luaRegister(setGemPosition), + luaRegister(setGemName), + luaRegister(setGemBlink), luaRegister(removeGem), luaRegister(setBeacon), luaRegister(getBeacon), diff --git a/Aquaria/WorldMapRender.cpp b/Aquaria/WorldMapRender.cpp index 736e429..44f92e1 100644 --- a/Aquaria/WorldMapRender.cpp +++ b/Aquaria/WorldMapRender.cpp @@ -1344,7 +1344,7 @@ void WorldMapRender::addAllGems() for (Continuity::Gems::reverse_iterator i = dsq->continuity.gems.rbegin(); i != dsq->continuity.gems.rend(); i++) { GemMover *g = addGem(&(*i)); - if (c == dsq->continuity.gems.size()-1) + if (c == dsq->continuity.gems.size()-1 || i->blink) g->setBlink(true); else g->setBlink(false);