- 22
- Posts
- 12
- Years
- Seen Jun 30, 2024
Recently I took on a screen resizing project for my game and so far its been going pretty well. I have ran into a bit of a snag and I was hoping for some direction. I'm trying to slide the items and the quantity over to one side but so far everything I've tried has resulted in the text being moved over and cut off at the edge.
I have been working in this bit of code UI_Bag. Specifically dealing with rect:
But as the images show I haven't been entirely successful and I would love some guidance on how to get my ideal setup.
I have been working in this bit of code UI_Bag. Specifically dealing with rect:
Spoiler:
def drawItem(index,_count,rect)
textpos = []
rect = Rect.new(rect.x+16,rect.y+16,rect.width-16,rect.height)
thispocket = @bag.pockets[@pocket]
if index==self.itemCount-1
textpos.push([_INTL("CLOSE BAG"),rect.x,rect.y-2,false,self.baseColor,self.shadowColor])
else
item = (@filterlist) ? thispocket[@filterlist[@pocket][index]][0] : thispocket[index][0]
baseColor = self.baseColor
shadowColor = self.shadowColor
if @sorting && index==self.index
baseColor = Color.new(224,0,0)
shadowColor = Color.new(248,144,144)
end
textpos.push(
[@adapter.getDisplayName(item),rect.x,rect.y-2,false,baseColor,shadowColor]
)
if GameData::Item.get(item).is_important?
if @bag.pbIsRegistered?(item)
pbDrawImagePositions(self.contents,[
["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,rect.y+8,0,0,-1,24]
])
elsif pbCanRegisterItem?(item)
pbDrawImagePositions(self.contents,[
["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,rect.y+8,0,24,-1,24]
])
end
else
qty = (@filterlist) ? thispocket[@filterlist[@pocket][index]][1] : thispocket[index][1]
qtytext = _ISPRINTF("x{1: 3d}",qty)
xQty = rect.x+rect.width-self.contents.text_size(qtytext).width-16
textpos.push([qtytext,xQty,rect.y-2,false,baseColor,shadowColor])
end
end
pbDrawTextPositions(self.contents,textpos)
end
textpos = []
rect = Rect.new(rect.x+16,rect.y+16,rect.width-16,rect.height)
thispocket = @bag.pockets[@pocket]
if index==self.itemCount-1
textpos.push([_INTL("CLOSE BAG"),rect.x,rect.y-2,false,self.baseColor,self.shadowColor])
else
item = (@filterlist) ? thispocket[@filterlist[@pocket][index]][0] : thispocket[index][0]
baseColor = self.baseColor
shadowColor = self.shadowColor
if @sorting && index==self.index
baseColor = Color.new(224,0,0)
shadowColor = Color.new(248,144,144)
end
textpos.push(
[@adapter.getDisplayName(item),rect.x,rect.y-2,false,baseColor,shadowColor]
)
if GameData::Item.get(item).is_important?
if @bag.pbIsRegistered?(item)
pbDrawImagePositions(self.contents,[
["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,rect.y+8,0,0,-1,24]
])
elsif pbCanRegisterItem?(item)
pbDrawImagePositions(self.contents,[
["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,rect.y+8,0,24,-1,24]
])
end
else
qty = (@filterlist) ? thispocket[@filterlist[@pocket][index]][1] : thispocket[index][1]
qtytext = _ISPRINTF("x{1: 3d}",qty)
xQty = rect.x+rect.width-self.contents.text_size(qtytext).width-16
textpos.push([qtytext,xQty,rect.y-2,false,baseColor,shadowColor])
end
end
pbDrawTextPositions(self.contents,textpos)
end
But as the images show I haven't been entirely successful and I would love some guidance on how to get my ideal setup.