void addWinInfoToTextbox(Textbox * tb)
{
    addBoldString(tb, "       Congratulations!       ");
    addString(tb,     "           You win!           ");
    addString(tb,     "You can continue game or quit.");
    addEnter(tb);
    addString(tb,     "(press q to hide this message)");
}
// public virtual [base kpCommand]
void kpToolTextEnterCommand::execute ()
{
    viewManager ()->setTextCursorPosition (m_row, m_col);
    int oldNumEnters = m_numEnters;
    m_numEnters = 0;

    for (int i = 0; i < oldNumEnters; i++)
        addEnter ();
}
void addHelpInfoToTextbox(Textbox * tb)
{
    addBoldString(tb, "Welcome to SimpleCiv help!");
    addString(tb, "This is simple guide for this game. Use up/down arrow keys to scroll this text.");
    addString(tb, "More info about game you can find here: http://melkogotto.github.com/SimpleCiv/");
    addString(tb, "Press q to hide this help.");
    addEnter(tb);

    addBoldString(tb, "SimpleCiv in nutshell:");
    addString(tb, "* SimpleCiv is Civilization game clone. You can build cities, hire units, explore new lands and fight!");
    addString(tb, "* Main window is map window. You can scroll map, choose your units and move them. Also you can select any your city.");
    addString(tb, "* By pressing Space key on the city you can open city hiring dialog, where you can hire units in this city.");
    addString(tb, "* By pressing T key you can open research dialog, where you can start researhes.");
    addString(tb, "* All keys' bindings you can find below.");
    addEnter(tb);

    // Map window.
    addBoldString(tb, "Map:");
    addString(tb, "Arrow keys       Move unit/cursor.");
    addString(tb, "Enter            End turn.");
    addString(tb, "Space            Choose unit to move or open city hiring dialog.");
    addString(tb, "c                Create city (if settler is selected).");
    addString(tb, "b                Cut the forest (if lumberjack is selected).");
    addString(tb, "m                Build a mine (if miner is selected).");
    addString(tb, "t                Open research dialog.");
    addString(tb, "h                Show this help.");
    addString(tb, "i                Show unit information.");
    addString(tb, "n                Show next unit (if selected) or next city.");
    addString(tb, "q                Quit game.");
    addEnter(tb);

    // Hiring dialog.
    addBoldString(tb, "Hiring dialog:");
    addString(tb, "Up/down keys     Choose unit.");
    addString(tb, "Enter            Start hiring (will terminate current hiring).");
    addString(tb, "q                Quit to map.");
    addEnter(tb);

    // Research dialog.
    addBoldString(tb, "Research dialog:");
    addString(tb, "Up/down keys     Choose technology.");
    addString(tb, "Enter            Start research (will terminate current research).");
    addString(tb, "q                Quit to map.");
}
kpToolTextEnterCommand::kpToolTextEnterCommand (const QString &name,
    int row, int col, Action action,
    kpCommandEnvironment *environ)
    : kpNamedCommand (name, environ),
      m_row (row), m_col (col),
      m_numEnters (0)
{
    viewManager ()->setTextCursorPosition (m_row, m_col);

    if (action == AddEnterNow)
        addEnter ();
}
void addUnitInfoToTextbox(Textbox * tb, World * world, View * view)
{
    // Getting unit.
    Node * n = getNeighbour(view -> current_cell, EDGE_CELL_UNIT);
    Unit * u = (Unit *) n -> data;
    UnitCommonInfo * u_info = (UnitCommonInfo *) daGetByIndex(world -> units_info, u -> unit_id);

    // Add unit info.
    addBoldString(tb, u_info -> name);
    addEnter(tb);

    addString(tb, "Symbol       %c", u_info -> c);
    addEnter(tb);

    addString(tb, "Health       %d", u_info -> max_health);
    addString(tb, "Damage       %d", u_info -> max_damage);
    addString(tb, "Moves        %d", u_info -> max_moves);
    addEnter(tb);

    addString(tb, "Hiring turns %d", u_info -> hiring_turns);
    addEnter(tb);

    addString(tb, "Gold drop    %d", u_info -> gold_drop);
    addEnter(tb);

    addString(tb, "Requires for hiring:");
    if(u_info -> resources == NULL || u_info -> resources -> length == 0)
    {
        addString(tb, "    Nothing");
    }
    else
    {
        for(int i = 0; i < u_info -> resources -> length; i++)
        {
            int r = iaGetByIndex(u_info -> resources, i);
            for(int j = 0; j < CELL_RES_COUNT; j++)
            {
                if(VIEW_RES_VALUES[j] == r)
                {
                    addString(tb, "    %s", VIEW_RES_NAMES[j]);
                    break;
                }
            }
        }
    }

    addEnter(tb);

    addString(tb, "Privileges:");
    if(u_info -> privileges == NULL || u_info -> privileges -> length == 0)
    {
        addString(tb, "    Nothing");
    }
    else
    {
        for(int i = 0; i < u_info -> privileges -> length; i++)
        {
            int r = iaGetByIndex(u_info -> privileges, i);
            for(int j = 0; j < UNIT_PRVL_COUNT; j++)
            {
                if(VIEW_PRVL_VALUES[j] == r)
                {
                    addString(tb, "    %s", VIEW_PRVL_NAMES[j]);
                    break;
                }
            }
        }
    }
}