dsiver144

TileViewer 1.0

Apr 29th, 2016
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.93 KB | None | 0 0
  1. #==========================================================================
  2. # TileViewer 1.0 -
  3. # DARK SKY -
  4. # PERFECT TOOL FOR DARK'S HOUSE DECORATING SYSTEM -
  5. #==========================================================================
  6. # Put this Below Dark's House Decorating System Script.
  7. #--------------------------------------------------------------------------
  8. # F8 : Open Scene
  9. #==========================================================================
  10. class Scene_TileViewer < Scene_Base
  11. include Dark_HouseDecorate
  12. TILE_PAGE = ["B","C","D","E"]
  13. #--------------------------------------------------------------------------
  14. # * Create Tilemap
  15. #--------------------------------------------------------------------------
  16. def create_tilemap
  17. @viewport1 = Viewport.new
  18. @tilemap = Tilemap.new(@viewport1)
  19. @map = load_data(sprintf("Data/Map%03d.rvdata2", $game_map.map_id))
  20. @tilemap.map_data = @map.data
  21. load_tileset
  22. end
  23. #--------------------------------------------------------------------------
  24. # * Load Tileset
  25. #--------------------------------------------------------------------------
  26. def load_tileset
  27. @tileset = $game_map.tileset
  28. @tileset.tileset_names.each_with_index do |name, i|
  29. @tilemap.bitmaps[i] = Cache.tileset(name)
  30. end
  31. @tilemap.flags = @tileset.flags
  32. end
  33. #--------------------------------------------------------------------------
  34. # * Terminate
  35. #--------------------------------------------------------------------------
  36. def terminate
  37. super
  38. @tilemap.dispose
  39. @sprite.bitmap.dispose
  40. @sprite.dispose
  41. @contents.dispose
  42. end
  43. #--------------------------------------------------------------------------
  44. # * Change key
  45. #--------------------------------------------------------------------------
  46. def change_key
  47. if @sprite
  48. @sprite.dispose
  49. end
  50. if @contents
  51. @contents.dispose
  52. end
  53. @key = @key = TILE_PAGE[@index]
  54. @sprite = Sprite.new
  55. bitmap = @tilemap.bitmaps[TableH[@key]]
  56. rect = Rect.new(0,0,32*8,32*18)
  57. rect2 = Rect.new(32*8,0,32*9,32*18)
  58. bitmap2 = Bitmap.new(600,2000)
  59. bitmap2.blt(0,0,bitmap,rect)
  60. bitmap2.blt(0,32*(9+7),bitmap,rect2)
  61. bitmap2.font.size = 20
  62. counter = @key == "B"? 0 : 1
  63. for j in 0..((9+7)*2 - 1)
  64. for i in 0..(7)
  65. bitmap2.draw_text(i*32+5,j*32,32,32,"#{counter}")
  66. counter += 1
  67. end
  68. end
  69. @sprite.bitmap = bitmap2
  70. @sprite.x = 544.0 / 2 - 32*7 / 2 + 100
  71. @sprite.z = 999
  72. @contents = Sprite.new
  73. @contents.viewport = @viewport1
  74. @contents.bitmap = Bitmap.new(544,416)
  75. @contents.bitmap.font.size = 17
  76. @contents.bitmap.font.name = ["SP3 - Hero",Font.default_name]
  77. @contents.bitmap.font.bold = true
  78. @contents.bitmap.fill_rect(0,0,544,416,Color.new(0,0,0,200))
  79. @contents.bitmap.fill_rect(255,0,264,416,Color.new(0,0,0,230))
  80. @contents.bitmap.draw_text(10,0,500,32,"TileViewer 1.0 by Dark Sky")
  81. @contents.bitmap.fill_rect(10,22,50*4,1,Color.new(255,255,255,200))
  82. @contents.bitmap.font.size = 16
  83. @contents.bitmap.font.bold = false
  84. y = 14
  85. @contents.bitmap.draw_text(10,y,500,32,"Current Tile Page: #{@key}")
  86. y += 12
  87. @help_txt = ["Map_ID : #{$game_map.map_id}","UP/DOWN Key: Move Up/Down","X: Back","LEFT/RIGHT: Change TILE Page","SHIFT: Speed Up!"]
  88. @help_txt.each do |text|
  89. @contents.bitmap.draw_text(10,y,500,32,text)
  90. y += 12
  91. end
  92. end
  93. #--------------------------------------------------------------------------
  94. # * Start
  95. #--------------------------------------------------------------------------
  96. def start
  97. super
  98. create_tilemap
  99. @index = 0
  100. @key = TILE_PAGE[@index]
  101. @speed = 1
  102. change_key
  103. end
  104. #--------------------------------------------------------------------------
  105. # * Update
  106. #--------------------------------------------------------------------------
  107. def update
  108. super
  109. if Input.press?(:A)
  110. @speed = 5
  111. else
  112. @speed = 1
  113. end
  114. if Input.trigger?(:RIGHT)
  115. @index += 1
  116. if @index > TILE_PAGE.size - 1
  117. @index = 0
  118. end
  119. change_key
  120. end
  121. if Input.trigger?(:LEFT)
  122. @index -= 1
  123. if @index < 0
  124. @index = TILE_PAGE.size - 1
  125. end
  126. change_key
  127. end
  128. if Input.press?(:UP)
  129. @sprite.oy -= @speed
  130. end
  131. if Input.press?(:DOWN)
  132. @sprite.oy += @speed
  133. end
  134. if Input.press?(:B)
  135. @sprite.bitmap.dispose
  136. @sprite.dispose
  137. return_scene
  138. end
  139. end
  140. end
  141. #==========================================================================
  142. # * Scene Map
  143. #==========================================================================
  144. class Scene_Map
  145. alias dark_stuff_tileviewer_update update
  146. def update(*args)
  147. dark_stuff_tileviewer_update(*args)
  148. if Input.trigger?(:F8) && $TEST
  149. SceneManager.call(Scene_TileViewer)
  150. end
  151. end
  152. end
Add Comment
Please, Sign In to add comment