예제 #1
0
void SoundDB::load()
{
    unload();
    loadXmlFile(paths.getStringValue("soundsFile"));
    loadXmlFile(paths.getStringValue("soundsPatchFile"));
    loadXmlDir("soundsPatchDir", loadXmlFile);
}
예제 #2
0
void SoundDB::load()
{
    unload();
    logger->log1("Initializing sound database...");
    loadXmlFile(paths.getStringValue("soundsFile"), SkipError_false);
    loadXmlFile(paths.getStringValue("soundsPatchFile"), SkipError_true);
    loadXmlDir("soundsPatchDir", loadXmlFile);
}
예제 #3
0
파일: avatardb.cpp 프로젝트: Rawng/ManaPlus
void AvatarDB::load()
{
    if (mLoaded)
        unload();
    loadXmlFile(paths.getStringValue("avatarsFile"));
    loadXmlFile(paths.getStringValue("avatarsPatchFile"));
    loadXmlDir("avatarsPatchDir", loadXmlFile);
}
예제 #4
0
파일: textdb.cpp 프로젝트: mekolat/ManaPlus
void TextDb::load()
{
    unload();
    logger->log1("Initializing text database...");
    loadXmlFile(paths.getStringValue("textsFile"), SkipError_false);
    loadXmlFile(paths.getStringValue("textsPatchFile"), SkipError_true);
    loadXmlDir("textsPatchDir", loadXmlFile);
}
예제 #5
0
void PETDB::load()
{
    if (mLoaded)
        unload();

    logger->log1("Initializing PET database...");
    loadXmlFile(paths.getStringValue("petsFile"), SkipError_false);
    loadXmlFile(paths.getStringValue("petsPatchFile"), SkipError_true);
    loadXmlDir("petsPatchDir", loadXmlFile);
    mLoaded = true;
}
예제 #6
0
void StatusEffect::load()
{
    if (mLoaded)
        unload();

    loadXmlFile(paths.getStringValue("statusEffectsFile"));
    loadXmlFile(paths.getStringValue("statusEffectsPatchFile"));
    loadXmlDir("statusEffectsPatchDir", loadXmlFile);

    mLoaded = true;
}
예제 #7
0
void SkillUnitDb::load()
{
    if (mLoaded)
        unload();

    logger->log1("Initializing skill unit database...");
    loadXmlFile(paths.getStringValue("skillUnitsFile"), SkipError_false);
    loadXmlFile(paths.getStringValue("skillUnitsPatchFile"), SkipError_true);
    loadXmlDir("skillUnitsPatchDir", loadXmlFile);
    mLoaded = true;
}
예제 #8
0
void NetworkDb::load()
{
    if (mLoaded)
        unload();

    logger->log1("Initializing network database...");
    loadXmlFile(paths.getStringValue("networkFile"), SkipError_false);
    loadXmlFile(paths.getStringValue("networkPatchFile"), SkipError_true);
    loadXmlDir("networkPatchDir", loadXmlFile)
    mLoaded = true;
}
예제 #9
0
void MonsterDB::load()
{
    if (mLoaded)
        unload();

    logger->log1("Initializing monster database...");
    loadXmlFile(paths.getStringValue("monstersFile"));
    loadXmlFile(paths.getStringValue("monstersPatchFile"));
    loadXmlDir("monstersPatchDir", loadXmlFile);

    mLoaded = true;
}
예제 #10
0
void ElementalDb::load()
{
    if (mLoaded)
        unload();

    logger->log1("Initializing elemental database...");
    loadXmlFile(paths.getStringValue("elementalsFile"), SkipError_false);
    loadXmlFile(paths.getStringValue("elementalsPatchFile"), SkipError_true);
    loadXmlDir("elementalsPatchDir", loadXmlFile);

    mLoaded = true;
}
예제 #11
0
void NpcDialogDB::load()
{
    if (mLoaded)
        unload();

    logger->log1("Loading npcdialog database...");
    loadXmlFile(paths.getStringValue("npcDialogsFile"));
    loadXmlFile(paths.getStringValue("npcDialogsPatchFile"));
    loadXmlDir("npcDialogsPatchDir", loadXmlFile);

    mLoaded = true;
}
예제 #12
0
void MercenaryDB::load()
{
    if (mLoaded)
        unload();

    logger->log1("Initializing mercenary database...");
    loadXmlFile(paths.getStringValue("mercenariesFile"));
    loadXmlFile(paths.getStringValue("mercenariesPatchFile"));
    loadXmlDir("mercenariesPatchDir", loadXmlFile);

    mLoaded = true;
}
예제 #13
0
void HomunculusDB::load()
{
    if (mLoaded)
        unload();

    logger->log1("Initializing homunculus database...");
    loadXmlFile(paths.getStringValue("homunculusesFile"));
    loadXmlFile(paths.getStringValue("homunculusesPatchFile"));
    loadXmlDir("homunculusesPatchDir", loadXmlFile);

    mLoaded = true;
}
예제 #14
0
void NPCDB::load()
{
    if (mLoaded)
        unload();

    logger->log1("Initializing NPC database...");

    loadXmlFile(paths.getStringValue("npcsFile"));
    loadXmlFile(paths.getStringValue("npcsPatchFile"));
    loadXmlDir("npcsPatchDir", loadXmlFile);

    mLoaded = true;
}
예제 #15
0
static void loadDB(const std::string &name, BadgesInfos &arr)
{
    loadXmlFile(paths.getStringValue("badgesFile"),
        name, arr, SkipError_false);
    loadXmlFile(paths.getStringValue("badgesPatchFile"),
        name, arr, SkipError_true);

    StringVect listVect;
    Files::getFilesInDir(paths.getStringValue(
        "badgesPatchDir"), listVect, ".xml");
    FOR_EACH (StringVectCIter, itVect, listVect)
        loadXmlFile(*itVect, name, arr, SkipError_true);
}
예제 #16
0
void StatusEffectDB::load()
{
    if (mLoaded)
        unload();

    logger->log1("Initializing status effect database...");

    loadXmlFile(paths.getStringValue("statusEffectsFile"), SkipError_false);
    loadXmlFile(paths.getStringValue("statusEffectsPatchFile"),
        SkipError_true);
    loadXmlDir("statusEffectsPatchDir", loadXmlFile);

    mLoaded = true;
}
예제 #17
0
void QuestDb::loadXmlFile(const std::string &fileName,
                          const SkipError skipError)
{
    XML::Document doc(fileName,
        UseVirtFs_true,
        skipError);
    XmlNodeConstPtrConst root = doc.rootNode();
    if (root == nullptr)
        return;

    for_each_xml_child_node(varNode, root)
    {
        if (xmlNameEqual(varNode, "include"))
        {
            const std::string name = XML::getProperty(varNode, "name", "");
            if (!name.empty())
                loadXmlFile(name, skipError);
            continue;
        }
        else if (xmlNameEqual(varNode, "var"))
        {
            const int id = XML::getProperty(varNode, "id", 0);
            if (id < 0)
                continue;
            mVars[id] = QuestVar();
            for_each_xml_child_node(questNode, varNode)
            {
                if (xmlNameEqual(questNode, "quest"))
                    loadQuest(id, questNode);
                else if (xmlNameEqual(questNode, "effect"))
                    loadEffect(id, questNode);
            }
        }
    }
}
예제 #18
0
void QuestsWindow::loadXmlFile(const std::string &fileName)
{
    XML::Document doc(fileName);
    const XmlNodePtrConst root = doc.rootNode();
    if (!root)
        return;

    for_each_xml_child_node(varNode, root)
    {
        if (xmlNameEqual(varNode, "include"))
        {
            const std::string name = XML::getProperty(varNode, "name", "");
            if (!name.empty())
                loadXmlFile(name);
            continue;
        }
        else if (xmlNameEqual(varNode, "var"))
        {
            const int id = XML::getProperty(varNode, "id", 0);
            if (id < 0)
                continue;
            for_each_xml_child_node(questNode, varNode)
            {
                if (xmlNameEqual(questNode, "quest"))
                    loadQuest(id, questNode);
                else if (xmlNameEqual(questNode, "effect"))
                    loadEffect(id, questNode);
            }
        }
    }
}
예제 #19
0
void UserMenuDialog::slotLoadClicked()
{
	KILE_DEBUG() << "load xml file ";

	if ( !m_menutree->isEmpty() && m_modified ) {
		if ( KMessageBox::questionYesNo(this, i18n("Current menu tree was modified, but not saved.\nDiscard this tree?")) == KMessageBox::No ) {
			return;
		}
	}

	QString directory = UserMenu::selectUserMenuDir();
	QString filter = i18n("*.xml|Latex Menu Files");

	QString filename = KFileDialog::getOpenFileName(directory, filter, this, i18n("Select Menu File"));
	if(filename.isEmpty()) {
		return;
	}

	if( QFile::exists(filename) ) {
		loadXmlFile(filename,false);   // includes buttons update
	}
	else {
		KMessageBox::error(this, i18n("File '%1' does not exist.", filename));
	}
}
예제 #20
0
void SoundDB::loadXmlFile(const std::string &fileName)
{
    XML::Document *doc = new XML::Document(fileName);
    const XmlNodePtrConst root = doc->rootNode();

    if (!root || !xmlNameEqual(root, "sounds"))
    {
        delete doc;
        return;
    }

    for_each_xml_child_node(node, root)
    {
        if (xmlNameEqual(node, "include"))
        {
            const std::string name = XML::getProperty(node, "name", "");
            if (!name.empty())
                loadXmlFile(name);
            continue;
        }
        else if (xmlNameEqual(node, "sound"))
        {
            const std::string name = XML::getProperty(node, "name", "");
            const int id = NotifyManager::getIndexBySound(name);
            if (id)
            {
                const std::string value = XML::getProperty(node, "value", "");
                mSounds[id] = value;
            }
        }
    }

    delete doc;
}
예제 #21
0
파일: units.cpp 프로젝트: Rawng/ManaPlus
void Units::loadUnits()
{
    { // Setup default weight
        UnitDescription ud;

        ud.conversion = 1.0;
        ud.mix = false;

        const UnitLevel bu =
        {
            "g",
            1,
            0,
            ""
        };
        ud.levels.push_back(bu);

        const UnitLevel ul =
        {
            "kg",
            1000,
            2,
            ""
        };
        ud.levels.push_back(ul);

        units[UNIT_WEIGHT] = ud;
    }

    { // Setup default currency
        UnitDescription ud;

        ud.conversion = 1.0;
        ud.mix = false;

        UnitLevel bu = {"¤", 1, 0, ""};
        ud.levels.push_back(bu);

        units[UNIT_CURRENCY] = ud;
    }

    loadXmlFile(paths.getStringValue("unitsFile"));
    loadXmlFile(paths.getStringValue("unitsPatchFile"));
    loadXmlDir("unitsPatchDir", loadXmlFile);
}
예제 #22
0
파일: statdb.cpp 프로젝트: mekolat/ManaPlus
void StatDb::loadXmlFile(const std::string &fileName,
                         const SkipError skipError)
{
    XML::Document doc(fileName,
        UseVirtFs_true,
        skipError);
    XmlNodeConstPtrConst rootNode = doc.rootNode();

    if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "stats"))
    {
        logger->log("StatDb: Error while loading %s!",
            fileName.c_str());
        if (skipError == SkipError_false)
            addDefaultStats();
        return;
    }

    for_each_xml_child_node(node, rootNode)
    {
        if (xmlNameEqual(node, "include"))
        {
            const std::string name = XML::getProperty(node, "name", "");
            if (!name.empty())
                loadXmlFile(name, skipError);
            continue;
        }
        else if (xmlNameEqual(node, "basic"))
        {
            loadBasicStats(node);
        }
        else if (xmlNameEqual(node, "extended"))
        {
            // TRANSLATORS: stats page name
            loadStats(node, _("Extended"));
        }
        else if (xmlNameEqual(node, "page"))
        {
            std::string page = XML::langProperty(node, "name", "");
            if (page.empty())
            {
                reportAlways("Page without name in stats.xml");
                page = "Unknown";
            }
            loadStats(node, page);
        }
    }
    if (skipError == SkipError_false)
    {
        if (mBasicStats.empty() &&
            mStats.empty())
        {
            reportAlways("StatDb: no stats found");
            addDefaultStats();
        }
    }
}
예제 #23
0
파일: textdb.cpp 프로젝트: mekolat/ManaPlus
void TextDb::loadXmlFile(const std::string &fileName,
                         const SkipError skipError)
{
    XML::Document *doc = new XML::Document(fileName,
        UseVirtFs_true,
        skipError);
    XmlNodeConstPtrConst root = doc->rootNode();

    if ((root == nullptr) || !xmlNameEqual(root, "texts"))
    {
        delete doc;
        return;
    }

    for_each_xml_child_node(node, root)
    {
        if (xmlNameEqual(node, "include"))
        {
            const std::string name = XML::getProperty(node, "name", "");
            if (!name.empty())
                loadXmlFile(name, skipError);
            continue;
        }
        else if (xmlNameEqual(node, "text"))
        {
            const bool show = XML::getBoolProperty(node, "show", false);
            if (show == true)
            {
                if (!XmlHaveChildContent(node))
                    continue;

                std::string text = XmlChildContent(node);
                mTexts.push_back(text);
            }
        }
    }

    delete doc;
}
예제 #24
0
void MonsterDB::loadXmlFile(const std::string &fileName)
{
    XML::Document doc(fileName, UseResman_true, SkipError_false);
    const XmlNodePtr rootNode = doc.rootNode();

    if (!rootNode || !xmlNameEqual(rootNode, "monsters"))
    {
        logger->log("Monster Database: Error while loading %s!",
            paths.getStringValue("monstersFile").c_str());
        mLoaded = true;
        return;
    }

    const int offset = XML::getProperty(rootNode,
        "offset", OLD_TMWATHENA_OFFSET);

    // iterate <monster>s
    for_each_xml_child_node(monsterNode, rootNode)
    {
        if (xmlNameEqual(monsterNode, "include"))
        {
            const std::string name = XML::getProperty(monsterNode, "name", "");
            if (!name.empty())
                loadXmlFile(name);
            continue;
        }
        if (!xmlNameEqual(monsterNode, "monster"))
            continue;

        const int id = XML::getProperty(monsterNode, "id", 0);
        BeingInfo *currentInfo = nullptr;
        if (mMonsterInfos.find(fromInt(id + offset, BeingTypeId))
            != mMonsterInfos.end())
        {
            logger->log("MonsterDB: Redefinition of monster ID %d", id);
            currentInfo = mMonsterInfos[fromInt(id + offset, BeingTypeId)];
        }
        if (!currentInfo)
            currentInfo = new BeingInfo;

        currentInfo->setBlockType(BlockType::MONSTER);
        currentInfo->setName(XML::langProperty(
            // TRANSLATORS: unknown info name
            monsterNode, "name", _("unnamed")));

        BeingCommon::readBasicAttributes(currentInfo, monsterNode, "attack");

        currentInfo->setMaxHP(XML::getProperty(monsterNode, "maxHP", 0));

        currentInfo->setDeadSortOffsetY(XML::getProperty(
            monsterNode, "deadSortOffsetY", 31));

        currentInfo->setColorsList(XML::getProperty(monsterNode,
            "colors", ""));

        unsigned char block = 0;
        std::string walkStr = XML::getProperty(
            monsterNode, "walkType", "walk");
        if (walkStr == "walk")
            block = BlockMask::WATER | BlockMask::AIR;
        else if (walkStr == "fly")
            block = 0;
        else if (walkStr == "swim")
            block = BlockMask::GROUND | BlockMask::AIR;
        else if (walkStr == "walkswim" || walkStr == "swimwalk")
            block = BlockMask::AIR;

        currentInfo->setBlockWalkMask(static_cast<unsigned char>(
            BlockMask::WALL | block));

        if (currentInfo->getMaxHP())
            currentInfo->setStaticMaxHP(true);

        SpriteDisplay display;

        // iterate <sprite>s and <sound>s
        for_each_xml_child_node(spriteNode, monsterNode)
        {
            BeingCommon::readObjectNodes(spriteNode, display,
                currentInfo, "MonsterDB");
        }
        currentInfo->setDisplay(display);

        mMonsterInfos[fromInt(id + offset, BeingTypeId)] = currentInfo;
    }
예제 #25
0
QuestsWindow::QuestsWindow() :
    // TRANSLATORS: quests window name
    Window(_("Quests"), false, nullptr, "quests.xml"),
    ActionListener(),
    mQuestsModel(new QuestsModel),
    mQuestsListBox(new ExtendedListBox(this,
        mQuestsModel, "extendedlistbox.xml")),
    mQuestScrollArea(new ScrollArea(this, mQuestsListBox,
        getOptionBool("showlistbackground"), "quests_list_background.xml")),
    mItemLinkHandler(new ItemLinkHandler),
    mText(new BrowserBox(this, BrowserBox::AUTO_WRAP, true, "browserbox.xml")),
    mTextScrollArea(new ScrollArea(this, mText,
        getOptionBool("showtextbackground"), "quests_text_background.xml")),
    // TRANSLATORS: quests window button
    mCloseButton(new Button(this, _("Close"), "close", this)),
    mCompleteIcon(Theme::getImageFromThemeXml("complete_icon.xml", "")),
    mIncompleteIcon(Theme::getImageFromThemeXml("incomplete_icon.xml", "")),
    mVars(),
    mQuests(),
    mAllEffects(),
    mMapEffects(),
    mNpcEffects(),
    mQuestLinks(),
    mNewQuestEffectId(paths.getIntValue("newQuestEffectId")),
    mCompleteQuestEffectId(paths.getIntValue("completeQuestEffectId")),
    mMap(nullptr)
{
    mQuestsListBox->postInit();

    setWindowName("Quests");
    setResizable(true);
    setCloseButton(true);
    setStickyButtonLock(true);
    setSaveVisible(true);

    setDefaultSize(400, 350, ImageRect::RIGHT);
    setMinWidth(310);
    setMinHeight(220);

    mQuestsListBox->setActionEventId("select");
    mQuestsListBox->addActionListener(this);

    mQuestScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
    mText->setOpaque(false);
    mText->setLinkHandler(mItemLinkHandler);
    mTextScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
    mQuestsListBox->setWidth(500);
    if (!gui || gui->getNpcFont()->getHeight() < 20)
        mQuestsListBox->setRowHeight(20);
    else
        mQuestsListBox->setRowHeight(gui->getNpcFont()->getHeight());

    ContainerPlacer placer;
    placer = getPlacer(0, 0);

    placer(0, 0, mQuestScrollArea, 4, 3).setPadding(3);
    placer(4, 0, mTextScrollArea, 4, 3).setPadding(3);
    placer(7, 3, mCloseButton);

    Layout &layout = getLayout();
    layout.setRowHeight(0, LayoutType::SET);

    loadWindowState();
    enableVisibleSound(true);
    loadXmlFile(paths.getStringValue("questsFile"));
    loadXmlFile(paths.getStringValue("questsPatchFile"));
    loadXmlDir("questsPatchDir", loadXmlFile);
}
예제 #26
0
void MonsterDB::loadXmlFile(const std::string &fileName)
{
    XML::Document doc(fileName);
    const XmlNodePtr rootNode = doc.rootNode();

    if (!rootNode || !xmlNameEqual(rootNode, "monsters"))
    {
        logger->log("Monster Database: Error while loading %s!",
            paths.getStringValue("monstersFile").c_str());
        mLoaded = true;
        return;
    }

    const int offset = XML::getProperty(rootNode,
        "offset", OLD_TMWATHENA_OFFSET);

    // iterate <monster>s
    for_each_xml_child_node(monsterNode, rootNode)
    {
        if (xmlNameEqual(monsterNode, "include"))
        {
            const std::string name = XML::getProperty(monsterNode, "name", "");
            if (!name.empty())
                loadXmlFile(name);
            continue;
        }
        if (!xmlNameEqual(monsterNode, "monster"))
            continue;

        const int id = XML::getProperty(monsterNode, "id", 0);
        BeingInfo *currentInfo = nullptr;
        if (mMonsterInfos.find(id + offset) != mMonsterInfos.end())
        {
            logger->log("MonsterDB: Redefinition of monster ID %d", id);
            currentInfo = mMonsterInfos[id + offset];
        }
        if (!currentInfo)
            currentInfo = new BeingInfo;

        currentInfo->setWalkMask(BlockMask::WALL
            | BlockMask::CHARACTER | BlockMask::MONSTER);
        currentInfo->setBlockType(BlockType::MONSTER);

        currentInfo->setName(XML::langProperty(
            // TRANSLATORS: unknown info name
            monsterNode, "name", _("unnamed")));

        BeingCommon::readBasicAttributes(currentInfo, monsterNode, "attack");

        currentInfo->setMaxHP(XML::getProperty(monsterNode, "maxHP", 0));

        currentInfo->setDeadSortOffsetY(XML::getProperty(
            monsterNode, "deadSortOffsetY", 31));

        currentInfo->setColorsList(XML::getProperty(monsterNode,
            "colors", ""));

        unsigned char block = 0;
        std::string walkStr = XML::getProperty(
            monsterNode, "walkType", "walk");
        if (walkStr == "walk")
            block = BlockMask::WATER | BlockMask::AIR;
        else if (walkStr == "fly")
            block = 0;
        else if (walkStr == "swim")
            block = BlockMask::GROUND | BlockMask::AIR;
        else if (walkStr == "walkswim" || walkStr == "swimwalk")
            block = BlockMask::AIR;

        currentInfo->setWalkMask(static_cast<unsigned char>(
            BlockMask::WALL | block));

        if (currentInfo->getMaxHP())
            currentInfo->setStaticMaxHP(true);

        SpriteDisplay display;

        // iterate <sprite>s and <sound>s
        for_each_xml_child_node(spriteNode, monsterNode)
        {
            if (xmlNameEqual(spriteNode, "sprite"))
            {
                if (!spriteNode->xmlChildrenNode)
                    continue;

                SpriteReference *const currentSprite = new SpriteReference;
                currentSprite->sprite = reinterpret_cast<const char*>(
                    spriteNode->xmlChildrenNode->content);

                currentSprite->variant = XML::getProperty(
                    spriteNode, "variant", 0);
                display.sprites.push_back(currentSprite);
            }
            else if (xmlNameEqual(spriteNode, "sound"))
            {
                if (!spriteNode->xmlChildrenNode)
                    continue;

                const std::string event = XML::getProperty(
                    spriteNode, "event", "");
                const int delay = XML::getProperty(
                    spriteNode, "delay", 0);
                const char *const filename = reinterpret_cast<const char*>(
                    spriteNode->xmlChildrenNode->content);

                if (event == "hit")
                {
                    currentInfo->addSound(ItemSoundEvent::HIT,
                        filename, delay);
                }
                else if (event == "miss")
                {
                    currentInfo->addSound(ItemSoundEvent::MISS,
                        filename, delay);
                }
                else if (event == "hurt")
                {
                    currentInfo->addSound(ItemSoundEvent::HURT,
                        filename, delay);
                }
                else if (event == "die")
                {
                    currentInfo->addSound(ItemSoundEvent::DIE,
                        filename, delay);
                }
                else if (event == "move")
                {
                    currentInfo->addSound(ItemSoundEvent::MOVE,
                        filename, delay);
                }
                else if (event == "sit")
                {
                    currentInfo->addSound(ItemSoundEvent::SIT,
                        filename, delay);
                }
                else if (event == "sittop")
                {
                    currentInfo->addSound(ItemSoundEvent::SITTOP,
                        filename, delay);
                }
                else if (event == "spawn")
                {
                    currentInfo->addSound(ItemSoundEvent::SPAWN,
                        filename, delay);
                }
                else
                {
                    logger->log("MonsterDB: Warning, sound effect %s for "
                                "unknown event %s of monster %s",
                                filename, event.c_str(),
                                currentInfo->getName().c_str());
                }
            }
            else if (xmlNameEqual(spriteNode, "attack"))
            {
                const int attackId = XML::getProperty(spriteNode, "id", 0);
                const int effectId = XML::getProperty(
                    spriteNode, "effect-id", paths.getIntValue("effectId"));
                const int hitEffectId = XML::getProperty(spriteNode,
                    "hit-effect-id", paths.getIntValue("hitEffectId"));
                const int criticalHitEffectId = XML::getProperty(spriteNode,
                    "critical-hit-effect-id",
                    paths.getIntValue("criticalHitEffectId"));
                const int missEffectId = XML::getProperty(spriteNode,
                    "miss-effect-id", paths.getIntValue("missEffectId"));

                const std::string spriteAction = XML::getProperty(
                    spriteNode, "action", "attack");
                const std::string skySpriteAction = XML::getProperty(
                    spriteNode, "skyaction", "skyattack");
                const std::string waterSpriteAction = XML::getProperty(
                    spriteNode, "wateraction", "waterattack");

                const std::string missileParticle = XML::getProperty(
                        spriteNode, "missile-particle", "");

                currentInfo->addAttack(attackId, spriteAction, skySpriteAction,
                    waterSpriteAction, effectId, hitEffectId,
                    criticalHitEffectId, missEffectId, missileParticle);
            }
            else if (xmlNameEqual(spriteNode, "particlefx"))
            {
                if (!spriteNode->xmlChildrenNode)
                    continue;

                display.particles.push_back(reinterpret_cast<const char*>(
                    spriteNode->xmlChildrenNode->content));
            }
        }
        currentInfo->setDisplay(display);

        mMonsterInfos[id + offset] = currentInfo;
    }
}
예제 #27
0
void PETDB::loadXmlFile(const std::string &fileName,
                        const SkipError skipError)
{
    XML::Document doc(fileName,
        UseResman_true,
        skipError);
    const XmlNodePtrConst rootNode = doc.rootNode();

    if (!rootNode || !xmlNameEqual(rootNode, "pets"))
    {
        logger->log("PET Database: Error while loading %s!",
            fileName.c_str());
        return;
    }

    // iterate <pet>s
    for_each_xml_child_node(petNode, rootNode)
    {
        if (xmlNameEqual(petNode, "include"))
        {
            const std::string name = XML::getProperty(petNode, "name", "");
            if (!name.empty())
                loadXmlFile(name, skipError);
            continue;
        }
        else if (!xmlNameEqual(petNode, "pet"))
        {
            continue;
        }

        const BeingTypeId id = fromInt(XML::getProperty(
            petNode, "id", -1), BeingTypeId);
        if (id == BeingTypeId_negOne)
        {
            reportAlways("PET Database: PET with missing ID in %s!",
                paths.getStringValue("petsFile").c_str());
            continue;
        }

        BeingInfo *currentInfo = nullptr;
        if (mPETInfos.find(id) != mPETInfos.end())
            currentInfo = mPETInfos[id];
        if (!currentInfo)
            currentInfo = new BeingInfo;

        currentInfo->setName(XML::langProperty(petNode,
            // TRANSLATORS: unknown info name
            "name", _("pet")));

        currentInfo->setTargetSelection(XML::getBoolProperty(petNode,
            "targetSelection", true));

        BeingCommon::readBasicAttributes(currentInfo, petNode, "talk");
        BeingCommon::readWalkingAttributes(currentInfo, petNode, 0);

        currentInfo->setDeadSortOffsetY(XML::getProperty(petNode,
            "deadSortOffsetY", 31));

        const std::string returnMessage = XML::langProperty(petNode,
            // TRANSLATORS: popup menu item
            // TRANSLATORS: pet return to egg
            "removeMessage", _("Return to egg"));
        currentInfo->setString(0, returnMessage);

        SpriteDisplay display;
        for_each_xml_child_node(spriteNode, petNode)
        {
            if (!XmlHaveChildContent(spriteNode))
                continue;

            if (xmlNameEqual(spriteNode, "sprite"))
            {
                SpriteReference *const currentSprite = new SpriteReference;
                currentSprite->sprite = XmlChildContent(spriteNode);
                currentSprite->variant =
                    XML::getProperty(spriteNode, "variant", 0);
                display.sprites.push_back(currentSprite);
            }
            else if (xmlNameEqual(spriteNode, "particlefx"))
            {
                std::string particlefx = XmlChildContent(spriteNode);
                display.particles.push_back(particlefx);
            }
        }

        currentInfo->setDisplay(display);

        mPETInfos[id] = currentInfo;
    }
}
예제 #28
0
void StatusEffectDB::loadXmlFile(const std::string &fileName,
                                 const SkipError skipError)
{
    XML::Document doc(fileName, UseVirtFs_true, skipError);
    XmlNodeConstPtrConst rootNode = doc.rootNode();

    if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "status-effects"))
    {
        logger->log("Error loading status effects file: " + fileName);
        return;
    }

    for_each_xml_child_node(node, rootNode)
    {
        if (xmlNameEqual(node, "include"))
        {
            const std::string incName = XML::getProperty(node, "name", "");
            if (!incName.empty())
                loadXmlFile(incName, skipError);
            continue;
        }
        else if (!xmlNameEqual(node, "status-effect"))
        {
            continue;
        }

        int id = XML::getProperty(node, "id", -1);
        if (id == -1)
        {
            id = fakeId;
            fakeId ++;
        }
        const int option = XML::getProperty(node, "option", 0);
        const int opt1 = XML::getProperty(node, "opt1", 0);
        const int opt2 = XML::getProperty(node, "opt2", 0);
        const int opt3 = XML::getProperty(node, "opt3", 0);
        if (option != 0)
        {
            optionToIdMap[option] = id;
        }
        if (opt1 != 0)
        {
            opt1ToIdMap[opt1] = id;
        }
        if (opt2 != 0)
        {
            opt2ToIdMap[opt2] = id;
        }
        if (opt3 != 0)
        {
            opt3ToIdMap[opt3] = id;
        }

        StatusEffect *startEffect = statusEffects[1][id];
        StatusEffect *endEffect = statusEffects[0][id];
        const std::string name = XML::getProperty(node, "name", "");
        const std::string name2 = XML::langProperty(node, "name", "");
        if (startEffect == nullptr)
            startEffect = new StatusEffect;
        if (endEffect == nullptr)
            endEffect = new StatusEffect;

        startEffect->mName = name2;
        startEffect->mIsPoison =
            (name == paths.getStringValue("poisonEffectName"));
        startEffect->mIsCart =
            (name == paths.getStringValue("cartEffectName"));
        startEffect->mIsRiding =
            (name == paths.getStringValue("ridingEffectName"));
        startEffect->mIsTrickDead =
            (name == paths.getStringValue("trickDeadEffectName"));
        startEffect->mIsPostDelay =
            (name == paths.getStringValue("postDelayName"));
        startEffect->mMessage = XML::getProperty(
            node, "start-message", "");
        startEffect->mSFXEffect = XML::getProperty(
            node, "start-audio", "");
        startEffect->mStartParticleEffect = XML::getProperty(
            node, "start-particle", "");
        startEffect->mParticleEffect = XML::getProperty(
            node, "particle", "");

        startEffect->mIcon = XML::getProperty(node, "icon", "");
        startEffect->mAction = XML::getProperty(node, "action", "");
        startEffect->mIsPersistent = (XML::getProperty(
            node, "persistent-particle-effect", "no")) != "no";

        endEffect->mName = startEffect->mName;
        endEffect->mIsPoison = startEffect->mIsPoison;
        endEffect->mIsCart = startEffect->mIsCart;
        endEffect->mIsRiding = startEffect->mIsRiding;
        endEffect->mIsTrickDead = startEffect->mIsTrickDead;
        endEffect->mIsPostDelay = startEffect->mIsPostDelay;
        endEffect->mMessage = XML::getProperty(node, "end-message", "");
        endEffect->mSFXEffect = XML::getProperty(node, "end-audio", "");
        endEffect->mStartParticleEffect = XML::getProperty(
            node, "end-particle", "");

        statusEffects[1][id] = startEffect;
        statusEffects[0][id] = endEffect;
    }
}
예제 #29
0
void ofApp::setup() {

	for (int i = 0; i < allCameras.size(); i++) {
		allCameras[i] = NULL;
		allMatrix[i] = NULL;
		cameras[i].ResolutionX = 800;
		cameras[i].ResolutionY = 600;
		cameras[i].ResolutionDownSample = 1;
		cameras[i].ColorRGB = true;
		cameras[i].FPS = 24;
		cameras[i].Use2D = false;
		cameras[i].Use3D = false;
		cameras[i].DataContext = "";
		cameras[i].DepthSettings.Near = 0;
		cameras[i].DepthSettings.Far = 0;
		cameras[i].DepthSettings.PointsDownSample = 0;
		for (int k = 0; k < 16; k++) {
			cameras[i].Matrix[k] = 0;
		}
	}

	ofSetVerticalSync(true); 
	ofEnableSmoothing(); 
    
    gui = new ofxUISuperCanvas("XML GENERATOR");
	gui->setHeight(720);

    gui->addSpacer();
	gui->addLabel("General Options:");

	gui->addToggle("realTime", true);

	gui->addLabel("realTimeFPS");
	gui->addTextInput("realTimeFPSValue", "10");
	
	gui->addLabel("realTimePort");
	gui->addTextInput("realTimePortValue", "3232");

    gui->addSpacer();
	gui->addLabelButton("ADD CAMERA", false);
	gui->addLabelButton("SAVE", false);
	
    gui->addSpacer();
	gui->addLabelButton("CAMERA 0", false);
	gui->addLabelButton("CAMERA 1", false);
	gui->addLabelButton("CAMERA 2", false);

	vector<ofxUIWidget*> widgets = gui->getWidgets();
	for_each (widgets.begin(), widgets.end(), getCameraTabs);

	allTabs[0]->setVisible(false);
	allTabs[1]->setVisible(false);
	allTabs[2]->setVisible(false);

    gui->autoSizeToFitWidgets();
    ofAddListener(gui->newGUIEvent,this,&ofApp::guiEvent);
    gui->loadSettings("guiSettings.xml");
	gui->setHeight(720);

	loadXmlFile();

}
예제 #30
0
파일: units.cpp 프로젝트: Rawng/ManaPlus
void Units::loadXmlFile(const std::string &fileName)
{
    XML::Document doc(fileName, UseResman_true, SkipError_false);
    const XmlNodePtrConst root = doc.rootNode();

    if (!root || !xmlNameEqual(root, "units"))
    {
        logger->log("Error loading unit definition file: "
            + paths.getStringValue("unitsFile"));
        return;
    }

    for_each_xml_child_node(node, root)
    {
        if (xmlNameEqual(node, "include"))
        {
            const std::string name = XML::getProperty(node, "name", "");
            if (!name.empty())
                loadXmlFile(name);
            continue;
        }
        else if (xmlNameEqual(node, "unit"))
        {
            UnitDescription ud;
            int level = 1;
            const std::string type = XML::getProperty(node, "type", "");
            ud.conversion = XML::getProperty(node, "conversion", 1);
            ud.mix = XML::getProperty(node, "mix", "no") == "yes";

            UnitLevel bu;
            bu.symbol = XML::getProperty(node, "base", "¤");
            bu.count = 1;
            bu.round = XML::getProperty(node, "round", 2);
            bu.separator = XML::getProperty(node, "separator", " ");

            ud.levels.push_back(bu);

            for_each_xml_child_node(uLevel, node)
            {
                if (xmlNameEqual(uLevel, "level"))
                {
                    const UnitLevel ul =
                    {
                        XML::getProperty(uLevel, "symbol",
                                         strprintf("¤%d", level)),
                        XML::getProperty(uLevel, "count", -1),
                        XML::getProperty(uLevel, "round", bu.round),
                        XML::getProperty(uLevel, "separator", bu.separator)
                    };

                    if (ul.count > 0)
                    {
                        ud.levels.push_back(ul);
                        level++;
                    }
                    else
                    {
                        logger->log("Error bad unit count: %d for %s in %s",
                                    ul.count, ul.symbol.c_str(),
                                    bu.symbol.c_str());
                    }
                }
            }

            // Add one more level for saftey
            const UnitLevel lev =
            {
                "",
                INT_MAX,
                0,
                ""
            };
            ud.levels.push_back(lev);

            if (type == "weight")
                units[UNIT_WEIGHT] = ud;
            else if (type == "currency")
                units[UNIT_CURRENCY] = ud;
            else
                logger->log("Error unknown unit type: %s", type.c_str());
        }
    }