1 --- Parse interface of ark_scene_editor_edit_menu ---
2 local script
= [[<interface_config>
3 <root id="interface" x="0" y="0" w="800" h="600" active="true"/>
4 <group type="menu" id="ark_scene_editor_edit_menu" extends="base_menu" mouse_pos="true">
7 parseInterfaceFromString(script
)
10 if SceneEditor
== nil then
14 LastEditedGroup
= nil,
20 function SceneEditor
:init(scene_id
, form_url
, translations
, icons_url
)
21 self
.sceneId
= scene_id
22 self
.baseUrl
= form_url
23 self
.iconsUrl
= icons_url
27 function SceneEditor
:reset(no_get_html
)
30 self
.LastEditedGroup
= nil
32 runAH(nil, "remove_shapes", "")
33 if no_get_html
== true then
34 self
:get_html("Reseted")
38 function SceneEditor
:show_menu()
40 SceneEditor
:launch_menu()
45 function SceneEditor
:launch_menu(id
)
46 -- SelectedInstanceId can be set by client application
48 SelectedInstanceId
= id
50 local menu
= getUI("ui:interface:ark_scene_editor_edit_menu")
53 menu
= menu
:getRootMenu()
55 menu
:addLine(getUCtf8("-- SHAPE EDITION --"), "", "", "shape_header")
56 menu
:addLine(getUCtf8("Move"), "", "", "shape_move")
58 local subMenu
= menu
:getSubMenu(1)
59 subMenu
:addIconLine(getUCtf8("Axe X"), "lua", "setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:move_x()\')", "shape_move_x", "ark_move_x.tga")
60 subMenu
:addIconLine(getUCtf8("Axe Y"), "lua", "setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:move_y()\')", "shape_move_y", "ark_move_y.tga")
61 subMenu
:addIconLine(getUCtf8("Axe Z"), "lua", "x, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:move_z()\')", "shape_move_z", "ark_move_z.tga")
62 subMenu
:addIconLine(getUCtf8("Axes X & Y"), "lua", "setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:move_xy()\')", "shape_move_xy", "ark_move_xy.tga")
63 subMenu
:addIconLine(getUCtf8("Axes X & Y Snap to ground "), "lua", "setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:move_xysnap()\')", "shape_move_xy_snap", "ark_move_xysnap.tga")
64 subMenu
:addSeparator()
65 subMenu
:addIconLine(getUCtf8("Move to player "), "lua", "SceneEditor:move_player()", "shape_move_player", "ark_move_player.tga")
67 menu
:addLine(getUCtf8("Rotate"), "", "", "shape_rotate")
69 subMenu
= menu
:getSubMenu(2)
70 subMenu
:addIconLine(getUCtf8("Axe X"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:rotate(SelectedInstanceId, \"x\")\')", "shape_rotate_x", "ark_rotate_x.tga")
71 subMenu
:addIconLine(getUCtf8("Axe Y"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:rotate(SelectedInstanceId, \"y\")\')", "shape_rotate_y", "ark_rotate_y.tga")
72 subMenu
:addIconLine(getUCtf8("Axe Z "), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:rotate(SelectedInstanceId, \"z\")\')", "shape_rotate_z", "ark_rotate_z.tga")
74 menu
:addLine(getUCtf8("Scale"), "", "", "shape_scale")
76 subMenu
= menu
:getSubMenu(3)
77 subMenu
:addIconLine(getUCtf8("Axe X"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:scale(SelectedInstanceId, \"x\")\')", "shape_scale_x", "ark_scale_x.tga")
78 subMenu
:addIconLine(getUCtf8("Axe Y"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:scale(SelectedInstanceId, \"y\")\')", "shape_scale_y", "ark_scale_y.tga")
79 subMenu
:addIconLine(getUCtf8("Axe Z"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:scale(SelectedInstanceId, \"z\")\')", "shape_scale_z", "ark_scale_z.tga")
80 subMenu
:addIconLine(getUCtf8("Axes X & Y & Z "), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:scale(SelectedInstanceId, \"xyz\")\')", "shape_scale_xyz", "ark_scale_xyz.tga")
82 menu
:addLine(getUCtf8("-- COLLISION EDITION --"), "", "", "col_header")
83 menu
:addLine(getUCtf8("Move"), "", "", "col_move")
85 subMenu
= menu
:getSubMenu(5)
86 subMenu
:addIconLine(getUCtf8("Axe X"), "lua", "setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:col_move_x()\')", "col_move_x", "ark_move_x.tga")
87 subMenu
:addIconLine(getUCtf8("Axe Y"), "lua", "setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:col_move_y()\')", "col_move_y", "ark_move_y.tga")
88 subMenu
:addIconLine(getUCtf8("Axe Z"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:col_move_z()\')", "col_move_z", "ark_move_xy.tga")
89 subMenu
:addIconLine(getUCtf8("Axe X & Y "), "lua", "setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:col_move_xy()\')", "col_move_xy", "ark_move_xy.tga")
90 subMenu
:addSeparator()
91 subMenu
:addIconLine(getUCtf8("Move to Shape "), "lua", "SceneEditor:col_move_to_shape()", "col_move_to_shape", "ark_move_player.tga")
93 menu
:addIconLine(getUCtf8("Rotate"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:col_rotate(SelectedInstanceId, \"x\")\')", "col_rotate_x", "ark_rotate_x.tga")
95 menu
:addLine(getUCtf8("Scale"), "", "", "col_scale")
97 subMenu
= menu
:getSubMenu(7)
98 subMenu
:addIconLine(getUCtf8("Axe X"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:col_scale(SelectedInstanceId, \"x\")\')", "col_scale_x", "ark_scale_x.tga")
99 subMenu
:addIconLine(getUCtf8("Axe Y"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:col_scale(SelectedInstanceId, \"y\")\')", "col_scale_y", "ark_scale_y.tga")
100 subMenu
:addIconLine(getUCtf8("Axe Z"), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:col_scale(SelectedInstanceId, \"z\")\')", "col_scale_z", "ark_scale_z.tga")
101 subMenu
:addIconLine(getUCtf8("Axe X & Y "), "lua", "ARK_SHAPE_LATEST_X, ARK_SHAPE_LATEST_Y = getMousePos(); setOnDraw(getUI(\'ui:interface:ark_scene_editor\'), \'SceneEditor:col_scale(SelectedInstanceId, \"xy\")\')", "col_scale_xy", "ark_scale_xyz.tga")
103 launchContextMenuInGame("ui:interface:ark_scene_editor_edit_menu")
106 function arcc_tools_check_rclick()
107 root
= getUI("ui:interface")
108 local rx
, ry
= getMousePos()
109 i_id
= getShapeIdAt(rx
, ry
)
111 setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
115 function SceneEditor
:move(id
, axe
)
116 local d
, mx
, my
= getMouseDown()
118 setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
119 SceneEditor
:set_modified(id
)
120 self
:get_html("Moved")
122 local x
,y
,z
= getGroundAtMouse()
123 if axe
== "x" then moveShape(id
, tostring(x
), "+0", "+0") end
124 if axe
== "y" then moveShape(id
, "+0", tostring(y
), "+0") end
126 mx
, my
= getMousePos()
127 moveShape(id
, "+0", "+0", "+"..tostring((my
-ARK_SHAPE_LATEST_Y
)/100))
128 ARK_SHAPE_LATEST_Y
= my
130 if axe
== "xysnap" then moveShape(id
, tostring(x
), tostring(y
), tostring(z
)) end
131 if axe
== "xy" then moveShape(id
, tostring(x
), tostring(y
), "+0") end
132 if axe
== "player" then
133 x
, y
, z
= getPlayerPos()
134 moveShape(id
, tostring(x
), tostring(y
), tostring(z
))
135 SceneEditor
:set_modified(id
)
136 self
:get_html("Moved to player")
142 function SceneEditor
:rotate(id
, axe
)
143 local d
, mx
, my
= getMouseDown()
145 setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
146 SceneEditor
:set_modified(id
)
147 self
:get_html("Rotate")
149 mx
, my
= getMousePos()
150 if axe
== "x" then rotateShape(id
, "+"..tostring((my
-ARK_SHAPE_LATEST_Y
)/100), "+0", "+0") end
151 if axe
== "y" then rotateShape(id
, "+0", "+"..tostring((my
-ARK_SHAPE_LATEST_Y
)/100), "+0") end
152 if axe
== "z" then rotateShape(id
, "+0", "+0", "+"..tostring((mx
-ARK_SHAPE_LATEST_X
)/100)) end
153 ARK_SHAPE_LATEST_X
= mx
154 ARK_SHAPE_LATEST_Y
= my
158 function SceneEditor
:scale(id
, axe
)
159 local d
, mx
, my
= getMouseDown()
161 setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
162 SceneEditor
:set_modified(id
)
163 self
:get_html("Rotate")
165 mx
, my
= getMousePos()
168 setup
["scale x"]="+"..tostring((mx
-ARK_SHAPE_LATEST_X
)/100)
169 setup
["scale y"]="+"..tostring((mx
-ARK_SHAPE_LATEST_X
)/100)
170 setup
["scale z"]="+"..tostring((mx
-ARK_SHAPE_LATEST_X
)/100)
172 if axe
== "x" then setup
["scale x"]="+"..tostring((mx
-ARK_SHAPE_LATEST_X
)/100) end
173 if axe
== "y" then setup
["scale y"]="+"..tostring((mx
-ARK_SHAPE_LATEST_X
)/100) end
174 if axe
== "z" then setup
["scale z"]="+"..tostring((my
-ARK_SHAPE_LATEST_Y
)/100) end
175 setupShape(id
, setup
)
176 ARK_SHAPE_LATEST_X
= mx
177 ARK_SHAPE_LATEST_Y
= my
182 function SceneEditor
:move_x()
183 self
:move(SelectedInstanceId
, "x")
186 function SceneEditor
:move_y()
187 self
:move(SelectedInstanceId
, "y")
190 function SceneEditor
:move_xy()
191 self
:move(SelectedInstanceId
, "xy")
194 function SceneEditor
:move_xysnap()
195 self
:move(SelectedInstanceId
, "xysnap")
198 function SceneEditor
:move_z()
199 self
:move(SelectedInstanceId
, "z")
202 function SceneEditor
:move_player()
203 self
:move(SelectedInstanceId
, "player")
207 function SceneEditor
:col_move(id
, axe
)
208 local d
, mx
, my
= getMouseDown()
211 setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
212 self
:set_modified(id
)
213 self
:get_html("Updated")
215 local x
,y
,z
= getGroundAtMouse()
217 if axe
== "x" then setup
["col pos x"]=tostring(x
) end
218 if axe
== "y" then setup
["col pos y"]=tostring(y
) end
220 mx
, my
= getMousePos()
221 setup
["col pos z"]="+"..tostring((my
-ARK_SHAPE_LATEST_Y
)/100)
222 ARK_SHAPE_LATEST_X
= mx
223 ARK_SHAPE_LATEST_Y
= my
225 if axe
== "xy" then setup
["col pos x"]=tostring(x
); setup
["col pos y"]=tostring(y
) end
226 if axe
== "shape" then
227 x
, y
, z
= getShapePos(id
)
228 setup
["col pos x"]=tostring(x
)
229 setup
["col pos y"]=tostring(y
)
230 self
:set_modified(id
)
231 setupShape(id
, setup
)
232 self
:get_html("Updated")
234 setupShape(id
, setup
)
239 function SceneEditor
:col_rotate(id
, axe
)
240 local d
, mx
, my
= getMouseDown()
242 setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
243 SceneEditor
:set_modified(id
)
244 self
:get_html("Rotate")
246 mx
, my
= getMousePos()
248 setup
["col orientation"]="+"..tostring((mx
-ARK_SHAPE_LATEST_X
)/100)
249 setupShape(id
, setup
)
250 ARK_SHAPE_LATEST_X
= mx
251 ARK_SHAPE_LATEST_Y
= my
257 function SceneEditor
:col_scale(id
, axe
)
258 local d
, mx
, my
= getMouseDown()
260 setOnDraw(getUI("ui:interface:ark_scene_editor"), "")
261 SceneEditor
:set_modified(id
)
262 self
:get_html("Rotate")
264 mx
, my
= getMousePos()
266 if axe
== "x" or axe
== "xy" then setup
["col size x"]="+"..tostring((mx
-ARK_SHAPE_LATEST_X
)/100) end
267 if axe
== "y" or axe
== "xy" then setup
["col size y"]="+"..tostring((mx
-ARK_SHAPE_LATEST_X
)/100) end
268 if axe
== "z" then setup
["col size z"]="+"..tostring((my
-ARK_SHAPE_LATEST_Y
)/100) end
269 setupShape(id
, setup
)
270 ARK_SHAPE_LATEST_X
= mx
271 ARK_SHAPE_LATEST_Y
= my
276 function SceneEditor
:set_modified(id
)
277 if self
.Shapes
[id
] then
278 self
.Groups
[self
.Shapes
[id
].group
].props
.modified
=true
279 self
.Shapes
[id
].modified
= "modified"
281 self
.HaveUpdate
= true
282 if self
.repeatAdd
~= nil then
283 local d
, mx
, my
= getMouseRightDown()
286 self
:add(self
.repeatAdd
)
290 getUI("ui:interface:arkpowo_preview_shape:content:scene3d").active
=1
291 local framewin
= getUI("ui:interface:arkpowo_preview_shape")
293 if self
.hideMenu
then
294 setOnDraw(getUI("ui:interface:game_context_menu"), "SceneEditor:setTopWindowShapeList()")
295 setOnDraw(getUI("ui:interface:ark_scene_editor_edit_menu"), "SceneEditor:setTopWindowShapeList()")
301 function SceneEditor
:col_move_x()
302 self
:col_move(SelectedInstanceId
, "x")
305 function SceneEditor
:col_move_y()
306 self
:col_move(SelectedInstanceId
, "y")
308 function SceneEditor
:col_move_z()
309 self
:col_move(SelectedInstanceId
, "z")
313 function SceneEditor
:col_move_xy()
314 self
:col_move(SelectedInstanceId
, "xy")
318 function SceneEditor
:col_move_to_shape()
319 self
:col_move(SelectedInstanceId
, "shape")
323 function SceneEditor
:setup_shape(shape_id
, setup
)
324 final_setup
= self
.Shapes
[new_shape
.id
].setup
325 if final_setup
== nil then
328 for k
,v
in pairs(setup
) do
331 self
.Shapes
[new_shape
.id
].setup
= final_setup
332 setupShape(shape_id
, setup
)
335 function SceneEditor
:add(shape
)
336 if self
.LastEditedGroup
== nil then
337 self
:get_html("<font color=\"#aa00000\">"..self
.T
["no_selected_group"].."</font>\", \"000000\"")
340 new_shape
.file
= shape
341 new_shape
.group
= self
.LastEditedGroup
342 self
.Groups
[new_shape
.group
].props
.modified
=true
343 new_shape
.db_id
= self
.Groups
[new_shape
.group
].props
.count
+ 1
344 new_shape
.modified
= "added"
345 new_shape_id
= addShape(shape
, 0, 0, 0, "user", 1, true, "", "SceneEditor:show_menu()", false, false, "", "", false)
346 table.insert(self
.Groups
[new_shape
.group
], new_shape_id
)
347 self
.Groups
[new_shape
.group
].props
.count
= self
.Groups
[new_shape
.group
].props
.count
+ 1
348 self
.Shapes
[new_shape_id
] = new_shape
349 self
:get_html("Added")
351 self
.move_timer
= nltime
.getLocalTime() + 60
352 getUI("ui:interface:arkpowo_preview_shape:content:scene3d").active
=false
353 local framewin
= getUI("ui:interface:arkpowo_preview_shape")
354 framewin
.opened
=false
355 setOnDraw(framewin
, "SceneEditor:moveTimerUpdate( \'"..shape
.."\', "..tostring(new_shape_id
)..")")
359 function SceneEditor
:removeShape(shape_id
)
360 deleteShape(shape_id
)
361 local group
= self
.Shapes
[shape_id
].group
362 for k
,g_shape_id
in pairs(self
.Groups
[group
]) do
363 if shape_id
== g_shape_id
then
364 self
.Groups
[group
][k
] = nil
367 self
:set_modified(shape_id
)
368 self
.Shapes
[shape_id
] = nil
369 self
:get_html("Removed")
372 function SceneEditor
:addGroup(name
, count
, show
, edit
)
376 if self
.Groups
[name
] == nil then
377 self
.Groups
[name
] = {}
378 self
.Groups
[name
].props
= {}
379 self
.Groups
[name
].props
.count
= count
380 self
.Groups
[name
].props
.show
= show
381 self
.Groups
[name
].props
.edit
= edit
382 self
.Groups
[name
].props
.modified
= false
384 self
.Groups
[name
].props
.show
= show
385 self
.Groups
[name
].props
.edit
= edit
389 function SceneEditor
:editGroup(group
)
390 if self
.LastEditedGroup
then
391 self
:removeGroup(self
.LastEditedGroup
, true)
392 self
:addGroup(self
.LastEditedGroup
, 0, true, false)
394 self
:removeGroup(group
, true);
395 self
:addGroup(group
, 0, true, true)
396 self
.LastEditedGroup
= group
399 function SceneEditor
:addFromDb(group
, db_id
, json_shape
, edit
)
400 local shape
= Json
.decode(json_shape
)
406 if shape
.setup
["textures"] ~= nil then
407 textures
= shape
.setup
["textures"]
412 if shape
.setup
["context"] ~= nil then
413 context
= shape
.setup
["context"]
418 if shape
.setup
["url"] ~= nil then
419 url
= shape
.setup
["url"]
425 shape_id
= addShape(shape
.file
, shape
.pos
[1], shape
.pos
[2], shape
.pos
[3], "user", 1, true, "", "SceneEditor:show_menu()", false, false, textures
, "", false)
427 shape_id
= addShape(shape
.file
, shape
.pos
[1], shape
.pos
[2], shape
.pos
[3], "user", 1, true, context
, url
, false, false, textures
, "", false)
430 rotateShape(shape_id
, tostring(shape
.rot
[1]), tostring(shape
.rot
[2]), tostring(shape
.rot
[3]))
431 setupShape(shape_id
, shape
.setup
)
432 self
.Shapes
[shape_id
] = shape
433 table.insert(self
.Groups
[group
], shape_id
)
434 if db_id
> self
.Groups
[group
].props
.count
then
435 self
.Groups
[group
].props
.count
= db_id
439 function SceneEditor
:spawnShape(shape
, x
, y
, z
, rotx
, roty
, rotz
, setup
)
440 if type(setup
) == "string" then
441 setup
= Json
.decode(setup
)
443 return SceneEditor
:doSpawnShape(shape
, setup
, x
, y
, z
, rotx
, roty
, rotz
, "user", 1, setup
["no collisons"] == nil, setup
["action"], setup
["url"], false, false, setup
["textures"], "", true)
446 function SceneEditor
:doSpawnShape(shape
, setup
, x
, y
, z
, rotx
, roty
, rotz
, angle
, scale
, collisions
, action
, url
, highlight
, transparency
, textures
, skeleton
, igzone
)
448 local id
= addShape(shape
, x
, y
, z
, angle
, scale
, collisions
, misc
:nilToEmpty(action
), misc
:nilToEmpty(url
), highlight
, transparency
, misc
:nilToEmpty(textures
), misc
:nilToEmpty(skeleton
), igzone
)
449 rotateShape(id
, tostring(rotx
), tostring(roty
), tostring(rotz
))
450 setupShape(id
, setup
)
455 function SceneEditor
:removeGroup(group
, no_get_html
)
456 if self
.Groups
[group
] == nil then
460 for k
,shape_id
in pairs(self
.Groups
[group
]) do
462 self
.Shapes
[shape_id
] = nil
463 deleteShape(shape_id
)
467 self
.Groups
[group
] = nil
468 if self
.LastEditedGroup
== group
then
469 self
.LastEditedGroup
= nil
470 local ui
= getUI("ui:interface:ark_list_of_shapes")
475 if no_get_html
== nil then
476 self
:get_html("Group Removed")
480 function SceneEditor
:enc64(data
)
481 local b
='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
482 return ((data
:gsub('.', function(x
)
483 local r
,b
='',x
:byte()
484 for i
=8,1,-1 do r
=r
..(b
%2^i
-b
%2^
(i
-1)>0 and '1' or '0') end
486 end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x
)
487 if (#x
< 6) then return '' end
489 for i
=1,6 do c
=c
+(x
:sub(i
,i
)=='1' and 2^
(6-i
) or 0) end
490 return b
:sub(c
+1,c
+1)
491 end)..({ '', '==', '=' })[#data
%3+1])
494 function SceneEditor
:get_vector(x
, y
, z
)
496 table.insert(vector
, x
)
497 table.insert(vector
, y
)
498 table.insert(vector
, z
)
503 function SceneEditor
:get_random_color()
504 local r
= math
.random(44, 66);
505 local g
= math
.random(44, 66);
506 local b
= math
.random(44, 66);
507 return '#'..tostring(r
)..tostring(g
)..tostring(b
)
511 function pairsByKeys(t
, f
)
513 for n
in pairs(t
) do table.insert(a
, n
) end
515 local i
= 0 -- iterator variable
516 local iter
= function () -- iterator function
527 function SceneEditor
:show_shape_list()
528 local ui
= getUI("ui:interface:ark_list_of_shapes")
529 local need_setup
= ui
== nil
531 WebBrowser
:openWindow("ark_list_of_shapes", self
.baseUrl
..'_ListShapes')
532 ui
= getUI("ui:interface:ark_list_of_shapes")
535 getUI("ui:interface:ark_list_of_shapes:browser:header_opened:browse_redo").active
=false
536 getUI("ui:interface:ark_list_of_shapes:browser:header_opened:browse_undo").active
=false
537 getUI("ui:interface:ark_list_of_shapes:browser:header_opened:browse_refresh").active
=false
538 getUI("ui:interface:ark_list_of_shapes:browser:header_opened:browse_home").active
=false
544 function SceneEditor
:getShapesByGroups()
546 for shape_id
, shape
in pairs(self
.Shapes
) do
547 if shape
.group
== nil then
551 if groups
[shape
.group
] == nil then
552 groups
[shape
.group
] = {}
554 table.insert(groups
[shape
.group
], shape_id
)
560 function SceneEditor
:get_html_section(message
, color
)
561 return '<table width="100%" cellspacing="0" cellpadding="0"><tr bgcolor="'..color
..'"><td align="center" valign="middle"><font color="#FFFFFF" size="12">'..message
..'</font></td></tr></table>'
564 function SceneEditor
:get_html(message
, message_bg
)
565 debug("get_html :"..message
)
566 local new_group
= ' <a class="ryzom-ui-button" href="'..self
.baseUrl
..'_AddGroup&add_new_group=1&scene_id='..self
.sceneId
..'"><img src="'..self
.iconsUrl
..'/32/chart_organisation_add.png" alt="'..self
.T
["add_new_group"]..'" /></a>'
567 local show_hide_cols
= ' <a class="ryzom-ui-button" href="ah:ark_pacs_borders"><img src="'..self
.iconsUrl
..'/32/show_hide_cols.png" alt="'..self
.T
["show_hide_cols"]..'" /></a>'
568 local reset_scene
= '</td><td align="center" bgcolor="#502020" width="40px"><a class="ryzom-ui-button" href="'..self
.baseUrl
..'_SaveShapes&reset_scene=1&scene_id='..self
.sceneId
..'"><img src="'..self
.iconsUrl
..'/32/bin.png" alt="'..self
.T
["reset_scene"]..'" /></a>'
570 local html
= '<header><title>'..self
.T
["sceno_editor"]..'</title></header>'..self
:get_html_section(message
..'</td><td bgcolor="#202020" align="center" height="40px" width="140px" valign="middle">'..new_group
..show_hide_cols
..reset_scene
, (message_bg
or SceneEditor
:get_random_color()))
572 html
= html
.. '<form action="'..self
.baseUrl
..'_SaveShapes" method="POST"><input type="hidden" name="group" value="'..(self
.LastEditedGroup
or "")..'" /><input type="hidden" name="scene_id" value="'..self
.sceneId
..'" />\
573 <table width="100%" cellspacing="0" cellpadding="0">'
575 local groups
= self
:getShapesByGroups()
577 for group
, shapes
in pairsByKeys(self
.Groups
) do
578 debug("Group : "..group
)
579 local groupname
= group
580 html
= html
.. '<tr bgcolor="#444444"><td height="20px"><table width="100%"><tr><td> '..groupname
..' ('..(self
.Groups
[group
].props
.count
or '0')..') </td><td align="right"><input type="hidden" name="shape[]", value="#"/>'
583 if self
.Groups
[group
].props
.show
then
584 debug("Group : show")
585 if self
.Groups
[group
].props
.edit
then
586 html
= html
.. '<a href="ah:lua:SceneEditor:show_shape_list()"><img src="'..self
.iconsUrl
..'/16/box_add.png" alt="'..self
.T
["add_shape"]..'"/></a></td><td align="right">'
587 if self
.HaveUpdate
then
588 html
= html
.. '<a class="ryzom-ui-button" href="'..self
.baseUrl
..'_SaveShapes&hide_group='..group
..'&edit_group='..group
..'">'..self
.T
["cancel"]..'</a>'
590 html
= html
.. '<a class="ryzom-ui-button" href="'..self
.baseUrl
..'_SaveShapes&hide_group='..group
..'">'..self
.T
["hide"]..'</a>'
593 html
= html
.. '<a class="ryzom-ui-button" href="'..self
.baseUrl
..'_SaveShapes&hide_group='..group
..'">'..self
.T
["hide"]..'</a>'
596 html
= html
.. '<a class="ryzom-ui-button" href="'..self
.baseUrl
..'_SaveShapes&show_group='..group
..'">'..self
.T
["show"]..'</a>'
599 local shapes_html
= ""
600 local shapes_html_dict
= {}
601 local show
= self
.Groups
[group
].props
.show
602 if self
.Groups
[group
].props
.edit
then
603 shapes_id
= groups
[group
]
605 for k
,shape_id
in pairs(shapes_id
) do
607 if self
.Shapes
[shape_id
] then
608 shape
["db_id"] = self
.Shapes
[shape_id
].db_id
609 shape
["file"] = self
.Shapes
[shape_id
].file
610 shape
["pos"] = self
:get_vector(getShapePos(shape_id
))
611 scale_x
, scale_y
, scale_z
= getShapeScale(shape_id
)
612 shape
["rot"] = self
:get_vector(getShapeRot(shape_id
))
613 colpos_x
, colpos_y
, colpos_z
= getShapeColPos(shape_id
)
614 colscale_x
, colscale_y
, colscale_z
= getShapeColScale(shape_id
)
615 colorient
= getShapeColOrient(shape_id
)
617 shape
["setup"]["scale x"] = scale_x
618 shape
["setup"]["scale y"] = scale_y
619 shape
["setup"]["scale z"] = scale_z
620 shape
["setup"]["col pos x"] = shape
["pos"][1]+colpos_x
621 shape
["setup"]["col pos y"] = shape
["pos"][2]+colpos_y
622 shape
["setup"]["col size x"] = colscale_x
623 shape
["setup"]["col size y"] = colscale_y
624 shape
["setup"]["col size z"] = colscale_z
625 shape
["setup"]["col orientation"] = colorient
626 local color
= "202020"
630 local text_color
= "ef9b64"
631 if self
.Shapes
[shape_id
].modified
== "modified" then
632 text_color
= "aa5555"
634 if self
.Shapes
[shape_id
].modified
== "added" then
635 text_color
= "55aa55"
638 table.insert(shapes_html_dict
, {id
=shape
.db_id
, html
="<tr bgcolor='#"..color
.."'><td height='20px'> <input type='hidden' name='shape[]', value='"..SceneEditor
:enc64((shape
.db_id
or '')..":"..Json
.encode(shape
)).."' />"..'#'..(shape
.db_id
or '0').." <a href='ah:lua:SceneEditor:launch_menu("..tostring(shape_id
)..")'><font color='#"..text_color
.."'>"..shape
.file
.."</font></a></td>\
639 <td width='30px'><a href='ah:lua:SceneEditor:editShapeProperties("..tostring(shape_id
)..")'><img src='"..self
.iconsUrl
.."/16/layout_edit.png' /></a></td>\
640 <td width='3px'><a href='ah:lua:SceneEditor:removeShape("..tostring(shape_id
)..")'><img src='"..self
.iconsUrl
.."/16/cross.png' /></a></td>\
645 table.sort(shapes_html_dict
, function (a
, b
) return a
.id
< b
.id
end)
646 for k
,shape
in ipairs(shapes_html_dict
) do
647 shapes_html
= shape
.html
.. shapes_html
651 if self
.HaveUpdate
== nil then
652 html
= html
.. ' <a class="ryzom-ui-button" href="'..self
.baseUrl
..'_SaveShapes&edit_group='..group
..'">'..self
.T
["edit"]..'</a>'
653 html
= html
.. '</td><td align="right"><a class="ryzom-ui-button" href="'..self
.baseUrl
..'_SaveShapes&reset_scene=1&del_group='..group
..'">'..self
.T
["remove"]..'</a>'
657 if self
.Groups
[group
].props
.modified
then
658 html
= html
.. ' <input type="submit" value="'..self
.T
["save"]..'" />'
660 html
= html
.. '</td></tr></table></td><td></td></tr>'..shapes_html
664 html
= html
.. '</table></form>'
665 ui
= getUI("ui:interface:ark_scene_editor:browser:content:html", false)
673 RYZOM_SCENEEDIT_VERSION
= 324