[Orxonox-commit 4169] r8840 - in code/branches/output: data/gui/scripts data/lua src/libraries/core src/libraries/core/command src/libraries/util/output
landauf at orxonox.net
landauf at orxonox.net
Sat Aug 13 23:58:07 CEST 2011
Author: landauf
Date: 2011-08-13 23:58:07 +0200 (Sat, 13 Aug 2011)
New Revision: 8840
Modified:
code/branches/output/data/gui/scripts/GameplayMenu.lua
code/branches/output/data/gui/scripts/MultiplayerMenu.lua
code/branches/output/data/gui/scripts/NotificationLayer.lua
code/branches/output/data/gui/scripts/QuestGUI.lua
code/branches/output/data/lua/LuaStateInit.lua
code/branches/output/src/libraries/core/CMakeLists.txt
code/branches/output/src/libraries/core/LuaState.cc
code/branches/output/src/libraries/core/LuaState.h
code/branches/output/src/libraries/core/command/Shell.cc
code/branches/output/src/libraries/util/output/OutputDefinitions.h
Log:
Exported orxout() and the output levels to lua, replaces logMessage() and cout().
Note that OutputDefinitions.h is now included in the tolua section of core, even though the file is in util. But I guess that's ok.
Modified: code/branches/output/data/gui/scripts/GameplayMenu.lua
===================================================================
--- code/branches/output/data/gui/scripts/GameplayMenu.lua 2011-08-13 21:27:42 UTC (rev 8839)
+++ code/branches/output/data/gui/scripts/GameplayMenu.lua 2011-08-13 21:58:07 UTC (rev 8840)
@@ -17,22 +17,22 @@
function P.GameplayThemeCombobox_changed(e)
-- theme
- logMessage(0, "event: theme")
+ orxout("event: theme")
end
function P.GameplayDifficultyEasyButton_clicked(e)
-- difficulty easy
- logMessage(0, "event: easy")
+ orxout("event: easy")
end
function P.GameplayDifficultyNormalButton_clicked(e)
-- difficulty normal
- logMessage(0, "event: normal")
+ orxout("event: normal")
end
function P.GameplayDifficultyHardButton_clicked(e)
-- difficulty hard
- logMessage(0, "event: hard")
+ orxout("event: hard")
end
function P.GameplayBackButton_clicked(e)
Modified: code/branches/output/data/gui/scripts/MultiplayerMenu.lua
===================================================================
--- code/branches/output/data/gui/scripts/MultiplayerMenu.lua 2011-08-13 21:27:42 UTC (rev 8839)
+++ code/branches/output/data/gui/scripts/MultiplayerMenu.lua 2011-08-13 21:58:07 UTC (rev 8840)
@@ -117,9 +117,9 @@
local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
CEGUI.toListbox(listbox):resetList()
local discovery = orxonox.WANDiscovery()
- cout(0, "discovering.\n" )
+ orxout("discovering." )
discovery:discover()
- cout(0, "discovered.\n" )
+ orxout("discovered." )
P.serverList = {}
local index = 0
local servername = ""
Modified: code/branches/output/data/gui/scripts/NotificationLayer.lua
===================================================================
--- code/branches/output/data/gui/scripts/NotificationLayer.lua 2011-08-13 21:27:42 UTC (rev 8839)
+++ code/branches/output/data/gui/scripts/NotificationLayer.lua 2011-08-13 21:58:07 UTC (rev 8840)
@@ -135,7 +135,7 @@
local moved = false
if index > queue.first then -- Move all older notifications up in the list.
for i=index-1,-1,queue.first do
- cout(0, i)
+ orxout(i)
item = queue.items[i]
item:setYposition(CEGUI.UDim(0, itemHeight*(queue.last-i-1)))
queue.items[i+1] = item
Modified: code/branches/output/data/gui/scripts/QuestGUI.lua
===================================================================
--- code/branches/output/data/gui/scripts/QuestGUI.lua 2011-08-13 21:27:42 UTC (rev 8839)
+++ code/branches/output/data/gui/scripts/QuestGUI.lua 2011-08-13 21:58:07 UTC (rev 8840)
@@ -219,7 +219,7 @@
-- quest is the quest to be selected.
function P.selectQuest(list, quest)
if quest == nil then -- If the input quest is nil, there is nothing to be selected, an error is output and the first quest is selected instead.
- cout(1, "Error in QuestGUI: selectQuest(), input quest is nil. Selecting first.")
+ orxout(orxonox.level.internal_error, "Error in QuestGUI: selectQuest(), input quest is nil. Selecting first.")
list:setItemSelectState(list:getListboxItemFromIndex(0), true) -- Select first
return
end
@@ -239,7 +239,7 @@
if found then -- If the quest was found it is selected.
list:setItemSelectState(list:getListboxItemFromIndex(index), true)
else -- If the quest isn't found an error is output and the first quest is selected instead.
- cout(1, "Error in QuestGUI: selectQuest(), input quest is not in list. Selecting first.")
+ orxout(orxonox.level.internal_error, "Error in QuestGUI: selectQuest(), input quest is not in list. Selecting first.")
list:setItemSelectState(list:getListboxItemFromIndex(0), true) -- Select first
end
end
@@ -312,7 +312,7 @@
P.loadQuestsList(quest)
end
else
- cout(1, "Error in QuestGUI: changeToSubquest(), quest was nil. Ignoring...")
+ orxout(orxonox.level.internal_error, "Error in QuestGUI: changeToSubquest(), quest was nil. Ignoring...")
end
end
end
Modified: code/branches/output/data/lua/LuaStateInit.lua
===================================================================
--- code/branches/output/data/lua/LuaStateInit.lua 2011-08-13 21:27:42 UTC (rev 8839)
+++ code/branches/output/data/lua/LuaStateInit.lua 2011-08-13 21:58:07 UTC (rev 8840)
@@ -6,11 +6,21 @@
luaState:luaPrint(s)
end
--- Create function to log text like COUT, but always prints a line!
-logMessage = function(level, message)
- luaState:luaLog(level, message)
+-- Prints output to the console and the logfile
+--
+-- Accepts the following arguments:
+-- orxout("message")
+-- orxout(orxonox.level.levelname, "message")
+-- orxout(orxonox.level.levelname, "context", "message)
+orxout = function(arg1, arg2, arg3)
+ if arg1 and arg2 and arg3 then
+ luaState:luaOutput(arg1, arg2, arg3)
+ elseif arg1 and arg2 then
+ luaState:luaOutput(arg1, arg2)
+ else
+ luaState:luaOutput(arg1)
+ end
end
-cout = logMessage
-- Redirect dofile in order to load with the resource manager
original_dofile = dofile
@@ -41,7 +51,7 @@
LuaStateReturnValue = true
require = function(moduleName)
if not luaState:fileExists(moduleName .. ".lua") then
- logMessage(2, "Warning: Lua function require() could not find file '" .. moduleName .. ".lua' ")
+ orxout(orxonox.level.internal_warning, "Warning: Lua function require() could not find file '" .. moduleName .. ".lua' ")
return nil
end
@@ -84,7 +94,7 @@
else
-- Fallback pause function
pause = function()
- logMessage(2, [["Warning: debug() called in Lua, but Debugger is not active.
+ orxout(orxonox.level.internal_warning, [["Warning: debug() called in Lua, but Debugger is not active.
Do you have the IOConsole disabled and are you using Lua version 5.1?"]])
end
end
@@ -97,7 +107,7 @@
return err
end
-- Display the error message
- logMessage(1, "Lua runtime error: "..err)
+ orxout(orxonox.level.internal_error, "Lua runtime error: "..err)
end
-- Start debugger if possible
@@ -105,7 +115,7 @@
pause()
else
-- Fallback: print stack trace
- logMessage(3, debug.traceback(""))
+ orxout(orxonox.level.internal_error, debug.traceback(""))
end
return err -- Hello Lua debugger user! Please type 'set 2' to get to the
-- actual position in the stack where the error occurred
Modified: code/branches/output/src/libraries/core/CMakeLists.txt
===================================================================
--- code/branches/output/src/libraries/core/CMakeLists.txt 2011-08-13 21:27:42 UTC (rev 8839)
+++ code/branches/output/src/libraries/core/CMakeLists.txt 2011-08-13 21:58:07 UTC (rev 8840)
@@ -85,6 +85,7 @@
input/InputManager.h
input/KeyBinder.h
input/KeyBinderManager.h
+ ../util/output/OutputDefinitions.h
PCH_FILE
CorePrecompiledHeaders.h
LINK_LIBRARIES
Modified: code/branches/output/src/libraries/core/LuaState.cc
===================================================================
--- code/branches/output/src/libraries/core/LuaState.cc 2011-08-13 21:27:42 UTC (rev 8839)
+++ code/branches/output/src/libraries/core/LuaState.cc 2011-08-13 21:58:07 UTC (rev 8840)
@@ -35,7 +35,6 @@
#include <lualib.h>
}
#include <loki/ScopeGuard.h>
-#include <boost/preprocessor/stringize.hpp>
#include "util/Output.h"
#include "util/Exception.h"
@@ -236,12 +235,21 @@
output_ << str;
}
- void LuaState::luaLog(unsigned int level, const std::string& message)
+ void LuaState::luaOutput(OutputLevel level, const std::string& context, const std::string& message)
{
-#pragma message(__FILE__ "("BOOST_PP_STRINGIZE(__LINE__)") : Warning: TODO: use correct level, inspect lua support (and remove boost include)")
- orxout(debug_output, context::lua) << "luaLog (level: " << level << "): " << message << endl;
+ orxout(level, registerContext(context)) << message << endl;
}
+ void LuaState::luaOutput(OutputLevel level, const std::string& message)
+ {
+ orxout(level, context::lua) << message << endl;
+ }
+
+ void LuaState::luaOutput(const std::string& message)
+ {
+ orxout(debug_output, context::lua) << message << endl;
+ }
+
bool LuaState::fileExists(const std::string& filename)
{
shared_ptr<ResourceInfo> info = this->getFileInfo(filename);
Modified: code/branches/output/src/libraries/core/LuaState.h
===================================================================
--- code/branches/output/src/libraries/core/LuaState.h 2011-08-13 21:27:42 UTC (rev 8839)
+++ code/branches/output/src/libraries/core/LuaState.h 2011-08-13 21:58:07 UTC (rev 8840)
@@ -82,7 +82,9 @@
bool includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>());
void luaPrint(const std::string& str); // tolua_export
- void luaLog(unsigned int level, const std::string& message); // tolua_export
+ void luaOutput(orxonox::level::OutputLevel level, const std::string& context, const std::string& message); // tolua_export
+ void luaOutput(orxonox::level::OutputLevel level, const std::string& message); // tolua_export
+ void luaOutput(const std::string& message); // tolua_export
bool fileExists(const std::string& filename); // tolua_export
std::string getSourceCode(const std::string& filename); // tolua_export
Modified: code/branches/output/src/libraries/core/command/Shell.cc
===================================================================
--- code/branches/output/src/libraries/core/command/Shell.cc 2011-08-13 21:27:42 UTC (rev 8839)
+++ code/branches/output/src/libraries/core/command/Shell.cc 2011-08-13 21:58:07 UTC (rev 8840)
@@ -33,8 +33,6 @@
#include "Shell.h"
-#include <boost/preprocessor/stringize.hpp>
-
#include "util/Math.h"
#include "util/StringUtils.h"
#include "util/SubString.h"
Modified: code/branches/output/src/libraries/util/output/OutputDefinitions.h
===================================================================
--- code/branches/output/src/libraries/util/output/OutputDefinitions.h 2011-08-13 21:27:42 UTC (rev 8839)
+++ code/branches/output/src/libraries/util/output/OutputDefinitions.h 2011-08-13 21:58:07 UTC (rev 8840)
@@ -38,6 +38,7 @@
#define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
const OutputContextContainer& subname() { static const OutputContextContainer& context = registerContext(#name, #subname); return context; }
+// tolua_begin
namespace orxonox
{
namespace level
@@ -62,6 +63,7 @@
verbose_ultra = 0x1000
};
}
+// tolua_end
using namespace level;
@@ -127,6 +129,6 @@
}
}
-}
+} // tolua_export
#endif /* _OutputDefinitions_H__ */
More information about the Orxonox-commit
mailing list