Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> 


———
Before you ask! Read! ;)

You must have 30+ Posts to create a topic here!

Thanks for reading!
———

 
Reply to this topicStart new topic
> Map Journal, Looking for a very basic Map Journal
superafroboy
post Mar 12 2012, 06:45 PM
Post #1


Level 3
Group Icon

Group: Member
Posts: 39
Type: None
RM Skill: Skilled




Hey, I'm just looking to have a simple journal that can be called, and it will have a list of maps that you currently have. For the maps to appear in the list the player would have to actually have the map as an in game item, or possibly just a turn on a switch. Whichever is easier / most efficient.

When you select a map from the list it just shows a full screen png, and you can press any button to return to the map journal.


__________________________
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Mar 13 2012, 06:32 AM
Post #2


Level 50
Group Icon

Group: +Gold Member
Posts: 1,529
Type: Scripter
RM Skill: Undisclosed




I've made a quick demo, how does this look:

CODE
class Game_Map
  alias nr_mapJournal_initialize  initialize  unless $@
  alias nr_mapJournal_setup       setup       unless $@
  attr_reader :visited_maps
  @@map_infos = load_data("Data/MapInfos.rxdata")
  def initialize(*args)
    # Initialize the array of map' visited
    @visited_maps = []
    # Run the original initialize
    nr_mapJournal_initialize(*args)
  end
  def setup(*args)
    # Run the original setup
    nr_mapJournal_setup(*args)
    # Add this map to the list of maps visited
    @visited_maps = ( @visited_maps + [@@map_infos[@map_id].name] ).uniq
  end
end

class Window_Preview_Map < Window_Base
  def initialize(graphic_name)
    # Set an unachievable bitmap
    @last_graphic_name = -1
    # Tell Window_Base some dummy settings for the x, y, width and height
    super(0, 0, 640, 480)
    # Set the graphic to the graphic_name
    set_graphic(graphic_name.to_s)
  end
  
  def set_graphic(graphic_name)
    # If the graphic has changed, refresh the bitmap
    if graphic_name != @last_graphic_name
      @last_graphic_name = graphic_name
      refresh
    end
  end
  
  def refresh
    # Dispose and recreate the bitmap (in case the window size has changed)
    self.contents.dispose unless self.contents.nil? or self.contents.disposed?
    self.contents = Bitmap.new(width - 32, height - 32)
    # Load the image
    src_bitmap = RPG::Cache.picture(@last_graphic_name)
    # Get the aspect ratio
    sf_width, sf_height = self.contents.width, self.contents.height
    s_width, s_height = src_bitmap.width, src_bitmap.height
    if s_width * 1000 / s_height > sf_width * 1000 / sf_height
      ratio = sf_width.to_f / s_width.to_f
      d_width = sf_width
      d_height = (s_height * ratio).to_i
      d_x = 0
      d_y = (sf_height - d_height) / 2
    else
      ratio = sf_height.to_f / s_height.to_f
      d_height = sf_height
      d_width = (s_width * ratio).to_i
      d_y = 0
      d_x = (s_width - d_width) / 2
    end
    dest_rect = Rect.new(d_x, d_y, d_width, d_height)
    # Copy the graphic onto this window
    self.contents.stretch_blt(dest_rect, src_bitmap, src_bitmap.rect)
  end
end
      


class Scene_MapJournal
  def initialize
    @return_scene = $scene.clone
  end
  def main
    # Run the starting code (create windows, etc)
    start
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    terminate
  end
  def start
    # Get the list of maps visited
    @map_names = $game_map.visited_maps
    # Ensure that there is at least 1 command
    @map_names = [''] if @map_names.empty?
    # Create the title window
    @title_window = Window_Help.new
    @title_window.set_text('Map Journal', 1)
    # Create the map list
    @command_window = Window_Command.new(192, @map_names)
    @command_window.y = @title_window.height
    @command_window.height = 640 - @title_window.height
    # Create the preview
    map_name = @map_names[@command_window.index]
    @preview_map_window = Window_Preview_Map.new(map_name)
    @preview_map_window.x = @command_window.width
    @preview_map_window.y = @title_window.height
    @preview_map_window.width = 640 - @command_window.width
    @preview_map_window.height = 480 - @title_window.height
    @preview_map_window.refresh
    # Create a variable to know if the image is fullscreen or not
    @state = :small_image
  end
  def update
    # Update the windows
    @title_window.update
    @command_window.update
    @preview_map_window.update
    # Update the picture being shown
    map_name = @map_names[@command_window.index]
    @preview_map_window.set_graphic(map_name)
    # Update the processing
    case @state
    when :small_image
      small_image_update
    when :large_image
      large_image_update
    end
  end
  def terminate
    @title_window.dispose
    @command_window.dispose
    @preview_map_window.dispose
  end
  def small_image_update
    # If the decision key is rpessed
    if Input.trigger?(Input::C)
      # If the picture is a real one
      map_name = @map_names[@command_window.index]
      if map_name != ''
        # Play the decision SE
        $game_system.se_play($data_system.decision_se)
        # Create the fullscreen image
        @sprite = Sprite.new
        @sprite.z = 99999
        @sprite.bitmap = RPG::Cache.picture(map_name)
        @state = :large_image
      # If the map name doesn't exist
      else
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
      end
    end
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      $scene = @return_scene
    end
  end
  def large_image_update
    # Update the sprite
    @sprite.update
    # Make sure that the image is the highlighted option
    map_name = @map_names[@command_window.index]
    @sprite.bitmap = RPG::Cache.picture(map_name)
    # If anything is pressed
    if Input.trigger?(Input::C) or Input.trigger?(Input::B)
      # Play the decision SE
      $game_system.se_play($data_system.decision_se)
      # Return from fullscreen mode
      @state = :small_image
      # Dispose the sprite
      @sprite.bitmap.dispose
      @sprite.dispose
    end
  end
end


At the moment it gets the maps that you've been on, and looks for a picture that has the same name as the map.
I can change it over to items/switches easily enough, both take the same amount of effort so let me know which is easier for your eventing ^_^

And how's the layout, does anything need changing?


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
superafroboy
post Mar 13 2012, 06:47 AM
Post #3


Level 3
Group Icon

Group: Member
Posts: 39
Type: None
RM Skill: Skilled




Looks great! I think I would rather have it based on items, though. That way the player could have more then one map for a specific area, perhaps with one showing locations of chests, and another showing some other detail or whatever. Also I could have maps that are not based on a specific map, perhaps some kind of treasure map that has clue's and junk on it.

But the layout and everything else is perfect!

This post has been edited by superafroboy: Mar 13 2012, 06:47 AM


__________________________
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Mar 14 2012, 01:29 AM
Post #4


Level 50
Group Icon

Group: +Gold Member
Posts: 1,529
Type: Scripter
RM Skill: Undisclosed




Enjoy!

CODE
#==============================================================================
# ** XP: Night_Runner's Map Journal Script.
#------------------------------------------------------------------------------
# History:
#  Date Created: 14/Mar/2012
#  Created for: superafroboy
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=55718
#
# Description:
#  This script creates a scene (Scene_Map_Journal), which displays images
#  linked to maps.
#
# How to Install:
#  Copy this entire script. In your game editor select Tools >> Script
#  Editor. Along the left scroll to the bottom, right click on 'Main' and
#  select 'Insert'. Paste this code on the right.
#
# Customisation:
#  See lines 35 - 42 below.
#
# Technical Information:
#  On line 36 you define which items are required to be held in the party
#  before it's appropriate map is displayed. The image that the item
#  points to must have the same name as the item and must be placed
#  in the Graphics/Pictures folder.
#==============================================================================



#==============================================================================
# ** Customisation.
#==============================================================================

module NR_MapJournal_Customisation
  # Items 34 through 36 (3 items) represent the maps unlockable
  Map_Items = 34..36
  # Title information
  Title_Text = "Map Journal"
  Title_Font_Increase = 4
  # Preview window text
  To_Fullscreen_Text = "Press C to toggle between fullscreen"
  To_Fullscreen_Font_Increase = 4
end



#==============================================================================
# ** Window_Preview_Map
#------------------------------------------------------------------------------
#  This window displays a preview of the map.
#==============================================================================

class Window_Preview_Map < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(graphic_name)
    # Set an unachievable bitmap
    @last_graphic_name = -1
    # Tell Window_Base some dummy settings for the x, y, width and height
    super(0, 0, 640, 480)
    # Set the graphic to the graphic_name
    set_graphic(graphic_name.to_s)
  end
  #--------------------------------------------------------------------------
  # * Set Graphic
  #--------------------------------------------------------------------------
  def set_graphic(graphic_name)
    # If the graphic has changed, refresh the bitmap
    if graphic_name != @last_graphic_name
      @last_graphic_name = graphic_name
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Dispose and recreate the bitmap (in case the window size has changed)
    self.contents.dispose unless self.contents.nil? or self.contents.disposed?
    self.contents = Bitmap.new(width - 32, height - 32)
    # Load the image
    src_bitmap = RPG::Cache.picture(@last_graphic_name)
    # Get the aspect ratio
    sf_width, sf_height = self.contents.width, self.contents.height
    s_width, s_height = src_bitmap.width, src_bitmap.height
    if s_width * 1000 / s_height > sf_width * 1000 / sf_height
      ratio = sf_width.to_f / s_width.to_f
      d_width = sf_width
      d_height = (s_height * ratio).to_i
      d_x = 0
      d_y = (sf_height - d_height) / 2
    else
      ratio = sf_height.to_f / s_height.to_f
      d_height = sf_height
      d_width = (s_width * ratio).to_i
      d_y = 0
      d_x = (s_width - d_width) / 2
    end
    dest_rect = Rect.new(d_x, d_y, d_width, d_height)
    # Copy the graphic onto this window
    self.contents.stretch_blt(dest_rect, src_bitmap, src_bitmap.rect)
    # Press C to enert fullscreen
    text_y = self.contents.height - 32
    text = NR_MapJournal_Customisation::To_Fullscreen_Text
    font_size = NR_MapJournal_Customisation::To_Fullscreen_Font_Increase
    self.contents.font.size += font_size
    self.contents.draw_text(0, text_y, self.contents.width, 32, text, 1)
    self.contents.font.size -= font_size
  end
end
      


#==============================================================================
# ** Scene_MapJournal
#------------------------------------------------------------------------------
#  This class performs the map journal scene processing.
#==============================================================================

class Scene_MapJournal
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @return_scene = $scene.clone
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Run the starting code (create windows, etc)
    start
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    terminate
  end
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    # Get the list of maps visited
    @map_names = get_map_names
    # Ensure that there is at least 1 command
    @map_names = [''] if @map_names.empty?
    # Create the title window
    @title_window = Window_Help.new
    text = NR_MapJournal_Customisation::Title_Text
    d_font_size = NR_MapJournal_Customisation::Title_Font_Increase
    @title_window.contents.font.size += d_font_size
    @title_window.set_text(text, 1)
    @title_window.contents.font.size -= d_font_size
    # Create the map list
    @command_window = Window_Command.new(192, @map_names)
    @command_window.y = @title_window.height
    @command_window.height = 640 - @title_window.height
    # Create the preview
    map_name = @map_names[@command_window.index]
    @preview_map_window = Window_Preview_Map.new(map_name)
    @preview_map_window.x = @command_window.width
    @preview_map_window.y = @title_window.height
    @preview_map_window.width = 640 - @command_window.width
    @preview_map_window.height = 480 - @title_window.height
    @preview_map_window.refresh
    # Create a variable to know if the image is fullscreen or not
    @state = :small_image
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update the windows
    @title_window.update
    @command_window.update
    @preview_map_window.update
    # Update the picture being shown
    map_name = @map_names[@command_window.index]
    @preview_map_window.set_graphic(map_name)
    # Update the processing
    case @state
    when :small_image
      small_image_update
    when :large_image
      large_image_update
    end
  end
  #--------------------------------------------------------------------------
  # * Terminate Scene
  #--------------------------------------------------------------------------
  def terminate
    @title_window.dispose
    @command_window.dispose
    @preview_map_window.dispose
    # Remove the sprite if it existed
    unless @sprite.nil?
      @sprite.bitmap.dispose
      @sprite.dispose
      @sprite = nil
    end
  end
  #--------------------------------------------------------------------------
  # * Update: Small Image Processing
  #--------------------------------------------------------------------------
  def small_image_update
    # If the decision key is rpessed
    if Input.trigger?(Input::C)
      # If the picture is a real one
      map_name = @map_names[@command_window.index]
      if map_name != ''
        # Play the decision SE
        $game_system.se_play($data_system.decision_se)
        # Create the fullscreen image
        @sprite = Sprite.new
        @sprite.z = 99999
        @sprite.bitmap = RPG::Cache.picture(map_name)
        @state = :large_image
      # If the map name doesn't exist
      else
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
      end
    end
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      $scene = @return_scene
    end
  end
  #--------------------------------------------------------------------------
  # * Update: Large Image Processing
  #--------------------------------------------------------------------------
  def large_image_update
    # Update the sprite
    @sprite.update
    # Make sure that the image is the highlighted option
    map_name = @map_names[@command_window.index]
    @sprite.bitmap = RPG::Cache.picture(map_name)
    # If anything is pressed
    if Input.trigger?(Input::C) or Input.trigger?(Input::B)
      # Play the decision SE
      $game_system.se_play($data_system.decision_se)
      # Return from fullscreen mode
      @state = :small_image
      # Dispose the sprite
      @sprite.bitmap.dispose
      @sprite.dispose
      @sprite = nil
    end
  end
  #--------------------------------------------------------------------------
  # * Get Map Names
  #--------------------------------------------------------------------------
  def get_map_names
    # Create a blank array
    names = []
    # Loop through each item
    for item_id in NR_MapJournal_Customisation::Map_Items.to_a
      # If the party has that item
      if $game_party.item_number(item_id) > 0
        # Add that item's name to the list of maps visited
        names << $data_items[item_id].name
      end
    end
    return names
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================


So just to iterate how to make the images:
How to setup

Under my Items tab of the database I have items MAP001 - MAP003, and by using the item ID to the left of them they are in the range ID = 34 to ID = 36



So we import 3 images with the same name as the items (I only have 2 for bug testing purposes, but you should have MAP003 here as well)



And on line 36 of the script you need to say that the items are in the range between ID = 34 to ID = 36



__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 06:33 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker