Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: nathmatt on April 15, 2010, 06:53:01 pm

Title: [XP] Character Drop Down Menu
Post by: nathmatt on April 15, 2010, 06:53:01 pm
Character Drop Down Menu
Authors: Nathmatt
Version: 1.15
Type: Misc System
Key Term: Custom Menu System



Introduction
creates a drop down menu for the character you right click on
Requires RMX-OS & Mouse Controller by Blizzard


Features



Screenshots
Spoiler: ShowHide
(http://img36.imageshack.us/img36/653/screenshotovj.png)



Demo

No Demo


Script
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Character Drop Down Menu by Nathmatt
# Version: 1.15
# Type: Misc System
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  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.
# # 
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Character_Drop_Down_Menu
 
  def initialize
    username = ''
    @mini_list_array = ['Add Buddy','Trade']
    @mini_list_array.insert(1,'Add Party') if $blizzabs_rmxos != nil
    if $network.guildleader == $network.username
      @mini_list_array.insert(0,'Guild Invite')
    end
    @mini_list_array.push('Kick','Ban') if $network.usergroup > 0
    @confirm_window = Window_Confirm.new
    @mini_list = Window_Mini_List.new(@mini_list_array)
    @mini_list.visible = false
    @wait = 0
  end

  def update
    @wait -= 1 if @wait > 0
    if Input.trigger?(Input::Key['Mouse Right'])
      return if @wait != 0
      @mx,@my = $mouse.pos
      @sx,@sy = $mouse.position
      @player_username = $network.check_player(@mx,@my)
      @players_info = $network.get_player(@mx,@my)
      if @player_username != nil
        @mini_list.visible = true
        @mini_list.active = true
        @mini_list.x = @sx
        @mini_list.y = @sy
        $MCES.disabled = true
      end
      @wait = 5
    end
   
    if @mini_list.active
      @mini_list.update
      if Input.trigger?(Input::Key['Mouse Left'])
        return if @wait != 0
        if @mini_list.index >= 0
          @confirm_window.set_commands(@mini_list.item,@player_username)
        end
        @mini_list.visible = false
        @mini_list.active = false
        @wait = 5
      end
    end
   
    if @confirm_window.active
      @confirm_window.update
      if Input.trigger?(Input::Key['Mouse Left'])
        return if @wait != 0
        case @confirm_window.index
        when 0
          case @mini_list.item
          when 'Add Buddy'
            $network.command_buddy_add(@player_username)
          when 'Trade'     
            $network.command_trade_request(@player_username)
          when 'Guild Invite'
            $network.command_guild_invite(@player_username)
          when 'Kick'
            $network.command_kick_player(@player_username)
          when 'Ban'
            $network.command_ban_player(@player_username)
          when 'Add Party'
            $network.command_party_invite(@player_username)
          end
          @confirm_window.visible = false
          @confirm_window.active = false
        else
          @confirm_window.visible = false
          @confirm_window.active = false
        end
        $MCES.disabled = false
        $MCES.wait = 5
        @wait = 5
      end
    end
   
  end
   
end
#==============================================================================
# Scene_Map
#==============================================================================
class Scene_Map
 
  alias character_drop_down_menu_main main
  def main
    @mini_menu = Character_Drop_Down_Menu.new
    character_drop_down_menu_main
  end
 
  alias character_drop_down_menu_update update
  def update
    @mini_menu.update
    character_drop_down_menu_update
  end
 
end
#==============================================================================
# Mouse
#==============================================================================
class Mouse
 
  attr_accessor :cursor
 
  def pos
    x, y = self.position
    x = ( x + $game_map.display_x / 4) / 32
    y = ( y + $game_map.display_y / 4) / 32
    return x, y
  end
   
end
#==============================================================================
# Window_list
#==============================================================================
class Window_Mini_List < Window_Selectable
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(list)
    super(476, 175, 104, 300)
    @list = list
    @column_max = 1
    refresh
    self.index = 0
    self.opacity = 0
    self.active = false
    self.z = 10000
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index] if self.index >= 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    @list.each {|i| @data.push(i)}
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.fill_rect(0,0,width,height,Color.new(0, 0, 0, 160))
      @data.each_index {|i| draw_item(i)}
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = index % 1 * (288 + 32)
    y = index / 1 * 32
    self.contents.font.size = 16
    self.contents.draw_text(x, y, width - 32, 32, @data[index].to_s, 1)
  end
end
#==============================================================================
# Window_Confirm
#==============================================================================
class Window_Confirm < Window_Selectable
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize
    super(100, 100, 300, 150)
    @data = ['Yes','No']
    @column_max = 2
    @command = nil
    @user = nil
    refresh
    self.index = 0
    self.opacity = 0
    self.active = false
    self.visible = false
    self.z = 10000
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index] if self.index >= 0
  end
  #--------------------------------------------------------------------------
  # * reset
  #--------------------------------------------------------------------------
  def set_commands(command,user)
    @command = command
    @user = user
    self.visible = true
    self.active  = true
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, 20 + row_max * 32)
      self.contents.font.size = 16
      self.contents.fill_rect(0,0,width,height,Color.new(0, 0, 0, 160))
      self.contents.draw_text(0,0,width,20,
      'Are you sure you want to '+ @command.to_s + ' ' + @user.to_s)
      @data.each_index {|i| draw_item(i)}
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = index * (width - 32) / 2
    self.contents.draw_text(x, 20, (width - 32) / 2, 32, @data[index].to_s, 1)
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(self.index * (width - 32) / 2, 25,
     (width - 32) / 2 , 20)
    end
  end
end
#============================================================================
# RMXOS::Network
#============================================================================
class RMXOS::Network
  def check_player(x,y)
    @players.any? {|key, value|
    return value.username if value.x == x && value.y == y}
    return nil
  end
  def get_player(x,y)
    if $blizzabs_rmxos != nil
      @players.any? {|key, value|
      return value.battler if value.x == x && value.y == y}
    end
    return nil
  end
end
# Load the network
$network = RMXOS::Network.new



Instructions
place below Mouse Controller script & below my Mouse Path Finder


Compatibility
no compatibility issues known


Credits and Thanks




Author's Notes
Any suggestions for updates are appreciated
Title: Re: [XP] Character Drop Down Menu
Post by: Wizered67 on April 15, 2010, 07:47:20 pm
amazing! level up!
Title: Re: [XP] Character Drop Down Menu
Post by: Blizzard on April 16, 2010, 02:23:32 am
Ah, finally people are extending RMX-OS in the right ways. :D
Title: Re: [XP] Character Drop Down Menu
Post by: nathmatt on April 16, 2010, 08:40:53 am
im open to suggestions for more options to add  

update: 1.01 small bug fix
Title: Re: [XP] Character Drop Down Menu
Post by: Jackolas on April 16, 2010, 09:22:07 am
suggestion:
invite/kick guild?

btw.. lvl up for great script
Title: Re: [XP] Character Drop Down Menu
Post by: element on April 16, 2010, 11:35:53 am
suggestion : remove the nickname above the head of the player -> insert the nickname above in your menu
Title: Re: [XP] Character Drop Down Menu
Post by: nathmatt on April 16, 2010, 03:17:37 pm
update: 1.11 added Kick & Ban if you have any mod status & Guild Invite if your a guild leader
Title: Re: [XP] Character Drop Down Menu
Post by: Wizered67 on April 16, 2010, 06:50:31 pm
I keep getting

undefined method 'battler'

error
Title: Re: [XP] Character Drop Down Menu
Post by: nathmatt on April 16, 2010, 08:00:31 pm
update:1.12 fixed undefined method 'battler' error
Title: Re: [XP] Character Drop Down Menu
Post by: Wizered67 on April 16, 2010, 08:07:48 pm
Great! It now works. The only problem I have is that when you open the drop down menu and then open the regular menu, the drop down menu will still show.
Title: Re: [XP] Character Drop Down Menu
Post by: nathmatt on April 16, 2010, 09:15:34 pm
update 1.13 fixed forgot to add the dispose method just put

 @mini_list.dispose


below

mouse_check_main
Title: Re: [XP] Character Drop Down Menu
Post by: Ryex on April 16, 2010, 10:01:19 pm
hey i have a question for the sensitive functions like kick and ban/invite do you have a confirm dialog to make sure the player really wants to do those things in case the click on them by accident?
Title: Re: [XP] Character Drop Down Menu
Post by: Kett Shee on April 16, 2010, 11:11:29 pm
 :clap: Yay! *lvls up*
Title: Re: [XP] Character Drop Down Menu
Post by: nathmatt on April 21, 2010, 05:47:49 pm
update 1.14 added confirm window
Title: Re: [XP] Character Drop Down Menu
Post by: Ryex on April 22, 2010, 12:05:02 am
Quote from: nathmatt on April 21, 2010, 05:47:49 pm
update 1.14 added confirm window

yay!  :haha:
Title: Re: [XP] Character Drop Down Menu
Post by: nathmatt on June 10, 2010, 08:22:15 pm
update 1.15 fixed compatibility with my Mouse Controller enhancement Script
Title: Re: [XP] Character Drop Down Menu
Post by: Unleashed on July 11, 2010, 09:45:45 am
I'm gettin this error...:(

"Script 'CharacterDropDownMenu' line 145: TypeError occurred

Mouse is not a class"
Title: Re: [XP] Character Drop Down Menu
Post by: nathmatt on July 11, 2010, 10:03:55 am
are you using the mouse controller script by Blizzard
Title: Re: [XP] Character Drop Down Menu
Post by: Unleashed on July 11, 2010, 11:09:58 am
yes i do
Title: Re: [XP] Character Drop Down Menu
Post by: nathmatt on July 11, 2010, 02:44:09 pm
sorry for the stupid questions but is my script below his mouse controller
Title: Re: [XP] Character Drop Down Menu
Post by: stripe103 on July 11, 2010, 03:58:11 pm
I don't see why that would be a stupid question. :P
Title: Re: [XP] Character Drop Down Menu
Post by: Unleashed on July 12, 2010, 05:16:45 am
Quote from: nathmatt on July 11, 2010, 02:44:09 pm
sorry for the stupid questions but is my script below his mouse controller


yes it is...
Title: Re: [XP] Character Drop Down Menu
Post by: jrbault on August 26, 2010, 09:39:09 pm
okay i keep getting this error.

(http://img1.UploadScreenshot.com/images/main/8/23721362776.png) (http://www.UploadScreenshot.com/image/113846/340893)


These are the extra scripts and their order if its needed.

Tons of add ons 1,2,3
Mouse Controller by Blizzard
Mouse Controller Enhancement Script by Nathmatt
Character Drop Down Menu by Nathmatt
RPG Maker XP Online System (RMX-OS) (options,script,and main)
Title: Re: [XP] Character Drop Down Menu
Post by: Wizered67 on August 26, 2010, 09:39:58 pm
Make sure this is below RMX-OS.....
Title: Re: [XP] Character Drop Down Menu
Post by: nathmatt on August 27, 2010, 07:08:24 pm
is it ? if it is i need to look into it
Title: Re: [XP] Character Drop Down Menu
Post by: whitespirits on January 21, 2014, 05:46:35 am
Im getting this error. any ideas how to fix?
http://s804.photobucket.com/user/richadam111/media/errordropdown_zpsa7ceab54.png.html
Title: Re: [XP] Character Drop Down Menu
Post by: KK20 on January 21, 2014, 01:28:17 pm
You need this (http://forum.chaos-project.com/index.php/topic,5909.0.html).
Title: Re: [XP] Character Drop Down Menu
Post by: whitespirits on January 21, 2014, 03:01:55 pm
Thank you :),  I can now click and see add party, buddy and trade but clicking them results in further errors, any idea?

http://s804.photobucket.com/user/richadam111/media/error_zps91254c19.png.html?sort=3&o=0
Title: Re: [XP] Character Drop Down Menu
Post by: KK20 on January 21, 2014, 05:27:36 pm
It seems when nathmatt updated his MCES script, he changed the parameter @wait into, what I believe to be, @lwait and @rwait.

In the MCES script, at this spot

  #============================================================================
  # MCES::Processor
  #----------------------------------------------------------------------------
  #  This class performs the $MCES's processing.
  #============================================================================
  class Processor
   
    attr_accessor :item,:curser_lock,:disabled,:movement_disabled,:location
    attr_reader   :event_start

add this to the following

attr_accessor :lwait, :rwait

Then, in the Drop Down script, at the line that the error pointed out to you, change it into
$MCES.lwait = 5


This is all conjecture based on what makes logical sense. If that doesn't work, someone else will have to help you.
Title: Re: [XP] Character Drop Down Menu
Post by: whitespirits on January 22, 2014, 06:10:35 am
Thank you that has worked :)