Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Mouse
- def Mouse.pos
- x, y = Mouse.screen_to_client(*Mouse.global_pos)
- width, height = Mouse.client_size
- begin
- if (x >= 0 and y >= 0 and x < width and y < height)
- return x, y
- else
- return -100,-100
- end
- rescue
- return -100,-100
- end
- end
- end
- class Scene_Title
- alias start_mapmenuhud_settings start
- def start
- start_mapmenuhud_settings
- $game_system.menu_disabled = DISABLE_STANDART_MENU
- $game_switches[CONTROLL_SWITCH_ID] = START_UP_MENU_STATUS
- end
- end
- class Scene_Map
- alias start_mapmousehud start unless $@
- def start
- start_mapmousehud
- @mmhud = Window_MapMouseHUD.new(X,Y,ITEMS)
- end
- alias update_mapmousehud update unless $@
- def update
- update_mapmousehud
- @mmhud.update if !$game_map.interpreter.running? && !$game_message.visible && $game_switches[CONTROLL_SWITCH_ID]
- if $game_switches[CONTROLL_SWITCH_ID] && !$game_message.visible
- @mmhud.change_visibility(true)
- else
- @mmhud.change_visibility(false)
- end
- end
- alias terminate_mapmousehud terminate unless $@
- def terminate
- terminate_mapmousehud
- @mmhud.dispose
- end
- end
- class Window_MapMouseHUD < Window_Base
- def initialize(x,y,items = [])
- super(x,y,32+items.length+items.length*24,56)
- @items = []
- @actors = []
- @scene = nil
- if self.y - 56 < 0
- @help = Window_Base.new(x,y+112+DISCRITION_Y,DISCRIPTION_WIDTH,56)
- else
- @help = Window_Base.new(x,y-56+DISCRITION_Y,DISCRIPTION_WIDTH,56)
- end
- @cursor = [Sprite.new,Sprite.new]
- @cursor[0].visible = false
- @cursor[1].visible = false
- @c_id = nil
- @help.visible = false
- @help.opacity = DISCRIPTION_OPACITY
- x = ACTOR_X
- y = ACTOR_Y
- width = ACTOR_WIDTH
- if ACTOR_AUTO
- x = self.x + self.width
- y = self.y
- width = 544 - self.width - self.x
- end
- #@actor = Window_Base.new(x,y,width,56)
- # @help.z = #@actor.z + 1
- self.visible = $game_switches[CONTROLL_SWITCH_ID]
- #@actor.visible = $game_switches[CONTROLL_SWITCH_ID]
- draw_items(items)
- #draw_party
- create_cursor
- end
- def create_cursor
- =begin
- @cursor[0].bitmap = Bitmap.new(24,24)
- @cursor[0].bitmap.fill_rect(0,0,@cursor[0].bitmap.width,@cursor[0].bitmap.height,CURSOR_COLOR)
- @cursor[0].bitmap.clear_rect(2,2,@cursor[0].bitmap.width-4,@cursor[0].bitmap.height-4)
- width = (@actor.width-32) / $game_party.members.size
- if $game_party.members.size == 1
- width = width / 2.5
- end
- =end
- @cursor[1].bitmap = Bitmap.new(width,24)
- @cursor[1].bitmap.fill_rect(0,0,@cursor[1].bitmap.width,@cursor[1].bitmap.height,CURSOR_COLOR)
- @cursor[1].bitmap.clear_rect(2,2,@cursor[1].bitmap.width-4,@cursor[1].bitmap.height-4)
- #@cursor[0].z = 101
- @cursor[1].z = 101
- #@cursor[0].x = -1000
- #@cursor[1].x = -1000
- end
- def draw_items(items)
- @items = []
- self.contents.clear
- for i in 0...items.length
- draw_icon(items[i][0],i + i*24, 0)
- @items.push(MapMouseHUD_Item.new(self.x + 16 + i + i*24,self.y+16,items[i][1],items[i][2],items[i][3]))
- end
- end
- def draw_party
- @actors = []
- @actor.contents.clear
- a = 0
- platz = (@actor.width-32) / $game_party.members.size
- if $game_party.members.size == 1
- platz = platz / 2.5
- end
- for i in $game_party.members
- x = a*(platz)
- draw_member(x,a,platz)
- @actors.push(MapMouseHUD_Character.new(@actor.x + 16 + x,@actor.y + 16,a,platz))
- a += 1
- end
- end
- def draw_member(x,id,platz)
- actor = $game_party.members[id]
- width = platz - 20
- @actor.draw_actor_hp_gauge(actor,x+20,-8,width)
- @actor.draw_actor_mp_gauge(actor,x+20,0,width)
- bitmap = Cache.character(actor.character_name)
- sign = actor.character_name[/^[\!\$]./]
- if sign != nil and sign.include?('$')
- cw = bitmap.width / 3
- ch = bitmap.height / 4
- else
- cw = bitmap.width / 12
- ch = bitmap.height / 8
- end
- n = actor.character_index
- src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
- head = Bitmap.new(cw,ch)
- head.blt(0,0, bitmap, src_rect)
- @actor.contents.blt(x,0,head,Rect.new(0,0,cw,ch))
- if $game_party.members.size == 1
- draw_actor_state(actor, platz + 2, 0, platz - 2)
- end
- end
- def draw_actor_state(actor, x, y, width = 96)
- count = 0
- for state in actor.states
- @actor.contents.fill_rect(x,y,24,24,SLOT_COLORS[0])
- @actor.contents.fill_rect(x+2,y+2,20,20,SLOT_COLORS[1])
- draw_icon(state.icon_index, x + 24 * count, y)
- count += 1
- break if (24 * count > width - 24)
- end
- end
- def draw_icon(icon_index, x, y, enabled = true)
- self.contents.fill_rect(x,y,24,24,SLOT_COLORS[0])
- self.contents.fill_rect(x+1,y+1,22,22,SLOT_COLORS[1])
- bitmap = Cache.system("Iconset")
- rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
- end
- def hit?
- if Mouse.pos != nil
- return Mouse.pos[0] >= self.x && Mouse.pos[0] <= self.x+self.width && Mouse.pos[1] >= self.y && Mouse.pos[1] <= self.y+self.height
- else
- return false
- end
- end
- def actor_hit?
- return
- if Mouse.pos != nil
- return Mouse.pos[0] >= @actor.x && Mouse.pos[0] <= @actor.x+@actor.width && Mouse.pos[1] >= @actor.y && Mouse.pos[1] <= @actor.y+@actor.height
- else
- return false
- end
- end
- def change_visibility(switch)
- #@actor.visible = switch
- self.visible = switch
- end
- def update_items
- id = 0
- for i in @items
- if i.hit?
- if !i.choose
- i.call_item_scene
- @scene = nil
- @c_id = nil
- else
- @c_id = id
- @scene = i.scene[0]
- end
- end
- id += 1
- end
- end
- def update_actors
- for i in @actors
- if i.hit?
- i.call_item_scene(@scene)
- @scene = nil
- @c_id = nil
- end
- end
- end
- def update_cursor(item = nil)
- if item != nil
- if item.methods.include?("desc")
- @cursor[0].x = item.x
- @cursor[0].y = item.y
- else
- @cursor[1].x = item.x
- @cursor[1].y = item.y
- end
- elsif @c_id != nil
- @cursor[0].x = @items[@c_id].x
- end
- update_cursor_visibility
- end
- def update_cursor_visibility
- if hit? || @c_id != nil
- @cursor[0].visible = true
- else
- @cursor[0].visible = false
- end
- @cursor[1].visible = actor_hit?
- end
- def update
- return if Mouse.pos.nil?
- update_cursor
- if Mouse.click?(1)
- if @scene == nil || @c_id != nil
- update_items
- end
- if @c_id != nil
- #update_actors
- elsif !actor_hit?
- @scene = nil
- @c_id = nil
- end
- else
- for i in @items + @actors
- if i.hit?
- update_cursor(i)
- if !@help.visible
- @help.visible = true
- end
- @help.x = i.x if SLIDE_TO_ICON
- @help.contents.clear
- if i.methods.include?("desc")
- text = i.desc
- else
- text = i.name
- end
- @help.contents.draw_text(0,0,DISCRIPTION_WIDTH-32,24,text,1)
- break
- else
- if @help.visible
- @help.visible = false
- @help.contents.clear
- end
- end
- end
- end
- end
- def dispose
- @items = []
- @actors = []
- @scene = nil
- @c_id = nil
- @help.dispose
- #@actor.dispose
- for i in @cursor
- i.dispose
- end
- self.contents.dispose
- super
- end
- end
- class MapMouseHUD_Item
- attr_reader :x
- attr_reader :y
- attr_reader :desc
- attr_reader :scene
- attr_reader :choose
- def initialize(x,y,scene,choose_actor,description)
- @x = x
- @y = y
- @scene = scene
- @choose = choose_actor
- @desc = description
- end
- def hit?
- if Mouse.pos != nil
- return Mouse.pos[0] >= @x && Mouse.pos[0] <= @x+24 && Mouse.pos[1] >= @y && Mouse.pos[1] <= @y+24
- else
- return false
- end
- end
- def call_item_scene
- $scene = eval("#{@scene[0]}.new(#{@scene[1]})")
- end
- end
- class MapMouseHUD_Character
- attr_reader :x
- attr_reader :y
- attr_reader :name
- def initialize(x,y,mem_id,width)
- @x = x
- @y = y
- @width = width
- @id = mem_id
- @name = $game_party.members[@id].name
- end
- def hit?
- if Mouse.pos != nil
- return Mouse.pos[0] >= @x && Mouse.pos[0] <= @x+@width && Mouse.pos[1] >= @y && Mouse.pos[1] <= @y+24
- else
- return false
- end
- end
- def call_item_scene(scene)
- $scene = eval("#{scene}.new(#{@id})")
- end
- end
- if RETURN_TO_MAP
- class Scene_File
- def return_scene
- if @from_title
- $scene = Scene_Title.new
- elsif @from_event
- $scene = Scene_Map.new
- else
- $scene = Scene_Map.new
- end
- end
- end
- class Scene_Equip
- def return_scene
- $scene = Scene_Map.new
- end
- end
- class Scene_Status
- def return_scene
- $scene = Scene_Map.new
- end
- end
- class Scene_Item
- def return_scene
- $scene = Scene_Map.new
- end
- end
- class Scene_Skill
- def return_scene
- $scene = Scene_Map.new
- end
- end
- class Scene_End
- def return_scene
- $scene = Scene_Map.new
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement