Improved Pokégear screen to work for all screen sizes

This commit is contained in:
Maruno17
2022-01-03 13:48:44 +00:00
parent aa18a59413
commit a939406e60

View File

@@ -6,6 +6,9 @@ class PokegearButton < SpriteWrapper
attr_reader :name attr_reader :name
attr_reader :selected attr_reader :selected
TEXT_BASE_COLOR = Color.new(248, 248, 248)
TEXT_SHADOW_COLOR = Color.new(40, 40, 40)
def initialize(command, x, y, viewport = nil) def initialize(command, x, y, viewport = nil)
super(viewport) super(viewport)
@image = command[0] @image = command[0]
@@ -18,7 +21,7 @@ class PokegearButton < SpriteWrapper
end end
@contents = BitmapWrapper.new(@button.width, @button.height) @contents = BitmapWrapper.new(@button.width, @button.height)
self.bitmap = @contents self.bitmap = @contents
self.x = x self.x = x - (@button.width / 2)
self.y = y self.y = y
pbSetSystemFont(self.bitmap) pbSetSystemFont(self.bitmap)
refresh refresh
@@ -42,7 +45,7 @@ class PokegearButton < SpriteWrapper
rect.y = @button.height / 2 if @selected rect.y = @button.height / 2 if @selected
self.bitmap.blt(0, 0, @button.bitmap, rect) self.bitmap.blt(0, 0, @button.bitmap, rect)
textpos = [ textpos = [
[@name, self.bitmap.width / 2, 4, 2, Color.new(248, 248, 248), Color.new(40, 40, 40)] [@name, rect.width / 2, (rect.height / 2) - 22, 2, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR]
] ]
pbDrawTextPositions(self.bitmap, textpos) pbDrawTextPositions(self.bitmap, textpos)
imagepos = [ imagepos = [
@@ -76,8 +79,9 @@ class PokemonPokegear_Scene
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg") @sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg")
end end
@commands.length.times do |i| @commands.length.times do |i|
y = 196 - (@commands.length * 24) + (i * 48) @sprites["button#{i}"] = PokegearButton.new(@commands[i], Graphics.width / 2, 0, @viewport)
@sprites["button#{i}"] = PokegearButton.new(@commands[i], 118, y, @viewport) button_height = @sprites["button#{i}"].bitmap.height / 2
@sprites["button#{i}"].y = ((Graphics.height - (@commands.length * button_height)) / 2) + (i * button_height)
end end
pbFadeInAndShow(@sprites) { pbUpdate } pbFadeInAndShow(@sprites) { pbUpdate }
end end