Пример #1
0
//! 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);
}
Пример #2
0
void ComplexBaseInputField::xmlData( QDomDocument &document, QDomElement &parent )
{
  QDomElement element = document.createElement( mName );

  XSD::Element::List elements = mType->elements();
  XSD::Element::List::ConstIterator elemIt;
  for ( elemIt = elements.constBegin(); elemIt != elements.constEnd(); ++elemIt ) {
    InputField *field = childField( (*elemIt).name() );
    if ( !field ) {
      qDebug( "ComplexBaseInputField: No child found" );
    } else {
      field->xmlData( document, element );
    }
  }

  XSD::Attribute::List attributes = mType->attributes();
  XSD::Attribute::List::ConstIterator attrIt;
  for ( attrIt = attributes.constBegin(); attrIt != attributes.constEnd(); ++attrIt ) {
    InputField *field = childField( (*attrIt).name() );
    if ( !field ) {
      qDebug( "ComplexBaseInputField: No child found" );
    } else {
      element.setAttribute( field->name(), field->data() );
    }
  }

  parent.appendChild( element );
}
Пример #3
0
void ListInputField::setXMLData(const QDomElement &element)
{
    InputField::List::Iterator it;
    for(it = mFields.begin(); it != mFields.end(); ++it)
    {
        delete *it;
    }
    mFields.clear();

    QDomNode node = element.firstChild();
    while(!node.isNull())
    {
        QDomElement child = node.toElement();
        if(!child.isNull())
        {
            InputField *field = InputFieldFactory::self()->createField(name(), mTypeName);
            if(field)
            {
                field->setXMLData(child);
                appendChild(field);
            }
            else
                qDebug("ListInputField: Unable to create field of type %s", mTypeName.latin1());
        }

        node = node.nextSibling();
    }
}
Пример #4
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;
  }
}
Пример #5
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);
}
	void MouseUp()
	{
		if (stricmp(m_name, LANGUAGEPHRASE("editor_generate")) == 0)
		{
			LandscapeDef *def = &g_app->m_location->m_levelFile->m_landscape;
			g_app->m_location->m_landscape.Init(def);
		}
		else if (stricmp(m_name, LANGUAGEPHRASE("editor_randomise")) == 0)
		{
			m_def->m_randomSeed = (int)(GetHighResTime() * 1000.0f);
			InputField *randomSeed = (InputField *)m_parent->GetButton(LANGUAGEPHRASE("editor_seed"));
			if (randomSeed)
			{
				randomSeed->Refresh();
			}
			LandscapeDef *def = &g_app->m_location->m_levelFile->m_landscape;
			g_app->m_location->m_landscape.Init(def);
		}
        else if( stricmp(m_name, LANGUAGEPHRASE("editor_delete")) == 0 )
        {
            int tileId = ((LandscapeTileEditWindow *) m_parent)->m_tileId;
            g_app->m_location->m_landscape.DeleteTile( tileId );
            EclRemoveWindow( m_parent->m_name );
        }
        else if( stricmp(m_name, LANGUAGEPHRASE("editor_clone")) == 0 )
        {
            Vector3 rayStart;
	        Vector3 rayDir;
	        g_app->m_camera->GetClickRay(g_app->m_renderer->ScreenW()/2, g_app->m_renderer->ScreenH()/2, &rayStart, &rayDir);
            Vector3 _pos;
            g_app->m_location->m_landscape.RayHit( rayStart, rayDir, &_pos );

            LandscapeDef *landscapeDef = &(g_app->m_location->m_levelFile->m_landscape);
    	    LandscapeTile *tile = new LandscapeTile();
    	    g_app->m_location->m_levelFile->m_landscape.m_tiles.PutDataAtEnd(tile);
            tile->m_size = m_def->m_size;
            tile->m_posX = _pos.x - tile->m_size/2;
            tile->m_posY = m_def->m_posY;
            tile->m_posZ = _pos.z - tile->m_size/2;
            tile->m_fractalDimension = m_def->m_fractalDimension;
            tile->m_heightScale = m_def->m_heightScale;
            tile->m_desiredHeight = m_def->m_desiredHeight;
            tile->m_randomSeed = m_def->m_randomSeed;
            tile->m_lowlandSmoothingFactor = m_def->m_lowlandSmoothingFactor;
            tile->m_generationMethod = m_def->m_generationMethod;

		    LandscapeDef *def = &g_app->m_location->m_levelFile->m_landscape;
            g_app->m_location->m_landscape.Init(def);

        }
        else if( stricmp(m_name, LANGUAGEPHRASE("editor_guidegrid")) == 0 )
        {
            int tileId = ((LandscapeTileEditWindow *) m_parent)->m_tileId;
            LandscapeGuideGridWindow *guide = new LandscapeGuideGridWindow(LANGUAGEPHRASE("editor_guidegrid"), tileId );
            guide->SetSize( 300, 300 );
            guide->SetPosition( m_parent->m_x + m_parent->m_w + 10, m_parent->m_y );
            EclRegisterWindow( guide, m_parent );
        }
	}
Пример #7
0
//! evaluate attribs button
void Menu::evaluateAttribs(Gui::GuiElement* elem){
  Model* mdl = Graphic::instance()->getCurrModel();
  if (!mdl)
    return;
  Dialog* dia = dynamic_cast<Dialog*>(elem->getParent());
  InputField* in = dynamic_cast<InputField*>(dia->getElement(1));
  int att = Editor::instance()->attribValue(in->getText());
  mdl->setAttrib(0,att);
  in = dynamic_cast<InputField*>(dia->getElement(2));
  att = Editor::instance()->attribValue(in->getText());
  mdl->setAttrib(1,att);
  in = dynamic_cast<InputField*>(dia->getElement(3));
  att = Editor::instance()->attribValue(in->getText());
  mdl->setAttrib(2,att);
  in = dynamic_cast<InputField*>(dia->getElement(4));
  att = Editor::instance()->attribValue(in->getText());
  mdl->setAttrib(3,att);
  in = dynamic_cast<InputField*>(dia->getElement(5));
  att = Editor::instance()->attribValue(in->getText());
  mdl->setAttrib(4,att);
  in = dynamic_cast<InputField*>(dia->getElement(6));
  att = Editor::instance()->attribValue(in->getText());
  mdl->setAttrib(5,att);
  in = dynamic_cast<InputField*>(dia->getElement(7));
  att = Editor::instance()->attribValue(in->getText());
  mdl->setAttrib(6,att);
  in = dynamic_cast<InputField*>(dia->getElement(8));
  att = Editor::instance()->attribValue(in->getText());
  mdl->setAttrib(7,att);
}
Пример #8
0
void Menu::changeOptions(Gui::GuiElement* elem){
  Dialog* dia = dynamic_cast<Dialog*>(elem->getParent());
  //The edit plane
  DropDownButton* dd = dynamic_cast<DropDownButton*>(dia->getElement(0));
  Editor::Plane plane = (Editor::Plane)dd->getSelection();
  Editor::instance()->setEditPlane(plane);
  //The translation step
  InputField* input = dynamic_cast<InputField*>(dia->getElement(1));
  float step = toFloat(input->getText());
  Editor::instance()->setGridStep(step);
}
Пример #9
0
void SimpleBaseInputField::xmlData( QDomDocument &document, QDomElement &parent )
{
  if ( mType->subType() == Schema::SimpleType::TypeRestriction ) {
    InputField *field = mFields.first();
    if ( !field ) {
      qDebug( "SimpleBaseInputField: No child found" );
    } else {
      field->xmlData( document, parent );
    }
  } else {
    qDebug( "SimpleBaseInputField: Unsupported subtype" );
  }
}
Пример #10
0
void SimpleBaseInputField::setData( const QString &data )
{
  if ( mType->subType() == Schema::SimpleType::TypeRestriction ) {
    InputField *field = mFields.first();
    if ( !field ) {
      qDebug( "SimpleBaseInputField: No child found" );
    } else {
      field->setData( data );
    }
  } else {
    qDebug( "SimpleBaseInputField: Unsupported subtype" );
  }
}
Пример #11
0
QString SimpleBaseInputField::data() const
{
  if ( mType->subType() == Schema::SimpleType::TypeRestriction ) {
    InputField *field = mFields.first();
    if ( !field ) {
      qDebug( "SimpleBaseInputField: No child found" );
    } else {
      field->data();
    }
  } else {
    qDebug( "SimpleBaseInputField: Unsupported subtype" );
  }

  return QString();
}
Пример #12
0
QWidget *SimpleBaseInputField::createWidget( QWidget *parent )
{
  if ( mType->subType() == Schema::SimpleType::TypeRestriction ) {
    InputField *field = mFields.first();
    if ( !field ) {
      qDebug( "SimpleBaseInputField: No child found" );
      return 0;
    } else {
      return field->createWidget( parent );
    }
  } else {
    qDebug( "SimpleBaseInputField: Unsupported subtype" );
    return 0;
  }
}
Пример #13
0
void ListWidget::edit()
{
    int pos = mView->currentItem();

    if(pos == -1)
        return;

    InputField *field = mParentField->childFields()[ pos ];
    if(!field)
        return;

    OutputDialog dlg(field->createWidget(this), this);
    dlg.exec();

    update();
}
Пример #14
0
void SimpleBaseInputField::setXMLData( const QDomElement &element )
{
  if ( mName != element.tagName() ) {
    qDebug( "SimpleBaseInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
    return;
  }

  if ( mType->subType() == Schema::SimpleType::TypeRestriction ) {
    InputField *field = childField( element.tagName() );
    if ( !field ) {
      qDebug( "SimpleBaseInputField: Child field %s does not exists", element.tagName().latin1() );
    } else {
      field->setXMLData( element );
    }
  } else {
    qDebug( "SimpleBaseInputField: Unsupported subtype" );
  }
}
Пример #15
0
void ListWidget::add()
{
    InputField *field = InputFieldFactory::self()->createField(mName, mType);
    if(!field)
    {
        qDebug("ListInputField: Unable to create field of type %s", mType.latin1());
        return;
    }

    InputDialog dlg(field->createWidget(this), this);
    if(dlg.exec())
    {
        mParentField->appendChild(field);

        update();
    }
    else
        delete field;
}
Пример #16
0
void PageInputField::setXMLData( const QDomElement &element )
{
    if ( mName != element.tagName() ) {
        qDebug( "PageInputField: Wrong dom element passed: expected %s, got %s", qPrintable( mName ), qPrintable( element.tagName() ) );
        return;
    }

    QDomNode node = element.firstChild();
    while ( !node.isNull() ) {
        QDomElement child = node.toElement();
        if ( !child.isNull() ) {
            InputField *field = childField( child.tagName() );
            if ( !field ) {
                qDebug( "PageInputField: Child field %s does not exists", qPrintable( child.tagName() ) );
            } else {
                field->setXMLData( child );
            }
        }

        node = node.nextSibling();
    }
}
Пример #17
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);
}
void InterfaceWindow::CreateValueControl( char *name, int x, int y, int w, int h,
                                          int dataType, void *value, float change, float _lowBound, float _highBound,
                                          InterfaceButton *callback, char *tooltip, bool tooltipIsLanguagePhrase )
{
    InputField *input = new InputField();
    
    if( dataType == InputField::TypeString )
    {
        input->SetProperties( name, x, y, w, h, name, tooltip, false, tooltipIsLanguagePhrase );
    }
    else
    {
        input->SetProperties( name, x+h+2, y, w-h*2-4, h, name, tooltip, false, tooltipIsLanguagePhrase );
    }

	input->m_lowBound = _lowBound;
	input->m_highBound = _highBound;
    input->SetCallback( callback );
    switch( dataType )
    {
        case InputField::TypeChar:      input->RegisterChar     ( (unsigned char *) value );    break;
        case InputField::TypeInt:       input->RegisterInt      ( (int *) value );              break;
        case InputField::TypeFloat:     input->RegisterFloat    ( (float *) value );            break;
        case InputField::TypeString:    input->RegisterString   ( (char *) value );             break;
    }
    
    RegisterButton( input );

    if( dataType != InputField::TypeString )
    {
        char nameLeft[64];
        sprintf( nameLeft, "%s left", name );
        InputScroller *left = new InputScroller();
        left->SetProperties( nameLeft, input->m_x - h-2, y, h, h, " ", "dialog_decrease", false, true );
        left->m_inputField = input;
        left->m_change = -change;
        RegisterButton( left );

        char nameRight[64];
        sprintf( nameRight, "%s right", name );
        InputScroller *right = new InputScroller();
        right->SetProperties( nameRight, input->m_x + input->m_w+2, y, h, h, " ", "dialog_increase", false, true );
        right->m_inputField = input;
        right->m_change = change;
        RegisterButton( right );
    }
}
Пример #19
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;
}
Пример #20
0
void ComplexBaseInputField::setXMLData( const QDomElement &element )
{
  if ( mName != element.tagName() ) {
    qDebug( "ComplexBaseInputField: Wrong dom element passed: expected %s, got %s", qPrintable( mName ), qPrintable( element.tagName() ) );
    return;
  }

  // elements
  if ( mType->isArray() ) {
    InputField *field = childField( "item" );
    field->setXMLData( element );
  } else {
    QDomNode node = element.firstChild();
    while ( !node.isNull() ) {
      QDomElement child = node.toElement();
      if ( !child.isNull() ) {
        InputField *field = childField( child.tagName() );
        if ( !field ) {
          qDebug( "ComplexBaseInputField: Child field %s does not exists", qPrintable( child.tagName() ) );
        } else {
          field->setXMLData( child );
        }
      }

      node = node.nextSibling();
    }
  }

  // attributes
  QDomNamedNodeMap nodes = element.attributes();
  for ( int i = 0; i < nodes.count(); ++i ) {
    QDomNode node = nodes.item( i );
    QDomAttr attr = node.toAttr();

    InputField *field = childField( attr.name() );
    if ( !field ) {
      qDebug( "ComplexBaseInputField: Child field %s does not exists", qPrintable( attr.name() ) );
    } else {
      field->setData( attr.value() );
    }
  }
}
Пример #21
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);
}
Пример #22
0
//! Get the relative path to the file
std::string FileDialog::getRelFile() const{
  InputField* inp = dynamic_cast<InputField*>(getElement(2));
  return path_+SEPARATOR+inp->getText();
}
Пример #23
0
UIElement *UserInterface::createElement(SlotType *iter, UIElement* parent) {
    UIElement *el = nullptr;
    //  ----------- КНОПКА
    if (iter->choiceValue.button != nullptr) {
        Button *b = new Button(iter);
        el = b;
        buttonIndex[b->getName()] = b;
    } else if (iter->choiceValue.image != nullptr) {
        el = new Image(iter);
    } else if (iter->choiceValue.text != nullptr) {
        el = new TextLabel(iter);
    } else if (iter->choiceValue.tableContainer != nullptr) {
        TableContainer *tabCont = new TableContainer(iter);
        for (auto subIter : iter->choiceValue.tableContainer->slot) {
            tabCont->add(createElement(subIter, tabCont));
        }
        tabCont->pack();
        el = tabCont;
        tableIndex[tabCont->getName()] = tabCont;
    } else if (iter->choiceValue.input != nullptr) {
        InputField *ipf = new InputField(iter);
        el = ipf;
        inputIndex[ipf->getName()] = ipf;
    } else if (iter->choiceValue.ddlb != nullptr) {
        DropDownListBox *lb = new DropDownListBox(iter);
        ddlbIndex[lb->getName()] = lb;
        el = lb;
    } else if (iter->choiceValue.context != nullptr) {
        ButtonContextMenu *b = new ButtonContextMenu(iter);
        el = b;
        if (b->getName().size() > 0) {
            if (contextMenuIndex.find(el->getName()) != contextMenuIndex.end()) {
                logger.warn("Context Menu with name %s already exists!", el->getName().c_str());
            }
            contextMenuIndex[el->getName()] = b;
        }
    } else if (iter->choiceValue.dialog != nullptr) {
        Dialog *d = new Dialog(iter);
        for (auto subIter : iter->choiceValue.dialog->slot) {
            d->add(createElement(subIter));
        }
        el = d;
    } else if (iter->choiceValue.imagePicker != nullptr) {
        ImagePicker *ip = new ImagePicker(iter);
        imagePickerIndex[ip->getName()] = ip;
        el = ip;
    } else if (iter->choiceValue.rgb != nullptr) {
        RGBSlider *s = new RGBSlider(iter);
        el = s;
        rgbSliderIndex[s->getName()] = s;
    } else if (iter->choiceValue.healthbar != nullptr) {
        el = new Healthbar(iter);
    } else if (iter->choiceValue.slider != nullptr) {
        Slider *s = new Slider(iter);
        el = s;
        sliderIndex[s->getName()] = s;
    } else if (iter->choiceValue.checkbox != nullptr) {
        Checkbox *lb = new Checkbox(iter);
        checkboxIndex[lb->getName()] = lb;
        el = lb;
    } else if (iter->choiceValue.radio != nullptr) {
        RadioButton *r = new RadioButton(iter);
        checkboxIndex[r->getName()] = r;
        el = r;
    } else if (iter->choiceValue.labelsList!=nullptr){
        LabelsList* ll = new LabelsList(iter);
        el = ll;
    } else if (iter->choiceValue.lineContainer!=nullptr){
        el = new LineContainer(iter);
    } else if(iter->choiceValue.containerSelector!=nullptr){
        ContainerSelector* cs;
        if(parent==nullptr) {
            cs = new ContainerSelector(iter,nullptr);
        }else{
            TableContainer *contParent = dynamic_cast<TableContainer *>(parent);
            if(contParent==nullptr){
                logger.error("ContainerSelector [%s] parent can be only TableContainer", iter->name.c_str());
                return nullptr;
            }
            cs = new ContainerSelector(iter,contParent);
        }
        containerSelectorIndex[cs->getName()]=cs;
        el=cs;
    }

    //common atrs
    if (el != nullptr) {
        el->setVisible(iter->visible);
        el->setEnabled(iter->enabled);
    }

    return el;
}
Пример #24
0
ZString api_gui_addform( ZCsl *aCsl )
{
	clear_controlid_list();

	int argCount = aCsl->get("argCount").asInt();
//	int flags = GUMPFLAG_MOVABLE | GUMPFLAG_CLOSABLE | GUMPFLAG_FOCUSABLE;
	int x = aCsl->get("x").asInt();
	int y = aCsl->get("y").asInt();
	std::string gfm_file = std::string (aCsl->get("gfm_file").buffer ());
	bool is_container = (argCount > 3) ? ((int) aCsl->get("is_container").asInt()) : false;

	Container* container = NULL;
	std::string shape;
	
	XML::Parser parser;
	XML::Node* form=NULL,* document=NULL;
	
	try
	{
		parser.loadData(gfm_file);
		document = parser.parseDocument();

		int width=640,height=480, alpha=0, flags=0, fade_alpha=0, fade_time=0;
		
		std::string onclick, onclose, onmouseup, onmousedown, onkeypressed;
		
		form = document->findNode("form");
		if ( !form )
		{
			throw;
		}
		
		form->lookupAttribute("width", width);
		form->lookupAttribute("height", height);
		form->lookupAttribute("alpha", alpha);
		form->lookupAttribute("flags", flags);
		form->lookupAttribute("shape", shape);

		XML::Node* fade_node = form->findNode("fade");
		if (fade_node)
		{
			fade_node->lookupAttribute("alpha", fade_alpha);
			fade_node->lookupAttribute("time", fade_time);
		}

		XML::Node* event_node = form->findNode("event");

		if (event_node)
		{
			event_node->lookupAttribute("onclick", onclick);
			event_node->lookupAttribute("onclose", onclose);
			event_node->lookupAttribute("onmouseup", onmouseup);
			event_node->lookupAttribute("onmousedown", onmousedown);
			event_node->lookupAttribute("onkeypressed", onkeypressed);
		}	

		if (is_container)
		{
			container = new Container();
			container->SetPosition(x,y);
			container->SetSize(width, height);
			container->SetAlpha(alpha);
			if (fade_time != 0) 
				container->FadeTo(fade_alpha, fade_time);

			x = 0, y = 0;
			
			api_addcontrol( container );

			Control* control=container;
			if (!onclose.empty()) {
				control->OnClose(on_closehandler);
				control->SetScriptFunction(FUNC_ONCLOSE, (char*)onclose.c_str());
			}
			if (!onmousedown.empty()) {
				control->OnMouseDown(on_mousedownhandler);
				control->SetScriptFunction(FUNC_ONMOUSEDOWN, (char*)onmousedown.c_str());
			}
			if (!onmouseup.empty()) {
				control->OnMouseUp(on_mouseuphandler);
				control->SetScriptFunction(FUNC_ONMOUSEUP, (char*)onmouseup.c_str());
			}

			act_container_id = container->GetID();
		}
	} catch (...) {
		//delete document;
		return "0";
	}

	int idx=0;
	XML::Node* control_node = NULL;			
	
	while ((control_node = form->findNode("control", idx++))) {
		Control* control=NULL;
		XML::Node* event_node=NULL,* gump_node=NULL, * passwd_node=NULL;
		XML::Node* check_node=NULL,* group_node=NULL,* text_node=NULL;
		
		std::string type, name;
		std::string onclick, onclose, onmouseup, onmousedown, onkeypressed;

		int left=0,top=0,width=0,height=0,freezed=0,visible=1;			
		int alpha=0,flags=0;

		if (!control_node->lookupAttribute("class", type)) continue;

		control_node->lookupAttribute("name", name);
		control_node->lookupAttribute("left", left);
		control_node->lookupAttribute("top", top);
		control_node->lookupAttribute("width", width);
		control_node->lookupAttribute("height", height);
		control_node->lookupAttribute("freezed", freezed);
		control_node->lookupAttribute("visible", visible);
		control_node->lookupAttribute("alpha", alpha);
		control_node->lookupAttribute("flags", flags);

		left+=x;
		top+=y;

		if ((event_node = control_node->findNode("event"))) {
			event_node->lookupAttribute("onclick", onclick);
			event_node->lookupAttribute("onclose", onclose);
			event_node->lookupAttribute("onmouseup", onmouseup);
			event_node->lookupAttribute("onmousedown", onmousedown);
			event_node->lookupAttribute("onkeypressed", onkeypressed);
		}	
		
		if (type=="picture" || type=="border" || type=="paperdoll") {			
			int gump=0;
			if ((gump_node = control_node->findNode("gump"))) 
				gump = gump_node->asInteger();

			//int flags = GUMPFLAG_MOVABLE | GUMPFLAG_CLOSABLE | GUMPFLAG_FOCUSABLE;
			
			if (type=="picture") {
				control = new Image(left, top, gump, flags);
			} else if (type=="border") {
				control = new Border(left,top, gump, flags);
			} else {
				control = new Paperdoll(left, top, 0);
			}
			control->SetSize(width, height);
			
		} else if (type=="button") {
			int normal=-1, over=-1, pressed=-1;
			if ((gump_node = control_node->findNode("gump"))) { 
				gump_node->lookupAttribute("normal", normal);
				gump_node->lookupAttribute("over", over);
				gump_node->lookupAttribute("pressed", pressed);
			}

			//Button *button = new Button(left,top);
			
			
			/*if (normal >= 0) button->SetButton(BUTTONGUMP_NORMAL, normal);
			if (over >= 0) button->SetButton(BUTTONGUMP_MOUSEOVER, over);
			if (pressed >= 0) button->SetButton(BUTTONGUMP_PRESSED, pressed);*/
			control = new Button( left, top );

			if (normal >= 0)
				((Button*)control)->SetButton(BUTTONGUMP_NORMAL, normal);
			if (over >= 0)
				((Button*)control)->SetButton(BUTTONGUMP_MOUSEOVER, over);
			if (pressed >= 0)
				((Button*)control)->SetButton(BUTTONGUMP_PRESSED, pressed);

			if (!onclick.empty()) {
				/*button->OnClick(on_clickhandler);
				button->SetScriptFunction(FUNC_ONCLICK, (char*)onclick.c_str());*/
				((Button*)control)->OnClick(on_clickhandler);
				((Button*)control)->SetScriptFunction(FUNC_ONCLICK, (char*)onclick.c_str());
			}
			
			//control = button;
		} else if (type=="checkbox" || type=="radio") {
			int normal=-1, checked=-1, group=0, ischecked=0;
			gump_node = control_node->findNode("gump");
			if (gump_node) { 
				gump_node->lookupAttribute("normal", normal);
				gump_node->lookupAttribute("checked", checked);
			}
			if ((check_node = control_node->findNode("checked"))) {
				ischecked = check_node->asBool();
			}
			if ((group_node = control_node->findNode("group"))) {
				group = group_node->asInteger();
			}
		} else if (type=="label" || type=="edit") {
			std::string text, align;
			int font=-1,hue=-1,password=0, label_align=-1;
			if ((text_node = control_node->findNode("text"))) {
				text = text_node->asString();
				text_node->lookupAttribute("font", font);
				text_node->lookupAttribute("hue", hue);
				text_node->lookupAttribute("align", align);
			}

			if ((passwd_node = control_node->findNode("password"))) {
				password = passwd_node->asBool();
			}
			
			if (type == "label") {
				if (align=="center") {
					label_align=1;
					left += width / 2;
					//top  += height / 2;
				} else if (align=="right") {
					label_align=2;
					left += width;
					//top  += height;
				}

				Label* label = new Label(left, top, text.c_str(), hue, font);
/*SiENcE:
				if (font >= 0) label->setFont(font);
				if (hue >= 0) label->setHue(hue);
*/
				if (label_align >= 0) label->setAlign(label_align);
					control = label;
				}
				else
				{
					font = font < 0 ? 3 : font;
					hue = hue < 0 ? 0 : hue;
					InputField *input = new InputField(left,top,width,height, text.c_str(), hue, font, password ? 42 : 0);
					input->OnKeyPress(on_keypressedhandler);
					if (!onkeypressed.empty())
						input->SetScriptFunction(FUNC_ONKEYPRESSED, (char*)onkeypressed.c_str());
					control = input;
				}
		}

		if ( !control )
		{
			continue;
		}

		api_addcontrol(control);

		add_controlid(name,control->GetID());

		if (!onclose.empty()) {
			control->OnClose(on_closehandler);
			control->SetScriptFunction(FUNC_ONCLOSE, (char*)onclose.c_str());
		}
		if (!onmousedown.empty()) {
			control->OnMouseDown(on_mousedownhandler);
			control->SetScriptFunction(FUNC_ONMOUSEDOWN, (char*)onmousedown.c_str());
		}
		if (!onmouseup.empty()) {
			control->OnMouseUp(on_mouseuphandler);
			control->SetScriptFunction(FUNC_ONMOUSEUP, (char*)onmouseup.c_str());
		}
	}

	document = NULL;

	if ( container )
	{
		if ( !shape.empty() )
		{
			container->SetShape( get_controlid( shape ) );
		}
		act_container_id = 0;
		return ZString( container->GetID() );
	}

	return "0";
}
void BuildingEditWindow::Create()
{
	DarwiniaWindow::Create();

	Building *building = g_app->m_location->GetBuilding(g_app->m_locationEditor->m_selectionId);
	DarwiniaDebugAssert(building);

	int buttonPitch = 18;
	int y = 6;

    ToolButton *mb = new ToolButton(LocationEditor::ToolMove);
	mb->SetShortProperties(LANGUAGEPHRASE("editor_move"), 10, y += buttonPitch, m_w-20);
	RegisterButton(mb);

    ToolButton *rb = new ToolButton(LocationEditor::ToolRotate);
	rb->SetShortProperties(LANGUAGEPHRASE("editor_rotate"), 10, y += buttonPitch, m_w-20);
	RegisterButton(rb);

    CloneBuildingButton *clone = new CloneBuildingButton();
    clone->SetShortProperties(LANGUAGEPHRASE("editor_clone"), 10, y+=buttonPitch, m_w-20);
    RegisterButton(clone);

    DeleteBuildingButton *db = new DeleteBuildingButton();
    db->SetShortProperties(LANGUAGEPHRASE("editor_delete"), 10, y += buttonPitch, m_w-20);
    RegisterButton(db);

    ToolButton *lb = new ToolButton(LocationEditor::ToolLink);
    lb->SetShortProperties(LANGUAGEPHRASE("editor_link"), 10, y += buttonPitch, m_w-20);
    RegisterButton(lb);

	y += buttonPitch;

    for( int i = -1; i < 3; ++i )
    {
        char name[256];
        int w = m_w/4 - 5;
        sprintf( name, "T%d",i);
        TeamButton *tb = new TeamButton(i);
        tb->SetShortProperties(name, 61 + (float)i*((float)w + 1.0f), y, w - 2);
        RegisterButton(tb);
    }

	CreateValueControl(LANGUAGEPHRASE("editor_dynamic"), InputField::TypeChar, &building->m_dynamic, y += buttonPitch,
					   1.0f, 0, 1);

	CreateValueControl(LANGUAGEPHRASE("editor_isglobal"), InputField::TypeChar, &building->m_isGlobal, y += buttonPitch,
					   1.0f, 0, 1);

    if (building->m_type == Building::TypeFactory)
	{
		InputField *intExtra = new InputField();
		intExtra->SetShortProperties(LANGUAGEPHRASE("editor_spirits"), 10, y += buttonPitch, m_w-20);
		Factory *factory = (Factory*)building;
		intExtra->RegisterInt(&factory->m_initialCapacity);
		RegisterButton(intExtra);
	}
    else if (building->m_type == Building::TypeTrunkPort)
    {
        InputField *inExtra = new InputField();
        inExtra->SetShortProperties(LANGUAGEPHRASE("editor_targetlocation"), 10, y += buttonPitch, m_w-20);
        TrunkPort *port = (TrunkPort *) building;
        inExtra->RegisterInt( &port->m_targetLocationId );
        RegisterButton(inExtra);
    }
    else if (building->m_type == Building::TypeLaserFence)
    {
        LaserFence *fence = (LaserFence *) building;
        CreateValueControl( LANGUAGEPHRASE("editor_scale"), InputField::TypeFloat, &fence->m_scale, y+=buttonPitch, 0.01f, 0.0f, 100.0f );

       DropDownMenu *menu = new DropDownMenu(true);
        menu->SetShortProperties( LANGUAGEPHRASE("editor_mode"), 10, y+=buttonPitch, m_w-20 );
        menu->AddOption( LANGUAGEPHRASE("editor_disabled") );
        menu->AddOption( LANGUAGEPHRASE("editor_enabling") );
        menu->AddOption( LANGUAGEPHRASE("editor_enabled") );
        menu->AddOption( LANGUAGEPHRASE("editor_disabling") );
		menu->AddOption( LANGUAGEPHRASE("editor_neveron") );
        menu->RegisterInt( &fence->m_mode );
        RegisterButton( menu );
    }
    else if(building->m_type == Building::TypeAntHill)
    {
        AntHill *antHill = (AntHill *) building;
        CreateValueControl( LANGUAGEPHRASE("editor_numants"), InputField::TypeInt, &antHill->m_numAntsInside, y+=buttonPitch, 1, 0, 1000 );
    }
    else if(building->m_type == Building::TypeSafeArea)
    {
        SafeArea *safeArea = (SafeArea *) building;
        CreateValueControl( LANGUAGEPHRASE("editor_size"), InputField::TypeFloat, &safeArea->m_size, y+=buttonPitch, 1.0f, 0.0f, 1000.0f );
        CreateValueControl( LANGUAGEPHRASE("editor_capacity"), InputField::TypeInt, &safeArea->m_entitiesRequired, y+=buttonPitch, 1, 0, 10000 );

        DropDownMenu *menu = new DropDownMenu(true);
        menu->SetShortProperties( LANGUAGEPHRASE("editor_entitytype"), 10, y+=buttonPitch, m_w-20 );
        for( int i = 0; i < Entity::NumEntityTypes; ++i)
        {
            menu->AddOption( Entity::GetTypeNameTranslated(i), i );
        }
        menu->RegisterInt( &safeArea->m_entityTypeRequired );
        RegisterButton( menu );
    }
    else if(building->m_type == Building::TypeTrackStart)
    {
        TrackStart *trackStart = (TrackStart *) building;
        CreateValueControl( LANGUAGEPHRASE("editor_toggledby"), InputField::TypeInt, &trackStart->m_reqBuildingId, y+=buttonPitch, 1.0f, -1.0f, 1000.0f );
    }
    else if(building->m_type == Building::TypeTrackEnd)
    {
        TrackEnd *trackEnd = (TrackEnd *) building;
        CreateValueControl( LANGUAGEPHRASE("editor_toggledby"), InputField::TypeInt, &trackEnd->m_reqBuildingId, y+=buttonPitch, 1.0f, -1.0f, 1000.0f );
    }
    else if(building->m_type == Building::TypePylonStart)
    {
        PylonStart *pylonStart = (PylonStart *) building;
        CreateValueControl( LANGUAGEPHRASE("editor_toggledby"), InputField::TypeInt, &pylonStart->m_reqBuildingId, y+=buttonPitch, 1.0f, -1.0f, 1000.0f );
    }
    else if(building->m_type == Building::TypeResearchItem )
    {
        DropDownMenu *menu = new DropDownMenu(true);
        menu->SetShortProperties( LANGUAGEPHRASE("editor_research"), 10, y+=buttonPitch, m_w-20 );
        for( int i = 0; i < GlobalResearch::NumResearchItems; ++i )
        {
            menu->AddOption( GlobalResearch::GetTypeNameTranslated( i ), i );
        }
        menu->RegisterInt( &((ResearchItem *)building)->m_researchType );
        RegisterButton( menu );
        CreateValueControl( LANGUAGEPHRASE("editor_level"), InputField::TypeInt, &((ResearchItem *)building)->m_level, y+=buttonPitch, 1, 0, 4 );
    }
    else if( building->m_type == Building::TypeTriffid )
    {
        Triffid *triffid = (Triffid *) building;
        CreateValueControl( LANGUAGEPHRASE("editor_size"), InputField::TypeFloat, &triffid->m_size, y+=buttonPitch, 0.1f, 0.0f, 50.0f );
        CreateValueControl( LANGUAGEPHRASE("editor_pitch"), InputField::TypeFloat, &triffid->m_pitch, y+=buttonPitch, 0.1f, -M_PI, M_PI );
        CreateValueControl( LANGUAGEPHRASE("editor_force"), InputField::TypeFloat, &triffid->m_force, y+=buttonPitch, 1.0f, 0.0f, 1000.0f );
        CreateValueControl( LANGUAGEPHRASE("editor_variance"), InputField::TypeFloat, &triffid->m_variance, y+=buttonPitch, 0.01f, 0.0f, M_PI );
        CreateValueControl( LANGUAGEPHRASE("editor_reload"), InputField::TypeFloat, &triffid->m_reloadTime, y+=buttonPitch, 1.0f, 0.0f, 1000.0f );

        for( int i = 0; i < Triffid::NumSpawnTypes; ++i )
        {
            CreateValueControl( Triffid::GetSpawnNameTranslated(i), InputField::TypeChar, &triffid->m_spawn[i], y+=buttonPitch, 1.0f, 0.0f, 1.0f );
        }

        CreateValueControl( LANGUAGEPHRASE("editor_usetrigger"), InputField::TypeChar, &triffid->m_useTrigger, y+=buttonPitch, 1, 0, 1 );
        CreateValueControl( LANGUAGEPHRASE("editor_triggerX"), InputField::TypeFloat, &triffid->m_triggerLocation.x, y+=buttonPitch, 1.0f, -10000.0f, 10000.0f );
        CreateValueControl( LANGUAGEPHRASE("editor_triggerZ"), InputField::TypeFloat, &triffid->m_triggerLocation.z, y+=buttonPitch, 1.0f, -10000.0f, 10000.0f );
        CreateValueControl( LANGUAGEPHRASE("editor_triggerrad"), InputField::TypeFloat, &triffid->m_triggerRadius, y+=buttonPitch, 1.0f, 0.0f, 1000.0f );

    }
    else if( building->m_type == Building::TypeBlueprintRelay )
    {
        BlueprintRelay *relay = (BlueprintRelay *) building;
        CreateValueControl( LANGUAGEPHRASE("editor_altitude"), InputField::TypeFloat, &relay->m_altitude, y+=buttonPitch, 1.0f, 0.0f, 1000.0f );
    }
    else if( building->m_type == Building::TypeBlueprintConsole )
    {
        BlueprintConsole *console = (BlueprintConsole *) building;
        CreateValueControl( LANGUAGEPHRASE("editor_segment"), InputField::TypeInt, &console->m_segment, y+=buttonPitch, 1, 0, 3 );
    }
    else if( building->m_type == Building::TypeAISpawnPoint )
    {
        AISpawnPoint *spawn = (AISpawnPoint *) building;
        DropDownMenu *menu = new DropDownMenu();
        menu->SetShortProperties( LANGUAGEPHRASE("editor_entitytype"), 10, y+=buttonPitch, m_w-20 );
        for( int i = 0; i < Entity::NumEntityTypes; ++i )
        {
            menu->AddOption( Entity::GetTypeNameTranslated(i), i );
        }
        menu->RegisterInt( &spawn->m_entityType );
        RegisterButton(menu);

        CreateValueControl( LANGUAGEPHRASE("editor_count"), InputField::TypeInt, &spawn->m_count, y+=buttonPitch, 1, 0, 1000 );
        CreateValueControl( LANGUAGEPHRASE("editor_period"), InputField::TypeInt, &spawn->m_period, y+=buttonPitch, 1, 0, 1000 );
        CreateValueControl( LANGUAGEPHRASE("editor_spawnlimit"), InputField::TypeInt, &spawn->m_spawnLimit, y+=buttonPitch, 1, 0, 1000 );
    }
    else if( building->m_type == Building::TypeSpawnPopulationLock )
    {
        SpawnPopulationLock *lock = (SpawnPopulationLock *) building;

        CreateValueControl( LANGUAGEPHRASE("editor_searchradius"), InputField::TypeFloat, &lock->m_searchRadius, y+=buttonPitch, 1.0f, 0.0f, 10000.0f );
        CreateValueControl( LANGUAGEPHRASE("editor_maxpopulation"), InputField::TypeInt, &lock->m_maxPopulation, y+=buttonPitch, 1, 0, 10000 );
    }
    else if( building->m_type == Building::TypeSpawnLink ||
             building->m_type == Building::TypeSpawnPointMaster ||
             building->m_type == Building::TypeSpawnPoint )
    {
        class ClearLinksButton: public DarwiniaButton
        {
        public:
            int m_buildingId;
            void MouseUp()
            {
                SpawnBuilding *building = (SpawnBuilding *) g_app->m_location->GetBuilding( m_buildingId );
                building->ClearLinks();
            }
        };

        ClearLinksButton *button = new ClearLinksButton();
        button->SetShortProperties( LANGUAGEPHRASE("editor_clearlinks"), 10, y+=buttonPitch, m_w-20 );
        button->m_buildingId = building->m_id.GetUniqueId();
        RegisterButton( button );
    }
    else if( building->m_type == Building::TypeScriptTrigger )
    {
        ScriptTrigger *trigger = (ScriptTrigger *) building;

        CreateValueControl( LANGUAGEPHRASE("editor_range"), InputField::TypeFloat, &trigger->m_range, y+=buttonPitch, 0.5f, 0.0f, 1000.0f );
        CreateValueControl( LANGUAGEPHRASE("editor_script"), InputField::TypeString, trigger->m_scriptFilename, y+=buttonPitch, 0,0,0 );

        DropDownMenu *menu = new DropDownMenu(true);
        menu->SetShortProperties( LANGUAGEPHRASE("editor_entitytype"), 10, y+=buttonPitch, m_w-20 );
        menu->AddOption( LANGUAGEPHRASE("editor_always"), SCRIPTRIGGER_RUNALWAYS );
        menu->AddOption( LANGUAGEPHRASE("editor_never"), SCRIPTRIGGER_RUNNEVER );
        menu->AddOption( LANGUAGEPHRASE("editor_cameraenter"), SCRIPTRIGGER_RUNCAMENTER );
        menu->AddOption( LANGUAGEPHRASE("editor_cameraview"), SCRIPTRIGGER_RUNCAMVIEW );
        for( int i = 0; i < Entity::NumEntityTypes; ++i)
        {
            menu->AddOption( Entity::GetTypeNameTranslated(i), i );
        }
        menu->RegisterInt( &trigger->m_entityType);
        RegisterButton( menu );
    }
    else if( building->m_type == Building::TypeStaticShape )
    {
        StaticShape *staticShape = (StaticShape *) building;

        CreateValueControl( LANGUAGEPHRASE("editor_scale"), InputField::TypeFloat, &staticShape->m_scale, y+=buttonPitch, 0.1f, 0.0f, 100.0f );
        CreateValueControl( LANGUAGEPHRASE("editor_shape"), InputField::TypeString, &staticShape->m_shapeName, y+=buttonPitch, 0,0,0 );
    }
    else if( building->m_type == Building::TypeIncubator )
    {
        CreateValueControl( LANGUAGEPHRASE("editor_spirits"), InputField::TypeInt, &((Incubator *) building)->m_numStartingSpirits, y+=buttonPitch, 1, 0, 1000 );
    }
    else if( building->m_type == Building::TypeEscapeRocket )
    {
        EscapeRocket *rocket = (EscapeRocket *) building;

        CreateValueControl( LANGUAGEPHRASE("editor_fuel"), InputField::TypeFloat, &rocket->m_fuel, y+=buttonPitch, 0.1f, 0.0f, 100.0f );
        CreateValueControl( LANGUAGEPHRASE("editor_passengers"), InputField::TypeInt, &rocket->m_passengers, y+=buttonPitch, 1, 0, 100 );
        CreateValueControl( LANGUAGEPHRASE("editor_spawnport"), InputField::TypeInt, &rocket->m_spawnBuildingId, y+=buttonPitch, 1, 0, 9999 );
    }
    else if( building->m_type == Building::TypeDynamicHub )
    {
        DynamicHub *hub = (DynamicHub *)building;

        CreateValueControl( LANGUAGEPHRASE("editor_shape"), InputField::TypeString, &hub->m_shapeName, y+=buttonPitch, 0,0,0 );
        CreateValueControl( LANGUAGEPHRASE("editor_requiredscore"), InputField::TypeInt, &hub->m_requiredScore, y+=buttonPitch, 1, 0, 100000 );
        CreateValueControl( LANGUAGEPHRASE("editor_minlinks"), InputField::TypeInt, &hub->m_minActiveLinks, y+=buttonPitch, 1, 0, 100 );
    }
    else if( building->m_type == Building::TypeDynamicNode )
    {
        DynamicNode *node = (DynamicNode *)building;

        CreateValueControl( LANGUAGEPHRASE("editor_shape"), InputField::TypeString, &node->m_shapeName, y+=buttonPitch, 0,0,0 );
        CreateValueControl( LANGUAGEPHRASE("editor_pointspersec"), InputField::TypeInt, &node->m_scoreValue, y+=buttonPitch, 1, 0, 1000 );
    }
	else if( building->m_type == Building::TypeFenceSwitch )
	{
		FenceSwitch *fs = (FenceSwitch *)building;

		CreateValueControl( LANGUAGEPHRASE("editor_switchonce"), InputField::TypeInt, &fs->m_lockable, y+=buttonPitch, 0, 1, 0 );
        CreateValueControl( LANGUAGEPHRASE("editor_script"), InputField::TypeString, &fs->m_script, y+=buttonPitch, 0, 0, 0 );
	}

}