Added: AppZone and WebBrowser components
--HG-- branch : developfeature/pipeline-tools
parent
89532b2afb
commit
2eb1d7b293
@ -0,0 +1,192 @@
|
||||
|
||||
-- global
|
||||
AppZone = {
|
||||
id = "ui:interface:appzone",
|
||||
homeuri = "?action=appzone_toolbar",
|
||||
launchuri = "?action=launch_app",
|
||||
addappuri = "?action=list_user_apps",
|
||||
mode = "h_bar",
|
||||
imagesize = 26
|
||||
}
|
||||
|
||||
-- use client.cfg value when available
|
||||
local uri getClientCfg("AppZoneUrl")
|
||||
if uri == nil or uri == '' then
|
||||
uri = 'http://app.ryzom.com/'
|
||||
end
|
||||
|
||||
AppZone.homeuri = uri .. AppZone.homeuri
|
||||
AppZone.launchuri = uri .. AppZone.launchuri
|
||||
AppZone.addappuri = uri .. AppZone.addappuri
|
||||
|
||||
function AppZone:getRoot()
|
||||
return getUI(self.id)
|
||||
end
|
||||
|
||||
function AppZone:onButtonHome()
|
||||
local webig = getUI("ui:interface:webig")
|
||||
webig:find("html").url = self.addappuri
|
||||
webig.active = true
|
||||
end
|
||||
|
||||
function AppZone:calculateSize(count, spacer, mode)
|
||||
local w, h
|
||||
if mode == "h_bar" then
|
||||
-- icon=32, space=2+2
|
||||
w = count * self.imagesize + spacer * 15
|
||||
w = w + 55 + 10 + 20
|
||||
h = self.imagesize + 2
|
||||
elseif mode == "h_box" then
|
||||
w = count * self.imagesize
|
||||
w = w + 20
|
||||
h = self.imagesize + 2
|
||||
h = h * spacer
|
||||
h = h + 15
|
||||
elseif mode == "v_bar" then
|
||||
-- icon=32, space=2+2
|
||||
h = count * self.imagesize + spacer * 15
|
||||
h = h + 20 + 20 + 12
|
||||
w = self.imagesize + 2 + 18
|
||||
else
|
||||
h = count * self.imagesize
|
||||
h = h + 20 + 25
|
||||
w = self.imagesize + 2
|
||||
w = w * spacer
|
||||
w = w + 16
|
||||
end
|
||||
|
||||
local ui = getUI("ui:interface")
|
||||
if w > ui.w then
|
||||
w = ui.w
|
||||
end
|
||||
if h > ui.h then
|
||||
h = ui.h
|
||||
end
|
||||
|
||||
return w, h
|
||||
end
|
||||
|
||||
function AppZone:setElementCount(count,spacer,m)
|
||||
self.mode = m
|
||||
|
||||
local root = self:getRoot()
|
||||
local content = root:find("content")
|
||||
local html = root:find("html")
|
||||
|
||||
local button_toggle = root:find("toggle_mode")
|
||||
local button_reload = root:find("browse_reload")
|
||||
local button_home = root:find("browse_home")
|
||||
|
||||
local w, h = self:calculateSize(count, spacer, self.mode)
|
||||
root.h = h
|
||||
root.w = w
|
||||
content.w = w
|
||||
content.h = h
|
||||
|
||||
-- set position of buttons
|
||||
if self.mode == "h_bar" then
|
||||
-- button_toggle.posref = "BL BL"
|
||||
button_toggle.x = 2
|
||||
button_toggle.y = 0
|
||||
-- button_reload.posref = "TL BL"
|
||||
html.x = 15
|
||||
html.y = 0
|
||||
button_reload.x = -25
|
||||
button_reload.y = -25
|
||||
-- button_home.posref = "BR BR"
|
||||
button_home.x = 0
|
||||
button_home.y = -3 + 5
|
||||
elseif self.mode == "h_box" then
|
||||
-- button_toggle.posref = "TL TL"
|
||||
button_toggle.x = 2
|
||||
button_toggle.y = h - 15
|
||||
-- button_reload.posref = "TL BL"
|
||||
html.x = 0
|
||||
html.y = -20
|
||||
button_reload.x = -25
|
||||
button_reload.y = -4 - 20
|
||||
-- button_home.posref = "BR BR"
|
||||
button_home.x = 0
|
||||
button_home.y = -3 + h - 18
|
||||
elseif self.mode == "v_bar" then
|
||||
-- button_toggle.posref = "TL TL"
|
||||
button_toggle.x = 2
|
||||
button_toggle.y = h - 15
|
||||
-- button_reload.posref = "TL BL"
|
||||
html.x = 0
|
||||
html.y = -20
|
||||
button_reload.x = 0
|
||||
button_reload.y = -4
|
||||
-- button_home.posref = "BR BR"
|
||||
button_home.x = 4 - 7
|
||||
button_home.y = -3
|
||||
else
|
||||
-- button_toggle.posref = "TL TL"
|
||||
button_toggle.x = 2
|
||||
button_toggle.y = h - 15
|
||||
-- button_reload.posref = "TL BL"
|
||||
html.x = 0
|
||||
html.y = -20
|
||||
button_reload.x = -25
|
||||
button_reload.y = -4 - 20
|
||||
-- button_home.posref = "BR BR"
|
||||
button_home.x = 0 - w + 54 + 12
|
||||
button_home.y = -3
|
||||
end
|
||||
end
|
||||
|
||||
function AppZone:setMode(m)
|
||||
self.mode = m
|
||||
|
||||
self:reload()
|
||||
end
|
||||
|
||||
function AppZone:setActive(s)
|
||||
self:getRoot().active = s
|
||||
end
|
||||
|
||||
function AppZone:launchApp(appid, appwin, appurl)
|
||||
if not appwin then
|
||||
if string.match(appid, "^[0-9]+$") then
|
||||
appwin = "app" .. tostring(appid)
|
||||
else
|
||||
appwin = "webig"
|
||||
end
|
||||
end
|
||||
|
||||
if not appurl then
|
||||
appurl = self.launchuri .. "&appid=" .. tostring(appid)
|
||||
end
|
||||
|
||||
if WebBrowser then
|
||||
WebBrowser:openWindow(appwin, appurl)
|
||||
else
|
||||
-- fallback if WebBrowser not present
|
||||
local webig = getUI("ui:interface:webig")
|
||||
webig:find("html").url = appurl;
|
||||
webig.active = true
|
||||
end
|
||||
end
|
||||
|
||||
function AppZone:reload()
|
||||
local url = self.homeuri
|
||||
url = url .. "&mode=" .. tostring(self.mode)
|
||||
|
||||
local html = self:getRoot():find("html")
|
||||
html.url = url
|
||||
end
|
||||
|
||||
-- slash command: /appzone <cmd>
|
||||
function AppZone:handle(cmd)
|
||||
if cmd == 'show' then
|
||||
self:setActive(true)
|
||||
elseif cmd == 'hide' then
|
||||
self:setActive(false)
|
||||
elseif cmd == 'reload' then
|
||||
self:reload()
|
||||
elseif cmd == 'list' then
|
||||
self:onButtonHome()
|
||||
else
|
||||
self:launchApp(cmd)
|
||||
end
|
||||
end
|
@ -0,0 +1,258 @@
|
||||
<?xml version="1.0"?>
|
||||
<interface_config>
|
||||
<root id="interface"
|
||||
x="0"
|
||||
y="0"
|
||||
w="800"
|
||||
h="600"
|
||||
active="true" />
|
||||
|
||||
<!-- default: active, h_bar -->
|
||||
<variable entry="UI:VARIABLES:ISACTIVE:APPZONE"
|
||||
type="sint32"
|
||||
value="1" />
|
||||
<variable entry="UI:SAVE:APPZONE:MODE"
|
||||
type="sint32"
|
||||
value="1" />
|
||||
|
||||
<!-- load lua after variable are setup -->
|
||||
<lua file="appzone.lua" />
|
||||
<lua file="webbrowser.lua" />
|
||||
|
||||
<proc id="appzone_proc_active">
|
||||
<action handler="set"
|
||||
params="dblink=UI:VARIABLES:ISACTIVE:APPZONE|value=1" />
|
||||
<action handler="proc"
|
||||
params="appzone_proc_mode" />
|
||||
</proc>
|
||||
|
||||
<proc id="appzone_proc_deactive">
|
||||
<action handler="set"
|
||||
params="dblink=UI:VARIABLES:ISACTIVE:APPZONE|value=0" />
|
||||
</proc>
|
||||
|
||||
<proc id="appzone_proc_mode_set">
|
||||
<action handler="set"
|
||||
params="dblink=UI:SAVE:APPZONE:MODE|value=@0" />
|
||||
<action handler="proc"
|
||||
params="appzone_proc_mode" />
|
||||
</proc>
|
||||
|
||||
<proc id="appzone_proc_mode_inc">
|
||||
<action handler="set"
|
||||
params="dblink=UI:SAVE:APPZONE:MODE|value=add(@UI:SAVE:APPZONE:MODE,1)" />
|
||||
<action handler="proc"
|
||||
params="appzone_proc_mode" />
|
||||
</proc>
|
||||
|
||||
<proc id="appzone_proc_mode">
|
||||
<action handler="set"
|
||||
cond="le(@UI:SAVE:APPZONE:MODE,0)"
|
||||
params="dblink=UI:SAVE:APPZONE:MODE|value=1" />
|
||||
<action handler="set"
|
||||
cond="ge(@UI:SAVE:APPZONE:MODE,5)"
|
||||
params="dblink=UI:SAVE:APPZONE:MODE|value=1" />
|
||||
|
||||
<action handler="lua"
|
||||
cond="eq(@UI:SAVE:APPZONE:MODE,1)"
|
||||
params="AppZone:setMode('h_bar')" />
|
||||
<action handler="lua"
|
||||
cond="eq(@UI:SAVE:APPZONE:MODE,2)"
|
||||
params="AppZone:setMode('h_box')" />
|
||||
<action handler="lua"
|
||||
cond="eq(@UI:SAVE:APPZONE:MODE,3)"
|
||||
params="AppZone:setMode('v_bar')" />
|
||||
<action handler="lua"
|
||||
cond="eq(@UI:SAVE:APPZONE:MODE,4)"
|
||||
params="AppZone:setMode('v_box')" />
|
||||
</proc>
|
||||
|
||||
<group type="menu"
|
||||
id="appzone_menu"
|
||||
extends="base_menu_with_color">
|
||||
<action id="settings"
|
||||
name="uiBrowseHome"
|
||||
handler="lua"
|
||||
params="AppZone:onButtonHome()" />
|
||||
<action id="reload"
|
||||
name="uiBrowseRefresh"
|
||||
handler="lua"
|
||||
params="AppZone:reload()" />
|
||||
<action id="hide"
|
||||
name="uiHide"
|
||||
handler="lua"
|
||||
params="AppZone:setActive(false)" />
|
||||
<separator />
|
||||
</group>
|
||||
|
||||
<group id="appzone"
|
||||
type="container"
|
||||
x="0"
|
||||
y="0"
|
||||
w="200"
|
||||
h="26"
|
||||
posref="MM MM"
|
||||
min_w="26"
|
||||
min_h="26"
|
||||
max_w="1600"
|
||||
max_h="1600"
|
||||
pop_max_w="1600"
|
||||
pop_max_h="1600"
|
||||
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"
|
||||
on_active="proc"
|
||||
on_active_params="appzone_proc_active"
|
||||
on_deactive="proc"
|
||||
on_deactive_params="appzone_proc_deactive"
|
||||
group_onclick_r="active_menu"
|
||||
group_params_r="menu=ui:interface:appzone_menu">
|
||||
<group id="header_closed"
|
||||
x="0"
|
||||
y="0"
|
||||
w="0"
|
||||
h="0"
|
||||
posref="TL TL" />
|
||||
<group id="header_opened"
|
||||
x="0"
|
||||
y="0"
|
||||
w="0"
|
||||
h="0"
|
||||
wmin="5"
|
||||
sizeref="w"
|
||||
posref="TL TL" />
|
||||
<group id="content"
|
||||
x="0"
|
||||
y="0"
|
||||
w="0"
|
||||
h="26"
|
||||
posref="TL TL">
|
||||
<ctrl type="button"
|
||||
style="text_button_header"
|
||||
button_type="toggle_button"
|
||||
id="toggle_mode"
|
||||
posref="BL BL"
|
||||
x="2"
|
||||
y="0"
|
||||
tx_normal="tb_mode.tga"
|
||||
tx_pushed="tb_mode.tga"
|
||||
tooltip="uiMk_mode"
|
||||
onclick_l="proc"
|
||||
params_l="appzone_proc_mode_inc" />
|
||||
<ctrl type="button"
|
||||
style="text_button_header"
|
||||
button_type="toggle_button"
|
||||
id="browse_home"
|
||||
posref="BR BR"
|
||||
x="0"
|
||||
y="-3"
|
||||
tx_normal="r2_palette_components.tga"
|
||||
tx_pushed="r2_palette_components.tga"
|
||||
tooltip="uittBrowseHome"
|
||||
onclick_l="lua"
|
||||
params_l="AppZone:onButtonHome()" />
|
||||
<ctrl type="button"
|
||||
style="text_button_header"
|
||||
button_type="toggle_button"
|
||||
id="browse_reload"
|
||||
posref="TL BL"
|
||||
posparent="browse_home"
|
||||
x="0"
|
||||
y="-4"
|
||||
tx_normal="r2ed_icon_rotate.tga"
|
||||
tx_pushed="r2ed_icon_rotate.tga"
|
||||
tooltip="uiBrowseRefresh"
|
||||
onclick_l="lua"
|
||||
params_l="AppZone:reload()" />
|
||||
<group id="html"
|
||||
type="webig_html"
|
||||
posref="TL TL"
|
||||
url=""
|
||||
title_prefix=""
|
||||
sizeref="wh"
|
||||
x="15"
|
||||
y="0"
|
||||
w="0"
|
||||
h="0"
|
||||
background_color="0 0 0 0"
|
||||
error_color="255 240 48 255"
|
||||
link_color="240 155 100 255"
|
||||
text_color="210 210 210 255"
|
||||
h1_color="255 255 255 255"
|
||||
h2_color="255 255 255 255"
|
||||
h3_color="255 255 255 255"
|
||||
h4_color="255 255 255 255"
|
||||
h5_color="255 255 255 255"
|
||||
h6_color="255 255 255 255"
|
||||
text_font_size="10"
|
||||
h1_font_size="16"
|
||||
h2_font_size="14"
|
||||
h3_font_size="13"
|
||||
h4_font_size="12"
|
||||
h5_font_size="11"
|
||||
h6_font_size="11"
|
||||
paragraph_begin_space="12"
|
||||
multi_line_space_factor="0.25"
|
||||
td_begin_space="0"
|
||||
li_begin_space="4"
|
||||
ul_begin_space="12"
|
||||
li_indent="-10"
|
||||
ul_indent="30"
|
||||
checkbox_bitmap_normal="patch_off.tga"
|
||||
checkbox_bitmap_pushed="patch_on.tga"
|
||||
checkbox_bitmap_over=""
|
||||
background_bitmap_view=""
|
||||
home=""
|
||||
browse_next_time="false"
|
||||
timeout="5"
|
||||
form_text_area_group="edit_box_widget_multiline">
|
||||
<group id="black"
|
||||
posref="BR BR"
|
||||
sizeref="hw"
|
||||
w="0"
|
||||
h="0"
|
||||
inherit_gc_alpha="true" />
|
||||
<view type="bitmap"
|
||||
id="black2"
|
||||
posparent="black"
|
||||
posref="MM MM"
|
||||
sizeref="wh"
|
||||
w="0"
|
||||
h="0"
|
||||
inherit_gc_alpha="true"
|
||||
scale="true"
|
||||
texture="blank.tga"
|
||||
global_color="false" />
|
||||
<group type="list"
|
||||
id="text_list"
|
||||
fontsize="9"
|
||||
posref="TL TL"
|
||||
posparent="black"
|
||||
x="0"
|
||||
y="0"
|
||||
space="0"
|
||||
sizeref="hw"
|
||||
w="-4"
|
||||
h="0"
|
||||
maxelements="2000" />
|
||||
<ctrl style="skin_scroll"
|
||||
id="scroll_bar" />
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<tree node="appzone" />
|
||||
|
||||
<command name="appzone"
|
||||
action="lua"
|
||||
params="AppZone:handle('$')" />
|
||||
|
||||
</interface_config>
|
@ -0,0 +1,161 @@
|
||||
|
||||
-- global
|
||||
WebBrowser = {
|
||||
template = "webig_browser",
|
||||
apps = {}
|
||||
}
|
||||
|
||||
function WebBrowser:openWindow(id, url)
|
||||
-- default value if url is not set
|
||||
url = url or "http://app.ryzom.com/"
|
||||
|
||||
local newWindow = false
|
||||
local app = self:findAppById(id)
|
||||
|
||||
if not app then
|
||||
app = {}
|
||||
app.id = id
|
||||
app.title = ""
|
||||
app.url = url
|
||||
-- getUI() object
|
||||
app.uiWindow = nil
|
||||
app.winid = "ui:interface:" .. id
|
||||
app.winw = 780
|
||||
app.winh = 500
|
||||
app.minimized = true
|
||||
app.activeUrl = ""
|
||||
|
||||
table.insert(self.apps, app)
|
||||
end
|
||||
|
||||
if not app.uiWindow then
|
||||
-- if there is window present (eg, 'webig'), then reuse it
|
||||
app.uiWindow = getUI(app.winid, false)
|
||||
if not app.uiWindow then
|
||||
app.uiWindow = createRootGroupInstance(self.template, app.id, {
|
||||
x = 0, y = 0, w = app.winw, h = app.winh, home = app.url,
|
||||
browse_redo = "ui:interface:" .. app.id .. ":browser:header_opened:browse_redo",
|
||||
browse_undo = "ui:interface:" .. app.id .. ":browser:header_opened:browse_undo",
|
||||
browse_refresh = "ui:interface:" .. app.id .. ":browser:header_opened:browse_refresh"
|
||||
})
|
||||
if not app.uiWindow then
|
||||
return
|
||||
end
|
||||
app.uiWindow:center()
|
||||
end
|
||||
|
||||
newWindow = true
|
||||
end
|
||||
|
||||
app.activeUrl = url
|
||||
|
||||
-- trigger on_open event
|
||||
if not app.uiWindow.opened then
|
||||
app.uiWindow.opened = true
|
||||
end
|
||||
|
||||
-- trigger on_active event
|
||||
if not app.uiWindow.active then
|
||||
app.uiWindow.active = true
|
||||
end
|
||||
|
||||
local html = app.uiWindow:find("html")
|
||||
html:browse(url)
|
||||
|
||||
setTopWindow(app.uiWindow)
|
||||
end
|
||||
|
||||
function WebBrowser:findAppById(id)
|
||||
for k,app in pairs(self.apps) do
|
||||
if app.id == id then
|
||||
return app
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function WebBrowser:findAppFromUiCaller()
|
||||
-- id = app123
|
||||
local id = getUICaller().id:match("ui:interface:([^:]*):?")
|
||||
local app = self:findAppById(id)
|
||||
if app then
|
||||
return app
|
||||
end
|
||||
end
|
||||
|
||||
function WebBrowser:onActive()
|
||||
if app then
|
||||
self:restoreWindow(app)
|
||||
end
|
||||
end
|
||||
|
||||
function WebBrowser:onClickHeaderClose()
|
||||
local app = self:findAppFromUiCaller()
|
||||
if app then
|
||||
self:saveWindow(app)
|
||||
end
|
||||
end
|
||||
|
||||
function WebBrowser:onClickHeaderOpen()
|
||||
local app = self:findAppFromUiCaller()
|
||||
if app then
|
||||
self:restoreWindow(app)
|
||||
end
|
||||
end
|
||||
|
||||
-- save current window dimension and minimize window
|
||||
function WebBrowser:saveWindow(app)
|
||||
app.minimized = true
|
||||
app.winw = app.uiWindow.w
|
||||
app.winh = app.uiWindow.h
|
||||
-- minimize
|
||||
app.uiWindow.w = 150
|
||||
app.uiWindow.h = 0
|
||||
end
|
||||
|
||||
function WebBrowser:restoreWindow(app)
|
||||
if app.minimized then
|
||||
app.uiWindow.w = app.winw
|
||||
app.uiWindow.h = app.winh
|
||||
app.minimized = false
|
||||
end
|
||||
end
|
||||
|
||||
function WebBrowser:onClickRedo()
|
||||
-- caller is :header_opened:browse_redo
|
||||
local uiWindow = getUICaller().parent.parent
|
||||
local html = uiWindow:find("html")
|
||||
if html ~= nil then
|
||||
runAH(nil, "browse_redo", "name=" .. html.id)
|
||||
end
|
||||
end
|
||||
|
||||
function WebBrowser:onClickUndo()
|
||||
-- caller is :header_opened:browse_undo
|
||||
local uiWindow = getUICaller().parent.parent
|
||||
|
||||
local html = uiWindow:find("html")
|
||||
if html ~= nil then
|
||||
runAH(nil, "browse_undo", "name=" .. html.id)
|
||||
end
|
||||
end
|
||||
|
||||
function WebBrowser:onClickRefresh()
|
||||
-- caller is :header_opened:browse_refresh
|
||||
local uiWindow = getUICaller().parent.parent
|
||||
|
||||
local html = uiWindow:find("html")
|
||||
if html ~= nil then
|
||||
html:refresh()
|
||||
end
|
||||
end
|
||||
|
||||
function WebBrowser:onClickHome()
|
||||
-- caller is :header_opened:browse_home
|
||||
local uiWindow = getUICaller().parent.parent
|
||||
|
||||
local html = uiWindow:find("html")
|
||||
if html ~= nil then
|
||||
html:browse("home")
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue