From 6a258886fe79a89957763acab00fb34e4616e77a Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 22 Mar 2016 12:23:04 +0200 Subject: [PATCH] Merge with develop --- code/ryzom/client/client_default.cfg | 1 + .../data/gamedev/interfaces_v3/appzone.lua | 192 +++++++++++++ .../data/gamedev/interfaces_v3/appzone.xml | 258 ++++++++++++++++++ .../data/gamedev/interfaces_v3/reset.xml | 8 +- .../data/gamedev/interfaces_v3/taskbar.xml | 5 +- .../data/gamedev/interfaces_v3/webbrowser.lua | 161 +++++++++++ .../data/gamedev/interfaces_v3/widgets.xml | 198 +++++++++++++- 7 files changed, 819 insertions(+), 4 deletions(-) create mode 100644 code/ryzom/client/data/gamedev/interfaces_v3/appzone.lua create mode 100644 code/ryzom/client/data/gamedev/interfaces_v3/appzone.xml create mode 100644 code/ryzom/client/data/gamedev/interfaces_v3/webbrowser.lua diff --git a/code/ryzom/client/client_default.cfg b/code/ryzom/client/client_default.cfg index 340b14edc..394a31e6f 100644 --- a/code/ryzom/client/client_default.cfg +++ b/code/ryzom/client/client_default.cfg @@ -447,6 +447,7 @@ XMLInterfaceFiles = { "config.xml", "widgets.xml", "webig_widgets.xml", + "appzone.xml", "player.xml", "inventory.xml", "interaction.xml", diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/appzone.lua b/code/ryzom/client/data/gamedev/interfaces_v3/appzone.lua new file mode 100644 index 000000000..1332eb3d5 --- /dev/null +++ b/code/ryzom/client/data/gamedev/interfaces_v3/appzone.lua @@ -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 +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 diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/appzone.xml b/code/ryzom/client/data/gamedev/interfaces_v3/appzone.xml new file mode 100644 index 000000000..c6f08c3b2 --- /dev/null +++ b/code/ryzom/client/data/gamedev/interfaces_v3/appzone.xml @@ -0,0 +1,258 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/reset.xml b/code/ryzom/client/data/gamedev/interfaces_v3/reset.xml index 1d7e0c66d..8c14f2567 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/reset.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/reset.xml @@ -91,7 +91,11 @@ - + + + + + @@ -470,4 +474,4 @@ - \ No newline at end of file + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/taskbar.xml b/code/ryzom/client/data/gamedev/interfaces_v3/taskbar.xml index 0c42103f3..e497f25e3 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/taskbar.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/taskbar.xml @@ -1091,7 +1091,10 @@ - + + + diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/webbrowser.lua b/code/ryzom/client/data/gamedev/interfaces_v3/webbrowser.lua new file mode 100644 index 000000000..f51d7a9da --- /dev/null +++ b/code/ryzom/client/data/gamedev/interfaces_v3/webbrowser.lua @@ -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 diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml b/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml index 10431b84c..b806edb8d 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/widgets.xml @@ -6927,7 +6927,203 @@ - + + + + + + +