Exemplo n.º 1
0
        public void Draw(TCODConsole screen)
        {
            const int LinesInTextConsole = TextBoxHeight - 2;
            screen.printFrame(0, TextBoxYPosition, TextBoxWidth, TextBoxHeight, true);

            if (m_textList.Count == 0)
                return;        // No Text == Nothing to Draw.

            // Draw either all the text, or all that will fit
            int numberToDraw = ((m_textList.Count - m_textBoxPosition) < LinesInTextConsole) ?
                (m_textList.Count - m_textBoxPosition) : LinesInTextConsole;

            int currentElement = 0;
            for (int i = 0; i < LinesInTextConsole; ++i)
            {
                if (currentElement == numberToDraw)
                    break;
                
                string currentString = m_textList[m_textBoxPosition + currentElement];
                
                // If it's over 1 line long, we treat it special. See if it will be early.
                int numberOfLinesLong = screen.getHeightRect(1, TextBoxYPosition, TextBoxWidth - 2, 8, currentString);

                if (numberOfLinesLong > 1)
                {
                    i += numberOfLinesLong - 1;
                    if (i >= LinesInTextConsole)
                        break;
                    screen.printRect(1, TextBoxYPosition + LinesInTextConsole - i, TextBoxWidth - 2, numberOfLinesLong, currentString);
                }
                else
                {
                    screen.print(1, TextBoxYPosition + LinesInTextConsole - i, currentString);
                }
                currentElement++;
            }
        }
Exemplo n.º 2
0
 public int WriteString(TCODConsole console, int x, int y, string msg, TCODColor col)
 {
     console.setForegroundColor(col);
     return console.printRect(x, y, console.getWidth()-2, 0, msg);
 }
Exemplo n.º 3
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.º 4
0
        private void DrawSkillPopup(TCODConsole console, List<ISkill> selectedSkillList, int skillPointsLeft, SkillSquare cursorSkillSquare, ISkill cursorOverSkill, Point cursorPosition)
        {
            Point drawUpperLeft = ConvertGridToDrawCoord(cursorSkillSquare.UpperRight + new Point(1, 1), cursorPosition);
            
            int numberOfDependencies = cursorSkillSquare.DependentSkills.Count();
            int dialogHeight = ExplainPopupHeight;
            if (numberOfDependencies > 0)
            {
                int linesOfDependencies = numberOfDependencies;
                foreach (string dependentSkillName in cursorSkillSquare.DependentSkills)
                    linesOfDependencies += console.getHeightRect(drawUpperLeft.X + 2 + 3, 0, 20, 2, dependentSkillName);
                
                dialogHeight += 2 + linesOfDependencies;
                drawUpperLeft += new Point(0, 2 + linesOfDependencies);
            }

            string title = cursorOverSkill.Name;
            if (title.Length > 22)
                title = title.Substring(0, 22);

            console.printFrame(drawUpperLeft.X, drawUpperLeft.Y - dialogHeight, ExplainPopupWidth, dialogHeight, true, TCODBackgroundFlag.Set, title);

            int textX = drawUpperLeft.X + 2;
            int textY = drawUpperLeft.Y - dialogHeight + 2;

            // If we can't afford it and it isn't already selected, show the cost in red
            if (!selectedSkillList.Contains(cursorOverSkill) && cursorOverSkill.Cost > skillPointsLeft)
            {
                m_dialogHelper.SaveColors(console);
                console.setForegroundColor(TCODColor.red);
                console.print(textX, textY, string.Format("Skill Point Cost: {0}", cursorOverSkill.Cost));
                m_dialogHelper.ResetColors(console);
            }
            else
            {
                console.print(textX, textY, string.Format("Skill Point Cost: {0}", cursorOverSkill.Cost));
            }
            textY++;

            if (numberOfDependencies > 0)
            {
                textY++;
                console.print(textX, textY, "Dependencies:");
                textY++;
                m_dialogHelper.SaveColors(console);
                foreach (string dependentSkillName in cursorSkillSquare.DependentSkills)
                {
                    if (SkillTreeModelHelpers.IsSkillSelected(selectedSkillList, dependentSkillName))
                        m_dialogHelper.SetColors(console, false, true);
                    else
                        m_dialogHelper.SetColors(console, false, false);

                    console.printRect(textX + 3, textY, 20, 2, dependentSkillName);
                    textY++;
                }
                m_dialogHelper.ResetColors(console);
            }
            textY++;

            console.printRectEx(textX, textY, ExplainPopupWidth - 4, ExplainPopupHeight - 6, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, cursorOverSkill.Description);
        }
Exemplo n.º 5
0
        public override void DrawNewFrame(TCODConsole screen)
        {
            screen.printFrame(StartingX, 0, InfoWidth, InfoHeight, true);
            screen.printEx(SectionCenter, 1, TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, m_name);

            // The 7 and 18 here are psydo-magical, since they place the text overlap just so it fits and doesn't go over for sane values
            screen.printEx(StartingX + 7, 2, TCODBackgroundFlag.None, TCODAlignment.CenterAlignment, m_healthString);
            screen.printEx(StartingX + 18, 2, TCODBackgroundFlag.None, TCODAlignment.CenterAlignment, m_staminaString);
            for (int j = 0; j < BarLength; ++j)
                screen.setCharBackground(StartingX + 2 + j, 2, PlayerHealthBarColorAtPosition(j));

            screen.printEx(StartingX + 13, 3, TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, m_manaString);
            for (int j = 0; j < BarLength; ++j)
                screen.setCharBackground(StartingX + 2 + j, 3, PlayerManaBarColor(j));

            int nextAvailablePosition = 6;

            string skillPointString = "Skill Points: " + m_skillPoints;
            screen.print(StartingX + 2, nextAvailablePosition, skillPointString);
            nextAvailablePosition += 2;

            int linesTaken = screen.printRect(StartingX + 2, nextAvailablePosition, UIHelper.ScreenWidth - StartingX - 3, 5, m_weaponString);
            nextAvailablePosition += linesTaken + 1;

            m_colorHelper.SaveColors(screen);
            if (m_statusEffects.Count() > 0)
            {
                screen.print(StartingX + 2, nextAvailablePosition, "Status Effects:");
                int currentX = StartingX + 2 + 1 + 15;
                foreach (IStatusEffect s in m_statusEffects)
                {
                    if (currentX + s.Name.Length >= UIHelper.ScreenWidth)
                    {
                        currentX = StartingX + 2;
                        nextAvailablePosition++;
                    }
                    screen.setForegroundColor(s.IsPositiveEffect ? ColorCache.Instance["DarkGreen"] : ColorCache.Instance["DarkRed"] );
                    screen.print(currentX, nextAvailablePosition, s.Name);
                    currentX += s.Name.Length + 1;
                }
                nextAvailablePosition += 2;
            }
            m_colorHelper.ResetColors(screen);

            m_colorHelper.SaveColors(screen);
            if (m_monstersNearby.Count > 0)
            {
                screen.print(StartingX + 2, nextAvailablePosition, m_nearbyEnemyString);
                
                // Show at most 8 monsters
                int numberOfMonstersToShow = m_monstersNearby.Count > 8 ? 8 : m_monstersNearby.Count;
                for (int i = 0; i < numberOfMonstersToShow; ++i)
                {
                    ICharacter currentMonster = m_monstersNearby[i];
                    if (MapCursorEnabled)
                    {
                        if (currentMonster.Position == CursorSpot)
                            screen.setForegroundColor(ColorCache.Instance["DarkYellow"]);
                        else
                            screen.setForegroundColor(UIHelper.ForegroundColor);
                    }

                    screen.printEx(StartingX + 12, nextAvailablePosition + 1 + i, TCODBackgroundFlag.Set, TCODAlignment.CenterAlignment, currentMonster.Name);
                    for (int j = 0; j < HealthBarLength(currentMonster, true); ++j)
                        screen.setCharBackground(StartingX + 2 + j, nextAvailablePosition + 1 + i, EnemyHealthBarColor(currentMonster));
                }
                nextAvailablePosition += 2;
            }
            m_colorHelper.ResetColors(screen);

            if (Preferences.Instance.DebuggingMode)
            {
                screen.print(54, 39, "Turn Count - " + m_turnCount.ToString());

                screen.print(54, 40, "Danger - " + m_inDanger.ToString());

                string level = (m_currentLevel + 1).ToString();
                screen.print(54, 41, "Level - " + level);

                string position = m_position.ToString();
                screen.print(54, 42, position);

                string fps = TCODSystem.getFps().ToString();
                screen.print(54, 43, fps);
            }
        }
Exemplo n.º 6
0
 public int PrintString(Rectangle rect, string text, params object[] args)
 {
     return(_console.printRect(rect.X, rect.Y, rect.Width, rect.Height, string.Format(text, args)));
 }
Exemplo n.º 7
0
 public static void DrawString(IntVector2 pos, int width, string str)
 {
     displayConsole.printRect(pos.X, pos.Y, width, 0, str);
 }
Exemplo n.º 8
0
        private void DrawItemInRightPane(TCODConsole screen)
        {
            int x = SelectedItemOffsetX + ((SelectedItemWidth * 2) / 6) + 2;
            int y = SelectedItemOffsetY + 4;
            int w = ((SelectedItemWidth * 2) / 3) - 4;
            int h = SelectedItemHeight - 6;

            string itemDescription = m_selectedItem.ItemDescription + "\n\n" + m_selectedItem.FlavorDescription;
            y += screen.printRect(x, y, w, h, itemDescription);
            y += 2;

            IConsumable asConsumable = m_selectedItem as IConsumable;
            if (asConsumable != null && asConsumable.MaxCharges > 1)
            {
                screen.print(x, y, string.Format("Charges: {0} of {1}", asConsumable.Charges, asConsumable.MaxCharges));
                y++;
            }

            IArmor asArmor = m_selectedItem as IArmor;
            if (asArmor != null)
            {
                screen.print(x, y, "Stamina Bonus: " + asArmor.StaminaBonus);
                y += 2;
                screen.print(x, y, "Evade: " + asArmor.Evade);
                y += 2;

                IList<EquipArmorReasons> armorReasons = m_player.CanNotEquipArmorReasons(asArmor);
                if (armorReasons.Contains(EquipArmorReasons.Weight))
                {
                    m_dialogColorHelper.SaveColors(screen);
                    screen.setForegroundColor(TCODColor.red);
                    screen.print(x, y, "Weight: " + asArmor.Weight);
                    y += 2;
                    m_dialogColorHelper.ResetColors(screen);
                }
                else
                {
                    screen.print(x, y, "Weight: " + asArmor.Weight);
                    y += 2;
                }

                if (armorReasons.Contains(EquipArmorReasons.RobesPreventBoots) || armorReasons.Contains(EquipArmorReasons.BootsPreventRobes))
                {
                    m_dialogColorHelper.SaveColors(screen);
                    screen.setForegroundColor(TCODColor.red);
                    string outputString = armorReasons.Contains(EquipArmorReasons.RobesPreventBoots) ? "Robes prevent boots from being worn." : "Boots prevent robes from being worn.";
                    screen.print(x, y, outputString);
                    y += 2;
                    m_dialogColorHelper.ResetColors(screen);
                }
            }

            IWeapon asWeapon = m_selectedItem as IWeapon;
            if (asWeapon != null)
            {
                m_dialogColorHelper.SaveColors(screen);                
                if (!m_player.CanEquipWeapon(asWeapon))
                    screen.setForegroundColor(TCODColor.red);
                screen.print(x, y, "Type : " + asWeapon.Type);
                m_dialogColorHelper.ResetColors(screen);

                y += 2;
                screen.print(x, y, "Damage: " + asWeapon.Damage);

                y += 2;
                screen.print(x, y, "Speed: " + asWeapon.CTCostToAttack);
            }
        }