Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Poprawa kodu Python


Rekomendowane odpowiedzi

Opublikowano

@Edit problem rozwiązany

 

Witam, jako iż nienawidzę pythona (może po prostu nie mogę go strawić) chciałbym abyście pomogli mi jak w tym kodzie edytować coś, aby ten suwak był równy z całym oknem, próbuje na wszystkie sposoby ale nic mi nie wychodzi.

 

76654195170119991488.jpg

 

 

 

import ui
import dbg
import app
import uiToolTip
import chat

global MAP_LIST
global MOB_LIST

MAP_LIST = {

#	NR : ["NAME", MOB1, MOB2...]

	0 : ["Miasto Pierwsze", 0,1,2,3,4],
	1 : ["Miasto Drugie", 4,5,6],
	2 : ["Dolina Orków", 2],
	3 : ["Pustynia Yongbi", 6,7,8],
	4 : ["Świątynia Hwang", 6,7,8],
	5 : ["Góra Sohan", 6,7,8],
	6 : ["Piekło", 6,7,8],
	7 : ["Las Duchów", 6,7,8],
	8 : ["Czerw. Las Duchów", 6,7,8],
	9 : ["Grota Wygnańców I", 6,7,8],
	10 : ["Grota Wygnańców II", 6,7,8],
	11 : ["Mapa 90", 6,7,8],
	12 : ["Mapa 95", 6,7,8],
	13 : ["Mapa 100", 6,7,8],
}
	
MOB_LIST = { 

#	NR : ["NAME", [ITEM1, SLOT1], [ITEM2, SLOT2]...]

	0 : ["Metin Cierpienia [Poz. 5]", [170000, 0]], 
	1 : ["Metin Walki [Poz. 10]", [170000, 0]],
	2 : ["Metin Bitwy [Poz. 15]", [170000, 0], [71084, 1], [71085, 2]],
	3 : ["Metin Chciwości [Poz. 20]", [170000, 0], [71084, 1], [71085, 2]],
	4 : ["Metin Czerni [Poz. 25]", [170000, 0], [170001, 1], [71084, 2], [71085, 3], [27102, 4], [27105, 5]],
	5 : ["Metin Ciemności [Poz. 30]", [170000, 0], [170001, 1], [171001, 2], [71084, 3], [71085, 4], [27102, 5], [27105, 6]],
	6 : ["Metin Zazdrości [Poz. 35]", [170000, 0], [170001, 1], [171001, 2], [71084, 3], [71085, 4], [27102, 5], [27105, 6], [50513, 7], [71001, 8], [71094, 9]],
	7 : ["Metin Duszy [Poz. 40]", [170000, 0], [170001, 1], [171003, 2], [71084, 3], [71085, 4], [27102, 5], [27105, 6], [50513, 7], [71001, 8], [71094, 9]],
	8 : ["Metin Cienia [Poz. 45]", [170000, 0], [170001, 1], [71084, 2], [71085, 3], [27102, 4], [27105, 5], [50513, 6], [71001, 7], [71094, 8]],
	9 : ["Metin Twardości [Poz. 50]", [26, 0], [27, 1]],
	10 : ["Metin Diabła [Poz. 55]", [26, 0], [27, 1]],
	11 : ["Metin Upadku [Poz. 60]", [26, 0], [27, 1]],
	12 : ["Metin Śmierci [Poz. 65]", [26, 0], [27, 1]],
	13 : ["Metin Morderstwa [Poz. 70]", [26, 0], [27, 1]],
	14 : ["Metin Pung-Ma [Poz. 75]", [26, 0], [27, 1]],
	15 : ["Metin Ma-An [Poz. 80]", [26, 0], [27, 1]],
	16 : ["Metin Tu-Young [Poz. 85]", [26, 0], [27, 1]],
	17 : ["Metin Jeon-Un [Poz. 90]", [26, 0], [27, 1]],
	18 : ["Metin Pung-Ma [Poz. 5]", [26, 0], [27, 1]],
	
	
}

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

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

	def GetText(self):
		return self.textLine.GetText()

	def SetSize(self, width, height):
		ui.ListBoxEx.Item.SetSize(self, 115, height)

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

		textLine.SetText(fileName)
		textLine.Show()
		return textLine

class wikipedia(ui.Window):
	def __init__(self):
		ui.Window.__init__(self)
		self.BuildWindow()

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

	def BuildWindow(self):
		self.Board = ui.BoardWithTitleBar()
		self.Board.SetSize(650, 250)
		self.Board.SetCenterPosition()
		self.Board.AddFlag('movable')
		self.Board.AddFlag('float')
		self.Board.SetTitleName('Wikipedia Dropu')
		self.Board.SetCloseEvent(self.Close)
		self.OnPressEscapeKey = self.Close()
		
		self.comp = Component()
		
		self.tooltipItem = uiToolTip.ItemToolTip()
		self.tooltipItem.Hide()
		
		self.slots = {}

		self.bar_maps, self.list_maps = self.comp.ListBoxEx(self.Board, 16, 34, 170, 255)
		self.bar_mobs, self.list_mobs = self.comp.ListBoxEx(self.Board, 200, 34, 170, 255)
		self.Slots = ui.GridSlotWindow()
		self.Slots.SetParent(self.Board)
		self.Slots.SetSize(160, 160)
		self.Slots.SetPosition(400, 40)
		self.Slots.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
		self.Slots.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
		self.Slots.ArrangeSlot(0, 7, 6, 32, 32, 0, 0)
		self.Slots.RefreshSlot()
		self.Slots.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0)
		self.Slots.Show()
		
		global MAP_LIST
		global MOB_LIST
		
		self.list_maps.RemoveAllItems()
		[self.list_maps.AppendItem(ItemListBox(str(MAP_LIST[i][0]))) for i in range(len(MAP_LIST))]
		self.list_maps.SelectIndex(0)
		self.list_maps.SetSelectEvent(self.SelectMap)
		self.SelectMap(0)
		self.list_mobs.SetSelectEvent(self.SelectMob)
		
	def SelectMap(self, index):
		self.indexMap = self.list_maps.GetItemIndex(self.list_maps.GetSelectedItem())
		self.list_mobs.RemoveAllItems()
		self.new_mobs = []
		for i in range(1, len(MAP_LIST[self.indexMap])):
			self.new_mobs.append(MAP_LIST[self.indexMap][i])
		for x in xrange(len(self.new_mobs)):
			self.list_mobs.AppendItem(ItemListBox(str(MOB_LIST[self.new_mobs[x]][0])))
		self.list_mobs.SelectIndex(0)
		self.SelectMob(0)

	def SelectMob(self, index):
		for i in xrange(49):
			self.Slots.SetItemSlot(i, 0)
			self.Slots.RefreshSlot()
		self.indexMob = self.list_mobs.GetItemIndex(self.list_mobs.GetSelectedItem())
		self.items_id = []
		self.slots_nr = []
		for i in range(1, len(MOB_LIST[MAP_LIST[self.indexMap][self.indexMob+1]])):
			self.items_id.append(MOB_LIST[MAP_LIST[self.indexMap][self.indexMob+1]][i][0])
			self.slots_nr.append(MOB_LIST[MAP_LIST[self.indexMap][self.indexMob+1]][i][1])
		for x in xrange(len(self.items_id)):
			self.Slots.SetItemSlot(self.slots_nr[x], self.items_id[x])
			self.slots[self.slots_nr[x]] = self.items_id[x]
		
	def OverInItem(self, slot):
		self.tooltipItem.SetItemToolTip(self.slots[slot])
		
	def OverOutItem(self):
		if self.tooltipItem:
			self.tooltipItem.HideToolTip()

	def Open(self):
		if self.Board.IsShow():
			self.Board.Hide()
		else:
			self.Board.Show()
	
	def Close(self):
		self.Board.Hide()

	def OnPressEscapeKey(self):
		if self.Board.IsShow():
			self.Close()
			return TRUE
		return FALSE

class Component:
	def Button(self, parent, buttonName, tooltipText, x, y, func, UpVisual, OverVisual, DownVisual):
		button = ui.Button()
		if parent != None:
			button.SetParent(parent)
		button.SetPosition(x, y)
		button.SetUpVisual(UpVisual)
		button.SetOverVisual(OverVisual)
		button.SetDownVisual(DownVisual)
		button.SetText(buttonName)
		button.SetToolTipText(tooltipText)
		button.Show()
		button.SetEvent(func)
		return button

	def ToggleButton(self, parent, buttonName, tooltipText, x, y, funcUp, funcDown, UpVisual, OverVisual, DownVisual):
		button = ui.ToggleButton()
		if parent != None:
			button.SetParent(parent)
		button.SetPosition(x, y)
		button.SetUpVisual(UpVisual)
		button.SetOverVisual(OverVisual)
		button.SetDownVisual(DownVisual)
		button.SetText(buttonName)
		button.SetToolTipText(tooltipText)
		button.Show()
		button.SetToggleUpEvent(funcUp)
		button.SetToggleDownEvent(funcDown)
		return button

	def EditLine(self, parent, editlineText, x, y, width, heigh, max):
		SlotBar = ui.SlotBar()
		if parent != None:
			SlotBar.SetParent(parent)
		SlotBar.SetSize(width, heigh)
		SlotBar.SetPosition(x, y)
		SlotBar.Show()
		Value = ui.EditLine()
		Value.SetParent(SlotBar)
		Value.SetSize(width, heigh)
		Value.SetPosition(1, 1)
		Value.SetMax(max)
		Value.SetLimitWidth(width)
		Value.SetMultiLine()
		Value.SetText(editlineText)
		Value.Show()
		return SlotBar, Value

	def TextLine(self, parent, textlineText, x, y, color):
		textline = ui.TextLine()
		if parent != None:
			textline.SetParent(parent)
		textline.SetPosition(x, y)
		if color != None:
			textline.SetFontColor(color[0], color[1], color[2])
		textline.SetText(textlineText)
		textline.Show()
		return textline

	def RGB(self, r, g, :
		return (r*255, g*255, b*255)

	def SliderBar(self, parent, sliderPos, func, x, y):
		Slider = ui.SliderBar()
		if parent != None:
			Slider.SetParent(parent)
		Slider.SetPosition(x, y)
		Slider.SetSliderPos(sliderPos / 100)
		Slider.Show()
		Slider.SetEvent(func)
		return Slider

	def ExpandedImage(self, parent, x, y, img):
		image = ui.ExpandedImageBox()
		if parent != None:
			image.SetParent(parent)
		image.SetPosition(x, y)
		image.LoadImage(img)
		image.Show()
		return image

	def ComboBox(self, parent, text, x, y, width):
		combo = ui.ComboBox()
		if parent != None:
			combo.SetParent(parent)
		combo.SetPosition(x, y)
		combo.SetSize(width, 15)
		combo.SetCurrentItem(text)
		combo.Show()
		return combo

	def ThinBoard(self, parent, moveable, x, y, width, heigh, center):
		thin = ui.ThinBoard()
		if parent != None:
			thin.SetParent(parent)
		if moveable == TRUE:
			thin.AddFlag('movable')
			thin.AddFlag('float')
		thin.SetSize(width, heigh)
		thin.SetPosition(x, y)
		if center == TRUE:
			thin.SetCenterPosition()
		thin.Show()
		return thin

	def Gauge(self, parent, width, color, x, y):
		gauge = ui.Gauge()
		if parent != None:
			gauge.SetParent(parent)
		gauge.SetPosition(x, y)
		gauge.MakeGauge(width, color)
		gauge.Show()
		return gauge

	def ListBoxEx(self, parent, x, y, width, heigh):
		bar = ui.Bar()
		if parent != None:
			bar.SetParent(parent)
		bar.SetPosition(x, y)
		bar.SetSize(width, heigh)
		bar.SetColor(0x77000000)
		bar.Show()
		ListBox=ui.ListBoxEx()
		ListBox.SetParent(bar)
		ListBox.SetPosition(0, 0)
		ListBox.SetSize(width, heigh)
		ListBox.Show()
		scroll = ui.ScrollBar()
		scroll.SetParent(ListBox)
		scroll.SetPosition(width-15, 0)
		scroll.SetScrollBarSize(heigh)
		scroll.Show()
		ListBox.SetScrollBar(scroll)
		return bar, ListBox

class Item(ui.ListBoxEx.Item):
	def __init__(self, text):
		ui.ListBoxEx.Item.__init__(self)
		self.canLoad=0
		self.text=text
		self.textLine=self.__CreateTextLine(text[:50])
	def __del__(self):
		ui.ListBoxEx.Item.__del__(self)
	def GetText(self):
		return self.text
	def SetSize(self, width, height):
		ui.ListBoxEx.Item.SetSize(self, 7*len(self.textLine.GetText()) + 4, height)
	def __CreateTextLine(self, text):
		textLine=ui.TextLine()
		textLine.SetParent(self)
		textLine.SetPosition(0, 0)
		textLine.SetText(text)
		textLine.Show()
		return textLine

wikipedia().Show()

 

 

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...