1 -- In Transalation file
2 -- Category : uiR2EdTimer --
3 -- CreationFrom : uiR2EdTimerParameters
4 -- uiR2EDtooltipCreateFeatureTimer -> tooltip
6 r2
.Features
.TimerFeature
= {}
8 local feature
= r2
.Features
.TimerFeature
10 feature
.Name
="TimerFeature"
12 feature
.BanditCount
= 0
14 feature
.Description
="A Timer"
16 feature
.Components
= {}
19 feature
.Components
.Timer
=
21 PropertySheetHeader
= r2
.getDisplayButtonHeader("r2.events:openEditor()", "uiR2EdEditEventsButton"),
22 BaseClass
="LogicEntity",
25 Menu
="ui:interface:r2ed_feature_menu",
27 DisplayerUI
= "R2::CDisplayerLua",
28 DisplayerUIParams
= "defaultUIDisplayer",
29 DisplayerVisual
= "R2::CDisplayerVisualEntity",
30 -----------------------------------------------------------------------------------------------
33 "Activate", "Deactivate", "Pause", "Resume", "Trigger",
34 "add seconds", "sub seconds",
35 -- "Add 10 Seconds", "Add 1 minute", "Sub 10 seconds", "Sub 1 minute"
39 "On Activation", "On Desactivation",
40 "On Pause", "On Resume"
43 "is active", "is inactive", "is paused",
44 "is running", "is finished"
49 -----------------------------------------------------------------------------------------------
50 -- Category="uiR2EDRollout_Timer",
53 {Name
="InstanceId", Type
="String", WidgetStyle
="StaticText", Visible
= false},
54 {Name
="Name", Type
="String", MaxNumChar
="32"},
55 {Name
="Components", Type
="Table"},
56 {Name
="Minutes", Type
="Number", Min
="0", Max
="120", DefaultValue
="0"},
57 {Name
="Secondes",Type
="Number", Min
="0", Max
="999", DefaultValue
="30"},
58 {Name
="Cyclic", Type
="Number", WidgetStyle
="Boolean", Min
="0", Max
="1", DefaultValue
="0"},
59 {Name
="Active", Type
="Number", WidgetStyle
="Boolean", DefaultValue
="1"},
61 -----------------------------------------------------------------------------------------------
63 getParentTreeNode
= function(this
)
64 return this
:getFeatureParentTreeNode()
66 ---------------------------------------------------------------------------------------------------------
67 getAvailableCommands
= function(this
, dest
)
68 r2
.Classes
.LogicEntity
.getAvailableCommands(this
, dest
) -- fill by ancestor
69 this
:getAvailableDisplayModeCommands(dest
)
71 ---------------------------------------------------------------------------------------------------------
73 appendInstancesByType
= function(this
, destTable
, kind
)
74 assert(type(kind
) == "string")
75 --this:delegate():appendInstancesByType(destTable, kind)
76 r2
.Classes
.LogicEntity
.appendInstancesByType(this
, destTable
, kind
)
77 for k
, component
in specPairs(this
.Components
) do
78 component
:appendInstancesByType(destTable
, kind
)
81 ---------------------------------------------------------------------------------------------------------
83 getSelectBarSons
= function(this
)
86 ---------------------------------------------------------------------------------------------------------
88 canHaveSelectBarSons
= function(this
)
92 onPostCreate
= function(this
)
93 --this:createGhostComponents()
94 if this
.User
.DisplayProp
and this
.User
.DisplayProp
== 1 then
95 r2
:setSelectedInstanceId(this
.InstanceId
)
96 r2
:showProperties(this
)
97 this
.User
.DisplayProp
= nil
101 pretranslate
= function(this
, context
)
102 r2
.Translator
.createAiGroup(this
, context
)
105 translate
= function(this
, context
)
106 r2
.Translator
.translateAiGroup(this
, context
)
109 local time
= this
.Secondes
+ this
.Minutes
* 60
110 --local time = secs + min * 60
111 local rtNpcGrp
= r2
.Translator
.getRtGroup(context
, this
.InstanceId
)
113 if this
.Active
== 1 then
114 local action1
= r2
.Translator
.createAction("timer_set", rtNpcGrp
.Id
, 0, time
)
115 local action2
= r2
.Translator
.createAction("generic_event_trigger", rtNpcGrp
.Id
, 0)
116 local action3
= r2
.Translator
.createAction("set_value", rtNpcGrp
.Id
, "v2", 0)
117 local action4
= r2
.Translator
.createAction("set_value", rtNpcGrp
.Id
, "Active", 1)
118 local action
= r2
.Translator
.createAction("multi_actions", {action1
, action2
, action3
, action4
})
120 r2
.Translator
.translateAiGroupInitialState(this
, context
, action
)
122 local action1
= r2
.Translator
.createAction("set_value", rtNpcGrp
.Id
, "v2", 0)
123 local action2
= r2
.Translator
.createAction("set_value", rtNpcGrp
.Id
, "Active", 0)
124 local action
= r2
.Translator
.createAction("multi_actions", {action1
, action2
})
126 r2
.Translator
.translateAiGroupInitialState(this
, context
, action
)
130 local actionTrigger
= r2
.Translator
.createAction("set_value", rtNpcGrp
.Id
, "v2", 1)
131 r2
.Translator
.translateAiGroupEvent("timer_t0_triggered", this
, context
, actionTrigger
)
134 --TODO: gestion v2 pour trigger
135 if this
.Cyclic
== 1 then
136 local states
= r2
.Translator
.getRtStatesNames(context
, this
.InstanceId
)
137 local eventHandler
= r2
.Translator
.createEvent("timer_t0_triggered", states
, rtNpcGrp
.Id
)
138 local action1
= r2
.Translator
.createAction("timer_set", rtNpcGrp
.Id
, 0, time
)
139 local action2
= r2
.Translator
.createAction("generic_event_trigger", rtNpcGrp
.Id
, 0)
140 local action
= r2
.Translator
.createAction("multi_actions", {action1
, action2
})
141 table.insert(context
.RtAct
.Events
, eventHandler
)
142 -- insert a npc_event_handler_action
143 table.insert(eventHandler
.ActionsId
, action
.Id
)
144 table.insert(context
.RtAct
.Actions
, action
)
146 local states
= r2
.Translator
.getRtStatesNames(context
, this
.InstanceId
)
147 local eventHandler
= r2
.Translator
.createEvent("timer_t0_triggered", states
, rtNpcGrp
.Id
)
148 local actionEmit
= r2
.Translator
.createAction("generic_event_trigger", rtNpcGrp
.Id
, 1)
149 table.insert(context
.RtAct
.Events
, eventHandler
)
150 -- insert a npc_event_handler_action
151 table.insert(eventHandler
.ActionsId
, actionEmit
.Id
)
152 table.insert(context
.RtAct
.Actions
, actionEmit
)
157 -- Specific to the component Timer
158 local component
= feature
.Components
.Timer
161 function component
.getLogicActionActivate(entity
, context
, action
, rtNpcGrp
)
163 local time
= entity
.Secondes
+ entity
.Minutes
* 60
164 local action1
= r2
.Translator
.createAction("timer_set", rtNpcGrp
.Id
, 0, time
)
165 -- local action1 = r2.Translator.createAction("timer_enable", rtNpcGrp.Id, 0)
166 local action2
= r2
.Translator
.createAction("generic_event_trigger", rtNpcGrp
.Id
, 0)
167 local actionIfInactive
= r2
.Translator
.createAction("if_value_equal", rtNpcGrp
.Id
, "Active", 0,
168 r2
.Translator
.createAction("multi_actions", {action1
, action2
}))
170 return actionIfInactive
, actionIfInactive
173 function component
.getLogicActionDeactivate(entity
, context
, action
, rtNpcGrp
)
174 local action2
= r2
.Translator
.createAction("timer_disable", rtNpcGrp
.Id
, 0)
175 local action1
= r2
.Translator
.createAction("generic_event_trigger", rtNpcGrp
.Id
, 1)
176 local retAction
= r2
.Translator
.createAction("multi_actions", {action1
, action2
})
177 local actionIfActive
= r2
.Translator
.createAction("if_value_equal", rtNpcGrp
.Id
, "Active", 1, retAction
)
178 return actionIfActive
, actionIfActive
181 function component
.getLogicActionPause(entity
, context
, action
, rtNpcGrp
)
182 local action1
= r2
.Translator
.createAction("timer_suspend", rtNpcGrp
.Id
, 0)
183 local action2
= r2
.Translator
.createAction("generic_event_trigger", rtNpcGrp
.Id
, 2)
185 local multiAction
= r2
.Translator
.createAction("multi_actions", {action1
, action2
})
187 local actionIsEnable
= r2
.Translator
.createAction("timer_is_enable", rtNpcGrp
.Id
, 0);
188 local actionIf
= r2
.Translator
.createAction("if_value_equal", rtNpcGrp
.Id
, "is_enable", 1, multiAction
)
189 local retAction
= r2
.Translator
.createAction("multi_actions", {actionIsEnable
, actionIf
})
191 return retAction
, retAction
194 function component
.getLogicActionResume(entity
, context
, action
, rtNpcGrp
)
196 local action1
= r2
.Translator
.createAction("timer_resume", rtNpcGrp
.Id
, 0)
197 local action2
= r2
.Translator
.createAction("generic_event_trigger", rtNpcGrp
.Id
, 3)
199 local multiAction
= r2
.Translator
.createAction("multi_actions", {action1
, action2
})
201 local actionIsEnable
= r2
.Translator
.createAction("timer_is_enable", rtNpcGrp
.Id
, 0);
202 local actionIf
= r2
.Translator
.createAction("if_value_equal", rtNpcGrp
.Id
, "is_enable", 1, multiAction
)
203 local retAction
= r2
.Translator
.createAction("multi_actions", {actionIsEnable
, actionIf
})
205 return retAction
, retAction
208 function component
.getLogicActionTrigger(entity
, context
, action
, rtNpcGrp
)
209 local multiAction
= r2
.Translator
.createAction("multi_actions", {
210 r2
.Translator
.createAction("set_value", rtNpcGrp
.Id
, "v2", 1),
211 r2
.Translator
.createAction("timer_trigger", rtNpcGrp
.Id
, 0)})
212 local actionIsEnable
= r2
.Translator
.createAction("timer_is_enable", rtNpcGrp
.Id
, 0);
213 local actionIf
= r2
.Translator
.createAction("if_value_equal", rtNpcGrp
.Id
, "is_enable", 1, multiAction
)
214 local retAction
= r2
.Translator
.createAction("multi_actions", {actionIsEnable
, actionIf
})
216 return retAction
, retAction
219 function component
.getLogicActionAddSeconds(entity
, context
, action
, rtNpcGrp
)
221 if action
.Action
.ValueString
then value
= tonumber(action
.Action
.ValueString
) end
222 local timerAdd
= r2
.Translator
.createAction("timer_add", rtNpcGrp
.Id
, 0, value
)
224 local actionIsEnable
= r2
.Translator
.createAction("timer_is_enable", rtNpcGrp
.Id
, 0);
225 local actionIf
= r2
.Translator
.createAction("if_value_equal", rtNpcGrp
.Id
, "is_enable", 1, timerAdd
)
226 local retAction
= r2
.Translator
.createAction("multi_actions", {actionIsEnable
, actionIf
})
228 return retAction
, retAction
231 function component
.getLogicActionSubSeconds(entity
, context
, action
, rtNpcGrp
)
233 if action
.Action
.ValueString
then value
= tonumber(action
.Action
.ValueString
) end
234 local actionSub
= r2
.Translator
.createAction("timer_sub", rtNpcGrp
.Id
, 0, value
)
236 local actionIsEnable
= r2
.Translator
.createAction("timer_is_enable", rtNpcGrp
.Id
, 0);
237 local actionIf
= r2
.Translator
.createAction("if_value_equal", rtNpcGrp
.Id
, "is_enable", 1, actionSub
)
238 local retAction
= r2
.Translator
.createAction("multi_actions", {actionIsEnable
, actionIf
})
240 return retAction
, retAction
245 component
.getLogicAction
= function(entity
, context
, action
)
247 assert( action
.Class
== "ActionStep")
248 local component
= r2
:getInstanceFromId(action
.Entity
)
250 local rtNpcGrp
= r2
.Translator
.getRtGroup(context
, component
.InstanceId
)
255 ["Activate"] = component
.getLogicActionActivate
,
256 ["Deactivate"] = component
.getLogicActionDeactivate
,
257 ["Pause"] = component
.getLogicActionPause
,
258 ["Resume"] = component
.getLogicActionResume
,
259 ["Trigger"] = component
.getLogicActionTrigger
,
260 ["Add 10 Seconds"] = component
.getLogicActionAdd10Seconds
,
261 ["Add 1 minute"] = component
.getLogicActionAdd1Minute
,
262 ["Sub 10 seconds"] = component
.getLogicActionSub0Seconds
,
263 ["Sub 1 minute"] = component
.getLogicActionSub1Minute
,
264 ["sub seconds"] = component
.getLogicActionSubSeconds
,
265 ["add seconds"] = component
.getLogicActionAddSeconds
,
270 local fun
= funs
[ action
.Action
.Type
]
272 firstAction
, lastAction
= fun(entity
, context
, action
, rtNpcGrp
)
277 return firstAction
, lastAction
282 component
.getLogicCondition
= function(this
, context
, condition
)
284 assert( condition
.Class
== "ConditionStep")
285 local component
= r2
:getInstanceFromId(condition
.Entity
)
287 local rtNpcGrp
= r2
.Translator
.getRtGroup(context
, component
.InstanceId
)
291 if rtNpcGrp
.Id
and rtNpcGrp
.Id
~= "" then
292 prefix
= r2
:getNamespace() .. rtNpcGrp
.Id
.."."
295 if condition
.Condition
.Type
== "is active" then
296 local action1
= r2
.Translator
.createAction("timer_is_enable", rtNpcGrp
.Id
, 0);
297 local action2
= r2
.Translator
.createAction("condition_if", prefix
.."is_enable == 1" );
298 local multiactions
= r2
.Translator
.createAction("multi_actions", {action1
, action2
});
299 return multiactions
, action2
300 elseif condition
.Condition
.Type
== "is inactive" then
301 local action1
= r2
.Translator
.createAction("timer_is_enable", rtNpcGrp
.Id
, 0)
302 local action2
= r2
.Translator
.createAction("condition_if", prefix
.."is_enable == 0")
303 local multiActions
= r2
.Translator
.createAction("multi_actions", {action1
, action2
})
304 return multiActions
, action2
305 elseif condition
.Condition
.Type
== "is paused" then
306 local action1
= r2
.Translator
.createAction("timer_is_enable", rtNpcGrp
.Id
, 0);
307 local action2
= r2
.Translator
.createAction("timer_is_suspended", rtNpcGrp
.Id
, 0);
308 local actionSuspended
= r2
.Translator
.createAction("condition_if", prefix
.."is_suspended == 1");
309 local action3
= r2
.Translator
.createAction("condition_if", prefix
.."is_enable == 1", actionSuspended
);
310 local multiactions
= r2
.Translator
.createAction("multi_actions", {action1
, action2
, action3
});
311 return multiactions
, actionSuspended
312 elseif condition
.Condition
.Type
== "is running" then
313 local action1
= r2
.Translator
.createAction("timer_is_enable", rtNpcGrp
.Id
, 0);
314 local action2
= r2
.Translator
.createAction("timer_is_suspended", rtNpcGrp
.Id
, 0);
315 local actionSuspended
= r2
.Translator
.createAction("condition_if", prefix
.."is_suspended == 0");
316 local action3
= r2
.Translator
.createAction("condition_if", prefix
.."is_enable == 1", actionSuspended
);
317 local multiactions
= r2
.Translator
.createAction("multi_actions", {action1
, action2
, action3
});
318 return multiactions
, actionSuspended
319 elseif condition
.Condition
.Type
== "is finished" then
320 local action1
= r2
.Translator
.createAction("timer_is_enable", rtNpcGrp
.Id
, 0);
321 local action2
= r2
.Translator
.createAction("condition_if", prefix
.."is_enable == 0");
322 local action3
= r2
.Translator
.createAction("condition_if", prefix
.."v2 == 1", action2
);
324 local multiactions
= r2
.Translator
.createAction("multi_actions", {action1
, action3
});
326 return multiactions
, action2
333 component
.getLogicEvent
= function(this
, context
, event
)
334 assert( event
.Class
== "LogicEntityAction")
336 local component
= this
-- r2:getInstanceFromId(event.Entity)
338 local rtNpcGrp
= r2
.Translator
.getRtGroup(context
, component
.InstanceId
)
341 local eventType
= tostring(event
.Event
.Type
)
343 local eventHandler
, lastCondition
= nil, nil
345 if eventType
== "On Trigger" then
346 eventHandler
, firstCondition
, lastCondition
= r2
.Translator
.createEvent("timer_t0_triggered", "", rtNpcGrp
.Id
)
347 --return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
348 elseif eventType
== "On Activation" then
349 return r2
.Translator
.getComponentGenericEvent(rtNpcGrp
, 0)
350 elseif eventType
== "On Desactivation" then
351 return r2
.Translator
.getComponentGenericEvent(rtNpcGrp
, 1)
352 elseif eventType
== "On Pause" then
353 return r2
.Translator
.getComponentGenericEvent(rtNpcGrp
, 2)
354 elseif eventType
== "On Resume" then
355 return r2
.Translator
.getComponentGenericEvent(rtNpcGrp
, 3)
359 return eventHandler
, firstCondition
, lastCondition
362 component
.createComponent
= function(x
, y
, secondes
, minutes
, cyclic
)
364 local comp
= r2
.newComponent("Timer")
367 comp
.Base
= r2
.Translator
.getDebugBase("palette.entities.botobjects.timer")
368 comp
.Name
= r2
:genInstanceName(i18n
.get("uiR2EdNameTimerFeature")):toUtf8()
372 comp
.Position
.z
= r2
:snapZToGround(x
, y
)
373 if minutes
then comp
.Minutes
= minutes
end
374 if secondes
then comp
.Secondes
= secondes
end
375 if cyclic
then comp
.Cyclic
= cyclic
end
381 component
.create
= function()
383 if not r2
:checkAiQuota() then return end
386 local function paramsOk(resultTable
)
390 local x
= tonumber( resultTable
["X"] )
391 local y
= tonumber( resultTable
["Y"] )
392 local minutes
= tonumber( resultTable
["Minutes"] )
393 local secondes
= tonumber( resultTable
["Secondes"] )
394 local cyclic
= tonumber( resultTable
["Cyclic"] )
395 local showAgain
= tonumber(resultTable
["Display"])
399 debugInfo("Can't create Component")
403 local component
= feature
.Components
.Timer
.createComponent( x
, y
, secondes
, minutes
, cyclic
)
404 r2
:setCookie(component
.InstanceId
, "DisplayProp", 1)
405 r2
.requestInsertNode(r2
:getCurrentAct().InstanceId
, "Features", -1, "", component
)
408 local function paramsCancel()
409 debugInfo("Cancel form for 'Timer' creation")
411 local function posOk(x
, y
, z
)
412 debugInfo(string.format("Validate creation of 'Timer' at pos (%d, %d, %d)", x
, y
, z
))
413 if r2
.mustDisplayInfo("Timer") == 1 then
414 r2
.displayFeatureHelp("Timer")
416 r2
.requestNewAction(i18n
.get("uiR2EDNewTimerFeatureAction"))
417 local component
= feature
.Components
.Timer
.createComponent( x
, y
)
418 r2
:setCookie(component
.InstanceId
, "DisplayProp", 1)
419 r2
.requestInsertNode(r2
:getCurrentAct().InstanceId
, "Features", -1, "", component
)
422 local function posCancel()
423 debugInfo("Cancel choice 'Timer' position")
425 local creature
= r2
.Translator
.getDebugCreature("object_component_timer.creature")
426 r2
:choosePos(creature
, posOk
, posCancel
, "createFeatureTimer")
431 function feature
.registerForms()
434 Caption
= "uiR2EdTimerParameters",
435 PropertySheetHeader
=
437 <view type="text" id="t" multi_line="true" sizeref="w" w="-36" x="4" y="-2" posref="TL TL" global_color="true" fontsize="14" shadow="true" hardtext="uiR2EDTimerDescription"/>
442 {Name
="Display", Type
="Number", WidgetStyle
="Boolean", DefaultValue
="0", Translation
="uiR2showMessageAgain", InvertWidget
=true, CaptionWidth
=5 },
443 -- following field are tmp for property sheet building testing
444 -- {Name="Minutes", Type="Number", Category="uiR2EDRollout_Timer", Min="0", Max="59", Default="0"},
445 -- {Name="Secondes", Type="Number", Category="uiR2EDRollout_Timer", Min="0", Max="59", Default="10"},
446 -- {Name="Cyclic", Type="Number", Category="uiR2EDRollout_Timer", WidgetStyle="Boolean", Min="0", Max="1", Default="0"},
447 -- {Name="Active", Type="Number", WidgetStyle="Boolean", Category="uiR2EDRollout_Default", DefaultValue="1"},
454 function component
:getLogicTranslations()
456 local logicTranslations
= {
457 ["ApplicableActions"] = {
458 ["Activate"] = { menu
=i18n
.get( "uiR2AA0Activate" ):toUtf8(),
459 text
=i18n
.get( "uiR2AA1Activate" ):toUtf8()},
460 ["Deactivate"] = { menu
=i18n
.get( "uiR2AA0Deactivate" ):toUtf8(),
461 text
=i18n
.get( "uiR2AA1Deactivate" ):toUtf8()},
462 ["Trigger"] = { menu
=i18n
.get( "uiR2AA0Trigger" ):toUtf8(),
463 text
=i18n
.get( "uiR2AA1Trigger" ):toUtf8()},
464 ["Pause"] = { menu
=i18n
.get( "uiR2AA0TimerPause" ):toUtf8(),
465 text
=i18n
.get( "uiR2AA1TimerPause" ):toUtf8()},
466 ["Resume"] = { menu
=i18n
.get( "uiR2AA0TimerResume" ):toUtf8(),
467 text
=i18n
.get( "uiR2AA1TimerResume" ):toUtf8()},
468 ["Add 10 Seconds"] = { menu
=i18n
.get( "uiR2AA0TimerAdd10s" ):toUtf8(),
469 text
=i18n
.get( "uiR2AA1TimerAdds10s" ):toUtf8()},
470 ["Add 1 minute"] = { menu
=i18n
.get( "uiR2AA0TimerAdd1m" ):toUtf8(),
471 text
=i18n
.get( "uiR2AA1TimerAdds1m" ):toUtf8()},
472 ["Sub 10 seconds"] = { menu
=i18n
.get( "uiR2AA0TimerSub10s" ):toUtf8(),
473 text
=i18n
.get( "uiR2AA1TimerSubs10s" ):toUtf8()},
474 ["Sub 1 minute"] = { menu
=i18n
.get( "uiR2AA0TimerSub1m" ):toUtf8(),
475 text
=i18n
.get( "uiR2AA1TimerSubs1m" ):toUtf8()},
476 ["add seconds"] = { menu
=i18n
.get( "uiR2AA0TimerAddNSeconds" ):toUtf8(),
477 text
=i18n
.get( "uiR2AA1TimerAddNSeconds" ):toUtf8()},
478 ["sub seconds"] = { menu
=i18n
.get( "uiR2AA0TimerSubNSeconds" ):toUtf8(),
479 text
=i18n
.get( "uiR2AA1TimerSubNSeconds" ):toUtf8()},
482 ["On Activation"] = { menu
=i18n
.get( "uiR2Event0Activation" ):toUtf8(),
483 text
=i18n
.get( "uiR2Event1Activation" ):toUtf8()},
484 ["On Desactivation"]= { menu
=i18n
.get( "uiR2Event0Deactivation" ):toUtf8(),
485 text
=i18n
.get( "uiR2Event1Deactivation" ):toUtf8()},
486 ["On Trigger"] = { menu
=i18n
.get( "uiR2Event0Trigger" ):toUtf8(),
487 text
=i18n
.get( "uiR2Event1Trigger" ):toUtf8()},
488 ["On Pause"] = { menu
=i18n
.get( "uiR2Event0TimerPause" ):toUtf8(),
489 text
=i18n
.get( "uiR2Event1TimerPause" ):toUtf8()},
490 ["On Resume"] = { menu
=i18n
.get( "uiR2Event0TimerResume" ):toUtf8(),
491 text
=i18n
.get( "uiR2Event1TimerResume" ):toUtf8()},
494 ["is active"] = { menu
=i18n
.get( "uiR2Test0Active" ):toUtf8(),
495 text
=i18n
.get( "uiR2Test1Active" ):toUtf8()},
496 ["is inactive"] = { menu
=i18n
.get( "uiR2Test0Inactive" ):toUtf8(),
497 text
=i18n
.get( "uiR2Test1Inactive" ):toUtf8()},
498 ["is paused"] = { menu
=i18n
.get( "uiR2Test0TimerPaused" ):toUtf8(),
499 text
=i18n
.get( "uiR2Test1TimerPaused" ):toUtf8()},
500 ["is running"] = { menu
=i18n
.get( "uiR2Test0TimerRunning" ):toUtf8(),
501 text
=i18n
.get( "uiR2Test1TimerRunning" ):toUtf8()},
502 ["is finished"] = { menu
=i18n
.get( "uiR2Test0TimerFinished" ):toUtf8(),
503 text
=i18n
.get( "uiR2Test1TimerFinished" ):toUtf8()},
506 return logicTranslations
509 function component
.initEventValuesMenu(this
, menu
, categoryEvent
)
510 --local startTime = nltime.getPreciseLocalTime()
511 for ev
=0,menu
:getNumLine()-1 do
513 local eventType
= tostring(menu
:getLineId(ev
))
515 --local endTime = nltime.getPreciseLocalTime()
516 --debugInfo(string.format("time for 10 is %f", endTime - startTime))
517 --startTime = nltime.getPreciseLocalTime()
519 if r2
.events
.eventTypeWithValue
[eventType
] == "Number" then
521 local subMenu
= menu
:getSubMenu(ev
)
524 -- local uc_name = ucstring()
525 -- uc_name:fromUtf8( tostring(i) )
526 -- func = "r2.events:setEventValue('','" .. categoryEvent .."','".. tostring(i).."')"
527 -- subMenu:addLine(uc_name, "lua", func, tostring(i))
530 --endTime = nltime.getPreciseLocalTime()
531 --debugInfo(string.format("time for 11 is %f", endTime - startTime))
532 --startTime = nltime.getPreciseLocalTime()
536 local lineStr
= tostring(i
).."/"..tostring(i
+9)
537 subMenu
:addLine(ucstring(lineStr
), "", "", tostring(i
))
539 --endTime = nltime.getPreciseLocalTime()
540 --debugInfo(string.format("time for 12 is %f", endTime - startTime))
541 --startTime = nltime.getPreciseLocalTime()
543 subMenu
:addSubMenu(lineNb
)
544 local subMenu2
= subMenu
:getSubMenu(lineNb
)
546 lineStr
= tostring(i
+s
)
547 local func
= "r2.events:setEventValue('','" .. categoryEvent
.."','".. lineStr
.."')"
548 subMenu2
:addLine(ucstring(lineStr
), "lua", func
, lineStr
)
552 --endTime = nltime.getPreciseLocalTime()
553 --debugInfo(string.format("time for 13 is %f", endTime - startTime))
554 --startTime = nltime.getPreciseLocalTime()
558 local lineStr
= tostring(i
).." m /"..tostring(i
+9).." m"
559 subMenu
:addLine(ucstring(lineStr
), "", "", tostring(i
))
561 subMenu
:addSubMenu(lineNb
)
562 local subMenu2
= subMenu
:getSubMenu(lineNb
)
565 --endTime = nltime.getPreciseLocalTime()
566 --debugInfo(string.format("time for 14 is %f", endTime - startTime))
567 --startTime = nltime.getPreciseLocalTime()
570 lineStr
= tostring( (i
+m
)*60)
571 -- local func = "r2.events:setEventValue('','" .. categoryEvent .."','".. lineStr.."')"
572 subMenu2
:addLine(ucstring(tostring(i
+m
) .. "m"), "", "", lineStr
)
573 subMenu2
:addSubMenu(index
)
574 local subMenu3
= subMenu2
:getSubMenu(index
)
577 lineStr
= tostring( (i
+m
)*60 + s
)
578 local func
= "r2.events:setEventValue('','" .. categoryEvent
.."','".. lineStr
.."')"
579 subMenu3
:addLine(ucstring(tostring(i
+m
) .. "m ".. s
.. "s"), "lua", func
, lineStr
)
584 --endTime = nltime.getPreciseLocalTime()
585 --debugInfo(string.format("time for 15 is %f", endTime - startTime))
586 --startTime = nltime.getPreciseLocalTime()
592 r2
.Features
["TimerFeature"] = feature