Update lua versions
[ryzomcore.git] / ryzom / client / data / gamedev / interfaces_v3 / map.lua
blob54f4a27855eba3f8d9e4e43037d5c710985af9fa
1 --
2 -- custom maps
3 --
5 if (game==nil) then
6 game= {};
7 end
9 -- alternative textures for maps
10 game.mapTextures = {}
11 -- game.mapTextures["zorai_map.tga"] = "tryker_map.tga"
13 -- Dynamic points/icons for the map
14 game.mapArkPoints = {}
16 -- Hide sections for the map
17 game.mapHideSections = {}
19 -- Region sections for the map
20 game.mapRegionSections = {}
22 -- Region sections for the map
23 game.mapArkPointsCachedHelp = {}
25 -- Shapes spawned
26 game.spawnShapesByZone = {}
28 -- register alternative texture for map1
29 function game:setAltMap(mapName, altMap)
30 self.mapTextures[mapName] = altMap
31 end
33 -- remove alternative map texture
34 function game:removeAltMap(mapName)
35 self.mapTextures[mapName] = nil
36 end
38 function game:addMapArkPoint(section, x, y, name, title, texture, url, h)
39 if game.mapArkPoints[section] == nil then
40 game.mapArkPoints[section] = {}
41 end
42 if url == nil then
43 game.mapArkPoints[section][name] = {x, y, title, texture, "", ""}
44 else
45 if h ~= nil and h > 0 then
46 game.mapArkPoints[section][name] = {x, y, title, texture, "", "game:openMapArkPointHelp([["..url.."]], "..tostring(h)..")"}
47 else
48 game.mapArkPoints[section][name] = {x, y, title, texture, "game:openUrlOnWebig([["..url.."]])", "game:updateMapArkPointColor()"}
49 end
50 end
51 end
53 function game:delMapArkPoint(section, name)
54 game.mapArkPoints[section][name] = nil
55 end
57 function game:delMapArkSection(section)
58 game.mapArkPoints[section] = nil
59 end
61 function game:updateMapArkPointColor()
62 local button = getUICaller()
63 button.texture_over = "lm_respawn_over.tga"
64 end
66 function game:openMapArkPointHelp(url, h)
67 local whm = getUI("ui:interface:webig_html_modal")
68 local x, y = getMousePos()
69 whm.x = x
70 whm.y = y
71 if whm.active == false then
72 runAH(nil, "enter_modal", "group=ui:interface:webig_html_modal")
73 whm.child_resize_h = false
74 whm.w = 480
75 if h == nil then
76 h = 240
77 end
78 whm.h = h
79 local whm_html = getUI("ui:interface:webig_html_modal:html")
80 if game.mapArkPointsCachedHelp[url] == nil then
81 if whm_html ~= nil then
82 game.mapMapArkPointHelpUrl = url
83 whm_html:renderHtml("<body style:'background-color: #ffffff00'>...</body>")
84 whm_html:browse(url)
85 end
86 else
87 whm_html:renderHtml(game.mapArkPointsCachedHelp[url])
88 end
89 setOnDraw(getUI("ui:interface:webig_html_modal"), "game:updateMapArkPointHelp([["..url.."]])")
90 game.mapArkPointHelpOpened = 1
91 end
92 end
94 function game:updateMapArkPointHelp()
95 local caller = getUI("ui:interface:webig_html_modal")
96 local whm_html = getUI("ui:interface:webig_html_modal:html")
97 if whm_html.html ~= "<body style:'background-color: #ffffff00'>...</body>" and game.mapArkPointsCachedHelp[game.mapMapArkPointHelpUrl] == nil then
98 game.mapArkPointsCachedHelp[game.mapMapArkPointHelpUrl] = whm_html.html
99 end
101 local x, y = getMousePos()
102 x0 = game.mapArkPointHelpMousePosX
103 if caller.x ~= 0 or caller.y ~= 0 then
104 if x < caller.x - 20 or x > caller.x + caller.w + 20 or y < caller.y - caller.h - 20 or y > caller.y + 20 then
105 setOnDraw(getUI("ui:interface:webig_html_modal"), "")
106 runAH(nil, "leave_modal", "group=ui:interface:webig_html_modal")
111 function game:onLoadMap(map)
112 if map then
113 game.currentMap = map
114 if map.continent then
115 game.currentMapContinent = map.continent
117 if map.texture then
118 game.currentMapTexture = map.texture
123 local texture = game.currentMap.texture
124 if not texture then
125 texture = game.currentMapTexture
129 delArkPoints()
130 game.mapMapArkPointHelpUrl = ""
131 for section, points in pairs(game.mapArkPoints) do
132 real_section = {}
133 map_section = section
134 for k, v in string.gmatch(section, "(%w+)/(%w+)") do
135 real_section = {k, v}
138 if real_section[1] then
139 section = real_section[1]
140 map_section = real_section[2]
143 if game.mapHideSections[section] == nil then
144 if game.mapRegionSections[map_section] == nil or game.mapRegionSections[map_section][texture] == true then
145 for name, point in pairs(points) do
146 addLandMark(point[1], point[2], point[3], point[4], "lua", point[5], "", "", "lua", point[6])
152 -- if alt view not enabled
153 if getDbProp("UI:VARIABLES:SHOW_ALT_MAP") == 0 or map:isIsland() then
154 return
158 if self.mapTextures[texture] ~= nil then
159 -- debugInfo("-- using ".. self.mapTextures[texture] .." for " .. texture)
160 return self.mapTextures[texture]
164 function game:openFullMap()
165 local ui = getUI("ui:interface:map")
166 if ui.active == false then
167 ui.active = true
170 if game.saveMapFull then
171 game.saveMapFull = false
172 ui.x = game.saveMapX
173 ui.y = game.saveMapY
174 ui.w = game.saveMapW
175 ui.h = game.saveMapH
177 game.savedMapFullZoom = getActualMapZoom()
178 if game.savedMapZoom then
179 setActualMapZoom(game.savedMapZoom)
181 else
182 game.saveMapFull = true
183 game.saveMapX = ui.x
184 game.saveMapY = ui.y
185 game.saveMapW = ui.w
186 game.saveMapH = ui.h
187 ui.x = 0
188 ui.y = 0
189 ui.w = getUI("ui:interface").w
190 ui.h = getUI("ui:interface").h
191 game.savedMapZoom = getActualMapZoom()
192 if game.savedMapFullZoom then
193 setActualMapZoom(game.savedMapFullZoom)
195 setTopWindow(ui)
199 function game:addSpawnShapesByZone(zone, continent, name, displayIcon, setup, finish, openShape, text, icon)
200 local id1 = -1
201 local id2 = -1
203 if game.spawnShapesByZone[continent] == nil
204 then
205 game.spawnShapesByZone[continent] = {}
208 if game.spawnShapesByZone[continent][name] then
209 id1 = game.spawnShapesByZone[continent][name][9]
210 id2 = game.spawnShapesByZone[continent][name][10]
213 table.insert(setup, id1)
214 table.insert(setup, id2)
215 table.insert(setup, finish)
216 table.insert(setup, openShape)
217 game.spawnShapesByZone[continent][name] = setup
218 game.spawnShapesByZone[continent][name][8] = Json.decode(setup[8])
220 if not text then
221 text = i18n.get("uiWisdomChest"):toUtf8()
224 if not icon then
225 icon = "ico_box"
228 if displayIcon == 1 then
229 game:addMapArkPoint(zone, setup[2], setup[3], setup[1], text, icon..".tga")
230 else
231 game:delMapArkPoint(zone, setup[1])
235 function game:doSpawnShapesByZone(continent)
236 if game.spawnShapesByZone[continent] then
237 for name, shape in pairs(game.spawnShapesByZone[continent]) do
238 if shape[9] then
239 deleteShape(shape[9])
241 if shape[10] then
242 deleteShape(shape[10])
245 local setup = shape[8]
246 game.spawnShapesByZone[continent][name][9] = SceneEditor:doSpawnShape(shape[1]..".shape", setup, shape[2], shape[3], shape[4], shape[5], shape[6], shape[7], "user", 1, true, setup["action"], setup["url"], false, false, setup["textures"], "", false)
247 if shape[11] == 0 then
248 game.spawnShapesByZone[continent][name][10] = SceneEditor:doSpawnShape("ge_mission_evenement.ps", setup, shape[2], shape[3], shape[4]+0.35, shape[5], shape[6], shape[7], "user", 1, false, setup["action"], setup["url"], false, false, setup["textures"], "", false)
249 else
250 game.spawnShapesByZone[continent][name][10] = nil
256 game.mapRegionSections["Silan"] = {}
257 game.mapRegionSections["Silan"]["newbieland_city.tga"] = true
258 game.mapRegionSections["Zorai"] = {}
259 game.mapRegionSections["Zorai"]["zorai_map.tga"] = true
261 game:addMapArkPoint("Vip/Silan", 10276, -11791, "vip_silan_tryker", "", "dynicon_vip.tga", "https://app.ryzom.com/app_arcc/index.php?action=mScript_Run&script=9894&vip=nb_tryker_leader&title=fct_chief_explorer&gender=1", 150)
262 game:addMapArkPoint("Vip/Silan", 10341, -11822, "vip_silan_matis", "", "dynicon_vip.tga", "https://app.ryzom.com/app_arcc/index.php?action=mScript_Run&script=9894&vip=nb_matis_leader&title=fct_matis_master_artisan&gender=1", 150)
263 game:addMapArkPoint("Vip/Silan", 10382, -11741, "vip_silan_zorai", "", "dynicon_vip.tga", "https://app.ryzom.com/app_arcc/index.php?action=mScript_Run&script=9894&vip=nb_zorai_leader&title=fct_sage&gender=1", 150)
264 game:addMapArkPoint("Vip/Silan", 10366, -11692, "vip_silan_fyros", "", "dynicon_vip.tga", "https://app.ryzom.com/app_arcc/index.php?action=mScript_Run&script=9894&vip=nb_fyros_leader&title=fct_fyros_commander&gender=1", 150)
265 game:addMapArkPoint("Vip/Silan", 10304, -11719, "vip_silan_ranger", "", "dynicon_vipbox.tga", "https://app.ryzom.com/app_arcc/index.php?action=mScript_Run&script=9894&vip=chiang_the_strong&title=fct_ranger_leader&gender=1", 150)
267 game:addMapArkPoint("Vip", 4154, -3305, "vip_allegory", "", "allegory_16.tga", "https://app.ryzom.com/app_arcc/index.php?action=mScript_Run&script=9894&vip=allegory_vip&title=fct_allegory_maker&gender=1", 150)
270 -- register map overrride
271 -- game:setAltMap("fyros_map.tga", "fyros_map_sp.tga")
273 -- VERSION --
274 RYZOM_MAP_VERSION = 10469