Exemple #1
0
    void apply_options(AG_Event *event)
    {
        int opengl = *static_cast<int*>(AG_PTR(1));
        int fs = *static_cast<int*>(AG_PTR(2));
        int lang = *static_cast<int*>(AG_PTR(3));

        std::stringstream str;
        str << "Fullscreen: " << fs;
        logger->logDebug(str.str());

        if (lang == -1)
            return;

        switch (lang)
        {
            case 0:
                game->setLanguage("en");
                break;

            case 1:
                game->setLanguage("pt");
                break;

            case 2:
                game->setLanguage("es");
                break;
        }

        interfaceManager->removeAllWindows();
        game->restart(opengl, fs, width, height);

        XMLFile file;
        if (file.load(resourceManager->getDataPath("townslife.cfg")))
        {
            file.setElement("graphics");

            file.changeInt("graphics", "opengl", opengl);
            if (fs)
                file.changeString("graphics", "fullscreen", "true");
            else
                file.changeString("graphics", "fullscreen", "false");
            file.changeInt("graphics", "width", width);
            file.changeInt("graphics", "height", height);

            file.setElement("language");
            file.changeString("language", "value", game->getLanguage());

            file.save();
        }

        GameState *state = new LoginState;
        game->changeState(state);
    }
Exemple #2
0
void Costume::save(string dirPath)
{
	Log::write(LOG_INFO, "Costume\n");
	Log::indent();

	if (!IO::createDirectory(dirPath))
		Log::write(LOG_ERROR, "Could not create directory \"%s\" !\n", dirPath.c_str());

	XMLFile xmlFile;
	XMLNode *rootNode = new XMLNode("costume");
	xmlFile.setRootNode(rootNode);

	rootNode->addChild(new XMLNode("name", _name));
	Log::write(LOG_INFO, "name: %s\n", _name.c_str());

	rootNode->addChild(new XMLNode("mirror", _mirror));
	Log::write(LOG_INFO, "mirror: %d\n", _mirror);

	for (int i = 0; i < _anims.size(); i++)
	{
		XMLNode *child = new XMLNode("anim");
		rootNode->addChild(child);
		_anims[i]->save(child);
	}

	for (int i = 0; i < _frames.size(); i++)
	{
		XMLNode *child = new XMLNode("frame");
		rootNode->addChild(child);
		_frames[i]->save(child, dirPath);
	}

	_paletteData->save(dirPath);

	if (!xmlFile.save(dirPath + XML_FILE_NAME))
		Log::write(LOG_ERROR, "Couldn't save costume to the specified directory !\n");

	Log::unIndent();
}
Exemple #3
0
void Object::save(string dirPath)
{
	Log::write(LOG_INFO, "Object\n");
	Log::indent();

	if (!IO::createDirectory(dirPath))
		Log::write(LOG_ERROR, "Could not create directory \"%s\" !\n", dirPath.c_str());

	XMLFile xmlFile;
	XMLNode *rootNode = new XMLNode("object");
	xmlFile.setRootNode(rootNode);

	rootNode->addChild(new XMLNode("name", _name));
	Log::write(LOG_INFO, "name: %s\n", _name.c_str());

	rootNode->addChild(new XMLNode("displayName", _displayName));
	Log::write(LOG_INFO, "displayName: %s\n", _displayName.c_str());

	// Change hotspots from relative to absolute positions when saving them
	rootNode->addChild(new XMLNode("hotspotX", _hotspotX + _x));
	Log::write(LOG_INFO, "hotspotX: %d\n", _hotspotX + _y);

	rootNode->addChild(new XMLNode("hotspotY", _hotspotY));
	Log::write(LOG_INFO, "hotspotY: %d\n", _hotspotY);

	rootNode->addChild(new XMLNode("x", _x));
	Log::write(LOG_INFO, "x: %u\n", _x);

	rootNode->addChild(new XMLNode("y", _y));
	Log::write(LOG_INFO, "y: %u\n", _y);

	rootNode->addChild(new XMLNode("width", _width));
	Log::write(LOG_INFO, "width: %u\n", _width);

	rootNode->addChild(new XMLNode("height", _height));
	Log::write(LOG_INFO, "height: %u\n", _height);

	string actorDir;
	switch (_actorDir)
	{
		case ACTOR_DIR_WEST:
			actorDir = "west";
			break;
		case ACTOR_DIR_EAST:
			actorDir = "east";
			break;
		case ACTOR_DIR_SOUTH:
			actorDir = "south";
			break;
		case ACTOR_DIR_NORTH:
			actorDir = "north";
			break;
	}
	rootNode->addChild(new XMLNode("actorDir", actorDir));
	Log::write(LOG_INFO, "actorDir: %s (%u)\n", actorDir.c_str(), _actorDir);

	for (int i = 0; i < _images.size(); i++)
	{
		_images[i]->save(dirPath + _images[i]->getName() + '/');
		rootNode->addChild(new XMLNode("image", _images[i]->getName()));
	}

	if (!_images.empty())
		_paletteData->save(dirPath);

	if (!xmlFile.save(dirPath + XML_FILE_NAME))
		Log::write(LOG_ERROR, "Couldn't save object to the specified directory !\n");

	Log::unIndent();
}