summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-12 21:32:57 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-12 21:32:57 (GMT)
commit8ca27520a437bf33fb374d5a88731605cd3739e7 (patch)
treef081511e0f26946016529382c68000d3c6ea5a3a /src
parentca7c0e7370542a97dd03210e13ec2c56679d5ca4 (diff)
downloadpowder-8ca27520a437bf33fb374d5a88731605cd3739e7.zip
powder-8ca27520a437bf33fb374d5a88731605cd3739e7.tar.gz
Use forward declarations more to avoid excessive includes
Diffstat (limited to 'src')
-rw-r--r--src/Config.h1
-rw-r--r--src/Format.h1
-rw-r--r--src/PowderToySDL.cpp2
-rw-r--r--src/Style.cpp2
-rw-r--r--src/Style.h3
-rw-r--r--src/client/Client.cpp179
-rw-r--r--src/client/Client.h61
-rw-r--r--src/client/GameSave.cpp24
-rw-r--r--src/client/GameSave.h9
-rw-r--r--src/client/SaveFile.cpp11
-rw-r--r--src/client/SaveFile.h18
-rw-r--r--src/client/SaveInfo.cpp29
-rw-r--r--src/client/SaveInfo.h32
-rw-r--r--src/client/ThumbnailBroker.cpp1
-rw-r--r--src/client/User.h8
-rw-r--r--src/elementsearch/ElementSearchActivity.cpp1
-rw-r--r--src/filebrowser/FileBrowserActivity.cpp1
-rw-r--r--src/graphics/Renderer.h1
-rw-r--r--src/interface/Label.cpp1
-rw-r--r--src/interface/SaveButton.cpp2
-rw-r--r--src/interface/Window.cpp1
-rw-r--r--src/localbrowser/LocalBrowserModel.cpp3
-rw-r--r--src/localbrowser/LocalBrowserModel.h9
-rw-r--r--src/localbrowser/LocalBrowserView.cpp6
-rw-r--r--src/localbrowser/LocalBrowserView.h11
-rw-r--r--src/login/LoginView.cpp5
-rw-r--r--src/login/LoginView.h10
-rw-r--r--src/preview/PreviewModel.cpp1
-rw-r--r--src/save/LocalSaveActivity.cpp1
-rw-r--r--src/search/SearchView.cpp7
-rw-r--r--src/simulation/SaveRenderer.cpp3
-rw-r--r--src/simulation/SaveRenderer.h5
-rw-r--r--src/simulation/Simulation.h6
-rw-r--r--src/tags/TagsController.cpp4
-rw-r--r--src/tags/TagsController.h4
-rw-r--r--src/tags/TagsModel.cpp13
-rw-r--r--src/tags/TagsModel.h8
-rw-r--r--src/tags/TagsModelException.h5
-rw-r--r--src/tags/TagsView.cpp9
-rw-r--r--src/tags/TagsView.h10
-rw-r--r--src/update/UpdateActivity.h1
41 files changed, 281 insertions, 228 deletions
diff --git a/src/Config.h b/src/Config.h
index 730b2ff..2310555 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -202,5 +202,4 @@ extern unsigned char ZSIZE;
#define DEBUG_PERFORMANCE_CALC 0x0008
#define DEBUG_PERFORMANCE_FRAME 0x0010
-#include "interface/Keys.h"
//#endif /* CONFIG_H_ */
diff --git a/src/Format.h b/src/Format.h
index fc55f8f..532f952 100644
--- a/src/Format.h
+++ b/src/Format.h
@@ -4,6 +4,7 @@
#include <vector>
class VideoBuffer;
+
namespace format
{
template <typename T> std::string NumberToString(T number)
diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp
index 1085561..8d7903b 100644
--- a/src/PowderToySDL.cpp
+++ b/src/PowderToySDL.cpp
@@ -28,6 +28,8 @@
#include "interface/Panel.h"
#include "interface/Point.h"
#include "interface/Label.h"
+#include "interface/Keys.h"
+
#include "simulation/SaveRenderer.h"
#include "client/Client.h"
#include "Misc.h"
diff --git a/src/Style.cpp b/src/Style.cpp
index 4ffd6c4..9bb5c65 100644
--- a/src/Style.cpp
+++ b/src/Style.cpp
@@ -7,7 +7,9 @@
//
#include <iostream>
+
#include "Style.h"
+#include "interface/Colour.h"
namespace style {
ui::Colour Colour::InformationTitle = ui::Colour(140, 140, 255);
diff --git a/src/Style.h b/src/Style.h
index 75df1b3..0463a22 100644
--- a/src/Style.h
+++ b/src/Style.h
@@ -7,7 +7,8 @@
#ifndef The_Powder_Toy_Style_h
#define The_Powder_Toy_Style_h
-#include "interface/Colour.h"
+
+namespace ui { class Colour; }
namespace style
{
diff --git a/src/client/Client.cpp b/src/client/Client.cpp
index 9908e69..192c87b 100644
--- a/src/client/Client.cpp
+++ b/src/client/Client.cpp
@@ -7,6 +7,7 @@
#include <time.h>
#include <stdio.h>
#include <deque>
+#include <fstream>
#ifdef MACOSX
#include <mach-o/dyld.h>
@@ -29,14 +30,22 @@
#include "MD5.h"
#include "graphics/Graphics.h"
#include "Misc.h"
+#include "Update.h"
+#include "HTTP.h"
#include "simulation/SaveRenderer.h"
#include "interface/Point.h"
#include "client/SaveInfo.h"
+#include "client/SaveFile.h"
+#include "client/GameSave.h"
+#include "search/Thumbnail.h"
+#include "preview/Comment.h"
#include "ClientListener.h"
-#include "Update.h"
#include "ThumbnailBroker.h"
+#include "cajun/reader.h"
+#include "cajun/writer.h"
+
extern "C"
{
#if defined(WIN) && !defined(__GNUC__)
@@ -65,13 +74,13 @@ Client::Client():
//Read config
std::ifstream configFile;
- configFile.open("powder.pref", ios::binary);
+ configFile.open("powder.pref", std::ios::binary);
if(configFile)
{
int fsize = configFile.tellg();
configFile.seekg(0, std::ios::end);
fsize = configFile.tellg() - (std::streampos)fsize;
- configFile.seekg(0, ios::beg);
+ configFile.seekg(0, std::ios::beg);
if(fsize)
{
json::Reader::Read(configDocument, configFile);
@@ -84,11 +93,11 @@ Client::Client():
std::string userElevation = ((json::String)(configDocument["User"]["Elevation"])).Value();
if(userElevation == "Admin")
- authUser.UserElevation = ElevationAdmin;
+ authUser.UserElevation = User::ElevationAdmin;
else if(userElevation == "Mod")
- authUser.UserElevation = ElevationModerator;
+ authUser.UserElevation = User::ElevationModerator;
else
- authUser.UserElevation= ElevationNone;
+ authUser.UserElevation = User::ElevationNone;
}
catch (json::Exception &e)
{
@@ -116,7 +125,7 @@ void Client::Initialise(std::string proxyString)
//Read stamps library
std::ifstream stampsLib;
- stampsLib.open(STAMPS_DIR PATH_SEP "stamps.def", ios::binary);
+ stampsLib.open(STAMPS_DIR PATH_SEP "stamps.def", std::ios::binary);
while(true)
{
char data[11];
@@ -404,7 +413,7 @@ void Client::WriteFile(std::vector<unsigned char> fileData, std::string filename
try
{
std::ofstream fileStream;
- fileStream.open(string(filename).c_str(), ios::binary);
+ fileStream.open(std::string(filename).c_str(), std::ios::binary);
if(fileStream.is_open())
{
fileStream.write((char*)&fileData[0], fileData.size());
@@ -424,7 +433,7 @@ bool Client::FileExists(std::string filename)
try
{
std::ifstream fileStream;
- fileStream.open(string(filename).c_str(), ios::binary);
+ fileStream.open(std::string(filename).c_str(), std::ios::binary);
if(fileStream.is_open())
{
exists = true;
@@ -443,7 +452,7 @@ void Client::WriteFile(std::vector<char> fileData, std::string filename)
try
{
std::ofstream fileStream;
- fileStream.open(string(filename).c_str(), ios::binary);
+ fileStream.open(std::string(filename).c_str(), std::ios::binary);
if(fileStream.is_open())
{
fileStream.write(&fileData[0], fileData.size());
@@ -462,10 +471,10 @@ std::vector<unsigned char> Client::ReadFile(std::string filename)
try
{
std::ifstream fileStream;
- fileStream.open(string(filename).c_str(), ios::binary);
+ fileStream.open(std::string(filename).c_str(), std::ios::binary);
if(fileStream.is_open())
{
- fileStream.seekg(0, ios::end);
+ fileStream.seekg(0, std::ios::end);
size_t fileSize = fileStream.tellg();
fileStream.seekg(0);
@@ -652,7 +661,7 @@ void Client::Shutdown()
//Save config
std::ofstream configFile;
- configFile.open("powder.pref", ios::trunc);
+ configFile.open("powder.pref", std::ios::trunc);
if(configFile)
{
if(authUser.ID)
@@ -661,9 +670,9 @@ void Client::Shutdown()
configDocument["User"]["SessionID"] = json::String(authUser.SessionID);
configDocument["User"]["SessionKey"] = json::String(authUser.SessionKey);
configDocument["User"]["Username"] = json::String(authUser.Username);
- if(authUser.UserElevation == ElevationAdmin)
+ if(authUser.UserElevation == User::ElevationAdmin)
configDocument["User"]["Elevation"] = json::String("Admin");
- else if(authUser.UserElevation == ElevationModerator)
+ else if(authUser.UserElevation == User::ElevationModerator)
configDocument["User"]["Elevation"] = json::String("Mod");
else
configDocument["User"]["Elevation"] = json::String("None");
@@ -767,13 +776,13 @@ RequestStatus Client::UploadSave(SaveInfo & save)
return RequestFailure;
}
-SaveFile * Client::GetStamp(string stampID)
+SaveFile * Client::GetStamp(std::string stampID)
{
std::ifstream stampFile;
- stampFile.open(string(STAMPS_DIR PATH_SEP + stampID + ".stm").c_str(), ios::binary);
+ stampFile.open(std::string(STAMPS_DIR PATH_SEP + stampID + ".stm").c_str(), std::ios::binary);
if(stampFile.is_open())
{
- stampFile.seekg(0, ios::end);
+ stampFile.seekg(0, std::ios::end);
size_t fileSize = stampFile.tellg();
stampFile.seekg(0);
@@ -781,7 +790,7 @@ SaveFile * Client::GetStamp(string stampID)
stampFile.read((char *)tempData, fileSize);
stampFile.close();
- SaveFile * file = new SaveFile(string(stampID).c_str());
+ SaveFile * file = new SaveFile(std::string(stampID).c_str());
GameSave * tempSave = new GameSave((char *)tempData, fileSize);
file->SetGameSave(tempSave);
return file;
@@ -792,13 +801,13 @@ SaveFile * Client::GetStamp(string stampID)
}
}
-void Client::DeleteStamp(string stampID)
+void Client::DeleteStamp(std::string stampID)
{
- for (std::list<string>::iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator)
+ for (std::list<std::string>::iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator)
{
if((*iterator) == stampID)
{
- stringstream stampFilename;
+ std::stringstream stampFilename;
stampFilename << STAMPS_DIR;
stampFilename << PATH_SEP;
stampFilename << stampID;
@@ -810,7 +819,7 @@ void Client::DeleteStamp(string stampID)
}
}
-string Client::AddStamp(GameSave * saveData)
+std::string Client::AddStamp(GameSave * saveData)
{
unsigned t=(unsigned)time(NULL);
if (lastStampTime!=t)
@@ -836,7 +845,7 @@ string Client::AddStamp(GameSave * saveData)
char * gameData = saveData->Serialise(gameDataLength);
std::ofstream stampStream;
- stampStream.open(string(STAMPS_DIR PATH_SEP + saveID.str()+".stm").c_str(), ios::binary);
+ stampStream.open(std::string(STAMPS_DIR PATH_SEP + saveID.str()+".stm").c_str(), std::ios::binary);
stampStream.write((const char *)gameData, gameDataLength);
stampStream.close();
@@ -857,8 +866,8 @@ void Client::updateStamps()
#endif
std::ofstream stampsStream;
- stampsStream.open(string(STAMPS_DIR PATH_SEP "stamps.def").c_str(), ios::binary);
- for (std::list<string>::const_iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator)
+ stampsStream.open(std::string(STAMPS_DIR PATH_SEP "stamps.def").c_str(), std::ios::binary);
+ for (std::list<std::string>::const_iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator)
{
stampsStream.write((*iterator).c_str(), 10);
}
@@ -872,17 +881,17 @@ int Client::GetStampsCount()
return stampIDs.size();
}
-vector<string> Client::GetStamps(int start, int count)
+std::vector<std::string> Client::GetStamps(int start, int count)
{
if(start+count > stampIDs.size()) {
if(start > stampIDs.size())
- return vector<string>();
+ return std::vector<std::string>();
count = stampIDs.size()-start;
}
- vector<string> stampRange;
+ std::vector<std::string> stampRange;
int index = 0;
- for (std::list<string>::const_iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator, ++index) {
+ for (std::list<std::string>::const_iterator iterator = stampIDs.begin(), end = stampIDs.end(); iterator != end; ++iterator, ++index) {
if(index>=start && index < start+count)
stampRange.push_back(*iterator);
}
@@ -979,7 +988,7 @@ std::vector<unsigned char> Client::GetSaveData(int saveID, int saveDate)
return saveData;
}
-LoginStatus Client::Login(string username, string password, User & user)
+LoginStatus Client::Login(std::string username, std::string password, User & user)
{
lastError = "";
std::stringstream urlStream;
@@ -1028,11 +1037,11 @@ LoginStatus Client::Login(string username, string password, User & user)
user.SessionKey = sessionKeyTemp.Value();
std::string userElevation = userElevationTemp.Value();
if(userElevation == "Admin")
- user.UserElevation = ElevationAdmin;
+ user.UserElevation = User::ElevationAdmin;
else if(userElevation == "Mod")
- user.UserElevation = ElevationModerator;
+ user.UserElevation = User::ElevationModerator;
else
- user.UserElevation= ElevationNone;
+ user.UserElevation= User::ElevationNone;
return LoginOkay;
}
else
@@ -1062,7 +1071,7 @@ LoginStatus Client::Login(string username, string password, User & user)
RequestStatus Client::DeleteSave(int saveID)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1114,7 +1123,7 @@ failure:
RequestStatus Client::AddComment(int saveID, std::string comment)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1175,7 +1184,7 @@ failure:
RequestStatus Client::FavouriteSave(int saveID, bool favourite)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1232,7 +1241,7 @@ failure:
RequestStatus Client::ReportSave(int saveID, std::string message)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1291,7 +1300,7 @@ failure:
RequestStatus Client::UnpublishSave(int saveID)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1383,7 +1392,7 @@ SaveInfo * Client::GetSave(int saveID, int saveDate)
json::Number tempComments = objDocument["Comments"];
json::Array tagsArray = objDocument["Tags"];
- vector<string> tempTags;
+ std::vector<std::string> tempTags;
for(int j = 0; j < tagsArray.Size(); j++)
{
@@ -1508,7 +1517,7 @@ std::vector<SaveComment*> * Client::GetComments(int saveID, int start, int count
return commentArray;
}
-std::vector<std::pair<std::string, int> > * Client::GetTags(int start, int count, string query, int & resultCount)
+std::vector<std::pair<std::string, int> > * Client::GetTags(int start, int count, std::string query, int & resultCount)
{
lastError = "";
resultCount = 0;
@@ -1557,7 +1566,7 @@ std::vector<std::pair<std::string, int> > * Client::GetTags(int start, int count
return tagArray;
}
-std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, string query, string sort, std::string category, int & resultCount)
+std::vector<SaveInfo*> * Client::SearchSaves(int start, int count, std::string query, std::string sort, std::string category, int & resultCount)
{
lastError = "";
resultCount = 0;
@@ -1765,10 +1774,10 @@ Thumbnail * Client::GetThumbnail(int saveID, int saveDate)
return NULL;
}
-std::vector<string> * Client::RemoveTag(int saveID, string tag)
+std::vector<std::string> * Client::RemoveTag(int saveID, std::string tag)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1792,7 +1801,7 @@ std::vector<string> * Client::RemoveTag(int saveID, string tag)
json::Array tagsArray;
json::Reader::Read(tagsArray, dataStream);
- tags = new std::vector<string>();
+ tags = new std::vector<std::string>();
for(int j = 0; j < tagsArray.Size(); j++)
{
@@ -1814,10 +1823,10 @@ std::vector<string> * Client::RemoveTag(int saveID, string tag)
return tags;
}
-std::vector<string> * Client::AddTag(int saveID, string tag)
+std::vector<std::string> * Client::AddTag(int saveID, std::string tag)
{
lastError = "";
- std::vector<string> * tags = NULL;
+ std::vector<std::string> * tags = NULL;
std::stringstream urlStream;
char * data = NULL;
int dataStatus, dataLength;
@@ -1841,7 +1850,7 @@ std::vector<string> * Client::AddTag(int saveID, string tag)
json::Array tagsArray;
json::Reader::Read(tagsArray, dataStream);
- tags = new std::vector<string>();
+ tags = new std::vector<std::string>();
for(int j = 0; j < tagsArray.Size(); j++)
{
@@ -1863,11 +1872,11 @@ std::vector<string> * Client::AddTag(int saveID, string tag)
return tags;
}
-vector<std::string> Client::explodePropertyString(std::string property)
+std::vector<std::string> Client::explodePropertyString(std::string property)
{
- vector<string> stringArray;
- string current = "";
- for (string::iterator iter = property.begin(); iter != property.end(); ++iter) {
+ std::vector<std::string> stringArray;
+ std::string current = "";
+ for (std::string::iterator iter = property.begin(); iter != property.end(); ++iter) {
if (*iter == '.') {
if (current.length() > 0) {
stringArray.push_back(current);
@@ -1931,7 +1940,7 @@ int Client::GetPrefInteger(std::string property, int defaultValue)
{
}
- catch(exception & e)
+ catch(std::exception & e)
{
}
@@ -1959,19 +1968,19 @@ unsigned int Client::GetPrefUInteger(std::string property, unsigned int defaultV
{
}
- catch(exception & e)
+ catch(std::exception & e)
{
}
return defaultValue;
}
-vector<string> Client::GetPrefStringArray(std::string property)
+std::vector<std::string> Client::GetPrefStringArray(std::string property)
{
try
{
json::Array value = GetPref(property);
- vector<string> strArray;
+ std::vector<std::string> strArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
@@ -1990,15 +1999,15 @@ vector<string> Client::GetPrefStringArray(std::string property)
{
}
- return vector<string>();
+ return std::vector<std::string>();
}
-vector<double> Client::GetPrefNumberArray(std::string property)
+std::vector<double> Client::GetPrefNumberArray(std::string property)
{
try
{
json::Array value = GetPref(property);
- vector<double> strArray;
+ std::vector<double> strArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
@@ -2017,15 +2026,15 @@ vector<double> Client::GetPrefNumberArray(std::string property)
{
}
- return vector<double>();
+ return std::vector<double>();
}
-vector<int> Client::GetPrefIntegerArray(std::string property)
+std::vector<int> Client::GetPrefIntegerArray(std::string property)
{
try
{
json::Array value = GetPref(property);
- vector<int> intArray;
+ std::vector<int> intArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
@@ -2051,15 +2060,15 @@ vector<int> Client::GetPrefIntegerArray(std::string property)
{
}
- return vector<int>();
+ return std::vector<int>();
}
-vector<unsigned int> Client::GetPrefUIntegerArray(std::string property)
+std::vector<unsigned int> Client::GetPrefUIntegerArray(std::string property)
{
try
{
json::Array value = GetPref(property);
- vector<unsigned int> intArray;
+ std::vector<unsigned int> intArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
@@ -2085,15 +2094,15 @@ vector<unsigned int> Client::GetPrefUIntegerArray(std::string property)
{
}
- return vector<unsigned int>();
+ return std::vector<unsigned int>();
}
-vector<bool> Client::GetPrefBoolArray(std::string property)
+std::vector<bool> Client::GetPrefBoolArray(std::string property)
{
try
{
json::Array value = GetPref(property);
- vector<bool> strArray;
+ std::vector<bool> strArray;
for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
{
try
@@ -2112,7 +2121,7 @@ vector<bool> Client::GetPrefBoolArray(std::string property)
{
}
- return vector<bool>();
+ return std::vector<bool>();
}
bool Client::GetPrefBool(std::string property, bool defaultValue)
@@ -2157,10 +2166,10 @@ void Client::SetPref(std::string property, unsigned int value)
SetPref(property, intValue);
}
-void Client::SetPref(std::string property, vector<string> value)
+void Client::SetPref(std::string property, std::vector<std::string> value)
{
json::Array newArray;
- for(vector<string>::iterator iter = value.begin(); iter != value.end(); ++iter)
+ for(std::vector<std::string>::iterator iter = value.begin(); iter != value.end(); ++iter)
{
newArray.Insert(json::String(*iter));
}
@@ -2168,10 +2177,10 @@ void Client::SetPref(std::string property, vector<string> value)
SetPref(property, newArrayValue);
}
-void Client::SetPref(std::string property, vector<double> value)
+void Client::SetPref(std::string property, std::vector<double> value)
{
json::Array newArray;
- for(vector<double>::iterator iter = value.begin(); iter != value.end(); ++iter)
+ for(std::vector<double>::iterator iter = value.begin(); iter != value.end(); ++iter)
{
newArray.Insert(json::Number(*iter));
}
@@ -2179,10 +2188,10 @@ void Client::SetPref(std::string property, vector<double> value)
SetPref(property, newArrayValue);
}
-void Client::SetPref(std::string property, vector<bool> value)
+void Client::SetPref(std::string property, std::vector<bool> value)
{
json::Array newArray;
- for(vector<bool>::iterator iter = value.begin(); iter != value.end(); ++iter)
+ for(std::vector<bool>::iterator iter = value.begin(); iter != value.end(); ++iter)
{
newArray.Insert(json::Boolean(*iter));
}
@@ -2190,10 +2199,10 @@ void Client::SetPref(std::string property, vector<bool> value)
SetPref(property, newArrayValue);
}
-void Client::SetPref(std::string property, vector<int> value)
+void Client::SetPref(std::string property, std::vector<int> value)
{
json::Array newArray;
- for(vector<int>::iterator iter = value.begin(); iter != value.end(); ++iter)
+ for(std::vector<int>::iterator iter = value.begin(); iter != value.end(); ++iter)
{
std::stringstream hexInt;
hexInt << std::hex << *iter;
@@ -2204,10 +2213,10 @@ void Client::SetPref(std::string property, vector<int> value)
SetPref(property, newArrayValue);
}
-void Client::SetPref(std::string property, vector<unsigned int> value)
+void Client::SetPref(std::string property, std::vector<unsigned int> value)
{
json::Array newArray;
- for(vector<unsigned int>::iterator iter = value.begin(); iter != value.end(); ++iter)
+ for(std::vector<unsigned int>::iterator iter = value.begin(); iter != value.end(); ++iter)
{
std::stringstream hexInt;
hexInt << std::hex << *iter;
@@ -2226,17 +2235,17 @@ void Client::SetPref(std::string property, bool value)
json::UnknownElement Client::GetPref(std::string property)
{
- vector<string> pTokens = Client::explodePropertyString(property);
+ std::vector<std::string> pTokens = Client::explodePropertyString(property);
const json::UnknownElement & configDocumentCopy = configDocument;
json::UnknownElement currentRef = configDocumentCopy;
- for(vector<string>::iterator iter = pTokens.begin(); iter != pTokens.end(); ++iter)
+ for(std::vector<std::string>::iterator iter = pTokens.begin(); iter != pTokens.end(); ++iter)
{
currentRef = ((const json::UnknownElement &)currentRef)[*iter];
}
return currentRef;
}
-void Client::setPrefR(std::deque<string> tokens, json::UnknownElement & element, json::UnknownElement & value)
+void Client::setPrefR(std::deque<std::string> tokens, json::UnknownElement & element, json::UnknownElement & value)
{
if(tokens.size())
{
@@ -2250,9 +2259,9 @@ void Client::setPrefR(std::deque<string> tokens, json::UnknownElement & element,
void Client::SetPref(std::string property, json::UnknownElement & value)
{
- vector<string> pTokens = Client::explodePropertyString(property);
- deque<string> dTokens(pTokens.begin(), pTokens.end());
- string token = dTokens.front();
+ std::vector<std::string> pTokens = Client::explodePropertyString(property);
+ std::deque<std::string> dTokens(pTokens.begin(), pTokens.end());
+ std::string token = dTokens.front();
dTokens.pop_front();
setPrefR(dTokens, configDocument[token], value);
}
diff --git a/src/client/Client.h b/src/client/Client.h
index 31f1fa1..d9fedd5 100644
--- a/src/client/Client.h
+++ b/src/client/Client.h
@@ -4,21 +4,20 @@
#include <queue>
#include <vector>
#include <list>
-#include <fstream>
#include "Config.h"
-#include "HTTP.h"
-#include "preview/Comment.h"
-#include "search/Thumbnail.h"
-#include "client/SaveInfo.h"
-#include "client/SaveFile.h"
#include "Singleton.h"
+
#include "User.h"
-#include "cajun/reader.h"
-#include "cajun/writer.h"
#include "cajun/elements.h"
+class Thumbnail;
+class SaveInfo;
+class SaveFile;
+class SaveComment;
+class GameSave;
+
enum LoginStatus {
LoginOkay, LoginError
};
@@ -55,7 +54,7 @@ private:
std::string lastError;
- list<string> stampIDs;
+ std::list<std::string> stampIDs;
int lastStampTime;
int lastStampName;
@@ -70,7 +69,7 @@ private:
int activeThumbRequestCompleteTimes[IMGCONNS];
std::string activeThumbRequestIDs[IMGCONNS];
void updateStamps();
- static vector<std::string> explodePropertyString(std::string property);
+ static std::vector<std::string> explodePropertyString(std::string property);
void notifyUpdateAvailable();
void notifyAuthUserChanged();
void notifyMessageOfTheDay();
@@ -79,7 +78,7 @@ private:
json::Object configDocument;
public:
- vector<ClientListener*> listeners;
+ std::vector<ClientListener*> listeners;
UpdateInfo GetUpdateInfo();
@@ -109,10 +108,10 @@ public:
RequestStatus ExecVote(int saveID, int direction);
RequestStatus UploadSave(SaveInfo & save);
- SaveFile * GetStamp(string stampID);
- void DeleteStamp(string stampID);
- string AddStamp(GameSave * saveData);
- vector<string> GetStamps(int start, int count);
+ SaveFile * GetStamp(std::string stampID);
+ void DeleteStamp(std::string stampID);
+ std::string AddStamp(GameSave * saveData);
+ std::vector<std::string> GetStamps(int start, int count);
int GetStampsCount();
SaveFile * GetFirstStamp();
@@ -120,10 +119,10 @@ public:
unsigned char * GetSaveData(int saveID, int saveDate, int & dataLength);
std::vector<unsigned char> GetSaveData(int saveID, int saveDate);
- LoginStatus Login(string username, string password, User & user);
+ LoginStatus Login(std::string username, std::string password, User & user);
void ClearThumbnailRequests();
- std::vector<SaveInfo*> * SearchSaves(int start, int count, string query, string sort, string category, int & resultCount);
- std::vector<std::pair<std::string, int> > * GetTags(int start, int count, string query, int & resultCount);
+ std::vector<SaveInfo*> * SearchSaves(int start, int count, std::string query, std::string sort, std::string category, int & resultCount);
+ std::vector<std::pair<std::string, int> > * GetTags(int start, int count, std::string query, int & resultCount);
std::vector<SaveComment*> * GetComments(int saveID, int start, int count);
Thumbnail * GetPreview(int saveID, int saveDate);
Thumbnail * GetThumbnail(int saveID, int saveDate);
@@ -134,8 +133,8 @@ public:
RequestStatus FavouriteSave(int saveID, bool favourite);
void SetAuthUser(User user);
User GetAuthUser();
- std::vector<string> * RemoveTag(int saveID, string tag); //TODO RequestStatus
- std::vector<string> * AddTag(int saveID, string tag);
+ std::vector<std::string> * RemoveTag(int saveID, std::string tag); //TODO RequestStatus
+ std::vector<std::string> * AddTag(int saveID, std::string tag);
std::string GetLastError() {
return lastError;
}
@@ -146,26 +145,26 @@ public:
double GetPrefNumber(std::string property, double defaultValue);
int GetPrefInteger(std::string property, int defaultValue);
unsigned int GetPrefUInteger(std::string property, unsigned int defaultValue);
- vector<string> GetPrefStringArray(std::string property);
- vector<double> GetPrefNumberArray(std::string property);
- vector<int> GetPrefIntegerArray(std::string property);
- vector<unsigned int> GetPrefUIntegerArray(std::string property);
- vector<bool> GetPrefBoolArray(std::string property);
+ std::vector<std::string> GetPrefStringArray(std::string property);
+ std::vector<double> GetPrefNumberArray(std::string property);
+ std::vector<int> GetPrefIntegerArray(std::string property);
+ std::vector<unsigned int> GetPrefUIntegerArray(std::string property);
+ std::vector<bool> GetPrefBoolArray(std::string property);
bool GetPrefBool(std::string property, bool defaultValue);
void SetPref(std::string property, std::string value);
void SetPref(std::string property, double value);
void SetPref(std::string property, int value);
void SetPref(std::string property, unsigned int value);
- void SetPref(std::string property, vector<string> value);
- void SetPref(std::string property, vector<double> value);
- void SetPref(std::string property, vector<int> value);
- void SetPref(std::string property, vector<unsigned int> value);
- void SetPref(std::string property, vector<bool> value);
+ void SetPref(std::string property, std::vector<std::string> value);
+ void SetPref(std::string property, std::vector<double> value);
+ void SetPref(std::string property, std::vector<int> value);
+ void SetPref(std::string property, std::vector<unsigned int> value);
+ void SetPref(std::string property, std::vector<bool> value);
void SetPref(std::string property, bool value);
json::UnknownElement GetPref(std::string property);
- void setPrefR(std::deque<string> tokens, json::UnknownElement & element, json::UnknownElement & value);
+ void setPrefR(std::deque<std::string> tokens, json::UnknownElement & element, json::UnknownElement & value);
void SetPref(std::string property, json::UnknownElement & value);
};
diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp
index f615c6f..3cb3c29 100644
--- a/src/client/GameSave.cpp
+++ b/src/client/GameSave.cpp
@@ -41,10 +41,10 @@ originalData(save.originalData)
{
setSize(save.blockWidth, save.blockHeight);
- copy(save.particles, save.particles+NPART, particles);
- copy(save.blockMapPtr, save.blockMapPtr+(blockHeight*blockWidth), blockMapPtr);
- copy(save.fanVelXPtr, save.fanVelXPtr+(blockHeight*blockWidth), fanVelXPtr);
- copy(save.fanVelYPtr, save.fanVelYPtr+(blockHeight*blockWidth), fanVelYPtr);
+ std::copy(save.particles, save.particles+NPART, particles);
+ std::copy(save.blockMapPtr, save.blockMapPtr+(blockHeight*blockWidth), blockMapPtr);
+ std::copy(save.fanVelXPtr, save.fanVelXPtr+(blockHeight*blockWidth), fanVelXPtr);
+ std::copy(save.fanVelYPtr, save.fanVelYPtr+(blockHeight*blockWidth), fanVelYPtr);
}
else
{
@@ -261,11 +261,11 @@ void GameSave::setSize(int newWidth, int newHeight)
particles = new Particle[NPART];
blockMapPtr = new unsigned char[blockHeight*blockWidth];
- fill(blockMapPtr, blockMapPtr+(blockHeight*blockWidth), 0);
+ std::fill(blockMapPtr, blockMapPtr+(blockHeight*blockWidth), 0);
fanVelXPtr = new float[(blockHeight)*(blockWidth)];
- fill(fanVelXPtr, fanVelXPtr+((blockHeight)*(blockWidth)), 0);
+ std::fill(fanVelXPtr, fanVelXPtr+((blockHeight)*(blockWidth)), 0);
fanVelYPtr = new float[(blockHeight)*(blockWidth)];
- fill(fanVelYPtr, fanVelYPtr+((blockHeight)*(blockWidth)), 0);
+ std::fill(fanVelYPtr, fanVelYPtr+((blockHeight)*(blockWidth)), 0);
blockMap = new unsigned char*[blockHeight];
for(int y = 0; y < blockHeight; y++)
@@ -330,11 +330,11 @@ void GameSave::Transform(matrix2d transform, vector2d translate)
unsigned char * blockMapPtrNew;
blockMapPtrNew = new unsigned char[newBlockHeight*newBlockWidth];
- fill(blockMapPtrNew, blockMapPtrNew+(newBlockHeight*newBlockWidth), 0);
+ std::fill(blockMapPtrNew, blockMapPtrNew+(newBlockHeight*newBlockWidth), 0);
fanVelXPtrNew = new float[newBlockHeight*newBlockWidth];
- fill(fanVelXPtrNew, fanVelXPtrNew+(newBlockHeight*newBlockWidth), 0);
+ std::fill(fanVelXPtrNew, fanVelXPtrNew+(newBlockHeight*newBlockWidth), 0);
fanVelYPtrNew = new float[(newBlockHeight)*(newBlockWidth)];
- fill(fanVelYPtrNew, fanVelYPtrNew+(newBlockHeight*newBlockWidth), 0);
+ std::fill(fanVelYPtrNew, fanVelYPtrNew+(newBlockHeight*newBlockWidth), 0);
blockMapNew = new unsigned char*[newBlockHeight];
for(int y = 0; y < newBlockHeight; y++)
@@ -992,7 +992,7 @@ void GameSave::readPSv(char * data, int dataLength)
memcpy(goltype, golTypesT, sizeof(int) * (golTypesCount));
free(golTypesT);
- vector<Element> elements = GetElements();
+ std::vector<Element> elements = GetElements();
try
{
@@ -1609,7 +1609,7 @@ char * GameSave::serialiseOPS(int & dataLength)
int posCount, signsCount;
bson b;
- fill(elementCount, elementCount+PT_NUM, 0);
+ std::fill(elementCount, elementCount+PT_NUM, 0);
//Get coords in blocks
blockX = 0;//orig_x0/CELL;
diff --git a/src/client/GameSave.h b/src/client/GameSave.h
index 2c86ea1..7f8e7fc 100644
--- a/src/client/GameSave.h
+++ b/src/client/GameSave.h
@@ -12,17 +12,18 @@
#include <string>
#include "Config.h"
#include "Misc.h"
+
#include "simulation/Sign.h"
#include "simulation/Particle.h"
-using namespace std;
+//using namespace std;
-struct ParseException: public exception {
+struct ParseException: public std::exception {
enum ParseResult { OK = 0, Corrupt, WrongVersion, InvalidDimensions, InternalError, MissingElement };
- string message;
+ std::string message;
ParseResult result;
public:
- ParseException(ParseResult result, string message_): message(message_), result(result) {}
+ ParseException(ParseResult result, std::string message_): message(message_), result(result) {}
const char * what() const throw()
{
return message.c_str();
diff --git a/src/client/SaveFile.cpp b/src/client/SaveFile.cpp
index 0694167..368d89d 100644
--- a/src/client/SaveFile.cpp
+++ b/src/client/SaveFile.cpp
@@ -6,8 +6,9 @@
*/
#include "SaveFile.h"
+#include "GameSave.h"
#include "Client.h"
- #include "search/Thumbnail.h"
+#include "search/Thumbnail.h"
SaveFile::SaveFile(SaveFile & save):
gameSave(NULL),
@@ -31,7 +32,7 @@ void SaveFile::SetThumbnail(Thumbnail * thumb)
thumbnail = thumb;
}
-SaveFile::SaveFile(string filename):
+SaveFile::SaveFile(std::string filename):
filename(filename),
displayName(filename),
gameSave(NULL),
@@ -50,17 +51,17 @@ void SaveFile::SetGameSave(GameSave * save)
gameSave = save;
}
-string SaveFile::GetName()
+std::string SaveFile::GetName()
{
return filename;
}
-string SaveFile::GetDisplayName()
+std::string SaveFile::GetDisplayName()
{
return displayName;
}
-void SaveFile::SetDisplayName(string displayName)
+void SaveFile::SetDisplayName(std::string displayName)
{
this->displayName = displayName;
}
diff --git a/src/client/SaveFile.h b/src/client/SaveFile.h
index d631bc1..9a9310f 100644
--- a/src/client/SaveFile.h
+++ b/src/client/SaveFile.h
@@ -9,31 +9,29 @@
#define SAVEFILE_H_
#include <string>
-#include "GameSave.h"
-
-
-using namespace std;
+class GameSave;
class Thumbnail;
+
class SaveFile {
public:
SaveFile(SaveFile & save);
- SaveFile(string filename);
+ SaveFile(std::string filename);
Thumbnail * GetThumbnail();
GameSave * GetGameSave();
void SetThumbnail(Thumbnail * thumb);
void SetGameSave(GameSave * save);
- string GetDisplayName();
- void SetDisplayName(string displayName);
- string GetName();
+ std::string GetDisplayName();
+ void SetDisplayName(std::string displayName);
+ std::string GetName();
virtual ~SaveFile();
private:
Thumbnail * thumbnail;
GameSave * gameSave;
- string filename;
- string displayName;
+ std::string filename;
+ std::string displayName;
};
#endif /* SAVEFILE_H_ */
diff --git a/src/client/SaveInfo.cpp b/src/client/SaveInfo.cpp
index 1df74c7..3b8b9a1 100644
--- a/src/client/SaveInfo.cpp
+++ b/src/client/SaveInfo.cpp
@@ -5,8 +5,9 @@
* Author: Simon
*/
-#include "client/SaveInfo.h"
-#include "client/Client.h"
+#include "SaveInfo.h"
+#include "GameSave.h"
+#include "Client.h"
SaveInfo::SaveInfo(SaveInfo & save) :
userName(save.userName), name(save.name), Description(save.Description), date(
@@ -16,15 +17,15 @@ SaveInfo::SaveInfo(SaveInfo & save) :
gameSave = new GameSave(*save.gameSave);
}
-SaveInfo::SaveInfo(int _id, int _date, int _votesUp, int _votesDown, string _userName,
- string _name) :
+SaveInfo::SaveInfo(int _id, int _date, int _votesUp, int _votesDown, std::string _userName,
+ std::string _name) :
id(_id), votesUp(_votesUp), votesDown(_votesDown), userName(_userName), name(
_name), Description("No description provided"), date(_date), Published(
true), gameSave(NULL), vote(0), tags(), Comments(0) {
}
-SaveInfo::SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, string _userName,
- string _name, string description_, bool published_, vector<string> tags_) :
+SaveInfo::SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, std::string _userName,
+ std::string _name, std::string description_, bool published_, std::vector<std::string> tags_) :
id(_id), votesUp(_votesUp), votesDown(_votesDown), userName(_userName), name(
_name), Description(description_), date(date_), Published(
published_), gameSave(NULL), vote(_vote), tags(tags_), Comments(0) {
@@ -38,17 +39,17 @@ SaveInfo::~SaveInfo()
}
}
-void SaveInfo::SetName(string name) {
+void SaveInfo::SetName(std::string name) {
this->name = name;
}
-string SaveInfo::GetName() {
+std::string SaveInfo::GetName() {
return name;
}
-void SaveInfo::SetDescription(string description) {
+void SaveInfo::SetDescription(std::string description) {
Description = description;
}
-string SaveInfo::GetDescription() {
+std::string SaveInfo::GetDescription() {
return Description;
}
@@ -69,11 +70,11 @@ int SaveInfo::GetVote()
return vote;
}
-void SaveInfo::SetUserName(string userName) {
+void SaveInfo::SetUserName(std::string userName) {
this->userName = userName;
}
-string SaveInfo::GetUserName() {
+std::string SaveInfo::GetUserName() {
return userName;
}
@@ -98,11 +99,11 @@ int SaveInfo::GetVotesDown() {
return votesDown;
}
-void SaveInfo::SetTags(vector<string> tags)
+void SaveInfo::SetTags(std::vector<std::string> tags)
{
this->tags = tags;
}
-vector<string> SaveInfo::GetTags()
+std::vector<std::string> SaveInfo::GetTags()
{
return tags;
}
diff --git a/src/client/SaveInfo.h b/src/client/SaveInfo.h
index a54741a..6c3a2a3 100644
--- a/src/client/SaveInfo.h
+++ b/src/client/SaveInfo.h
@@ -5,10 +5,8 @@
#include <string>
#include <stdlib.h>
#include <iostream>
-#include <string.h>
-#include "GameSave.h"
-using namespace std;
+class GameSave;
class SaveInfo
{
@@ -24,34 +22,34 @@ public:
SaveInfo(SaveInfo & save);
- SaveInfo(int _id, int _date, int _votesUp, int _votesDown, string _userName, string _name);
+ SaveInfo(int _id, int _date, int _votesUp, int _votesDown, std::string _userName, std::string _name);
- SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, string _userName, string _name, string description_, bool published_, vector<string> tags);
+ SaveInfo(int _id, int date_, int _votesUp, int _votesDown, int _vote, std::string _userName, std::string _name, std::string description_, bool published_, std::vector<std::string> tags);
~SaveInfo();
- string userName;
- string name;
+ std::string userName;
+ std::string name;
- string Description;
+ std::string Description;
- vector<string> tags;
+ std::vector<std::string> tags;
int vote;
bool Published;
- void SetName(string name);
- string GetName();
+ void SetName(std::string name);
+ std::string GetName();
- void SetDescription(string description);
- string GetDescription();
+ void SetDescription(std::string description);
+ std::string GetDescription();
void SetPublished(bool published);
bool GetPublished();
- void SetUserName(string userName);
- string GetUserName();
+ void SetUserName(std::string userName);
+ std::string GetUserName();
void SetID(int id);
int GetID();
@@ -65,8 +63,8 @@ public:
void SetVotesDown(int votesDown);
int GetVotesDown();
- void SetTags(vector<string> tags);
- vector<string> GetTags();
+ void SetTags(std::vector<std::string> tags);
+ std::vector<std::string> GetTags();
GameSave * GetGameSave();
void SetGameSave(GameSave * gameSave);
diff --git a/src/client/ThumbnailBroker.cpp b/src/client/ThumbnailBroker.cpp
index 86a38d8..0a36fc0 100644
--- a/src/client/ThumbnailBroker.cpp
+++ b/src/client/ThumbnailBroker.cpp
@@ -4,6 +4,7 @@
#include "ThumbnailBroker.h"
#include "ThumbnailListener.h"
#include "Client.h"
+#include "HTTP.h"
#include "GameSave.h"
#include "search/Thumbnail.h"
#include "simulation/SaveRenderer.h"
diff --git a/src/client/User.h b/src/client/User.h
index 163f463..5a47a3e 100644
--- a/src/client/User.h
+++ b/src/client/User.h
@@ -10,14 +10,14 @@
#include <string>
-enum Elevation
-{
- ElevationAdmin, ElevationModerator, ElevationNone
-};
class User
{
public:
+ enum Elevation
+ {
+ ElevationAdmin, ElevationModerator, ElevationNone
+ };
int ID;
std::string Username;
std::string SessionID;
diff --git a/src/elementsearch/ElementSearchActivity.cpp b/src/elementsearch/ElementSearchActivity.cpp
index c8b0b82..8bf9e6e 100644
--- a/src/elementsearch/ElementSearchActivity.cpp
+++ b/src/elementsearch/ElementSearchActivity.cpp
@@ -9,6 +9,7 @@
#include "ElementSearchActivity.h"
#include "interface/Textbox.h"
#include "interface/Label.h"
+#include "interface/Keys.h"
#include "game/Tool.h"
#include "Style.h"
#include "game/GameModel.h"
diff --git a/src/filebrowser/FileBrowserActivity.cpp b/src/filebrowser/FileBrowserActivity.cpp
index 787afd3..52656df 100644
--- a/src/filebrowser/FileBrowserActivity.cpp
+++ b/src/filebrowser/FileBrowserActivity.cpp
@@ -8,6 +8,7 @@
#include "interface/ProgressBar.h"
#include "client/Client.h"
#include "client/SaveFile.h"
+#include "client/GameSave.h"
#include "Style.h"
#include "tasks/Task.h"
#include "simulation/SaveRenderer.h"
diff --git a/src/graphics/Renderer.h b/src/graphics/Renderer.h
index c395a91..6e814cc 100644
--- a/src/graphics/Renderer.h
+++ b/src/graphics/Renderer.h
@@ -8,7 +8,6 @@
#include "Config.h"
#include "client/Client.h"
-#include "simulation/Simulation.h"
#include "Graphics.h"
#include "interface/Point.h"
diff --git a/src/interface/Label.cpp b/src/interface/Label.cpp
index ee52fd8..976c788 100644
--- a/src/interface/Label.cpp
+++ b/src/interface/Label.cpp
@@ -2,6 +2,7 @@
#include "Config.h"
#include "Point.h"
#include "Label.h"
+#include "Keys.h"
#include "ContextMenu.h"
using namespace ui;
diff --git a/src/interface/SaveButton.cpp b/src/interface/SaveButton.cpp
index 18e382d..cc90a2f 100644
--- a/src/interface/SaveButton.cpp
+++ b/src/interface/SaveButton.cpp
@@ -222,7 +222,7 @@ void SaveButton::Draw(const Point& screenPos)
g->drawrect(screenPos.X-3+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 180, 180, 180, 255);
g->drawrect(screenPos.X-4+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, 7, thumbBoxSize.Y, 180, 180, 180, 255);
- int voteBar = max(10.0f, ((float)(thumbBoxSize.Y-4))*voteRatio);
+ int voteBar = std::max(10.0f, ((float)(thumbBoxSize.Y-4))*voteRatio);
g->fillrect(1+screenPos.X-3+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, (screenPos.Y-2)+(thumbBoxSize.Y-voteBar)+(Size.Y-21-thumbBoxSize.Y)/2, 3, voteBar, voteColour.Red, voteColour.Green, voteColour.Blue, 255);
}
else
diff --git a/src/interface/Window.cpp b/src/interface/Window.cpp
index 2914b1e..7a376d8 100644
--- a/src/interface/Window.cpp
+++ b/src/interface/Window.cpp
@@ -1,5 +1,6 @@
#include <iostream>
#include "Window.h"
+#include "Keys.h"
#include "Component.h"
#include "interface/Point.h"
#include "interface/Button.h"
diff --git a/src/localbrowser/LocalBrowserModel.cpp b/src/localbrowser/LocalBrowserModel.cpp
index 10290cc..c9fb0d9 100644
--- a/src/localbrowser/LocalBrowserModel.cpp
+++ b/src/localbrowser/LocalBrowserModel.cpp
@@ -7,8 +7,9 @@
#include "LocalBrowserModel.h"
#include "LocalBrowserView.h"
-#include "client/Client.h"
#include "LocalBrowserModelException.h"
+#include "client/Client.h"
+#include "client/SaveFile.h"
LocalBrowserModel::LocalBrowserModel():
stamp(NULL),
diff --git a/src/localbrowser/LocalBrowserModel.h b/src/localbrowser/LocalBrowserModel.h
index 531cc9b..a0a2956 100644
--- a/src/localbrowser/LocalBrowserModel.h
+++ b/src/localbrowser/LocalBrowserModel.h
@@ -11,11 +11,12 @@
#include <vector>
#include <string>
#include <cmath>
-#include "client/SaveFile.h"
+
+class SaveFile;
class LocalBrowserView;
class LocalBrowserModel {
- vector<std::string> selected;
+ std::vector<std::string> selected;
SaveFile * stamp;
std::vector<std::string> stampIDs;
std::vector<SaveFile*> savesList;
@@ -26,14 +27,14 @@ class LocalBrowserModel {
void notifySelectedChanged();
public:
LocalBrowserModel();
- int GetPageCount() { return max(1, (int)(ceil(stampIDs.size()/16))); }
+ int GetPageCount() { return std::max(1, (int)(std::ceil(stampIDs.size()/16))); }
int GetPageNum() { return currentPage; }
void AddObserver(LocalBrowserView * observer);
std::vector<SaveFile *> GetSavesList();
void UpdateSavesList(int pageNumber);
SaveFile * GetSave();
void SetSave(SaveFile * newStamp);
- vector<std::string> GetSelected() { return selected; }
+ std::vector<std::string> GetSelected() { return selected; }
void ClearSelected() { selected.clear(); notifySelectedChanged(); }
void SelectSave(std::string stampID);
void DeselectSave(std::string stampID);
diff --git a/src/localbrowser/LocalBrowserView.cpp b/src/localbrowser/LocalBrowserView.cpp
index 82182f4..448b5c5 100644
--- a/src/localbrowser/LocalBrowserView.cpp
+++ b/src/localbrowser/LocalBrowserView.cpp
@@ -9,6 +9,12 @@
#include "client/Client.h"
#include "LocalBrowserView.h"
+#include "interface/Button.h"
+#include "interface/Textbox.h"
+#include "interface/Label.h"
+#include "interface/SaveButton.h"
+#include "interface/Keys.h"
+
#include "dialogues/ErrorMessage.h"
#include "LocalBrowserController.h"
#include "LocalBrowserModel.h"
diff --git a/src/localbrowser/LocalBrowserView.h b/src/localbrowser/LocalBrowserView.h
index 3f197e0..71c20ee 100644
--- a/src/localbrowser/LocalBrowserView.h
+++ b/src/localbrowser/LocalBrowserView.h
@@ -10,10 +10,13 @@
#include <vector>
#include "interface/Window.h"
-#include "interface/Button.h"
-#include "interface/Textbox.h"
-#include "interface/Label.h"
-#include "interface/SaveButton.h"
+
+namespace ui
+{
+ class Label;
+ class Button;
+ class SaveButton;
+}
class LocalBrowserController;
class LocalBrowserModel;
diff --git a/src/login/LoginView.cpp b/src/login/LoginView.cpp
index 2902547..8cbdcfb 100644
--- a/src/login/LoginView.cpp
+++ b/src/login/LoginView.cpp
@@ -6,6 +6,11 @@
*/
#include "LoginView.h"
+
+#include "interface/Button.h"
+#include "interface/Label.h"
+#include "interface/Textbox.h"
+#include "interface/Keys.h"
#include "Style.h"
class LoginView::LoginAction : public ui::ButtonAction
diff --git a/src/login/LoginView.h b/src/login/LoginView.h
index 61d6d24..fe87a3f 100644
--- a/src/login/LoginView.h
+++ b/src/login/LoginView.h
@@ -8,13 +8,17 @@
#ifndef LOGINVIEW_H_
#define LOGINVIEW_H_
-#include "interface/Button.h"
#include "interface/Window.h"
-#include "interface/Label.h"
-#include "interface/Textbox.h"
#include "LoginController.h"
#include "LoginModel.h"
+namespace ui
+{
+ class Textbox;
+ class Button;
+ class Label;
+}
+
class LoginController;
class LoginMode;
class LoginView: public ui::Window {
diff --git a/src/preview/PreviewModel.cpp b/src/preview/PreviewModel.cpp
index 59c1c0b..8b327f9 100644
--- a/src/preview/PreviewModel.cpp
+++ b/src/preview/PreviewModel.cpp
@@ -8,6 +8,7 @@
#include <cmath>
#include "PreviewModel.h"
#include "client/Client.h"
+#include "client/GameSave.h";
#include "PreviewModelException.h"
PreviewModel::PreviewModel():
diff --git a/src/save/LocalSaveActivity.cpp b/src/save/LocalSaveActivity.cpp
index 387d0b8..fab71f2 100644
--- a/src/save/LocalSaveActivity.cpp
+++ b/src/save/LocalSaveActivity.cpp
@@ -12,6 +12,7 @@
#include "dialogues/ErrorMessage.h"
#include "dialogues/ConfirmPrompt.h"
#include "client/Client.h"
+#include "client/GameSave.h"
#include "Style.h"
class LocalSaveActivity::CancelAction: public ui::ButtonAction
diff --git a/src/search/SearchView.cpp b/src/search/SearchView.cpp
index 5e42289..80248e2 100644
--- a/src/search/SearchView.cpp
+++ b/src/search/SearchView.cpp
@@ -2,6 +2,7 @@
#include "SearchView.h"
#include "client/Client.h"
+#include "interface/Keys.h"
#include "interface/SaveButton.h"
#include "interface/Label.h"
#include "interface/Textbox.h"
@@ -264,7 +265,7 @@ void SearchView::NotifySortChanged(SearchModel * sender)
void SearchView::NotifyShowOwnChanged(SearchModel * sender)
{
ownButton->SetToggleState(sender->GetShowOwn());
- if(sender->GetShowOwn() || Client::Ref().GetAuthUser().UserElevation == ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == ElevationModerator)
+ if(sender->GetShowOwn() || Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator)
{
unpublishSelected->Enabled = true;
removeSelected->Enabled = true;
@@ -289,7 +290,7 @@ void SearchView::NotifyShowFavouriteChanged(SearchModel * sender)
unpublishSelected->Enabled = false;
removeSelected->Enabled = true;
}
- else if(sender->GetShowOwn() || Client::Ref().GetAuthUser().UserElevation == ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == ElevationModerator)
+ else if(sender->GetShowOwn() || Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator)
{
unpublishSelected->Enabled = true;
removeSelected->Enabled = true;
@@ -347,7 +348,7 @@ void SearchView::CheckAccess()
favButton->Enabled = true;
favouriteSelected->Enabled = true;
- if(Client::Ref().GetAuthUser().UserElevation == ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == ElevationModerator)
+ if(Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator)
{
unpublishSelected->Enabled = true;
removeSelected->Enabled = true;
diff --git a/src/simulation/SaveRenderer.cpp b/src/simulation/SaveRenderer.cpp
index 8aef523..ce3161a 100644
--- a/src/simulation/SaveRenderer.cpp
+++ b/src/simulation/SaveRenderer.cpp
@@ -9,6 +9,7 @@
#include "graphics/Graphics.h"
#include "Simulation.h"
#include "graphics/Renderer.h"
+#include "search/Thumbnail.h"
SaveRenderer::SaveRenderer(){
@@ -124,7 +125,7 @@ Thumbnail * SaveRenderer::Render(unsigned char * saveData, int dataSize)
GameSave * tempSave;
try {
tempSave = new GameSave((char*)saveData, dataSize);
- } catch (exception & e) {
+ } catch (std::exception & e) {
//Todo: make this look a little less shit
VideoBuffer buffer(64, 64);
diff --git a/src/simulation/SaveRenderer.h b/src/simulation/SaveRenderer.h
index e858918..ee83b00 100644
--- a/src/simulation/SaveRenderer.h
+++ b/src/simulation/SaveRenderer.h
@@ -9,12 +9,13 @@
#define SAVERENDERER_H_
#include "Singleton.h"
-#include "search/Thumbnail.h"
-#include "client/GameSave.h"
+class GameSave;
+class Thumbnail;
class Graphics;
class Simulation;
class Renderer;
+
class SaveRenderer: public Singleton<SaveRenderer> {
Graphics * g;
Simulation * sim;
diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h
index 387d3b3..13da42f 100644
--- a/src/simulation/Simulation.h
+++ b/src/simulation/Simulation.h
@@ -9,6 +9,8 @@
#define SIMULATION_H_
#include <cstring>
#include <cstddef>
+#include <vector>
+
#include "Config.h"
#include "graphics/Renderer.h"
#include "graphics/Graphics.h"
@@ -45,9 +47,9 @@ public:
Gravity * grav;
Air * air;
- vector<sign> signs;
+ std::vector<sign> signs;
Element * elements;
- vector<SimTool*> tools;
+ std::vector<SimTool*> tools;
unsigned int * platent;
wall_type wtypes[UI_WALLCOUNT];
gol_menu gmenu[NGOL];
diff --git a/src/tags/TagsController.cpp b/src/tags/TagsController.cpp
index 845c50f..cf373e6 100644
--- a/src/tags/TagsController.cpp
+++ b/src/tags/TagsController.cpp
@@ -29,13 +29,13 @@ SaveInfo * TagsController::GetSave()
return tagsModel->GetSave();
}
-void TagsController::RemoveTag(string tag)
+void TagsController::RemoveTag(std::string tag)
{
tagsModel->RemoveTag(tag);
}
-void TagsController::AddTag(string tag)
+void TagsController::AddTag(std::string tag)
{
tagsModel->AddTag(tag);
}
diff --git a/src/tags/TagsController.h b/src/tags/TagsController.h
index 2aa1be7..ee68a03 100644
--- a/src/tags/TagsController.h
+++ b/src/tags/TagsController.h
@@ -23,8 +23,8 @@ public:
TagsController(ControllerCallback * callback, SaveInfo * save);
TagsView * GetView() {return tagsView;}
SaveInfo * GetSave();
- void RemoveTag(string tag);
- void AddTag(string tag);
+ void RemoveTag(std::string tag);
+ void AddTag(std::string tag);
void Exit();
virtual ~TagsController();
};
diff --git a/src/tags/TagsModel.cpp b/src/tags/TagsModel.cpp
index 3b5ee1d..b4b3ff9 100644
--- a/src/tags/TagsModel.cpp
+++ b/src/tags/TagsModel.cpp
@@ -9,6 +9,7 @@
#include "TagsView.h"
#include "client/Client.h"
#include "TagsModelException.h"
+#include "client/SaveInfo.h"
TagsModel::TagsModel():
save(NULL)
@@ -28,14 +29,14 @@ SaveInfo * TagsModel::GetSave()
return save;
}
-void TagsModel::RemoveTag(string tag)
+void TagsModel::RemoveTag(std::string tag)
{
if(save)
{
- std::vector<string> * tags = Client::Ref().RemoveTag(save->GetID(), tag);
+ std::vector<std::string> * tags = Client::Ref().RemoveTag(save->GetID(), tag);
if(tags)
{
- save->SetTags(vector<string>(*tags));
+ save->SetTags(std::vector<std::string>(*tags));
notifyTagsChanged();
delete tags;
}
@@ -46,14 +47,14 @@ void TagsModel::RemoveTag(string tag)
}
}
-void TagsModel::AddTag(string tag)
+void TagsModel::AddTag(std::string tag)
{
if(save)
{
- std::vector<string> * tags = Client::Ref().AddTag(save->GetID(), tag);
+ std::vector<std::string> * tags = Client::Ref().AddTag(save->GetID(), tag);
if(tags)
{
- save->SetTags(vector<string>(*tags));
+ save->SetTags(std::vector<std::string>(*tags));
notifyTagsChanged();
delete tags;
}
diff --git a/src/tags/TagsModel.h b/src/tags/TagsModel.h
index 9d3d53b..e1c3b32 100644
--- a/src/tags/TagsModel.h
+++ b/src/tags/TagsModel.h
@@ -9,7 +9,9 @@
#define TAGSMODEL_H_
#include <vector>
-#include "client/SaveInfo.h"
+#include <string>
+
+class SaveInfo;
class TagsView;
class TagsModel {
@@ -20,8 +22,8 @@ public:
TagsModel();
void AddObserver(TagsView * observer);
void SetSave(SaveInfo * save);
- void RemoveTag(string tag);
- void AddTag(string tag);
+ void RemoveTag(std::string tag);
+ void AddTag(std::string tag);
SaveInfo * GetSave();
virtual ~TagsModel();
};
diff --git a/src/tags/TagsModelException.h b/src/tags/TagsModelException.h
index 2473cab..10aaa31 100644
--- a/src/tags/TagsModelException.h
+++ b/src/tags/TagsModelException.h
@@ -10,12 +10,11 @@
#include <string>
#include <exception>
-using namespace std;
class TagsModelException {
- string message;
+ std::string message;
public:
- TagsModelException(string message_): message(message_) {};
+ TagsModelException(std::string message_): message(message_) {};
const char * what() const throw() { return message.c_str(); };
~TagsModelException() throw() {};
};
diff --git a/src/tags/TagsView.cpp b/src/tags/TagsView.cpp
index 0baed21..01c3b15 100644
--- a/src/tags/TagsView.cpp
+++ b/src/tags/TagsView.cpp
@@ -13,6 +13,11 @@
#include "TagsModel.h"
#include "TagsModelException.h"
+#include "interface/Button.h"
+#include "interface/Textbox.h"
+#include "interface/Label.h"
+#include "interface/Keys.h"
+
TagsView::TagsView():
ui::Window(ui::Point(-1, -1), ui::Point(195, 250))
{
@@ -60,9 +65,9 @@ void TagsView::NotifyTagsChanged(TagsModel * sender)
class DeleteTagAction : public ui::ButtonAction
{
TagsView * v;
- string tag;
+ std::string tag;
public:
- DeleteTagAction(TagsView * _v, string tag) { v = _v; this->tag = tag; }
+ DeleteTagAction(TagsView * _v, std::string tag) { v = _v; this->tag = tag; }
void ActionCallback(ui::Button * sender)
{
try
diff --git a/src/tags/TagsView.h b/src/tags/TagsView.h
index 2861c8c..bac0fae 100644
--- a/src/tags/TagsView.h
+++ b/src/tags/TagsView.h
@@ -10,9 +10,13 @@
#include <vector>
#include "interface/Window.h"
-#include "interface/Button.h"
-#include "interface/Textbox.h"
-#include "interface/Label.h"
+
+namespace ui
+{
+ class Button;
+ class Textbox;
+ class Label;
+}
class TagsController;
class TagsModel;
diff --git a/src/update/UpdateActivity.h b/src/update/UpdateActivity.h
index f923684..533aaf7 100644
--- a/src/update/UpdateActivity.h
+++ b/src/update/UpdateActivity.h
@@ -8,7 +8,6 @@
#ifndef UPDATEACTIVITY_H_
#define UPDATEACTIVITY_H_
-#include "interface/Window.h"
#include "tasks/TaskWindow.h"
class UpdateActivity {