示例#1
0
BotFight::BotFight(QWidget *parent):
    QWidget(parent),
    name("Bot fight"),
    mapEditor(NULL),
    visualisation(NULL),
    loadMapBtn(new QPushButton("Load...")),
    reloadMapBtn(new QPushButton("Reload map")),
    startMapEditorBtn(new QPushButton("Edit map"))
{
    setWindowTitle(name + " - " + "Empty map");

    connect(loadMapBtn, SIGNAL(clicked()), this, SLOT(loadFromFile()));
    connect(reloadMapBtn, SIGNAL(clicked()), this, SLOT(reloadMap()));
    connect(startMapEditorBtn, SIGNAL(clicked()), this, SLOT(editMap()));

    QHBoxLayout *mapControls = new QHBoxLayout();
    mapControls->addWidget(loadMapBtn);
    mapControls->addWidget(reloadMapBtn);
    mapControls->addWidget(startMapEditorBtn);
    mapControls->addStretch(1);



    mainLayout = new QGridLayout();
    setVisualisation(new Visualisation(QVector<QVector<QPointF> > ()));
    mainLayout->addLayout(mapControls, 1, 0);
    mainLayout->setSizeConstraint(QLayout::SetFixedSize);

    setLayout(mainLayout);
}
示例#2
0
void MainWindow::buttons()
{
    connect(this, SIGNAL(adminEditType()), dialHall, SLOT(editHallType()));
    connect(this, SIGNAL(isConnect()), connecting, SLOT(isConnected()));
    connect(this, SIGNAL(adminEditBldg()), dialBldg, SLOT(editBldg()));
    connect(this, SIGNAL(adminEditShow()), dialShow, SLOT(editShow()));
    connect(this, SIGNAL(adminEditTimes()),dialTimes, SLOT(editTimes()));
    connect(this, SIGNAL(adminEditMap()), dialMap, SLOT(editMap()));
    connect(this, SIGNAL(adminEditZone()), dialZone, SLOT(editZone()));

    // temp slots
    connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateRelation(int)));
}
示例#3
0
void BTEditor::edit(BTDisplay &d)
{
 char **files = PHYSFS_enumerateFiles("");
 char **i;
 int count(4);

 d.setPsuedo3DConfig(&getPsuedo3DConfigList());
 d.setWallGraphics(0);
 for (i = files; *i != NULL; i++)
 {
  if (checkSkipFiles(*i))
   continue;
  int len = strlen(*i);
  if ((len > 4) && (strcmp(".MAP", (*i) + (len - 4)) == 0))
  {
   char tmp[len + 1];
   strcpy(tmp, (*i));
   strcpy(tmp + len - 3, "xml");
   if (0 == PHYSFS_exists(tmp))
   {
    count++;
   }
  }
  else if ((len > 4) && (strcmp(".xml", (*i) + (len - 4)) == 0))
  {
   count++;
  }
 }
 BTDisplay::selectItem *list = new BTDisplay::selectItem[count];
 list[0].name = module->item;
 list[1].name = module->spell;
 list[2].name = module->monster;
 int current = 3;
 for (i = files; *i != NULL; i++)
 {
  if (checkSkipFiles(*i))
   continue;
  int len = strlen(*i);
  if ((len > 4) && (strcmp(".MAP", (*i) + (len - 4)) == 0))
  {
   char tmp[len + 1];
   strcpy(tmp, (*i));
   strcpy(tmp + len - 3, "xml");
   if (0 == PHYSFS_exists(tmp))
   {
    list[current].name = *i;
    current++;
   }
  }
  else if ((len > 4) && (strcmp(".xml", (*i) + (len - 4)) == 0))
  {
   list[current].name = *i;
   current++;
  }
 }
 list[current].name = "<New Map>";
 PHYSFS_freeList(files);
 int start(0);
 int select(0);
 d.clearElements();
 d.addSelection(list, count, start, select);
 unsigned int key = d.process();
 d.clearText();
 if (key == 13)
 {
  if (list[select].name == module->monster)
  {
   BTFactory<BTMonster> &monsterList = getMonsterList();
   BTMonsterListCompare compare;
   BTMonsterEditor monsterEditor;
   int monster = 0;
   while (-1 != (monster = monsterEditor.editFactoryList<BTMonster>(d, monsterList, compare, "<New Monster>")))
   {
    ObjectSerializer serial;
    monsterList[monster].serialize(&serial);
    monsterEditor.edit(d, serial);
   }
   monsterList.save(module->monster);
  }
  else if (list[select].name == module->spell)
  {
   BTFactory<BTSpell, BTSpell1> &spellList = getSpellList();
   BTSpellListCompare compare;
   int spell = 0;
   BTSpellEditor spellEditor;
   while (-1 != (spell = spellEditor.editFactoryList<BTSpell, BTSpell1>(d, spellList, compare, "<New Spell>")))
   {
    ObjectSerializer serial;
    spellList[spell].serialize(&serial);
    spellEditor.edit(d, serial);
   }
   spellList.save(module->spell);
  }
  else if (list[select].name == module->item)
  {
   BTFactory<BTItem> &itemList = getItemList();
   BTItemListCompare compare;
   int item = 0;
   BTItemEditor itemEditor;
   while (-1 != (item = itemEditor.editFactoryList<BTItem>(d, itemList, compare, "<New Item>")))
   {
    ObjectSerializer serial;
    itemList[item].serialize(&serial);
    itemEditor.edit(d, serial);
   }
   itemList.save(module->item);
  }
  else if (count - 1 == select)
  {
   d.clearText();
   d.drawText("Filename:");
   std::string name = d.readString("", 60, "");
   d.clearText();
   editMap(d, name.c_str());
  }
  else
   editMap(d, list[select].name.c_str());
 }
 d.setPsuedo3DConfig(NULL);
}