Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,37 @@
#include <vector>
#include <list>
#include <fstream>
#include <unistd.h>
#include "colony.hpp"
#include "config.hpp"
#include "display_manager.hpp"


std::string getCurrentPath()
{
std::string path;
static constexpr size_t PATH_SIZE = 1024;
path.resize(PATH_SIZE);
#if defined(__unix__)
size_t pos = readlink("/proc/self/exe", &path[0], PATH_SIZE);
path.resize(pos);
pos = path.rfind("/");
path.resize(++pos);
#endif

#if defined(_WIN32)
char currentPath[PATH_SIZE];
_getcwd(currentPath, sizeof(currentPath));
path = std::string(currentPath);
path += "\\";
#endif

return path;
}

void loadUserConf()
{
std::ifstream conf_file("conf.txt");
std::ifstream conf_file(getCurrentPath() + "conf.txt");
if (conf_file) {
conf_file >> Conf::WIN_WIDTH;
conf_file >> Conf::WIN_HEIGHT;
Expand All @@ -26,10 +48,11 @@ int main()
{
Conf::loadTextures();
loadUserConf();
Conf::COLONY_POSITION = sf::Vector2f(Conf::WIN_WIDTH * 0.5f, Conf::WIN_HEIGHT * 0.5f);

sf::ContextSettings settings;
settings.antialiasingLevel = 4;
sf::RenderWindow window(sf::VideoMode(Conf::WIN_WIDTH, Conf::WIN_HEIGHT), "AntSim", sf::Style::Fullscreen, settings);
sf::RenderWindow window(sf::VideoMode(Conf::WIN_WIDTH, Conf::WIN_HEIGHT), "AntSim", sf::Style::Default, settings);
window.setFramerateLimit(60);

World world(Conf::WORLD_WIDTH, Conf::WORLD_HEIGHT);
Expand Down