Пример #1
0
            static Pipeline()
            {
                program = new List<Directive>();
                buffers = new Dictionary<string, ScreenBuffer>();
                main_window = new ScreenBuffer(true, screen_w, screen_h);
                main_window.autoscales = true;
                main_window.scaler = 1f;

                default_program();
            }
Пример #2
0
 public static void begin_targeted_render_sequence(ScreenBuffer buffer)
 {
     var d = Graphics.Pipeline.add_directive(Pipeline.Directives.clear_buffer, target_buffer : buffer, color: 0x0);
     d.temporary = true;
     d = Graphics.Pipeline.add_directive(Pipeline.Directives.render_layers, target_buffer: buffer);
     d.temporary = true;
     buffer.dedicated_layer = new Layer("");
     d.include_layer(buffer.dedicated_layer);
     if (backup_layer == null) backup_layer = Graphics.current_layer;
     Graphics.current_layer = buffer.dedicated_layer;
 }
Пример #3
0
 public void reset()
 {
     mode = blend_mode.normal;
     sequence.set(0, 0);
     scale.set(1.0f, 1.0f);
     color = 0xffffffff;
     rotation = 0.0f;
     t = null;
     buffer = null;
     _use_special_margins = false;
 }
Пример #4
0
        private static void render_buffer(ScreenBuffer source_buffer, ScreenBuffer target_buffer, EffectInstance effect)
        {
            var img = source_buffer.render_image as SFML.Graphics.RenderImage;
            if (img != null)
            {
                SFML.Graphics.Sprite sfml_spr = new SFML.Graphics.Sprite(img.Image);

                //sfml_spr.FlipY(true); 
                sfml_spr.Scale = new Vector2f((float)screen_w / source_buffer.w, (float)screen_h / source_buffer.h);

                

                effect.prepare();
                var so = effect.shader.sfml_shader_object;
                if (so == null) target_buffer.render_image.Draw(sfml_spr);
                else            target_buffer.render_image.Draw(sfml_spr, so);
            }
        }
Пример #5
0
 public Shot(Ship ShipToAttach, ScreenBuffer SB) : base(new ConsoleEngine.Coordinate(ShipToAttach.Position.X + 2, ShipToAttach.Position.Y - 1), new string[] { "|" }, new Coordinate(0, -1), SB)
 {
 }
Пример #6
0
 public void Init(TextConsole console, ScreenBuffer buffer)
 {
     Console     = console;
     ScrapBuffer = buffer;
 }
Пример #7
0
 public static Sprite add_offscreen_sprite(ScreenBuffer buffer, float x, float y)
 {
     Sprite spr = current_layer.new_sprite;
     spr.coords.set(x, y);
     spr.blit.buffer = buffer;
     spr.blit.t = null;
     spr.kind = Sprite.draw_mode.spr;
     last_sprite = spr;
     return spr;
 }
Пример #8
0
        private void ReadBoardInfo(PTTClient client, LiPttEventArgs e)
        {
            ScreenBuffer screen = client.Screen;

            if (e.State == PttState.BoardInfomation)
            {
                LiPTT.PttEventEchoed -= ReadBoardInfo;

                var action = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    var Board = CurrentBoard;

                    //看板名稱
                    string str  = screen.ToString(3);
                    Match match = new Regex(LiPTT.bracket_regex).Match(str);
                    if (match.Success)
                    {
                        Board.Name = str.Substring(match.Index + 1, match.Length - 2);
                        Board.Nick = LiPTT.GetBoardNick(Board.Name);
                    }

                    //看板分類 中文敘述
                    Board.Category    = screen.ToString(5, 15, 4);
                    Board.Description = client.Screen.ToString(5, 22, screen.Width - 22).Replace('\0', ' ').Trim();

                    //版主名單
                    str = screen.ToString(6, 15, screen.Width - 15).Replace('\0', ' ').Trim();
                    if (!new Regex(LiPTT.bound_regex).Match(str).Success) //(無)
                    {
                        Board.Leaders = str.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                    }

                    if (screen.ToString(7, 25, 4) == "公開")
                    {
                        Board.公開 = true;
                    }

                    if (screen.ToString(8, 12, 4) == "可以")
                    {
                        Board.可進入十大排行榜 = true;
                    }

                    if (screen.ToString(9, 5, 4) == "開放")
                    {
                        Board.開放非看板會員發文 = true;
                    }

                    if (screen.ToString(10, 5, 4) == "開放")
                    {
                        Board.開放回文 = true;
                    }

                    if (screen.ToString(11, 5, 4) == "開放")
                    {
                        Board.開放自刪 = true;
                    }

                    if (screen.ToString(12, 5, 4) == "開放")
                    {
                        Board.開放推文 = true;
                    }

                    if (screen.ToString(13, 5, 4) == "開放")
                    {
                        Board.開放噓文 = true;
                    }

                    if (screen.ToString(14, 5, 4) == "開放")
                    {
                        Board.開放快速連推 = true;
                    }

                    if (screen.ToString(15, 12, 4) == "自動")
                    {
                        Board.IPVisible = true;
                    }

                    if (screen.ToString(16, 12, 4) == "對齊")
                    {
                        Board.自動對齊 = true;
                    }

                    if (screen.ToString(17, 10, 2) == "可")
                    {
                        Board.板主可刪除違規文字 = true;
                    }

                    if (screen.ToString(18, 14, 2) == "會")
                    {
                        Board.轉文自動記錄 = true;
                    }

                    if (screen.ToString(19, 5, 2) == "已")
                    {
                        Board.冷靜模式 = true;
                    }

                    if (screen.ToString(20, 5, 4) == "允許")
                    {
                        Board.允許十八歲進入 = true;
                    }

                    //發文限制 - 登入次數
                    str   = screen.ToString(12);
                    match = new Regex(@"\d+").Match(str);
                    if (match.Success)
                    {
                        try
                        {
                            Board.LimitLogin = Convert.ToInt32(str.Substring(match.Index, match.Length));
                        }
                        catch { Debug.WriteLine(str.Substring(match.Index, match.Length)); }
                    }

                    //發文限制 - 退文篇數
                    str   = screen.ToString(13);
                    match = new Regex(@"\d+").Match(str);
                    if (match.Success)
                    {
                        try
                        {
                            Board.LimitReject = Convert.ToInt32(str.Substring(match.Index, match.Length));
                        }
                        catch { Debug.WriteLine(str.Substring(match.Index, match.Length)); }
                    }

                    if (LiPTT.CacheBoard)
                    {
                        ControlVisible = true;
                        Window.Current.CoreWindow.KeyDown        += CoreWindow_KeyDown;
                        Window.Current.CoreWindow.PointerPressed += Board_PointerPressed;
                    }
                    else
                    {
                        ContentCollection.Clear();
                        LiPTT.PttEventEchoed += InitBoard;
                    }

                    LiPTT.PressAnyKey();
                });
            }
        }
        public void ActuallyFire(int Charges)
        {
            FocusPsi PsiMutation = ParentObject.GetPart <FocusPsi>();

            // Shows the line picker interface for the player.

            TextConsole  _TextConsole = UI.Look._TextConsole;
            ScreenBuffer Buffer       = TextConsole.ScrapBuffer;

            Core.XRLCore.Core.RenderMapToBuffer(Buffer);

            List <GameObject> hit       = new List <GameObject>(1);
            List <Cell>       usedCells = new List <Cell>(1);
            var line = PickLine(20, AllowVis.Any, null, false, ForMissileFrom: ParentObject);

            Body            body        = ParentObject.GetPart <Body>();
            List <BodyPart> ParentsHead = body.GetPart("Head");

            Cell targetCell = line[line.Count - 1];

            if (!PsiMutation.usePsiCharges(Charges))
            {
                AddPlayerMessage("You do not have enough psi-charges!");
                return;
            }
            foreach (var Head in ParentsHead)
            {
                if (Head.Equipped != null)
                {
                    Physics.ApplyExplosion(currentCell, GetForce(Level, Charges), usedCells, hit, true, true, ParentObject, GetDamage(Level, Charges), 1, false, false, 2);
                    AddPlayerMessage("Your helmet obstructs the energy of the beam--it explodes in your face!");
                    return;
                }
            }
            if (ParentObject.HasEffect("Dazed") || ParentObject.HasEffect("Confused"))
            {
                Physics.ApplyExplosion(currentCell, GetForce(Level, Charges), usedCells, hit, true, true, ParentObject, GetDamage(Level, Charges), 1, false, false, 2);
                AddPlayerMessage("You lack the concentration to hold your focus! The collected energy explodes in your face!");
                return;
            }

            ActivatedAbilities activatedAbilities = ParentObject.GetPart("ActivatedAbilities") as ActivatedAbilities;

            activatedAbilities.GetAbility(CombustionBlastActivatedAbilityID).Cooldown = (Charges - 1) * 100;

            // Loop through each cell of the line in order.

            List <string> SparkySparkyChars = new List <string>()
            {
                "\xf8", "*", "."
            };
            List <Point> Beamline = Zone.Line(line[0].X, line[0].Y, targetCell.X, targetCell.Y);

            base.PlayWorldSound("sparkblast", 0.3f, 0.1f, true, null);

            for (int index = 1; index < line.Count; index++)
            {
                Cell cell        = line[index];
                char DisplayBeam = Beamline[index].DisplayChar;
                Buffer.Goto(cell.X, cell.Y);
                Buffer.Write("&Y^r" + DisplayBeam);

                Cell SparkyBeam = cell.GetRandomLocalAdjacentCell();
                Buffer.Goto(SparkyBeam.X, SparkyBeam.Y);
                Buffer.Write("&W" + SparkySparkyChars.GetRandomElement());
                _TextConsole.DrawBuffer(Buffer);
                System.Threading.Thread.Sleep(18);
                // Find a solid object and combat id on obj in line, to hit in this cell.
                GameObject obj = cell.FindObject(o => o.ConsiderSolidFor(ParentObject, ParentObject) || (o.HasPart("Combat") && !o.pPhysics.Solid));


                if (obj != null)
                {
                    targetCell = cell;
                    break;
                }
            }
            if (Stat.Random(1, 100) <= 50)
            {
                base.PlayWorldSound("bang1", 0.3f, 0, true, null);
            }
            else
            {
                base.PlayWorldSound("bang2", 0.3f, 0, true, null);
            }
            ComExplode(GetForce(Level, Charges), targetCell, ParentObject, GetDamage(Level, Charges));
            ParentObject.UseEnergy(10000);
        }
Пример #10
0
 public static ScreenBuffer create_fixed_size_buffer(string identifier, uint w, uint h)
 {
     ScreenBuffer new_buffer = new ScreenBuffer(false, w, h);
     buffers.Add(identifier, new_buffer);
     return new_buffer;
 }
Пример #11
0
 public static void Write(String s)
 {
     ScreenBuffer.Write(s);
 }
Пример #12
0
 protected override void FinishTemplate(ScreenBuffer screenBuffer, string result)
 {
     screenBuffer.WriteFinishMessage(_message);
     screenBuffer.Write(new string('*', _inputBuffer.Length), Prompt.ColorSchema.Answer);
 }
Пример #13
0
 public static void ResetColor()
 {
     ScreenBuffer.ResetColor();
 }
Пример #14
0
 public Rock(int x, int y, ScreenBuffer SB) : base(new Coordinate(x, y), Graphics.Rock, new Coordinate(0, 1), SB)
 {
 }
Пример #15
0
 public Rock(int x, int y, ScreenBuffer SB, Tuple <int, int> Direction) : base(new Coordinate(x, y), Graphics.Rock, new Coordinate(Direction.Item1, Direction.Item2), SB)
 {
 }
Пример #16
0
 //////////////////////////////////////////////////////////////////////////////////////////////////////
 public static Directive add_directive(Directives which_directive, ScreenBuffer target_buffer = null, List<Layer> layers = null, ScreenBuffer source_buffer = null, EffectInstance shader = null, uint color = 0xff000000)
 {
     Directive D = new Directive(which_directive, source_buffer, target_buffer, layers, shader, color);
     program.Add(D);
     return D;
 }
Пример #17
0
        public void UpdateScreen()
        {
            //check if previously drawn tiles are still rendered in the same spot(s) on screen - if so, no update needed
            if (this.LastTileCoordsList.Count > 0)
            {
                bool tilesValid = true;
                foreach (Coords coords in this.LastTileCoordsList)
                {
                    if (!this.LookTargetInfo.IsTileOnScreen(coords))
                    {
                        tilesValid = false;
                    }
                }
                if (tilesValid)
                {
                    return;
                }
            }
            this.LastTileCoordsList.Clear();
            string       description = this.LookTargetName;
            ScreenBuffer scrapBuffer = ScreenBuffer.GetScrapBuffer2(true);

            UnityEngine.Color color_y = ColorUtility.usfColorMap[7];
            UnityEngine.Color color_k = ColorUtility.usfColorMap[0];
            bool bDidDraw             = false;

            for (int y = 1; y < 24; y++)
            {
                for (int x = 0; x < 39; x++)
                {
                    if (scrapBuffer[x, y].Char == 'Ý' && scrapBuffer[x, y].Foreground == color_y && scrapBuffer[x, y].Background == color_k) //this character is the left thick border line of a popup dialog
                    {
                        if (scrapBuffer[x + 2, y + 1].Char == description[0])                                                                //item name found in expected spot on the first line of the pop-up box.
                        {
                            int targetCol = 0;
                            int charIdx   = 0;
                            int targetRow = y + 1;
                            for (int letterPos = x + 3; letterPos < 80; letterPos++)
                            {
                                charIdx++;
                                if (charIdx < description.Length)
                                {
                                    if (scrapBuffer[letterPos, targetRow].Char != description[charIdx])
                                    {
                                        if (charIdx > 30 && scrapBuffer[letterPos, targetRow].Char == ' ')
                                        {
                                            //matched at least 30 characters and we now have unexpected blank spaces - this likely means the
                                            //display name wrapped to the next line, and we can add the tile here after the wrap point
                                            if (scrapBuffer[letterPos - 1, targetRow].Char == ' ')
                                            {
                                                targetCol = letterPos;
                                            }
                                            else if (scrapBuffer[letterPos + 1, targetRow].Char == ' ')
                                            {
                                                targetCol = letterPos + 1;
                                            }
                                        }
                                        break;
                                    }
                                }
                                else
                                {
                                    if (scrapBuffer[letterPos, targetRow].Char == ' ' && scrapBuffer[letterPos + 1, targetRow].Char == ' ')
                                    {
                                        targetCol = letterPos + 1;
                                    }
                                    break;
                                }
                            }
                            if (targetCol > 0) //identified a spot to put the item's tile.
                            {
                                //draw tile
                                this.LookTargetInfo.WriteTileToBuffer(scrapBuffer, targetCol, targetRow);
                                this.LastTileCoordsList.Add(new Coords(targetCol, targetRow));
                                bDidDraw = true;
                            }
                        }
                    }
                }
            }
            if (bDidDraw)
            {
                Popup._TextConsole.DrawBuffer(scrapBuffer, null, false);
            }
        }
Пример #18
0
 public Directive(Directives wat, ScreenBuffer source, ScreenBuffer target, List<Layer> layers, EffectInstance effect = null, uint color = 0xff000000)
 {
     this.do_what        = wat;
     this.source_buffer  = source;
     this.target_buffer  = target;
     this.layers         = layers;
     this.color          = color;
     this.effect         = effect;
     if (this.effect == null) this.effect = EffectInstance.empty;
 }
        public void UpdateScreen()
        {
            object bufferCS = TextConsole.BufferCS;

            lock (bufferCS) //acquire a lock, otherwise we get weird screens due to buffer contention
            {
                ScreenBuffer scrapBuffer = ScreenBuffer.GetScrapBuffer2(true);
                for (int i = 4; i < 24; i++)           //4 is the first row any entry can appear on
                {
                    if (scrapBuffer[3, i].Char == '$') //indicates a discrete location entry
                    {
                        char[] locationChars = new char[70];
                        for (int j = 9; j < 79; j++)
                        {
                            locationChars[j - 9] = scrapBuffer[j, i].Char;
                        }
                        string locationName = new string(locationChars).Trim().ToLower();

                        this.UpdateJournalNoteDictionary();

                        if (!this.CachedRelevantJournalNotesByName.ContainsKey(locationName))
                        {
                            if (!this.ErroredJournalScreenStrings.Contains(locationName))
                            {
                                Debug.Log("QudUX Mod: Error trying to parse location from journal screen. [locationName = "
                                          + locationName + "]\nKNOWN LOCATIONS:\n" + DebugGetKnownLocationsList());
                                this.ErroredJournalScreenStrings.Add(locationName);
                            }
                            continue;
                        }

                        JournalFacts jFacts           = new JournalFacts();
                        bool         bFactsIdentified = false;
                        if (this.CachedRelevantJournalNotesByName[locationName].Count == 1)
                        {
                            //only one matching entry, no need to parse the directions
                            jFacts           = this.CachedRelevantJournalNotesByName[locationName][0];
                            bFactsIdentified = true;
                        }
                        else if (i < 23) //verify there's at least one line left for directoins to appear on screen
                        {
                            List <JournalFacts> jFactsArray = this.CachedRelevantJournalNotesByName[locationName];
                            char[] directionChars           = new char[76];
                            for (int j = 3; j < 79; j++)
                            {
                                directionChars[j - 3] = scrapBuffer[j, i + 1].Char;
                            }
                            string directionString = new string(directionChars).Trim();

                            int count = 0;
                            int index = -1;
                            for (int j = 0; j < jFactsArray.Count; j++)
                            {
                                if (jFactsArray[j].directionsTo == directionString)
                                {
                                    count++;
                                    index = j;
                                }
                            }
                            if (count == 1)
                            {
                                jFacts           = jFactsArray[index];
                                bFactsIdentified = true;
                            }
                        }
                        if (bFactsIdentified) //draw the appropriate character to represent if this location was previously visited
                        {
                            string locationIndicator = jFacts.hasBeenVisited ? "&G" + this.ExploredLocationSymbol : "&K" + this.UnexploredLocationSymbol;
                            this.AppliedSymbol = TextConsole.CurrentBuffer[4, i];
                            scrapBuffer.Goto(4, i);
                            scrapBuffer.Write(locationIndicator);
                        }
                    }
                }
                Popup._TextConsole.DrawBuffer(scrapBuffer, null, false);
            }
        }
Пример #20
0
        /*
         *      @TODO:
         *      SetError
         *      SetIn
         *      SetOut
         */

        public static void SetWindowPosition(int left, int top)
        {
            ScreenBuffer.SetWindowPosition(left, top);
        }
Пример #21
0
        public static string CustomRender(acegiak_ScreenBufferMaker sbMaker, int width, int height)
        {
            GameManager.Instance.PushGameView("Popup:AskString");
            PauseThinking();
            string Return       = "";
            int    StartingLine = 0;

            ScrapBuffer.Copy(TextConsole.CurrentBuffer);
            ScrapBuffer2.Copy(TextConsole.CurrentBuffer);


            ScreenBuffer Lines = ScreenBuffer.create(width, height);

            int c = (int)'_';

            while (c != 13)
            {
                ScrapBuffer.Copy(ScrapBuffer2);
                Lines = sbMaker(Lines, c);
                RenderCharBlock(Lines, "[Enter to confirm]", "[&WEnter&y to confirm]", ScrapBuffer, StartingLine);
                _TextConsole.DrawBuffer(ScrapBuffer, null, true);

                c = Keyboard.getch();

                if (Keyboard.vkCode == Keys.MouseEvent && Keyboard.CurrentMouseEvent.Event.StartsWith("SubmitString:"))
                {
                    Return = Keyboard.CurrentMouseEvent.Event.Substring(Keyboard.CurrentMouseEvent.Event.IndexOf(':') + 1);

                    Keyboard.ClearInput();
                    GameManager.Instance.PopGameView(true);
                    _TextConsole.DrawBuffer(ScrapBuffer2, null, true);
                    ResumeThinking();
                    return(Return);
                }

                if (Keyboard.vkCode != Keys.MouseEvent)
                {
                    char asChar = (char)c;
                    if (Char.IsDigit(asChar) || Char.IsLetter(asChar) || Char.IsPunctuation(asChar) || Char.IsSeparator(asChar) || Char.IsSymbol(asChar) || c == ' ')
                    {
                        Return += asChar;
                    }
                }

                if (Keyboard.vkCode == Keys.Back)
                {
                    if (Return.Length > 0)
                    {
                        Return = Return.Substring(0, Return.Length - 1);
                    }
                }

                if (Keyboard.vkCode == Keys.Escape || (Keyboard.vkCode == Keys.MouseEvent && Keyboard.CurrentMouseEvent.Event == "RightClick"))
                {
                    Keyboard.ClearInput();
                    GameManager.Instance.PopGameView(true);
                    _TextConsole.DrawBuffer(ScrapBuffer2, null, true);
                    ResumeThinking();
                    return("");    //escape
                }

                if ((Keyboard.vkCode == Keys.MouseEvent && Keyboard.CurrentMouseEvent.Event == "LeftClick"))
                {
                    break;
                }

//                if (c == (int)KeyCode.CrDown || c == '2') StartingLine++;
//                if (c == (int)KeyCode.CrUp || c == '8') StartingLine--;
//                if (c == (int)KeyCode.PgDown) StartingLine += 23;
//                if (c == (int)KeyCode.PgUp) StartingLine -= 23;
//                if (StartingLine < 0) StartingLine = 0;
            }

            Keyboard.ClearInput();
            GameManager.Instance.PopGameView(true);
            _TextConsole.DrawBuffer(ScrapBuffer2, null, true);
            ResumeThinking();

            return(Return);
        }
Пример #22
0
 public static ScreenBuffer create_autoscaling_buffer(string identifier, float scale)
 {
     ScreenBuffer new_buffer = new ScreenBuffer(scale);
     buffers.Add(identifier, new_buffer);
     return new_buffer;
 }
Пример #23
0
 public static void Clear()
 {
     ScreenBuffer.Clear();
 }
Пример #24
0
        public static int RenderCharBlock(ScreenBuffer Lines, string BottomLineNoFormat, string BottomLine, ScreenBuffer Buffer, int StartingLine, int MinWidth = -1, int MinHeight = -1, string Title = null, bool BottomLineRegions = false)
        {
            int Width = 22;

            if (Title != null)
            {
                string StrippedTitle = ConsoleLib.Console.ColorUtility.StripFormatting(Title);
                if (MinWidth < StrippedTitle.Length + 2)
                {
                    MinWidth = StrippedTitle.Length + 2;
                }
            }
            if (MinWidth > -1)
            {
                Width = MinWidth;
            }

            // for (int x = 0; x < Lines.Height; x++)
            // {
            //     string Stripped = ConsoleLib.Console.ColorUtility.StripFormatting(Lines[x]);
            //     if (Stripped.Length + 2 >= Width) Width = Stripped.Length + 2;
            // }

            int HOffset = Width / 2;
            int Offset  = Lines.Height / 2;

            HOffset++;

            if (MinHeight > -1)
            {
                Offset = MinHeight;
            }
            if (Offset < 2)
            {
                Offset = 2;
            }

            int Top    = 10 - Offset;
            int Bottom = Top + Lines.Height + 3;
            int Left   = 40 - HOffset;
            int Right  = 40 + HOffset;

            if (Left < 0)
            {
                Left = 0;
            }
            if (Right > 79)
            {
                Right = 79;
            }
            if (Top < 0)
            {
                Top = 0;
            }
            if (Bottom > 24)
            {
                Bottom = 24;
            }

            if (Right < MinWidth - 1)
            {
                Right = MinHeight - 1;
            }
            if (Bottom < MinHeight - 1)
            {
                Bottom = MinHeight - 1;
            }

            Buffer.Fill(Left, Top, Right, Bottom, ' ', ConsoleLib.Console.ColorUtility.MakeColor(TextColor.Black, TextColor.Black));
            Buffer.ThickSingleBox(Left, Top, Right, Bottom, ConsoleLib.Console.ColorUtility.MakeColor(TextColor.Grey, TextColor.Black));

            if (Title != null)
            {
                Buffer.Goto(Left + 1, Top);
                Buffer.Write(Title);
            }

            for (int x = 0; x < Lines.Height; x++)
            {
                Buffer.Goto(Left + 2, Top + 2 + x - StartingLine);

                if (StartingLine > 0 && x == StartingLine)
                {
                    Buffer.Write("<up for more...>");
                }
                else
                if (Top + 2 + x - StartingLine == 23)
                {
                    Buffer.Write("<down for more...>");
                }
                else
                {
                    for (int i = 0; i < Lines.Width; i++)
                    {
                        if (Lines[i, x] != null && Lines[i, x].Tile != null)
                        {
                            //IPart.AddPlayerMessage("Tile:"+Lines[i,x].Tile);

                            Buffer[Left + 2 + i, Top + 2 + x]      = new ConsoleChar();
                            Buffer[Left + 2 + i, Top + 2 + x].Char = Lines[i, x].Char;
                            Buffer[Left + 2 + i, Top + 2 + x].Tile = Lines[i, x].Tile;
                            Buffer[Left + 2 + i, Top + 2 + x].SetForeground('y');
                            Buffer[Left + 2 + i, Top + 2 + x].SetBackground('k');
                            Buffer[Left + 2 + i, Top + 2 + x].TileLayerBackground[0] = ConsoleLib.Console.ColorUtility.ColorMap['r'];
                        }
                        // Write(Buffer,Lines[i,x]);
                    }
                }
            }

            int Spacing = HOffset * 2;

            Spacing -= BottomLineNoFormat.Length;
            Spacing /= 2;
            Spacing++;
            Buffer.Goto(Left + Spacing, Bottom);
            Buffer.Write(BottomLine);

            if (BottomLineRegions)
            {
                GameManager.Instance.ClearRegions();
                List <int> RegionPlaces = new List <int>();
                RegionPlaces.Add(0);
                for (int x = 0; x < BottomLineNoFormat.Length; x++)
                {
                    if (BottomLineNoFormat[x] == ' ')
                    {
                        RegionPlaces.Add(x);
                    }
                }
                RegionPlaces.Add(BottomLineNoFormat.Length);
                for (int x = 0; x < RegionPlaces.Count - 1; x++)
                {
                    GameManager.Instance.AddRegion(Left + Spacing + RegionPlaces[x], Bottom - 1, Left + Spacing + RegionPlaces[x + 1], Bottom + 1, "LeftOption:" + (x + 1), "RightOption:" + (x + 1));
                }
            }

            return(Lines.Height);
        }
Пример #25
0
 public static void SetCursorPosition(int x, int y)
 {
     ScreenBuffer.SetCursorPosition(x, y);
 }
Пример #26
0
 protected abstract void InputTemplate(ScreenBuffer screenBuffer);
Пример #27
0
 public static void SetWindowSize(int width, int height)
 {
     ScreenBuffer.SetWindowSize(width, height);
 }
Пример #28
0
 protected abstract void FinishTemplate(ScreenBuffer screenBuffer, T result);
Пример #29
0
 void VideoForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     ScreenBuffer.Dispose();
 }
Пример #30
0
 protected virtual void InputTemplate(ScreenBuffer screenBuffer)
 {
 }
 public void EraseSelectionBox(ScreenBuffer buffer)
 {
     DrawSelectionBox(buffer, true);
 }
Пример #32
0
 protected virtual void FinishTemplate(ScreenBuffer screenBuffer, T result)
 {
 }
        public void ApplyCombustExplosion(Cell C, List <Cell> UsedCells, List <GameObject> Hit, int Force, bool bLocal, bool bShow, GameObject Owner, string BonusDamage, bool?Phase, bool Neutron = false, float DamageModifier = 1f)
        {
            TextConsole  textConsole = Look._TextConsole;
            ScreenBuffer scrapBuffer = TextConsole.ScrapBuffer;

            if (bShow)
            {
                TextConsole.LoadScrapBuffers();
                XRLCore.Core.RenderMapToBuffer(scrapBuffer);
            }
            CleanQueue <Cell>   cleanQueue  = new CleanQueue <Cell>();
            CleanQueue <int>    cleanQueue2 = new CleanQueue <int>();
            CleanQueue <string> cleanQueue3 = new CleanQueue <string>();

            cleanQueue.Enqueue(C);
            cleanQueue2.Enqueue(Force);
            cleanQueue3.Enqueue(".");
            UsedCells.Add(C);
            while (cleanQueue.Count > 0)
            {
                Cell   cell = cleanQueue.Dequeue();
                int    num  = cleanQueue2.Dequeue();
                string text = cleanQueue3.Dequeue();
                for (int i = 0; i < UsedCells.Count; i++)
                {
                    Cell cell2 = UsedCells[i];
                    if (cell2 == null)
                    {
                        return;
                    }
                    if (cell2.ParentZone == XRLCore.Core.Game.ZoneManager.ActiveZone)
                    {
                        scrapBuffer.Goto(cell2.X, cell2.Y);
                        int num2 = Stat.Random(1, 3);
                        if (num2 == 1)
                        {
                            scrapBuffer.Write((Phase != null) ? ((!(Phase == true)) ? "&Y*" : "&K*") : "&M*");
                        }
                        else if (num2 == 2)
                        {
                            scrapBuffer.Write((Phase != null) ? ((!(Phase == true)) ? "&R*" : "&b*") : "&G*");
                        }
                        else
                        {
                            scrapBuffer.Write((Phase != null) ? ((!(Phase == true)) ? "&W*" : "&c*") : "&m*");
                        }
                    }
                }
                if (bShow && C.ParentZone != null && C.ParentZone.IsActive())
                {
                    textConsole.DrawBuffer(scrapBuffer, null, false);
                    if (Force < 100000)
                    {
                        Thread.Sleep(5);
                    }
                }
                List <Cell> list;
                if (bLocal)
                {
                    list = cell.GetLocalAdjacentCells(1, false);
                }
                else
                {
                    list = cell.GetAdjacentCells(true);
                }
                for (int j = 0; j < UsedCells.Count; j++)
                {
                    Cell item = UsedCells[j];
                    if (list.CleanContains(item))
                    {
                        list.Remove(item);
                    }
                }
                int    num3   = 0;
                Damage damage = null;
                Event  @event = null;
                foreach (GameObject gameObject in cell.GetObjectsWithPart("Physics"))
                {
                    if (!Hit.Contains(gameObject))
                    {
                        Hit.Add(gameObject);
                        if (gameObject.PhaseMatches(0))
                        {
                            num3 += gameObject.Weight;
                            if (damage == null || !string.IsNullOrEmpty(BonusDamage))
                            {
                                damage = new Damage((int)(DamageModifier * (float)num / 250f));
                                if (!string.IsNullOrEmpty(BonusDamage))
                                {
                                    damage.Amount += BonusDamage.RollCached();
                                }
                                damage.AddAttribute("Explosion");
                                damage.AddAttribute("Heat");
                                damage.AddAttribute("Fire");
                                damage.AddAttribute("Concussion");
                                if (cell != C)
                                {
                                    damage.AddAttribute("Accidental");
                                }
                            }
                            if (@event == null || !string.IsNullOrEmpty(BonusDamage))
                            {
                                @event = Event.New("TakeDamage", 0, 0, 0);
                                @event.SetParameter("Damage", damage);
                                @event.SetParameter("Owner", Owner);
                                @event.SetParameter("Attacker", Owner);
                                if (Neutron)
                                {
                                    if (gameObject.IsPlayer())
                                    {
                                        gameObject.pPhysics.LastDeathReason = "Crushed under the weight of a thousand suns.";
                                    }
                                    @event.SetParameter("Message", "from being crushed under the weight of a thousand suns.");
                                }
                                else
                                {
                                    @event.SetParameter("Message", "from %t explosion!");
                                }
                            }
                            gameObject.FireEvent(@event);
                        }
                    }
                }
                System.Random random = new System.Random();
                for (int k = 0; k < list.Count; k++)
                {
                    int  index = random.Next(0, list.Count);
                    Cell value = list[k];
                    list[k]     = list[index];
                    list[index] = value;
                }
                Damage damage2 = null;
                Event  event2  = null;
                for (; ;)
                {
IL_44B:
                    int l = 0;
                    while (l < list.Count)
                    {
                        Cell cell3 = list[l];
                        if (!bLocal)
                        {
                            goto IL_4AD;
                        }
                        if (cell3.X != 0)
                        {
                            if (cell3.X != 79)
                            {
                                if (cell3.Y != 0)
                                {
                                    if (cell3.Y != 24)
                                    {
                                        goto IL_4AD;
                                    }
                                }
                            }
                        }
IL_68C:
                        l++;
                        continue;
IL_4AD:
                        foreach (GameObject gameObject2 in cell3.GetObjectsWithPart("Physics"))
                        {
                            if (!Hit.Contains(gameObject2))
                            {
                                Hit.Add(gameObject2);
                                if (gameObject2.PhaseMatches(0))
                                {
                                    if (damage2 == null || !string.IsNullOrEmpty(BonusDamage))
                                    {
                                        damage2 = new Damage(num / 250);
                                        if (!string.IsNullOrEmpty(BonusDamage))
                                        {
                                            damage2.Amount += BonusDamage.RollCached();
                                        }
                                        damage2.AddAttribute("Explosion");
                                        damage2.AddAttribute("Accidental");
                                        damage2.AddAttribute("Heat");
                                        damage2.AddAttribute("Fire");
                                        damage2.AddAttribute("Concussion");
                                    }
                                    if (event2 == null || !string.IsNullOrEmpty(BonusDamage))
                                    {
                                        event2 = Event.New("TakeDamage", 0, 0, 0);
                                        event2.SetParameter("Damage", damage2);
                                        event2.SetParameter("Owner", Owner);
                                        event2.SetParameter("Attacker", Owner);
                                        if (Neutron)
                                        {
                                            if (gameObject2.IsPlayer())
                                            {
                                                gameObject2.pPhysics.LastDeathReason = "Crushed under the weight of a thousand suns.";
                                            }
                                            event2.SetParameter("Message", "from being crushed under the weight of a thousand suns.");
                                        }
                                        else
                                        {
                                            event2.SetParameter("Message", "from %t explosion!");
                                        }
                                    }
                                    gameObject2.FireEvent(event2);
                                }
                            }
                            if (gameObject2.PhaseMatches(0))
                            {
                                int weight = gameObject2.Weight;
                                if (weight > num)
                                {
                                    list.Remove(cell3);
                                    goto IL_44B;
                                }
                                if (weight > 0)
                                {
                                    gameObject2.Move((!(text == ".")) ? text : Directions.GetRandomDirection(), EnergyCost: 1000);
                                }
                            }
                        }
                        if (cell3.IsSolid())
                        {
                            list.Remove(cell3);
                            goto IL_44B;
                        }
                        goto IL_68C;
                    }
                    break;
                }
                if (list.Count > 0)
                {
                    int num4 = (num - num3) / list.Count;
                    if (num4 > 100)
                    {
                        foreach (Cell cell4 in list)
                        {
                            if (cell4 != null && !UsedCells.Contains(cell4))
                            {
                                UsedCells.Add(cell4);
                                cleanQueue.Enqueue(cell4);
                                cleanQueue2.Enqueue(num4);
                                cleanQueue3.Enqueue(cell.GetDirectionFromCell(cell4));
                            }
                        }
                    }
                }
            }
        }
Пример #34
0
 protected override void FinishTemplate(ScreenBuffer screenBuffer, bool result)
 {
     screenBuffer.WriteFinish(_message);
     screenBuffer.Write(result ? "Yes" : "No", Prompt.ColorSchema.Answer);
 }
Пример #35
0
        /// <summary>
        /// Our main menu screen method. Draws the ingredient selection screen and handles related functions.
        /// </summary>
        /// <remarks>
        /// This (and several supporting methods) are static just for simplicity's sake, because it
        /// is easier to call from a Harmony patch when it's static. If we were implementing this
        /// directly, we wouldn't make this static.
        /// </remarks>
        public static ScreenReturn Show(List <GameObject> ingredients, List <bool> isIngredientSelected)
        {
            if (ingredients == null || ingredients.Count <= 0 || isIngredientSelected == null || isIngredientSelected.Count != ingredients.Count)
            {
                return(ScreenReturn.Exit);
            }

            GameManager.Instance.PushGameView("QudUX:CookIngredients");
            ScreenBuffer cachedScrapBuffer = ScreenBuffer.GetScrapBuffer2(true);
            Keys         keys                    = Keys.None;
            bool         shouldExitMenu          = false;
            int          scrollOffset            = 0;
            int          selectedIngredientIndex = 0;
            int          scrollAreaHeight        = 14;
            int          amountColumnPos         = 43;

            //Determine number of ingredients player is allowed to use
            int allowedIngredientCount = 2;

            if (IComponent <GameObject> .ThePlayer.HasSkill("CookingAndGathering_Spicer"))
            {
                allowedIngredientCount++;
            }

            //Gather ingredient display details
            List <IngredientScreenInfo> ingredientOptions = GetIngredientScreenInfo(ingredients, isIngredientSelected);

            while (!shouldExitMenu)
            {
                ScrapBuffer.Clear();
                //Event.ResetPool();  // Can't call this here because there are active event pool lists in use by the enclosing Campfire code
                int selectedIngredientCount = ingredientOptions.Where(io => io.IsSelected == true).Count();

                //Draw main box
                ScrapBuffer.TitledBox("Ingredients");

                //Draw bottom box with selected ingredients
                ScrapBuffer.SingleBoxHorizontalDivider(17);
                int row = 18;
                foreach (IngredientScreenInfo info in ingredientOptions.Where(io => io.IsSelected == true))
                {
                    ScrapBuffer.Write(2, row++, info.OptionName);
                    ScrapBuffer.Write(5, row++, info.CookEffect);
                    if (row > 23)
                    {
                        break;
                    }
                }

                //Draw ingredient list
                if (ingredientOptions.Count == 0)
                {
                    ScrapBuffer.Write(4, 3, "You don't have any ingredients.");
                }
                else
                {
                    for (int drawIndex = scrollOffset; drawIndex < ingredientOptions.Count && drawIndex - scrollOffset < scrollAreaHeight; drawIndex++)
                    {
                        int yPos = 2 + (drawIndex - scrollOffset);
                        ScrapBuffer.Goto(4, yPos);
                        if (string.IsNullOrEmpty(ingredientOptions[drawIndex].OptionName))
                        {
                            ScrapBuffer.Write("&k<Error: unknown ingredient>&y");
                        }
                        else
                        {
                            string option = ingredientOptions[drawIndex].GetCheckboxString();
                            ScrapBuffer.Write(option);
                            if (ConsoleLib.Console.ColorUtility.LengthExceptFormatting(option) > 39)
                            {
                                ScrapBuffer.Write(40, yPos, "{{y|...             }}");
                            }
                        }

                        ScrapBuffer.Goto(amountColumnPos, 2 + (drawIndex - scrollOffset));
                        if (drawIndex == selectedIngredientIndex)
                        {
                            ScrapBuffer.Write("{{^K|" + ingredientOptions[drawIndex].UseCount + "}}");
                        }
                        else
                        {
                            ScrapBuffer.Write(ingredientOptions[drawIndex].UseCount);
                        }

                        //Draw selection caret at current index
                        if (drawIndex == selectedIngredientIndex)
                        {
                            ScrapBuffer.Goto(2, 2 + (drawIndex - scrollOffset));
                            ScrapBuffer.Write("{{Y|>}}");
                        }
                    }
                }

                //Help text on bottom of screen
                ScrapBuffer.Write(2, 24, " {{W|Space{{y|/}}Enter}}{{y| - Select}} ");
                ScrapBuffer.Write(46, 24, " {{W|C{{y|/}}Ctrl+Space{{y|/}}Ctrl+Enter}}{{y| - Cook}} ");

                //Infobox on right-hand side of screen
                ScrapBuffer.SingleBox(56, 0, 79, 17, ConsoleLib.Console.ColorUtility.MakeColor(TextColor.Grey, TextColor.Black));
                ScrapBuffer.Fill(57, 1, 78, 16, ' ', ConsoleLib.Console.ColorUtility.MakeColor(TextColor.Black, TextColor.Black));
                //Fix box intersections
                ScrapBuffer.Goto(56, 17);
                ScrapBuffer.Write(193);
                ScrapBuffer.Goto(56, 0);
                ScrapBuffer.Write(194);
                ScrapBuffer.Goto(79, 17);
                ScrapBuffer.Write(180);

                //Help text at top of screen
                ScrapBuffer.Write(2, 0, "{{y| {{W|2}} or {{W|8}} to scroll }}");
                ScrapBuffer.EscOr5ToExit();

                //Write description to infobox for currently highlighted ingredient
                string   highlightDescription      = ingredientOptions[selectedIngredientIndex].CookEffect;
                string[] linedHighlightDescription = StringFormat.ClipTextToArray(highlightDescription, 20).ToArray();
                ScrapBuffer.Goto(58, 2);
                ScrapBuffer.WriteBlockWithNewlines(linedHighlightDescription, 14);

                //Draw the screen
                Console.DrawBuffer(ScrapBuffer);

                //Respond to keyboard input
                keys = Keyboard.getvk(Options.MapDirectionsToKeypad);

                if (keys == Keys.Escape || keys == Keys.NumPad5)
                {
                    //clear out the boolean list, since our current Harmony setup uses that as a method
                    //to determine whether anything was selected from this menu
                    for (int i = 0; i < isIngredientSelected.Count(); i++)
                    {
                        isIngredientSelected[i] = false;
                    }
                    shouldExitMenu = true;
                }
                if (keys == Keys.NumPad8)
                {
                    if (selectedIngredientIndex == scrollOffset)
                    {
                        if (scrollOffset > 0)
                        {
                            scrollOffset--;
                            selectedIngredientIndex--;
                        }
                    }
                    else if (selectedIngredientIndex > 0)
                    {
                        selectedIngredientIndex--;
                    }
                }
                if (keys == Keys.NumPad2)
                {
                    int maxIndex = ingredientOptions.Count - 1;
                    if (selectedIngredientIndex < maxIndex)
                    {
                        selectedIngredientIndex++;
                    }
                    if (selectedIngredientIndex - scrollOffset >= scrollAreaHeight)
                    {
                        scrollOffset++;
                    }
                }
                if (keys == Keys.Prior)                 //PgUp
                {
                    selectedIngredientIndex = ((selectedIngredientIndex != scrollOffset) ? scrollOffset : (scrollOffset = Math.Max(scrollOffset - (scrollAreaHeight - 1), 0)));
                }
                if (keys == Keys.Next)                 //PgDn
                {
                    if (selectedIngredientIndex != scrollOffset + (scrollAreaHeight - 1))
                    {
                        selectedIngredientIndex = scrollOffset + (scrollAreaHeight - 1);
                    }
                    else
                    {
                        int advancementDistance = scrollAreaHeight - 1;
                        selectedIngredientIndex += advancementDistance;
                        scrollOffset            += advancementDistance;
                    }
                    selectedIngredientIndex = Math.Min(selectedIngredientIndex, ingredientOptions.Count - 1);
                    scrollOffset            = Math.Min(scrollOffset, ingredientOptions.Count - 1);
                }
                if (keys == Keys.C || keys == (Keys.Control | Keys.Enter) || keys == (Keys.Control | Keys.Space))
                {
                    if (selectedIngredientCount > 0)
                    {
                        shouldExitMenu = true;
                    }
                    else
                    {
                        Popup.Show("You haven't selected any ingredients to cook with.", LogMessage: false);
                    }
                }
                if (keys == Keys.Space || keys == Keys.Enter)
                {
                    if (ingredientOptions[selectedIngredientIndex].IsSelected == true)
                    {
                        ingredientOptions[selectedIngredientIndex].IsSelected = false;
                    }
                    else
                    {
                        if (selectedIngredientCount >= allowedIngredientCount)
                        {
                            Popup.Show("You can't select more than " + selectedIngredientCount + " ingredients.", LogMessage: false);
                        }
                        else
                        {
                            ingredientOptions[selectedIngredientIndex].IsSelected = true;
                        }
                    }
                }
                if (keys == Keys.NumPad6)
                {
                    if (ingredientOptions[selectedIngredientIndex].IsSelected == false)
                    {
                        if (selectedIngredientCount >= allowedIngredientCount)
                        {
                            Popup.Show("You can't select more than " + selectedIngredientCount + " ingredients.", LogMessage: false);
                        }
                        else
                        {
                            ingredientOptions[selectedIngredientIndex].IsSelected = true;
                        }
                    }
                }
                if (keys == Keys.NumPad4)
                {
                    if (ingredientOptions[selectedIngredientIndex].IsSelected == true)
                    {
                        ingredientOptions[selectedIngredientIndex].IsSelected = false;
                    }
                }
            }

            //Screen exit
            Console.DrawBuffer(cachedScrapBuffer);
            GameManager.Instance.PopGameView(true);
            return(ScreenReturn.Exit);
        }
Пример #36
0
        public void Parse()
        {
            Regex        regex;
            Match        match;
            string       str;
            uint         id     = 0;
            ScreenBuffer screen = LiPTT.Screen;

            var x = screen.ToStringArray();

            /////////////////////////////
            ///置底文 and 其他文章
            ///
            for (int i = 22; i >= 3; i--)
            {
                Article article = new Article();

                //ID流水號
                str = screen.ToString(i, 0, 8);
                if (str.IndexOf('★') != -1)
                {
                    article.ID   = uint.MaxValue;
                    article.Star = StarCount++;
                }
                else
                {
                    regex = new Regex(@"(\d+)");
                    match = regex.Match(str);

                    if (match.Success)
                    {
                        id         = Convert.ToUInt32(str.Substring(match.Index, match.Length));
                        article.ID = id;

                        if (id > CurrentIndex)
                        {
                            continue;
                        }

                        if (id != CurrentIndex && CurrentIndex != uint.MaxValue) //id 被游標遮住
                        {
                            article.ID = CurrentIndex;
                        }

                        CurrentIndex = article.ID - 1;
                    }
                }

                //推文數
                str = screen.ToString(i, 9, 2);

                if (str[0] == '爆')
                {
                    article.Like = 100;
                }
                else if (str[0] == 'X')
                {
                    if (str[1] == 'X')
                    {
                        article.Like = -100;
                    }
                    else
                    {
                        article.Like = Convert.ToInt32(str[1].ToString());
                        article.Like = -article.Like * 10;
                    }
                }
                else
                {
                    regex = new Regex(@"(\d+)");
                    match = regex.Match(str);
                    if (match.Success)
                    {
                        article.Like = Convert.ToInt32(str.Substring(match.Index, match.Length));
                    }
                    else
                    {
                        article.Like = 0;
                    }
                }

                //未讀、已讀、M文 等等等
                article.State = LiPTT.GetReadSate((char)screen[i][8].Content);

                //文章日期
                str = screen.ToString(i, 11, 5);
                try
                {
                    article.Date = DateTimeOffset.Parse(str);
                }
                catch
                {
                    continue;
                }

                //作者
                str   = screen.ToString(i, 17, 13).Replace('\0', ' ');
                regex = new Regex(@"[\w\S]+");
                match = regex.Match(str);
                if (match.Success)
                {
                    article.Author = str.Substring(match.Index, match.Length);
                }

                //文章類型
                str = screen.ToString(i, 30, 2).Replace('\0', ' ');
                if (str.StartsWith("R:"))
                {
                    article.Type = ArticleType.回覆;
                }
                else if (str.StartsWith("□"))
                {
                    article.Type = ArticleType.一般;
                }
                else if (str.StartsWith("轉"))
                {
                    article.Type = ArticleType.轉文;
                }
                else
                {
                    article.Type = ArticleType.無;
                }
                //是否被刪除
                if (article.Author == "-")
                {
                    article.Deleted = true;
                }
                else
                {
                    article.Deleted = false;
                }

                str = screen.ToString(i, 30, screen.Width - 30).Replace('\0', ' ');

                if (article.Deleted)
                {
                    article.Title = str;
                    regex         = new Regex(LiPTT.bracket_regex);
                    match         = regex.Match(str);
                    string s = str.Substring(1);
                    if (match.Success)
                    {
                        article.Author = str.Substring(match.Index + 1, match.Length - 2);
                        s = s.Replace(match.ToString(), "");
                    }
                    article.Title = s;
                    article.Type  = ArticleType.無;
                }
                else
                {
                    //標題, 分類
                    regex = new Regex(LiPTT.bracket_regex);
                    match = regex.Match(str);
                    if (match.Success)
                    {
                        article.Category = str.Substring(match.Index + 1, match.Length - 2).Trim();
                        str = str.Substring(match.Index + match.Length);
                        int k = 0;
                        while (k < str.Length && str[k] == ' ')
                        {
                            k++;
                        }
                        int j = str.Length - 1;
                        while (j >= 0 && str[j] == ' ')
                        {
                            j--;
                        }
                        if (k <= j)
                        {
                            article.Title = str.Substring(k, j - k + 1);
                        }
                    }
                    else
                    {
                        article.Title = str.Substring(2);
                    }
                }

                Add(article);
            }

            CurrentIndex = id - 1;

            if (CurrentIndex > 0)
            {
                more = true;
            }
            else
            {
                more = false;
            }
        }
Пример #37
0
        private void SearchBoard(PTTClient sender, LiPttEventArgs e)
        {
            Regex        regex = new Regex(@"([\w-_]+)");
            Match        match;
            ScreenBuffer screen = sender.Screen;

            switch (e.State)
            {
            case PttState.SearchBoard:
                LiPTT.PttEventEchoed -= SearchBoard;
                var msg = screen.ToString(1, 34, 20).Trim();

                match = regex.Match(msg);

                if (match.Success)
                {
                    string suggestion = msg.Substring(match.Index, match.Length);

                    var action = LiPTT.RunInUIThread(() =>
                    {
                        if (BoardAutoSuggestBox.Text.Length <= suggestion.Length)
                        {
                            RelatedTable.Add(suggestion);
                        }
                    });
                }

                ClearSearch();

                var a = LiPTT.RunInUIThread(() =>
                {
                    BoardAutoSuggestBox.ItemsSource = RelatedTable;
                });

                break;

            case PttState.RelatedBoard:

                for (int i = 3; i < 23; i++)
                {
                    string k = screen.ToString(i).Replace('\0', ' ');

                    match = regex.Match(k, 0);
                    if (match.Success)
                    {
                        RelatedTable.Add(k.Substring(match.Index, match.Length));
                    }

                    match = regex.Match(k, 22);
                    if (match.Success)
                    {
                        RelatedTable.Add(k.Substring(match.Index, match.Length));
                    }

                    match = regex.Match(k, 44);
                    if (match.Success)
                    {
                        RelatedTable.Add(k.Substring(match.Index, match.Length));
                    }
                }

                if (new Regex("按空白鍵可列出更多項目").Match(screen.ToString(23)).Success)
                {
                    LiPTT.PressSpace();
                }
                else
                {
                    LiPTT.PttEventEchoed -= SearchBoard;

                    RelatedTable.Sort();
                    ClearSearch();

                    var t = LiPTT.RunInUIThread(() =>
                    {
                        BoardAutoSuggestBox.ItemsSource = RelatedTable;
                    });
                }
                break;
            }
        }
Пример #38
0
 public Ship(ScreenBuffer SB) : base(new ConsoleEngine.Coordinate(35, 35), Graphics.ShipIcon, SB)
 {
     ShotFired = new List <Shot>();
     Buffer    = SB;
 }