Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # หน้าจอไอเท็มแสดงรูปด้านขวา
- # ผู้เขียน : jojo741963
- # เวอร์ชั่น : 1.0 - 31/10/2014
- #------------------------------------------------------------------------------
- # คุณสมบัติ :
- # แสดงรูปไอเท็มด้านขวาของ Scene_Item
- #------------------------------------------------------------------------------
- # วิธีใช้ :
- # นำสคริปต์นี้ไปวางเหนือสคริปต์ Main และใต้ Scene_Debug
- # หารูปที่จะใช้แสดงประกอบไอเท็มไอดีที่ต้องการ กำหนดชื่อได้จากส่วนตั้งค่าข้างล่าง ใส่ในโฟลเดอร์ Pictures
- # **ไม่จำเป็นต้องหามาใส่ทุกรูปก็ได้ ไอเท็มไหนที่ไม่มีรูป จะเป็นช่องว่างๆ เอาไว้
- #==============================================================================
- module Item_Help
- #กำหนดชื่อของไฟล์รูปภาพ ที่ต้องตามหลังด้วย ไอดีของไอเท็ม อยู่ในโฟลเดอร์ Pictures
- Name = "item_pic"
- #ต้องการให้แสดงจำนวนไอเท็มด้วยหรือไม่
- Amount_item = true
- #ความโปร่งใสของวินโดว์รูป ถ้าต้องการให้โปร่งใส ก็ใส่เป็น 0
- Window_Back_Opacity = 255
- end
- #==============================================================================
- # * Window_Item
- #------------------------------------------------------------------------------
- # In the item picture and the battle picture, it is the window which indicates the summary
- # of the possession item.
- #==============================================================================
- class Window_Item < Window_Selectable
- #--------------------------------------------------------------------------
- # - Object initialization
- #--------------------------------------------------------------------------
- def initialize
- super(0, 64, 320, 416)
- @column_max = 1
- refresh
- self.index = 0
- # When it is in the midst of fighting, it moves the window to the picture center, makes translucent
- if $game_temp.in_battle
- self.y = 64
- self.height = 256
- self.width = 640
- self.back_opacity = 160
- end
- end
- #--------------------------------------------------------------------------
- # - Acquisition of item
- #--------------------------------------------------------------------------
- def item
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # - Refreshment
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- # Adding the item
- for i in 1...$data_items.size
- if $game_party.item_number(i) > 0
- @data.push($data_items[i])
- end
- end
- # While fighting if other than it adds also the weapon and the guard
- unless $game_temp.in_battle
- for i in 1...$data_weapons.size
- if $game_party.weapon_number(i) > 0
- @data.push($data_weapons[i])
- end
- end
- for i in 1...$data_armors.size
- if $game_party.armor_number(i) > 0
- @data.push($data_armors[i])
- end
- end
- end
- #กำหนดให้แสดงไอเท็มชิ้นต่อช่อง
- if Item_Help::Amount_item == false && $game_temp.in_battle == false
- @data = []
- for i in 1...$data_items.size
- if $game_party.item_number(i) > 0
- for a in 1..$game_party.item_number(i)
- @data.push($data_items[i])
- end
- end
- end
- for i in 1...$data_weapons.size
- if $game_party.weapon_number(i) > 0
- for a in 1..$game_party.weapon_number(i)
- @data.push($data_weapons[i])
- end
- end
- end
- for i in 1...$data_armors.size
- if $game_party.armor_number(i) > 0
- for a in 1..$game_party.armor_number(i)
- @data.push($data_armors[i])
- end
- end
- end
- end
- # If the number of items is not 0, it draws up bit map, drawing all item
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- self.contents.font.name = $fontface
- self.contents.font.size = $fontsize
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # - Drawing of item
- # index : Item number
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- case item
- when RPG::Item
- number = $game_party.item_number(item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- end
- if item.is_a?(RPG::Item) and
- $game_party.item_can_use?(item.id)
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- x = 4 #+ index % 2 * (288 + 32)
- y = index * 32 #index / * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
- if Item_Help::Amount_item
- self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
- self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
- end
- end
- #--------------------------------------------------------------------------
- # - Help text renewal
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(self.item == nil ? "" : self.item.description)
- end
- end
- class Window_Item_Help < Window_Base
- #--------------------------------------------------------------------------
- # - Object initialization
- #--------------------------------------------------------------------------
- def initialize
- super(320, 64, 320, 416)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.name = $fontface
- self.contents.font.size = $fontsize
- self.back_opacity = Item_Help::Window_Back_Opacity
- end
- #--------------------------------------------------------------------------
- # - Refreshment
- #--------------------------------------------------------------------------
- def set_item(item)
- self.contents.clear
- bitmap = RPG::Cache.picture(Item_Help::Name + item.id.to_s) rescue nil
- src_rect = Rect.new(0, 0, bitmap.width, bitmap.height) rescue bitmap
- self.contents.blt(140-(bitmap.width/2), 188-(bitmap.height/2), bitmap, src_rect) rescue bitmap
- end
- end
- #==============================================================================
- # * Scene_Item
- #------------------------------------------------------------------------------
- # It is the class which processes the item picture.
- #==============================================================================
- class Scene_Item
- #--------------------------------------------------------------------------
- # - Main processing
- #--------------------------------------------------------------------------
- def main
- # Drawing up the help window and the item window
- @help_window = Window_Help.new
- @item_window = Window_Item.new
- # Help window association
- @item_window.help_window = @help_window
- # Target window compilation (invisibility non actively setting)
- @target_window = Window_Target.new
- @target_window.visible = false
- @target_window.active = false
- #เพิ่ม
- @item_help_window = Window_Item_Help.new
- #จบ
- # Transition execution
- Graphics.transition
- # Main loop
- loop do
- # Renewing the game picture
- Graphics.update
- # Updating the information of input
- Input.update
- # Frame renewal
- update
- # When the picture changes, discontinuing the loop
- if $scene != self
- break
- end
- end
- # Transition preparation
- Graphics.freeze
- # Releasing the window
- @help_window.dispose
- @item_window.dispose
- @target_window.dispose
- #เพิ่ม
- @item_help_window.dispose
- #จบ
- end
- #--------------------------------------------------------------------------
- # - Frame renewal
- #--------------------------------------------------------------------------
- def update
- # Renewing the window
- @help_window.update
- @item_window.update
- @target_window.update
- #เพิ่ม
- @item_help_window.set_item(@item_window.item)
- #จบ
- # When the item window is active,: Update_item is called
- if @item_window.active
- update_item
- return
- end
- # When the target window is active,: Update_target is called
- if @target_window.active
- update_target
- return
- end
- end
- #--------------------------------------------------------------------------
- # - When frame renewal (the item window is active)
- #--------------------------------------------------------------------------
- def update_item
- # The B when button is pushed
- if Input.trigger?(Input::B)
- # Performing cancellation SE
- $game_system.se_play($data_system.cancel_se)
- # Change to menu screen
- $scene = Scene_Menu.new(0)
- return
- end
- # When C button is pushed
- if Input.trigger?(Input::C)
- # Acquiring the data which presently is selected in the item window
- @item = @item_window.item
- # When it is not the use item
- unless @item.is_a?(RPG::Item)
- # Performing buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # When you cannot use
- unless $game_party.item_can_use?(@item.id)
- # Performing buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Performing decision SE
- $game_system.se_play($data_system.decision_se)
- # When the effective range takes part,
- if @item.scope >= 3
- # Active conversion target window
- @item_window.active = false
- #ปรับตำแหน่ง @target_window
- @target_window.x = 304#(@item_window.index + 1) % 2 * 304
- @target_window.visible = true
- @target_window.active = true
- # Setting cursor position the effective range (the single unit/the whole) according to
- if @item.scope == 4 || @item.scope == 6
- @target_window.index = -1
- else
- @target_window.index = 0
- end
- # When the effective range is other than taking part
- else
- # When common event ID is effective
- if @item.common_event_id > 0
- # Common event call reservation
- $game_temp.common_event_id = @item.common_event_id
- # When using the item performing SE
- $game_system.se_play(@item.menu_se)
- # In case of consumable
- if @item.consumable
- # The item which you use is decreased 1
- $game_party.lose_item(@item.id, 1)
- # Redrawing the item of the item window
- @item_window.draw_item(@item_window.index)
- end
- # Change to map picture
- $scene = Scene_Map.new
- return
- end
- end
- return
- end
- end
- #--------------------------------------------------------------------------
- # - When frame renewal (the target window is active)
- #--------------------------------------------------------------------------
- def update_target
- # The B when button is pushed
- if Input.trigger?(Input::B)
- # Performing cancellation SE
- $game_system.se_play($data_system.cancel_se)
- # When with the item and so on is cut off and it becomes not be able to use
- unless $game_party.item_can_use?(@item.id)
- # Rewriting the contents of the item window
- @item_window.refresh
- end
- # Eliminating the target window
- @item_window.active = true
- @target_window.visible = false
- @target_window.active = false
- return
- end
- # When C button is pushed
- if Input.trigger?(Input::C)
- # When the item is consumed
- if $game_party.item_number(@item.id) == 0
- # Performing buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # When the target is the whole
- if @target_window.index == -1
- # Applying the use effect of the item to the whole party
- used = false
- for i in $game_party.actors
- used |= i.item_effect(@item)
- end
- end
- # When the target is the single unit
- if @target_window.index >= 0
- # Applying the use effect of the item to the actor of the target
- target = $game_party.actors[@target_window.index]
- used = target.item_effect(@item)
- end
- # When the item was used
- if used
- # When using the item performing SE
- $game_system.se_play(@item.menu_se)
- # In case of consumable
- if @item.consumable
- # The item which you use is decreased 1
- $game_party.lose_item(@item.id, 1)
- # Redrawing the item of the item window
- @item_window.draw_item(@item_window.index)
- end
- # Rewriting the contents of the target window
- @target_window.refresh
- # In case of total destruction
- if $game_party.all_dead?
- # Change to game over picture
- $scene = Scene_Gameover.new
- return
- end
- # When common event ID is effective
- if @item.common_event_id > 0
- # Common event call reservation
- $game_temp.common_event_id = @item.common_event_id
- # Change to map picture
- $scene = Scene_Map.new
- return
- end
- end
- # When the item was not used
- unless used
- # Performing buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- end
- return
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement