[XP] Character Drop Down Menu

Started by nathmatt, April 15, 2010, 06:53:01 pm

Previous topic - Next topic

nathmatt

April 15, 2010, 06:53:01 pm Last Edit: June 10, 2010, 08:20:47 pm by nathmatt
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

  • Add Buddy & trade always
  • Kick & Ban if you have any mod status
  • Guild Invite if your a guild leader
  • Add Party if Blizz-ABS Controller is being used



Screenshots
Spoiler: ShowHide



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


  • Nathmatt
  • Blizzard for the Mouse Controller script and  RMX-OS



Author's Notes
Any suggestions for updates are appreciated
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script



Blizzard

Ah, finally people are extending RMX-OS in the right ways. :D
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

nathmatt

April 16, 2010, 08:40:53 am #3 Last Edit: April 16, 2010, 09:18:07 am by nathmatt
im open to suggestions for more options to add  

update: 1.01 small bug fix
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Jackolas

suggestion:
invite/kick guild?

btw.. lvl up for great script

element

suggestion : remove the nickname above the head of the player -> insert the nickname above in your menu

nathmatt

update: 1.11 added Kick & Ban if you have any mod status & Guild Invite if your a guild leader
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Wizered67

I keep getting

undefined method 'battler'

error

nathmatt

update:1.12 fixed undefined method 'battler' error
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Wizered67

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.

nathmatt

update 1.13 fixed forgot to add the dispose method just put

 @mini_list.dispose


below

mouse_check_main
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Ryex

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?
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Kett Shee

You're all daft cunts. I love you. <3

nathmatt

April 21, 2010, 05:47:49 pm #13 Last Edit: April 21, 2010, 05:49:42 pm by nathmatt
update 1.14 added confirm window
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Ryex

I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

nathmatt

update 1.15 fixed compatibility with my Mouse Controller enhancement Script
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


Unleashed

I'm gettin this error...:(

"Script 'CharacterDropDownMenu' line 145: TypeError occurred

Mouse is not a class"

nathmatt

are you using the mouse controller script by Blizzard
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script



nathmatt

sorry for the stupid questions but is my script below his mouse controller
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


stripe103

I don't see why that would be a stupid question. :P

Unleashed

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...

jrbault

okay i keep getting this error.




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)

Wizered67

Make sure this is below RMX-OS.....

nathmatt

is it ? if it is i need to look into it
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


whitespirits

January 21, 2014, 05:46:35 am #25 Last Edit: January 21, 2014, 05:47:39 am by whitespirits

KK20


Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

whitespirits

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

KK20

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.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

whitespirits