Need some help with aligning custom shop window properly. Using 640 x 480 resolution.
Screenshot of how the script looks currently:
Example of how I would like it to look (withouth few of the windows that are not present in custom shop):
Here's the code:
Screenshot of how the script looks currently:
module Config_Triple_Triad
# Opacity of windows, if you wish to show a background image
Window_Shop_Opacity = 255
# Shop background, put "" if no image
Shop_background = ""
end
#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
# Esta classe executa o processamento da tela de loja.
#==============================================================================
class Shop_Triple_Triad < Scene_MenuBase
include Config_Triple_Triad
#--------------------------------------------------------------------------
# * Inicialização do processo
#--------------------------------------------------------------------------
def start
super
create_gold_window
create_command_window
create_buy_window
create_background_image
@old_index = 0
end
#--------------------------------------------------------------------------
# * Criação da imagem de fundo
#--------------------------------------------------------------------------
def create_background_image
@back_image = Sprite.new
@back_image.bitmap = Cache.triple_triad(Shop_background)
@back_image.z = 150
end
#--------------------------------------------------------------------------
# * Criação das janelas
#--------------------------------------------------------------------------
def create_buy_window
@buy_window = Window_Card_BuyList.new($triad_shop, @command_window.height)
@desc_window = Window_Card_Description_S.new($game_timer.total_cards, @command_window.height)
@sell_window = Window_Card_SellList.new($game_timer.total_cards, @command_window.height)
h = (Graphics.height - (@buy_window.height + @command_window.height))/2
@dummy_window = Window_Base.new(0, h + @command_window.height, 200, Graphics.height/2 - @command_window.height)
@desc_window.opacity = Window_Shop_Opacity
@gold_window.opacity = Window_Shop_Opacity
@dummy_window.opacity = Window_Shop_Opacity
@command_window.opacity = Window_Shop_Opacity
@sell_window.opacity = 0
@buy_window.opacity = 0
@buy_window.active = false
@sell_window.active = false
@buy_window.contents_opacity = 0
@sell_window.contents_opacity = 0
@buy_window.y = h + @command_window.height
@sell_window.y = h + @command_window.height
@desc_window.y = h + @command_window.height
@gold_window.y = h
@command_window.y = h
@buy_window.z = 200
@sell_window.z = 200
end
#--------------------------------------------------------------------------
# * Atualização da cena
#--------------------------------------------------------------------------
def update
super
if @buy_window.active
if @old_index != @buy_window.index
@old_index = @buy_window.index
@desc_window.refresh($triad_shop[@old_index], true)
end
if Input.trigger?🙂 😎
@buy_window.contents_opacity = 0
@buy_window.active = false
@command_window.active = true
end
if Input.trigger?🙂C)
if $game_party.gold >= Card[$triad_shop[@old_index]]['Price']*2
Sound.play_ok
$game_timer.total_cards[$triad_shop[@old_index]] += 1
$game_party.gain_gold(-Card[$triad_shop[@old_index]]['Price']*2)
@desc_window.refresh($triad_shop[@old_index], true)
@gold_window.refresh
else
Sound.play_buzzer
end
end
end
if @sell_window.active
if @old_index != @sell_window.index
@old_index = @sell_window.index
@desc_window.refresh(@sell_window.array_cards[@old_index])
end
if Input.trigger?🙂 😎
@sell_window.contents_opacity = 0
@sell_window.active = false
@command_window.active = true
end
if Input.trigger?🙂C)
if $game_timer.total_cards[@sell_window.array_cards[@old_index]] > 0 && Card[@sell_window.array_cards[@old_index]]['Price'] != 0
Sound.play_ok
$game_timer.total_cards[@sell_window.array_cards[@old_index]] -= 1
$game_party.gain_gold(Card[@sell_window.array_cards[@old_index]]['Price'])
@desc_window.refresh(@sell_window.array_cards[@old_index])
@gold_window.refresh
else
Sound.play_buzzer
end
end
end
end
#--------------------------------------------------------------------------
# * Criação da janela de dinheiro
#--------------------------------------------------------------------------
def create_gold_window
@gold_window = Window_Gold.new
@gold_window.viewport = @viewport
@gold_window.x = Graphics.width - @gold_window.width
@gold_window.y = 0
end
#--------------------------------------------------------------------------
# * Criação da janela de comando
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_ShopCommand.new(@gold_window.x, @purchase_only)
@command_window.viewport = @viewport
@command_window.y = 0
@command_window.set_handler🙂buy, method🙂command_buy))
@command_window.set_handler🙂sell, method🙂command_sell))
@command_window.set_handler🙂cancel, method🙂return_scene))
end
#--------------------------------------------------------------------------
# * Comando [Comprar]
#--------------------------------------------------------------------------
def command_buy
if $triad_shop == []
Sound.play_buzzer
@command_window.active = true
return
else
@sell_window.contents_opacity = 0
@buy_window.contents_opacity = 255
@buy_window.active = true
@command_window.active = false
end
end
#--------------------------------------------------------------------------
# * Comando [Vender]
#--------------------------------------------------------------------------
def command_sell
@sell_window.dispose
@sell_window = Window_Card_SellList.new($game_timer.total_cards, @command_window.height)
h = (Graphics.height - (@buy_window.height + @command_window.height))/2
@sell_window.y = h + @command_window.height
@desc_window.refresh(@sell_window.array_cards[@old_index])
@sell_window.opacity = 0
@sell_window.z = 200
if $game_timer.total_cards.dup.sum == 0
Sound.play_buzzer
@command_window.active = true
@sell_window.active = false
return
else
@sell_window.contents_opacity = 255
@sell_window.active = true
@command_window.active = false
end
end
#--------------------------------------------------------------------------
# * Dispose de images, janelas e retorna a cena
#--------------------------------------------------------------------------
def return_scene
@back_image.bitmap.dispose
@back_image.dispose
super
end
end
#==============================================================================
# ** Window_ItemCategory
#------------------------------------------------------------------------------
# Esta janela é usada para selecionar o tipo de item e equipamentos para
# tela de itens ou lojas.
#==============================================================================
class Window_Card_BuyList < Window_Command
include Config_Triple_Triad
#--------------------------------------------------------------------------
# * Variáveis públicas
#--------------------------------------------------------------------------
attr_reader :item_window
#--------------------------------------------------------------------------
# * Inicialização do objeto
#--------------------------------------------------------------------------
def initialize(number, heigh)
@heigh = heigh
@card_number = number
super(0, heigh)
end
#--------------------------------------------------------------------------
# * Aquisição da largura da janela
#--------------------------------------------------------------------------
def window_width
200
end
def window_height
Graphics.height/2 - @heigh
end
#--------------------------------------------------------------------------
# * Definição de resultado ao pressionar o botão de confirmação
#--------------------------------------------------------------------------
def process_ok
if current_item_enabled?
Input.update
deactivate
call_ok_handler
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# * Definição de controle de confirmação e cancelamento
#--------------------------------------------------------------------------
def process_handling
return unless open? && active
return process_cancel if cancel_enabled? && Input.trigger?🙂 😎
return process_pagedown if handle?🙂pagedown) && Input.trigger?🙂R)
return process_pageup if handle?🙂pageup) && Input.trigger?🙂L)
end
#--------------------------------------------------------------------------
# * Aquisição do número de colunas
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# * Atualização da tela
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# * Criação da lista de comandos
#--------------------------------------------------------------------------
def make_command_list
for i in 0...@card_number.length
command = Card[@card_number]['Name']
add_command(command, nil)
end
end
end
#==============================================================================
# ** Window_ItemCategory
#------------------------------------------------------------------------------
# Esta janela é usada para selecionar o tipo de item e equipamentos para
# tela de itens ou lojas.
#==============================================================================
class Window_Card_SellList < Window_Command
include Config_Triple_Triad
#--------------------------------------------------------------------------
# * Variáveis públicas
#--------------------------------------------------------------------------
attr_reader :item_window
attr_accessor :array_cards
#--------------------------------------------------------------------------
# * Inicialização do objeto
#--------------------------------------------------------------------------
def initialize(number, heigh)
@heigh = heigh
@card_number = number
@array_cards = []
super(0, heigh)
end
#--------------------------------------------------------------------------
# * Aquisição da largura da janela
#--------------------------------------------------------------------------
def window_width
200
end
def window_height
Graphics.height/2 - @heigh
end
#--------------------------------------------------------------------------
# * Definição de resultado ao pressionar o botão de confirmação
#--------------------------------------------------------------------------
def process_ok
if current_item_enabled?
Input.update
deactivate
call_ok_handler
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# * Definição de controle de confirmação e cancelamento
#--------------------------------------------------------------------------
def process_handling
return unless open? && active
return process_cancel if cancel_enabled? && Input.trigger?🙂 😎
return process_pagedown if handle?🙂pagedown) && Input.trigger?🙂R)
return process_pageup if handle?🙂pageup) && Input.trigger?🙂L)
end
#--------------------------------------------------------------------------
# * Aquisição do número de colunas
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# * Atualização da tela
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# * Criação da lista de comandos
#--------------------------------------------------------------------------
def make_command_list
for i in 0...@card_number.length
if @card_number != 0
command = Card['Name']
add_command(command, nil)
@array_cards.push(i)
end
end
end
end
#==============================================================================
# ** Window_ItemCategory
#------------------------------------------------------------------------------
# Esta janela é usada para selecionar o tipo de item e equipamentos para
# tela de itens ou lojas.
#==============================================================================
class Window_Card_Description_S < Window_Base
include Config_Triple_Triad
def initialize(num, heigh)
@card_number = num
super(200, heigh, window_width, Graphics.height/2 - heigh)
refresh($triad_shop[0], true) unless @card_number.empty?
end
def refresh(index, b=false)
contents.clear
return if index == nil
contents.font.size = Text_size
contents.font.name = Text_font
bitmap = Cache.triple_triad(Card[index]['Image1'])
rect = Rect.new(0, 0, bitmap.width, bitmap.height)
contents.blt(0, 0, bitmap, rect, 255)
draw_text(Text_album_x, 0, window_width - Text_album_x, fitting_height(1), Card[index]['Name'], 1)
draw_text(Text_album_x, fitting_height(0), window_width - Text_album_x, fitting_height(1), Album_Text[0] + $game_timer.total_cards[index].to_s, 1)
draw_text(Text_album_x, fitting_height(1), window_width - Text_album_x, fitting_height(1), Album_Text[1] + Card[index]['Rarity'].to_s, 1)
sum = Card[index]['UP'] + Card[index]['RIGHT'] + Card[index]['LEFT'] + Card[index]['DOWN']
draw_text(Text_album_x, fitting_height(2), window_width - Text_album_x, fitting_height(1), Album_Text[2] + sum.to_s, 1)
price = Card[index]['Price']
price *= 2 if b
draw_text(Text_album_x, fitting_height(3), window_width - Text_album_x, fitting_height(1), Album_Text[4] + price.to_s, 1)
reset_font_settings
end
#--------------------------------------------------------------------------
# * Aquisição da largura da janela
#--------------------------------------------------------------------------
def window_width
return Graphics.width - 200
end
#--------------------------------------------------------------------------
# * Aquisição da altura da janela
#--------------------------------------------------------------------------
def window_height
fitting_height(visible_line_number)
end
end
#==============================================================================
# ** Arrays
#------------------------------------------------------------------------------
# Novo método para somar os valores dentro da array
#==============================================================================
class Array
def sum
a = 0
for n in 0...size
a += self[n]
end
return a
end
end
# Opacity of windows, if you wish to show a background image
Window_Shop_Opacity = 255
# Shop background, put "" if no image
Shop_background = ""
end
#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
# Esta classe executa o processamento da tela de loja.
#==============================================================================
class Shop_Triple_Triad < Scene_MenuBase
include Config_Triple_Triad
#--------------------------------------------------------------------------
# * Inicialização do processo
#--------------------------------------------------------------------------
def start
super
create_gold_window
create_command_window
create_buy_window
create_background_image
@old_index = 0
end
#--------------------------------------------------------------------------
# * Criação da imagem de fundo
#--------------------------------------------------------------------------
def create_background_image
@back_image = Sprite.new
@back_image.bitmap = Cache.triple_triad(Shop_background)
@back_image.z = 150
end
#--------------------------------------------------------------------------
# * Criação das janelas
#--------------------------------------------------------------------------
def create_buy_window
@buy_window = Window_Card_BuyList.new($triad_shop, @command_window.height)
@desc_window = Window_Card_Description_S.new($game_timer.total_cards, @command_window.height)
@sell_window = Window_Card_SellList.new($game_timer.total_cards, @command_window.height)
h = (Graphics.height - (@buy_window.height + @command_window.height))/2
@dummy_window = Window_Base.new(0, h + @command_window.height, 200, Graphics.height/2 - @command_window.height)
@desc_window.opacity = Window_Shop_Opacity
@gold_window.opacity = Window_Shop_Opacity
@dummy_window.opacity = Window_Shop_Opacity
@command_window.opacity = Window_Shop_Opacity
@sell_window.opacity = 0
@buy_window.opacity = 0
@buy_window.active = false
@sell_window.active = false
@buy_window.contents_opacity = 0
@sell_window.contents_opacity = 0
@buy_window.y = h + @command_window.height
@sell_window.y = h + @command_window.height
@desc_window.y = h + @command_window.height
@gold_window.y = h
@command_window.y = h
@buy_window.z = 200
@sell_window.z = 200
end
#--------------------------------------------------------------------------
# * Atualização da cena
#--------------------------------------------------------------------------
def update
super
if @buy_window.active
if @old_index != @buy_window.index
@old_index = @buy_window.index
@desc_window.refresh($triad_shop[@old_index], true)
end
if Input.trigger?🙂 😎
@buy_window.contents_opacity = 0
@buy_window.active = false
@command_window.active = true
end
if Input.trigger?🙂C)
if $game_party.gold >= Card[$triad_shop[@old_index]]['Price']*2
Sound.play_ok
$game_timer.total_cards[$triad_shop[@old_index]] += 1
$game_party.gain_gold(-Card[$triad_shop[@old_index]]['Price']*2)
@desc_window.refresh($triad_shop[@old_index], true)
@gold_window.refresh
else
Sound.play_buzzer
end
end
end
if @sell_window.active
if @old_index != @sell_window.index
@old_index = @sell_window.index
@desc_window.refresh(@sell_window.array_cards[@old_index])
end
if Input.trigger?🙂 😎
@sell_window.contents_opacity = 0
@sell_window.active = false
@command_window.active = true
end
if Input.trigger?🙂C)
if $game_timer.total_cards[@sell_window.array_cards[@old_index]] > 0 && Card[@sell_window.array_cards[@old_index]]['Price'] != 0
Sound.play_ok
$game_timer.total_cards[@sell_window.array_cards[@old_index]] -= 1
$game_party.gain_gold(Card[@sell_window.array_cards[@old_index]]['Price'])
@desc_window.refresh(@sell_window.array_cards[@old_index])
@gold_window.refresh
else
Sound.play_buzzer
end
end
end
end
#--------------------------------------------------------------------------
# * Criação da janela de dinheiro
#--------------------------------------------------------------------------
def create_gold_window
@gold_window = Window_Gold.new
@gold_window.viewport = @viewport
@gold_window.x = Graphics.width - @gold_window.width
@gold_window.y = 0
end
#--------------------------------------------------------------------------
# * Criação da janela de comando
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_ShopCommand.new(@gold_window.x, @purchase_only)
@command_window.viewport = @viewport
@command_window.y = 0
@command_window.set_handler🙂buy, method🙂command_buy))
@command_window.set_handler🙂sell, method🙂command_sell))
@command_window.set_handler🙂cancel, method🙂return_scene))
end
#--------------------------------------------------------------------------
# * Comando [Comprar]
#--------------------------------------------------------------------------
def command_buy
if $triad_shop == []
Sound.play_buzzer
@command_window.active = true
return
else
@sell_window.contents_opacity = 0
@buy_window.contents_opacity = 255
@buy_window.active = true
@command_window.active = false
end
end
#--------------------------------------------------------------------------
# * Comando [Vender]
#--------------------------------------------------------------------------
def command_sell
@sell_window.dispose
@sell_window = Window_Card_SellList.new($game_timer.total_cards, @command_window.height)
h = (Graphics.height - (@buy_window.height + @command_window.height))/2
@sell_window.y = h + @command_window.height
@desc_window.refresh(@sell_window.array_cards[@old_index])
@sell_window.opacity = 0
@sell_window.z = 200
if $game_timer.total_cards.dup.sum == 0
Sound.play_buzzer
@command_window.active = true
@sell_window.active = false
return
else
@sell_window.contents_opacity = 255
@sell_window.active = true
@command_window.active = false
end
end
#--------------------------------------------------------------------------
# * Dispose de images, janelas e retorna a cena
#--------------------------------------------------------------------------
def return_scene
@back_image.bitmap.dispose
@back_image.dispose
super
end
end
#==============================================================================
# ** Window_ItemCategory
#------------------------------------------------------------------------------
# Esta janela é usada para selecionar o tipo de item e equipamentos para
# tela de itens ou lojas.
#==============================================================================
class Window_Card_BuyList < Window_Command
include Config_Triple_Triad
#--------------------------------------------------------------------------
# * Variáveis públicas
#--------------------------------------------------------------------------
attr_reader :item_window
#--------------------------------------------------------------------------
# * Inicialização do objeto
#--------------------------------------------------------------------------
def initialize(number, heigh)
@heigh = heigh
@card_number = number
super(0, heigh)
end
#--------------------------------------------------------------------------
# * Aquisição da largura da janela
#--------------------------------------------------------------------------
def window_width
200
end
def window_height
Graphics.height/2 - @heigh
end
#--------------------------------------------------------------------------
# * Definição de resultado ao pressionar o botão de confirmação
#--------------------------------------------------------------------------
def process_ok
if current_item_enabled?
Input.update
deactivate
call_ok_handler
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# * Definição de controle de confirmação e cancelamento
#--------------------------------------------------------------------------
def process_handling
return unless open? && active
return process_cancel if cancel_enabled? && Input.trigger?🙂 😎
return process_pagedown if handle?🙂pagedown) && Input.trigger?🙂R)
return process_pageup if handle?🙂pageup) && Input.trigger?🙂L)
end
#--------------------------------------------------------------------------
# * Aquisição do número de colunas
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# * Atualização da tela
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# * Criação da lista de comandos
#--------------------------------------------------------------------------
def make_command_list
for i in 0...@card_number.length
command = Card[@card_number]['Name']
add_command(command, nil)
end
end
end
#==============================================================================
# ** Window_ItemCategory
#------------------------------------------------------------------------------
# Esta janela é usada para selecionar o tipo de item e equipamentos para
# tela de itens ou lojas.
#==============================================================================
class Window_Card_SellList < Window_Command
include Config_Triple_Triad
#--------------------------------------------------------------------------
# * Variáveis públicas
#--------------------------------------------------------------------------
attr_reader :item_window
attr_accessor :array_cards
#--------------------------------------------------------------------------
# * Inicialização do objeto
#--------------------------------------------------------------------------
def initialize(number, heigh)
@heigh = heigh
@card_number = number
@array_cards = []
super(0, heigh)
end
#--------------------------------------------------------------------------
# * Aquisição da largura da janela
#--------------------------------------------------------------------------
def window_width
200
end
def window_height
Graphics.height/2 - @heigh
end
#--------------------------------------------------------------------------
# * Definição de resultado ao pressionar o botão de confirmação
#--------------------------------------------------------------------------
def process_ok
if current_item_enabled?
Input.update
deactivate
call_ok_handler
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# * Definição de controle de confirmação e cancelamento
#--------------------------------------------------------------------------
def process_handling
return unless open? && active
return process_cancel if cancel_enabled? && Input.trigger?🙂 😎
return process_pagedown if handle?🙂pagedown) && Input.trigger?🙂R)
return process_pageup if handle?🙂pageup) && Input.trigger?🙂L)
end
#--------------------------------------------------------------------------
# * Aquisição do número de colunas
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# * Atualização da tela
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# * Criação da lista de comandos
#--------------------------------------------------------------------------
def make_command_list
for i in 0...@card_number.length
if @card_number != 0
command = Card['Name']
add_command(command, nil)
@array_cards.push(i)
end
end
end
end
#==============================================================================
# ** Window_ItemCategory
#------------------------------------------------------------------------------
# Esta janela é usada para selecionar o tipo de item e equipamentos para
# tela de itens ou lojas.
#==============================================================================
class Window_Card_Description_S < Window_Base
include Config_Triple_Triad
def initialize(num, heigh)
@card_number = num
super(200, heigh, window_width, Graphics.height/2 - heigh)
refresh($triad_shop[0], true) unless @card_number.empty?
end
def refresh(index, b=false)
contents.clear
return if index == nil
contents.font.size = Text_size
contents.font.name = Text_font
bitmap = Cache.triple_triad(Card[index]['Image1'])
rect = Rect.new(0, 0, bitmap.width, bitmap.height)
contents.blt(0, 0, bitmap, rect, 255)
draw_text(Text_album_x, 0, window_width - Text_album_x, fitting_height(1), Card[index]['Name'], 1)
draw_text(Text_album_x, fitting_height(0), window_width - Text_album_x, fitting_height(1), Album_Text[0] + $game_timer.total_cards[index].to_s, 1)
draw_text(Text_album_x, fitting_height(1), window_width - Text_album_x, fitting_height(1), Album_Text[1] + Card[index]['Rarity'].to_s, 1)
sum = Card[index]['UP'] + Card[index]['RIGHT'] + Card[index]['LEFT'] + Card[index]['DOWN']
draw_text(Text_album_x, fitting_height(2), window_width - Text_album_x, fitting_height(1), Album_Text[2] + sum.to_s, 1)
price = Card[index]['Price']
price *= 2 if b
draw_text(Text_album_x, fitting_height(3), window_width - Text_album_x, fitting_height(1), Album_Text[4] + price.to_s, 1)
reset_font_settings
end
#--------------------------------------------------------------------------
# * Aquisição da largura da janela
#--------------------------------------------------------------------------
def window_width
return Graphics.width - 200
end
#--------------------------------------------------------------------------
# * Aquisição da altura da janela
#--------------------------------------------------------------------------
def window_height
fitting_height(visible_line_number)
end
end
#==============================================================================
# ** Arrays
#------------------------------------------------------------------------------
# Novo método para somar os valores dentro da array
#==============================================================================
class Array
def sum
a = 0
for n in 0...size
a += self[n]
end
return a
end
end