Fixes
[ryzomcore.git] / ryzom / client / data / gamedev / interfaces_v3 / map.lua
blob9cdfa0c2d3c2e125ad0bb8432e928e92bdc2d2cf
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 if game.mapArkPoints[section] ~= nil then
55 game.mapArkPoints[section][name] = nil
56 end
57 end
59 function game:delMapArkSection(section)
60 game.mapArkPoints[section] = nil
61 end
63 function game:updateMapArkPointColor()
64 local button = getUICaller()
65 button.texture_over = "lm_respawn_over.tga"
66 end
68 function game:openMapArkPointHelp(url, h)
69 local whm = getUI("ui:interface:webig_html_modal")
70 local x, y = getMousePos()
71 whm.x = x
72 whm.y = y
73 if whm.active == false then
74 runAH(nil, "enter_modal", "group=ui:interface:webig_html_modal")
75 whm.child_resize_h = false
76 whm.w = 480
77 if h == nil then
78 h = 240
79 end
80 whm.h = h
81 local whm_html = getUI("ui:interface:webig_html_modal:html")
82 if game.mapArkPointsCachedHelp[url] == nil then
83 if whm_html ~= nil then
84 game.mapMapArkPointHelpUrl = url
85 whm_html:renderHtml("<body style:'background-color: #ffffff00'>...</body>")
86 whm_html:browse(url)
87 end
88 else
89 whm_html:renderHtml(game.mapArkPointsCachedHelp[url])
90 end
91 setOnDraw(getUI("ui:interface:webig_html_modal"), "game:updateMapArkPointHelp([["..url.."]])")
92 game.mapArkPointHelpOpened = 1
93 end
94 end
96 function game:updateMapArkPointHelp()
97 local caller = getUI("ui:interface:webig_html_modal")
98 local whm_html = getUI("ui:interface:webig_html_modal:html")
99 if whm_html.html ~= "<body style:'background-color: #ffffff00'>...</body>" and game.mapArkPointsCachedHelp[game.mapMapArkPointHelpUrl] == nil then
100 game.mapArkPointsCachedHelp[game.mapMapArkPointHelpUrl] = whm_html.html
103 local x, y = getMousePos()
104 x0 = game.mapArkPointHelpMousePosX
105 if caller.x ~= 0 or caller.y ~= 0 then
106 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
107 setOnDraw(getUI("ui:interface:webig_html_modal"), "")
108 runAH(nil, "leave_modal", "group=ui:interface:webig_html_modal")
113 function game:onLoadMap(map)
114 if map then
115 game.currentMap = map
116 if map.continent then
117 game.currentMapContinent = map.continent
119 if map.texture then
120 game.currentMapTexture = map.texture
125 local texture = game.currentMap.texture
126 if not texture then
127 texture = game.currentMapTexture
131 delArkPoints()
132 game.mapMapArkPointHelpUrl = ""
133 for section, points in pairs(game.mapArkPoints) do
134 real_section = {}
135 map_section = section
136 for k, v in string.gmatch(section, "(%w+)/(%w+)") do
137 real_section = {k, v}
140 if real_section[1] then
141 section = real_section[1]
142 map_section = real_section[2]
145 if game.mapHideSections[section] == nil then
146 if game.mapRegionSections[map_section] == nil or game.mapRegionSections[map_section][texture] == true then
147 for name, point in pairs(points) do
148 addLandMark(point[1], point[2], point[3], point[4], "lua", point[5], "", "", "lua", point[6])
154 -- if alt view not enabled
155 if getDbProp("UI:VARIABLES:SHOW_ALT_MAP") == 0 or map:isIsland() then
156 return
160 if self.mapTextures[texture] ~= nil then
161 -- debugInfo("-- using ".. self.mapTextures[texture] .." for " .. texture)
162 return self.mapTextures[texture]
166 function game:openFullMap()
167 local ui = getUI("ui:interface:map")
168 if ui.active == false then
169 ui.active = true
172 if game.saveMapFull then
173 game.saveMapFull = false
174 ui.x = game.saveMapX
175 ui.y = game.saveMapY
176 ui.w = game.saveMapW
177 ui.h = game.saveMapH
179 game.savedMapFullZoom = getActualMapZoom()
180 if game.savedMapZoom then
181 setActualMapZoom(game.savedMapZoom)
183 else
184 game.saveMapFull = true
185 game.saveMapX = ui.x
186 game.saveMapY = ui.y
187 game.saveMapW = ui.w
188 game.saveMapH = ui.h
189 ui.x = 0
190 ui.y = 0
191 ui.w = getUI("ui:interface").w
192 ui.h = getUI("ui:interface").h
193 game.savedMapZoom = getActualMapZoom()
194 if game.savedMapFullZoom then
195 setActualMapZoom(game.savedMapFullZoom)
197 setTopWindow(ui)
201 function game:addSpawnShapesByZone(zone, continent, name, displayIcon, setup, finish, openShape, text, icon)
202 local id1 = -1
203 local id2 = -1
205 if game.spawnShapesByZone[continent] == nil
206 then
207 game.spawnShapesByZone[continent] = {}
210 if game.spawnShapesByZone[continent][name] then
211 id1 = game.spawnShapesByZone[continent][name][9]
212 id2 = game.spawnShapesByZone[continent][name][10]
215 table.insert(setup, id1)
216 table.insert(setup, id2)
217 table.insert(setup, finish)
218 table.insert(setup, openShape)
219 game.spawnShapesByZone[continent][name] = setup
220 game.spawnShapesByZone[continent][name][8] = Json.decode(setup[8])
222 if not text then
223 text = i18n.get("uiWisdomChest"):toUtf8()
226 if not icon then
227 icon = "ico_box"
230 if displayIcon == 1 then
231 game:addMapArkPoint(zone, setup[2], setup[3], setup[1], text, icon..".tga")
232 else
233 game:delMapArkPoint(zone, setup[1])
237 function game:doSpawnShapesByZone(continent)
238 if game.spawnShapesByZone[continent] then
239 for name, shape in pairs(game.spawnShapesByZone[continent]) do
240 if shape[9] then
241 if shape[9] ~= nil and shape[9] > 0 then
242 deleteShape(shape[9])
244 if shape[10] then
245 if shape[10] ~= nil and shape[9] > 0then
246 deleteShape(shape[10])
249 local setup = shape[8]
250 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, false, setup["action"], setup["url"], false, false, setup["textures"], "", false)
251 if shape[11] == 0 then
252 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)
253 else
254 game.spawnShapesByZone[continent][name][10] = nil
260 game.mapRegionSections["Silan"] = {}
261 game.mapRegionSections["Silan"]["newbieland_city.tga"] = true
262 game.mapRegionSections["Zorai"] = {}
263 game.mapRegionSections["Zorai"]["zorai_map.tga"] = true
265 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)
266 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)
267 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)
268 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)
269 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)
271 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)
274 -- register map overrride
275 -- game:setAltMap("fyros_map.tga", "fyros_map_sp.tga")
277 -- VERSION --
278 RYZOM_MAP_VERSION = 324