Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # Mouse Map Menu by Nathmatt
- # Version: 1.26
- # Type: Menu
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- #
- # This work is protected by the following license:
- # #----------------------------------------------------------------------------
- # #
- # # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
- # # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
- # #
- # # You are free:
- # #
- # # to Share - to copy, distribute and transmit the work
- # # to Remix - to adapt the work
- # #
- # # Under the following conditions:
- # #
- # # Attribution. You must attribute the work in the manner specified by the
- # # author or licensor (but not in any way that suggests that they endorse you
- # # or your use of the work).
- # #
- # # Noncommercial. You may not use this work for commercial purposes.
- # #
- # # Share alike. If you alter, transform, or build upon this work, you may
- # # distribute the resulting work only under the same or similar license to
- # # this one.
- # #
- # # - For any reuse or distribution, you must make clear to others the license
- # # terms of this work. The best way to do this is with a link to this web
- # # page.
- # #
- # # - Any of the above conditions can be waived if you get permission from the
- # # copyright holder.
- # #
- # # - Nothing in this license impairs or restricts the author's moral rights.
- # #
- # #----------------------------------------------------------------------------
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- module Mouse_Map_Menu
- Version = 1.26
- #============================================================================
- # Mouse_Map_Menu::Config
- #----------------------------------------------------------------------------
- # This module performs the the configurations.
- #============================================================================
- module Config
- Condition = 0 # 0 for Horizontal 1 for Vertical
- Icons = ['040-Item09'] # Array of menu icons
- Key = ['M'] # Array of keys that will call the scene
- Scenes = [Scene_Menu] # Array of scenes add Back to to return to map
- # when not on map Scene_End if you are
- Mouse = false # The mouse graphic while over a command
- # or false for none
- Back = false # The picture back for each icon or false for none
- Window = false # The picture used like a window for the icons
- # or false for none
- X = 0 # The x co-ordanance is by 32
- Y = 14 # The y co-ordanance is by 32
- end
- #============================================================================
- # Mouse_Map_Menu::Processor
- #----------------------------------------------------------------------------
- # This class performs the mouse processing.
- #============================================================================
- class Processor
- attr_reader :event_disabled
- attr_accessor :menu_disabled
- CON = Config::Condition
- ICONS = Config::Icons
- KEY = Config::Key
- SCENES = Config::Scenes
- MOUSE = Config::Mouse
- BACK = Config::Back
- WINDOW = Config::Window
- SIZE = ICONS.size
- X = Config::X * 32
- Y = Config::Y * 32
- W = (CON == 0 ? SIZE * 32 : 32)
- H = (CON == 1 ? SIZE * 32 : 32)
- def main
- return if @window != nil
- @window,@back,@menu = Sprite.new,Sprite.new,Sprite.new
- @window.z,@back.z,@menu.z = 100,150,200
- @window.x = @back.x = @menu.x = X
- @window.y = @back.y = @menu.y = Y
- @window.bitmap = RPG::Cache.picture(WINDOW) if WINDOW != false
- @back.bitmap = Bitmap.new(W,H)
- @menu.bitmap = Bitmap.new(W,H)
- @disabled = []
- (0...SIZE).each{|i|draw_command(i)}
- end
- def draw_command(i)
- x,y = (CON == 0 ? (i * 32) : 0),(CON == 1 ? (i * 32) : 0)
- rect = Rect.new(x,y,32,32)
- @menu.bitmap.fill_rect(rect,Color.new(0,0,0,0))
- if BACK != false
- item = RPG::Cache.picture(BACK)
- @back.bitmap.stretch_blt(rect,item,Rect.new(0,0,item.width,item.height))
- end
- item = RPG::Cache.icon(ICONS[i])
- opacity = (@disabled[i] ? 128 : 255)
- @menu.bitmap.fill_rect(rect,Color.new(0,0,0,0))
- @menu.bitmap.blt(x+4,y+4,item,Rect.new(0,0,24,24),opacity)
- end
- def update
- dispose if @menu_disabled
- main if !@menu_disabled
- return if @menu == nil
- check_mouse
- check_opacity
- i = check_keys
- @event_disabled = (i != false)
- if i != false
- if SCENES[i] == 'Back'
- $scene = ($scene.is_a?(Scene_Map) ? Scene_End.new : Scene_Map.new)
- return
- end
- $scene = SCENES[i].new
- end
- end
- def check_mouse
- return if MOUSE == false
- i = over_button?
- if $MCES != nil
- $MCES.mouse_menu = (i != false)
- return
- end
- if i != false
- $mouse.set_cursor(MOUSE)
- else
- $mouse.set_cursor(Mouse::MOUSE_ICON)
- end
- end
- def check_keys
- return over_button? if Input.trigger?(Input::Key['Mouse Left'])
- (0...SIZE).each{|i|
- return i if Config::Key[i] != nil &&
- Input.trigger?(Input::Key[Config::Key[i]])}
- return false
- end
- def over_button?
- (0...SIZE).each{|i|
- x,y = (CON == 0 ? (X + i * 32) : X),(CON == 1 ? (Y + i * 32) : Y)
- if $mouse.x >= x && $mouse.y >= y && $mouse.x <= x + 32 && $mouse.y <= y + 32
- return i
- end}
- return false
- end
- def dispose
- [@window,@back,@menu].each{|s|s.dispose if s != nil && !s.disposed?}
- @window = @back = @menu = nil
- end
- def mouse_in_area?
- return false if @menu == nil || @menu.disposed?
- s = @menu
- b = s.bitmap
- return $game_player.screen_x <= s.x + b.width &&
- $game_player.screen_y <= s.y + b.height &&
- $game_player.screen_x >= s.x && $game_player.screen_y >= s.y
- end
- def check_opacity
- if mouse_in_area?
- @menu.opacity -= 25 if @menu.opacity > 80
- elsif @menu.opacity <= 255
- @menu.opacity += 25
- end
- [@window,@back,@menu].each{|s|s.opacity = @menu.opacity if !s.disposed?}
- end
- end
- end
- $mouse_map_menu = Mouse_Map_Menu::Processor.new
- class Scene_Map
- alias mouse_map_menu_main main
- def main
- $mouse_map_menu.main
- mouse_map_menu_main
- $mouse_map_menu.dispose
- end
- alias mouse_map_menu_update update
- def update
- $mouse_map_menu.update
- mouse_map_menu_update
- end
- end
- class Game_Event < Game_Character
- alias start_event_menu start
- def start
- return if $mouse_map_menu.event_disabled
- start_event_menu
- end
- end
- if $MCES != nil
- class MCES::Processor
- attr_accessor :mouse_menu
- alias mouse_menu_check_mouse check_mouse
- def check_mouse
- if @mouse_menu
- $mouse.set_cursor(Mouse_Map_Menu::Config::Mouse)
- return
- end
- mouse_menu_check_mouse
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement