Merge branch 'fixes' into main/gingo-test
[ryzomcore.git] / ryzom / common / data_common / r2 / r2_ui.lua
bloba9d4547cf9695ba39d54cb5cd288459d99ab99ba
1 -- In this file we define functions that serves as an interface between the framework of the
2 -- editor (C++ code), and the ui. Ideally the C++ should never manipulate the ui directly.
3 -- It should rather call functions in this interface to do the job.
4 -- This allow for easy customisation, because users can replace any function with their
5 -- own lua code (possibly forwarding to the previous function).
6 -- This file works in close relation with the r2.xml file with contains the actual ui
10 -------------
11 -------------
12 -- GLOBALS --
13 -------------
14 -------------
16 -- The following table is intended to contain ui related classes & functions
17 -- For now the ui stuffs are being migrated into this table
18 -- TODO nico : move ui stuff here to 'depolute' the r2 table
20 r2.ui = {}
23 -----------------
24 -----------------
25 -- GLOBAL INIT --
26 -----------------
27 -----------------
29 function r2:initUI()
30 self:buildPaletteUI()
31 r2.FeatureTree.buildFeatureTreeUI()
32 r2:refreshWindowButtons()
33 --updateAllLocalisedElements()
34 -- init all forms
35 for k, form in pairs(r2.Forms) do
36 form.NameToProp = {}
37 for l, prop in pairs(form.Prop) do
38 form.NameToProp[prop.Name] = prop
39 end
40 end
41 -- make the admin window point on the main page (obsolete, replaced by Session Browser)
42 -- if browseRingWindowHomePage ~= nil then
43 -- browseRingWindowHomePage()
44 -- else
45 -- debugInfo("---> ERROR: what is browseRingWindowHomePage?")
46 -- end
47 r2.SelectBar:init()
48 local paletteWnd = getUI("ui:interface:r2ed_palette")
49 local debugPanel = paletteWnd:find("debug_panel").button_enclosing
50 local extDbg = (config.R2EDExtendedDebug == 1)
52 local chooseLocationWnd = getUI("ui:interface:r2ed_acts")
53 local ringLevelDebug = chooseLocationWnd:find("ring_level")
55 if debugPanel then
56 debugPanel.reset_ed.active = extDbg
57 debugPanel.reset_ed_and_reload_ui.active = extDbg
58 debugPanel.reload_core.active = extDbg
59 debugPanel.inspect_r2.active = extDbg
60 debugPanel.reset_display.active = extDbg
61 ringLevelDebug.active = extDbg
62 -- debugPanel.test.active = extDbg
63 -- debugPanel.create_scenario.active = extDbg
64 -- debugPanel.create_act.active = extDbg
65 -- debugPanel.connect_scenario.active = extDbg
66 -- debugPanel.reconnect_scenario.active = extDbg
67 -- debugPanel.list_adventures.active = extDbg
68 end
69 paletteWnd:find("tab2").active = true
70 paletteWnd:find("tab2_bm").active = true
71 paletteWnd:find("tab4").active = extDbg
72 paletteWnd:find("tab4_bm").active = extDbg
73 end
76 -----------
77 -----------
78 -- TESTS --
79 -----------
80 -----------
81 function testTree()
82 local headNode = SNode()
83 local rootNode = SNode()
84 headNode:addChild(rootNode)
85 rootNode.Text = "Root"
86 rootNode.Opened = true
87 rootNode.Bitmap = "ICO_Atys.tga"
88 local tree = getUI(r2.instanceTree);
89 for i = 1,3 do
90 local son = SNode()
91 son.Text = "Node " .. tostring(i)
92 rootNode:addChild(son)
93 end
94 tree:setRootNode(headNode)
95 tree:forceRebuild()
96 end