Ejemplo n.º 1
0
void FileDialog::init(){
  //Directories
  ListBox* dir = new ListBox();
  dir->setPosition(Vector2D(50, 100));
  dir->setSpan(Vector2D(400, 600));
  dir->addEntries(Filesystem::getDirectories(cwd_+SEPARATOR+path_));
  dir->setCbFunc(&changeDir);
  addElement(dir);
  //Files
  ListBox* file = new ListBox();
  file->setPosition(Vector2D(564, 100));
  file->setSpan(Vector2D(400, 600));
  file->addEntries(Filesystem::getFiles(cwd_+SEPARATOR+path_));
  file->setCbFunc(&writeFilename);
  addElement(file);
  //Input field
  InputField* inp = new InputField();
  inp->setOpacity(0.8f);
  inp->setPosition(Vector2D(50, 50));
  inp->setSpan(Vector2D(300,18));
  addUnscaledElement(inp);
  //OK button
  PDButton* ok = new PDButton();
  ok->setPosition(Vector2D(575, 50));
  ok->setSpan(Vector2D(75,18));
  ok->setText("  OK");
  addUnscaledElement(ok);
  //Abort button
  PDButton* abort = new PDButton();
  abort->setPosition(Vector2D(700, 50));
  abort->setSpan(Vector2D(75,18));
  abort->setText(" Abort");
  addUnscaledElement(abort);
}
Ejemplo n.º 2
0
// the button click handling
void HQRenderer::buttonDown_(int x, int y, int buttons){
  //clickable map
  if (game.getState() == PREPARE && !Mouse::instance()->isGuiClick() && clickedField_ == Vector2D(-1,-1) && !trade_){
    float dx = (float)wrld.getMapSize().x/SCREENWIDTH;
    float dy = (float)wrld.getMapSize().y/SCREENHEIGHT;
    clickedField_.x = (int)(x*dx);
    clickedField_.y = (int)(y*dy);

    //buttons to add a hero at this position
    CGE::Engine::instance()->getFont(0)->setColor(1,1,1);
    CGE::Engine::instance()->getFont(0)->print(250, 500, "Hero name:", 1, (float)HUGE_VAL);
    InputField* in = new InputField();
    in->setName("Playname");
    in->setPosition(Vector2D(400, 500));
    CGE::Engine::instance()->addGuiListener(in);

    Button* but = new Button();
    but->setPosition(Vector2D(400, 450));
    but->setText("    Play");
    but->setName("Play");
    but->setCbFunc(Menu::play);
    CGE::Engine::instance()->addGuiListener(but);
  }
  else if (game.getState() == RUN && !Mouse::instance()->isGuiClick() && awaitMapClick_){
    //awaiting click on map for various ingame functions
    float dx = (float)wrld.getMapSize().x/SCREENWIDTH;
    float dy = (float)wrld.getMapSize().y/SCREENHEIGHT;
    Vector2D click;
    click.x = (int)(x*dx);
    click.y = (int)(y*dy);
    //call function that awaits the click
    awaitMapClick_(click);
    awaitMapClick_ = NULL;
  }
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
//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;
}
Ejemplo n.º 5
0
//! 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);
}