#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# 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