예제 #1
0
파일: main.cpp 프로젝트: wemstar/Qt
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    ListWidget w;
    w.show();
    
    return a.exec();
}
void OptionsScreenPlayers::selectPlayer(const irr::core::stringw& name)
{
    ListWidget* players = this->getWidget<ListWidget>("players");
    assert(players != NULL);
    players->selectItemWithLabel(name);

    players->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
예제 #3
0
QWidget *WalkmeshManager::buildWalkmeshPage()
{
	QWidget *ret = new QWidget(this);

	ListWidget *listWidget = new ListWidget(ret);
	listWidget->addAction(ListWidget::Add, tr("Ajouter triangle"), this, SLOT(addTriangle()));
	listWidget->addAction(ListWidget::Rem, tr("Supprimer triangle"), this, SLOT(removeTriangle()));

	idToolbar = listWidget->toolBar();
	idList = listWidget->listWidget();

	idVertices[0] = new VertexWidget(ret);
	idVertices[1] = new VertexWidget(ret);
	idVertices[2] = new VertexWidget(ret);

	idAccess[0] = new QSpinBox(ret);
	idAccess[1] = new QSpinBox(ret);
	idAccess[2] = new QSpinBox(ret);

	idAccess[0]->setRange(-32768, 32767);
	idAccess[1]->setRange(-32768, 32767);
	idAccess[2]->setRange(-32768, 32767);

	QHBoxLayout *accessLayout0 = new QHBoxLayout;
	accessLayout0->addWidget(new QLabel(tr("Triangle accessible via la ligne 1-2 :")));
	accessLayout0->addWidget(idAccess[0]);

	QHBoxLayout *accessLayout1 = new QHBoxLayout;
	accessLayout1->addWidget(new QLabel(tr("Triangle accessible via la ligne 2-3 :")));
	accessLayout1->addWidget(idAccess[1]);

	QHBoxLayout *accessLayout2 = new QHBoxLayout;
	accessLayout2->addWidget(new QLabel(tr("Triangle accessible via la ligne 3-1 :")));
	accessLayout2->addWidget(idAccess[2]);

	QGridLayout *layout = new QGridLayout(ret);
	layout->addWidget(listWidget, 0, 0, 7, 1, Qt::AlignLeft);
	layout->addWidget(new QLabel(tr("Point 1 :")), 0, 1);
	layout->addWidget(idVertices[0], 0, 2);
	layout->addWidget(new QLabel(tr("Point 2 :")), 1, 1);
	layout->addWidget(idVertices[1], 1, 2);
	layout->addWidget(new QLabel(tr("Point 3 :")), 2, 1);
	layout->addWidget(idVertices[2], 2, 2);
	layout->addLayout(accessLayout0, 3, 1, 1, 2);
	layout->addLayout(accessLayout1, 4, 1, 1, 2);
	layout->addLayout(accessLayout2, 5, 1, 1, 2);
	layout->setRowStretch(6, 1);

	connect(idList, SIGNAL(currentRowChanged(int)), SLOT(setCurrentId(int)));
	connect(idVertices[0], SIGNAL(valuesChanged(Vertex_s)), SLOT(editIdTriangle(Vertex_s)));
	connect(idVertices[1], SIGNAL(valuesChanged(Vertex_s)), SLOT(editIdTriangle(Vertex_s)));
	connect(idVertices[2], SIGNAL(valuesChanged(Vertex_s)), SLOT(editIdTriangle(Vertex_s)));
	connect(idAccess[0], SIGNAL(valueChanged(int)), SLOT(editIdAccess(int)));
	connect(idAccess[1], SIGNAL(valueChanged(int)), SLOT(editIdAccess(int)));
	connect(idAccess[2], SIGNAL(valueChanged(int)), SLOT(editIdAccess(int)));

	return ret;
}
예제 #4
0
void MainWindow::showPDFView(QListWidgetItem *item)
{
    ListWidget *w = (ListWidget*)(ui->lstResults->itemWidget(item));
    Poppler::Document *document = Poppler::Document::load(w->getPath());
    PDFview *view = new PDFview(document,w->getPage(), readerPath, w->getPath());
    view->setAttribute(Qt::WA_DeleteOnClose);
    view->setWindowTitle("PDF Folder Search");
    view->showMaximized();
}
void OptionsScreenPlayers::onNewPlayerWithName(const stringw& newName)
{
    ListWidget* players = this->getWidget<ListWidget>("players");
    if (players != NULL)
    {
        core::stringc newNameC(newName.c_str());
        players->addItem( newNameC.c_str(), translations->fribidize(newName) );
    }
}
예제 #6
0
void ListBoxImpl::GetValue(int n, char *value, int len)
{
	ListWidget *list = static_cast<ListWidget *>(wid);
	QListWidgetItem *item = list->item(n);
	QString str = item->data(Qt::DisplayRole).toString();
	QByteArray bytes = unicodeMode ? str.toUtf8() : str.toLocal8Bit();

	strncpy(value, bytes.constData(), len);
	value[len-1] = '\0';
}
예제 #7
0
void ListBoxImpl::Create(Window &parent,
                         int /*ctrlID*/,
                         Point location,
                         int /*lineHeight*/,
                         bool unicodeMode_,
			 int)
{
	unicodeMode = unicodeMode_;

	QWidget *qparent = static_cast<QWidget *>(parent.GetID());
	ListWidget *list = new ListWidget(qparent);

#if defined(Q_OS_WIN)
	// On Windows, Qt::ToolTip causes a crash when the list is clicked on
	// so Qt::Tool is used.
	list->setParent(0, Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
#else
	// On OS X, Qt::Tool takes focus so main window loses focus so
	// keyboard stops working. Qt::ToolTip works but its only really
	// documented for tooltips.
	// On Linux / X this setting allows clicking on list items.
	list->setParent(0, Qt::ToolTip | Qt::FramelessWindowHint);
#endif
	list->setAttribute(Qt::WA_ShowWithoutActivating);
	list->setFocusPolicy(Qt::NoFocus);
	list->setUniformItemSizes(true);
	list->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	list->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	list->move(location.x, location.y);

	wid = list;
}
예제 #8
0
int main(int argc, char *argv[]) {

    QApplication app(argc, argv);

    ListWidget window;

    window.setWindowTitle("QListWidget");
    window.show();

    return app.exec();
}
예제 #9
0
int ListBoxImpl::Find(const char *prefix)
{
	ListWidget *list = static_cast<ListWidget *>(wid);
	QString sPrefix = unicodeMode ? QString::fromUtf8(prefix) : QString::fromLocal8Bit(prefix);
	QList<QListWidgetItem *> ms = list->findItems(sPrefix, Qt::MatchStartsWith);

	int result = -1;
	if (!ms.isEmpty()) {
		result = list->row(ms.first());
	}

	return result;
}
예제 #10
0
/** Updates the list of tracks shown.
 */
void GPInfoScreen::addTracks()
{
    const std::vector<std::string> tracks = m_gp.getTrackNames();

    ListWidget *list = getWidget<ListWidget>("tracks");
    list->clear();
    for (unsigned int i = 0; i < (unsigned int)tracks.size(); i++)
    {
        const Track *track = track_manager->getTrack(tracks[i]);
        std::string s = StringUtils::toString(i);
        list->addItem(s, translations->fribidize(track->getName()));
    }
}   // addTracks
예제 #11
0
int ListBoxImpl::CaretFromEdge()
{
	ListWidget *list = static_cast<ListWidget *>(wid);

	int maxIconWidth = 0;
	foreach (QPixmap im, images) {
		if (maxIconWidth < im.width())
			maxIconWidth = im.width();
	}

	// The '7' is from trial and error on Windows - there may be
	// a better programmatic way to find any padding factors.
	return maxIconWidth  + (2 * list->frameWidth()) + 7;
}
void OptionsScreenPlayers::eventCallback(Widget* widget, const std::string& name, const int playerID)
{
    if (name == "options_choice")
    {
        std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str();

        if (selection == "tab_audio") StateManager::get()->replaceTopMostScreen(OptionsScreenAudio::getInstance());
        else if (selection == "tab_video") StateManager::get()->replaceTopMostScreen(OptionsScreenVideo::getInstance());
        else if (selection == "tab_players") StateManager::get()->replaceTopMostScreen(OptionsScreenPlayers::getInstance());
        else if (selection == "tab_controls") StateManager::get()->replaceTopMostScreen(OptionsScreenInput::getInstance());
        else if (selection == "tab_ui") StateManager::get()->replaceTopMostScreen(OptionsScreenUI::getInstance());
    }
    else if (name == "back")
    {
        StateManager::get()->escapePressed();
    }
    else if (name == "addplayer")
    {
        new EnterPlayerNameDialog(this, 0.5f, 0.4f);
    }
    else if (name == "players")
    {
        // Find which player in the list was clicked
        ListWidget* players = this->getWidget<ListWidget>("players");
        assert(players != NULL);

        core::stringw selectedPlayer = players->getSelectionLabel();
        const int player_amount = PlayerManager::get()->getNumPlayers();
        for (int i=0; i<player_amount; i++)
        {
            PlayerProfile *player = PlayerManager::get()->getPlayer(i);
            if (selectedPlayer == translations->fribidize(player->getName()))
            {
                if (!(player->isGuestAccount()))
                {
                    new PlayerInfoDialog( player, 0.5f, 0.6f );
                }
                return;
            }
        } // end for
    }
    else if (name == "playername")
    {
        race_manager->clearKartLastPositionOnOverworld();
        PlayerManager::get()->setCurrentPlayer(NULL,false);
        StateManager::get()->pushScreen(StoryModeLobbyScreen::getInstance());
    }

}   // eventCallback
예제 #13
0
void OptionsScreenInput::rebuildDeviceList()
{
    /*
    DynamicRibbonWidget* devices = this->getWidget<DynamicRibbonWidget>("devices");
    assert( devices != NULL );

    devices->clearItems();
    buildDeviceList();
    devices->updateItemDisplay();
     */

    ListWidget* devices = this->getWidget<ListWidget>("devices");
    assert( devices != NULL );

    devices->clear();
    buildDeviceList();
}   // rebuildDeviceList
void StoryModeLobbyScreen::eventCallback(Widget* widget, const std::string& name, const int playerID)
{
    if (name == "back")
    {
        StateManager::get()->escapePressed();
    }
    else if (name == "creategame")
    {
        new EnterPlayerNameDialog(this, 0.5f, 0.4f);
    }
    else if (name == "gameslots")
    {
        ListWidget* list = getWidget<ListWidget>("gameslots");
        
        bool slot_found = false;
        
        PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
        for (int n=0; n<players.size(); n++)
        {
            if (list->getSelectionLabel() == players[n].getName())
            {
                unlock_manager->setCurrentSlot(players[n].getUniqueID());
                unlock_manager->updateActiveChallengeList();
                slot_found = true;
                break;
            }
        }
        
        if (!slot_found)
        {
            fprintf(stderr, "[StoryModeLobbyScreen] ERROR: cannot find player corresponding to slot '%s'\n",
                    core::stringc(list->getSelectionLabel().c_str()).c_str());
        }
        else
        {
            CheckBoxWidget* cb = getWidget<CheckBoxWidget>("rememberme");
            if (cb->getState())
            {
                UserConfigParams::m_default_player = list->getSelectionLabel();
            }
        }
            
        StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
    }
}   // eventCallback
예제 #15
0
PRectangle ListBoxImpl::GetDesiredRect()
{
	ListWidget *list = static_cast<ListWidget *>(wid);

	int rows = Length();
	if (rows == 0 || rows > visibleRows) {
		rows = visibleRows;
	}
	int rowHeight = list->sizeHintForRow(0);
	int height = (rows * rowHeight) + (2 * list->frameWidth());

	QStyle *style = QApplication::style();
	int width = list->sizeHintForColumn(0) + (2 * list->frameWidth());
	if (Length() > rows) {
		width += style->pixelMetric(QStyle::PM_ScrollBarExtent);
	}

	return PRectangle(0, 0, width, height);
}
/** Refreshes the list of players.
 */
bool OptionsScreenPlayers::refreshPlayerList()
{
    ListWidget* players = this->getWidget<ListWidget>("players");
    if (players == NULL) return false;
    // Get rid of previous
    players->clear();
    // Rebuild it
    const int player_amount = PlayerManager::get()->getNumPlayers();
    for (int i = 0; i < player_amount; i++)
    {
        // FIXME: Using a truncated ASCII string for internal ID. Let's cross
        // our fingers and hope no one enters two player names that,
        // when stripped down to ASCII, give the same identifier...
        const PlayerProfile *player = PlayerManager::get()->getPlayer(i);
        players->addItem(
            core::stringc(player->getName().c_str()).c_str(),
            translations->fribidize(player->getName()));
    }

    return true;
}
예제 #17
0
int main(int argc, char *argv[]) {
	int ret = -1;
	QApplication application(argc, argv);


    ListWidget* list = new ListWidget;

    for(int i=0;i<10;++i)
    {
        list->addWidget(new QPushButton(QString::number(i)));
    }

    WidgetList widgetList(list);
    widgetList.show();


    ret = application.exec();

    delete list;
    return ret;
}
예제 #18
0
void OptionsScreenInput::filterInput(Input::InputType type,
                                     int deviceID,
                                     int btnID,
                                     int axisDir,
                                     int axisRange,
                                     int value)
{
    if (type == Input::IT_STICKMOTION || type == Input::IT_STICKBUTTON)
    {
        GamePadDevice* gamepad = input_manager->getDeviceList()->getGamePadFromIrrID(deviceID);
        if (gamepad != NULL && gamepad->getConfiguration() != NULL)
        {
            //printf("'%s'\n", gamepad->getConfiguration()->getName().c_str());

            ListWidget* devices = this->getWidget<ListWidget>("devices");
            assert(devices != NULL);

            std::string internal_name;
            const int gpad_config_count = input_manager->getDeviceList()->getGamePadConfigAmount();
            for (int i = 0; i < gpad_config_count; i++)
            {
                GamepadConfig *config = input_manager->getDeviceList()->getGamepadConfig(i);

                // Don't display the configuration if a matching device is not available
                if (config == gamepad->getConfiguration())
                {
                    std::ostringstream gpname;
                    gpname << "gamepad" << i;
                    internal_name = gpname.str();
                }
            }

            if (internal_name.size() > 0 && abs(value) > Input::MAX_VALUE/2)
            {
                devices->markItemRed(internal_name.c_str());
                m_highlights[internal_name] = 0.25f;
            }
        }
    }
}
예제 #19
0
void OptionsScreenInput::onUpdate(float dt)
{
    std::map<std::string, float>::iterator it;
    for (it = m_highlights.begin(); it != m_highlights.end();)
    {
        it->second -= dt;
        if (it->second < 0.0f)
        {
            ListWidget* devices = this->getWidget<ListWidget>("devices");
            assert(devices != NULL);

            devices->markItemRed(it->first.c_str(), false);

            m_highlights.erase(it++);
        }
        else
        {
            it++;
        }
    }
    //m_highlights[internal_name]
}   // onUpdate
void StoryModeLobbyScreen::init()
{
    Screen::init();
    
    CheckBoxWidget* cb = getWidget<CheckBoxWidget>("rememberme");
    cb->setState(false);
    
    ListWidget* list = getWidget<ListWidget>("gameslots");
    list->clear();
    
    PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players;
    
    if (UserConfigParams::m_default_player.toString().size() > 0)
    {
        for (int n=0; n<players.size(); n++)
        {
            if (players[n].getName() == UserConfigParams::m_default_player.toString())
            {
                unlock_manager->setCurrentSlot(players[n].getUniqueID());
                StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
                return;
            }
        }
    }
    
    for (int n=0; n<players.size(); n++)
    {
        if (players[n].isGuestAccount()) continue;
        
        // FIXME: we're using a trunacted ascii version of the player name as
        //        identifier, let's hope this causes no issues...
        list->addItem(core::stringc(players[n].getName().c_str()).c_str(),
                      players[n].getName() );
    }
    
    list->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
    list->setSelectionID(0);
    
}   // init
void OptionsScreenPlayers::init()
{
    Screen::init();

    RibbonWidget* tabBar = this->getWidget<RibbonWidget>("options_choice");
    if (tabBar != NULL) tabBar->select( "tab_players", PLAYER_ID_GAME_MASTER );

    tabBar->getRibbonChildren()[0].setTooltip( _("Graphics") );
    tabBar->getRibbonChildren()[1].setTooltip( _("Audio") );
    tabBar->getRibbonChildren()[2].setTooltip( _("User Interface") );
    tabBar->getRibbonChildren()[4].setTooltip( _("Controls") );

    ListWidget* players = this->getWidget<ListWidget>("players");
    assert(players != NULL);

    refreshPlayerList();

    ButtonWidget* you = getWidget<ButtonWidget>("playername");
    unsigned int playerID = PlayerManager::get()->getCurrentPlayer()->getUniqueID();
    core::stringw player_name = L"-";
    const PlayerProfile* curr = PlayerManager::get()->getPlayerById(playerID);
    if(curr)
        player_name = curr->getName();

    you->setText( player_name );
    ((gui::IGUIButton*)you->getIrrlichtElement())->setOverrideFont( GUIEngine::getSmallFont() );

    if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
    {
        players->setDeactivated();
        you->setDeactivated();
    }
    else
    {
        players->setActivated();
        you->setActivated();
    }
}   // init
예제 #22
0
void ListBoxImpl::SetDoubleClickAction(CallBackAction action, void *data)
{
	ListWidget *list = static_cast<ListWidget *>(wid);
	list->setDoubleClickAction(action, data);
}
예제 #23
0
파일: ListPicker.cpp 프로젝트: hor63/XCSoar
 /**
  * This timer is used to postpone the initial UpdateHelp() call.
  * This is necessary because the TwoWidgets instance is not fully
  * initialised yet in Show(), and recursively calling into Widget
  * methods is dangerous anyway.
  */
 virtual void OnTimer() override {
   UpdateHelp(GetList().GetCursorIndex());
   Timer::Cancel();
 }
예제 #24
0
void ListBoxImpl::Select(int n)
{
	ListWidget *list = static_cast<ListWidget *>(wid);
	list->setCurrentRow(n);
}
예제 #25
0
int ListBoxImpl::GetSelection()
{
	ListWidget *list = static_cast<ListWidget *>(wid);
	return list->currentRow();
}
예제 #26
0
int ListBoxImpl::Length()
{
	ListWidget *list = static_cast<ListWidget *>(wid);
	return list->count();
}
예제 #27
0
void ListBoxImpl::Clear()
{
	ListWidget *list = static_cast<ListWidget *>(wid);
	list->clear();
}
예제 #28
0
void EventHandler::navigateDown(const int playerID, Input::InputType type, const bool pressedDown)
{
    //std::cout << "Naviagte down!\n";

    IGUIElement *el = NULL, *closest = NULL;

    if (type == Input::IT_STICKBUTTON && !pressedDown)
        return;

    Widget* w = GUIEngine::getFocusForPlayer(playerID);
    if (w != NULL)
    {
        el = w->getIrrlichtElement();
    }
    //std::cout << "!!! Player " << playerID << " navigating down of " << w->m_element->getID() << std::endl;

    // list widgets are a bit special, because up/down keys are also used
    // to navigate between various list items, not only to navigate between
    // components
    if (w != NULL && w->m_type == WTYPE_LIST)
    {
        ListWidget* list = (ListWidget*)w;

        const bool stay_within_list = list->getSelectionID() < list->getItemCount()-1;

        if (stay_within_list)
        {
            list->setSelectionID(list->getSelectionID()+1);
            return;
        }
        else
        {
            list->setSelectionID(-1);
        }
    }

    if (w != NULL && w->m_tab_down_root != -1)
    {
        Widget* down = GUIEngine::getWidget( w->m_tab_down_root );
        assert(down != NULL);
        el = down->getIrrlichtElement();

        if (el == NULL)
        {
            std::cerr << "WARNING : m_tab_down_root is set to an ID for which I can't find the widget\n";
            return;
        }
    }

    // don't allow navigating to any widget when a dialog is shown; only navigate to widgets in the dialog
    if (ModalDialog::isADialogActive() && !ModalDialog::getCurrent()->isMyIrrChild(el))
    {
        el = NULL;
    }

    bool found = false;

    if (el != NULL && el->getTabGroup() != NULL)
    {
        // if the current widget is e.g. 5, search for widget 6, 7, 8, 9, ..., 15 (up to 10 IDs may be missing)
        for (int n=1; n<10 && !found; n++)
        {
            closest = GUIEngine::getGUIEnv()->getRootGUIElement()->getElementFromId(el->getTabOrder() + n, true);

            if (closest != NULL && Widget::isFocusableId(closest->getID()))
            {

                Widget* closestWidget = GUIEngine::getWidget( closest->getID() );
                if (playerID != PLAYER_ID_GAME_MASTER && !closestWidget->m_supports_multiplayer) return;

                // if a dialog is shown, restrict to items in the dialog
                if (ModalDialog::isADialogActive() && !ModalDialog::getCurrent()->isMyChild(closestWidget))
                {
                    continue;
                }

                if (NAVIGATION_DEBUG)
                {
                    std::cout << "Navigating down to " << closestWidget->getID() << "\n";
                }

                assert( closestWidget != NULL );
                closestWidget->setFocusForPlayer(playerID);

                // another list exception : when entering a list, select the first item
                if (closestWidget->m_type == WTYPE_LIST)
                {
                    IGUIListBox* list = (IGUIListBox*)(closestWidget->m_element);
                    assert(list != NULL);

                    list->setSelected(0);
                }

                found = true;
            }
        } // end for
    }

    if (!found)
    {

        if (NAVIGATION_DEBUG) std::cout << "Navigating down : wrap around\n";

        // select the first widget
        Widget* firstWidget = NULL;

        if (ModalDialog::isADialogActive())
        {
            //std::cout <<  "w = ModalDialog::getCurrent()->getFirstWidget();\n";
            firstWidget = ModalDialog::getCurrent()->getFirstWidget();
        }
        else
        {
            Screen* screen = GUIEngine::getCurrentScreen();
            if (screen == NULL) return;
            firstWidget = screen->getFirstWidget();
        }

        if (firstWidget != NULL)  firstWidget->setFocusForPlayer(playerID);
    }
}
예제 #29
0
void TracksScreen::eventCallback(Widget* widget, const std::string& name,
                                 const int playerID)
{
    if ((name == "lap-spinner" || name == "reverse") &&
         STKHost::existHost() && m_selected_track != NULL)
    {
        voteForPlayer();
    }

    else if (name == "vote-list")
    {
        auto cl = LobbyProtocol::get<ClientLobby>();
        ListWidget* list = dynamic_cast<ListWidget*>(widget);
        DynamicRibbonWidget* tracks_widget =
            getWidget<DynamicRibbonWidget>("tracks");

        if (!list || !cl || !tracks_widget || !m_laps || !m_reversed)
            return;
        // Vote to agree with selection of host id
        uint32_t host_id = -1;
        if (StringUtils::fromString(list->getSelectionInternalName(),
            host_id) && host_id != STKHost::get()->getMyHostId())
        {
            const PeerVote* host_vote = cl->getVote(host_id);
            if (host_vote)
            {
                m_selected_track = track_manager->getTrack(
                    host_vote->m_track_name);
                if (!m_selected_track)
                    return;
                tracks_widget->setBadge(host_vote->m_track_name, OK_BADGE);
                m_laps->setValue(host_vote->m_num_laps);
                m_reversed->setState(host_vote->m_reverse);
                voteForPlayer();
            }
        }
    }
    else if (name == "tracks")
    {
        DynamicRibbonWidget* w2 = dynamic_cast<DynamicRibbonWidget*>(widget);
        if(!w2) return;

        std::string selection = w2->getSelectionIDString(PLAYER_ID_GAME_MASTER);
        if (UserConfigParams::logGUI())
        {
            Log::info("TracksScreen", "Clicked on track '%s'.",
                       selection.c_str());
        }

        UserConfigParams::m_last_track = selection;
        if (selection == "locked" && race_manager->getNumLocalPlayers() == 1)
        {
            unlock_manager->playLockSound();
            return;
        }
        else if (selection == RibbonWidget::NO_ITEM_ID)
        {
            return;
        }

        if (selection == "random_track")
        {
            if (m_random_track_list.empty()) return;

            selection = m_random_track_list.front();
            m_random_track_list.pop_front();
            m_random_track_list.push_back(selection);
        }   // selection=="random_track"

        m_selected_track = track_manager->getTrack(selection);

        if (m_selected_track)
        {
            if (STKHost::existHost())
            {
                w2->setBadge(selection, OK_BADGE);
                voteForPlayer();
            }
            else
            {
                TrackInfoScreen::getInstance()->setTrack(m_selected_track);
                TrackInfoScreen::getInstance()->push();
            }
        }   // if clicked_track

    }   // name=="tracks"
    else if (name == "trackgroups")
    {
        RibbonWidget* tabs = this->getWidget<RibbonWidget>("trackgroups");
        UserConfigParams::m_last_used_track_group = tabs->getSelectionIDString(0);
        buildTrackList();
        
        if (m_network_tracks)
        {
            auto cl = LobbyProtocol::get<ClientLobby>();
    
            const PeerVote* vote = cl->getVote(STKHost::get()->getMyHostId());
            if (vote)
            {
                DynamicRibbonWidget* w2 = getWidget<DynamicRibbonWidget>("tracks");
                w2->setBadge(vote->m_track_name, OK_BADGE);
            }
        }
    }
    else if (name == "back")
    {
        StateManager::get()->escapePressed();
    }
}   // eventCallback
예제 #30
0
void ListBoxImpl::SetFont(Font &font)
{
	ListWidget *list = static_cast<ListWidget *>(wid);
	list->setFont(*FontPointer(font));
}