Jump to content

[Python]Easier way to configure your inventory buttons!


Guest Ezrekith
 Share

Recommended Posts

Hi folks!

i'd like to share an easier way to configure your inventory page buttons.

 

First of all you need to remove the old one so just search for the following lines and delete them:

#In class InventoryWindow(ui.ScriptWindow):

#Search for this lines and delete them:

			self.inventoryTab = []
			self.inventoryTab.append(self.GetChild("Inventory_Tab_01"))
			self.inventoryTab.append(self.GetChild("Inventory_Tab_02"))
			self.inventoryTab.append(self.GetChild("Inventory_Tab_03"))
			self.inventoryTab.append(self.GetChild("Inventory_Tab_04"))

		self.inventoryTab[0].SetEvent(lambda arg=0: self.SetInventoryPage(arg))
		self.inventoryTab[1].SetEvent(lambda arg=1: self.SetInventoryPage(arg))
		self.inventoryTab[2].SetEvent(lambda arg=2: self.SetInventoryPage(arg))
		self.inventoryTab[3].SetEvent(lambda arg=3: self.SetInventoryPage(arg))
		self.inventoryTab[0].Down()

		self.SetInventoryPage(0)
		self.inventoryTab = []

	def SetInventoryPage(self, page):
		self.inventoryTab[self.inventoryPageIndex].SetUp()
		self.inventoryPageIndex = page
		self.inventoryTab[self.inventoryPageIndex].Down()
		self.RefreshBagSlotWindow()

So basically you deleted the old inventory page navigator functions, now lets add the new one!
 

#In the InventoryWindow(ui.ScriptWindow): class 
#Search for:

def __LoadWindow(self):

#After the:

self.RefreshStatus()

#Add the following lines:

self.__MakeMeANewInventoryButtonFunctionHehe(9) #9 must be replaced by your inventory page count!
self.RefreshBagSlotWindow()

#After this you have to define the __MakePageButton function.

#Search for this:

def SetEquipmentPage(self, page):

#And add this after the definition of SetEquipmentPage:

	def __MakeMeANewInventoryButtonFunctionHehe(self, pageCount):
		self.curPageIndex = 0
		self.pageButtonList = []
		idx_page = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"] #Replace this with your inventory page count!
		idx_pos = [-30, -30, -30, -30, -30, -30, -30, -30, -30] #Replace this with your inventory page count! And position it by yourself.
		pos = -130 #Position it by yourself.
		for i in xrange(9): #Replace the 9 with your inventory page count!
			button = ui.RadioButton()
			button.SetParent(self)
			button.SetUpVisual("REPLACE THIS WITH YOUR BUTTON IMAGE!!!")
			button.SetOverVisual("REPLACE THIS WITH YOUR BUTTON IMAGE!!!")
			button.SetDownVisual("REPLACE THIS WITH YOUR BUTTON IMAGE!!!")
			button.SetWindowHorizontalAlignCenter()
			button.SetWindowVerticalAlignCenter()
			if i < 9: #Replace the 9 with your inventory page count!
				button.SetPosition(pos, idx_pos[i])
				pos += 32
	
			button.SetText(idx_page[i])
			button.SetEvent(lambda arg=i: self.SelectPage(arg))
			button.Show()
			self.pageButtonList.append(button)
	
		self.pageButtonList[0].Down()
        
	def SelectPage(self, index):

		self.inventoryPageIndex = index

		for btn in self.pageButtonList:
			btn.SetUp()

		self.pageButtonList[index].Down()
		self.RefreshBagSlotWindow()

 

Now search for your inventory.py in locale or uiscript whatever you use and delete the old buttons.

And thats it!

Since my design is so much different than any other design please DO NOT FORGET to replace the button visuals with yours and the positions of the button!

Good luck with that!

Edited by Ezrekith
Link to comment
Share on other sites

Oh sorry i missed this part:

Add this under the  __MakeMeANewInventoryButtonFunctionHehe definition.

	def SelectPage(self, index):

		self.inventoryPageIndex = index

		for btn in self.pageButtonList:
			btn.SetUp()

		self.pageButtonList[index].Down()
		self.RefreshBagSlotWindow()

Topic edited, thank you and sorry!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...