Guest User

Untitled

a guest
May 2nd, 2016
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.39 KB | None | 0 0
  1. #===============================================================================
  2. # * SEE - Item Menu ACE
  3. # * By Crazyninjaguy
  4. # * Requested by BizarreMonkey
  5. # * http://www.stormxstudios.co.uk
  6. # * 02/01/2012
  7. # * If you like my scripts, please show your appreciation by checking out
  8. # my friendly, helpful Game Development Community, StormCross Studios.
  9. # ---------------------------------------------------------------------------
  10. # * Aliased Methods
  11. # - start (Scene_Item)
  12. # - update_item_selection (Scene_Item)
  13. # - terminate (Scene_Item)
  14. # ---------------------------------------------------------------------------
  15. # * This script adds a new item description window with support for four text
  16. # text lines and a 96 x 96 picture in Graphics/Pictures.
  17. # * To add a picture for your item, add this into the notebox of that item in
  18. # the database
  19. # * <picture potionpicture>
  20. # * Replacing potionpicture for your image filename.
  21. #===============================================================================
  22.  
  23. $imported = {} if $imported == nil
  24. $imported["SEE - Item Menu Ace"] = true
  25.  
  26.  
  27.  
  28.  
  29. #===============================================================================
  30. # * Main StormCross Engine Evolution Configuration Module
  31. #===============================================================================
  32. module SEE
  33. #=============================================================================
  34. # * Item Menu Configuration Module
  35. #=============================================================================
  36. module Item
  37. ITEMS = []
  38. #===========================================================================
  39. # * The number at the beginning of the ITEMS[1] is the item id in the
  40. # database.
  41. # * Each line of text in quotes is a seperate line in the window.
  42. # Seperate each with a comma
  43. #===========================================================================
  44. ITEMS[1] = ["A letter from Mary-Anne Coletta.", "A personal letter that started this whole mess.", "In it Mary-Anne asks me for help and alludes to a terrible", "danger that she and the rest of the town are in."]
  45. ITEMS[2] = ["This is a high potion.", "It's very nice and restores 2500hp.", "Costs 150 Gil in a shop.", "Has a purplish glow."]
  46.  
  47. ITEM_COLOURS = []
  48. #===========================================================================
  49. # * As with the previous, the number at the beginning of COLOURS[1] is the
  50. # item id in the database.
  51. # * The numbers in the array correspond to the text_color() argument of
  52. # window base. 0 is white. You can find these by looking at the
  53. # Window.png graphic. Seperate each value with a comma.
  54. #===========================================================================
  55. ITEM_COLOURS[1] = [6, 0, 0, 0]
  56.  
  57. end # Item
  58. end # SEE
  59.  
  60.  
  61. module ReadNote
  62. module DTOPM
  63.  
  64. #Window skin to use, place in system.
  65. WINDOW = ('Window')
  66.  
  67. #Status Window X
  68. SX = 10
  69.  
  70. #Status Window Y
  71. SY = 10
  72.  
  73. end
  74.  
  75. def read_note(note, tag, position = 1)
  76. note2 = note.dup
  77. lines = note2.scan(/<.+>/)
  78. for line in lines
  79. words = line.split(/[ <>]/)
  80. words.delete("")
  81. for word in words
  82. if word == tag
  83. result = words[words.index(word) + position]
  84. return true if result == nil
  85. return result
  86. end
  87. end
  88. end
  89. return false
  90. end
  91. end
  92.  
  93. class Scene_Item < Scene_ItemBase
  94. def start
  95. super
  96. create_description_window
  97. create_category_window
  98. create_item_window
  99. create_status_window
  100. @description_index = 0
  101. end
  102. def create_description_window
  103. @description = Window_ItemDescription.new
  104. @description.viewport = @viewport
  105. end
  106. def create_category_window
  107. @category_window = Window_ItemCategory.new
  108. @category_window.viewport = @viewport
  109. @category_window.y = @description.height
  110. @category_window.set_handler(:ok, method(:on_category_ok))
  111. @category_window.set_handler(:cancel, method(:return_scene))
  112. end
  113. #--------------------------------------------------------------------------
  114. # * Create Status Window
  115. #--------------------------------------------------------------------------
  116. def create_status_window
  117. @status_window = Window_MenuInfo.new((DTOPM::SX), (DTOPM::SY))
  118. @status_window.windowskin = Cache.system(DTOPM::WINDOW)
  119. end
  120.  
  121. def create_item_window
  122. wy = (@category_window.y - 82) + (@category_window.height - 160)
  123. wh = (Graphics.height - 264 )#wy
  124. @item_window = Window_ItemList.new(104 , wy, (Graphics.width - 114), wh)
  125. @item_window.set_handler(:ok, method(:on_item_ok))
  126. @item_window.set_handler(:cancel, method(:on_item_cancel))
  127. @category_window.item_window = @item_window
  128. @item_window.viewport = @viewport
  129. end
  130.  
  131. def on_item_cancel
  132. @item_window.unselect
  133. @category_window.activate
  134. @description.refresh(nil)
  135. end
  136.  
  137. def update
  138. super
  139. if @description_index != @item_window.index
  140. @description.refresh(@item_window.item)
  141. @description_index = @item_window.index
  142. end
  143. end
  144. end
  145.  
  146. class Window_ItemDescription < Window_Base
  147. include ReadNote
  148. include SEE::Item
  149. def initialize (item = nil)
  150. super(10, 202, (Graphics.width - 20), (Graphics.height - 212))
  151. refresh(item)
  152. end # initialize
  153.  
  154. class Window_MenuInfo < Window_Base
  155. #--------------------------------------------------------------------------
  156. # * Object Initialization
  157. # x : window X coordinate
  158. # y : window Y coordinate
  159. #--------------------------------------------------------------------------
  160. def initialize(x, y)
  161. super(x, y, 0, 52)
  162. refresh
  163. end
  164. #--------------------------------------------------------------------------
  165. # * Refresh
  166. #--------------------------------------------------------------------------
  167. def refresh
  168. self.contents.clear
  169. @actor = $game_party.members[0]
  170. draw_actor_face(@actor, 0, 0, width = 92)
  171. draw_actor_name(@actor, 12, 104)
  172. end
  173. end
  174.  
  175. def refresh(item)
  176. self.contents.clear
  177. if item != nil
  178. if item.is_a?(RPG::Item)
  179. picture = read_note($data_items[item.id].note, "picture")
  180. =begin elsif item.is_a?(RPG::Weapon)
  181. picture = read_note($data_weapons[item.id].note, "picture")
  182. elsif item.is_a?(RPG::Armor)
  183. picture = read_note($data_armors[item.id].note, "picture")
  184. end
  185. =end
  186. if picture != false
  187. bitmap = Cache.picture(picture)
  188. rect = Rect.new(0, 0, 96, 96)
  189. self.contents.blt(0, 0, bitmap, rect)
  190. end
  191.  
  192. if item.is_a?(RPG::Item)
  193. if ITEMS[item.id] != nil
  194. if ITEM_COLOURS[item.id] != nil
  195. self.contents.font.color = text_color(ITEM_COLOURS[item.id][0])
  196. self.contents.draw_text(0, 0, width - 128, 24, ITEMS[item.id][0])
  197. self.contents.font.color = text_color(ITEM_COLOURS[item.id][1])
  198. self.contents.draw_text(0, 24, width - 128, 24, ITEMS[item.id][1])
  199. self.contents.font.color = text_color(ITEM_COLOURS[item.id][2])
  200. self.contents.draw_text(0, 48, width - 128, 24, ITEMS[item.id][2])
  201. self.contents.font.color = text_color(ITEM_COLOURS[item.id][3])
  202. self.contents.draw_text(0, 72, width - 128, 24, ITEMS[item.id][3])
  203. self.contents.font.color = text_color(0)
  204. else
  205. self.contents.draw_text(0, 0, width - 128, 24, ITEMS[item.id][0])
  206. self.contents.draw_text(0, 24, width - 128, 24, ITEMS[item.id][1])
  207. self.contents.draw_text(0, 48, width - 128, 24, ITEMS[item.id][2])
  208. self.contents.draw_text(0, 72, width - 128, 24, ITEMS[item.id][3])
  209. end
  210. end
  211. =begin
  212. elsif item.is_a?(RPG::Weapon)
  213. if WEAPONS[item.id] != nil
  214. if WEAPON_COLOURS[item.id] != nil
  215. self.contents.font.color = text_color(WEAPON_COLOURS[item.id][0])
  216. self.contents.draw_text(0, 0, width - 128, 24, WEAPONS[item.id][0])
  217. self.contents.font.color = text_color(WEAPON_COLOURS[item.id][1])
  218. self.contents.draw_text(0, 24, width - 128, 24, WEAPONS[item.id][1])
  219. self.contents.font.color = text_color(WEAPON_COLOURS[item.id][2])
  220. self.contents.draw_text(0, 48, width - 128, 24, WEAPONS[item.id][2])
  221. self.contents.font.color = text_color(WEAPON_COLOURS[item.id][3])
  222. self.contents.draw_text(0, 72, width - 128, 24, WEAPONS[item.id][3])
  223. self.contents.font.color = text_color(0)
  224. else
  225. self.contents.draw_text(96, 0, width - 128, 24, WEAPONS[item.id][0])
  226. self.contents.draw_text(96, 24, width - 128, 24, WEAPONS[item.id][1])
  227. self.contents.draw_text(96, 48, width - 128, 24, WEAPONS[item.id][2])
  228. self.contents.draw_text(96, 72, width - 128, 24, WEAPONS[item.id][3])
  229. end
  230. end
  231.  
  232. elsif item.is_a?(RPG::Armor)
  233. if ARMORS[item.id] != nil
  234. if ARMOR_COLOURS[item.id] != nil
  235. self.contents.font.color = text_color(ARMOR_COLOURS[item.id][0])
  236. self.contents.draw_text(96, 0, width - 128, 24, ARMORS[item.id][0])
  237. self.contents.font.color = text_color(ARMOR_COLOURS[item.id][1])
  238. self.contents.draw_text(96, 24, width - 128, 24, ARMORS[item.id][1])
  239. self.contents.font.color = text_color(ARMOR_COLOURS[item.id][2])
  240. self.contents.draw_text(96, 48, width - 128, 24, ARMORS[item.id][2])
  241. self.contents.font.color = text_color(ARMOR_COLOURS[item.id][3])
  242. self.contents.draw_text(96, 72, width - 128, 24, ARMORS[item.id][3])
  243. self.contents.font.color = text_color(0)
  244. else
  245. self.contents.draw_text(96, 0, width - 128, 24, ARMORS[item.id][0])
  246. self.contents.draw_text(96, 24, width - 128, 24, ARMORS[item.id][1])
  247. self.contents.draw_text(96, 48, width - 128, 24, ARMORS[item.id][2])
  248. self.contents.draw_text(96, 72, width - 128, 24, ARMORS[item.id][3])
  249. =end
  250.  
  251. end
  252. end
  253. end
  254. end # refresh
  255. end # Window_ItemDescription
Advertisement
Add Comment
Please, Sign In to add comment