Ejemplo n.º 1
0
        public override string EncodeIntAsCharEscape(int v)
        {
            if (v < char.MinValue || v > char.MaxValue)
            {
                throw new ArgumentException(string.Format("Cannot encode the specified value: {0}", v));
            }

            if (v >= 0 && v < targetCharValueEscape.Length && targetCharValueEscape[v] != null)
            {
                return(targetCharValueEscape[v]);
            }

            if (v >= 0x20 && v < 127 && (!char.IsDigit((char)v) || v == '8' || v == '9'))
            {
                return(((char)v).ToString());
            }

            if (v >= 0 && v <= 127)
            {
                string oct = Convert.ToString(v, 8);
                return("\\" + oct);
            }

            string hex = v.ToString("x4");

            return("\\u" + hex);
        }
Ejemplo n.º 2
0
        void SerializeString(string aString, StringBuilder builder)
        {
            builder.Append("\"");

            char[] charArray = aString.ToCharArray();
            for (int i = 0; i < charArray.Length; i++)
            {
                char c = charArray[i];
                if (c == '"')
                {
                    builder.Append("\\\"");
                }
                else if (c == '\\')
                {
                    builder.Append("\\\\");
                }
                else if (c == '\b')
                {
                    builder.Append("\\b");
                }
                else if (c == '\f')
                {
                    builder.Append("\\f");
                }
                else if (c == '\n')
                {
                    builder.Append("\\n");
                }
                else if (c == '\r')
                {
                    builder.Append("\\r");
                }
                else if (c == '\t')
                {
                    builder.Append("\\t");
                }
                else
                {
                    int codepoint = Convert.ToInt32(c);
                    if ((codepoint >= 32) && (codepoint <= 126))
                    {
                        builder.Append(c);
                    }
                    else
                    {
                        builder.Append("\\u" + Convert.ToString(codepoint, 16).PadLeft(4, '0'));
                    }
                }
            }

            builder.Append("\"");
        }
Ejemplo n.º 3
0
        private void LoadVariables()
        {
            Prefix      = Convert.ToString(GetConfig("Chat Settings", "Prefix", "[My MiniCopter] :"));             // CHAT PLUGIN PREFIX
            SteamIDIcon = Convert.ToUInt64(GetConfig("Chat Settings", "SteamIDIcon", "76561198059533272"));        // SteamID FOR PLUGIN ICON - STEAM PROFILE CREATED FOR THIS PLUGIN / NONE YET /
            cooldownmin = Convert.ToSingle(GetConfig("Cooldown (on permission)", "Value in minutes", "60"));

            if (!ConfigChanged)
            {
                return;
            }
            SaveConfig();
            ConfigChanged = false;
        }
        private void LoadVariables()
        {
            Prefix       = Convert.ToString(GetConfig("Chat Settings", "Prefix", "[PSS] :"));                 // CHAT PLUGIN PREFIX
            PrefixColor  = Convert.ToString(GetConfig("Chat Settings", "PrefixColor", "#42d7f4"));            // CHAT PLUGIN PREFIX COLOR
            ChatColor    = Convert.ToString(GetConfig("Chat Settings", "ChatColor", "#b7f5ff"));              // CHAT  COLOR
            SteamIDIcon  = Convert.ToUInt64(GetConfig("Chat Settings", "SteamIDIcon", 76561198859649789));
            bonusratemin = Convert.ToSingle(GetConfig("Bonus Playtime", "Value in minutes", "60"));
            spawnbonus   = Convert.ToBoolean(GetConfig("Bonus on Spawn", "Give a SupplySignal on first arrival", "true"));

            if (!ConfigChanged)
            {
                return;
            }
            SaveConfig();
            ConfigChanged = false;
        }
Ejemplo n.º 5
0
        private void LoadVariables()
        {
            Prefix        = Convert.ToString(GetConfig("Chat Settings", "Prefix", "[My CH47] "));                // CHAT PLUGIN PREFIX
            PrefixColor   = Convert.ToString(GetConfig("Chat Settings", "PrefixColor", "#149800"));              // CHAT PLUGIN PREFIX COLOR
            ChatColor     = Convert.ToString(GetConfig("Chat Settings", "ChatColor", "#bbffb1"));                // CHAT MESSAGE COLOR
            SteamIDIcon   = Convert.ToUInt64(GetConfig("Chat Settings", "SteamIDIcon", "76561198332562475"));    // SteamID FOR PLUGIN ICON - STEAM PROFILE CREATED FOR THIS PLUGIN / NONE YET /
            withoutdebris = Convert.ToBoolean(GetConfig("Debris Settings", "Remove debris", "false"));
            cooldownmin   = Convert.ToSingle(GetConfig("Cooldown (on permission)", "Value in minutes", "60"));

            if (!ConfigChanged)
            {
                return;
            }
            SaveConfig();
            ConfigChanged = false;
        }
Ejemplo n.º 6
0
 bool SerializeValue(object value, StringBuilder builder)
 {
     if (value == null)
     {
         builder.Append("null");
     }
     else if (value.GetType().IsArray)
     {
         SerializeArray(new ArrayList((ICollection)value), builder);
     }
     else if (value is string)
     {
         SerializeString((string)value, builder);
     }
     else if (value is Char)
     {
         SerializeString(Convert.ToString((char)value), builder);
     }
     else if (value is Hashtable)
     {
         SerializeObject((Hashtable)value, builder);
     }
     else if (value is ArrayList)
     {
         SerializeArray((ArrayList)value, builder);
     }
     else if ((value is bool) && ((bool)value == true))
     {
         builder.Append("true");
     }
     else if ((value is bool) && ((bool)value == false))
     {
         builder.Append("false");
     }
     else if (value.GetType().IsPrimitive)
     {
         SerializeNumber(Convert.ToDouble(value), builder);
     }
     else
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 7
0
        private void LoadVariables()
        {
            /*Prefix = Convert.ToString(GetConfig("Chat Settings", "Prefix", "[My CH47] "));                       // CHAT PLUGIN PREFIX
             * PrefixColor = Convert.ToString(GetConfig("Chat Settings", "PrefixColor", "#149800"));                // CHAT PLUGIN PREFIX COLOR
             * ChatColor = Convert.ToString(GetConfig("Chat Settings", "ChatColor", "#bbffb1"));                    // CHAT MESSAGE COLOR
             * SteamIDIcon = Convert.ToUInt64(GetConfig("Chat Settings", "SteamIDIcon", "76561198332562475"));*/
            sound         = Convert.ToBoolean(GetConfig("Sound Settings", "play soundfx", "false"));
            bannerdisplay = Convert.ToBoolean(GetConfig("Banner Settings", "display banner", "false"));
            HUDfontsize   = Convert.ToInt32(GetConfig("HUD Settings", "font size", "10"));
            HUDcolor      = Convert.ToString(GetConfig("HUD Settings", "color on 3 firsts numbers - opacity on last number", "0.5 0.5 0.5 0.30"));
            bannercolor   = Convert.ToString(GetConfig("Banner Settings", "color on 3 firsts numbers - opacity on last number", "0.5 0.5 0.5 0.30"));

            if (!ConfigChanged)
            {
                return;
            }
            SaveConfig();
            ConfigChanged = false;
        }
Ejemplo n.º 8
0
        private void LoadVariables()
        {
            /*Prefix = Convert.ToString(GetConfig("Chat Settings", "Prefix", "[NightPVP] "));                       // CHAT PLUGIN PREFIX
             * PrefixColor = Convert.ToString(GetConfig("Chat Settings", "PrefixColor", "#bf0000"));                // CHAT PLUGIN PREFIX COLOR
             * ChatColor = Convert.ToString(GetConfig("Chat Settings", "ChatColor", "#dd8e8e"));                    // CHAT MESSAGE COLOR
             * SteamIDIcon = Convert.ToUInt64(GetConfig("Chat Settings", "SteamIDIcon", "76561198079320022")); */// SteamID FOR PLUGIN ICON - STEAM PROFILE CREATED FOR THIS PLUGIN / NONE YET /
            pvpcolor        = Convert.ToString(GetConfig("HUD COLOR", "for PVP", "0.6 0.2 0.2"));
            pvecolor        = Convert.ToString(GetConfig("HUD COLOR", "for PVE", "0.5 1.0 0.0"));
            pvpcoloropacity = Convert.ToString(GetConfig("HUD OPACITY", "for PVP", "0.5"));
            pvecoloropacity = Convert.ToString(GetConfig("HUD OPACITY", "for PVE", "0.4"));
            textsize        = Convert.ToInt32(GetConfig("HUD TEXT", "size", "12"));
            pvptextcolor    = Convert.ToString(GetConfig("HUD TEXT", "color for PVP", "1.0 1.0 1.0"));
            pvetextcolor    = Convert.ToString(GetConfig("HUD TEXT", "color for PVE", "1.0 1.0 1.0"));
            HUDleft         = Convert.ToDouble(GetConfig("HUD POSITION", "left", "0.65"));
            HUDbottom       = Convert.ToDouble(GetConfig("HUD COLOR", "bottom", "0.04"));

            if (!ConfigChanged)
            {
                return;
            }
            SaveConfig();
            ConfigChanged = false;
        }
Ejemplo n.º 9
0
 void SerializeNumber(double number, StringBuilder builder)
 {
     builder.Append(Convert.ToString(number)); // , CultureInfo.InvariantCulture));
 }
Ejemplo n.º 10
0
        private static int Str_Format(ILuaState lua)
        {
            int           top    = lua.GetTop();
            StringBuilder sb     = new StringBuilder();
            int           arg    = 1;
            string        format = lua.L_CheckString(arg);
            int           s      = 0;
            int           e      = format.Length;

            while (s < e)
            {
                if (format[s] != L_ESC)
                {
                    sb.Append(format[s++]);
                    continue;
                }

                if (format[++s] == L_ESC)
                {
                    sb.Append(format[s++]);
                    continue;
                }

                // else format item
                if (++arg > top)
                {
                    lua.L_ArgError(arg, "no value");
                }

                string form;
                s = ScanFormat(lua, format, s, out form);
                switch (format[s++])                  // TODO: properly handle form
                {
                case 'c':
                {
                    sb.Append((char)lua.L_CheckInteger(arg));
                    break;
                }

                case 'd':
                case 'i':
                {
                    int n = lua.L_CheckInteger(arg);
                    sb.Append(n.ToString());
                    break;
                }

                case 'u':
                {
                    int n = lua.L_CheckInteger(arg);
                    lua.L_ArgCheck(n >= 0, arg,
                                   "not a non-negative number is proper range");
                    sb.Append(n.ToString());
                    break;
                }

                case 'o':
                {
                    int n = lua.L_CheckInteger(arg);
                    lua.L_ArgCheck(n >= 0, arg,
                                   "not a non-negative number is proper range");
                    sb.Append(Convert.ToString(n, 8));
                    break;
                }

                case 'x':
                {
                    int n = lua.L_CheckInteger(arg);
                    lua.L_ArgCheck(n >= 0, arg,
                                   "not a non-negative number is proper range");
                    // sb.Append( string.Format("{0:x}", n) );
                    sb.AppendFormat("{0:x}", n);
                    break;
                }

                case 'X':
                {
                    int n = lua.L_CheckInteger(arg);
                    lua.L_ArgCheck(n >= 0, arg,
                                   "not a non-negative number is proper range");
                    // sb.Append( string.Format("{0:X}", n) );
                    sb.AppendFormat("{0:X}", n);
                    break;
                }

                case 'e':
                case 'E':
                {
                    sb.AppendFormat("{0:E}", lua.L_CheckNumber(arg));
                    break;
                }

                case 'f':
                {
                    sb.AppendFormat("{0:F}", lua.L_CheckNumber(arg));
                    break;
                }

#if LUA_USE_AFORMAT
                case 'a':
                case 'A':
#endif
                case 'g':
                case 'G':
                {
                    sb.AppendFormat("{0:G}", lua.L_CheckNumber(arg));
                    break;
                }

                case 'q':
                {
                    AddQuoted(lua, sb, arg);
                    break;
                }

                case 's':
                {
                    sb.Append(lua.L_CheckString(arg));
                    break;
                }

                default:                         // also treat cases `pnLlh'
                {
                    return(lua.L_Error("invalid option '{0}' to 'format'",
                                       format[s - 1]));
                }
                }
            }
            lua.PushString(sb.ToString());
            return(1);
        }