[XP] Online Players Window for RMX-OS

Started by Sylphe, July 31, 2014, 01:55:37 pm

Previous topic - Next topic

Sylphe

July 31, 2014, 01:55:37 pm Last Edit: August 02, 2014, 05:11:44 pm by Sylphe
Onmap Players Window for RMX-OS
Authors: Sylphe
Version: 1.1
Type: RMX-OS Plugin
Key Term: RMX-OS Plugin



Introduction
If your game uses RMX OS you'll certainly want to have some windows here and there, but you're too lazy to do it :p so this will help you a bit.



Features


  • Display onmap players

  • System of pages where you can switch pages with P and O if more than 15 players

  • You can show/hide the window with one switch

  • You can turn this switch on/off with one RMX-OS chat command (/offmap)




Screenshots

Spoiler: ShowHide




Demo

None.


Script

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


Here is the window code, put it as the Blizzard's order script say :  http://forum.chaos-project.com/index.php/topic,23.0.html
Window: ShowHide

=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





Instructions

See at the top of the code.


Compatibility
Not compatible with radically Window_Base or RMXOS modifying scripts


Credits and Thanks


  • Sylphe, for the script.

  • Blizzard, for RMXOS and OnlineAwareness.




Author's Notes
It was made for R5GAMER but I tought anyone could want this ^^ so here is the release
Please report any bugs or suggestions.
( the feature with more than 15 players may bug I didn't test it because I don't have 15 players in my project)
blindly follow his heart can lead to the loss

Sylphe, descendant of Zoldik Family.
Quote from: TedBearTRY KEEP UP

Zexion

Lol, this has been requested so many times. I'm glad someone finally made it xD
also, add this at the bottom for the scene_map stuff
Alias: ShowHide
class Scene_Map  
  alias sylphe_opw_main main
  def main
    @onmap_window = Onmap_Window.new
    sylphe_opw_main
    @onmap_window.dispose
  end
  alias sylphe_opw_update update
  def update
    @onmap_window.update
    @onmap_window.refresh
    sylphe_opw_update
  end
end

Sylphe

Yeah I was wondering why anyone didn't post windows scripts for RMX OS ^^ I'm also doing a graphical buddy list but there are some annoying things causing troubles
Thank you for the enhancement I added it :) and now I think I understood how aliases works ^^
blindly follow his heart can lead to the loss

Sylphe, descendant of Zoldik Family.
Quote from: TedBearTRY KEEP UP

whitespirits

Great to see people adding things to rmx-os ;)

Sylphe

rmx-os is something great I hope the general bugs like the ones you mentionned will be fixes one day
Maybe I ! Will fix it 8-| haha
but for now I'm a noob
blindly follow his heart can lead to the loss

Sylphe, descendant of Zoldik Family.
Quote from: TedBearTRY KEEP UP

Blizzard

You shouldn't actually call refresh every frame, but only when the player list changes.
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.

whitespirits

what do i change here guys?

   # ici change le WINDOWSKIN selon ce que tu veux
   self.windowskin = RPG::Cache.windowskin(BuddyData:windowskin)
   refresh
  end


I use a different window skin to standard rmxp

Sylphe

July 31, 2014, 05:12:19 pm #7 Last Edit: July 31, 2014, 05:14:30 pm by Sylphe
Quote from: Blizzard on July 31, 2014, 04:18:14 pm
You shouldn't actually call refresh every frame, but only when the player list changes.

Do I have to move some codes from refresh method to scene_map ?
(I think about the timer)

white you just have to put here the windowskin you want to, it doesn't work if you just put
self.windowskin = RPG::Cache.windowskin('Yourwindowskin')
?
blindly follow his heart can lead to the loss

Sylphe, descendant of Zoldik Family.
Quote from: TedBearTRY KEEP UP

R5GAMER

..........________
....'/,-Y"............."~-.
..l.Y.......................^.
./\............................_\
i.................... ___/"...."\
|.................../"...."\ .....o!
l..................].......o !__../
.\..._..._.........\..___./......"~\
..X...\/...\.....................___./
.(. \.___......_.....--~~".....~`-.           
....`.Z,--........./.....................\
.......\__....(......../.........._____)
...........\.........l......../---~~" /
............Y.......\................../
............|........"x_____.^
............|.....................\
............j.....................Y

Sylphe

You welcome :D
Updated, the refresh performed only when checking server's datas
blindly follow his heart can lead to the loss

Sylphe, descendant of Zoldik Family.
Quote from: TedBearTRY KEEP UP

Blizzard

You have a refresh flag there already as far as I can see.

if $onmap_player_need_refresh
  @onmap_window.refresh
  $onmap_player_need_refresh = false
end


Using a timer is unnecessary if you refresh it only when the data has changed.
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.

Sylphe

I updated it =)
The timer is for checking the datas (sending /onmap manually). Once I receive the datas, I set the flag to true in onlineAwareness then I can run the refresh in the code you mentionned, in the scene_map update ^^
blindly follow his heart can lead to the loss

Sylphe, descendant of Zoldik Family.
Quote from: TedBearTRY KEEP UP

R5GAMER

August 01, 2014, 02:37:54 am #12 Last Edit: August 01, 2014, 02:50:02 am by R5GAMER
I just tested with 16 players to see if there was a concern with touch p and o and see if the code do its job .. Unfortunately, there is an error ..

And I change :

def update_controls
   if Input.trigger?(Input::P)
      @page += 1
   elsif Iput.trigger?(Input::O)
      @page -= 1
    end
end


to :

def update_controls
  if Input.trigger?(Input::Key['P'])
      @page += 1
  elsif Input.trigger?(Input::Key['O'])
      @page -= 1
  end
end
..........________
....'/,-Y"............."~-.
..l.Y.......................^.
./\............................_\
i.................... ___/"...."\
|.................../"...."\ .....o!
l..................].......o !__../
.\..._..._.........\..___./......"~\
..X...\/...\.....................___./
.(. \.___......_.....--~~".....~`-.           
....`.Z,--........./.....................\
.......\__....(......../.........._____)
...........\.........l......../---~~" /
............Y.......\................../
............|........"x_____.^
............|.....................\
............j.....................Y

G_G

Try replacing 'o' and 'p' with a capitol 'O' and 'P'.

R5GAMER

August 01, 2014, 02:53:10 am #14 Last Edit: August 01, 2014, 03:06:53 am by R5GAMER
Quote from: gameus on August 01, 2014, 02:45:13 am
Try replacing 'o' and 'p' with a capitol 'O' and 'P'.


Yes, I just saw I was not careful .. lol
Another problem, I've put 20 players when the player clicks on P must do this several times until you get to another window .. By cons, once the other window and reached .. and that you click on O, its deletes all the names and adds in a few ..

MMMhhh.. I changed the timer in 1 and I noticed he responds immediately to the 'P' button but the button 'O' it does not respond ..
..........________
....'/,-Y"............."~-.
..l.Y.......................^.
./\............................_\
i.................... ___/"...."\
|.................../"...."\ .....o!
l..................].......o !__../
.\..._..._.........\..___./......"~\
..X...\/...\.....................___./
.(. \.___......_.....--~~".....~`-.           
....`.Z,--........./.....................\
.......\__....(......../.........._____)
...........\.........l......../---~~" /
............Y.......\................../
............|........"x_____.^
............|.....................\
............j.....................Y

whitespirits


Sylphe

August 01, 2014, 12:14:47 pm #16 Last Edit: August 01, 2014, 01:06:11 pm by Sylphe
@R5GAMER ok thank you I'll see what I can do and I have an idea why it bugs (also clean your inbox when I send you a PM it says your inbox is full xd)
@whitespirit Are you sure you put the lines I mentionned for OnlineAwareness at the right place ? (it's near line 126 for me in online awareness)


EDIT : updated please try the new code with more than 15 players
blindly follow his heart can lead to the loss

Sylphe, descendant of Zoldik Family.
Quote from: TedBearTRY KEEP UP

R5GAMER

August 01, 2014, 04:37:38 pm #17 Last Edit: August 01, 2014, 04:50:04 pm by R5GAMER
Quote from: Sylphe on August 01, 2014, 12:14:47 pm
@R5GAMER ok thank you I'll see what I can do and I have an idea why it bugs (also clean your inbox when I send you a PM it says your inbox is full xd)
@whitespirit Are you sure you put the lines I mentionned for OnlineAwareness at the right place ? (it's near line 126 for me in online awareness)


EDIT : updated please try the new code with more than 15 players


I go test and I tell you!

An Error :

elsif Iput.trigger?(Input::Key['O'])
       @onmap_window.page -= 1
       @onmap_window.refresh
end


Remplace to :

elsif Input.trigger?(Input::Key['O'])
       @onmap_window.page -= 1
       @onmap_window.refresh
end


If you touch the button 'P' he can't no longer use the 'O' button ..
If you click on 'O' he appears other players but when repeatedly clicking on 'O' he displays an error.

..........________
....'/,-Y"............."~-.
..l.Y.......................^.
./\............................_\
i.................... ___/"...."\
|.................../"...."\ .....o!
l..................].......o !__../
.\..._..._.........\..___./......"~\
..X...\/...\.....................___./
.(. \.___......_.....--~~".....~`-.           
....`.Z,--........./.....................\
.......\__....(......../.........._____)
...........\.........l......../---~~" /
............Y.......\................../
............|........"x_____.^
............|.....................\
............j.....................Y

Sylphe

Ok thank you ! I updated, try again ! Lol
blindly follow his heart can lead to the loss

Sylphe, descendant of Zoldik Family.
Quote from: TedBearTRY KEEP UP

R5GAMER

..........________
....'/,-Y"............."~-.
..l.Y.......................^.
./\............................_\
i.................... ___/"...."\
|.................../"...."\ .....o!
l..................].......o !__../
.\..._..._.........\..___./......"~\
..X...\/...\.....................___./
.(. \.___......_.....--~~".....~`-.           
....`.Z,--........./.....................\
.......\__....(......../.........._____)
...........\.........l......../---~~" /
............Y.......\................../
............|........"x_____.^
............|.....................\
............j.....................Y