Changed: Merged changes from compatibility-develop that should also be in develop

This commit is contained in:
kervala 2016-12-18 20:39:16 +01:00
parent 8cbdf6917a
commit 44a7872135
29 changed files with 3580 additions and 396 deletions

View file

@ -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);
};

View file

@ -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 ?

View file

@ -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

View file

@ -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)
{

View file

@ -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;
}
// --------------------------------------------------------------------------------------------------------------------

View file

@ -63,9 +63,15 @@
<command name="target" action="target" params="entity=$" />
<command name="tar" action="target" params="entity=$" />
<command name="target_quiet" action="target" params="entity=$|quiet=true" />
<command name="tarq" action="target" params="entity=$|quiet=true" />
<command name="target" action="target" params="entity=$|prefer_complete_match=$" />
<command name="tar" action="target" params="entity=$|prefer_complete_match=$" />
<command name="target_quiet" action="target" params="entity=$|prefer_complete_match=$|quiet=true" />
<command name="tarq" action="target" params="entity=$|prefer_complete_match=$|quiet=true" />
<command name="target" action="no_target" params="" />
<command name="tar" action="no_target" params="" />

View file

@ -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

View file

@ -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.."&amp;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

View file

@ -0,0 +1,445 @@
<interface_config>
<root id="interface" x="0" y="0" w="800" h="600" active="true" />
<lua file="ryzhome_toolbar.lua" />
<style style="button_over"
type="button"
id="button_over"
button_type="push_button"
posref="TR TR"
x="0"
y="0"
h="39"
w="44"
scale="true"
tx_over="W_button_32_over.tga"
global_color_normal="false"
global_color_pushed="false" />
<group type="container"
id="webig_ryzhome_toolbar"
x="0" y="0" w="200" h="56" posref="MM MM"
max_w="1600" pop_max_w="1600"
max_h="1600" pop_max_h="1600"
min_w="26" pop_min_w="26"
min_h="26" pop_min_h="26"
title=""
global_color="true"
global_color_over="true"
header_active="false"
right_button="false"
options="layer0_pad"
movable="true"
active="true"
opened="true"
openable="false"
resizer="false">
<group id="header_closed" x="0" y="0" w="0" h="0" posref="TL TL"></group>
<group id="header_opened" x="0" y="0" w="0" h="0" wmin="5" sizeref="w" posref="TL TL"></group>
<group id="content" x="0#" y="0#" w="200" h="56" posref="TL TL">
<view id="action_title"
type="text"
posref="TL TL"
x="2"
y="-2"
color="255 255 255 255"
fontsize="12"
shadow="true"
global_color="false"
hardtext="Ryzhome" />
<ctrl id="close"
type="button"
style="button_close"
button_type="push_button"
posref="TR TR"
x="1"
y="1"
tx_normal="w_win_close.tga"
tx_pushed="w_win_close.tga"
tooltip="uiNoteClose"
onclick_l="lua"
params_l="RyzhomeBar:close()"/>
<ctrl id="config"
type="button"
style="button_close"
button_type="push_button"
posref="TL TR"
posparent="close"
x="-2"
y="-1"
tx_normal="r2ed_permanent_pins.tga"
tx_pushed="r2ed_permanent_pins.tga"
tooltip="uiCreateUserLM"
onclick_l="lua"
params_l="RyzhomeBar:saveConfig()"/>
<ctrl id="add"
type="button"
style="button_over"
button_type="toggle_button"
posref="BL BL"
x="3"
y="0"
tx_normal="ryzhome_add_item.png"
tx_pushed="ryzhome_add_item.png"
tx_over="W_button_32_over.tga"
tooltip="uiPeopleAdd"
onclick_l="lua"
params_l="RyzhomeBar:addItems()"/>
<view id="new_items_quantity"
type="text"
posref="BL BL"
posparent="add"
x="-1"
y="-1"
color="255 200 0 255"
global_color="false"
fontsize="16"
shadow="true"
hardtext="" />
<ctrl id="move"
type="button"
style="button_over"
button_type="toggle_button"
posref="BR BL"
posparent="add"
x="3"
y="0"
tx_normal="ryzhome_move_item.png"
tx_pushed="ryzhome_move_item.png"
tx_over="W_button_32_over.tga"
tooltip="uimMoveTo"
onclick_l="lua"
params_l="RyzhomeBar:moveItems()"/>
<ctrl id="remove"
type="button"
style="button_over"
posref="BR BL"
posparent="move"
x="3"
tx_normal="ryzhome_remove_item.png"
tx_pushed="ryzhome_remove_item.png"
tx_over="W_button_32_over.tga"
tooltip="uimRemove"
onclick_l="lua"
params_l="RyzhomeBar:removeItems()"/>
<ctrl id="invite"
type="button"
style="button_over"
posref="BR BL"
posparent="remove"
x="3"
tx_normal="ryzhome_invite.png"
tx_pushed="ryzhome_invite.png"
tx_over="W_button_32_over.tga"
tooltip="uiRAP_Invite"
onclick_l="lua"
params_l="RyzhomeBar:inviteFriend()"/>
</group>
</group>
<tree node="webig_ryzhome_toolbar"></tree>
<style style="button_over"
id="over"
posref="TL TL"
render_layer="-1"
y="1" w="600" h="44" scale="true"
button_type="push_button"
tx_normal="blank.tga"
tx_pushed="blank.tga"
tx_over="blank.tga"
color="255 255 255 0"
col_over="255 255 255 64"
col_pushed="255 255 255 128"
global_color_over="false" />
<group id="webig_ryzhome_list_item"
style="bot_chat_window"
posref="MM MM"
min_w="316"
max_w="316"
max_h="420"
min_h="420"
w="316"
h="420"
x="0"
y="0"
pop_max_h="700"
active="false"
title=""
modal_parent="gestionsets">
<group id="header_opened"
child_resize_hmargin="24"
w="600"
h="420"
x="0"
y="0"
posref="TL TL">
<view id="action_title"
type="text"
posref="TL TL"
x="2"
y="-25"
color="255 255 255 255"
fontsize="12"
shadow="true"
hardtext="uiSelectMission" />
<ctrl id="page_next"
type="button"
posref="TR TR"
x="-2"
y="-20"
tx_normal="W_arrow_right_0.tga"
tx_pushed="W_arrow_right_0.tga"
tooltip="uiKeyNEXT"
onclick_l="lua"
params_l="RyzhomeBar:movePage(1)" />
<view id="page"
type="text"
posref="TL TR"
posparent="page_next"
x="-2"
y="0"
color="255 255 255 255"
fontsize="12"
shadow="true"
hardtext="1/1" />
<ctrl id="page_previous"
type="button"
posref="TL TR"
posparent="page"
x="-2"
y="0"
tx_normal="w_arrow_left_0.tga"
tx_pushed="w_arrow_left_0.tga"
tooltip="uiKeyPRIOR"
onclick_l="lua"
params_l="RyzhomeBar:movePage(-1)" />
<group id="scroll_text"
sizeref="w"
posref="TL TL"
w="0"
y="-40"
child_resize_h="false"
child_resize_hmargin="8">
<instance template="inner_thin_border_group" />
<group id="text_list"
posref="TL TL"
x="12"
y="-4"
sizeref="w"
max_h="380"
child_resize_h="true" >
<view type="bitmap" id="icon1" posref="TL TL" texture="r2ed_toolbar_freeze.tga" global_color="false" />
<view type="text" id="text1" posref="TR TL" posparent="icon1" fontsize="10" x="5" y="-5" hardtext="" />
<view type="text" id="info1" posref="BL TL" color="55 205 55 205" posparent="text1" fontsize="10" x="10" y="-5" hardtext="" />
<ctrl type="button" id="but1" posparent="icon1" style="button_over" onover="lua" params_over="RyzhomeBar:highlightItem(1)" onclick_l="lua" params_l="RyzhomeBar:useItem(1)" />
<view type="bitmap" id="icon2" posparent="but1" posref="BL TL" y="-4" texture="r2ed_toolbar_freeze.tga" global_color="false" />
<view type="text" id="text2" posref="TR TL" posparent="icon2" fontsize="10" x="5" y="-5" hardtext="" />
<view type="text" id="info2" posref="BL TL" color="55 205 55 205" posparent="text2" fontsize="10" x="10" y="-5" hardtext="" />
<ctrl type="button" id="but2" posparent="icon2" style="button_over" onover="lua" params_over="RyzhomeBar:highlightItem(2)" onclick_l="lua" params_l="RyzhomeBar:useItem(2)" />
<view type="bitmap" id="icon3" posparent="but2" posref="BL TL" y="-4" texture="r2ed_toolbar_freeze.tga" global_color="false" />
<view type="text" id="text3" posref="TR TL" posparent="icon3" fontsize="10" x="5" y="-5" hardtext="" />
<view type="text" id="info3" posref="BL TL" color="55 205 55 205" posparent="text3" fontsize="10" x="10" y="-5" hardtext="" />
<ctrl type="button" id="but3" posparent="icon3" style="button_over" onover="lua" params_over="RyzhomeBar:highlightItem(3)" onclick_l="lua" params_l="RyzhomeBar:useItem(3)" />
<view type="bitmap" id="icon4" posparent="but3" posref="BL TL" y="-4" texture="r2ed_toolbar_freeze.tga" global_color="false" />
<view type="text" id="text4" posref="TR TL" posparent="icon4" fontsize="10" x="5" y="-5" hardtext="" />
<view type="text" id="info4" posref="BL TL" color="55 205 55 205" posparent="text4" fontsize="10" x="10" y="-5" hardtext="" />
<ctrl type="button" id="but4" posparent="icon4" style="button_over" onover="lua" params_over="RyzhomeBar:highlightItem(4)" onclick_l="lua" params_l="RyzhomeBar:useItem(4)" />
<view type="bitmap" id="icon5" posparent="but4" posref="BL TL" y="-4" texture="r2ed_toolbar_freeze.tga" global_color="false" />
<view type="text" id="text5" posref="TR TL" posparent="icon5" fontsize="10" x="5" y="-5" hardtext="" />
<view type="text" id="info5" posref="BL TL" color="55 205 55 205" posparent="text5" fontsize="10" x="10" y="-5" hardtext="" />
<ctrl type="button" id="but5" posparent="icon5" style="button_over" onover="lua" params_over="RyzhomeBar:highlightItem(5)" onclick_l="lua" params_l="RyzhomeBar:useItem(5)" />
<view type="bitmap" id="icon6" posparent="but5" posref="BL TL" y="-4" texture="r2ed_toolbar_freeze.tga" global_color="false" />
<view type="text" id="text6" posref="TR TL" posparent="icon6" fontsize="10" x="5" y="-5" hardtext="" />
<view type="text" id="info6" posref="BL TL" color="55 205 55 205" posparent="text6" fontsize="10" x="10" y="-5" hardtext="" />
<ctrl type="button" id="but6" posparent="icon6" style="button_over" onover="lua" params_over="RyzhomeBar:highlightItem(6)" onclick_l="lua" params_l="RyzhomeBar:useItem(6)" />
<view type="bitmap" id="icon7" posparent="but6" posref="BL TL" y="-4" texture="r2ed_toolbar_freeze.tga" global_color="false" />
<view type="text" id="text7" posref="TR TL" posparent="icon7" fontsize="10" x="5" y="-5" hardtext="" />
<view type="text" id="info7" posref="BL TL" color="55 205 55 205" posparent="text7" fontsize="10" x="10" y="-5" hardtext="" />
<ctrl type="button" id="but7" posparent="icon7" style="button_over" onover="lua" params_over="RyzhomeBar:highlightItem(7)" onclick_l="lua" params_l="RyzhomeBar:useItem(7)" />
<view type="bitmap" id="icon8" posparent="but7" posref="BL TL" y="-4" texture="r2ed_toolbar_freeze.tga" global_color="false" />
<view type="text" id="text8" posref="TR TL" posparent="icon8" fontsize="10" x="5" y="-5" hardtext="" />
<view type="text" id="info8" posref="BL TL" color="55 205 55 205" posparent="text8" fontsize="10" x="10" y="-5" hardtext="" />
<ctrl type="button" id="but8" posparent="icon8" style="button_over" onover="lua" params_over="RyzhomeBar:highlightItem(8)" onclick_l="lua" params_l="RyzhomeBar:useItem(8)" />
</group>
<ctrl style="skin_scroll"
id="scroll_row"
posref="TL TL"
target_stepy="44"
target="text_list" />
<group id="list"
max_sizeref="h"
max_sizeparent="parent"
max_h="0"
sizeref="w"
posref="TL TL"
x="8"
y="0"
w="-16" />
</group>
</group>
</group>
<tree node="webig_ryzhome_list_item"></tree>
<template name="t_webig_ryzhome_button">
<ctrl type="button"
button_type="push_button"
id="#id"
posref="TL TL"
x="#x"
y="#y"
tx_normal="#tx_normal"
global_color="false"
tooltip="#tooltip"
onclick_l="lua"
params_l="#params_l"/>
<view type="bitmap"
id="i_#id"
posref="TL TL"
x="#x"
y="#y"
rot="#rot"
texture="#texture"
global_color="false"/>
</template>
<group type="container"
id="webig_ryzhome_place_item"
x="0" y="0" w="200" h="140" posref="TL TL"
title=""
global_color="true"
global_color_over="true"
header_active="false"
right_button="false"
options="layer0_pad"
movable="true"
active="true"
opened="true"
openable="false"
resizer="false">
<group id="header_closed" x="0" y="0" w="0" h="0" posref="TL TL"></group>
<group id="header_opened" x="0" y="0" w="0" h="0" wmin="5" sizeref="w" posref="TL TL"></group>
<group id="content" x="0" y="0" w="400" h="140" posref="TL TL">
<view type="text"
id="item"
posref="TL TL"
x="2"
y="-4"
color="255 255 255 255"
shadow="true"
global_color="false"
fontsize="10"
hardtext="" />
<ctrl style="text_button_16"
id="quit"
posref="TR TR"
x="-2"
y="-2"
hardtext="uiClose"
onclick_l="lua"
params_l="RyzhomePlace:close()" />
<!--
<view type="bitmap" id="black" x="2" y="0" w="200" h="150" posref="ML ML" inherit_gc_alpha="true" scale="true" texture="blank.tga" color="0 0 0 240"/>
<scene3d id="scene3d" x="2" y="0" w="200" h="150" posref="ML ML" curcam="cam" curcs="env" render_layer="-2" active="false"
user_interaction="true" rotz_factor="0.017"
roty_factor="0.005" roty_limit_min="-80" roty_limit_max="90"
dist_factor="0.05" dist_limit_min="1" dist_limit_max="20.0"
ambient="128 96 64" sun_ambient="0 0 0" sun_diffuse="255 255 196" sun_specular="0 0 0" sun_direction="-1.0 1.0 -1.0" >
<camera id="cam" fov="80" pos="0.0 20.0 0" target="0.0 26.5 2" roll="0" />
<light id="back" pos="0.0 28.2 1.6" color="255 255 255" near="2.5" far="4.0" />
<light id="lgt" pos="0.0 25.3 2.48" color="255 255 255" near="3.0" far="4.0" />
<shape id="shape" name="" pos="0.0 26.5 0.0" rot="0.0 0.0 0.0" />
</scene3d>
-->
<group id="movers" x="0" y="-4" w="182" h="140" posref="MM MM">
<instance template="t_webig_ryzhome_button" id="previous_x2" rot="2" x="2" y="-16" tooltip="ll" texture="mp3_button_next.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:move(-0.1, 0, 0)" />
<instance template="t_webig_ryzhome_button" id="previous_x" rot="2" x="32" y="-16" tooltip="ll" texture="mp3_button_play.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:move(-0.01, 0, 0)" />
<view type="text" id="x" posref="TL TL" x="76" y="-20" color="255 255 255 255" shadow="true" global_color="false" fontsize="10" hardtext="Axe X" />
<instance template="t_webig_ryzhome_button" id="next_x" rot="0" x="130" y="-16" tooltip="ll" texture="mp3_button_play.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:move(0.01, 0, 0)" />
<instance template="t_webig_ryzhome_button" id="next_x2" rot="0" x="160" y="-16" tooltip="ll" texture="mp3_button_next.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:move(0.1, 0, 0)" />
<instance template="t_webig_ryzhome_button" id="previous_y2" rot="2" x="2" y="-34" tooltip="ll" texture="mp3_button_next.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:move(0, -0.1, 0)" />
<instance template="t_webig_ryzhome_button" id="previous_y" rot="2" x="32" y="-34" tooltip="ll" texture="mp3_button_play.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:move(0, -0.01, 0)" />
<view type="text" id="y" posref="TL TL" x="76" y="-38" color="255 255 255 255" shadow="true" global_color="false" fontsize="10" hardtext="Axe Y" />
<instance template="t_webig_ryzhome_button" id="next_y" rot="0" x="130" y="-34" tooltip="ll" texture="mp3_button_play.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:move(0, 0.01, 0)" />
<instance template="t_webig_ryzhome_button" id="next_y2" rot="0" x="160" y="-34" tooltip="ll" texture="mp3_button_next.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:move(0, 0.1, 0)" />
<instance template="t_webig_ryzhome_button" id="previous_z2" rot="2" x="2" y="-52" tooltip="ll" texture="mp3_button_next.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:move(0, 0, -0.1, 0)" />
<instance template="t_webig_ryzhome_button" id="previous_z" rot="2" x="32" y="-52" tooltip="ll" texture="mp3_button_play.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:move(0, 0, -0.01, 0)" />
<view type="text" id="z" posref="TL TL" x="76" y="-58" color="255 255 255 255" shadow="true" global_color="false" fontsize="10" hardtext="Axe Z" />
<instance template="t_webig_ryzhome_button" id="next_z" rot="0" x="130" y="-52" tooltip="ll" texture="mp3_button_play.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:move(0, 0, 0.01, 0)" />
<instance template="t_webig_ryzhome_button" id="next_z2" rot="0" x="160" y="-52" tooltip="ll" texture="mp3_button_next.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:move(0, 0, 0.1, 0)" />
<instance template="t_webig_ryzhome_button" id="previous_a2" rot="2" x="2" y="-70" tooltip="ll" texture="mp3_button_next.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:rot(-0.1)" />
<instance template="t_webig_ryzhome_button" id="previous_a" rot="2" x="32" y="-70" tooltip="ll" texture="mp3_button_play.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:rot(-0.01)" />
<view type="text" id="a" posref="TL TL" x="76" y="-76" color="255 255 255 255" shadow="true" global_color="false" fontsize="10" hardtext="Angle" />
<instance template="t_webig_ryzhome_button" id="next_a" rot="0" x="130" y="-70" tooltip="ll" texture="mp3_button_play.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:rot(0.01)" />
<instance template="t_webig_ryzhome_button" id="next_a2" rot="0" x="160" y="-70" tooltip="ll" texture="mp3_button_next.tga" tx_normal="mp3_button_play.tga" params_l="RyzhomePlace:rot(0.1)" />
</group>
<ctrl style="text_button_16"
id="validate"
posref="BR BR"
x="-2"
y="2"
hardtext="reset"
onclick_l="lua"
params_l="RyzhomePlace:apply()" />
<ctrl style="text_button_16"
id="reset"
posref="ML MR"
posparent="validate"
x="-2"
y="0"
hardtext="reset"
onclick_l="lua"
params_l="RyzhomePlace:reset()" />
</group>
</group>
<tree node="webig_ryzhome_place_item"></tree>
</interface_config>

View file

@ -0,0 +1,590 @@
--- Parse interface of ark_scene_editor_edit_menu ---
local script = [[<interface_config>
<root id="interface" x="0" y="0" w="800" h="600" active="true"/>
<group type="menu" id="ark_scene_editor_edit_menu" extends="base_menu" mouse_pos="true">
</group>
</interface_config>]]
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('<font color="#aa00000">'..self.T["no_selected_group"]..'</font>', '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 '<table width="100%" cellspacing="0" cellpadding="0"><tr bgcolor="'..color..'"><td align="center" valign="middle"><font color="#FFFFFF" size="12">'..message..'</font></td></tr></table>'
end
function SceneEditor:get_html(message, message_bg)
local new_group = '&nbsp;&nbsp;<a class="ryzom-ui-button" href="'..self.baseUrl..'_AddGroup&amp;add_new_group=1&amp;scene_id='..self.sceneId..'"><img src="'..self.iconsUrl..'/32/chart_organisation_add.png" alt="'..self.T["add_new_group"]..'" /></a>'
local show_hide_cols = '&nbsp;&nbsp;<a class="ryzom-ui-button" href="ah:ark_pacs_borders"><img src="'..self.iconsUrl..'/32/show_hide_cols.png" alt="'..self.T["show_hide_cols"]..'" /></a>'
local reset_scene = '</td><td align="center" bgcolor="#502020" width="40px"><a class="ryzom-ui-button" href="'..self.baseUrl..'_SaveShapes&amp;reset_scene=1&amp;scene_id='..self.sceneId..'"><img src="'..self.iconsUrl..'/32/bin.png" alt="'..self.T["reset_scene"]..'" /></a>'
local html = '<header><title>'..self.T["sceno_editor"]..'</title></header>'..self:get_html_section(message..'</td><td bgcolor="#202020" align="center" height="40px" width="140px" valign="middle">'..new_group..show_hide_cols..reset_scene, (message_bg or SceneEditor:get_random_color()))
html = html .. '<form action="'..self.baseUrl..'_SaveShapes" method="POST"><input type="hidden" name="group" value="'..(self.LastEditedGroup or "")..'" /><input type="hidden" name="scene_id" value="'..self.sceneId..'" />\
<table width="100%" cellspacing="0" cellpadding="0">'
local groups = {}
for shape_id, shape in pairs(self.Shapes) do
if shape.group == nil then
shape.group = ""
end
if groups[shape.group] == nil then
groups[shape.group] = {}
end
table.insert(groups[shape.group], shape_id)
end
for group, shapes in pairsByKeys(self.Groups) do
local groupname = group
html = html .. '<tr bgcolor="#444444"><td height="20px"><table width="100%"><tr><td>&nbsp;'..groupname..' ('..(self.Groups[group].props.count or '0')..') </td><td align="right"><input type="hidden" name="shape[]", value="#"/>'
if self.Groups[group].props.show then
if self.Groups[group].props.edit then
html = html .. '<a href="ah:lua:SceneEditor:show_shape_list()"><img src="'..self.iconsUrl..'/16/box_add.png" alt="'..self.T["add_shape"]..'"/></a></td><td align="right">'
if self.HaveUpdate then
html = html .. '<a class="ryzom-ui-button" href="'..self.baseUrl..'_SaveShapes&amp;hide_group='..group..'&amp;edit_group='..group..'">'..self.T["cancel"]..'</a>'
else
html = html .. '<a class="ryzom-ui-button" href="'..self.baseUrl..'_SaveShapes&amp;hide_group='..group..'">'..self.T["hide"]..'</a>'
end
else
html = html .. '<a class="ryzom-ui-button" href="'..self.baseUrl..'_SaveShapes&amp;hide_group='..group..'">'..self.T["hide"]..'</a>'
end
else
html = html .. '<a class="ryzom-ui-button" href="'..self.baseUrl..'_SaveShapes&amp;show_group='..group..'">'..self.T["show"]..'</a>'
end
local shapes_html = ""
local show = self.Groups[group].props.show
if self.Groups[group].props.edit then
shapes_id = groups[group]
if shapes_id then
for k,shape_id in pairs(shapes_id) do
shape = {}
if self.Shapes[shape_id] then
shape["db_id"] = self.Shapes[shape_id].db_id
shape["file"] = self.Shapes[shape_id].file
shape["pos"] = self:get_vector(getShapePos(shape_id))
scale_x, scale_y, scale_z = getShapeScale(shape_id)
shape["rot"] = self:get_vector(getShapeRot(shape_id))
colpos_x, colpos_y, colpos_z = getShapeColPos(shape_id)
colscale_x, colscale_y, colscale_z = getShapeColScale(shape_id)
shape["setup"] = {}
shape["setup"]["scale x"] = scale_x
shape["setup"]["scale y"] = scale_y
shape["setup"]["scale z"] = scale_z
shape["setup"]["col pos x"] = shape["pos"][1]+colpos_x
shape["setup"]["col pos y"] = shape["pos"][2]+colpos_y
shape["setup"]["col size x"] = colscale_x
shape["setup"]["col size y"] = colscale_y
shape["setup"]["col size z"] = colscale_z
local color = "202020"
if k % 2 == 0 then
color = "101010"
end
local text_color = "ef9b64"
if self.Shapes[shape_id].modified == "modified" then
text_color = "aa5555"
else
if self.Shapes[shape_id].modified == "added" then
text_color = "55aa55"
end
end
shapes_html = shapes_html .. "<tr bgcolor='#"..color.."'><td height='20px'>&nbsp;<input type='hidden' name='shape[]', value='"..SceneEditor:enc64((shape.db_id or '')..":"..Json.encode(shape)).."' />"..'#'..(shape.db_id or '0').." <a href='ah:lua:SceneEditor:launch_menu("..tostring(shape_id)..")'><font color='#"..text_color.."'>"..shape.file.."</font></a></td>\
<td width='16px'><a href='ah:lua:SceneEditor:removeShape("..tostring(shape_id)..")'><img src='"..self.iconsUrl.."/16/cross.png' /></a></td>\
</tr>"
end
end
end
else
if self.HaveUpdate == nil then
html = html .. '&nbsp;&nbsp;<a class="ryzom-ui-button" href="'..self.baseUrl..'_SaveShapes&amp;edit_group='..group..'">'..self.T["edit"]..'</a>'
html = html .. '</td><td align="right"><a class="ryzom-ui-button" href="'..self.baseUrl..'_SaveShapes&amp;reset_scene=1&amp;del_group='..group..'">'..self.T["remove"]..'</a>'
end
end
if self.Groups[group].props.modified then
html = html .. '&nbsp;&nbsp;<input type="submit" value="'..self.T["save"]..'" />'
end
html = html .. '</td></tr></table></td><td></td></tr>'..shapes_html
end
html = html .. '</table></form>'
ui = getUI("ui:interface:ark_scene_editor:browser:content:html", false)
if ui then
ui:renderHtml(html)
end
end

View file

@ -4,6 +4,8 @@
<interface_config>
<root id="interface" x="0" y="0" w="800" h="600" active="true" />
<lua file="webig.lua" />
<lua file="json.lua" />
<lua file="sceneedit.lua" />
<!-- //////////// STYLE : webigchat_desc /////////// -->
<style style="webigchat_desc" type="text" fontsize="12" justification="dont_clip_word" color="0 0 0 255" global_color="false" multi_line="true" multi_line_space="0" line_maxw="320" multi_line_maxw_only="true" />

View file

@ -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)

View file

@ -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<CInterface3DShape*>(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
//-----------------------------------------------

View file

@ -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<string> &keys, const vector<string> &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;j<instance.getNumMaterials();j++)
{
instance.getMaterial(j).setShininess( 1000.0f );
instance.getMaterial(j).setEmissive(c);
instance.getMaterial(j).setDiffuse(c);
}
}
}
else if (param == "texture")
{
if (!values[i].empty())
{
for(uint j=0;j<instance.getNumMaterials();j++)
{
sint numStages = instance.getMaterial(j).getLastTextureStage() + 1;
for(sint l = 0; l < numStages; l++)
{
if (instance.getMaterial(j).isTextureFile((uint) l))
instance.getMaterial(j).setTextureFileName(values[i], (uint) l);
}
}
}
}
else if (param == "scale x" || param == "scale y" || param == "scale z")
{
float v;
CVector scale = instance.getScale();
if( getRelativeFloatFromString( values[i], v ) ) {
updateVector(param, scale, v, true);
} else {
updateVector(param, scale, v, false);
}
instance.setScale(scale);
}
// Primitive colissions setups
if (!primitive) continue;
if (param == "col size x" || param == "col size y" || param == "col size z")
{
float width, depth;
primitive->getSize(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; i<count; i++)
{
if(_Entities[i])
if(_Entities[i]->sheetId() == sheetRef)
return _Entities[i];
}
}
return NULL;
}
//-----------------------------------------------
// managePACSTriggers :
// Manage PACS Triggers.

View file

@ -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<CShapeInstanceReference> _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<std::string> &keys, const std::vector<std::string> &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;

View file

@ -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);
}
}

View file

@ -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

View file

@ -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);

File diff suppressed because it is too large Load diff

View file

@ -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);

View file

@ -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();

View file

@ -1507,3 +1507,44 @@ bool getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<st
return nFoundStringMode > -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;
}
}

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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
*/

View file

@ -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);
}
}

View file

@ -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);
}
// ***************************************************************

View file

@ -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();
{