Exemplo n.º 1
0
        private static void RenderAllConsoles(Game game, TCODConsole rootConsole, TCODConsole playConsole, TCODColor fogOfWarColour,
                                              TCODConsole playerConsole, TCODConsole competitorConsole,
                                              TCODConsole eventsConsole, Rectangle playBounds, Rectangle playerBounds,
                                              Rectangle competitorBounds, Rectangle eventBounds)
        {
            rootConsole.clear();
            rootConsole.setForegroundColor(ColorPresets.White);
            rootConsole.setBackgroundColor(ColorPresets.Black);

            RenderPlayConsole(game, playConsole, fogOfWarColour, playBounds);
            RenderPlayerConsole(game.Player, playerConsole, playerBounds);
            //RenderThreatConsole(game.Player, game.Actors, threatConsole, threatBounds);
            RenderCompetitorConsole(game, competitorConsole, competitorBounds);
            RenderEventsConsole(game, eventsConsole, eventBounds);

            TCODConsole.blit(playConsole, 0, 0, playBounds.Width, playBounds.Height, rootConsole, playBounds.X, playBounds.Y);
            TCODConsole.blit(playerConsole, 0, 0, playerBounds.Width, playerBounds.Height, rootConsole, playerBounds.X, playerBounds.Y);
            TCODConsole.blit(competitorConsole, 0, 0, competitorBounds.Width, competitorBounds.Height, rootConsole, competitorBounds.X, competitorBounds.Y);
            TCODConsole.blit(eventsConsole, 0, 0, eventBounds.Width, eventBounds.Height, rootConsole, eventBounds.X, eventBounds.Y);

            //playConsole.Blit(0, 0, playBounds.Width, playBounds.Height, rootConsole, playBounds.X, playBounds.Y);
            //playerConsole.Blit(0, 0, playerBounds.Width, playerBounds.Height, rootConsole, playerBounds.X,
            //                   playerBounds.Y);

            //competitorConsole.Blit(0, 0, competitorBounds.Width, competitorBounds.Height, rootConsole,
            //                       competitorBounds.X, competitorBounds.Y);
            //eventsConsole.Blit(0, 0, eventBounds.Width, eventBounds.Height, rootConsole, eventBounds.X, eventBounds.Y);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the consoles tiles to the default state of this window
        /// </summary>
        public virtual void InitializeConsole()
        {
            Vector2   screenCoords;
            TCODColor coordColor;
            Vector2   screenCenter = new Vector2(RogueGame.WindowWidth / 2, RogueGame.WindowHeight / 2);

            console.clear();

            for (int x = 0; x < console.getWidth(); x++)
            {
                for (int y = 0; y < console.getHeight(); y++)
                {
                    // Get the absolute screen coords
                    screenCoords = new Vector2(x + origin.x, y + origin.y);
                    coordColor   = Renderer.GetFadedColor(screenCoords, screenCenter, backgroundColor);

                    console.setCharBackground(x, y, coordColor);
                    DrawBorderAt(x, y, console.getWidth(), console.getHeight(), screenCoords, screenCenter);
                }
            }

            // draw the windows title
            if (title != null)
            {
                DrawText(2, 0, title, TCODColor.white);
            }
        }
Exemplo n.º 3
0
        public static TCODConsole LoadImage(string fileName)
        {
            var         transparentColor = new TCODColor(255, 0, 255);
            TCODConsole image            = null;

            try {
                using (var file = File.Open(fileName, FileMode.Open)) {
                    var decrompressedStream = new GZipStream(file, CompressionMode.Decompress);
                    var reader      = new BinaryReader(decrompressedStream);
                    var fileVersion = reader.ReadInt32();
                    var layerCount  = reader.ReadInt32();

                    // Reserving space for these in advance, so I'm not doing memory
                    // allocations repeatedly in the loop.
                    int       layerWidth = 0;
                    int       layerHeight = 0;
                    int       x, y;
                    int       characterCode = 0;
                    TCODColor foreground    = new TCODColor();
                    TCODColor background    = new TCODColor();

                    for (int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
                    {
                        layerWidth  = reader.ReadInt32();
                        layerHeight = reader.ReadInt32();
                        if (image == null)
                        {
                            image = new TCODConsole(layerWidth, layerHeight);
                            image.setBackgroundColor(transparentColor);
                            image.clear();
                            image.setKeyColor(transparentColor);
                        }

                        for (var charIndex = 0; charIndex < layerWidth * layerHeight; ++charIndex)
                        {
                            x                = charIndex / layerHeight;
                            y                = charIndex % layerHeight;
                            characterCode    = reader.ReadInt32();
                            foreground.Red   = reader.ReadByte();
                            foreground.Green = reader.ReadByte();
                            foreground.Blue  = reader.ReadByte();
                            background.Red   = reader.ReadByte();
                            background.Green = reader.ReadByte();
                            background.Blue  = reader.ReadByte();

                            // Check if the current cell is transparent.
                            if (background.NotEqual(transparentColor))
                            {
                                image.putCharEx(x, y, characterCode, foreground, background);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                Logger.Error($"Error loading file '{fileName}': {e.Message}");
            }
            return(image);
        }
Exemplo n.º 4
0
        private static void RenderPlayConsole(Game gameInstance, TCODConsole console, TCODColor fogOfWarColour, Rectangle bounds)
        {
            console.clear();
            console.setForegroundColor(ColorPresets.White);
            console.printFrame(0, 0, bounds.Width, bounds.Height, true);


            for (int y = 0; y < gameInstance.Terrain.Height; y++)
            {
                for (int x = 0; x < gameInstance.Terrain.Width; x++)
                {
                    if (gameInstance.Player.VisibilityMap[x, y].WasSeen)
                    {
                        TCODColor lightColour = new TCODColor(gameInstance.LightMap[x, y].Colour.R,
                                                              gameInstance.LightMap[x, y].Colour.G,
                                                              gameInstance.LightMap[x, y].Colour.B);

                        if (lightColour.getValue() < fogOfWarColour.getValue())
                        {
                            lightColour = fogOfWarColour;
                        }

                        console.setForegroundColor(gameInstance.Player.VisibilityMap[x, y].IsVisible
                                                      ? lightColour
                                                      : fogOfWarColour);
                        console.putChar(x + 1, y + 1, gameInstance.Terrain[x, y].Symbol);
                    }
                }
            }

            console.setForegroundColor(
                new TCODColor(gameInstance.LightMap[gameInstance.Player.Location.Coordinate].Colour.R,
                              gameInstance.LightMap[gameInstance.Player.Location.Coordinate].Colour.G,
                              gameInstance.LightMap[gameInstance.Player.Location.Coordinate].Colour.B));
            console.putChar(gameInstance.Player.Location.Coordinate.X + 1, gameInstance.Player.Location.Coordinate.Y + 1,
                            '@');

            foreach (IActor actor in gameInstance.Actors.Where(x => x != gameInstance.Player))
            {
                if (gameInstance.Player.VisibilityMap[actor.Location.Coordinate].IsVisible)
                {
                    TCODColor lightColour = new TCODColor(gameInstance.LightMap[actor.Location.Coordinate].Colour.R,
                                                          gameInstance.LightMap[actor.Location.Coordinate].Colour.G,
                                                          gameInstance.LightMap[actor.Location.Coordinate].Colour.B);

                    if (lightColour.getValue() < fogOfWarColour.getValue())
                    {
                        lightColour = fogOfWarColour;
                    }

                    console.setForegroundColor(lightColour);
                    console.putChar(actor.Location.Coordinate.X + 1, actor.Location.Coordinate.Y + 1, actor.Race.Symbol);
                }
            }
        }
Exemplo n.º 5
0
        private static void RenderPlayerConsole(IActor player, TCODConsole console, Rectangle bounds)
        {
            console.clear();
            console.setForegroundColor(ColorPresets.White);
            console.printFrame(0, 0, bounds.Width, bounds.Height, true, TCODBackgroundFlag.Set, "Player");


            console.printEx(1, 2, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, string.Format("Health : {0}", player.Health));
            console.printEx(1, 4, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, string.Format("Damage : {0}", player.Damage));
            console.printEx(1, 6, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, string.Format("Kills : {0}", player.Kills.Count));
        }
Exemplo n.º 6
0
        public void render()
        {
            map.render();

            TCODConsole.blit(lightMapConsole, 0, 0,
                             lightMapConsole.getWidth(), lightMapConsole.getHeight(), TCODConsole.root, 0, 0, 0.7F, 0.7F);
            lightMapConsole.clear();
            actorHandler.render();

            map.updateDynFov = false;
            map.updateFov    = false;
        }
Exemplo n.º 7
0
Arquivo: Fov.cs Projeto: dritory/Janus
        public override void update()
        {
            if (map.updateFov || initializeFov || owner.x != oldx || owner.y != oldy)
            {
                Map m  = map;
                int ox = owner.x - m.offsetX;
                int oy = owner.y - m.offsetY;
                if (ox >= -fovRadius * 2 && ox < m.renderWidth + fovRadius * 2 && oy >= -fovRadius * 2 && oy < m.renderHeight + fovRadius * 2)
                {
                    lightmap.clear();
                    for (int x = -mapx; x < width; x++)
                    {
                        for (int y = -mapx; y < height; y++)
                        {
                            int mx = owner.x + x;
                            int my = owner.y + y;
                            for (int i = 0; i < fovMaps.Length; i++)
                            {
                                fovMaps[i].setProperties(x + mapx, y + mapy, m.map.isTransparent(mx, my), m.map.isWalkable(mx, my));
                            }
                        }
                    }


                    if (owner.getActorHandler() != null)
                    {
                        initializeFov = false;
                    }
                }
                else
                {
                    initializeFov = true;
                }
                updateFov();
                base.update();
            }

            oldx = owner.x;
            oldy = owner.y;
        }
Exemplo n.º 8
0
        private static void RenderThreatConsole(IActor player, IList <IActor> monsters, TCODConsole console, Rectangle bounds)
        {
            console.clear();
            console.setForegroundColor(ColorPresets.White);
            console.printFrame(0, 0, bounds.Width, bounds.Height, true, TCODBackgroundFlag.Set, "Threats");

            List <IActor> threats = player.Intellect.IdentifyThreats(monsters).ToList();

            for (int i = 1; i < threats.Count; i++)
            {
                console.printEx(1, (i * 2) + 1, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, string.Format("{0} : {1}", threats[i].Race.Symbol, threats[i]));
            }
        }
Exemplo n.º 9
0
        private static void RenderCompetitorConsole(Game gameInstance, TCODConsole console, Rectangle bounds)
        {
            console.clear();
            console.setForegroundColor(ColorPresets.White);
            console.printFrame(0, 0, bounds.Width, bounds.Height, true, TCODBackgroundFlag.Set, "Competitors");


            List <IActor> competitors = gameInstance.AllActors.Where(x => x != gameInstance.Player).ToList();

            for (int i = 0; i < competitors.Count; i++)
            {
                console.setForegroundColor(competitors[i].IsAlive ? ColorPresets.White : ColorPresets.Red);
                console.printEx(1, (i * 2) + 1, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, string.Format("{0} is {1} with {2} kills", competitors[i], competitors[i].IsAlive ? "Alive" : "Dead",
                                                                                                                   competitors[i].Kills.Count));
            }
        }
Exemplo n.º 10
0
Arquivo: Game.cs Projeto: rezich/zday
        public void Draw()
        {
            TCODConsole r = TCODConsole.root;

            r.clear();

            // world box
            r.printFrame(0, 0, 47, 47);
            r.print(2, 0, "Z-DAY v0.01");
            Point offset = new Point(Player.Position.X - 23, Player.Position.Y - 23);

            Area.Current.Map.computeFov(Player.Position.X, Player.Position.Y, Player.ViewRadius, true, TCODFOVTypes.BasicFov);
            foreach (Terrain t in Area.Current.Terrain)
            {
                if (Area.Current.Map.isInFov(t.Position.X, t.Position.Y))
                {
                    t.Draw(TCODConsole.root, offset);
                }
            }
            foreach (Decal d in Area.Current.Decals)
            {
                if (Area.Current.Map.isInFov(d.Position.X, d.Position.Y))
                {
                    d.Draw(TCODConsole.root, offset);
                }
            }
            foreach (Item i in Area.Current.Items)
            {
                if (Area.Current.Map.isInFov(i.Position.X, i.Position.Y))
                {
                    i.Draw(TCODConsole.root, offset);
                }
            }
            foreach (Character c in Area.Current.Characters)
            {
                if (Area.Current.Map.isInFov(c.Position.X, c.Position.Y))
                {
                    c.Draw(TCODConsole.root, offset);
                }
            }

            DrawHUD();
            TCODConsole.flush();
        }
Exemplo n.º 11
0
        private static void RenderEventsConsole(Game gameInstance, TCODConsole console, Rectangle bounds)
        {
            console.clear();
            console.setForegroundColor(ColorPresets.White);
            console.printFrame(0, 0, bounds.Width, bounds.Height, true, TCODBackgroundFlag.Set, "Events");

            int j = gameInstance.GameEvents.Count - 1;
            int i = 1;

            if (!gameInstance.IsActive)
            {
                console.setForegroundColor(gameInstance.AllMonstersAreDead() ? ColorPresets.Gold : ColorPresets.Red);
                console.printEx(
                    1,
                    i, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, gameInstance.AllMonstersAreDead() ? "You are the last man standing!" : "You have been eliminated");
                i++;
            }

            for (; i < bounds.Height; i++)
            {
                console.setForegroundColor(ColorPresets.White);

                if ((j < 0) || (j >= gameInstance.GameEvents.Count))
                {
                    break;
                }

                while ((j >= 0) &&
                       !(gameInstance.GameEvents[j].Command is AttackCommand ||
                         gameInstance.GameEvents[j].Command is OpenDoorCommand))
                {
                    j--;
                }

                if ((j < 0) || (j >= gameInstance.GameEvents.Count))
                {
                    break;
                }
                console.printEx(1, i, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, gameInstance.GameEvents[j].Result.Message);
                j--;
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Runs at arbitrary rate: renders everything with a render component.
        /// NOTE: render does not actually draw anything to the window, it only fills out console,
        /// The TCODConsole does the actual window drawing using the data set in Render()
        /// </summary>
        private void Render()
        {
            mainConsole.clear();
            switch (engineState)
            {
            case EEngineState.Menu:
                if (currentMenuContext != null)
                {
                    renderer.DrawMenu(mainConsole, currentMenuContext);
                }
                break;

            case EEngineState.Game:
                renderer.ReDraw(mainConsole, world.currentMap);
                break;

            case EEngineState.Pause:

                break;

            default:
                break;
            }
        }
Exemplo n.º 13
0
 public static void ClearScreen()
 {
     displayConsole.clear();
 }
Exemplo n.º 14
0
        public override void DrawNewFrame(TCODConsole screen)
        {
            const int LeftThird = UIHelper.ScreenWidth / 6;
            const int RightThird = 4 * UIHelper.ScreenWidth / 6;

            if (m_enabled)
            {
                screen.clear();

                if (m_firstFrame)
                {
                    TCODConsole.resetCredits();
                    m_firstFrame = false;
                }

                if (!m_creditsDone)
                {
                    m_dialogColorHelper.SaveColors(screen);
                    m_creditsDone = TCODConsole.renderCredits(RightThird + 10, 54, true);
                    m_dialogColorHelper.ResetColors(screen);
                }

                screen.printFrame(0, 0, UIHelper.ScreenWidth, UIHelper.ScreenHeight, false, TCODBackgroundFlag.Set, "Help");

                screen.printRect(RightThird - 19, 52, 45, 7, "Copyright Chris Hamons 2010.\nThank you Ben for\nearly development help.\n\nSoli Deo Gloria");

                const int SymbolStartY = 3;
                const int SymbolVerticalOffset = -8;
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY, "Map Symbols");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 1, "------------------------");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 2, "@ - You");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 3, "; - Open Door");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 4, ": - Closed Door");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 5, "_ - Cosmetic");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 6, "& - Item on Ground");
                screen.print(LeftThird + SymbolVerticalOffset, SymbolStartY + 7, "%% - Stack of Items");

                const int ActionStartY = SymbolStartY + 10;
                const int ActionVerticalOffset = -8;
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY, "Action Keys");
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 1, "------------------------");
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 2, "Attack (or reload) - " + m_keyMappings["Attack"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 3, "Get Item           - " + m_keyMappings["GetItem"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 4, "Cast Spell         - " + m_keyMappings["CastSpell"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 5, "Inventory          - " + m_keyMappings["Inventory"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 6, "Equipment          - " + m_keyMappings["Equipment"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 7, "Skill Tree         - " + m_keyMappings["ShowSkillTree"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 8, "Show Status Effects- " + m_keyMappings["ShowEffects"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 9, "Operate            - " + m_keyMappings["Operate"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 10, "Wait               - " + m_keyMappings["Wait"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 11, "Rest Until Healed  - " + m_keyMappings["RestTillHealed"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 12, "Move To Location   - " + m_keyMappings["MoveToLocation"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 13, "View Mode          - " + m_keyMappings["ViewMode"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 14, "Down Stairs        - " + m_keyMappings["DownStairs"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 15, "Up Stairs          - " + m_keyMappings["UpStairs"]);
                screen.print(LeftThird + ActionVerticalOffset, ActionStartY + 16, "Swap Weapons       - " + m_keyMappings["SwapWeapon"]);

                const int RebindingStartY = SymbolStartY;
                string rebindingText = "To change keystroke bindings, edit KeyMappings.xml and restart magecrawl.\n\nA list of possible keys can be found at: http://tinyurl.com/ya5l8sj\n\nOther preferences can be found in Preferences.xml";
                screen.printFrame(RightThird - 12, RebindingStartY, 31, 12, true);
                screen.printRect(RightThird - 11, RebindingStartY + 1, 29, 10, rebindingText);

                const int DirectionStartY = ActionStartY + 19;
                const int DirectionVerticalOffset = -8;
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY, string.Format("Direction Keys (+{0} to Run)", (bool)Preferences.Instance["UseAltInsteadOfCtrlForRunning"] ? "Alt" : "Ctrl"));
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 1, "------------------------");
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 2, "North      - " + m_keyMappings["North"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 3, "West       - " + m_keyMappings["West"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 4, "East       - " + m_keyMappings["East"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 5, "South      - " + m_keyMappings["South"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 6, "North West - " + m_keyMappings["Northwest"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 7, "North East - " + m_keyMappings["Northeast"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 8, "South West - " + m_keyMappings["Southwest"]);
                screen.print(LeftThird + DirectionVerticalOffset, DirectionStartY + 9, "South East - " + m_keyMappings["Southeast"]);

                const int OtherKeysStartY = ActionStartY + 4;
                const int OtherKeysVerticalOffset = -12;
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY, "Other Keys");
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 1, "----------------------------");
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 2, "Text Box Page Up   - " + m_keyMappings["TextBoxPageUp"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 3, "Text Box Page Down - " + m_keyMappings["TextBoxPageDown"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 4, "Text Box Clear     - " + m_keyMappings["TextBoxClear"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 5, "Escape             - " + m_keyMappings["Escape"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 6, "Select             - " + m_keyMappings["Select"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 7, "Save               - " + m_keyMappings["Save"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 8, "Help               - " + m_keyMappings["Help"]);
                screen.print(RightThird + OtherKeysVerticalOffset, OtherKeysStartY + 9, "Quit               - " + m_keyMappings["Quit"]);
            }
        }
Exemplo n.º 15
0
        public int Run(string[] args)
        {
            fillSampleList();

            int curSample = 0; // index of the current sample
            bool first = true; // first time we render a sample
            TCODKey key = new TCODKey();
            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;
            TCODFontFlags flags = TCODFontFlags.Grayscale | TCODFontFlags.LayoutTCOD;
            TCODFontFlags 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 |= TCODFontFlags.LayoutAsciiInRow;
                }
                else if (args[i] == "-font-greyscale")
                {
                    flags = 0;
                    newFlags |= TCODFontFlags.Grayscale;
                }
                else if (args[i] == "-font-tcod")
                {
                    flags = 0;
                    newFlags |= TCODFontFlags.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");
                    return 0;
                }
            }
            if (flags == 0)
                flags = newFlags;

            if (fullscreenWidth > 0)
                TCODSystem.forceFullscreenResolution(fullscreenWidth, fullscreenHeight);

            TCODConsole.setCustomFont(font, (int)flags, numberCharsHorz, numberCharsVert);
            TCODConsole.initRoot(80, 50, "tcodlib C# sample", fullscreen, TCODRendererType.SDL);
            rootConsole = TCODConsole.root;
            sampleConsole = new TCODConsole(SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT);

            setupStaticData();
            rootConsole.setBackgroundFlag(TCODBackgroundFlag.Set);
            rootConsole.setAlignment(TCODAlignment.LeftAlignment);
            do
            {
                rootConsole.clear();
                if (!credits)
                    credits = TCODConsole.renderCredits(60, 42, false);
                for (int i = 0; i < sampleList.Length; i++)
                {
                    if (i == curSample)
                    {
                        // set colors for currently selected sample
                        rootConsole.setForegroundColor(TCODColor.white);
                        rootConsole.setBackgroundColor(TCODColor.blue);
                    }
                    else
                    {
                        // set colors for other samples
                        rootConsole.setForegroundColor(TCODColor.grey);
                        rootConsole.setBackgroundColor(TCODColor.black);
                    }
                    rootConsole.print(2, 45 - sampleList.Length + i, sampleList[i].name);
                }
                rootConsole.setForegroundColor(TCODColor.grey);
                rootConsole.setBackgroundColor(TCODColor.black);
                rootConsole.printEx(79, 46, TCODBackgroundFlag.Set, TCODAlignment.RightAlignment, "last frame : " + ((int)(TCODSystem.getLastFrameLength() * 1000)).ToString() + " ms ( " + TCODSystem.getFps() + "fps)");
                rootConsole.printEx(79, 47, TCODBackgroundFlag.Set, TCODAlignment.RightAlignment, "elapsed : " + TCODSystem.getElapsedMilli() + "ms " + (TCODSystem.getElapsedSeconds().ToString("0.00")) + "s");
                rootConsole.putChar(2, 47, (char)TCODSpecialCharacter.ArrowNorth);
                rootConsole.putChar(3, 47, (char)TCODSpecialCharacter.ArrowSouth);
                rootConsole.print(4, 47, " : select a sample");
                rootConsole.print(2, 48, "ALT-ENTER : switch to " + (TCODConsole.isFullscreen() ? "windowed mode  " : "fullscreen mode"));

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

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

                TCODConsole.flush();
                key = TCODConsole.checkForKeypress((int)TCODKeyStatus.KeyPressed);

                if (key.KeyCode == TCODKeyCode.Down)
                {
                    // down arrow : next sample
                    curSample = (curSample + 1) % sampleList.Length;
                    first = true;
                }
                else if (key.KeyCode == TCODKeyCode.Up)
                {
                    // up arrow : previous sample
                    curSample--;
                    if (curSample < 0)
                        curSample = sampleList.Length - 1;
                    first = true;
                }
                else if (key.KeyCode == TCODKeyCode.Enter && (key.LeftAlt || key.RightAlt))
                {
                    // ALT-ENTER : switch fullscreen
                    TCODConsole.setFullscreen(!TCODConsole.isFullscreen());
                }
                else if (key.KeyCode == TCODKeyCode.F1)
                {
                    System.Console.Out.WriteLine("key.pressed" + " " +
                        key.LeftAlt + " " + key.LeftControl + " " + key.RightAlt +
                        " " + key.RightControl + " " + key.Shift);
                }

            }
            while (!TCODConsole.isWindowClosed());
            return 0;
        }
Exemplo n.º 16
0
 public void Clear()
 {
     _console.clear();
 }
Exemplo n.º 17
0
 public void ClearScreen()
 {
     rootConsole.clear();
     rootConsole.setBackgroundColor(TCODColor.black);
 }
Exemplo n.º 18
0
        public new void Render(TCODConsole con)
        {
            int maxchars = con.getWidth() - 4;
            int y = 2;
            int cap_lines = 0;

            con.setBackgroundColor(TCODColor.black);
            con.setBackgroundFlag(TCODBackgroundFlag.Set);
            con.clear();
            con.setBackgroundFlag(TCODBackgroundFlag.Default);

            con.setForegroundColor(TCODColor.darkerAzure);
            con.printFrame(0, 0, con.getWidth(), con.getHeight());
            con.setForegroundColor(TCODColor.white);

            List<string> lines = new List<string>();

            lines.AddRange(wrapLine(Text, maxchars));
            cap_lines = lines.Count;

            foreach (KeyValuePair<char, string> kv in responses)
            {
                lines.Add(kv.Key + ") " + kv.Value);
            }

            for (int i = 0; i < lines.Count; i++)
            {
                con.setBackgroundFlag(TCODBackgroundFlag.Set);
                if (i - cap_lines == selectedIndex)
                    con.setBackgroundColor(TCODColor.sepia);
                else
                    con.setBackgroundColor(TCODColor.black);

                con.print(2, y+i, lines[i]);
                con.setBackgroundFlag(TCODBackgroundFlag.Default);
            }
        }