fork download
  1. #==============================================================================
  2. # □ デバッグ用スクリプト(地形を元にリージョン塗りつぶし)
  3. #==============================================================================
  4.  
  5. module Geo_To_Region
  6. BACKUP_SAVE = false # バックアップの自動作成
  7. CALL_BUTTON = :F5
  8. end
  9.  
  10. #==============================================================================
  11. #  Game_Map拡張
  12. #==============================================================================
  13. class Game_Map
  14. def geo_to_region(geo_num, region_id)
  15. # 念のためリージョンIDのチェック
  16. unless (0..63).include?(region_id)
  17. p "リージョン番号が範囲外でした:#{region_id}"
  18. return
  19. end
  20.  
  21. # バックアップの作成
  22. if Geo_To_Region::BACKUP_SAVE
  23. i = 1
  24. backup_filename = ""
  25. loop do
  26. backup_filename = sprintf("Data/Map%03d_backup%d.rvdata2", @map_id, i)
  27. result = FileTest.exist?(backup_filename)
  28. break unless result
  29. i += 1
  30. end
  31. save_data(@map, backup_filename)
  32. p "バックアップの作成:#{backup_filename}"
  33. end
  34.  
  35. # リージョンの塗り潰し
  36. for i in 0...width
  37. for j in 0...height
  38. if geo_num == autotile_type(i, j, 0)
  39. @map.data[i,j,3] &= 0x00FF
  40. @map.data[i,j,3] += region_id << 8
  41. end
  42. end
  43. end
  44.  
  45. # データの保存、及び再セットアップ
  46. map_filename = sprintf("Data/Map%03d.rvdata2", @map_id)
  47. save_data(@map, map_filename)
  48. p geo_num
  49. p region_id
  50. p "セーブ完了:#{map_filename}"
  51. setup(@map_id)
  52. end
  53. end
  54.  
  55. #==============================================================================
  56. #  実行確認用ウィンドウ
  57. #==============================================================================
  58. class Window_GeoToRegion < Window_Selectable
  59. CONTENTS_MESSAGE = [
  60. "プレイヤ位置を元にリージョン変更します",
  61. "リージョン番号を指定してください",
  62. "【↑:+1】【↓:-1】【→:+10】【←:-10】"
  63. ].freeze
  64.  
  65. attr_reader :region_id
  66.  
  67. #--------------------------------------------------------------------------
  68. # ● オブジェクト初期化
  69. #--------------------------------------------------------------------------
  70. def initialize
  71. super(0, 0, window_width, window_height)
  72. @region_id = 0
  73. update_placement
  74. refresh
  75. activate
  76. end
  77. #--------------------------------------------------------------------------
  78. # ● 色調の更新
  79. #--------------------------------------------------------------------------
  80. def update_tone
  81. self.tone.set(-255,64,0)
  82. end
  83. #--------------------------------------------------------------------------
  84. # ● ウィンドウ位置の更新
  85. #--------------------------------------------------------------------------
  86. def update_placement
  87. self.x = (Graphics.width - width) / 2
  88. self.y = (Graphics.height - height) / 2
  89. self.z = 1000
  90. end
  91. #--------------------------------------------------------------------------
  92. # ● ウィンドウ幅の取得
  93. #--------------------------------------------------------------------------
  94. def window_width
  95. return 400
  96. end
  97. #--------------------------------------------------------------------------
  98. # ● ウィンドウ高さの取得
  99. #--------------------------------------------------------------------------
  100. def window_height
  101. fitting_height(4)
  102. end
  103. #--------------------------------------------------------------------------
  104. # ● アライメントの取得
  105. #--------------------------------------------------------------------------
  106. def alignment
  107. return 1
  108. end
  109. #--------------------------------------------------------------------------
  110. # ● リフレッシュ
  111. #--------------------------------------------------------------------------
  112. def refresh
  113. contents.clear
  114. rect = Rect.new(0,0,contents.width,line_height)
  115. CONTENTS_MESSAGE.each do |mes|
  116. draw_text(rect, mes, alignment)
  117. rect.y += line_height
  118. end
  119. draw_text(rect,"リージョン番号:#{@region_id}", alignment)
  120. end
  121. #--------------------------------------------------------------------------
  122. # ● カーソル移動可能判定
  123. #--------------------------------------------------------------------------
  124. def cursor_movable?
  125. active && open?
  126. end
  127. #--------------------------------------------------------------------------
  128. # ● カーソルを下に移動
  129. #--------------------------------------------------------------------------
  130. def cursor_down(wrap = false)
  131. @region_id -= 1
  132. @region_id += 64 if @region_id < 0
  133. Sound.play_cursor
  134. refresh
  135. end
  136. #--------------------------------------------------------------------------
  137. # ● カーソルを上に移動
  138. #--------------------------------------------------------------------------
  139. def cursor_up(wrap = false)
  140. @region_id += 1
  141. @region_id %= 64
  142. Sound.play_cursor
  143. refresh
  144. end
  145. #--------------------------------------------------------------------------
  146. # ● カーソルを右に移動
  147. #--------------------------------------------------------------------------
  148. def cursor_right(wrap = false)
  149. @region_id += 10
  150. @region_id %= 64
  151. Sound.play_cursor
  152. refresh
  153. end
  154. #--------------------------------------------------------------------------
  155. # ● カーソルを左に移動
  156. #--------------------------------------------------------------------------
  157. def cursor_left(wrap = false)
  158. @region_id -= 10
  159. @region_id += 64 if @region_id < 0
  160. Sound.play_cursor
  161. refresh
  162. end
  163. end
  164.  
  165.  
  166. class Scene_GeoToRegion < Scene_MenuBase
  167. #--------------------------------------------------------------------------
  168. # ● 開始処理
  169. #--------------------------------------------------------------------------
  170. def start
  171. super
  172. create_background
  173. @geo_to_region_window = Window_GeoToRegion.new
  174. @geo_to_region_window.set_handler(:ok, method(:on_ok))
  175. @geo_to_region_window.set_handler(:cancel, method(:return_scene))
  176. end
  177. #--------------------------------------------------------------------------
  178. # ● 終了処理
  179. #--------------------------------------------------------------------------
  180. def terminate
  181. super
  182. dispose_background
  183. @geo_to_region_window.dispose
  184. end
  185. #--------------------------------------------------------------------------
  186. # ● 決定時の処理
  187. #--------------------------------------------------------------------------
  188. def on_ok
  189. geo_num = $game_map.autotile_type($game_player.x,$game_player.y,0)
  190. region_id = @geo_to_region_window.region_id
  191. $game_map.geo_to_region(geo_num, region_id)
  192. return_scene
  193. end
  194. end
  195.  
  196. #==============================================================================
  197. #  Scene_Map拡張
  198. #==============================================================================
  199. class Scene_Map < Scene_Base
  200. alias geo_to_region_update_scene update_scene
  201. def update_scene
  202. geo_to_region_update_scene
  203. update_geo_to_region unless scene_changing?
  204. end
  205.  
  206. def update_geo_to_region
  207. if Input.trigger?(Geo_To_Region::CALL_BUTTON)
  208. Sound.play_ok
  209. SceneManager.call(Scene_GeoToRegion)
  210. end
  211. end
  212. end
  213.  
  214.  
  215.  
  216.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty