示例#1
0
void BTSpellEditor::handleSpecialField(BTDisplay &d, ObjectSerializer &serial, int val)
{
 val -= 100;
 if ((val == extra.size()) || (extra[val].name == "type"))
 {
  BTDisplay::selectItem lookupItem[BT_SPELLTYPES_USED];
  int lookupStart(0);
  int lookupCurrent(0);
  for (int i = 0; i < BT_SPELLTYPES_USED; ++i)
  {
   lookupItem[i].name = spellTypeLookup.getName(spellTypes[i].type);
   if ((val != extra.size()) && (extra[val].item->type == spellTypes[i].type))
    lookupCurrent = i;
  }
  d.addSelection(lookupItem, BT_SPELLTYPES_USED, lookupStart, lookupCurrent);
  if ((27 != d.process()) && ((val == extra.size()) || (lookupCurrent != extra[val].item->type)))
  {
   XMLAction *manifestField = serial.find("manifest", NULL);
   XMLArray *manifestArray = (reinterpret_cast<XMLArray*>(manifestField->object));
   XMLVector<BTManifest*> *manifest = dynamic_cast<XMLVector<BTManifest*> *>(manifestArray);
   if (val == extra.size())
   {
    manifest->push_back((*spellTypes[lookupCurrent].f)(NULL, NULL));
    (*manifest)[manifest->size()  - 1]->type = spellTypes[lookupCurrent].type;
   }
   else
   {
    for (int i = 0; i < manifest->size(); ++i)
    {
     if (extra[val].item == (*manifest)[i])
     {
      (*manifest)[i] = dynamic_cast<BTManifest*>((*spellTypes[lookupCurrent].f)(NULL, NULL));
      (*manifest)[i]->type = spellTypes[lookupCurrent].type;
      delete extra[val].item;
      break;
     }
    }
   }
  }
  d.clearText();
 }
 else
 {
  ObjectSerializer serialSub;
  extra[val].item->serialize(&serialSub);
  XMLAction *manifestField = serialSub.find(extra[val].name.c_str(), NULL);
  editField(d, serialSub, extra[val].item->getEditFieldDescription(extra[val].value), manifestField, extra[val].value, 0);
 }
}
示例#2
0
文件: pc.C 项目: Methuselas/btbuilder
void BTPc::readXML(const char *filename, XMLVector<BTGroup*> &group, XMLVector<BTPc*> &pc)
{
 XMLSerializer parser;
 parser.add("party", &group, &BTGroup::create);
 parser.add("pc", &pc, &BTPc::create);
 parser.parse(filename, true);
 for (int i = 0; i < pc.size(); ++i)
  pc[i]->updateSkills();
}
示例#3
0
void BTSpellEditor::delSpecialField(BTDisplay &d, ObjectSerializer &serial, int val)
{
 val -= 100;
 if ((val != extra.size()) && (extra[val].name == "type"))
 {
  XMLAction *manifestField = serial.find("manifest", NULL);
  XMLArray *manifestArray = (reinterpret_cast<XMLArray*>(manifestField->object));
  XMLVector<BTManifest*> *manifest = dynamic_cast<XMLVector<BTManifest*> *>(manifestArray);
  for (size_t i = 0; i < manifest->size(); ++i)
  {
   if (extra[val].item == (*manifest)[i])
   {
    manifest->erase(i);
    break;
   }
  }
 }
}
示例#4
0
void BTSpellEditor::complete(ObjectSerializer &serial)
{
 XMLAction *rangeField = serial.find("range", NULL);
 XMLAction *effectiveRangeField = serial.find("effectiveRange", NULL);
 IShort range = *(reinterpret_cast<IShort*>(rangeField->object));
 IShort effectiveRange = *(reinterpret_cast<IShort*>(effectiveRangeField->object));
 XMLAction *manifestField = serial.find("manifest", NULL);
 XMLArray *manifestArray = (reinterpret_cast<XMLArray*>(manifestField->object));
 XMLVector<BTManifest*> *manifest = dynamic_cast<XMLVector<BTManifest*> *>(manifestArray);
 for (size_t i = 0; i < manifest->size(); ++i)
 {
  BTRangedManifest *rangedManifest = dynamic_cast<BTRangedManifest*>(manifest->get(i));
  if (rangedManifest)
  {
   rangedManifest->range = range;
   rangedManifest->effectiveRange = effectiveRange;
  }
 }
}
示例#5
0
int BTSpellEditor::setup(ObjectSerializer &serial, BitField &active, std::vector<BTDisplay::selectItem> &items)
{
 int current = BTSerializedEditor::setup(serial, active, items);
 XMLAction *manifestField = serial.find("manifest", NULL);
 XMLArray *manifestArray = (reinterpret_cast<XMLArray*>(manifestField->object));
 XMLVector<BTManifest*> *manifest = dynamic_cast<XMLVector<BTManifest*> *>(manifestArray);
 extra.clear();
 int extraVal = 100;
 for (size_t i = 0; i < manifest->size(); ++i)
 {
  if (current == items.size())
   items.push_back(BTDisplay::selectItem());
  BTManifest *manifestObj = dynamic_cast<BTManifest*>(manifest->get(i));
  extra.push_back(BTSpellEditor::extraItems(manifestObj, "type", -1));
  items[current].name = std::string("Effect: ") + spellTypeLookup.getName(manifestObj->type);
  items[current].value = extraVal++;
  current++;
  int manifestEntries = manifestObj->getEditFieldNumber();
  if (manifestEntries > 0)
  {
   ObjectSerializer serialSub;
   manifestObj->serialize(&serialSub);
   for (int n = 0; n < manifestEntries; ++n)
   {
    if (current == items.size())
     items.push_back(BTDisplay::selectItem());
    extra.push_back(BTSpellEditor::extraItems(manifestObj, manifestObj->getEditField(n), n));
    XMLAction *curField = serialSub.find(manifestObj->getEditField(n), NULL);
    items[current].name = std::string("  ") + std::string(manifestObj->getEditFieldDescription(n)) + ": " + curField->createString();
    items[current].value = extraVal++;
    current++;
   }
  }
 }
 if (current == items.size())
  items.push_back(BTDisplay::selectItem());
 items[current].name = std::string("<New Effect>");
 items[current].value = extraVal++;
 current++;
 return current;
}