1 r2
.classLogicAttributes
= {}
5 uiId
= "ui:interface:r2ed_events",
6 ownCreatedInstances
= {},
12 selectElt
="r2.events:selectElement()",
15 removeElt
="r2.events:removeElementInst()",
16 colOver
="200 150 0 100",
17 colPushed
="200 150 0 255",
21 elementEditorTemplate
= "template_edit_events",
22 elementInitialName
=i18n
.get("uiR2EdAction"):toUtf8(),
24 currentEltUIID
= nil, -- initialisé quand l'editeur est ouvert ou fermé
27 ["ApplicableActions"] = {},
35 eventTypeWithValue
= {
36 ["end of chat"] = "ChatStep",
37 ["start of chat"] = "ChatStep",
38 ["starts chat"] = "ChatStep",
39 ["is in chat"] = "ChatStep",
41 ["begin of activity step"] = "ActivityStep",
42 ["end of activity step"] = "ActivityStep",
43 ["is in activity step"] = "ActivityStep",
44 ["is in activity sequence"] = "ActivitySequence",
45 ["end of activity sequence"] = "ActivitySequence",
46 ["begin activity sequence"] = "ActivitySequence",
47 ["begin of activity sequence"] = "ActivitySequence",
48 ["emits user event"] = "Number",
49 ["user event emitted"] = "Number",
50 ["add seconds"] = "Number",
51 ["sub seconds"] = "Number",
52 ["add scenario points"] = "Number",
58 filteredLogicEntityId
= nil,
59 dismatchWithFilter
= 0,
61 actionOrConditionUIId
= nil,
63 keyWordsColor
= "@{FFFF}",
64 communWordsColor
= "@{FFFB}",
65 filterWordColor
= "@{FF0F}",
66 entityWordColor
= "@{F90B}",
70 memberManagement
= false,
78 -- sequence --------------------------------------------------
79 function r2
.events
:currentSequUI()
80 return getUI(self
.uiId
):find("sequence_elts")
83 function r2
.events
:currentSequInstId()
84 return self
:currentSequUI().Env
.InstanceId
87 -- initialisé quand selection dialog dans menu
88 function r2
.events
:setSequUIInstId(sequUI
, id
)
89 sequUI
.Env
.InstanceId
= id
92 function r2
.events
:currentSequInst()
93 return r2
:getInstanceFromId(self
:currentSequInstId())
96 -- element ---------------------------------------------------
97 function r2
.events
:currentEltUIId()
98 return self
.currentEltUIID
101 function r2
.events
:currentEltUI()
102 if self
.currentEltUIID
then
103 return getUI(self
.currentEltUIID
)
108 function r2
.events
:setCurrentEltUIId(id
)
109 self
.currentEltUIID
= id
112 function r2
.events
:currentEltInstId()
113 if self
.currentEltUIID
then
114 return self
:currentEltUI().Env
.InstanceId
119 function r2
.events
:currentEltInst()
120 if self
.currentEltUIID
and self
:currentEltInstId() then
121 return r2
:getInstanceFromId(self
:currentEltInstId())
126 -- updated element and/or sequence (not necessary the same as current sequence or element)
127 function r2
.events
:updatedSequUI()
128 return self
:currentSequUI()
131 function r2
.events
:setUpdatedSequUIId(sequUIId
)
134 function r2
.events
:updatedEltUI()
135 return self
:currentEltUI()
138 function r2
.events
:setUpdatedEltUIId(eltUIId
)
143 ------------------ INIT EVENTS EDITOR -------------------------
144 function r2
.events
:initEditor()
145 self
:mergeLogicTranslations()
148 ------------------ TRANSLATION TEXT ---------------------------
149 function r2
.events
:getTranslationText(eventCategory
, eventType
)
150 if self
.logicTranslations
[eventCategory
][eventType
] then
151 return self
.logicTranslations
[eventCategory
][eventType
].text
153 debugInfo(eventType
.. " is not translated")
158 ------------------ TRANSLATION IN MENU ------------------------
159 function r2
.events
:getTranslationMenu(eventCategory
, eventType
)
160 if self
.logicTranslations
[eventCategory
][eventType
] then
161 return ucstring(self
.logicTranslations
[eventCategory
][eventType
].menu
)
163 debugInfo(eventType
.. " is not translated")
164 return ucstring(eventType
)
168 -------------------------------------------------
169 -- Another global map containing all logic attributes per class
170 function r2
.events
:registerClassLogicAttributes(class
, logicTranslations
)
171 if r2
.classLogicAttributes
[class
] then
172 r2
.print("Logic attributes are already registered for class '" ..class
.."'")
176 r2
.classLogicAttributes
[class
] = logicTranslations
179 -------------------------------------------------
180 --Looks for a logic attribute for a given class. If the attribute isn't in the corresponding map, looks
181 -- in the class's baseclass map
182 function r2
.getLogicAttribute(class
, logicCategory
, value
)
183 if not class
or class
== "" then return nil end
185 local logicAttributes
= r2
.classLogicAttributes
[class
]
187 if not logicAttributes
then
189 local baseclass
= r2
.Classes
[class
].BaseClass
190 r2
.print("Attributes not defined for class '"..class
.."' looking in '"..baseclass
.."' for inherited attributes")
192 return r2
.getLogicAttribute(baseclass
, logicCategory
, value
)
197 local attr
= logicAttributes
[logicCategory
][value
]
201 local baseclass
= r2
.Classes
[class
].BaseClass
203 return r2
.getLogicAttribute(baseclass
, logicCategory
, value
)
210 ------------------------------------------------
211 function r2
.events
:mergeLogicTranslations()
213 registerComponentsLogicTranslations
= function(localLogicTranslations
)
214 local k
, v
= next(localLogicTranslations
, nil)
216 local k2
, v2
= next(v
, nil)
219 if not self
.logicTranslations
[k
][k2
] then
220 self
.logicTranslations
[k
][k2
] = v2
224 k
, v
= next(localLogicTranslations
, k
)
228 local k
, v
= next(r2
.Classes
, nil)
230 if v
.getLogicTranslations
then
231 local localLogicTranslations
= v
:getLogicTranslations()
232 if localLogicTranslations
then
233 self
:registerClassLogicAttributes(k
, localLogicTranslations
)
234 --registerComponentsLogicTranslations(localLogicTranslations)
236 debugInfo(colorTag(255,0,0).."No Translation for component "..k
)
239 k
, v
= next(r2
.Classes
, k
)
244 ------ OPEN EDITOR ------------------------------------------
245 function r2
.events
:openEditor()
247 local ui
= getUI(self
.uiId
)
249 if not ui
.active
then
257 if self
.openFirst
== nil then
258 self
.openFirst
= true
267 ------ CLOSE EDITOR ------------------------------------------
268 function r2
.events
:closeEditor()
269 local ui
= getUI(self
.uiId
)
271 r2
.logicUI
:closeEditor(r2
.events
)
274 ------ CLEAN EDITOR ------------------------------------------
275 function r2
.events
:cleanEditor()
277 -- reset current dialog and current chat
278 self
:setCurrentEltUIId(nil)
279 self
:setUpdatedSequUIId(nil)
280 self
:setUpdatedEltUIId(nil)
281 self
.elementsIdCounter
= 0
283 local sequenceUI
= self
:currentSequUI()
285 local eltsList
= sequenceUI
:find("elements_list")
289 local dismatchFilterMenu
= getUI(self
.uiId
):find("filterMenu"):find("dismatch_filter")
290 assert(dismatchFilterMenu
)
291 dismatchFilterMenu
.active
= false
293 self
.dismatchWithFilter
= 0
296 --- UPDATE SEQUENCE UI-------------------------------------------
297 function r2
.events
:updateSequenceUI()
299 local ui
= getUI(self
.uiId
)
302 local filterMenuText
= ui
:find("filterMenu"):find("menu"):find("text")
303 assert(filterMenuText
)
305 local logicEntity
= r2
:getInstanceFromId(self
.filteredLogicEntityId
)
308 filterMenuText
.uc_hardtext
= logicEntity
:getDisplayName()
310 local currentSequ
= self
:currentSequUI()
312 local eltsList
= currentSequ
:find("elements_list")
314 for i
=0, eltsList
.childrenNb
-1 do
315 local elt
= eltsList
:getChild(i
)
318 if r2
.logicUI
:getEltUIInstId(elt
) then
319 self
:updateElementUI(elt
)
325 function r2
.events
:getLogicEntityParent(event
)
327 local logicEntity
= event
.Parent
.Parent
.Parent
329 if logicEntity
:isGrouped() and logicEntity
:isLeader() then
330 logicEntity
= logicEntity
:getParentGroup()
335 function r2
.events
:filterIsLogicEntityParent(event
)
336 return self
.filteredLogicEntityId
==self
:getLogicEntityParent(event
).InstanceId
339 function r2
.events
:getBehavior(logicEntity
)
340 return logicEntity
.Behavior
344 ------ SELECT FILTER EVENTS --------------------------------------
345 function r2
.events
:filterEvents(logicEntityId
)
347 if logicEntityId
==nil then
348 logicEntityId
= r2
:getSelectedInstance().InstanceId
351 local logicEntity
= r2
:getInstanceFromId(logicEntityId
)
354 if not self
.memberManagement
and logicEntity
:isGrouped() then --TEMP
355 logicEntity
= logicEntity
:getParentGroup() --TEMP
356 logicEntityId
= logicEntity
.InstanceId
--TEMP
362 local ui
= getUI(self
.uiId
)
365 -- update filter text
366 local filterMenuText
= ui
:find("filterMenu"):find("menu"):find("text")
367 assert(filterMenuText
)
368 filterMenuText
.uc_hardtext
= logicEntity
:getDisplayName()
370 self
.filteredLogicEntityId
= logicEntityId
372 -- recover all events of logic entities in current act
374 local allLogicEntities
= {}
376 for i
=0, r2
.Scenario
.Acts
.Size
-1 do
377 local act
= r2
.Scenario
.Acts
[i
]
378 act
:appendInstancesByType(allLogicEntities
, "LogicEntity")
379 table.insert(allLogicEntities
, act
)
382 table.insert(allLogicEntities
, r2
.Scenario
)
383 for k0
, entity
in pairs(allLogicEntities
) do
385 local behavior
= self
:getBehavior(entity
)
386 if not self
.memberManagement
then -- TEMP
387 behavior
= entity
:getBehavior() -- TEMP
390 for e
=0, behavior
.Actions
.Size
-1 do
391 local event
= behavior
.Actions
[e
]
393 allEvents
[event
.InstanceId
] = event
397 -- recover events which match with filter
398 local eventsType
= {}
399 local eventsAction
= {}
400 local eventsCondition
= {}
402 for k
, event
in pairs(allEvents
) do
404 local isSelected
= false
406 local filterIsLogicEntityParentB
= self
:filterIsLogicEntityParent(event
)
407 if not self
.memberManagement
then -- TEMP
408 filterIsLogicEntityParentB
= (event
:getLogicEntityParent().InstanceId
== logicEntityId
) -- TEMP
412 if filterIsLogicEntityParentB
then
413 table.insert(eventsType
, event
.InstanceId
)
418 if not isSelected
then
420 for a
=0, event
.Actions
.Size
-1 do
421 local action
= event
.Actions
[a
]
424 if tostring(action
.Entity
) == logicEntityId
then
425 table.insert(eventsAction
, event
.InstanceId
)
433 if not isSelected
then
435 for a
=0, event
.Conditions
.Size
-1 do
436 local condition
= event
.Conditions
[a
]
439 if tostring(condition
.Entity
) == logicEntityId
then
440 table.insert(eventsCondition
, event
.InstanceId
)
447 -- create event editor
448 self
:createElementEditor()
450 -- display "events type"
451 for k
, eventId
in pairs(eventsType
) do
452 local event
= r2
:getInstanceFromId(eventId
)
454 self
:newElementUI(event
)
457 -- display "events action"
458 for k
, eventId
in pairs(eventsAction
) do
459 local event
= r2
:getInstanceFromId(eventId
)
461 self
:newElementUI(event
)
464 -- display "events condition"
465 for k
, eventId
in pairs(eventsCondition
) do
466 local event
= r2
:getInstanceFromId(eventId
)
468 self
:newElementUI(event
)
473 debugInfo("UNKNOWN FILTER EVENTS")
475 for k
, eventId
in pairs(allEvents
) do
476 local event
= r2
:getInstanceFromId(eventId
)
478 self
:newElementUI(event
)
482 r2
.logicComponents
:selectSequence(r2
.events
)
485 ------ REFRESH FILTER --------------------------------------------
486 function r2
.events
:refreshEvents()
487 self
:filterEvents(self
.filteredLogicEntityId
)
491 ------ SELECT ELEMENT --------------------------------------------
492 function r2
.events
:selectElement(selectedButtonElt
)
493 r2
.logicComponents
:selectElement(r2
.events
, selectedButtonElt
)
496 ------ CREATE EDITOR -----------------------------------------------
497 function r2
.events
:createElementEditor()
499 r2
.logicComponents
:createElementEditor(r2
.events
)
502 ------ OPEN ELEMENT EDITOR -----------------------------------------------
503 function r2
.events
:updateElementEditor()
505 local instanceEvent
= self
:currentEltInst()
506 if instanceEvent
==nil then return end
508 local ui
= getUI(self
.uiId
)
511 local sequenceUI
= self
:currentSequUI()
514 local eventEditor
= sequenceUI
:find("edit_element")
518 local editorTitleText
= eventEditor
:find("event_name"):find("name")
519 assert(editorTitleText
)
521 local logicEntity
= self
:getLogicEntityParent(instanceEvent
)
522 if not self
.memberManagement
then --TEMP
523 logicEntity
= instanceEvent
:getLogicEntityParent() --TEMP
528 local when
= eventEditor
:find("when")
530 when
.Env
.InstanceId
= logicEntity
.InstanceId
531 local whenMenuText
= when
:find("text")
534 local coloredName
= (logicEntity
.InstanceId
== self
.filteredLogicEntityId
)
537 eventType
= self
.filterWordColor
539 eventType
= self
.communWordsColor
542 local name
= "No name"
543 if logicEntity
.getName
then
544 name
= logicEntity
:getName()
545 elseif logicEntity
.Name
then
546 name
= logicEntity
.Name
548 eventType
= eventType
.. name
.. " "
549 if coloredName
then eventType
= eventType
.. self
.communWordsColor
end
552 local class
= logicEntity
.Class
554 eventType
= eventType
..r2
.getLogicAttribute(class
, "Events", instanceEvent
.Event
.Type
).text
555 if instanceEvent
.Event
.Value
~="" then
556 local instance
= r2
:getInstanceFromId(instanceEvent
.Event
.Value
)
558 eventType
= eventType
.. " '" .. instance
:getShortName() .. "'"
560 if instanceEvent
.Event
.ValueString
and instanceEvent
.Event
.ValueString
~="" then
561 eventType
= eventType
.. " '" .. instanceEvent
.Event
.ValueString
.. "'"
564 local uc_when_text
= ucstring()
565 uc_when_text
:fromUtf8(eventType
)
566 whenMenuText
.uc_hardtext_single_line_format
= uc_when_text
567 editorTitleText
.uc_hardtext
= whenMenuText
.hardtext
.. " ..."
570 local actionsList
= eventEditor
:find("actions_list")
574 if instanceEvent
.Actions
.Size
> 0 then
576 for i
=0, instanceEvent
.Actions
.Size
-1 do
577 local actionInst
= instanceEvent
.Actions
[i
]
579 local actionUI
= self
:newActionUI()
580 actionUI
.Env
.InstanceId
= actionInst
.InstanceId
582 local actionMenuText
= actionUI
:find("text")
583 assert(actionMenuText
)
585 if actionInst
.Entity
~="" and actionInst
.Action
.Type
~="" then
587 local actionLogicEntity
= r2
:getInstanceFromId(tostring(actionInst
.Entity
))
588 assert(actionLogicEntity
)
590 coloredName
= (actionLogicEntity
.InstanceId
== self
.filteredLogicEntityId
)
593 actionType
= self
.filterWordColor
595 actionType
= self
.communWordsColor
597 local name
= "No name"
598 if actionLogicEntity
.getName
then
599 name
= actionLogicEntity
:getName()
600 elseif actionLogicEntity
.Name
then
601 name
= actionLogicEntity
.Name
603 actionType
= actionType
.. name
.. " "
604 if coloredName
then actionType
= actionType
.. self
.communWordsColor
end
606 local class
= actionLogicEntity
.Class
608 actionType
= actionType
..r2
.getLogicAttribute(class
, "ApplicableActions", actionInst
.Action
.Type
).text
609 if actionInst
.Action
.Value
~="" then
610 local instance
= r2
:getInstanceFromId(actionInst
.Action
.Value
)
612 actionType
= actionType
.. " '" .. instance
:getShortName() .. "'"
614 if actionInst
.Action
.ValueString
and actionInst
.Action
.ValueString
~= "" then
615 if string.gfind(actionType
, "%%1")() then
616 actionType
= string.gsub(actionType
, "%%1", "'"..tostring(actionInst
.Action
.ValueString
).."'")
618 actionType
= actionType
.. " '" .. tostring(actionInst
.Action
.ValueString
).. "'"
622 local uc_action_text
= ucstring()
623 uc_action_text
:fromUtf8(actionType
)
624 actionMenuText
.uc_hardtext_single_line_format
= uc_action_text
632 local conditionsList
= eventEditor
:find("conditions_list")
633 assert(conditionsList
)
634 conditionsList
:clear()
636 for i
=0, instanceEvent
.Conditions
.Size
-1 do
637 local conditionInst
= instanceEvent
.Conditions
[i
]
639 local conditionUI
= self
:newConditionUI()
640 conditionUI
.Env
.InstanceId
= conditionInst
.InstanceId
642 local conditionMenuText
= conditionUI
:find("text")
643 assert(conditionMenuText
)
645 if conditionInst
.Entity
~="" and conditionInst
.Condition
.Type
~="" then
647 local conditionLogicEntity
= r2
:getInstanceFromId(tostring(conditionInst
.Entity
))
648 assert(conditionLogicEntity
)
650 coloredName
= (conditionLogicEntity
.InstanceId
== self
.filteredLogicEntityId
)
653 conditionType
= self
.filterWordColor
655 conditionType
= self
.communWordsColor
657 conditionType
= conditionType
.. conditionLogicEntity
.Name
.. " "
658 if coloredName
then conditionType
= conditionType
.. self
.communWordsColor
end
660 local class
= conditionLogicEntity
.Class
662 conditionType
= conditionType
..r2
.getLogicAttribute(class
, "Conditions", conditionInst
.Condition
.Type
).text
663 if conditionInst
.Condition
.Value
~="" then
664 local instance
= r2
:getInstanceFromId(conditionInst
.Condition
.Value
)
666 conditionType
= conditionType
.. " '" .. instance
:getShortName() .."'"
669 local uc_condition_text
= ucstring()
670 uc_condition_text
:fromUtf8(conditionType
)
671 conditionMenuText
.uc_hardtext_single_line_format
= uc_condition_text
675 self
:advancedEditor(((instanceEvent
.Actions
.Size
> 1) or (instanceEvent
.Conditions
.Size
> 0)))
678 local matchFilter
= self
:logicEntityActionMatchFilter(instanceEvent
)
680 local dismatchFilter
= eventEditor
:find("dismatch_filter")
681 assert(dismatchFilter
)
682 dismatchFilter
.active
= not matchFilter
685 self
:updateValiditySymbol(eventEditor
, instanceEvent
)
688 function r2
.events
:updateElementsUI()
690 local sequenceUI
= self
:currentSequUI()
693 local eltsList
= sequenceUI
:find("elements_list")
696 for i
=0,eltsList
.childrenNb
-1 do
697 local elementUI
= eltsList
:getChild(i
)
698 if r2
.logicUI
:getEltUIInstId(elementUI
) then
699 self
:updateElementUI(elementUI
)
704 ----- CLOSE ELEMENT EDITOR ---------------------------------------------
705 function r2
.events
:closeElementEditor()
706 r2
.logicComponents
:closeElementEditor(r2
.events
)
709 ------ NEW ELEMENT INST ------------------------------------------
710 function r2
.events
:newElementInst()
712 r2
.requestNewAction(i18n
.get("uiR2EDNewEventAction"))
715 if self
.filteredLogicEntityId
~=nil then
716 logicEntity
= r2
:getInstanceFromId(self
.filteredLogicEntityId
)
718 logicEntity
= r2
:getSelectedInstance()
722 local logicEvent
= r2
.newComponent("LogicEntityAction")
727 if not self
.memberManagement
or not logicEntity
:isGrouped() then
728 local class
= r2
.Classes
[logicEntity
.Class
]
730 if table.getn(class
.Events
) > 0 then
731 defaultEvent
= class
.Events
[1]
733 debugInfo("Empty events table of lua class : "..logicEntity
.Class
)
737 messageBox(i18n
.get("uiR2EDNoEventCreation"))
741 local eventType
= r2
.newComponent("EventType")
742 eventType
.Type
= defaultEvent
743 logicEvent
.Event
= eventType
745 local behavior
= self
:getBehavior(logicEntity
)
746 if not self
.memberManagement
then --TEMP
747 behavior
= logicEntity
:getBehavior() --TEMP
749 r2
.requestInsertNode(behavior
.InstanceId
, "Actions", -1, "", logicEvent
)
751 self
.ownCreatedInstances
[logicEvent
.InstanceId
] = true
753 r2
.logicComponents
:newElementInst(r2
.events
)
756 -------- get first event in events list of a class -----------------
757 function r2
.events
:hasApplicableActions(logicEntity
)
759 local class
= r2
.Classes
[logicEntity
.Class
]
762 -- local eventsTable = {}
763 -- if categoryEvent=="ApplicableActions" then
764 -- eventsTable = logicEntity:getApplicableActions()
766 -- eventsTable = class[categoryEvent]
768 local actionsTable
= logicEntity
:getApplicableActions()
770 if table.getn(actionsTable
) > 0 then
772 if logicEntity
:isGrouped() then
773 local groupIndependantEvent
774 for k
, eventType
in pairs(actionsTable
) do
775 local menuTitle
= r2
.getLogicAttribute(logicEntity
.Class
, "ApplicableActions", eventType
)
776 if menuTitle
.groupIndependant
==true then
777 groupIndependantEvent
= true
782 if groupIndependantEvent
==nil then
787 debugInfo("Empty 'ApplicableActions' table of lua class : "..logicEntity
.Class
)
794 ------ NEW ELEMENT UI ------------------------------------------
795 function r2
.events
:newElementUI(newInst
)
796 r2
.logicUI
:newElementUI(r2
.events
, newInst
, false)
799 ------ REMOVE ELEMENT INST ----------------------------------------
800 function r2
.events
:removeElementInst()
801 r2
.requestNewAction(i18n
.get("uiR2EDRemoveLogicElementAction"))
802 r2
.logicComponents
:removeElementInst(r2
.events
)
803 r2
.requestEndAction()
806 ------ REMOVE ELEMENT UI -------------------------------------------
807 function r2
.events
:removeElementUI(removedEltUI
)
808 r2
.logicUI
:removeElementUI(r2
.events
, removedEltUI
)
811 ------ UPDATE ELEMENT TITLE -------------------------------------------
812 function r2
.events
:updateElementTitle(eventUI
)
814 r2
.logicComponents
:updateElementTitle(r2
.events
, eventUI
, false)
817 ------ UPDATE ELEMENT UI -------------------------------------------
818 function r2
.events
:updateElementUI(elementUI
)
820 r2
.logicUI
:updateElementUI(r2
.events
, elementUI
)
822 local logicEntityAction
= r2
:getInstanceFromId(r2
.logicUI
:getEltUIInstId(elementUI
))
823 assert(logicEntityAction
)
825 local matchFilter
= self
:logicEntityActionMatchFilter(logicEntityAction
)
827 local dismatchFilter
= elementUI
:find("dismatch_filter")
828 assert(dismatchFilter
)
830 if dismatchFilter
.active
~=not matchFilter
then
832 self
.dismatchWithFilter
= self
.dismatchWithFilter
-1
834 self
.dismatchWithFilter
= self
.dismatchWithFilter
+1
838 local dismatchFilterMenu
= getUI(self
.uiId
):find("filterMenu"):find("dismatch_filter")
839 assert(dismatchFilterMenu
)
840 dismatchFilterMenu
.active
= (self
.dismatchWithFilter
>0)
842 dismatchFilter
.active
= not matchFilter
845 self
:updateValiditySymbol(elementUI
, logicEntityAction
)
848 -------------------------------------------------------------------------------
849 function r2
.events
:updateValiditySymbol(elementUI
, eventInst
)
851 local invalidEvent
= elementUI
:find("invalid_event")
854 local validEvent
= elementUI
:find("valid_event")
857 local logicAct
= eventInst
:getLogicAct()
858 invalidEvent
.active
= (logicAct
==nil)
859 validEvent
.active
= (logicAct
~=nil and logicAct
~=r2
:getCurrentAct())
860 if validEvent
.active
then
861 local uc_other_act
= ucstring()
862 uc_other_act
:fromUtf8(i18n
.get("uiR2EDEventNotInCurrentAct"):toUtf8() .. "'" .. logicAct
.Name
.. "'")
863 validEvent
.tooltip
= uc_other_act
867 function r2
.events
:logicEntityActionMatchFilter(logicEntityAction
)
869 local logicEntity
= self
:getLogicEntityParent(logicEntityAction
)
870 if not self
.memberManagement
then --TEMP
871 logicEntity
= logicEntityAction
:getLogicEntityParent() --TEMP
874 local matchFilter
= (logicEntity
.InstanceId
==self
.filteredLogicEntityId
)
879 for i
=0, logicEntityAction
.Actions
.Size
-1 do
880 local action
= logicEntityAction
.Actions
[i
]
881 if action
.Entity
==self
.filteredLogicEntityId
then
886 for i
=0, logicEntityAction
.Conditions
.Size
-1 do
887 local condition
= logicEntityAction
.Conditions
[i
]
888 if condition
.Entity
==self
.filteredLogicEntityId
then
896 --- INIT FILTER MENU ---------------------------------------------------
897 function r2
.events
:initFilterMenu()
899 -- which entity menu initialization
900 local logicEntityMenu
= getUI("ui:interface:r2ed_triggers_menu")
901 assert(logicEntityMenu
)
903 local logicEntityMenu
= logicEntityMenu
:getRootMenu()
904 assert(logicEntityMenu
)
906 logicEntityMenu
:reset()
909 for k
, class
in pairs(r2
.Classes
) do
910 if class
.initLogicEntitiesMenu
then class
:initLogicEntitiesMenu(logicEntityMenu
) end
912 logicEntityMenu
:setMaxVisibleLine(self
.maxVisibleLine
)
914 -- for each entity classes, list of instances in current act
915 for c
=0,logicEntityMenu
:getNumLine()-1 do
917 logicEntityMenu
:addSubMenu(c
)
918 local subMenu
= logicEntityMenu
:getSubMenu(c
)
920 local entityClass
= tostring(logicEntityMenu
:getLineId(c
))
921 local class
= r2
.Classes
[entityClass
]
923 if class
.initLogicEntitiesInstancesMenu
then
924 class
:initLogicEntitiesInstancesMenu(subMenu
, "r2.events:filterEvents")
926 subMenu
:setMaxVisibleLine(self
.maxVisibleLine
)
929 r2
.logicUI
:openLogicMenu(getUICaller())
932 ------ INIT EVENT TYPE MENU -------------------------------------------
933 function r2
.events
:initEventMenu(categoryEvent
)
937 -- local startTime = nltime.getPreciseLocalTime()
939 self
.actionOrConditionUIId
= getUICaller().parent
.parent
.id
941 -- which entity menu initialization
942 local logicEntityMenu
= getUI("ui:interface:r2ed_triggers_menu")
943 assert(logicEntityMenu
)
945 local logicEntityMenu
= logicEntityMenu
:getRootMenu()
946 assert(logicEntityMenu
)
948 logicEntityMenu
:reset()
950 -- if a logic entity has been already selected, we give a direct access to this one
951 local caller
= getUI(self
.actionOrConditionUIId
)
955 if caller
.Env
.InstanceId
~= nil then
956 if categoryEvent
=="Events" then
957 logicEntity
= r2
:getInstanceFromId(caller
.Env
.InstanceId
)
958 elseif categoryEvent
=="ApplicableActions" or categoryEvent
=="Conditions" then
959 local instance
= r2
:getInstanceFromId(caller
.Env
.InstanceId
)
960 logicEntity
= r2
:getInstanceFromId(instance
.Entity
)
965 --local endTime = nltime.getPreciseLocalTime()
966 --debugInfo(string.format("time for 1 is %f", endTime - startTime))
967 --startTime = nltime.getPreciseLocalTime()
973 local uc_name
= ucstring()
974 uc_name
:fromUtf8(logicEntity
.Name
)
975 logicEntityMenu
:addLine(uc_name
, "lua", "r2.events:setLogicEntity('".. logicEntity
.InstanceId
.."')", logicEntity
.InstanceId
)
976 logicEntityMenu
:addSeparator()
978 logicEntityMenu
:addSubMenu(0)
979 local subMenuEventType
= logicEntityMenu
:getSubMenu(0)
981 logicEntity
:initEventTypeMenu(subMenuEventType
, categoryEvent
)
983 if logicEntity
.initEventValuesMenu
then
984 logicEntity
:initEventValuesMenu(subMenuEventType
, categoryEvent
)
986 subMenuEventType
:setMaxVisibleLine(self
.maxVisibleLine
)
989 --local endTime = nltime.getPreciseLocalTime()
990 --debugInfo(string.format("time for 2 is %f", endTime - startTime))
991 --startTime = nltime.getPreciseLocalTime()
994 for k
, class
in pairs(r2
.Classes
) do
995 if class
.initLogicEntitiesMenu
and table.getn(class
[categoryEvent
])~=0 then
996 class
:initLogicEntitiesMenu(logicEntityMenu
, (categoryEvent
=="ApplicableActions"))
999 logicEntityMenu
:setMaxVisibleLine(self
.maxVisibleLine
)
1001 --local endTime = nltime.getPreciseLocalTime()
1002 --debugInfo(string.format("time for 3 is %f", endTime - startTime))
1003 --startTime = nltime.getPreciseLocalTime()
1005 -- for each entity classes, list of instances in current act
1006 for c
=firstLine
,logicEntityMenu
:getNumLine()-1 do
1008 logicEntityMenu
:addSubMenu(c
)
1009 local subMenu
= logicEntityMenu
:getSubMenu(c
)
1011 local entityClass
= tostring(logicEntityMenu
:getLineId(c
))
1012 local class
= r2
.Classes
[entityClass
]
1014 if class
.initLogicEntitiesInstancesMenu
then
1016 class
:initLogicEntitiesInstancesMenu(subMenu
, "r2.events:setLogicEntity")
1018 --local endTime = nltime.getPreciseLocalTime()
1019 --debugInfo(string.format("time for 6 is %f", endTime - startTime))
1020 --startTime = nltime.getPreciseLocalTime()
1022 -- for each entity, list of its events type
1023 for e
=0,subMenu
:getNumLine()-1 do
1025 local entityId
= tostring(subMenu
:getLineId(e
))
1026 local entity
= r2
:getInstanceFromId(entityId
)
1029 subMenu
:addSubMenu(e
)
1030 local subMenuEventType
= subMenu
:getSubMenu(e
)
1032 entity
:initEventTypeMenu(subMenuEventType
, categoryEvent
)
1034 --local endTime = nltime.getPreciseLocalTime()
1035 --debugInfo(string.format("time for 7 is %f", endTime - startTime))
1036 --startTime = nltime.getPreciseLocalTime()
1038 if entity
.initEventValuesMenu
then
1039 entity
:initEventValuesMenu(subMenuEventType
, categoryEvent
)
1042 --local endTime = nltime.getPreciseLocalTime()
1043 --debugInfo(string.format("time for 9 is %f", endTime - startTime))
1044 --startTime = nltime.getPreciseLocalTime()
1046 subMenuEventType
:setMaxVisibleLine(self
.maxVisibleLine
)
1048 --local endTime = nltime.getPreciseLocalTime()
1049 --debugInfo(string.format("time for 8 is %f", endTime - startTime))
1050 --startTime = nltime.getPreciseLocalTime()
1054 subMenu
:setMaxVisibleLine(self
.maxVisibleLine
)
1057 --local endTime = nltime.getPreciseLocalTime()
1058 --debugInfo(string.format("time for 4 is %f", endTime - startTime))
1059 --startTime = nltime.getPreciseLocalTime()
1061 r2
.logicUI
:openLogicMenu(getUICaller())
1063 --local endTime = nltime.getPreciseLocalTime()
1064 --debugInfo(string.format("time for 5 is %f", endTime - startTime))
1065 --startTime = nltime.getPreciseLocalTime()
1069 ----- SET LOGIC ENTITY (selected in menu ) -------------------------------------------
1070 function r2
.events
:setLogicEntity(entityId
)
1071 self
.selectedLogicEntity
= entityId
1074 ----- SET EVENT TYPE ------------------------------------------------
1075 function r2
.events
:setEventType(eventType
, endRequest
, categoryEvent
)
1077 self
.selectedEventType
= eventType
1079 if endRequest
==tostring(true) then
1080 if categoryEvent
=="Events" then self
:setEvent("")
1081 elseif categoryEvent
=="ApplicableActions" then self
:setAction("")
1082 elseif categoryEvent
=="Conditions" then self
:setCondition("")
1087 ----- SET EVENT VALUE ------------------------------------------------
1088 function r2
.events
:setEventValue(instanceId
, categoryEvent
, optionalValueString
)
1090 if categoryEvent
=="Events" then self
:setEvent(instanceId
, optionalValueString
)
1091 elseif categoryEvent
=="ApplicableActions" then self
:setAction(instanceId
, optionalValueString
)
1092 elseif categoryEvent
=="Conditions" then self
:setCondition(instanceId
, optionalValueString
)
1096 ---- SET EVENT -----------------------------------------------------------------------
1097 function r2
.events
:setEvent(valueInstId
, optionalValueString
)
1099 r2
.requestNewAction(i18n
.get("uiR2EDSetEventAction"))
1101 local eventInst
= self
:currentEltInst()
1104 local oldLogicEntity
= self
:getLogicEntityParent(eventInst
)
1105 if not self
.memberManagement
then
1106 oldLogicEntity
= eventInst
:getLogicEntityParent()
1108 assert(oldLogicEntity
)
1110 local newLogicEntity
= r2
:getInstanceFromId(self
.selectedLogicEntity
)
1111 assert(newLogicEntity
)
1113 if oldLogicEntity
~=newLogicEntity
then
1115 local index
= r2
.logicComponents
:searchElementIndex(eventInst
)
1118 local oldBehavior
= self
:getBehavior(oldLogicEntity
)
1119 local newBehavior
= self
:getBehavior(newLogicEntity
)
1120 if not self
.memberManagement
then --TEMP
1121 oldBehavior
= oldLogicEntity
:getBehavior() --TEMP
1122 newBehavior
= newLogicEntity
:getBehavior() --TEMP
1124 r2
.requestMoveNode(oldBehavior
.InstanceId
, "Actions", index
,
1125 newBehavior
.InstanceId
, "Actions", -1)
1129 r2
.requestSetNode(eventInst
.Event
.InstanceId
, "Type", self
.selectedEventType
)
1131 r2
.requestSetNode(eventInst
.Event
.InstanceId
, "Value", r2
.RefId(valueInstId
))
1132 if optionalValueString
then
1133 r2
.requestSetNode(eventInst
.Event
.InstanceId
, "ValueString", optionalValueString
)
1134 elseif eventInst
.ValueString
and eventInst
.ValueString
~="" then
1135 r2
.requestSetNode(eventInst
.Event
.InstanceId
, "ValueString", optionalValueString
)
1139 self
.selectedLogicEntity
= nil
1140 self
.selectedEventType
= nil
1143 ------ SET ACTION ------------------------------------------------------
1144 function r2
.events
:setAction(valueInstId
, optionalValueString
)
1146 r2
.requestNewAction(i18n
.get("uiR2EDSetEventActionAction"))
1148 local eventInst
= self
:currentEltInst()
1151 local actionLogicEntity
= r2
:getInstanceFromId(self
.selectedLogicEntity
)
1152 assert(actionLogicEntity
)
1154 local caller
= getUI(self
.actionOrConditionUIId
)
1158 if caller
.Env
.InstanceId
== nil then
1159 action
= r2
.newComponent("ActionStep")
1160 r2
.requestInsertNode(eventInst
.InstanceId
, "Actions",-1,"", action
)
1161 caller
.Env
.InstanceId
= action
.InstanceId
1163 action
= r2
:getInstanceFromId(caller
.Env
.InstanceId
)
1167 r2
.requestSetNode(action
.InstanceId
, "Entity", r2
.RefId(self
.selectedLogicEntity
))
1168 r2
.requestSetNode(action
.Action
.InstanceId
, "Type", self
.selectedEventType
)
1169 r2
.requestSetNode(action
.Action
.InstanceId
, "Value", r2
.RefId(valueInstId
))
1170 if optionalValueString
then
1171 r2
.requestSetNode(action
.Action
.InstanceId
, "ValueString", optionalValueString
)
1172 elseif action
.Action
.ValueString
and action
.Action
.ValueString
~= "" then
1173 r2
.requestSetNode(action
.Action
.InstanceId
, "ValueString", "")
1177 self
.selectedLogicEntity
= nil
1178 self
.selectedEventType
= nil
1179 self
.actionOrConditionUIId
= nil
1182 ------ SET CONDITION ------------------------------------------------------
1183 function r2
.events
:setCondition(valueInstId
)
1185 r2
.requestNewAction(i18n
.get("uiR2EDSetEventConditionAction"))
1187 local eventInst
= self
:currentEltInst()
1190 local actionLogicEntity
= r2
:getInstanceFromId(self
.selectedLogicEntity
)
1191 assert(actionLogicEntity
)
1193 local caller
= getUI(self
.actionOrConditionUIId
)
1197 if caller
.Env
.InstanceId
== nil then
1198 condition
= r2
.newComponent("ConditionStep")
1199 r2
.requestInsertNode(eventInst
.InstanceId
, "Conditions",-1,"", condition
)
1200 caller
.Env
.InstanceId
= condition
.InstanceId
1202 condition
= r2
:getInstanceFromId(caller
.Env
.InstanceId
)
1206 r2
.requestSetNode(condition
.InstanceId
, "Entity", r2
.RefId(self
.selectedLogicEntity
))
1207 r2
.requestSetNode(condition
.Condition
.InstanceId
, "Type", self
.selectedEventType
)
1209 r2
.requestSetNode(condition
.Condition
.InstanceId
, "Value", r2
.RefId(valueInstId
))
1211 self
.selectedLogicEntity
= nil
1212 self
.selectedEventType
= nil
1213 self
.actionOrConditionUIId
= nil
1216 ---- EDITOR ELEMENT IN ADVANCED OR EASY MODE
1217 function r2
.events
:advancedEditor(advancedMode
)
1219 local instanceEvent
= self
:currentEltInst()
1220 if instanceEvent
==nil then return end
1222 local sequenceUI
= self
:currentSequUI()
1225 local eventEditor
= sequenceUI
:find("edit_element")
1228 local addActionButton
= eventEditor
:find("what_happens"):find("add")
1229 assert(addActionButton
)
1230 addActionButton
.active
= advancedMode
1232 local conditionsGr
= eventEditor
:find("conditions")
1233 assert(conditionsGr
)
1234 conditionsGr
.active
= advancedMode
1236 local addConditionButton
= conditionsGr
:find("add")
1237 assert(addConditionButton
)
1238 addConditionButton
.active
= advancedMode
1240 local advancedButton
= eventEditor
:find("advanced")
1241 advancedButton
.active
= not advancedMode
1243 local conditionsList
= eventEditor
:find("conditions_gr")
1244 assert(conditionsList
)
1245 conditionsList
.active
= (instanceEvent
.Conditions
.Size
> 0)
1248 -- NEW ACTION -------------------------------------------------
1249 function r2
.events
:newActionUI()
1251 local sequenceUI
= self
:currentSequUI()
1254 local eventEditor
= sequenceUI
:find("edit_element")
1257 local actionsList
= eventEditor
:find("actions_list")
1260 local idActionUI
= "action" .. actionsList
.childrenNb
1263 id
=idActionUI
, x
="0", y
="0", sizeref
="w",
1264 posparent
="", posref
="TL TL", w
="0", h
="20",
1265 params_l
="r2.events:initEventMenu('ApplicableActions')",
1266 remove_menu
="r2.events:removeActionInst()", params_over
="r2.events:activeTrashButton('true')",
1270 local newActionUI
= createGroupInstance("menu_trash_template", actionsList
.id
, params
)
1272 actionsList
:addChild(newActionUI
)
1273 actionsList
.parent
:updateCoords()
1275 newActionUI
.Env
.InstanceId
= nil
1280 -- NEW CONDITION -------------------------------------------------
1281 function r2
.events
:newConditionUI()
1283 local sequenceUI
= self
:currentSequUI()
1286 local eventEditor
= sequenceUI
:find("edit_element")
1289 local conditionsGr
= eventEditor
:find("conditions_gr")
1290 assert(conditionsGr
)
1291 conditionsGr
.active
= true
1293 local conditionsList
= eventEditor
:find("conditions_list")
1294 assert(conditionsList
)
1296 local idConditionUI
= "condition" .. conditionsList
.childrenNb
1299 id
=idConditionUI
, x
="0", y
="0", sizeref
="w",
1300 posparent
="", posref
="TL TL", w
="0", h
="20",
1301 params_l
="r2.events:initEventMenu('Conditions')",
1302 remove_menu
="r2.events:removeConditionInst()", params_over
="r2.events:activeTrashButton('false')",
1306 local newConditionUI
= createGroupInstance("menu_trash_template", conditionsList
.id
, params
)
1307 assert(newConditionUI
)
1308 conditionsList
:addChild(newConditionUI
)
1309 conditionsList
.parent
:updateCoords()
1311 newConditionUI
.Env
.InstanceId
= nil
1313 return newConditionUI
1317 --- ACTIVE TRASH BUTTON ----------------------------------------------------------
1318 function r2
.events
:activeTrashButton(actionsList
)
1320 local overMenuTrash
= getUICaller().parent
.parent
1321 assert(overMenuTrash
)
1323 local trashButtonCaller
= overMenuTrash
:find("remove_menu")
1324 assert(trashButtonCaller
)
1326 local menuTrashList
= overMenuTrash
.parent
1327 assert(menuTrashList
)
1329 if actionsList
==tostring(true) and menuTrashList
.childrenNb
==1 then return end
1331 for i
=0, menuTrashList
.childrenNb
-1 do
1332 local menuTrash
= menuTrashList
:getChild(i
)
1335 local trashButton
= menuTrash
:find("remove_menu")
1338 if trashButton
.active
then
1339 if trashButton
.id
== trashButtonCaller
.id
then return end
1340 trashButton
.active
= false
1345 trashButtonCaller
.active
= true
1349 --- REMOVE CONDITION INSTANCE -----------------------------------------------------
1350 function r2
.events
:removeConditionInst()
1352 r2
.requestNewAction(i18n
.get("uiR2EDRemoveEventConditionAction"))
1354 local menuTrash
= getUICaller().parent
.parent
.parent
.parent
1357 local menuTrashList
= menuTrash
.parent
1358 assert(menuTrashList
)
1360 if menuTrash
.Env
.InstanceId
~=nil then
1361 r2
.requestEraseNode(menuTrash
.Env
.InstanceId
, "", -1)
1363 menuTrashList
:delChild(menuTrash
)
1367 --- REMOVE ACTION INSTANCE -----------------------------------------------------
1368 function r2
.events
:removeActionInst()
1370 r2
.requestNewAction(i18n
.get("uiR2EDRemoveEventActionAction"))
1372 local menuTrash
= getUICaller().parent
.parent
.parent
.parent
1375 local menuTrashList
= menuTrash
.parent
1376 assert(menuTrashList
)
1378 if menuTrash
.Env
.InstanceId
~=nil then
1379 r2
.requestEraseNode(menuTrash
.Env
.InstanceId
, "", -1)
1381 menuTrashList
:delChild(menuTrash
)
1392 --------------------------------------------------------------------------------------------------
1393 -------------------------------- LOGIC ENTITY DisplayerProperties -------------------------
1394 --------------------------------------------------------------------------------------------------
1395 local logicEntityPropertySheetDisplayerTable
= clone(r2
:propertySheetDisplayer())
1397 ------------------------------------------------
1398 function logicEntityPropertySheetDisplayerTable
:onPostCreate(instance
)
1400 ------------------------------------------------
1401 function logicEntityPropertySheetDisplayerTable
:onErase(instance
)
1403 local elementUI
= r2
.logicUI
:findElementUIFromInstance(r2
.events
, instance
)
1406 r2
.events
:removeElementUI(elementUI
)
1409 ------------------------------------------------
1410 function logicEntityPropertySheetDisplayerTable
:onPreHrcMove(instance
)
1412 ------------------------------------------------
1413 function logicEntityPropertySheetDisplayerTable
:onPostHrcMove(instance
)
1415 ------------------------------------------------
1416 function logicEntityPropertySheetDisplayerTable
:onFocus(instance
, hasFocus
)
1419 ------------------------------------------------
1420 function logicEntityPropertySheetDisplayerTable
:onSelect(instance
, isSelected
)
1422 if not isSelected
then
1423 r2
.events
:closeEditor()
1427 ------------------------------------------------
1428 local oldOnAttrModified
= logicEntityPropertySheetDisplayerTable
.onAttrModified
1429 function logicEntityPropertySheetDisplayerTable
:onAttrModified(instance
, attributeName
)
1431 if attributeName
== "Name" then
1432 local elementUI
= r2
.logicUI
:findElementUIFromInstance(r2
.events
, instance
)
1435 r2
.events
:updateElementUI(elementUI
)
1438 oldOnAttrModified(self
, instance
, attributeName
)
1441 ------------------------------------------------
1442 function r2
:logicEntityPropertySheetDisplayer()
1443 return logicEntityPropertySheetDisplayerTable
-- returned shared displayer to avoid wasting memory
1448 --------------------------------------------------------------------------------------------------
1449 -------------------------------- LOGIC ENTITY ACTION DisplayerProperties -------------------------
1450 --------------------------------------------------------------------------------------------------
1451 local logicEntityActionPropertySheetDisplayerTable
= clone(r2
:propertySheetDisplayer())
1453 ------------------------------------------------
1454 function logicEntityActionPropertySheetDisplayerTable
:onPostCreate(instance
)
1456 local filterIsLogicEntityParentB
= r2
.events
:filterIsLogicEntityParent(instance
)
1457 if not r2
.events
.memberManagement
then
1458 filterIsLogicEntityParentB
= (instance
:getLogicEntityParent().InstanceId
==r2
.events
.filteredLogicEntityId
)
1460 if filterIsLogicEntityParentB
then
1461 r2
.events
:newElementUI(instance
)
1464 ------------------------------------------------
1465 function logicEntityActionPropertySheetDisplayerTable
:onErase(instance
)
1467 instance
.User
.Deleted
= true
1469 local elementUI
= r2
.logicUI
:findElementUIFromInstance(r2
.events
, instance
)
1472 r2
.events
:removeElementUI(elementUI
)
1475 ------------------------------------------------
1476 function logicEntityActionPropertySheetDisplayerTable
:onPreHrcMove(instance
)
1479 ------------------------------------------------
1480 function logicEntityActionPropertySheetDisplayerTable
:onPostHrcMove(instance
)
1482 local elementUI
= r2
.logicUI
:findElementUIFromInstance(r2
.events
, instance
)
1484 local filterIsLogicEntityParentB
= r2
.events
:filterIsLogicEntityParent(instance
)
1485 if not r2
.events
.memberManagement
then
1486 filterIsLogicEntityParentB
= (instance
:getLogicEntityParent().InstanceId
==r2
.events
.filteredLogicEntityId
)
1490 r2
.events
:updateElementUI(elementUI
)
1491 elseif filterIsLogicEntityParentB
then
1492 r2
.events
:newElementUI(instance
)
1495 ------------------------------------------------
1496 function logicEntityActionPropertySheetDisplayerTable
:onFocus(instance
, hasFocus
)
1499 ------------------------------------------------
1500 function logicEntityActionPropertySheetDisplayerTable
:onSelect(instance
, isSelected
)
1503 ------------------------------------------------
1504 function logicEntityActionPropertySheetDisplayerTable
:onAttrModified(instance
, attributeName
)
1506 local elementUI
= r2
.logicUI
:findElementUIFromInstance(r2
.events
, instance
)
1509 r2
.events
:updateElementUI(elementUI
)
1513 ------------------------------------------------
1514 function r2
:logicEntityActionPropertySheetDisplayer()
1515 return logicEntityActionPropertySheetDisplayerTable
-- returned shared displayer to avoid wasting memory
1519 --------------------------------------------------------------------------------------------------
1520 -------------------------------- EVENT TYPE DisplayerProperties -----------------------
1521 --------------------------------------------------------------------------------------------------
1522 local eventTypePropertySheetDisplayerTable
= clone(r2
:propertySheetDisplayer())
1524 ------------------------------------------------
1525 function eventTypePropertySheetDisplayerTable
:onPostCreate(instance
)
1527 ------------------------------------------------
1528 function eventTypePropertySheetDisplayerTable
:onErase(instance
)
1530 ------------------------------------------------
1531 function eventTypePropertySheetDisplayerTable
:onPreHrcMove(instance
)
1533 ------------------------------------------------
1534 function eventTypePropertySheetDisplayerTable
:onPostHrcMove(instance
)
1536 ------------------------------------------------
1537 function eventTypePropertySheetDisplayerTable
:onFocus(instance
, hasFocus
)
1540 ------------------------------------------------
1541 function eventTypePropertySheetDisplayerTable
:onSelect(instance
, isSelected
)
1544 ------------------------------------------------
1545 function eventTypePropertySheetDisplayerTable
:onAttrModified(instance
, attributeName
)
1548 ------------------------------------------------
1549 function eventTypePropertySheetDisplayerTable
:onTargetInstanceEraseRequested(instance
, refIdName
, refIdIndexInArray
)
1550 r2
.requestEraseNode(instance
.Parent
.InstanceId
, "", -1)
1552 ------------------------------------------------
1553 function eventTypePropertySheetDisplayerTable
:onTargetInstanceAttrModified(instance
, refIdName
, refIdIndexInArray
, targetAttrName
, targetAttrIndexInArray
)
1554 if targetAttrName
== "Name" then
1556 local eventInst
= instance
.Parent
1557 assert(eventInst
.Class
=="LogicEntityAction")
1558 local elementUI
= r2
.logicUI
:findElementUIFromInstance(r2
.events
, eventInst
)
1561 r2
.events
:updateElementUI(elementUI
)
1566 ------------------------------------------------
1567 function r2
:eventTypePropertySheetDisplayer()
1568 return eventTypePropertySheetDisplayerTable
-- returned shared displayer to avoid wasting memory
1573 --------------------------------------------------------------------------------------------------
1574 -------------------------------- ACTION STEP DisplayerProperties -----------------------
1575 --------------------------------------------------------------------------------------------------
1576 local actionStepPropertySheetDisplayerTable
= clone(r2
:propertySheetDisplayer())
1578 ------------------------------------------------
1579 function actionStepPropertySheetDisplayerTable
:onPostCreate(instance
)
1581 ------------------------------------------------
1582 function actionStepPropertySheetDisplayerTable
:onErase(instance
)
1584 ------------------------------------------------
1585 function actionStepPropertySheetDisplayerTable
:onPreHrcMove(instance
)
1587 ------------------------------------------------
1588 function actionStepPropertySheetDisplayerTable
:onPostHrcMove(instance
)
1590 ------------------------------------------------
1591 function actionStepPropertySheetDisplayerTable
:onFocus(instance
, hasFocus
)
1594 ------------------------------------------------
1595 function actionStepPropertySheetDisplayerTable
:onSelect(instance
, isSelected
)
1598 ------------------------------------------------
1599 function actionStepPropertySheetDisplayerTable
:onAttrModified(instance
, attributeName
)
1602 ------------------------------------------------
1603 function actionStepPropertySheetDisplayerTable
:onTargetInstanceEraseRequested(instance
, refIdName
, refIdIndexInArray
)
1605 if refIdName
== "Entity" then
1606 r2
.requestEraseNode(instance
.InstanceId
, "", -1)
1609 ------------------------------------------------
1610 function actionStepPropertySheetDisplayerTable
:onTargetInstanceAttrModified(instance
, refIdName
, refIdIndexInArray
, targetAttrName
, targetAttrIndexInArray
)
1611 if targetAttrName
== "Name" then
1613 local eventInst
= instance
.Parent
.Parent
1614 assert(eventInst
.Class
=="LogicEntityAction")
1615 local elementUI
= r2
.logicUI
:findElementUIFromInstance(r2
.events
, eventInst
)
1618 r2
.events
:updateElementUI(elementUI
)
1623 ------------------------------------------------
1624 function actionStepPropertySheetDisplayerTable
:onTargetInstancePostHrcMove(instance
, refIdName
, refIdIndexInArray
)
1626 if refIdName
=="Entity" then
1627 r2
.requestSetNode(instance
.InstanceId
, "Entity", r2
.RefId(""))
1628 r2
.requestSetNode(instance
.Action
.InstanceId
, "Type", "")
1629 r2
.requestSetNode(instance
.Action
.InstanceId
, "Value", r2
.RefId(""))
1634 ------------------------------------------------
1635 function r2
:actionStepPropertySheetDisplayer()
1636 return actionStepPropertySheetDisplayerTable
-- returned shared displayer to avoid wasting memory
1641 --------------------------------------------------------------------------------------------------
1642 -------------------------------- ACTION TYPE DisplayerProperties -----------------------
1643 --------------------------------------------------------------------------------------------------
1644 local actionTypePropertySheetDisplayerTable
= clone(r2
:propertySheetDisplayer())
1646 ------------------------------------------------
1647 function actionTypePropertySheetDisplayerTable
:onPostCreate(instance
)
1649 ------------------------------------------------
1650 function actionTypePropertySheetDisplayerTable
:onErase(instance
)
1652 ------------------------------------------------
1653 function actionTypePropertySheetDisplayerTable
:onPreHrcMove(instance
)
1655 ------------------------------------------------
1656 function actionTypePropertySheetDisplayerTable
:onPostHrcMove(instance
)
1658 ------------------------------------------------
1659 function actionTypePropertySheetDisplayerTable
:onFocus(instance
, hasFocus
)
1662 ------------------------------------------------
1663 function actionTypePropertySheetDisplayerTable
:onSelect(instance
, isSelected
)
1666 ------------------------------------------------
1667 function actionTypePropertySheetDisplayerTable
:onAttrModified(instance
, attributeName
)
1670 ------------------------------------------------
1671 function actionTypePropertySheetDisplayerTable
:onTargetInstanceEraseRequested(instance
, refIdName
, refIdIndexInArray
)
1672 r2
.requestSetNode(instance
.InstanceId
, "Type", "")
1673 r2
.requestSetNode(instance
.InstanceId
, "Value", r2
.RefId(""))
1675 ------------------------------------------------
1676 function actionTypePropertySheetDisplayerTable
:onTargetInstanceAttrModified(instance
, refIdName
, refIdIndexInArray
, targetAttrName
, targetAttrIndexInArray
)
1677 if targetAttrName
== "Name" then
1679 local eventInst
= instance
.Parent
.Parent
.Parent
1680 assert(eventInst
.Class
=="LogicEntityAction")
1681 local elementUI
= r2
.logicUI
:findElementUIFromInstance(r2
.events
, eventInst
)
1684 r2
.events
:updateElementUI(elementUI
)
1689 ------------------------------------------------
1690 function r2
:actionTypePropertySheetDisplayer()
1691 return actionTypePropertySheetDisplayerTable
-- returned shared displayer to avoid wasting memory
1696 --------------------------------------------------------------------------------------------------
1697 -------------------------------- CONDITION STEP DisplayerProperties -----------------------
1698 --------------------------------------------------------------------------------------------------
1699 local conditionStepPropertySheetDisplayerTable
= clone(r2
:propertySheetDisplayer())
1701 ------------------------------------------------
1702 function conditionStepPropertySheetDisplayerTable
:onPostCreate(instance
)
1704 ------------------------------------------------
1705 function conditionStepPropertySheetDisplayerTable
:onErase(instance
)
1707 ------------------------------------------------
1708 function conditionStepPropertySheetDisplayerTable
:onPreHrcMove(instance
)
1710 ------------------------------------------------
1711 function conditionStepPropertySheetDisplayerTable
:onPostHrcMove(instance
)
1713 ------------------------------------------------
1714 function conditionStepPropertySheetDisplayerTable
:onFocus(instance
, hasFocus
)
1717 ------------------------------------------------
1718 function conditionStepPropertySheetDisplayerTable
:onSelect(instance
, isSelected
)
1721 ------------------------------------------------
1722 function conditionStepPropertySheetDisplayerTable
:onAttrModified(instance
, attributeName
)
1725 ------------------------------------------------
1726 function conditionStepPropertySheetDisplayerTable
:onTargetInstanceEraseRequested(instance
, refIdName
, refIdIndexInArray
)
1728 if refIdName
== "Entity" then
1729 r2
.requestEraseNode(instance
.InstanceId
, "", -1)
1732 ------------------------------------------------
1733 function conditionStepPropertySheetDisplayerTable
:onTargetInstanceAttrModified(instance
, refIdName
, refIdIndexInArray
, targetAttrName
, targetAttrIndexInArray
)
1734 if targetAttrName
== "Name" then
1736 local eventInst
= instance
.Parent
.Parent
1737 assert(eventInst
.Class
=="LogicEntityAction")
1738 local elementUI
= r2
.logicUI
:findElementUIFromInstance(r2
.events
, eventInst
)
1741 r2
.events
:updateElementUI(elementUI
)
1746 ------------------------------------------------
1747 function r2
:conditionStepPropertySheetDisplayer()
1748 return conditionStepPropertySheetDisplayerTable
-- returned shared displayer to avoid wasting memory
1754 --------------------------------------------------------------------------------------------------
1755 -------------------------------- CONDITION TYPE DisplayerProperties -----------------------
1756 --------------------------------------------------------------------------------------------------
1757 local conditionTypePropertySheetDisplayerTable
= clone(r2
:propertySheetDisplayer())
1759 ------------------------------------------------
1760 function conditionTypePropertySheetDisplayerTable
:onPostCreate(instance
)
1762 ------------------------------------------------
1763 function conditionTypePropertySheetDisplayerTable
:onErase(instance
)
1765 ------------------------------------------------
1766 function conditionTypePropertySheetDisplayerTable
:onPreHrcMove(instance
)
1768 ------------------------------------------------
1769 function conditionTypePropertySheetDisplayerTable
:onPostHrcMove(instance
)
1771 ------------------------------------------------
1772 function conditionTypePropertySheetDisplayerTable
:onFocus(instance
, hasFocus
)
1775 ------------------------------------------------
1776 function conditionTypePropertySheetDisplayerTable
:onSelect(instance
, isSelected
)
1779 ------------------------------------------------
1780 function conditionTypePropertySheetDisplayerTable
:onAttrModified(instance
, attributeName
)
1783 ------------------------------------------------
1784 function conditionTypePropertySheetDisplayerTable
:onTargetInstanceEraseRequested(instance
, refIdName
, refIdIndexInArray
)
1785 r2
.requestSetNode(instance
.InstanceId
, "Type", "")
1786 r2
.requestSetNode(instance
.InstanceId
, "Value", r2
.RefId(""))
1788 ------------------------------------------------
1789 function conditionTypePropertySheetDisplayerTable
:onTargetInstanceAttrModified(instance
, refIdName
, refIdIndexInArray
, targetAttrName
, targetAttrIndexInArray
)
1790 if targetAttrName
== "Name" then
1792 local eventInst
= instance
.Parent
.Parent
.Parent
1793 assert(eventInst
.Class
=="LogicEntityAction")
1794 local elementUI
= r2
.logicUI
:findElementUIFromInstance(r2
.events
, eventInst
)
1797 r2
.events
:updateElementUI(elementUI
)
1802 ------------------------------------------------
1803 function r2
:conditionTypePropertySheetDisplayer()
1804 return conditionTypePropertySheetDisplayerTable
-- returned shared displayer to avoid wasting memory