Ejemplo n.º 1
0
 /// <summary>
 /// Create the root console with custom font
 /// </summary>
 /// <param name="w">Width in characters</param>
 /// <param name="h">Height in characters</param>
 /// <param name="title">Title of window</param>
 /// <param name="fullscreen">Fullscreen?</param>
 /// <param name="font">Custom font request</param>
 private RootConsole(int w, int h, String title, bool fullscreen, CustomFontRequest font)
     : base(IntPtr.Zero, w, h)
 {
     TCOD_console_set_custom_font(new StringBuilder(font.m_fontFile), font.m_char_width,
                                  font.m_char_height, (int)font.m_type);
     TCOD_console_init_root(w, h, new StringBuilder(title), fullscreen);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Create the root console with custom font
 /// </summary>
 /// <param name="w">Width in characters</param>
 /// <param name="h">Height in characters</param>
 /// <param name="title">Title of window</param>
 /// <param name="fullscreen">Fullscreen?</param>
 /// <param name="font">Custom font request</param>
 private RootConsole(int w, int h, String title, bool fullscreen, CustomFontRequest font)
     : base(IntPtr.Zero, w, h)
 {
     TCOD_console_set_custom_font(new StringBuilder(font.m_fontFile), (int)font.m_type, font.m_numberCharHoriz,
                                  font.m_numberCharVert);
     TCOD_console_init_root(w, h, new StringBuilder(title), fullscreen);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Create the root console with custom font
 /// </summary>
 /// <param name="w">Width in characters</param>
 /// <param name="h">Height in characters</param>
 /// <param name="title">Title of window</param>
 /// <param name="fullscreen">Fullscreen?</param>
 /// <param name="font">Custom font request</param>
 private RootConsole(int w, int h, String title, bool fullscreen, CustomFontRequest font)
     : base(IntPtr.Zero, w, h)
 {
     TCOD_console_set_custom_font(new StringBuilder(font.m_fontFile), font.m_char_width,
         font.m_char_height, (int)font.m_type);
     TCOD_console_init_root(w, h, new StringBuilder(title), fullscreen);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Create the root console with custom font
 /// </summary>
 /// <param name="w">Width in characters</param>
 /// <param name="h">Height in characters</param>
 /// <param name="title">Title of window</param>
 /// <param name="fullscreen">Fullscreen?</param>
 /// <param name="font">Custom font request</param>
 private RootConsole(int w, int h, String title, bool fullscreen, CustomFontRequest font)
     : base(IntPtr.Zero, w, h)
 {
     TCOD_console_set_custom_font(new StringBuilder(font.m_fontFile), (int)font.m_type, font.m_numberCharHoriz,
         font.m_numberCharVert);
     TCOD_console_init_root(w, h, new StringBuilder(title), fullscreen);
 }
Ejemplo n.º 5
0
        //Setup the screen
        public void InitialSetup()
        {
            int tileSize = 16;

            try
            {
                tileSize = Convert.ToInt16(Game.Config.Entries["tilesize"]);
            }
            catch (Exception)
            {
                LogFile.Log.LogEntryDebug("Error getting tilesize from config file", LogDebugLevel.High);
            }

            string tileMapFilename = "FileSupport.dll";
            if(tileSize == 32)
                tileMapFilename = "StreamSupport.dll";

            //CustomFontRequest fontReq = new CustomFontRequest("tallfont.png", 8, 16, CustomFontRequestFontTypes.LayoutAsciiInColumn);
            CustomFontRequest fontReq = new CustomFontRequest(tileMapFilename, tileSize, tileSize, CustomFontRequestFontTypes.LayoutAsciiInRow);
            //CustomFontRequest fontReq = new CustomFontRequest("tallfont.png", 8, 16, CustomFontRequestFontTypes.LayoutAsciiInColumn);
            //CustomFontRequest fontReq = new CustomFontRequest("tallfont.png", 8, 16, CustomFontRequestFontTypes.LayoutAsciiInColumn);
            //CustomFontRequest fontReq = new CustomFontRequest("shroom_moved_big.png", 32, 32, CustomFontRequestFontTypes.LayoutAsciiInRow);
            //CustomFontRequest fontReq = new CustomFontRequest("shroom_moved.png", 16, 16, CustomFontRequestFontTypes.LayoutAsciiInRow);
            //CustomFontRequest fontReq = new CustomFontRequest("Anikki_square_20x20.bmp", 20, 20, CustomFontRequestFontTypes.LayoutAsciiInRow);
            //CustomFontRequest fontReq = new CustomFontRequest("Markvii.png", 12, 12, CustomFontRequestFontTypes.LayoutAsciiInRow);
            //CustomFontRequest fontReq = new CustomFontRequest("Tahin_16x16_rounded.png", 16, 16, CustomFontRequestFontTypes.LayoutAsciiInRow);
            //CustomFontRequest fontReq = new CustomFontRequest("msgothic.png", 16, 16, CustomFontRequestFontTypes.LayoutAsciiInRow);
            RootConsole.Width = Width;
            RootConsole.Height = Height;
            RootConsole.WindowTitle = "TraumaRL";
            RootConsole.Fullscreen = false;
            RootConsole.Font = fontReq;
            /*
            RootConsole rootConsole = RootConsole.GetInstance();

            rootConsole.PrintLine("Hello world!", 30, 30, LineAlignment.Left);
            rootConsole.Flush();
            */
            Console.WriteLine("debug test message.");
        }
Ejemplo n.º 6
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;
        }