Exemplo n.º 1
0
 private static void AddEnumValue(ScriptEnum insideEnumDefinition, FastString script, string lastWord)
 {
     if ((lastWord.Length > 0) && (Char.IsLetter(lastWord[0])))
     {
         if (!DoesCurrentLineHaveToken(script, AUTO_COMPLETE_IGNORE))
         {
             insideEnumDefinition.EnumValues.Add(lastWord);
         }
     }
 }
Exemplo n.º 2
0
        internal static FastString StrToHex2(string s)
        {
            FastString sb = new FastString(s.Length * 2);

            foreach (char c in s)
            {
                sb.Append(((UInt16)c).ToString("X4"));
            }
            return(sb);
        }
Exemplo n.º 3
0
        internal static string StrToHex(string s)
        {
            FastString sb = new FastString(s.Length * 2);

            foreach (char c in s)
            {
                sb.Append(((byte)c).ToString("X2"));
            }
            return(sb.ToString());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="header">Header text</param>
        public Menu(FastString header)
        {
            mHeader.Set(header);
            for (int i = 0; i < mOptions.Length; i++)
            {
                mOptions[i] = new Option();
            }

            ClearOptions();
        }
 public static FastString Concat(
     FastString fs1,
     FastString fs2,
     FastString fs3,
     FastString fs4,
     FastString fs5)
 {
     fs1.Append(fs2).Append(fs3).Append(fs4).Append(fs5);
     return(fs1);
 }
Exemplo n.º 6
0
        internal static string StringFromByteArray(byte[] array)
        {
            FastString result = new FastString(array.Length);

            foreach (byte b in array)
            {
                result.Append((char)b);
            }
            return(result.ToString());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Color index to color string
        /// </summary>
        /// <param name="color">Color index</param>
        /// <param name="outStr">Output string</param>
        /// <returns>String</returns>
        public static FastString IndexToColorString(int color, FastString outStr)
        {
            var demo = (DemoReel)RB.Game;

            Color32 rgb = IndexToRGB(color);

            outStr.Append("@").Append(rgb.r, 2, FastString.FORMAT_HEX_CAPS).Append(rgb.g, 2, FastString.FORMAT_HEX_CAPS).Append(rgb.b, 2, FastString.FORMAT_HEX_CAPS);

            return(outStr);
        }
Exemplo n.º 8
0
        private string HTMLGetStyleHeader(long index, long subindex)
        {
            FastString header = new FastString();

            return(header.Append(".").
                   Append(stylePrefix).
                   Append("s").
                   Append(index.ToString()).
                   Append((singlePage || layers)? String.Empty : String.Concat("-", subindex.ToString())).
                   Append(" { ").ToString());
        }
Exemplo n.º 9
0
        internal static string ReverseString(string str)
        {
            FastString result = new FastString(str.Length);
            int        i, j;

            for (j = 0, i = str.Length - 1; i >= 0; i--, j++)
            {
                result.Append(str[i]);
            }
            return(result.ToString());
        }
Exemplo n.º 10
0
        /// <summary>
        /// Add a log line to console
        /// </summary>
        /// <param name="str">Line</param>
        public void Log(FastString str)
        {
            // Rotate a log line from the end of the log to the start
            var line = mLogLines.Last;

            mLogLines.RemoveLast();

            line.Value.Set(str);

            mLogLines.AddFirst(line.Value);
        }
Exemplo n.º 11
0
 private void ExportPageStylesLayers(FastString styles, int PageNumber)
 {
     if (prevStyleListIndex < cssStyles.Count)
     {
         styles.Append(HTMLGetStylesHeader(PageNumber));
         for (int i = prevStyleListIndex; i < cssStyles.Count; i++)
         {
             styles.Append(HTMLGetStyleHeader(i, PageNumber)).Append(cssStyles[i]).AppendLine("}");
         }
         styles.AppendLine(HTMLGetStylesFooter());
     }
 }
Exemplo n.º 12
0
        private string HTMLGetStylesHeader(int PageNumber)
        {
            FastString header = new FastString();

            if (singlePage && pageBreaks)
            {
                header.AppendLine("<style type=\"text/css\" media=\"print\"><!--");
                header.AppendLine("div.frpage { page-break-after: always; page-break-inside: avoid; }");
                header.AppendLine("--></style>");
            }
            header.AppendLine("<style type=\"text/css\"><!-- ");
            return(header.ToString());
        }
    public static FastString Format(
        FastString format,
        FastString args0,
        FastString args1)
    {
        format.Replace("{0}", args0);
        format.Replace("{1}", args1);

        Release(args0);
        Release(args1);

        return(format);
    }
Exemplo n.º 14
0
        private void DrawTextFrame(Rect2i rect, FastString subTitle)
        {
            var demo = (DemoReel)RB.Game;

            RB.DrawRectFill(rect, DemoUtil.IndexToRGB(1));
            RB.DrawRect(rect, DemoUtil.IndexToRGB(2));

            if (subTitle != null)
            {
                var subTitleRect = new Rect2i(rect.x, rect.y + rect.height + 5, rect.width, rect.height);
                RB.Print(subTitleRect, DemoUtil.IndexToRGB(3), RB.ALIGN_H_CENTER | RB.TEXT_OVERFLOW_WRAP, subTitle);
            }
        }
Exemplo n.º 15
0
        private static void GoToNextLine(ref FastString script)
        {
            int indexOfNextLine = script.IndexOf("\r\n");

            if (indexOfNextLine < 0)
            {
                script = string.Empty;
            }
            else
            {
                script = script.Substring(indexOfNextLine + 2);
            }
        }
Exemplo n.º 16
0
 private void HTMLGetStyle(FastString style, Font Font, Color TextColor, Color FillColor, HorzAlign HAlign, VertAlign VAlign,
                           Border Border, Padding Padding, bool RTL, bool wordWrap, float LineHeight, float ParagraphOffset)
 {
     HTMLFontStyle(style, Font, LineHeight);
     style.Append("color:").Append(ExportUtils.HTMLColor(TextColor)).Append(";");
     style.Append("background-color:");
     style.Append(FillColor.A == 0 ? "transparent" : ExportUtils.HTMLColor(FillColor)).Append(";");
     HTMLAlign(style, HAlign, VAlign, wordWrap);
     HTMLBorder(style, Border);
     HTMLPadding(style, Padding, ParagraphOffset);
     HTMLRtl(style, RTL);
     style.AppendLine("}");
 }
Exemplo n.º 17
0
        private static bool DoesCurrentLineHaveToken(FastString script, string tokenToCheckFor)
        {
            int indexOfNextLine = script.IndexOf("\r\n");

            if (indexOfNextLine > 0)
            {
                if (script.Substring(0, indexOfNextLine).IndexOf(tokenToCheckFor) > 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 18
0
        private void LayerShape(FastString Page, ShapeObject obj, FastString text)
        {
            float      Width, Height;
            FastString addstyle = new FastString(64);

            addstyle.Append(GetStyle());

            addstyle.Append("background: url('" + GetLayerPicture(obj, out Width, out Height) + "');no-repeat !important;-webkit-print-color-adjust:exact;");

            float x = obj.Width > 0 ? obj.AbsLeft : (obj.AbsLeft + obj.Width);
            float y = obj.Height > 0 ? hPos + obj.AbsTop : (hPos + obj.AbsTop + obj.Height);

            Layer(Page, obj, x, y, obj.Width, obj.Height, text, null, addstyle);
        }
Exemplo n.º 19
0
    /// <summary>
    /// Make linked string
    /// </summary>
    /// <returns></returns>
    private string ToLinkedString()
    {
        StringBuilder retStr = new StringBuilder();

        FastString next = this;

        while (next)
        {
            retStr.Append(next.ToNormalString());
            next = next.m_nextNode;
        }

        return(retStr.ToString());
    }
Exemplo n.º 20
0
        private void LayerTable(FastString Page, FastString CSS, TableBase table)
        {
            float y = 0;

            for (int i = 0; i < table.RowCount; i++)
            {
                float x = 0;
                for (int j = 0; j < table.ColumnCount; j++)
                {
                    if (!table.IsInsideSpan(table[j, i]))
                    {
                        TableCell textcell = table[j, i];

                        textcell.Left = x;
                        textcell.Top  = y;

                        // custom draw
                        CustomDrawEventArgs e = new CustomDrawEventArgs();
                        e.report       = Report;
                        e.reportObject = textcell;
                        e.layers       = Layers;
                        e.zoom         = Zoom;
                        e.left         = textcell.AbsLeft;
                        e.top          = hPos + textcell.AbsTop;
                        e.width        = textcell.Width;
                        e.height       = textcell.Height;
                        OnCustomDraw(e);
                        if (e.done)
                        {
                            CSS.Append(e.css);
                            Page.Append(e.html);
                        }
                        else
                        {
                            if (textcell is TextObject && !(textcell as TextObject).TextOutline.Enabled && IsMemo(textcell))
                            {
                                LayerText(Page, textcell as TextObject);
                            }
                            else
                            {
                                LayerBack(Page, textcell as ReportComponentBase, null);
                                LayerPicture(Page, textcell as ReportComponentBase, null);
                            }
                        }
                    }
                    x += (table.Columns[j]).Width;
                }
                y += (table.Rows[i]).Height;
            }
        }
Exemplo n.º 21
0
 /// <summary>
 /// Initialize the entity
 /// </summary>
 /// <param name="pos">Position</param>
 /// <param name="sprite">Sprite to draw with</param>
 /// <param name="color">Color</param>
 /// <param name="name">String name</param>
 /// <param name="renderOrder">Rendering order</param>
 /// <param name="blocks">Whether the entity is blocking</param>
 public void Initialize(
     Vector2i pos,
     PackedSpriteID sprite,
     Color32 color,
     FastString name,
     RenderFunctions.RenderOrder renderOrder,
     bool blocks = false)
 {
     this.pos    = pos;
     this.sprite = sprite;
     this.color  = color;
     this.name.Append(name);
     this.blocks      = blocks;
     this.renderOrder = renderOrder;
 }
Exemplo n.º 22
0
        /// <summary>
        /// Write FastString
        /// </summary>
        /// <param name="writer">Writer instance</param>
        /// <param name="str">String</param>
        public static void Write(this BinaryWriter writer, FastString str)
        {
            writer.Write(str != null ? true : false);

            if (str != null)
            {
                writer.Write(str.Capacity);
                writer.Write(str.Length);
                for (int i = 0; i < str.Length; i++)
                {
                    char c = str[i];
                    writer.Write(c);
                }
            }
        }
Exemplo n.º 23
0
        public int Delete()
        {
            var cmd = new FastString(CMD_INIT_BUFFER_SIZE);

            cmd.Append("DELETE FROM ").Append(tableName);

            if (!whereStr.IsEmpty())
            {
                cmd.Append(" WHERE ").Append(whereStr);
            }

            cmd.Append(";");

            return(db.ExecuteNonQuery(cmd.ToString(), whereArgs.ToArray()));
        }
Exemplo n.º 24
0
    /// <summary>
    /// Return 'FastString' obj to pool. if head is a linked list, return all the linked list node
    /// </summary>
    /// <param name="head"></param>
    public static void Release(FastString head)
    {
        var next = head;

        while (next)
        {
            var tempObj  = next;
            var nextNode = next.m_nextNode;

            tempObj.m_nextNode = null;
            s_Pool?.Return(ref tempObj);

            next = nextNode;
        }
    }
Exemplo n.º 25
0
    public void ViewSpellTab(int pawnId)
    {
        for (int j = 0; j < viewPawnImages.Length; j++)
        {
            if (viewPawnImages[j] != null)
            {
                viewPawnImages[j].isVisible = j == pawnId;
            }
        }
        spellPane.OpenTab(pawnId);
        infoPane.OpenTab(0);
        PlayerPawn pawn = battle.allies[pawnId] as PlayerPawn;

        playerName.SetText(pawn.GetName());
        string     affText = "";
        FastString perc    = new FastString(3);

        double affTotal = pawn.GetAffinityTotal();

        for (int i = 0; i < 6; i++)
        {
            perc.Clear();
            double aff = pawn.GetAffinity(i);
            perc.Append((int)(aff / affTotal * 100), 2, FastString.FILL_SPACES);
            affText += "\n" /*+ Element.All[i].GetColorHex()*/ + pawn.GetAffinity(i) + " (" + perc + "%)";
        }
        affinities.SetText(affText);

        foreach (Text text in currentItemTexts)
        {
            RemoveUIObj(text);
        }
        string[] eq       = pawn.GetEquipment();
        int      currentY = size.height - 58;

        for (int i = 0; i < eq.Length; i++)
        {
            Equipment e    = Equipments.Get(eq[i]);
            Text      text = new Text(new Vector2i(5, currentY), new Vector2i(), RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, e.GetName());
            text.FitSizeToText(1);
            text.SetTooltip(e.GetDescription());
            currentY += text.size.height + 2;
            AddUIObj(text);
            currentItemTexts.Add(text);
            bottomPane.AddToTab(1, text);
        }
        UpdateContext();
    }
Exemplo n.º 26
0
        private FastString GetSpanText(TextObjectBase obj, FastString text,
                                       float top, float width,
                                       float ParagraphOffset)
        {
            FastString style = new FastString();

            style.Append("display:block;border:0;width:").Append(Px(width * Zoom));
            if (ParagraphOffset != 0)
            {
                style.Append("text-indent:").Append(Px(ParagraphOffset * Zoom));
            }
            if (obj.Padding.Left != 0)
            {
                style.Append("padding-left:").Append(Px((obj.Padding.Left) * Zoom));
            }
            if (obj.Padding.Right != 0)
            {
                style.Append("padding-right:").Append(Px(obj.Padding.Right * Zoom));
            }
            if (top != 0)
            {
                style.Append("margin-top:").Append(Px(top * Zoom));
            }

            // we need to apply border width in order to position our div perfectly
            float borderLeft   = 0;
            float borderRight  = 0;
            float borderTop    = 0;
            float borderBottom = 0;

            if (HTMLBorderWidthValues(obj, out borderLeft, out borderTop, out borderRight, out borderBottom))
            {
                style.Append("position:absolute;")
                .Append("left:").Append(Px(-1 * borderLeft / 2f))
                .Append("top:").Append(Px(-1 * borderTop / 2f));
            }

            string href = GetHref(obj);

            FastString result = new FastString(128);

            result.Append("<div ").
            Append(GetStyleTag(UpdateCSSTable(style.ToString()))).Append(">").
            Append(href).Append(text).Append(href != String.Empty ? "</a>" : String.Empty).
            Append("</div>");

            return(result);
        }
Exemplo n.º 27
0
        private void ExportHTMLPageFinalWeb(FastString CSS, FastString Page, HTMLData d, float MaxWidth, float MaxHeight)
        {
            CalcPageSize(pages[d.CurrentPage], MaxWidth, MaxHeight);

            if (Page != null)
            {
                pages[d.CurrentPage].PageText = Page.ToString();
                Page.Clear();
            }
            if (CSS != null)
            {
                pages[d.CurrentPage].CSSText = CSS.ToString();
                CSS.Clear();
            }
            pages[d.CurrentPage].PageEvent.Set();
        }
Exemplo n.º 28
0
        private void WriteMHTHeader(Stream Stream, string FileName)
        {
            FastString sb = new FastString(256);
            string     s  = "=?utf-8?B?" + System.Convert.ToBase64String(Encoding.UTF8.GetBytes(FileName)) + "?=";

            sb.Append("From: ").AppendLine(s);
            sb.Append("Subject: ").AppendLine(s);
            sb.Append("Date: ").AppendLine(ExportUtils.GetRFCDate(SystemFake.DateTime.Now));
            sb.AppendLine("MIME-Version: 1.0");
            sb.Append("Content-Type: multipart/related; type=\"text/html\"; boundary=\"").Append(boundary).AppendLine("\"");
            sb.AppendLine();
            sb.AppendLine("This is a multi-part message in MIME format.");
            sb.AppendLine();
            ExportUtils.Write(Stream, sb.ToString());
            sb.Clear();
        }
Exemplo n.º 29
0
        /// <summary>
        /// Get a string describing all entities at given position
        /// </summary>
        /// <param name="pos">Position</param>
        /// <param name="outStr">Entity string</param>
        public static void GetEntitiesStringAtTile(Vector2i pos, FastString outStr)
        {
            var game = (RetroDungeoneerGame)RB.Game;

            outStr.Clear();

            for (int i = RenderFunctions.renderOrderList.Length - 1; i >= 0; i--)
            {
                var currentRenderOrder = RenderFunctions.renderOrderList[i];
                if (currentRenderOrder == RenderFunctions.RenderOrder.HIDDEN)
                {
                    continue;
                }

                var entityList = GetEntitiesAtPos(pos);
                if (entityList == null)
                {
                    continue;
                }

                for (int j = 0; j < entityList.Count; j++)
                {
                    var e = entityList[j].e;

                    if (e != null && e.renderOrder == currentRenderOrder && game.map.IsInFOV(e.pos))
                    {
                        if (outStr.Length > 0)
                        {
                            outStr.Append('\n');
                        }

                        if (currentRenderOrder == RenderFunctions.RenderOrder.CORPSE)
                        {
                            outStr.Append(C.STR_COLOR_CORPSE).Append(e.name).Append("@-");
                        }
                        else if (currentRenderOrder == RenderFunctions.RenderOrder.ACTOR)
                        {
                            outStr.Append(C.STR_COLOR_NAME).Append(e.name).Append("@-");
                        }
                        else
                        {
                            outStr.Append(e.name);
                        }
                    }
                }
            }
        }
Exemplo n.º 30
0
        private void ExportHTMLPageStart(FastString Page, int PageNumber, int CurrentPage)
        {
            if (webMode)
            {
                if (!layers)
                {
                    pages[CurrentPage].CSSText = Page.ToString();
                    Page.Clear();
                }
                pages[CurrentPage].PageNumber = PageNumber;
            }

            if (!webMode && !singlePage)
            {
                Page.AppendLine(BODY_BEGIN);
            }
        }