diff --git a/code/nel/include/nel/gui/group_menu.h b/code/nel/include/nel/gui/group_menu.h
index e55bed751..d4f940088 100644
--- a/code/nel/include/nel/gui/group_menu.h
+++ b/code/nel/include/nel/gui/group_menu.h
@@ -191,6 +191,7 @@ namespace NLGUI
int luaGetLineFromId(CLuaState &ls);
int luaIsSeparator(CLuaState &ls);
int luaAddLine(CLuaState &ls);
+ int luaAddIconLine(CLuaState &ls);
int luaAddLineAtIndex(CLuaState &ls);
int luaAddSeparator(CLuaState &ls);
int luaAddSeparatorAtIndex(CLuaState &ls);
@@ -210,6 +211,7 @@ namespace NLGUI
REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu);
REFLECT_LUA_METHOD("isSeparator", luaIsSeparator);
REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id
+ REFLECT_LUA_METHOD("addIconLine", luaAddIconLine); // name, ah, ah_params, id, texture
REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id
REFLECT_LUA_METHOD("addSeparator", luaAddSeparator);
REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex);
@@ -278,6 +280,7 @@ namespace NLGUI
*/
CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const;
void initOptions(CInterfaceGroup *parent);
+ CViewBitmap *createIcon(CInterfaceElement *parentPos, const std::string &texture);
CViewBitmap *createCheckBox(bool checked);
CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center);
};
diff --git a/code/nel/include/nel/gui/view_pointer_base.h b/code/nel/include/nel/gui/view_pointer_base.h
index e772d934f..5468ba6d5 100644
--- a/code/nel/include/nel/gui/view_pointer_base.h
+++ b/code/nel/include/nel/gui/view_pointer_base.h
@@ -38,14 +38,17 @@ namespace NLGUI
void resetPointerPos ();
void setPointerDown (bool pd);
+ void setPointerMiddleDown (bool pd);
+ void setPointerRightDown (bool pd);
void setPointerDownString (const std::string &s);
void getPointerPos (sint32 &x, sint32 &y);
void getPointerDispPos (sint32 &x, sint32 &y);
void getPointerOldPos (sint32 &x, sint32 &y);
- void getPointerDownPos (sint32 &x, sint32 &y);
- bool getPointerDown ();
+ bool getPointerDown (sint32 &x, sint32 &y);
+ bool getPointerMiddleDown (sint32 &x, sint32 &y);
+ bool getPointerRightDown (sint32 &x, sint32 &y);
std::string getPointerDownString ();
bool getPointerDrag ();
@@ -70,6 +73,12 @@ namespace NLGUI
bool _PointerDown; // Is the pointer down ?
sint32 _PointerDownX; // Pointer down position
sint32 _PointerDownY;
+ bool _PointerMiddleDown; // Is the middle pointer down ?
+ sint32 _PointerMiddleDownX; // Pointer middle down position
+ sint32 _PointerMiddleDownY;
+ bool _PointerRightDown; // Is the right pointer down ?
+ sint32 _PointerRightDownX; // Pointer right down position
+ sint32 _PointerRightDownY;
std::string _PointerDownString; // What is under the pointer at the down position
bool _PointerDrag; // Is the pointer down and we have moved ?
bool _PointerVisible; // Is the pointer visible or hidden ?
diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp
index f370813b0..916b6a9e2 100644
--- a/code/nel/src/gui/group_html.cpp
+++ b/code/nel/src/gui/group_html.cpp
@@ -2014,7 +2014,6 @@ namespace NLGUI
it = styles.find("background-image");
if (it != styles.end())
{
- nlinfo("found background-image %s", it->second.c_str());
string image = (*it).second;
string::size_type texExt = toLower(image).find("url(");
// Url image
diff --git a/code/nel/src/gui/group_menu.cpp b/code/nel/src/gui/group_menu.cpp
index 3b0e4549d..97d45c870 100644
--- a/code/nel/src/gui/group_menu.cpp
+++ b/code/nel/src/gui/group_menu.cpp
@@ -384,6 +384,22 @@ namespace NLGUI
return true;
}
+ // ------------------------------------------------------------------------------------------------
+ CViewBitmap *CGroupSubMenu::createIcon(CInterfaceElement *parentPos, const string &texture)
+ {
+ // Add an icon to the line
+ CViewBitmap *pVB = new CViewBitmap(CViewBase::TCtorParam());
+ pVB->setSerializable( false );
+ pVB->setParent (this);
+ pVB->setParentPos (parentPos);
+ pVB->setParentPosRef (Hotspot_ML);
+ pVB->setPosRef (Hotspot_MR);
+ pVB->setTexture(texture);
+ pVB->setModulateGlobalColor(false);
+ pVB->setX (-2);
+ addView (pVB);
+ return pVB;
+ }
// ------------------------------------------------------------------------------------------------
CViewBitmap *CGroupSubMenu::createCheckBox(bool checked)
@@ -1229,13 +1245,22 @@ namespace NLGUI
pV->setCheckBox(checkBox);
}
+ CViewBitmap *icon = NULL;
+ if (!texture.empty())
+ {
+ if (_GroupList->getNumChildren() == 1)
+ pV->setX(20);
+ icon = createIcon(pV, texture);
+ }
+
+
tmp.ViewText = pV;
tmp.Separator = NULL;
tmp.AHName = ah;
tmp.AHParams = params;
tmp.Cond = cond;
tmp.CheckBox = checkBox;
- tmp.RightArrow = NULL;
+ tmp.RightArrow = icon;
if (id.empty())
tmp.Id = NLMISC::toString (_Lines.size());
else
@@ -1776,6 +1801,22 @@ namespace NLGUI
return 0;
}
+ // ------------------------------------------------------------------------------------------------
+ int CGroupSubMenu::luaAddIconLine(CLuaState &ls)
+ {
+ const char *funcName = "addIconLine";
+ CLuaIHM::checkArgCount(ls, funcName, 5);
+ CLuaIHM::checkArgTypeUCString(ls, funcName, 1);
+ CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
+ CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING);
+ CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING);
+ CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING);
+ ucstring arg1;
+ nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1));
+ addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5));
+ return 0;
+ }
+
// ------------------------------------------------------------------------------------------------
int CGroupSubMenu::luaAddLineAtIndex(CLuaState &ls)
{
diff --git a/code/nel/src/gui/view_pointer_base.cpp b/code/nel/src/gui/view_pointer_base.cpp
index f0cf3b6bb..9589afd9c 100644
--- a/code/nel/src/gui/view_pointer_base.cpp
+++ b/code/nel/src/gui/view_pointer_base.cpp
@@ -80,16 +80,39 @@ namespace NLGUI
{
_PointerDown = pd;
- if (_PointerDown == true)
+ if (_PointerDown)
{
_PointerDownX = _PointerX;
_PointerDownY = _PointerY;
}
-
- if (_PointerDown == false)
+ else
_PointerDrag = false;
}
+ // --------------------------------------------------------------------------------------------------------------------
+ void CViewPointerBase::setPointerMiddleDown (bool pd)
+ {
+ _PointerMiddleDown = pd;
+
+ if (_PointerMiddleDown)
+ {
+ _PointerMiddleDownX = _PointerX;
+ _PointerMiddleDownY = _PointerY;
+ }
+ }
+
+ // --------------------------------------------------------------------------------------------------------------------
+ void CViewPointerBase::setPointerRightDown (bool pd)
+ {
+ _PointerRightDown = pd;
+
+ if (_PointerRightDown)
+ {
+ _PointerRightDownX = _PointerX;
+ _PointerRightDownY = _PointerY;
+ }
+ }
+
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDownString (const std::string &s)
{
@@ -120,16 +143,30 @@ namespace NLGUI
}
// --------------------------------------------------------------------------------------------------------------------
- void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y)
+ bool CViewPointerBase::getPointerDown (sint32 &x, sint32 &y)
{
x = _PointerDownX;
y = _PointerDownY;
+
+ return _PointerDown;
}
// --------------------------------------------------------------------------------------------------------------------
- bool CViewPointerBase::getPointerDown ()
+ bool CViewPointerBase::getPointerMiddleDown (sint32 &x, sint32 &y)
{
- return _PointerDown;
+ x = _PointerMiddleDownX;
+ y = _PointerMiddleDownY;
+
+ return _PointerMiddleDown;
+ }
+
+ // --------------------------------------------------------------------------------------------------------------------
+ bool CViewPointerBase::getPointerRightDown (sint32 &x, sint32 &y)
+ {
+ x = _PointerRightDownX;
+ y = _PointerRightDownY;
+
+ return _PointerRightDown;
}
// --------------------------------------------------------------------------------------------------------------------
diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml b/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml
index 6fdb5d32a..58f41d919 100644
--- a/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml
+++ b/code/ryzom/client/data/gamedev/interfaces_v3/commands.xml
@@ -63,9 +63,15 @@
+
+
+
+
+
+
diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/json.lua b/code/ryzom/client/data/gamedev/interfaces_v3/json.lua
new file mode 100644
index 000000000..70d8c4413
--- /dev/null
+++ b/code/ryzom/client/data/gamedev/interfaces_v3/json.lua
@@ -0,0 +1,376 @@
+--
+-- json.lua
+--
+-- Copyright (c) 2015 rxi
+--
+-- This library is free software; you can redistribute it and/or modify it
+-- under the terms of the MIT license. See LICENSE for details.
+--
+
+Json = { _version = "0.1.0" }
+
+-------------------------------------------------------------------------------
+-- Encode
+-------------------------------------------------------------------------------
+
+local encode
+
+local escape_char_map = {
+ [ "\\" ] = "\\\\",
+ [ "\"" ] = "\\\"",
+ [ "\b" ] = "\\b",
+ [ "\f" ] = "\\f",
+ [ "\n" ] = "\\n",
+ [ "\r" ] = "\\r",
+ [ "\t" ] = "\\t",
+}
+
+local escape_char_map_inv = { [ "\\/" ] = "/" }
+for k, v in pairs(escape_char_map) do
+ escape_char_map_inv[v] = k
+end
+
+
+local function escape_char(c)
+ return escape_char_map[c] or string.format("\\u%04x", c:byte())
+end
+
+
+local function encode_nil(val)
+ return "null"
+end
+
+
+local function encode_table(val, stack)
+ local res = {}
+ stack = stack or {}
+
+ -- Circular reference?
+ if stack[val] then error("circular reference") end
+
+ stack[val] = true
+
+ if val[1] ~= nil or next(val) == nil then
+ -- Treat as array -- check keys are valid and it is not sparse
+ local n = 0
+ for k in pairs(val) do
+ if type(k) ~= "number" then
+ error("invalid table: mixed or invalid key types")
+ end
+ n = n + 1
+ end
+ if n ~= #val then
+ error("invalid table: sparse array")
+ end
+ -- Encode
+ for i, v in ipairs(val) do
+ table.insert(res, encode(v, stack))
+ end
+ stack[val] = nil
+ return "[" .. table.concat(res, ",") .. "]"
+
+ else
+ -- Treat as an object
+ for k, v in pairs(val) do
+ if type(k) ~= "string" then
+ error("invalid table: mixed or invalid key types")
+ end
+ table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
+ end
+ stack[val] = nil
+ return "{" .. table.concat(res, ",") .. "}"
+ end
+end
+
+
+local function encode_string(val)
+ return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"'
+end
+
+
+local function encode_number(val)
+ -- Check for NaN, -inf and inf
+ if val ~= val or val <= -math.huge or val >= math.huge then
+ error("unexpected number value '" .. tostring(val) .. "'")
+ end
+ return string.format("%.3f", val)
+end
+
+local type_func_map = {
+ [ "nil" ] = encode_nil,
+ [ "table" ] = encode_table,
+ [ "string" ] = encode_string,
+ [ "number" ] = encode_number,
+ [ "boolean" ] = tostring,
+}
+
+
+encode = function(val, stack)
+ local t = type(val)
+ local f = type_func_map[t]
+ if f then
+ return f(val, stack)
+ end
+ error("unexpected type '" .. t .. "'")
+end
+
+
+function Json.encode(val)
+ return ( encode(val) )
+end
+
+
+-------------------------------------------------------------------------------
+-- Decode
+-------------------------------------------------------------------------------
+
+local parse
+
+local function create_set(...)
+ local res = {}
+ for i = 1, select("#", ...) do
+ res[ select(i, ...) ] = true
+ end
+ return res
+end
+
+local space_chars = create_set(" ", "\t", "\r", "\n")
+local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",")
+local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u")
+local literals = create_set("true", "false", "null")
+
+local literal_map = {
+ [ "true" ] = true,
+ [ "false" ] = false,
+ [ "null" ] = nil,
+}
+
+
+local function next_char(str, idx, set, negate)
+ for i = idx, #str do
+ if set[str:sub(i, i)] ~= negate then
+ return i
+ end
+ end
+ return #str + 1
+end
+
+
+local function decode_error(str, idx, msg)
+ local line_count = 1
+ local col_count = 1
+ for i = 1, idx - 1 do
+ col_count = col_count + 1
+ if str:sub(i, i) == "\n" then
+ line_count = line_count + 1
+ col_count = 1
+ end
+ end
+ error( string.format("%s at line %d col %d", msg, line_count, col_count) )
+end
+
+
+local function codepoint_to_utf8(n)
+ -- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa
+ local f = math.floor
+ if n <= 0x7f then
+ return string.char(n)
+ elseif n <= 0x7ff then
+ return string.char(f(n / 64) + 192, n % 64 + 128)
+ elseif n <= 0xffff then
+ return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128)
+ elseif n <= 0x10ffff then
+ return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128,
+ f(n % 4096 / 64) + 128, n % 64 + 128)
+ end
+ error( string.format("invalid unicode codepoint '%x'", n) )
+end
+
+
+local function parse_unicode_escape(s)
+ local n1 = tonumber( s:sub(3, 6), 16 )
+ local n2 = tonumber( s:sub(9, 12), 16 )
+ -- Surrogate pair?
+ if n2 then
+ return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000)
+ else
+ return codepoint_to_utf8(n1)
+ end
+end
+
+
+local function parse_string(str, i)
+ local has_unicode_escape = false
+ local has_surrogate_escape = false
+ local has_escape = false
+ local last
+ for j = i + 1, #str do
+ local x = str:byte(j)
+
+ if x < 32 then
+ decode_error(str, j, "control character in string")
+ end
+
+ if last == 92 then -- "\\" (escape char)
+ if x == 117 then -- "u" (unicode escape sequence)
+ local hex = str:sub(j + 1, j + 5)
+ if not hex:find("%x%x%x%x") then
+ decode_error(str, j, "invalid unicode escape in string")
+ end
+ if hex:find("^[dD][89aAbB]") then
+ has_surrogate_escape = true
+ else
+ has_unicode_escape = true
+ end
+ else
+ local c = string.char(x)
+ if not escape_chars[c] then
+ decode_error(str, j, "invalid escape char '" .. c .. "' in string")
+ end
+ has_escape = true
+ end
+ last = nil
+
+ elseif x == 34 then -- '"' (end of string)
+ local s = str:sub(i + 1, j - 1)
+ if has_surrogate_escape then
+ s = s:gsub("\\u[dD][89aAbB]..\\u....", parse_unicode_escape)
+ end
+ if has_unicode_escape then
+ s = s:gsub("\\u....", parse_unicode_escape)
+ end
+ if has_escape then
+ s = s:gsub("\\.", escape_char_map_inv)
+ end
+ return s, j + 1
+
+ else
+ last = x
+ end
+ end
+ decode_error(str, i, "expected closing quote for string")
+end
+
+
+local function parse_number(str, i)
+ local x = next_char(str, i, delim_chars)
+ local s = str:sub(i, x - 1)
+ local n = tonumber(s)
+ if not n then
+ decode_error(str, i, "invalid number '" .. s .. "'")
+ end
+ return n, x
+end
+
+
+local function parse_literal(str, i)
+ local x = next_char(str, i, delim_chars)
+ local word = str:sub(i, x - 1)
+ if not literals[word] then
+ decode_error(str, i, "invalid literal '" .. word .. "'")
+ end
+ return literal_map[word], x
+end
+
+
+local function parse_array(str, i)
+ local res = {}
+ local n = 1
+ i = i + 1
+ while 1 do
+ local x
+ i = next_char(str, i, space_chars, true)
+ -- Empty / end of array?
+ if str:sub(i, i) == "]" then
+ i = i + 1
+ break
+ end
+ -- Read token
+ x, i = parse(str, i)
+ res[n] = x
+ n = n + 1
+ -- Next token
+ i = next_char(str, i, space_chars, true)
+ local chr = str:sub(i, i)
+ i = i + 1
+ if chr == "]" then break end
+ if chr ~= "," then decode_error(str, i, "expected ']' or ','") end
+ end
+ return res, i
+end
+
+
+local function parse_object(str, i)
+ local res = {}
+ i = i + 1
+ while 1 do
+ local key, val
+ i = next_char(str, i, space_chars, true)
+ -- Empty / end of object?
+ if str:sub(i, i) == "}" then
+ i = i + 1
+ break
+ end
+ -- Read key
+ if str:sub(i, i) ~= '"' then
+ decode_error(str, i, "expected string for key")
+ end
+ key, i = parse(str, i)
+ -- Read ':' delimiter
+ i = next_char(str, i, space_chars, true)
+ if str:sub(i, i) ~= ":" then
+ decode_error(str, i, "expected ':' after key")
+ end
+ i = next_char(str, i + 1, space_chars, true)
+ -- Read value
+ val, i = parse(str, i)
+ -- Set
+ res[key] = val
+ -- Next token
+ i = next_char(str, i, space_chars, true)
+ local chr = str:sub(i, i)
+ i = i + 1
+ if chr == "}" then break end
+ if chr ~= "," then decode_error(str, i, "expected '}' or ','") end
+ end
+ return res, i
+end
+
+
+local char_func_map = {
+ [ '"' ] = parse_string,
+ [ "0" ] = parse_number,
+ [ "1" ] = parse_number,
+ [ "2" ] = parse_number,
+ [ "3" ] = parse_number,
+ [ "4" ] = parse_number,
+ [ "5" ] = parse_number,
+ [ "6" ] = parse_number,
+ [ "7" ] = parse_number,
+ [ "8" ] = parse_number,
+ [ "9" ] = parse_number,
+ [ "-" ] = parse_number,
+ [ "t" ] = parse_literal,
+ [ "f" ] = parse_literal,
+ [ "n" ] = parse_literal,
+ [ "[" ] = parse_array,
+ [ "{" ] = parse_object,
+}
+
+
+parse = function(str, idx)
+ local chr = str:sub(idx, idx)
+ local f = char_func_map[chr]
+ if f then
+ return f(str, idx)
+ end
+ decode_error(str, idx, "unexpected character '" .. chr .. "'")
+end
+
+
+function Json.decode(str)
+ if type(str) ~= "string" then
+ error("expected argument of type string, got " .. type(str))
+ end
+ return ( parse(str, next_char(str, 1, space_chars, true)) )
+end
diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/ryzhome_toolbar.lua b/code/ryzom/client/data/gamedev/interfaces_v3/ryzhome_toolbar.lua
new file mode 100644
index 000000000..21b035f48
--- /dev/null
+++ b/code/ryzom/client/data/gamedev/interfaces_v3/ryzhome_toolbar.lua
@@ -0,0 +1,242 @@
+RyzhomeBar = {
+ id = "ui:interface:webig_ryzhome_toolbar",
+ saveuri = "http://app.ryzom.com/app_ryzhome/index.php?action=toolbar_save",
+ selectedPage = 1
+}
+
+function RyzhomeBar:close()
+ getUI("ui:interface:webig_ryzhome_toolbar").active=false
+ self:saveConfig()
+
+end
+
+function RyzhomeBar:addItems()
+ local url = "http://app.ryzom.com/app_arcc/index.php?action=player_ryzhome_LuaListItems&command=add"
+ getUI("ui:interface:web_transactions:content:html"):browse(url)
+end
+
+function RyzhomeBar:moveItems()
+ local url = "http://app.ryzom.com/app_arcc/index.php?action=player_ryzhome_LuaListItems&command=move"
+ getUI("ui:interface:web_transactions:content:html"):browse(url)
+end
+
+function RyzhomeBar:removeItems()
+ local url = "http://app.ryzom.com/app_arcc/index.php?action=player_ryzhome_LuaListItems&command=remove"
+ getUI("ui:interface:web_transactions:content:html"):browse(url)
+end
+
+function RyzhomeBar:inviteFriend()
+ local url = "http://app.ryzom.com/app_arcc/index.php?action=player_ryzhome_InviteFriend"
+ getUI("ui:interface:web_transactions:content:html"):browse(url)
+end
+
+function RyzhomeBar:listFriends()
+ getUI("ui:interface:web_transactions:content:html"):browse(RyzhomeBar.listFriendsUrl)
+ getUI("ui:interface:web_transactions:header_opened:browse_undo").active=false
+ getUI("ui:interface:web_transactions:header_opened:browse_redo").active=false
+ getUI("ui:interface:web_transactions:header_opened:browse_refresh").active=false
+ getUI("ui:interface:web_transactions:header_opened:browse_home").active=false
+ local wt = getUI("ui:interface:web_transactions")
+ wt.w=316
+ wt.h=420
+ wt.pop_min_w=316
+ wt.pop_max_w=316
+ wt.pop_min_h=420
+ wt.pop_max_h=420
+
+ local framewin = getUI("ui:interface:webig_ryzhome_list_item")
+ if framewin ~= nil then
+ framewin.active=false
+ wt.x = framewin.x
+ wt.y = framewin.y
+ end
+
+ getUI("ui:interface:web_transactions").active=true
+
+ setOnDraw(getUI("ui:interface:web_transactions"), "RyzhomeBar:autocloseWebTransactions()")
+end
+
+function RyzhomeBar:autocloseWebTransactions()
+ local current_url = getUI("ui:interface:web_transactions:content:html").url
+ if (current_url ~= RyzhomeBar.listFriendsUrl and current_url ~= inviteFriendsUrl) then
+ local framewin = getUI("ui:interface:webig_ryzhome_list_item")
+ framewin.x = getUI("ui:interface:web_transactions").x
+ framewin.y = getUI("ui:interface:web_transactions").y
+ getUI("ui:interface:web_transactions").active=false
+ setOnDraw(getUI("ui:interface:web_transactions"), "")
+ end
+end
+
+
+function RyzhomeBar:serialize()
+ local ui = getUI(self.id)
+ local url = "&posx=" .. tostring(ui.x) .. "&posy=" .. tostring(ui.y)
+ return url
+end
+
+function RyzhomeBar:updateNbrItems(offset)
+ RyzhomeBar.nbrItems = RyzhomeBar.nbrItems + offset
+ if RyzhomeBar.nbrItems == 0 then
+ getUI("ui:interface:webig_ryzhome_toolbar:content:new_items_quantity").hardtext=""
+ else
+ getUI("ui:interface:webig_ryzhome_toolbar:content:new_items_quantity").hardtext=tostring(RyzhomeBar.nbrItems)
+ end
+end
+
+function RyzhomeBar:saveConfig()
+ local url = self.saveuri .. self:serialize()
+ getUI("ui:interface:web_transactions:content:html"):browse(url)
+end
+
+function RyzhomeBar:movePage(offset)
+ RyzhomeBar.selectedPage = RyzhomeBar.selectedPage + offset
+ if RyzhomeBar.selectedPage <= 0 then
+ RyzhomeBar.selectedPage = 1
+ elseif RyzhomeBar.selectedPage > RyzhomeBar.nbrPages then
+ RyzhomeBar.selectedPage = RyzhomeBar.nbrPages
+ end
+ getUI("ui:interface:webig_ryzhome_list_item:header_opened:page").hardtext=tostring(RyzhomeBar.selectedPage).." / "..tostring(RyzhomeBar.nbrPages)
+ RyzhomeBar:setupItems()
+end
+
+function RyzhomeBar:listItems()
+ RyzhomeBar.recently_removed_item = false
+
+ local framewin = getUI("ui:interface:webig_ryzhome_list_item")
+ --framewin.opened=true
+ framewin.active=true
+ if framewin.x == 0 and framewin.y == 0 then
+ local ui = getUI("ui:interface")
+ framewin.x = (ui.w - framewin.w) / 2
+ framewin.y = (ui.h + framewin.h) / 2
+ end
+
+ if RyzhomeBar.Items == nil then
+ RyzhomeBar.Items = {}
+ end
+end
+
+function RyzhomeBar:useItem(id)
+ id = tostring(RyzhomeBar.Items[RyzhomeBar.selectedPage][id][1])
+ if RyzhomeBar.itemCommand == "add" then
+ RyzhomeBar:addItem(id)
+ elseif RyzhomeBar.itemCommand == "remove" then
+ RyzhomeBar:removeItem(id)
+ elseif RyzhomeBar.itemCommand == "move" then
+ RyzhomeBar:moveItem(id)
+ end
+end
+
+function RyzhomeBar:addItem(id)
+ local url = "http://app.ryzom.com/app_arcc/index.php?action=player_ryzhome_Place&command=add&id="..id
+ getUI("ui:interface:web_transactions:content:html"):browse(url)
+end
+
+function RyzhomeBar:removeItem(id)
+ RyzhomeBar.recently_removed_item = true
+ RyzhomeBar:spawnItems()
+ local v = RyzhomeBar.spawnedItems[id]
+ runAH(nil,"add_shape", "shape=sp_mort.ps|x="..v[2].."|y="..v[3].."|z="..v[4].."|angle="..v[5].."|scale="..tostring(tonumber(v[6])*4)..v[7]..v[8]..v[9])
+ local url = "http://app.ryzom.com/app_arcc/index.php?action=player_ryzhome_Remove&id="..id
+ getUI("ui:interface:web_transactions:content:html"):browse(url)
+end
+
+function RyzhomeBar:moveItem(id)
+ local url = "http://app.ryzom.com/app_arcc/index.php?action=player_ryzhome_Place&command=move&id="..id
+ getUI("ui:interface:web_transactions:content:html"):browse(url)
+end
+
+function RyzhomeBar:highlightItem(id)
+ if RyzhomeBar.itemCommand == "add" then
+ return
+ end
+ if RyzhomeBar.recently_removed_item then
+ RyzhomeBar.recently_removed_item = false
+ else
+ RyzhomeBar:spawnItems()
+ local v = RyzhomeBar.spawnedItems[tostring(RyzhomeBar.Items[RyzhomeBar.selectedPage][id][1])]
+ if v then
+ runAH(nil, "add_shape", "shape=ma_acc_ascenseur.ps|x="..v[2].."|y="..v[3].."|z="..v[4].."|angle="..v[5].."|scale="..tostring(tonumber(v[6])*2)..v[7]..v[8]..v[9])
+ end
+ end
+end
+
+function RyzhomeBar:callFriendUrl(action, target)
+ local url = "http://app.ryzom.com/app_arcc/index.php?action=player_ryzhome_"..action.."&target="..target
+ getUI("ui:interface:web_transactions:content:html"):browse(url)
+end
+
+function RyzhomeBar:spawnItems()
+ runAH(nil, "remove_shapes", "")
+ for k,v in pairs(RyzhomeBar.spawnedItems) do
+ runAH(nil, "add_shape", "shape="..v[1].."|x="..v[2].."|y="..v[3].."|z="..v[4].."|angle="..v[5].."|scale="..v[6]..v[7]..v[8]..v[9])
+ end
+
+end
+
+function RyzhomeBar:setupItems()
+ for k = 1, 8 do
+ getUI("ui:interface:webig_ryzhome_list_item:header_opened"):find(":but"..tostring(k)).active=false
+ getUI("ui:interface:webig_ryzhome_list_item:header_opened"):find(":icon"..tostring(k)).active=false
+ getUI("ui:interface:webig_ryzhome_list_item:header_opened"):find(":text"..tostring(k)).uc_hardtext=""
+ getUI("ui:interface:webig_ryzhome_list_item:header_opened"):find(":info"..tostring(k)).uc_hardtext=""
+ end
+ for k,v in pairs(RyzhomeBar.Items[RyzhomeBar.selectedPage]) do
+ if k ~= nil then
+ getUI("ui:interface:webig_ryzhome_list_item:header_opened"):find(":icon"..tostring(k)).active=true
+ getUI("ui:interface:webig_ryzhome_list_item:header_opened"):find(":but"..tostring(k)).active=true
+ local text = ucstring()
+ text:fromUtf8(v[3])
+ getUI("ui:interface:webig_ryzhome_list_item:header_opened"):find(":text"..tostring(k)).uc_hardtext=text
+ text:fromUtf8(v[4])
+ getUI("ui:interface:webig_ryzhome_list_item:header_opened"):find(":info"..tostring(k)).uc_hardtext=text
+ end
+ end
+end
+
+if RyzhomePlace == nil then
+ RyzhomePlace = {
+ saveuri = "",
+ }
+end
+
+function RyzhomePlace:move(x, y, z)
+ pos_x=pos_x+x
+ pos_y=pos_y+y
+ pos_z=pos_z+z
+ RyzhomePlace:update()
+end
+
+function RyzhomePlace:rot(a)
+ pos_a=pos_a+a
+ RyzhomePlace:update()
+end
+
+function RyzhomePlace:reset()
+ --Ryzhome:addShapes()
+ pos_x, pos_y, pos_z = getPlayerPos()
+ pos_a = (3.14*getUI("ui:interface:compass:arrow3d:arrow").rotz)/18
+ RyzhomePlace:addShape()
+ RyzhomeBar:spawnItems()
+end
+
+function RyzhomePlace:update()
+ RyzhomePlace:addShapes()
+ RyzhomePlace:addShape()
+ RyzhomeBar:spawnItems()
+end
+
+function RyzhomePlace:apply()
+ getUI("ui:interface:web_transactions:content:html"):browse(RyzhomePlace.saveuri.."&pos_x="..pos_x.."&pos_y="..pos_y.."&pos_z="..pos_z.."&pos_a="..pos_a)
+end
+
+function RyzhomePlace:close()
+ --runAH(nil, "remove_shapes", "")
+ getUI("ui:interface:webig_ryzhome_place_item").active=false
+end
+
+function debug(text)
+ local uc = ucstring()
+ uc:fromUtf8(tostring(text))
+ displaySystemInfo(ucstring(uc), "sys")
+end
diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/ryzhome_toolbar.xml b/code/ryzom/client/data/gamedev/interfaces_v3/ryzhome_toolbar.xml
new file mode 100644
index 000000000..ef470005c
--- /dev/null
+++ b/code/ryzom/client/data/gamedev/interfaces_v3/ryzhome_toolbar.xml
@@ -0,0 +1,445 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/sceneedit.lua b/code/ryzom/client/data/gamedev/interfaces_v3/sceneedit.lua
new file mode 100644
index 000000000..e0285da86
--- /dev/null
+++ b/code/ryzom/client/data/gamedev/interfaces_v3/sceneedit.lua
@@ -0,0 +1,590 @@
+--- Parse interface of ark_scene_editor_edit_menu ---
+local script = [[
+
+
+]]
+parseInterfaceFromString(script)
+
+
+if SceneEditor == nil then
+ SceneEditor = {
+ Shapes = {},
+ Groups = {},
+ LastEditedGroup = nil,
+ HaveUpdate = nil
+
+ };
+end
+
+
+function debug(text)
+ local message = ucstring()
+ message:fromUtf8(tostring(text))
+ displaySystemInfo(message, "SYS")
+end
+
+
+function SceneEditor:init(scene_id, form_url, translations, icons_url)
+ self.sceneId = scene_id
+ self.baseUrl = form_url
+ self.iconsUrl = icons_url
+ self.T = translations
+end
+
+function SceneEditor:reset()
+ self.Shapes = {}
+ self.Groups = {}
+ self.LastEditedGroup = nil
+ self.HaveUpdate = nil
+ runAH(nil, "remove_shapes", "")
+ self:get_html("Reseted")
+end
+
+function SceneEditor:show_menu()
+ if (rightClick) then
+ SceneEditor:launch_menu()
+ end
+end
+
+
+function SceneEditor:launch_menu(id)
+ -- SelectedInstanceId can be set by client application
+ if id ~= nil then
+ SelectedInstanceId = id
+ end
+ local menu = getUI("ui:interface:ark_scene_editor_edit_menu")
+ menu:setMinW(85)
+ menu:updateCoords()
+ menu = menu:getRootMenu()
+ menu:reset()
+ menu:addLine(ucstring("-- SHAPE EDITION --"), "", "", "shape_header")
+ menu:addLine(ucstring("Move"), "", "", "shape_move")
+ menu:addSubMenu(1)
+ local subMenu = menu:getSubMenu(1)
+ subMenu:addIconLine(ucstring("Axe X"), "lua", "setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:move_x()')", "shape_move_x", "ark_move_x.tga")
+ subMenu:addIconLine(ucstring("Axe Y"), "lua", "setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:move_y()')", "shape_move_y", "ark_move_y.tga")
+ subMenu:addIconLine(ucstring("Axe Z"), "lua", "x, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:move_z()')", "shape_move_z", "ark_move_z.tga")
+ subMenu:addIconLine(ucstring("Axes X & Y"), "lua", "setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:move_xy()')", "shape_move_xy", "ark_move_xy.tga")
+ subMenu:addIconLine(ucstring("Axes X & Y Snap to ground"), "lua", "setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:move_xysnap()')", "shape_move_xy_snap", "ark_move_xysnap.tga")
+ subMenu:addSeparator()
+ subMenu:addIconLine(ucstring("Move to player"), "lua", "SceneEditor:move_player()", "shape_move_player", "ark_move_player.tga")
+
+ menu:addLine(ucstring("Rotate"), "", "", "shape_rotate")
+ menu:addSubMenu(2)
+ subMenu = menu:getSubMenu(2)
+ subMenu:addIconLine(ucstring("Axe X"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:rotate(SelectedInstanceId, \"x\")')", "shape_rotate_x", "ark_rotate_x.tga")
+ subMenu:addIconLine(ucstring("Axe Y"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:rotate(SelectedInstanceId, \"y\")')", "shape_rotate_y", "ark_rotate_y.tga")
+ subMenu:addIconLine(ucstring("Axe Z"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:rotate(SelectedInstanceId, \"z\")')", "shape_rotate_z", "ark_rotate_z.tga")
+
+ menu:addLine(ucstring("Scale"), "", "", "shape_scale")
+ menu:addSubMenu(3)
+ subMenu = menu:getSubMenu(3)
+ subMenu:addIconLine(ucstring("Axe X"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:scale(SelectedInstanceId, \"x\")')", "shape_scale_x", "ark_scale_x.tga")
+ subMenu:addIconLine(ucstring("Axe Y"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:scale(SelectedInstanceId, \"y\")')", "shape_scale_y", "ark_scale_y.tga")
+ subMenu:addIconLine(ucstring("Axe Z"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:scale(SelectedInstanceId, \"z\")')", "shape_scale_z", "ark_scale_z.tga")
+
+ menu:addLine(ucstring("-- COLLISION EDITION --"), "", "", "col_header")
+ menu:addLine(ucstring("Move"), "", "", "col_move")
+ menu:addSubMenu(5)
+ subMenu = menu:getSubMenu(5)
+ subMenu:addIconLine(ucstring("Axe X"), "lua", "setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:col_move_x()')", "col_move_x", "ark_move_x.tga")
+ subMenu:addIconLine(ucstring("Axe Y"), "lua", "setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:col_move_y()')", "col_move_y", "ark_move_y.tga")
+ subMenu:addIconLine(ucstring("Axe Z"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:col_move_z()')", "col_move_z", "ark_move_xy.tga")
+ subMenu:addIconLine(ucstring("Axe X & Y"), "lua", "setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:col_move_xy()')", "col_move_xy", "ark_move_xy.tga")
+ subMenu:addSeparator()
+ subMenu:addIconLine(ucstring("Move to Shape"), "lua", "SceneEditor:col_move_to_shape()", "col_move_to_shape", "ark_move_player.tga")
+
+ menu:addIconLine(ucstring("Rotate"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:col_rotate(SelectedInstanceId, \"x\")')", "col_rotate_x", "ark_rotate_x.tga")
+
+ menu:addLine(ucstring("Scale"), "", "", "col_scale")
+ menu:addSubMenu(7)
+ subMenu = menu:getSubMenu(7)
+ subMenu:addIconLine(ucstring("Axe X"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:col_scale(SelectedInstanceId, \"x\")')", "col_scale_x", "ark_scale_x.tga")
+ subMenu:addIconLine(ucstring("Axe Y"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:col_scale(SelectedInstanceId, \"y\")')", "col_scale_y", "ark_scale_y.tga")
+ subMenu:addIconLine(ucstring("Axe Z"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI('ui:interface:ark_scene_editor'), 'SceneEditor:col_scale(SelectedInstanceId, \"z\")')", "col_scale_z", "ark_scale_z.tga")
+
+ launchContextMenuInGame("ui:interface:ark_scene_editor_edit_menu")
+end
+
+
+function arcc_tools_check_rclick()
+ root = getUI("ui:interface")
+ local rx, ry = getMousePos()
+ i_id = getShapeIdAt(rx, ry)
+ if i_id >= 0 then
+ setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
+ end
+end
+
+function SceneEditor:move(id, axe)
+ local d, mx, my = getMouseDown()
+ if d then
+ setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
+ SceneEditor:set_modified(id)
+ self:get_html("Moved")
+ else
+ local x,y,z = getGroundAtMouse()
+ if axe == "x" then moveShape(id, tostring(x), "+0", "+0") end
+ if axe == "y" then moveShape(id, "+0", tostring(y), "+0") end
+ if axe == "z" then
+ mx, my = getMousePos()
+ moveShape(id, "+0", "+0", "+"..tostring((my-ARK_SHAPE_LATEST_Y)/100))
+ ARK_SHAPE_LATEST_Y = my
+ end
+ if axe == "xysnap" then moveShape(id, tostring(x), tostring(y), tostring(z)) end
+ if axe == "xy" then moveShape(id, tostring(x), tostring(y), "+0") end
+ if axe == "player" then
+ x, y, z = getPlayerPos()
+ moveShape(id, tostring(x), tostring(y), tostring(z))
+ SceneEditor:set_modified(id)
+ self:get_html("Moved to player")
+ end
+
+ end
+end
+
+function SceneEditor:rotate(id, axe)
+ local d, mx, my = getMouseDown()
+ if d then
+ setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
+ SceneEditor:set_modified(id)
+ self:get_html("Rotate")
+ else
+ mx, my = getMousePos()
+ if axe == "x" then rotateShape(id, "+"..tostring((my-ARK_SHAPE_LATEST_Y)/100), "+0", "+0") end
+ if axe == "y" then rotateShape(id, "+0", "+"..tostring((my-ARK_SHAPE_LATEST_Y)/100), "+0") end
+ if axe == "z" then rotateShape(id, "+0", "+0", "+"..tostring((mx-ARK_SHAPE_LATEST_X)/100)) end
+ ARK_SHAPE_LATEST_X = mx
+ ARK_SHAPE_LATEST_Y = my
+ end
+end
+
+function SceneEditor:scale(id, axe)
+ local d, mx, my = getMouseDown()
+ if d then
+ setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
+ SceneEditor:set_modified(id)
+ self:get_html("Rotate")
+ else
+ mx, my = getMousePos()
+ local setup = {}
+ if axe == "x" then setup["scale x"]="+"..tostring((mx-ARK_SHAPE_LATEST_X)/100) end
+ if axe == "y" then setup["scale y"]="+"..tostring((mx-ARK_SHAPE_LATEST_X)/100) end
+ if axe == "z" then setup["scale z"]="+"..tostring((my-ARK_SHAPE_LATEST_Y)/100) end
+ setupShape(id, setup)
+ ARK_SHAPE_LATEST_X = mx
+ ARK_SHAPE_LATEST_Y = my
+ end
+end
+
+
+function SceneEditor:move_x()
+ self:move(SelectedInstanceId, "x")
+end
+
+function SceneEditor:move_y()
+ self:move(SelectedInstanceId, "y")
+end
+
+function SceneEditor:move_xy()
+ self:move(SelectedInstanceId, "xy")
+end
+
+function SceneEditor:move_xysnap()
+ self:move(SelectedInstanceId, "xysnap")
+end
+
+function SceneEditor:move_z()
+ self:move(SelectedInstanceId, "z")
+end
+
+function SceneEditor:move_player()
+ self:move(SelectedInstanceId, "player")
+end
+
+
+function SceneEditor:col_move(id, axe)
+ local d, mx, my = getMouseDown()
+
+ if d then
+ setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
+ self:set_modified(id)
+ self:get_html("Updated")
+ else
+ local x,y,z = getGroundAtMouse()
+ local setup = {}
+ if axe == "x" then setup["col pos x"]=tostring(x) end
+ if axe == "y" then setup["col pos y"]=tostring(y) end
+ if axe == "z" then
+ mx, my = getMousePos()
+ setup["col pos z"]="+"..tostring((my-ARK_SHAPE_LATEST_Y)/100)
+ ARK_SHAPE_LATEST_X = mx
+ ARK_SHAPE_LATEST_Y = my
+ end
+ if axe == "xy" then setup["col pos x"]=tostring(x); setup["col pos y"]=tostring(y) end
+ if axe == "shape" then
+ x, y, z = getShapePos(id)
+ setup["col pos x"]=tostring(x)
+ setup["col pos y"]=tostring(y)
+ self:set_modified(id)
+ setupShape(id, setup)
+ self:get_html("Updated")
+ else
+ setupShape(id, setup)
+ end
+ end
+end
+
+function SceneEditor:col_rotate(id, axe)
+ local d, mx, my = getMouseDown()
+ if d then
+ setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
+ SceneEditor:set_modified(id)
+ self:get_html("Rotate")
+ else
+ mx, my = getMousePos()
+ local setup = {}
+ setup["col orientation"]="+"..tostring((mx-ARK_SHAPE_LATEST_X)/100)
+ setupShape(id, setup)
+ ARK_SHAPE_LATEST_X = mx
+ ARK_SHAPE_LATEST_Y = my
+ end
+end
+
+
+
+function SceneEditor:col_scale(id, axe)
+ local d, mx, my = getMouseDown()
+ if d then
+ setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
+ SceneEditor:set_modified(id)
+ self:get_html("Rotate")
+ else
+ mx, my = getMousePos()
+ local setup = {}
+ if axe == "x" then setup["col size x"]="+"..tostring((mx-ARK_SHAPE_LATEST_X)/100) end
+ if axe == "y" then setup["col size y"]="+"..tostring((mx-ARK_SHAPE_LATEST_X)/100) end
+ if axe == "z" then setup["col size z"]="+"..tostring((my-ARK_SHAPE_LATEST_Y)/100) end
+ setupShape(id, setup)
+ ARK_SHAPE_LATEST_X = mx
+ ARK_SHAPE_LATEST_Y = my
+ end
+end
+
+
+function SceneEditor:set_modified(id)
+ self.Groups[self.Shapes[id].group].props.modified=true
+ self.Shapes[id].modified = "modified"
+ self.HaveUpdate = true
+end
+
+
+function SceneEditor:col_move_x()
+ self:col_move(SelectedInstanceId, "x")
+end
+
+function SceneEditor:col_move_y()
+ self:col_move(SelectedInstanceId, "y")
+end
+function SceneEditor:col_move_z()
+ self:col_move(SelectedInstanceId, "z")
+end
+
+
+function SceneEditor:col_move_xy()
+ self:col_move(SelectedInstanceId, "xy")
+end
+
+
+function SceneEditor:col_move_to_shape()
+ self:col_move(SelectedInstanceId, "shape")
+end
+
+
+function SceneEditor:setup_shape(shape_id, setup)
+ final_setup = self.Shapes[new_shape.id].setup
+ if final_setup == nil then
+ final_setup = {}
+ end
+ for k,v in pairs(setup) do
+ final_setup[k] = v
+ end
+ self.Shapes[new_shape.id].setup = final_setup
+ setupShape(shape_id, setup)
+end
+
+function SceneEditor:add(shape)
+ if self.LastEditedGroup == nil then
+ self:get_html(''..self.T["no_selected_group"]..'', '000000')
+ end
+ local new_shape = {}
+ new_shape.file = shape
+ new_shape.group = self.LastEditedGroup
+ self.Groups[new_shape.group].props.modified=true
+ new_shape.db_id = self.Groups[new_shape.group].props.count + 1
+ new_shape.modified = "added"
+ new_shape_id = addShape(shape, 0, 0, 0, "user", 1, true, "", "SceneEditor:show_menu()")
+ table.insert(self.Groups[new_shape.group], new_shape_id)
+ self.Groups[new_shape.group].props.count = self.Groups[new_shape.group].props.count + 1
+ self.Shapes[new_shape_id] = new_shape
+ self:get_html("Added")
+end
+
+
+function SceneEditor:removeShape(shape_id)
+ deleteShape(shape_id)
+ local group = self.Shapes[shape_id].group
+ for k,g_shape_id in pairs(self.Groups[group]) do
+ if shape_id == g_shape_id then
+ self.Groups[group][k] = nil
+ end
+ end
+ self:set_modified(shape_id)
+ self.Shapes[shape_id] = nil
+ self:get_html("Removed")
+end
+
+function SceneEditor:addGroup(name, count, show, edit)
+ if name == nil then
+ return
+ end
+ if self.Groups[name] == nil then
+ self.Groups[name] = {}
+ self.Groups[name].props = {}
+ self.Groups[name].props.count = count
+ self.Groups[name].props.show = show
+ self.Groups[name].props.edit = edit
+ self.Groups[name].props.modified = false
+ else
+ self.Groups[name].props.show = show
+ self.Groups[name].props.edit = edit
+ end
+end
+
+function SceneEditor:editGroup(group)
+ if self.LastEditedGroup then
+ self:removeGroup(self.LastEditedGroup)
+ self:addGroup(self.LastEditedGroup, 0, true, false)
+ end
+ self:removeGroup(group);
+ self:addGroup(group, 0, true, true)
+ self.LastEditedGroup = group
+end
+
+function SceneEditor:addFromDb(group, db_id, json_shape)
+ shape = Json.decode(json_shape)
+ shape.db_id = db_id
+
+ shape.group = group
+ shape.modified = ""
+ if hide then
+ shape_id = addShape(shape.file, shape.pos[1], shape.pos[2], shape.pos[3], "user", 1, false, "", "")
+ else
+ shape_id = addShape(shape.file, shape.pos[1], shape.pos[2], shape.pos[3], "user", 1, true, "", "SceneEditor:show_menu()")
+ end
+ rotateShape(shape_id, tostring(shape.rot[1]), tostring(shape.rot[2]), tostring(shape.rot[3]))
+ setupShape(shape_id, shape.setup)
+ self.Shapes[shape_id] = shape
+ table.insert(self.Groups[group], shape_id)
+ if db_id > self.Groups[group].props.count then
+ self.Groups[group].props.count = db_id
+ end
+end
+
+
+function SceneEditor:removeGroup(group)
+ if self.Groups[group] == nil then
+ return
+ end
+
+ for k,shape_id in pairs(self.Groups[group]) do
+ if k ~= "props" then
+ self.Shapes[shape_id] = nil
+ deleteShape(shape_id)
+ end
+ end
+ self.Groups[group] = nil
+ if self.LastEditedGroup == group then
+ self.LastEditedGroup = nil
+ local ui = getUI("ui:interface:ark_list_of_shapes")
+ if ui then
+ ui.active=false
+ end
+ end
+ self:get_html("Group Removed")
+end
+
+function SceneEditor:enc64(data)
+ local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
+ return ((data:gsub('.', function(x)
+ local r,b='',x:byte()
+ for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
+ return r;
+ end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
+ if (#x < 6) then return '' end
+ local c=0
+ for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
+ return b:sub(c+1,c+1)
+ end)..({ '', '==', '=' })[#data%3+1])
+end
+
+function SceneEditor:get_vector(x, y, z)
+ local vector = {}
+ table.insert(vector, x)
+ table.insert(vector, y)
+ table.insert(vector, z)
+
+ return vector
+end
+
+function SceneEditor:get_random_color()
+ local r = math.random(44, 66);
+ local g = math.random(44, 66);
+ local b = math.random(44, 66);
+ return '#'..tostring(r)..tostring(g)..tostring(b)
+
+end
+
+function pairsByKeys(t, f)
+ local a = {}
+ for n in pairs(t) do table.insert(a, n) end
+ table.sort(a, f)
+ local i = 0 -- iterator variable
+ local iter = function () -- iterator function
+ i = i + 1
+ if a[i] == nil then
+ return nil
+ else
+ return a[i], t[a[i]]
+ end
+ end
+ return iter
+end
+
+function SceneEditor:show_shape_list()
+ local ui = getUI("ui:interface:ark_list_of_shapes")
+ local need_setup = ui == nil
+ if need_setup then
+ WebBrowser:openWindow("ark_list_of_shapes", self.baseUrl..'_ListShapes')
+ ui = getUI("ui:interface:ark_list_of_shapes")
+ ui.pop_min_w = 400
+ ui.w = 400
+ getUI("ui:interface:ark_list_of_shapes:browser:header_opened:browse_redo").active=false
+ getUI("ui:interface:ark_list_of_shapes:browser:header_opened:browse_undo").active=false
+ getUI("ui:interface:ark_list_of_shapes:browser:header_opened:browse_refresh").active=false
+ getUI("ui:interface:ark_list_of_shapes:browser:header_opened:browse_home").active=false
+ else
+ ui.active = true
+ end
+end
+
+
+function SceneEditor:get_html_section(message, color)
+ return '
'
+end
+
+function SceneEditor:get_html(message, message_bg)
+ local new_group = ' '
+ local show_hide_cols = ' '
+ local reset_scene = ''
+
+ local html = ''..self.T["sceno_editor"]..''..self:get_html_section(message..' | '..new_group..show_hide_cols..reset_scene, (message_bg or SceneEditor:get_random_color()))
+
+ html = html .. ''
+ ui = getUI("ui:interface:ark_scene_editor:browser:content:html", false)
+ if ui then
+ ui:renderHtml(html)
+ end
+end
+
diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/webig_widgets.xml b/code/ryzom/client/data/gamedev/interfaces_v3/webig_widgets.xml
index 3c1470485..9392c94fe 100644
--- a/code/ryzom/client/data/gamedev/interfaces_v3/webig_widgets.xml
+++ b/code/ryzom/client/data/gamedev/interfaces_v3/webig_widgets.xml
@@ -4,6 +4,8 @@
+
+
diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp
index f907206fd..8fe4b4754 100644
--- a/code/ryzom/client/src/client_cfg.cpp
+++ b/code/ryzom/client/src/client_cfg.cpp
@@ -1058,7 +1058,7 @@ void CClientConfig::setValues()
/////////////////////////
// NEW PATCHING SYSTEM //
- READ_BOOL_DEV(PatchWanted)
+ READ_BOOL_FV(PatchWanted)
#ifdef RZ_USE_CUSTOM_PATCH_SERVER
READ_STRING_FV(PatchUrl)
diff --git a/code/ryzom/client/src/cursor_functions.cpp b/code/ryzom/client/src/cursor_functions.cpp
index 163d04ea3..8796d509a 100644
--- a/code/ryzom/client/src/cursor_functions.cpp
+++ b/code/ryzom/client/src/cursor_functions.cpp
@@ -59,6 +59,7 @@ CContextualCursor ContextCur;
CLFECOMMON::TCLEntityId SlotUnderCursor;
uint32 MissionId = 0;
uint32 MissionRingId = 0;
+sint32 InstanceId = 0;
UInstance selectedInstance;
const UInstance noSelectedInstance;
string selectedInstanceURL;
@@ -89,6 +90,7 @@ void contextExtractRM (bool rightClick, bool dblClick);
void contextMission (bool rightClick, bool dblClick);
void contextWebPage (bool rightClick, bool dblClick);
void contextWebIG (bool rightClick, bool dblClick);
+void contextARKitect (bool rightClick, bool dblClick);
void contextRingMission (bool rightClick, bool dblClick);
void contextOutpost (bool rightClick, bool dblClick);
void contextBuildTotem (bool rightClick, bool dblClick);
@@ -127,6 +129,7 @@ void initContextualCursor()
ContextCur.add(true, "MISSION", string(""), 0.0f, checkUnderCursor, contextMission);
ContextCur.add(true, "WEB PAGE", string(""), 0.0f, checkUnderCursor, contextWebPage);
ContextCur.add(true, "WEBIG", string(""), 0.0f, checkUnderCursor, contextWebIG);
+ ContextCur.add(false, "ARKITECT", string("curs_pick.tga"), 0.0f, checkUnderCursor, contextARKitect);
ContextCur.add(true, "OUTPOST", string(""), 0.0f, checkUnderCursor, contextOutpost);
ContextCur.add(true, "RING MISSION", string(""), 0.0f, checkUnderCursor, contextRingMission);
ContextCur.add(true, "BUILD_TOTEM", string("uimGcmChooseBuilding"), 0.0f, checkUnderCursor, contextBuildTotem);
@@ -530,10 +533,10 @@ void checkUnderCursor()
}
else
{
- CShapeInstanceReference instref = EntitiesMngr.getShapeInstanceUnderPos(cursX, cursY);
+ sint32 instance_idx;
+ CShapeInstanceReference instref = EntitiesMngr.getShapeInstanceUnderPos(cursX, cursY, instance_idx);
- bool cleanSelectedInstance = EntitiesMngr.instancesRemoved();
- if (cleanSelectedInstance)
+ if (EntitiesMngr.instancesRemoved())
selectedInstance = noSelectedInstance;
UInstance instance = instref.Instance;
@@ -556,9 +559,16 @@ void checkUnderCursor()
selectedInstance.getMaterial(j).setShininess( 1000.0f );
}
}
- if (!instref.ContextText.empty())
+
+ selectedInstanceURL = instref.ContextURL;
+ if (instref.ContextText.empty())
+ {
+ InstanceId = instance_idx;
+ if(ContextCur.context("ARKITECT", 0.f, ucstring()))
+ return;
+ }
+ else
{
- selectedInstanceURL = instref.ContextURL;
ucstring contextText;
contextText.fromUtf8(instref.ContextText);
if(ContextCur.context("WEBIG", 0.f, contextText))
@@ -879,6 +889,8 @@ void contextWebPage(bool rightClick, bool dblClick)
//-----------------------------------------------
void contextWebIG(bool rightClick, bool dblClick)
{
+ if(rightClick)
+ return;
CInterfaceManager *IM = CInterfaceManager::getInstance();
CInterfaceElement *pGC = CWidgetManager::getInstance()->getElementFromId("ui:interface:bot_chat_object");
CInterface3DShape *el= dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:bot_chat_object:scene3d:object_1"));
@@ -900,6 +912,24 @@ void contextWebIG(bool rightClick, bool dblClick)
}
}// contextWebIG //
+//-----------------------------------------------
+// contextARKitect :
+//-----------------------------------------------
+void contextARKitect(bool rightClick, bool dblClick)
+{
+ string header;
+ if (rightClick)
+ {
+ header = toString("rightClick = true\nSelectedInstanceId = %u\n", InstanceId);
+ } else {
+ header = toString("rightClick = false\nSelectedInstanceId = %u\n", InstanceId);
+ }
+
+ CLuaManager::getInstance().executeLuaScript(string(header)+selectedInstanceURL, true);
+
+}// contextARKitect //
+
+
//-----------------------------------------------
// contextOutpost
//-----------------------------------------------
diff --git a/code/ryzom/client/src/entities.cpp b/code/ryzom/client/src/entities.cpp
index 5deeb437c..cb324d2bc 100644
--- a/code/ryzom/client/src/entities.cpp
+++ b/code/ryzom/client/src/entities.cpp
@@ -43,6 +43,7 @@
#include "interface_v3/people_interraction.h"
#include "interface_v3/bar_manager.h"
#include "interface_v3/group_compas.h"
+#include "misc.h"
// 3D
#include "nel/3d/quad_tree.h"
// Interface 3D
@@ -65,11 +66,13 @@
#include "player_r2_cl.h"
#include "r2/editor.h"
+
///////////
// USING //
///////////
using namespace NLMISC;
using namespace NL3D;
+using namespace NLPACS;
using namespace std;
#ifdef DEBUG_NEW
@@ -403,6 +406,7 @@ CEntityManager::CEntityManager()
_NbPlayer = 0;
_NbChar = 0;
_LastEntityUnderPos= NULL;
+ _LastRemovedInstance = -1;
}// CEntityManager //
//-----------------------------------------------
@@ -525,22 +529,181 @@ void CEntityManager::reinit()
initialize(_NbMaxEntity);
}
-CShapeInstanceReference CEntityManager::createInstance(const string& shape, const CVector &pos, const string& text, const string& url, bool bbox_active)
+CShapeInstanceReference CEntityManager::createInstance(const string& shape, const CVector &pos, const string& text, const string& url, bool haveCollisions, sint32& idx)
{
+ idx = -1;
CShapeInstanceReference nullinstref(UInstance(), string(""), string(""));
if (!Scene) return nullinstref;
UInstance instance = Scene->createInstance(shape);
- if (text.empty())
- bbox_active = false;
- CShapeInstanceReference instref = CShapeInstanceReference(instance, text, url, bbox_active);
+
if(!instance.empty())
{
- _ShapeInstances.push_back(instref);
+ UMovePrimitive *primitive = NULL;
+
+ if (PACS && haveCollisions)
+ {
+ primitive = PACS->addCollisionablePrimitive(dynamicWI, 1);
+ primitive->setDontSnapToGround(false);
+ }
+
+ // Put instance in last deleted position if found
+ if (_LastRemovedInstance != -1)
+ {
+ idx = _LastRemovedInstance;
+ _ShapeInstances[idx].Instance = instance;
+ _ShapeInstances[idx].Primitive = primitive;
+ _ShapeInstances[idx].ContextText = text;
+ _ShapeInstances[idx].ContextURL = url;
+ _ShapeInstances[idx].BboxActive = !text.empty() || !url.empty();
+ _ShapeInstances[idx].Deleted = false;
+
+ _LastRemovedInstance = _ShapeInstances[idx].LastDeleted;
+ _ShapeInstances[idx].LastDeleted = -1;
+ return _ShapeInstances[idx];
+ }
+ else
+ {
+ CShapeInstanceReference instref = CShapeInstanceReference(instance, text, url, !text.empty() || !url.empty());
+ instref.Primitive = primitive;
+ idx = _ShapeInstances.size();
+ _ShapeInstances.push_back(instref);
+ return instref;
+ }
}
- return instref;
+ return nullinstref;
}
+bool CEntityManager::deleteInstance(uint32 idx)
+{
+ if (!Scene || idx >= _ShapeInstances.size())
+ return false;
+
+ if (!_ShapeInstances[idx].Instance.empty())
+ Scene->deleteInstance(_ShapeInstances[idx].Instance);
+ UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
+ if (primitive)
+ {
+ PACS->removePrimitive(primitive);
+ }
+
+ if (!_ShapeInstances[idx].Deleted)
+ {
+ _ShapeInstances[idx].Primitive = NULL;
+ _ShapeInstances[idx].Deleted = true;
+ _ShapeInstances[idx].LastDeleted = _LastRemovedInstance;
+ _LastRemovedInstance = idx;
+ }
+
+ return true;
+}
+
+CVector CEntityManager::getInstancePos(uint32 idx)
+{
+ if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
+ return CVector(0,0,0);
+
+ UInstance instance = _ShapeInstances[idx].Instance;
+ if(instance.empty())
+ return CVector(0,0,0);
+
+ return instance.getPos();
+}
+
+bool CEntityManager::setInstancePos(uint32 idx, CVector pos)
+{
+ if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
+ return false;
+
+ UInstance instance = _ShapeInstances[idx].Instance;
+ if(instance.empty())
+ return false;
+
+ UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
+ if (primitive)
+ {
+ primitive->setGlobalPosition(_ShapeInstances[idx].PrimRelativePos + pos, dynamicWI);
+ }
+
+ instance.setPos(pos);
+ return true;
+}
+
+CVector CEntityManager::getInstanceRot(uint32 idx)
+{
+ if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
+ return CVector(0,0,0);
+
+ UInstance instance = _ShapeInstances[idx].Instance;
+ if(instance.empty())
+ return CVector(0,0,0);
+
+ return instance.getRotEuler();
+}
+
+bool CEntityManager::setInstanceRot(uint32 idx, CVector rot)
+{
+ if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
+ return false;
+
+ UInstance instance = _ShapeInstances[idx].Instance;
+ if(instance.empty())
+ return false;
+
+ instance.setRotEuler(rot);
+
+ return true;
+}
+
+CVector CEntityManager::getInstanceScale(uint32 idx)
+{
+ if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
+ return CVector(0,0,0);
+
+ UInstance instance = _ShapeInstances[idx].Instance;
+ if(instance.empty())
+ return CVector(0,0,0);
+
+ return instance.getScale();
+}
+
+CVector CEntityManager::getInstanceColPos(uint32 idx)
+{
+ if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
+ return CVector(0,0,0);
+
+ return _ShapeInstances[idx].PrimRelativePos;
+}
+
+CVector CEntityManager::getInstanceColScale(uint32 idx)
+{
+ if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
+ return CVector(0,0,0);
+
+ UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
+ if (!primitive)
+ return CVector(0,0,0);
+
+ float width, depth;
+ primitive->getSize(width, depth);
+ float height = primitive->getHeight();
+
+ return CVector(width, depth, height);
+}
+
+double CEntityManager::getInstanceColOrient(uint32 idx)
+{
+ if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
+ return 0.f;
+
+ UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
+ if (!primitive)
+ return 0.f;
+
+ return primitive->getOrientation(dynamicWI);
+}
+
+
bool CEntityManager::removeInstances()
{
if (!Scene) return false;
@@ -549,9 +712,16 @@ bool CEntityManager::removeInstances()
{
if (!_ShapeInstances[i].Instance.empty())
Scene->deleteInstance(_ShapeInstances[i].Instance);
+
+ UMovePrimitive *primitive = _ShapeInstances[i].Primitive;
+ if (primitive)
+ {
+ PACS->removePrimitive(primitive);
+ }
}
_ShapeInstances.clear();
_InstancesRemoved = true;
+ _LastRemovedInstance = -1;
return true;
}
@@ -562,11 +732,165 @@ bool CEntityManager::instancesRemoved()
return instRemoved;
}
-CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float y)
+bool CEntityManager::setupInstance(uint32 idx, const vector &keys, const vector &values)
+{
+ if (!Scene || idx >= _ShapeInstances.size() || _ShapeInstances[idx].Deleted)
+ return false;
+
+ UInstance instance = _ShapeInstances[idx].Instance;
+ if(instance.empty())
+ return false;
+
+ UMovePrimitive *primitive = _ShapeInstances[idx].Primitive;
+
+ for (uint32 i=0; i < keys.size(); i++)
+ {
+ string param = keys[i];
+ if (param == "transparency")
+ {
+ uint t;
+ if( fromString( values[i], t ) ) {
+ t = max(0, min((int)t, 255));
+ makeInstanceTransparent(instance, t, t == 255);
+ }
+ }
+ else if (param == "colorize")
+ {
+ CRGBA c;
+ if( fromString( values[i], c ) )
+ {
+ for(uint j=0;jgetSize(width, depth);
+ float height = primitive->getHeight();
+
+ CVector size = CVector(width, depth, height);
+ float v;
+ if( getRelativeFloatFromString( values[i], v ) ) {
+ updateVector(param, size, v, true);
+ } else {
+ updateVector(param, size, v, false);
+ }
+ primitive->setSize(size.x, size.y);
+ primitive->setHeight(size.z);
+ }
+ else if (param == "col pos x" || param == "col pos y" || param == "col pos z")
+ {
+ CVector pos = instance.getPos();
+ float v;
+
+ if( getRelativeFloatFromString( values[i], v ) ) {
+ updateVector(param, _ShapeInstances[idx].PrimRelativePos, v, false);
+ } else {
+ if (param == "col pos x")
+ _ShapeInstances[idx].PrimRelativePos.x = v - pos.x;
+ if (param == "col pos y")
+ _ShapeInstances[idx].PrimRelativePos.y = v - pos.y;
+ if (param == "col pos z")
+ _ShapeInstances[idx].PrimRelativePos.z = v - pos.z;
+ }
+ primitive->setGlobalPosition(pos + _ShapeInstances[idx].PrimRelativePos, dynamicWI);
+ }
+ else if (param == "col orientation")
+ {
+ double orient = primitive->getOrientation(dynamicWI);
+ double v = 0.f;
+
+ if (values[i].empty())
+ continue;
+
+ if (values[i][0] == '+')
+ {
+ fromString(values[i].substr(1), v);
+ orient += v;
+ }
+ else
+ {
+ fromString(values[i], v);
+ orient = v;
+ }
+
+ primitive->setOrientation(orient, dynamicWI);
+ }
+ else if (param == "col mask player")
+ {
+ bool active;
+ fromString(values[i], active);
+ UMovePrimitive::TCollisionMask mask=primitive->getCollisionMask();
+ if (active)
+ primitive->setCollisionMask(mask|MaskColPlayer);
+ else
+ primitive->setCollisionMask(mask&~MaskColPlayer);
+ }
+ else if (param == "col mask door")
+ {
+ bool active;
+ fromString(values[i], active);
+ UMovePrimitive::TCollisionMask mask=primitive->getCollisionMask();
+ if (active)
+ primitive->setCollisionMask(mask|MaskColDoor);
+ else
+ primitive->setCollisionMask(mask&~MaskColDoor);
+ }
+ else if (param == "col obstacle")
+ {
+ bool active;
+ fromString(values[i], active);
+ primitive->setObstacle(active);
+ }
+ }
+
+ return true;
+}
+
+
+CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float y, sint32 &idx)
{
CShapeInstanceReference selectedInstance(UInstance(), string(""), string(""));
_LastInstanceUnderPos= NULL;
-
+ idx = -1;
+
// If not initialised, return
if (_ShapeInstances.empty())
return selectedInstance;
@@ -586,29 +910,40 @@ CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float
float bestDist = 255;
for(uint i=0; i<_ShapeInstances.size(); i++)
{
- if (_ShapeInstances[i].BboxActive)
+ if (!_ShapeInstances[i].Deleted && _ShapeInstances[i].BboxActive)
{
H_AUTO(RZ_Client_GEUP_box_intersect)
// if intersect the bbox
NLMISC::CAABBox bbox;
//= _ShapeInstances[i].SelectionBox;
- _ShapeInstances[i].Instance.getShapeAABBox(bbox);
- if (bbox.getCenter() == CVector::Null)
- {
- bbox.setMinMax(CVector(-0.3f, -0.3f, -0.3f)+_ShapeInstances[i].Instance.getPos(), CVector(0.3f, 0.3f, 0.3f)+_ShapeInstances[i].Instance.getPos());
- }
- else
- {
- bbox.setMinMax((bbox.getMin()*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos(), (bbox.getMax()*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos());
- }
- if(bbox.intersect(pos, pos+dir*15.0f))
- {
- float dist = (bbox.getCenter()-pos).norm();
- if (dist < bestDist)
+ if(!_ShapeInstances[i].Instance.empty()) {
+ _ShapeInstances[i].Instance.getShapeAABBox(bbox);
+ CVector bbox_min;
+ CVector bbox_max;
+
+ if (bbox.getCenter() == CVector::Null)
{
- selectedInstance = _ShapeInstances[i];
- bestDist = dist;
+ bbox_min = CVector(-0.5f, -0.5f, -0.5f);
+ bbox_max = CVector(-0.5f, -0.5f, -0.5f);
+ }
+ else
+ {
+ bbox_min = bbox.getMin();
+ bbox_max = bbox.getMax();
+ }
+
+ bbox.setMinMax((bbox_min*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos(), (bbox_max*_ShapeInstances[i].Instance.getScale().x)+_ShapeInstances[i].Instance.getPos());
+
+ if(bbox.intersect(pos, pos+dir*100.0f))
+ {
+ float dist = (bbox.getCenter()-pos).norm();
+ if (dist < bestDist)
+ {
+ selectedInstance = _ShapeInstances[i];
+ bestDist = dist;
+ idx = (sint32)i;
+ }
}
}
}
@@ -1952,7 +2287,26 @@ CEntityCL *CEntityManager::getEntityByCompressedIndex(TDataSetIndex compressedIn
}
return NULL;
}
-
+//-----------------------------------------------
+// getEntityBySheetName :
+// Return an entity based on its sheet name
+//-----------------------------------------------
+CEntityCL *CEntityManager::getEntityBySheetName (const std::string &sheet) const
+{
+ if (!sheet.empty())
+ {
+ uint i;
+ const CSheetId& sheetRef = NLMISC::CSheetId(sheet);
+ const uint count = (uint)_Entities.size();
+ for (i=0; isheetId() == sheetRef)
+ return _Entities[i];
+ }
+ }
+ return NULL;
+}
//-----------------------------------------------
// managePACSTriggers :
// Manage PACS Triggers.
diff --git a/code/ryzom/client/src/entities.h b/code/ryzom/client/src/entities.h
index f71240b63..ed9b6ea6d 100644
--- a/code/ryzom/client/src/entities.h
+++ b/code/ryzom/client/src/entities.h
@@ -101,12 +101,24 @@ public:
ContextText = text;
ContextURL = url;
BboxActive = bbox_active;
+ Deleted = false;
+ LastDeleted = -1;
+ Primitive = NULL;
+ PrimSize = CVector(1.f, 1.f, 1.f);
+ PrimHeight = 1.f;
+ PrimRelativePos = CVector(0.f, 0.f, 0.f);
}
NL3D::UInstance Instance;
+ NLPACS::UMovePrimitive *Primitive;
+ CVector PrimSize;
+ float PrimHeight;
+ CVector PrimRelativePos;
string ContextText;
string ContextURL;
bool BboxActive;
+ bool Deleted;
+ sint32 LastDeleted;
};
/**
@@ -132,6 +144,7 @@ private:
/// Shapes Instances caches
std::vector _ShapeInstances;
+ sint32 _LastRemovedInstance;
bool _InstancesRemoved;
typedef struct
@@ -213,10 +226,20 @@ public:
void reinit();
- CShapeInstanceReference createInstance(const string& shape, const CVector &pos, const string &text, const string &url, bool active=true);
+ CShapeInstanceReference createInstance(const string& shape, const CVector &pos, const string &text, const string &url, bool haveCollisions, sint32 &idx);
+ bool deleteInstance(uint32 idx);
bool removeInstances();
+ CVector getInstancePos(uint32 idx);
+ bool setInstancePos(uint32 idx, CVector pos);
+ CVector getInstanceRot(uint32 idx);
+ CVector getInstanceScale(uint32 idx);
+ CVector getInstanceColPos(uint32 idx);
+ CVector getInstanceColScale(uint32 idx);
+ double getInstanceColOrient(uint32 idx);
+ bool setInstanceRot(uint32 idx, CVector pos);
bool instancesRemoved();
- CShapeInstanceReference getShapeInstanceUnderPos(float x, float y);
+ bool setupInstance(uint32 idx, const std::vector &keys, const std::vector &values);
+ CShapeInstanceReference getShapeInstanceUnderPos(float x, float y, sint32 &idx);
/**
* Create an entity according to the slot and the form.
@@ -277,7 +300,7 @@ public:
* \param complete : if true, the name must match the full name of the entity.
*/
CEntityCL *getEntityByName (const ucstring &name, bool caseSensitive, bool complete) const;
-
+ CEntityCL *getEntityBySheetName (const std::string &sheet) const;
/// Get an entity by dataset index. Returns NULL if the entity is not found.
CEntityCL *getEntityByCompressedIndex(TDataSetIndex compressedIndex) const;
diff --git a/code/ryzom/client/src/input.cpp b/code/ryzom/client/src/input.cpp
index 403947538..df4b15c61 100644
--- a/code/ryzom/client/src/input.cpp
+++ b/code/ryzom/client/src/input.cpp
@@ -271,6 +271,15 @@ void HandleSystemCursorCapture(const CEvent &event)
{
CEventMouseDown &em = (CEventMouseDown &) event;
DownMouseButtons |= em.Button & (leftButton | middleButton | rightButton);
+
+ CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
+ if (cursor)
+ {
+ cursor->setPointerDown(em.Button == leftButton);
+ cursor->setPointerMiddleDown(em.Button == middleButton);
+ cursor->setPointerRightDown(em.Button == rightButton);
+ }
+
Driver->setCapture(true);
}
@@ -281,6 +290,13 @@ void HandleSystemCursorCapture(const CEvent &event)
DownMouseButtons &= ~(em.Button & (leftButton | middleButton | rightButton));
if (DownMouseButtons == 0)
{
+ CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
+ if (cursor)
+ {
+ cursor->setPointerDown(false);
+ cursor->setPointerMiddleDown(false);
+ cursor->setPointerRightDown(false);
+ }
Driver->setCapture(false);
}
}
diff --git a/code/ryzom/client/src/interface_v3/action_handler_debug.cpp b/code/ryzom/client/src/interface_v3/action_handler_debug.cpp
index 616d66a1c..51b029815 100644
--- a/code/ryzom/client/src/interface_v3/action_handler_debug.cpp
+++ b/code/ryzom/client/src/interface_v3/action_handler_debug.cpp
@@ -42,6 +42,7 @@ extern bool Render;
extern bool WantProfiling; // Do we want a CPU profile?
extern bool WantProfilingVBLock; // Do we want a VBLock profile?
extern bool PACSBorders;
+extern bool ARKPACSBorders;
extern bool DebugClusters;
extern bool SoundBox;
extern uint8 ShowInfos;
@@ -92,6 +93,16 @@ REGISTER_ACTION_HANDLER (CAHDisplayInfos, "display_infos");
* *
***********************************************************************************************************/
+// ------------------------------------------------------------------------------------------------
+class CAHToggleARKPACSBorders : public IActionHandler
+{
+ virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
+ {
+ ARKPACSBorders = !ARKPACSBorders;
+ }
+};
+REGISTER_ACTION_HANDLER (CAHToggleARKPACSBorders, "ark_pacs_borders");
+
#if !FINAL_VERSION
// ------------------------------------------------------------------------------------------------
class CAHProfile : public IActionHandler
diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp
index 9efcf41b2..2f14ce8a0 100644
--- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp
+++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp
@@ -2418,6 +2418,7 @@ class CAHTarget : public IActionHandler
ucstring entityName;
entityName.fromUtf8 (getParam (Params, "entity"));
bool preferCompleteMatch = (getParam (Params, "prefer_complete_match") != "0");
+ bool quiet = (getParam (Params, "quiet") == "true");
if (!entityName.empty())
{
@@ -2433,6 +2434,12 @@ class CAHTarget : public IActionHandler
// Get the entity with a partial match
entity = EntitiesMngr.getEntityByName (entityName, false, false);
}
+
+ if (entity == NULL)
+ {
+ //Get the entity with a sheetName
+ entity = EntitiesMngr.getEntityBySheetName(entityName.toUtf8());
+ }
if (entity)
{
@@ -2457,7 +2464,8 @@ class CAHTarget : public IActionHandler
// to avoid campfire selection exploit #316
nldebug("is not prop selectable");
CInterfaceManager *pIM= CInterfaceManager::getInstance();
- pIM->displaySystemInfo(CI18N::get("uiTargetErrorCmd"));
+ if(!quiet)
+ pIM->displaySystemInfo(CI18N::get("uiTargetErrorCmd"));
return;
}
@@ -2467,7 +2475,8 @@ class CAHTarget : public IActionHandler
else
{
CInterfaceManager *pIM= CInterfaceManager::getInstance();
- pIM->displaySystemInfo(CI18N::get("uiTargetErrorCmd"));
+ if(!quiet)
+ pIM->displaySystemInfo(CI18N::get("uiTargetErrorCmd"));
}
}
}
@@ -2528,7 +2537,6 @@ class CAHAddShape : public IActionHandler
}
bool have_shapes = true;
- bool first_shape = true;
while(have_shapes)
{
string shape;
@@ -2545,8 +2553,8 @@ class CAHAddShape : public IActionHandler
have_shapes = false;
}
-
- CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector((float)x, (float)y, (float)z), c, u, first_shape);
+ sint32 idx;
+ CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector((float)x, (float)y, (float)z), c, u, false, idx);
UInstance instance = instref.Instance;
if(!instance.empty())
@@ -2566,7 +2574,7 @@ class CAHAddShape : public IActionHandler
instance.getMaterial(j).setShininess( 1000.0f );
}
- if (!texture_name.empty() && first_shape)
+ if (!texture_name.empty())
{
sint numStages = instance.getMaterial(j).getLastTextureStage() + 1;
for(sint l = 0; l < numStages; l++)
@@ -2579,8 +2587,6 @@ class CAHAddShape : public IActionHandler
}
}
- first_shape = false;
-
if (transparency.empty())
::makeInstanceTransparent(instance, 255, false);
else
@@ -2613,6 +2619,9 @@ class CAHAddShape : public IActionHandler
instance.setPos(CVector((float)x, (float)y, (float)z));
instance.setRotQuat(dir.getRot());
}
+
+ instance.setTransformMode(UTransformable::RotEuler);
+
// if the shape is a particle system, additionnal parameters are user params
UParticleSystemInstance psi;
psi.cast (instance);
diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp
index fb0d251f5..3ecf011d7 100644
--- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp
+++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp
@@ -21,7 +21,7 @@
// to get rid of you_must_not_use_assert___use_nl_assert___read_debug_h_file messages
#include
#ifdef assert
- #undef assert
+#undef assert
#endif
// Warning: cannot use namespace std, when using luabind
@@ -107,6 +107,9 @@
#include "../bg_downloader_access.h"
#include "../connection.h"
#include "../login_patch.h"
+#include "../r2/tool.h"
+#include "../entities.h"
+#include "../misc.h"
#include "bot_chat_page_all.h"
#include "bot_chat_page_ring_sessions.h"
@@ -119,18 +122,21 @@
#include "game_share/constants.h"
#include "game_share/visual_slot_manager.h"
#include "nel/gui/lua_manager.h"
+#include "pacs_client.h"
#ifdef LUA_NEVRAX_VERSION
- #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger
+#include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger
#endif
#ifdef LUA_NEVRAX_VERSION
- extern ILuaIDEInterface *LuaDebuggerIDE;
+extern ILuaIDEInterface* LuaDebuggerIDE;
#endif
using namespace NLMISC;
using namespace NLGUI;
+using namespace NL3D;
+using namespace NLPACS;
using namespace R2;
extern NLMISC::CLog g_log;
@@ -141,12 +147,12 @@ extern CClientChatManager ChatMngr;
class CHandlerLUA : public IActionHandler
{
public:
- void execute (CCtrlBase *pCaller, const std::string &sParams)
+ void execute(CCtrlBase *pCaller, const std::string &sParams)
{
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
// For getUI() LUA function, push the UI caller
- if(pCaller)
+ if (pCaller)
_UICallerStack.push_back(pCaller);
// execute a small script. NB: use a small script here because
@@ -154,38 +160,39 @@ public:
CLuaManager::getInstance().executeLuaScript(sParams, true);
// pop UI caller
- if(pCaller)
+ if (pCaller)
_UICallerStack.pop_back();
}
// get the top of stack Caller to this LUA script
- static CCtrlBase *getUICaller();
+ static CCtrlBase* getUICaller();
private:
static std::deque > _UICallerStack;
};
-REGISTER_ACTION_HANDLER( CHandlerLUA, "lua");
+REGISTER_ACTION_HANDLER(CHandlerLUA, "lua");
std::deque > CHandlerLUA::_UICallerStack;
// ***************************************************************************
// Allow also to call script from expression
static DECLARE_INTERFACE_USER_FCT(lua)
{
- if(args.size()!=1 || !args[0].toString())
+ if (args.size() != 1 || !args[0].toString())
{
nlwarning(" requires 1 arg (string=script)");
return false;
}
// Retrieve lua state
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
- CLuaState *state= CLuaManager::getInstance().getLuaState();
- if(!state)
- return false;
- CLuaState &ls= *state;
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
+ CLuaState *state = CLuaManager::getInstance().getLuaState();
+ if (!state)
+ return false;
+
+ CLuaState &ls = *state;
// *** clear return value
- const std::string retId= "__ui_internal_ret_";
+ const std::string retId = "__ui_internal_ret_";
CLuaStackChecker lsc(&ls);
ls.pushGlobalTable();
ls.push(retId);
@@ -193,51 +200,50 @@ static DECLARE_INTERFACE_USER_FCT(lua)
ls.setTable(-3); //pop pop
ls.pop();
-
// *** execute script
- std::string script= args[0].getString();
+ std::string script = args[0].getString();
// assign return value in retId.
- script= retId + "= " + script;
+ script = retId + "= " + script;
// execute a small script here, because most often exprs are called from xml files => lot of redundant script
CLuaManager::getInstance().executeLuaScript(script, true);
-
// *** retrieve and convert return value
ls.pushGlobalTable();
ls.push(retId);
ls.getTable(-2);
ls.remove(-2);
- bool ok= false;
- sint type= ls.type();
- if (type==LUA_TBOOLEAN)
+ bool ok = false;
+ sint type = ls.type();
+
+ if (type == LUA_TBOOLEAN)
{
// get and pop
- bool val= ls.toBoolean();
+ bool val = ls.toBoolean();
ls.pop();
// set result
result.setBool(val);
- ok= true;
+ ok = true;
}
- else if(type==LUA_TNUMBER)
+ else if (type == LUA_TNUMBER)
{
if (ls.isInteger())
{
// get and pop
- sint64 val= ls.toInteger();
+ sint64 val = ls.toInteger();
ls.pop();
result.setInteger(val);
- ok= true;
+ ok = true;
}
else
{
// get and pop
- double val= ls.toNumber();
+ double val = ls.toNumber();
ls.pop();
result.setDouble(val);
- ok= true;
+ ok = true;
}
}
- else if(type==LUA_TSTRING)
+ else if (type == LUA_TSTRING)
{
// get and pop
std::string val;
@@ -245,28 +251,30 @@ static DECLARE_INTERFACE_USER_FCT(lua)
ls.pop();
// set result
result.setString(val);
- ok= true;
+ ok = true;
}
- else if(type==LUA_TUSERDATA)
+ else if (type == LUA_TUSERDATA)
{
// NB: the value is poped in obj.set() (no need to do ls.pop());
// try with ucstring
ucstring ucstrVal;
+
if (CLuaIHM::pop(ls, ucstrVal))
{
result.setUCString(ucstrVal);
- ok= true;
+ ok = true;
}
// try with RGBA
- if(!ok)
+ if (!ok)
{
NLMISC::CRGBA rgbaVal;
+
if (CLuaIHM::pop(ls, rgbaVal))
{
result.setRGBA(rgbaVal);
- ok= true;
+ ok = true;
}
}
}
@@ -281,9 +289,9 @@ static DECLARE_INTERFACE_USER_FCT(lua)
REGISTER_INTERFACE_USER_FCT("lua", lua)
-CCtrlBase *CHandlerLUA::getUICaller()
+CCtrlBase* CHandlerLUA::getUICaller()
{
- if(_UICallerStack.empty())
+ if (_UICallerStack.empty())
return NULL;
else
return _UICallerStack.back();
@@ -307,28 +315,34 @@ int CLuaIHMRyzom::luaClientCfgIndex(CLuaState &ls)
{
//H_AUTO(Lua_CLuaIHM_luaClientCfgIndex)
CConfigFile::CVar *v = ClientCfg.ConfigFile.getVarPtr(ls.toString(2));
+
if (!v) return 0;
+
if (v->size() != 1)
{
// arrays not implemented (would require a second metatable)....
throw ELuaWrappedFunctionException(&ls, "Access to array inside client.cfg not supported.");
}
- switch(v->Type)
+
+ switch (v->Type)
{
- case CConfigFile::CVar::T_REAL:
- ls.push(v->asDouble());
- return 1;
+ case CConfigFile::CVar::T_REAL:
+ ls.push(v->asDouble());
+ return 1;
break;
- case CConfigFile::CVar::T_STRING:
- ls.push(v->asString());
- return 1;
+
+ case CConfigFile::CVar::T_STRING:
+ ls.push(v->asString());
+ return 1;
break;
- default: // handle both T_INT && T_BOOL
- case CConfigFile::CVar::T_INT:
- ls.push(v->asInt());
- return 1;
+
+ default: // handle both T_INT && T_BOOL
+ case CConfigFile::CVar::T_INT:
+ ls.push(v->asInt());
+ return 1;
break;
}
+
return 0;
}
@@ -350,21 +364,23 @@ void CLuaIHMRyzom::createLuaEnumTable(CLuaState &ls, const std::string &str)
CSString s = str;
// Create table recursively (ex: 'game.TPVPClan' will check/create the table 'game' and 'game.TPVPClan')
p = s.splitTo('.', true);
+
while (p.size() > 0)
{
if (path.empty())
path = p;
else
path += "." + p;
+
script = "if (" + path + " == nil) then " + path + " = {}; end";
ls.executeScript(script);
p = s.splitTo('.', true);
}
}
-void CLuaIHMRyzom::RegisterRyzomFunctions( NLGUI::CLuaState &ls )
+void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls)
{
- CLuaStackChecker lsc( &ls );
+ CLuaStackChecker lsc(&ls);
// MISC ui ctors
struct CUICtor
@@ -419,6 +435,12 @@ void CLuaIHMRyzom::RegisterRyzomFunctions( NLGUI::CLuaState &ls )
ls.registerFunc("getAutoSeason", getAutoSeason);
ls.registerFunc("enableModalWindow", enableModalWindow);
ls.registerFunc("getPlayerPos", getPlayerPos);
+ ls.registerFunc("getGroundAtMouse", getGroundAtMouse),
+ ls.registerFunc("getMousePos", getMousePos),
+ ls.registerFunc("getMouseDown", getMouseDown),
+ ls.registerFunc("getMouseMiddleDown", getMouseMiddleDown),
+ ls.registerFunc("getMouseRightDown", getMouseRightDown),
+ ls.registerFunc("getShapeIdAt", getShapeIdAt),
ls.registerFunc("getPlayerFront", getPlayerFront);
ls.registerFunc("getPlayerDirection", getPlayerDirection);
ls.registerFunc("getPlayerGender", getPlayerGender);
@@ -449,9 +471,19 @@ void CLuaIHMRyzom::RegisterRyzomFunctions( NLGUI::CLuaState &ls )
ls.registerFunc("getSheet2idx", getSheet2idx);
ls.registerFunc("getTargetSlot", getTargetSlot);
ls.registerFunc("getSlotDataSetId", getSlotDataSetId);
+ ls.registerFunc("addShape", addShape);
+ ls.registerFunc("moveShape", moveShape);
+ ls.registerFunc("rotateShape", rotateShape);
+ ls.registerFunc("getShapePos", getShapePos);
+ ls.registerFunc("getShapeScale", getShapeScale);
+ ls.registerFunc("getShapeRot", getShapeRot);
+ ls.registerFunc("getShapeColPos", getShapeColPos);
+ ls.registerFunc("getShapeColScale", getShapeColScale);
+ ls.registerFunc("getShapeColOrient", getShapeColOrient);
+ ls.registerFunc("deleteShape", deleteShape);
+ ls.registerFunc("setupShape", setupShape);
-
- lua_State *L= ls.getStatePointer();
+ lua_State *L = ls.getStatePointer();
LUABIND_ENUM(PVP_CLAN::TPVPClan, "game.TPVPClan", PVP_CLAN::NbClans, PVP_CLAN::toString);
LUABIND_ENUM(BONUS_MALUS::TBonusMalusSpecialTT, "game.TBonusMalusSpecialTT", BONUS_MALUS::NbSpecialTT, BONUS_MALUS::toString);
@@ -467,14 +499,14 @@ void CLuaIHMRyzom::RegisterRyzomFunctions( NLGUI::CLuaState &ls )
LUABIND_FUNC(dumpCallStack),
LUABIND_FUNC(getDefine),
LUABIND_FUNC(setContextHelpText),
- luabind::def("messageBox", (void(*)(const ucstring &)) &messageBox),
- luabind::def("messageBox", (void(*)(const ucstring &, const std::string &)) &messageBox),
- luabind::def("messageBox", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBox),
- luabind::def("messageBox", (void(*)(const std::string &)) &messageBox),
- luabind::def("messageBoxWithHelp", (void(*)(const ucstring &)) &messageBoxWithHelp),
- luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp),
- luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp),
- luabind::def("messageBoxWithHelp", (void(*)(const std::string &)) &messageBoxWithHelp),
+ luabind::def("messageBox", (void(*)(const ucstring &)) &messageBox),
+ luabind::def("messageBox", (void(*)(const ucstring &, const std::string &)) &messageBox),
+ luabind::def("messageBox", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBox),
+ luabind::def("messageBox", (void(*)(const std::string &)) &messageBox),
+ luabind::def("messageBoxWithHelp", (void(*)(const ucstring &)) &messageBoxWithHelp),
+ luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp),
+ luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp),
+ luabind::def("messageBoxWithHelp", (void(*)(const std::string &)) &messageBoxWithHelp),
LUABIND_FUNC(replacePvpEffectParam),
LUABIND_FUNC(secondsSince1970ToHour),
LUABIND_FUNC(pauseBGDownloader),
@@ -542,7 +574,6 @@ void CLuaIHMRyzom::RegisterRyzomFunctions( NLGUI::CLuaState &ls )
LUABIND_FUNC(isPlayerInPVPMode),
LUABIND_FUNC(isTargetInPVPMode)
];
-
}
// ***************************************************************************
@@ -551,11 +582,14 @@ static sint32 getTargetSlotNr()
const char *dbPath = "UI:VARIABLES:TARGET:SLOT";
CInterfaceManager *im = CInterfaceManager::getInstance();
CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(dbPath, false);
+
if (!node) return 0;
+
if ((uint8) node->getValue32() == (uint8) CLFECOMMON::INVALID_SLOT)
{
return 0;
}
+
return node->getValue32();
}
@@ -564,11 +598,14 @@ static CEntityCL *getTargetEntity()
const char *dbPath = "UI:VARIABLES:TARGET:SLOT";
CInterfaceManager *im = CInterfaceManager::getInstance();
CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(dbPath, false);
+
if (!node) return NULL;
+
if ((uint8) node->getValue32() == (uint8) CLFECOMMON::INVALID_SLOT)
{
return NULL;
}
+
return EntitiesMngr.entity((uint) node->getValue32());
}
@@ -588,6 +625,7 @@ int CLuaIHMRyzom::getUI(CLuaState &ls)
CLuaIHM::check(ls, ls.getTop() == 1 || ls.getTop() == 2, funcName);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
bool verbose = true;
+
if (ls.getTop() > 1)
{
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TBOOLEAN);
@@ -599,22 +637,25 @@ int CLuaIHMRyzom::getUI(CLuaState &ls)
ls.toString(1, eltStr);
// return the element
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
- CInterfaceElement *pIE= CWidgetManager::getInstance()->getElementFromId(eltStr);
- if(!pIE)
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
+ CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(eltStr);
+
+ if (!pIE)
{
ls.pushNil();
+
if (verbose)
{
std::string stackContext;
ls.getStackContext(stackContext, 1);
- debugInfo( NLMISC::toString("%s : getUI(): '%s' not found", stackContext.c_str(), eltStr.c_str()));
+ debugInfo(NLMISC::toString("%s : getUI(): '%s' not found", stackContext.c_str(), eltStr.c_str()));
}
}
else
{
CLuaIHM::pushUIOnStack(ls, pIE);
}
+
return 1;
}
@@ -635,24 +676,27 @@ int CLuaIHMRyzom::formatUI(CLuaState &ls)
ls.toString(1, propVal);
// *** format with %
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
std::string newPropVal, defError;
- if( !CWidgetManager::getInstance()->getParser()->solveDefine(propVal, newPropVal, defError))
+
+ if (!CWidgetManager::getInstance()->getParser()->solveDefine(propVal, newPropVal, defError))
{
throw ELuaIHMException("formatUI(): Can't find define: '%s'", defError.c_str());
}
// *** format with any additional parameter and #1, #2, #3 etc...
// search backward, starting from bigger param to replace (thus avoid to replace #1 before #13 for instance...)
- sint stackIndex= ls.getTop();
- while(stackIndex>1)
+ sint stackIndex = ls.getTop();
+
+ while (stackIndex > 1)
{
std::string paramValue;
ls.toString(stackIndex, paramValue);
// For stack param 4, the param index is 3 (because stack param 2 is the param No 1)
- sint paramIndex= stackIndex-1;
- while(NLMISC::strFindReplace(newPropVal, NLMISC::toString("#%d", paramIndex), paramValue));
+ sint paramIndex = stackIndex - 1;
+
+ while (NLMISC::strFindReplace(newPropVal, NLMISC::toString("#%d", paramIndex), paramValue));
// next
stackIndex--;
@@ -672,19 +716,20 @@ int CLuaIHMRyzom::formatDB(CLuaState &ls)
// params: param1, param2....
// return: string with @ and , added
CLuaIHM::checkArgMin(ls, "formatDB", 1);
- uint top= ls.getTop();
+ uint top = ls.getTop();
std::string dbRes;
- for(uint i=1;i<=top;i++)
+
+ for (uint i = 1; i <= top; i++)
{
- if(i==1)
- dbRes= "@";
+ if (i == 1)
+ dbRes = "@";
else
- dbRes+= ", @";
+ dbRes += ", @";
std::string paramValue;
ls.toString(i, paramValue);
- dbRes+= paramValue;
+ dbRes += paramValue;
}
// return result
@@ -704,15 +749,16 @@ int CLuaIHMRyzom::dumpUI(CLuaState &ls)
CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "dumpUI() requires a UI object in param 1");
// retrieve args
- CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1);
- if(!pIE)
+ CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1);
+
+ if (!pIE)
debugInfo("UI: NULL");
else
{
// Display also Information on RefPtr (warning: don't modify pinfo!!!)
nlassert(pIE->pinfo);
debugInfo(NLMISC::toString("UI: %x. %s. RefPtrCount: %d", pIE, pIE->getId().c_str(),
- pIE->pinfo->IsNullPtrInfo?0:pIE->pinfo->RefCount));
+ pIE->pinfo->IsNullPtrInfo ? 0 : pIE->pinfo->RefCount));
}
return 0;
@@ -760,10 +806,12 @@ int CLuaIHMRyzom::breakPoint(CLuaState &ls)
LuaHelperStuff::formatLuaStackContext(reason);
NLMISC::InfoLog->displayRawNL(reason.c_str());
static volatile bool doAssert = true;
+
if (doAssert) // breakPoint can be discarded in case of looping assert
{
NLMISC_BREAKPOINT;
}
+
return 0;
}
@@ -778,29 +826,31 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls)
// *** check and retrieve param 1
CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "setTextFormatTaged() requires a UI object in param 1");
- CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1);
+ CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1);
// *** check and retrieve param 2. must be a string or a ucstring
ucstring text;
- if(ls.isString(2))
+
+ if (ls.isString(2))
{
std::string str;
ls.toString(2, str);
- text= str;
+ text = str;
}
else
{
// try to pop a ucstring from the stack
// fail?
- if(!CLuaIHM::pop(ls, text))
+ if (!CLuaIHM::pop(ls, text))
{
CLuaIHM::check(ls, false, "setTextFormatTaged() requires a string or a ucstring in param 2");
}
}
// must be a view text
- CViewText *vt= dynamic_cast(pIE);
- if(!vt)
+ CViewText *vt = dynamic_cast(pIE);
+
+ if (!vt)
throw ELuaIHMException("setTextFormatTaged(): '%s' is not a CViewText", pIE->getId().c_str());
// Set the text as format
@@ -817,12 +867,12 @@ struct CEmoteStruct
string Anim;
bool UsableFromClientUI;
- bool operator< (const CEmoteStruct & entry) const
+ bool operator< (const CEmoteStruct &entry) const
{
string path1 = Path;
string path2 = entry.Path;
- for(;;)
+ for (;;)
{
string::size_type pos1 = path1.find('|');
string::size_type pos2 = path2.find('|');
@@ -831,17 +881,20 @@ struct CEmoteStruct
ucstring s2 = toUpper(CI18N::get(path2.substr(0, pos2)));
sint result = s1.compare(s2);
+
if (result != 0)
return (result < 0);
if (pos1 == string::npos)
return (pos2 != string::npos);
+
if (pos2 == string::npos)
return false;
path1 = path1.substr(pos1 + 1);
path2 = path2.substr(pos2 + 1);
}
+
return false;
}
};
@@ -852,19 +905,21 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls)
//H_AUTO(Lua_CLuaIHM_initEmotesMenu)
CLuaIHM::checkArgCount(ls, "initEmotesMenu", 2);
CLuaIHM::checkArgType(ls, "initEmotesMenu", 2, LUA_TSTRING);
- const std::string & emoteMenu = ls.toString(1);
- const std::string & luaParams = ls.toString(2);
+
+ const std::string &emoteMenu = ls.toString(1);
+ const std::string &luaParams = ls.toString(2);
ls.newTable();
CLuaObject result(ls);
std::map emoteList;
- uint maxVisibleLine=10;
+ uint maxVisibleLine = 10;
CTextEmotListSheet *pTELS = dynamic_cast(SheetMngr.get(CSheetId("list.text_emotes")));
if (pTELS == NULL)
return 0;
std::list entries;
+
if (entries.empty())
{
for (uint i = 0; i < pTELS->TextEmotList.size(); i++)
@@ -876,22 +931,21 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls)
entry.UsableFromClientUI = pTELS->TextEmotList[i].UsableFromClientUI;
entries.push_back(entry);
}
+
entries.sort();
}
// The list of behaviour missnames emotList
CEmotListSheet *pEmotList = dynamic_cast(SheetMngr.get(CSheetId("list.emot")));
- nlassert (pEmotList != NULL);
- nlassert (pEmotList->Emots.size() <= 255);
-
+ nlassert(pEmotList != NULL);
+ nlassert(pEmotList->Emots.size() <= 255);
// Get the focus beta tester flag
bool betaTester = false;
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CSkillManager *pSM = CSkillManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
+ CSkillManager *pSM = CSkillManager::getInstance();
betaTester = pSM->isTitleUnblocked(CHARACTER_TITLE::FBT);
-
CGroupMenu *pInitRootMenu = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(emoteMenu));
pInitRootMenu->reset();
@@ -903,7 +957,7 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls)
// Check that the emote can be added to UI
// ---------------------------------------
- if( (*it).UsableFromClientUI == false )
+ if ((*it).UsableFromClientUI == false)
{
continue;
}
@@ -917,6 +971,7 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls)
// Add to the game context menu
// ----------------------------
uint32 nbToken = 1;
+
for (i = 0; i < sName.size(); ++i)
if (sName[i] == '|')
nbToken++;
@@ -926,22 +981,22 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls)
for (i = 0; i < nbToken; ++i)
{
- if(i==0)
+ if (i == 0)
{
- sName = sName.substr(sName.find('|')+1,sName.size());
+ sName = sName.substr(sName.find('|') + 1, sName.size());
}
else
{
string sTmp;
- if (i != (nbToken-1))
- sTmp = sName.substr(0,sName.find('|'));
+
+ if (i != (nbToken - 1))
+ sTmp = sName.substr(0, sName.find('|'));
else
sTmp = sName;
-
-
// Look if this part of the path is already present
bool bFound = false;
+
for (j = 0; j < pMenu->getNumLine(); ++j)
{
if (sTmp == pMenu->getLineId(j))
@@ -953,39 +1008,42 @@ int CLuaIHMRyzom::initEmotesMenu(CLuaState &ls)
if (!bFound) // Create it
{
- if (i != (nbToken-1))
+ if (i != (nbToken - 1))
{
- pMenu->addLine (CI18N::get(sTmp), "", "", sTmp);
+ pMenu->addLine(CI18N::get(sTmp), "", "", sTmp);
// Create a sub menu
- CGroupSubMenu *pNewSubMenu = new CGroupSubMenu(CViewBase::TCtorParam());
+ CGroupSubMenu* pNewSubMenu = new CGroupSubMenu(CViewBase::TCtorParam());
pMenu->setSubMenu(j, pNewSubMenu);
}
else
{
// Create a line
- pMenu->addLine (CI18N::get(sTmp), "lua",
- luaParams+"('"+sEmoteId+"', '"+toString(CI18N::get(sTmp))+"')", sTmp);
+ pMenu->addLine(CI18N::get(sTmp), "lua",
+ luaParams + "('" + sEmoteId + "', '" + toString(CI18N::get(sTmp)) + "')", sTmp);
emoteList[sEmoteId] = (toLower(CI18N::get(sTmp))).toUtf8();
}
}
// Jump to sub menu
- if (i != (nbToken-1))
+ if (i != (nbToken - 1))
{
pMenu = pMenu->getSubMenu(j);
- sName = sName.substr(sName.find('|')+1,sName.size());
+ sName = sName.substr(sName.find('|') + 1, sName.size());
}
}
}
+
pMenu->setMaxVisibleLine(maxVisibleLine);
}
- pInitRootMenu->setMaxVisibleLine(maxVisibleLine);
+ pInitRootMenu->setMaxVisibleLine(maxVisibleLine);
std::map::iterator it;
- for(it=emoteList.begin(); it!=emoteList.end(); it++)
+
+ for (it = emoteList.begin(); it != emoteList.end(); it++)
{
result.setValue(it->first, it->second);
}
+
result.push();
return 1;
@@ -1023,15 +1081,14 @@ int CLuaIHMRyzom::setLuaBreakPoint(CLuaState &ls)
CLuaIHM::checkArgCount(ls, funcName, 2);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER);
+#ifdef LUA_NEVRAX_VERSION
+ if (LuaDebuggerIDE)
+ {
+ LuaDebuggerIDE->setBreakPoint(ls.toString(1), (int) ls.toInteger(2));
+ }
- #ifdef LUA_NEVRAX_VERSION
- if (LuaDebuggerIDE)
- {
- LuaDebuggerIDE->setBreakPoint(ls.toString(1), (int) ls.toInteger(2));
- }
- #endif
-
+#endif
return 0;
}
@@ -1092,18 +1149,20 @@ int CLuaIHMRyzom::enableModalWindow(CLuaState &ls)
CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "enableModalWindow() requires a UI object in param 1");
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
- CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1);
+ CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1);
std::string modalId = ls.toString(2);
// convert to id
- if(pIE)
+ if (pIE)
{
- CCtrlBase * ctrl = dynamic_cast(pIE);
- if(ctrl)
+ CCtrlBase *ctrl = dynamic_cast(pIE);
+
+ if (ctrl)
{
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
- CInterfaceGroup *group= dynamic_cast( CWidgetManager::getInstance()->getElementFromId(modalId) );
- if(group)
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
+ CInterfaceGroup *group = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(modalId));
+
+ if (group)
{
UserControls.stopFreeLook();
@@ -1114,13 +1173,127 @@ int CLuaIHMRyzom::enableModalWindow(CLuaState &ls)
{
nlwarning(" Couldn't find group %s", modalId.c_str());
}
-
}
}
return 0;
}
+int CLuaIHMRyzom::getMousePos(CLuaState &ls)
+{
+ sint32 x, y;
+ CTool::getMousePos(x, y);
+ ls.push(x);
+ ls.push(y);
+
+ return 2;
+}
+
+int CLuaIHMRyzom::getMouseDown(CLuaState &ls)
+{
+ sint32 x, y;
+ bool down;
+ CTool::getMouseDown(down, x, y);
+ ls.push(down);
+ ls.push(x);
+ ls.push(y);
+
+ return 3;
+}
+
+int CLuaIHMRyzom::getMouseMiddleDown(CLuaState &ls)
+{
+ sint32 x, y;
+ bool down;
+ CTool::getMouseMiddleDown(down, x, y);
+
+ ls.push(down);
+ ls.push(x);
+ ls.push(y);
+
+ return 3;
+}
+
+int CLuaIHMRyzom::getMouseRightDown(CLuaState &ls)
+{
+ sint32 x, y;
+ bool down;
+ CTool::getMouseRightDown(down, x, y);
+
+ ls.push(down);
+ ls.push(x);
+ ls.push(y);
+
+ return 3;
+}
+
+
+int CLuaIHMRyzom::getShapeIdAt(CLuaState &ls)
+{
+ const char* funcName = "getShapeIdAt";
+ CLuaIHM::checkArgCount(ls, funcName, 2);
+ CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
+ CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER);
+
+ uint32 x = (uint32)ls.toInteger(1);
+ uint32 y = (uint32)ls.toInteger(2);
+
+ uint32 w, h;
+ CViewRenderer &viewRender = *CViewRenderer::getInstance();
+ viewRender.getScreenSize(w, h);
+ if(x >= w || y >= h) {
+ ls.push(-1);
+ return 1;
+ }
+
+ float cursX = (float)x/(float)w;
+ float cursY = (float)y/(float)h;
+
+ sint32 instance_idx;
+ EntitiesMngr.getShapeInstanceUnderPos(cursX, cursY, instance_idx);
+ ls.push(instance_idx);
+
+ return 1;
+}
+
+int CLuaIHMRyzom::getGroundAtMouse(CLuaState &ls)
+{
+ sint32 x, y;
+ CTool::getMousePos(x, y);
+
+ if (CTool::isInScreen(x, y))
+ {
+ float cursX, cursY;
+ cursX = x / (float) CTool::getScreenWidth();
+ cursY = y / (float) CTool::getScreenHeight();
+ CMatrix camMatrix = MainCam.getMatrix();
+ NL3D::CFrustum camFrust = MainCam.getFrustum();
+ NL3D::CViewport viewport = Driver->getViewport();
+ // Get the Ray made by the mouse.
+ CTool::CWorldViewRay worldViewRay;
+ worldViewRay.OnMiniMap = false;
+ worldViewRay.Valid = true;
+ viewport.getRayWithPoint(cursX, cursY, worldViewRay.Origin, worldViewRay.Dir, camMatrix, camFrust);
+ worldViewRay.Dir.normalize();
+ worldViewRay.Right = camMatrix.getI().normed();
+ worldViewRay.Up = camMatrix.getK().normed();
+ CVector sceneInter;
+ CTool::TRayIntersectionType rayInterType = CTool::computeLandscapeRayIntersection(worldViewRay, sceneInter);
+
+ ls.push(sceneInter.x);
+ ls.push(sceneInter.y);
+ ls.push(sceneInter.z);
+ }
+ else
+ {
+ ls.push(0);
+ ls.push(0);
+ ls.push(0);
+ }
+
+ return 3;
+}
+
// ***************************************************************************
int CLuaIHMRyzom::getPlayerPos(CLuaState &ls)
{
@@ -1185,7 +1358,9 @@ int CLuaIHMRyzom::getTargetPos(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "getTargetPos", 0);
CEntityCL *target = getTargetEntity();
+
if (!target) return 0;
+
ls.push(target->pos().x);
ls.push(target->pos().y);
ls.push(target->pos().z);
@@ -1197,7 +1372,9 @@ int CLuaIHMRyzom::getTargetFront(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "getTargetFront", 0);
CEntityCL *target = getTargetEntity();
+
if (!target) return 0;
+
ls.push(atan2(target->front().y, target->front().x));
return 1;
}
@@ -1207,7 +1384,9 @@ int CLuaIHMRyzom::getTargetDirection(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "getTargetDirection", 0);
CEntityCL *target = getTargetEntity();
+
if (!target) return 0;
+
ls.push(atan2(target->dir().y, target->dir().x));
return 1;
}
@@ -1217,7 +1396,9 @@ int CLuaIHMRyzom::getTargetGender(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "getTargetGender", 0);
CCharacterCL* target = (CCharacterCL*)getTargetEntity();
+
if (!target) return (int)GSGENDER::unknown;
+
ls.push((uint8)target->getGender());
return 1;
}
@@ -1227,7 +1408,9 @@ int CLuaIHMRyzom::getTargetName(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "getTargetName", 0);
CEntityCL *target = getTargetEntity();
+
if (!target) return 0;
+
ls.push(target->getEntityName().toUtf8());
return 1;
}
@@ -1237,7 +1420,9 @@ int CLuaIHMRyzom::getTargetTitleRaw(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "getTargetTitleRaw", 0);
CEntityCL *target = getTargetEntity();
+
if (!target) return 0;
+
ls.push(target->getTitleRaw().toUtf8());
return 1;
}
@@ -1247,7 +1432,9 @@ int CLuaIHMRyzom::getTargetTitle(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "getTargetTitle", 0);
CEntityCL *target = getTargetEntity();
+
if (!target) return 0;
+
ls.push(target->getTitle().toUtf8());
return 1;
}
@@ -1257,15 +1444,19 @@ int CLuaIHMRyzom::addSearchPathUser(CLuaState &ls)
{
//H_AUTO(Lua_CLuaIHM_addSearchPathUser)
bool memoryCompressed = CPath::isMemoryCompressed();
+
if (memoryCompressed)
{
CPath::memoryUncompress();
}
+
CPath::addSearchPath("user/", true, false, NULL);
+
if (memoryCompressed)
{
CPath::memoryCompress();
}
+
return 0;
}
@@ -1301,7 +1492,7 @@ int CLuaIHMRyzom::disableContextHelpForControl(CLuaState &ls)
CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "disableContextHelpForControl() requires a UI object in param 1");
// retrieve args
- CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1);
+ CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1);
// go
CWidgetManager::getInstance()->disableContextHelpForControl(dynamic_cast(pIE));
@@ -1333,6 +1524,7 @@ int CLuaIHMRyzom::isInRingMode(CLuaState &ls)
int CLuaIHMRyzom::getUserRace(CLuaState &ls)
{
CLuaIHM::checkArgCount(ls, "getUserRace", 0);
+
if (!UserEntity || !UserEntity->playerSheet())
{
ls.push("Unknwown");
@@ -1341,6 +1533,7 @@ int CLuaIHMRyzom::getUserRace(CLuaState &ls)
{
ls.push(EGSPD::CPeople::toString(UserEntity->playerSheet()->People));
}
+
return 1;
}
@@ -1351,7 +1544,7 @@ int CLuaIHMRyzom::getSheet2idx(CLuaState &ls)
CLuaIHM::checkArgType(ls, "getSheet2idx", 1, LUA_TSTRING);
CLuaIHM::checkArgType(ls, "getSheet2idx", 2, LUA_TNUMBER);
- const std::string & sheedtName = ls.toString(1);
+ const std::string &sheedtName = ls.toString(1);
uint32 slotId = (uint32)ls.toInteger(2);
NLMISC::CSheetId sheetId;
@@ -1363,6 +1556,7 @@ int CLuaIHMRyzom::getSheet2idx(CLuaState &ls)
}
else
return 0;
+
return 1;
}
@@ -1396,23 +1590,27 @@ int CLuaIHMRyzom::getClientCfgVar(CLuaState &ls)
std::string varName = ls.toString(1);
CConfigFile::CVar *v = ClientCfg.ConfigFile.getVarPtr(varName);
+
if (!v) return 0;
- if(v->size()==1)
+
+ if (v->size() == 1)
{
- switch(v->Type)
+ switch (v->Type)
{
- case CConfigFile::CVar::T_REAL:
- ls.push(v->asDouble());
- return 1;
+ case CConfigFile::CVar::T_REAL:
+ ls.push(v->asDouble());
+ return 1;
break;
- case CConfigFile::CVar::T_STRING:
- ls.push(v->asString());
- return 1;
+
+ case CConfigFile::CVar::T_STRING:
+ ls.push(v->asString());
+ return 1;
break;
- default: // handle both T_INT && T_BOOL
- case CConfigFile::CVar::T_INT:
- ls.push(v->asInt());
- return 1;
+
+ default: // handle both T_INT && T_BOOL
+ case CConfigFile::CVar::T_INT:
+ ls.push(v->asInt());
+ return 1;
break;
}
}
@@ -1421,21 +1619,25 @@ int CLuaIHMRyzom::getClientCfgVar(CLuaState &ls)
ls.newTable();
CLuaObject result(ls);
uint count = 0;
- for(uint i = 0; iStrValues.size(); i++)
+
+ for (uint i = 0; i < v->StrValues.size(); i++)
{
result.setValue(toString(count).c_str(), v->StrValues[i]);
count++;
}
- for(uint i = 0; iIntValues.size(); i++)
+
+ for (uint i = 0; i < v->IntValues.size(); i++)
{
result.setValue(toString(count).c_str(), (sint32)v->IntValues[i]);
count++;
}
- for(uint i = 0; iRealValues.size(); i++)
+
+ for (uint i = 0; i < v->RealValues.size(); i++)
{
result.setValue(toString(count).c_str(), (double)v->RealValues[i]);
count++;
}
+
result.push();
return 1;
}
@@ -1452,7 +1654,7 @@ int CLuaIHMRyzom::displaySystemInfo(CLuaState &ls)
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
ucstring msg;
nlverify(CLuaIHM::getUCStringOnStack(ls, 1, msg));
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
pIM->displaySystemInfo(msg, ls.toString(2));
return 0;
}
@@ -1464,13 +1666,15 @@ int CLuaIHMRyzom::setWeatherValue(CLuaState &ls)
CLuaIHM::checkArgMin(ls, funcName, 1);
CLuaIHM::checkArgMax(ls, funcName, 2);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TBOOLEAN);
-// bool autoWeather = ls.toBoolean(1);
+ // bool autoWeather = ls.toBoolean(1);
ClientCfg.ManualWeatherSetup = !ls.toBoolean(1);
+
if (ls.getTop() == 2)
{
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER);
ManualWeatherValue = (float) ls.toNumber(2);
}
+
return 0;
}
@@ -1492,8 +1696,9 @@ int CLuaIHMRyzom::getUICaller(CLuaState &ls)
// params: none.
// return: CInterfaceElement* (nil if error)
- CInterfaceElement *pIE= CHandlerLUA::getUICaller();
- if(!pIE)
+ CInterfaceElement *pIE = CHandlerLUA::getUICaller();
+
+ if (!pIE)
{
ls.pushNil();
debugInfo(toString("getUICaller(): No UICaller found. return Nil"));
@@ -1502,6 +1707,7 @@ int CLuaIHMRyzom::getUICaller(CLuaState &ls)
{
CLuaIHM::pushUIOnStack(ls, pIE);
}
+
return 1;
}
@@ -1517,11 +1723,11 @@ int CLuaIHMRyzom::getIndexInDB(CLuaState &ls)
CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), "getIndexInDB() requires a UI object in param 1");
// retrieve args
- CInterfaceElement *pIE= CLuaIHM::getUIOnStack(ls, 1);
- CDBCtrlSheet *pCS= dynamic_cast(pIE);
+ CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1);
+ CDBCtrlSheet *pCS = dynamic_cast(pIE);
// get the index in db
- if(pCS)
+ if (pCS)
ls.push(pCS->getIndexInDB());
else
ls.push((sint)0);
@@ -1548,15 +1754,18 @@ int CLuaIHMRyzom::createGroupInstance(CLuaState &ls)
nlwarning("%s : bad key encountered with type %s, string expected.", funcName, it.nextKey().getTypename());
continue;
}
+
if (!it.nextValue().isString())
{
nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str());
continue;
}
+
templateParams.push_back(std::pair(it.nextKey().toString(), it.nextValue().toString())); // strange compilation bug here when I use std::make_pair ... :(
}
CInterfaceManager *im = CInterfaceManager::getInstance();
CInterfaceGroup *result = CWidgetManager::getInstance()->getParser()->createGroupInstance(ls.toString(1), ls.toString(2), templateParams);
+
if (!result)
{
ls.pushNil();
@@ -1565,6 +1774,7 @@ int CLuaIHMRyzom::createGroupInstance(CLuaState &ls)
{
CLuaIHM::pushUIOnStack(ls, result);
}
+
return 1;
}
@@ -1587,31 +1797,37 @@ int CLuaIHMRyzom::createRootGroupInstance(CLuaState &ls)
nlwarning("%s : bad key encountered with type %s, string expected.", funcName, it.nextKey().getTypename());
continue;
}
+
if (!it.nextValue().isString())
{
nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str());
continue;
}
+
templateParams.push_back(std::pair(it.nextKey().toString(), it.nextValue().toString())); // strange compilation bug here when I use std::make_pair ... :(
}
CInterfaceManager *im = CInterfaceManager::getInstance();
- CInterfaceGroup *result = CWidgetManager::getInstance()->getParser()->createGroupInstance(ls.toString(1), "ui:interface:"+string(ls.toString(2)), templateParams);
+ CInterfaceGroup *result = CWidgetManager::getInstance()->getParser()->createGroupInstance(ls.toString(1), "ui:interface:" + string(ls.toString(2)), templateParams);
+
if (!result)
{
ls.pushNil();
}
else
{
- result->setId("ui:interface:"+string(ls.toString(2)));
+ result->setId("ui:interface:" + string(ls.toString(2)));
result->updateCoords();
CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", result);
CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface"));
result->setParent(pRoot);
+
if (pRoot)
pRoot->addGroup(result);
+
result->setActive(true);
CLuaIHM::pushUIOnStack(ls, result);
}
+
return 1;
}
@@ -1634,15 +1850,18 @@ int CLuaIHMRyzom::createUIElement(CLuaState &ls)
nlwarning("%s : bad key encountered with type %s, string expected.", funcName, it.nextKey().getTypename());
continue;
}
+
if (!it.nextValue().isString())
{
nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str());
continue;
}
+
templateParams.push_back(std::pair(it.nextKey().toString(), it.nextValue().toString())); // strange compilation bug here when I use std::make_pair ... :(
}
CInterfaceManager *im = CInterfaceManager::getInstance();
CInterfaceElement *result = CWidgetManager::getInstance()->getParser()->createUIElement(ls.toString(1), ls.toString(2), templateParams);
+
if (!result)
{
ls.pushNil();
@@ -1651,6 +1870,7 @@ int CLuaIHMRyzom::createUIElement(CLuaState &ls)
{
CLuaIHM::pushUIOnStack(ls, result);
}
+
return 1;
}
@@ -1675,17 +1895,19 @@ int CLuaIHMRyzom::displayBubble(CLuaState &ls)
nlwarning("%s : bad key encountered with type %s, string expected.", funcName, it.nextKey().getTypename());
continue;
}
+
if (!it.nextValue().isString())
{
nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str());
continue;
}
+
links.push_back(it.nextValue().toString());
strs.push_back(it.nextKey().toString());
}
-
+
InSceneBubbleManager.webIgChatOpen((uint32)ls.toInteger(1), ls.toString(2), strs, links);
-
+
return 1;
}
@@ -1695,7 +1917,7 @@ int CLuaIHMRyzom::launchContextMenuInGame(CLuaState &ls)
CLuaStackChecker lsc(&ls);
CLuaIHM::checkArgCount(ls, "launchContextMenuInGame", 1);
CLuaIHM::check(ls, ls.isString(1), "launchContextMenuInGame() requires a string in param 1");
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
pIM->launchContextMenuInGame(ls.toString(1));
return 0;
}
@@ -1707,7 +1929,7 @@ int CLuaIHMRyzom::parseInterfaceFromString(CLuaState &ls)
CLuaStackChecker lsc(&ls, 1);
CLuaIHM::checkArgCount(ls, "parseInterfaceFromString", 1);
CLuaIHM::check(ls, ls.isString(1), "parseInterfaceFromString() requires a string in param 1");
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
std::vector script(1);
script[0] = ls.toString(1);
ls.push(pIM->parseInterface(script, true, false));
@@ -1722,14 +1944,16 @@ int CLuaIHMRyzom::updateAllLocalisedElements(CLuaState &ls)
//
CLuaStackChecker lsc(&ls);
CLuaIHM::checkArgCount(ls, "updateAllLocalisedElements", 0);
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
CWidgetManager::getInstance()->updateAllLocalisedElements();
//
TTime endTime = CTime::getLocalTime();
+
if (ClientCfg.R2EDVerboseParseTime)
{
nlinfo("%.2f seconds for 'updateAllLocalisedElements'", (endTime - startTime) / 1000.f);
}
+
return 0;
}
@@ -1745,10 +1969,11 @@ int CLuaIHMRyzom::getCompleteIslands(CLuaState &ls)
// load entryPoints
CScenarioEntryPoints scenarioEntryPoints = CScenarioEntryPoints::getInstance();
- const CScenarioEntryPoints::TCompleteIslands& islands = scenarioEntryPoints.getCompleteIslands();
+ const CScenarioEntryPoints::TCompleteIslands &islands = scenarioEntryPoints.getCompleteIslands();
CScenarioEntryPoints::TCompleteIslands::const_iterator island(islands.begin()), lastIsland(islands.end());
- for( ; island != lastIsland ; ++island)
+
+ for (; island != lastIsland ; ++island)
{
ls.newTable();
CLuaObject islandTable(ls);
@@ -1761,9 +1986,9 @@ int CLuaIHMRyzom::getCompleteIslands(CLuaState &ls)
ls.newTable();
CLuaObject entrypointsTable(ls);
- for(uint e=0; eEntryPoints.size(); e++)
+ for (uint e = 0; e < island->EntryPoints.size(); e++)
{
- const CScenarioEntryPoints::CShortEntryPoint & entryPoint = island->EntryPoints[e];
+ const CScenarioEntryPoints::CShortEntryPoint &entryPoint = island->EntryPoints[e];
ls.newTable();
CLuaObject entrypointTable(ls);
entrypointTable.setValue("x", entryPoint.X);
@@ -1771,6 +1996,7 @@ int CLuaIHMRyzom::getCompleteIslands(CLuaState &ls)
entrypointsTable.setValue(entryPoint.Location, entrypointTable);
}
+
islandTable.setValue("entrypoints", entrypointsTable);
result.setValue(island->Island, islandTable);
@@ -1789,23 +2015,555 @@ int CLuaIHMRyzom::getIslandId(CLuaState &ls)
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::check(ls, ls.isString(1), "getIslandId() requires a string in param 1");
-
CScenarioEntryPoints scenarioEntryPoints = CScenarioEntryPoints::getInstance();
uint32 id = scenarioEntryPoints.getIslandId(ls.toString(1));
ls.push(id);
+ return 1;
+}
+
+// ***************************************************************************
+//
+// addShape("shape", x, y, z, "angle", scale, collision?)
+//
+//********
+int CLuaIHMRyzom::addShape(CLuaState &ls)
+{
+ const char* funcName = "addShape";
+ CLuaIHM::checkArgMin(ls, funcName, 1);
+ CLuaIHM::checkArgMax(ls, funcName, 13);
+ CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
+
+ sint32 idx = -1;
+
+ if (!Scene)
+ {
+ nlwarning("No scene available");
+ ls.pushNil();
+ return 1;
+ }
+
+ string shape = ls.toString(1);
+
+ float x,y,z = 0.0f;
+ float scale = 1.0f;
+ string context,url,skeleton,texture = "";
+ bool highlight, transparency, collision = false;
+
+ if (ls.getTop() >= 2)
+ {
+ CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER);
+ x = (float) ls.toNumber(2);
+ }
+
+ if (ls.getTop() >= 3)
+ {
+ CLuaIHM::checkArgType(ls, funcName, 3, LUA_TNUMBER);
+ y = (float) ls.toNumber(3);
+ }
+
+ if (ls.getTop() >= 4)
+ {
+ CLuaIHM::checkArgType(ls, funcName, 4, LUA_TNUMBER);
+ z = (float) ls.toNumber(4);
+ }
+
+
+ if (x == 0 && y == 0)
+ {
+ x = UserEntity->pos().x;
+ y = UserEntity->pos().y;
+ z = UserEntity->pos().z;
+ }
+
+ CVector userDir = UserEntity->dir();
+
+ if (ls.getTop() >= 5)
+ {
+ CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING);
+ string angle = ls.toString(5);
+
+ if (angle != "user")
+ {
+ float a;
+ fromString(angle, a);
+ userDir = CVector(sin(a), cos(a), 0.f);
+ }
+ }
+
+ if (ls.getTop() >= 6)
+ {
+ CLuaIHM::checkArgType(ls, funcName, 6, LUA_TNUMBER);
+ scale = (float) ls.toNumber(6);
+ }
+
+ if (ls.getTop() >= 7)
+ {
+ CLuaIHM::checkArgType(ls, funcName, 7, LUA_TBOOLEAN);
+ collision = ls.toBoolean(7);
+ }
+
+ if (ls.getTop() >= 8)
+ {
+ CLuaIHM::checkArgType(ls, funcName, 8, LUA_TSTRING);
+ context = ls.toString(8);
+ }
+
+ if (ls.getTop() >= 9)
+ {
+ CLuaIHM::checkArgType(ls, funcName, 9, LUA_TSTRING);
+ url = ls.toString(9);
+ }
+
+ if (ls.getTop() >= 10)
+ {
+ CLuaIHM::checkArgType(ls, funcName, 10, LUA_TBOOLEAN);
+ highlight = ls.toBoolean(10);
+ }
+
+ if (ls.getTop() >= 11)
+ {
+ CLuaIHM::checkArgType(ls, funcName, 11, LUA_TBOOLEAN);
+ transparency = ls.toBoolean(11);
+ }
+
+ if (ls.getTop() >= 12)
+ {
+ CLuaIHM::checkArgType(ls, funcName, 12, LUA_TSTRING);
+ texture = ls.toString(12);
+ }
+
+ if (ls.getTop() >= 13)
+ {
+ CLuaIHM::checkArgType(ls, funcName, 13, LUA_TSTRING);
+ skeleton = ls.toString(13);
+ }
+
+ /// ???????????????
+ transparency = false;
+ highlight = false;
+ collision = true;
+
+ CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector(x, y, z), context, url, collision, idx);
+ UInstance instance = instref.Instance;
+
+ if(!instance.empty())
+ {
+ for(uint j=0;jgetClusterSystem()); // for simplicity, assume it is in the same
+ // cluster system than the user
+ // Compute the direction Matrix
+ CMatrix dir;
+ dir.identity();
+ CVector vi = userDir^CVector(0.f, 0.f, 1.f);
+ CVector vk = vi^userDir;
+ dir.setRot(vi, userDir, vk, true);
+ // Set Orientation : User Direction should be normalized.
+ if (!skeleton.empty())
+ {
+ USkeleton skel = Scene->createSkeleton(skeleton);
+ if (!skel.empty())
+ {
+ skel.bindSkin(instance);
+ skel.setClusterSystem(UserEntity->getClusterSystem());
+ skel.setScale(skel.getScale()*scale);
+ skel.setPos(CVector(x, y, z));
+ skel.setRotQuat(dir.getRot());
+ }
+ }
+ else
+ {
+ instance.setScale(instance.getScale()*scale);
+ instance.setPos(CVector(x, y, z));
+ instance.setRotQuat(dir.getRot());
+ }
+
+ instance.setTransformMode(UTransformable::RotEuler);
+
+ // if the shape is a particle system, additionnal parameters are user params
+ UParticleSystemInstance psi;
+ psi.cast (instance);
+ /*if (!psi.empty())
+ {
+ // set each user param that is present
+ for(uint k = 0; k < 4; ++k)
+ {
+ if (args.size() >= (k + 2))
+ {
+ float uparam;
+ if (fromString(args[k + 1], uparam))
+ {
+ psi.setUserParam(k, uparam);
+ }
+ else
+ {
+ nlwarning("Cant read param %d", k);
+ }
+ }
+ }
+ }*/
+
+ UMovePrimitive *primitive = instref.Primitive;
+ if (primitive)
+ {
+ NLMISC::CAABBox bbox;
+ instance.getShapeAABBox(bbox);
+
+ primitive->setReactionType(UMovePrimitive::Slide);
+ primitive->setTriggerType(UMovePrimitive::NotATrigger);
+ primitive->setAbsorbtion(0);
+
+ primitive->setPrimitiveType(UMovePrimitive::_2DOrientedBox);
+ primitive->setSize((bbox.getMax().x - bbox.getMin().x)*scale, (bbox.getMax().y - bbox.getMin().y)*scale);
+ primitive->setHeight((bbox.getMax().z - bbox.getMin().z)*scale);
+
+ primitive->setCollisionMask(MaskColPlayer | MaskColNpc | MaskColDoor);
+ primitive->setOcclusionMask(MaskColPlayer | MaskColNpc | MaskColDoor);
+ primitive->setObstacle(true);
+
+
+ primitive->setGlobalPosition(instance.getPos(), dynamicWI);
+
+ primitive->insertInWorldImage(dynamicWI);
+ }
+ }
+
+ ls.push(idx);
+ return 1;
+}
+
+int CLuaIHMRyzom::setupShape(CLuaState &ls)
+{
+ const char* funcName = "setupShape";
+ CLuaIHM::checkArgCount(ls, funcName, 2);
+ CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
+ CLuaIHM::checkArgType(ls, funcName, 2, LUA_TTABLE);
+
+ uint32 idx = (uint32)ls.toInteger(1);
+
+ std::vector keys;
+ std::vector values;
+ CLuaObject params;
+ params.pop(ls);
+
+ ENUM_LUA_TABLE(params, it)
+ {
+ if (!it.nextKey().isString())
+ {
+ nlwarning("%s : bad key encountered with type %s, string expected.", funcName, it.nextKey().getTypename());
+ continue;
+ }
+
+ if (!it.nextValue().isString())
+ {
+ nlwarning("%s : bad value encountered with type %s for key %s, string expected.", funcName, it.nextValue().getTypename(), it.nextKey().toString().c_str());
+ continue;
+ }
+
+ values.push_back(it.nextValue().toString());
+ keys.push_back(it.nextKey().toString());
+ }
+
+ if (EntitiesMngr.setupInstance(idx, keys, values))
+ ls.push(1);
+ else
+ ls.pushNil();
+
+ return 1;
+}
+
+int CLuaIHMRyzom::moveShape(CLuaState &ls)
+{
+ const char* funcName = "moveShape";
+ CLuaIHM::checkArgCount(ls, funcName, 4);
+ CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
+ CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
+ CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING);
+ CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING);
+
+ uint32 idx = (uint32)ls.toInteger(1);
+
+ CVector pos = EntitiesMngr.getInstancePos(idx);
+
+ string x = ls.toString(2);
+ string y = ls.toString(3);
+ string z = ls.toString(4);
+
+ float move_x = 0;
+ float move_y = 0;
+ float move_z = 0;
+
+ if (!x.empty())
+ {
+ if (x[0] == '+')
+ {
+ fromString(x.substr(1), move_x);
+ pos.x += move_x;
+ }
+ else
+ {
+ fromString(x, move_x);
+ pos.x = move_x;
+ }
+ }
+
+ if (!y.empty())
+ {
+ if (y[0] == '+')
+ {
+ fromString(y.substr(1), move_y);
+ pos.y += move_y;
+ }
+ else
+ {
+ fromString(y, move_y);
+ pos.y = move_y;
+ }
+ }
+
+ if (!z.empty())
+ {
+ if (z[0] == '+')
+ {
+ fromString(z.substr(1), move_z);
+ pos.z += move_z;
+ }
+ else
+ {
+ fromString(z, move_z);
+ pos.z = move_z;
+ }
+ }
+
+ if (EntitiesMngr.setInstancePos(idx, pos))
+ ls.push(1);
+ else
+ ls.pushNil();
+
+ return 1;
+}
+
+int CLuaIHMRyzom::rotateShape(CLuaState &ls)
+{
+ const char* funcName = "rotateShape";
+ CLuaIHM::checkArgCount(ls, funcName, 4);
+ CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
+ CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
+ CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING);
+ CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING);
+
+ uint32 idx = (uint32)ls.toInteger(1);
+
+ CVector rot = EntitiesMngr.getInstanceRot(idx);
+
+ string x = ls.toString(2);
+ string y = ls.toString(3);
+ string z = ls.toString(4);
+
+ float rot_x = 0;
+ float rot_y = 0;
+ float rot_z = 0;
+
+ if (!x.empty())
+ {
+ if (x[0] == '+')
+ {
+ fromString(x.substr(1), rot_x);
+ rot.x += rot_x;
+ }
+ else
+ {
+ fromString(x, rot_x);
+ rot.x = rot_x;
+ }
+ }
+
+ if (!y.empty())
+ {
+ if (y[0] == '+')
+ {
+ fromString(y.substr(1), rot_y);
+ rot.y += rot_y;
+ }
+ else
+ {
+ fromString(y, rot_y);
+ rot.y = rot_y;
+ }
+ }
+
+ if (!z.empty())
+ {
+ if (z[0] == '+')
+ {
+ fromString(z.substr(1), rot_z);
+ rot.z += rot_z;
+ }
+ else
+ {
+ fromString(z, rot_z);
+ rot.z = rot_z;
+ }
+ }
+
+ if (EntitiesMngr.setInstanceRot(idx, rot))
+ ls.push(1);
+ else
+ ls.pushNil();
+
+ return 1;
+}
+
+int CLuaIHMRyzom::deleteShape(CLuaState &ls)
+{
+ const char* funcName = "deleteShape";
+ CLuaIHM::checkArgCount(ls, funcName, 1);
+ CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
+
+ if (EntitiesMngr.deleteInstance((uint32)ls.toInteger(1)))
+ ls.push(1);
+ else
+ ls.pushNil();
return 1;
}
+int CLuaIHMRyzom::getShapePos(CLuaState &ls)
+{
+ const char* funcName = "getShapePos";
+ CLuaIHM::checkArgCount(ls, funcName, 1);
+ CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
+
+ uint32 idx = (uint32)ls.toInteger(1);
+
+ CVector pos = EntitiesMngr.getInstancePos(idx);
+
+ ls.push(pos.x);
+ ls.push(pos.y);
+ ls.push(pos.z);
+ return 3;
+}
+
+int CLuaIHMRyzom::getShapeRot(CLuaState &ls)
+{
+ const char* funcName = "getShapeRot";
+ CLuaIHM::checkArgCount(ls, funcName, 1);
+ CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
+
+ uint32 idx = (uint32)ls.toInteger(1);
+
+ CVector rot = EntitiesMngr.getInstanceRot(idx);
+
+ ls.push(rot.x);
+ ls.push(rot.y);
+ ls.push(rot.z);
+ return 3;
+}
+
+int CLuaIHMRyzom::getShapeScale(CLuaState &ls)
+{
+ const char* funcName = "getShapeScale";
+ CLuaIHM::checkArgCount(ls, funcName, 1);
+ CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
+
+ uint32 idx = (uint32)ls.toInteger(1);
+
+ CVector scale = EntitiesMngr.getInstanceScale(idx);
+
+ ls.push(scale.x);
+ ls.push(scale.y);
+ ls.push(scale.z);
+ return 3;
+}
+
+int CLuaIHMRyzom::getShapeColPos(CLuaState &ls)
+{
+ const char* funcName = "getShapeColPos";
+ CLuaIHM::checkArgCount(ls, funcName, 1);
+ CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
+
+ uint32 idx = (uint32)ls.toInteger(1);
+
+ CVector pos = EntitiesMngr.getInstanceColPos(idx);
+
+ ls.push(pos.x);
+ ls.push(pos.y);
+ ls.push(pos.z);
+ return 3;
+}
+
+int CLuaIHMRyzom::getShapeColScale(CLuaState &ls)
+{
+ const char* funcName = "getShapeColScale";
+ CLuaIHM::checkArgCount(ls, funcName, 1);
+ CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
+
+ uint32 idx = (uint32)ls.toInteger(1);
+
+ CVector scale = EntitiesMngr.getInstanceColScale(idx);
+
+ ls.push(scale.x);
+ ls.push(scale.y);
+ ls.push(scale.z);
+ return 3;
+}
+
+int CLuaIHMRyzom::getShapeColOrient(CLuaState &ls)
+{
+ const char* funcName = "getShapeColOrient";
+ CLuaIHM::checkArgCount(ls, funcName, 1);
+ CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
+
+ uint32 idx = (uint32)ls.toInteger(1);
+
+ double orient = EntitiesMngr.getInstanceColOrient(idx);
+
+ ls.push(orient);
+ return 1;
+}
+
+
////////////////////////////////////////// Standard Lua stuff ends here //////////////////////////////////////
// ***************************************************************************
sint32 CLuaIHMRyzom::getDbProp(const std::string &dbProp)
{
//H_AUTO(Lua_CLuaIHM_getDbProp)
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
- CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(dbProp, false);
- if(node)
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
+ CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(dbProp, false);
+
+ if (node)
return node->getValue32();
else
{
@@ -1818,14 +2576,15 @@ void CLuaIHMRyzom::setDbProp(const std::string &dbProp, sint32 value)
{
//H_AUTO(Lua_CLuaIHM_setDbProp)
// Do not allow Write on SERVER: or LOCAL:
- static const std::string dbServer= "SERVER:";
- static const std::string dbLocal= "LOCAL:";
- static const std::string dbLocalR2= "LOCAL:R2";
- if( (0==dbProp.compare(0, dbServer.size(), dbServer)) ||
- (0==dbProp.compare(0, dbLocal.size(), dbLocal))
+ static const std::string dbServer = "SERVER:";
+ static const std::string dbLocal = "LOCAL:";
+ static const std::string dbLocalR2 = "LOCAL:R2";
+
+ if ((dbProp.compare(0, dbServer.size(), dbServer) == 0) ||
+ (dbProp.compare(0, dbLocal.size(), dbLocal) == 0)
)
{
- if (0!=dbProp.compare(0, dbLocalR2.size(), dbLocalR2))
+ if (dbProp.compare(0, dbLocalR2.size(), dbLocalR2) != 0)
{
nlstop;
throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database");
@@ -1833,10 +2592,10 @@ void CLuaIHMRyzom::setDbProp(const std::string &dbProp, sint32 value)
}
// Write to the DB if found
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
- CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(dbProp, false);
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
+ CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(dbProp, false);
- if(node)
+ if (node)
node->setValue32(value);
else
debugInfo(toString("setDbProp(): '%s' dbProp Not found", dbProp.c_str()));
@@ -1846,14 +2605,15 @@ void CLuaIHMRyzom::delDbProp(const string &dbProp)
{
//H_AUTO(Lua_CLuaIHM_setDbProp)
// Do not allow Write on SERVER: or LOCAL:
- static const string dbServer= "SERVER:";
- static const string dbLocal= "LOCAL:";
- static const string dbLocalR2= "LOCAL:R2";
- if( (0==dbProp.compare(0, dbServer.size(), dbServer)) ||
- (0==dbProp.compare(0, dbLocal.size(), dbLocal))
+ static const string dbServer = "SERVER:";
+ static const string dbLocal = "LOCAL:";
+ static const string dbLocalR2 = "LOCAL:R2";
+
+ if ((dbProp.compare(0, dbServer.size(), dbServer) == 0) ||
+ (dbProp.compare(0, dbLocal.size(), dbLocal) == 0)
)
{
- if (0!=dbProp.compare(0, dbLocalR2.size(), dbLocalR2))
+ if (dbProp.compare(0, dbLocalR2.size(), dbLocalR2) != 0)
{
nlstop;
throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database");
@@ -1861,7 +2621,7 @@ void CLuaIHMRyzom::delDbProp(const string &dbProp)
}
// Write to the DB if found
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
NLGUI::CDBManager::getInstance()->delDbProp(dbProp);
}
@@ -1869,14 +2629,15 @@ void CLuaIHMRyzom::addDbProp(const std::string &dbProp, sint32 value)
{
//H_AUTO(Lua_CLuaIHM_setDbProp)
// Do not allow Write on SERVER: or LOCAL:
- static const std::string dbServer= "SERVER:";
- static const std::string dbLocal= "LOCAL:";
- static const std::string dbLocalR2= "LOCAL:R2";
- if( (0==dbProp.compare(0, dbServer.size(), dbServer)) ||
- (0==dbProp.compare(0, dbLocal.size(), dbLocal))
+ static const std::string dbServer = "SERVER:";
+ static const std::string dbLocal = "LOCAL:";
+ static const std::string dbLocalR2 = "LOCAL:R2";
+
+ if ((dbProp.compare(0, dbServer.size(), dbServer) == 0) ||
+ (dbProp.compare(0, dbLocal.size(), dbLocal) == 0)
)
{
- if (0!=dbProp.compare(0, dbLocalR2.size(), dbLocalR2))
+ if (dbProp.compare(0, dbLocalR2.size(), dbLocalR2) != 0)
{
nlstop;
throw ELuaIHMException("setDbProp(): You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database");
@@ -1884,9 +2645,10 @@ void CLuaIHMRyzom::addDbProp(const std::string &dbProp, sint32 value)
}
// Write to the DB if found
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
- CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(dbProp, true);
- if(node)
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
+ CCDBNodeLeaf *node = NLGUI::CDBManager::getInstance()->getDbProp(dbProp, true);
+
+ if (node)
node->setValue32(value);
}
@@ -1894,23 +2656,26 @@ void CLuaIHMRyzom::addDbProp(const std::string &dbProp, sint32 value)
void CLuaIHMRyzom::debugInfo(const std::string &cstDbg)
{
//H_AUTO(Lua_CLuaIHM_debugInfo)
- if(ClientCfg.DisplayLuaDebugInfo)
+ if (ClientCfg.DisplayLuaDebugInfo)
{
std::string dbg = cstDbg;
+
if (ClientCfg.LuaDebugInfoGotoButtonEnabled)
{
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
lua_State *ls = CLuaManager::getInstance().getLuaState()->getStatePointer();
lua_Debug luaDbg;
- if(lua_getstack (ls, 1, &luaDbg))
+
+ if (lua_getstack(ls, 1, &luaDbg))
{
- if(lua_getinfo(ls, "lS", &luaDbg))
+ if (lua_getinfo(ls, "lS", &luaDbg))
{
// add a command button to jump to the wanted file
dbg = createGotoFileButtonTag(luaDbg.short_src, luaDbg.currentline) + dbg;
}
}
}
+
rawDebugInfo(dbg);
}
}
@@ -1919,9 +2684,10 @@ void CLuaIHMRyzom::debugInfo(const std::string &cstDbg)
void CLuaIHMRyzom::rawDebugInfo(const std::string &dbg)
{
//H_AUTO(Lua_CLuaIHM_rawDebugInfo)
- if(ClientCfg.DisplayLuaDebugInfo)
+ if (ClientCfg.DisplayLuaDebugInfo)
{
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
+
if (!dbg.empty() && dbg[0] == '@')
{
// if color is already given use the message as it
@@ -1931,13 +2697,16 @@ void CLuaIHMRyzom::rawDebugInfo(const std::string &dbg)
{
NLMISC::InfoLog->displayRawNL(LuaHelperStuff::formatLuaErrorSysInfo(dbg).c_str());
}
- #ifdef LUA_NEVRAX_VERSION
- if (LuaDebuggerIDE)
- {
- LuaDebuggerIDE->debugInfo(dbg.c_str());
- }
- #endif
- pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(dbg));
+
+#ifdef LUA_NEVRAX_VERSION
+
+ if (LuaDebuggerIDE)
+ {
+ LuaDebuggerIDE->debugInfo(dbg.c_str());
+ }
+
+#endif
+ pIM->displaySystemInfo(LuaHelperStuff::formatLuaErrorSysInfo(dbg));
}
}
@@ -1945,43 +2714,47 @@ void CLuaIHMRyzom::rawDebugInfo(const std::string &dbg)
void CLuaIHMRyzom::dumpCallStack(int startStackLevel)
{
//H_AUTO(Lua_CLuaIHM_dumpCallStack)
- if(ClientCfg.DisplayLuaDebugInfo)
+ if (ClientCfg.DisplayLuaDebugInfo)
{
lua_Debug dbg;
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
lua_State *ls = CLuaManager::getInstance().getLuaState()->getStatePointer();
int stackLevel = startStackLevel;
rawDebugInfo("Call stack : ");
rawDebugInfo("-------------");
- while (lua_getstack (ls, stackLevel, &dbg))
+
+ while (lua_getstack(ls, stackLevel, &dbg))
{
- if(lua_getinfo(ls, "lS", &dbg))
+ if (lua_getinfo(ls, "lS", &dbg))
{
std::string result = createGotoFileButtonTag(dbg.short_src, dbg.currentline) + NLMISC::toString("%s:%d:", dbg.short_src, dbg.currentline);
rawDebugInfo(result);
}
+
++ stackLevel;
}
}
}
// ***************************************************************************
-void CLuaIHMRyzom::getCallStackAsString(int startStackLevel /*=0*/,std::string &result)
+void CLuaIHMRyzom::getCallStackAsString(int startStackLevel /*=0*/, std::string &result)
{
//H_AUTO(Lua_CLuaIHM_getCallStackAsString)
result.clear();
lua_Debug dbg;
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
lua_State *ls = CLuaManager::getInstance().getLuaState()->getStatePointer();
int stackLevel = startStackLevel;
result += "Call stack : \n";
result += "-------------";
- while (lua_getstack (ls, stackLevel, &dbg))
+
+ while (lua_getstack(ls, stackLevel, &dbg))
{
- if(lua_getinfo(ls, "lS", &dbg))
+ if (lua_getinfo(ls, "lS", &dbg))
{
result += NLMISC::toString("%s:%d:", dbg.short_src, dbg.currentline);
}
+
++ stackLevel;
}
}
@@ -1990,9 +2763,11 @@ void CLuaIHMRyzom::getCallStackAsString(int startStackLevel /*=0*/,std::string &
std::string CLuaIHMRyzom::getDefine(const std::string &def)
{
//H_AUTO(Lua_CLuaIHM_getDefine)
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
- if(ClientCfg.DisplayLuaDebugInfo && !CWidgetManager::getInstance()->getParser()->isDefineExist(def))
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
+
+ if (ClientCfg.DisplayLuaDebugInfo && !CWidgetManager::getInstance()->getParser()->isDefineExist(def))
debugInfo(toString("getDefine(): '%s' not found", def.c_str()));
+
return CWidgetManager::getInstance()->getParser()->getDefine(def);
}
@@ -2006,7 +2781,7 @@ void CLuaIHMRyzom::setContextHelpText(const ucstring &text)
void CLuaIHMRyzom::messageBox(const ucstring &text)
{
//H_AUTO(Lua_CLuaIHM_messageBox)
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
pIM->messageBox(text);
}
@@ -2014,7 +2789,7 @@ void CLuaIHMRyzom::messageBox(const ucstring &text)
void CLuaIHMRyzom::messageBox(const ucstring &text, const std::string &masterGroup)
{
//H_AUTO(Lua_CLuaIHM_messageBox)
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
pIM->messageBox(text, masterGroup);
}
@@ -2025,8 +2800,9 @@ void CLuaIHMRyzom::messageBox(const ucstring &text, const std::string &masterGr
{
throw ELuaIHMException("messageBox: case mode value is invalid.");
}
+
//H_AUTO(Lua_CLuaIHM_messageBox)
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
pIM->messageBox(text, masterGroup, (TCaseMode) caseMode);
}
@@ -2035,11 +2811,13 @@ void CLuaIHMRyzom::messageBox(const std::string &text)
{
//H_AUTO(Lua_CLuaIHM_messageBox)
static volatile bool dumpCallStack = false;
+
if (dumpCallStack)
{
CLuaIHMRyzom::dumpCallStack(0);
}
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
pIM->messageBox(text);
}
@@ -2047,7 +2825,7 @@ void CLuaIHMRyzom::messageBox(const std::string &text)
void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text)
{
//H_AUTO(Lua_CLuaIHM_messageBox)
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
pIM->messageBoxWithHelp(text);
}
@@ -2055,7 +2833,7 @@ void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text)
void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &masterGroup)
{
//H_AUTO(Lua_CLuaIHM_messageBox)
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
pIM->messageBoxWithHelp(text, masterGroup);
}
@@ -2066,9 +2844,10 @@ void CLuaIHMRyzom::messageBoxWithHelp(const ucstring &text, const std::string &
{
throw ELuaIHMException("messageBoxWithHelp: case mode value is invalid.");
}
+
//H_AUTO(Lua_CLuaIHM_messageBox)
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
- pIM->messageBoxWithHelp(text, masterGroup, "" ,"", (TCaseMode) caseMode);
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
+ pIM->messageBoxWithHelp(text, masterGroup, "" , "", (TCaseMode) caseMode);
}
// ***************************************************************************
@@ -2076,11 +2855,13 @@ void CLuaIHMRyzom::messageBoxWithHelp(const std::string &text)
{
//H_AUTO(Lua_CLuaIHM_messageBox)
static volatile bool dumpCallStack = false;
+
if (dumpCallStack)
{
CLuaIHMRyzom::dumpCallStack(0);
}
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
+
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
pIM->messageBoxWithHelp(text);
}
@@ -2089,33 +2870,39 @@ bool CLuaIHMRyzom::executeFunctionOnStack(CLuaState &ls, int numArgs, int nu
{
//H_AUTO(Lua_CLuaIHM_executeFunctionOnStack)
static volatile bool dumpFunction = false;
+
if (dumpFunction)
{
CLuaStackRestorer lsr(&ls, ls.getTop());
lua_Debug ar;
ls.pushValue(-1 - numArgs);
- lua_getinfo (ls.getStatePointer(), ">lS", &ar);
+ lua_getinfo(ls.getStatePointer(), ">lS", &ar);
nlwarning((std::string(ar.what) + ", at line " + toString(ar.linedefined) + " in " + std::string(ar.source)).c_str());
}
+
int result = ls.pcall(numArgs, numRet);
+
switch (result)
{
- case LUA_ERRRUN:
- case LUA_ERRMEM:
- case LUA_ERRERR:
- {
- debugInfo(ls.toString(-1));
- ls.pop();
- return false;
- }
+ case LUA_ERRRUN:
+ case LUA_ERRMEM:
+ case LUA_ERRERR:
+ {
+ debugInfo(ls.toString(-1));
+ ls.pop();
+ return false;
+ }
+ break;
+
+ case 0:
+ return true;
break;
- case 0:
- return true;
- break;
- default:
- nlassert(0);
+
+ default:
+ nlassert(0);
break;
}
+
return false;
}
@@ -2129,6 +2916,7 @@ ucstring CLuaIHMRyzom::replacePvpEffectParam(const ucstring &str, sint32 paramet
// Locate parameter and store it
p = s.splitTo('%', true);
+
while (p.size() > 0 && s.size() > 0)
{
if (s[0] == 'p' || s[0] == 'n' || s[0] == 'r')
@@ -2137,6 +2925,7 @@ ucstring CLuaIHMRyzom::replacePvpEffectParam(const ucstring &str, sint32 paramet
paramString += s[0];
break;
}
+
p = s.splitTo('%', true);
}
@@ -2148,14 +2937,17 @@ ucstring CLuaIHMRyzom::replacePvpEffectParam(const ucstring &str, sint32 paramet
switch (paramString[1])
{
case 'p':
- p = toString("%.1f %%", parameter/100.0);
+ p = toString("%.1f %%", parameter / 100.0);
break;
+
case 'n':
p = toString(parameter);
break;
+
case 'r':
- p = toString("%.1f", parameter/100.0);
+ p = toString("%.1f", parameter / 100.0);
break;
+
default:
debugInfo("Bad arguments in " + str.toString() + " : " + paramString);
}
@@ -2170,10 +2962,11 @@ sint32 CLuaIHMRyzom::secondsSince1970ToHour(sint32 seconds)
{
//H_AUTO(Lua_CLuaIHM_secondsSince1970ToHour)
// convert to readable form
- struct tm *tstruct;
- time_t tval= seconds;
- tstruct= gmtime(&tval);
- if(!tstruct)
+ struct tm *tstruct;
+ time_t tval = seconds;
+ tstruct = gmtime(&tval);
+
+ if (!tstruct)
{
debugInfo(toString("Bad Date Received: %d", seconds));
return 0;
@@ -2201,6 +2994,7 @@ void CLuaIHMRyzom::requestBGDownloaderPriority(uint priority)
{
throw NLMISC::Exception("requestBGDownloaderPriority() : invalid priority");
}
+
CBGDownloaderAccess::getInstance().requestDownloadThreadPriority((BGDownloader::TThreadPriority) priority, false);
}
@@ -2227,7 +3021,7 @@ ucstring CLuaIHMRyzom::getPatchLastErrorMessage()
// ***************************************************************************
bool CLuaIHMRyzom::isInGame()
{
- CInterfaceManager *pIM = CInterfaceManager::getInstance();
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
return pIM->isInGame();
}
@@ -2242,8 +3036,9 @@ bool CLuaIHMRyzom::isPlayerSlotNewbieLand(uint32 slot)
{
if (slot > CharacterSummaries.size())
{
- throw ELuaIHMException("isPlayerSlotNewbieLand(): Invalid slot %d", (int) slot);
+ throw ELuaIHMException("isPlayerSlotNewbieLand(): Invalid slot %d", (int) slot);
}
+
return CharacterSummaries[slot].InNewbieland;
}
@@ -2251,10 +3046,12 @@ bool CLuaIHMRyzom::isPlayerSlotNewbieLand(uint32 slot)
sint32 CLuaIHMRyzom::getSkillIdFromName(const std::string &def)
{
//H_AUTO(Lua_CLuaIHM_getSkillIdFromName)
- SKILLS::ESkills e= SKILLS::toSkill(def);
+ SKILLS::ESkills e = SKILLS::toSkill(def);
+
// Avoid any bug, return SF if not found
- if(e>=SKILLS::unknown)
- e= SKILLS::SF;
+ if (e >= SKILLS::unknown)
+ e = SKILLS::SF;
+
return e;
}
@@ -2269,7 +3066,7 @@ ucstring CLuaIHMRyzom::getSkillLocalizedName(sint32 skillId)
sint32 CLuaIHMRyzom::getMaxSkillValue(sint32 skillId)
{
//H_AUTO(Lua_CLuaIHM_getMaxSkillValue)
- CSkillManager *pSM= CSkillManager::getInstance();
+ CSkillManager *pSM = CSkillManager::getInstance();
return pSM->getMaxSkillValue((SKILLS::ESkills)skillId);
}
@@ -2277,7 +3074,7 @@ sint32 CLuaIHMRyzom::getMaxSkillValue(sint32 skillId)
sint32 CLuaIHMRyzom::getBaseSkillValueMaxChildren(sint32 skillId)
{
//H_AUTO(Lua_CLuaIHM_getBaseSkillValueMaxChildren)
- CSkillManager *pSM= CSkillManager::getInstance();
+ CSkillManager *pSM = CSkillManager::getInstance();
return pSM->getBaseSkillValueMaxChildren((SKILLS::ESkills)skillId);
}
@@ -2285,15 +3082,15 @@ sint32 CLuaIHMRyzom::getBaseSkillValueMaxChildren(sint32 skillId)
sint32 CLuaIHMRyzom::getMagicResistChance(bool elementalSpell, sint32 casterSpellLvl, sint32 victimResistLvl)
{
//H_AUTO(Lua_CLuaIHM_getMagicResistChance)
- CSPhraseManager *pPM= CSPhraseManager::getInstance();
- casterSpellLvl= std::max(casterSpellLvl, sint32(0));
- victimResistLvl= std::max(victimResistLvl, sint32(0));
+ CSPhraseManager *pPM = CSPhraseManager::getInstance();
+ casterSpellLvl = std::max(casterSpellLvl, sint32(0));
+ victimResistLvl = std::max(victimResistLvl, sint32(0));
/* The success rate in the table is actually the "Casting Success Chance".
Thus, the relativeLevel is casterSpellLvl - victimResistLvl
Moreover, must take the "PartialSuccessMaxDraw" line because the spell is not resisted if success>0
*/
- sint32 chanceToHit= pPM->getSuccessRate(elementalSpell?CSPhraseManager::STResistMagic:CSPhraseManager::STResistMagicLink,
- casterSpellLvl-victimResistLvl, true);
+ sint32 chanceToHit = pPM->getSuccessRate(elementalSpell ? CSPhraseManager::STResistMagic : CSPhraseManager::STResistMagicLink,
+ casterSpellLvl - victimResistLvl, true);
clamp(chanceToHit, 0, 100);
// Thus, the resist chance is 100 - hit chance.
@@ -2304,11 +3101,11 @@ sint32 CLuaIHMRyzom::getMagicResistChance(bool elementalSpell, sint32 casterSp
sint32 CLuaIHMRyzom::getDodgeParryChance(sint32 attLvl, sint32 defLvl)
{
//H_AUTO(Lua_CLuaIHM_getDodgeParryChance)
- CSPhraseManager *pPM = CSPhraseManager::getInstance();
- attLvl= std::max(attLvl, sint32(0));
- defLvl= std::max(defLvl, sint32(0));
+ CSPhraseManager *pPM = CSPhraseManager::getInstance();
+ attLvl = std::max(attLvl, sint32(0));
+ defLvl = std::max(defLvl, sint32(0));
- sint32 chance = pPM->getSuccessRate(CSPhraseManager::STDodgeParry, defLvl-attLvl, false);
+ sint32 chance = pPM->getSuccessRate(CSPhraseManager::STDodgeParry, defLvl - attLvl, false);
clamp(chance, 0, 100);
return chance;
@@ -2318,20 +3115,22 @@ sint32 CLuaIHMRyzom::getDodgeParryChance(sint32 attLvl, sint32 defLvl)
void CLuaIHMRyzom::browseNpcWebPage(const std::string &htmlId, const std::string &urlIn, bool addParameters, double timeout)
{
//H_AUTO(Lua_CLuaIHM_browseNpcWebPage)
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
- CGroupHTML *groupHtml= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(htmlId));
- if(groupHtml)
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
+ CGroupHTML *groupHtml = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(htmlId));
+
+ if (groupHtml)
{
// if true, it means that we want to display a web page that use webig auth
bool webig = urlIn.find("http://") == 0;
string url;
+
// append the WebServer to the url
if (urlIn.find("ring_access_point=1") != std::string::npos)
{
url = RingMainURL + "?" + urlIn;
}
- else if(webig)
+ else if (webig)
{
url = urlIn;
}
@@ -2345,12 +3144,13 @@ void CLuaIHMRyzom::browseNpcWebPage(const std::string &htmlId, const std::string
// append shardid, playername and language code
string userName;
string guildName;
- if(UserEntity)
+
+ if (UserEntity)
{
- userName = UserEntity->getDisplayName ().toString();
+ userName = UserEntity->getDisplayName().toString();
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
ucstring ucsTmp;
- pSMC->getString (UserEntity->getGuildNameID(), ucsTmp);
+ pSMC->getString(UserEntity->getGuildNameID(), ucsTmp);
guildName = ucsTmp.toString();
while (guildName.find(' ') != string::npos)
@@ -2360,18 +3160,19 @@ void CLuaIHMRyzom::browseNpcWebPage(const std::string &htmlId, const std::string
}
url += ((url.find('?') != string::npos) ? "&" : "?") +
- string("shard=") + toString(ShardId) +
- string("&user_login=") + userName +
- string("&lang=") + ClientCfg.getHtmlLanguageCode() +
- string("&guild_name=") + guildName;
+ string("shard=") + toString(ShardId) +
+ string("&user_login=") + userName +
+ string("&lang=") + ClientCfg.getHtmlLanguageCode() +
+ string("&guild_name=") + guildName;
}
-/* Already added by GroupHtml
- if(webig)
- {
- // append special webig auth params
- addWebIGParams(url);
- }
-*/
+
+ /* Already added by GroupHtml
+ if(webig)
+ {
+ // append special webig auth params
+ addWebIGParams(url);
+ }
+ */
// set the wanted timeout
groupHtml->setTimeout((float)std::max(0.0, timeout));
@@ -2380,6 +3181,7 @@ void CLuaIHMRyzom::browseNpcWebPage(const std::string &htmlId, const std::string
groupHtml->browse(url.c_str());
// Set top of the page
CCtrlScroll *pScroll = groupHtml->getScrollBar();
+
if (pScroll != NULL)
pScroll->moveTrackY(10000);
}
@@ -2390,9 +3192,10 @@ void CLuaIHMRyzom::browseNpcWebPage(const std::string &htmlId, const std::string
void CLuaIHMRyzom::clearHtmlUndoRedo(const std::string &htmlId)
{
//H_AUTO(Lua_CLuaIHM_clearHtmlUndoRedo)
- CInterfaceManager *pIM= CInterfaceManager::getInstance();
- CGroupHTML *groupHtml= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(htmlId));
- if(groupHtml)
+ CInterfaceManager *pIM = CInterfaceManager::getInstance();
+ CGroupHTML *groupHtml = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(htmlId));
+
+ if (groupHtml)
groupHtml->clearUndoRedo();
}
@@ -2425,7 +3228,9 @@ std::string CLuaIHMRyzom::getSheetType(const std::string &sheet)
{
//H_AUTO(Lua_CLuaIHM_getSheetType)
const CEntitySheet *sheetPtr = SheetMngr.get(CSheetId(sheet));
+
if (!sheetPtr) return "";
+
return CEntitySheet::typeToString(sheetPtr->Type);
}
@@ -2455,7 +3260,7 @@ sint32 CLuaIHMRyzom::getFameDBIndex(sint32 fameIndex)
{
//H_AUTO(Lua_CLuaIHM_getFameDBIndex)
// Yoyo: avoid crash if fames not initialized
- if(CStaticFames::getInstance().getNbFame()==0)
+ if (CStaticFames::getInstance().getNbFame() == 0)
return 0;
else
return CStaticFames::getInstance().getDatabaseIndex(fameIndex);
@@ -2525,6 +3330,7 @@ string CLuaIHMRyzom::getGuildMemberName(sint32 nMemberId)
//H_AUTO(Lua_CLuaIHM_getGuildMemberName)
if ((nMemberId < 0) || (nMemberId >= getNbGuildMembers()))
return "";
+
return CGuildManager::getInstance()->getGuildMembers()[nMemberId].Name.toString();
}
@@ -2534,6 +3340,7 @@ string CLuaIHMRyzom::getGuildMemberGrade(sint32 nMemberId)
//H_AUTO(Lua_CLuaIHM_getGuildMemberGrade)
if ((nMemberId < 0) || (nMemberId >= getNbGuildMembers()))
return "";
+
return EGSPD::CGuildGrade::toString(CGuildManager::getInstance()->getGuildMembers()[nMemberId].Grade);
}
@@ -2542,9 +3349,13 @@ bool CLuaIHMRyzom::isR2Player(const std::string &sheet)
{
//H_AUTO(Lua_CLuaIHM_isR2Player)
const CEntitySheet *entitySheet = SheetMngr.get(CSheetId(sheet));
+
if (!entitySheet) return false;
- const CCharacterSheet *chSheet = dynamic_cast(entitySheet);
- if(!chSheet) return false;
+
+ const CCharacterSheet *chSheet = dynamic_cast(entitySheet);
+
+ if (!chSheet) return false;
+
return chSheet->R2Npc;
}
@@ -2553,9 +3364,13 @@ std::string CLuaIHMRyzom::getR2PlayerRace(const std::string &sheet)
{
//H_AUTO(Lua_CLuaIHM_getR2PlayerRace)
const CEntitySheet *entitySheet = SheetMngr.get(CSheetId(sheet));
+
if (!entitySheet) return "";
- const CCharacterSheet *chSheet = dynamic_cast(entitySheet);
- if(!chSheet) return "";
+
+ const CCharacterSheet *chSheet = dynamic_cast(entitySheet);
+
+ if (!chSheet) return "";
+
return EGSPD::CPeople::toString(chSheet->Race);
}
@@ -2564,9 +3379,12 @@ bool CLuaIHMRyzom::isR2PlayerMale(const std::string &sheet)
{
//H_AUTO(Lua_CLuaIHM_isR2PlayerMale)
const CEntitySheet *entitySheet = SheetMngr.get(CSheetId(sheet));
+
if (!entitySheet) return true;
- const CCharacterSheet *chSheet = dynamic_cast(entitySheet);
- if(!chSheet) return true;
+
+ const CCharacterSheet *chSheet = dynamic_cast(entitySheet);
+
+ if (!chSheet) return true;
return (chSheet->Gender == GSGENDER::male);
}
@@ -2576,10 +3394,14 @@ std::string CLuaIHMRyzom::getCharacterSheetSkel(const std::string &sheet, bool i
{
//H_AUTO(Lua_CLuaIHM_getCharacterSheetSkel)
const CEntitySheet *sheetPtr = SheetMngr.get(CSheetId(sheet));
- const CCharacterSheet *charSheet = dynamic_cast(sheetPtr);
+ const CCharacterSheet *charSheet = dynamic_cast(sheetPtr);
+
if (charSheet) return charSheet->getSkelFilename();
- const CRaceStatsSheet *raceStatSheet = dynamic_cast(sheetPtr);
+
+ const CRaceStatsSheet *raceStatSheet = dynamic_cast(sheetPtr);
+
if (raceStatSheet) return raceStatSheet->GenderInfos[isMale ? 0 : 1].Skelfilename;
+
return "";
}
@@ -2594,8 +3416,10 @@ sint32 CLuaIHMRyzom::getSheetId(const std::string &itemName)
sint CLuaIHMRyzom::getCharacterSheetRegionForce(const std::string &sheet)
{
//H_AUTO(Lua_CLuaIHM_getCharacterSheetRegionForce)
- const CCharacterSheet *charSheet = dynamic_cast(SheetMngr.get(CSheetId(sheet)));
+ const CCharacterSheet *charSheet = dynamic_cast(SheetMngr.get(CSheetId(sheet)));
+
if (!charSheet) return 0;
+
return charSheet->RegionForce;
}
@@ -2603,8 +3427,10 @@ sint CLuaIHMRyzom::getCharacterSheetRegionForce(const std::string &sheet)
sint CLuaIHMRyzom::getCharacterSheetRegionLevel(const std::string &sheet)
{
//H_AUTO(Lua_CLuaIHM_getCharacterSheetRegionLevel)
- const CCharacterSheet *charSheet = dynamic_cast(SheetMngr.get(CSheetId(sheet)));
+ const CCharacterSheet *charSheet = dynamic_cast(SheetMngr.get(CSheetId(sheet)));
+
if (!charSheet) return 0;
+
return charSheet->RegionForce;
}
@@ -2615,16 +3441,24 @@ string CLuaIHMRyzom::getRegionByAlias(uint32 alias)
return ContinentMngr.getRegionNameByAlias(alias);
}
-
sint32 CLuaIHMRyzom::getGroundZ(uint32 x, sint32 y)
{
- CVector vect = CVector(x, y, 0);
- nlinfo("TEST");
+ CVector vect = UserEntity->pos();
+ vect.x = x;
+ vect.y = y;
+
UserEntity->getCollisionEntity()->snapToGround(vect);
- nlinfo("Ground Z of (%d,%d) = %d", x, y, vect.z);
+
return vect.z;
}
+void setMouseCursor(const std::string &texture)
+{
+ if (texture.empty())
+ CTool::setMouseCursor("curs_default.tga");
+ else
+ CTool::setMouseCursor(texture);
+}
// ***************************************************************************
void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg)
@@ -2637,16 +3471,19 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg)
{
// Parse any tokens in the message.
ucstring msg_modified = msg;
+
// Parse any tokens in the text
- if ( ! CInterfaceManager::parseTokens(msg_modified))
+ if (! CInterfaceManager::parseTokens(msg_modified))
{
return;
}
+
ChatMngr.tell(player.toUtf8(), msg_modified);
}
else
{
CChatWindow *w = PeopleInterraction.ChatGroup.Window;
+
if (w)
{
CInterfaceManager *im = CInterfaceManager::getInstance();
@@ -2654,10 +3491,12 @@ void CLuaIHMRyzom::tell(const ucstring &player, const ucstring &msg)
w->enableBlink(1);
w->setCommand(ucstring("tell ") + CEntityCL::removeTitleFromName(player) + ucstring(" "), false);
CGroupEditBox *eb = w->getEditBox();
+
if (eb != NULL)
{
eb->bypassNextKey();
}
+
if (w->getContainer())
{
w->getContainer()->setActive(true);
@@ -2673,9 +3512,10 @@ bool CLuaIHMRyzom::isRingAccessPointInReach()
{
//H_AUTO(Lua_CLuaIHM_isRingAccessPointInReach)
if (BotChatPageAll->RingSessions->RingAccessPointPos == CVector::Null) return false;
+
const CVectorD &vect1 = BotChatPageAll->RingSessions->RingAccessPointPos;
CVectorD vect2 = UserEntity->pos();
- double distanceSquare = pow(vect1.x-vect2.x,2) + pow(vect1.y-vect2.y,2);
+ double distanceSquare = pow(vect1.x - vect2.x, 2) + pow(vect1.y - vect2.y, 2);
return distanceSquare <= MaxTalkingDistSquare;
}
@@ -2691,8 +3531,10 @@ bool CLuaIHMRyzom::isCtrlKeyDown()
//H_AUTO(Lua_CLuaIHM_isCtrlKeyDown)
bool ctrlDown = Driver->AsyncListener.isKeyDown(KeyLCONTROL) ||
Driver->AsyncListener.isKeyDown(KeyRCONTROL);
+
if (ctrlDown) nlwarning("ctrl down");
else nlwarning("ctrl up");
+
return ctrlDown;
}
@@ -2707,7 +3549,8 @@ std::string CLuaIHMRyzom::encodeURLUnicodeParam(const ucstring &text)
sint32 CLuaIHMRyzom::getPlayerLevel()
{
if (!UserEntity) return -1;
- CSkillManager *pSM= CSkillManager::getInstance();
+
+ CSkillManager *pSM = CSkillManager::getInstance();
uint32 maxskill = pSM->getBestSkillValue(SKILLS::SC);
maxskill = std::max(maxskill, pSM->getBestSkillValue(SKILLS::SF));
maxskill = std::max(maxskill, pSM->getBestSkillValue(SKILLS::SH));
@@ -2718,21 +3561,21 @@ sint32 CLuaIHMRyzom::getPlayerLevel()
// ***************************************************************************
sint64 CLuaIHMRyzom::getPlayerVpa()
{
- sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64();
+ sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64();
return prop;
}
// ***************************************************************************
sint64 CLuaIHMRyzom::getPlayerVpb()
{
- sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64();
+ sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64();
return prop;
}
// ***************************************************************************
sint64 CLuaIHMRyzom::getPlayerVpc()
{
- sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64();
+ sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64();
return prop;
}
@@ -2740,22 +3583,29 @@ sint64 CLuaIHMRyzom::getPlayerVpc()
sint32 CLuaIHMRyzom::getTargetLevel()
{
CEntityCL *target = getTargetEntity();
+
if (!target) return -1;
- if ( target->isPlayer() )
+
+ if (target->isPlayer())
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CCDBNodeLeaf *pDbPlayerLevel = NLGUI::CDBManager::getInstance()->getDbProp( CWidgetManager::getInstance()->getParser()->getDefine("target_player_level") );
+ CCDBNodeLeaf *pDbPlayerLevel = NLGUI::CDBManager::getInstance()->getDbProp(CWidgetManager::getInstance()->getParser()->getDefine("target_player_level"));
return pDbPlayerLevel ? pDbPlayerLevel->getValue32() : -1;
}
else
{
CCharacterSheet *pCS = dynamic_cast(SheetMngr.get(target->sheetId()));
- if(!pCS) return -1;
+
+ if (!pCS) return -1;
+
// only display the consider if the target is attackable #523
- if(!pCS->Attackable) return -1;
- if(!target->properties().attackable()) return -1;
+ if (!pCS->Attackable) return -1;
+
+ if (!target->properties().attackable()) return -1;
+
return sint32(pCS->Level);
}
+
return -1;
}
@@ -2774,7 +3624,7 @@ sint64 CLuaIHMRyzom::getTargetVpa()
CEntityCL *target = getTargetEntity();
if (!target) return 0;
- sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64();
+ sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64();
return prop;
}
@@ -2785,7 +3635,7 @@ sint64 CLuaIHMRyzom::getTargetVpb()
CEntityCL *target = getTargetEntity();
if (!target) return 0;
- sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64();
+ sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64();
return prop;
}
@@ -2796,36 +3646,42 @@ sint64 CLuaIHMRyzom::getTargetVpc()
CEntityCL *target = getTargetEntity();
if (!target) return 0;
- sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E"+toString("%d", getTargetSlotNr())+":P"+toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64();
+ sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64();
return prop;
}
// ***************************************************************************
sint32 CLuaIHMRyzom::getTargetForceRegion()
-{
+{
CEntityCL *target = getTargetEntity();
+
if (!target) return -1;
- if ( target->isPlayer() )
- {
+
+ if (target->isPlayer())
+ {
CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CCDBNodeLeaf *pDbPlayerLevel = NLGUI::CDBManager::getInstance()->getDbProp( CWidgetManager::getInstance()->getParser()->getDefine("target_player_level") );
+ CCDBNodeLeaf *pDbPlayerLevel = NLGUI::CDBManager::getInstance()->getDbProp(CWidgetManager::getInstance()->getParser()->getDefine("target_player_level"));
+
if (!pDbPlayerLevel) return -1;
+
sint nLevel = pDbPlayerLevel->getValue32();
- if ( nLevel < 250 )
- {
- return (sint32) ((nLevel < 20) ? 1 : (nLevel / 50) + 2);
+
+ if (nLevel < 250)
+ {
+ return (sint32)((nLevel < 20) ? 1 : (nLevel / 50) + 2);
}
else
- {
+ {
return 8;
}
}
else
- {
+ {
CCharacterSheet *pCS = dynamic_cast(SheetMngr.get(target->sheetId()));
return pCS ? (sint32) pCS->RegionForce : -1;
- }
+ }
+
return 0;
}
@@ -2833,16 +3689,21 @@ sint32 CLuaIHMRyzom::getTargetForceRegion()
sint32 CLuaIHMRyzom::getTargetLevelForce()
{
CEntityCL *target = getTargetEntity();
+
if (!target) return -1;
- if ( target->isPlayer() )
+
+ if (target->isPlayer())
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
- CCDBNodeLeaf *pDbPlayerLevel = NLGUI::CDBManager::getInstance()->getDbProp( CWidgetManager::getInstance()->getParser()->getDefine("target_player_level") );
+ CCDBNodeLeaf *pDbPlayerLevel = NLGUI::CDBManager::getInstance()->getDbProp(CWidgetManager::getInstance()->getParser()->getDefine("target_player_level"));
+
if (!pDbPlayerLevel) return -1;
+
sint nLevel = pDbPlayerLevel->getValue32();
- if ( nLevel < 250 )
+
+ if (nLevel < 250)
{
- return (sint32) (((nLevel % 50) * 5 / 50) + 1);
+ return (sint32)(((nLevel % 50) * 5 / 50) + 1);
}
else
{
@@ -2854,6 +3715,7 @@ sint32 CLuaIHMRyzom::getTargetLevelForce()
CCharacterSheet *pCS = dynamic_cast(SheetMngr.get(target->sheetId()));
return pCS ? (sint32) pCS->ForceLevel : -1;
}
+
return 0;
}
@@ -2861,7 +3723,9 @@ sint32 CLuaIHMRyzom::getTargetLevelForce()
bool CLuaIHMRyzom::isTargetNPC()
{
CEntityCL *target = getTargetEntity();
+
if (!target) return false;
+
return target->isNPC();
}
@@ -2869,7 +3733,9 @@ bool CLuaIHMRyzom::isTargetNPC()
bool CLuaIHMRyzom::isTargetPlayer()
{
CEntityCL *target = getTargetEntity();
+
if (!target) return false;
+
return target->isPlayer();
}
@@ -2878,7 +3744,9 @@ bool CLuaIHMRyzom::isTargetPlayer()
bool CLuaIHMRyzom::isTargetUser()
{
CEntityCL *target = getTargetEntity();
+
if (!target) return false;
+
return target->isUser();
}
@@ -2886,6 +3754,7 @@ bool CLuaIHMRyzom::isTargetUser()
bool CLuaIHMRyzom::isPlayerInPVPMode()
{
if (!UserEntity) return false;
+
return (UserEntity->getPvpMode() & PVP_MODE::PvpFaction || UserEntity->getPvpMode() & PVP_MODE::PvpFactionFlagged || UserEntity->getPvpMode() & PVP_MODE::PvpZoneFaction) != 0;
}
@@ -2893,7 +3762,9 @@ bool CLuaIHMRyzom::isPlayerInPVPMode()
bool CLuaIHMRyzom::isTargetInPVPMode()
{
CEntityCL *target = getTargetEntity();
+
if (!target) return false;
+
return (target->getPvpMode() & PVP_MODE::PvpFaction || target->getPvpMode() & PVP_MODE::PvpFactionFlagged || target->getPvpMode() & PVP_MODE::PvpZoneFaction) != 0;
}
@@ -2906,14 +3777,13 @@ std::string CLuaIHMRyzom::createGotoFileButtonTag(const char *fileName, uint lin
// TODO nico : put this in the interface
// add a command button to jump to the wanted file
return toString("/$$%s|%s|lua|%s('%s', %d)$$/",
- ClientCfg.LuaDebugInfoGotoButtonTemplate.c_str(),
- ClientCfg.LuaDebugInfoGotoButtonCaption.c_str(),
- ClientCfg.LuaDebugInfoGotoButtonFunction.c_str(),
- fileName,
- line
- );
+ ClientCfg.LuaDebugInfoGotoButtonTemplate.c_str(),
+ ClientCfg.LuaDebugInfoGotoButtonCaption.c_str(),
+ ClientCfg.LuaDebugInfoGotoButtonFunction.c_str(),
+ fileName,
+ line
+ );
}
+
return "";
}
-
-
diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h
index 43033d81c..b4712a253 100644
--- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h
+++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h
@@ -106,6 +106,16 @@ private:
static int getCompleteIslands(CLuaState &ls);
static int getIslandId(CLuaState &ls);//TEMP
+ static int addShape(CLuaState &ls);
+ static int moveShape(CLuaState &ls);
+ static int rotateShape(CLuaState &ls);
+ static int getShapePos(CLuaState &ls);
+ static int getShapeScale(CLuaState &ls);
+ static int getShapeRot(CLuaState &ls);
+ static int getShapeColPos(CLuaState &ls);
+ static int getShapeColScale(CLuaState &ls);
+ static int getShapeColOrient(CLuaState &ls);
+ static int deleteShape(CLuaState &ls);
///////////////////////////// Standard Lua stuff ends here //////////////////////////////////////////////
@@ -202,6 +212,14 @@ private:
static sint getCharacterSheetRegionLevel(const std::string &sheet);
static std::string getRegionByAlias(uint32 alias);
static sint getGroundZ(uint32 x, sint32 y);
+ static int getGroundAtMouse(CLuaState &ls);
+ static int getMousePos(CLuaState &ls);
+ static int getMouseDown(CLuaState &ls);
+ static int getMouseMiddleDown(CLuaState &ls);
+ static int getMouseRightDown(CLuaState &ls);
+ static int getShapeIdAt(CLuaState &ls);
+ static int setupShape(CLuaState &ls);
+ static void setMouseCursor(const std::string &texture);
// open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly
// else, current command of the chat window will be replaced with tell 'player'
static void tell(const ucstring &player, const ucstring &msg);
diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp
index cf3368726..565c23311 100644
--- a/code/ryzom/client/src/main_loop.cpp
+++ b/code/ryzom/client/src/main_loop.cpp
@@ -274,6 +274,7 @@ CTimedFXManager::TDebugDisplayMode ShowTimedFXMode = CTimedFXManager::NoText;
// DEBUG
bool PACSBorders = false;
+bool ARKPACSBorders = false;
bool DebugClusters = false;
CVector LastDebugClusterCameraThirdPersonStart= CVector::Null;
CVector LastDebugClusterCameraThirdPersonEnd= CVector::Null;
@@ -1796,6 +1797,12 @@ bool mainLoop()
displayPACSPrimitive();
}
+ // Display PACS borders only (for ARK).
+ if (ARKPACSBorders)
+ {
+ displayPACSPrimitive();
+ }
+
// display Sound box
if (SoundBox)
{
@@ -2505,6 +2512,8 @@ bool mainLoop()
// R2ED enabled ?
R2::getEditor().autoConfigInit(IsInRingSession);
+ if (!IsInRingSession)
+ R2::getEditor().registerLuaFunc();
CurrSeason = computeCurrSeason();
diff --git a/code/ryzom/client/src/misc.cpp b/code/ryzom/client/src/misc.cpp
index 111f0cbb2..0f87b8037 100644
--- a/code/ryzom/client/src/misc.cpp
+++ b/code/ryzom/client/src/misc.cpp
@@ -1507,3 +1507,44 @@ bool getRyzomModes(std::vector &videoModes, std::vector -1;
}
+
+// Get float value from string. Return true if the value is relatif ( src = "+15.5" for example )
+bool getRelativeFloatFromString(const std::string src, float &dst)
+{
+ dst = 0;
+ if (src.empty())
+ return false;
+
+ if (src[0] == '+')
+ return fromString(src.substr(1), dst);
+ else
+ fromString(src, dst);
+
+ return false;
+}
+
+void updateVector(const string part, CVector &dst, float value, bool add /* = false */)
+{
+ string p = part;
+ if (part.size() > 1)
+ p = part.substr(part.size()-1, 1);
+
+ if (add)
+ {
+ if (p == "x")
+ dst.x += value;
+ else if (p == "y")
+ dst.y += value;
+ else if (p == "z")
+ dst.z += value;
+ }
+ else
+ {
+ if (p == "x")
+ dst.x = value;
+ else if (p == "y")
+ dst.y = value;
+ else if (p == "z")
+ dst.z = value;
+ }
+}
diff --git a/code/ryzom/client/src/misc.h b/code/ryzom/client/src/misc.h
index d7b86755d..9ba48b718 100644
--- a/code/ryzom/client/src/misc.h
+++ b/code/ryzom/client/src/misc.h
@@ -168,6 +168,9 @@ std::string getStringCategory(const ucstring &src, ucstring &dest, bool alwaysAd
// Get the category from the string (src="&SYS&Who are you?" and dest="Who are you?" and return "SYS"), if no category, return ""
std::string getStringCategoryIfAny(const ucstring &src, ucstring &dest);
+bool getRelativeFloatFromString(const std::string src, float &dst);
+void updateVector(const std::string part, NLMISC::CVector &dst, float value, bool add = false);
+
// Number of shortcut
#define RYZOM_MAX_SHORTCUT 20
diff --git a/code/ryzom/client/src/r2/editor.h b/code/ryzom/client/src/r2/editor.h
index 8b1c371eb..48a9c6a50 100644
--- a/code/ryzom/client/src/r2/editor.h
+++ b/code/ryzom/client/src/r2/editor.h
@@ -893,6 +893,7 @@ public:
static NLMISC::CCDBNodeLeaf *getPlotItemSheetDBLeaf(uint index);
static bool getIsStartingScenario() { return _IsStartingScenario; }
bool isClearingContent() const { return _ClearingContent; }
+ void registerLuaFunc();
private:
void initPlotItems();
@@ -925,7 +926,7 @@ private:
void initObjectProjectionMetatable();
void registerDisplayers();
void registerTools();
- void registerLuaFunc();
+
// add a C++ method in the environement
void registerEnvMethod(const char *name, TLuaWrappedFunction func);
void registerEnvFunction(const char *name, TLuaWrappedFunction func);
diff --git a/code/ryzom/client/src/r2/tool.cpp b/code/ryzom/client/src/r2/tool.cpp
index 995394b94..bcbe7f5ac 100644
--- a/code/ryzom/client/src/r2/tool.cpp
+++ b/code/ryzom/client/src/r2/tool.cpp
@@ -165,6 +165,47 @@ void CTool::getMousePos(sint32 &x, sint32 &y)
cursor->getPointerPos(x, y);
}
+// ***************************************************************
+void CTool::getMouseDown(bool &down, sint32 &x, sint32 &y)
+{
+ down = false;
+ //H_AUTO(R2_CTool_getMousePos)
+ CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
+ if(cursor == NULL)
+ {
+ x = y = -1;
+ return;
+ }
+ down = cursor->getPointerDown(x, y);
+}
+
+// ***************************************************************
+void CTool::getMouseMiddleDown(bool &down, sint32 &x, sint32 &y)
+{
+ //H_AUTO(R2_CTool_getMousePos)
+ CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
+ if(cursor == NULL)
+ {
+ x = y = -1;
+ return;
+ }
+ down = cursor->getPointerMiddleDown(x, y);
+}
+
+// ***************************************************************
+void CTool::getMouseRightDown(bool &down, sint32 &x, sint32 &y)
+{
+ //H_AUTO(R2_CTool_getMousePos)
+ CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
+ if(cursor == NULL)
+ {
+ x = y = -1;
+ return;
+ }
+ down = cursor->getPointerRightDown(x, y);
+}
+
+
// ***************************************************************
sint32 CTool::getMouseX()
{
@@ -446,13 +487,16 @@ bool CTool::computeNearestValidSurfaceFromHeightMap(float x, float y, NLMISC::CV
sint mapX = (sint) (x - islandDesc->XMin);
sint mapY = (sint) (y - islandDesc->YMin);
+
if (mapX < 0 || mapY < 0 || mapX >= (islandDesc->XMax - islandDesc->XMin) || mapY >= (islandDesc->YMax - islandDesc->YMin)) return false;
sint hmZ = heightMap(mapX, mapY);
if (hmZ >= 0x7ffe) return false; // not an accessible pos
+
if (!isIslandValidPos(heightMap, *islandDesc, x + 0.5f, y) ||
!isIslandValidPos(heightMap, *islandDesc, x - 0.5f, y) ||
!isIslandValidPos(heightMap, *islandDesc, x, y + 0.5f) ||
!isIslandValidPos(heightMap, *islandDesc, x, y - 0.5f)) return false;
+
float z = 1.f + 2.f * hmZ;
// this is a possibly valid position
// compute nearest surface from here, and see if not far from the intersection
@@ -471,6 +515,7 @@ bool CTool::computeNearestValidSurfaceFromHeightMap(float x, float y, NLMISC::CV
inter1Found = inter1Found && normal1.z >= minAngleSin;
inter2Found = inter2Found && normal2.z >= minAngleSin;
if (!inter1Found && !inter2Found) return false;
+
if (inter1Found && inter2Found)
{
// because z in heightmap in usually a 'ceil' of real height, tends to favor surface below
@@ -752,7 +797,7 @@ bool CTool::isMouseCaptured()
}
// *********************************************************************************************************
-void CTool::setMouseCursor(const char *cursorTexture)
+void CTool::setMouseCursor(const std::string &cursorTexture)
{
//H_AUTO(R2_CTool_setMouseCursor)
CViewPointer *cursor = static_cast< CViewPointer* >( CWidgetManager::getInstance()->getPointer() );
@@ -901,5 +946,4 @@ NLMISC::CRGBA CTool::getInvalidPosColor()
}
-
} // R2
diff --git a/code/ryzom/client/src/r2/tool.h b/code/ryzom/client/src/r2/tool.h
index d36c514c1..ee6b4fa27 100644
--- a/code/ryzom/client/src/r2/tool.h
+++ b/code/ryzom/client/src/r2/tool.h
@@ -213,13 +213,18 @@ public:
static CInterfaceManager &getUI();
// Get mouse position
static void getMousePos(sint32 &x, sint32 &y) ;
+ // Get if mouse are clicked down and position of last down click
+ static void getMouseDown(bool &down, sint32 &x, sint32 &y);
+ // Get if mouse are middle clicked down and position of last down click
+ static void getMouseMiddleDown(bool &down, sint32 &x, sint32 &y);
+ // Get if mouse are right clicked down and position of last down click
+ static void getMouseRightDown(bool &down, sint32 &x, sint32 &y);
// Get mouse x position
static sint32 getMouseX();
// Get mouse y position
static sint32 getMouseY();
// Set the current mouse cursor
- static void setMouseCursor(const char *cursorTexture);
- static void setMouseCursor(const std::string &cursorTexture) { setMouseCursor(cursorTexture.c_str()); }
+ static void setMouseCursor(const std::string &cursorTexture);
/** Compute a view vector (with its direction z set to 1) from coordinate of the mouse on screen
* If the mouse is on the island map, then a vector looking down from heights will be returned
*/
diff --git a/code/ryzom/client/src/r2/tool_choose_pos.cpp b/code/ryzom/client/src/r2/tool_choose_pos.cpp
index c41597656..64d0b9d7f 100644
--- a/code/ryzom/client/src/r2/tool_choose_pos.cpp
+++ b/code/ryzom/client/src/r2/tool_choose_pos.cpp
@@ -414,21 +414,21 @@ void CToolChoosePos::updateBeforeRender()
{
if (_MultiPos && isShiftDown() && !_MultiPosLocked)
{
- setMouseCursor(_CursValidMulti.c_str());
+ setMouseCursor(_CursValidMulti);
}
else
{
- setMouseCursor(_CursValid.c_str());
+ setMouseCursor(_CursValid);
}
}
else
{
- setMouseCursor(_CursInvalid.c_str());
+ setMouseCursor(_CursInvalid);
}
}
else
{
- setMouseCursor(_CursValid.c_str());
+ setMouseCursor(_CursValid);
}
}
diff --git a/code/ryzom/client/src/r2/tool_create_entity.cpp b/code/ryzom/client/src/r2/tool_create_entity.cpp
index c29209b43..7c6af14c5 100644
--- a/code/ryzom/client/src/r2/tool_create_entity.cpp
+++ b/code/ryzom/client/src/r2/tool_create_entity.cpp
@@ -596,7 +596,7 @@ void CToolCreateEntity::updateBeforeRender()
}
CGroupMap *worldMap = getWorldMap();
if (worldMap) worldMap->setSelectionAxis(_ValidArray);
- setMouseCursor(_ValidArray ? _CursValid.c_str() : _CursInvalid.c_str());
+ setMouseCursor(_ValidArray ? _CursValid : _CursInvalid);
}
// ***************************************************************
diff --git a/code/ryzom/server/src/ai_service/ai_bot_fauna.cpp b/code/ryzom/server/src/ai_service/ai_bot_fauna.cpp
index 84bc47bf1..53afcd30a 100644
--- a/code/ryzom/server/src/ai_service/ai_bot_fauna.cpp
+++ b/code/ryzom/server/src/ai_service/ai_bot_fauna.cpp
@@ -1060,7 +1060,6 @@ void CMovementMagnet::update(uint32 waitTime, uint32 ticksSinceLastUpdate, bool
BeginMove:
_State=Movement_Move;
getNewDestination (_BotFauna.wpos(), _denyFlags); // drop through to Move
- _Speed=_BotFauna.walkSpeed();
case Movement_Move:
{
@@ -1070,6 +1069,7 @@ void CMovementMagnet::update(uint32 waitTime, uint32 ticksSinceLastUpdate, bool
float distToDest=(float)_PathCont.getDestination().quickDistTo(_BotFauna.pos());
distToDest-=((_BotFauna.getPersistent().getChildIndex()&7)+1.5f);
+ _Speed=_BotFauna.walkSpeed();
float dist=_Speed*ticksSinceLastUpdate;
CAIVector lastPos=_BotFauna.pos();
{
|