forked from metin-server/m2dev-client
212 lines
6.0 KiB
Python
212 lines
6.0 KiB
Python
import app
|
|
import ui
|
|
import uiScriptLocale
|
|
import localeInfo
|
|
|
|
LOCALE_PATH = uiScriptLocale.MAPNAME_PATH
|
|
|
|
# Static map name -> image suffix mapping (locale-independent)
|
|
_MAP_NAME_SUFFIXES = {
|
|
"metin2_map_a1": "a1.tga",
|
|
"map_a2": "a2.tga",
|
|
"metin2_map_a3": "a3.tga",
|
|
"metin2_map_b1": "b1.tga",
|
|
"map_b2": "b2.tga",
|
|
"metin2_map_b3": "b3.tga",
|
|
"metin2_map_c1": "c1.tga",
|
|
"map_c2": "c2.tga",
|
|
"metin2_map_c3": "c3.tga",
|
|
"map_n_snowm_01": "snow1.tga",
|
|
"metin2_map_deviltower1": "devil1_title.tga",
|
|
"metin2_map_n_flame_01": "frame1.tga",
|
|
"metin2_map_n_desert_01": "desert1.tga",
|
|
"metin2_map_milgyo": "milgyo.tga",
|
|
"metin2_map_monkeydungeon": "monkey1.tga",
|
|
"metin2_map_monkeydungeon_02": "monkey2.tga",
|
|
"metin2_map_monkeydungeon_03": "monkey3.tga",
|
|
"metin2_map_guild_01": "guild1.tga",
|
|
"metin2_map_guild_02": "guild2.tga",
|
|
"metin2_map_guild_03": "guild3.tga",
|
|
"metin2_map_trent": "trent.tga",
|
|
"metin2_map_trent02": "trent02.tga",
|
|
"season2/map_n_snowm_02": "snow2.tga",
|
|
"season2/metin2_map_a2_1": "a2_2.tga",
|
|
"season2/metin2_map_n_desert_02": "desert2.tga",
|
|
"season2/metin2_map_n_flame_02": "frame2.tga",
|
|
"season2/metin2_map_milgyo_a": "milgyo2.TGA",
|
|
"season2/metin2_map_trent_a": "trent_a.tga",
|
|
"season2/metin2_map_trent02_a": "trent02_a.tga",
|
|
"season2/metin2_map_skipia_dungeon_01": "skipia.tga",
|
|
"season2/metin2_map_skipia_dungeon_02": "skipia.tga",
|
|
"metin2_map_devilsCatacomb": "devil_basement.tga",
|
|
"metin2_guild_village_01": "a4.tga",
|
|
"metin2_guild_village_02": "b4.tga",
|
|
"metin2_guild_village_03": "c4.tga",
|
|
"metin2_map_BayBlackSand": "bay.tga",
|
|
"metin2_map_Mt_Thunder": "thunder.tga",
|
|
"metin2_map_dawnmistwood": "dawn.tga",
|
|
"Metin2_map_CapeDragonHead": "cape.tga",
|
|
"metin2_map_spiderdungeon": "spider1.tga",
|
|
"metin2_map_spiderdungeon_02": "spider1.tga",
|
|
"metin2_map_spiderdungeon_03": "spider1.tga",
|
|
}
|
|
|
|
def _RebuildLocaleStrings():
|
|
global LOCALE_PATH
|
|
LOCALE_PATH = uiScriptLocale.MAPNAME_PATH
|
|
|
|
localeInfo.RegisterReloadCallback(_RebuildLocaleStrings)
|
|
|
|
class MapNameShower(ui.ExpandedImageBox):
|
|
|
|
STATE_HIDE = 0
|
|
STATE_FADE_IN = 1
|
|
STATE_SHOW = 2
|
|
STATE_FADE_OUT = 3
|
|
|
|
def __init__(self):
|
|
ui.ExpandedImageBox.__init__(self, "TOP_MOST")
|
|
self.AddFlag("not_pick")
|
|
self.__Initialize()
|
|
|
|
def __del__(self):
|
|
ui.ExpandedImageBox.__del__(self)
|
|
|
|
def __Initialize(self):
|
|
self.floorImage = None
|
|
self.objectiveImage = None
|
|
self.fadeStartTime = 0
|
|
self.state = self.STATE_HIDE
|
|
self.curAlpha = 0.0
|
|
self.SetAlpha(0.0)
|
|
self.SetWindowHorizontalAlignCenter()
|
|
self.SetPosition(0, 80)
|
|
self.Hide()
|
|
|
|
def __GetDevilTowerFloor(self, x, y):
|
|
if x > 10000 and y > 58000 and x < 25000 and y < 72000:
|
|
return 1
|
|
elif x > 10000 and y > 35000 and x < 25000 and y < 50000:
|
|
return 2
|
|
elif x > 10000 and y > 10000 and x < 25000 and y < 25000:
|
|
return 3
|
|
elif x > 35000 and y > 61000 and x < 43500 and y < 70500:
|
|
return 4
|
|
elif x > 35000 and y > 38000 and x < 43500 and y < 48000:
|
|
return 5
|
|
elif x > 14000 and y > 14000 and x < 43500 and y < 24500:
|
|
return 6
|
|
elif x > 56000 and y > 60000 and x < 68000 and y < 73000:
|
|
return 7
|
|
elif x > 56000 and y > 38000 and x < 68000 and y < 49000:
|
|
return 8
|
|
elif x > 56000 and y > 13000 and x < 68000 and y < 23000:
|
|
return 9
|
|
return 0
|
|
|
|
def __GetDevilBase(self, x, y):
|
|
if x > 3000 and y > 4500 and x < 45000 and y < 45000:
|
|
return 1
|
|
elif x > 54000 and y > 3900 and x < 100000 and y < 46200:
|
|
return 2
|
|
elif x > 104800 and y > 3500 and x < 145500 and y < 45800:
|
|
return 3
|
|
elif x > 3100 and y > 54100 and x < 56400 and y < 105800:
|
|
return 4
|
|
elif x > 65000 and y > 54000 and x < 105000 and y < 95500:
|
|
return 5
|
|
elif x > 117500 and y > 57600 and x < 142000 and y < 81000:
|
|
return 6
|
|
elif x > 5000 and y > 104900 and x < 15000 and y < 122000:
|
|
return 7
|
|
return 0
|
|
|
|
def ShowMapName(self, mapName, x, y):
|
|
if mapName not in _MAP_NAME_SUFFIXES:
|
|
print((" [ERROR] - There is no map name image", mapName))
|
|
return
|
|
|
|
try:
|
|
self.LoadImage(LOCALE_PATH + _MAP_NAME_SUFFIXES[mapName])
|
|
except RuntimeError:
|
|
return
|
|
|
|
self.__Initialize()
|
|
|
|
if mapName == "metin2_map_deviltower1":
|
|
self.SetPosition(-60, 80)
|
|
|
|
self.floorImage = ui.ExpandedImageBox()
|
|
self.floorImage.AddFlag("not_pick")
|
|
self.floorImage.SetWindowHorizontalAlignCenter()
|
|
self.floorImage.SetPosition(100, 80)
|
|
self.floorImage.SetAlpha(0.0)
|
|
self.floorImage.Show()
|
|
|
|
try:
|
|
floor = self.__GetDevilTowerFloor(x, y)
|
|
print((x, y, floor))
|
|
self.floorImage.LoadImage(LOCALE_PATH+"devil1_%df.tga" % floor)
|
|
except RuntimeError:
|
|
self.SetPosition(0, 80)
|
|
self.floorImage.Hide()
|
|
self.floorImage = None
|
|
|
|
if mapName == "metin2_map_devilsCatacomb":
|
|
self.SetPosition(-75, 80)
|
|
|
|
self.floorImage = ui.ExpandedImageBox()
|
|
self.floorImage.AddFlag("not_pick")
|
|
self.floorImage.SetWindowHorizontalAlignCenter()
|
|
self.floorImage.SetPosition(100, 80)
|
|
self.floorImage.SetAlpha(0.0)
|
|
self.floorImage.Show()
|
|
|
|
try:
|
|
floor = self.__GetDevilBase(x, y)
|
|
print((x, y, floor))
|
|
self.floorImage.LoadImage(LOCALE_PATH+"devil1_%df.tga" % floor)
|
|
except RuntimeError:
|
|
self.SetPosition(0, 80)
|
|
self.floorImage.Hide()
|
|
self.floorImage = None
|
|
|
|
self.state = self.STATE_FADE_IN
|
|
self.fadeStartTime = app.GetTime() + 1.0
|
|
self.Show()
|
|
|
|
def Update(self):
|
|
|
|
self.SetAlpha(self.curAlpha)
|
|
if self.floorImage:
|
|
self.floorImage.SetAlpha(self.curAlpha)
|
|
|
|
if self.objectiveImage:
|
|
self.objectiveImage.SetAlpha(self.curAlpha)
|
|
|
|
if self.STATE_FADE_IN == self.state:
|
|
if app.GetTime() > self.fadeStartTime:
|
|
self.curAlpha += 0.05
|
|
|
|
if self.curAlpha > 0.9:
|
|
self.state = self.STATE_SHOW
|
|
self.fadeStartTime = app.GetTime() + 5.0
|
|
|
|
elif self.STATE_SHOW == self.state:
|
|
if app.GetTime() > self.fadeStartTime:
|
|
self.state = self.STATE_FADE_OUT
|
|
|
|
elif self.STATE_FADE_OUT == self.state:
|
|
self.curAlpha -= 0.05
|
|
|
|
if self.curAlpha < 0.0001:
|
|
self.Hide()
|
|
if self.floorImage:
|
|
self.floorImage.Hide()
|
|
self.floorImage = None
|
|
|
|
if self.objectiveImage:
|
|
self.objectiveImage.Hide()
|
|
self.objectiveImage = None
|
|
return
|