//! The write filename callback void FileDialog::writeFilename(GuiElement* elem){ FileDialog* dia = dynamic_cast<FileDialog*>(elem->getParent()); InputField* inp = dynamic_cast<InputField*>(dia->getElement(2)); ListBox* files = dynamic_cast<ListBox*>(dia->getElement(1)); string file = files->selectedItem(); inp->setText(file); }
void Menu::options(Gui::GuiElement* elem){ //Dialog Dialog* dia = new Dialog(); CGE::Engine::instance()->addGuiListener(dia); //The plane chooser DropDownButton* planes = new DropDownButton(); planes->setPosition(Vector2D(20, 680)); dia->addUnscaledElement(planes); planes->calcDDPos(1); Editor::Plane plane = Editor::instance()->getEditPlane(); string label; if (plane == Editor::XZ) label = "XZ Plane"; else if (plane == Editor::XY) label = "XY Plane"; else if (plane == Editor::YZ) label = "YZ Plane"; planes->setText(label); planes->addEntry("XZ Plane"); planes->addEntry("XY Plane"); planes->addEntry("YZ Plane"); //The translation step InputField* input = new InputField(); input->setPosition(Vector2D(20, 650)); float step = Editor::instance()->getGridStep(); input->setText(toStr(step)); dia->addUnscaledElement(input); //OK button PDButton* ok = new PDButton(); ok->setPosition(Vector2D(575, 50)); ok->setSpan(Vector2D(75,18)); ok->setText(" OK"); ok->setCbFunc(changeOptions); dia->addUnscaledElement(ok); }
//start game bool GameState::start(){ //init camera cam.positionCamera(Vector3D(-10, 8, -12), Vector3D(-9, 8, -12), Vector3D(0, 1, 0)); cam.setCameraRadius(1); //start screen with GUI Font* f = CGE::Engine::instance()->getFont(0); f->setColor(1.0,1.0,1.0); f->print(120, 450, "Server:", 1, (float)HUGE_VAL); InputField* in = new InputField(); in->setPosition(Vector2D(200, 450)); in->setText(msg.getSetting(0)); CGE::Engine::instance()->addGuiListener(in); f->print(120, 400, "Port:", 1, (float)HUGE_VAL); InputField* in2 = new InputField(); in2->setPosition(Vector2D(200, 400)); in2->setText(msg.getSetting(1)); CGE::Engine::instance()->addGuiListener(in2); Button* but = new Button(); but->setPosition(Vector2D(200,300)); but->setText(" Play local"); CGE::Engine::instance()->addGuiListener(but); but->setCbFunc(Menu::playLocal); but = new Button(); but->setPosition(Vector2D(200, 250)); but->setText(" ´Connect"); CGE::Engine::instance()->addGuiListener(but); //void (*p)(); //p = &Renderer::connect; but->setCbFunc(Menu::connect); return true; }
//! the model properties callback void Menu::properties(Gui::GuiElement* elem){ //Dialog Dialog* dia = new Dialog(); CGE::Engine::instance()->addGuiListener(dia); //Assign texture button PDButton* assTex = new PDButton(); assTex->setPosition(Vector2D(20, 730)); assTex->setText("Assign Texture"); assTex->setCbFunc(assignTexture); dia->addUnscaledElement(assTex); Model* mdl = Graphic::instance()->getCurrModel(); //Attributes InputField* in = new InputField(); in->setPosition(Vector2D(20, 690)); if (!mdl) in->setText("-1"); else in->setText(Editor::instance()->attribString(mdl->getAttrib(0))); dia->addUnscaledElement(in); in = new InputField(); in->setPosition(Vector2D(20, 660)); if (!mdl) in->setText("-1"); else in->setText(Editor::instance()->attribString(mdl->getAttrib(1))); dia->addUnscaledElement(in); in = new InputField(); in->setPosition(Vector2D(20, 630)); if (!mdl) in->setText("-1"); else in->setText(Editor::instance()->attribString(mdl->getAttrib(2))); dia->addUnscaledElement(in); in = new InputField(); in->setPosition(Vector2D(20, 600)); if (!mdl) in->setText("-1"); else in->setText(Editor::instance()->attribString(mdl->getAttrib(3))); dia->addUnscaledElement(in); in = new InputField(); in->setPosition(Vector2D(20, 570)); if (!mdl) in->setText("-1"); else in->setText(Editor::instance()->attribString(mdl->getAttrib(4))); dia->addUnscaledElement(in); in = new InputField(); in->setPosition(Vector2D(20, 540)); if (!mdl) in->setText("-1"); else in->setText(Editor::instance()->attribString(mdl->getAttrib(5))); dia->addUnscaledElement(in); in = new InputField(); in->setPosition(Vector2D(20, 510)); if (!mdl) in->setText("-1"); else in->setText(Editor::instance()->attribString(mdl->getAttrib(6))); dia->addUnscaledElement(in); in = new InputField(); in->setPosition(Vector2D(20, 480)); if (!mdl) in->setText("-1"); else in->setText(Editor::instance()->attribString(mdl->getAttrib(7))); dia->addUnscaledElement(in); //Close button PDButton* close = new PDButton(); close->setPosition(Vector2D(575, 50)); close->setSpan(Vector2D(75,18)); close->setText(" Close"); close->setCbFunc(evaluateAttribs); dia->addUnscaledElement(close); }