Original Source
- Original title: Combine Minimap with Menu
- Original author: Tw0Face
- Original date: April 4, 2021
- Source thread: https://forums.rpgmakerweb.com/threads/combine-minimap-with-menu.135162/
- Source forum path: Game Development Engines > Ruby Game System (RGSS) Scripts > RGSSx Script Support
Summary
Hi gentlemen, I don't know if it's possible, but I want to combine two scripts I use. I use a minimap script and a menu script. I would like the minimap to be part of the menu and appear there as long as the menu points (Items, Save, Shutdown) are not used. Lemme show it. This is my menu and minimap.
Archived First Post
I don't know if it's possible, but I want to combine two scripts I use.
I use a minimap script and a menu script. I would like the minimap to be part of the menu and appear there as long as the menu points (Items, Save, Shutdown) are not used.
Lemme show it. This is my menu and minimap.
Protected download
Protected download
What I want is something like this:
Protected download
Here's the scripts used.
#===============================================================
# ● [VX Ace] ◦ MiniMap ◦ □
# * Plug N Play Minimap (Don't need image~) *
#--------------------------------------------------------------
# ◦ by Woratana [woratana@hotmail.com]
# ◦ Thaiware RPG Maker Community
# ◦ Released on: 09/06/2008
# ◦ Version: 1.0
#--------------------------------------------------------------
# ◦ Credit: KGC for XP MiniMap Script,
# this script can't be done without his MiniMap.
#--------------------------------------------------------------
# ◦ Ported to VX Ace by Kal on 2011/12/17
#--------------------------------------------------------------
module MiniMap
#==========================================================================
# [START] MINIMAP SCRIPT SETUP PART
#---------------------------------------------------------------------------
SWITCH_NO_MINIMAP = 8 # Turn ON this switch to NOT SHOW minimap
MAP_RECT = [435, 250, 100, 100] # Minimap size and position
# [X, Y, Width, Height]
# You can change it in game, by call script:
# $game_system.minimap = [X, Y, Width, Height]
MAP_Z = 0 # Minimap's Z-coordinate
# Increase this number if there is problem that minimap show below some objects.
GRID_SIZE = 10 # Minimap's grid size. Recommend to use more than 3.
MINIMAP_BORDER_COLOR = Color.new(0, 0, 0, 0) # Minimap's border color
# Color.new(Red, Green, Blue, Opacity)
MINIMAP_BORDER_SIZE = 2 # Minimap's border size
FOREGROUND_COLOR = Color.new(224, 224, 255, 160) # Passable tile color
BACKGROUND_COLOR = Color.new(0, 0, 0, 160) # Unpassable tile color
USE_OUTLINE_PLAYER = true # Draw outline around player in minimap?
PLAYER_OUTLINE_COLOR = Color.new(0, 0, 0, 192) # Player Outline color
USE_OUTLINE_EVENT = true # Draw outline around events in minimap?
EVENT_OUTLINE_COLOR = Color.new(255, 255, 255, 192) # Player Outline color
PLAYER_COLOR = Color.new(255, 0, 0, 192) # Player color
#---------------------------------------------------------------------------
OBJECT_COLOR = {} # Don't change or delete this line!
#===============================================================
# * SETUP EVENT KEYWORD & COLOR
#---------------------------------------------------------------
# ** Template:
# OBJECT_COLOR['keyword'] = Color.new(Red, Green, Blue, Opacity)
#-------------------------------------------------------------
# * 'keyword': Word you want to put in event's comment to show this color
# ** Note: 'keyword' is CASE SENSITIVE!
# * Color.new(...): Color you want
# You can put between 0 - 255 in each argument (Red, Green, Blue, Opacity)
#-------------------------------------------------------------
OBJECT_COLOR['npc'] = Color.new(30,144,255,160)
OBJECT_COLOR['treasure'] = Color.new(0,255,255,160)
OBJECT_COLOR['enemy'] = Color.new(139,35,35,160)
OBJECT_COLOR['merchant'] = Color.new(255,255,0,160)
#==========================================================================
# * [OPTIONAL] TAGS:
#---------------------------------------------------------------------------
# Change keyword for disable minimap & keyword for show event on minimap~
#-----------------------------------------------------------------------
TAG_NO_MINIMAP = '[NOMAP]' # Tag for disable minimap
TAG_EVENT = 'MMEV' # Tag for show event on minimap
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# [END] MINIMAP SCRIPT SETUP PART
#==========================================================================
def self.refresh
if SceneManager.scene.is_a?(Scene_Map)
SceneManager.scene.spriteset.minimap.refresh
end
end
def self.update_object
if SceneManager.scene.is_a?(Scene_Map)
SceneManager.scene.spriteset.minimap.update_object_list
end
end
end
#==============================================================================
# � RPG::MapInfo
#==============================================================================
class RPG::MapInfo
def name
return @name.gsub(/\[.*\]/) { }
end
def original_name
return @name
end
def show_minimap?
return !@name.include?(MiniMap::TAG_NO_MINIMAP)
end
end
#==============================================================================
# � Game_System
#==============================================================================
class Game_System
attr_accessor :minimap
alias wora_minimap_gamsys_ini initialize
def initialize
wora_minimap_gamsys_ini
@minimap = MiniMap::MAP_RECT
end
def show_minimap
return !$game_switches[MiniMap::SWITCH_NO_MINIMAP]
end
end
#==============================================================================
# � Game_Map
#==============================================================================
class Game_Map
alias wora_minimap_gammap_setup setup
def setup(map_id)
wora_minimap_gammap_setup(map_id)
@db_info = load_data('Data/MapInfos.rvdata2') if @db_info.nil?
@map_info = @db_info[map_id]
end
def show_minimap?
return @map_info.show_minimap?
end
end
#==============================================================================
# � Game_Event
#==============================================================================
class Game_Event < Game_Character
def mm_comment?(comment, return_comment = false )
if !@list.nil?
for i in 0...@list.size - 1
next if @list[i].code != 108
if @list[i].parameters[0].include?(comment)
return @list[i].parameters[0] if return_comment
return true
end
end
end
return '' if return_comment
return false
end
end
#==============================================================================
# � Game_MiniMap
#------------------------------------------------------------------------------
class Game_MiniMap
def initialize(tilemap)
@tilemap = tilemap
refresh
end
def dispose
@border.bitmap.dispose
@border.dispose
@map_sprite.bitmap.dispose
@map_sprite.dispose
@object_sprite.bitmap.dispose
@object_sprite.dispose
@position_sprite.bitmap.dispose
@position_sprite.dispose
end
def visible
return @map_sprite.visible
end
def visible=(value)
@map_sprite.visible = value
@object_sprite.visible = value
@position_sprite.visible = value
@border.visible = value
end
def refresh
@mmr = $game_system.minimap
map_rect = Rect.new(@mmr[0], @mmr[1], @mmr[2], @mmr[3])
grid_size = [MiniMap::GRID_SIZE, 1].max
@x = 0
@y = 0
@size = [map_rect.width / grid_size, map_rect.height / grid_size]
@border = Sprite.new
@border.x = map_rect.x - MiniMap::MINIMAP_BORDER_SIZE
@border.y = map_rect.y - MiniMap::MINIMAP_BORDER_SIZE
b_width = map_rect.width + (MiniMap::MINIMAP_BORDER_SIZE * 2)
b_height = map_rect.height + (MiniMap::MINIMAP_BORDER_SIZE * 2)
@border.bitmap = Bitmap.new(b_width, b_height)
@border.bitmap.fill_rect(@border.bitmap.rect, MiniMap::MINIMAP_BORDER_COLOR)
@border.bitmap.clear_rect(MiniMap::MINIMAP_BORDER_SIZE, MiniMap::MINIMAP_BORDER_SIZE,
@border.bitmap.width - (MiniMap::MINIMAP_BORDER_SIZE * 2),
@border.bitmap.height - (MiniMap::MINIMAP_BORDER_SIZE * 2))
@map_sprite = Sprite.new
@map_sprite.x = map_rect.x
@map_sprite.y = map_rect.y
@map_sprite.z = MiniMap::MAP_Z
bitmap_width = $game_map.width * grid_size + map_rect.width
bitmap_height = $game_map.height * grid_size + map_rect.height
@map_sprite.bitmap = Bitmap.new(bitmap_width, bitmap_height)
@map_sprite.src_rect = map_rect
@object_sprite = Sprite.new
@object_sprite.x = map_rect.x
@object_sprite.y = map_rect.y
@object_sprite.z = MiniMap::MAP_Z + 1
@object_sprite.bitmap = Bitmap.new(bitmap_width, bitmap_height)
@object_sprite.src_rect = map_rect
@position_sprite = Sprite_Base.new
@position_sprite.x = map_rect.x + @size[0] / 2 * grid_size
@position_sprite.y = map_rect.y + @size[1] / 2 * grid_size
@position_sprite.z = MiniMap::MAP_Z + 2
bitmap = Bitmap.new(grid_size, grid_size)
# Player's Outline
if MiniMap::USE_OUTLINE_PLAYER and MiniMap::GRID_SIZE >= 3
bitmap.fill_rect(bitmap.rect, MiniMap::PLAYER_OUTLINE_COLOR)
brect = Rect.new(bitmap.rect.x + 1, bitmap.rect.y + 1, bitmap.rect.width - 2,
bitmap.rect.height - 2)
bitmap.clear_rect(brect)
else
brect = bitmap.rect
end
bitmap.fill_rect(brect, MiniMap::PLAYER_COLOR)
@position_sprite.bitmap = bitmap
draw_map
update_object_list
draw_object
update_position
end
def draw_map
bitmap = @map_sprite.bitmap
bitmap.fill_rect(bitmap.rect, MiniMap::BACKGROUND_COLOR)
map_rect = Rect.new(@mmr[0], @mmr[1], @mmr[2], @mmr[3])
grid_size = [MiniMap::GRID_SIZE, 1].max
$game_map.width.times do |i|
$game_map.height.times do |j|
if !$game_map.passable?(i, j, 4) #KAL: d = number of direcitons passable?
next
end
rect = Rect.new(map_rect.width / 2 + grid_size * i,
map_rect.height / 2 + grid_size * j,
grid_size, grid_size)
if grid_size >= 3
if !$game_map.passable?(i, j, 4) #KAL: d = number of direcitons passable?
rect.height -= 1
rect.x += 1
rect.width -= 1
rect.width -= 1
rect.y += 1
rect.height -= 1
end
end
bitmap.fill_rect(rect, MiniMap::FOREGROUND_COLOR)
end
end
end
def update_object_list
@object_list = {}
$game_map.events.values.each do |e|
comment = e.mm_comment?(MiniMap::TAG_EVENT, true)
if comment != ''
type = comment.gsub(/#{MiniMap::TAG_EVENT}/){}.gsub(/\s+/){}
@object_list[type] = [] if @object_list[type].nil?
@object_list[type] << e
end
end
end
def draw_object
bitmap = @object_sprite.bitmap
bitmap.clear
map_rect = Rect.new(@mmr[0], @mmr[1], @mmr[2], @mmr[3])
grid_size = [MiniMap::GRID_SIZE, 1].max
rect = Rect.new(0, 0, grid_size, grid_size)
mw = map_rect.width / 2
mh = map_rect.height / 2
@object_list.each do |key, events|
color = MiniMap::OBJECT_COLOR[key]
next if events.nil? or color.nil?
events.each do |obj|
if !obj.character_name.empty?
rect.x = mw + obj.real_x * grid_size / 256
rect.y = mh + obj.real_y * grid_size / 256
# Event's Outline
if MiniMap::USE_OUTLINE_EVENT and MiniMap::GRID_SIZE >= 3
bitmap.fill_rect(rect, MiniMap::EVENT_OUTLINE_COLOR)
brect = Rect.new(rect.x + 1, rect.y + 1, rect.width - 2,
rect.height - 2)
bitmap.clear_rect(brect)
else
brect = bitmap.rect
end
bitmap.fill_rect(brect, color)
end
end
end
end
def update
if @mmr != $game_system.minimap
dispose
refresh
end
draw_object
update_position
if @map_sprite.visible
@map_sprite.update
@object_sprite.update
@position_sprite.update
end
end
def update_position
map_rect = Rect.new(@mmr[0], @mmr[1], @mmr[2], @mmr[3])
grid_size = [MiniMap::GRID_SIZE, 1].max
sx = $game_player.real_x * grid_size
sy = $game_player.real_y * grid_size
@map_sprite.src_rect.x = sx
@map_sprite.src_rect.y = sy
@object_sprite.src_rect.x = sx
@object_sprite.src_rect.y = sy
end
end
#==============================================================================
# � Spriteset_Map
#------------------------------------------------------------------------------
class Spriteset_Map
attr_reader :minimap
alias wora_minimap_sprsetmap_ini initialize
alias wora_minimap_sprsetmap_dis dispose
alias wora_minimap_sprsetmap_upd update
def initialize
wora_minimap_sprsetmap_ini
if $game_map.show_minimap?
@minimap = Game_MiniMap.new(@tilemap)
$game_system.show_minimap = true if $game_system.show_minimap.nil?
@minimap.visible = $game_system.show_minimap
end
end
def dispose
@minimap.dispose if !@minimap.nil?
wora_minimap_sprsetmap_dis
end
def update
if !@minimap.nil?
if $game_system.show_minimap
@minimap.visible = true
@minimap.update
else
@minimap.visible = false
end
end
wora_minimap_sprsetmap_upd
end
end
#==============================================================================
# � Scene_Map
#------------------------------------------------------------------------------
class Scene_Map < Scene_Base
attr_reader :spriteset
end
module Zale
module KsiMenu
Window_Skin = "" # if this is not empty, it will set the windowskin to this.
line_height = 24 #24 is the default
Face_WP = 2 + 48# Add additional padding here
Face_HP = 2 + 72
Win_W = 96 * 3 + 24 + (Face_WP * 3)
Win_H = 96 * 2 + 24 + Face_HP
Pos_X = Graphics.width / 2 - (Win_W / 2) # Center it on screen
Pos_Y = Graphics.height * 0.1
Face_W = 96
Face_H = 96
Arrows = false # Show arrows on the help window? (they're there because we shrunk the window
# And it thinks that something is there).
end
end
class Window_MenuHCommand < Window_HorzCommand
# We include Zale::KsiMenu in ever class because it's faster
# to write out 'Variable' rather than 'Zale::KsiMenu::Variable' for everything
include Zale::KsiMenu
# Initialize is called whenever any object is make. It's built into ruby to do
# that, so this is where you would put everything to set up what you're making.
# In this case, we call this window's superclass, which we see above is
# Window_HorzCommand (Horizontal command window). It needs to know where to place
# the window, so we use the variables x and y, which we got when the object was
# originally made.
# Then we check if the Window_Skin variable is "" (empty). If it is, don't do
# anything. If it is different though, use that as our window skin. Then we
#use self.width = blah to change how wide the window is. We want all the windows
# to be the same width, so we use the same variable (Technically, variables that
# start with capital letters are constants, we're not allowed to change them,
# though there is *technically* a way to).
# Next we call the refresh method, and then update the cursor.
#
# The refresh method is not in this class, so where is it? Kind of like when we
# called super in initialize, if we don't define a method in out class, and then
# some other script calls this method (such as refresh), we see if the superclass
# has it. If it does, we do that, if not, check its superclass. This keeps going
# until we find the method or we run out of classes, in which case we'll get an
# error saying we can't find this method.
# These types of errors are 'undefined local variable or method `something' for
# MyClass:0xItsMemoryAddress.
def initialize(x, y)
super(x, y)
if Zale::KsiMenu::Window_Skin != ""
self.windowskin = Cache.system(Window_Skin)
end
self.width = Win_W
refresh
update_cursor
end
# We use the add_command method, defined in Window_Command to add a command to the
# window so we can select it later. We give it a symbol, the thing with the : in front
# so that we can handle that specifically later. Vocab.whatever is the set of terms that
# are defined in the Terms tab of the database. You can see the available terms at the
# Vocab script at the top of the script editor. Check the bottom for the ones you can use
# They'll look like:
# def self.item; command(4); end # Items
def make_command_list
add_command(Vocab.item, :item)
add_command(Vocab.save, :save)
add_command(Vocab.shutdown, :quit)
end
# Here we define how many columns out window will have. By default, a Window_HorzCommand
# window will have four columns, but we only want 3, item, save, and quit. So this is how
# we set that up.
def col_max
return 3
end
end
class Window_KsiStatus < Window_Selectable
include Zale::KsiMenu
# Same as above.
# @index = -1 is used to make sure we don't have a cursor over any
# of the actor's faces (even though it shouldn't be there anyway).
def initialize
super(Pos_X, Pos_Y, Win_W, Win_H)
if Window_Skin != ""
self.windowskin = Cache.system(Window_Skin)
end
@index = -1
draw_actors
end
# Here's an example of a refresh method. This will clear the contents
# of a window, which is just a bitmap, a picture. It's refered to by
# a method named 'contents'. So we clear it using contents.clear, and
# then we use the create_contents method which will make a new bitmap
# to use. This will make it whatever size we need and make sure it's
# cleared. Then we redraw the actor's faces.
def refresh
contents.clear
create_contents
draw_actors
end
# First we setup variables for position, since we'll be changing them
# based on how many faces we've already drawn. Then, for the size of
# our party, we go through all the people. 'i' starts at 0 whenever you
# use the 'times' method, and it increases by one each time the loop end
# until it has done the number of loops. So we want to see, if i is greater
# than 5(it drew 6 faces), then we just skip to the next iteration by using
# 'next' This will keep happening until we run out of actors. We do this
# because we won't fit them onto the screen anyway, so don't waste the time
# to draw them.
def draw_actors
x = y = 0
$game_party.members.size.times{ |i|
if i > 5
next # index starts at 0, greater than 5 won't be drawn on the screen unless you change the dimensions.
end
act = $game_party.members[i]
draw_face(act.face_name, act.face_index, x, y)
x += Face_W + Face_WP
if x >= Face_W * 3 + (Face_WP * 3)
x = 0
y += Face_H + Face_HP
end
}
end
end
class Scene_Menu < Scene_MenuBase
include Zale::KsiMenu
def start
super
create_status
create_command
end
# Create the window that we use to select our commands. This is where
# we use those symbols to handle processing separately. First, though,
# we make the command window with the x position, and the y position
# PLUS the height of the status window, because we want the command
# window to be on the bottom of the status window.
# Then we use the set_handler command for window so we can tell
# Ruby what to do when we select an option. We need to specify the
# symbol we gave them when we added the commands, and then a method
# to handle the option. the method() command is part of Ruby's kernel
# which will give you a way to call a method from anyway. We can pass
# the method around from class to class, and still use it. So in this
# case we're putting the method 'command_item' into another class,
# because that's where its held until we select the option. They're
# all stored in Window_Command. It has a container (A simple Hash)
# to hold them all.
def create_command
@cmd = Window_MenuHCommand.new(Pos_X, Pos_Y + @stat.height)
@cmd.set_handler(:item, method(:command_item))
@cmd.set_handler(:save, method(:command_save))
@cmd.set_handler(:quit, method(:command_quit))
end
# Create the status menu, which sets itself up automatically, we don't
# need to pass any values to its initialize method for it to finish
# properly.
def create_status
@stat = Window_KsiStatus.new
end
# The SceneManager is what handles all the scenes in the game. As such,
# that's how we change them too. The command_whatever methods just change
# the scene.
def command_item
SceneManager.call(Scene_Items)
end
def command_save
SceneManager.call(Scene_Save)
end
def command_quit
SceneManager.call(Scene_End)
end
# Update is called by Scene_Base every frame. In this scene, we're going
# to run Scene_Base's update so that the game doesn't crash, and then we
# check to see if we press the :B key, which is the escape key by default.
# If we do press it, we return to the scene that was up before this.
def update
super
if Input.trigger?(:B)
SceneManager.return
end
end
# When the scene is being closed, we need to clean up, so we dispose our
# windows so that we can free up the memory they used.
def terminate
super
@stat.dispose
@cmd.dispose
end
end
class Window_KsiItem < Window_Selectable
# This class is mostly recycled from the Window_ItemList class, as it mainly still all
# applied, I just took out the category window. The attr_accessor is saying to let
# a class that has a KsiItem window to change or see what we have for our @help_window
# variable. We use this to give it the window under the item list in the item scene
# so that it can update the description.
attr_accessor :help_window
include Zale::KsiMenu
def initialize
@items = []
super(Pos_X, Pos_Y, Win_W, Win_H)
refresh
select(0)
activate
end
def make_item_list
@items = $game_party.all_items
@items.empty? ? @items.push(nil) : nil
end
def col_max
return 2
end
def enable?(item)
$game_party.usable?(item)
end
def draw_item(index)
item = @items[index]
if item
rect = item_rect(index)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enable?(item), rect.width - 24)
draw_item_number(rect, item)
end
end
def draw_item_number(rect, item)
# draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
end
def item
@items && index >= 0 ? @items[index] : nil
end
def update_help
@help_window.set_item(item)
end
def cursor_move
super
update_help
end
def item_max
return @items.size
end
def refresh
make_item_list
create_contents
draw_all_items
end
end
class Scene_Items < Scene_ItemBase
# The Item scene class. In the initialize method, we setup the help window
# that displays the item's description, as well as create the item window.
include Zale::KsiMenu
def start
super
create_help_window
create_item
@actor_window.hide
@help_window.x = Pos_X
@help_window.y = Pos_Y + Win_H
@help_window.height = @help_window.fitting_height(1)
@help_window.width = Win_W
@help_window.arrows_visible = Arrows
if Window_Skin != ""
@help_window.windoskin = Cache.system(Window_Skin)
@item_window.windowskin = Cache.system(Window_Skin)
end
end
# We create the item window, set its help window using the attr_accessor we made
# earlier, and then update the help window so that the description is updated and
# ready when the scene starts.
def create_item
@item_window = Window_KsiItem.new
@item_window.help_window = @help_window
@item_window.update_help
end
# Check to see if we want to leave the item scene!
def update
super
if Input.trigger?(:B)
SceneManager.return
end
end
# Clean up our item window. The help window was made by the superclass, so we
# letit take care of that.
def terminate
super
@item_window.dispose
end
end
Downloads / Referenced Files
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadLicense / Terms Note
# ◦ Credit: KGC for XP MiniMap Script, # this script can't be done without his MiniMap. #-------------------------------------------------------------- # ◦ Ported to VX Ace by Kal on 2011/12/17
Referenced Images / Attachments
Creator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
Topic Summary
Loading summary...


