3 uiId
= "ui:interface:r2ed_activities",
4 sequenceEditorId
= "ui:interface:r2ed_edit_activity_sequence",
5 ownCreatedInstances
= {},
9 sequencesIdCounter
= 0,
13 selectElt
="r2.activities.selectElement()",
16 removeElt
="r2.activities.removeElementInst()",
17 colOver
="200 120 80 120",
18 colPushed
="200 120 80 255",
21 elementEditorTemplate
= "template_edit_activity",
22 elementInitialName
=i18n
.get("uiR2EdActivity"):toUtf8(),
23 sequenceInitialName
=i18n
.get("uiR2EdSeq"):toUtf8(),
25 isInitialized
= false,
32 -- element ---------------------------------------------------
33 currentEltUIID
= nil, -- initialisé quand l'editeur est ouvert ou fermé
35 updatedSequUIID
= nil, -- creation of sequence or of one of this elements
36 updatedEltUIID
= nil, -- creation or update of element
39 activityTypeTranslation
= {
40 ["Stand Still"] ={trans
=i18n
.get("uiR2EdStandStill"):toUtf8(), zone
=""},
41 ["Follow Route"] ={trans
=i18n
.get("uiR2EdFollowRoad"):toUtf8(), zone
="Road"},
42 ["Patrol"] ={trans
=i18n
.get("uiR2EdPatrol"):toUtf8(), zone
="Road"},
43 ["Repeat Road"] ={trans
=i18n
.get("uiR2EdRepeatRoad"):toUtf8(), zone
="Road"},
44 ["Wander"] ={trans
=i18n
.get("uiR2EdWander"):toUtf8(), zone
="Region"},
45 ["Stand On Start Point"] ={trans
=i18n
.get("uiR2EdStandOnStartPoint"):toUtf8(), zone
=""},
46 ["Go To Start Point"] ={trans
=i18n
.get("uiR2EdGoToStartPoint"):toUtf8(), zone
=""},
47 ["Go To Zone"] ={trans
=i18n
.get("uiR2EdGoToZone"):toUtf8(), zone
="Region"},
48 ["Sit Down"] ={trans
=i18n
.get("uiR2EdSitDown"):toUtf8(), zone
=""},
49 ["Stand Up"] ={trans
=i18n
.get("uiR2EdStandUp"):toUtf8(), zone
=""},
50 ["Rest In Zone"] ={trans
=i18n
.get("uiR2EDRest"):toUtf8(), zone
="Region"},
51 ["Feed In Zone"] ={trans
=i18n
.get("uiR2EDFeed"):toUtf8(), zone
="Region"},
52 ["Work In Zone"] ={trans
=i18n
.get("uiR2EDWork"):toUtf8(), zone
="Region"},
53 ["Hunt In Zone"] ={trans
=i18n
.get("uiR2EDHunt"):toUtf8(), zone
="Region"},
54 ["Guard Zone"] ={trans
=i18n
.get("uiR2EDGuard"):toUtf8(), zone
="Region"},
57 timeLimitsTranslation
= {
58 ["No Limit"] =i18n
.get("uiR2EdNoTimeLimit"):toUtf8(),
59 ["Chat"] =i18n
.get("uiR2EdWhileChat"):toUtf8(),
60 ["Few Sec"] =i18n
.get("uiR2EdForCertainTime"):toUtf8(),
63 timeLimitsProperties
= {
64 [i18n
.get("uiR2EdNoTimeLimit"):toUtf8()] ="No Limit",
65 [i18n
.get("uiR2EdWhileChat"):toUtf8()] ="Chat",
66 [i18n
.get("uiR2EdForCertainTime"):toUtf8()] ="Few Sec"
71 -- sequence --------------------------------------------------
72 function r2
.activities
:currentSequUI()
73 local ui
= getUI(self
.uiId
)
74 local tab
= ui
:find("sequence_tabs")
77 local sequenceUI
= tab
:getGroup(tab
.selection
)
82 function r2
.activities
:currentSequInstId()
83 if self
:currentSequUI() then
84 return self
:currentSequUI().Env
.InstanceId
89 --initialisé quand selection sequence dans tab ou dans barre menu
90 function r2
.activities
:setSequUIInstId(sequUI
, id
)
91 sequUI
.Env
.InstanceId
= id
94 function r2
.activities
:currentSequInst()
95 if self
:currentSequInstId() then
96 return r2
:getInstanceFromId(self
:currentSequInstId())
101 -- element ---------------------------------------------------
103 function r2
.activities
:currentEltUIId()
104 return self
.currentEltUIID
107 function r2
.activities
:currentEltUI()
108 if self
.currentEltUIID
then
109 return getUI(self
.currentEltUIID
)
114 function r2
.activities
:setCurrentEltUIId(id
)
115 self
.currentEltUIID
= id
118 function r2
.activities
:currentEltInstId()
119 if self
.currentEltUIID
then
120 return self
:currentEltUI().Env
.InstanceId
125 function r2
.activities
:currentEltInst()
126 if self
.currentEltUIID
and self
:currentEltInstId() then
127 return r2
:getInstanceFromId(self
:currentEltInstId())
132 -- updated element and/or sequence (not necessary the same as current sequence or element)
133 function r2
.activities
:updatedSequUI()
134 if self
.updatedSequUIID
then
135 return getUI(self
.updatedSequUIID
)
140 function r2
.activities
:setUpdatedSequUIId(sequUIId
)
141 self
.updatedSequUIID
= sequUIId
144 function r2
.activities
:updatedEltUI()
145 if self
.updatedEltUIID
then
146 return getUI(self
.updatedEltUIID
)
151 function r2
.activities
:setUpdatedEltUIId(eltUIId
)
152 self
.updatedEltUIID
= eltUIId
161 ------------------ INIT ACTIVITIES EDITOR --------------------------------------
162 function r2
.activities
:initEditor()
166 function r2
.activities
:initEditorAfterFirstCall()
168 if not self
.isInitialized
then
172 -- create sequences UI for selected entity
173 local entity
= r2
:getSelectedInstance()
175 local activitySequences
= entity
:getBehavior().Activities
177 local selectedSequenceIndex
= entity
:getSelectedSequenceIndex()
179 for s
= 0, activitySequences
.Size
- 1 do
180 r2
.activities
:newSequenceUI(activitySequences
[s
])
184 local ui
= getUI(self
.uiId
)
187 local tabActivities
= ui
:find("sequence_tabs")
188 assert(tabActivities
)
189 tabActivities
.selection
= -1
191 if activitySequences
.Size
>0 then
192 self
:triggerSelectSequence(activitySequences
[selectedSequenceIndex
].InstanceId
)
195 local uc_title
= ucstring()
196 uc_title
:fromUtf8(i18n
.get("uiR2EDActivitySequenceEditor"):toUtf8() .. entity
.Name
)
197 ui
.uc_title
= uc_title
199 self
.isInitialized
= true
203 ------ OPEN EDITOR ---------------------------------------------------------------
204 function r2
.activities
:openEditor()
206 local ui
= getUI(self
.uiId
)
208 if not ui
.active
then
210 self
:initEditorAfterFirstCall()
216 if self
.openFirst
== nil then
217 self
.openFirst
= true
226 ------ OPEN SEQUENCE EDITOR ---------------------------------------------------------------
227 function r2
.activities
:openSequenceEditor()
229 local sequenceEditor
= getUI(self
.sequenceEditorId
)
230 assert(sequenceEditor
)
231 sequenceEditor
.active
= false
233 local ui
= getUI(self
.uiId
)
236 sequenceEditor
.x
= ui
.x
237 sequenceEditor
.y
= ui
.y
238 sequenceEditor
.active
= true
240 -- update edit box text with current sequence name
241 local editName
= sequenceEditor
:find("sequence_name"):find("edit_box_group")
244 local tab
= ui
:find("sequence_tabs")
247 local sequInstId
= r2
.logicUI
:getSequUIInstId(ui
:find(tab
.associatedGroupSelection
))
249 local activitySequence
= r2
:getInstanceFromId(sequInstId
)
250 assert(activitySequence
)
252 if activitySequence
.Name
~= "" then
253 tabName
= activitySequence
.Name
255 local comps
= activitySequence
.Parent
256 for i
=0, comps
.Size
-1 do
257 if comps
[i
].InstanceId
== activitySequence
.InstanceId
then
258 tabName
= self
.sequenceInitialName
..(i
+1)
264 local uc_sequ
= ucstring()
265 uc_sequ
:fromUtf8(tabName
)
266 editName
.uc_input_string
= uc_sequ
270 ------ SET SEQUENCE NAME ---------------------------------------------------------------
271 function r2
.activities
:setSequenceName()
273 r2
.requestNewAction(i18n
.get("uiR2EDSetSequenceNameAction"))
275 local sequenceEditor
= getUI(self
.sequenceEditorId
)
276 assert(sequenceEditor
)
278 local editName
= sequenceEditor
:find("sequence_name"):find("edit_box_group")
281 local sequenceInstId
= self
:currentSequInstId()
282 r2
.requestSetNode(sequenceInstId
, "Name", editName
.uc_input_string
:toUtf8())
284 sequenceEditor
.active
= false
288 ------ NEW SEQUENCE INST -------------------------------------------------------------
289 function r2
.activities
:newSequenceInst()
291 r2
.requestNewAction(i18n
.get("uiR2EDNewSequenceListAction"))
293 local ui
= getUI(self
.uiId
)
296 local tab
= ui
:find("sequence_tabs")
299 --if tab.tabButtonNb == self.maxSequences then return end
301 local entity
= r2
:getSelectedInstance()
304 local activitySequence
= r2
.newComponent("ActivitySequence")
306 r2
.requestInsertNode(entity
:getBehavior().InstanceId
, "Activities", -1, "", activitySequence
)
307 self
.ownCreatedInstances
[activitySequence
.InstanceId
] = true
309 if entity
:getBehavior().Activities
.Size
== 0 then
310 self
.firstSequence
[entity
.InstanceId
] = activitySequence
.InstanceId
313 return activitySequence
.InstanceId
316 ------ NEW SEQUENCE UI --------------------------------------------------------------
317 function r2
.activities
:newSequenceUI(activitySequence
)
319 local templateParams
= {
320 newElt
="r2.activities:newElementInst()",
321 newEltText
=i18n
.get("uiR2EdNewActivity"):toUtf8(),
322 eltOrderText
=i18n
.get("uiR2EdActivityOrder"):toUtf8(),
323 upElt
="r2.activities:upElementInst()",
324 downElt
="r2.activities:downElementInst()",
325 maxMinElts
="r2.activities:maximizeMinimizeElements()",
326 downUpColor
="220 140 100 255",
327 overDownUpColor
="255 180 170 255",
328 colPushed
= "220 140 100 255",
329 paramsL
= "r2.activities:selectSequence('"..activitySequence
.InstanceId
.."')"
332 local ui
= getUI(self
.uiId
)
335 local menu
= ui
:find("sequence_menu")
338 local tab
= menu
:find("sequence_tabs")
341 -- NEW SEQUENCE GROUP --------------------------------------------
342 local newTabNb
= tab
.tabButtonNb
+1
343 local posParent
, posRef
, id
, group
344 if newTabNb
== 1 then
348 posParent
= "tab"..(newTabNb
-2)
352 local id
= "tab"..(newTabNb
-1)
354 local groupId
= "sequence"..self
.sequencesIdCounter
355 self
.sequencesIdCounter
= self
.sequencesIdCounter
+1
357 local newTabGroup
= createUIElement("sequence_elements_template", menu
.id
, {id
=groupId
,
358 new_elt
=templateParams
.newElt
, new_elt_text
=templateParams
.newEltText
,
359 elt_order_text
=templateParams
.eltOrderText
, up_elt
=templateParams
.upElt
,
360 down_elt
=templateParams
.downElt
, max_min_elts
=templateParams
.maxMinElts
,
361 down_up_color
=templateParams
.downUpColor
, over_down_up_color
=templateParams
.overDownUpColor
})
364 menu
:addGroup(newTabGroup
)
366 r2
.logicUI
:setSequUIInstId(newTabGroup
, activitySequence
.InstanceId
)
367 self
:setUpdatedSequUIId(newTabGroup
.id
)
369 -- NEW TAB ----------------------------------------------------
370 local comps
= activitySequence
.Parent
372 for i
=0, comps
.Size
-1 do
373 if comps
[i
].InstanceId
== activitySequence
.InstanceId
then
379 local newTab
= createUIElement("sequence_tab_template", tab
.id
,
380 {id
=id
, posparent
=posParent
, posref
=posRef
, group
=groupId
,
381 col_pushed
=templateParams
.colPushed
, params_l
=templateParams
.paramsL
})
384 tab
:addTabWithOrder(newTab
, sequIndex
)
386 local viewText
= newTab
:getViewText()
388 viewText
.overExtendViewText
= true
389 viewText
.overExtendViewTextUseParentRect
= false
390 viewText
:setLineMaxW(40)
392 newTab
:updateCoords()
394 -- if it's the first sequence, active all separators and buttons around it
395 if tab
.tabButtonNb
== 1 then
399 -- create element editor of new sequence
400 self
:createElementEditor()
402 -- create all elements ui of new sequence
403 for a
= 0, activitySequence
.Components
.Size
- 1 do
404 self
:newElementUI(activitySequence
.Components
[a
])
407 -- if YOU just called creation of this sequence (or undo/redo request), it becomes current
409 if self
.ownCreatedInstances
[activitySequence
.InstanceId
] == true
410 or r2
.logicComponents
.undoRedoInstances
[activitySequence
.InstanceId
]==true then
412 -- right and left buttons to decal showed sequences
413 self
:triggerSelectSequence(activitySequence
.InstanceId
)
414 self
.ownCreatedInstances
[activitySequence
.InstanceId
] = nil
416 r2
.logicComponents
.undoRedoInstances
[activitySequence
.InstanceId
] = nil
419 -- update next sequences UI names
420 for i
=sequIndex
, tab
.tabButtonNb
-1 do
422 local tabButton
= tab
:getTabButton(i
)
424 local sequenceUI
= tab
:getGroup(i
)
426 local sequInst
= r2
:getInstanceFromId(r2
.logicUI
:getSequUIInstId(sequenceUI
))
430 if sequInst
.Name
~= "" then
431 sequName
= sequInst
.Name
433 sequName
= self
.sequenceInitialName
.. (i
+1)
436 local uc_name
= ucstring()
437 uc_name
:fromUtf8(sequName
)
438 tabButton
.uc_hardtext
= uc_name
442 ---- REMOVE SEQUENCE INSTANCE ---------------------------------------------
443 function r2
.activities
:removeSequenceInst()
444 r2
.requestNewAction(i18n
.get("uiR2EDRemoveSequenceListAction"))
445 local sequenceInstId
= self
:currentSequInstId()
446 assert(sequenceInstId
)
447 r2
.requestEraseNode(sequenceInstId
, "", -1)
450 ---- REMOVE SEQUENCE UI --------------------------------------------------
451 function r2
.activities
:removeSequenceUI(instance
)
453 -- if sequenceUI to delete is the current sequenceUI, no current elementUI anymore
454 local selectedElt
= self
:currentEltUI()
455 if (selectedElt
and selectedElt
.parent
.parent
.parent
== self
:updatedSequUI()) then
456 self
:setCurrentEltUIId(nil)
458 local deleteCurrentSequUI
= (self
:updatedSequUI() == self
:currentSequUI())
460 -- rename sequences which have default name and are after the removed sequence in list
461 local ui
= getUI(self
.uiId
)
463 local tab
= ui
:find("sequence_tabs")
466 local selection
= tab
.selection
468 local removedIndex
= tab
.tabButtonNb
469 for i
=0, tab
.tabButtonNb
-1 do
470 local sequenceUI
= tab
:getGroup(i
)
472 if r2
.logicUI
:getSequUIInstId(sequenceUI
) == instance
.InstanceId
then
475 if i
>removedIndex
then
476 local buttonTab
= tab
:find("tab"..i
)
478 if buttonTab
.hardtext
== self
.sequenceInitialName
..(i
+1) then
479 buttonTab
.uc_hardtext
= self
.sequenceInitialName
..i
484 if removedIndex
< selection
then
485 selection
= selection
-1
488 -- remove tab of the tab list
489 tab
:removeTab(removedIndex
)
492 for i
=0, tab
.tabButtonNb
-1 do
493 local tabButton
= tab
:getTabButton(i
)
494 if tabButton
.active
then
500 -- if no sequence anymore, hide separators, buttons...
501 if tab
.tabButtonNb
== 0 then
506 ----- REPEAT SEQUENCE -------------------------------------------
507 function r2
.activities
:repeatSequence()
509 r2
.requestNewAction(i18n
.get("uiR2EDSetSequenceRepeatFlagAction"))
512 local sequenceInst
= self
:currentSequInst()
513 if sequenceInst
==nil then return end
515 local sequenceType
= 1
516 if getUICaller().pushed
==true then sequenceType
= 0 end
518 r2
.requestSetNode(sequenceInst
.InstanceId
, "Repeating", sequenceType
)
521 ------ UPDATE SEQUENCE UI ------------------------------------------------------
522 function r2
.activities
:updateSequenceUI(instance
, attributeName
)
524 local ui
= getUI(self
.uiId
)
527 if attributeName
=="Name" then
529 local name
= instance
:getName()
531 local tab
= ui
:find("sequence_tabs")
535 for i
=0, tab
.tabButtonNb
-1 do
536 local sequenceUI
= tab
:getGroup(i
)
537 if r2
.logicUI
:getSequUIInstId(sequenceUI
) == instance
.InstanceId
then
544 local buttonTab
= tab
:find("tab"..tabId
)
547 local uc_name
= ucstring()
548 uc_name
:fromUtf8(name
)
549 buttonTab
.uc_hardtext
= uc_name
551 local viewText
= buttonTab
:getViewText()
555 -- r2.miniActivities:updateSequenceButtonBar()
557 elseif attributeName
=="Repeating" then
558 local sequenceUI
= self
:updatedSequUI()
561 local repeatButton
= ui
:find("repeat_group"):find("repeat"):find("toggle_butt")
562 repeatButton
.pushed
= (instance
.Repeating
== 0)
566 ------ DECAL TO RIGHT SEQUENCES IN EDITOR ------------------------------
567 function r2
.activities
:rightSequenceUI()
569 local ui
= getUI(self
.uiId
)
572 local tabGr
= ui
:find("sequence_tabs")
575 local lastTab
= tabGr
.lastTabButton
576 tabGr
:showTabButton(lastTab
+1);
579 ------ DECAL TO LEFT SEQUENCES IN EDITOR -------------------------------
580 function r2
.activities
:leftSequenceUI()
582 local ui
= getUI(self
.uiId
)
585 local tabGr
= ui
:find("sequence_tabs")
588 local firstTab
= tabGr
.firstTabButton
589 tabGr
:showTabButton(firstTab
-1);
592 function r2
.activities
:showSequencesUI()
594 local ui
= getUI(self
.uiId
)
597 local tabGr
= ui
:find("sequence_tabs")
600 local leftTabsButton
= ui
:find("left_sequences")
601 assert(leftTabsButton
)
603 local rightTabsButton
= ui
:find("right_sequences")
604 assert(rightTabsButton
)
608 for i
=0, tabGr
.tabButtonNb
-1 do
609 local tab
= tabGr
:getTabButton(i
)
616 elseif firstTab
~=nil then
621 if firstTab
and lastTab
then
622 leftTabsButton
.active
= (firstTab
~=0)
623 rightTabsButton
.active
= (lastTab
~=tabGr
.tabButtonNb
-1)
627 ------ CLOSE EDITOR ------------------------------------------------------
628 function r2
.activities
:closeEditor()
630 local ui
= getUI(self
.uiId
)
636 local sequenceEditor
= getUI(self
.sequenceEditorId
)
637 assert(sequenceEditor
)
638 sequenceEditor
.active
= false
640 self
.isInitialized
= false
643 ------ CLEAN EDITOR -------------------------------------------------------
644 function r2
.activities
:cleanEditor()
646 self
:setCurrentEltUIId(nil)
647 self
:setUpdatedSequUIId(nil)
648 self
:setUpdatedEltUIId(nil)
649 self
.elementsIdCounter
= 0
651 self
.sequencesIdCounter
= 0
653 local ui
= getUI(self
.uiId
)
656 -- remove all tabs and associated groups
657 local sequenceMenu
= ui
:find("sequence_menu")
660 local tabActivities
= ui
:find("sequence_tabs")
661 assert(tabActivities
)
663 tabActivities
:removeAll()
665 -- hide separators and buttons around
669 ------ SELECT ELEMENT --------------------------------------------------
670 function r2
.activities
:selectElement(selectedButtonElt
, sequInstId
)
672 self
:triggerSelectSequence(sequInstId
)
674 r2
.logicComponents
:selectElement(r2
.activities
, selectedButtonElt
)
677 ------ SELECT SEQUENCE -----------------------------------------------
678 function r2
.activities
:triggerSelectSequence(sequInstId
)
680 local ui
= getUI(self
.uiId
)
683 local tabActivities
= ui
:find("sequence_tabs")
684 assert(tabActivities
)
686 local sequInst
= r2
:getInstanceFromId(sequInstId
)
688 local tabNb
= r2
.logicComponents
:searchElementIndex(sequInst
)-1
690 local sequenceUI
= tabActivities
:getGroup(tabNb
)
691 if sequenceUI
and r2
.logicUI
:getSequUIInstId(sequenceUI
)==sequInstId
then
693 -- triggers call of r2.activities:selectSequence
694 tabActivities
.selection
= tonumber(tabNb
)
698 function r2
.activities
:selectSequence(sequInstId
)
700 r2
.logicComponents
:selectSequence(r2
.activities
)
702 local ui
= getUI(self
.uiId
)
705 local sequInst
= r2
:getInstanceFromId(sequInstId
)
709 local repeatButton
= ui
:find("repeat_group"):find("repeat"):find("toggle_butt")
710 repeatButton
.pushed
= (sequInst
.Repeating
== 0)
712 -- update sequence button bar
713 r2
.miniActivities
:updateSequenceButtonBar()
715 -- update mini activities view
716 r2
.miniActivities
:updateMiniActivityView()
718 -- set the sequence in activity owner
719 local owner
= sequInst
.ParentInstance
.ParentInstance
721 owner
.User
.SelectedSequence
= sequInst
.IndexInParent
724 ------ CREATE EDITOR -------------------------------------------------------
725 function r2
.activities
:createElementEditor()
727 local activityEditor
= r2
.logicComponents
:createElementEditor(r2
.activities
)
728 assert(activityEditor
)
731 local timeLimitCB
= activityEditor
:find("time_limit"):find("combo_box")
733 timeLimitCB
:resetTexts()
734 timeLimitCB
:addText(i18n
.get("uiR2EdNoTimeLimit"))
735 timeLimitCB
:addText(i18n
.get("uiR2EdForCertainTime"))
738 local cb
= activityEditor
:find("road_count_limit"):find("combo_box")
741 cb
:addText(i18n
.get("uiR2EdNoRoadCountLimit"))
745 cb
:addText(ucstring(tostring(i
)))
752 ------ OPEN ELEMENT EDITOR -----------------------------------------------
753 function r2
.activities
:updateElementEditor()
755 local instanceActivity
= self
:currentEltInst()
756 if instanceActivity
==nil then return end
758 local sequenceUI
= self
:currentSequUI()
761 local activityEditor
= sequenceUI
:find("edit_element")
762 assert(activityEditor
)
765 local activityName
= activityEditor
:find("name")
769 local activityButtonText
= activityEditor
:find("activity"):find("text")
770 assert(activityButtonText
)
772 -- patrol / repeat road special casefalse
774 local grp
= activityEditor
:find("road_count_group")
775 if instanceActivity
.Activity
== "Patrol" or instanceActivity
.Activity
== "Repeat Road" then
783 local comboBox
= activityEditor
:find("road_count_limit").combo_box
785 local value
= select(instanceActivity
.RoadCountLimit
, instanceActivity
.RoadCountLimit
, "0")
787 value
= i18n
.get("uiR2EdNoRoadCountLimit"):toUtf8()
789 comboBox
.Env
.locked
= true
790 comboBox
.selection_text
= value
791 comboBox
.Env
.locked
= false
796 local comboBox
= activityEditor
:find("time_limit").combo_box
799 local index
= r2
.logicComponents
:searchElementIndex(instanceActivity
)
800 local uc_activityName
= ucstring(self
.elementInitialName
.." : ")
802 uc_activityName
:fromUtf8(self
.elementInitialName
.." "..index
.." : ")
804 activityName
.uc_hardtext
= uc_activityName
807 local activityText
= instanceActivity
:getVerb()
808 if instanceActivity
.ActivityZoneId
~= "" then
809 local place
= r2
:getInstanceFromId(instanceActivity
.ActivityZoneId
)
812 activityText
= activityText
.. " " .. place
.Name
815 local uc_activityText
= ucstring()
816 uc_activityText
:fromUtf8(activityText
)
817 activityButtonText
.uc_hardtext
= uc_activityText
821 local timeLimit
= instanceActivity
.TimeLimit
823 local certainTime
= activityEditor
:find("certain_time")
826 comboBox
.Env
.locked
= true
827 if timeLimit
== "Few Sec" then
829 local timeLimitValue
= tonumber(instanceActivity
.TimeLimitValue
)
831 if timeLimitValue
~= nil then
833 local hoursNb
, minNb
, secNb
= r2
.logicComponents
:calculHourMinSec(timeLimitValue
)
835 local timeLimitText
= i18n
.get("uiR2EdFor"):toUtf8() .. " "
836 if hoursNb
~= 0 then timeLimitText
= timeLimitText
.. hoursNb
.. i18n
.get("uiR2EdShortHours"):toUtf8() .. " " end
837 if minNb
~= 0 then timeLimitText
= timeLimitText
.. minNb
.. i18n
.get("uiR2EdShortMinutes"):toUtf8() .. " " end
838 timeLimitText
= timeLimitText
.. secNb
.. i18n
.get("uiR2EdShortSeconds"):toUtf8()
840 certainTime
.active
= true
841 local hoursMenu
= certainTime
:find("hours"):find("text")
843 hoursMenu
.uc_hardtext
= tostring(hoursNb
)
845 local minutesMenu
= certainTime
:find("minutes"):find("text")
847 minutesMenu
.uc_hardtext
= tostring(minNb
)
849 local secondsMenu
= certainTime
:find("seconds"):find("text")
851 secondsMenu
.uc_hardtext
= tostring(secNb
)
853 local uc_time
= ucstring()
854 uc_time
:fromUtf8(timeLimitText
)
855 comboBox
.view_text
= uc_time
858 certainTime
.active
= false
859 timeLimit
= self
.timeLimitsTranslation
[timeLimit
]
860 if timeLimit
~= nil then
861 comboBox
.selection_text
= timeLimit
864 comboBox
.Env
.locked
= false
867 ----- CLOSE ELEMENT EDITOR --------------------------------------------------------
868 function r2
.activities
:closeElementEditor()
870 r2
.logicComponents
:closeElementEditor(r2
.activities
)
873 ------ NEW ELEMENT INST ----------------------------------------------------------
874 function r2
.activities
:newElementInst(tableInit
)
876 local sequenceUI
= self
:currentSequUI()
878 local eltsList
= sequenceUI
:find("elements_list")
881 if eltsList
.childrenNb
>= self
.maxElements
then return end
884 local sequenceInstId
= self
:currentSequInstId()
885 -- when no sequences, we create the first
886 local selectedInst
= r2
:getSelectedInstance()
888 local selectedInstId
= selectedInst
.InstanceId
889 if sequenceInstId
== nil then
890 if self
.firstSequence
[selectedInstId
] then
891 sequenceInstId
= self
.firstSequence
[selectedInstId
]
893 sequenceInstId
= self
:newSequenceInst()
897 local instanceElement
= r2
.newComponent("ActivityStep")
899 local existZone
= false
900 local actionToInitDefaultActivity
= ""
902 if tableInit
~= nil then
903 instanceElement
.Activity
= tableInit
.Activity
904 instanceElement
.ActivityZoneId
= r2
.RefId(tableInit
.ActivityZoneId
)
905 instanceElement
.TimeLimit
= tableInit
.TimeLimit
906 instanceElement
.TimeLimitValue
= tableInit
.TimeLimitValue
908 if tableInit
.RoadCountLimit
then instanceElement
.RoadCountLimit
= tableInit
.RoadCountLimit
end
910 instanceElement
.TimeLimit
= "No Limit"
912 local activitiesTable
= {}
913 selectedInst
:getAvailableActivities(activitiesTable
)
914 local standStillAct
= false
915 local roadAct
= false
916 local regionAct
= false
918 for k
, activity
in pairs(activitiesTable
) do
919 if activity
=="Stand Still" then
922 elseif self
.activityTypeTranslation
[activity
].zone
=="Road" then
924 activityZone
= activity
925 elseif self
.activityTypeTranslation
[activity
].zone
=="Region" then
927 activityZone
= activity
931 if standStillAct
then
932 instanceElement
.Activity
= "Stand Still"
934 local roadsTable
= r2
.Scenario
:getAllInstancesByType("Road")
935 if table.getn(roadsTable
) > 0 then
936 instanceElement
.Activity
= activityZone
938 for k
, v
in pairs(roadsTable
) do
939 zoneId
= v
.InstanceId
942 instanceElement
.ActivityZoneId
= zoneId
945 elseif regionAct
then
946 local regionsTable
= r2
.Scenario
:getAllInstancesByType("Region")
947 if table.getn(regionsTable
) > 0 then
948 instanceElement
.Activity
= activityZone
950 for k
, v
in pairs(regionsTable
) do
951 zoneId
= v
.InstanceId
954 instanceElement
.ActivityZoneId
= zoneId
958 debugInfo("No activity type to initialize default activity step")
962 actionToInitDefaultActivity
= i18n
.get("uiR2EdRoad"):toUtf8() .. " "
966 if actionToInitDefaultActivity
~="" then
967 actionToInitDefaultActivity
= actionToInitDefaultActivity
.. i18n
.get("uiR2EdOr"):toUtf8().. " "
969 actionToInitDefaultActivity
= actionToInitDefaultActivity
.. i18n
.get("uiR2EdRegion"):toUtf8() .. " "
973 if instanceElement
.Activity
~="" then
974 r2
.requestNewAction(i18n
.get("uiR2EDNewSequenceElementAction"))
975 r2
.requestInsertNode(sequenceInstId
, "Components", -1, "", instanceElement
)
976 self
.ownCreatedInstances
[instanceElement
.InstanceId
] = true
978 r2
.logicComponents
:newElementInst(r2
.activities
)
980 elseif not existZone
then
981 local message
= i18n
.get("uiR2EdCreateZone"):toUtf8() .. actionToInitDefaultActivity
.. i18n
.get("uiR2EdFor"):toUtf8() .. " " .. selectedInst
.Name
982 local uc_message
= ucstring()
983 uc_message
:fromUtf8(message
)
984 messageBox(uc_message
)
986 r2
.requestForceEndMultiAction()
989 ------ NEW ELEMENT UI -------------------------------------------------------------
990 function r2
.activities
:newElementUI(newInst
)
991 r2
.logicUI
:newElementUI(r2
.activities
, newInst
, true)
994 ------ REMOVE ELEMENT INST --------------------------------------------------------
995 function r2
.activities
:removeElementInst()
996 r2
.requestNewAction(i18n
.get("uiR2EDRemoveLogicElementAction"))
997 r2
.logicComponents
:removeElementInst(r2
.activities
)
998 r2
.requestEndAction()
1001 ------ REMOVE ELEMENT UI ---------------------------------------------------------
1002 function r2
.activities
:removeElementUI(removedEltUI
)
1003 r2
.logicUI
:removeElementUI(r2
.activities
, removedEltUI
)
1006 ------ UP ELEMENT INST ------------------------------------------------------------
1007 function r2
.activities
:upElementInst()
1008 r2
.logicComponents
:upElementInst(r2
.activities
)
1011 ------ DOWN ELEMENT INST ---------------------------------------------------------
1012 function r2
.activities
:downElementInst()
1013 r2
.logicComponents
:downElementInst(r2
.activities
)
1016 ------ MAX/MIN ELEMENTS UI --------------------------------------------------------
1017 function r2
.activities
:maximizeMinimizeElements()
1018 r2
.logicUI
:maximizeMinimizeElements(r2
.activities
)
1021 ------ MAX/MIN ELEMENT UI ------------------------------------------------------------
1022 function r2
.activities
:maximizeMinimizeElement(element
, allMinimize
)
1024 r2
.logicUI
:maximizeMinimizeElement(element
, allMinimize
)
1027 ------ DOWN/UP ELEMENT UI -----------------------------------------------------------
1028 function r2
.activities
:downUpElementUI(elementUI
, instance
)
1029 r2
.logicUI
:downUpElementUI(r2
.activities
, elementUI
, instance
)
1032 ------ UPDATE ELEMENT UI -------------------------------------------------------------
1033 function r2
.activities
:updateElementUI(elementUI
)
1035 r2
.logicUI
:updateElementUI(r2
.activities
, elementUI
)
1038 ------ UPDATE ELEMENT TITLE -----------------------------------------------------------
1039 function r2
.activities
:updateElementTitle(activityUI
)
1041 r2
.logicComponents
:updateElementTitle(r2
.activities
, activityUI
, true)
1044 ------ INIT ACTIVITY MENU -------------------------------------------------------------------
1045 function r2
.activities
:initActivityMenu()
1047 local menuName
= "ui:interface:r2ed_triggers_menu"
1048 local activityMenu
= getUI(menuName
)
1049 local activityMenu
= activityMenu
:getRootMenu()
1050 assert(activityMenu
)
1051 activityMenu
:reset()
1052 local uc_activity
= ucstring()
1054 local activitiesTable
= {}
1055 r2
:getSelectedInstance():getAvailableActivities(activitiesTable
)
1057 local activitiesNb
= 0
1058 for k
, actType
in pairs(activitiesTable
) do
1059 local uc_activity
= ucstring()
1060 local translation
= self
.activityTypeTranslation
[actType
].trans
1061 uc_activity
:fromUtf8(translation
)
1063 local zone
= self
.activityTypeTranslation
[actType
].zone
1065 activityMenu
:addLine(uc_activity
, "lua", "r2.activities:setActivityType('"..actType
.."')", actType
)
1067 activityMenu
:addLine(uc_activity
, "", "", actType
)
1069 local textureName
= ""
1070 if zone
== "Road" then
1071 textureName
= "r2ed_icon_road.tga"
1072 elseif zone
== "Region" then
1073 textureName
= "r2ed_icon_region.tga"
1076 local menuButton
= createGroupInstance("r2_menu_button", "", { bitmap
= textureName
, size
="14" })
1077 activityMenu
:setUserGroupLeft(activitiesNb
, menuButton
)
1078 activityMenu
:addSubMenu(activitiesNb
)
1079 local zonesMenu
= activityMenu
:getSubMenu(activitiesNb
)
1080 local zonesTable
= r2
.Scenario
:getAllInstancesByType(zone
)
1081 for key
, z
in pairs(zonesTable
) do
1082 uc_activity
:fromUtf8(z
.Name
)
1083 zonesMenu
:addLine(uc_activity
, "lua", "r2.activities:setActivityType('"..actType
.."', '".. z
.InstanceId
.."')", z
.InstanceId
)
1085 if table.getn(zonesTable
) == 0 then
1086 zonesMenu
:addLine(i18n
.get("uiR2EdNoSelelection"), "lua", "r2.activities:setActivityType()", "")
1090 activitiesNb
= activitiesNb
+1
1093 r2
.logicUI
:openLogicMenu(getUICaller())
1096 --- SET ACTIVITY TYPE --------------------------------------------------------------------
1097 function r2
.activities
:setActivityType(activityType
, placeId
)
1099 local activityInstId
= self
:currentEltInstId()
1100 assert(activityInstId
)
1102 if activityType
== nil then
1104 elseif placeId
== nil then
1105 r2
.requestNewAction(i18n
.get("uiR2EDSetActivityTypeAction"))
1106 r2
.requestSetNode(activityInstId
, "Activity", activityType
)
1107 r2
.requestSetNode(activityInstId
, "ActivityZoneId", r2
.RefId(""))
1109 r2
.requestNewAction(i18n
.get("uiR2EDSetActivityTypeAction"))
1110 r2
.requestSetNode(activityInstId
, "Activity", activityType
)
1111 r2
.requestSetNode(activityInstId
, "ActivityZoneId", r2
.RefId(placeId
))
1115 --- SET TIME LIMIT --------------------------------------------------------------------
1116 function r2
.activities
:setTimeLimit(timeLimit
)
1118 r2
.requestNewAction(i18n
.get("uiR2EDSetActivityTimeLimitAction"))
1120 if timeLimit
== nil then
1121 timeLimit
= getUICaller().selection_text
1122 if getUICaller().Env
.locked
then return end
1125 local activityInstId
= self
:currentEltInstId()
1126 assert(activityInstId
)
1129 if timeLimit
== i18n
.get("uiR2EdForCertainTime"):toUtf8() then
1130 r2
.requestSetNode(activityInstId
, "TimeLimitValue", tostring(20))
1132 r2
.requestSetNode(activityInstId
, "TimeLimitValue", "")
1136 timeLimit
= self
.timeLimitsProperties
[timeLimit
]
1138 r2
.requestSetNode(activityInstId
, "TimeLimit", timeLimit
)
1141 --- SET TIME LIMIT --------------------------------------------------------------------
1142 function r2
.activities
:setRoadCountLimit(limit
)
1144 r2
.requestNewAction(i18n
.get("uiR2EDSetActivityRoadCountAction"))
1146 if limit
== nil then
1147 timeLimit
= getUICaller().selection_text
1148 if getUICaller().Env
.locked
then return end
1151 local activityInstId
= self
:currentEltInstId()
1152 assert(activityInstId
)
1155 if limit
== i18n
.get("uiR2EdNoRoadCountLimit"):toUtf8() then
1156 r2
.requestSetNode(activityInstId
, "RoadCountLimit", "0")
1158 r2
.requestSetNode(activityInstId
, "RoadCountLimit", timeLimit
)
1162 ------ INIT TIME MENU -----------------------------------------------------------------
1163 function r2
.activities
:initTimeMenu(timeFunction
, isHours
)
1165 local timeMenu
= getUI("ui:interface:r2ed_triggers_menu")
1168 local timeMenu
= timeMenu
:getRootMenu()
1174 timeMenu
:addLine(ucstring(tostring(i
)), "lua", timeFunction
.. "(" .. tostring(i
) .. ")", tostring(i
))
1177 if isHours
== true then
1178 timeMenu
:addLine(ucstring(tostring(10)), "lua", timeFunction
.. "(" .. tostring(10) .. ")", tostring(10))
1183 local lineStr
= tostring(i
).."/"..tostring(i
+9)
1184 timeMenu
:addLine(ucstring(lineStr
), "", "", tostring(i
))
1187 timeMenu
:addSubMenu(lineNb
)
1188 local subMenu
= timeMenu
:getSubMenu(lineNb
)
1191 lineStr
= tostring(i
+s
)
1192 subMenu
:addLine(ucstring(lineStr
), "lua", timeFunction
.. "(" .. tostring(i
+s
) .. ")", lineStr
)
1197 r2
.logicUI
:openLogicMenu(getUICaller())
1200 ----- SET HOURS/MINUTES/SECONDS -----------------------------------------------------------------
1201 function r2
.activities
:activityForHours(hourNb
)
1203 local activityInst
= self
:currentEltInst()
1204 assert(activityInst
)
1206 local lastHourNb
, minNb
, secNb
= r2
.logicComponents
:calculHourMinSec(tonumber(activityInst
.TimeLimitValue
))
1208 self
:setLimitTimeValue(hourNb
, minNb
, secNb
)
1211 function r2
.activities
:activityForMinutes(minNb
)
1213 local activityInst
= self
:currentEltInst()
1214 assert(activityInst
)
1216 local hoursNb
, lastMinNb
, secNb
= r2
.logicComponents
:calculHourMinSec(tonumber(activityInst
.TimeLimitValue
))
1218 self
:setLimitTimeValue(hoursNb
, minNb
, secNb
)
1221 function r2
.activities
:activityForSeconds(secNb
)
1223 local activityInst
= self
:currentEltInst()
1224 assert(activityInst
)
1226 local hoursNb
, minNb
, lastSecNb
= r2
.logicComponents
:calculHourMinSec(tonumber(activityInst
.TimeLimitValue
))
1228 self
:setLimitTimeValue(hoursNb
, minNb
, secNb
)
1231 -------- SET LIMIT TIME VALUE -------------------------------------------------------------------
1232 function r2
.activities
:setLimitTimeValue(hourNb
, minNb
, secNb
)
1233 r2
.requestNewAction(i18n
.get("uiR2EDSetActivityTimeLimitValueAction"))
1235 local activityInstId
= self
:currentEltInstId()
1236 assert(activityInstId
)
1238 local totalSec
= tostring(hourNb
*3600 + minNb
*60 + secNb
)
1239 r2
.requestSetNode(activityInstId
, "TimeLimitValue", totalSec
)
1243 ----- UTILS ---------------------------------------------------------
1245 function r2
.activities
:findSequenceUIFromInstance(instance
)
1247 local ui
= getUI(r2
.activities
.uiId
)
1250 local sequenceTabs
= ui
:find("sequence_tabs")
1251 assert(sequenceTabs
)
1253 for i
=0,sequenceTabs
.tabButtonNb
-1 do
1254 local sequenceUI
= sequenceTabs
:getGroup(i
)
1255 if r2
.logicUI
:getSequUIInstId(sequenceUI
) == instance
.InstanceId
then
1256 r2
.activities
:setUpdatedSequUIId(sequenceUI
.id
)
1264 function r2
.activities
:findElementUIInSequenceUI(sequenceUI
, instance
)
1266 local eltsList
= sequenceUI
:find("elements_list")
1269 for i
=0,eltsList
.childrenNb
-1 do
1270 local element
= eltsList
:getChild(i
)
1271 if r2
.logicUI
:getEltUIInstId(element
) == instance
.InstanceId
then
1279 function r2
.activities
:updateUI(active
)
1281 local ui
= getUI(self
.uiId
)
1283 local sepTop
= ui
:find("sep_top")
1285 local sepBottom
= ui
:find("sep_bottom")
1287 local sepLeft
= ui
:find("sep_left")
1289 local sepRight
= ui
:find("sep_right")
1291 local removeSequence
= ui
:find("remove_sequence_button")
1292 assert(removeSequence
)
1293 local editSequence
= ui
:find("edit_sequence")
1294 assert(editSequence
)
1295 local repeatButtonGr
= ui
:find("repeat_group")
1296 assert(repeatButtonGr
)
1298 sepTop
.active
= active
1299 sepBottom
.active
= active
1300 sepLeft
.active
= active
1301 sepRight
.active
= active
1302 removeSequence
.active
= active
1303 editSequence
.active
= active
1304 repeatButtonGr
.active
= active
1313 --------------------------------------------------------------------------------------------------
1314 -------------------------------- ACTIVITY SEQUENCE DisplayerProperties ---------------------------
1315 --------------------------------------------------------------------------------------------------
1316 local activitySequencePropertySheetDisplayerTable
= clone(r2
:propertySheetDisplayer())
1318 ------------------------------------------------
1319 function activitySequencePropertySheetDisplayerTable
:onPostCreate(instance
)
1321 local activeLogicEntity
= r2
:getSelectedInstance()
1322 if activeLogicEntity
and activeLogicEntity
.isGrouped
and (activeLogicEntity
:isGrouped() or activeLogicEntity
:isKindOf("NpcGrpFeature")) then
1323 activeLogicEntity
= r2
:getLeader(activeLogicEntity
)
1326 if activeLogicEntity
~= instance
:getParentOfKind("LogicEntity") then return end
1328 local activeLogicEntityParent
= instance
:getActiveLogicEntityParent()
1330 if activeLogicEntity
==nil or activeLogicEntity
~=activeLogicEntityParent
then
1334 if r2
.activities
.isInitialized
then
1335 r2
.activities
.firstSequence
[activeLogicEntity
.InstanceId
] = nil
1336 r2
.activities
:newSequenceUI(instance
)
1339 r2
.miniActivities
:updateSequenceButtonBar()
1341 ------------------------------------------------
1342 function activitySequencePropertySheetDisplayerTable
:onErase(instance
)
1344 instance
.User
.Deleted
= true
1346 local activeLogicEntity
= r2
:getSelectedInstance()
1347 if activeLogicEntity
and activeLogicEntity
.isGrouped
and (activeLogicEntity
:isGrouped() or activeLogicEntity
:isKindOf("NpcGrpFeature")) then
1348 activeLogicEntity
= r2
:getLeader(activeLogicEntity
)
1351 if activeLogicEntity
~= instance
:getParentOfKind("LogicEntity") then return end
1353 local activeLogicEntityParent
= instance
:getActiveLogicEntityParent()
1355 if activeLogicEntity
==nil or activeLogicEntity
~=activeLogicEntityParent
then
1359 if r2
.activities
.isInitialized
and r2
.activities
:findSequenceUIFromInstance(instance
) then
1360 r2
.activities
:removeSequenceUI(instance
)
1364 if instance
.Parent
.Size
==1 then
1365 r2
.miniActivities
:updateMiniActivityView()
1366 r2
.miniActivities
:updateSequenceButtonBar()
1369 ------------------------------------------------
1370 function activitySequencePropertySheetDisplayerTable
:onPreHrcMove(instance
)
1372 ------------------------------------------------
1373 function activitySequencePropertySheetDisplayerTable
:onPostHrcMove(instance
)
1375 ------------------------------------------------
1376 function activitySequencePropertySheetDisplayerTable
:onFocus(instance
, hasFocus
)
1379 ------------------------------------------------
1380 function activitySequencePropertySheetDisplayerTable
:onSelect(instance
, isSelected
)
1383 ------------------------------------------------
1384 function activitySequencePropertySheetDisplayerTable
:onAttrModified(instance
, attributeName
)
1386 local activeLogicEntity
= r2
:getSelectedInstance()
1387 if activeLogicEntity
and activeLogicEntity
.isGrouped
and (activeLogicEntity
:isGrouped() or activeLogicEntity
:isKindOf("NpcGrpFeature")) then
1388 activeLogicEntity
= r2
:getLeader(activeLogicEntity
)
1391 if activeLogicEntity
~= instance
:getParentOfKind("LogicEntity") then return end
1393 local activeLogicEntityParent
= instance
:getActiveLogicEntityParent()
1395 if activeLogicEntity
==nil or activeLogicEntity
~=activeLogicEntityParent
then
1399 if r2
.activities
.isInitialized
and r2
.activities
:findSequenceUIFromInstance(instance
) then
1400 r2
.activities
:updateSequenceUI(instance
, attributeName
)
1403 if attributeName
=="Name" then
1404 r2
.miniActivities
:updateSequenceButtonBar()
1408 ------------------------------------------------
1409 function r2
:activitySequencePropertySheetDisplayer()
1410 return activitySequencePropertySheetDisplayerTable
-- returned shared displayer to avoid wasting memory
1414 --------------------------------------------------------------------------------------------------
1415 -------------------------------- ACTIVITY STEP DisplayerProperties--------------------------------
1416 --------------------------------------------------------------------------------------------------
1417 local activityStepPropertySheetDisplayerTable
= clone(r2
:propertySheetDisplayer())
1419 ------------------------------------------------
1420 function activityStepPropertySheetDisplayerTable
:onPostCreate(instance
)
1422 local activeLogicEntity
= r2
:getSelectedInstance()
1423 if activeLogicEntity
and activeLogicEntity
.isGrouped
and (activeLogicEntity
:isGrouped() or activeLogicEntity
:isKindOf("NpcGrpFeature")) then
1424 activeLogicEntity
= r2
:getLeader(activeLogicEntity
)
1427 if activeLogicEntity
~= instance
:getParentOfKind("LogicEntity") then return end
1429 local activitySequInst
= instance
.Parent
.Parent
1430 local activeLogicEntityParent
= activitySequInst
:getActiveLogicEntityParent()
1432 if activeLogicEntity
==nil or activeLogicEntity
~=activeLogicEntityParent
then
1436 if r2
.activities
.isInitialized
and r2
.activities
:findSequenceUIFromInstance(activitySequInst
) then
1437 r2
.activities
:newElementUI(instance
)
1440 -- update mini activities view
1441 r2
.miniActivities
:updateMiniActivityView()
1443 ------------------------------------------------
1444 function activityStepPropertySheetDisplayerTable
:onErase(instance
)
1446 instance
.User
.Deleted
= true
1448 local activeLogicEntity
= r2
:getSelectedInstance()
1449 if activeLogicEntity
and activeLogicEntity
.isGrouped
and (activeLogicEntity
:isGrouped() or activeLogicEntity
:isKindOf("NpcGrpFeature")) then
1450 activeLogicEntity
= r2
:getLeader(activeLogicEntity
)
1453 if activeLogicEntity
~= instance
:getParentOfKind("LogicEntity") then return end
1455 local activitySequInst
= instance
.Parent
.Parent
1456 local activeLogicEntityParent
= activitySequInst
:getActiveLogicEntityParent()
1458 if activeLogicEntity
==nil or activeLogicEntity
~=activeLogicEntityParent
then
1462 local sequenceUI
= r2
.activities
:findSequenceUIFromInstance(activitySequInst
)
1463 if r2
.activities
.isInitialized
and sequenceUI
then
1464 local eltUI
= r2
.activities
:findElementUIInSequenceUI(sequenceUI
, instance
)
1466 r2
.activities
:removeElementUI(eltUI
)
1470 r2
.miniActivities
:updateMiniActivityView()
1472 ------------------------------------------------
1473 function activityStepPropertySheetDisplayerTable
:onPreHrcMove(instance
)
1475 ------------------------------------------------
1476 function activityStepPropertySheetDisplayerTable
:onPostHrcMove(instance
)
1478 local activeLogicEntity
= r2
:getSelectedInstance()
1479 if activeLogicEntity
and activeLogicEntity
.isGrouped
and (activeLogicEntity
:isGrouped() or activeLogicEntity
:isKindOf("NpcGrpFeature")) then
1480 activeLogicEntity
= r2
:getLeader(activeLogicEntity
)
1483 if activeLogicEntity
~= instance
:getParentOfKind("LogicEntity") then return end
1485 local activitySequInst
= instance
.Parent
.Parent
1486 local activeLogicEntityParent
= activitySequInst
:getActiveLogicEntityParent()
1488 if activeLogicEntity
==nil or activeLogicEntity
~=activeLogicEntityParent
then
1492 local sequenceUI
= r2
.activities
:findSequenceUIFromInstance(activitySequInst
)
1493 if r2
.activities
.isInitialized
and sequenceUI
then
1494 local eltUI
= r2
.activities
:findElementUIInSequenceUI(sequenceUI
, instance
)
1495 if eltUI
then r2
.activities
:downUpElementUI(eltUI
, instance
) end
1498 r2
.miniActivities
:updateMiniActivityView()
1500 ------------------------------------------------
1501 function activityStepPropertySheetDisplayerTable
:onFocus(instance
, hasFocus
)
1504 ------------------------------------------------
1505 function activityStepPropertySheetDisplayerTable
:onSelect(instance
, isSelected
)
1508 ------------------------------------------------
1509 function activityStepPropertySheetDisplayerTable
:onAttrModified(instance
, attributeName
)
1511 local activeLogicEntity
= r2
:getSelectedInstance()
1512 if activeLogicEntity
and activeLogicEntity
.isGrouped
and (activeLogicEntity
:isGrouped() or activeLogicEntity
:isKindOf("NpcGrpFeature")) then
1513 activeLogicEntity
= r2
:getLeader(activeLogicEntity
)
1516 if activeLogicEntity
~= instance
:getParentOfKind("LogicEntity") then return end
1518 local activitySequInst
= instance
.Parent
.Parent
1519 local activeLogicEntityParent
= activitySequInst
:getActiveLogicEntityParent()
1521 if activeLogicEntity
==nil or activeLogicEntity
~=activeLogicEntityParent
then
1525 local sequenceUI
= r2
.activities
:findSequenceUIFromInstance(activitySequInst
)
1526 if r2
.activities
.isInitialized
and sequenceUI
then
1527 local eltUI
= r2
.activities
:findElementUIInSequenceUI(sequenceUI
, instance
)
1528 if eltUI
then r2
.activities
:updateElementUI(eltUI
) end
1531 -- update mini activities view
1532 r2
.miniActivities
:updateMiniActivityView()
1535 ------------------------------------------------
1536 function activityStepPropertySheetDisplayerTable
:onTargetInstanceEraseRequested(instance
, refIdName
, refIdIndexInArray
)
1537 if refIdName
== "ActivityZoneId" then
1538 r2
.requestEraseNode(instance
.InstanceId
, "", -1)
1542 ------------------------------------------------
1543 function activityStepPropertySheetDisplayerTable
:onTargetInstanceAttrModified(instance
, refIdName
, refIdIndexInArray
, targetAttrName
, targetAttrIndexInArray
)
1546 -------------------------------------------------
1547 function r2
:activityStepPropertySheetDisplayer()
1548 return activityStepPropertySheetDisplayerTable
-- returned shared displayer to avoid wasting memory