cooldoode325

Patch System

Mar 9th, 2014
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.90 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ¥ Yami Engine Ace - Patch System
  4. # -- Last Updated: 2012.04.06
  5. # -- Level: Hard
  6. # -- Requires: Yami Engine Ace - Basic Module
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YSE-PatchSystem"] = true
  12.  
  13. #==============================================================================
  14. # ¥ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.04.06 - Changed fake-patch detection.
  17. # 2012.03.17 - Released Full version.
  18. # 2012.03.04 - Released Open Beta version.
  19. # 2012.03.01 - Started Script.
  20. #
  21. #==============================================================================
  22. # ¥ Introduction
  23. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  24. # This script will generate patch files for your game and make your game read
  25. # it to update things.
  26. #
  27. #==============================================================================
  28. # ¥ Instructions
  29. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. # To install this script, open up your script editor and copy/paste this script
  31. # to an open slot below ¥ Materials/‘fÞ but above ¥ Main. Remember to save.
  32. #
  33. # To open Patch Maker, use this custom script: (Use Script in Event)
  34. #---------------------------
  35. # YSE.patch_start
  36. #---------------------------
  37. #
  38. #==============================================================================
  39. # ¥ Compatibility
  40. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  41. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  42. # it will run with RPG Maker VX without adjusting.
  43. #
  44. # Do not compress patch files in any methods.
  45. #
  46. #==============================================================================
  47.  
  48. #==============================================================================
  49. # ¥ Configuration
  50. #==============================================================================
  51.  
  52. module YSE
  53. module PATCH_SYSTEM
  54.  
  55. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  56. # - Save Data Configuration -
  57. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  58. SAVE_CONFIGURATION = { # Start here.
  59. :path => "Patches",
  60. :prefix_name => "Patch",
  61. } # Do not delete this.
  62.  
  63. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  64. # - Load Data Configuration -
  65. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  66. LOAD_CONFIGURATION = { # Start here.
  67. :load_test => true, # Load Patches when Test.
  68. :quit_fake => true, # Quit Game when detected Fake Patches.
  69. :check_patch => true,
  70. } # Do not delete this.
  71.  
  72. end
  73. end
  74.  
  75. #==============================================================================
  76. # ¥ Editting anything past this point may potentially result in causing
  77. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  78. # halitosis so edit at your own risk.
  79. #==============================================================================
  80.  
  81. #==============================================================================
  82. # ¡ YSE - Patch Module
  83. #==============================================================================
  84.  
  85. module YSE
  86. module PATCH_SYSTEM
  87.  
  88. #--------------------------------------------------------------------------
  89. # load_map_data
  90. #--------------------------------------------------------------------------
  91. def self.load_map_data(map_id)
  92. result = load_data(sprintf("Data/Map%03d.rvdata2", map_id))
  93. result
  94. end
  95.  
  96. #--------------------------------------------------------------------------
  97. # slice_data
  98. #--------------------------------------------------------------------------
  99. def self.slice_data(data)
  100. # Preparing Output
  101. result = {}
  102. actors = {}
  103. classes = {}
  104. skills = {}
  105. items = {}
  106. weapons = {}
  107. armors = {}
  108. enemies = {}
  109. troops = {}
  110. states = {}
  111. animations = {}
  112. map_data = {}
  113. tileset = {}
  114. common_event = {}
  115. # Analyzing Data
  116. data.each { |key, value|
  117. case key
  118. when /(?:common_event)(\d+)?/i
  119. common_event[$1] = value
  120. when /(?:tileset)(\d+)?/i
  121. tileset[$1] = value
  122. when /(?:map)(\d+)/i
  123. map_data[$1] = value
  124. when /(?:map_info)/i
  125. map_data[:map_info] = value
  126. when /(?:actors)(\d+)/i
  127. actors[$1] = value
  128. when /(?:classes)(\d+)/i
  129. classes[$1] = value
  130. when /(?:skills)(\d+)/i
  131. skills[$1] = value
  132. when /(?:items)(\d+)/i
  133. items[$1] = value
  134. when /(?:weapons)(\d+)/i
  135. weapons[$1] = value
  136. when /(?:armors)(\d+)/i
  137. armors[$1] = value
  138. when /(?:enemies)(\d+)/i
  139. enemies[$1] = value
  140. when /(?:troops)(\d+)/i
  141. troops[$1] = value
  142. when /(?:states)(\d+)/i
  143. states[$1] = value
  144. when /(?:animations)(\d+)/i
  145. animations[$1] = value
  146. end
  147. }
  148. # Combining Data
  149. result[:common_event] = common_event
  150. result[:tileset] = tileset
  151. result[:map_data] = map_data
  152. result[:actors] = actors
  153. result[:classes] = classes
  154. result[:skills] = skills
  155. result[:items] = items
  156. result[:weapons] = weapons
  157. result[:armors] = armors
  158. result[:enemies] = enemies
  159. result[:troops] = troops
  160. result[:states] = states
  161. result[:animations] = animations
  162. result
  163. end
  164.  
  165. end # PATCH_SYSTEM
  166. end # YSE
  167.  
  168. #==============================================================================
  169. # ¡ DataManager
  170. #==============================================================================
  171.  
  172. module DataManager
  173.  
  174. #--------------------------------------------------------------------------
  175. # alias method: load_normal_database
  176. #--------------------------------------------------------------------------
  177. class<<self; alias datamanager_patch_yse_load_normal_database load_normal_database; end
  178. def self.load_normal_database
  179. datamanager_patch_yse_load_normal_database
  180. return unless YSE::PATCH_SYSTEM::LOAD_CONFIGURATION[:load_test]
  181. load_patch_database
  182. end
  183.  
  184. #--------------------------------------------------------------------------
  185. # new method: load_patch_database
  186. #--------------------------------------------------------------------------
  187. def self.load_patch_database
  188. $data_maps_patch = {}
  189. # Load Directory
  190. dir = YSE::PATCH_SYSTEM::SAVE_CONFIGURATION[:path]
  191. prefix = YSE::PATCH_SYSTEM::SAVE_CONFIGURATION[:prefix_name]
  192. begin
  193. directory = Dir.open("./#{dir}")
  194. rescue
  195. Dir.mkdir("./#{dir}", 0777)
  196. directory = Dir.open("./#{dir}")
  197. end
  198. directory.each { |filename|
  199. if filename =~ /(?:#{prefix})(\d+)?(?:.*)/i
  200. YSE.load_data("./#{dir}/#{filename}", method(:extract_patch_data), 0, :mtime)
  201. end
  202. }
  203. end
  204.  
  205. #--------------------------------------------------------------------------
  206. # new method: check_hash
  207. #--------------------------------------------------------------------------
  208. def self.check_hash(data)
  209. return unless YSE::PATCH_SYSTEM::LOAD_CONFIGURATION[:check_patch]
  210. return unless data["time"]
  211. real_check = YSE.make_hash(data["time"])
  212. return if data["hash"] == real_check
  213. msg = "System detected a fake patch. Filename: #{data["filename"]}.\n"
  214. msg += "Please delete that file or you will take your own risk.\n"
  215. msg += "Thank you."
  216. YSE.message_box("Fake Patch Detected!", msg)
  217. exit if YSE::PATCH_SYSTEM::LOAD_CONFIGURATION[:quit_fake]
  218. end
  219.  
  220. #--------------------------------------------------------------------------
  221. # new method: extract_patch_data
  222. #--------------------------------------------------------------------------
  223. def self.extract_patch_data(data, mtime)
  224. # Checking hash
  225. check_hash(data)
  226. # Slice Data
  227. temp = YSE::PATCH_SYSTEM.slice_data(data)
  228. common_event = temp[:common_event]
  229. tileset = temp[:tileset]
  230. map_data = temp[:map_data]
  231. actors = temp[:actors]
  232. classes = temp[:classes]
  233. skills = temp[:skills]
  234. items = temp[:items]
  235. weapons = temp[:weapons]
  236. armors = temp[:armors]
  237. enemies = temp[:enemies]
  238. troops = temp[:troops]
  239. states = temp[:states]
  240. animations = temp[:animations]
  241. # Common Events
  242. common_event.each { |key, value|
  243. next if value.nil?
  244. $data_common_events[key.to_i] = value
  245. }
  246. # Database
  247. tileset.each { |key, value|
  248. next if value.nil?
  249. $data_tilesets[key.to_i] = value
  250. }
  251. actors.each { |key, value|
  252. next if value.nil?
  253. $data_actors[key.to_i] = value
  254. }
  255. classes.each { |key, value|
  256. next if value.nil?
  257. $data_classes[key.to_i] = value
  258. }
  259. skills.each { |key, value|
  260. next if value.nil?
  261. $data_skills[key.to_i] = value
  262. }
  263. items.each { |key, value|
  264. next if value.nil?
  265. $data_items[key.to_i] = value
  266. }
  267. weapons.each { |key, value|
  268. next if value.nil?
  269. $data_weapons[key.to_i] = value
  270. }
  271. armors.each { |key, value|
  272. next if value.nil?
  273. $data_armors[key.to_i] = value
  274. }
  275. enemies.each { |key, value|
  276. next if value.nil?
  277. $data_enemies[key.to_i] = value
  278. }
  279. troops.each { |key, value|
  280. next if value.nil?
  281. $data_troops[key.to_i] = value
  282. }
  283. states.each { |key, value|
  284. next if value.nil?
  285. $data_states[key.to_i] = value
  286. }
  287. animations.each { |key, value|
  288. next if value.nil?
  289. $data_animations[key.to_i] = value
  290. }
  291. # Maps
  292. $data_mapinfos = map_data[:map_info] if map_data[:map_info]
  293. map_data.delete(:map_info)
  294. $data_maps_patch = map_data
  295. end
  296.  
  297. #--------------------------------------------------------------------------
  298. # alias method: reload_map_if_updated
  299. #--------------------------------------------------------------------------
  300. class<<self; alias datamanager_patch_yse_reload_map_if_updated reload_map_if_updated; end
  301. def self.reload_map_if_updated
  302. datamanager_patch_yse_reload_map_if_updated
  303. reload_map_if_patched
  304. end
  305.  
  306. #--------------------------------------------------------------------------
  307. # new method: reload_map_if_patched
  308. #--------------------------------------------------------------------------
  309. def self.reload_map_if_patched
  310. unless $data_maps_patch[$game_map.map_id].nil?
  311. $game_map.setup($game_map.map_id)
  312. $game_player.center($game_player.x, $game_player.y)
  313. $game_player.make_encounter_count
  314. end
  315. end
  316.  
  317. end # DataManager
  318.  
  319. #==============================================================================
  320. # ¡ Game_Map
  321. #==============================================================================
  322.  
  323. class Game_Map
  324.  
  325. #--------------------------------------------------------------------------
  326. # overwrite method: setup
  327. #--------------------------------------------------------------------------
  328. def setup(map_id)
  329. @map_id = map_id
  330. if $data_maps_patch.nil? || $data_maps_patch[map_id.to_s].nil?
  331. @map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
  332. else
  333. @map = $data_maps_patch[map_id.to_s]
  334. end
  335. @tileset_id = @map.tileset_id
  336. @display_x = 0
  337. @display_y = 0
  338. referesh_vehicles
  339. setup_events
  340. setup_scroll
  341. setup_parallax
  342. setup_battleback
  343. @need_refresh = false
  344. end
  345.  
  346. end # Game_Map
  347.  
  348. #==============================================================================
  349. # ¡ Window_Patch_Base
  350. #==============================================================================
  351.  
  352. class Window_Patch_Base < Window_Selectable
  353.  
  354. #--------------------------------------------------------------------------
  355. # initialize
  356. #--------------------------------------------------------------------------
  357. def initialize
  358. super((Graphics.width - 408) / 2, (Graphics.height - 344) / 2, 408, 344)
  359. @data = []
  360. refresh
  361. end
  362.  
  363. #--------------------------------------------------------------------------
  364. # item_max
  365. #--------------------------------------------------------------------------
  366. def item_max
  367. return @data.nil? ? 1 : @data.size
  368. end
  369.  
  370. #--------------------------------------------------------------------------
  371. # item_max
  372. #--------------------------------------------------------------------------
  373. def make_data_list
  374. # Loading Data.
  375. end
  376.  
  377. #--------------------------------------------------------------------------
  378. # highlight
  379. #--------------------------------------------------------------------------
  380. def highlight(index)
  381. # Highlight Data.
  382. end
  383.  
  384. #--------------------------------------------------------------------------
  385. # draw_item
  386. #--------------------------------------------------------------------------
  387. def draw_item(index)
  388. name = @data[index]
  389. rect = item_rect(index)
  390. rect.width -= 4
  391. change_color(normal_color)
  392. rect.x += 4
  393. draw_text(rect, "#{index + 1}, ", 0)
  394. change_color(normal_color)
  395. change_color(Color.new(100,100,100)) unless highlight(index)
  396. rect.x += 40
  397. draw_text(rect, "#{name}", 0)
  398. change_color(Color.new(255,175,175))
  399. rect.x -= 44
  400. draw_text(rect, sprintf("(ID: %03d)", index + 1), 2)
  401. end
  402.  
  403. #--------------------------------------------------------------------------
  404. # refresh
  405. #--------------------------------------------------------------------------
  406. def refresh
  407. make_data_list
  408. create_contents
  409. draw_all_items
  410. end
  411.  
  412. #--------------------------------------------------------------------------
  413. # refresh
  414. #--------------------------------------------------------------------------
  415. def set_on_off
  416. # Set on/off
  417. end
  418.  
  419. end # Window_Patch_Base
  420.  
  421. #==============================================================================
  422. # ¡ Window_Patch_Maps
  423. #==============================================================================
  424.  
  425. class Window_Patch_Maps < Window_Patch_Base
  426.  
  427. #--------------------------------------------------------------------------
  428. # initialize
  429. #--------------------------------------------------------------------------
  430. def initialize
  431. $patch_map_temp = []
  432. super
  433. end
  434.  
  435. #--------------------------------------------------------------------------
  436. # make_data_list
  437. #--------------------------------------------------------------------------
  438. def make_data_list
  439. $data_mapinfos.each { |key, value|
  440. @data.push(value.name)
  441. }
  442. end
  443.  
  444. #--------------------------------------------------------------------------
  445. # highlight
  446. #--------------------------------------------------------------------------
  447. def highlight(index)
  448. $patch_map_temp.include?(index + 1)
  449. end
  450.  
  451. #--------------------------------------------------------------------------
  452. # set_on_off
  453. #--------------------------------------------------------------------------
  454. def set_on_off
  455. if $patch_map_temp.include?(index + 1)
  456. $patch_map_temp.delete(index + 1)
  457. draw_item(index)
  458. else
  459. $patch_map_temp.push(index + 1)
  460. draw_item(index)
  461. end
  462. end
  463.  
  464. end # Window_Patch_Maps
  465.  
  466. #==============================================================================
  467. # ¡ Window_Patch_Common_Event
  468. #==============================================================================
  469.  
  470. class Window_Patch_Common_Event < Window_Patch_Base
  471.  
  472. #--------------------------------------------------------------------------
  473. # initialize
  474. #--------------------------------------------------------------------------
  475. def initialize
  476. $patch_ce_temp = []
  477. super
  478. end
  479.  
  480. #--------------------------------------------------------------------------
  481. # make_data_list
  482. #--------------------------------------------------------------------------
  483. def make_data_list
  484. $data_common_events.each { |value|
  485. next if value.nil?
  486. @data.push(value.name)
  487. }
  488. end
  489.  
  490. #--------------------------------------------------------------------------
  491. # highlight
  492. #--------------------------------------------------------------------------
  493. def highlight(index)
  494. $patch_ce_temp.include?(index + 1)
  495. end
  496.  
  497. #--------------------------------------------------------------------------
  498. # refresh
  499. #--------------------------------------------------------------------------
  500. def set_on_off
  501. if $patch_ce_temp.include?(index + 1)
  502. $patch_ce_temp.delete(index + 1)
  503. draw_item(index)
  504. else
  505. $patch_ce_temp.push(index + 1)
  506. draw_item(index)
  507. end
  508. end
  509.  
  510. end # Window_Patch_Common_Event
  511.  
  512. #==============================================================================
  513. # ¡ Window_Patch_Tileset
  514. #==============================================================================
  515.  
  516. class Window_Patch_Tileset < Window_Patch_Base
  517.  
  518. #--------------------------------------------------------------------------
  519. # initialize
  520. #--------------------------------------------------------------------------
  521. def initialize
  522. $patch_ts_temp = []
  523. super
  524. end
  525.  
  526. #--------------------------------------------------------------------------
  527. # make_data_list
  528. #--------------------------------------------------------------------------
  529. def make_data_list
  530. $data_tilesets.each { |value|
  531. next if value.nil?
  532. @data.push(value.name)
  533. }
  534. end
  535.  
  536. #--------------------------------------------------------------------------
  537. # highlight
  538. #--------------------------------------------------------------------------
  539. def highlight(index)
  540. $patch_ts_temp.include?(index + 1)
  541. end
  542.  
  543. #--------------------------------------------------------------------------
  544. # refresh
  545. #--------------------------------------------------------------------------
  546. def set_on_off
  547. if $patch_ts_temp.include?(index + 1)
  548. $patch_ts_temp.delete(index + 1)
  549. draw_item(index)
  550. else
  551. $patch_ts_temp.push(index + 1)
  552. draw_item(index)
  553. end
  554. end
  555.  
  556. end # Window_Patch_Tileset
  557.  
  558. PATCH_HASH_NAME = ["Actors", "Classes", "Skills", "Items", "Weapons", "Armors",
  559. "Enemies", "Troops", "States", "Animations"]
  560. PATCH_HASH_NAME.each { |patch_name|
  561. cStr = %Q(
  562. class Window_Patch_#{patch_name} < Window_Patch_Base
  563.  
  564. #--------------------------------------------------------------------------
  565. # initialize
  566. #--------------------------------------------------------------------------
  567. def initialize
  568. $patch_#{patch_name.downcase}_temp = []
  569. super
  570. end
  571.  
  572. #--------------------------------------------------------------------------
  573. # make_data_list
  574. #--------------------------------------------------------------------------
  575. def make_data_list
  576. $data_#{patch_name.downcase}.each { |value|
  577. next if value.nil?
  578. @data.push(value.name)
  579. }
  580. end
  581.  
  582. #--------------------------------------------------------------------------
  583. # highlight
  584. #--------------------------------------------------------------------------
  585. def highlight(index)
  586. $patch_#{patch_name.downcase}_temp.include?(index + 1)
  587. end
  588.  
  589. #--------------------------------------------------------------------------
  590. # refresh
  591. #--------------------------------------------------------------------------
  592. def set_on_off
  593. if $patch_#{patch_name.downcase}_temp.include?(index + 1)
  594. $patch_#{patch_name.downcase}_temp.delete(index + 1)
  595. draw_item(index)
  596. else
  597. $patch_#{patch_name.downcase}_temp.push(index + 1)
  598. draw_item(index)
  599. end
  600. end
  601.  
  602. end
  603. )
  604. eval(cStr)
  605. }
  606.  
  607. #==============================================================================
  608. # ¡ Window_Patch_Command
  609. #==============================================================================
  610.  
  611. class Window_Patch_Command < Window_Command
  612.  
  613. #--------------------------------------------------------------------------
  614. # initialize
  615. #--------------------------------------------------------------------------
  616. def initialize
  617. super(0, (Graphics.height - fitting_height(4)) / 2)
  618. end
  619.  
  620. #--------------------------------------------------------------------------
  621. # window_width
  622. #--------------------------------------------------------------------------
  623. def window_width
  624. return Graphics.width
  625. end
  626.  
  627. #--------------------------------------------------------------------------
  628. # visible_line_number
  629. #--------------------------------------------------------------------------
  630. def visible_line_number
  631. return 4
  632. end
  633.  
  634. #--------------------------------------------------------------------------
  635. # col_max
  636. #--------------------------------------------------------------------------
  637. def col_max
  638. 4
  639. end
  640.  
  641. #--------------------------------------------------------------------------
  642. # make_command_list
  643. #--------------------------------------------------------------------------
  644. def make_command_list
  645. add_command("Maps", :maps, true)
  646. add_command("Common Events", :ce, true)
  647. add_command("Tilesets", :ts, true)
  648. PATCH_HASH_NAME.each { |patch_name|
  649. cStr = "add_command(\"#{patch_name}\", :#{patch_name.downcase}, true)"
  650. eval(cStr)
  651. }
  652. add_command("Patch!", :patch, true)
  653. add_command("Patch All Things", :patch_all, true)
  654. add_command("Exit", :cancel, true)
  655. end
  656.  
  657. end # Window_Patch_Command
  658.  
  659. #==============================================================================
  660. # ¡ Scene_Patch_YSE
  661. #==============================================================================
  662.  
  663. class Scene_Patch_YSE < Scene_Base
  664.  
  665. #--------------------------------------------------------------------------
  666. # start
  667. #--------------------------------------------------------------------------
  668. def start
  669. super
  670. create_all_windows
  671. @command_window.activate
  672. @command_window.select(0)
  673. end
  674.  
  675. #--------------------------------------------------------------------------
  676. # create_all_windows
  677. #--------------------------------------------------------------------------
  678. def create_all_windows
  679. #---
  680. @command_window = Window_Patch_Command.new
  681. @command_window.viewport = @viewport
  682. @command_window.set_handler(:maps, method(:patch_maps))
  683. @command_window.set_handler(:ts, method(:patch_tileset))
  684. @command_window.set_handler(:ce, method(:patch_common_event))
  685. @command_window.set_handler(:patch, method(:apply_patch))
  686. @command_window.set_handler(:patch_all, method(:apply_patch_all))
  687. PATCH_HASH_NAME.each { |patch_name|
  688. cStr = "@command_window.set_handler(:#{patch_name.downcase}, method(:patch_#{patch_name.downcase}))"
  689. eval(cStr)
  690. }
  691. @command_window.set_handler(:cancel, method(:return_scene))
  692. #---
  693. @maps_window = Window_Patch_Maps.new
  694. @maps_window.viewport = @viewport
  695. @maps_window.set_handler(:ok, method(:on_maps_ok))
  696. @maps_window.set_handler(:cancel, method(:on_maps_cancel))
  697. @maps_window.close
  698. #---
  699. PATCH_HASH_NAME.each { |patch_name|
  700. cStr = %Q(
  701. @#{patch_name.downcase}_window = Window_Patch_#{patch_name}.new
  702. @#{patch_name.downcase}_window.viewport = @viewport
  703. @#{patch_name.downcase}_window.set_handler(:ok, method(:on_#{patch_name.downcase}_ok))
  704. @#{patch_name.downcase}_window.set_handler(:cancel, method(:on_#{patch_name.downcase}_cancel))
  705. @#{patch_name.downcase}_window.close
  706. )
  707. eval(cStr)
  708. }
  709. #---
  710. @ce_window = Window_Patch_Common_Event.new
  711. @ce_window.viewport = @viewport
  712. @ce_window.set_handler(:ok, method(:on_ce_ok))
  713. @ce_window.set_handler(:cancel, method(:on_ce_cancel))
  714. @ce_window.close
  715. #---
  716. @ts_window = Window_Patch_Tileset.new
  717. @ts_window.viewport = @viewport
  718. @ts_window.set_handler(:ok, method(:on_ts_ok))
  719. @ts_window.set_handler(:cancel, method(:on_ts_cancel))
  720. @ts_window.close
  721. end
  722.  
  723. #--------------------------------------------------------------------------
  724. # patch_maps
  725. #--------------------------------------------------------------------------
  726. def patch_maps
  727. @command_window.deactivate
  728. @maps_window.open
  729. @maps_window.activate
  730. @maps_window.select(0)
  731. end
  732.  
  733. #--------------------------------------------------------------------------
  734. # patch_tileset
  735. #--------------------------------------------------------------------------
  736. def patch_tileset
  737. @command_window.deactivate
  738. @ts_window.open
  739. @ts_window.activate
  740. @ts_window.select(0)
  741. end
  742.  
  743. #--------------------------------------------------------------------------
  744. # patch_common_event
  745. #--------------------------------------------------------------------------
  746. def patch_common_event
  747. @command_window.deactivate
  748. @ce_window.open
  749. @ce_window.activate
  750. @ce_window.select(0)
  751. end
  752.  
  753. PATCH_HASH_NAME.each { |patch_name|
  754. cStr = %Q(
  755. def patch_#{patch_name.downcase}
  756. @command_window.deactivate
  757. @#{patch_name.downcase}_window.open
  758. @#{patch_name.downcase}_window.activate
  759. @#{patch_name.downcase}_window.select(0)
  760. end
  761. )
  762. module_eval(cStr)
  763. }
  764.  
  765. #--------------------------------------------------------------------------
  766. # on_maps_ok
  767. #--------------------------------------------------------------------------
  768. def on_maps_ok
  769. @maps_window.set_on_off
  770. @maps_window.activate
  771. end
  772.  
  773. #--------------------------------------------------------------------------
  774. # on_maps_ok
  775. #--------------------------------------------------------------------------
  776. def on_maps_cancel
  777. @maps_window.deactivate
  778. @maps_window.close
  779. @command_window.activate
  780. end
  781.  
  782. PATCH_HASH_NAME.each { |patch_name|
  783. cStr = %Q(
  784. def on_#{patch_name.downcase}_ok
  785. @#{patch_name.downcase}_window.set_on_off
  786. @#{patch_name.downcase}_window.activate
  787. end
  788. def on_#{patch_name.downcase}_cancel
  789. @#{patch_name.downcase}_window.deactivate
  790. @#{patch_name.downcase}_window.close
  791. @command_window.activate
  792. end
  793. )
  794. module_eval(cStr)
  795. }
  796.  
  797. #--------------------------------------------------------------------------
  798. # on_ce_ok
  799. #--------------------------------------------------------------------------
  800. def on_ce_ok
  801. @ce_window.set_on_off
  802. @ce_window.activate
  803. end
  804.  
  805. #--------------------------------------------------------------------------
  806. # on_ce_cancel
  807. #--------------------------------------------------------------------------
  808. def on_ce_cancel
  809. @ce_window.deactivate
  810. @ce_window.close
  811. @command_window.activate
  812. end
  813.  
  814. #--------------------------------------------------------------------------
  815. # on_ts_ok
  816. #--------------------------------------------------------------------------
  817. def on_ts_ok
  818. @ts_window.set_on_off
  819. @ts_window.activate
  820. end
  821.  
  822. #--------------------------------------------------------------------------
  823. # on_ts_cancel
  824. #--------------------------------------------------------------------------
  825. def on_ts_cancel
  826. @ts_window.deactivate
  827. @ts_window.close
  828. @command_window.activate
  829. end
  830.  
  831. #--------------------------------------------------------------------------
  832. # apply_patch
  833. #--------------------------------------------------------------------------
  834. def apply_patch
  835. dir = YSE::PATCH_SYSTEM::SAVE_CONFIGURATION[:path]
  836. prefix = YSE::PATCH_SYSTEM::SAVE_CONFIGURATION[:prefix_name]
  837. time = Time.now.strftime("%s")
  838. filename = YSE.make_filename("#{prefix}#{time}", dir)
  839. @temporary = {}
  840. $patch_map_temp.each { |id|
  841. next if id.nil?
  842. map_data = YSE::PATCH_SYSTEM.load_map_data(id)
  843. @temporary["map#{id}"] = map_data
  844. @temporary["map_info"] = $data_mapinfos
  845. }
  846. $patch_ce_temp.each { |id|
  847. next if id.nil?
  848. @temporary["common_event#{id}"] = $data_common_events[id]
  849. }
  850. $patch_ts_temp.each { |id|
  851. next if id.nil?
  852. @temporary["tileset#{id}"] = $data_tilesets[id]
  853. }
  854. PATCH_HASH_NAME.each { |patch_name|
  855. cStr = %Q(
  856. $patch_#{patch_name.downcase}_temp.each { |id|
  857. next if id.nil?
  858. @temporary["#{patch_name.downcase}"+id.to_s] = $data_#{patch_name.downcase}[id]
  859. }
  860. )
  861. eval(cStr)
  862. }
  863. @temporary["hash"] = YSE.make_hash(time)
  864. @temporary["time"] = time
  865. @temporary["filename"] = filename
  866. YSE.save_data(filename, @temporary)
  867. YSE.message_box("Patch System","Create Patch Complete! Location: #{filename}. Click OK to Exit.")
  868. exit
  869. end
  870.  
  871. #--------------------------------------------------------------------------
  872. # apply_patch_all
  873. #--------------------------------------------------------------------------
  874. def apply_patch_all
  875. $data_mapinfos.each_key { |i|
  876. next if i == 0
  877. $patch_map_temp.push(i)
  878. }
  879. $data_common_events.size.times { |i|
  880. next if i == 0
  881. $patch_ce_temp.push(i)
  882. }
  883. $data_tilesets.size.times { |i|
  884. next if i == 0
  885. $patch_ts_temp.push(i)
  886. }
  887. PATCH_HASH_NAME.each { |patch_name|
  888. cStr = %Q(
  889. $data_#{patch_name.downcase}.size.times { |i|
  890. next if i == 0
  891. $patch_#{patch_name.downcase}_temp.push(i)
  892. }
  893. )
  894. eval(cStr)
  895. }
  896. apply_patch
  897. end
  898.  
  899. end # Scene_Patch_YSE
  900.  
  901. #==============================================================================
  902. #
  903. # ¥ End of File
  904. #
  905. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment