Browse Source

Put data into data folder and setup basic logging to file on release builds

master
C. J. Howard 5 years ago
parent
commit
bd1f831963
Signed by: cjhoward GPG Key ID: 03E1FABA9C3EC195
4 changed files with 19 additions and 9 deletions
  1. +3
    -2
      CMakeLists.txt
  2. +1
    -1
      src/entity/systems/sound-system.cpp
  3. +13
    -6
      src/game.cpp
  4. +2
    -0
      src/game.hpp

+ 3
- 2
CMakeLists.txt View File

@ -25,7 +25,8 @@ find_package(OpenAL REQUIRED CONFIG)
# Determine dependencies
set(STATIC_LIBS
emergent
emergent)
set(SHARED_LIBS
OpenAL::OpenAL)
# Generate configuration header file
@ -54,7 +55,7 @@ target_include_directories(${EXECUTABLE_TARGET}
${PROJECT_BINARY_DIR}/src)
# Link to dependencies
target_link_libraries(${EXECUTABLE_TARGET} ${STATIC_LIBS})
target_link_libraries(${EXECUTABLE_TARGET} ${STATIC_LIBS} ${SHARED_LIBS})
# Install executable
install(TARGETS ${EXECUTABLE_TARGET} DESTINATION bin)

+ 1
- 1
src/entity/systems/sound-system.cpp View File

@ -55,7 +55,7 @@ SoundSystem::SoundSystem(ComponentManager* componentManager):
// Load wav file
{
const char* filename = "shutter.wav";
const char* filename = "data/shutter.wav";
unsigned int channels;
unsigned int sampleRate;
drwav_uint64 frameCount;

+ 13
- 6
src/game.cpp View File

@ -168,12 +168,9 @@ Game::Game(int argc, char* argv[]):
#endif
// Form resource paths
dataPath = getDataPath(applicationName);
dataPath = getDataPath(applicationName) + "data/";
configPath = getConfigPath(applicationName);
controlsPath = configPath + "/controls/";
std::cout << "Data path: " << dataPath << std::endl;
std::cout << "Config path: " << configPath << std::endl;
controlsPath = configPath + "controls/";
// Create nonexistent config directories
std::vector<std::string> configPaths;
@ -186,6 +183,16 @@ Game::Game(int argc, char* argv[]):
createDirectory(path);
}
}
// Setup logging
#if !defined(DEBUG)
std::string logFilename = configPath + "log.txt";
logFileStream.open(logFilename.c_str());
std::cout.rdbuf(logFileStream.rdbuf());
#endif
std::cout << "Data path: " << dataPath << std::endl;
std::cout << "Config path: " << configPath << std::endl;
// Setup resource manager
resourceManager = new ResourceManager();
@ -2074,7 +2081,7 @@ void Game::screenshot()
std::transform(title.begin(), title.end(), title.begin(), ::tolower);
// Create screenshot directory if it doesn't exist
std::string screenshotDirectory = configPath + std::string("/screenshots/");
std::string screenshotDirectory = configPath + std::string("screenshots/");
if (!pathExists(screenshotDirectory))
{
createDirectory(screenshotDirectory);

+ 2
- 0
src/game.hpp View File

@ -27,6 +27,7 @@ using namespace Emergent;
#include <map>
#include <string>
#include <vector>
#include <fstream>
class GameState;
class SplashState;
@ -418,6 +419,7 @@ public:
std::string controlProfileName;
// Debugging
std::ofstream logFileStream;
bool wireframe;
private:

Loading…
Cancel
Save