public void Run()
        {
            while (true)
            {
                if (background.BackColor != null)
                {
                    screenBuffer.Clear(background.FillChar,
                                       background.CharColor, background.BackColor.Value);
                }
                else
                {
                    screenBuffer.Clear(background.FillChar,
                                       background.CharColor, ConsoleColor.Black);
                }

                var controlsToDraw = Controls.OrderBy(c => c.ZIndex);
                foreach (Control control in controlsToDraw)
                {
                    if (control.Visible)
                    {
                        control.Draw(screenGraphics);
                    }
                }

                screenBuffer.Flush();

                var keyInfo = System.Console.ReadKey(true);
                if (focusedControl != null)
                {
                    focusedControl.DispatchKeyPress(keyInfo);
                }
            }
        }
Пример #2
0
        /// <summary>フリガナ順でトップ10のキャラクターをコンソールに表示します。</summary>
        /// <param name="console">表示するコンソールを表すConsoleBuffer。</param>
        public void ShowTopFuriganaCharacters(ConsoleBuffer console)
        {
            console.Clear();

            List <BleachCharacter> characters = null;

            using (var repository = this._factory.Create())
            {
                characters = repository.GetTop10Furigana();
            }

            // データを作成する
            var result = new DataTable("NewTable from Service");// newで新たにテーブルごと作り直すと、Viewに変更通知が出される。

            result.Columns.Add("ID", typeof(long));
            result.Columns.Add("名前", typeof(string));
            result.Columns.Add("かな", typeof(string));
            result.Columns.Add("誕生日", typeof(string));
            result.Columns.Add("所属", typeof(string));
            result.Columns.Add("斬魄刀", typeof(string));

            foreach (var character in characters)
            {
                _ = result.Rows.Add(character.Id.Value, character.Name.Value, character.Furigana.Value,
                                    character.Birthday.Value, character.OrganizationName.Value,
                                    character.ZanpakutouName.Value);
            }

            console.Data.Value = result;
        }
Пример #3
0
        /// <summary>護廷十三隊別にキャラクターをコンソールに表示します。</summary>
        /// <param name="console">表示するコンソールを表すConsoleBuffer。</param>
        public void ShowCharactersByParty(ConsoleBuffer console)
        {
            console.Clear();

            List <SoulSocietyParty> parties = null;

            using (var repository = this._factory.Create())
            {
                parties = repository.GetCharactersByParty();
            }

            // データを作成する

            var result = new DataTable("NewTable from Service");// newで新たにテーブルごと作り直すと、Viewに変更通知が出される。

            result.Columns.Add("隊ID", typeof(long));
            result.Columns.Add("隊名", typeof(string));
            result.Columns.Add("ID", typeof(long));
            result.Columns.Add("名前", typeof(string));
            result.Columns.Add("斬魄刀", typeof(string));
            result.Columns.Add("卍解", typeof(string));

            foreach (SoulSocietyParty party in parties)
            {
                foreach (BleachCharacter character in party.PartyMembers)
                {
                    _ = result.Rows.Add(party.PartyId, party.PartyName, character.Id.Value, character.Name.Value,
                                        character.ZanpakutouName.Value, character.BankaiName.Value);
                }
            }

            console.Data.Value = result;
        }
Пример #4
0
        /// <summary>ID順でトップ10のキャラクターをコンソールに表示します。</summary>
        /// <param name="console">表示するコンソールを表すConsoleBuffer。</param>
        public void ShowTopIdCharacters(ConsoleBuffer console)
        {
            // bufferに残っている文字を全て削除
            console.Clear();

            IEnumerable <dynamic> characters = null;

            using (var repository = this._factory.Create())
            {
                characters = repository.GetTop10Id();
            }

            // データを作成する
            // cf.https://teratail.com/questions/82476
            var result = new DataTable("NewTable from Service");// newで新たにテーブルごと作り直すと、Viewに変更通知が出される。

            result.Columns.Add("ID", typeof(long));
            result.Columns.Add("名前", typeof(string));
            result.Columns.Add("かな", typeof(string));
            result.Columns.Add("誕生日", typeof(string));
            result.Columns.Add("所属", typeof(string));
            result.Columns.Add("斬魄刀", typeof(string));

            foreach (dynamic character in characters)
            {
                _ = result.Rows.Add(character.ID, character.CHARACTER_NAME, character.KANA,
                                    character.BIRTHDAY, character.ORGANIZATION_NAME,
                                    character.ZANPAKUTOU_NAME);
            }

            console.Data.Value = result;
        }
Пример #5
0
        public void Clear_should_reset_all_chars_to_default_value()
        {
            var cb = new ConsoleBuffer(4, 4, ConsoleColor.White, ConsoleColor.Black);
            cb.Clear();

            for (int y=0;y<4;y++)
                for (int x = 0; x < 4; x++)
                {
                    var ch = cb.Get(x, y);
                    Assert.AreEqual(' ', ch.Char);
                    Assert.AreEqual(ConsoleColor.White, ch.ForegroundColor);
                    Assert.AreEqual(ConsoleColor.Black, ch.BackgroundColor);
                }
        }
Пример #6
0
        /// <summary>Insertしたキャラクターを表示します。</summary>
        /// <param name="console">表示するコンソールを表すConsoleBuffer。</param>
        /// <returns>非同期処理の結果を表すTask。</returns>
        public async Task ShowInsertCharacterAsync(ConsoleBuffer console)
        {
            console.Clear();

            IEnumerable <BleachCharacter> newCharacters = null;

            using (var repository = this._factory.Create())
            {
                long seq = repository.GetCharacterSeq();

                using (var tran = repository.BeginTransaction())
                {
                    var characters = this.createSavesCharacters();

                    try
                    {
                        await repository.DeleteCharactersByKanaAsync(characters)
                        .ContinueWith(c => repository.RegistCharactersAsync(characters))
                        .ContinueWith(c => tran.CommitAsync());
                    }
                    catch (System.Exception)
                    {
                        tran.Rollback();
                        throw;
                    }
                }

                newCharacters = await repository.GetCharactersByIdOrverAsync(seq);
            }

            // データを作成する

            var result = new DataTable("NewTable from Service");// newで新たにテーブルごと作り直すと、Viewに変更通知が出される。

            result.Columns.Add("ID", typeof(long));
            result.Columns.Add("名前", typeof(string));
            result.Columns.Add("ふりかな", typeof(string));
            result.Columns.Add("所属", typeof(string));

            foreach (var character in newCharacters)
            {
                _ = result.Rows.Add(character.Id.Value, character.Name.Value, character.Furigana.Value,
                                    character.OrganizationName.Value);
            }

            console.Data.Value = result;
        }
Пример #7
0
        public ConsoleBuffer MapBuffer(bool temperature = false)
        {
            ConsoleBuffer buf = new ConsoleBuffer(Width, Height);

            buf.Clear();
            for (int i = 0; i < Tiles.Length; i++)
            {
                Tile t = Tiles[i];
                if (temperature)
                {
                    buf.SetPoint(TemperatureToColor(Heatmap[i]), i % Width, i / Width);
                }
                else
                {
                    buf.SetPoint(ConsoleBuffer.newCharInfo(t.Char, t.Foreground, t.Background), i % Width, i / Width);
                }
            }
            return(buf);
        }
Пример #8
0
        static void RunInterpreter(string romName)
        {
            ConsoleBuffer  console = new ConsoleBuffer();
            VmemVisualizer view    = new VmemVisualizer();

            Chip8VM inr = new Chip8Sharp.Chip8InterpreterDBG();
            var     ROM = File.ReadAllBytes(romName);

            inr.LoadBinary(ROM);

            DisassemblyProvider disasm = new DisassemblyProvider(ROM, inr.State);

            //inr.AddBreakPoint(0x268);

            byte[] OldRegisters = new byte[0x10];
            UInt16 OldI         = 0;

            while (true)
            {
                console.Clear();

                int startOffset = inr.State.PC - Console.WindowHeight;
                if (startOffset % 2 != 0)
                {
                    startOffset += 1;
                }

                for (int i = 0; i < Console.WindowHeight - 4; i++)
                {
                    UInt16 offset = (UInt16)(startOffset + i * 2);

                    if (inr.IsBreakpoint(offset))
                    {
                        console.Write(offset.ToString("X4") + " | ", ConsoleColor.Red);
                    }
                    else
                    {
                        console.Write(offset.ToString("X4") + " | ", ConsoleColor.Gray);
                    }

                    if (disasm.IsLabel(offset))
                    {
                        console.Write("off_" + offset.ToString("X4") + ":  ", ConsoleColor.Yellow);
                    }

                    var text = disasm.DisassembleLine(offset);

                    if (offset == inr.State.PC)
                    {
                        console.Write("  > ", ConsoleColor.Green);
                        console.WriteLine(text, ConsoleColor.Green);
                    }
                    else if (text.Contains("off_"))
                    {
                        var off = text.IndexOf("off_");
                        console.Write(text.Substring(0, off));
                        console.WriteLine(text.Substring(off), ConsoleColor.Yellow);
                    }
                    else
                    {
                        console.WriteLine(text);
                    }
                }

                for (int i = 0; i < 16; i++)
                {
                    console.Write($"V{i.ToString("X")}: {inr.State.Register((byte)i).ToString("X2")}   | ", inr.State.Registers.AsSpan()[i] != OldRegisters[i] ? ConsoleColor.Red : ConsoleColor.White);
                }
                console.Write($"I: {inr.State.I.ToString("X4")}   |", inr.State.I != OldI ? ConsoleColor.Red : ConsoleColor.White);
                console.Write($"PC: {inr.State.PC.ToString("X4")}   |");
                console.Write($"SP: {inr.State.SP.ToString("X4")}   |");
                console.Write($"DT: {inr.State.DT.ToString("X2")}   |");
                console.Write($"ST: {inr.State.ST.ToString("X2")}   |");

                console.WriteLine("");

                OldRegisters = inr.State.Registers.AsSpan().ToArray();
                OldI         = inr.State.I;

                console.Write("Space: ", ConsoleColor.Cyan);
                console.Write("step  ");
                console.Write("Q: ", ConsoleColor.Cyan);
                console.Write("run  ");
                console.Write("Z: ", ConsoleColor.Cyan);
                console.Write("run 5  ");
                console.Write("X: ", ConsoleColor.Cyan);
                console.Write("run 10  ");
                console.Write("C: ", ConsoleColor.Cyan);
                console.Write("run 15  ");
                console.Write("V: ", ConsoleColor.Cyan);
                console.Write("run 30  ");
                console.Write("N: ", ConsoleColor.Cyan);
                console.Write("run to jump  ");
                console.Write("B: ", ConsoleColor.Cyan);
                console.Write("toggle BP  ");
                console.Write("P: ", ConsoleColor.Cyan);
                console.Write("Break in VS ");
                console.Write("M: ", ConsoleColor.Cyan);
                console.Write("Disasm RAM ", disasm.DisassembleRam ? ConsoleColor.Green : ConsoleColor.White);

                console.Display();
                if (inr.CheckVMEMUpdate())
                {
                    view.Draw(inr);
                }

ReadAgain:
                switch (Console.ReadKey(true).Key)
                {
                case ConsoleKey.P:
                    Debugger.Break();
                    inr.StepInto();
                    break;

                case ConsoleKey.Spacebar:
                    inr.StepInto();
                    break;

                case ConsoleKey.Q:
                    inr.Run();
                    break;

                case ConsoleKey.Z:
                    inr.Run(5);
                    break;

                case ConsoleKey.X:
                    inr.Run(10);
                    break;

                case ConsoleKey.C:
                    inr.Run(15);
                    break;

                case ConsoleKey.V:
                    inr.Run(30);
                    break;

                case ConsoleKey.N:
                    inr.BreakOnJump = true;
                    inr.Run();
                    break;

                case ConsoleKey.M:
                    disasm.DisassembleRam = !disasm.DisassembleRam;
                    continue;

                case ConsoleKey.B:
                    var bp = ReadBreakPoint();
                    if (inr.IsBreakpoint(bp))
                    {
                        inr.RemovBreakPoint(bp);
                    }
                    else
                    {
                        inr.AddBreakPoint(bp);
                    }
                    console.UnbufferedClear();
                    continue;

                default:
                    goto ReadAgain;
                }
            }
        }
Пример #9
0
 /// <summary>
 /// Clear a screen by filling it with specified color.
 /// </summary>
 /// <param name="fillColor">Color to fill the screen.</param>
 public override void Clear(Color fillColor)
 {
     consoleBuffer.Clear(' ', ConsoleColor.Black, ColorHelper.ToConsole(fillColor));
 }
Пример #10
0
        public void Show(GameClient client, IPEndPoint ep)
        {
            buffer.SetCursorPosition(10, 3);
            buffer.ForegroundColor = ConsoleColor.Gray;
            buffer.InsertBuffer(headline, 26, 4);
            string ip = ep.Address.ToString();

            buffer.SetCursorPosition((80 - ip.Length) / 2, 8);
            buffer.Write(ip);
            buffer.DrawSelf();

            Console.SetCursorPosition(26, 12);
            Console.ForegroundColor = SelectedColor;
            Console.Write(pretoken);
            Console.ResetColor();
            Console.BackgroundColor = SelectedColor;
            Console.Write("Cancel");
            Console.ResetColor();

            client.Connect(ep);



            long starttime = Program.Time;

            while (true)
            {
                double        time   = Program.Time / 120.0;
                ConsoleBuffer slider = new ConsoleBuffer(headline.Width, 1);
                //slider.BackgroundColor = ConsoleColor.DarkBlue;
                slider.Clear();

                string s = "██████";
                slider.DrawText(s, (int)(0.55 * Math.Sin(time) * slider.Width + 0.5 * slider.Width) - s.Length / 2, 0, this.SelectedColor, ConsoleColor.Black);

                slider.DrawText(" ", 0, 0, ConsoleColor.Black, ConsoleColor.White);
                slider.DrawText(" ", slider.Width - 1, 0, ConsoleColor.Black, ConsoleColor.White);
                slider.DrawSelf(26, 10);
                Thread.Sleep(20);

                if (Console.KeyAvailable)
                {
                    if (Console.ReadKey(true).Key == ConsoleKey.Enter)
                    {
                        client.Close();
                        return;
                    }
                }

                if (client.Connected)
                {
                    break;
                }

                if (starttime < Program.Time - 20 * 1000)
                {
                    client.ErrorMessage = "Connection timed out.";
                    break;
                }
            }

            Console.SetCursorPosition(26, 10);
            Console.Write("Connected! Logging in...");
            //buffer.DrawSelf();
            buffer.SetCursorPosition(26, 11);

            // waits for client to finish stuff
            client.Sync();

            if (client.LoggedIn)
            {
                try
                {
                    client.LobbyMenu.Show();
                }
                catch (Exception e)
                {
                    client.ErrorMessage = e.Message;
                }
            }

            if (!(client.LoggedIn && client.Connected))
            {
                Items[0] = proitems1[0] + " " + client.ErrorMessage;
                this.ReadMenu();
            }
            client.Close();
        }
Пример #11
0
        public void Show()
        {
            client = new GameClient();

            if (File.Exists("player.char"))
            {
                client.Character = PlayerCharacter.ReadFromFile("player.char");
            }

            while (true)
            {
                buffer = new ConsoleBuffer();

                ConsoleColor logo1 = ConsoleColor.Red, logo2 = ConsoleColor.DarkCyan, black = ConsoleColor.Black;

                buffer.Clear();
                buffer.ForegroundColor = logo1;
                buffer.Write("\n" +
                             "              ██░ ██  █    ██  ███▄    █   ▄████ ▓█████  ██▀███  \n" +
                             "             ▓██░ ██▒ ██  ▓██▒ ██ ▀█   █  ██▒ ▀█▒▓█   ▀ ▓██ ▒ ██▒\n" +
                             "             ▒██▀▀██░▓██  ▒██░▓██  ▀█ ██▒▒██░▄▄▄░▒███   ▓██ ░▄█ ▒\n" +
                             "             ░▓█ ░██ ▓▓█  ░██░▓██▒  ▐▌██▒░▓█  ██▓▒▓█  ▄ ▒██▀▀█▄  \n" +
                             "             ░▓█▒░██▓▒▒█████▓ ▒██ ░  ▓██░░▒▓███▀▒░▒████▒░██▓ ▒██▒\n" +
                             "              ▒ ░░▒░▒░▒▓▒ ▒ ▒ ░ ▒ ░  ▒ ▒  ░▒   ▒ ░░ ▒░ ░░ ▒▓ ░▒▓░\n" +
                             "              ▒ ░▒░ ░░░▒░ ░░░ ░ ░ ▒  ░ ▒░  ░   ░  ░ ░  ░  ░▒ ░ ▒░\n" +
                             "              ░  ░░ ░ ░░░ ░ ░    ░░  ░ ░ ░ ░   ░    ░     ░░   ░ \n" +
                             "              ░  ░  ░   ░              ░       ░    ░  ░   ░     \n"
                             );

                if (true)
                {
                    buffer.SetCursorPosition(0, buffer.CursorTop - 3);
                    string online =
                        "                ██████╗ ███╗   ██╗██╗     ██╗███╗   ██╗███████╗\n" +
                        "               ██╔═══██╗████╗  ██║██║     ██║████╗  ██║██╔════╝\n" +
                        "               ██║   ██║██╔██╗ ██║██║     ██║██╔██╗ ██║█████╗  \n" +
                        "               ██║   ██║██║╚██╗██║██║     ██║██║╚██╗██║██╔══╝  \n" +
                        "               ╚██████╔╝██║ ╚████║███████╗██║██║ ╚████║███████╗\n" +
                        "                ╚═════╝ ╚═╝  ╚═══╝╚══════╝╚═╝╚═╝   ╚══╝╚══════╝\n"
                    ;

                    int X = buffer.CursorLeft, Y = buffer.CursorTop;
                    for (int i = 0; i < online.Length; i++)
                    {
                        int x = i % (online.Length / 6) + X, y = i / (online.Length / 6) + Y;
                        ConsoleBuffer.CharInfo ci = buffer[x, y];
                        char overchar             = ' ';
                        if (ci.Char.AsciiChar == ConsoleBuffer.ASCII.IndexOf('░'))
                        {
                            overchar = '▒';
                        }
                        if (ci.Char.AsciiChar == ConsoleBuffer.ASCII.IndexOf('▒'))
                        {
                            overchar = '▓';
                        }


                        char online_char = online[i];
                        if (online_char == '\n')
                        {
                            online_char = ' ';
                        }

                        if (online_char == '█')
                        {
                            buffer.DrawText(overchar.ToString(), x, y, logo1, logo2);
                        }
                        else if (online_char == ' ')
                        {
                            buffer.DrawText(" ", x, y, logo2, black);
                        }
                        else
                        {
                            buffer.DrawText(online_char.ToString(), x, y, logo2, overchar != ' ' ? black : black);
                        }
                    }
                }


                buffer.SetCursorPosition(35, buffer.CursorTop + 7);
                int selected = this.ReadMenu();

                if (selected == 0)
                {
                    GameServer server = new GameServer();
                    server.LoadAssets();
                    new MapPreviewMenu().Show(server, client);
                }
                if (selected == 1)
                {
                    bool      valid  = true;
                    string    result = "";
                    IPAddress ip     = null;
                    int       port   = GameServer.DEFAULT_PORT;
                    InputBox.Show("Enter IP address", ref result);

                    if (result.Contains(':'))
                    {
                        if (int.TryParse(result.Split(':')[1], out port))
                        {
                            result = result.Split(':')[0];
                        }
                        else
                        {
                            valid = false;
                        }
                    }

                    if (IPAddress.TryParse(result, out ip))
                    {
                        IPEndPoint ep = new IPEndPoint(ip, port);
                        new ConnectingMenu().Show(client, ep);
                    }
                    else
                    {
                        valid = false;
                    }

                    if (!valid)
                    {
                        MessageBox.Show("Invalid IP address format.", MessageBox.Buttons.OK);
                    }
                }
                if (selected == 3)
                {
                    new SettingsMenu().Show(client);
                }
                if (selected == Items.Length - 1)
                {
                    ConsoleBuffer.Fullscreen = false;
                    return;
                }
            }
        }
Пример #12
0
 public override void Clear()
 {
     Buffer.Clear();
 }