Advertisement
Guest User

:(

a guest
Jul 10th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.00 KB | None | 0 0
  1. #==============================================================================
  2. # Cute Menu by VitorJ (http://vjrgss.blogspot.com/)
  3. #-Função-----------------------------------------------------------------------
  4. # Modifica o menu padrão por um animado e por pictures
  5. #-Change log-------------------------------------------------------------------
  6. # v1.0: Script criado.
  7. # v1.1: Corrigido alguns bugs, código melhorado, algumas melhorias visuais.
  8. #-Nome do mapa-----------------------------------------------------------------
  9. # O nome que aparecera na area de nome do mapa sera o nome escolhido para
  10. # exibição, caso não tenha um, ele ira procurar o seguinte comando na nota do
  11. # mapa: <mname>Nome do Mapa</mname>
  12. # Onde o nome do mapa deve ser posto, não é necessario estar entre aspas.
  13. #==============================================================================
  14. module VJCM
  15. #Os chares terão animação de movimento?
  16. Char_Anim = true
  17. #Se sim, qual o tempo de animação? (em frames)
  18. Char_Anim_T = 20
  19. #Nome da imagem de fundo
  20. Background = "Background"
  21. #Movimento [x,y] da imagem de fundo
  22. Back_Move = [-1,-1]
  23. #Grafico de fundo do char
  24. Char_Back = "Char_Back"
  25. #Tempo de movimento da caixa dos chares
  26. Char_Move = 10
  27. #Grafico da imagem que aparecera nos chares ativos
  28. Active = "Active"
  29. #Grafico do fundo da janela de informações
  30. Info_Back = "Info_Back"
  31. #Grafico de fundo da janela de sistema
  32. Sys_Back = "Info_Back"
  33. #Grafico de fundo da janela de sair
  34. End_Back = "End_Back"
  35. #Grafico de fundo do comando de char
  36. CCom_Back = "End_Back"
  37. #Imagem da seta ["Nome da Imagem",numero de frames] coloque 1 frame para não
  38. #animar
  39. Arrow = ["Arrow_Main",6]
  40. #Imagem da seta nas janelas de comando
  41. Opt_Arrow = ["Arrow_Opt",6]
  42. #Imagem da seta de formação
  43. Org_Arrow = ["Arrow_Organize",6]
  44. #Tempo de movimento e animação da seta, sendo [movimento,animação]
  45. Arrow_Time = [10,5]
  46. #Icone das classes, na ordem das classes no database
  47. Class_Icon = [128,129,130,131,132,133,134,135,136,136]
  48. #Para cores use Color.new(r,g,b)
  49. #r = vermelho, g = verde e b = azul.
  50. #Cor da borda
  51. Shadow = Color.new(70,40,20)
  52. #Cor do texto do nome do char
  53. Name_Color = Color.new(255,200,15)
  54. #Cor do level
  55. Lv_Color = Color.new(255,145,145)
  56. #Cor do titulo da informação
  57. Info_Title_Color = Color.new(255,230,130)
  58. #Cor do titulo do sistema
  59. Sys_Title_Color = Color.new(255,230,130)
  60. #Cor do texto do tempo de jogo, sendo [texto,numeros]
  61. Play_Time_Color = [Color.new(160,250,255),Color.new(160,250,255)]
  62. #Cor do texto do passos, sendo [texto,numeros]
  63. Step_Color = [Color.new(190,255,190),Color.new(190,255,190)]
  64. #Cor do texto de dinheiro, sendo [texto,numeros]
  65. Gold_Color = [Color.new(255,200,15),Color.new(255,200,15)]
  66. #Cor do texto do HP, sendo [texto,numeros]
  67. HP_Color = [Color.new(190,255,190),Color.new(190,255,190)]
  68. #Cor do texto do MP, sendo [texto,numeros]
  69. MP_Color = [Color.new(160,250,255),Color.new(160,250,255)]
  70. #* Cor das barras
  71. #Cor do fundo [centro,borda]
  72. GBack_Color = Color.new(90,90,90)
  73. #Cor da borda
  74. GBorder_Color = Color.new(120,80,60)
  75. #Cor da barra de HP [centro,borda]
  76. GHP_Color = Color.new(190,240,60)
  77. #Cor da barra de HP [centro,borda]
  78. GMP_Color = Color.new(100,225,200)
  79. #* Teclas
  80. #Para ver as dentro do maker e suas teclas no teclado, aperte F1 no maker
  81. #e va na aba "Keyboard" (terceira aba)
  82. #Tecla de informações
  83. Info_Key = :R
  84. #Tecla de sistema (sair,grupo,etc)
  85. Sys_Key = :L
  86. #Tempo em frames para aparecer a janela de informações
  87. Info_Time = 20
  88. #Tempo em frames para aparecer a janela de sistema
  89. Sys_Time = 20
  90. #Tempo em frames para aparecer a janela de fim de jogo
  91. End_Time = 20
  92.  
  93. #*Textos
  94. #Texto para pressionar o botão de info
  95. Info_Press = "W: mais informações"
  96. #Texto para soltar o botão de info
  97. Info_Release = "Solte para esconder"
  98. #Texto para abrir a janela de sistema
  99. Sys_Open = "Q: abrir sistema"
  100. #Texto para fechar a janela de sistema
  101. Sys_Close = "ESC ou Q para fechar"
  102. #Titulo da janela de informações
  103. Info_Title = "Informações"
  104. #Titulo da janela de sistema
  105. Sys_Title = "Sistema"
  106. #Texto do tempo de jogo
  107. Play_Time = "Tempo de jogo"
  108. #Texto de passos
  109. Step = "Passos"
  110. #Imagem de fundo da janela do mapa
  111. Map_Back = "Map_Back"
  112. #Cor do nome do mapa
  113. Map_Color = Color.new(255,200,15)
  114.  
  115. end
  116.  
  117. class VJSprite < Sprite
  118. attr_reader :duration
  119. def initialize(viewport = nil)
  120. super(viewport)
  121. init_target
  122. init_frame
  123. end
  124. def init_target
  125. @target_x = self.x
  126. @target_y = self.y
  127. @target_zoom_x = self.zoom_x
  128. @target_zoom_y = self.zoom_y
  129. @target_opacity = self.opacity
  130. @duration = 0
  131. end
  132. def init_frame
  133. @frames = 1
  134. @frame_time = 0
  135. @change_time = 0
  136. @frame = 0
  137. end
  138. def frames(f,time)
  139. @frames = f
  140. @change_time = time
  141. make_rect
  142. end
  143. def make_rect
  144. return unless self.bitmap
  145. bitmap = self.bitmap
  146. cw = bitmap.width / @frames
  147. ch = bitmap.height
  148. rect = Rect.new(@frame*cw,0,cw,ch)
  149. self.src_rect.set(rect)
  150. end
  151. def move(x, y, zoom_x, zoom_y, opacity, blend_type, duration)
  152. @target_x = x.to_f
  153. @target_y = y.to_f
  154. @target_zoom_x = zoom_x.to_f
  155. @target_zoom_y = zoom_y.to_f
  156. @target_opacity = opacity.to_f
  157. self.blend_type = blend_type
  158. @duration = duration
  159. end
  160. def update
  161. super
  162. update_move
  163. update_anim
  164. end
  165. def update_move
  166. return if @duration == 0
  167. d = @duration
  168. self.x = (self.x * (d - 1) + @target_x) / d
  169. self.y = (self.y * (d - 1) + @target_y) / d
  170. self.zoom_x = (self.zoom_x * (d - 1) + @target_zoom_x) / d
  171. self.zoom_y = (self.zoom_y * (d - 1) + @target_zoom_y) / d
  172. self.opacity = (self.opacity * (d - 1) + @target_opacity) / d
  173. @duration -= 1
  174. end
  175. def update_anim
  176. return unless @frames
  177. return if @frames == 1
  178. @frame_time += 1
  179. if @frame_time == @change_time
  180. @frame_time = 0
  181. @frame = @frame == (@frames-1) ? 0 : @frame+1
  182. make_rect
  183. end
  184. end
  185. end
  186.  
  187. class Window_MCommand < Window_Command
  188. def draw_item(index)
  189. contents.font.outline = false
  190. contents.font.size = 18
  191. color = normal_color
  192. color.alpha = translucent_alpha unless command_enabled?(index)
  193. rect = item_rect_for_text(index)
  194. draw_text(rect.x,rect.y,rect.width,rect.height, command_name(index),color, 1)
  195. end
  196. def draw_text(x,y,width,height,text,color,align = 0)
  197. contents.font.color = VJCM::Shadow
  198. contents.draw_text(Rect.new(x-1, y,width,height), text, align)
  199. contents.draw_text(Rect.new(x+1, y,width,height), text, align)
  200. contents.draw_text(Rect.new(x, y-1,width,height), text, align)
  201. contents.draw_text(Rect.new(x, y+1,width,height), text, align)
  202. contents.font.color = color
  203. contents.draw_text(Rect.new(x, y,width,height), text, align)
  204. end
  205. def get_pos(index)
  206. rect = item_rect(index)
  207. contents.font.size = 18
  208. text = command_name(index)
  209. size = contents.text_size(text)
  210. calc = (rect.width/2)+(size.width/2)+32
  211. x = self.x+rect.x+calc
  212. y = self.y+rect.y+rect.height
  213. return [x,y]
  214. end
  215. def update_cursor
  216. cursor_rect.empty
  217. end
  218. end
  219. class Sprite_AnimChar < Sprite
  220. include VJCM
  221. def initialize(viewport,actor)
  222. super(viewport)
  223. self.bitmap = Bitmap.new(544, 416)
  224. self.bitmap.font.size = 18
  225. self.bitmap.font.outline = false
  226. @actor = actor
  227. @time = 0
  228. @frame = 1
  229. refresh
  230. end
  231. def refresh
  232. self.bitmap.clear
  233. create_back
  234. create_char
  235. create_infos
  236. end
  237. def create_back
  238. bitmap = Cache.picture(Char_Back)
  239. rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  240. self.bitmap.blt(0, 0, bitmap, rect)
  241. end
  242. def create_infos
  243. self.bitmap.font.size = 18
  244. if $game_party.battle_members.include?(@actor)
  245. bitmap = Cache.picture(Active)
  246. rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  247. self.bitmap.blt(0, 0, bitmap, rect)
  248. end
  249.  
  250. x = 8
  251. y = 4
  252. text = @actor.name
  253. size = self.bitmap.text_size(text)
  254. draw_text(x, y,size.width,size.height,text,Name_Color)
  255.  
  256. draw_icon(Class_Icon[@actor.class_id-1], x+80, y)
  257.  
  258. y += size.height
  259. text = "#{Vocab::level_a}. #{@actor.level.to_s}"
  260. size = self.bitmap.text_size(text)
  261. draw_text(x, y,size.width,size.height,text,Lv_Color)
  262.  
  263. x = 42
  264.  
  265. self.bitmap.font.size = 14
  266. y += size.height
  267. fill = 1.fdiv(@actor.mhp)*@actor.hp
  268. color = GHP_Color.clone
  269. calc = 0.8
  270. color.red *= calc
  271. color.green *= calc
  272. color.blue *= calc
  273. draw_gauge(x+3,y+13,GHP_Color,color,fill)
  274. text = "#{Vocab::hp_a}:"
  275. size = self.bitmap.text_size(text)
  276. draw_text(x, y,size.width,size.height,text,HP_Color[0])
  277. text = @actor.hp.to_s
  278. draw_text(x, y,70,size.height,text,HP_Color[1],2)
  279.  
  280. y += size.height+4
  281. fill = 1.fdiv(@actor.mmp)*@actor.mp
  282. color = GMP_Color.clone
  283. calc = 0.8
  284. color.red *= calc
  285. color.green *= calc
  286. color.blue *= calc
  287. draw_gauge(x+3,y+13,GMP_Color,color,fill)
  288. text = "#{Vocab::mp_a}:"
  289. size = self.bitmap.text_size(text)
  290. draw_text(x, y,size.width,size.height,text,MP_Color[0])
  291. text = @actor.mp.to_s
  292. draw_text(x, y,70,size.height,text,MP_Color[1],2)
  293.  
  294. x = 12
  295. y = 90
  296. draw_actor_icons(@actor,x,y)
  297. end
  298. def draw_gauge(x,y,color1,color2,filled)
  299. size = 65
  300. self.bitmap.fill_rect(x+2, y, size-4, 1, GBorder_Color)
  301. self.bitmap.fill_rect(x+1, y+1, size-2, 3, GBorder_Color)
  302. self.bitmap.fill_rect(x+2, y+4, size-4, 1, GBorder_Color)
  303.  
  304. bcolor2 = GBack_Color.clone
  305. bcolor2.red *= 0.8
  306. bcolor2.green *= 0.8
  307. bcolor2.blue *= 0.8
  308. self.bitmap.fill_rect(x+2, y+1, size-4, 1, bcolor2)
  309. self.bitmap.fill_rect(x+2, y+2, size-4, 1, GBack_Color)
  310. self.bitmap.fill_rect(x+2, y+3, size-4, 1, bcolor2)
  311.  
  312. fill = (size-4)*filled
  313. self.bitmap.fill_rect(x+2, y+1, fill, 1, color2)
  314. self.bitmap.fill_rect(x+2, y+2, fill, 1, color1)
  315. self.bitmap.fill_rect(x+2, y+3, fill, 1, color2)
  316. end
  317. def draw_actor_icons(actor, x, y, width = 128)
  318. icons = (actor.state_icons + actor.buff_icons)
  319. i = 0
  320. icons.each do |icon|
  321. break if i == 4
  322. ix = x+(i*24)
  323. draw_icon(icon, ix, y)
  324. i+= 1
  325. end
  326. end
  327. def draw_icon(icon_index, x, y, enabled = true)
  328. bitmap = Cache.system("Iconset")
  329. rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  330. self.bitmap.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  331. end
  332. def draw_text(x,y,width,height,text,color,align = 0)
  333. self.bitmap.font.color = Shadow
  334. self.bitmap.draw_text(Rect.new(x-1, y,width,height), text, align)
  335. self.bitmap.draw_text(Rect.new(x+1, y,width,height), text, align)
  336. self.bitmap.draw_text(Rect.new(x, y-1,width,height), text, align)
  337. self.bitmap.draw_text(Rect.new(x, y+1,width,height), text, align)
  338. self.bitmap.font.color = color
  339. self.bitmap.draw_text(Rect.new(x, y,width,height), text, align)
  340. end
  341. def create_char
  342. bitmap = Cache.character(@actor.character_name)
  343. bitmap2 = Cache.picture(Char_Back)
  344. rect2 = get_rect(0)
  345. rect = Rect.new(7, 40, rect2.width, rect2.height)
  346. self.bitmap.blt(7, 40, bitmap2, rect)
  347. src_rect = get_rect(@frame)
  348. self.bitmap.blt(7, 40, bitmap, src_rect)
  349. end
  350. def update
  351. frame = @frame
  352. @time += 1
  353. if @time > Char_Anim_T
  354. @time = 0
  355. @frame = (@frame + 1) % 4
  356. end
  357. if frame != @frame
  358. create_char
  359. end
  360. end
  361. def straight
  362. return unless @frame != 1
  363. @frame = 1
  364. @time = 0
  365. create_char
  366. end
  367. def get_rect(frame)
  368. character_name = @actor.character_name
  369. return unless character_name
  370. bitmap = Cache.character(character_name)
  371. sign = character_name[/^[\!\$]./]
  372. if sign && sign.include?('$')
  373. cw = bitmap.width / 3
  374. ch = bitmap.height / 4
  375. else
  376. cw = bitmap.width / 12
  377. ch = bitmap.height / 8
  378. end
  379. n = @actor.character_index
  380. pattern = frame < 3 ? frame : 1
  381. src_rect = Rect.new((n%4*3+pattern)*cw, (n/4*4)*ch, cw, ch)
  382. return src_rect
  383. end
  384. end
  385. class Window_SysCommand < Window_MCommand
  386. attr_accessor :pressed
  387. def initialize(x,y)
  388. super(x, y)
  389. @pressed = false
  390. self.opacity = 0
  391. end
  392. def window_height
  393. bitmap = Cache.picture(VJCM::Sys_Back)
  394. return bitmap.height+24
  395. end
  396. def refresh
  397. clear_command_list
  398. make_command_list
  399. create_contents
  400. super
  401. create_press_text
  402. end
  403. def make_command_list
  404. add_command(Vocab::item, :item, $game_party.exists)
  405. add_command(Vocab::formation, :formation, $game_party.members.size >= 2 && !$game_system.formation_disabled)
  406. add_command(Vocab::save, :save, !$game_system.save_disabled)
  407. add_command(Vocab::game_end, :game_end)
  408. end
  409. def create_press_text
  410. text = @pressed ? VJCM::Sys_Close : VJCM::Sys_Open
  411. size = contents.text_size(text)
  412. y = contents.height-(size.height+14)
  413. contents.fill_rect(0, y, contents.width, size.height, Color.new(0,0,0,0))
  414. draw_text(0,y,contents.width,size.height,text,VJCM::Sys_Title_Color,1)
  415. end
  416. end
  417. class Window_CharaCommand < Window_Selectable
  418. attr_reader :pending_index # Manter a posição (para organizar)
  419. def initialize
  420. super(0, 0, 0, 0)
  421. @index = 0
  422. @pending_index = -1
  423. refresh
  424. end
  425. def col_max
  426. return 4
  427. end
  428. def item_max
  429. $game_party.members.size
  430. end
  431. def item_height
  432. (height - standard_padding * 2) / 4
  433. end
  434. def draw_item(index)
  435. end
  436. def process_ok
  437. super
  438. $game_party.menu_actor = $game_party.members[index]
  439. end
  440. def select_last
  441. select($game_party.menu_actor.index || 0)
  442. end
  443. def pending_index=(index)
  444. last_pending_index = @pending_index
  445. @pending_index = index
  446. end
  447. end
  448. class Window_Info < Window_Base
  449. attr_accessor :pressed
  450. def initialize(x, y)
  451. bitmap = Cache.picture(VJCM::Info_Back)
  452. super(x, y, bitmap.width, bitmap.height+8)
  453. self.opacity = 0
  454. @pressed = false
  455. contents.font.outline = false
  456. refresh
  457. end
  458. def refresh
  459. contents.clear
  460. contents.font.size = 18
  461. text = VJCM::Info_Title
  462. size = contents.text_size(text)
  463. draw_text(0, 0,contents.width,size.height,text,VJCM::Info_Title_Color,1)
  464.  
  465. contents.font.size = 14
  466. text = VJCM::Play_Time+":"
  467. size = contents.text_size(text)
  468. draw_text(0, 24,contents.width,size.height,text,VJCM::Play_Time_Color[0],0)
  469. draw_play_time
  470.  
  471. text = VJCM::Step+":"
  472. size = contents.text_size(text)
  473. draw_text(0, 48,contents.width,size.height,text,VJCM::Step_Color[0],0)
  474. text = $game_party.steps
  475. draw_text(0, 48+size.height,contents.width,size.height,text,VJCM::Step_Color[1],2)
  476.  
  477. text = Vocab::currency_unit+":"
  478. size = contents.text_size(text)
  479. draw_text(0, 72,contents.width,size.height,text,VJCM::Gold_Color[0],0)
  480. text = $game_party.gold
  481. draw_text(0, 72+size.height,contents.width,size.height,text,VJCM::Gold_Color[1],2)
  482.  
  483. draw_press_text
  484. end
  485. def draw_play_time
  486. contents.font.size = 14
  487. text = $game_system.playtime_s
  488. size = contents.text_size(text)
  489. @old_time = $game_system.playtime_s
  490. contents.fill_rect(contents.width-(size.width+4), 24+size.height, size.width+4, size.height, Color.new(0,0,0,0))
  491. draw_text(0, 24+size.height,contents.width,size.height,text,VJCM::Play_Time_Color[1],2)
  492. end
  493. def draw_press_text
  494. contents.font.size = 18
  495. text = @pressed ? VJCM::Info_Release : VJCM::Info_Press
  496. size = contents.text_size(text)
  497. y = contents.height-size.height
  498. contents.fill_rect(0, y, contents.width, size.height, Color.new(0,0,0,0))
  499. draw_text(0, y,contents.width,size.height,text,VJCM::Info_Title_Color,1)
  500. end
  501. def draw_text(x,y,width,height,text,color,align = 0)
  502. contents.font.color = VJCM::Shadow
  503. contents.draw_text(Rect.new(x-1, y,width,height), text, align)
  504. contents.draw_text(Rect.new(x+1, y,width,height), text, align)
  505. contents.draw_text(Rect.new(x, y-1,width,height), text, align)
  506. contents.draw_text(Rect.new(x, y+1,width,height), text, align)
  507. contents.font.color = color
  508. contents.draw_text(Rect.new(x, y,width,height), text, align)
  509. end
  510. def update
  511. return unless @pressed
  512. draw_play_time if @old_time != $game_system.playtime_s
  513. end
  514. end
  515.  
  516. class Window_Map < Window_Base
  517. def initialize(x, y)
  518. bitmap = Cache.picture(VJCM::Map_Back)
  519. super(x, y-4, bitmap.width+24, bitmap.height+24)
  520. self.opacity = 0
  521. contents.font.outline = false
  522. contents.font.size = 16
  523. refresh
  524. end
  525. def refresh
  526. text = get_map_name
  527. draw_text(0,0,contents.width,contents.height,text, VJCM::Map_Color,1)
  528. end
  529. def draw_text(x,y,width,height,text,color,align = 0)
  530. contents.font.color = VJCM::Shadow
  531. contents.draw_text(Rect.new(x-1, y,width,height), text, align)
  532. contents.draw_text(Rect.new(x+1, y,width,height), text, align)
  533. contents.draw_text(Rect.new(x, y-1,width,height), text, align)
  534. contents.draw_text(Rect.new(x, y+1,width,height), text, align)
  535. contents.font.color = color
  536. contents.draw_text(Rect.new(x, y,width,height), text, align)
  537. end
  538. def get_map_name
  539. if $game_map.display_name.empty?
  540. map_a = load_data(sprintf("Data/Map%03d.rvdata2", $game_map.map_id))
  541. note = map_a.note.split("\r\n")
  542. text = "Nome da mapa não definido"
  543. note.each do |thing|
  544. if thing.include?("<mname>")
  545. text = thing
  546. text.slice!("<mname>")
  547. text.slice!("</mname>")
  548. end
  549. end
  550. map = text
  551. else
  552. map = $game_map.display_name
  553. end
  554. return map
  555. end
  556. end
  557.  
  558. class Window_MGameEnd < Window_MCommand
  559. def initialize
  560. super(0, 0)
  561. self.opacity = 0
  562. end
  563. def window_width
  564. return 160
  565. end
  566. def make_command_list
  567. add_command(Vocab::to_title, :to_title)
  568. add_command(Vocab::shutdown, :shutdown)
  569. add_command(Vocab::cancel, :cancel)
  570. end
  571. end
  572.  
  573. class Window_CharCommand < Window_MCommand
  574. def initialize
  575. super(0, 0)
  576. self.opacity = 0
  577. end
  578. def window_width
  579. return 160
  580. end
  581. def make_command_list
  582. add_command(Vocab::skill, :skill)
  583. add_command(Vocab::equip, :equip)
  584. add_command(Vocab::status, :status)
  585. end
  586. end
  587.  
  588. class Scene_Menu < Scene_MenuBase
  589. include VJCM # Including the module
  590. # Starting the script
  591. def start
  592. super
  593. create_background
  594. create_chara_command
  595. create_chara
  596. create_arrow
  597. create_info_window
  598. create_map_window
  599. create_sys_window
  600. create_end_window
  601. create_ccom_window
  602. end
  603. # Creation of all contents
  604. def create_background
  605. @background = Plane.new
  606. @background.bitmap = Cache.picture(Background)
  607. @background.z = 0
  608. end
  609. def create_chara_command
  610. @chara_command = Window_CharaCommand.new
  611. @chara_command.active = true
  612. @chara_command.set_handler(:ok, method(:chara_ok))
  613. @chara_command.set_handler(:cancel, method(:return_scene))
  614. end
  615. def create_chara
  616. @formation = false
  617. @chara = []
  618. @original_pos = []
  619. @chara_x = 25
  620. @chara_y = 60
  621. @c_duration = 0
  622. for i in 0...$game_party.members.size
  623. actor = $game_party.members[i]
  624. x = @chara_x + ((i%4)*125)
  625. yv = (i%2)*30
  626. yv += (i/4) * 160
  627. y = @chara_y + yv
  628. @original_pos[i] = [x,y]
  629. rect = Rect.new(0,0,Graphics.width,Graphics.height)
  630. viewport = Viewport.new(rect)
  631. @chara[i] = Sprite_AnimChar.new(viewport,actor)
  632. @chara[i].x , @chara[i].y = [x,y]
  633. @chara[i].z = 1
  634. end
  635. @c_target = @original_pos.clone
  636. end
  637. def create_arrow
  638. index = @chara_command.index
  639. @old_index = index
  640. bitmap = Cache.picture(Arrow[0])
  641. cw = bitmap.width/Arrow[1]
  642. pos = @original_pos[index].clone
  643. pos[0] -= cw/2
  644. pos[1] -= bitmap.height/2
  645.  
  646. @arrow = VJSprite.new
  647. @arrow.bitmap = bitmap
  648. @arrow.frames(Arrow[1],Arrow_Time[1])
  649. @arrow.z = 3
  650. @arrow.x , @arrow.y = pos
  651. @arrow.ox , @arrow.oy = [cw/3,bitmap.height/3]
  652.  
  653. bitmap = Cache.picture(Org_Arrow[0])
  654. cw = bitmap.width/Org_Arrow[1]
  655. @org_arrow = VJSprite.new
  656. @org_arrow.bitmap = bitmap
  657. @org_arrow.frames(Org_Arrow[1],Arrow_Time[1])
  658. @org_arrow.x , @org_arrow.y = pos
  659. @org_arrow.ox , @org_arrow.oy = [cw/3,bitmap.height/3]
  660. @org_arrow.visible = false
  661.  
  662. @opt_arrow = VJSprite.new
  663. @opt_arrow.bitmap = Cache.picture(Opt_Arrow[0])
  664. @opt_arrow.frames(Opt_Arrow[1],Arrow_Time[1])
  665. @opt_arrow.z = 6
  666. @c_old_index = -1
  667. @opt_arrow.opacity = 0
  668. end
  669. def create_info_window
  670. @info_back = VJSprite.new
  671. @info_back.bitmap = Cache.picture(Info_Back)
  672. @info_back.x = Graphics.width-@info_back.bitmap.width
  673. @info_back.y = -147
  674. @info_back.z = 4
  675. @info = Window_Info.new(@info_back.x,@info_back.y)
  676. @info.z = 5
  677. end
  678. def create_map_window
  679. @map_back = Sprite.new
  680. bitmap = Cache.picture(Info_Back)
  681. @map_back.bitmap = Cache.picture(Map_Back)
  682. @map_back.x = Graphics.width-(bitmap.width+@map_back.bitmap.width)
  683. @map_back.y = 0
  684. @map_back.z = 4
  685. @map = Window_Map.new(@map_back.x-14,@map_back.y-12)
  686. @map.z = 5
  687. end
  688. def create_sys_window
  689. @sys_back = VJSprite.new
  690. @sys_back.bitmap = Cache.picture(Sys_Back)
  691. @sys_back.x = 0
  692. @sys_back.y = -147
  693. @sys_back.z = 4
  694. @sys = Window_SysCommand.new(@sys_back.x,@sys_back.y)
  695. @sys.z = 5
  696. @sys.set_handler(:item, method(:command_item))
  697. @sys.set_handler(:formation, method(:command_formation))
  698. @sys.set_handler(:save, method(:command_save))
  699. @sys.set_handler(:game_end, method(:command_game_end))
  700. @sys.set_handler(:cancel, method(:command_sys_cancel))
  701. @sys.deactivate
  702. end
  703. def create_end_window
  704. @end_back = VJSprite.new
  705. @end_back.bitmap = Cache.picture(End_Back)
  706. @end = Window_MGameEnd.new
  707. y = (Graphics.height/2)-(@end.height/2)
  708. @end.x , @end.y = [Graphics.width,y]
  709. @end_back.x , @end_back.y = [Graphics.width,y]
  710. @end.set_handler(:to_title, method(:command_to_title))
  711. @end.set_handler(:shutdown, method(:command_shutdown))
  712. @end.set_handler(:cancel, method(:command_end_cancel))
  713. @end_back.z = 4
  714. @end.z = 5
  715. @end.deactivate
  716. end
  717. def create_ccom_window
  718. @ccom_back = Sprite.new
  719. @ccom_back.bitmap = Cache.picture(CCom_Back)
  720. @ccom = Window_CharCommand.new
  721. @ccom.x , @ccom.y = [0,0]
  722. @ccom_back.x , @ccom_back.y = [0,0]
  723. @ccom.set_handler(:skill, method(:command_personal))
  724. @ccom.set_handler(:equip, method(:command_personal))
  725. @ccom.set_handler(:status, method(:command_personal))
  726. @ccom.set_handler(:cancel, method(:chara_cancel))
  727. @ccom.z , @ccom_back.z = [5,4]
  728. @ccom.deactivate.hide
  729. @ccom_back.visible = false
  730. end
  731. # Update of all contents
  732. def update
  733. super
  734. update_background
  735. update_chara
  736. update_arrow
  737. update_info
  738. update_sys
  739. update_opt_arrow if @sys.active or @end.active or @ccom.active
  740. update_char_move
  741. @old_index = @chara_command.index
  742. end
  743. def update_background
  744. @background.ox += Back_Move[0]
  745. @background.oy += Back_Move[1]
  746. end
  747. def update_chara
  748. @chara[@chara_command.index].update
  749. @chara.each do |char|
  750. char.straight if @chara.index(char) != @chara_command.index and @chara.index(char) != @chara_command.pending_index
  751. end
  752. if @chara_command.pending_index > -1
  753. @chara[@chara_command.pending_index].update
  754. end
  755. if @old_index != @chara_command.index
  756. @chara.each do |char|
  757. break if last_line
  758. pos = @original_pos[@chara.index(char)].clone
  759. pos[1] -= 160*(@chara_command.index/4)
  760. @c_target[@chara.index(char)] = pos
  761. end
  762. @c_duration = Char_Move-@c_duration
  763. end
  764. end
  765. def last_line
  766. return (@chara_command.index/4) == (@chara_command.item_max/4)
  767. end
  768. def update_info
  769. if Input.press?(Info_Key) and !@info.pressed
  770. @info.pressed = true
  771. @info.refresh
  772. time = Info_Time-(@info_back.duration+1)
  773. @info_back.move(@info_back.x, 0, 1, 1, 255, 0, time)
  774. elsif !Input.press?(Info_Key) and @info.pressed
  775. @info.pressed = false
  776. @info.refresh
  777. time = Info_Time-(@info_back.duration+1)
  778. @info_back.move(@info_back.x, -147, 1, 1, 255, 0, time)
  779. end
  780. @info_back.update
  781. @info.x, @info.y = [@info_back.x, @info_back.y]
  782. end
  783. def update_sys
  784. if Input.press?(Sys_Key) and !@sys.active
  785. if @formation
  786. @chara_command.pending_index = -1
  787. on_formation_cancel
  788. elsif @end.active
  789. command_end_cancel
  790. elsif @ccom.active
  791. chara_cancel
  792. end
  793. @sys.pressed = true
  794. @sys.refresh
  795. @sys.activate
  796. @chara_command.deactivate
  797. @sys_back.move(@sys_back.x, 0, 1, 1, 255, 0, Sys_Time)
  798. wait_move(0) until @sys_back.duration == 0
  799. @c_old_index = -1
  800. end
  801. @sys_back.update
  802. @sys.y = @sys_back.y
  803. command_sys_cancel if Input.trigger?(VJCM::Sys_Key) and @sys.pressed
  804. end
  805. def update_end
  806. @end_back.update
  807. @end.x = @end_back.x
  808. end
  809. def update_arrow
  810. if @old_index != @chara_command.index
  811. cw = @arrow.bitmap.width/Arrow[1]
  812. index = @chara_command.index
  813. pos = @c_target[index].clone
  814. pos[0] -= cw/2
  815. pos[1] -= @arrow.bitmap.height/2
  816. @arrow.move(pos[0], pos[1], 1, 1, 255, 0, Arrow_Time[0])
  817. end
  818. @arrow.update
  819. @org_arrow.update
  820. end
  821. def update_opt_arrow
  822. window = @sys if @sys.active
  823. window = @end if @end.active
  824. window = @ccom if @ccom.active
  825. return unless window
  826. if @c_old_index != window.index
  827. index = window.index
  828. cw = @opt_arrow.bitmap.width/Opt_Arrow[1]
  829. pos = window.get_pos(index)
  830. pos[0] -= cw/2
  831. pos[1] -= @opt_arrow.bitmap.height/2
  832. @opt_arrow.move(pos[0], pos[1], 1, 1, 255, 0, Arrow_Time[0])
  833. @c_old_index = index
  834. end
  835. @opt_arrow.update
  836. end
  837. # Command process
  838. def command_personal
  839. case @ccom.current_symbol
  840. when :skill
  841. SceneManager.call(Scene_Skill)
  842. when :equip
  843. SceneManager.call(Scene_Equip)
  844. when :status
  845. SceneManager.call(Scene_Status)
  846. end
  847. end
  848. def chara_ok
  849. place_ccom
  850. @ccom.index = 0
  851. @ccom_back.visible = true
  852. @ccom.activate.show
  853. @chara_command.deactivate
  854. @opt_arrow.visible = true
  855. @c_old_index = -1
  856. end
  857. def chara_cancel
  858. @ccom_back.visible = false
  859. @ccom.deactivate.hide
  860. @chara_command.activate
  861. @opt_arrow.move(@opt_arrow.x, @opt_arrow.y, 1, 1, 0, 0, Arrow_Time[0])
  862. wait_move until @opt_arrow.duration == 0
  863. @c_old_index = -1
  864. end
  865. def cursor_left?
  866. result = false
  867. result = true if @chara_command.index % 4 == 2 or @chara_command.index % 4 == 3
  868. return result
  869. end
  870. def place_ccom
  871. calc = 0
  872. calc += 1 if cursor_left?
  873. chara = Cache.picture(Char_Back)
  874. pos = @c_target[@chara_command.index].clone
  875. case calc
  876. when 0
  877. pos[0] += chara.width
  878. when 1
  879. pos[0] -= @ccom_back.width
  880. end
  881. @ccom.x , @ccom.y = pos
  882. @ccom_back.x , @ccom_back.y = pos
  883. end
  884. def on_formation_cancel
  885. if @chara_command.pending_index >= 0
  886. @chara_command.pending_index = -1
  887. @chara_command.activate
  888. @org_arrow.visible = false
  889. else
  890. @formation = false
  891. @chara_command.index = 0
  892. @sys.pressed = true
  893. @sys.refresh
  894. @sys.activate
  895. @chara_command.deactivate
  896. @sys_back.move(@sys_back.x, 0, 1, 1, 255, 0, Sys_Time)
  897. wait_move(0) until @sys_back.duration == 0
  898. @org_arrow.visible = false
  899. @chara_command.set_handler(:ok, method(:chara_ok))
  900. @chara_command.set_handler(:cancel, method(:return_scene))
  901. end
  902. end
  903. def on_formation_ok
  904. if @chara_command.pending_index >= 0
  905. $game_party.swap_order(@chara_command.index,@chara_command.pending_index)
  906.  
  907. chara = @chara[@chara_command.pending_index]
  908. @chara[@chara_command.pending_index] = @chara[@chara_command.index]
  909. @chara[@chara_command.index] = chara
  910. @chara[@chara_command.index].refresh
  911. @chara[@chara_command.pending_index].refresh
  912.  
  913. @chara.each do |char|
  914. break if last_line
  915. pos = @original_pos[@chara.index(char)].clone
  916. pos[1] -= 160*(@chara_command.index/4)
  917. @c_target[@chara.index(char)] = pos
  918. end
  919.  
  920. @c_duration = Char_Move-@c_duration
  921. @org_arrow.visible = false
  922. wait_move(2) until @c_duration == 0
  923.  
  924. @chara_command.pending_index = -1
  925. @chara_command.index = 0
  926.  
  927. @changed = true
  928. else
  929. @org_arrow.x , @org_arrow.y = [@arrow.x,@arrow.y]
  930. @org_arrow.visible = true
  931. @chara_command.pending_index = @chara_command.index
  932. end
  933. if @changed
  934. formation_complete
  935. @changed = false
  936. else
  937. @chara_command.activate
  938. end
  939. end
  940. def formation_complete
  941. @sys.pressed = true
  942. @sys.refresh
  943. @sys.activate
  944. @chara_command.deactivate
  945. @sys_back.move(@sys_back.x, 0, 1, 1, 255, 0, Sys_Time)
  946. wait_move(0) until @sys_back.duration == 0
  947. @chara_command.set_handler(:ok, method(:chara_ok))
  948. @chara_command.set_handler(:cancel, method(:return_scene))
  949. @formation = false
  950. end
  951. def command_formation
  952. command_sys_cancel
  953. @formation = true
  954. @chara_command.set_handler(:ok, method(:on_formation_ok))
  955. @chara_command.set_handler(:cancel, method(:on_formation_cancel))
  956. end
  957. def command_to_title
  958. fadeout_all
  959. SceneManager.goto(Scene_Title)
  960. end
  961. def command_shutdown
  962. fadeout_all
  963. SceneManager.exit
  964. end
  965. def command_end_cancel
  966. x = 0-@end.width
  967. @end.deactivate
  968. @opt_arrow.move(@opt_arrow.x, @opt_arrow.y, 1, 1, 0, 0, Arrow_Time[0])
  969. @end_back.move(x,@end_back.y,1,1,255,0,End_Time)
  970. wait_move(1) until @end_back.duration == 0
  971. @sys.activate
  972. end
  973. def command_sys_cancel
  974. @c_old_index = -1
  975. @sys.pressed = false
  976. @sys.refresh
  977. @chara_command.activate
  978. @opt_arrow.move(@opt_arrow.x, @opt_arrow.y, 1, 1, 0, 0, Arrow_Time[0])
  979. @sys_back.move(@sys_back.x,-147,1,1,255,0,Sys_Time)
  980. wait_move(0) until @sys_back.duration == 0
  981. @sys.deactivate
  982. end
  983. def command_game_end
  984. @end.x = Graphics.width
  985. @end_back.x = @end.x
  986. @sys.deactivate
  987. x = (Graphics.width/2)-(@end.width/2)
  988. @opt_arrow.move(@opt_arrow.x, @opt_arrow.y, 1, 1, 0, 0, Arrow_Time[0])
  989. @end_back.move(x,@end_back.y,1,1,255,0,End_Time)
  990. wait_move(1) until @end_back.duration == 0
  991. @end.activate
  992. end
  993. def wait_move(n=nil)
  994. Graphics.update
  995. Input.update
  996. update_background
  997. update_arrow
  998. update_chara
  999. @opt_arrow.update
  1000. case n
  1001. when 0
  1002. update_sys
  1003. when 1
  1004. update_end
  1005. when 2
  1006. update_char_move
  1007. end
  1008. end
  1009. def update_char_move
  1010. return if @c_duration == 0
  1011. d = @c_duration
  1012. @chara.each do |char|
  1013. pos = @c_target[@chara.index(char)]
  1014. char.x = (char.x * (d - 1) + pos[0]) / d
  1015. char.y = (char.y * (d - 1) + pos[1]) / d
  1016. end
  1017. if @formation
  1018. bitmap = Cache.picture(Org_Arrow[0])
  1019. cw = bitmap.width/Org_Arrow[1]
  1020. index = @chara_command.pending_index
  1021. chara = @chara[index]
  1022. pos = [chara.x,chara.y]
  1023. pos[0] -= cw/2
  1024. pos[1] -= bitmap.height/2
  1025. @org_arrow.x , @org_arrow.y = pos
  1026. end
  1027. @c_duration -= 1
  1028. end
  1029. def command_item
  1030. SceneManager.call(Scene_Item)
  1031. end
  1032. def command_save
  1033. SceneManager.call(Scene_Save)
  1034. end
  1035. # End of the scene
  1036. def terminate
  1037. super
  1038. dispose_background
  1039. dispose_chara
  1040. dispose_sprites
  1041. end
  1042. def dispose_background
  1043. @background.dispose
  1044. end
  1045. def dispose_chara
  1046. @chara.each {|char| char.dispose}
  1047. end
  1048. def dispose_sprites
  1049. instance_variables.each do |varname|
  1050. ivar = instance_variable_get(varname)
  1051. ivar.dispose if ivar.is_a?(Sprite)
  1052. end
  1053. end
  1054. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement