Frontend:
* Simplified the code to setup config structure and prepared it to enable user accessible asset directories
* Renamed team file extensions from ".ini" to ".hwt" (Hedgewars Team)
* Added campaign progress to teams (I know, no campaign ... yet)
--- a/QTfrontend/main.cpp Mon Aug 23 13:58:46 2010 +0200
+++ b/QTfrontend/main.cpp Mon Aug 23 16:29:12 2010 +0200
@@ -319,62 +319,52 @@
if(cConfigDir->length() == 0)
{
#ifdef __APPLE__
- if (checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars"))
- {
- checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Demos");
- checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Saves");
- checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Screenshots");
- checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Teams");
- }
+ checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars");
cfgdir->cd("Library/Application Support/Hedgewars");
#elif defined _WIN32
char path[1024];
if(!SHGetFolderPathA(0, CSIDL_PERSONAL, NULL, 0, path))
{
cfgdir->cd(path);
- if (checkForDir(cfgdir->absolutePath() + "/Hedgewars"))
- {
- checkForDir(cfgdir->absolutePath() + "/Hedgewars/Demos");
- checkForDir(cfgdir->absolutePath() + "/Hedgewars/Saves");
- checkForDir(cfgdir->absolutePath() + "/Hedgewars/Screenshots");
- checkForDir(cfgdir->absolutePath() + "/Hedgewars/Teams");
- }
+ checkForDir(cfgdir->absolutePath() + "/Hedgewars");
cfgdir->cd("Hedgewars");
}
- else
+ else // couldn't retrieve documents folder? almost impossible, but in case fall back to classic path
{
- if (checkForDir(cfgdir->absolutePath() + "/.hedgewars"))
- {
- checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos");
- checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves");
- checkForDir(cfgdir->absolutePath() + "/.hedgewars/Screenshots");
- checkForDir(cfgdir->absolutePath() + "/.hedgewars/Teams");
- }
+ checkForDir(cfgdir->absolutePath() + "/.hedgewars");
cfgdir->cd(".hedgewars");
}
#else
- if (checkForDir(cfgdir->absolutePath() + "/.hedgewars"))
- {
- checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos");
- checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves");
- checkForDir(cfgdir->absolutePath() + "/.hedgewars/Screenshots");
- checkForDir(cfgdir->absolutePath() + "/.hedgewars/Teams");
- }
+ checkForDir(cfgdir->absolutePath() + "/.hedgewars");
cfgdir->cd(".hedgewars");
#endif
}
- else
+
+ if (checkForDir(cfgdir->absolutePath()))
{
- if (checkForDir(cfgdir->absolutePath()))
- {
- checkForDir(cfgdir->absolutePath() + "/Demos");
- checkForDir(cfgdir->absolutePath() + "/Saves");
- checkForDir(cfgdir->absolutePath() + "/Screenshots");
- checkForDir(cfgdir->absolutePath() + "/Teams");
- }
+ // alternative loading/lookup paths
+ // TODO: Uncomment paths as they're implemented
+ checkForDir(cfgdir->absolutePath() + "/Data");
+ //checkForDir(cfgdir->absolutePath() + "/Data/Forts");
+ //checkForDir(cfgdir->absolutePath() + "/Data/Graphics");
+ //checkForDir(cfgdir->absolutePath() + "/Data/Graphics/Flags");
+ //checkForDir(cfgdir->absolutePath() + "/Data/Graphics/Graves");
+ //checkForDir(cfgdir->absolutePath() + "/Data/Graphics/Hats");
+ //checkForDir(cfgdir->absolutePath() + "/Data/Maps");
+ //checkForDir(cfgdir->absolutePath() + "/Data/Missions");
+ //checkForDir(cfgdir->absolutePath() + "/Data/Missions/Campaign");
+ //checkForDir(cfgdir->absolutePath() + "/Data/Missions/Training");
+ //checkForDir(cfgdir->absolutePath() + "/Data/Sounds");
+ //checkForDir(cfgdir->absolutePath() + "/Data/Sounds/voices");
+ //checkForDir(cfgdir->absolutePath() + "/Data/Themes");
+
+ // config/save paths
+ checkForDir(cfgdir->absolutePath() + "/Demos");
+ checkForDir(cfgdir->absolutePath() + "/Saves");
+ checkForDir(cfgdir->absolutePath() + "/Screenshots");
+ checkForDir(cfgdir->absolutePath() + "/Teams");
}
-
datadir->cd(bindir->absolutePath());
datadir->cd(*cDataDir);
if(!datadir->cd("hedgewars/Data")) {
--- a/QTfrontend/team.cpp Mon Aug 23 13:58:46 2010 +0200
+++ b/QTfrontend/team.cpp Mon Aug 23 16:29:12 2010 +0200
@@ -52,6 +52,7 @@
}
Rounds = 0;
Wins = 0;
+ CampaignProgress = 0;
}
HWTeam::HWTeam(const QStringList& strLst) :
@@ -77,6 +78,7 @@
}
Rounds = 0;
Wins = 0;
+ CampaignProgress = 0;
}
HWTeam::HWTeam() :
@@ -103,12 +105,13 @@
}
Rounds = 0;
Wins = 0;
+ CampaignProgress = 0;
}
bool HWTeam::LoadFromFile()
{
- QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + TeamName + ".ini", QSettings::IniFormat, 0);
+ QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + TeamName + ".hwt", QSettings::IniFormat, 0);
teamfile.setIniCodec("UTF-8");
TeamName = teamfile.value("Team/Name", TeamName).toString();
Grave = teamfile.value("Team/Grave", "Statue").toString();
@@ -118,6 +121,7 @@
difficulty = teamfile.value("Team/Difficulty", 0).toInt();
Rounds = teamfile.value("Team/Rounds", 0).toInt();
Wins = teamfile.value("Team/Wins", 0).toInt();
+ CampaignProgress = teamfile.value("Team/CampaignProgress", 0).toInt();
for(int i = 0; i < 8; i++)
{
QString hh = QString("Hedgehog%1/").arg(i);
@@ -140,7 +144,7 @@
bool HWTeam::FileExists()
{
- QFile f(cfgdir->absolutePath() + "/Teams/" + TeamName + ".ini");
+ QFile f(cfgdir->absolutePath() + "/Teams/" + TeamName + ".hwt");
return f.exists();
}
@@ -148,7 +152,7 @@
{
if(m_isNetTeam)
return false;
- QFile cfgfile(cfgdir->absolutePath() + "/Teams/" + TeamName + ".ini");
+ QFile cfgfile(cfgdir->absolutePath() + "/Teams/" + TeamName + ".hwt");
cfgfile.remove();
return true;
}
@@ -157,11 +161,11 @@
{
if (OldTeamName != TeamName)
{
- QFile cfgfile(cfgdir->absolutePath() + "/Teams/" + OldTeamName + ".ini");
+ QFile cfgfile(cfgdir->absolutePath() + "/Teams/" + OldTeamName + ".hwt");
cfgfile.remove();
OldTeamName = TeamName;
}
- QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + TeamName + ".ini", QSettings::IniFormat, 0);
+ QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + TeamName + ".hwt", QSettings::IniFormat, 0);
teamfile.setIniCodec("UTF-8");
teamfile.setValue("Team/Name", TeamName);
teamfile.setValue("Team/Grave", Grave);
@@ -171,6 +175,7 @@
teamfile.setValue("Team/Difficulty", difficulty);
teamfile.setValue("Team/Rounds", Rounds);
teamfile.setValue("Team/Wins", Wins);
+ teamfile.setValue("Team/CampaignProgress", CampaignProgress);
for(int i = 0; i < 8; i++)
{
QString hh = QString("Hedgehog%1/").arg(i);
--- a/QTfrontend/team.h Mon Aug 23 13:58:46 2010 +0200
+++ b/QTfrontend/team.h Mon Aug 23 16:29:12 2010 +0200
@@ -56,6 +56,7 @@
QString Owner;
int Rounds;
int Wins;
+ int CampaignProgress;
HWHog Hedgehogs[8];
unsigned int AchievementProgress[MAX_ACHIEVEMENTS];
unsigned int difficulty;