diff --git a/source/code/Makefile b/source/code/Makefile index 8e3b0fb..abce4b0 100644 --- a/source/code/Makefile +++ b/source/code/Makefile @@ -51,7 +51,7 @@ endif BASE_LIBS += -lphysfs OFILES=main.o highscore.o ReadKeyboard.o joypad.o listFiles.o common.o stats.o Libs/NFont.o Libs/SDL_FontCache.o MenuSystem.o menudef.o \ - puzzlehandler.o stageclearhandler.o icon.o ${SAGO_O_FILES} + puzzlehandler.o stageclearhandler.o icon.o os.o ${SAGO_O_FILES} ifeq ($(CROSS),i686-w64-mingw32.static-) OFILES += winicon.res diff --git a/source/code/common.cpp b/source/code/common.cpp index 58cb6fe..f6f568e 100644 --- a/source/code/common.cpp +++ b/source/code/common.cpp @@ -24,6 +24,7 @@ http://blockattack.net #include "common.h" #include #include +#include "os.hpp" using namespace std; using boost::format; @@ -92,44 +93,6 @@ int str2int(const string& str2parse) { } } -#ifdef _WIN32 -//Returns path to "my Documents" in windows: -string getMyDocumentsPath() { - TCHAR pszPath[MAX_PATH]; - //if (SUCCEEDED(SHGetSpecialFolderPath(nullptr, pszPath, CSIDL_PERSONAL, FALSE))) { - if (SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_PERSONAL, nullptr, 0, pszPath))) { - // pszPath is now the path that you want -#if DEBUG - cout << "MyDocuments Located: " << pszPath << endl; -#endif - string theResult= pszPath; - return theResult; - } - else { - cout << "Warning: My Documents not found!" << endl; - string theResult =""; - return theResult; - } -} - -#endif - -/** - * Returns the path to where all settings must be saved. - * On unix-like systems this is the home-folder under: ~/.gamesaves/GAMENAME - * In Windows it is My Documents/My Games - * Consider changing this for Vista that has a special save games folder - */ -string getPathToSaveFiles() { -#ifdef __unix__ - return (string)getenv("HOME")+(string)"/.gamesaves/"+GAMENAME; -#elif _WIN32 - return getMyDocumentsPath()+(string)"/My Games/"+GAMENAME; -#else - return "."; -#endif -} - /** * Takes a number of milliseconds and returns the value in commonTime format. */ diff --git a/source/code/common.h b/source/code/common.h index e508c8e..c5a26fd 100644 --- a/source/code/common.h +++ b/source/code/common.h @@ -30,13 +30,6 @@ http://blockattack.net #ifndef _COMMON_H #define _COMMON_H -/* - *Files will be saved in: - * HOME/.gamesaves/"+GAMENAME (unix) - *or DOCUMENTS/My Games/GAMENAME (Windows) - */ -#define GAMENAME "blockattack" - #include #include #include @@ -44,10 +37,7 @@ http://blockattack.net #include #include #include -#if defined(_WIN32) -#include "windows.h" -#include "shlobj.h" -#endif + #define _(String) gettext (String) @@ -61,8 +51,6 @@ struct commonTime std::string itoa(int num) __attribute__((const)); -std::string getPathToSaveFiles() __attribute__((pure)); - bool strequals(const char* a, const char* b); /** @@ -83,9 +71,6 @@ void dieOnNullptr(bool, const char* msg); */ double str2double(const std::string &str2parse) __attribute__((const)); -#if defined(_WIN32) -std::string getMyDocumentsPath(); -#endif class TimeHandler { diff --git a/source/code/os.cpp b/source/code/os.cpp new file mode 100644 index 0000000..c9cf5a8 --- /dev/null +++ b/source/code/os.cpp @@ -0,0 +1,70 @@ +/* +=========================================================================== +blockattack - Block Attack - Rise of the Blocks +Copyright (C) 2005-2015 Poul Sander + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see http://www.gnu.org/licenses/ + +Source information and contacts persons can be found at +http://blockattack.net +=========================================================================== +*/ + +#include "os.hpp" + + +/* + *Files will be saved in: + * HOME/.gamesaves/"+GAMENAME (unix) + *or DOCUMENTS/My Games/GAMENAME (Windows) + */ +#define GAMENAME "blockattack" + +#ifdef _WIN32 +//Returns path to "my Documents" in windows: +string getMyDocumentsPath() { + TCHAR pszPath[MAX_PATH]; + //if (SUCCEEDED(SHGetSpecialFolderPath(nullptr, pszPath, CSIDL_PERSONAL, FALSE))) { + if (SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_PERSONAL, nullptr, 0, pszPath))) { + // pszPath is now the path that you want +#if DEBUG + cout << "MyDocuments Located: " << pszPath << endl; +#endif + string theResult= pszPath; + return theResult; + } + else { + cout << "Warning: My Documents not found!" << endl; + string theResult =""; + return theResult; + } +} + +#endif + +/** + * Returns the path to where all settings must be saved. + * On unix-like systems this is the home-folder under: ~/.gamesaves/GAMENAME + * In Windows it is My Documents/My Games + * Consider changing this for Vista that has a special save games folder + */ +std::string getPathToSaveFiles() { +#ifdef __unix__ + return (std::string)getenv("HOME")+(std::string)"/.gamesaves/"+GAMENAME; +#elif _WIN32 + return getMyDocumentsPath()+(string)"/My Games/"+GAMENAME; +#else + return "."; +#endif +} \ No newline at end of file diff --git a/source/code/os.hpp b/source/code/os.hpp new file mode 100644 index 0000000..156f039 --- /dev/null +++ b/source/code/os.hpp @@ -0,0 +1,33 @@ +/* +=========================================================================== +blockattack - Block Attack - Rise of the Blocks +Copyright (C) 2005-2015 Poul Sander + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see http://www.gnu.org/licenses/ + +Source information and contacts persons can be found at +http://blockattack.net +=========================================================================== +*/ + +#if defined(_WIN32) +#include "windows.h" +#include "shlobj.h" +#endif +#include + +std::string getPathToSaveFiles() __attribute__((pure)); +#if defined(_WIN32) +std::string getMyDocumentsPath(); +#endif \ No newline at end of file diff --git a/source/code/puzzlehandler.cpp b/source/code/puzzlehandler.cpp index b6ca3f4..dbe10cf 100644 --- a/source/code/puzzlehandler.cpp +++ b/source/code/puzzlehandler.cpp @@ -1,3 +1,26 @@ +/* +=========================================================================== +blockattack - Block Attack - Rise of the Blocks +Copyright (C) 2005-2015 Poul Sander + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see http://www.gnu.org/licenses/ + +Source information and contacts persons can be found at +http://blockattack.net +=========================================================================== +*/ + #include "puzzlehandler.hpp" #include #include diff --git a/source/code/puzzlehandler.hpp b/source/code/puzzlehandler.hpp index d40c659..d8db7c5 100644 --- a/source/code/puzzlehandler.hpp +++ b/source/code/puzzlehandler.hpp @@ -1,9 +1,25 @@ -/* - * File: puzzlehandler.hpp - * Author: poul - * - * Created on 22. august 2015, 20:09 - */ +/* +=========================================================================== +blockattack - Block Attack - Rise of the Blocks +Copyright (C) 2005-2015 Poul Sander + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see http://www.gnu.org/licenses/ + +Source information and contacts persons can be found at +http://blockattack.net +=========================================================================== +*/ #ifndef PUZZLEHANDLER_HPP #define PUZZLEHANDLER_HPP diff --git a/source/code/scopeHelpers.hpp b/source/code/scopeHelpers.hpp index 999f9f5..8b898d3 100644 --- a/source/code/scopeHelpers.hpp +++ b/source/code/scopeHelpers.hpp @@ -1,7 +1,7 @@ /* =========================================================================== blockattack - Block Attack - Rise of the Blocks -Copyright (C) 2005-2012 Poul Sander +Copyright (C) 2005-2015 Poul Sander This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/source/code/stageclearhandler.cpp b/source/code/stageclearhandler.cpp index d57d656..ef81f6e 100644 --- a/source/code/stageclearhandler.cpp +++ b/source/code/stageclearhandler.cpp @@ -1,8 +1,25 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ +=========================================================================== +blockattack - Block Attack - Rise of the Blocks +Copyright (C) 2005-2015 Poul Sander + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see http://www.gnu.org/licenses/ + +Source information and contacts persons can be found at +http://blockattack.net +=========================================================================== +*/ #include "stageclearhandler.hpp" #include "SDL.h" diff --git a/source/code/stageclearhandler.hpp b/source/code/stageclearhandler.hpp index 8d77bd5..c80a184 100644 --- a/source/code/stageclearhandler.hpp +++ b/source/code/stageclearhandler.hpp @@ -1,8 +1,26 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ +=========================================================================== +blockattack - Block Attack - Rise of the Blocks +Copyright (C) 2005-2015 Poul Sander + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see http://www.gnu.org/licenses/ + +Source information and contacts persons can be found at +http://blockattack.net +=========================================================================== +*/ + /* * File: stageclearhandler.hpp diff --git a/source/code/stats.cpp b/source/code/stats.cpp index 886d009..a3070b7 100644 --- a/source/code/stats.cpp +++ b/source/code/stats.cpp @@ -23,6 +23,7 @@ http://blockattack.net #include "stats.h" #include "common.h" +#include "os.hpp" using namespace std;