5 if ArkLessons
== nil then
8 ArkLessons
.Callbacks
= {}
9 ArkLessons
.Callbacks
["accept"] = {}
10 ArkLessons
.Callbacks
["reward"] = {}
11 ArkLessons
.Callbacks
["step"] = {}
14 if ArkLessons
.CurrentStep
== nil then ArkLessons
.CurrentStep
= {} end
15 if ArkLessons
.UsedWindow
== nil then ArkLessons
.UsedWindow
= {} end
16 if ArkLessons
.RevealStep
== nil then ArkLessons
.RevealStep
= {} end
17 if ArkLessons
.OnDraw
== nil then ArkLessons
.OnDraw
= {} end
19 if ArkLessons
.RevealMoves
== nil then
20 ArkLessons
.RevealMoves
= {}
21 ArkLessons
.RevealTooltips
= {}
24 function ArkLessons
:Callback(event
, id
, args
)
26 if ArkLessons
.Callbacks
and ArkLessons
.Callbacks
[event
] and ArkLessons
.Callbacks
[event
][id
] then
27 ArkLessons
.Callbacks
[event
][id
](args
)
31 game
.ArkLessonUsedWindowUrl
= "https://app.ryzom.com/app_arcc/index.php?action=mLesson_Run&script="
33 webig
.urls_to_check
= {}
36 function ArkOpenLesson(id
, require_rpitem
)
38 if id
~= 0 and id
~= nil then
39 local win
= getUI("ui:interface:web_transaction_lessons")
41 win
:find("html"):browse(game
.ArkLessonUsedWindowUrl
..id
)
43 getUI("ui:interface:web_transactions"):find("html"):browse(game
.ArkLessonUsedWindowUrl
..id
)
48 function ArkRevealLesson(id
, i
, total
)
49 if i
== game
.ArkLessonRevealStep
[id
] then
50 game
.ArkLessonRevealStep
[id
] = game
.ArkLessonRevealStep
[id
] + 1
51 game
:ArkLessonCallback("step", id
, i
)
52 game
:ArkRevealLessonInfos(id
, i
, total
)
54 game
:ArkAcceptLesson()
59 function game
:ArkRevealLessonInfos(id
, i
, total
)
60 local ui
= getUI("ui:interface:ArkLessonWin"..tostring(id
))
62 local html
= ui
:find("html")
63 html
:showDiv("enabled_"..tostring(i
), false)
64 html
:showDiv("disabled_"..tostring(i
), false)
65 html
:showDiv("current_"..tostring(i
), true)
68 html
:showDiv("current_"..tostring(i
-1), false)
69 html
:showDiv("enabled_"..tostring(i
-1), true)
72 if game
.ArkLessonRevealCaps
and game
.ArkLessonRevealCaps
[id
] then
74 setCap(game
.ArkLessonRevealCaps
[id
], "p", math
.floor((100*i
)/total
), tostring(i
).." / "..tostring(total
))
76 setCap(game
.ArkLessonRevealCaps
[id
], "p", 100, "")
83 function ArkLessonUpdateHtml(win
, scriptid
, title
, progression
, started
, finished
, requirement
, reward
)
85 win
= win
:find("div_lesson_"..scriptid
..":html")
87 if requirement
~= [[]] then
88 requirement
= [[<tr><td height="20px" style="font-size: 11px; color: pink">]]..ArkLessons
.NeedRequirement
..[[</td>]]
91 top
= [[<tr><td height="5px"></td></tr>]]
94 local progressionHtml
= "<td><table><tr><td><table style=\'background-color: black;\'><tr><td></td></tr></table></td></tr></table></td>"
97 if requirement
~= "" then
102 pogressionHtml
= "<tr><td height=\'12px\' align=\'left\' >"..progression
.."</td></tr>"
116 <table cellspacing="0" cellpadding="0">
118 <td width="2px"></td>
119 <td width="407px" align="left" valign="top">
120 <table width="407px" cellspacing="0" cellpadding="0">
123 <td height="]]..height
..[[px" valign="top"><strong style="color: #]]..color
..[[">]]..title
..[[</strong></td>
125 ]]..requirement
..pogressionHtml
..[[
128 <td width="6px"></td>
129 <td align="left" valign="top" height="80px" width="46px">]]..reward
..[[</td>
136 function ArkLessons
:Show(id
, w
, h
, content
, scriptid
)
137 local ui
= getUI("ui:interface:"..id
)
138 -- deleteUI(framewin)
139 -- local framewin = getUI("ui:interface:"..id)
142 createRootGroupInstance("webig_browser_no_header", id
, {h
=h
, w
=1024, global_color
="false", bg_color
="0 0 0 255", movable
="0"})
143 WebBrowser
:addWindow(id
, "", getUI("ui:interface:"..id
))
144 ui
= getUI("ui:interface:"..id
)
158 local html
= ui
:find("html")
159 html
:renderHtml(content
)
162 ui
.x
= math
.floor((getUI("ui:interface").w
- ui
.w
) / 2)
163 ui
.y
= math
.floor((getUI("ui:interface").h
+ ui
.h
) / 2)
166 setOnDraw(ui
, "ArkLessons:onDraw("..tostring(scriptid
)..")")
169 function ArkLessons
:Minimize(id
, h
, w
)
170 local ui
= getUI("ui:interface:ArkLessonWin"..tostring(id
))
178 webig
:displayWait("ui:interface:ArkLessonWin"..tostring(id
))
180 webig
:checkUrl(ArkLessons
.NextStepUrl
[id
]["mini"])
184 function ArkLessons
:MiniShowSteps(id
, i
)
185 getUI("ui:interface:web_transactions_lessons"):find("html"):browse(ArkLessons
.NextStepUrl
[id
]["url"].."&mini_step="..tostring(i
))
189 function ArkRevealLesson(id
, i
, total
)
190 if i
== ArkLessons
.CurrentStep
[id
] then
191 ArkLessons
.RevealStep
[id
] = ArkLessons
.RevealStep
[id
] + 1
192 ArkLessons
:Callback("step", id
, i
)
193 ArkLessons
:ArkRevealLessonInfos(id
, i
, total
)
194 WebQueue
:push(ArkLessons
.NextStepUrl
[id
][i
])
198 function ArkLessons
:ArkRevealLessonInfos(scriptid
, i
, total
)
200 local ui
= getUI("ui:interface:ArkLessonWin"..tostring(scriptid
))
202 local html
= ui
:find("html")
204 html
:showDiv("disabled_"..tostring(i
), false)
205 html
:showDiv("current2_"..tostring(i
), false)
206 html
:showDiv("enabled_"..tostring(i
), false)
207 html
:showDiv("current_"..tostring(i
), true)
209 if ArkLessons
.OnDraw
[scriptid
] == nil then ArkLessons
.OnDraw
[scriptid
] = {} end
210 if ArkLessons
.OnDraw
[scriptid
][i
] == nil or ArkLessons
.OnDraw
[scriptid
][i
][4] == nil or ArkLessons
.OnDraw
[scriptid
][i
][4] < 1 then
211 ArkLessons
.OnDraw
[scriptid
][i
] = {"blink", nltime
.getLocalTime(), 1, 4}
213 if i
> 1 and i
~= total
+1 then
214 html
:showDiv("current_"..tostring(i
-1), false)
215 html
:showDiv("enabled_"..tostring(i
-1), true)
216 ArkLessons
.OnDraw
[scriptid
][i
-1] = nil
219 if ArkLessons
.RevealCaps
and ArkLessons
.RevealCaps
[scriptid
] then
221 setCap(ArkLessons
.RevealCaps
[scriptid
], "p", math
.floor((100*i
)/total
), tostring(i
).." / "..tostring(total
))
223 setCap(ArkLessons
.RevealCaps
[scriptid
], "p", 100, "")
229 function openArkLessonScript(i
, script_id
, url
)
230 if i
== ArkLessons
.RevealStep
[script_id
] then
231 getUI("ui:interface:ArkLessonWin"..tostring(script_id
)).active
= false
236 function readArkLesson(i
, script_id
, url
)
237 if ArkLessons
.LockedArkReadlesson
then
241 if i
== ArkLessons
.RevealStep
[script_id
] then
242 ArkLessons
.LockedArkReadlesson
= true
243 ArkLessons
:ArkRevealLessonInfos(script_id
, i
, 8)
248 function ArkLessons
:onDraw(scriptid
)
249 if ArkLessons
.OnDraw
[scriptid
] ~= nil then
250 for id
, command
in pairs(ArkLessons
.OnDraw
[scriptid
]) do
251 if command
== "rotate" then
252 doRotateLessonQuestion(scriptid
, id
)
253 elseif command
[1] == "blink" then
254 if command
[4] > 0 and (nltime
.getLocalTime() - command
[2]) > 300 then
255 ui
= getUI("ui:interface:ArkLessonWin"..tostring(scriptid
))
256 local html
= ui
:find("html")
257 if command
[3] == 1 then
258 ArkLessons
.OnDraw
[scriptid
][id
][3] = 2
259 html
:showDiv("current_"..tostring(id
), false)
260 html
:showDiv("current2_"..tostring(id
), true)
262 ArkLessons
.OnDraw
[scriptid
][id
][3] = 1
263 html
:showDiv("current_"..tostring(id
), true)
264 html
:showDiv("current2_"..tostring(id
), false)
266 ArkLessons
.OnDraw
[scriptid
][id
][2] = nltime
.getLocalTime()
267 ArkLessons
.OnDraw
[scriptid
][id
][4] = ArkLessons
.OnDraw
[scriptid
][id
][4] - 1
268 if ArkLessons
.OnDraw
[scriptid
][id
][4] <= 0 then
269 ArkLessons
.LockedArkReadlesson
= nil
278 function ArkLessons
:openLessonBox(continent
, name
, text
)
279 if game
.spawnShapesByZone
== nil then return end
281 local box
= game
.spawnShapesByZone
[continent
]
288 if box
[8] and box
[8]["action"] then
289 box
[8]["action"]= text
290 game
.spawnShapesByZone
[continent
][name
][9] = SceneEditor
:spawnShape(box
[12]..".shape", box
[2], box
[3], box
[4], box
[5], box
[6], box
[7], box
[8])
296 function ArkLessons
:finishLessonBox(continent
, name
, text
)
297 print_r(game
.spawnShapesByZone
)
299 if game
.spawnShapesByZone
== nil then return end
301 local box
= game
.spawnShapesByZone
[continent
]
312 if box
[8] and box
[8]["action"] then
313 box
[8]["action"] = text
314 game
.spawnShapesByZone
[continent
][name
][9] = SceneEditor
:spawnShape(box
[12]..".shape", box
[2], box
[3], box
[4], box
[5], box
[6], box
[7], box
[8])
315 game
.spawnShapesByZone
[continent
][name
][10] = nil
321 function ArkLessons
:init()
322 if webig
.check_started
== nil then
323 webig
.urls_to_check
= {}
324 webig
.check_started
= true
325 addOnDbChange(getUI("ui:interface:web_transactions_lessons"), "@UI:VARIABLES:CURRENT_SERVER_TICK", "webig:checkUrlLoop()")
330 function rotateLessonQuestion(scriptid
, id
)
331 local framewin
= getUI("ui:interface:ArkLessonWin"..scriptid
)
332 local empty
= framewin
:find("empty_"..id
)
333 if not empty
then return end
334 local sel
= empty
:find("selection")
335 local scene
= empty
:find("scene")
337 if ArkLessons
.RevealStep
[scriptid
] == id
then
338 local moves
={-1, 0.5, 0, 0.5, 1}
340 if ArkLessons
.RevealMoves
[scriptid
] == nil then
341 ArkLessons
.RevealMoves
[scriptid
] = {}
343 ArkLessons
.RevealMoves
[scriptid
][id
] = {moves
[math
.random(#moves
)], moves
[math
.random(#moves
)], moves2
[math
.random(#moves2
)]}
344 if ArkLessons
.OnDraw
[scriptid
] == nil then ArkLessons
.OnDraw
[scriptid
] = {} end
345 ArkLessons
.OnDraw
[scriptid
][id
] = "rotate"
346 sel
.tooltip
= getUCtf8(ArkLessons
.RevealTooltips
[scriptid
][id
])
347 scene
:getElement("camera#0").posy
= 24.5
349 sel
.col_over
= "0 0 0 0"
350 sel
.col_pushed
= "0 0 0 0"
352 scene
:getElement("camera#0").posy
= 23.5
357 function doRotateLessonQuestion(scriptid
, id
)
358 local framewin
= getUI("ui:interface:ArkLessonWin"..scriptid
)
359 local empty
= framewin
:find("empty_"..id
)
360 if not empty
then return end
361 local x
,y
= getMousePos()
362 empty
:find("selection").col_normal
= "200 200 255 50"
363 if empty
~= nil and x
> empty
.x_real
and x
< empty
.x_real
+ empty
.w
and y
> empty
.y_real
and y
< empty
.y_real
+ empty
.h
then
364 local scene
= empty
:find("scene")
365 empty
:find("selection").col_over
= "255 200 255 50"
366 scene
:getElement("shape#0").rotx
= scene
:getElement("shape#0").rotx
+ ArkLessons
.RevealMoves
[scriptid
][id
][1]
367 scene
:getElement("shape#0").roty
= scene
:getElement("shape#0").roty
+ ArkLessons
.RevealMoves
[scriptid
][id
][2]
368 scene
:getElement("shape#0").rotz
= scene
:getElement("shape#0").rotz
+ ArkLessons
.RevealMoves
[scriptid
][id
][3]
372 function webig
:checkUrlLoop()
373 if webig
.urls_to_check
[1] ~= nil then
374 if webig
.urls_to_check
[1][2] == "done" then
375 table.remove(self
.urls_to_check
, 1)
379 if webig
.urls_to_check
[1][2] == "wait" then
380 local url
= webig
.urls_to_check
[1][1]
381 webig
.urls_to_check
[1][2] = "run"
382 getUI("ui:interface:web_transactions_lessons"):find("html"):browse(url
)
388 function webig
:checkUrl(url
)
389 table.insert(webig
.urls_to_check
, {url
, "wait"})
392 function webig
:luaWebLoaded()
393 if webig
.urls_to_check
[1] then
394 webig
.urls_to_check
[1][2] = "done"
398 function webig
:displayWait(ui_name
)
399 local ui
= getUI(ui_name
)
402 ui
:find("html"):renderHtml([[
404 * { color: white; background-color: #000000F0 }
408 <div class="ryzom-ui-grouptemplate" id="ark_lesson_please_wait" style="template:webig_inv_item_shape;id:ark_lesson_please_wait;w:]]..tostring(ui
.w
)..[[;h:]]..tostring(ui
.h
)..[[;shape:ge_mission_chrono.ps;shape_pos:0 0 -1;rotz:0;roty:0;dist:0;fontsize:16;text:uiPleaseWait;text_y:]]..tostring(-(ui
.h
/5.7))..[[;text_color:255 200 150 255;color_over:0 165 255 0;fx:env_aqua2.ps;"></div>
415 function webig
:openWin(ui_name
)
416 local ui
= getUI(ui_name
)
424 RYZOM_ARK_LESSONS_VERSION
= 324