Switchbot Refresh Button fehlt O.o

03/31/2014 07:09 M2Back2Roots#1
Bei dem Switchbot von DaRealFreak v 3.1.2 fehlt mir der Refresh Button für die Item Liste links :o wie mache ich den rein?

Code:
import chat
import item
import net
import player
import snd
import locale
import shop
import ui
import uiTip

Bonus0 = 0
Bonus1 = 0
Bonus2 = 0
Bonus3 = 0
Bonus4 = 0
SwitchButton = 0	
Boniswitchvalue = 71084
PRESSWISH0 = 0
PRESSWISH1 = 0
PRESSWISH2 = 0
PRESSWISH3 = 0

class SwitchBotDialog(ui.ScriptWindow):
	Gui = []
	BoniGui = []
	
	Values = []
	Boni = []
	Count = 0
	Slot = 0
	Startmode = 0
	
	LastProcessTimeStamp = 0
	
	SlotStack = [0, 0]
	
	BonusIDListe = [["keiner", 0], ["Max. TP", 1], ["Max. MP", 2], ["Vitalität", 3], ["Intelligenz", 4], ["Stärke", 5], ["Ausweichwert", 6], ["Angriffsgeschwindigkeit", 7], ["Bewegungsgeschwindigkeit", 8], ["Zaubergeschwindigkeit", 9], ["TP-Regeneration", 10], ["MP-Regeneration", 11], ["Vergiftungschance", 12], ["Ohnmachtschance", 13], ["Verlangsamungschance", 14], ["Kritischer Treffer", 15], ["Durchbohrender Treffer", 16], ["Stark ggn Halbmenschen", 17], ["Stark ggn Tiere", 18], ["Stark ggn Orks", 19], ["Stark ggn Esoterische", 20], ["Stark ggn Untote", 21], ["Stark ggn Teufel", 22], ["TP-Absorbierung", 23], ["MP-Absorbierung", 24], ["Chance auf Manaraub", 25], ["Chance MP-Regeneration", 26], ["Nahkampf-Angriff blocken", 27], ["Pfeilangriff ausweichen", 28], ["Schwertverteidigung", 29], ["Zweihandverteidigung", 30], ["Dolchverteidigung", 31], ["Glockenverteidigung", 32], ["Fächerverteidigung", 33], ["Pfeilwiderstand", 34], ["Feuerwiderstand", 35,	"Blitzwiderstand", 36], ["Magieverteidigung", 37], ["Windverteidigung", 38], ["Nahkampftreffer reflektieren", 39], ["Fluch reflektieren", 40], ["Giftverteidigung", 41], ["Chance MP wiederherzustellen", 42], ["Exp-Bonus", 43], ["Yang-Drop", 44], ["Item-Drop", 45], ["steigernde Trankwirkung", 46], ["Chance TP wiederherzustellen", 47], ["Immun gegen Ohnmacht", 48], ["Immun gegen Verlangsamung", 49], ["Immun gegen Stürzen", 50], ["APPLY_SKILL", 51], ["Pfeilreichweite", 52], ["Angriffswert", 53], ["Verteidigungswert", 54], ["Magischer Angriffswert", 55], ["Magischer Verteidigungswert", 56], ["Max. Ausdauer", 58], ["Stark gegen Krieger", 59], ["Stark gegen Ninjas", 60], ["Stark gegen Suras", 61], ["Stark gegen Schamanen", 62], ["Stark gegen Monster", 63], ["Itemshop Angriffswert", 64], ["Itemshop Verteidigungswert", 65], ["Itemshop Exp-Bonus", 66], ["Itemshop Item-Bonus", 67], ["Itemshop Yang-Bonus", 68], ["APPLY_MAX_HP_PCT", 69], ["APPLY_MAX_SP_PCT", 70], ["Fertigkeitsschaden", 71], ["Durchschn. Schaden", 72], ["Fertigkeitsschaden Widerstand", 73], ["Durchschn. Schadenswiderstand", 74], ["iCafe EXP-Bonus", 76], ["iCafe Item-Bonus", 77], ["Abwehr ggn Krieger", 78], ["Abwehr ggn Ninjas", 79], ["Abwehr ggn Suras", 80], ["Abwehr ggn Schamanen", 81]]

	SearchBoni = []
	SearchBoniValues = [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]
	
	SwitchValue = 71084
	
	State = "Stop"
	
	def __init__(self):
		self.Gui = []
		ui.ScriptWindow.__init__(self)
		self.AddGui()
		self.LoadButtons()
		
	def __del__(self):
		self.Gui[0].Hide()
		ui.ScriptWindow.__del__(self)

		##
	def LoadButtons(self):
		self.RefreshInvListButton = ui.Button()
		self.RefreshInvListButton.SetParent(self)
		self.RefreshInvListButton.SetPosition(120, 305)
		self.RefreshInvListButton.SetUpVisual("d:/ymir work/ui/public/Large_Button_01.sub")
		self.RefreshInvListButton.SetOverVisual("d:/ymir work/ui/public/Large_Button_02.sub")
		self.RefreshInvListButton.SetDownVisual("d:/ymir work/ui/public/Large_Button_03.sub")
		self.RefreshInvListButton.SetEvent(ui.__mem_func__(self.UpdateFileList))
		self.RefreshInvListButton.SetText("Refresh")
		self.RefreshInvListButton.Show()
##
		
	def AddGui(self):
		Gui = [
			[[ui.ThinBoard, ""], [533, 353], [0,0], [["SetCenterPosition", [""]]], ["movable", "float"]],			
			[[ui.Button, 0], [0, 0], [493, 18], [['SetUpVisual', ["d:/ymir work/ui/public/close_button_01.sub"]],['SetOverVisual', ["d:/ymir work/ui/public/close_button_02.sub"]], ['SetDownVisual', ["d:/ymir work/ui/public/close_button_03.sub"]], ['SetToolTipText', ["Schließen", 0, - 23]], ['SetEvent', [lambda : self.__del__()]]], []],	
			[[ui.SlotBar, 0], [190, 255], [10, 35], [], []],			
			[[ui.ListBoxEx, 0], [0, 0], [15, 65], [["SetViewItemCount", [11]], ["SetItemStep",[20]]], []],			
			[[ui.ScrollBar, 0], [0, 0], [180, 55], [["SetScrollBarSize", [230]]], []],			
			[[ui.TextLine, 0], [0, 0], [10, 39], [["SetDefaultFontName", [""]],	["SetText", ["Slot:			Name:"]],	["SetFontColor", [0.2, 0.2, 1.0]]], []],
			[[ui.TextLine, 0], [0, 0], [210, 180], [["SetText", ["Boni"]],	["SetFontColor", [0.2, 0.2, 1.0]]], []],
			[[ui.TextLine, 0], [0, 0], [370, 180], [["SetText", ["Altern. Boni"]],	["SetFontColor", [0.2, 0.2, 1.0]]], []],
			[[ui.Line, 0], [310, 0], [210, 195], [["SetColor",[0xff777777]]], []],
			[[ui.Button, 0], [0, 0], [179, 305], [['SetUpVisual', ["d:/ymir work/ui/public/large_button_01.sub"]],['SetOverVisual', ["d:/ymir work/ui/public/large_button_02.sub"]], ['SetDownVisual', ["d:/ymir work/ui/public/large_button_03.sub"]], ["SetText", ["Start"]], ['SetEvent', [lambda : self.ChangeState("Start")]]], []],			
			[[ui.Button, 0], [0, 0], [272, 305], [['SetUpVisual', ["d:/ymir work/ui/public/large_button_01.sub"]],['SetOverVisual', ["d:/ymir work/ui/public/large_button_02.sub"]], ['SetDownVisual', ["d:/ymir work/ui/public/large_button_03.sub"]], ["SetText", ["Stop"]], ['SetEvent', [lambda : self.ChangeState("Stop")]]], []],
			# [[ui.Button, 0], [0, 0], [150, 305], [['SetUpVisual', ["d:/ymir work/ui/public/large_button_01.sub"]],['SetOverVisual', ["d:/ymir work/ui/public/large_button_02.sub"]], ['SetDownVisual', ["d:/ymir work/ui/public/large_button_03.sub"]], ["SetText", ["Refresh"]], ['SetEvent', [lambda : self.UpdateFileList()]]], []],
			[[ui.TextLine, 0], [0, 0], [210, 18], [["SetText", ["Switchbot v3.1.2 by DaRealFreak"]],	["SetFontColor", [0.8, 0.6, 0.1]]], []],
			]
			
		GuiParser(Gui, self.Gui)
		
		tmp = []
		y = 37
		texty = 200
		for i in xrange(5):
			button = [[ui.Button, 0], [0, 0], [210, y], [['SetUpVisual', ["d:/ymir work/ui/public/Large_button_01.sub"]],['SetOverVisual', ["d:/ymir work/ui/public/Large_button_02.sub"]], ['SetDownVisual', ["d:/ymir work/ui/public/Large_button_03.sub"]], ["SetText", ["Bonus " + str(i + 1)]], ['SetEvent', [lambda Index = i: self.SelectBonus(Index)]]], []]
			slotbar = [[ui.SlotBar, 0], [35, 18], [310, y], [], []]
			editline = [[ui.EditLine, 13 + i*4], [35, 17], [6, 2], [["SetMax", [4]], ["SetNumberMode", [""]], ["SetText", ["0"]]], []]
			textline = [[ui.TextLine, 0], [0, 0], [210, texty], [["SetText", ["keiner"]]], []]
			tmp.append(button)
			tmp.append(slotbar)
			tmp.append(textline)
			tmp.append(editline)
			y += 30
			texty += 20
			
		y = 37
		texty = 200
		for i in xrange(5, 10):
			button = [[ui.Button, 0], [0, 0], [370, y], [['SetUpVisual', ["d:/ymir work/ui/public/Large_button_01.sub"]],['SetOverVisual', ["d:/ymir work/ui/public/Large_button_02.sub"]], ['SetDownVisual', ["d:/ymir work/ui/public/Large_button_03.sub"]], ["SetText", ["Altern. Bonus " + str(i - 5 + 1)]], ['SetEvent', [lambda Index = i: self.SelectBonus(Index)]]], []]
			slotbar = [[ui.SlotBar, 0], [35, 18], [470, y], [], []]
			editline = [[ui.EditLine, 33 + (i-5)*4], [35, 17], [6, 2], [["SetMax", [4]], ["SetNumberMode", [""]], ["SetText", ["0"]]], []]
			textline = [[ui.TextLine, 0], [0, 0], [370, texty], [["SetText", ["keiner"]]], []]
			tmp.append(button)
			tmp.append(slotbar)
			tmp.append(editline)
			tmp.append(textline)
			y += 30
			texty += 20
			
		GuiParser(tmp, self.Gui)
		
		self.Gui[3].SetScrollBar(self.Gui[4])
#		self.Gui[7].SetFocus()
		self.UpdateFileList()
		
	def ChangeState(self, state):
		if state == "Start":
			if self.SearchBoni == []:
				chat.AppendChat(1, "Bitte trage erst Bonis ein.")
				
			ItemIndex = self.Gui[3].GetSelectedItem()
			if ItemIndex:
				pass
			else:
				chat.AppendChat(chat.CHAT_TYPE_INFO, "Kein Item ausgewählt!")
				return
			self.Slot = int(ItemIndex.GetText().split("	")[0])
			self.Startmode = 1
			
			for Slot in xrange(player.INVENTORY_PAGE_SIZE*2):
				itemVNum = player.GetItemIndex(Slot)
				if itemVNum == self.SwitchValue:
					self.SlotStack = [Slot, player.GetItemCount(Slot)]
					break
					
			self.DefineBoni()
			self.State = "Start"
			
			chat.AppendChat(1, "Switchbot wurde gestartet.")
		else:
			self.State = "Stop"
			chat.AppendChat(1, "Switchbot wurde gestoppt.")

		
	def SelectBonus(self, Index):
		self.BoniGui = []
		Gui = [
			[[ui.ThinBoard, ""], [223, 323], [0,0], [["SetCenterPosition", [""]]], ["movable", "float"]],			
			[[ui.Button, 0], [0, 0], [183, 18], [['SetUpVisual', ["d:/ymir work/ui/public/close_button_01.sub"]],['SetOverVisual', ["d:/ymir work/ui/public/close_button_02.sub"]], ['SetDownVisual', ["d:/ymir work/ui/public/close_button_03.sub"]], ['SetToolTipText', ["Schließen", 0, - 23]], ['SetEvent', [lambda : self.HideBonusList()]]], []],	
			[[ui.SlotBar, 0], [190, 227], [15, 35], [], []],			
			[[ui.ListBoxEx, 0], [0, 0], [20, 65], [], []],			
			[[ui.ScrollBar, 0], [0, 0], [185, 55], [["SetScrollBarSize", [200]]], []],			
			[[ui.TextLine, 0], [0, 0], [15, 39], [["SetDefaultFontName", [""]],	["SetText", ["ID:			Bonus:"]],	["SetFontColor", [0.2, 0.2, 1.0]]], []],
			[[ui.TextLine, 0], [0, 0], [20, 18], [["SetText", ["Bestimme Bonus " + str(Index + 1)]],	["SetFontColor", [0.8, 0.6, 0.1]]], []],
			[[ui.Button, 0], [0, 0], [20, 275], [['SetUpVisual', ["d:/ymir work/ui/public/large_button_01.sub"]],['SetOverVisual', ["d:/ymir work/ui/public/large_button_02.sub"]], ['SetDownVisual', ["d:/ymir work/ui/public/large_button_03.sub"]], ["SetText", ["Auswählen"]], ['SetEvent', [lambda index = Index: self.AddBonus(Index)]]], []],			
			[[ui.Button, 0], [0, 0], [113, 275], [['SetUpVisual', ["d:/ymir work/ui/public/large_button_01.sub"]],['SetOverVisual', ["d:/ymir work/ui/public/large_button_02.sub"]], ['SetDownVisual', ["d:/ymir work/ui/public/large_button_03.sub"]], ["SetText", ["Abbrechen"]], ['SetEvent', [lambda : self.HideBonusList()]]], []],
			]
			
		GuiParser(Gui, self.BoniGui)
		
		self.BoniGui[3].SetScrollBar(self.BoniGui[4])
		self.SetBonusList()
		
	def AddBonus(self, Index):
		ItemIndex = self.BoniGui[3].GetSelectedItem()
		if ItemIndex:
			pass
		else:
			chat.AppendChat(chat.CHAT_TYPE_INFO, "Kein Item ausgewählt!")
			return
		BonusValue = ItemIndex.GetText().split("			")
		if int(BonusValue[0]) == 0:
			try:
				if Index > 4:
					BackUp = self.SearchBoni[Index - 5]
					if BackUp[0] == 0:
						self.SearchBoni.remove(self.SearchBoni[Index - 5])
					else:
						self.SearchBoni[Index - 5] = [BackUp[0], 0]
				else:
					BackUp = self.SearchBoni[Index]
					if BackUp[1] == 0:
						self.SearchBoni.remove(self.SearchBoni[Index])
					else:
						self.SearchBoni[Index] = [0, BackUp[1]]
			except:
				pass
		else:
			if Index > 4:
				NewIndex = Index - 5
				try:
					try:
						BackUp = self.SearchBoni[NewIndex]
						self.SearchBoni.remove(self.SearchBoni[NewIndex])
					except:
						Backup = [0, 0]
					self.SearchBoni.insert(NewIndex, [BackUp[0], int(BonusValue[0])])
				except:
					self.SearchBoni.append([0, int(BonusValue[0])])
			else:
				try:
					try:
						BackUp = self.SearchBoni[Index]
						self.SearchBoni.remove(self.SearchBoni[Index])
					except:
						Backup = [0, 0]
					self.SearchBoni.insert(Index,  [int(BonusValue[0]), BackUp[1]])
				except:
					self.SearchBoni.append([int(BonusValue[0]), 0])

		self.UpdateBonusList()
		self.HideBonusList()
		
	def UpdateBonusValues(self):
		TmpValues = []
		for Index in xrange(5):
			try:
				SearchValue = int(self.Gui[15 + (Index)*4].GetText())
			except:
				SearchValue = 0
			try:
				AlternateSearchValue = int(self.Gui[34 + (Index)*4].GetText())
			except:
				AlternateSearchValue = 0
			TmpValues.append([SearchValue, AlternateSearchValue])
			
		if TmpValues != self.SearchBoniValues:
			self.SearchBoniValues = TmpValues
		
	def UpdateBonusList(self):
		tmp = {}
		for Bonus in self.BonusIDListe:
			tmp[Bonus[1]] = Bonus[0]
			
		for Index in xrange(5):
			self.Gui[14 + (Index)*4].SetText("keiner")
			self.Gui[35 + (Index)*4].SetText("keiner")			
			
		for Bonus in self.SearchBoni:
			Index = self.SearchBoni.index(Bonus)
			self.Gui[14 + (Index)*4].SetText(tmp[Bonus[0]])
			self.Gui[35 + (Index)*4].SetText(tmp[Bonus[1]])
		
	def SetBonusList(self):
		self.BoniGui[3].RemoveAllItems()
		for Bonus in self.BonusIDListe:
			self.BoniGui[3].AppendItem(Item(str(Bonus[1]) + "			" + Bonus[0]))
		
	def HideBonusList(self):
		self.BoniGui[0].Hide()
		
	def UpdateFileList(self):
		Allow = [item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR]
		self.Gui[3].RemoveAllItems()
		for i in xrange(101):
			ItemIndex = player.GetItemIndex(i)
			ItemType = item.GetItemType(item.SelectItem(ItemIndex))
			if ItemIndex != 0 and ItemType in Allow:
				item.SelectItem(ItemIndex)
				item.GetItemName(ItemIndex)
				ItemName = item.GetItemName()
				self.Gui[3].AppendItem(Item(str(i) + "	" + ItemName))

		self.UpdateBonusList()
	
	def OnUpdate(self):		
		if self.State == "Stop":
			return
			
		self.UpdateBonusValues()
		self.UpdateBoni()
		
	def ControllBoni(self, Boni, Values):
		try:
			for i in xrange(len(self.SearchBoni)):
				try:
					Index = Boni.index(self.SearchBoni[i][0])
					if Values[Index] < self.SearchBoniValues[i][0]:
						Boni.index("-1")
				except:
					Index = Boni.index(self.SearchBoni[i][1])
					if Values[Index] < self.SearchBoniValues[i][1]:
						Boni.index("-1")				
			self.State = "Stop"
			chat.AppendChat(1, "Boni Count: " + str(self.Count))
			chat.AppendChat(1, "Bonis: " + str(Boni))
			chat.AppendChat(1, "Values: " + str(Values))
		except:
			if player.GetItemCountByVnum(self.SwitchValue) <= 0:
				if shop.IsOpen():
					for EachShopSlot in xrange(shop.SHOP_SLOT_COUNT):
						ShopItemValue = shop.GetItemID(EachShopSlot)
						if ShopItemValue == int(self.SwitchValue):
							net.SendShopBuyPacket(EachShopSlot)
				else:
					chat.AppendChat(1, "Keine Switchen mehr im Inventar")
					self.State = "Stop"
					return
				
			for Slot in xrange(player.INVENTORY_PAGE_SIZE*2):
				ItemValue = player.GetItemIndex(Slot)
				if ItemValue == self.SwitchValue:
					if self.State == "Stop":
						return
					self.SlotStack = [Slot, player.GetItemCount(Slot)]
					net.SendItemUseToItemPacket(Slot, self.Slot)
					break
					
	def DefineBoni(self):
		self.Values = []
		self.Boni = []
		self.Count = 0
		for AttributeIndex in xrange(5):
			Bonus, Value = player.GetItemAttribute(self.Slot, AttributeIndex)
			if Bonus != 0:
				self.Count += 1
				self.Boni.append(Bonus)
				self.Values.append(Value)
		self.ControllBoni(self.Boni, self.Values)
	
	def UpdateBoni(self):
		if self.State == "Stop":
			return
		Values = []
		Boni = []
		Count = 0
		for AttributeIndex in xrange(self.Count):
			Bonus, Value = player.GetItemAttribute(self.Slot, AttributeIndex)
			if Bonus == 0:
				return
			Count += 1
			Values.append(Value)
			Boni.append(Bonus)
		
		if (player.GetItemCount(self.SlotStack[0]) <= 0 and (self.Boni != Boni or self.Values != Values)) or (self.Boni != Boni or self.Values != Values) or app.GetTime() >= self.LastProcessTimeStamp + 0.8:
			self.LastProcessTimeStamp = app.GetTime()
			self.Boni = Boni
			self.Values = Values
			self.ControllBoni(Boni, Values)
#			chat.AppendChat(1, "Switchvorgang erkannt")
#			chat.AppendChat(1, "Neue Boni: " + str(self.Boni))
#			chat.AppendChat(1, "Neue Values: " + str(self.Values))

class FileListDialog(ui.ThinBoard):
	def __init__(self):
		ui.ThinBoard.__init__(self)

		self.isLoaded=0
		self.selectEvent=None
		self.fileListBox=None

		self.SetCenterPosition()
		self.SetSize(170, 305)
		self.Show()
		self.AddFlag("movable")
		self.AddFlag("float")
		
	def __del__(self):
		ui.ThinBoard.__del__(self)

	def Show(self):
		if self.isLoaded==0:
			self.isLoaded=1

			self.__Load()

		ui.ThinBoard.Show(self)

	def Open(self):
		self.Show()

		self.SetCenterPosition()
		self.SetTop()
		self.UpdateFileList()

	def Close(self):
		self.Hide()

	def OnPressEscapeKey(self):
		self.Close()
		return TRUE

	def __CreateFileListBox(self):
		fileListBox = ui.ListBoxEx()
		fileListBox.SetParent(self)
		fileListBox.SetPosition(15, 50)
		fileListBox.Show()
		return fileListBox

	def __Load(self):
		self.__Load_BindObject()

		self.UpdateFileList()

	def __Load_BindObject(self):
		self.fileListBox = self.__CreateFileListBox()
		self.LoadFuckingScrollBar()
		self.LoadTextLines()
		self.fileListBox.SetScrollBar(self.ScrollBar)

		self.UpdateButton = ui.Button()
		self.UpdateButton.SetParent(self)
		self.UpdateButton.SetUpVisual("d:/ymir work/ui/public/Large_button_01.sub")
		self.UpdateButton.SetOverVisual("d:/ymir work/ui/public/Large_button_02.sub")
		self.UpdateButton.SetDownVisual("d:/ymir work/ui/public/Large_button_03.sub")
		self.UpdateButton.SetText("Aktualisieren")
		self.UpdateButton.SetPosition(150, 305)
		self.UpdateButton.SetEvent(ui.__mem_func__(self.UpdateFileList))
		self.UpdateButton.Show()
		
		# self.RefreshInvListButton = ui.Button()
		# self.RefreshInvListButton.SetParent(self)
		# self.RefreshInvListButton.SetPosition(50, 285)
		# self.RefreshInvListButton.SetUpVisual("d:/ymir work/ui/public/Large_Button_01.sub")
		# self.RefreshInvListButton.SetOverVisual("d:/ymir work/ui/public/Large_Button_02.sub")
		# self.RefreshInvListButton.SetDownVisual("d:/ymir work/ui/public/Large_Button_03.sub")
		# self.RefreshInvListButton.SetEvent(ui.__mem_func__(self.UpdateInventoryList))
		# self.RefreshInvListButton.SetText("Refresh")
		# self.RefreshInvListButton.Show()
		
		self.SelectBonus = ui.Button()
		self.SelectBonus.SetParent(self)
		self.SelectBonus.SetPosition(19, 265)
		self.SelectBonus.SetUpVisual("d:/ymir work/ui/public/Middle_Button_01.sub")
		self.SelectBonus.SetOverVisual("d:/ymir work/ui/public/Middle_Button_02.sub")
		self.SelectBonus.SetDownVisual("d:/ymir work/ui/public/Middle_Button_03.sub")
		self.SelectBonus.SetText("OK")
		self.SelectBonus.SetEvent(ui.__mem_func__(self.SetBonis))
		self.SelectBonus.Show()

		self.CancelBonus = ui.Button()
		self.CancelBonus.SetParent(self)
		self.CancelBonus.SetPosition(89, 265)
		self.CancelBonus.SetUpVisual("d:/ymir work/ui/public/Middle_Button_01.sub")
		self.CancelBonus.SetOverVisual("d:/ymir work/ui/public/Middle_Button_02.sub")
		self.CancelBonus.SetDownVisual("d:/ymir work/ui/public/Middle_Button_03.sub")
		self.CancelBonus.SetText("Abbrechen")
		self.CancelBonus.SetEvent(ui.__mem_func__(self.Close))
		self.CancelBonus.Show()

	def UpdateFileList(self):
		self.__RefreshFileList()
		for BonusType in BonusListe:
			if BonusType == "":
				self.fileListBox.AppendItem(Item("Löschen"))
			elif BonusType != "":
				self.fileListBox.AppendItem(Item(BonusType))
			# chat.AppendChat(chat.CHAT_TYPE_INFO, str(BonusIDListe[BonusType]))

	def __RefreshFileList(self):
		self.fileListBox.RemoveAllItems()
		
		
	def LoadTextLines(self):
		self.copyright = ui.TextLine()
		self.copyright.SetParent(self)
		self.copyright.SetDefaultFontName()
		self.copyright.SetPosition(50, 29)
		self.copyright.SetFeather()
		self.copyright.SetText("Bonus wählen:")
		self.copyright.SetFontColor(0.2, 0.2, 1.0)
		self.copyright.SetOutline()
		self.copyright.Show()


	def LoadFuckingScrollBar(self):
		self.ScrollBar = ui.ScrollBar()
		self.ScrollBar.SetParent(self)
		self.ScrollBar.SetPosition(140, 40)
		self.ScrollBar.SetScrollBarSize(220)
		self.ScrollBar.Show()

	def CancelGuildName(self):
		self.guildNameBoard.Close()
		self.guildNameBoard = None
		return TRUE

	def UpdateFileList(self):
		self.__RefreshFileList()
		for BonusType in BonusListe:
			if BonusType == "":
				self.fileListBox.AppendItem(Item("keiner"))
			elif BonusType != "":
				self.fileListBox.AppendItem(Item(BonusType))
			#chat.AppendChat(chat.CHAT_TYPE_INFO, str(BonusIDListe[BonusType]))		
		
	def __RefreshFileList(self):
		self.fileListBox.RemoveAllItems()
		
	def SetBonis(self):
		global Bonus0
		global Bonus1
		global Bonus2
		global Bonus3
		global Bonus4
		global PRESSWISH0
		global PRESSWISH1
		global PRESSWISH2
		global PRESSWISH3
		global PRESSWISH4
		SelectedIndex = self.fileListBox.GetSelectedItem()
		SelectedIndex = SelectedIndex.GetText()
		if str(SelectedIndex) != "keiner" and str(SelectedIndex) != "":
			if PRESSWISH0 == 1:
				chat.AppendChat(chat.CHAT_TYPE_INFO, "1.Bonus " + str(SelectedIndex))
				Bonus0 = BonusIDListe[str(SelectedIndex)]
				PRESSWISH0 = 0
			elif PRESSWISH1 == 1:
				chat.AppendChat(chat.CHAT_TYPE_INFO, "2.Bonus " + str(SelectedIndex))
				Bonus1 = int(BonusIDListe[SelectedIndex])
				PRESSWISH1 = 0
			elif PRESSWISH2 == 1:
				chat.AppendChat(chat.CHAT_TYPE_INFO, "3.Bonus " + str(SelectedIndex))
				Bonus2 = int(BonusIDListe[SelectedIndex])
				PRESSWISH2 = 0
			elif PRESSWISH3 == 1:
				chat.AppendChat(chat.CHAT_TYPE_INFO, "4.Bonus " + str(SelectedIndex))
				Bonus3 = int(BonusIDListe[SelectedIndex])
				PRESSWISH3 = 0
			elif PRESSWISH4 == 1:
				chat.AppendChat(chat.CHAT_TYPE_INFO, "5.Bonus " + str(SelectedIndex))
				Bonus4 = int(BonusIDListe[SelectedIndex])
				PRESSWISH4 = 0
				
		elif str(SelectedIndex) == "keiner" and str(SelectedIndex) != "":
			if PRESSWISH0 == 1:
				chat.AppendChat(chat.CHAT_TYPE_INFO, "1.Bonus wurde gelöscht")
				Bonus0 = 0
				PRESSWISH0 = 0
			elif PRESSWISH1 == 1:
				chat.AppendChat(chat.CHAT_TYPE_INFO, "2.Bonus wurde gelöscht")
				Bonus1 = 0
				PRESSWISH1 = 0
			elif PRESSWISH2 == 1:
				chat.AppendChat(chat.CHAT_TYPE_INFO, "3.Bonus wurde gelöscht")
				Bonus2 = 0
				PRESSWISH2 = 0
			elif PRESSWISH3 == 1:
				chat.AppendChat(chat.CHAT_TYPE_INFO, "4.Bonus wurde gelöscht")
				Bonus3 = 0
				PRESSWISH3 = 0
			elif PRESSWISH4 == 1:
				chat.AppendChat(chat.CHAT_TYPE_INFO, "5.Bonus wurde gelöscht")
				Bonus4 = 0
				PRESSWISH4 = 0	
				
		else:
			chat.AppendChat(chat.CHAT_TYPE_INFO, "Kein Bonus ausgewählt")		
		self.Close()

class WaitingDialog(ui.ScriptWindow):

	def __init__(self):
		ui.ScriptWindow.__init__(self)
		self.eventTimeOver = lambda *arg: None
		self.eventExit = lambda *arg: None

	def __del__(self):
		ui.ScriptWindow.__del__(self)

	def Open(self, waitTime):
		import time
		curTime = time.clock()
		self.endTime = curTime + waitTime

		self.Show()		

	def Close(self):
		self.Hide()

	def Destroy(self):
		self.Hide()

	def SAFE_SetTimeOverEvent(self, event):
		self.eventTimeOver = ui.__mem_func__(event)

	def SAFE_SetExitEvent(self, event):
		self.eventExit = ui.__mem_func__(event)
		
	def OnUpdate(self):
		import time
		lastTime = max(0, self.endTime - time.clock())
		if 0 == lastTime:
			self.Close()
			self.eventTimeOver()
		else:
			return
		
	def OnPressExitKey(self):
		self.Close()
		return TRUE
		
FILE_NAME_LEN = 40 

def GuiParser(guiobjects, list):
	#[Type, Parentindex],[Sizex, Sizey], [Posx, Posy], [commands], [flags]
	for object in guiobjects:
		Object = object[0][0]()
		if object[0][1] != "":
			Object.SetParent(list[object[0][1]])
		if object[1][0] + object[1][1] != 0:
			Object.SetSize(object[1][0], object[1][1])
		if object[2][0] + object[2][1] != 0:
			Object.SetPosition(object[2][0], object[2][1])
				
		for command in object[3]:
			cmd = command[0]	
			attr = getattr(Object,cmd)			
			if callable(attr):
				argument = command[1]
				lenght = len(argument)
				if lenght == 1:
					if argument[0] == "":
						attr()
					else:
						attr(argument[0])
				elif lenght == 2:
					attr(argument[0], argument[1])
				elif lenght == 3:
					attr(argument[0], argument[1], argument[2])
				elif lenght == 4:
					attr(argument[0], argument[1], argument[2], argument[3])
		for flag in object[4]:
			Object.AddFlag(str(flag))
		Object.Show()
	
		list.append(Object)

class Item(ui.ListBoxEx.Item):
	def __init__(self, fileName):
		ui.ListBoxEx.Item.__init__(self)
		self.canLoad=0
		self.text=fileName
		self.textLine=self.__CreateTextLine(fileName[:FILE_NAME_LEN])          

	def __del__(self):
		ui.ListBoxEx.Item.__del__(self)

	def GetText(self):
		return self.text

	def SetSize(self, width, height):
		ui.ListBoxEx.Item.SetSize(self, 6*len(self.textLine.GetText()) + 4, height)

	def __CreateTextLine(self, fileName):
		textLine=ui.TextLine()
		textLine.SetParent(self)
		textLine.SetPosition(0, 0)
		textLine.SetText(fileName)
		textLine.Show()
		return textLine


StartDialog = SwitchBotDialog()
StartDialog.Show()
03/31/2014 08:06 Poccix#2
Du musst den Refresh-Button auf die AddGui beziehen und nicht auf "(self)".
Also das ausgeklammerte in der AddGui verwenden.
Dort dann die Positionen anpassen.
Bei 'SetEvent' dann statt "lambda : self.UpdateFileList()" das einfügen "ui.__mem_func__(self.UpdateFileList)".
Sollte eigendlich funktionieren wenn ich richtig denke.
03/31/2014 09:37 M2Back2Roots#3
das ist jetzt der neue code mit der änderung von dir

[Only registered and activated users can see links. Click Here To Register...]
03/31/2014 11:00 .Monkey#4
Füg ihn doch manuell hinzu.
03/31/2014 20:15 M2Back2Roots#5
ja aber wie :o
04/01/2014 15:20 Poccix#6
Es sagt ja aus das es in der SlotBar kein SetText auslesen kann, es ist ja auch keiner da. Die Update Funktion will wohl anscheind aus der GUI Liste in jeder Zeile SetText lesen da er dies nicht bei SlotBar findet gibt es den Fehler. Mach bei der Slotbar mal auch einen SetText nur ohne Inhalt.