本文整理汇总了C++中Menu类的典型用法代码示例。如果您正苦于以下问题:C++ Menu类的具体用法?C++ Menu怎么用?C++ Menu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Menu类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void){
Menu menu;
menu.choiceMenu();
return 0;
}
示例2: produceMainMenu
void CrustaApp::
produceMainMenu()
{
/* Create a popup shell to hold the main menu: */
popMenu = new PopupMenu("MainMenuPopup",Vrui::getWidgetManager());
popMenu->setTitle("Crusta");
/* Create the main menu itself: */
Menu* mainMenu =
new Menu("MainMenu",popMenu,false);
/* Data Loading menu entry */
produceDataDialog();
Button* dataLoadButton = new Button(
"DataLoadButton", mainMenu, "Load Data");
dataLoadButton->getSelectCallbacks().add(
this, &CrustaApp::showDataDialogCallback);
verticalScaleSettings.createMenuEntry(mainMenu);
opacitySettings.createMenuEntry(mainMenu);
lightSettings.createMenuEntry(mainMenu);
/* Inject the map management menu entries */
crusta->getMapManager()->addMenuEntry(mainMenu);
//color map settings dialog toggle
layerSettings.createMenuEntry(mainMenu);
/* Create a button to open or hide the palette editor dialog: */
ToggleButton* showPaletteEditorToggle = new ToggleButton(
"ShowPaletteEditorToggle", mainMenu, "Palette Editor");
showPaletteEditorToggle->setToggle(false);
showPaletteEditorToggle->getValueChangedCallbacks().add(
this, &CrustaApp::showPaletteEditorCallback);
/* Create settings submenu */
Popup* settingsMenuPopup =
new Popup("SettingsMenuPopup", Vrui::getWidgetManager());
SubMenu* settingsMenu =
new SubMenu("Settings", settingsMenuPopup, false);
//line decoration toggle
ToggleButton* decorateLinesToggle = new ToggleButton(
"DecorateLinesToggle", settingsMenu, "Decorate Lines");
decorateLinesToggle->setToggle(SETTINGS->lineDecorated);
decorateLinesToggle->getValueChangedCallbacks().add(
this, &CrustaApp::decorateLinesCallback);
//terrain color settings dialog toggle
terrainColorSettings.createMenuEntry(settingsMenu);
/* Create the advanced submenu */
Popup* advancedMenuPopup =
new Popup("AdvancedMenuPopup", Vrui::getWidgetManager());
SubMenu* advancedMenu =
new SubMenu("Advanced", advancedMenuPopup, false);
//toogle display of the debugging grid
ToggleButton* debugGridToggle = new ToggleButton(
"DebugGridToggle", advancedMenu, "Debug Grid");
debugGridToggle->setToggle(false);
debugGridToggle->getValueChangedCallbacks().add(
this, &CrustaApp::debugGridCallback);
//toogle display of the debugging sphere
ToggleButton* debugSpheresToggle = new ToggleButton(
"DebugSpheresToggle", advancedMenu, "Debug Spheres");
debugSpheresToggle->setToggle(false);
debugSpheresToggle->getValueChangedCallbacks().add(
this, &CrustaApp::debugSpheresCallback);
advancedMenu->manageChild();
CascadeButton* advancedMenuCascade = new CascadeButton(
"AdvancedMenuCascade", settingsMenu, "Advanced");
advancedMenuCascade->setPopup(advancedMenuPopup);
settingsMenu->manageChild();
CascadeButton* settingsMenuCascade = new CascadeButton(
"SettingsMenuCascade", mainMenu, "Settings");
settingsMenuCascade->setPopup(settingsMenuPopup);
/* Navigation reset: */
Button* resetNavigationButton = new Button(
"ResetNavigationButton",mainMenu,"Reset Navigation");
resetNavigationButton->getSelectCallbacks().add(
this, &CrustaApp::resetNavigationCallback);
/* Finish building the main menu: */
mainMenu->manageChild();
Vrui::setMainMenu(popMenu);
}
示例3: main
int main(int argc, char *argv[]) {
#if VERBOSE
printf("LIMBS OFF - verbose version\n\n"
"feel free to explore our little world.\n"
"as you will learn, it's not very big.\n"
"it's supposed to be a fighting/platform\n"
"game, with a focus on manipulating physics.\n"
"right now we don't even have interaction.\n"
"we are trying to fix that. you can help!\n\n"
"we need programmers, artists, everything.\n"
"see TODO for what needs to be done, and\n"
"HACKING for coding style and best practices.\n"
"check out https://github.com/stiell/limbs-off\n"
"and https://plaimi.net for more information.\n\n");
printf("hit alt+enter to enter and leave fullscreen.\n\n");
#endif
Screen::setVideoMode(1024, 768, 32);
Screen* screen = Screen::getInstance();
screen->setDrawingMode(Screen::DM_FRONT_TO_BACK | Screen::DM_SMOOTH, -1);
SDL_Event event;
Game* limbsOff = NULL;
Menu menu;
MenuGraphic menugraphic(&menu);
bool running = true;
bool menuP = true;
int prevWidth_, prevHeight_;
Uint8 *keystate = SDL_GetKeyState(NULL);
while (running) {
// Events
while (SDL_PollEvent(&event)) {
//Quit
if (event.type == SDL_QUIT) {
running = false;
if (limbsOff)
limbsOff->cease();
}
// Screen
if ( (keystate[SDLK_LALT] || keystate[SDLK_RALT])
&& event.type == SDL_KEYDOWN &&
event.key.keysym.sym == SDLK_RETURN) {
// Enter/leave fullscreen
if (!screen->getFullscreen()) {
prevWidth_ = screen->getSurfaceWidth();
prevHeight_ = screen->getSurfaceHeight();
screen->setVideoMode(0, 0, 32, true);
} else
screen->setVideoMode(prevWidth_, prevHeight_, 32, false);
}
if (screen->handle(event))
continue;
// Menu
if (event.type == SDL_KEYDOWN &&
event.key.keysym.sym == SDLK_ESCAPE)
menuP = !menuP;
if (menuP)
menuP = !menu.handle(event);
// Game
else
if (limbsOff)
limbsOff->handle(event);
if (event.type == SDL_USEREVENT) {
if (event.user.code == NEW_GAME)
if (limbsOff)
delete limbsOff;
limbsOff = new Game(screen);
}
}
// Draw
glClear(GL_COLOR_BUFFER_BIT);
// Menu
if (menuP)
menugraphic.draw();
// Game
if (limbsOff)
limbsOff->main();
// Swap buffers
SDL_GL_SwapBuffers();
}
#if VERBOSE
printf("thank you for playing LIMBS OFF.\n");
#endif
return 0;
}
示例4: updateQuantityLabel
////////////////////////////////////////////////////////
//
// ParticleMainScene
//
////////////////////////////////////////////////////////
void ParticleMainScene::initWithSubTest(int asubtest, int particles)
{
//srandom(0);
subtestNumber = asubtest;
Size s = Director::getInstance()->getWinSize();
lastRenderedCount = 0;
quantityParticles = particles;
MenuItemFont::setFontSize(65);
MenuItemFont *decrease = MenuItemFont::create(" - ", [&](Object *sender) {
quantityParticles -= kNodesIncrease;
if( quantityParticles < 0 )
quantityParticles = 0;
updateQuantityLabel();
createParticleSystem();
});
decrease->setColor(Color3B(0,200,20));
MenuItemFont *increase = MenuItemFont::create(" + ", [&](Object *sender) {
quantityParticles += kNodesIncrease;
if( quantityParticles > kMaxParticles )
quantityParticles = kMaxParticles;
updateQuantityLabel();
createParticleSystem();
});
increase->setColor(Color3B(0,200,20));
Menu *menu = Menu::create(decrease, increase, NULL);
menu->alignItemsHorizontally();
menu->setPosition(Point(s.width/2, s.height/2+15));
addChild(menu, 1);
LabelTTF *infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30);
infoLabel->setColor(Color3B(0,200,20));
infoLabel->setPosition(Point(s.width/2, s.height - 90));
addChild(infoLabel, 1, kTagInfoLayer);
// particles on stage
LabelAtlas *labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.');
addChild(labelAtlas, 0, kTagLabelAtlas);
labelAtlas->setPosition(Point(s.width-66,50));
// Next Prev Test
ParticleMenuLayer* menuLayer = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx);
addChild(menuLayer, 1, kTagMenuLayer);
menuLayer->release();
// Sub Tests
MenuItemFont::setFontSize(40);
Menu* pSubMenu = Menu::create();
for (int i = 1; i <= 6; ++i)
{
char str[10] = {0};
sprintf(str, "%d ", i);
MenuItemFont* itemFont = MenuItemFont::create(str, CC_CALLBACK_1(ParticleMainScene::testNCallback, this));
itemFont->setTag(i);
pSubMenu->addChild(itemFont, 10);
if (i <= 3)
{
itemFont->setColor(Color3B(200,20,20));
}
else
{
itemFont->setColor(Color3B(0,200,20));
}
}
pSubMenu->alignItemsHorizontally();
pSubMenu->setPosition(Point(s.width/2, 80));
addChild(pSubMenu, 2);
LabelTTF *label = LabelTTF::create(title().c_str(), "Arial", 40);
addChild(label, 1);
label->setPosition(Point(s.width/2, s.height-32));
label->setColor(Color3B(255,255,40));
updateQuantityLabel();
createParticleSystem();
schedule(schedule_selector(ParticleMainScene::step));
}