import net, constInfo, ui, background, time, chat
class Zmiana_Kanalu(ui.Window):
def __init__(self):
ui.Window.__init__(self)
def __del__(self):
ui.Window.__del__(self)
def Open(self):
self.vegas_change = ui.BoardWithTitleBar()
self.vegas_change.AddFlag("movable")
self.vegas_change.AddFlag("float")
self.vegas_change.SetTitleName("Zmiana Kanału")
self.vegas_change.SetCloseEvent(self.Close)
x = 0
self.channel_list = []
for ch in xrange(4): #Nr of channels
channel_button = ui.Button()
channel_button.SetParent(self.vegas_change)
channel_button.SetSize(100, 100)
channel_button.SetPosition(30, 34 + (20 * x + x))
channel_button.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
channel_button.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
channel_button.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
channel_button.SetEvent(ui.__mem_func__(self.change_channel), ch)
channel_button.SetText("Kanał " + str(ch+1))
channel_button.Show()
self.channel_list.append(channel_button)
x = x + 1
self.vegas_change.SetSize(150, 50 + (20 * x + x))
self.vegas_change.SetCenterPosition()
self.vegas_change.Show()
def protect_maps(self):
protect_list = [
"season99/new_map_ox",
"maps_dungeon/devils_zone",
"maps_dungeon/dt_zone",
"maps_vegas/wedding_zone",
"maps_dungeon/spider_3",
"maps_vegas/duel_zone",
]
if str(background.GetCurrentMapName()) in protect_list:
return TRUE
return FALSE
def change_channel(self, ch):
if self.protect_maps():
chat.AppendChat(1, "[Zmiana Kanału] Nie możesz zmienić kanału na tej mapie!")
return
elif time.clock() >= constInfo.change_time:
self.Close()
net.SetServerInfo("Metin2 - Kanał %d" % int(ch+1)) # Nazwa pod minimapką po zmianie kanału
chat.AppendChat(chat.CHAT_TYPE_INFO, "[Zmiana Kanału] Zmiana kanału zakończona pomyślnie!")
net.SendChatPacket("/ch %d" % int(ch+1))
constInfo.change_time = time.clock() + 10 # Czas po którym można zmieniać kanał
else:
chat.AppendChat(chat.CHAT_TYPE_INFO, "[Zmiana Kanału] Możesz zmieniać kanał co 10 sekund!")
def Close(self):
self.vegas_change.Hide()
def OnPressExitKey(self):
self.Close()
return True
def OnPressEscapeKey(self):
self.Close()
return True