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
        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);
        }