Example #1
0
        // Creates an empty table structure
        public static List <byte[]> TableStruct(string[] args, long cKey)
        {
            List <byte[]> result = new List <byte[]>();

            if (!RVIDefinitions.Initialized)
            {
                RVIDefinitions.Initialize();
            }

            RVIVector2 position = RVIVector2.Parse(args[0]);
            float      width    = float.Parse(args[1], CultureInfo.InvariantCulture);
            float      height   = float.Parse(args[2], CultureInfo.InvariantCulture);
            byte       hCount   = byte.Parse(args[3], CultureInfo.InvariantCulture);
            byte       vCount   = byte.Parse(args[4], CultureInfo.InvariantCulture);

            float currenyY = position.y;

            for (int v = 0; v < vCount; v++)
            {
                float currentX = position.x;
                for (int h = 0; h < hCount; h++)
                {
                    result.Add(RVIPackets.Server_Rect.Create(new RVIVector2(currentX, currenyY), width, height, cKey));
                    currentX += width;
                }
                currenyY -= height;
            }

            return(result);
        }
Example #2
0
        // Draws an array of defined functions, separated by the '%' character. Inherits offseting and scaling
        private static List <byte[]> Array(string[] args, long cKey, RVIVector2 offset, float scale)
        {
            List <byte[]> result = new List <byte[]>();

            // Initialize server definitions if necessary
            if (!RVIDefinitions.Initialized)
            {
                RVIDefinitions.Initialize();
            }

            // Parse arguments
            RVIVector2 position     = RVIVector2.Parse(args[0]);
            float      elementScale = float.Parse(args[1], CultureInfo.InvariantCulture);

            string[] fNames = args[2].Split('%');

            // Apply scale
            RVIVector2 finalOffset = position * scale;
            float      finalScale  = elementScale * scale;

            // Apply offset
            finalOffset += offset;

            foreach (string func in fNames)
            {
                string[] fLines = RVIDefinitions.Definitions[func.ToUpper()];
                for (int i = 0; i < fLines.Length; i++)
                {
                    // Ignore comment lines, empty lines and '-' lines
                    if ((fLines[i][0] == '#') || (fLines[i][0] == '!') || (string.IsNullOrEmpty(fLines[i])))
                    {
                        continue;
                    }
                    else
                    {
                        result.AddRange(Instruction2Packet.GetBytes(fLines[i], cKey, finalOffset.x, finalOffset.y, finalScale));
                    }
                }
                finalOffset += new RVIVector2(elementScale, 0);
            }
            return(result);
        }
Example #3
0
        // Creates a filled, borderless table. The text size and lining are manually provided.
        public static List <byte[]> TableArraySB(string[] args, long cKey)
        {
            List <byte[]> result = new List <byte[]>();

            if (!RVIDefinitions.Initialized)
            {
                RVIDefinitions.Initialize();
            }

            RVIVector2 pos       = RVIVector2.Parse(args[0]);
            float      width     = float.Parse(args[1], CultureInfo.InvariantCulture);
            float      height    = float.Parse(args[2], CultureInfo.InvariantCulture);
            byte       hCount    = byte.Parse(args[3], CultureInfo.InvariantCulture);
            byte       vCount    = byte.Parse(args[4], CultureInfo.InvariantCulture);
            float      charScale = float.Parse(args[5], CultureInfo.InvariantCulture);

            string[] contents = args[6].Split('·');

            float currentY = pos.y - charScale / 2;

            for (int v = 0; v < vCount; v++)
            {
                float currentX = pos.x;
                for (int h = 0; h < hCount; h++)
                {
                    int contentIndex = (v * hCount) + h;
                    if (contentIndex > contents.Length - 1)
                    {
                        return(result);
                    }

                    string instruct = RVIInstructions.TextBoxSB(new RVIVector2(currentX, currentY), width, height, charScale, contents[contentIndex]);
                    result.AddRange(GetBytes(instruct, cKey));

                    currentX += width;
                }
                currentY -= height;
            }

            return(result);
        }
Example #4
0
        // Calls a definition from the dictionary in RVIDefinitions. Inherits offseting and scaling
        private static List <byte[]> Func(string[] args, long cKey, RVIVector2 offset, float scale)
        {
            List <byte[]> result = new List <byte[]>();

            // Initialize server definitions if necessary
            if (!RVIDefinitions.Initialized)
            {
                RVIDefinitions.Initialize();
            }

            // Parse args
            string     funcName   = args[0];
            RVIVector2 funcOffset = RVIVector2.Parse(args[1]);
            float      funcScale  = float.Parse(args[2], CultureInfo.InvariantCulture);

            // Apply scale
            RVIVector2 finalOffset = funcOffset * scale;
            float      finalScale  = funcScale * scale;

            // Apply offset
            finalOffset += offset;

            // Get function program lines
            string[] fLines = RVIDefinitions.Definitions[funcName.ToUpper()];
            for (int i = 0; i < fLines.Length; i++)
            {
                // Ignore comment lines, empty lines and '-' lines
                if ((fLines[i][0] == '#') || (fLines[i][0] == '!') || (string.IsNullOrEmpty(fLines[i])))
                {
                    continue;
                }
                else
                {
                    // Recursively call 'GetBytes' until all instructions are atomized
                    result.AddRange(Instruction2Packet.GetBytes(fLines[i], cKey, finalOffset.x, finalOffset.y, finalScale));
                }
            }
            return(result);
        }
Example #5
0
        // Draws an array of 1 character-size functions. Inherits offseting and scaling
        private static List <byte[]> ArrayChar(string[] args, long cKey, RVIVector2 offset, float scale)
        {
            List <byte[]> result = new List <byte[]>();

            // Initialize server definitions if necessary
            if (!RVIDefinitions.Initialized)
            {
                RVIDefinitions.Initialize();
            }

            // Parse arguments
            RVIVector2 position     = RVIVector2.Parse(args[0]);
            float      elementScale = float.Parse(args[1], CultureInfo.InvariantCulture);
            string     chars        = args[2];

            string[] fNames = new string[chars.Length];

            for (int i = 0; i < fNames.Length; i++)
            {
                fNames[i] = chars[i].ToString();
            }

            // Apply scale
            RVIVector2 finalOffset = position * scale;
            float      finalScale  = elementScale * scale;

            // Apply offset
            finalOffset += offset;

            foreach (string func in fNames)
            {
                if (func == "\0")
                {
                    continue;
                }
                if (func == "¬")
                {
                    finalOffset.y -= elementScale * 1.4f;
                    finalOffset.x  = position.x * scale;
                    continue;
                }
                string[]      fLines = RVIDefinitions.Definitions[func.ToUpper()];
                List <string> lns    = fLines.ToList();
                foreach (string line in lns)
                {
                    line.Replace("\r", "").Replace(" ", "").Replace("\t", "");
                }
                lns.RemoveAll(o => string.IsNullOrWhiteSpace(o));
                fLines = lns.ToArray();
                for (int i = 0; i < fLines.Length; i++)
                {
                    // Ignore comment lines, empty lines and '-' lines
                    if ((fLines[i][0] == '#') || (fLines[i][0] == '!') || (string.IsNullOrEmpty(fLines[i])))
                    {
                        continue;
                    }
                    else
                    {
                        result.AddRange(Instruction2Packet.GetBytes(fLines[i], cKey, finalOffset.x, finalOffset.y, finalScale));
                    }
                }
                finalOffset += new RVIVector2(elementScale, 0);
            }
            return(result);
        }