From 8da20b30cc049745946ca9d1328dc060f0ba9236 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 18 Dec 2016 20:39:16 +0100 Subject: [PATCH] Changed: Merged changes from compatibility-develop that should also be in develop --HG-- branch : develop --- code/nel/include/nel/gui/group_menu.h | 3 + code/nel/include/nel/gui/view_pointer_base.h | 13 +- code/nel/src/gui/group_html.cpp | 1 - code/nel/src/gui/group_menu.cpp | 43 +- code/nel/src/gui/view_pointer_base.cpp | 49 +- .../data/gamedev/interfaces_v3/commands.xml | 6 + .../data/gamedev/interfaces_v3/json.lua | 376 ++++ .../gamedev/interfaces_v3/ryzhome_toolbar.lua | 242 +++ .../gamedev/interfaces_v3/ryzhome_toolbar.xml | 445 +++++ .../data/gamedev/interfaces_v3/sceneedit.lua | 590 +++++++ .../gamedev/interfaces_v3/webig_widgets.xml | 2 + code/ryzom/client/src/client_cfg.cpp | 2 +- code/ryzom/client/src/cursor_functions.cpp | 40 +- code/ryzom/client/src/entities.cpp | 404 ++++- code/ryzom/client/src/entities.h | 29 +- code/ryzom/client/src/input.cpp | 16 + .../src/interface_v3/action_handler_debug.cpp | 11 + .../src/interface_v3/action_handler_game.cpp | 25 +- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 1536 +++++++++++++---- .../client/src/interface_v3/lua_ihm_ryzom.h | 18 + code/ryzom/client/src/main_loop.cpp | 9 + code/ryzom/client/src/misc.cpp | 41 + code/ryzom/client/src/misc.h | 3 + code/ryzom/client/src/r2/editor.h | 3 +- code/ryzom/client/src/r2/tool.cpp | 48 +- code/ryzom/client/src/r2/tool.h | 9 +- code/ryzom/client/src/r2/tool_choose_pos.cpp | 8 +- .../client/src/r2/tool_create_entity.cpp | 2 +- .../server/src/ai_service/ai_bot_fauna.cpp | 2 +- 29 files changed, 3580 insertions(+), 396 deletions(-) create mode 100644 code/ryzom/client/data/gamedev/interfaces_v3/json.lua create mode 100644 code/ryzom/client/data/gamedev/interfaces_v3/ryzhome_toolbar.lua create mode 100644 code/ryzom/client/data/gamedev/interfaces_v3/ryzhome_toolbar.xml create mode 100644 code/ryzom/client/data/gamedev/interfaces_v3/sceneedit.lua 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 @@ + + + + + +