*/JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetCheckBoxesSelection(
		JNIEnv* env, jclass clazz, jint handle, jint idx) {
	if (handle) {
		IrrlichtDevice* device = (IrrlichtDevice*) handle;
		IGUIEnvironment* irrenv = device->getGUIEnvironment();
		IGUIElement* element = irrenv->getFocus();
		if (element) {
			IGUIWindow* window = (IGUIWindow*) (element);
			core::list<IGUIElement*> children = window->getChildren();
			core::list<IGUIElement*>::Iterator current = children.begin();
			int i = 0;
			do {
				if ((*current)->getType() == EGUIET_CHECK_BOX && i++ == idx) {
					break;
				}
				current++;
			} while (current != children.end());
			if (current == children.end()) {
				return;
			}
			IGUICheckBox* checkbox = (IGUICheckBox*) *current;
			checkbox->setChecked(true);
			SEvent e;
			e.EventType = EET_GUI_EVENT;
			e.GUIEvent.Caller = checkbox;
			e.GUIEvent.Element = 0;
			e.GUIEvent.EventType = EGET_CHECKBOX_CHANGED;
			window->OnEvent(e);
			irrenv->setFocus(window);
		}
	}
}
//! adds a checkbox
IGUICheckBox* CGUIEnvironment::addCheckBox(bool checked, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, const wchar_t* text)
{
	IGUICheckBox* b = new CGUICheckBox(checked, this,
	                                   parent ? parent : this, id, rectangle);

	if (text)
		b->setText(text);

	b->drop();
	return b;
}
Beispiel #3
0
void EditorEventReceiver::askForParameters(bool previous_was_bad)
{
	if (editor->getAllEditorNodes().size() == 0)
	{
		env->addMessageBox(L"Warning", L"There is nothing in the scene...");
	}
	else
	{
		// create the window
		IGUIWindow* wnd = env->addWindow(core::rect<s32>(driver->getScreenSize().Width/2-200,100,driver->getScreenSize().Width/2+200,460),
			true, L"Parameters", 0, GUI_ID_ASK_PARAMETERS_WINDOW);

		s32 y=20;
		if (editor->getName() == "untitled")
		{
			env->addStaticText(L"WARNING: this scene has never been saved and thus is named [untitled]. The simulation output will overwrite all files in \"simulated/untitled\" !", core::rect<s32>(20,y,380,y+30), false, true, wnd);
			y += 30;
		}

		env->addStaticText(L"WARNING: If you press \"GO!\", all player data will be unloaded. You will need to reload a video to watch it.", core::rect<s32>(20,y,380,y+30), false, true, wnd);
		
		y += 30;
		if (previous_was_bad)
			env->addStaticText(L"WRONG PARAMETERS, please try again. Choose the parameters for tetrahedrization and simulation.", core::rect<s32>(20,y,380,y+30), false, true, wnd);
		else
			env->addStaticText(L"Please, choose the parameters for tetrahedrization and simulation.", core::rect<s32>(20,y,380,y+30), false, true, wnd);

		y += 30;
		env->addStaticText(L"Approximate number of tetrahedra to be generated for each object (min: 10, max: 1,000,000)", core::rect<s32>(20,y,380,y+20), false, true, wnd);
		env->addEditBox(L"500", core::rect<s32>(40,y+20,80,y+36), true, wnd, GUI_ID_ASK_PARAMETERS_NBTET);
		y += 40;
		env->addStaticText(L"Number of frames to compute (min: 1)", core::rect<s32>(20,y,380,y+20), false, true, wnd);
		env->addEditBox(L"200", core::rect<s32>(40,y+20,80,y+36), true, wnd, GUI_ID_ASK_PARAMETERS_NBFRAME);
		y += 40;
		env->addStaticText(L"Frame step (strict-min: 0)", core::rect<s32>(20,y,380,y+20), false, true, wnd);
		env->addEditBox(L"0.01", core::rect<s32>(40,y+20,80,y+36), true, wnd, GUI_ID_ASK_PARAMETERS_DELTAT);
		y += 45;
		env->addStaticText(L"Handle fractures", core::rect<s32>(40,y,380,y+20), false, true, wnd);
		env->addCheckBox(false, core::rect<s32>(20,y+2,36,y+18), wnd, GUI_ID_ASK_PARAMETERS_FRACTURE);
		/*y += 20;
		env->addStaticText(L"Handle self-collisions", core::rect<s32>(40,y+4,380,y+20), false, true, wnd);*/
		IGUICheckBox* cb = env->addCheckBox(false, core::rect<s32>(20,y+2,36,y+18), wnd, GUI_ID_ASK_PARAMETERS_SELFCOLLISIONS);
		cb->setVisible(false);
		cb->setEnabled(false);

		y += 50;
		env->addButton(core::rect<s32>(60,y,100,y+16), wnd, GUI_ID_ASK_PARAMETERS_GO_BUTTON, L"GO!");
		env->addButton(core::rect<s32>(320,y,360,y+16), wnd, GUI_ID_ASK_PARAMETERS_CANCEL_BUTTON, L"Cancel");
	}
}
Beispiel #4
0
	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 == MYGUI_CURRENTIMAGE)
				{
					IGUIImage* img = (IGUIImage*)env->getRootGUIElement()->getElementFromId(MYGUI_IMAGE,true);
					s32 i = ((IGUIScrollBar*)event.GUIEvent.Caller)->getPos();
					img->setImage(FontTool->currentTextures[i]);

					return true;
				}
				break;
			case EGET_COMBO_BOX_CHANGED:
				if (id == MYGUI_CHARSET)
				{
					IGUIComboBox* cbo = (IGUIComboBox*)event.GUIEvent.Caller;
					IGUIComboBox* cbo_1 = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_FONTNAME,true);
					core::stringw str=FontTool->FontNames[cbo_1->getSelected()];
					u32 j=0;
					FontTool->selectCharSet(cbo->getSelected());
					// rebuild font list
					cbo = cbo_1;
					cbo->clear();
					for (u32 i=0; i < FontTool->FontNames.size(); ++i){
						cbo->addItem(FontTool->FontNames[i].c_str());
						if(FontTool->FontNames[i]==str) j=i;
					}
					cbo->setSelected(j);
					return true;
				}
				else if(id==MYGUI_FONTNAME){
					IGUIComboBox* cbo = (IGUIComboBox*)event.GUIEvent.Caller;
					std::cout << FontTool->FontNames[cbo->getSelected()].c_str() << std::endl;
				}
				break;
			case EGET_CHECKBOX_CHANGED:
				if (id == MYGUI_VECTOR)
				{
					IGUICheckBox* chk = (IGUICheckBox*)event.GUIEvent.Caller;

					IGUIComboBox *cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_FORMAT,true);
					cbo->clear();

					if (chk->isChecked() && VecTool)
					{
						// vector formats
						for (s32 i=0; fileformats[i] != 0; ++i)
							cbo->addItem( core::stringw(vectorfileformats[i]).c_str());

					}
					else
					{

						// bitmap formats
						if (!FontTool->UseAlphaChannel)
						{
							// add non-alpha formats
							for (s32 i=0; fileformats[i] != 0; ++i)
								cbo->addItem( core::stringw(fileformats[i]).c_str());
						}
						// add formats which support alpha
						for (s32 i=0; alphafileformats[i] != 0; ++i)
							cbo->addItem( core::stringw(alphafileformats[i]).c_str());
					}

				}
				break;

			case EGET_BUTTON_CLICKED:

				if (id == MYGUI_CREATE)
				{
					// create the font with the params
					IGUIComboBox* cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_CHARSET, true);
					int charset = cbo->getSelected();

					cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_FONTNAME,true);
					int fontname = cbo->getSelected();

					/*
					cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_SIZE,true);
					int fontsize = cbo->getSelected();
					*/

					int fontsize=wcstol(((IGUIEditBox*)env->getRootGUIElement()->getElementFromId(MYGUI_SIZE,true))->getText(),NULL,10);

					cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_TEXWIDTH,true);
					int texwidth = cbo->getSelected();

					cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_TEXHEIGHT,true);
					int texheight = cbo->getSelected();

					IGUICheckBox* chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(MYGUI_BOLD,true);
					bool bold = chk->isChecked();
					chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(MYGUI_ITALIC,true);
					bool italic = chk->isChecked();

					chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(MYGUI_ALPHA,true);
					bool alpha = chk->isChecked();

					chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(MYGUI_ANTIALIAS,true);
					bool aa = chk->isChecked();

					chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(201,true);
					bool usedOnly = chk->isChecked();

					chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(202,true);
					bool excludeLatin = chk->isChecked();

					// vector fonts disabled
					//chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(MYGUI_VECTOR,true);
					bool vec = false;//chk->isChecked();

					FontTool->makeBitmapFont(fontname, charset, /*FontTool->FontSizes[fontsize]*/ fontsize, texturesizes[texwidth], texturesizes[texheight], bold, italic, aa, alpha, usedOnly, excludeLatin);

					IGUIScrollBar* scrl = (IGUIScrollBar*)env->getRootGUIElement()->getElementFromId(MYGUI_CURRENTIMAGE,true);
					scrl->setMax(FontTool->currentTextures.size() == 0 ? 0 : FontTool->currentTextures.size()-1);

					if (FontTool->currentTextures.size() > 0)
					{
						IGUIImage* img = (IGUIImage*)env->getRootGUIElement()->getElementFromId(MYGUI_IMAGE,true);
						img->setImage(FontTool->currentTextures[0]);
						scrl->setPos(0);
					}

					// make sure users pick a file format that supports alpha channel
					cbo = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_FORMAT,true);
					cbo->clear();

					if (vec)
					{
						// add vector formats
						for (s32 i=0; fileformats[i] != 0; ++i)
							cbo->addItem( core::stringw(vectorfileformats[i]).c_str());
					}
					else
					{
						if (!alpha)
						{
							// add non-alpha formats
							for (s32 i=0; fileformats[i] != 0; ++i)
								cbo->addItem( core::stringw(fileformats[i]).c_str());
						}
						// add formats which support alpha
						for (s32 i=0; alphafileformats[i] != 0; ++i)
							cbo->addItem( core::stringw(alphafileformats[i]).c_str());
					}
					if (VecTool)
					{
						delete VecTool;
						VecTool = 0;
					}
					if (vec)
					{
						VecTool = new CVectorFontTool(FontTool);
					}

					/* Message box letting the user know the process is complete */
					env->addMessageBox(L"Create", completeText);

					return true;
				}

				if (id == MYGUI_SAVE)
				{
					IGUIEditBox *edt  = (IGUIEditBox*)env->getRootGUIElement()->getElementFromId(MYGUI_FILENAME,true);
					core::stringc name = edt->getText();

					IGUIComboBox *fmt  = (IGUIComboBox*)env->getRootGUIElement()->getElementFromId(MYGUI_FORMAT,true);
					core::stringc format = fmt->getItem(fmt->getSelected());

					// vector fonts disabled
					// IGUICheckBox *chk = (IGUICheckBox*)env->getRootGUIElement()->getElementFromId(MYGUI_VECTOR,true);
					// bool vec = chk->isChecked();
					bool vec = false;

					if (vec && VecTool)
						VecTool->saveVectorFont(name.c_str(), format.c_str());
					else
						FontTool->saveBitmapFont(name.c_str(), format.c_str());

					return true;
				}

				if (id == MYGUI_HELPBUTTON)
				{
					env->addMessageBox(L"Irrlicht Unicode Font Tool", helptext);
					return true;
				}

				break;

			default:
				break;
			}
		}

		return false;
	}
Beispiel #5
0
 bool                  getSwapState()    { return m_swap_uv->isChecked();        }
Beispiel #6
0
 bool                  getClosedState()  { return m_closed_road_cb->isChecked(); }
Beispiel #7
0
	virtual bool OnEvent(const SEvent& event)
	{
		// Escape swaps Camera Input
		if (event.EventType == EET_KEY_INPUT_EVENT
				&& event.KeyInput.PressedDown == false)
		{
			if (event.KeyInput.Key == irr::KEY_ESCAPE)
			{
				if (g_Device)
				{
					scene::ICameraSceneNode * camera =
							g_Device->getSceneManager()->getActiveCamera();
					if (camera)
					{
						camera->setInputReceiverEnabled(
								!camera->isInputReceiverEnabled());
					}
					return true;
				}
			}
		}
		else if (event.EventType == EET_GUI_EVENT)
		{
			s32 id = event.GUIEvent.Caller->getID();
			//IGUIEnvironment* env = g_Device->getGUIEnvironment();
			switch (event.GUIEvent.EventType)
			{
			case EGET_SCROLL_BAR_CHANGED:
			{
				IGUIScrollBar* scroll = (IGUIScrollBar*) event.GUIEvent.Caller;
				const s32 pos = scroll->getPos();
				if (id == GUI_ID_SPEED_SCROLL)
				{
					g_CameraAnimator->setMoveSpeed(pos * pos / 100000.0);
				}
				else if (id == GUI_ID_LEVEL)
				{
					//g_EarthVisualization->setLevel(pos);
				}
			}
				break;
			case EGET_CHECKBOX_CHANGED:
			{
				IGUICheckBox* checkBox = (IGUICheckBox*) event.GUIEvent.Caller;
				if (id == GUI_ID_WIREFRAME)
				{
					g_EarthVisualization->setWireframe(checkBox->isChecked());
				}
				else if (id == GUI_ID_MESH_UPDATE)
				{
					g_EarthVisualization->setMeshGenerated(
							checkBox->isChecked());
				}
			}
				break;
			default:
				break;
			}

		}
		else if (event.EventType == EET_USER_EVENT)
		{
			if (event.UserEvent.UserData1 == ANIMATION_MOVE_EVENT)
			{
				ISceneNode* node = (ISceneNode*) event.UserEvent.UserData2;
				g_EarthVisualization->setViewerPoint(node->getPosition());

				g_LevelScroll->setPos(g_EarthVisualization->getLevel());
			}

		}

		return false;
	}
Beispiel #8
0
int main(int argc,char **argv)
{
	IrrlichtDevice* device =createDevice(video::EDT_OPENGL, core::dimension2du(800, 600));
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();
	gui::IGUIEnvironment *env = device->getGUIEnvironment();

	// create font tool
	CFontTool *fc = new CFontTool(device);
	CVectorFontTool *vc = 0;

	MyEventReceiver events(device,fc,vc);
	device->setEventReceiver(&events);

	createGUI(device, fc);

    for(int i=1; i<argc; i++)
    {
        if(!strcmp(argv[i],"-c") && i<argc-1)
        {
            i++;
            if(setUsedCharacters(argv[i]))
            {
                IGUICheckBox *box =
                    dynamic_cast<IGUICheckBox*>(device->getGUIEnvironment()
                                                     ->getRootGUIElement()
                                                     ->getElementFromId(201, true));
                box->setChecked(true);
            }

        }
        else
        {  
            // Old style: just a single parameter, assume it's a file name with pot files in it
            if(LoadPoFiles(argv[i]))
            {
                IGUICheckBox *box =
                    dynamic_cast<IGUICheckBox*>(device->getGUIEnvironment()
                    ->getRootGUIElement()
                    ->getElementFromId(201, true));
                box->setChecked(true);
            }
        }
    }   // for i <argc

	while(device->run())
	{
		device->sleep(50);
		if (device->isWindowActive())
		{

			driver->beginScene(true, true, video::SColor(0,200,200,200));
			smgr->drawAll();
			env->drawAll();
			driver->endScene();
		}
	}

	// drop the font tool and resources
	fc->drop();

	device->drop();

	return 0;
}