Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Cute Menu by VitorJ (http://vjrgss.blogspot.com/)
- #-Função-----------------------------------------------------------------------
- # Modifica o menu padrão por um animado e por pictures
- #-Change log-------------------------------------------------------------------
- # v1.0: Script criado.
- # v1.1: Corrigido alguns bugs, código melhorado, algumas melhorias visuais.
- #-Nome do mapa-----------------------------------------------------------------
- # O nome que aparecera na area de nome do mapa sera o nome escolhido para
- # exibição, caso não tenha um, ele ira procurar o seguinte comando na nota do
- # mapa: <mname>Nome do Mapa</mname>
- # Onde o nome do mapa deve ser posto, não é necessario estar entre aspas.
- #==============================================================================
- module VJCM
- #Os chares terão animação de movimento?
- Char_Anim = true
- #Se sim, qual o tempo de animação? (em frames)
- Char_Anim_T = 20
- #Nome da imagem de fundo
- Background = "Background"
- #Movimento [x,y] da imagem de fundo
- Back_Move = [-1,-1]
- #Grafico de fundo do char
- Char_Back = "Char_Back"
- #Tempo de movimento da caixa dos chares
- Char_Move = 10
- #Grafico da imagem que aparecera nos chares ativos
- Active = "Active"
- #Grafico do fundo da janela de informações
- Info_Back = "Info_Back"
- #Grafico de fundo da janela de sistema
- Sys_Back = "Info_Back"
- #Grafico de fundo da janela de sair
- End_Back = "End_Back"
- #Grafico de fundo do comando de char
- CCom_Back = "End_Back"
- #Imagem da seta ["Nome da Imagem",numero de frames] coloque 1 frame para não
- #animar
- Arrow = ["Arrow_Main",6]
- #Imagem da seta nas janelas de comando
- Opt_Arrow = ["Arrow_Opt",6]
- #Imagem da seta de formação
- Org_Arrow = ["Arrow_Organize",6]
- #Tempo de movimento e animação da seta, sendo [movimento,animação]
- Arrow_Time = [10,5]
- #Icone das classes, na ordem das classes no database
- Class_Icon = [128,129,130,131,132,133,134,135,136,136]
- #Para cores use Color.new(r,g,b)
- #r = vermelho, g = verde e b = azul.
- #Cor da borda
- Shadow = Color.new(70,40,20)
- #Cor do texto do nome do char
- Name_Color = Color.new(255,200,15)
- #Cor do level
- Lv_Color = Color.new(255,145,145)
- #Cor do titulo da informação
- Info_Title_Color = Color.new(255,230,130)
- #Cor do titulo do sistema
- Sys_Title_Color = Color.new(255,230,130)
- #Cor do texto do tempo de jogo, sendo [texto,numeros]
- Play_Time_Color = [Color.new(160,250,255),Color.new(160,250,255)]
- #Cor do texto do passos, sendo [texto,numeros]
- Step_Color = [Color.new(190,255,190),Color.new(190,255,190)]
- #Cor do texto de dinheiro, sendo [texto,numeros]
- Gold_Color = [Color.new(255,200,15),Color.new(255,200,15)]
- #Cor do texto do HP, sendo [texto,numeros]
- HP_Color = [Color.new(190,255,190),Color.new(190,255,190)]
- #Cor do texto do MP, sendo [texto,numeros]
- MP_Color = [Color.new(160,250,255),Color.new(160,250,255)]
- #* Cor das barras
- #Cor do fundo [centro,borda]
- GBack_Color = Color.new(90,90,90)
- #Cor da borda
- GBorder_Color = Color.new(120,80,60)
- #Cor da barra de HP [centro,borda]
- GHP_Color = Color.new(190,240,60)
- #Cor da barra de HP [centro,borda]
- GMP_Color = Color.new(100,225,200)
- #* Teclas
- #Para ver as dentro do maker e suas teclas no teclado, aperte F1 no maker
- #e va na aba "Keyboard" (terceira aba)
- #Tecla de informações
- Info_Key = :R
- #Tecla de sistema (sair,grupo,etc)
- Sys_Key = :L
- #Tempo em frames para aparecer a janela de informações
- Info_Time = 20
- #Tempo em frames para aparecer a janela de sistema
- Sys_Time = 20
- #Tempo em frames para aparecer a janela de fim de jogo
- End_Time = 20
- #*Textos
- #Texto para pressionar o botão de info
- Info_Press = "W: mais informações"
- #Texto para soltar o botão de info
- Info_Release = "Solte para esconder"
- #Texto para abrir a janela de sistema
- Sys_Open = "Q: abrir sistema"
- #Texto para fechar a janela de sistema
- Sys_Close = "ESC ou Q para fechar"
- #Titulo da janela de informações
- Info_Title = "Informações"
- #Titulo da janela de sistema
- Sys_Title = "Sistema"
- #Texto do tempo de jogo
- Play_Time = "Tempo de jogo"
- #Texto de passos
- Step = "Passos"
- #Imagem de fundo da janela do mapa
- Map_Back = "Map_Back"
- #Cor do nome do mapa
- Map_Color = Color.new(255,200,15)
- end
- class VJSprite < Sprite
- attr_reader :duration
- def initialize(viewport = nil)
- super(viewport)
- init_target
- init_frame
- end
- def init_target
- @target_x = self.x
- @target_y = self.y
- @target_zoom_x = self.zoom_x
- @target_zoom_y = self.zoom_y
- @target_opacity = self.opacity
- @duration = 0
- end
- def init_frame
- @frames = 1
- @frame_time = 0
- @change_time = 0
- @frame = 0
- end
- def frames(f,time)
- @frames = f
- @change_time = time
- make_rect
- end
- def make_rect
- return unless self.bitmap
- bitmap = self.bitmap
- cw = bitmap.width / @frames
- ch = bitmap.height
- rect = Rect.new(@frame*cw,0,cw,ch)
- self.src_rect.set(rect)
- end
- def move(x, y, zoom_x, zoom_y, opacity, blend_type, duration)
- @target_x = x.to_f
- @target_y = y.to_f
- @target_zoom_x = zoom_x.to_f
- @target_zoom_y = zoom_y.to_f
- @target_opacity = opacity.to_f
- self.blend_type = blend_type
- @duration = duration
- end
- def update
- super
- update_move
- update_anim
- end
- def update_move
- return if @duration == 0
- d = @duration
- self.x = (self.x * (d - 1) + @target_x) / d
- self.y = (self.y * (d - 1) + @target_y) / d
- self.zoom_x = (self.zoom_x * (d - 1) + @target_zoom_x) / d
- self.zoom_y = (self.zoom_y * (d - 1) + @target_zoom_y) / d
- self.opacity = (self.opacity * (d - 1) + @target_opacity) / d
- @duration -= 1
- end
- def update_anim
- return unless @frames
- return if @frames == 1
- @frame_time += 1
- if @frame_time == @change_time
- @frame_time = 0
- @frame = @frame == (@frames-1) ? 0 : @frame+1
- make_rect
- end
- end
- end
- class Window_MCommand < Window_Command
- def draw_item(index)
- contents.font.outline = false
- contents.font.size = 18
- color = normal_color
- color.alpha = translucent_alpha unless command_enabled?(index)
- rect = item_rect_for_text(index)
- draw_text(rect.x,rect.y,rect.width,rect.height, command_name(index),color, 1)
- end
- def draw_text(x,y,width,height,text,color,align = 0)
- contents.font.color = VJCM::Shadow
- contents.draw_text(Rect.new(x-1, y,width,height), text, align)
- contents.draw_text(Rect.new(x+1, y,width,height), text, align)
- contents.draw_text(Rect.new(x, y-1,width,height), text, align)
- contents.draw_text(Rect.new(x, y+1,width,height), text, align)
- contents.font.color = color
- contents.draw_text(Rect.new(x, y,width,height), text, align)
- end
- def get_pos(index)
- rect = item_rect(index)
- contents.font.size = 18
- text = command_name(index)
- size = contents.text_size(text)
- calc = (rect.width/2)+(size.width/2)+32
- x = self.x+rect.x+calc
- y = self.y+rect.y+rect.height
- return [x,y]
- end
- def update_cursor
- cursor_rect.empty
- end
- end
- class Sprite_AnimChar < Sprite
- include VJCM
- def initialize(viewport,actor)
- super(viewport)
- self.bitmap = Bitmap.new(544, 416)
- self.bitmap.font.size = 18
- self.bitmap.font.outline = false
- @actor = actor
- @time = 0
- @frame = 1
- refresh
- end
- def refresh
- self.bitmap.clear
- create_back
- create_char
- create_infos
- end
- def create_back
- bitmap = Cache.picture(Char_Back)
- rect = Rect.new(0, 0, bitmap.width, bitmap.height)
- self.bitmap.blt(0, 0, bitmap, rect)
- end
- def create_infos
- self.bitmap.font.size = 18
- if $game_party.battle_members.include?(@actor)
- bitmap = Cache.picture(Active)
- rect = Rect.new(0, 0, bitmap.width, bitmap.height)
- self.bitmap.blt(0, 0, bitmap, rect)
- end
- x = 8
- y = 4
- text = @actor.name
- size = self.bitmap.text_size(text)
- draw_text(x, y,size.width,size.height,text,Name_Color)
- draw_icon(Class_Icon[@actor.class_id-1], x+80, y)
- y += size.height
- text = "#{Vocab::level_a}. #{@actor.level.to_s}"
- size = self.bitmap.text_size(text)
- draw_text(x, y,size.width,size.height,text,Lv_Color)
- x = 42
- self.bitmap.font.size = 14
- y += size.height
- fill = 1.fdiv(@actor.mhp)*@actor.hp
- color = GHP_Color.clone
- calc = 0.8
- color.red *= calc
- color.green *= calc
- color.blue *= calc
- draw_gauge(x+3,y+13,GHP_Color,color,fill)
- text = "#{Vocab::hp_a}:"
- size = self.bitmap.text_size(text)
- draw_text(x, y,size.width,size.height,text,HP_Color[0])
- text = @actor.hp.to_s
- draw_text(x, y,70,size.height,text,HP_Color[1],2)
- y += size.height+4
- fill = 1.fdiv(@actor.mmp)*@actor.mp
- color = GMP_Color.clone
- calc = 0.8
- color.red *= calc
- color.green *= calc
- color.blue *= calc
- draw_gauge(x+3,y+13,GMP_Color,color,fill)
- text = "#{Vocab::mp_a}:"
- size = self.bitmap.text_size(text)
- draw_text(x, y,size.width,size.height,text,MP_Color[0])
- text = @actor.mp.to_s
- draw_text(x, y,70,size.height,text,MP_Color[1],2)
- x = 12
- y = 90
- draw_actor_icons(@actor,x,y)
- end
- def draw_gauge(x,y,color1,color2,filled)
- size = 65
- self.bitmap.fill_rect(x+2, y, size-4, 1, GBorder_Color)
- self.bitmap.fill_rect(x+1, y+1, size-2, 3, GBorder_Color)
- self.bitmap.fill_rect(x+2, y+4, size-4, 1, GBorder_Color)
- bcolor2 = GBack_Color.clone
- bcolor2.red *= 0.8
- bcolor2.green *= 0.8
- bcolor2.blue *= 0.8
- self.bitmap.fill_rect(x+2, y+1, size-4, 1, bcolor2)
- self.bitmap.fill_rect(x+2, y+2, size-4, 1, GBack_Color)
- self.bitmap.fill_rect(x+2, y+3, size-4, 1, bcolor2)
- fill = (size-4)*filled
- self.bitmap.fill_rect(x+2, y+1, fill, 1, color2)
- self.bitmap.fill_rect(x+2, y+2, fill, 1, color1)
- self.bitmap.fill_rect(x+2, y+3, fill, 1, color2)
- end
- def draw_actor_icons(actor, x, y, width = 128)
- icons = (actor.state_icons + actor.buff_icons)
- i = 0
- icons.each do |icon|
- break if i == 4
- ix = x+(i*24)
- draw_icon(icon, ix, y)
- i+= 1
- end
- end
- def draw_icon(icon_index, x, y, enabled = true)
- bitmap = Cache.system("Iconset")
- rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- self.bitmap.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
- end
- def draw_text(x,y,width,height,text,color,align = 0)
- self.bitmap.font.color = Shadow
- self.bitmap.draw_text(Rect.new(x-1, y,width,height), text, align)
- self.bitmap.draw_text(Rect.new(x+1, y,width,height), text, align)
- self.bitmap.draw_text(Rect.new(x, y-1,width,height), text, align)
- self.bitmap.draw_text(Rect.new(x, y+1,width,height), text, align)
- self.bitmap.font.color = color
- self.bitmap.draw_text(Rect.new(x, y,width,height), text, align)
- end
- def create_char
- bitmap = Cache.character(@actor.character_name)
- bitmap2 = Cache.picture(Char_Back)
- rect2 = get_rect(0)
- rect = Rect.new(7, 40, rect2.width, rect2.height)
- self.bitmap.blt(7, 40, bitmap2, rect)
- src_rect = get_rect(@frame)
- self.bitmap.blt(7, 40, bitmap, src_rect)
- end
- def update
- frame = @frame
- @time += 1
- if @time > Char_Anim_T
- @time = 0
- @frame = (@frame + 1) % 4
- end
- if frame != @frame
- create_char
- end
- end
- def straight
- return unless @frame != 1
- @frame = 1
- @time = 0
- create_char
- end
- def get_rect(frame)
- character_name = @actor.character_name
- return unless character_name
- bitmap = Cache.character(character_name)
- sign = character_name[/^[\!\$]./]
- if sign && sign.include?('$')
- cw = bitmap.width / 3
- ch = bitmap.height / 4
- else
- cw = bitmap.width / 12
- ch = bitmap.height / 8
- end
- n = @actor.character_index
- pattern = frame < 3 ? frame : 1
- src_rect = Rect.new((n%4*3+pattern)*cw, (n/4*4)*ch, cw, ch)
- return src_rect
- end
- end
- class Window_SysCommand < Window_MCommand
- attr_accessor :pressed
- def initialize(x,y)
- super(x, y)
- @pressed = false
- self.opacity = 0
- end
- def window_height
- bitmap = Cache.picture(VJCM::Sys_Back)
- return bitmap.height+24
- end
- def refresh
- clear_command_list
- make_command_list
- create_contents
- super
- create_press_text
- end
- def make_command_list
- add_command(Vocab::item, :item, $game_party.exists)
- add_command(Vocab::formation, :formation, $game_party.members.size >= 2 && !$game_system.formation_disabled)
- add_command(Vocab::save, :save, !$game_system.save_disabled)
- add_command(Vocab::game_end, :game_end)
- end
- def create_press_text
- text = @pressed ? VJCM::Sys_Close : VJCM::Sys_Open
- size = contents.text_size(text)
- y = contents.height-(size.height+14)
- contents.fill_rect(0, y, contents.width, size.height, Color.new(0,0,0,0))
- draw_text(0,y,contents.width,size.height,text,VJCM::Sys_Title_Color,1)
- end
- end
- class Window_CharaCommand < Window_Selectable
- attr_reader :pending_index # Manter a posição (para organizar)
- def initialize
- super(0, 0, 0, 0)
- @index = 0
- @pending_index = -1
- refresh
- end
- def col_max
- return 4
- end
- def item_max
- $game_party.members.size
- end
- def item_height
- (height - standard_padding * 2) / 4
- end
- def draw_item(index)
- end
- def process_ok
- super
- $game_party.menu_actor = $game_party.members[index]
- end
- def select_last
- select($game_party.menu_actor.index || 0)
- end
- def pending_index=(index)
- last_pending_index = @pending_index
- @pending_index = index
- end
- end
- class Window_Info < Window_Base
- attr_accessor :pressed
- def initialize(x, y)
- bitmap = Cache.picture(VJCM::Info_Back)
- super(x, y, bitmap.width, bitmap.height+8)
- self.opacity = 0
- @pressed = false
- contents.font.outline = false
- refresh
- end
- def refresh
- contents.clear
- contents.font.size = 18
- text = VJCM::Info_Title
- size = contents.text_size(text)
- draw_text(0, 0,contents.width,size.height,text,VJCM::Info_Title_Color,1)
- contents.font.size = 14
- text = VJCM::Play_Time+":"
- size = contents.text_size(text)
- draw_text(0, 24,contents.width,size.height,text,VJCM::Play_Time_Color[0],0)
- draw_play_time
- text = VJCM::Step+":"
- size = contents.text_size(text)
- draw_text(0, 48,contents.width,size.height,text,VJCM::Step_Color[0],0)
- text = $game_party.steps
- draw_text(0, 48+size.height,contents.width,size.height,text,VJCM::Step_Color[1],2)
- text = Vocab::currency_unit+":"
- size = contents.text_size(text)
- draw_text(0, 72,contents.width,size.height,text,VJCM::Gold_Color[0],0)
- text = $game_party.gold
- draw_text(0, 72+size.height,contents.width,size.height,text,VJCM::Gold_Color[1],2)
- draw_press_text
- end
- def draw_play_time
- contents.font.size = 14
- text = $game_system.playtime_s
- size = contents.text_size(text)
- @old_time = $game_system.playtime_s
- contents.fill_rect(contents.width-(size.width+4), 24+size.height, size.width+4, size.height, Color.new(0,0,0,0))
- draw_text(0, 24+size.height,contents.width,size.height,text,VJCM::Play_Time_Color[1],2)
- end
- def draw_press_text
- contents.font.size = 18
- text = @pressed ? VJCM::Info_Release : VJCM::Info_Press
- size = contents.text_size(text)
- y = contents.height-size.height
- contents.fill_rect(0, y, contents.width, size.height, Color.new(0,0,0,0))
- draw_text(0, y,contents.width,size.height,text,VJCM::Info_Title_Color,1)
- end
- def draw_text(x,y,width,height,text,color,align = 0)
- contents.font.color = VJCM::Shadow
- contents.draw_text(Rect.new(x-1, y,width,height), text, align)
- contents.draw_text(Rect.new(x+1, y,width,height), text, align)
- contents.draw_text(Rect.new(x, y-1,width,height), text, align)
- contents.draw_text(Rect.new(x, y+1,width,height), text, align)
- contents.font.color = color
- contents.draw_text(Rect.new(x, y,width,height), text, align)
- end
- def update
- return unless @pressed
- draw_play_time if @old_time != $game_system.playtime_s
- end
- end
- class Window_Map < Window_Base
- def initialize(x, y)
- bitmap = Cache.picture(VJCM::Map_Back)
- super(x, y-4, bitmap.width+24, bitmap.height+24)
- self.opacity = 0
- contents.font.outline = false
- contents.font.size = 16
- refresh
- end
- def refresh
- text = get_map_name
- draw_text(0,0,contents.width,contents.height,text, VJCM::Map_Color,1)
- end
- def draw_text(x,y,width,height,text,color,align = 0)
- contents.font.color = VJCM::Shadow
- contents.draw_text(Rect.new(x-1, y,width,height), text, align)
- contents.draw_text(Rect.new(x+1, y,width,height), text, align)
- contents.draw_text(Rect.new(x, y-1,width,height), text, align)
- contents.draw_text(Rect.new(x, y+1,width,height), text, align)
- contents.font.color = color
- contents.draw_text(Rect.new(x, y,width,height), text, align)
- end
- def get_map_name
- if $game_map.display_name.empty?
- map_a = load_data(sprintf("Data/Map%03d.rvdata2", $game_map.map_id))
- note = map_a.note.split("\r\n")
- text = "Nome da mapa não definido"
- note.each do |thing|
- if thing.include?("<mname>")
- text = thing
- text.slice!("<mname>")
- text.slice!("</mname>")
- end
- end
- map = text
- else
- map = $game_map.display_name
- end
- return map
- end
- end
- class Window_MGameEnd < Window_MCommand
- def initialize
- super(0, 0)
- self.opacity = 0
- end
- def window_width
- return 160
- end
- def make_command_list
- add_command(Vocab::to_title, :to_title)
- add_command(Vocab::shutdown, :shutdown)
- add_command(Vocab::cancel, :cancel)
- end
- end
- class Window_CharCommand < Window_MCommand
- def initialize
- super(0, 0)
- self.opacity = 0
- end
- def window_width
- return 160
- end
- def make_command_list
- add_command(Vocab::skill, :skill)
- add_command(Vocab::equip, :equip)
- add_command(Vocab::status, :status)
- end
- end
- class Scene_Menu < Scene_MenuBase
- include VJCM # Including the module
- # Starting the script
- def start
- super
- create_background
- create_chara_command
- create_chara
- create_arrow
- create_info_window
- create_map_window
- create_sys_window
- create_end_window
- create_ccom_window
- end
- # Creation of all contents
- def create_background
- @background = Plane.new
- @background.bitmap = Cache.picture(Background)
- @background.z = 0
- end
- def create_chara_command
- @chara_command = Window_CharaCommand.new
- @chara_command.active = true
- @chara_command.set_handler(:ok, method(:chara_ok))
- @chara_command.set_handler(:cancel, method(:return_scene))
- end
- def create_chara
- @formation = false
- @chara = []
- @original_pos = []
- @chara_x = 25
- @chara_y = 60
- @c_duration = 0
- for i in 0...$game_party.members.size
- actor = $game_party.members[i]
- x = @chara_x + ((i%4)*125)
- yv = (i%2)*30
- yv += (i/4) * 160
- y = @chara_y + yv
- @original_pos[i] = [x,y]
- rect = Rect.new(0,0,Graphics.width,Graphics.height)
- viewport = Viewport.new(rect)
- @chara[i] = Sprite_AnimChar.new(viewport,actor)
- @chara[i].x , @chara[i].y = [x,y]
- @chara[i].z = 1
- end
- @c_target = @original_pos.clone
- end
- def create_arrow
- index = @chara_command.index
- @old_index = index
- bitmap = Cache.picture(Arrow[0])
- cw = bitmap.width/Arrow[1]
- pos = @original_pos[index].clone
- pos[0] -= cw/2
- pos[1] -= bitmap.height/2
- @arrow = VJSprite.new
- @arrow.bitmap = bitmap
- @arrow.frames(Arrow[1],Arrow_Time[1])
- @arrow.z = 3
- @arrow.x , @arrow.y = pos
- @arrow.ox , @arrow.oy = [cw/3,bitmap.height/3]
- bitmap = Cache.picture(Org_Arrow[0])
- cw = bitmap.width/Org_Arrow[1]
- @org_arrow = VJSprite.new
- @org_arrow.bitmap = bitmap
- @org_arrow.frames(Org_Arrow[1],Arrow_Time[1])
- @org_arrow.x , @org_arrow.y = pos
- @org_arrow.ox , @org_arrow.oy = [cw/3,bitmap.height/3]
- @org_arrow.visible = false
- @opt_arrow = VJSprite.new
- @opt_arrow.bitmap = Cache.picture(Opt_Arrow[0])
- @opt_arrow.frames(Opt_Arrow[1],Arrow_Time[1])
- @opt_arrow.z = 6
- @c_old_index = -1
- @opt_arrow.opacity = 0
- end
- def create_info_window
- @info_back = VJSprite.new
- @info_back.bitmap = Cache.picture(Info_Back)
- @info_back.x = Graphics.width-@info_back.bitmap.width
- @info_back.y = -147
- @info_back.z = 4
- @info = Window_Info.new(@info_back.x,@info_back.y)
- @info.z = 5
- end
- def create_map_window
- @map_back = Sprite.new
- bitmap = Cache.picture(Info_Back)
- @map_back.bitmap = Cache.picture(Map_Back)
- @map_back.x = Graphics.width-(bitmap.width+@map_back.bitmap.width)
- @map_back.y = 0
- @map_back.z = 4
- @map = Window_Map.new(@map_back.x-14,@map_back.y-12)
- @map.z = 5
- end
- def create_sys_window
- @sys_back = VJSprite.new
- @sys_back.bitmap = Cache.picture(Sys_Back)
- @sys_back.x = 0
- @sys_back.y = -147
- @sys_back.z = 4
- @sys = Window_SysCommand.new(@sys_back.x,@sys_back.y)
- @sys.z = 5
- @sys.set_handler(:item, method(:command_item))
- @sys.set_handler(:formation, method(:command_formation))
- @sys.set_handler(:save, method(:command_save))
- @sys.set_handler(:game_end, method(:command_game_end))
- @sys.set_handler(:cancel, method(:command_sys_cancel))
- @sys.deactivate
- end
- def create_end_window
- @end_back = VJSprite.new
- @end_back.bitmap = Cache.picture(End_Back)
- @end = Window_MGameEnd.new
- y = (Graphics.height/2)-(@end.height/2)
- @end.x , @end.y = [Graphics.width,y]
- @end_back.x , @end_back.y = [Graphics.width,y]
- @end.set_handler(:to_title, method(:command_to_title))
- @end.set_handler(:shutdown, method(:command_shutdown))
- @end.set_handler(:cancel, method(:command_end_cancel))
- @end_back.z = 4
- @end.z = 5
- @end.deactivate
- end
- def create_ccom_window
- @ccom_back = Sprite.new
- @ccom_back.bitmap = Cache.picture(CCom_Back)
- @ccom = Window_CharCommand.new
- @ccom.x , @ccom.y = [0,0]
- @ccom_back.x , @ccom_back.y = [0,0]
- @ccom.set_handler(:skill, method(:command_personal))
- @ccom.set_handler(:equip, method(:command_personal))
- @ccom.set_handler(:status, method(:command_personal))
- @ccom.set_handler(:cancel, method(:chara_cancel))
- @ccom.z , @ccom_back.z = [5,4]
- @ccom.deactivate.hide
- @ccom_back.visible = false
- end
- # Update of all contents
- def update
- super
- update_background
- update_chara
- update_arrow
- update_info
- update_sys
- update_opt_arrow if @sys.active or @end.active or @ccom.active
- update_char_move
- @old_index = @chara_command.index
- end
- def update_background
- @background.ox += Back_Move[0]
- @background.oy += Back_Move[1]
- end
- def update_chara
- @chara[@chara_command.index].update
- @chara.each do |char|
- char.straight if @chara.index(char) != @chara_command.index and @chara.index(char) != @chara_command.pending_index
- end
- if @chara_command.pending_index > -1
- @chara[@chara_command.pending_index].update
- end
- if @old_index != @chara_command.index
- @chara.each do |char|
- break if last_line
- pos = @original_pos[@chara.index(char)].clone
- pos[1] -= 160*(@chara_command.index/4)
- @c_target[@chara.index(char)] = pos
- end
- @c_duration = Char_Move-@c_duration
- end
- end
- def last_line
- return (@chara_command.index/4) == (@chara_command.item_max/4)
- end
- def update_info
- if Input.press?(Info_Key) and !@info.pressed
- @info.pressed = true
- @info.refresh
- time = Info_Time-(@info_back.duration+1)
- @info_back.move(@info_back.x, 0, 1, 1, 255, 0, time)
- elsif !Input.press?(Info_Key) and @info.pressed
- @info.pressed = false
- @info.refresh
- time = Info_Time-(@info_back.duration+1)
- @info_back.move(@info_back.x, -147, 1, 1, 255, 0, time)
- end
- @info_back.update
- @info.x, @info.y = [@info_back.x, @info_back.y]
- end
- def update_sys
- if Input.press?(Sys_Key) and !@sys.active
- if @formation
- @chara_command.pending_index = -1
- on_formation_cancel
- elsif @end.active
- command_end_cancel
- elsif @ccom.active
- chara_cancel
- end
- @sys.pressed = true
- @sys.refresh
- @sys.activate
- @chara_command.deactivate
- @sys_back.move(@sys_back.x, 0, 1, 1, 255, 0, Sys_Time)
- wait_move(0) until @sys_back.duration == 0
- @c_old_index = -1
- end
- @sys_back.update
- @sys.y = @sys_back.y
- command_sys_cancel if Input.trigger?(VJCM::Sys_Key) and @sys.pressed
- end
- def update_end
- @end_back.update
- @end.x = @end_back.x
- end
- def update_arrow
- if @old_index != @chara_command.index
- cw = @arrow.bitmap.width/Arrow[1]
- index = @chara_command.index
- pos = @c_target[index].clone
- pos[0] -= cw/2
- pos[1] -= @arrow.bitmap.height/2
- @arrow.move(pos[0], pos[1], 1, 1, 255, 0, Arrow_Time[0])
- end
- @arrow.update
- @org_arrow.update
- end
- def update_opt_arrow
- window = @sys if @sys.active
- window = @end if @end.active
- window = @ccom if @ccom.active
- return unless window
- if @c_old_index != window.index
- index = window.index
- cw = @opt_arrow.bitmap.width/Opt_Arrow[1]
- pos = window.get_pos(index)
- pos[0] -= cw/2
- pos[1] -= @opt_arrow.bitmap.height/2
- @opt_arrow.move(pos[0], pos[1], 1, 1, 255, 0, Arrow_Time[0])
- @c_old_index = index
- end
- @opt_arrow.update
- end
- # Command process
- def command_personal
- case @ccom.current_symbol
- when :skill
- SceneManager.call(Scene_Skill)
- when :equip
- SceneManager.call(Scene_Equip)
- when :status
- SceneManager.call(Scene_Status)
- end
- end
- def chara_ok
- place_ccom
- @ccom.index = 0
- @ccom_back.visible = true
- @ccom.activate.show
- @chara_command.deactivate
- @opt_arrow.visible = true
- @c_old_index = -1
- end
- def chara_cancel
- @ccom_back.visible = false
- @ccom.deactivate.hide
- @chara_command.activate
- @opt_arrow.move(@opt_arrow.x, @opt_arrow.y, 1, 1, 0, 0, Arrow_Time[0])
- wait_move until @opt_arrow.duration == 0
- @c_old_index = -1
- end
- def cursor_left?
- result = false
- result = true if @chara_command.index % 4 == 2 or @chara_command.index % 4 == 3
- return result
- end
- def place_ccom
- calc = 0
- calc += 1 if cursor_left?
- chara = Cache.picture(Char_Back)
- pos = @c_target[@chara_command.index].clone
- case calc
- when 0
- pos[0] += chara.width
- when 1
- pos[0] -= @ccom_back.width
- end
- @ccom.x , @ccom.y = pos
- @ccom_back.x , @ccom_back.y = pos
- end
- def on_formation_cancel
- if @chara_command.pending_index >= 0
- @chara_command.pending_index = -1
- @chara_command.activate
- @org_arrow.visible = false
- else
- @formation = false
- @chara_command.index = 0
- @sys.pressed = true
- @sys.refresh
- @sys.activate
- @chara_command.deactivate
- @sys_back.move(@sys_back.x, 0, 1, 1, 255, 0, Sys_Time)
- wait_move(0) until @sys_back.duration == 0
- @org_arrow.visible = false
- @chara_command.set_handler(:ok, method(:chara_ok))
- @chara_command.set_handler(:cancel, method(:return_scene))
- end
- end
- def on_formation_ok
- if @chara_command.pending_index >= 0
- $game_party.swap_order(@chara_command.index,@chara_command.pending_index)
- chara = @chara[@chara_command.pending_index]
- @chara[@chara_command.pending_index] = @chara[@chara_command.index]
- @chara[@chara_command.index] = chara
- @chara[@chara_command.index].refresh
- @chara[@chara_command.pending_index].refresh
- @chara.each do |char|
- break if last_line
- pos = @original_pos[@chara.index(char)].clone
- pos[1] -= 160*(@chara_command.index/4)
- @c_target[@chara.index(char)] = pos
- end
- @c_duration = Char_Move-@c_duration
- @org_arrow.visible = false
- wait_move(2) until @c_duration == 0
- @chara_command.pending_index = -1
- @chara_command.index = 0
- @changed = true
- else
- @org_arrow.x , @org_arrow.y = [@arrow.x,@arrow.y]
- @org_arrow.visible = true
- @chara_command.pending_index = @chara_command.index
- end
- if @changed
- formation_complete
- @changed = false
- else
- @chara_command.activate
- end
- end
- def formation_complete
- @sys.pressed = true
- @sys.refresh
- @sys.activate
- @chara_command.deactivate
- @sys_back.move(@sys_back.x, 0, 1, 1, 255, 0, Sys_Time)
- wait_move(0) until @sys_back.duration == 0
- @chara_command.set_handler(:ok, method(:chara_ok))
- @chara_command.set_handler(:cancel, method(:return_scene))
- @formation = false
- end
- def command_formation
- command_sys_cancel
- @formation = true
- @chara_command.set_handler(:ok, method(:on_formation_ok))
- @chara_command.set_handler(:cancel, method(:on_formation_cancel))
- end
- def command_to_title
- fadeout_all
- SceneManager.goto(Scene_Title)
- end
- def command_shutdown
- fadeout_all
- SceneManager.exit
- end
- def command_end_cancel
- x = 0-@end.width
- @end.deactivate
- @opt_arrow.move(@opt_arrow.x, @opt_arrow.y, 1, 1, 0, 0, Arrow_Time[0])
- @end_back.move(x,@end_back.y,1,1,255,0,End_Time)
- wait_move(1) until @end_back.duration == 0
- @sys.activate
- end
- def command_sys_cancel
- @c_old_index = -1
- @sys.pressed = false
- @sys.refresh
- @chara_command.activate
- @opt_arrow.move(@opt_arrow.x, @opt_arrow.y, 1, 1, 0, 0, Arrow_Time[0])
- @sys_back.move(@sys_back.x,-147,1,1,255,0,Sys_Time)
- wait_move(0) until @sys_back.duration == 0
- @sys.deactivate
- end
- def command_game_end
- @end.x = Graphics.width
- @end_back.x = @end.x
- @sys.deactivate
- x = (Graphics.width/2)-(@end.width/2)
- @opt_arrow.move(@opt_arrow.x, @opt_arrow.y, 1, 1, 0, 0, Arrow_Time[0])
- @end_back.move(x,@end_back.y,1,1,255,0,End_Time)
- wait_move(1) until @end_back.duration == 0
- @end.activate
- end
- def wait_move(n=nil)
- Graphics.update
- Input.update
- update_background
- update_arrow
- update_chara
- @opt_arrow.update
- case n
- when 0
- update_sys
- when 1
- update_end
- when 2
- update_char_move
- end
- end
- def update_char_move
- return if @c_duration == 0
- d = @c_duration
- @chara.each do |char|
- pos = @c_target[@chara.index(char)]
- char.x = (char.x * (d - 1) + pos[0]) / d
- char.y = (char.y * (d - 1) + pos[1]) / d
- end
- if @formation
- bitmap = Cache.picture(Org_Arrow[0])
- cw = bitmap.width/Org_Arrow[1]
- index = @chara_command.pending_index
- chara = @chara[index]
- pos = [chara.x,chara.y]
- pos[0] -= cw/2
- pos[1] -= bitmap.height/2
- @org_arrow.x , @org_arrow.y = pos
- end
- @c_duration -= 1
- end
- def command_item
- SceneManager.call(Scene_Item)
- end
- def command_save
- SceneManager.call(Scene_Save)
- end
- # End of the scene
- def terminate
- super
- dispose_background
- dispose_chara
- dispose_sprites
- end
- def dispose_background
- @background.dispose
- end
- def dispose_chara
- @chara.each {|char| char.dispose}
- end
- def dispose_sprites
- instance_variables.each do |varname|
- ivar = instance_variable_get(varname)
- ivar.dispose if ivar.is_a?(Sprite)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement