Пример #1
0
/**
 *  Konstruktor von @p IngameWindow.
 *
 *  @author OLiver
 */
IngameWindow::IngameWindow(unsigned int id, unsigned short x, unsigned short y, unsigned short width, unsigned short height, const std::string& title, glArchivItem_Bitmap* background, bool modal, bool close_on_right_click)
    : Window(x, y, id, NULL, width, height),
      iwHeight(height), title(title), background(background), last_x(0), last_y(0),
      last_down(false), last_down2(false), modal(modal), closeme(false), minimized(false), move(false), close_on_right_click(close_on_right_click)
{
    memset(button_state, BUTTON_UP, sizeof(ButtonState) * 2);

    // Load last position or center the window
    if(x == 0xFFFF)
    {
        MoveToCenter();

        if(id < MAX_POS_SAVE_ENTRIES)
        {
            Point<unsigned short> pos = last_pos[id];
            if(pos.x != 0xffff)
            {
                Move(pos.x, pos.y);
            }
        }


    }
    else if(x == 0xFFFE)
    {
        MoveNextToMouse();
    }
}
Пример #2
0
IngameWindow::IngameWindow(unsigned int id, const DrawPoint& pos, unsigned short width, unsigned short height,
                           const std::string& title, glArchivItem_Bitmap* background, bool modal, bool closeOnRightClick, Window* parent)
    : Window(pos, id, parent, width, height),
      title_(title), background(background), lastMousePos(0, 0),
      last_down(false), last_down2(false), isModal_(modal), closeme(false), isMinimized_(false), isMoving(false), closeOnRightClick_(closeOnRightClick)
{
    std::fill(button_state.begin(), button_state.end(), BUTTON_UP);
    contentOffset.x = LOADER.GetImageN("resource", 38)->getWidth();     // left border
    contentOffset.y = LOADER.GetImageN("resource", 42)->getHeight();    // title bar
    contentOffsetEnd.x = LOADER.GetImageN("resource", 39)->getWidth();  // right border
    contentOffsetEnd.y = LOADER.GetImageN("resource", 40)->getHeight(); // bottom bar

    // For compatibility we treat the given height as the window height, not the content height
    iwHeight = std::max(0, height - contentOffset.y - contentOffsetEnd.y);

    // Load last position or center the window
    if(pos == posLastOrCenter)
    {

        if(id < last_pos.size() && last_pos[id].isValid())
            Move(last_pos[id]);
        else
            MoveToCenter();
    } else if(pos == posAtMouse)
        MoveNextToMouse();
}
Пример #3
0
iwHelp::iwHelp(const GUI_ID gui_id, const std::string& title, const std::string& content)
    : IngameWindow(gui_id, 0xFFFE, 0xFFFE, HELP_WINDOW_WIDTH, 480, title, LOADER.GetImageN("resource", 41))
{
    glArchivItem_Font::WrapInfo wi = NormalFont->GetWrapInfo(content, HELP_WINDOW_WIDTH - 28, HELP_WINDOW_WIDTH - 28);

    // Mehr Linien benötigt als die maximalen? Dann kommt ja noch die Scrollbar dran und der ganze Spaß muss
    // umgebrochen werden, also nochmal mit geringerer Breite berechnen
    if(wi.positions.size() > MAX_LINES)
    {
        wi = NormalFont->GetWrapInfo(content,
            HELP_WINDOW_WIDTH - 28 - ctrlMultiline::SCROLLBAR_WIDTH,
            HELP_WINDOW_WIDTH - 24 - ctrlMultiline::SCROLLBAR_WIDTH);
    }

    unsigned int show_lines = std::min( (unsigned int)wi.positions.size(), MAX_LINES);

    unsigned short text_height = show_lines * NormalFont->getHeight();

    // Höhe setzen
    SetIwHeight(text_height + 40);
    // Fenster neben die Maus schieben
    MoveNextToMouse();

    // Größe des Fensters und des Controls nach der Anzahl der Zeilen
    ctrlMultiline* text = AddMultiline(2, 10, 20, HELP_WINDOW_WIDTH - 20, text_height + 4, TC_GREEN1, NormalFont, glArchivItem_Font::DF_LEFT | glArchivItem_Font::DF_TOP);
    text->EnableBox(false);

    std::vector<std::string> lines = wi.CreateSingleStrings(content);
    for(std::vector<std::string>::const_iterator it = lines.begin(); it != lines.end(); ++it)
        text->AddString(*it, COLOR_YELLOW, false);

}