Exemplo n.º 1
1
void MenuState::init() {
    IGUIEnvironment* guienv = GetState()->GetDevice()->getGUIEnvironment();
    guienv->clear();
    guienv->getSkin()->setFont(guienv->getFont("media/fontlucida.png"));

    // Main menu bar
    menubar=guienv->addMenu();
    menubar->addItem(L"File",-1,true,true);
    menubar->addItem(L"Edit",-1,true,true);
    menubar->addItem(L"View",-1,true,true);
    menubar->addItem(L"Project",-1,true,true);
    menubar->addItem(L"Help",-1,true,true);
    gui::IGUIContextMenu* submenu;

    // File
    submenu = menubar->getSubMenu(0);
    submenu->addItem(L"New Project",GUI_FILE_NEW_PROJECT,false);
    submenu->addItem(L"New Item",GUI_FILE_NEW_ITEM,false);
    submenu->addSeparator();
    submenu->addItem(L"Open Project",GUI_FILE_OPEN_PROJECT);
    submenu->addSeparator();
    submenu->addItem(L"Save Project",GUI_FILE_SAVE_PROJECT);
    submenu->addItem(L"Export",GUI_FILE_EXPORT);
    submenu->addSeparator();
    submenu->addItem(L"Exit",GUI_FILE_EXIT);

    // Edit
    submenu = menubar->getSubMenu(1);
    submenu->addItem(L"Undo",GUI_EDIT_UNDO,false);
    submenu->addItem(L"Redo",GUI_EDIT_REDO,false);
    submenu->addSeparator();
    submenu->addItem(
        L"Snapping",GUI_EDIT_SNAP,true,false,
        GetState()->Settings()->getSettingAsBool("snapping"),
        true
    );
    submenu->addItem(
        L"Limiting",GUI_EDIT_LIMIT,true,false,
        GetState()->Settings()->getSettingAsBool("limiting"),
        true
    );

    // View
    submenu = menubar->getSubMenu(2);
    submenu->addItem(L"Tiled View",GUI_VIEW_SP_ALL);
    submenu->addItem(L"Perspective View",GUI_VIEW_SP_PER);
    submenu->addItem(L"Top View",GUI_VIEW_SP_TOP);
    submenu->addItem(L"Front View",GUI_VIEW_SP_FRT);
    submenu->addItem(L"Side View",GUI_VIEW_SP_RHT);

    // Project
    _projectmb = menubar->getSubMenu(3);

    // Help
    submenu = menubar->getSubMenu(4);
    //submenu->addItem(L"Help",GUI_HELP_HELP,false);
    submenu->addItem(L"About",GUI_HELP_ABOUT);

    // Sidebar root
    u32 top = menubar->getAbsoluteClippingRect().LowerRightCorner.Y;
    _sidebar = guienv->addStaticText(L"Loading...",
                                     rect<s32>(
                                         (GetState()->GetDevice()->getVideoDriver()->getScreenSize().Width - 246), top+10,
                                         GetState()->GetDevice()->getVideoDriver()->getScreenSize().Width, GetState()->GetDevice()->getVideoDriver()->getScreenSize().Height
                                     ),false,true,0,GUI_SIDEBAR_TITLE
                                    );
    _sidebar->setAlignment(EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_UPPERLEFT,EGUIA_UPPERLEFT);
}
Exemplo n.º 2
0
bool
ProcTitle::OnExit(irr::IrrlichtDevice& device)
{	
	IGUIEnvironment* env = device.getGUIEnvironment();
	env->clear();

	// should I need to clear all texture here? 
	IVideoDriver* pDriver = IrrDvc.GetDriver();
	pDriver->removeAllTextures();

	return true;
}
bool EventReciever::OnEvent(const SEvent& event)
{
	switch (event.EventType)
	{
		case EET_KEY_INPUT_EVENT:
		{
			keyDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
			break;
		}

		case EET_GUI_EVENT:
		{
			s32 id = event.GUIEvent.Caller->getID();
			IGUIEnvironment* env = context.device->getGUIEnvironment();

			switch (event.GUIEvent.EventType)
			{
				case EGET_BUTTON_CLICKED:
				{
					switch (id)
					{
					case GUI_ID_PLAY_BUTTON:
						env->clear();
						*(context.gameStatePtr) = WAVE_1;
						break;
					
					case GUI_ID_INSTRUCTIONS_BUTTON:
						env->clear();
						env->addImage(context.device->getVideoDriver()->getTexture("Textures/Instructions.bmp"), vector2d<s32>(0, 0), false);
						env->addButton(rect<s32>(270, 380, 370, 420), NULL, GUI_ID_INSTRUCTIONS_BACK_BUTTON, L"Back");
						break;

					case GUI_ID_INSTRUCTIONS_BACK_BUTTON:
						env->clear();
						env->addImage(context.device->getVideoDriver()->getTexture("Textures/Menu.bmp"), vector2d<s32>(0, 0), false);
						env->addButton(rect<s32>(210, 100, 450, 170), NULL, GUI_ID_PLAY_BUTTON, L"Play");
						env->addButton(rect<s32>(210, 200, 450, 270), NULL, GUI_ID_INSTRUCTIONS_BUTTON, L"Instructions");
						env->addButton(rect<s32>(210, 300, 450, 370), NULL, GUI_ID_CONTROLS_BUTTON, L"Controls");
						env->addButton(rect<s32>(210, 400, 450, 470), NULL, GUI_ID_QUIT_BUTTON, L"Exit");
						break;

					case GUI_ID_CONTROLS_BUTTON:
						env->clear();
						env->addImage(context.device->getVideoDriver()->getTexture("Textures/Controls.bmp"), vector2d<s32>(0, 0), false);
						env->addButton(rect<s32>(270, 380, 370, 420), NULL, GUI_ID_CONTROLS_BACK_BUTTON, L"Back");
						break;

					case GUI_ID_CONTROLS_BACK_BUTTON:
						env->clear();
						env->addImage(context.device->getVideoDriver()->getTexture("Textures/Menu.bmp"), vector2d<s32>(0, 0), false);
						env->addButton(rect<s32>(210, 100, 450, 170), NULL, GUI_ID_PLAY_BUTTON, L"Play");
						env->addButton(rect<s32>(210, 200, 450, 270), NULL, GUI_ID_INSTRUCTIONS_BUTTON, L"Instructions");
						env->addButton(rect<s32>(210, 300, 450, 370), NULL, GUI_ID_CONTROLS_BUTTON, L"Controls");
						env->addButton(rect<s32>(210, 400, 450, 470), NULL, GUI_ID_QUIT_BUTTON, L"Exit");
						break;

					case GUI_ID_QUIT_BUTTON:
						env->clear();
						context.device->closeDevice();
						break;
					}
				}
			}
		}

		default:
			break;
	}
	return false;
}