commit
cab351b8f5
10
Bin/LibD.pro
10
Bin/LibD.pro
@ -51,7 +51,6 @@ HEADERS += ../src/Actor/Player.h \
|
||||
../src/System/Filesystem/FilePackageManager.h \
|
||||
../src/System/Filesystem/InputStreamWrapper.h \
|
||||
../src/System/Filesystem/MemoryStream.h \
|
||||
../src/System/Filesystem/SCCopyFile.cpp \
|
||||
../src/System/Filesystem/Checksum.h \
|
||||
../src/Texture/Texture.h \
|
||||
../src/Sound/Music.h \
|
||||
@ -61,7 +60,6 @@ HEADERS += ../src/Actor/Player.h \
|
||||
../src/Sound/SoundEffect.h \
|
||||
../src/Actor/Actor.h \
|
||||
../src/Animation/AnimimationSequence.h \
|
||||
../src/System/FileReader.h \
|
||||
../src/Animation/AnimationSequence.h \
|
||||
../src/System/String.h \
|
||||
../src/Font/Font.h \
|
||||
@ -85,7 +83,9 @@ HEADERS += ../src/Actor/Player.h \
|
||||
../src/TMXParser/TmxImage.h \
|
||||
../src/TMXParser/Tmx.h \
|
||||
../src/TMXParser/base64/base64.h \
|
||||
../src/TMXParser/TmxUtil.h
|
||||
../src/TMXParser/TmxUtil.h \
|
||||
../src/System/Filesystem/SCCopyFile.h \
|
||||
../src/System/Filesystem/FileReader.h
|
||||
|
||||
SOURCES += ../src/Actor/Player.cpp \
|
||||
../src/Collision/AABB.cpp \
|
||||
@ -120,7 +120,6 @@ SOURCES += ../src/Actor/Player.cpp \
|
||||
../src/Actor/NPC.cpp \
|
||||
../src/Sound/SoundEffect.cpp \
|
||||
../src/Actor/Actor.cpp \
|
||||
../src/System/FileReader.cpp \
|
||||
../src/Animation/AnimationSequence.cpp \
|
||||
../src/System/String.cpp \
|
||||
../src/Font/Font.cpp \
|
||||
@ -141,6 +140,7 @@ SOURCES += ../src/Actor/Player.cpp \
|
||||
../src/TMXParser/TmxLayer.cpp \
|
||||
../src/TMXParser/TmxImage.cpp \
|
||||
../src/TMXParser/base64/base64.cpp \
|
||||
../src/TMXParser/TmxUtil.cpp
|
||||
../src/TMXParser/TmxUtil.cpp \
|
||||
../src/System/Filesystem/FileReader.cpp
|
||||
|
||||
QMAKE_CLEAN += LibD Debug.log
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "../System/Debug.h"
|
||||
#include "AnimationSequence.h"
|
||||
|
||||
using saracraft::util::Debug;
|
||||
|
||||
/*
|
||||
* Load and read a sequence file for an animating sprite then
|
||||
* stores the result so you can call the sprites animation at any time.
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../System/FileReader.h"
|
||||
#include "../System/Filesystem/FileReader.h"
|
||||
#include "../System/String.h"
|
||||
|
||||
#define MAX_FRAMES 16
|
||||
@ -10,6 +10,9 @@
|
||||
#define ENDOFLINE 59
|
||||
#define SPACE 32
|
||||
|
||||
using saracraft::util::String;
|
||||
using saracraft::filesystem::FileReader;
|
||||
|
||||
struct Animation {
|
||||
String _animationID;
|
||||
int frameBegin;
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "Slot.h"
|
||||
|
||||
using saracraft::util::Debug;
|
||||
|
||||
Slot::Slot(void) {
|
||||
_triggered = false;
|
||||
_selected = false;
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "../System/Debug.h"
|
||||
#include "Font.h"
|
||||
|
||||
using saracraft::util::Debug;
|
||||
|
||||
Font::Font(void) {
|
||||
_texture = 0;
|
||||
_spaceWidth = 0;
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include <string.h>
|
||||
#include "Input.h"
|
||||
|
||||
using saracraft::util::Debug;
|
||||
|
||||
static mouse_t mouse;
|
||||
static keyboard_t keyboard;
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
using saracraft::util::Debug;
|
||||
|
||||
Level::Level(Game* game) {
|
||||
_game = game;
|
||||
_width = 0;
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "../System/String.h"
|
||||
#include "../Math/Vec2.h"
|
||||
|
||||
using saracraft::util::String;
|
||||
|
||||
class Warp {
|
||||
public:
|
||||
Warp(void);
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "Game.h"
|
||||
#include "TitleScreen.h"
|
||||
|
||||
using saracraft::util::Debug;
|
||||
|
||||
Game::Game(void) {
|
||||
_level = new Level(this);
|
||||
_player = new Player(_level);
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "../Global/Constants.h"
|
||||
#include "../System/Debug.h"
|
||||
|
||||
using saracraft::util::Debug;
|
||||
|
||||
void Destroy(void) {
|
||||
TTF_Quit();
|
||||
Mix_CloseAudio();
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "Music.h"
|
||||
|
||||
ResourceManager<Music> musicManager;
|
||||
saracraft::util::ResourceManager<Music> musicManager;
|
||||
|
||||
Music::Music() : Resource() {
|
||||
_music = NULL;
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
struct _Mix_Music;
|
||||
|
||||
class Music : public Resource {
|
||||
template<class T> friend class ResourceManager;
|
||||
class Music : public saracraft::util::Resource {
|
||||
template<class T> friend class saracraft::util::ResourceManager;
|
||||
|
||||
public:
|
||||
Music();
|
||||
@ -21,4 +21,4 @@ private:
|
||||
struct _Mix_Music* _music;
|
||||
};
|
||||
|
||||
extern ResourceManager<Music> musicManager;
|
||||
extern saracraft::util::ResourceManager<Music> musicManager;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "SoundEffect.h"
|
||||
|
||||
ResourceManager<SoundEffect> sfxManager;
|
||||
saracraft::util::ResourceManager<SoundEffect> sfxManager;
|
||||
|
||||
SoundEffect::SoundEffect() {
|
||||
_chunk = NULL;
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
struct Mix_Chunk;
|
||||
|
||||
class SoundEffect : public Resource {
|
||||
template<class T> friend class ResourceManager;
|
||||
class SoundEffect : public saracraft::util::Resource {
|
||||
template<class T> friend class saracraft::util::ResourceManager;
|
||||
|
||||
public:
|
||||
SoundEffect();
|
||||
@ -22,4 +22,4 @@ private:
|
||||
Mix_Chunk* _chunk;
|
||||
};
|
||||
|
||||
extern ResourceManager<SoundEffect> sfxManager;
|
||||
extern saracraft::util::ResourceManager<SoundEffect> sfxManager;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#endif
|
||||
|
||||
namespace saracraft {
|
||||
namespace filesystem {
|
||||
namespace util {
|
||||
|
||||
template<class T>
|
||||
struct ConvertBase {
|
||||
@ -50,6 +50,5 @@ struct ConvertTo: private ConvertBase<T> {
|
||||
|
||||
typedef unsigned short uint16_t;
|
||||
|
||||
} // Namespaces....
|
||||
}
|
||||
|
||||
} // Namespace util.
|
||||
} // Namespace saracraft.
|
||||
|
@ -1,7 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
namespace saracraft {
|
||||
namespace util {
|
||||
|
||||
extern char* int2str(int value);
|
||||
extern int str2int(const char* string);
|
||||
extern int str2int_errno(void);
|
||||
extern char* time2str(int secs); // hh:mm::ss.
|
||||
|
||||
} // Namespace util.
|
||||
} // Namespace saracraft.
|
||||
|
@ -8,6 +8,9 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace saracraft {
|
||||
namespace util {
|
||||
|
||||
// ===================================================================
|
||||
// The Debug log allows us to display ever piece of data that
|
||||
// populates our class components, anything that is loaded, serialized,
|
||||
@ -100,3 +103,6 @@ void Debug::closeLog(void) {
|
||||
delete logger;
|
||||
logger = NULL;
|
||||
}
|
||||
|
||||
} // End of namespace util.
|
||||
} // End of namespace saracraft.
|
||||
|
@ -3,6 +3,9 @@
|
||||
#include <fstream>
|
||||
#include "string"
|
||||
|
||||
namespace saracraft {
|
||||
namespace util {
|
||||
|
||||
class Debug {
|
||||
public:
|
||||
Debug(bool logToFile);
|
||||
@ -20,4 +23,7 @@ private:
|
||||
std::ofstream _logFile;
|
||||
};
|
||||
|
||||
} // Namespace util.
|
||||
} // Namespace saracraft.
|
||||
|
||||
#endif // _DEBUG_H_
|
||||
|
@ -3,7 +3,8 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace saracraft;
|
||||
namespace saracraft {
|
||||
namespace filesystem {
|
||||
|
||||
unsigned int Checksum::CountChecksumForFile(const char* filename) {
|
||||
unsigned int chksum = 0;
|
||||
@ -66,3 +67,5 @@ bool Checksum::CountChecksumForFileImpl(unsigned int* checksum, int* filesize, c
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace filesystem.
|
||||
} // End of namespace saracraft.
|
||||
|
@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
namespace saracraft {
|
||||
namespace filesystem {
|
||||
|
||||
class Checksum {
|
||||
public:
|
||||
static unsigned int CountChecksumForFile(const char* filename);
|
||||
@ -10,3 +13,5 @@ private:
|
||||
int* filesize, const char* filename);
|
||||
};
|
||||
|
||||
} // Namespace filesystem.
|
||||
} // Namespace saracraft.
|
||||
|
@ -9,6 +9,7 @@ using namespace boost;
|
||||
|
||||
namespace saracraft {
|
||||
namespace filesystem {
|
||||
|
||||
namespace {
|
||||
|
||||
struct Dir;
|
||||
@ -75,6 +76,7 @@ int GetDirNameImpl(const IteratorList& list, string& result, int currentIndex, i
|
||||
string empty;
|
||||
|
||||
} // Namespace unamed.
|
||||
|
||||
struct FileList::Data {
|
||||
bool caseSensitive;
|
||||
DirList dirs;
|
||||
|
@ -10,12 +10,15 @@
|
||||
|
||||
namespace saracraft {
|
||||
namespace filesystem {
|
||||
|
||||
namespace {
|
||||
typedef std::multimap<int, boost::shared_ptr<IFilePackage> > PackageMap;
|
||||
FilePackageManager instance;
|
||||
FilePackageManager* instancePtr = 0;
|
||||
} // Unamed namespace.
|
||||
|
||||
using namespace util;
|
||||
|
||||
struct FilePackageManagerData {
|
||||
PackageMap packages;
|
||||
bool logNonExisting;
|
||||
|
@ -1,9 +1,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Debug.h"
|
||||
#include "../Debug.h"
|
||||
#include "FileReader.h"
|
||||
|
||||
namespace saracraft {
|
||||
namespace filesystem {
|
||||
|
||||
FileReader::FileReader(void) {
|
||||
|
||||
}
|
||||
@ -109,3 +112,6 @@ void FileReader::ReadBuffer(const char* buffer, int count) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // Namespace filesystem.
|
||||
} // Namespace saracraft.
|
@ -2,7 +2,12 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../System/String.h"
|
||||
#include "../String.h"
|
||||
|
||||
namespace saracraft {
|
||||
namespace filesystem {
|
||||
|
||||
using util::String;
|
||||
|
||||
class FileReader {
|
||||
public:
|
||||
@ -28,3 +33,6 @@ private:
|
||||
String _filename;
|
||||
String _accessType;
|
||||
};
|
||||
|
||||
} // Namespace filesystem.
|
||||
} // Namespace saracraft.
|
@ -10,7 +10,8 @@
|
||||
#include "InputStreamWrapper.h"
|
||||
#include "FileTimestampChecker.h"
|
||||
|
||||
using namespace saracraft;
|
||||
namespace saracraft {
|
||||
namespace filesystem {
|
||||
|
||||
/*bool FileTimestampChecker::IsFileNewerThanFile(const char* file, const char* secondFile) {
|
||||
assert
|
||||
@ -80,3 +81,5 @@ int FileTimestampChecker::GetFileTimestamp(const char* file) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // End of namespace filesystem.
|
||||
} // End of namespace saracraft.
|
||||
|
@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
namespace saracraft {
|
||||
namespace filesystem {
|
||||
|
||||
class FileTimestampChecker {
|
||||
public:
|
||||
// Check if the given file with given name has been modified after another
|
||||
@ -15,3 +18,5 @@ public:
|
||||
static int GetFileTimestamp(const char *file);
|
||||
};
|
||||
|
||||
} // Namespace filesystem.
|
||||
} // Namespace saracraft.
|
||||
|
@ -8,7 +8,7 @@
|
||||
#pragma warning(disable: 444) // I think intel will complain at the base class not being virtual.
|
||||
#endif
|
||||
|
||||
BOOST_STATIC_ASSERT(sizeof(saracraft::filesystem::uint16_t) * CHAR_BIT == 16);
|
||||
BOOST_STATIC_ASSERT(sizeof(saracraft::util::uint16_t) * CHAR_BIT == 16);
|
||||
BOOST_STATIC_ASSERT(CHAR_BIT == 8);
|
||||
|
||||
namespace saracraft {
|
||||
@ -17,7 +17,7 @@ namespace {
|
||||
|
||||
template<class T>
|
||||
void ReadFromStream(IInputStreamBuffer& buffer, T& value) {
|
||||
ConvertTo<T> converter;
|
||||
util::ConvertTo<T> converter;
|
||||
for(int i = 0; i < converter.GetSize(); ++i)
|
||||
converter.SetByte(i, buffer.PopByte());
|
||||
|
||||
@ -52,7 +52,7 @@ int InputStream::GetSize(void) const {
|
||||
InputStream& InputStream::Read(std::string& value) {
|
||||
assert(_streamBuffer);
|
||||
|
||||
uint16_t stringSize = 0;
|
||||
util::uint16_t stringSize = 0;
|
||||
this->Read(stringSize);
|
||||
|
||||
value.resize(stringSize);
|
||||
|
@ -18,6 +18,8 @@ namespace {
|
||||
Tracker tracker;
|
||||
} // Namespace Unamed.
|
||||
|
||||
using namespace util;
|
||||
|
||||
struct SC_FILE {
|
||||
InputStream stream;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#pragma warning(disable: 444) // I think intel will complain at the base class not being virtual.
|
||||
#endif
|
||||
|
||||
BOOST_STATIC_ASSERT(sizeof(saracraft::filesystem::uint16_t) * CHAR_BIT == 16);
|
||||
BOOST_STATIC_ASSERT(sizeof(saracraft::util::uint16_t) * CHAR_BIT == 16);
|
||||
BOOST_STATIC_ASSERT(CHAR_BIT == 8);
|
||||
|
||||
namespace saracraft {
|
||||
@ -17,7 +17,7 @@ namespace {
|
||||
|
||||
template<class T>
|
||||
void SendToStream(IOutputStreamBuffer& buffer, T& value) {
|
||||
ConvertFrom<T> converter(value);
|
||||
util::ConvertFrom<T> converter(value);
|
||||
for(int i = 0; i < converter.GetSize(); ++i)
|
||||
buffer.PutByte(converter.GetByte(i));
|
||||
}
|
||||
@ -45,7 +45,7 @@ void OutputStream::UseTextStrings(void) {
|
||||
OutputStream& OutputStream::Write(std::string& value) {
|
||||
assert(_streamBuffer);
|
||||
|
||||
uint16_t stringSize = 0;
|
||||
util::uint16_t stringSize = 0;
|
||||
|
||||
if(!_textStrings)
|
||||
Write(stringSize);
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
#include "SCCopyFile.h"
|
||||
|
||||
namespace util {
|
||||
namespace saracraft {
|
||||
namespace filesystem {
|
||||
|
||||
void SCCopyFile::CopyFile(const std::string& from, const std::string& to) {
|
||||
std::fstream out(to.c_str(), std::ios::out);
|
||||
@ -19,5 +20,6 @@ void SCCopyFile::CopyFile(const std::string& from, const std::string& to) {
|
||||
out.close();
|
||||
}
|
||||
|
||||
} // Namespace util.
|
||||
} // Namespace filesystem.
|
||||
} // Namespace saracraft.
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace util {
|
||||
namespace saracraft {
|
||||
namespace filesystem {
|
||||
|
||||
class SCCopyFile {
|
||||
public:
|
||||
@ -12,5 +13,5 @@ public:
|
||||
static void CopyFile(const std::string& from, const std::string& to);
|
||||
};
|
||||
|
||||
} // Namespace util.
|
||||
|
||||
} // Namespace filesystem.
|
||||
} // Namespace saracraft.
|
||||
|
@ -5,6 +5,9 @@
|
||||
|
||||
#include "../System/String.h"
|
||||
|
||||
namespace saracraft {
|
||||
namespace util {
|
||||
|
||||
class Resource {
|
||||
public:
|
||||
virtual bool Load(const std::string& filename) = 0;
|
||||
@ -96,3 +99,6 @@ public:
|
||||
private:
|
||||
ResourceMap m_resources;
|
||||
};
|
||||
|
||||
} // Namespace util.
|
||||
} // Namespace saracraft.
|
||||
|
@ -5,6 +5,9 @@
|
||||
#include "String.h"
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
namespace saracraft {
|
||||
namespace util {
|
||||
|
||||
String::String(void) {
|
||||
_string = new char[1];
|
||||
_string[0] = 0;
|
||||
@ -150,3 +153,6 @@ String String::operator+(const String& value) const {
|
||||
String::operator const char*() const {
|
||||
return _string;
|
||||
}
|
||||
|
||||
} // End of namespace util.
|
||||
} // End of namespace saracraft.
|
||||
|
@ -1,6 +1,9 @@
|
||||
#pragma once
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
namespace saracraft {
|
||||
namespace util {
|
||||
|
||||
class String {
|
||||
public:
|
||||
String(void);
|
||||
@ -34,3 +37,6 @@ private:
|
||||
char* _string;
|
||||
int _length;
|
||||
};
|
||||
|
||||
} // Namespace util.
|
||||
} // Namespace saracraft.
|
||||
|
@ -11,7 +11,9 @@ using namespace std;
|
||||
#define GL_BGRA_EXT 0x80E1
|
||||
#endif
|
||||
|
||||
ResourceManager<Texture> textureManager;
|
||||
using saracraft::util::Debug;
|
||||
|
||||
saracraft::util::ResourceManager<Texture> textureManager;
|
||||
|
||||
static GLuint boundTexture = 0;
|
||||
|
||||
|
@ -27,8 +27,8 @@ void BindTexture(GLuint texID);
|
||||
|
||||
#include "../System/ResourceManager.h"
|
||||
|
||||
class Texture : public Resource {
|
||||
template<class T> friend class ResourceManager;
|
||||
class Texture : public saracraft::util::Resource {
|
||||
template<class T> friend class saracraft::util::ResourceManager;
|
||||
|
||||
public:
|
||||
Texture();
|
||||
@ -46,4 +46,4 @@ private:
|
||||
int height;
|
||||
};
|
||||
|
||||
extern ResourceManager<Texture> textureManager;
|
||||
extern saracraft::util::ResourceManager<Texture> textureManager;
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "../System/String.h"
|
||||
#include "../Font/Font.h"
|
||||
|
||||
using saracraft::util::String;
|
||||
|
||||
class Button {
|
||||
public:
|
||||
Button(void);
|
||||
|
Loading…
Reference in New Issue
Block a user