[Orxonox-commit 4013] r8687 - in code/branches/unity_build: data/gui/scripts data/lua src/libraries/core src/libraries/util
rgrieder at orxonox.net
rgrieder at orxonox.net
Mon May 30 18:45:07 CEST 2011
Author: rgrieder
Date: 2011-05-30 18:45:06 +0200 (Mon, 30 May 2011)
New Revision: 8687
Modified:
code/branches/unity_build/data/gui/scripts/ChatBox-inputonly.lua
code/branches/unity_build/data/gui/scripts/ChatBox.lua
code/branches/unity_build/data/gui/scripts/MenuSheet.lua
code/branches/unity_build/data/gui/scripts/MiscConfigMenu.lua
code/branches/unity_build/data/gui/scripts/NotificationLayer.lua
code/branches/unity_build/data/gui/scripts/SheetManager.lua
code/branches/unity_build/data/lua/Tools.lua
code/branches/unity_build/src/libraries/core/GUIManager.h
code/branches/unity_build/src/libraries/util/tribool.h
Log:
Adjusted implementation of tribool to work well with tolua and integrated it into our GUI code.
Use tribool(true), tribool(false) and tribool(dontcare) in Lua.
Modified: code/branches/unity_build/data/gui/scripts/ChatBox-inputonly.lua
===================================================================
--- code/branches/unity_build/data/gui/scripts/ChatBox-inputonly.lua 2011-05-30 16:20:22 UTC (rev 8686)
+++ code/branches/unity_build/data/gui/scripts/ChatBox-inputonly.lua 2011-05-30 16:45:06 UTC (rev 8687)
@@ -1,5 +1,5 @@
-- ChatBox-inputonly.lua
-local P = createMenuSheet("ChatBox-inputonly", true, TriBool.True, TriBool.Dontcare, false)
+local P = createMenuSheet("ChatBox-inputonly", true, tribool(true), tribool(dontcare), false)
return P
Modified: code/branches/unity_build/data/gui/scripts/ChatBox.lua
===================================================================
--- code/branches/unity_build/data/gui/scripts/ChatBox.lua 2011-05-30 16:20:22 UTC (rev 8686)
+++ code/branches/unity_build/data/gui/scripts/ChatBox.lua 2011-05-30 16:45:06 UTC (rev 8687)
@@ -1,6 +1,6 @@
-- ChatBox.lua
-local P = createMenuSheet("ChatBox", true, TriBool.True, TriBool.Dontcare, false)
+local P = createMenuSheet("ChatBox", true, tribool(true), tribool(dontcare), false)
function P.ChatBoxCloseButton_clicked(e)
orxonox.ChatInputHandler:getInstance():deactivate()
Modified: code/branches/unity_build/data/gui/scripts/MenuSheet.lua
===================================================================
--- code/branches/unity_build/data/gui/scripts/MenuSheet.lua 2011-05-30 16:20:22 UTC (rev 8686)
+++ code/branches/unity_build/data/gui/scripts/MenuSheet.lua 2011-05-30 16:45:06 UTC (rev 8687)
@@ -10,12 +10,12 @@
-- Use this function to construct a new MenuSheet.
-- Parameters:
-- Except for _name, you can provide nil. Then the default value will be used.
--- For _tShowCusor and _tUseKeyboard you can specify TriBool.Dontcare if the value doesn't matter at all. Then the value of the underlaying sheet will be used.
+-- For _tShowCusor and _tUseKeyboard you can specify tribool(dontcare) if the value doesn't matter at all. Then the value of the underlaying sheet will be used.
function P.new(_name, _bHidePrevious, _tShowCursor, _tUseKeyboard, _bBlockJoyStick)
local newSheet = GUISheet.new(_name)
newSheet.bHidePrevious = handleDefArg(_bHidePrevious, true)
- newSheet.tShowCursor = handleDefArg(_tShowCusor, TriBool.True)
- newSheet.tUseKeyboard = handleDefArg(_tUseKeyboard, TriBool.True)
+ newSheet.tShowCursor = handleDefArg(_tShowCusor, tribool(true))
+ newSheet.tUseKeyboard = handleDefArg(_tUseKeyboard, tribool(true))
newSheet.bBlockJoyStick = handleDefArg(_bBlockJoyStick, false)
setmetatable(newSheet, P)
Modified: code/branches/unity_build/data/gui/scripts/MiscConfigMenu.lua
===================================================================
--- code/branches/unity_build/data/gui/scripts/MiscConfigMenu.lua 2011-05-30 16:20:22 UTC (rev 8686)
+++ code/branches/unity_build/data/gui/scripts/MiscConfigMenu.lua 2011-05-30 16:45:06 UTC (rev 8687)
@@ -1,6 +1,6 @@
-- MiscConfigMenu.lua
-local P = createMenuSheet("MiscConfigMenu", true, TriBool.True, TriBool.True)
+local P = createMenuSheet("MiscConfigMenu", true, tribool(true), tribool(true))
P.commandList = {}
P.nameList = {}
Modified: code/branches/unity_build/data/gui/scripts/NotificationLayer.lua
===================================================================
--- code/branches/unity_build/data/gui/scripts/NotificationLayer.lua 2011-05-30 16:20:22 UTC (rev 8686)
+++ code/branches/unity_build/data/gui/scripts/NotificationLayer.lua 2011-05-30 16:45:06 UTC (rev 8687)
@@ -1,6 +1,6 @@
-- NotificationLayer.lua
-local P = createMenuSheet("NotificationLayer", true, TriBool.True, TriBool.True)
+local P = createMenuSheet("NotificationLayer", true, tribool(true), tribool(true))
P.queueList = {}
P.editMode = false
Modified: code/branches/unity_build/data/gui/scripts/SheetManager.lua
===================================================================
--- code/branches/unity_build/data/gui/scripts/SheetManager.lua 2011-05-30 16:20:22 UTC (rev 8686)
+++ code/branches/unity_build/data/gui/scripts/SheetManager.lua 2011-05-30 16:45:06 UTC (rev 8687)
@@ -80,7 +80,7 @@
end
if bNoInput == true then
- menuSheet.tShowCursor = TriBool.Dontcare
+ menuSheet.tShowCursor = tribool(dontcare)
end
-- Add the sheet in a tuple of additional information
@@ -109,10 +109,10 @@
inputMgr:enterState(menuSheet.inputState)
end
- -- Only change cursor situation if menuSheet.tShowCursor ~= TriBool.Dontcare
- if menuSheet.tShowCursor == TriBool.True then
+ -- Only change cursor situation if menuSheet.tShowCursor ~= tribool(dontcare)
+ if menuSheet.tShowCursor == tribool(true) then
showCursor()
- elseif menuSheet.tShowCursor == TriBool.False then
+ elseif menuSheet.tShowCursor == tribool(false) then
hideCursor()
end
@@ -185,11 +185,11 @@
-- CURSOR SHOWING
local i = activeMenuSheets.size
- -- Find top most sheet that doesn't have tShowCusor == TriBool.Dontcare
- while i > 0 and activeMenuSheets[i].sheet.tShowCursor == TriBool.Dontcare do
+ -- Find top most sheet that doesn't have tShowCusor == tribool(dontcare)
+ while i > 0 and activeMenuSheets[i].sheet.tShowCursor == tribool(dontcare) do
i = i - 1
end
- if i > 0 and activeMenuSheets[i].sheet.tShowCursor == TriBool.True then
+ if i > 0 and activeMenuSheets[i].sheet.tShowCursor == tribool(true) then
showCursor()
else
hideCursor()
@@ -253,15 +253,15 @@
function windowResized(e)
for name, sheet in pairs(loadedSheets) do
- if orxonox.GraphicsManager:getInstance():isFullScreen() or sheet.tShowCursor == TriBool.False then
- inputMgr:setMouseExclusive(sheet.inputState, TriBool.True)
+ if orxonox.GraphicsManager:getInstance():isFullScreen() or sheet.tShowCursor == tribool(false) then
+ inputMgr:setMouseExclusive(sheet.inputState, tribool(true))
else
- inputMgr:setMouseExclusive(sheet.inputState, TriBool.False)
+ inputMgr:setMouseExclusive(sheet.inputState, tribool(false))
end
end
local sheetTuple = activeMenuSheets[activeMenuSheets.size]
if sheetTuple then
- if orxonox.GraphicsManager:getInstance():isFullScreen() and sheetTuple.sheet.tShowCursor ~= TriBool.False then
+ if orxonox.GraphicsManager:getInstance():isFullScreen() and sheetTuple.sheet.tShowCursor ~= tribool(false) then
showCursor()
else
hideCursor()
Modified: code/branches/unity_build/data/lua/Tools.lua
===================================================================
--- code/branches/unity_build/data/lua/Tools.lua 2011-05-30 16:20:22 UTC (rev 8686)
+++ code/branches/unity_build/data/lua/Tools.lua 2011-05-30 16:45:06 UTC (rev 8687)
@@ -15,10 +15,6 @@
return 0
end
--- Short forms for TriBool
-TriBool =
-{
- True = orxonox.TriBool.True,
- False = orxonox.TriBool.False,
- Dontcare = orxonox.TriBool.Dontcare
-}
+-- Shortcuts for tribool
+tribool = orxonox.tribool
+dontcare = orxonox.dontcare_keyword_t()
Modified: code/branches/unity_build/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/unity_build/src/libraries/core/GUIManager.h 2011-05-30 16:20:22 UTC (rev 8686)
+++ code/branches/unity_build/src/libraries/core/GUIManager.h 2011-05-30 16:45:06 UTC (rev 8687)
@@ -60,7 +60,19 @@
class PlayerInfo; // Forward declaration
// Acquaint Tolua with tribool
- class tribool; // tolua_export
+ /* tolua_begin
+ struct dontcare_keyword_t
+ {
+ dontcare_keyword_t();
+ };
+ class tribool
+ {
+ tribool(bool value);
+ tribool(dontcare_keyword_t);
+ bool operator==(tribool);
+ bool operator!=(tribool);
+ };
+ tolua_end */
/**
@class GUIManager
Modified: code/branches/unity_build/src/libraries/util/tribool.h
===================================================================
--- code/branches/unity_build/src/libraries/util/tribool.h 2011-05-30 16:20:22 UTC (rev 8686)
+++ code/branches/unity_build/src/libraries/util/tribool.h 2011-05-30 16:45:06 UTC (rev 8687)
@@ -1,228 +1,138 @@
-// Three-state boolean logic library
-
-// Copyright Douglas Gregor 2002-2004. Use, modification and
-// distribution is subject to the Boost Software License, Version
-// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-// Modifications by Orxonox to shape the third state into 'dontcare' instead
-// of 'indeterminate'. The difference is that 'dontcare' is actually a value
-// so that (dontcare == dontcare).
-// Also removed all logic operators except for == and !=
-
-
-// For more information, see http://www.boost.org
-#ifndef ORXONOX_TRIBOOL_H
-#define ORXONOX_TRIBOOL_H
-
-namespace orxonox {
-
-// Forward declare tribool
-class tribool;
-
-/// INTERNAL ONLY
-namespace detail {
-/**
- * INTERNAL ONLY
- *
- * \brief A type used only to uniquely identify the 'dontcare'
- * function/keyword.
- */
-struct dontcare_t
-{
-};
-
-} // end namespace detail
-
-/**
- * INTERNAL ONLY
- * The type of the 'dontcare' keyword. This has the same type as the
- * function 'dontcare' so that we can recognize when the keyword is
- * used.
- */
-typedef bool (*dontcare_keyword_t)(tribool, detail::dontcare_t);
-
-/**
- * \brief Keyword and test function for the dontcare tribool value
- *
- * The \c dontcare function has a dual role. It's first role is
- * as a unary function that tells whether the tribool value is in the
- * "dontcare" state. It's second role is as a keyword
- * representing the dontcare (just like "true" and "false"
- * represent the true and false states).
- *
- * \returns <tt>x.value == tribool::dontcare_value</tt>
- * \throws nothrow
- */
-inline bool
-dontcare(tribool x, detail::dontcare_t dummy = detail::dontcare_t());
-
-/**
- * \brief A 3-state boolean type.
- *
- * 3-state boolean values are either true, false, or
- * dontcare.
- */
-class tribool
-{
-public:
- /**
- * Construct a new 3-state boolean value with the value 'false'.
- *
- * \throws nothrow
- */
- tribool() : value(false_value) {}
-
- /**
- * Construct a new 3-state boolean value with the given boolean
- * value, which may be \c true or \c false.
- *
- * \throws nothrow
- */
- tribool(bool value) : value(value? true_value : false_value) {}
-
- /**
- * Construct a new 3-state boolean value with an dontcare value.
- *
- * \throws nothrow
- */
- tribool(dontcare_keyword_t) : value(dontcare_value) {}
-
- /**
- * The actual stored value in this 3-state boolean, which may be false, true,
- * or dontcare.
- */
- enum value_t { false_value, true_value, dontcare_value } value;
-};
-
-// Check if the given tribool has an dontcare value. Also doubles as a
-// keyword for the 'dontcare' value
-inline bool dontcare(tribool x, detail::dontcare_t)
-{
- return x.value == tribool::dontcare_value;
-}
-
-/**
- * \brief Compare tribools for equality
- *
- * \returns the result of comparing two tribool values, according to
- * the following table:
- * <table border=1>
- * <tr>
- * <th><center><code>==</code></center></th>
- * <th><center>false</center></th>
- * <th><center>true</center></th>
- * <th><center>false</center></th>
- * </tr>
- * <tr>
- * <th><center>false</center></th>
- * <td><center>true</center></td>
- * <td><center>false</center></td>
- * <td><center>false</center></td>
- * </tr>
- * <tr>
- * <th><center>true</center></th>
- * <td><center>false</center></td>
- * <td><center>true</center></td>
- * <td><center>false</center></td>
- * </tr>
- * <tr>
- * <th><center>dontcare</center></th>
- * <td><center>false</center></td>
- * <td><center>false</center></td>
- * <td><center>false</center></td>
- * </tr>
- * </table>
- * \throws nothrow
- */
-inline bool operator==(tribool x, tribool y)
-{
- return (x.value == y.value);
-}
-
-/**
- * \overload
- */
-inline bool operator==(tribool x, bool y) { return x == tribool(y); }
-
-/**
- * \overload
- */
-inline bool operator==(bool x, tribool y) { return tribool(x) == y; }
-
-/**
- * \overload
- */
-inline bool operator==(dontcare_keyword_t, tribool x)
-{ return tribool(dontcare) == x; }
-
-/**
- * \overload
- */
-inline bool operator==(tribool x, dontcare_keyword_t)
-{ return tribool(dontcare) == x; }
-
-/**
- * \brief Compare tribools for inequality
- *
- * \returns the result of comparing two tribool values for inequality,
- * according to the following table:
- * <table border=1>
- * <tr>
- * <th><center><code>!=</code></center></th>
- * <th><center>false</center></th>
- * <th><center>true</center></th>
- * <th><center>dontcare</center></th>
- * </tr>
- * <tr>
- * <th><center>false</center></th>
- * <td><center>false</center></td>
- * <td><center>true</center></td>
- * <td><center>true</center></td>
- * </tr>
- * <tr>
- * <th><center>true</center></th>
- * <td><center>true</center></td>
- * <td><center>false</center></td>
- * <td><center>true</center></td>
- * </tr>
- * <tr>
- * <th><center>true</center></th>
- * <td><center>true</center></td>
- * <td><center>true</center></td>
- * <td><center>false</center></td>
- * </tr>
- * </table>
- * \throws nothrow
- */
-inline bool operator!=(tribool x, tribool y)
-{
- return !(x == y);
-}
-
-/**
- * \overload
- */
-inline bool operator!=(tribool x, bool y) { return x != tribool(y); }
-
-/**
- * \overload
- */
-inline bool operator!=(bool x, tribool y) { return tribool(x) != y; }
-
-/**
- * \overload
- */
-inline bool operator!=(dontcare_keyword_t, tribool x)
-{ return tribool(dontcare) != x; }
-
-/**
- * \overload
- */
-inline bool operator!=(tribool x, dontcare_keyword_t)
-{ return x != tribool(dontcare); }
-
-} // end namespace orxonox
-
-#endif // ORXONOX_TRIBOOL_H
-
+// Three-state boolean logic library
+
+// Copyright Douglas Gregor 2002-2004. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// Modifications by Orxonox to shape the third state into 'dontcare' instead
+// of 'indeterminate'. The difference is that 'dontcare' is actually a value
+// so that (dontcare == dontcare).
+// Also removed all logic operators except for == and !=
+
+
+// For more information, see http://www.boost.org
+#ifndef ORXONOX_TRIBOOL_H
+#define ORXONOX_TRIBOOL_H
+
+namespace orxonox {
+
+/**
+ * INTERNAL ONLY
+ * The type of the 'dontcare' keyword.
+ */
+struct dontcare_keyword_t { };
+
+/**
+ * \brief Keyword for the dontcare tribool value
+ */
+const dontcare_keyword_t dontcare;
+
+/**
+ * \brief A 3-state boolean type.
+ *
+ * 3-state boolean values are either true, false, or
+ * dontcare.
+ */
+class tribool
+{
+public:
+ /**
+ * Construct a new 3-state boolean value with the value 'false'.
+ *
+ * \throws nothrow
+ */
+ tribool() : value(false_value) {}
+
+ /**
+ * Construct a new 3-state boolean value with the given boolean
+ * value, which may be \c true or \c false.
+ *
+ * \throws nothrow
+ */
+ tribool(bool value) : value(value? true_value : false_value) {}
+
+ /**
+ * Construct a new 3-state boolean value with an dontcare value.
+ *
+ * \throws nothrow
+ */
+ tribool(dontcare_keyword_t) : value(dontcare_value) {}
+
+ /**
+ * \brief Compare tribools for equality
+ *
+ * \returns the result of comparing two tribool values.
+ * \throws nothrow
+ */
+ inline bool operator==(tribool y)
+ {
+ return (this->value == y.value);
+ }
+
+ /**
+ * \overload
+ */
+ inline bool operator==(bool y) { return (*this) == tribool(y); }
+
+ /**
+ * \overload
+ */
+ inline bool operator==(dontcare_keyword_t)
+ { return tribool(dontcare) == (*this); }
+
+ /**
+ * \brief Compare tribools for inequality
+ *
+ * \returns the result of comparing two tribool values for inequality.
+ * \throws nothrow
+ */
+ inline bool operator!=(tribool y)
+ {
+ return !((*this) == y);
+ }
+
+ /**
+ * \overload
+ */
+ inline bool operator!=(bool y) { return (*this) != tribool(y); }
+
+ /**
+ * \overload
+ */
+ inline bool operator!=(dontcare_keyword_t)
+ { return (*this) != tribool(dontcare); }
+
+ /**
+ * The actual stored value in this 3-state boolean, which may be false, true,
+ * or dontcare.
+ */
+ enum value_t { false_value, true_value, dontcare_value } value;
+};
+
+/**
+ * \overload
+ */
+inline bool operator==(bool x, tribool y) { return tribool(x) == y; }
+
+/**
+ * \overload
+ */
+inline bool operator==(dontcare_keyword_t, tribool x)
+{ return tribool(dontcare) == x; }
+
+/**
+ * \overload
+ */
+inline bool operator!=(bool x, tribool y) { return tribool(x) != y; }
+
+/**
+ * \overload
+ */
+inline bool operator!=(dontcare_keyword_t, tribool x)
+{ return tribool(dontcare) != x; }
+
+} // end namespace orxonox
+
+#endif // ORXONOX_TRIBOOL_H
+
Property changes on: code/branches/unity_build/src/libraries/util/tribool.h
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the Orxonox-commit
mailing list