1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-08-16 19:39:51 +00:00

Added support for world maps in mods.

Mods with a <Properties hasWorldMap="1"> tag in their XML definition
can now open a native world map like the original game.
Fixed an oversight that the world map visited area was
updated while the editor was open; fixed worldmap.txt saving;
removed the limitation that world map tiles had to be 256x256 -
all tile sizes work now.
Improved the builtin worldmap editor a little.
The game does now read _mods/#/data/stringbank.txt from a mod and merges
it with the main stringbank.txt, and uses _mods/#/data/worldmap.txt
as a full replacement.
Load _mods/#/[map|premap]_mapname.lua scripts to properly
initialize the Naija map token.
This commit is contained in:
fgenesis 2011-09-18 20:53:27 +02:00
parent d4282221fc
commit b0d9fdc1cc
9 changed files with 169 additions and 80 deletions

View file

@ -240,13 +240,21 @@ WorldMap::WorldMap()
gw=gh=0;
}
void WorldMap::load(const std::string &file)
void WorldMap::load()
{
if (!dsq->mod.isActive())
_load("data/worldmap.txt");
else
_load(dsq->mod.getPath() + "data/worldmap.txt");
}
void WorldMap::_load(const std::string &file)
{
worldMapTiles.clear();
std::string line;
std::ifstream in(file.c_str());
std::ifstream in(file.c_str());
while (std::getline(in, line))
{
@ -259,15 +267,30 @@ void WorldMap::load(const std::string &file)
}
}
void WorldMap::save(const std::string &file)
void WorldMap::save()
{
std::ofstream out(file.c_str());
for (int i = 0; i < worldMapTiles.size(); i++)
{
WorldMapTile *t = &worldMapTiles[i];
out << t->index << " " << t->name << " " << t->layer << " " << t->scale << " " << t->gridPos.x << " " << t->gridPos.y << " " << t->prerevealed << " " << t->scale2 << std::endl;
}
std::string fn;
if (dsq->mod.isActive())
fn = dsq->mod.getPath() + "data/worldmap.txt";
else
fn = "data/worldmap.txt";
std::ofstream out(fn.c_str());
if (out)
{
for (int i = 0; i < worldMapTiles.size(); i++)
{
WorldMapTile *t = &worldMapTiles[i];
out << t->index << " " << t->stringIndex << " " << t->name << " " << t->layer << " " << t->scale << " " << t->gridPos.x << " " << t->gridPos.y << " " << t->prerevealed << " " << t->scale2 << std::endl;
}
dsq->screenMessage("Saved worldmap data to " + fn);
}
else
{
dsq->screenMessage("Unable to save worldmap to " + fn);
}
}
void WorldMap::revealMap(const std::string &name)