Beispiel #1
0
void EsqMenuDialog::Init()
{
	if( Visible )
		return;

	GameGlobal* global = GameGlobal::Instance();

	double SizeX = 0.2, SizeY = 0.3;
	int sWidth = global->cfg->GetCfg()->Width,
		sHeight = global->cfg->GetCfg()->Height;

	IGUIEnvironment* env = device->getGUIEnvironment();
	IVideoDriver* driver = device->getVideoDriver();


	wnd = env->addWindow(CenterRect(SizeX, SizeY, sWidth, sHeight ),true,L"Меню игры");
	wnd->getCloseButton()->setVisible( false );

	int wndSizeX = sWidth*SizeX,
		  wndSizeY = sHeight *SizeY;

	
	resume = env->addButton(ItemRect(0.5,0.2, 0.9, 0.2, wndSizeX, wndSizeY ), wnd, start_id+btn_resume_esqmenu, L"Продолжить");
	leave = env->addButton(ItemRect(0.5,0.6, 0.9, 0.2, wndSizeX, wndSizeY ), wnd, start_id+btn_leave_esqmenu, L"Покинуть");
	quit = env->addButton(ItemRect(0.5,0.8, 0.9, 0.2, wndSizeX, wndSizeY ), wnd, start_id+btn_quit_esqmenu, L"Выход из игры");

	Visible = true;
}
/*
Finally, the third function creates a toolbox window. In this simple mesh
viewer, this toolbox only contains a tab control with three edit boxes for
changing the scale of the displayed model.
*/
void createToolBox()
{
	// remove tool box if already there
	IGUIEnvironment* env = Device->getGUIEnvironment();
	IGUIElement* root = env->getRootGUIElement();
	IGUIElement* e = root->getElementFromId(GUI_ID_DIALOG_ROOT_WINDOW, true);
	if (e)
		e->remove();

	// create the toolbox window
	IGUIWindow* wnd = env->addWindow(core::rect<s32>(600,45,800,480),
		false, L"Toolset", 0, GUI_ID_DIALOG_ROOT_WINDOW);

	// create tab control and tabs
	IGUITabControl* tab = env->addTabControl(
		core::rect<s32>(2,20,800-602,480-7), wnd, true, true);

	IGUITab* t1 = tab->addTab(L"Config");

	// add some edit boxes and a button to tab one
	env->addStaticText(L"Scale:",
			core::rect<s32>(10,20,60,45), false, false, t1);
	env->addStaticText(L"X:", core::rect<s32>(22,48,40,66), false, false, t1);
	env->addEditBox(L"1.0", core::rect<s32>(40,46,130,66), true, t1, GUI_ID_X_SCALE);
	env->addStaticText(L"Y:", core::rect<s32>(22,82,40,96), false, false, t1);
	env->addEditBox(L"1.0", core::rect<s32>(40,76,130,96), true, t1, GUI_ID_Y_SCALE);
	env->addStaticText(L"Z:", core::rect<s32>(22,108,40,126), false, false, t1);
	env->addEditBox(L"1.0", core::rect<s32>(40,106,130,126), true, t1, GUI_ID_Z_SCALE);

	env->addButton(core::rect<s32>(10,134,85,165), t1, GUI_ID_BUTTON_SET_SCALE, L"Set");

	// quick scale buttons
	env->addButton(core::rect<s32>(65,20,95,40), t1, GUI_ID_BUTTON_SCALE_MUL10, L"* 10");
	env->addButton(core::rect<s32>(100,20,130,40), t1, GUI_ID_BUTTON_SCALE_DIV10, L"* 0.1");

	updateScaleInfo(Model);

	// add transparency control
	env->addStaticText(L"GUI Transparency Control:",
			core::rect<s32>(10,200,150,225), true, false, t1);
	IGUIScrollBar* scrollbar = env->addScrollBar(true,
			core::rect<s32>(10,225,150,240), t1, GUI_ID_SKIN_TRANSPARENCY);
	scrollbar->setMax(255);
	scrollbar->setPos(255);

	// add framerate control
	env->addStaticText(L":", core::rect<s32>(10,240,150,265), true, false, t1);
	env->addStaticText(L"Framerate:",
			core::rect<s32>(12,240,75,265), false, false, t1);
	// current frame info
	env->addStaticText(L"", core::rect<s32>(75,240,200,265), false, false, t1,
			GUI_ID_ANIMATION_INFO);
	scrollbar = env->addScrollBar(true,
			core::rect<s32>(10,265,150,280), t1, GUI_ID_SKIN_ANIMATION_FPS);
	scrollbar->setMax(MAX_FRAMERATE);
	scrollbar->setMin(-MAX_FRAMERATE);
	scrollbar->setPos(DEFAULT_FRAMERATE);
	scrollbar->setSmallStep(1);
}
	void GUIChat::Load() {
		IGUIEnvironment* env = mainGame->env;
		wChat = env->addWindow(rect<s32>(305, 615, 1020, 640), false, L"");
		wChat->getCloseButton()->setVisible(false);
		wChat->setDraggable(false);
		wChat->setDrawTitlebar(false);
		wChat->setVisible(false);
		ebChatInput = env->addEditBox(L"", rect<s32>(3, 2, 710, 22), true, wChat, EDITBOX_CHAT);
	}
Beispiel #4
0
TextureDialog::TextureDialog(EditorState *pstate, Node *pnode, CubeSide pface):
    Dialog(pstate),
    node(pnode),
    face(pface),
    lb(NULL),
    the_image(NULL),
    context(NULL)
{
    IVideoDriver *driver = state->device->getVideoDriver();
    IGUIEnvironment *guienv = state->device->getGUIEnvironment();

    // Window and basic items
    win = guienv->addWindow(rect<s32>(340, 50, 340 + 74 * 3 + 10, 50 + 74 * 3 + 10), true,
                            narrow_to_wide(std::string(getCubeSideName(face)) + " texture").c_str());
    guienv->addButton(rect<s32>(155, 30, 74*3, 55), win, ETD_GUI_ID_APPLY,   L"Apply",  L"Apply this texture selection to the node face");
    guienv->addButton(rect<s32>(155, 60, 74*3, 85), win, ETD_GUI_ID_IMPORT,  L"Import", L"Import images from files");
    guienv->addButton(rect<s32>(84,  60, 150,  85), win, ETD_GUI_ID_ACTIONS, L"Actions");

    // Fill out listbox
    lb = guienv->addListBox(rect<s32>(10, 104, 74 * 3, 74 * 3), win, 502);
    Media *media = &state->project->media;
    std::map<std::string, Media::Image*>& images = media->getList();
    int count = 1;
    lb->addItem(L"");
    lb->setSelected(0);
    for (std::map<std::string, Media::Image*>::const_iterator it = images.begin();
            it != images.end();
            ++it) {
        if (!it->second) {
            continue;
        }
        if (it->second->name == "default") {
            lb->addItem(L"");
        } else {
            lb->addItem(narrow_to_wide(it->second->name + " [used " +
                                       num_to_str(it->second->getHolders()) + " times]").c_str());
        }
        if (it->second == node->getTexture(face))
            lb->setSelected(count);
        count++;
    }

    Media::Image *image = node->getTexture(face);
    if (image) {
        the_image = driver->addTexture("tmpicon.png", image->get());
    }

    // Context menu
    context = guienv->addContextMenu(rect<s32>(84, 85, 150, 180), win, ETD_GUI_ID_ACTIONS_CM);
    context->addItem(L"Export", ETD_GUI_ID_EXPORT);
    context->setCloseHandling(ECMC_HIDE);
    context->setVisible(false);
    context->setEventParent(win);
}
Beispiel #5
0
void EventReceiver::showExitConfirmDialog(){
	IGUIEnvironment* env = device->getGUIEnvironment();
	IGUIWindow* window = env->addWindow(
		rect<s32>(224, 200, 800, 390),true, L"Confirm dialog");
	env->addStaticText(L"Do you want to exit the game?",
		rect<s32>(35,50,600,150),
		false, // border?
		false, // wordwrap?
		window);
	for (u32 i=0; i<EGDC_COUNT ; ++i){
		SColor col = env->getSkin()->getColor((EGUI_DEFAULT_COLOR)i);
		col.setAlpha(255);
		env->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col);
	}
	env->addButton(
		rect<s32>(15, 100, 285, 170), window, EXIT_OK, L"Ok");
	env->addButton(
		rect<s32>(300, 100, 555, 170), window, EXIT_CANCEL, L"Cancel");
}
Beispiel #6
0
	virtual bool OnEvent(const SEvent& event)
	{
		if (event.EventType == EET_GUI_EVENT)
		{
			s32 id = event.GUIEvent.Caller->getID();
			IGUIEnvironment* env = Context.device->getGUIEnvironment();

			switch(event.GUIEvent.EventType)
			{

			/*
			If a scrollbar changed its scroll position, and it is
			'our' scrollbar (the one with id GUI_ID_TRANSPARENCY_SCROLL_BAR),
			then we change the transparency of all gui elements. This is an
			easy task: There is a skin object, in which all color
			settings are stored. We simply go through all colors
			stored in the skin and change their alpha value.
			*/
			case EGET_SCROLL_BAR_CHANGED:
				if (id == GUI_ID_TRANSPARENCY_SCROLL_BAR)
				{
					s32 pos = ((IGUIScrollBar*)event.GUIEvent.Caller)->getPos();
					setSkinTransparency(pos, env->getSkin());
				}
				break;

			/*
			If a button was clicked, it could be one of 'our'
			three buttons. If it is the first, we shut down the engine.
			If it is the second, we create a little window with some
			text on it. We also add a string to the list box to log
			what happened. And if it is the third button, we create
			a file open dialog, and add also this as string to the list box.
			That's all for the event receiver.
			*/
			case EGET_BUTTON_CLICKED:
				switch(id)
				{
				case GUI_ID_QUIT_BUTTON:
					Context.device->closeDevice();
					return true;

				case GUI_ID_NEW_WINDOW_BUTTON:
					{
					Context.listbox->addItem(L"Window created");
					Context.counter += 30;
					if (Context.counter > 200)
						Context.counter = 0;

					IGUIWindow* window = env->addWindow(
						rect<s32>(100 + Context.counter, 100 + Context.counter, 300 + Context.counter, 200 + Context.counter),
						false, // modal?
						L"Test window");

					env->addStaticText(L"Please close me",
						rect<s32>(35,35,140,50),
						true, // border?
						false, // wordwrap?
						window);
					}
					return true;

				case GUI_ID_FILE_OPEN_BUTTON:
					Context.listbox->addItem(L"File open");
					// There are some options for the file open dialog
					// We set the title, make it a modal window, and make sure
					// that the working directory is restored after the dialog
					// is finished.
					env->addFileOpenDialog(L"Please choose a file.", true, 0, -1, true);
					return true;

				default:
					return false;
				}
				break;

			case EGET_FILE_SELECTED:
				{
					// show the event and the selected model filename from the file dialog
					IGUIFileOpenDialog* dialog =
						(IGUIFileOpenDialog*)event.GUIEvent.Caller;
					Context.listbox->addItem(L"EGET_FILE_SELECTED");
					Context.listbox->addItem(dialog->getFileName());
				}
				break;

			case EGET_DIRECTORY_SELECTED:
				{
					// show the event and the selected directory name from the file dialog
					IGUIFileOpenDialog* dialog =
						(IGUIFileOpenDialog*)event.GUIEvent.Caller;
					Context.listbox->addItem(L"EGET_DIRECTORY_SELECTED");
					Context.listbox->addItem(dialog->getDirectoryNameW());
				}
				break;

			default:
				break;
			}
		}

		return false;
	}
bool MenuState::OnEvent(const SEvent& event) {
    if (event.EventType == EET_GUI_EVENT) {
        if (event.GUIEvent.EventType == EGET_MENU_ITEM_SELECTED) {
            IGUIContextMenu* menu = (IGUIContextMenu*)event.GUIEvent.Caller;
            switch (menu->getItemCommandId(menu->getSelectedItem())) {
            case GUI_FILE_OPEN_PROJECT:
            {
                NBEFileParser parser(GetState());
                Project* tmp = parser.open("save.nbe");

                if (tmp) {
                    delete GetState()->project;
                    GetState()->project = tmp;
                    GetState()->project->SelectNode(0);
                    GetState()->Mode()->unload();
                    init();
                    GetState()->Mode()->load();
                }
                return true;
            }
            break;
            case GUI_FILE_SAVE_PROJECT:
            {
                NBEFileParser parser(GetState());
                parser.save(GetState()->project,"save.nbe");
                return true;
            }
            break;
            case GUI_FILE_EXPORT:
            {
                LUAFileParser parser(GetState());
                parser.save(GetState()->project,"export.lua");
                return true;
            }
            break;
            case GUI_FILE_EXIT:
            {
                IGUIEnvironment* guienv = GetState()->GetDevice()->getGUIEnvironment();
                IGUIWindow* win = guienv->addWindow(rect<irr::s32>(100,100,356,215),true,L"Are you sure?");
                guienv->addButton(rect<irr::s32>(128-40,80,128+40,105),win,GUI_FILE_EXIT,L"Close",L"Close the editor");
                return true;
            }
            break;
            case GUI_EDIT_SNAP:
            {
                if (menu->isItemChecked(menu->getSelectedItem()))
                    GetState()->Settings()->setStringSetting("snapping","true");
                else
                    GetState()->Settings()->setStringSetting("snapping","false");

                menu->setItemChecked(menu->getSelectedItem(),GetState()->Settings()->getSettingAsBool("snapping"));
            }
            break;
            case GUI_EDIT_LIMIT:
            {
                if (menu->isItemChecked(menu->getSelectedItem()))
                    GetState()->Settings()->setStringSetting("limiting","true");
                else
                    GetState()->Settings()->setStringSetting("limiting","false");

                menu->setItemChecked(menu->getSelectedItem(),GetState()->Settings()->getSettingAsBool("limiting"));
            }
            break;
            case GUI_HELP_ABOUT:
            {
                core::stringw msg = L"The Nodebox Editor\n"
                                    L"Version: ";

                msg.append(EDITOR_TEXT_VERSION);
                msg.append(
                    L"\n\n"
                    L"This free nodebox editor was made by rubenwardy in C++ and Irrlicht.\n"
                    L"You can download newer versions from the Minetest forum."
                );

                GetState()->GetDevice()->getGUIEnvironment()->addMessageBox(L"About",msg.c_str());
                return true;
            }
            break;
            }
        } else if(event.GUIEvent.EventType == EGET_BUTTON_CLICKED) {
            if (event.GUIEvent.Caller->getID() == GUI_FILE_EXIT) {
                NBEFileParser parser(GetState());
                parser.save(GetState()->project,"exit.nbe");
                GetState()->CloseEditor();
                return true;
            }
        }
    }
    return false;
}
    virtual bool OnEvent(const SEvent& event)
    {
        if (event.EventType == EET_GUI_EVENT)
        {
            s32 id = event.GUIEvent.Caller->getID();
            IGUIEnvironment* env = Device->getGUIEnvironment();

            switch(event.GUIEvent.EventType)
            {

            case EGET_SCROLL_BAR_CHANGED:
                if (id == 104)
                {
                    s32 pos = ((IGUIScrollBar*)event.GUIEvent.Caller)->getPos();

                    for (s32 i=0; i<EGDC_COUNT ; ++i)
                    {
                        SColor col = env->getSkin()->getColor((EGUI_DEFAULT_COLOR)i);
                        col.setAlpha(pos);
                        env->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col);
                    }

                }
                break;

            case EGET_BUTTON_CLICKED:

                if (id == 101)
                {
                    Device->closeDevice();
                    return true;
                }

                if (id == 102)
                {
                    listbox->addItem(L"Window created");
                    cnt += 30;
                    if (cnt > 200)
                        cnt = 0;

                    IGUIWindow* window = env->addWindow(
                        rect<s32>(100 + cnt, 100 + cnt, 300 + cnt, 200 + cnt),
                        false, // modal?
                        L"Test window");

                    env->addStaticText(L"Please close me",
                        rect<s32>(35,35,140,50),
                        true, // border?
                        false, // wordwrap?
                        window);

                    return true;
                }

                if (id == 103)
                {
                    listbox->addItem(L"File open");
                    env->addFileOpenDialog(L"Please choose a file.");
                    return true;
                }

                break;
            case EGET_LISTBOX_CHANGED:
            case EGET_LISTBOX_SELECTED_AGAIN:
                if (id == 120){
                    int sel = lstLang->getSelected();
                    font = fonts[sel * 2];
                    font2 = fonts[sel * 2 + 1];
                    skin->setFont(font);
                    if (sel == 2){
                        ChangeCaption(1);
                    } else {
                        ChangeCaption(0);
                    }
                }
                break;
            }
        }

        return false;
    }
void MultiBouncerGame::initGUI()
{	
	//TODO: Filesystem tools
	//Clear file names
	m_MapFiles.clear();
	
	if( !filesystem::exists( "maps" ) )
	{
		std::cout << "Directory maps does not exist!" << std::endl;
		exit( EXIT_FAILURE );
	}
	
	//Read bouncer and map file names
	filesystem::directory_iterator end;
	for( filesystem::directory_iterator x( "maps" ); x != end; x++ )
		m_MapFiles.push_back( x->path() );
	
	for( unsigned int x = 0; x < m_MapFiles.size(); x++ )
	{
		ConfigStorage *conf = new ConfigStorage();
		conf->parseXMLFile( m_MapFiles.at( x ).string().c_str(), "Data" );
		m_MapData.push_back( conf );
	}
	
	//Get gui environment
	//TODO: Add a better method for gui management
	IGUIEnvironment *gui = m_Engine->getIrrlichtDevice()->getGUIEnvironment();
	
	//some defines for easier size definitions
	#define W mWinWidth
	#define H mWindHeight
	#define W2 (W/2)
	#define H2 (H/2)
	#define W4 (W/4)
	#define H4 (H/4)
	
	//Add main menu window
	m_MainMenu = gui->addWindow( 
		recti( 20, 20, W - 20, H - 20 ),
		false, L"MainMenu" );
	m_MainMenu->getCloseButton()->setVisible( false );
	m_MainMenu->setDraggable( false );
	m_MainMenu->setDrawTitlebar( false );

	//Add the reconnect button
	mReconnectButton = gui->addButton( recti( 10, 10, 410, 60 ),
		m_MainMenu, -1, L"(Re)connect wiimotes" );
	mReconnectButton->setVisible( m_Engine->getConfig()->get<bool>( "UseWiimotes", false ) );
	
	//Add the bouncer list
	m_MapList = gui->addListBox( recti( W4, H4, 3 * W4, 3 * H4 ), 
		m_MainMenu, -1, true );
	for( unsigned int x = 0; x < m_MapFiles.size(); x++ )
		m_MapList->addItem( stringw( 
		m_MapData.at( x )->get<String>( "MapName", "No Name!" ) ).c_str() );
	
	m_OkButton = gui->addButton( recti( W4, 3 * H4 + 10, W2 - 5, 3 * H4 + 60 ), 
		m_MainMenu, -1, L"Start" );
	
	m_PlayerCounter = gui->addSpinBox( L"Spieleranzahl:", 
		recti( W2 + 4, 3 * H4 + 10, 3 * W4, 3 * H4 + 60 ), true, m_MainMenu );
	m_PlayerCounter->getEditBox()->setTextAlignment( irr::gui::EGUIA_CENTER, 
		irr::gui::EGUIA_CENTER );
	m_PlayerCounter->setDecimalPlaces( 0 );
	m_PlayerCounter->setRange( 1.f, 32.f );
	m_PlayerCounter->setValue( 2.f );
	
	//Create ingame gui
	
	//Upper window for scores etc.
	mScoreWindow = gui->addWindow( recti( 0, 0, W, 50 ) );
	mScoreWindow->setDraggable( false );
	mScoreWindow->setDrawTitlebar( false );
	mScoreWindow->getCloseButton()->setVisible( false );
	
	mScoreCounter = gui->addStaticText( TEXT_SCORE_ZERO, 
		recti( W4, 0, 3 * W4, 50 ), false, false, mScoreWindow );
	mScoreCounter->setTextAlignment( irr::gui::EGUIA_CENTER, 
		irr::gui::EGUIA_CENTER );
	mScoreCounter->setOverrideColor( SColor( 255, 255, 255, 255 ) );
	
	//undefine sizes
	#undef W
	#undef H
	#undef W2
	#undef H2
	#undef W4
	#undef H4
	
	//hide all windows
	m_MainMenu->setVisible( false );
	mScoreWindow->setVisible( false );
}