예제 #1
0
AddDeviceDialog::AddDeviceDialog() : ModalDialog(0.90f, 0.80f)
{    
    ScalableFont* font = GUIEngine::getFont();
    const int textHeight = GUIEngine::getFontHeight();
    const int buttonHeight = textHeight + 10;
    
    const int y_bottom = m_area.getHeight() - 2*(buttonHeight + 10) - 10;

    core::rect<s32> text_area( 15, 15, m_area.getWidth()-15, y_bottom-15 );
    
    IGUIStaticText* b = GUIEngine::getGUIEnv()->addStaticText( _("To add a new Gamepad/Joystick device, simply start SuperTuxKart with it connected and it will appear in the list.\n\nTo add a keyboard config, you can use the button below, HOWEVER please note that most keyboards only support a limited amount of simultaneous keypresses and are thus inappropriate for multiplayer gameplay. (You can, however, connect multiple keyboards to the computer. Remember that everyone still needs different keybindings in this case.)"),
                                                              text_area, false , true , // border, word warp
                                                              m_irrlicht_window);
    b->setTabStop(false);
    
       
    {
        ButtonWidget* widget = new ButtonWidget();
        widget->m_properties[PROP_ID] = "addkeyboard";
        
        //I18N: In the 'add new input device' dialog
        widget->setText( _("Add Keyboard Configuration") );
        
        const int textWidth = 
            font->getDimension( widget->getText().c_str() ).Width + 40;
        
        widget->m_x = m_area.getWidth()/2 - textWidth/2;
        widget->m_y = y_bottom;
        widget->m_w = textWidth;
        widget->m_h = buttonHeight;
        widget->setParent(m_irrlicht_window);
        m_widgets.push_back(widget);
        widget->add();
    }
    {
        ButtonWidget* widget = new ButtonWidget();
        widget->m_properties[PROP_ID] = "cancel";
        widget->setText( _("Cancel") );
        
        const int textWidth = 
            font->getDimension( widget->getText().c_str() ).Width + 40;
        
        widget->m_x = m_area.getWidth()/2 - textWidth/2;
        widget->m_y = y_bottom + buttonHeight + 10;
        widget->m_w = textWidth;
        widget->m_h = buttonHeight;
        widget->setParent(m_irrlicht_window);
        m_widgets.push_back(widget);
        widget->add();
        
        widget->setFocusForPlayer( PLAYER_ID_GAME_MASTER );    

    }
    
}
예제 #2
0
GPInfoDialog::GPInfoDialog(const std::string& gpIdent, const float w, const float h) : ModalDialog(w, h)
{
    doInit();
    m_curr_time = 0.0f;

    const int y1 = m_area.getHeight()/7;
    const int y2 = m_area.getHeight()*6/7;

    m_gp_ident = gpIdent;

    const GrandPrixData* gp = grand_prix_manager->getGrandPrix(gpIdent);
    if (gp == NULL)
    {
        assert(false);
        std::cerr << "ERROR at " << __FILE__ << " : " << __LINE__ << "; trying to continue\n";
        ModalDialog::dismiss();
        return;
    }

    // ---- GP Name
    core::rect< s32 > area_top(0, 0, m_area.getWidth(), y1);
    IGUIStaticText* title = GUIEngine::getGUIEnv()->addStaticText( translations->fribidize(gp->getName()),
                                                               area_top, false, true, // border, word wrap
                                                               m_irrlicht_window);
    title->setTabStop(false);
    title->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);


    // ---- Track listings
    const std::vector<std::string>& tracks = gp->getTrackNames();
    const int trackAmount = tracks.size();

    int height_of_one_line = (y2 - y1)/(trackAmount+1);
    const int textHeight = GUIEngine::getFontHeight();
    if (height_of_one_line > (int)(textHeight*1.5f)) height_of_one_line = (int)(textHeight*1.5f);

    bool gp_ok = true;

    for (int t=0; t<trackAmount; t++)
    {
        const int from_y = y1 + height_of_one_line*(t+1);

        Track* track = track_manager->getTrack(tracks[t]);
        stringw lineText;
        if (track == NULL)
        {
            lineText = L"MISSING : ";
            lineText.append( stringw(tracks[t].c_str()) );
            gp_ok = false;
        }
        else
        {
            lineText = track->getName();
        }

        LabelWidget* widget = new LabelWidget();
        widget->setText(translations->fribidize(lineText), false);
        widget->m_x = 20;
        widget->m_y = from_y;
        widget->m_w = m_area.getWidth()/2 - 20;
        widget->m_h = height_of_one_line;
        widget->setParent(m_irrlicht_window);

        m_widgets.push_back(widget);
        widget->add();

        // IGUIStaticText* line = GUIEngine::getGUIEnv()->addStaticText( lineText.c_str(),
        //                                       entry_area, false , true , // border, word wrap
        //                                       m_irrlicht_window);
    }

    // ---- Track screenshot

    m_screenshot_widget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
                                               false /* tab stop */, false /* focusable */,
                                               IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE /* Track gives us absolute paths */);
    // images are saved squared, but must be stretched to 4:3
    m_screenshot_widget->setCustomAspectRatio(4.0f / 3.0f);

    m_screenshot_widget->m_x = m_area.getWidth()/2;
    m_screenshot_widget->m_y = y1;
    m_screenshot_widget->m_w = m_area.getWidth()/2;
    m_screenshot_widget->m_h = y2 - y1 - 10;

    Track* track = track_manager->getTrack(tracks[0]);

    m_screenshot_widget->m_properties[PROP_ICON] = (track  != NULL ?
                                                    track->getScreenshotFile().c_str() :
                                                    file_manager->getAsset(FileManager::GUI,"main_help.png"));
    m_screenshot_widget->setParent(m_irrlicht_window);
    m_screenshot_widget->add();
    m_widgets.push_back(m_screenshot_widget);


    // ---- Start button
    ButtonWidget* okBtn = new ButtonWidget();
    ButtonWidget* continueBtn = new ButtonWidget();

    SavedGrandPrix* saved_gp = SavedGrandPrix::getSavedGP( StateManager::get()
                                               ->getActivePlayerProfile(0)
                                               ->getUniqueID(),
                                               gpIdent,
                                               race_manager->getDifficulty(),
                                               race_manager->getNumberOfKarts(),
                                               race_manager->getNumLocalPlayers());

    if (gp_ok)
    {
        okBtn->m_properties[PROP_ID] = "start";
        okBtn->setText(_("Start Grand Prix"));

        continueBtn->m_properties[PROP_ID] = "continue";
        continueBtn->setText(_("Continue"));
    }
    else
    {
        okBtn->m_properties[PROP_ID] = "cannot_start";
        okBtn->setText(_("This Grand Prix is broken!"));
        okBtn->setBadge(BAD_BADGE);
    }

    if (saved_gp && gp_ok)
    {
        continueBtn->m_x = m_area.getWidth()/2 + 110;
        continueBtn->m_y = y2;
        continueBtn->m_w = 200;
        continueBtn->m_h = m_area.getHeight() - y2 - 15;
        continueBtn->setParent(m_irrlicht_window);
        m_widgets.push_back(continueBtn);
        continueBtn->add();
        continueBtn->getIrrlichtElement()->setTabStop(true);
        continueBtn->getIrrlichtElement()->setTabGroup(false);
        
        okBtn->m_x = m_area.getWidth()/2 - 310;
    }
    else
    {
        okBtn->m_x = m_area.getWidth()/2 - 200;
    }
    
    okBtn->m_y = y2;
    okBtn->m_w = 400;
    okBtn->m_h = m_area.getHeight() - y2 - 15;
    okBtn->setParent(m_irrlicht_window);
    m_widgets.push_back(okBtn);
    okBtn->add();
    okBtn->getIrrlichtElement()->setTabStop(true);
    okBtn->getIrrlichtElement()->setTabGroup(false);

    okBtn->setFocusForPlayer( PLAYER_ID_GAME_MASTER );
    
}
예제 #3
0
/** Show the current data of this player.
 */
void PlayerInfoDialog::showRegularDialog()
{
    if (m_irrlicht_window)
        clearWindow();

    const int y1 = m_area.getHeight()/6;
    const int y2 = m_area.getHeight()*2/6;
    const int y3 = m_area.getHeight()*3/6;
    const int y4 = m_area.getHeight()*5/6;

    ScalableFont* font = GUIEngine::getFont();
    const int textHeight = GUIEngine::getFontHeight();
    const int buttonHeight = textHeight + 10;

    {
        textCtrl = new TextBoxWidget();
        textCtrl->m_properties[PROP_ID] = "newname";
        textCtrl->setText(m_player->getName());
        textCtrl->m_x = 50;
        textCtrl->m_y = y1 - textHeight/2;
        textCtrl->m_w = m_area.getWidth()-100;
        textCtrl->m_h = textHeight + 5;
        textCtrl->setParent(m_irrlicht_window);
        m_widgets.push_back(textCtrl);
        textCtrl->add();
    }

    {
        ButtonWidget* widget = new ButtonWidget();
        widget->m_properties[PROP_ID] = "renameplayer";

        //I18N: In the player info dialog
        widget->setText( _("Rename") );

        const int textWidth = 
                    font->getDimension( widget->getText().c_str() ).Width + 40;

        widget->m_x = m_area.getWidth()/2 - textWidth/2;
        widget->m_y = y2;
        widget->m_w = textWidth;
        widget->m_h = buttonHeight;
        widget->setParent(m_irrlicht_window);
        m_widgets.push_back(widget);
        widget->add();
    }
    {
        ButtonWidget* widget = new ButtonWidget();
        widget->m_properties[PROP_ID] = "cancel";
        widget->setText( _("Cancel") );

        const int textWidth =
            font->getDimension(widget->getText().c_str()).Width + 40;

        widget->m_x = m_area.getWidth()/2 - textWidth/2;
        widget->m_y = y3;
        widget->m_w = textWidth;
        widget->m_h = buttonHeight;
        widget->setParent(m_irrlicht_window);
        m_widgets.push_back(widget);
        widget->add();
    }

    {
        ButtonWidget* widget = new ButtonWidget();
        widget->m_properties[PROP_ID] = "removeplayer";

        //I18N: In the player info dialog
        widget->setText( _("Remove"));

        const int textWidth =
            font->getDimension(widget->getText().c_str()).Width + 40;

        widget->m_x = m_area.getWidth()/2 - textWidth/2;
        widget->m_y = y4;
        widget->m_w = textWidth;
        widget->m_h = buttonHeight;
        widget->setParent(m_irrlicht_window);
        m_widgets.push_back(widget);
        widget->add();
    }

    textCtrl->setFocusForPlayer( PLAYER_ID_GAME_MASTER );
}   // showRegularDialog
예제 #4
0
/** Changes this dialog to confirm the changes.
 */
void PlayerInfoDialog::showConfirmDialog()
{
    clearWindow();

    IGUIFont* font = GUIEngine::getFont();
    const int textHeight = GUIEngine::getFontHeight();
    const int buttonHeight = textHeight + 10;

    irr::core::stringw message =
        //I18N: In the player info dialog (when deleting)
        _("Do you really want to delete player '%s' ?", m_player->getName());


    if (PlayerManager::getCurrentPlayer() == m_player)
    {
        message = _("You cannot delete this player "
                    "because it is currently in use.");
    }

    core::rect< s32 > area_left(5, 0, m_area.getWidth()-5, m_area.getHeight()/2);

    // When there is no need to tab through / click on images/labels,
    // we can add irrlicht labels directly
    // (more complicated uses require the use of our widget set)
    IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( message.c_str(),
                                              area_left, false /* border */,
                                              true /* word wrap */,
                                              m_irrlicht_window);
    a->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER);

    if (PlayerManager::getCurrentPlayer() != m_player)
    {
        ButtonWidget* widget = new ButtonWidget();
        widget->m_properties[PROP_ID] = "confirmremove";

        //I18N: In the player info dialog (when deleting)
        widget->setText( _("Confirm Remove") );

        const int textWidth =
            font->getDimension(widget->getText().c_str()).Width + 40;

        widget->m_x = m_area.getWidth()/2 - textWidth/2;
        widget->m_y = m_area.getHeight()/2;
        widget->m_w = textWidth;
        widget->m_h = buttonHeight;
        widget->setParent(m_irrlicht_window);
        m_widgets.push_back(widget);
        widget->add();
    }

    {
        ButtonWidget* widget = new ButtonWidget();
        widget->m_properties[PROP_ID] = "cancelremove";

        //I18N: In the player info dialog (when deleting)
        widget->setText( _("Cancel Remove") );

        const int textWidth =
            font->getDimension( widget->getText().c_str() ).Width + 40;

        widget->m_x = m_area.getWidth()/2 - textWidth/2;
        widget->m_y = m_area.getHeight()*3/4;
        widget->m_w = textWidth;
        widget->m_h = buttonHeight;
        widget->setParent(m_irrlicht_window);
        m_widgets.push_back(widget);
        widget->add();

        widget->setFocusForPlayer( PLAYER_ID_GAME_MASTER );
    }

}   // showConfirmDialog
예제 #5
0
AddDeviceDialog::AddDeviceDialog() : ModalDialog(0.90f, 0.80f)
{
    doInit();

    ScalableFont* font = GUIEngine::getFont();
    const int textHeight = GUIEngine::getFontHeight();
    const int buttonHeight = textHeight + 10;

#ifdef ENABLE_WIIUSE
    const int nbButtons = 3;
#else
    const int nbButtons = 2;
#endif

    const int y_bottom = m_area.getHeight() - nbButtons*(buttonHeight + 10) - 10;
    const int y_stride = buttonHeight+10;
    int cur_y = y_bottom;

    core::rect<s32> text_area( 15, 15, m_area.getWidth()-15, y_bottom-15 );

    core::stringw msg =
        _("To add a new Gamepad/Joystick device, simply start SuperTuxKart "
          "with it connected and it will appear in the list.\n\nTo add a "
          "keyboard config, you can use the button below, HOWEVER please "
          "note that most keyboards only support a limited amount of "
          "simultaneous keypresses and are thus inappropriate for multiplayer "
          "gameplay. (You can, however, connect multiple keyboards to the "
          "computer. Remember that everyone still needs different keybindings "
          "in this case.)");
    IGUIStaticText* b =
        GUIEngine::getGUIEnv()->addStaticText(msg.c_str(),
                                              text_area,
                                              /*border*/false ,
                                              /*word wrap*/true,
                                              m_irrlicht_window);
    b->setTabStop(false);
    b->setRightToLeft(translations->isRTLLanguage());
    // because it looks like 'setRightToLeft' applies next time
    // setText is called only
    b->setText(msg.c_str());

#ifdef ENABLE_WIIUSE
    {
        ButtonWidget* widget = new ButtonWidget();
        widget->m_properties[PROP_ID] = "addwiimote";

        //I18N: In the 'add new input device' dialog
        widget->setText( _("Add Wiimote") );

        const int textWidth =
            font->getDimension( widget->getText().c_str() ).Width + 40;

        widget->m_x = m_area.getWidth()/2 - textWidth/2;
        widget->m_y = cur_y;
        widget->m_w = textWidth;
        widget->m_h = buttonHeight;
        widget->setParent(m_irrlicht_window);
        m_widgets.push_back(widget);
        widget->add();
        cur_y += y_stride;
    }
#endif  // ENABLE_WIIUSE

    {
        ButtonWidget* widget = new ButtonWidget();
        widget->m_properties[PROP_ID] = "addkeyboard";

        //I18N: In the 'add new input device' dialog
        widget->setText( _("Add Keyboard Configuration") );

        const int textWidth =
            font->getDimension( widget->getText().c_str() ).Width + 40;

        widget->m_x = m_area.getWidth()/2 - textWidth/2;
        widget->m_y = cur_y;
        widget->m_w = textWidth;
        widget->m_h = buttonHeight;
        widget->setParent(m_irrlicht_window);
        m_widgets.push_back(widget);
        widget->add();
        cur_y += y_stride;
    }
    {
        ButtonWidget* widget = new ButtonWidget();
        widget->m_properties[PROP_ID] = "cancel";
        widget->setText( _("Cancel") );

        const int textWidth =
            font->getDimension( widget->getText().c_str() ).Width + 40;

        widget->m_x = m_area.getWidth()/2 - textWidth/2;
        widget->m_y = cur_y;
        widget->m_w = textWidth;
        widget->m_h = buttonHeight;
        widget->setParent(m_irrlicht_window);
        m_widgets.push_back(widget);
        widget->add();
        cur_y += y_stride;

        widget->setFocusForPlayer( PLAYER_ID_GAME_MASTER );

    }

}   // AddDeviceDialog
예제 #6
0
// -----------------------------------------------------------------------------
void ListWidget::add()
{
    const int header_height = GUIEngine::getFontHeight() + 15;

    rect<s32> widget_size = (m_header.size() > 0 ? rect<s32>(m_x, m_y + header_height, m_x + m_w, m_y + m_h) :
                                                   rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h) );

    IGUISkin * current_skin = GUIEngine::getGUIEnv()->getSkin();
    IGUIFont * current_font = GUIEngine::getGUIEnv()->getBuiltInFont();
    CGUISTKListBox * list_box = new CGUISTKListBox(
        GUIEngine::getGUIEnv(),
        m_parent ? m_parent : GUIEngine::getGUIEnv()->getRootGUIElement(),
        getNewID(),
        widget_size,
        true,
        true,
        false);

    if (current_skin && current_skin->getSpriteBank())
    {
            list_box->setSpriteBank(current_skin->getSpriteBank());
    }
    else if (current_font && current_font->getType() == EGFT_BITMAP)
    {
            list_box->setSpriteBank( ((IGUIFontBitmap*)current_font)->getSpriteBank());
    }

    list_box->drop();

    list_box->setAutoScrollEnabled(false);

    m_element = list_box;
    m_element->setTabOrder( list_box->getID() );

    if (m_header.size() > 0)
    {
        //const int col_size = m_w / m_header.size();

        int proportion_total = 0;
        for (unsigned int n=0; n<m_header.size(); n++)
        {
            proportion_total += m_header[n].m_proportion;
        }

        int x = m_x;
        for (unsigned int n=0; n<m_header.size(); n++)
        {
            std::ostringstream name;
            name << m_properties[PROP_ID];
            name << "_column_";
            name << n;

            ButtonWidget* header = new ButtonWidget();

            header->m_reserved_id = getNewNoFocusID();

            header->m_y = m_y;
            header->m_h = header_height;

            header->m_x = x;
            header->m_w = (int)(m_w * float(m_header[n].m_proportion)
                                /float(proportion_total));

            x += header->m_w;

            header->setText( m_header[n].m_text );
            header->m_properties[PROP_ID] = name.str();

            header->add();
            header->m_event_handler = this;

            header->getIrrlichtElement()->setTabStop(false);

            m_children.push_back(header);
            m_header_elements.push_back(header);
        }

        m_check_inside_me = true;
    }
}