Advertisement
Deedlit

ExShowScreenMessage

Jun 1st, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.36 KB | None | 0 0
  1. /*
  2.  * This program is free software: you can redistribute it and/or modify it under
  3.  * the terms of the GNU General Public License as published by the Free Software
  4.  * Foundation, either version 3 of the License, or (at your option) any later
  5.  * version.
  6.  *
  7.  * This program is distributed in the hope that it will be useful, but WITHOUT
  8.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9.  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10.  * details.
  11.  *
  12.  * You should have received a copy of the GNU General Public License along with
  13.  * this program. If not, see <http://www.gnu.org/licenses/>.
  14.  */
  15. package com.l2jserver.gameserver.network.serverpackets;
  16.  
  17. import com.l2jserver.gameserver.network.NpcStringId;
  18. import com.l2jserver.gameserver.network.SystemMessageId;
  19.  
  20. import java.util.ArrayList;
  21. import java.util.List;
  22.  
  23. /**
  24.  * @author Kerberos
  25.  *
  26.  */
  27. public class ExShowScreenMessage extends L2GameServerPacket
  28. {
  29.     private int _type;
  30.     private int _sysMessageId;
  31.     private int _unk1;
  32.     private int _unk2;
  33.     private int _unk3;
  34.     private boolean _fade;
  35.     private int _size;
  36.     private int _position;
  37.     private boolean _effect;
  38.     private String _text;
  39.     private int _time;
  40.     private int _npcString;
  41.     private List<String> _parameters;
  42.  
  43.     public ExShowScreenMessage (String text, int time)
  44.     {
  45.         _type = 1;
  46.         _sysMessageId = -1;
  47.         _unk1 = 0;
  48.         _unk2 = 0;
  49.         _unk3 = 0;
  50.         _fade = false;
  51.         _position = 0x02;
  52.         _text = text;
  53.         _time = time;
  54.         _size = 0;
  55.         _effect = false;
  56.         _npcString = -1;
  57.     }
  58.  
  59.     public ExShowScreenMessage (NpcStringId npcString, int position, int time) // For npcstring
  60.     {
  61.         _type = 2;
  62.         _sysMessageId = -1;
  63.         _unk1 = 0;
  64.         _unk2 = 0;
  65.         _unk3 = 0;
  66.         _fade = false;
  67.         _position = position;
  68.         _text = null;
  69.         _time = time;
  70.         _size = 0;
  71.         _effect = false;
  72.         _npcString = npcString.getId();
  73.     }
  74.  
  75.     public ExShowScreenMessage (SystemMessageId systemMsg, int position, int time) // For SystemMessage
  76.     {
  77.         _type = 2;
  78.         _sysMessageId = systemMsg.getId();
  79.         _unk1 = 0;
  80.         _unk2 = 0;
  81.         _unk3 = 0;
  82.         _fade = false;
  83.         _position = position;
  84.         _text = null;
  85.         _time = time;
  86.         _size = 0;
  87.         _effect = false;
  88.         _npcString = -1;
  89.     }
  90.  
  91.     public ExShowScreenMessage(int type, int messageId, int position, int size, boolean showEffect, int time, boolean fade, String text)
  92.     {
  93.         _type = type;
  94.         _sysMessageId = messageId;
  95.         _unk1 = 0;
  96.         _unk2 = 0;
  97.         _unk3 = 0;
  98.         _fade = fade;
  99.         _position = position;
  100.         _text = text;
  101.         _time = time;
  102.         _size = size;
  103.         _effect = showEffect;
  104.         _npcString = -1;
  105.     }
  106.  
  107.     public ExShowScreenMessage (int type, int messageId, int position, int unk1, int size, int unk2, int unk3,boolean showEffect, int time,boolean fade, String text, NpcStringId npcString)
  108.     {
  109.         _type = type;
  110.         _sysMessageId = messageId;
  111.         _unk1 = unk1;
  112.         _unk2 = unk2;
  113.         _unk3 = unk3;
  114.         _fade = fade;
  115.         _position = position;
  116.         _text = text;
  117.         _time = time;
  118.         _size = size;
  119.         _effect = showEffect;
  120.         if (npcString == NpcStringId.NO_MSG)
  121.             _npcString = -1;
  122.         else
  123.             _npcString = npcString.getId();
  124.     }
  125.  
  126.     /**
  127.      * String parameter for argument S1,S2,.. in npcstring-e.dat
  128.      * @param text
  129.      */
  130.     public void addStringParameter(String text)
  131.     {
  132.         if (_parameters == null)
  133.             _parameters = new ArrayList<String>();
  134.         _parameters.add(text);
  135.     }
  136.  
  137.     @Override
  138.     public String getType()
  139.     {
  140.         return "[S]FE:39 ExShowScreenMessage";
  141.     }
  142.  
  143.     @Override
  144.     protected void writeImpl()
  145.     {
  146.         writeC(0xfe);
  147.         writeH(0x39);
  148.         writeD(_type); // 0 - system messages, 1 - your defined text, 2 - npcstring
  149.         writeD(_sysMessageId); // system message id (_type must be 0 otherwise no effect)
  150.         writeD(_position); // message position
  151.         writeD(_unk1); // ?
  152.         writeD(_size); // font size 0 - normal, 1 - small
  153.         writeD(_unk2); // ?
  154.         writeD(_unk3); // ?
  155.         writeD(_effect == true ? 1 : 0); // upper effect (0 - disabled, 1 enabled) - _position must be 2 (center) otherwise no effect
  156.         writeD(_time); // time
  157.         writeD(_fade == true ? 1 : 0); // fade effect (0 - disabled, 1 enabled)
  158.         writeD(_npcString); // npcString
  159.         if (_npcString == -1)
  160.             writeSS(_text); // your text (_type must be 1, otherwise no effect)
  161.         else
  162.         {
  163.             if (_parameters != null)
  164.             {
  165.                 for (String s : _parameters)
  166.                     writeSS(s);
  167.             }
  168.         }
  169.     }
  170.  
  171.     public ExShowScreenMessage setUpperEffect(boolean value)
  172.     {
  173.       _effect = value;
  174.       return this;
  175.     }
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement