public void DrawNewFrame(Console console)
 {
     foreach (PainterBase p in m_painters)
     {
         p.DrawNewFrame(console);
     }
 }
 private static void PrintStatus(Console console, string name, bool status, int x, int y)
 {
     console.PrintLine("Pressed " + name + " = " + (status ? "On" : "Off"), x, y, LineAlignment.Left);
 }
Exemple #3
0
 private static void PrintStatus(Console console, string name, bool status, int x, int y)
 {
     console.PrintLine("Pressed " + name + " = " + (status ? "On" : "Off"), x, y, LineAlignment.Left);
 }
Exemple #4
0
        public int Run(string[] args)
        {
            fillSampleList();

            int curSample = 0; // index of the current sample
            bool first = true; // first time we render a sample
            KeyPress key = new KeyPress();
            string font = "celtic_garamond_10x10_gs_tc.png";
            int numberCharsHorz = 32;
            int numberCharsVert = 8;
            int fullscreenWidth = 0;
            int fullscreenHeight = 0;
            bool fullscreen = false;
            bool credits = false;
            CustomFontRequestFontTypes flags = CustomFontRequestFontTypes.Grayscale | CustomFontRequestFontTypes.LayoutTCOD;
            CustomFontRequestFontTypes newFlags = 0;

            for (int i = 1; i < args.Length; i++)
            {
                if (args[i] == "-font" && ArgsRemaining(args, i, 1))
                {
                    i++;
                    font = args[i];
                }
                else if (args[i] == "-font-char-numberRows" && ArgsRemaining(args, i, 2))
                {
                    i++;
                    numberCharsHorz = System.Convert.ToInt32(args[i]);
                    i++;
                    numberCharsVert = System.Convert.ToInt32(args[i]);
                }
                else if (args[i] == "-fullscreen-resolution" && ArgsRemaining(args, i, 2))
                {
                    i++;
                    fullscreenWidth = System.Convert.ToInt32(args[i]);
                    i++;
                    fullscreenHeight = System.Convert.ToInt32(args[i]);
                }
                else if (args[i] == "-fullscreen")
                {
                    fullscreen = true;
                }
                else if (args[i] == "-font-in-row")
                {
                    flags = 0;
                    newFlags |= CustomFontRequestFontTypes.LayoutAsciiInRow;
                }
                else if (args[i] == "-font-greyscale")
                {
                    flags = 0;
                    newFlags |= CustomFontRequestFontTypes.Grayscale;
                }
                else if (args[i] == "-font-tcod")
                {
                    flags = 0;
                    newFlags |= CustomFontRequestFontTypes.LayoutTCOD;
                }
                else if (args[i] == "-help")
                {
                    System.Console.Out.WriteLine("options : \n");
                    System.Console.Out.WriteLine("-font <filename> : use a custom font\n");
                    System.Console.Out.WriteLine("-font-char-size <char_width> <char_height> : size of the custom font's characters\n");
                    System.Console.Out.WriteLine("-font-in-row : the font layout is in row instead of columns\n");
                    System.Console.Out.WriteLine("-font-tcod : the font uses TCOD layout instead of ASCII\n");
                    System.Console.Out.WriteLine("-font-greyscale : antialiased font using greyscale bitmap\n");
                    System.Console.Out.WriteLine("-fullscreen : start in fullscreen\n");
                    System.Console.Out.WriteLine("-fullscreen-resolution <screen_width> <screen_height> : force fullscreen resolution\n");

                }
            }
            if (flags == 0)
                flags = newFlags;
            CustomFontRequest fontReq = new CustomFontRequest(font, flags, numberCharsHorz, numberCharsVert);
            if (fullscreenWidth > 0)
                TCODSystem.ForceFullscrenResolution(fullscreenWidth, fullscreenHeight);

            RootConsole.Width = 80;
            RootConsole.Height = 50;
            RootConsole.WindowTitle = "tcodlib C# sample";
            RootConsole.Fullscreen = fullscreen;
            RootConsole.Font = fontReq;
            rootConsole = RootConsole.GetInstance();
            sampleConsole = RootConsole.GetNewConsole(SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT);

            setupStaticData();
            do
            {
                rootConsole.Clear();
                if (!credits)
                    credits = rootConsole.ConsoleCreditsRender(60, 42, false);
                for (int i = 0; i < sampleList.Length; i++)
                {
                    if (i == curSample)
                    {
                        // set colors for currently selected sample
                        rootConsole.ForegroundColor = (ColorPresets.White);
                        rootConsole.BackgroundColor = (ColorPresets.Blue);
                    }
                    else
                    {
                        // set colors for other samples
                        rootConsole.ForegroundColor = (ColorPresets.Gray);
                        rootConsole.BackgroundColor = ColorPresets.Black;
                    }
                    rootConsole.PrintLine(sampleList[i].name, 2, 45 - sampleList.Length + i, Background.Set, LineAlignment.Left);
                }
                rootConsole.ForegroundColor = (ColorPresets.Gray);
                rootConsole.BackgroundColor = ColorPresets.Black;
                rootConsole.PrintLine("last frame : " + ((int)(TCODSystem.LastFrameLength * 1000)).ToString() + " ms ( " + TCODSystem.FPS + "fps)", 79, 46, LineAlignment.Right);
                rootConsole.PrintLine("elapsed : " + TCODSystem.ElapsedMilliseconds + "ms " + (TCODSystem.ElapsedSeconds.ToString("0.00")) + "s", 79, 47, LineAlignment.Right);
                rootConsole.PutChar(2, 47, SpecialCharacter.ARROW_N);
                rootConsole.PutChar(3, 47, SpecialCharacter.ARROW_S);
                rootConsole.PrintLine(" : select a sample", 4, 47, LineAlignment.Left);
                rootConsole.PrintLine("ALT-ENTER : switch to " + (RootConsole.Fullscreen ? "windowed mode  " : "fullscreen mode"), 2, 48, LineAlignment.Left);

                sampleList[curSample].render(first, key);
                first = false;

                sampleConsole.Blit(0, 0, SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT, rootConsole, SAMPLE_SCREEN_X, SAMPLE_SCREEN_Y);

                rootConsole.Flush();
                key = Keyboard.CheckForKeypress(KeyPressType.Pressed);

                if (key.KeyCode == KeyCode.TCODK_DOWN)
                {
                    // down arrow : next sample
                    curSample = (curSample + 1) % sampleList.Length;
                    first = true;
                }
                else if (key.KeyCode == KeyCode.TCODK_UP)
                {
                    // up arrow : previous sample
                    curSample--;
                    if (curSample < 0)
                        curSample = sampleList.Length - 1;
                    first = true;
                }
                else if (key.KeyCode == KeyCode.TCODK_ENTER && key.Alt)
                {
                    // ALT-ENTER : switch fullscreen
                    RootConsole.Fullscreen = !RootConsole.Fullscreen;
                }
                else if (key.KeyCode == KeyCode.TCODK_F1)
                {
                    System.Console.Out.WriteLine("key.pressed" + " " +
                        key.LeftAlt + " " + key.LeftControl + " " + key.RightAlt +
                        " " + key.RightControl + " " + key.Shift);
                }

            }
            while (!rootConsole.IsWindowClosed());
            return 0;
        }
Exemple #5
0
        private void setupStaticData()
        {
            random = new TCODRandom();

            render_cols = new Color[4];
            render_cols[0] = Color.FromRGB(50, 40, 150);
            render_cols[1] = Color.FromRGB(240, 85, 5);
            render_cols[2] = Color.FromRGB(50, 35, 240);
            render_cols[3] = Color.FromRGB(10, 200, 130);

            render_dirr = new int[] { 1, -1, 1, 1 };
            render_dirg = new int[] { 1, -1, -1, 1 };
            render_dirb = new int[] { 1, 1, 1, -1 };

            off_secondary = RootConsole.GetNewConsole(SAMPLE_SCREEN_WIDTH / 2, SAMPLE_SCREEN_HEIGHT / 2);
            off_screenshot = RootConsole.GetNewConsole(SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT);
            line_bk = RootConsole.GetNewConsole(SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT);
            noise = new TCODNoise(2, noise_hurst, noise_lacunarity);
        }