=begin
================================================================================
Onmap Player Window for RMXOS Version 1.0
Author: Sylphe [31/07/2014]
--------------------------------------------------------------------------------
This script is a window displaying all characters on the same map of the actor.
The limit of the window is 15 players, if there are more players, type P/O to
See previous/next page of players
--------------------------------------------------------------------------------
[[ Version History ]]
1.0
********************************************************************************
* I N S T R U C T I O N S *
********************************************************************************
You will have to change RMXOS OnlineAwareness line 126
Just add the extra lines of this code :
when /\A\/onmap\Z/
names = self.map_players.values.map {|player| player = player.username}
HERE ==> $onmap_players = names
HERE ==> $onmap_player_need_refresh = true
Then You will have to add this window in a scene, just do like all other
windows in scenes ( .new, dispose, update, refresh)
----------
-Controls-
----------
if player number exceed 15
P / O to change page (P = next Page, O = previous page)
you can change it at the end of this script, in class Scene_Map in the method update_controls
Use command /offmap on the rmx-os chat to show/hide this window
----------
-Graphics-
----------
WINDOWSKIN
line 85 change the windowskin to what you want.
WINDOW'S SIZE
line 174, 185 change the value 10 in 'self.heigt += 10' if you want the window
to be smaller or bigger than usual when another player is displayed.
SPACE BEETWEEN NAMES
line 117 change y+= 15 if you want more/less spaces beetween each player name
------------
-Compatibility-
------------
Only Work with RMXOS and RMXOS OnlineAwareness modified.
---------------
-Configuration-
---------------
TIMER
set line 204 the timer (255 by default). It is the time (in frame maybe)
the game will wait until asking the server who is on the same map
( And don't forget changing windowskin line 85 if you don't use my buddy list script )
SWITCH
Just below in the module you can change the switch you have to set to true or false
whether to hide or show this window.
================================================================================
Credits:
Sylphe -> Making this script
Blizzard -> Doing RMXOS and RMXOS OnlineAwareness
================================================================================
=end
module OnMapData
# The switch to hide/show this window
# note that you can manually change its switch by using /offmap command
Switch = 210
end
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#
# Window displaying onmap players
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#
class Onmap_Window < Window_Base
attr_accessor :page
def initialize
# store the last player number
@ancient_player_number = 0
#the actual window page
@page = 0
#The array that will store onmap players
#(used in online awareness if you changed like in configuration)
$onmap_players = []
# flag that will be used to know if we must refresh
$onmap_player_need_refresh = false
# Change this if you want to replace the window
# super (x, y, width, height)
super(380, 140, 200, 60)
bitmap = Bitmap.new(width - 32, height - 32)
bitmap.hue_change((3 - 1.5).sgn * (1.25 - 40 / 0.8) * 120 /
(3 ** 2))
bitmap.fill_rect(0, 0, bitmap.width, bitmap.height,
Color.new(0, 0, 0, 20))
self.contents = bitmap
self.opacity=125
# here change WINDOWSKIN like
# self.windowskin = RPG::Cache.windowskin("YourWindowskinFileName") without extension.
self.windowskin = RPG::Cache.windowskin(BuddyData::Windowskin)
refresh
end
def refresh
self.contents.clear
self.contents.font.color= Color.new(255, 255, 255, 255)
@actual_player_number = 0
y = 0
# the first player we display
@first_player = @page * 15
w = contents.text_size("Sylph was the Wind Goddess").width
#if there are players on the map
if $onmap_players[@first_player] != nil
# We display them until 15
for i in @first_player..($onmap_players.length-1)
if @actual_player_number < 15
# Si on a fait la requete on agrandi la fenetre si y a + de joueurs qu'avant
@actual_player_number += 1
if @actual_player_number > @ancient_player_number
bigger
end
self.contents.draw_text(0, y, w, 24,$onmap_players[i],1)
#CHANGE THIS IF THE SPACE BEETWEEN NAMES DOES NOT SUIT YOU
y += 15
end #if there are less than 15 players
end # for every onmap player
end # if player non null
# If there are less players than before we reduce window
difference = (@ancient_player_number - @actual_player_number)
# if 'O' doesn't work, try decomment those lines
# if @tropdmonde.length > 0
# difference -= (@tropdmonde[@page].length - 1)
# end
if difference > 0
for i in 1..difference
if i <= 15
smaller
end
end
end
@ancient_player_number = @actual_player_number
end # End of refresh
# scale window and it's content
def bigger
self.height += 8
bitmap = Bitmap.new(width - 32, height - 32)
bitmap.hue_change((3 - 1.5).sgn * (1.25 - 40 / 0.8) * 120 /
(3 ** 2))
bitmap.fill_rect(0, 0, bitmap.width, bitmap.height,
Color.new(0, 0, 0, 20))
self.contents = bitmap
end
# reduce window and it's content
def smaller
self.height -= 8
bitmap = Bitmap.new(width - 32, height - 32)
bitmap.hue_change((3 - 1.5).sgn * (1.25 - 40 / 0.8) * 120 /
(3 ** 2))
bitmap.fill_rect(0, 0, bitmap.width, bitmap.height,
Color.new(0, 0, 0, 20))
self.contents = bitmap
end
end # End of my window
class Scene_Map
alias sylphe_opw_main main
def main
#the timer, change the condition in update
@timer = 0
@onmap_window = Onmap_Window.new
sylphe_opw_main
@onmap_window.dispose
end
alias sylphe_opw_update update
def update
@onmap_window.update
# If we have too much persons, we check if player type P or O
if $onmap_players.length > 15
update_onmap_player_controls
end
# we check who is on the same map
# Once we connect and once the timer match condition at the bottom
if @timer == 0
$network.check_normal_commands('/onmap')
end
if $onmap_player_need_refresh
@onmap_window.refresh
@onmap_window.refresh
$onmap_player_need_refresh = false
end
@timer = @timer+1
# CHANGE THIS TO CHANGE THE TIME UNTIL IT WILL CHECK SERVER DATAS
#(255 = I dunno how many seconds, I would say 15)
if @timer == 255
@timer = 0
end
# If switch is activated
if !$game_switches[OnMapData::Switch] and @onmap_window.visible
@onmap_window.visible = false
elsif $game_switches[OnMapData::Switch] and !@onmap_window.visible
@onmap_window.visible = true
end
sylphe_opw_update
end
#we check if the input is P or O (works now)
def update_onmap_player_controls
if Input.trigger?(Input::Key['P'])
if ((@onmap_window.page*15)+15) < $onmap_players.length
@onmap_window.page += 1
@onmap_window.refresh
@onmap_window.refresh
else
$game_system.se_play($data_system.buzzer_se)
end
elsif Input.trigger?(Input::Key['O'])
if @onmap_window.page > 0
@onmap_window.page -= 1
@onmap_window.refresh
@onmap_window.refresh
else
$game_system.se_play($data_system.buzzer_se)
end
end
end
end # end of Class Scene_Map
module RMXOS
#============================================================================
# module Documentation
#============================================================================
module Documentation
PARAMETERS['offmap'] = 'none'
DESCRIPTIONS['offmap'] = 'Show/Hide the window displaying all onmap players.'
end
#============================================================================
# Network
#============================================================================
class Network
alias check_normal_commands_onmap_window_alias check_normal_commands
def check_normal_commands(message)
case message
when /\A\/offmap\Z/
$game_switches[OnMapData::Switch] = !$game_switches[OnMapData::Switch]
return true
end
return check_normal_commands_onmap_window_alias(message)
end
end
end