[Orxonox-commit 2357] r7072 - in code/branches/presentation3: data/gui/scripts data/levels src/libraries/core src/modules/questsystem src/orxonox src/orxonox/infos
dafrick at orxonox.net
dafrick at orxonox.net
Tue Jun 1 21:28:28 CEST 2010
Author: dafrick
Date: 2010-06-01 21:28:28 +0200 (Tue, 01 Jun 2010)
New Revision: 7072
Removed:
code/branches/presentation3/src/modules/questsystem/QuestGUI.cc
code/branches/presentation3/src/modules/questsystem/QuestGUI.h
code/branches/presentation3/src/modules/questsystem/QuestGUINode.cc
code/branches/presentation3/src/modules/questsystem/QuestGUINode.h
Modified:
code/branches/presentation3/data/gui/scripts/GUITools.lua
code/branches/presentation3/data/gui/scripts/PickupInventory.lua
code/branches/presentation3/data/gui/scripts/QuestGUI.lua
code/branches/presentation3/data/levels/Quest_PirateAttack.oxw
code/branches/presentation3/data/levels/pickups.oxw
code/branches/presentation3/src/libraries/core/GUIManager.h
code/branches/presentation3/src/modules/questsystem/CMakeLists.txt
code/branches/presentation3/src/modules/questsystem/Quest.h
code/branches/presentation3/src/modules/questsystem/QuestHint.h
code/branches/presentation3/src/modules/questsystem/QuestManager.cc
code/branches/presentation3/src/modules/questsystem/QuestManager.h
code/branches/presentation3/src/modules/questsystem/QuestsystemPrereqs.h
code/branches/presentation3/src/orxonox/CMakeLists.txt
code/branches/presentation3/src/orxonox/infos/PlayerInfo.h
Log:
Made the QuestGUI completely lua based in an attempt to remove a segfault that occured when closing orxonox. Successfully, I might add. ;)
In the process of doing so I expanded the GUITools by adding a function that calculates the height that text in an input window needs, with word-wrap enabled.
Also fixed a small error in the Quest_PirateAttack level.
Modified: code/branches/presentation3/data/gui/scripts/GUITools.lua
===================================================================
--- code/branches/presentation3/data/gui/scripts/GUITools.lua 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/data/gui/scripts/GUITools.lua 2010-06-01 19:28:28 UTC (rev 7072)
@@ -44,3 +44,12 @@
local ratio = height/maxHeight
return 0.008*ratio/0.3204
end
+
+function getStaticTextWindowHeight(window)
+ local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(window:getLookNFeel())
+ local formattedArea = lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window)
+ local frameHeight = window:getUnclippedPixelRect():getHeight() - formattedArea:getHeight()
+ local lines = window:getFont():getFormattedLineCount(window:getText(), formattedArea, CEGUI.WordWrapLeftAligned)
+ local height = lines * window:getFont():getLineSpacing() + frameHeight
+ return height
+end
Modified: code/branches/presentation3/data/gui/scripts/PickupInventory.lua
===================================================================
--- code/branches/presentation3/data/gui/scripts/PickupInventory.lua 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/data/gui/scripts/PickupInventory.lua 2010-06-01 19:28:28 UTC (rev 7072)
@@ -246,7 +246,6 @@
end
--- TODO: Smarter
function P.getNewDetailNumber()
local number = table.getn(P.detailsWindows)
for k,v in pairs(P.detailsWindows) do
Modified: code/branches/presentation3/data/gui/scripts/QuestGUI.lua
===================================================================
--- code/branches/presentation3/data/gui/scripts/QuestGUI.lua 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/data/gui/scripts/QuestGUI.lua 2010-06-01 19:28:28 UTC (rev 7072)
@@ -2,19 +2,287 @@
local P = createMenuSheet("QuestGUI")
-function P.show()
- P.window:show() -- TODO: Do this through parent...
- P.visible = true
+P.rootWindow = nil
+P.detailsWindows = {}
+P.quests = {}
+P.hints = {}
+P.player = nil
- local questManager = orxonox.QuestManager:getInstance()
+-- design parameters
+P.indentWidth = 20
+P.scrollbarWidth = 13
+P.buttonHeight = 30
+P.titleHeight = 26
+P.borderWidth = 5
+function P.onShow()
+
local questsList = winMgr:getWindow("orxonox/QuestGUI/QuestsList")
- local window = questManager:getQuestGUI(P.name)
+ P.player = orxonox.GUIManager:getInstance():getPlayer(P.name)
+ P.rootWindow = P.createQuestGUI();
- questsList:addChildWindow(window)
+ questsList:addChildWindow(P.rootWindow)
+end
+function P.onHide()
+ P.cleanup()
end
+function P.createQuestGUI()
+ local questManager = orxonox.QuestManager:getInstance()
+
+ local depth = 0
+ local index = 0
+
+ local questWindow = winMgr:createWindow("MenuWidgets/ScrollablePane", "orxonox/QuestGUI/Quests")
+ questWindow:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0),CEGUI.UDim(1, 0)))
+
+ -- Iterate through all parent-quests.
+ local numParentQuests = orxonox.QuestManager:getInstance():getNumParentQuests(P.player)
+ local i = 0
+ while i <= numParentQuests-1 do
+ local quest = orxonox.QuestManager:getInstance():getParentQuest(P.player, i)
+ index = P.createQuestNodes(questWindow, quest, depth, index)
+ i = i+1
+ end
+
+ return questWindow
+end
+
+function P.createQuestNodes(root, parent, depth, index)
+ local number = table.getn(P.quests)+1
+ local name = "orxonox/QuestGUI/Quests/" .. number
+ local node = winMgr:createWindow("MenuWidgets/TabButton", name)
+ node:setText(orxonox.QuestManager:getInstance():getDescription(parent):getTitle())
+ node:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.indentWidth*depth), CEGUI.UDim(0, P.buttonHeight*index)))
+ node:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.indentWidth*depth-P.scrollbarWidth), CEGUI.UDim(0, P.buttonHeight)))
+ orxonox.GUIManager:subscribeEventHelper(node, "Clicked", P.name .. ".openDetails_clicked")
+ root:addChildWindow(node)
+
+ table.insert(P.quests, parent)
+
+ index = index+1
+
+ -- Iterate through all sub-quests.
+ local numQuests = orxonox.QuestManager:getInstance():getNumSubQuests(parent, P.player)
+ local i = 0
+ while i <= numQuests-1 do
+ local quest = orxonox.QuestManager:getInstance():getSubQuest(parent, P.player, i)
+ index = P.createQuestNodes(root, quest, depth+1, index)
+ i = i+1
+ end
+
+ return index;
+end
+
+function P.cleanup()
+ winMgr:destroyWindow(P.rootWindow)
+ for k,v in pairs(P.detailsWindows) do
+ if v ~= nil then
+ winMgr:destroyWindow(v)
+ P.detailsWindows[k] = nil
+ end
+ end
+ P.detailsWindows = {}
+
+ P.quests = {}
+ P.hints = {}
+ P.player = nil
+
+ winMgr:destroyWindow(P.rootWindow)
+ P.rootWindow = nil
+end
+
+function P.openDetails_clicked(e)
+ --Get some numbers from the window
+ local we = CEGUI.toWindowEventArgs(e)
+ local name = we.window:getName()
+ local match = string.gmatch(name, "%d+")
+ local questNr = tonumber(match())
+
+ name = name .. "/Details" .. P.getNewDetailNumber()
+ quest = P.quests[questNr]
+
+ local details = winMgr:createWindow("MenuWidgets/FrameWindow", name)
+ details:setSize(CEGUI.UVector2(CEGUI.UDim(0.7, 0), CEGUI.UDim(0.7, 0)))
+ details:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0), CEGUI.UDim(0.1, 0)))
+ details:setText(orxonox.QuestManager:getInstance():getDescription(quest):getTitle())
+ details:setProperty("Alpha", 1.0)
+ details:setProperty("InheritsAlpha", "setFalse")
+ orxonox.GUIManager:subscribeEventHelper(details, "CloseClicked", P.name .. ".closeDetails_clicked")
+
+ table.insert(P.detailsWindows, details)
+
+ name = name .. "/Scrollable"
+ local window = winMgr:createWindow("MenuWidgets/ScrollablePane", name)
+ window:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -2*P.borderWidth),CEGUI.UDim(1.0, -P.titleHeight)))
+ window:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderWidth), CEGUI.UDim(0, P.titleHeight)))
+ details:addChildWindow(window)
+
+ local offset = 0
+
+ local status = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Status")
+ window:addChildWindow(status)
+ status:setProperty("HorzFormatting", "WordWrapLeftAligned")
+ status:setProperty("VertFormatting", "TopAligned")
+ if quest:isActive(P.player) then
+ status:setText("This quest is active.")
+ elseif quest:isCompleted(P.player) then
+ status:setText("This quest was completed.")
+ elseif quest:isFailed(P.player) then
+ status:setText("This quest was failed.")
+ end
+ status:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
+ status:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
+ local height = getStaticTextWindowHeight(status)
+ status:setHeight(CEGUI.UDim(0, height))
+ offset = offset + height
+
+ local descriptionTitle = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description/Title");
+ window:addChildWindow(descriptionTitle)
+ descriptionTitle:setProperty("HorzFormatting", "HorzCentred")
+ descriptionTitle:setProperty("VertFormatting", "TopAligned")
+ descriptionTitle:setText("Description:")
+ descriptionTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
+ descriptionTitle:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
+ height = getStaticTextWindowHeight(descriptionTitle)
+ descriptionTitle:setHeight(CEGUI.UDim(0, height))
+ offset = offset + height
+
+ local description = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description");
+ window:addChildWindow(description)
+ description:setProperty("HorzFormatting", "WordWrapLeftAligned")
+ description:setProperty("VertFormatting", "TopAligned")
+ description:setText(orxonox.QuestManager:getInstance():getDescription(quest):getDescription())
+ description:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
+ description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
+ height = getStaticTextWindowHeight(description)
+ description:setHeight(CEGUI.UDim(0, height))
+ offset = offset + height
+
+ -- Display the hints of this quest
+ local numHints = orxonox.QuestManager:getInstance():getNumHints(quest, P.player)
+ if numHints > 0 then
+ local hintsTitle = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Hints/Title");
+ window:addChildWindow(hintsTitle)
+ hintsTitle:setProperty("HorzFormatting", "HorzCentred")
+ hintsTitle:setProperty("VertFormatting", "TopAligned")
+ hintsTitle:setText("Hints:")
+ hintsTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
+ hintsTitle:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
+ height = getStaticTextWindowHeight(hintsTitle)
+ hintsTitle:setHeight(CEGUI.UDim(0, height))
+ offset = offset + height
+ end
+ local i = 0
+ while i <= numHints-1 do
+ local hint = orxonox.QuestManager:getInstance():getHints(quest, P.player, i)
+ table.insert(P.hints, hint)
+ local number = table.getn(P.hints)
+ local node = winMgr:createWindow("MenuWidgets/TabButton", name .. "/Hints" .. number)
+ node:setText(orxonox.QuestManager:getInstance():getDescription(hint):getTitle())
+ node:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
+ node:setSize(CEGUI.UVector2(CEGUI.UDim(1, -P.scrollbarWidth), CEGUI.UDim(0, P.buttonHeight)))
+ window:addChildWindow(node)
+ offset = offset + P.buttonHeight
+
+ orxonox.GUIManager:subscribeEventHelper(node, "Clicked", P.name .. ".openHintDetails_clicked")
+ i = i+1
+ end
+
+ local window = winMgr:getWindow("orxonox/QuestGUI/Background")
+ window:addChildWindow(details)
+end
+
+function P.getNewDetailNumber()
+ local number = table.getn(P.detailsWindows)
+ for k,v in pairs(P.detailsWindows) do
+ if v == nil then
+ number = k-1
+ end
+ end
+ return number+1
+end
+
+function P.closeDetails_clicked(e)
+ local we = CEGUI.toWindowEventArgs(e)
+ local name = we.window:getName()
+ local match = string.gmatch(name, "%d+")
+ match()
+ local detailsNr = tonumber(match())
+
+ winMgr:destroyWindow(P.detailsWindows[detailsNr])
+ P.detailsWindows[detailsNr] = nil
+end
+
+function P.openHintDetails_clicked(e)
+ --Get some numbers from the window
+ local we = CEGUI.toWindowEventArgs(e)
+ local name = we.window:getName()
+ local match = string.gmatch(name, "%d+")
+ match()
+ match()
+ local hintNr = tonumber(match())
+
+ name = name .. "/Details" .. P.getNewDetailNumber()
+ hint = P.hints[hintNr]
+
+ local details = winMgr:createWindow("MenuWidgets/FrameWindow", name)
+ details:setSize(CEGUI.UVector2(CEGUI.UDim(0.7, 0), CEGUI.UDim(0.7, 0)))
+ details:setPosition(CEGUI.UVector2(CEGUI.UDim(0.1, 0), CEGUI.UDim(0.1, 0)))
+ details:setText(orxonox.QuestManager:getInstance():getDescription(hint):getTitle())
+ details:setProperty("Alpha", 1.0)
+ details:setProperty("InheritsAlpha", "setFalse")
+ orxonox.GUIManager:subscribeEventHelper(details, "CloseClicked", P.name .. ".closeHintDetails_clicked")
+
+ table.insert(P.detailsWindows, details)
+
+ name = name .. "/Scrollable"
+ local window = winMgr:createWindow("MenuWidgets/ScrollablePane", name)
+ window:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -2*P.borderWidth),CEGUI.UDim(1.0, -P.titleHeight)))
+ window:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.borderWidth), CEGUI.UDim(0, P.titleHeight)))
+ details:addChildWindow(window)
+
+ local offset = 0
+
+ local descriptionTitle = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description/Title");
+ window:addChildWindow(descriptionTitle)
+ descriptionTitle:setProperty("HorzFormatting", "HorzCentred")
+ descriptionTitle:setProperty("VertFormatting", "TopAligned")
+ descriptionTitle:setText("Description:")
+ descriptionTitle:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
+ descriptionTitle:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
+ height = getStaticTextWindowHeight(descriptionTitle)
+ descriptionTitle:setHeight(CEGUI.UDim(0, height))
+ offset = offset + height
+
+ local description = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description");
+ window:addChildWindow(description)
+ description:setProperty("HorzFormatting", "WordWrapLeftAligned")
+ description:setProperty("VertFormatting", "TopAligned")
+ description:setText(orxonox.QuestManager:getInstance():getDescription(hint):getDescription())
+ description:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, offset)))
+ description:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -P.scrollbarWidth), CEGUI.UDim(1.0, 0)))
+ height = getStaticTextWindowHeight(description)
+ description:setHeight(CEGUI.UDim(0, height))
+
+ local window = winMgr:getWindow("orxonox/QuestGUI/Background")
+ window:addChildWindow(details)
+end
+
+function P.closeHintDetails_clicked(e)
+ local we = CEGUI.toWindowEventArgs(e)
+ local name = we.window:getName()
+ local match = string.gmatch(name, "%d+")
+ match()
+ match()
+ match()
+ local detailsNr = tonumber(match())
+
+ winMgr:destroyWindow(P.detailsWindows[detailsNr])
+ P.detailsWindows[detailsNr] = nil
+end
+
return P
Modified: code/branches/presentation3/data/levels/Quest_PirateAttack.oxw
===================================================================
--- code/branches/presentation3/data/levels/Quest_PirateAttack.oxw 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/data/levels/Quest_PirateAttack.oxw 2010-06-01 19:28:28 UTC (rev 7072)
@@ -157,7 +157,7 @@
<QuestEffectBeacon position="250,-300,-1500" times=1>
<attached>
<Billboard position="0,0,0" scale=3 colour="1.0,1.0,0" material="Examples/Flare" />
- <DistanceTrigger name=questbeacon2 targetname=Me position="0,0,0" distance=400 target="Pawn" />
+ <DistanceTrigger name=questbeacon2 targetname=Me position="0,0,0" target=DistanceTriggerBeacon distance=400 />
</attached>
<effects>
<AddQuest questId="3159b4d4-bc86-4190-ba1d-4530668dfe31" />
Modified: code/branches/presentation3/data/levels/pickups.oxw
===================================================================
--- code/branches/presentation3/data/levels/pickups.oxw 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/data/levels/pickups.oxw 2010-06-01 19:28:28 UTC (rev 7072)
@@ -5,7 +5,6 @@
<?lua
include("templates/spaceship_assff.oxt")
- include("templates/spaceship_pirate.oxt")
include("templates/pickup_representation_templates.oxt")
include("templates/lodinformation.oxt")
?>
Modified: code/branches/presentation3/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/presentation3/src/libraries/core/GUIManager.h 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/src/libraries/core/GUIManager.h 2010-06-01 19:28:28 UTC (rev 7072)
@@ -96,8 +96,7 @@
inline void setPlayer(const std::string& guiname, PlayerInfo* player)
{ this->players_[guiname] = player; }
- inline PlayerInfo* getPlayer(const std::string& guiname) const
- { std::map<std::string, PlayerInfo*>::const_iterator it = this->players_.find(guiname); return (it != this->players_.end()) ? it->second : 0; }
+ inline orxonox::PlayerInfo* getPlayer(const std::string& guiname) const { std::map<std::string, PlayerInfo*>::const_iterator it = this->players_.find(guiname); return (it != this->players_.end()) ? it->second : 0; } // tolua_export
// TODO: Temporary hack because the tolua exported CEGUI method does not seem to work
static void subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function); //tolua_export
Modified: code/branches/presentation3/src/modules/questsystem/CMakeLists.txt
===================================================================
--- code/branches/presentation3/src/modules/questsystem/CMakeLists.txt 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/src/modules/questsystem/CMakeLists.txt 2010-06-01 19:28:28 UTC (rev 7072)
@@ -11,8 +11,6 @@
QuestDescription.cc
QuestEffect.cc
QuestEffectBeacon.cc
- QuestGUINode.cc
- QuestGUI.cc
QuestHint.cc
QuestItem.cc
QuestListener.cc
@@ -27,6 +25,9 @@
FIND_HEADER_FILES
TOLUA_FILES
QuestManager.h
+ QuestDescription.h
+ Quest.h
+ QuestHint.h
DEFINE_SYMBOL
"QUESTSYSTEM_SHARED_BUILD"
PCH_FILE
Modified: code/branches/presentation3/src/modules/questsystem/Quest.h
===================================================================
--- code/branches/presentation3/src/modules/questsystem/Quest.h 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/src/modules/questsystem/Quest.h 2010-06-01 19:28:28 UTC (rev 7072)
@@ -40,8 +40,8 @@
#include <list>
#include "QuestItem.h"
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
namespace QuestStatus
{
//!Different states of a Quest.
@@ -66,8 +66,9 @@
@author
Damian 'Mozork' Frick
*/
- class _QuestsystemExport Quest : public QuestItem
- {
+ class _QuestsystemExport Quest // tolua_export
+ : public QuestItem
+ { // tolua_export
public:
Quest(BaseObject* creator);
virtual ~Quest();
@@ -96,9 +97,9 @@
{ return this->hints_; }
bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'.
- bool isActive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'active'.
- bool isFailed(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'failed'.
- bool isCompleted(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'completed'.
+ bool isActive(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'active'.
+ bool isFailed(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'failed'.
+ bool isCompleted(const orxonox::PlayerInfo* player) const; // tolua_export //!< Returns true if the quest status for the specific player is 'completed'.
bool start(PlayerInfo* player); //!< Sets a Quest to active.
virtual bool fail(PlayerInfo* player); //!< Fails the Quest.
@@ -150,8 +151,8 @@
bool addFailEffect(QuestEffect* effect); //!< Adds an QuestEffect to the list of fail QuestEffects.
bool addCompleteEffect(QuestEffect* effect); //!< Adds an QuestEffect to the list of complete QuestEffects.
- };
+ }; // tolua_export
-}
+} // tolua_export
#endif /* _Quest_H__ */
Deleted: code/branches/presentation3/src/modules/questsystem/QuestGUI.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestGUI.cc 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/src/modules/questsystem/QuestGUI.cc 2010-06-01 19:28:28 UTC (rev 7072)
@@ -1,274 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-#include "QuestGUI.h"
-
-#include <sstream>
-#include <CEGUIWindow.h>
-#include <CEGUIWindowManager.h>
-
-#include "core/CoreIncludes.h"
-#include "Quest.h"
-#include "QuestHint.h"
-#include "QuestItem.h"
-#include "QuestGUINode.h"
-#include "QuestManager.h"
-
-namespace orxonox {
-
- /**
- @brief
- Constructor. Registers and initializes the object.
- @param
- The player the GUI is for.
- */
- QuestGUI::QuestGUI(PlayerInfo* player)
- {
- RegisterRootObject(QuestGUI);
-
- this->player_ = player;
- this->windowManager_ = CEGUI::WindowManager::getSingletonPtr(); //!< Get CEGUI WindowManager.
- this->rootWindow_ = NULL;
- this->root_ = new QuestGUINode(); //!< Create empty root node.
-
- COUT(3) << "New QuestGUI created." << std::endl;
- }
-
- /**
- @brief
- Destructor.
- */
- QuestGUI::~QuestGUI()
- {
- COUT(3) << "Destroying QuestGUI..." << std::endl;
-
- this->clear(); //!< Clearing the GUI and in the process destroying all QuestGUINodes.
-
- //! Destroying the windows in the this->windows_ list.
- for(std::list<CEGUI::Window*>::iterator it = this->windows_.begin(); it != this->windows_.end(); it++)
- {
- if(*it != NULL)
- (*it)->destroy();
- }
- this->windows_.clear();
-
- if(this->root_ != NULL)
- this->root_->destroy();
- }
-
- /**
- @brief
- Get the root CEGUI Window of the GUI.
- @return
- Returns the root CEGUI Window of the GUI.
- */
- CEGUI::Window* QuestGUI::getGUI(void)
- {
- this->update(); //!< Update the GUI.
-
- return this->rootWindow_;
- }
-
- /**
- @brief
- Update the GUI.
- */
- void QuestGUI::update(void)
- {
- COUT(4) << "Updating QuestGUI..." << std::endl;
-
- this->clear(); //!< Clear the GUI.
-
- int depth = 0;
- int index = 0;
-
- //! Create root window.
- this->rootWindow_ = this->windowManager_->createWindow("MenuWidgets/ScrollablePane", "QuestGUI/Quests");
- this->rootWindow_->setSize(CEGUI::UVector2(CEGUI::UDim(1, 0),CEGUI::UDim(1, 0)));
-
- //! Iterate through all Quests.
- std::map<std::string, Quest*> quests = QuestManager::getInstance().getQuests();
- for(std::map<std::string, Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
- {
- Quest* quest = it->second;
- if(quest->getParentQuest() == NULL && !quest->isInactive(this->player_)) //!< If the Quest isn't inactive and a root Quest (meaning it has no parent.), create a Node.
- {
- index = createNode(this->root_, quest, depth, index);
- }
- }
- COUT(4) << "Updating QuestGUI done." << std::endl;
- }
-
- /**
- @brief
- Clear the QuestGUI.
- */
- void QuestGUI::clear(void)
- {
- COUT(4) << "Clearing QuestGUI..." << std::endl;
-
- //! Clear all nodes.
- for(std::map<CEGUI::Window*, QuestGUINode*>::iterator it = this->nodes_.begin(); it != this->nodes_.end(); it++)
- {
- QuestGUINode* node = it->second;
- if(node == NULL)
- {
- COUT(1) << "Node is NULL!";
- continue;
- }
- std::string* str = new std::string();
- node->getName(*str);
- COUT(3) << "Clearing Node '" << *str << "' ..." << std::endl;
- delete str;
- node->destroy();
- }
- this->nodes_.clear();
-
- //! Clear root window.
- if(this->rootWindow_ != NULL)
- this->rootWindow_->destroy();
-
- COUT(3) << "Clearing QuestGUI done." << std::endl;
- }
-
- /**
- @brief
- Get a CEGUI Window to use.
- Windows that are no longer used are collected with giveWindow, and are given out again with getWindow, so save some time recreating new windows everytime.
- The retreived window is of type "MenuWidgets/TabButton".
- @return
- Returns a CEGUI Window of type "MenuWidgets/TabButton".
- */
- CEGUI::Window* QuestGUI::getWindow(void)
- {
- if(!this->windows_.empty()) //!< If there are windows in the list.
- {
- CEGUI::Window* window = this->windows_.back();
- this->windows_.pop_back();
- return window;
- }
-
- //!< Else create a new one.
- std::ostringstream stream;
- stream << "QuestGUI/Quests/EmptyWindows/" << this->windows_.size()+1;
- return this->windowManager_->createWindow("MenuWidgets/TabButton", stream.str());
- }
-
- /**
- @brief
- Return a no longer needed CEGUI Window for reuse.
- @param window
- The CEGUI window ot be returned.
- */
- void QuestGUI::giveWindow(CEGUI::Window* window)
- {
- if(window == NULL)
- return;
- this->windows_.push_back(window);
- this->rootWindow_->removeChildWindow(window); //!< Remove the window as child of the rootWindow.
- std::ostringstream stream;
- stream << "QuestGUI/Quests/EmptyWindows/" << this->windows_.size();
- window->rename(stream.str());
- }
-
- /**
- @brief
- Finde the QuestGUINode belonging to the input CEGUI Window.
- @param window
- A pointer to a CEGUI Window.
- @return
- A pointer to the QuestGUI Node belonging to the input CEGUI Window.
- */
- /*static*/ QuestGUINode* QuestGUI::findNode(CEGUI::Window* window)
- {
- for(std::map<PlayerInfo*, QuestGUI*>::iterator it = QuestManager::getInstance().questGUIs_.begin(); it != QuestManager::getInstance().questGUIs_.end(); it++)
- {
- QuestGUI* gui = it->second;
- std::map<CEGUI::Window*, QuestGUINode*>::iterator node = gui->nodes_.find(window);
- if(node != gui->nodes_.end()) return node->second;
- }
- return NULL;
- }
-
- /**
- @brief
- Recursive method to create Nodes for all Quests an Hints the given Quest is a parent to.
- @param parent
- Pointer to the parent QuestGUINode.
- @param item
- The QuestItem the QuestGUINode is created for.
- @param depth
- Parameter to define how much the list item has to be indented.
- @param index
- "Counter" for Quests and Hints.
- @return
- Returns the index.
- */
- int QuestGUI::createNode(QuestGUINode* parent, QuestItem* item, int depth, int index)
- {
- QuestGUINode* node = new QuestGUINode(this, parent, item, depth, index); //!< Create a new QuestGUINode.
-
- this->nodes_.insert(std::pair<CEGUI::Window*, QuestGUINode*>(node->getWindow(),node)); //!< Insert the node and its window in the nodes_ map.
-
- index++;
-
- //! Check if the QuestItem is a Quest, if not (it's a QuestHint) it just returns.
- Quest* quest = dynamic_cast<Quest*>(item);
- if(quest == NULL)
- return index;
-
- //! Iterate through all subQuests.
- std::list<Quest*> quests = quest->getSubQuestList();
- for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
- {
- Quest* quest = *it;
- if(!quest->isInactive(this->player_)) //!< Add node if the subQuest is not inactive.
- {
- index = createNode(node, quest, depth+1, index);
- }
- }
-
- //! Iterate through all hints.
- std::list<QuestHint*> hints = quest->getHintsList();
- int tempIndex = index; //!< Preserve the index, since for the hints we start anew with index 0.
- index = 0;
- for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++)
- {
- QuestHint* hint = *it;
- if(hint->isActive(this->player_)) //!< Add node if the hint is active.
- {
- index = createNode(node, hint, depth+1, index);
- }
- }
- index = tempIndex; //!< Reset the index to the original level.
-
- return index;
- }
-
-}
-
Deleted: code/branches/presentation3/src/modules/questsystem/QuestGUI.h
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestGUI.h 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/src/modules/questsystem/QuestGUI.h 2010-06-01 19:28:28 UTC (rev 7072)
@@ -1,109 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Definition of the QuestGIU class.
-*/
-
-#ifndef _QuestGUI_H__
-#define _QuestGUI_H__
-
-#include "questsystem/QuestsystemPrereqs.h"
-
-#include <list>
-#include <map>
-#include <string>
-#include <CEGUIForwardRefs.h>
-
-#include "core/OrxonoxClass.h"
-
-namespace orxonox {
-
- /**
- @brief
- Handles the GUI for the Questsystem.
- @author
- Damian 'Mozork' Frick
- */
- class _QuestsystemExport QuestGUI : public OrxonoxClass
- {
-
- public:
-
- QuestGUI(PlayerInfo* player);
- virtual ~QuestGUI();
-
- void update(void); //!< Update the GUI.
- CEGUI::Window* getGUI(void); //!< Get the root CEGUI Window of the GUI.
-
- CEGUI::Window* getWindow(void); //!< Get a CEGUI Window to use.
- void giveWindow(CEGUI::Window* window); //!< Return a no longer needed CEGUI Window for reuse.
-
- static QuestGUINode* findNode(CEGUI::Window* window); //!< Finde the QuestGUINode belonging to the input CEGUI Window.
-
- /**
- @brief Retreive the CEGUI WindowManager.
- @return Returns the CEGUI WindoWManager.
- */
- inline CEGUI::WindowManager* getWindowManager(void)
- { return this->windowManager_; }
- /**
- @brief Retrieve the root window.
- @return Returns the root window.
- */
- inline CEGUI::Window* getRootWindow(void)
- { return this->rootWindow_; }
- /**
- @brief Retreive the player.
- @return Returns the player.
- */
- inline PlayerInfo* getPlayer(void)
- { return this->player_; }
-
- private:
-
- int createNode(QuestGUINode* parent, QuestItem* item, int depth, int index); //!< Recursive method to create Nodes for all Quests an Hints the given Quest is a parent to.
-
- void clear(void); //!< Clear the QuestGUI.
-
- QuestGUINode* root_; //!< An empty QuestGUINode being the parent of all otherwise parent-less nodes.
-
- CEGUI::WindowManager* windowManager_; //!< The CEGUI WindowManager.
- CEGUI::Window* rootWindow_; //!< The root CEGUI Window of the GUI.
- PlayerInfo* player_; //!< The player that owns the GUI.
-
- std::map<CEGUI::Window*, QuestGUINode*> nodes_; //!< A list of all QuestGUINodes, ordered by their respective CEGUI Windows.
- std::list<CEGUI::Window*> windows_; //!< A list of windows to be used.
-
- };
-
-}
-
-#endif /* _QuestGUI_H__ */
-
Deleted: code/branches/presentation3/src/modules/questsystem/QuestGUINode.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestGUINode.cc 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/src/modules/questsystem/QuestGUINode.cc 2010-06-01 19:28:28 UTC (rev 7072)
@@ -1,399 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-#include "QuestGUINode.h"
-
-#include <sstream>
-
-#include <CEGUIWindowManager.h>
-#include <elements/CEGUIFrameWindow.h>
-#include <elements/CEGUIPushButton.h>
-#include <falagard/CEGUIFalWidgetLookFeel.h>
-#include <falagard/CEGUIFalWidgetLookManager.h>
-
-#include "core/CoreIncludes.h"
-#include "Quest.h"
-#include "QuestHint.h"
-#include "QuestItem.h"
-#include "QuestDescription.h"
-#include "QuestGUI.h"
-
-namespace orxonox {
-
- /**
- @brief
- Default Constructor. Registers and initializes the object.
- */
- QuestGUINode::QuestGUINode(void)
- {
- this->initialize();
- }
-
- /**
- @brief
- Constructor. Registers and initializes the object.
- @param gui
- The QuestGUi the node beongs to.
- @param parent
- The parent node of the newly created node.
- @param item
- The QuestItem the newly created node is for.
- @param depth
- Parameter to define how much the list item has to be indented.
- @param index
- "Counter" for Quests and Hints.
- */
- QuestGUINode::QuestGUINode(QuestGUI* gui, QuestGUINode* parent, QuestItem* item, int depth, int index)
- {
- this->initialize();
-
- this->gui_ = gui;
- this->parent_ = parent;
- this->item_ = item;
- this->depth_ = depth;
- this->index_ = index;
-
- this->createWindow();
-
- COUT(4) << "New QuestGUINode '" << this->window_->getName() << "' created." << std::endl;
- }
-
- /**
- @brief
- Destructor.
- @todo
- Destroying everything?
- */
- QuestGUINode::~QuestGUINode(void)
- {
- if(this->window_ != NULL)
- this->window_->destroy();
- if(this->details_ != NULL)
- {
- this->details_->destroy();
- }
- }
-
- /**
- @brief
- Initialize the object.
- */
- void QuestGUINode::initialize(void)
- {
- RegisterRootObject(QuestGUINode);
-
- this->parent_ = NULL;
- this->item_ = NULL;
- this->window_ = NULL;
- this->details_ = NULL;
- this->depth_ = 0;
- this->index_ = 0;
- this->visible_ = true;
- }
-
- void QuestGUINode::toggleVisibility(void)
- {
-
- }
-
- /**
- @brief
- Sets the input buffer to the name of the node.
- @param buffer
- The buffer that is set to the name of the node.
- @todo
- Needed?
- */
- void QuestGUINode::getName(std::string & buffer)
- {
- if(this->window_ != NULL)
- {
- buffer = this->window_->getName().c_str();
- }
- else
- {
- buffer.erase();
- }
- }
-
- /**
- @brief
- Creates the details window.
- @return
- Returns the details window.
- @todo
- Return necessary?
- */
- CEGUI::Window* QuestGUINode::getDetails(void)
- {
-
- if(this->details_ == NULL) //!< If the details window was not already created.
- {
- std::ostringstream stream;
-
- //! Create the main window for the details.
- stream << this->window_->getName() << "/Details";
- const QuestDescription* description = this->item_->getDescription();
- this->details_ = this->gui_->getWindowManager()->createWindow("MenuWidgets/FrameWindow", stream.str());
- this->details_->setSize(CEGUI::UVector2(CEGUI::UDim(0.7f, 0),CEGUI::UDim(0.7f, 0)));
- this->details_->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1f, 0),CEGUI::UDim(0.1f, 0)));
- this->details_->setText(description->getTitle());
- this->details_->setAlpha(1.0);
- this->details_->setInheritsAlpha(false);
- this->details_->setProperty("CloseButtonEnabled", "True");
- this->details_->subscribeEvent(CEGUI::FrameWindow::EventCloseClicked, CEGUI::Event::Subscriber(&QuestGUINode::closeDetails, this));
-
- //! Create a ScrollablePane.
- stream << "/Scrollable";
- CEGUI::Window* window = this->gui_->getWindowManager()->createWindow("MenuWidgets/ScrollablePane", stream.str());
- window->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -2*QuestGUINode::BORDER_WIDTH),CEGUI::UDim(1.0, -QuestGUINode::TITLE_HEIGHT)));
- window->setPosition(CEGUI::UVector2(CEGUI::UDim(0, (float)QuestGUINode::BORDER_WIDTH),CEGUI::UDim(0, (float)QuestGUINode::TITLE_HEIGHT)));
- this->details_->addChildWindow(window);
-
- int height;
- int offset = 0;
-
- //! Display the status of the QuestItem if it is a Quest.
- Quest* quest = dynamic_cast<Quest*>(this->item_);
- if(quest != NULL) //!< If the QuestItem is a Quest
- {
- stream.str("");
- stream << this->details_->getName() << "/Status";
- CEGUI::Window* statusWindow = this->gui_->getWindowManager()->createWindow("MenuWidgets/StaticText", stream.str());
- window->addChildWindow(statusWindow);
- std::string status;
- if(quest->isActive(this->gui_->getPlayer()))
- {
- status = "This quest is active.";
- }
- else if(quest->isCompleted(this->gui_->getPlayer()))
- {
- status = "This quest was completed.";
- }
- else if(quest->isFailed(this->gui_->getPlayer()))
- {
- status = "This quest was failed.";
- }
- statusWindow->setProperty("HorzFormatting", "WordWrapLeftAligned");
- statusWindow->setProperty("VertFormatting", "TopAligned");
- statusWindow->setText(status);
- statusWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, (float)offset)));
- statusWindow->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, (float)-QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(1.0f, 0)));
- height = setHeight(statusWindow);
-
- offset += height;
- }
-
- //! Create title pane for the description.
- stream.str("");
- stream << this->details_->getName() << "/Description";
- stream << "/Title";
- CEGUI::Window* descriptionWindowTitle = this->gui_->getWindowManager()->createWindow("MenuWidgets/StaticText", stream.str());
- window->addChildWindow(descriptionWindowTitle);
- descriptionWindowTitle->setProperty("HorzFormatting", "HorzCentred");
- descriptionWindowTitle->setProperty("VertFormatting", "TopAligned");
- descriptionWindowTitle->setText("Description:");
- descriptionWindowTitle->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, (float)offset)));
- descriptionWindowTitle->setSize(CEGUI::UVector2(CEGUI::UDim(1.0f, -QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(1.0f, 0)));
-
- offset += setHeight(descriptionWindowTitle);
-
- //! Display the Description of the QuestItem.
- stream.str("");
- stream << this->details_->getName() << "/Description";
- CEGUI::Window* descriptionWindow = this->gui_->getWindowManager()->createWindow("MenuWidgets/StaticText", stream.str());
- window->addChildWindow(descriptionWindow);
- descriptionWindow->setProperty("HorzFormatting", "WordWrapLeftAligned");
- descriptionWindow->setProperty("VertFormatting", "TopAligned");
- descriptionWindow->setText(description->getDescription());
- descriptionWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, (float)offset)));
- descriptionWindow->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, (float)-QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(1.0f, 0)));
- height = setHeight(descriptionWindow);
-
- offset += height;
-
- //! Display a list of hints if the QuestItem is a Quest.
- bool title = true;
- if(quest != NULL)
- {
- for(std::list<QuestGUINode*>::iterator it = this->subNodes_.begin(); it != this->subNodes_.end(); it++)
- {
- if(dynamic_cast<QuestHint*>((*it)->item_) != NULL) //!< If the subNode belongs to a QuestHint.
- {
- if(title) //!< If no title pane for the QuestHints has been created, create one.
- {
- stream.str("");
- stream << this->details_->getName() << "/Hints/Title";
- CEGUI::Window* hintsTitle = this->gui_->getWindowManager()->createWindow("MenuWidgets/StaticText", stream.str());
- window->addChildWindow(hintsTitle);
- hintsTitle->setProperty("HorzFormatting", "HorzCentred");
- hintsTitle->setProperty("VertFormatting", "TopAligned");
- hintsTitle->setText("Hints:");
- hintsTitle->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, (float)offset)));
- hintsTitle->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(1.0, 0)));
- offset += setHeight(hintsTitle);;
- title = false;
- }
- QuestGUINode* node = *it;
- node->window_->setSize(CEGUI::UVector2(CEGUI::UDim(1.0f, (float)-QuestGUINode::SCROLLBAR_WIDTH),CEGUI::UDim(0, (float)QuestGUINode::BUTTON_HEIGHT)));
- node->window_->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, (float)offset)));
- window->addChildWindow(node->window_);
- offset += QuestGUINode::BUTTON_HEIGHT;
- }
- }
- }
-
- COUT(4) << "Show Details: " << this->details_->getName() << std::endl;
- }
-
- return this->details_;
- }
-
- /**
- @brief
- Opens the details window for the Quest/QuestHint clicked on.
- */
- bool QuestGUINode::openDetails(const CEGUI::EventArgs& e)
- {
- COUT(4) << "Open QuestItem..." << std::endl;
-
- //CEGUI::Window* window = this->gui_->getRootWindow();
- CEGUI::Window* window = this->gui_->getWindowManager()->getWindow("orxonox/QuestGUI/Background");
-
- if(window != NULL)
- window->addChildWindow(this->getDetails());
-
- return true;
- }
-
- /**
- @brief
- Close the details window.
- */
- bool QuestGUINode::closeDetails(const CEGUI::EventArgs& e)
- {
- //CEGUI::Window* window = this->gui_->getRootWindow();
- CEGUI::Window* window = this->gui_->getWindowManager()->getWindow("orxonox/QuestGUI/Background");
- window->removeChildWindow(this->details_);
-
- return true;
- }
-
- /**
- @brief
- Helper method for setHeight(). Gets the StaticTextArea for an input CEGUI Window.
- @param window
- The CEGUI window.
- @return
- Returns a CEGUI Rect.
- */
- /*static*/ CEGUI::Rect QuestGUINode::getStaticTextArea(const CEGUI::Window* window)
- {
- const CEGUI::WidgetLookFeel& lookAndFeel = CEGUI::WidgetLookManager::getSingleton().getWidgetLook(window->getLookNFeel());
-
- return lookAndFeel.getNamedArea("WithFrameTextRenderArea").getArea().getPixelRect(*window);
- }
-
- /**
- @brief
- Helper method to adjust the height of an input Window (of type StaticText) to the text it holds.
- @param window
- The CEGUI Window (of type StaticText) for which the height is to be adjusted to the text.
- @return
- Returns the set height.
- */
- /*static*/ int QuestGUINode::setHeight(CEGUI::Window* window)
- {
- //! Get the area the text is formatted and drawn into.
- const CEGUI::Rect formattedArea = getStaticTextArea(window);
-
- //! Calculate the pixel height of the frame by subtracting the height of the area above from the total height of the window.
- const float frameHeight = window->getUnclippedPixelRect().getHeight() - formattedArea.getHeight();
-
- //! Get the formatted line count - using the formatting area obtained above.
- const float lines = (float)(window->getFont()->getFormattedLineCount(window->getText(), formattedArea, CEGUI::WordWrapLeftAligned));
-
- //! Calculate pixel height of window, which is the number of formatted lines multiplied by the spacing of the font, plus the pixel height of the frame.
- const float height = lines * window->getFont()->getLineSpacing() + frameHeight;
-
- //! Set the height to the window.
- window->setHeight(CEGUI::UDim(0, height));
-
- //Debug
- const CEGUI::Rect newArea = getStaticTextArea(window);
-
- return static_cast<int>(height);
- }
-
- /**
- @brief
- Update the position list item.
- */
- void QuestGUINode::updatePosition(void)
- {
- this->window_->setPosition(CEGUI::UVector2(CEGUI::UDim(0, (float)(QuestGUINode::INDENT_WIDTH*this->depth_)),CEGUI::UDim(0, (float)(QuestGUINode::BUTTON_HEIGHT*this->index_))));
- this->window_->setSize(CEGUI::UVector2(CEGUI::UDim(1, (float)(-QuestGUINode::INDENT_WIDTH*this->depth_-QuestGUINode::SCROLLBAR_WIDTH)),CEGUI::UDim(0, (float)QuestGUINode::BUTTON_HEIGHT)));
- }
-
- /**
- @brief
- Helper method to create the CEGUI Window the node.
- */
- void QuestGUINode::createWindow(void)
- {
- Quest* quest = dynamic_cast<Quest*>(this->item_);
-
- this->window_ = this->gui_->getWindow();
- std::ostringstream stream;
- stream << "QuestGUI/Quests/";
- if(quest == NULL)
- {
- stream << this->parent_->index_ << "/Hints/";
- }
- stream << this->index_;
-
- this->window_->rename(stream.str());
- this->window_->setText(this->item_->getDescription()->getTitle());
-
- this->parent_->subNodes_.push_back(this);
-
- if(dynamic_cast<Quest*>(this->item_) != NULL)
- {
- this->gui_->getRootWindow()->addChildWindow(this->window_);
- this->updatePosition();
- }
- else
- {
- this->window_->setDestroyedByParent(false);
- }
-
- this->window_->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&QuestGUINode::openDetails, this));
- }
-
-}
-
Deleted: code/branches/presentation3/src/modules/questsystem/QuestGUINode.h
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestGUINode.h 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/src/modules/questsystem/QuestGUINode.h 2010-06-01 19:28:28 UTC (rev 7072)
@@ -1,98 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _QuestGUINode_H__
-#define _QuestGUINode_H__
-
-#include "questsystem/QuestsystemPrereqs.h"
-
-#include <list>
-#include <string>
-#include <CEGUIForwardRefs.h>
-#include "core/OrxonoxClass.h"
-
-
-namespace orxonox {
-
- class _QuestsystemExport QuestGUINode : public OrxonoxClass
- {
-
- public:
-
- QuestGUINode(void);
- QuestGUINode(QuestGUI* gui, QuestGUINode* parent, QuestItem* item, int depth, int index);
- virtual ~QuestGUINode(void);
-
- void toggleVisibility(void);
-
- void getName(std::string & buffer); //!< Sets the input buffer to the name of the node.
- /**
- @brief Retreive the window of this node.
- @return The CEGUI Window of this node.
- */
- inline CEGUI::Window* getWindow(void)
- { return this->window_; }
-
- bool openDetails(const CEGUI::EventArgs& e); //!< Opens the details window for the Quest/QuestHint clicked on.
- bool closeDetails(const CEGUI::EventArgs& e); //!< Close the details window.
-
- private:
- CEGUI::Window* getDetails(void); //!< Creates the details window.
-
- void initialize(void); //!< Initialize the object.
- void updatePosition(void); //!< Update the position list item.
- void createWindow(void); //!< Helper method to create the CEGUI Window the node.
- static CEGUI::Rect getStaticTextArea(const CEGUI::Window* window); //Helper method for setHeight(). Gets the StaticTextArea for an input CEGUI Window.
- static int setHeight(CEGUI::Window* window); //Helper method to adjust the height of an input Window (of type StaticText) to the text it holds.
-
- bool visible_; //!< Boolean determining the visibility of the node.
-
- QuestGUI* gui_; //!< The QuestGUI this node belongs to.
- QuestGUINode* parent_; //!< The parent node.
- std::list<QuestGUINode*> subNodes_; //!< A list of all subnodes.
- QuestItem* item_; //!< QuestItem belonging to this node.
-
- int depth_; //!< The depth (resp. indentation) of this node in the list of Quests. (Irrelevant for QuestHints)
- int index_; //!< The index of this node in the list of Quests, resp. in the list of QuestHints, if the node belongs to a QuestHint, rather than a Quest.
-
- CEGUI::Window* window_; //!< The list window of this node.
- CEGUI::Window* details_; //!< The details window of this node.
-
- //! Some magic numbers
- static const int TITLE_HEIGHT = 26;
- static const int BORDER_WIDTH = 5;
- static const int SCROLLBAR_WIDTH = 13;
- static const int BUTTON_HEIGHT = 30;
- static const int INDENT_WIDTH = 20;
-
- };
-
-}
-
-#endif /* _QuestGUINode_H__ */
-
Modified: code/branches/presentation3/src/modules/questsystem/QuestHint.h
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestHint.h 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/src/modules/questsystem/QuestHint.h 2010-06-01 19:28:28 UTC (rev 7072)
@@ -39,8 +39,8 @@
#include <map>
#include "QuestItem.h"
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
namespace QuestHintStatus
{
//! The state of the hint.
@@ -65,8 +65,9 @@
@author
Damian 'Mozork' Frick
*/
- class _QuestsystemExport QuestHint : public QuestItem
- {
+ class _QuestsystemExport QuestHint // tolua_export
+ : public QuestItem
+ { // tolua_export
public:
QuestHint(BaseObject* creator);
@@ -90,8 +91,8 @@
Quest* quest_; //!< The Quest the QuestHint belongs to.
std::map<const PlayerInfo*, QuestHintStatus::Value> playerStatus_; //!< List of the states for each player, with the Player-pointer as key.
- };
+ }; // tolua_export
-}
+} // tolua_export
#endif /* _QuestHint_H__ */
Modified: code/branches/presentation3/src/modules/questsystem/QuestManager.cc
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestManager.cc 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/src/modules/questsystem/QuestManager.cc 2010-06-01 19:28:28 UTC (rev 7072)
@@ -73,11 +73,7 @@
*/
QuestManager::~QuestManager()
{
- for(std::map<PlayerInfo*, QuestGUI*>::iterator it = this->questGUIs_.begin(); it != this->questGUIs_.end(); it++)
- {
- it->second->destroy();
- }
- this->questGUIs_.clear();
+
}
/**
@@ -243,25 +239,83 @@
}
- /**
- @brief
- Retreive the main window for the GUI.
- This is for the use in the lua script tu start the QuestGUI.
- @param guiName
- The name of the GUI.
- @return
- Returns a CEGUI Window.
- */
- CEGUI::Window* QuestManager::getQuestGUI(const std::string & guiName)
+ int QuestManager::getNumParentQuests(PlayerInfo* player)
{
- PlayerInfo* player = this->retrievePlayer(guiName);
+ int numQuests = 0;
+ for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++)
+ {
+ if(it->second->getParentQuest() == NULL && !it->second->isInactive(player))
+ numQuests++;
+ }
+ return numQuests;
+ }
+
+ Quest* QuestManager::getParentQuest(PlayerInfo* player, int index)
+ {
+ for(std::map<std::string, Quest*>::iterator it = this->questMap_.begin(); it != this->questMap_.end(); it++)
+ {
+ if(it->second->getParentQuest() == NULL && !it->second->isInactive(player) && index-- == 0)
+ return it->second;
+ }
+ return NULL;
+ }
- if(this->questGUIs_.find(player) == this->questGUIs_.end()) //!< Create a new GUI, if there is none, yet.
- this->questGUIs_[player] = new QuestGUI(player);
+ int QuestManager::getNumSubQuests(Quest* quest, PlayerInfo* player)
+ {
+ std::list<Quest*> quests = quest->getSubQuestList();
+ int numQuests = 0;
+ for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
+ {
+ if(!(*it)->isInactive(player))
+ numQuests++;
+ }
+ return numQuests;
+ }
+
+ Quest* QuestManager::getSubQuest(Quest* quest, PlayerInfo* player, int index)
+ {
+ std::list<Quest*> quests = quest->getSubQuestList();
+ for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
+ {
+ if(!(*it)->isInactive(player) && index-- == 0)
+ return *it;
+ }
+ return NULL;
+ }
- return this->questGUIs_[player]->getGUI();
+ int QuestManager::getNumHints(Quest* quest, PlayerInfo* player)
+ {
+ std::list<QuestHint*> hints = quest->getHintsList();
+ int numHints = 0;
+ for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++)
+ {
+ if((*it)->isActive(player))
+ numHints++;
+ }
+ return numHints;
}
+
+ QuestHint* QuestManager::getHints(Quest* quest, PlayerInfo* player, int index)
+ {
+ std::list<QuestHint*> hints = quest->getHintsList();
+ for(std::list<QuestHint*>::iterator it = hints.begin(); it != hints.end(); it++)
+ {
+ if((*it)->isActive(player) && index-- == 0)
+ return *it;
+ }
+ return NULL;
+ }
+ QuestDescription* QuestManager::getDescription(Quest* item)
+ {
+ return item->getDescription();
+ }
+
+ QuestDescription* QuestManager::getDescription(QuestHint* item)
+ {
+ return item->getDescription();
+ }
+
/**
@brief
Retrieve the player for a certain GUI.
Modified: code/branches/presentation3/src/modules/questsystem/QuestManager.h
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestManager.h 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/src/modules/questsystem/QuestManager.h 2010-06-01 19:28:28 UTC (rev 7072)
@@ -35,7 +35,6 @@
#define _QuestManager_H__
#include "questsystem/QuestsystemPrereqs.h"
-#include <CEGUIForwardRefs.h>
#include <list>
#include <map>
@@ -44,8 +43,6 @@
#include "util/Singleton.h"
#include "core/OrxonoxClass.h"
-#include "QuestGUI.h"
-
// tolua_begin
namespace orxonox
{
@@ -62,7 +59,6 @@
{ // tolua_export
friend class Singleton<QuestManager>;
- friend class QuestGUI;
public:
QuestManager();
@@ -71,9 +67,20 @@
//! Returns a reference to the single instance of the Quest Manager.
static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export
- //! Retrieve the main window for the GUI.
- CEGUI::Window* getQuestGUI(const std::string & guiName); // tolua_export
+ // tolua_begin
+ int getNumParentQuests(orxonox::PlayerInfo* player);
+ Quest* getParentQuest(orxonox::PlayerInfo* player, int index);
+ int getNumSubQuests(Quest* quest, orxonox::PlayerInfo* player);
+ Quest* getSubQuest(Quest* quest, orxonox::PlayerInfo* player, int index);
+
+ int getNumHints(Quest* quest, orxonox::PlayerInfo* player);
+ QuestHint* getHints(Quest* quest, orxonox::PlayerInfo* player, int index);
+
+ QuestDescription* getDescription(Quest* item);
+ QuestDescription* getDescription(QuestHint* item);
+ // tolua_end
+
bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager.
bool unregisterQuest(Quest* quest); //!< Unregisters a Quest in the QuestManager.
bool registerHint(QuestHint* hint); //!< Registers a QuestHint in the QuestManager.
@@ -92,8 +99,6 @@
std::map<std::string, Quest*> questMap_; //!< All Quests registered by their id's.
std::map<std::string, QuestHint*> hintMap_; //!< All QuestHints registered by their id's.
- std::map<PlayerInfo*, QuestGUI*> questGUIs_; //!< All GUI's registered by the players.
-
}; // tolua_export
} // tolua_export
Modified: code/branches/presentation3/src/modules/questsystem/QuestsystemPrereqs.h
===================================================================
--- code/branches/presentation3/src/modules/questsystem/QuestsystemPrereqs.h 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/src/modules/questsystem/QuestsystemPrereqs.h 2010-06-01 19:28:28 UTC (rev 7072)
@@ -76,8 +76,6 @@
class QuestDescription;
class QuestEffect;
class QuestEffectBeacon;
- class QuestGUI;
- class QuestGUINode;
class QuestHint;
class QuestItem;
class QuestListener;
Modified: code/branches/presentation3/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/presentation3/src/orxonox/CMakeLists.txt 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/src/orxonox/CMakeLists.txt 2010-06-01 19:28:28 UTC (rev 7072)
@@ -61,6 +61,7 @@
MoodManager.h
controllers/HumanController.h
interfaces/Pickupable.h
+ infos/PlayerInfo.h
sound/SoundManager.h
DEFINE_SYMBOL
"ORXONOX_SHARED_BUILD"
Modified: code/branches/presentation3/src/orxonox/infos/PlayerInfo.h
===================================================================
--- code/branches/presentation3/src/orxonox/infos/PlayerInfo.h 2010-06-01 12:44:31 UTC (rev 7071)
+++ code/branches/presentation3/src/orxonox/infos/PlayerInfo.h 2010-06-01 19:28:28 UTC (rev 7072)
@@ -34,10 +34,11 @@
#include "Info.h"
#include "core/SubclassIdentifier.h"
-namespace orxonox
-{
- class _OrxonoxExport PlayerInfo : public Info
- {
+namespace orxonox // tolua_export
+{ // tolua_export
+ class _OrxonoxExport PlayerInfo // tolua_export
+ : public Info
+ { // tolua_export
public:
PlayerInfo(BaseObject* creator);
virtual ~PlayerInfo();
@@ -102,7 +103,7 @@
const GametypeInfo* gtinfo_;
unsigned int gtinfoID_;
- };
-}
+ }; // tolua_export
+} // tolua_export
#endif /* _PlayerInfo_H__ */
More information about the Orxonox-commit
mailing list