Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        /*
         *  The following methods process a message and call
         *  the interfaced methods accordingly.
         */

        public void Line(byte[] data)
        {
            RVIVector2 posA = RVIPackets.Server_Line.ReadPositionA(data);
            RVIVector2 posB = RVIPackets.Server_Line.ReadPositionB(data);

            this._interface.DrawLine(posA, posB);
        }
Ejemplo n.º 3
0
        public static RVIShape CreateLine(RVIVector2 posA, RVIVector2 posB, int color32)
        {
            RVIShape result = new RVIShape();

            result.VertexList.Add(posA);
            result.VertexList.Add(posB);

            result.Color32 = color32;

            return(result);
        }
Ejemplo n.º 4
0
        // Creates a 2-point line
        private static byte[] Line(string[] args, long cKey, RVIVector2 offset, float scale)
        {
            RVIVector2 pointA = RVIVector2.Parse(args[0]);
            RVIVector2 pointB = RVIVector2.Parse(args[1]);

            pointA *= scale;
            pointB *= scale;

            pointA += offset;
            pointB += offset;

            return(RVIPackets.Server_Line.Create(pointA, pointB, cKey));
        }
Ejemplo n.º 5
0
 public void Click(RVIVector2 pos)
 {
     byte[] clickPacket = RVIPackets.Client_Click.Create(pos, 0);
     try
     {
         _client.SendPacket(clickPacket);
     }
     catch (MOTCPClient.MOTCPException ex)
     {
         Log(ex.Message);
         _interface.Reset();
     }
 }
Ejemplo n.º 6
0
        // Creates a 2D rectangle from a point, width and height
        private static byte[] Rect(string[] args, long cKey, RVIVector2 offset, float scale)
        {
            RVIVector2 position = RVIVector2.Parse(args[0]);
            float      width    = float.Parse(args[1], CultureInfo.InvariantCulture);
            float      height   = float.Parse(args[2], CultureInfo.InvariantCulture);

            position *= scale;
            width    *= scale;
            height   *= scale;

            position += offset;

            return(RVIPackets.Server_Rect.Create(position, width, height, cKey));
        }
Ejemplo n.º 7
0
        // Creates a borderless rectangle with text inside. The text size and lining are manually provided.
        public static List <byte[]> TextBoxSB(string[] args, long cKey)
        {
            List <byte[]> result = new List <byte[]>();

            RVIVector2 pos       = RVIVector2.Parse(args[0]);
            float      w         = float.Parse(args[1], CultureInfo.InvariantCulture);
            float      h         = float.Parse(args[2], CultureInfo.InvariantCulture);
            float      charScale = float.Parse(args[3], CultureInfo.InvariantCulture);
            string     text      = args[4];

            RVIVector2 arraypos = new RVIVector2(pos.x + (charScale / 2), pos.y + charScale / 2);

            result.AddRange(GetBytes(RVIInstructions.ArrayChar(arraypos, charScale, text), cKey));

            return(result);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        public static RVIShape CreateRect(RVIRectangle rect, int color32)
        {
            RVIVector2 v1 = new RVIVector2(rect.x, rect.y);
            RVIVector2 v2 = new RVIVector2(rect.x + rect.w, rect.y);
            RVIVector2 v3 = new RVIVector2(rect.x + rect.w, rect.y + rect.h);
            RVIVector2 v4 = new RVIVector2(rect.x, rect.y + rect.h);

            RVIShape result = new RVIShape();

            result.VertexList.Add(v1);
            result.VertexList.Add(v2);
            result.VertexList.Add(v3);
            result.VertexList.Add(v4);
            result.VertexList.Add(v1);
            result.VertexList.Add(v4);
            result.VertexList.Add(v3);
            result.VertexList.Add(v2);

            result.Color32 = color32;

            return(result);
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
 public static byte[] Create(RVIVector2 clickPos, Int64 serverKey)
 {
     byte[] result = new byte[NCore.Client.Click.GetSize()];
     NCore.Client.Click.Create(clickPos.x, clickPos.y, serverKey, result);
     return(result);
 }
Ejemplo n.º 13
0
 public static byte[] Create(RVIVector2 pos, float w, float h, Int64 clientKey)
 {
     byte[] result = new byte[NCore.Server.Rect.GetSize()];
     NCore.Server.Rect.Create(pos.x, pos.y, w, h, clientKey, result);
     return(result);
 }
Ejemplo n.º 14
0
 public static byte[] Create(RVIVector2 va, RVIVector2 vb, Int64 clientKey)
 {
     byte[] result = new byte[NCore.Server.Line.GetSize()];
     NCore.Server.Line.Create(va.x, va.y, vb.x, vb.y, clientKey, result);
     return(result);
 }
Ejemplo n.º 15
0
        // Creates a borderless rectangle with text inside.. The text font size and lines of the text are automatically adjusted to the textbox area.
        public static List <byte[]> TextBoxB(string[] args, long cKey)
        {
            List <byte[]> result = new List <byte[]>();

            RVIVector2 pos  = RVIVector2.Parse(args[0]);
            float      w    = float.Parse(args[1], CultureInfo.InvariantCulture);
            float      h    = float.Parse(args[2], CultureInfo.InvariantCulture);
            string     text = args[3];

            float         charScale = 1;
            const int     CharactersPerLineThreshold = 28;
            bool          newLine        = false;
            List <string> lines          = new List <string>();
            string        currentLine    = "";
            int           currentCounter = 0;

            for (int i = 0; i < text.Length; i++)
            {
                currentCounter++;
                if (currentCounter % CharactersPerLineThreshold == 0 && currentCounter != 0)
                {
                    newLine = true;
                }
                if (text[i] == '·' && newLine)
                {
                    lines.Add(currentLine);
                    currentLine    = "";
                    newLine        = false;
                    currentCounter = 0;
                }
                else
                {
                    currentLine += text[i];
                }
            }
            lines.Add(currentLine);

            charScale = w / ((lines.Max(o => o.Length)) + 1);

            text = "";
            foreach (string line in lines)
            {
                text += line + "¬";
            }

            if (charScale >= h / 1.5f)
            {
                charScale = h / 1.5f;
            }

            RVIVector2 arraypos = new RVIVector2(pos.x + (charScale / 2), pos.y + h - charScale * 2);

            if (lines.Count == 1)
            {
                arraypos.y = pos.y + h / 2 - charScale / 2;
            }

            result.AddRange(GetBytes(RVIInstructions.ArrayChar(arraypos, charScale, text), cKey));

            return(result);
        }
Ejemplo n.º 16
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);
        }
Ejemplo n.º 17
0
        // Recursively creates a list of data packets from an instruction
        public static List <byte[]> GetBytes(string instruction, long clientKey, float offsetX = 0, float offsetY = 0, float scale = 1)
        {
            List <byte[]> result = new List <byte[]>();
            string        type   = instruction.Split(':')[0];

            string[] args = instruction.Split(':')[1].Split('-');

            // Some functions inherit the parent's offset
            RVIVector2 offset = new RVIVector2(offsetX, offsetY);

            switch (type.ToUpper())
            {
            case "LINE":
                result.Add(Line(args, clientKey, offset, scale));
                return(result);

            case "RECT":
                result.Add(Rect(args, clientKey, offset, scale));
                return(result);

            case "SETFRAME":
                result.Add(SetFrame(args, clientKey));
                return(result);

            case "RELEASEFRAME":
                result.Add(ReleaseFrame(args, clientKey));
                return(result);

            case "DELETEFRAME":
                result.Add(DeleteFrame(args, clientKey));
                return(result);

            case "CLEARFRAME":
                result.Add(ClearFrame(args, clientKey));
                return(result);

            case "FUNC":
                result.AddRange(Func(args, clientKey, offset, scale));
                return(result);

            case "SETCOLORRGBA":
                result.Add(SetColorRGBA(args, clientKey));
                return(result);

            case "ARRAY":
                result.AddRange(Array(args, clientKey, offset, scale));
                return(result);

            case "ARRAYCHAR":
                result.AddRange(ArrayChar(args, clientKey, offset, scale));
                return(result);

            case "CLEAN":
                result.Add(Clean(clientKey));
                return(result);

            case "DELAY":
                result.Add(Delay(args, clientKey));
                return(result);

            case "BLINKFRAME":
                result.Add(BlinkFrame(args, clientKey));
                return(result);

            case "TABLESTRUCT":
                result.AddRange(TableStruct(args, clientKey));
                return(result);

            case "TABLEARRAY":
                result.AddRange(TableArray(args, clientKey));
                return(result);

            case "TABLEARRAYS":
                result.AddRange(TableArrayS(args, clientKey));
                return(result);

            case "TABLEARRAYB":
                result.AddRange(TableArrayB(args, clientKey));
                return(result);

            case "TABLEARRAYSB":
                result.AddRange(TableArraySB(args, clientKey));
                return(result);

            case "REQUESTINPUT":
                result.Add(RequestInput(clientKey));
                return(result);

            case "TEXTBOX":
                result.AddRange(TextBox(args, clientKey));
                return(result);

            case "TEXTBOXS":
                result.AddRange(TextBoxS(args, clientKey));
                return(result);

            case "TEXTBOXB":
                result.AddRange(TextBoxB(args, clientKey));
                return(result);

            case "TEXTBOXSB":
                result.AddRange(TextBoxSB(args, clientKey));
                return(result);

            default:
                throw new Exception("Invalid instruction type");
            }
        }