Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Munkis' Scrolling Location Window Display
munkis
post Jan 7 2011, 05:03 AM
Post #1


Woah, dude...
Group Icon

Group: Revolutionary
Posts: 197
Type: Writer
RM Skill: Intermediate




Munkis' Scrolling Location Window Display

Version: 1.1
Author: munkis & OriginalWij
Release Date: 01/07/2011


Exclusive Script at RPG RPG Revolution


Introduction
This is an edited version of a script made for me a couple years ago (before I knew how to script) by the man... the myth... the legend... OriginalWij.

Features
Displays the name of the map you're currently on. The name will become a scrolling marquee if it is longer than the window. While it is intended for use with a minimap script, you could probably make it into a map name pop-up like in Lufia & the Fortress of Doom

Script
Munkis' Location Window Display
CODE
#------------------------------------------------------------------------------
#  * Scrolling Location Window Display V 1.1
#  * Made by OriginalWij & munkis
#    ╔══════════╗
#    ║ FEATURES ║
#    ╚══════════╝
#  * This is a modified version of a script OriginalWij kindly made for me back
#    before I could script worth a snake fart.  This little gem is intended for
#    use with a minimap script, and displays the name of the map you're
#    currently on, which will become a scrolling marquee if it doesn't fit in
#    the window.  But with a little tweaking, you could probably use it as a map
#    name pop-up ala Lufia & the Fortress of Doom.
#  * Tested 100% compatible with all known minimap scripts.
#  * V 1.0: Initial release
#  * V 1.1: Text is no longer squashed when the string is longer than the
#               window, and the scrolling can now be delayed (thanks to Night Runner).
#------------------------------------------------------------------------------

module OW_MNK_LOC_DIS
  WINDOW_PROPERTIES = [414,                         # X
                       290,                         # Y
                       1000,                        # Z
                       146,                         # Width
                       56,                          # Height
                       0,                           # Window Opacity
                       Color.new(255,255,255,255),  # Font Color
                       12,                          # Font Size
                       16,                          # Enable Switch
                       30,                          # Scroll Speed Delay
                       99,                          # Delay Before Scrolling
                      ]
end

#==============================================================================
# Game_Map
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # Class Variables
  #--------------------------------------------------------------------------
  @@map_name_list = []
  #--------------------------------------------------------------------------
  # Get Map Name (New)
  #--------------------------------------------------------------------------
  def name
    if @@map_name_list[@map_id].nil?
      name = load_data("Data/MapInfos.rvdata")[@map_id].name
      name.gsub!(/\\N\[([0-9]+)\]/i) {$game_actors[$1.to_i].name}
      name.gsub!(/\[.*\]/) {""}
      @@map_name_list[@map_id] = name
    end
    return @@map_name_list[@map_id]
  end
end

#==============================================================================
# Spriteset_Map
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # Initialize (Mod)
  #--------------------------------------------------------------------------
  alias ow_mnk_loc_dis_sm_initialize initialize unless $@
  def initialize
    @location_window = Location_window.new
    ow_mnk_loc_dis_sm_initialize
    update
  end
  #--------------------------------------------------------------------------
  # Update (Mod)
  #--------------------------------------------------------------------------
  alias ow_mnk_loc_dis_sm_update update unless $@
  def update
    ow_mnk_loc_dis_sm_update
    wind_vis = $game_switches[OW_MNK_LOC_DIS::WINDOW_PROPERTIES[8]]
    @location_window.visible = wind_vis
    @location_window.update if wind_vis
  end
  #--------------------------------------------------------------------------
  # Dispose (Mod)
  #--------------------------------------------------------------------------
  alias ow_mnk_loc_dis_sm_dispose dispose unless $@
  def dispose
    ow_mnk_loc_dis_sm_dispose
    @location_window.dispose
  end
end

#==============================================================================
# Location_Window (New)
#==============================================================================

class Location_Window < Window_Base
  #--------------------------------------------------------------------------
  # Include Modules
  #--------------------------------------------------------------------------
  include OW_MNK_LOC_DIS
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize
    x, y = WINDOW_PROPERTIES[0..1]
    width, height = WINDOW_PROPERTIES[3..4]
    super(x, y, width, height)
    @text_size = 0
    @scroll_amount = 0
    @scroll_delay = 0
    @current_x = 0
    @frames_since_refresh = 0
    @reset_scroll = false
    self.z = WINDOW_PROPERTIES[2]
    self.opacity = WINDOW_PROPERTIES[5]
    refresh
  end
  #--------------------------------------------------------------------------
  # Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    create_contents
    self.contents.font.color = WINDOW_PROPERTIES[6]
    self.contents.font.size = WINDOW_PROPERTIES[7]
    @text_size = self.contents.text_size($game_map.name).width
    if @text_size > self.contents.width
      @scroll_amount = @text_size
    end
    width = @text_size + 64
    self.contents.draw_text(@current_x, 0, width, 24, $game_map.name)
  end
  #--------------------------------------------------------------------------
  # Update
  #--------------------------------------------------------------------------
  def update
    super
    @frames_since_refresh += 1
    if @frames_since_refresh > WINDOW_PROPERTIES[10]
      if @scroll_amount > 0
        @scroll_delay -= 1 unless @scroll_delay == 0
        if @scroll_delay == 0
          @current_x -= @scroll_amount / WINDOW_PROPERTIES[9]
          self.contents.clear
          self.contents.font.color = WINDOW_PROPERTIES[6]
          self.contents.font.size = WINDOW_PROPERTIES[7]
          text = $game_map.name
          self.contents.draw_text(@current_x, 0, @text_size + 64, 24, text)
          @scroll_delay = WINDOW_PROPERTIES[9] / 2
          if -@current_x >= @scroll_amount
            @reset_scroll = true
          end  
        end  
        if @reset_scroll  
          @current_x = self.contents.width
          @reset_scroll = false
        end
      end
    end
  end
end


Scrolling area name window(useful if you put all of your interior maps on one giant map)
CODE
#------------------------------------------------------------------------------
#  * Scrolling Area Location Window Display V 1.0
#  * Made by OriginalWij & munkis
#    ╔══════════╗
#    ║ FEATURES ║
#    ╚══════════╝
#  * This is a modified version of a script OriginalWij kindly made for me back
#    before I could script worth a snake fart.  This little gem is intended for
#    use with a minimap script, and displays the name of the map you're
#    currently on, which will become a scrolling marquee if it doesn't fit in
#    the window.  But with a little tweaking, you could probably use it as a map
#    name pop-up ala Lufia & the Fortress of Doom.
#  * Tested 100% compatible with all known minimap scripts.
#  * V 1.0: Initial release
#------------------------------------------------------------------------------

module OW_MNK_ARE_DIS
  WINDOW_PROPERTIES = [488,                         # X
                       345,                         # Y
                       1,                           # Z
                       146,                         # Width
                       56,                          # Height
                       0,                           # Window Opacity
                       Color.new(255,255,255,255),  # Font Color
                       16,                          # Font Size
                       7,                           # Enable Switch
                       30,                          # Scroll Speed Delay
                       60,                          # Delay Before Scrolling
                      ]
end

#==============================================================================
# Game_Map
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # Class Variables
  #--------------------------------------------------------------------------
  @@map_name_list = []
  @@areas_list = []
  #--------------------------------------------------------------------------
  # Get Map Name (New)
  #--------------------------------------------------------------------------
  def map_name
    if @@map_name_list[@map_id].nil?
      name = load_data("Data/MapInfos.rvdata")[@map_id].name
      name.gsub!(/\\N\[([0-9]+)\]/i) {$game_actors[$1.to_i].name}
      name.gsub!(/\[.*\]/) {""}
      @@map_name_list[@map_id] = name
    end
    return @@map_name_list[@map_id]
  end
  #--------------------------------------------------------------------------
  # * Determine if in Area
  #     area : Area data (RPG::Area)
  #--------------------------------------------------------------------------
  def in_area?(area)
    return false if not area.is_a?(RPG::Area)
    return false if $game_map.map_id != area.map_id
    px, py = $game_player.x, $game_player.y
    return false if px < area.rect.x
    return false if py < area.rect.y
    return false if px >= area.rect.x + area.rect.width
    return false if py >= area.rect.y + area.rect.height
    return true
  end
  #--------------------------------------------------------------------------
  # Get Area Name
  #--------------------------------------------------------------------------
  def area_name
    # Do nothing if there's no areas
    return "" if $data_areas.empty?
    # Initialize the areas list if appropriate
    @@areas_list = $data_areas.values.clone if @@areas_list.empty?
    # Initialize a variable for area that is inhabited
    inhabited_area = nil
    # Loop through the areas
    for area in @@areas_list
      # If the player is in the area, save it and break the loop
      if in_area?(area)
        inhabited_area = area
        break
      end
    end
    # Do nothing if the area doesn't exist
    return "" if inhabited_area.nil?
    # Move this area to the start of the @@areas_list (speed performance)
    @@areas_list.delete(inhabited_area)
    @@areas_list.insert(0, inhabited_area)
    # Return this area name
    return area.name
  end
end

#==============================================================================
# Spriteset_Map
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # Initialize (Mod)
  #--------------------------------------------------------------------------
  alias ow_mnk_are_dis_sm_initialize initialize unless $@
  def initialize
    @area_location_window = Window_AreaLocation.new
    ow_mnk_are_dis_sm_initialize
    update
  end
  #--------------------------------------------------------------------------
  # Update (Mod)
  #--------------------------------------------------------------------------
  alias ow_mnk_are_dis_sm_update update unless $@
  def update
    ow_mnk_are_dis_sm_update
    wind_vis = !$game_switches[OW_MNK_ARE_DIS::WINDOW_PROPERTIES[8]]
    @area_location_window.visible = wind_vis
    @area_location_window.update if wind_vis
  end
  #--------------------------------------------------------------------------
  # Dispose (Mod)
  #--------------------------------------------------------------------------
  alias ow_mnk_are_dis_sm_dispose dispose unless $@
  def dispose
    ow_mnk_are_dis_sm_dispose
    @area_location_window.dispose
  end
end

#==============================================================================
# Location_Window (New)
#==============================================================================

class Window_AreaLocation < Window_Base
  #--------------------------------------------------------------------------
  # Include Modules
  #--------------------------------------------------------------------------
  include OW_MNK_ARE_DIS
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize
    x, y = WINDOW_PROPERTIES[0..1]
    width, height = WINDOW_PROPERTIES[3..4]
    super(x, y, width, height)
    @text_size = 0
    @reset_scroll = false
    @area_name = ""
    self.z = WINDOW_PROPERTIES[2]
    self.opacity = WINDOW_PROPERTIES[5]
    refresh
  end
  #--------------------------------------------------------------------------
  # Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    create_contents
    @current_x = 0
    @scroll_amount = 0
    @scroll_delay = 0
    @frames_since_refresh = 0
    @area_name = $game_map.area_name.clone
    self.contents.font.color = WINDOW_PROPERTIES[6]
    self.contents.font.size = WINDOW_PROPERTIES[7]
    @text_size = self.contents.text_size(@area_name).width
    if @text_size > self.contents.width
      @scroll_amount = @text_size
    end
    text_width = @text_size + 64
    self.contents.draw_text(@current_x, 0, text_width, 24, @area_name)
  end
  #--------------------------------------------------------------------------
  # Update
  #--------------------------------------------------------------------------
  def update
    super
    refresh if @area_name != $game_map.area_name
    @frames_since_refresh += 1
    if @frames_since_refresh > WINDOW_PROPERTIES[10]
      if @scroll_amount > 0
        @scroll_delay -= 1 unless @scroll_delay == 0
        if @scroll_delay == 0
          @current_x -= @scroll_amount / WINDOW_PROPERTIES[9]
          self.contents.clear
          self.contents.font.color = WINDOW_PROPERTIES[6]
          self.contents.font.size = WINDOW_PROPERTIES[7]
          text = $game_map.area_name
          self.contents.draw_text(@current_x, 0, @text_size + 64, 24, text)
          @scroll_delay = WINDOW_PROPERTIES[9] / 2
          if -@current_x >= @scroll_amount
            @reset_scroll = true
          end  
        end  
        if @reset_scroll  
          @current_x = self.contents.width
          @reset_scroll = false
        end
      end
    end
  end
end


Customization
The array in the config module should be pretty simple to understand.

Compatibility
Tested 100% compatible with all known minimap scripts.

Screenshot

This screenshot is from a game I'm working on, so consider this your spoiler warning.

Location window pic


The text here is kinda small, but that can be changed in the script.


DEMO
The script is pretty simple to use, so a demo shouldn't be necessary.

Installation
Place in MATERIALS, above MAIN.

FAQ
Q: ZOMG teh scriptz doesn't werk!!!
A: First of all, be more specific. Second, all reports typed in chat-speak or 1337-speak will be ignored.

Terms and Conditions
I don't mind this script being posted or linked on other sites AS LONG AS YOU GIVE CREDIT!!! Same goes for using this in your project. Contact me if you want to use this in a commercial project.

Credits
Credit me (munkis) and OriginalWij. I don't know if OW cares, but it couldn't hurt.

This post has been edited by munkis: Nov 10 2011, 02:39 PM


__________________________
Go to the top of the page
 
+Quote Post
   
Kread-EX
post Jan 9 2011, 11:55 AM
Post #2


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




Found a crashing bug. In Spriteset_Map, you ceate the window like this:
CODE
@location_window = Location_window.new

While the window class takes a capitalized W.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
munkis
post Jan 9 2011, 01:10 PM
Post #3


Woah, dude...
Group Icon

Group: Revolutionary
Posts: 197
Type: Writer
RM Skill: Intermediate




D'oh pinch.gif

Fixed the N00B typo.


__________________________
Go to the top of the page
 
+Quote Post
   
hit268
post Jan 28 2011, 08:29 PM
Post #4


Level 5
Group Icon

Group: Member
Posts: 61
Type: None
RM Skill: Undisclosed




Umm confused here... It gives me an error on line 52 like Kread-EX said and I fix it but then I get an error on line 62! Help please!


__________________________

Top 5 awesome characters

Go to the top of the page
 
+Quote Post
   
munkis
post Jan 29 2011, 05:48 AM
Post #5


Woah, dude...
Group Icon

Group: Revolutionary
Posts: 197
Type: Writer
RM Skill: Intermediate




Can you be more specific? Because I can't reproduce the error you say you have.

off-topic: And why can't I correct the typo in the script? Every time I go in to edit, I click on 'Submit Modified Post' only to find that it's still lowercase.


__________________________
Go to the top of the page
 
+Quote Post
   
munkis
post Nov 2 2011, 01:50 PM
Post #6


Woah, dude...
Group Icon

Group: Revolutionary
Posts: 197
Type: Writer
RM Skill: Intermediate




UPDATE! See first post.


__________________________
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Nov 3 2011, 01:01 AM
Post #7


Level 50
Group Icon

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




Thanks for the credits tongue.gif


__________________________
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
   
munkis
post Nov 10 2011, 02:43 PM
Post #8


Woah, dude...
Group Icon

Group: Revolutionary
Posts: 197
Type: Writer
RM Skill: Intermediate




No problem; I also just added the Scrolling area name window patch (which could probably be a standalone script if the user were so inclined). I slightly modified it to look for the same switch that the original script uses, and if that switch is off, this script shows the area name. Otherwise they would display text simultaneously.


__________________________
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 May 2013 - 10:26 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker