1 -- Reset ui & manage desktop change (one desktop per editor mode)
5 ------------------------------------------------------------------------------------
6 function setActive(wndName
, active
)
7 local wnd
= getUI(wndName
, r2
.Config
.VerboseGetUI
)
13 ------------------------------------------------------------------------------------
14 function hide(wndName
)
15 setActive(wndName
, false)
18 ------------------------------------------------------------------------------------
19 function show(wndName
)
20 setActive(wndName
, true)
24 function r2
:hide(wndName
)
28 -- Reset windows placement in each desktop (one desktop per mode of the editor, so no virtual desktop are available in r2ed)
29 function r2
:resetDesktop(desktopIndex
)
30 local scrW
, scrH
= getWindowSize()
32 ----------------------------------------------------------------------------------------------------------
33 -- reset the EDITION desktop
34 if desktopIndex
== 0 then
36 local palette
= getUI("ui:interface:r2ed_palette")
44 local scenario
= getUI("ui:interface:r2ed_scenario")
46 scenario
.active
= false
50 scenario
.x
= scrW
- scenario
.w
- 5
51 scenario
.y
= scrH
- 65
52 -- by default the 'scene rollout' is opened
53 --r2:setRolloutOpened(scenario:find("geo_tree").caption, scenario:find("geo_tree_list"), true)
54 -- by default the 'permanent content' is opened
55 --r2:setRolloutOpened(scenario:find("content_tree").caption, scenario:find("content_tree_list"), true)
56 -- by default the 'act' rollout is opened
57 --r2:setRolloutOpened(scenario:find("acts").caption, scenario:find("act_tree_enclosing"), true)
59 local webAdmin
= getUI("ui:interface:r2ed_web_admin")
60 webAdmin
.active
= false
62 -- webAdmin.active = false
65 -- webAdmin.x = scrW - webAdmin.w - 5
67 -- webAdmin.y = scenario.y - scenario.h - 5
69 -- webAdmin.y = scrH - 5
73 local toolbar
= getUI("ui:interface:r2ed_toolbar")
76 toolbar
:invalidateCoords()
77 toolbar
:updateCoords()
82 r2
:setSelectedInstanceId("") -- force a real select
83 r2
:setSelectedInstanceId(r2
.Scenario
.InstanceId
)
85 -- <action handler="set" params="target='ui:interface:debug_info:active'|value=0"/>
86 -- <action handler="set" params="target='ui:interface:debug_info:w'|value=350" />
87 -- <action handler="set" params="target='ui:interface:debug_info:h'|value=300" />
88 -- <action handler="set" params="target='ui:interface:debug_info:x'|value=10000" />
89 -- <action handler="set" params="target='ui:interface:debug_info:y'|value=370" />
91 ----------------------------------------------------------------------------------------------------------
92 -- reset the TEST dektop
93 elseif desktopIndex
== 1 then
95 -- show game related windows in test mode
96 -- (same as virtual desktop 0 in game)
99 runAH(nil, "set", "target='ui:interface:target:active'|value=1")
100 runAH(nil, "set", "target='ui:interface:target:locked'|value=0")
101 runAH(nil, "set", "target='ui:interface:target:x'|value=sub(sub(getprop('ui:interface:w'),getprop('ui:interface:target:w')),4)")
102 runAH(nil, "set", "target='ui:interface:target:y'|value=sub(getprop('ui:interface:h'),4)")
105 runAH(nil, "set", "target='ui:interface:gestionsets:active'|value=1")
106 runAH(nil, "set", "target='ui:interface:gestionsets:x'|value=div(sub(getprop('ui:interface:w'),getprop('ui:interface:gestionsets:w')),2)")
107 runAH(nil, "set", "target='ui:interface:gestionsets:y'|value=sub(getprop('ui:interface:h'),4)")
110 runAH(nil, "set", "target='ui:interface:player:active'|value=1")
111 runAH(nil, "set", "target='ui:interface:player:x'|value=4")
112 runAH(nil, "set", "target='ui:interface:player:y'|value=sub(getprop('ui:interface:h'),4)" )
113 runAH(nil, "set", "target='ui:interface:player:locked'|value=0")
114 runAH(nil, "set_transparent", "ui:interface:player")
116 local webAdmin
= getUI("ui:interface:r2ed_web_admin")
117 webAdmin
.active
= false
119 -- webAdmin.active = true
122 -- webAdmin.x = scrW - webAdmin.w - 5
123 -- webAdmin.y = scrH - 75
126 -- bonus malus window
127 runAH(nil, "set", "target='ui:interface:bonus_malus:active'|value=1")
128 runAH(nil, "set", "target='ui:interface:bonus_malus:x'|value=188")
129 runAH(nil, "set", "target='ui:interface:bonus_malus:y'|value=sub(getprop('ui:interface:h'),4)")
130 runAH(nil, "set", "target='ui:interface:bonus_malus:locked'|value=1")
133 --runAH(nil, "set", "target='ui:interface:compass:x'|value=sub(sub(getprop('ui:interface:w'),getprop('ui:interface:compass:w')),4)")
134 --runAH(nil, "set", "target='ui:interface:compass:y'|value=sub(sub(getprop('ui:interface:h'),getprop('ui:interface:target:h')),8)")
137 --runAH(nil, "set", "target='ui:interface:help_browser:active'|value=1")
138 --runAH(nil, "set", "target='ui:interface:help_browser:locked'|value=0")
139 --runAH(nil, "set", "target='ui:interface:help_browser:w'|value=410")
140 --runAH(nil, "set", "target='ui:interface:help_browser:h'|value=128")
141 --runAH(nil, "set", "target='ui:interface:help_browser:x'|value=sub(sub(getprop('ui:interface:w'),getprop('ui:interface:help_browser:w')),4)")
142 --runAH(nil, "set", "target='ui:interface:help_browser:y'|value=add(getprop('ui:interface:help_browser:h'),4)")
145 --runAH(nil, "set", "target='ui:interface:system_info:w'|value=div(sub(getprop('ui:interface:w'),add(getprop('ui:interface:help_browser:w'),16)),2)")
146 --runAH(nil, "set", "target='ui:interface:system_info:h'|value=128")
147 --runAH(nil, "set", "target='ui:interface:system_info:x'|value=4")
148 --runAH(nil, "set", "target='ui:interface:system_info:y'|value=add(getprop('ui:interface:system_info:h'),4)")
151 -- runAH(nil, "set", "target='ui:interface:main_chat:w'|value=getprop('ui:interface:system_info:w')")
152 -- runAH(nil, "set", "target='ui:interface:main_chat:h'|value=128")
153 -- runAH(nil, "set", "target='ui:interface:main_chat:x'|value=add(getprop('ui:interface:system_info:w'),8)")
154 -- runAH(nil, "set", "target='ui:interface:main_chat:y'|value=add(getprop('ui:interface:system_info:h'),4)")
158 --runAH(nil, "set", "target='ui:interface:info_player_journal:active'|value=1")
159 --runAH(nil, "set", "target='ui:interface:info_player_journal:locked'|value=0")
160 --runAH(nil, "set", "target='ui:interface:info_player_journal:x'|value=4")
161 --runAH(nil, "set", "target='ui:interface:info_player_journal:y'|value=add(add(getprop('ui:interface:system_info:h'),getprop('ui:interface:info_player_journal:h')),8)")
165 --runAH(nil, "set", "target='ui:interface:milko:x'|value=sub(sub(getprop('ui:interface:w'),getprop('ui:interface:milko:w')),4)")
166 --runAH(nil, "set", "target='ui:interface:milko:y'|value=sub(sub(getprop('ui:interface:compass:y'),getprop('ui:interface:compass:h')),4)")
170 local toolbarWindow
= getUI("ui:interface:r2ed_toolbar_window")
174 local milkoPad
= getUI("ui:interface:milko_pad")
176 milkoPad
.x
= scrW
- milkoPad
.w
178 ----------------------------------------------------------------------------------------------------------
179 -- reset the DM destop
180 elseif desktopIndex
== 2 then
183 local webAdmin
= getUI("ui:interface:r2ed_web_admin")
184 webAdmin
.active
= false
186 -- webAdmin.active = true
189 -- webAdmin.x = scrW - webAdmin.w - 5
190 -- webAdmin.y = scrH - 5
192 local toolbar
= getUI("ui:interface:r2ed_toolbar")
194 toolbar
.active
= true
195 toolbar
:invalidateCoords()
196 toolbar
:updateCoords()
199 local dmToolbar
= getUI("ui:interface:r2ed_windows_dm_bar")
201 dmToolbar
.active
= true
202 dmToolbar
:invalidateCoords()
203 dmToolbar
:updateCoords()
206 hide("ui:interface:bonus_malus") -- patch for the bonus-malus window
207 elseif desktopIndex
== 3 then
210 r2
:resetDesktopVisibleWindows(desktopIndex
)
214 local function cleanEnv(contName
)
215 local cont
= getUI("ui:interface" .. contName
, r2
.Config
.VerboseGetUI
)
217 cont
:deleteLUAEnvTable(true) -- recursively delete lua environments
224 ----------------------------------------------------------------------------------------------------------
225 function r2
:adjustToolbarGap()
226 local toolbar
= getUI("ui:interface:r2ed_toolbar")
228 local numGroups
= toolbar
:getNumGroups()
229 for k
= 0, numGroups
- 1 do
230 local gr
= toolbar
:getGroup(k
)
240 ----------------------------------------------------------------------------------------------------------
241 -- common to r2:onChangeDesktop & r2:resetDesktop
242 function r2
:resetDesktopVisibleWindows(desktopIndex
)
243 -- reset the EDIT desktop
244 if desktopIndex
== 0 then
245 if (r2
.CurrentPropertyWindow
) then
246 r2
.CurrentPropertyWindow
.active
= false
247 r2
.CurrentPropertyWindow
= nil
249 r2
.PropertyWindowVisible
= false
250 show("ui:interface:r2ed_tool_context_help")
251 if config
.R2EDExtendedDebug
== 1 then
252 show("ui:interface:r2ed_current_session")
254 hide("ui:interface:r2ed_current_session")
256 hide("ui:interface:welcome_info")
257 hide("ui:interface:compass")
258 show("ui:interface:r2ed_main_menu_button")
259 show("ui:interface:r2ed_main_bl")
260 show("ui:interface:r2ed_select_bar")
261 hide("ui:interface:r2ed_select_bar:buttons")
262 hide("ui:interface:r2ed_select_bar:sequences")
263 hide("ui:interface:milko_pad")
264 hide("ui:interface:windows")
265 hide("ui:interface:r2ed_npc")
266 hide("ui:interface:ring_chars_tracking")
267 local b1
= getUI("ui:interface:r2ed_select_bar"):find("b1")
269 b1
:updateCoords() -- force to update the coords, icon position not good otherwise
271 hide("ui:interface:bonus_malus") -- patch for the bonus-malus window
272 r2
.ToolUI
:updateUndoRedo()
273 hide("ui:interface:r2ed_connect")
274 hide("ui:interface:r2ed_toolbar_window")
275 -- reset the TEST desktop
276 elseif desktopIndex
== 1 then
277 if config
.R2EDExtendedDebug
== 1 then
278 show("ui:interface:r2ed_current_session")
280 hide("ui:interface:r2ed_current_session")
282 hide("ui:interface:compass")
283 hide("ui:interface:welcome_info")
284 show("ui:interface:r2ed_main_bl")
285 hide("ui:interface:r2ed_testbar")
286 hide("ui:interface:r2ed_main_menu_button")
287 show("ui:interface:milko_pad")
288 hide("ui:interface:windows")
289 hide("ui:interface:r2ed_connect")
290 hide("ui:interface:ring_chars_tracking")
291 if not r2
.isSessionOwner() and r2
.AccessMode
~= "Editor" then
292 hide("ui:interface:r2ed_toolbar_window")
294 show("ui:interface:r2ed_toolbar_window")
297 -- reset the DM desktop
298 elseif desktopIndex
== 2 then
299 hide("ui:interface:compass")
300 if config
.R2EDExtendedDebug
== 1 then
301 show("ui:interface:r2ed_current_session")
303 hide("ui:interface:r2ed_current_session")
305 hide("ui:interface:r2ed_main_bl")
306 show("ui:interface:r2ed_testbar")
307 show("ui:interface:r2ed_main_menu_button")
308 hide("ui:interface:milko_pad")
309 hide("ui:interface:windows")
310 hide("ui:interface:bonus_malus") -- patch for the bonus-malus window
311 hide("ui:interface:r2ed_connect")
312 hide("ui:interface:r2ed_toolbar_window")
313 hide("ui:interface:ring_chars_tracking")
315 hide("ui:interface:bonus_malus") -- patch for the bonus-malus window
318 hide("ui:interface:team_share") -- patch for the 'team share' window
320 game
:updateMissionJournalMode()
324 -- called by C ++ : reset non savable parts after a desktop change
325 function r2
:onChangeDesktop(desktopIndex
)
326 --debugInfo("On change desktop = " .. tostring(desktopIndex))
327 hideAllNonSavableWindows();
329 -- in each case, hide welcom and ring access windows
330 getUI("ui:interface:npc_web_browser").active
=false
332 ----------------------------------------------------------------------------------------------------------
333 -- set the EDITION desktop
334 if desktopIndex
== 0 then
335 r2
:setFixedLighting(false)
336 hide("ui:interface:feature_help")
337 r2
.ui
.AnimBar
:clearActions()
338 local toolbar
= getUI("ui:interface:r2ed_toolbar")
340 toolbar
.active
= true
341 toolbar
.r2ed_tool_select
.active
= true
342 toolbar
.r2ed_tool_rotate
.active
= true
343 toolbar
.r2ed_tool_undo
.active
= true
344 toolbar
.r2ed_tool_redo
.active
= true
345 toolbar
.r2ed_tool_copy
.active
= true
346 toolbar
.r2ed_tool_paste
.active
= true
347 toolbar
.r2ed_tool_teleport
.active
= true
348 toolbar
.r2ed_tool_display_mode
.active
= true
349 toolbar
.r2ed_tool_start
.active
= true
350 toolbar
.r2ed_tool_stop
.active
= false
351 toolbar
.r2ed_stop_live
.active
= false
352 --toolbar.r2ed_tool_teleport.x = 4
353 r2
:adjustToolbarGap()
354 toolbar
.r2ed_freeze_bot_objects
.x
= 4
355 toolbar
.r2ed_unfreeze_bot_objects
.x
= 0
356 toolbar
:invalidateCoords()
357 toolbar
:updateCoords()
358 toolbar
.r2ed_live
.active
= false
362 local windowsDMBar
= getUI("ui:interface:r2ed_windows_dm_bar")
364 windowsDMBar
.active
=false
365 windowsDMBar
:invalidateCoords()
366 windowsDMBar
:updateCoords()
368 cleanEnv("r2ed_scenario")
369 cleanEnv("r2ed_bbox_edit")
370 cleanEnv("r2ed_toolbar")
371 cleanEnv("r2ed_windowbar")
372 cleanEnv("r2ed_testbar")
373 cleanEnv("r2ed_toolbar_admin")
374 cleanEnv("r2ed_table_test")
375 cleanEnv("r2ed_editbox_test")
376 cleanEnv("lua_inspector")
377 cleanEnv("r2ed_palette")
378 cleanEnv("r2ed_connect")
379 cleanEnv("r2ed_property_sheet_no_selection")
380 cleanEnv("r2ed_property_sheet_no_properties")
381 cleanEnv("r2ed_scenario")
382 r2
.ScenarioWindow
:resetWindow()
383 r2
.ContextualCommands
:setupToolbar(nil)
385 -- set new title for th "keys" window
386 local keys
= getUI("ui:interface:keys")
388 keys
.uc_title
= i18n
.get("uiR2EDEditingKeys")
391 if r2
.UserComponentsManager
then
392 r2
.UserComponentsManager
:updateUserComponentsUi()
394 r2
:setupFreezeBotObjectButton()
395 local goTestButton
= getUI("ui:interface:r2ed_toolbar"):find("r2ed_tool_start").unselected
.button
396 local goTestMenu
= getUI("ui:interface:r2ed_main_menu"):find("go_test")
397 goTestButton
.frozen
= false
398 goTestMenu
.grayed
= false
399 ----------------------------------------------------------------------------------------------------------
400 -- set the TEST desktop OR player desktop
401 elseif desktopIndex
== 1 then
402 r2
:setFixedLighting(false)
403 hide("ui:interface:feature_help")
404 r2
.ui
.AnimBar
:clearActions()
405 r2
.ui
.AnimBar
:update()
406 local toolbar
= getUI("ui:interface:r2ed_toolbar")
407 toolbar
.active
= false
408 local toolbarWindow
= getUI("ui:interface:r2ed_toolbar_window")
409 toolbarWindow
:find("r2ed_anim_dm_mode").active
= (r2
.AccessMode
== "Editor")
410 toolbarWindow
:find("r2ed_stop_live").active
= not (r2
.AccessMode
== "Editor") and r2
.isSessionOwner()
411 toolbarWindow
:find("player_control").active
= (not (r2
.AccessMode
== "Editor")) and r2
.isSessionOwner()
412 toolbarWindow
:find("r2ed_live").active
= false
414 -- resize the toolbarWindow depending on content
415 r2
:resizeToolbarWindow()
417 local windowsDMBar
= getUI("ui:interface:r2ed_windows_dm_bar")
419 windowsDMBar
.r2ed_live
.active
= (not (r2
.AccessMode
== "Editor")) and r2
.isSessionOwner()
420 windowsDMBar
.player_control
.active
= (not (r2
.AccessMode
== "Editor")) and r2
.isSessionOwner()
421 windowsDMBar
:invalidateCoords()
422 windowsDMBar
:updateCoords()
425 r2
:adjustToolbarGap()
427 local keys
= getUI("ui:interface:keys")
429 keys
.uc_title
= i18n
.get("uiR2EDTestOrDMKeys")
432 ----------------------------------------------------------------------------------------------------------
433 -- reset the DM desktop
434 elseif desktopIndex
== 2 then
435 r2
:setFixedLighting(false)
436 hide("ui:interface:feature_help")
437 r2
.ui
.AnimBar
:clearActions()
438 local toolbar
= getUI("ui:interface:r2ed_toolbar")
440 toolbar
.active
= true
441 toolbar
.r2ed_freeze_bot_objects
.active
= false
442 toolbar
.r2ed_unfreeze_bot_objects
.active
= false
443 toolbar
.r2ed_tool_select
.active
= false
444 toolbar
.r2ed_tool_rotate
.active
= false
445 toolbar
.r2ed_tool_undo
.active
= false
446 toolbar
.r2ed_tool_redo
.active
= false
447 toolbar
.r2ed_tool_copy
.active
= false
448 toolbar
.r2ed_tool_paste
.active
= false
449 toolbar
.r2ed_tool_teleport
.active
= true
450 toolbar
.r2ed_tool_display_mode
.active
= false
451 toolbar
.r2ed_tool_start
.active
= false
452 toolbar
.r2ed_tool_stop
.active
= (r2
.AccessMode
== "Editor")
453 toolbar
.r2ed_stop_live
.active
= (not (r2
.AccessMode
== "Editor")) and r2
.isSessionOwner()
454 --toolbar.r2ed_tool_teleport.x = -20 -- compensate x from previous buttons
455 --toolbar.r2ed_stop_live.x = -8 -- compensate x from previous buttons
456 toolbar
.r2ed_live
.active
= (r2
.AccessMode
=="Editor" or r2
.Mode
=="DM")
457 r2
:adjustToolbarGap()
458 toolbar
:invalidateCoords()
459 toolbar
:updateCoords()
463 local windowsDMBar
= getUI("ui:interface:r2ed_windows_dm_bar")
465 windowsDMBar
.active
=true
466 windowsDMBar
.r2ed_live
.active
= (not (r2
.AccessMode
== "Editor")) and r2
.isSessionOwner()
467 windowsDMBar
.player_control
.active
= (not (r2
.AccessMode
== "Editor")) and r2
.isSessionOwner()
469 windowsDMBar
:invalidateCoords()
470 windowsDMBar
:updateCoords()
472 r2
.ui
.AnimBar
:update()
473 r2
.ui
.AnimBar
:updateDMControlledEntitiesWindow()
474 local keys
= getUI("ui:interface:keys")
476 keys
.uc_title
= i18n
.get("uiR2EDTestOrDMKeys")
480 -- special : if "key" window is visible on current desktop, hide, then show it again to force a refresh of its content
481 local keys
= getUI("ui:interface:keys")
487 r2
:resetDesktopVisibleWindows(desktopIndex
)
488 r2
.ToolUI
:updateToggleWindowButtons()
489 r2
.ToolUI
:updateToggleWindowDMButtons()
492 function r2
:resizeToolbarWindow()
493 local toolbarWindow
= getUI("ui:interface:r2ed_toolbar_window")
494 toolbarWindow
:updateCoords()
495 local w
= toolbarWindow
:find("enclosing").w_real
+ 16
497 toolbarWindow
.pop_min_w
= w
498 toolbarWindow
.pop_max_w
= w
499 toolbarWindow
:updateCoords()
502 -- for masterless mode only : display option to control player & quit
503 function r2
:initDMToolbarWindowPos()
505 if not r2
.isSessionOwner() then return end
507 local scrW
, scrH
= getWindowSize()
508 -- init dm toolbar default pos
509 local toolbarWindow
= getUI("ui:interface:r2ed_toolbar_window")
510 toolbarWindow
.active
= true
512 toolbarWindow
.y
=scrH
- 190
515 -- for masterless mode only : display option to control player & quit
516 function r2
:popDMToolbarWindow()
517 local toolbarWindow
= getUI("ui:interface:r2ed_toolbar_window")
518 toolbarWindow
.active
= true
519 toolbarWindow
:find("r2ed_anim_dm_mode").active
= false
520 toolbarWindow
:find("r2ed_stop_live").active
= true
521 toolbarWindow
:find("r2ed_live").active
= true
522 toolbarWindow
:find("player_control").active
= true
523 r2
:resizeToolbarWindow()
524 setTopWindow(toolbarWindow
)
525 hide("ui:interface:r2ed_main_bl")
526 game
:updateMissionJournalMode()
528 getUI("ui:interface:welcome_info").active
=false
532 -- fix for previous versions : dm toolbar was shown on players desktop
533 function r2
:playerModeUIFix()
534 local toolbarWindow
= getUI("ui:interface:r2ed_toolbar_window")
535 toolbarWindow
.active
= false
536 hide("ui:interface:r2ed_main_bl")
537 game
:updateMissionJournalMode()
539 getUI("ui:interface:welcome_info").active
=false
543 function r2
:disableAnimals()
544 local animals
= getUI("ui:interface:animal_global")
545 animals
.content
.no_available_animals
.active
= true
546 animals
.list
.active
= false
547 animals
.header_opened
.active
= false
548 animals
.header_closed
.active
= true