import app import ui import uiToolTip import grp import item import player import constInfo import localeInfo import uiScriptLocale import uiCommon import net import nonplayer import constInfo import chat import chr if app.ENABLE_TARGET_BOARD_RENEWAL: from grid import Grid import pack INFO_PAGE_MAX = 3 PAGE_GENERAL = 0 PAGE_RESIST = 1 PAGE_DROP = 2 class DungeonInfo(ui.ScriptWindow): MIN_SCROLLBAR_LIST = 8 def __init__(self): ui.ScriptWindow.__init__(self) self.dungeonIndex = 0 self.dungeonButton = {} self.dungeonImage = {} self.dungeonImageIcon = {} self.dungeonName = {} self.dungeonAvailable = {} self.questionDialog = None self.isAlreadyLoaded = False self.interface = None def __del__(self): ui.ScriptWindow.__del__(self) self.dungeonIndex = 0 self.dungeonButton = {} self.dungeonImage = {} self.dungeonImageIcon = {} self.dungeonName = {} self.dungeonAvailable = {} self.questionDialog = None self.isAlreadyLoaded = False def LoadDialog(self): try: pyScrLoader = ui.PythonScriptLoader() pyScrLoader.LoadScriptFile(self, "UIScript/dungeoninfowindow.py") except: import exception exception.Abort("DungeonInfo.LoadDialog.LoadScript") try: self.dungeonBoard = self.GetChild("DungeonBoard") self.dungeonButtonBoard = self.GetChild("DungeonButtonBoard") self.dungeonScrollBar = self.GetChild("ScrollBar") self.dungeonInfoBoard = self.GetChild("DungeonInfoBoard") self.dungeonInfoTeleportButton = self.GetChild("DungeonInfoTeleport") self.DungeonInfoWiki = self.GetChild("DungeonInfoWiki") self.DungeonInfoName = self.GetChild("DungeonInfoName") self.infoText = self.GetChild("infoText") self.LvText = self.GetChild("LvText") self.SureText = self.GetChild("SureText") self.biletSlot = self.GetChild("biletSlot") except: import exception exception.Abort("DungeonInfo.LoadDialog.GetChild") self.dungeonInfoTeleportButton.SetEvent(self.TeleportDungeon) self.DungeonInfoWiki.SetEvent(self.DungeonInfoWikiF) self.toolTip = uiToolTip.ItemToolTip() self.LoadDungeonButtons() self.LoadDungeonInfoBoard(self.dungeonIndex) self.biletSlot.SetOverInItemEvent(ui.__mem_func__(self.__BiletSlotOverIn)) self.biletSlot.SetOverOutItemEvent(ui.__mem_func__(self.__BiletSlotOverOut)) self.isAlreadyLoaded = True if app.ENABLE_MOUSEWHEEL_EVENT: def OnRunMouseWheel(self, nLen): if nLen > 0: self.dungeonScrollBar.OnUp() else: self.dungeonScrollBar.OnDown() return True def Close(self): if self.isAlreadyLoaded == True: if self.toolTip: self.toolTip = None self.isAlreadyLoaded = False self.Hide() def CloseEx(self): self.Hide() def OnPressEscapeKey(self): self.Hide() return True def Open(self): if not self.isAlreadyLoaded: self.LoadDialog() self.dungeonScrollBar.SetPos(0) self.SetCenterPosition() self.SetTop() self.Show() def LoadDungeonButtons(self): if not constInfo.dungeonInfo: return for index in xrange(min(self.MIN_SCROLLBAR_LIST, len(constInfo.dungeonInfo))): self.AppendDungeonButton( index,\ self.dungeonButtonBoard,\ 3, 3 + 216 + (38 * index) ) if len(constInfo.dungeonInfo) <= self.MIN_SCROLLBAR_LIST: self.dungeonScrollBar.SetMiddleBarSize(float(len(constInfo.dungeonInfo)) / float(len(constInfo.dungeonInfo))) self.dungeonScrollBar.SetScrollStep(float(len(constInfo.dungeonInfo)) / float(len(constInfo.dungeonInfo))) self.dungeonScrollBar.Show() else: self.dungeonScrollBar.SetMiddleBarSize(float(self.MIN_SCROLLBAR_LIST) / float(len(constInfo.dungeonInfo))) self.dungeonScrollBar.Show() self.dungeonScrollBar.SetScrollEvent(self.OnScroll) self.dungeonScrollBar.SetScrollStep(float(1.0) / float(len(constInfo.dungeonInfo))) def OnScroll(self): button_count = len(self.dungeonButton) pos = int(self.dungeonScrollBar.GetPos() * (len(constInfo.dungeonInfo) - button_count)) self.dungeonButton = {} self.dungeonImage = {} self.dungeonImageIcon = {} self.dungeonName = {} self.dungeonAvailable = {} for idx in xrange(min(self.MIN_SCROLLBAR_LIST, button_count)): realPos = idx + pos self.AppendDungeonButton( realPos,\ self.dungeonButtonBoard,\ 3, 3 + (48 * idx) ) if realPos != self.dungeonIndex: self.dungeonButton[realPos].SetUpVisual("d:/ymir work/ui/zindantakip/Ztbg.png") self.dungeonButton[realPos].SetOverVisual("d:/ymir work/ui/zindantakip/Ztbg1.png") self.dungeonButton[realPos].SetDownVisual("d:/ymir work/ui/zindantakip/Ztbg2.png") def AppendDungeonButton(self, index, parent, x, y): self.dungeonButton[index] = ui.RadioButton() self.dungeonButton[index].SetParent(parent) self.dungeonButton[index].SetUpVisual("d:/ymir work/ui/zindantakip/Ztbg.png") self.dungeonButton[index].SetOverVisual("d:/ymir work/ui/zindantakip/Ztbg1.png") self.dungeonButton[index].SetDownVisual("d:/ymir work/ui/zindantakip/Ztbg2.png") self.dungeonButton[index].SetPosition(x, y) self.dungeonButton[index].SetEvent(lambda: self.LoadDungeonInfoBoard(index)) self.dungeonButton[index].Show() self.dungeonImageIcon[index] = ui.Button() self.dungeonImageIcon[index].SetParent(self.dungeonButton[index]) mapIndex = constInfo.dungeonInfo[index]['map_index'] self.dungeonImageIcon[index].SetUpVisual("d:/ymir work/ui/game/dungeon_info/extended/icons/%d.png" % mapIndex) self.dungeonImageIcon[index].SetOverVisual("d:/ymir work/ui/game/dungeon_info/extended/icons/%d.png" % mapIndex) self.dungeonImageIcon[index].SetDownVisual("d:/ymir work/ui/game/dungeon_info/extended/icons/%d.png" % mapIndex) self.dungeonImageIcon[index].SetEvent(lambda: self.LoadDungeonInfoBoard(index)) self.dungeonImageIcon[index].SetPosition(1, 0) self.dungeonImageIcon[index].Show() self.dungeonName[index] = ui.TextLine() self.dungeonName[index].SetParent(self.dungeonButton[index]) self.dungeonName[index].SetPosition(65, 12) self.dungeonName[index].SetText("%s" % constInfo.dungeonInfo[index]['map']) self.dungeonName[index].Show() self.dungeonAvailable[index] = ui.TextLine() self.dungeonAvailable[index].SetParent(self.dungeonButton[index]) self.dungeonAvailable[index].SetPosition(325, 12) self.dungeonAvailable[index].SetText(localeInfo.DUNGEON_INFO_UNAVAILABLE) self.dungeonAvailable[index].Show() self.dungeonAvailable[index].SetText("data_loading") def LoadDungeonInfoBoard(self, index): self.dungeonIndex = index mapIndex = constInfo.dungeonInfo[self.dungeonIndex]['map_index'] bossVnum = constInfo.dungeonInfo[self.dungeonIndex]['boss_vnum'] #if (self.dungeonIndex == 0): # self.dungeonInfoBoard.LoadImage("d:/ymir work/ui/game/dungeon_info/extended/background/66.png") #else: self.dungeonInfoBoard.LoadImage("d:/ymir work/ui/game/dungeon_info/extended/background/%d.png" % int(mapIndex)) self.dungeonButton[self.dungeonIndex].SetUpVisual("d:/ymir work/ui/zindantakip/Ztbg.png") self.dungeonButton[self.dungeonIndex].SetOverVisual("d:/ymir work/ui/zindantakip/Ztbg1.png") self.dungeonButton[self.dungeonIndex].SetDownVisual("d:/ymir work/ui/zindantakip/Ztbg2.png") pos = int(self.dungeonScrollBar.GetPos() * (len(constInfo.dungeonInfo) - len(self.dungeonButton))) for idx in xrange(len(self.dungeonButton)): realPos = idx + pos if realPos != self.dungeonIndex: self.dungeonButton[realPos].SetUpVisual("d:/ymir work/ui/zindantakip/Ztbg.png") self.dungeonButton[realPos].SetOverVisual("d:/ymir work/ui/zindantakip/Ztbg1.png") self.dungeonButton[realPos].SetDownVisual("d:/ymir work/ui/zindantakip/Ztbg2.png") self.dungeonButton[realPos].SetUp() else: self.dungeonButton[realPos].Down() if constInfo.dungeonInfo[self.dungeonIndex]['entrance_map'] == "Aktif Degil": pass elif player.GetStatus(player.LEVEL) >= constInfo.dungeonInfo[self.dungeonIndex]['min_level']: pass elif player.GetStatus(player.LEVEL) <= constInfo.dungeonInfo[self.dungeonIndex]['min_level']: pass d_name = constInfo.dungeonInfo[self.dungeonIndex]['map'] self.DungeonInfoName.SetText(d_name) def DungeonInfoWikiF(self): #bossVnum = int(constInfo.dungeonInfo[self.dungeonIndex]['boss_vnum']) #if self.interface: # self.interface.OpenWikiMobDetail(bossVnum) pass def TeleportDungeon(self): if player.GetStatus(player.LEVEL) < constInfo.dungeonInfo[self.dungeonIndex]['min_level']: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DUNGEON_INFO_LEVEL_ERROR) return if player.GetStatus(player.LEVEL) > constInfo.dungeonInfo[self.dungeonIndex]['max_level']: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DUNGEON_INFO_LEVEL_ERROR) return if constInfo.dungeonInfo[self.dungeonIndex]['entrance_map'] == "Aktif Degil" and not chr.IsGameMaster(player.GetMainCharacterIndex()): chat.AppendChat(chat.CHAT_TYPE_INFO, "Bu zindan bir sureligine aktif degil!") return self.questionDialog = uiCommon.QuestionDialog() self.questionDialog.Open() self.questionDialog.SetText(localeInfo.DUNGEON_INFO_TELEPORT % str(constInfo.dungeonInfo[self.dungeonIndex]['map'])) self.questionDialog.SetAcceptText(localeInfo.UI_ACCEPT) self.questionDialog.SetCancelText(localeInfo.UI_DENY) self.questionDialog.SetAcceptEvent(lambda arg = True: self.AnswerTeleport(arg)) self.questionDialog.SetCancelEvent(lambda arg = False: self.AnswerTeleport(arg)) self.questionDialog.SetTop() def AnswerTeleport(self, answer): if player.GetStatus(player.LEVEL) < constInfo.dungeonInfo[self.dungeonIndex]['min_level']: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DUNGEON_INFO_LEVEL_ERROR) return if player.GetStatus(player.LEVEL) > constInfo.dungeonInfo[self.dungeonIndex]['max_level']: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DUNGEON_INFO_LEVEL_ERROR) return if constInfo.dungeonInfo[self.dungeonIndex]['entrance_map'] == "Aktif Degil" and not chr.IsGameMaster(player.GetMainCharacterIndex()): chat.AppendChat(chat.CHAT_TYPE_INFO, "Bu zindan bir sureligine aktif degil!") return if not self.questionDialog: return if answer == True: import event net.DungeonTeleport(self.dungeonIndex) self.questionDialog.Close() self.questionDialog = None def OnUpdate(self): pos = int(self.dungeonScrollBar.GetPos() * (len(constInfo.dungeonInfo) - len(self.dungeonButton))) for idx in xrange(min(self.MIN_SCROLLBAR_LIST, len(self.dungeonButton))): realPos = idx + pos if constInfo.dungeonInfo[realPos]['entrance_map'] == "Aktif Degil": self.dungeonAvailable[realPos].SetText(localeInfo.DUNGEON_INFO_UNAVAILABLE) self.dungeonAvailable[realPos].SetPosition(240+10, 10) elif player.GetStatus(player.LEVEL) >= constInfo.dungeonInfo[realPos]['min_level']: format_time = constInfo.dungeonInfo[realPos]['rejoin_time']-app.GetGlobalTimeStamp() if (format_time < 0): self.dungeonAvailable[realPos].SetText(localeInfo.DUNGEON_INFO_AVAILABLE) self.dungeonAvailable[realPos].SetPosition(220, 10) else: self.dungeonAvailable[realPos].SetText("|cffc9c89a%s|r" % SecondToHM(format_time)) self.dungeonAvailable[realPos].SetPosition(240-16, 10) elif player.GetStatus(player.LEVEL) <= constInfo.dungeonInfo[realPos]['min_level']: self.dungeonAvailable[realPos].SetText(localeInfo.DUNGEON_INFO_NO_LEVEL) self.dungeonAvailable[realPos].SetPosition(240-10, 10) if realPos != self.dungeonIndex: self.dungeonButton[realPos].SetUp() else: self.dungeonButton[realPos].Down() self.LvText.SetText(localeInfo.DUNGEON_LV % (int(constInfo.dungeonInfo[realPos]['min_level']), int(constInfo.dungeonInfo[realPos]['max_level']))) if constInfo.dungeonInfo[realPos]['entrance_map'] == "Aktif Degil": self.infoText.SetText(localeInfo.DUNGEON_INFO_UNAVAILABLE) format_time = constInfo.dungeonInfo[realPos]['rejoin_time']-app.GetGlobalTimeStamp() if (format_time < 0): self.SureText.SetText(localeInfo.DUNGEON_INFO_AVAILABLE) else: self.SureText.SetText("%s" % SecondToHM(format_time)) self.biletSlot.SetItemSlot(0, int(constInfo.dungeonInfo[realPos]['item_vnum']), 1) def BindInterface(self, interface): self.interface = interface def __BiletSlotOverIn(self, index): if self.toolTip: self.toolTip.SetItemToolTip(int(constInfo.dungeonInfo[self.dungeonIndex]['item_vnum'])) def __BiletSlotOverOut(self): if self.toolTip: self.toolTip.HideToolTip() if app.ENABLE_TARGET_BOARD_RENEWAL: def RecvMobInformationDungeonDropItem(self, vnum, count, socket0): pass def SecondToHM(time): second = int(time % 60) minute = int((time / 60) % 60) hour = int((time / 60) / 60) % 24 return "Soğuma: %02d:%02d:%02d" % (hour, minute,second)