import ui import uiScriptLocale import wndMgr import player import miniMap import localeInfo import net import app import colorInfo import constInfo import uiCommon import background import serverLoginData as serverInfo import uiToolTip import grp import chr if app.ENABLE_HOUR_HISTORY_SYSTEM: import time import locale import datetime if app.ENABLE_EVENT_SYSTEM: import game_settings class MapTextToolTip(ui.Window): def __init__(self): ui.Window.__init__(self) textLine = ui.TextLine() textLine.SetParent(self) textLine.SetHorizontalAlignCenter() textLine.SetOutline() textLine.SetHorizontalAlignRight() textLine.Show() self.textLine = textLine def __del__(self): ui.Window.__del__(self) def SetText(self, text): self.textLine.SetText(text) def SetTooltipPosition(self, PosX, PosY): self.textLine.SetPosition(PosX - 5, PosY) def SetTextColor(self, TextColor): self.textLine.SetPackedFontColor(TextColor) def GetTextSize(self): return self.textLine.GetTextSize() class AtlasWindow(ui.ScriptWindow): class AtlasRenderer(ui.Window): def __init__(self): ui.Window.__init__(self) self.AddFlag("not_pick") def OnUpdate(self): miniMap.UpdateAtlas() def OnRender(self): (x, y) = self.GetGlobalPosition() fx = float(x) fy = float(y) miniMap.RenderAtlas(fx, fy) def HideAtlas(self): miniMap.HideAtlas() def ShowAtlas(self): miniMap.ShowAtlas() def __init__(self): self.tooltipInfo = MapTextToolTip() self.tooltipInfo.Hide() self.infoGuildMark = ui.MarkBox() self.infoGuildMark.Hide() self.AtlasMainWindow = None self.mapName = "" self.board = 0 self.tooltipInfoEx = None if app.ENABLE_ATLAS_RENDER_OPTION: self.optionBoard = 0 self.optionMarkerList = [] ui.ScriptWindow.__init__(self) def __del__(self): ui.ScriptWindow.__del__(self) if app.ENABLE_MAP_ALGORITHM_RENEWAL: def SetMapName(self, mapName): try: self.board.SetTitleName(mapName) except: pass def LoadWindow(self): try: pyScrLoader = ui.PythonScriptLoader() pyScrLoader.LoadScriptFile(self, "UIScript/AtlasWindow.py") except: import exception exception.Abort("AtlasWindow.LoadWindow.LoadScript") try: self.board = self.GetChild("board") if app.ENABLE_ATLAS_RENDER_OPTION: self.optionBoard = self.GetChild("optionBoard") for i in xrange(miniMap.MARKER_MAX): self.optionMarkerList.append(self.GetChild("OptionMarker_%02d" % (int(i)))) except: import exception exception.Abort("AtlasWindow.LoadWindow.BindObject") self.AtlasMainWindow = self.AtlasRenderer() self.board.SetCloseEvent(self.Hide) self.AtlasMainWindow.SetParent(self.board) self.AtlasMainWindow.SetPosition(7, 30) self.tooltipInfo.SetParent(self.board) self.infoGuildMark.SetParent(self.board) self.SetPosition(wndMgr.GetScreenWidth() - 136 - 256 - 10, 135) self.board.SetOnMouseLeftButtonUpEvent(ui.__mem_func__(self.OnMouseLeftButtonUpEvent)) self.Hide() if app.ENABLE_ATLAS_RENDER_OPTION: self.optionBoard.SetParent(self.board) for i in xrange(miniMap.MARKER_MAX): self.optionMarkerList[i].SetEvent(ui.__mem_func__(self.ToggleAtlasMarker), "ON_CHECK", True, i) self.optionMarkerList[i].SetEvent(ui.__mem_func__(self.ToggleAtlasMarker), "ON_UNCKECK", True, i) self.optionMarkerList[i].SetCheckStatus(miniMap.IsCheckedAtlasMarker(i)) miniMap.RegisterAtlasWindow(self) def Destroy(self): miniMap.UnregisterAtlasWindow() self.ClearDictionary() self.AtlasMainWindow = None self.tooltipAtlasClose = 0 self.tooltipInfo = None self.infoGuildMark = None self.board = None def OnUpdate(self): if not self.tooltipInfo: return if not self.infoGuildMark: return self.infoGuildMark.Hide() self.tooltipInfo.Hide() if False == self.board.IsIn(): return (mouseX, mouseY) = wndMgr.GetMousePosition() (bFind, sName, iPosX, iPosY, dwTextColor, dwGuildID) = miniMap.GetAtlasInfo(mouseX, mouseY) if False == bFind: return # TODO: Buraya entity tracking listesindeki arkadaslardan ise eger # uygun sekilde set etmemiz gerekiyor classa if "empty_guild_area" == sName: sName = localeInfo.GUILD_EMPTY_AREA self.tooltipInfo.SetText("%s(%d, %d)" % (sName, iPosX, iPosY)) (x, y) = self.GetGlobalPosition() self.tooltipInfo.SetTooltipPosition(mouseX - x, mouseY - y) self.tooltipInfo.SetTextColor(dwTextColor) self.tooltipInfo.Show() self.tooltipInfo.SetTop() if 0 != dwGuildID: textWidth, textHeight = self.tooltipInfo.GetTextSize() self.infoGuildMark.SetIndex(dwGuildID) self.infoGuildMark.SetPosition(mouseX - x - textWidth - 18 - 5, mouseY - y) self.infoGuildMark.Show() def Hide(self): if self.AtlasMainWindow: self.AtlasMainWindow.HideAtlas() self.AtlasMainWindow.Hide() for i in xrange(6): if self.tooltipInfoEx != None: self.tooltipInfoEx[i].Hide() ui.ScriptWindow.Hide(self) def Show(self): if self.AtlasMainWindow: (bGet, iSizeX, iSizeY) = miniMap.GetAtlasSize() if bGet: if app.ENABLE_ATLAS_RENDER_OPTION: iSizeY += 120 self.SetSize(iSizeX + 15, iSizeY + 38) self.board.SetSize(iSizeX + 15, iSizeY + 38) if app.ENABLE_ATLAS_RENDER_OPTION: BaseY = iSizeY-120 self.optionBoard.SetPosition(10, BaseY + 38) self.optionBoard.SetSize(iSizeX-5, 110) self.AtlasMainWindow.ShowAtlas() self.AtlasMainWindow.Show() ui.ScriptWindow.Show(self) def SetCenterPositionAdjust(self, x, y): self.SetPosition((wndMgr.GetScreenWidth() - self.GetWidth()) / 2 + x, (wndMgr.GetScreenHeight() - self.GetHeight()) / 2 + y) if app.ENABLE_ATLAS_RENDER_OPTION: def ToggleAtlasMarker(self, type, *args): status = args[0] marker = args[1] miniMap.ToggleAtlasMarker(marker, status) def OnMouseLeftButtonUpEvent(self): if not chr.IsGameMaster(player.GetMainCharacterIndex()): return (mouseX, mouseY) = wndMgr.GetMousePosition() (bFind, sName, iPosX, iPosY, dwTextColor, dwGuildID) = miniMap.GetAtlasInfo(mouseX, mouseY) net.SendChatPacket("/go %s %s" % (str(iPosX), str(iPosY))) def OnPressEscapeKey(self): self.Hide() return True def __RegisterMiniMapColor(type, rgb): miniMap.RegisterColor(type, rgb[0], rgb[1], rgb[2]) class MiniMap(ui.ScriptWindow): CANNOT_SEE_INFO_MAP_DICT = { "metin2_map_monkeydungeon" : False, "metin2_map_monkeydungeon_02" : False, "metin2_map_monkeydungeon_03" : False, } def __init__(self, interface): ui.ScriptWindow.__init__(self) self.__Initialize() miniMap.Create() miniMap.SetScale(2.0) self.AtlasWindow = AtlasWindow() self.AtlasWindow.LoadWindow() self.AtlasWindow.Hide() self.tooltipMiniMapOpen = MapTextToolTip() self.tooltipMiniMapOpen.SetText(localeInfo.MINIMAP) self.tooltipMiniMapOpen.Show() self.tooltipMiniMapClose = MapTextToolTip() self.tooltipMiniMapClose.SetText(localeInfo.UI_CLOSE) self.tooltipMiniMapClose.Show() self.tooltipScaleUp = MapTextToolTip() self.tooltipScaleUp.SetText(localeInfo.MINIMAP_INC_SCALE) self.tooltipScaleUp.Show() self.tooltipScaleDown = MapTextToolTip() self.tooltipScaleDown.SetText(localeInfo.MINIMAP_DEC_SCALE) self.tooltipScaleDown.Show() self.tooltipAtlasOpen = MapTextToolTip() self.tooltipAtlasOpen.SetText(localeInfo.MINIMAP_SHOW_AREAMAP) self.tooltipAtlasOpen.Show() self.tooltipInfo = MapTextToolTip() self.tooltipInfo.Show() if miniMap.IsAtlas(): self.tooltipAtlasOpen.SetText(localeInfo.MINIMAP_SHOW_AREAMAP) else: self.tooltipAtlasOpen.SetText(localeInfo.MINIMAP_CAN_NOT_SHOW_AREAMAP) self.tooltipInfo = MapTextToolTip() self.tooltipInfo.Show() if app.ENABLE_DUNGEON_INFO_SYSTEM: self.tooltipdungeonInfoButton = MapTextToolTip() self.tooltipdungeonInfoButton.SetText(localeInfo.DUNGEON_BOSS_INFO) self.tooltipdungeonInfoButton.Show() if app.ENABLE_EVENT_CALENDAR_SYSTEM: self.tooltipcalendarButton = MapTextToolTip() self.tooltipcalendarButton.SetText(localeInfo.CALENDAR_INFO) self.tooltipcalendarButton.Show() if app.ENABLE_UNBUG_CHARACTER_SYSTEM: self.tooltipUnBugCharacterButton = MapTextToolTip() self.tooltipUnBugCharacterButton.SetText(localeInfo.UNBUG_CHARACTER) self.tooltipUnBugCharacterButton.Show() self.tooltipAtaturkButton = MapTextToolTip() self.tooltipAtaturkButton.SetText(localeInfo.ATATURK_BUTTON) self.tooltipAtaturkButton.Show() self.mapName = "" self.isLoaded = 0 self.canSeeInfo = True if app.ENABLE_HOUR_HISTORY_SYSTEM: self.hour = 0 self.history = 0 self.interface = interface def __del__(self): miniMap.Destroy() ui.ScriptWindow.__del__(self) def __Initialize(self): self.positionInfo = 0 self.observerCount = 0 self.OpenWindow = 0 self.CloseWindow = 0 self.ScaleUpButton = 0 self.ScaleDownButton = 0 self.MiniMapHideButton = 0 self.MiniMapShowButton = 0 self.AtlasShowButton = 0 if app.ENABLE_DUNGEON_INFO_SYSTEM: self.tooltipdungeonInfoButton = 0 self.dungeonInfoButton = 0 if app.ENABLE_EVENT_CALENDAR_SYSTEM: self.tooltipcalendarButton = 0 self.calendarButton = 0 self.tooltipMiniMapOpen = 0 self.tooltipMiniMapClose = 0 self.tooltipScaleUp = 0 self.tooltipScaleDown = 0 self.tooltipAtlasOpen = 0 self.tooltipInfo = None self.serverInfo = None self.interface = None if app.ENABLE_UNBUG_CHARACTER_SYSTEM: self.UnBugCharacterButton = None self.AtaturkButton = None self.isAtaturkState = False self.AtamIlerliyor = None def SetMapName(self, mapName): self.mapName=mapName self.AtlasWindow.SetMapName(mapName) if self.CANNOT_SEE_INFO_MAP_DICT.has_key(mapName): self.canSeeInfo = False self.HideMiniMap() self.tooltipMiniMapOpen.SetText(localeInfo.MINIMAP_CANNOT_SEE) else: self.canSeeInfo = True self.ShowMiniMap() self.tooltipMiniMapOpen.SetText(localeInfo.MINIMAP) def Show(self): self.__LoadWindow() ui.ScriptWindow.Show(self) def __LoadWindow(self): if self.isLoaded == 1: return self.isLoaded = 1 try: pyScrLoader = ui.PythonScriptLoader() pyScrLoader.LoadScriptFile(self, "UIScript/MiniMap.py") except: import exception exception.Abort("MiniMap.LoadWindow.LoadScript") try: self.OpenWindow = self.GetChild("OpenWindow") self.MiniMapWindow = self.GetChild("MiniMapWindow") self.ScaleUpButton = self.GetChild("ScaleUpButton") self.ScaleDownButton = self.GetChild("ScaleDownButton") self.MiniMapHideButton = self.GetChild("MiniMapHideButton") self.AtlasShowButton = self.GetChild("AtlasShowButton") self.CloseWindow = self.GetChild("CloseWindow") self.MiniMapShowButton = self.GetChild("MiniMapShowButton") self.positionInfo = self.GetChild("PositionInfo") self.observerCount = self.GetChild("ObserverCount") self.serverInfo = self.GetChild("ServerInfo") self.OpenWindowBGI = self.GetChild("OpenWindowBGI") if app.ENABLE_HOUR_HISTORY_SYSTEM: self.hour = self.GetChild("Hour") self.history = self.GetChild("History") if app.ENABLE_DUNGEON_INFO_SYSTEM: self.dungeonInfoButton = self.GetChild("l_button") if app.ENABLE_EVENT_CALENDAR_SYSTEM: self.calendarButton = self.GetChild("calendar_button") if app.ENABLE_UNBUG_CHARACTER_SYSTEM: self.UnBugCharacterButton = self.GetChild("UnBugCharacterButton") self.AtaturkButton = self.GetChild("AtaturkButton") self.AtamIlerliyor = self.GetChild("AtamIlerliyor") except: import exception exception.Abort("MiniMap.LoadWindow.Bind") if constInfo.MINIMAP_POSITIONINFO_ENABLE==0: self.positionInfo.Hide() if app.ENABLE_HOUR_HISTORY_SYSTEM: self.hour.SetFontName("Tahoma:16") self.hour.Show() self.history.SetFontName("Tahoma:16") self.history.Show() self.serverInfo.SetText(net.GetServerInfo()) self.ScaleUpButton.SetEvent(ui.__mem_func__(self.ScaleUp)) self.ScaleDownButton.SetEvent(ui.__mem_func__(self.ScaleDown)) self.MiniMapHideButton.SetEvent(ui.__mem_func__(self.HideMiniMap)) self.MiniMapShowButton.SetEvent(ui.__mem_func__(self.ShowMiniMap)) if miniMap.IsAtlas(): self.AtlasShowButton.SetEvent(ui.__mem_func__(self.ShowAtlas)) (ButtonPosX, ButtonPosY) = self.MiniMapShowButton.GetGlobalPosition() self.tooltipMiniMapOpen.SetTooltipPosition(ButtonPosX, ButtonPosY) (ButtonPosX, ButtonPosY) = self.MiniMapHideButton.GetGlobalPosition() self.tooltipMiniMapClose.SetTooltipPosition(ButtonPosX, ButtonPosY) (ButtonPosX, ButtonPosY) = self.ScaleUpButton.GetGlobalPosition() self.tooltipScaleUp.SetTooltipPosition(ButtonPosX, ButtonPosY) (ButtonPosX, ButtonPosY) = self.ScaleDownButton.GetGlobalPosition() self.tooltipScaleDown.SetTooltipPosition(ButtonPosX, ButtonPosY) (ButtonPosX, ButtonPosY) = self.AtlasShowButton.GetGlobalPosition() self.tooltipAtlasOpen.SetTooltipPosition(ButtonPosX, ButtonPosY) if app.ENABLE_DUNGEON_INFO_SYSTEM: self.dungeonInfoButton.SetEvent(ui.__mem_func__(self.DungeonInfo)) (ButtonPosX, ButtonPosY) = self.dungeonInfoButton.GetGlobalPosition() self.tooltipdungeonInfoButton.SetTooltipPosition(ButtonPosX, ButtonPosY) if app.ENABLE_EVENT_CALENDAR_SYSTEM: self.calendarButton.SetEvent(ui.__mem_func__(self.CalendarEvent)) (ButtonPosX, ButtonPosY) = self.calendarButton.GetGlobalPosition() self.tooltipcalendarButton.SetTooltipPosition(ButtonPosX, ButtonPosY) if app.ENABLE_UNBUG_CHARACTER_SYSTEM: self.UnBugCharacterButton.SetEvent(ui.__mem_func__(self.UnBugCharacterEvent)) (ButtonPosX, ButtonPosY) = self.UnBugCharacterButton.GetGlobalPosition() self.tooltipUnBugCharacterButton.SetTooltipPosition(ButtonPosX, ButtonPosY) self.AtaturkButton.SetEvent(ui.__mem_func__(self.AtaturkButtonEvent)) (ButtonPosX, ButtonPosY) = self.AtaturkButton.GetGlobalPosition() self.tooltipAtaturkButton.SetTooltipPosition(ButtonPosX, ButtonPosY) self.AtamIlerliyor.Hide() self.ShowMiniMap() def Destroy(self): self.HideMiniMap() self.AtlasWindow.Hide() self.AtlasWindow.Destroy() self.AtlasWindow = None self.ClearDictionary() self.__Initialize() def UpdateObserverCount(self, observerCount): if app.ENABLE_HOUR_HISTORY_SYSTEM: if self.hour: self.hour.Hide() if self.history: self.history.Hide() if observerCount>0: self.observerCount.Show() elif observerCount<=0: self.observerCount.Hide() self.observerCount.SetText(localeInfo.MINIMAP_OBSERVER_COUNT % observerCount) def OnUpdate(self): (x, y, z) = player.GetMainCharacterPosition() miniMap.Update(x, y) self.positionInfo.SetText("(%.0f, %.0f)" % (x/100, y/100)) if self.tooltipInfo: if True == self.MiniMapWindow.IsIn(): (mouseX, mouseY) = wndMgr.GetMousePosition() (bFind, sName, iPosX, iPosY, dwTextColor) = miniMap.GetInfo(mouseX, mouseY) if bFind == 0: self.tooltipInfo.Hide() elif not self.canSeeInfo: self.tooltipInfo.SetText("%s(%s)" % (sName, localeInfo.UI_POS_UNKNOWN)) self.tooltipInfo.SetTooltipPosition(mouseX - 5, mouseY) self.tooltipInfo.SetTextColor(dwTextColor) self.tooltipInfo.Show() else: self.tooltipInfo.SetText("%s(%d, %d)" % (sName, iPosX, iPosY)) self.tooltipInfo.SetTooltipPosition(mouseX - 5, mouseY) self.tooltipInfo.SetTextColor(dwTextColor) self.tooltipInfo.Show() else: self.tooltipInfo.Hide() if True == self.MiniMapShowButton.IsIn(): self.tooltipMiniMapOpen.Show() else: self.tooltipMiniMapOpen.Hide() if True == self.MiniMapHideButton.IsIn(): self.tooltipMiniMapClose.Show() else: self.tooltipMiniMapClose.Hide() if True == self.ScaleUpButton.IsIn(): self.tooltipScaleUp.Show() else: self.tooltipScaleUp.Hide() if True == self.ScaleDownButton.IsIn(): self.tooltipScaleDown.Show() else: self.tooltipScaleDown.Hide() if True == self.AtlasShowButton.IsIn(): self.tooltipAtlasOpen.Show() else: self.tooltipAtlasOpen.Hide() if app.ENABLE_DUNGEON_INFO_SYSTEM: if True == self.dungeonInfoButton.IsIn(): self.tooltipdungeonInfoButton.Show() else: self.tooltipdungeonInfoButton.Hide() if app.ENABLE_EVENT_CALENDAR_SYSTEM: if True == self.calendarButton.IsIn(): self.tooltipcalendarButton.Show() else: self.tooltipcalendarButton.Hide() if app.ENABLE_UNBUG_CHARACTER_SYSTEM: if True == self.UnBugCharacterButton.IsIn(): self.tooltipUnBugCharacterButton.Show() else: self.tooltipUnBugCharacterButton.Hide() if True == self.AtaturkButton.IsIn(): self.tooltipAtaturkButton.Show() else: self.tooltipAtaturkButton.Hide() if app.ENABLE_HOUR_HISTORY_SYSTEM: locale.setlocale(locale.LC_ALL, 'turkish') mydate = datetime.datetime.now() day = time.strftime("%d ") month = mydate.strftime("%b ") year = time.strftime("%Y ") day2 = mydate.strftime("%a") self.history.SetText(time.strftime("("+"%H:%M:%S"+")")) self.hour.SetText(time.strftime(day+month+year+day2)) def OnRender(self): (x, y) = self.GetGlobalPosition() fx = float(x) fy = float(y) miniMap.Render(fx + 26.5, fy + 23.5) def Close(self): self.HideMiniMap() def HideMiniMap(self): miniMap.Hide() self.OpenWindow.Hide() self.CloseWindow.Show() def ShowMiniMap(self): if not self.canSeeInfo: return miniMap.Show() self.OpenWindow.Show() self.CloseWindow.Hide() def isShowMiniMap(self): return miniMap.isShow() def ScaleUp(self): miniMap.ScaleUp() def ScaleDown(self): miniMap.ScaleDown() def ShowAtlas(self): if not miniMap.IsAtlas(): return if not self.AtlasWindow.IsShow(): self.AtlasWindow.Show() if app.ENABLE_DUNGEON_INFO_SYSTEM: def DungeonInfo(self): if self.interface: self.interface.ShowDungeonInfoInterface() def ToggleAtlasWindow(self): if not miniMap.IsAtlas(): return if self.AtlasWindow.IsShow(): self.AtlasWindow.Hide() else: self.AtlasWindow.Show() if app.ENABLE_CHANNEL_INFO_UPDATE: def UpdateChannelInfo(self, channel): if channel == 99: serverInfoStr = serverInfo.SRV1["name"] + ' - Ortak CH' else: serverInfoStr = serverInfo.SRV1["name"] + ' - ' + 'CH ' + str(channel) self.serverInfo.SetText(serverInfoStr) net.SetServerInfo(serverInfoStr) if app.ENABLE_EVENT_CALENDAR_SYSTEM: def CalendarEvent(self): constInfo.remoteshopSystem = 1 if app.ENABLE_UNBUG_CHARACTER_SYSTEM: def UnBugCharacterEvent(self): player.UnBugCharacter() def AtaturkButtonEvent(self): if self.isAtaturkState == True: miniMap.Show() self.AtamIlerliyor.Hide() self.isAtaturkState = False else: miniMap.Hide() self.AtamIlerliyor.Show() self.isAtaturkState = True def IsAtaturkState(self): return self.isAtaturkState