|
@@ -19,6 +19,7 @@
|
|
#include <thread>
|
|
#include <thread>
|
|
#include <fstream>
|
|
#include <fstream>
|
|
#include <iomanip>
|
|
#include <iomanip>
|
|
|
|
+#include <codecvt>
|
|
#include "Triangles.hpp"
|
|
#include "Triangles.hpp"
|
|
#include "IngameState.hpp"
|
|
#include "IngameState.hpp"
|
|
#include "MenuState.hpp"
|
|
#include "MenuState.hpp"
|
|
@@ -36,6 +37,7 @@ Triangles::Triangles(int argc, char** argv):
|
|
_variables.running = true;
|
|
_variables.running = true;
|
|
_variables.needsUpdate = false;
|
|
_variables.needsUpdate = false;
|
|
_variables.shaders = true;
|
|
_variables.shaders = true;
|
|
|
|
+ _variables.nevermore = false;
|
|
_variables.window = &_window;
|
|
_variables.window = &_window;
|
|
_variables.assets = &_assets;
|
|
_variables.assets = &_assets;
|
|
_variables.core = this;
|
|
_variables.core = this;
|
|
@@ -72,20 +74,23 @@ void Triangles::init()
|
|
_loadingHint.setColor(sf::Color::White);
|
|
_loadingHint.setColor(sf::Color::White);
|
|
_loadingText.setColor(sf::Color::White);
|
|
_loadingText.setColor(sf::Color::White);
|
|
_loadingTriangle.setColor(sf::Color::White);
|
|
_loadingTriangle.setColor(sf::Color::White);
|
|
-
|
|
|
|
- std::ifstream ifs;
|
|
|
|
- ifs.open("data/hints.txt");
|
|
|
|
- while(ifs.good())
|
|
|
|
- {
|
|
|
|
- std::string s;
|
|
|
|
- std::getline(ifs, s);
|
|
|
|
- if(s.size() > 1)
|
|
|
|
- _loadingHints.push_back(sf::String(s));
|
|
|
|
- }
|
|
|
|
- ifs.close();
|
|
|
|
-
|
|
|
|
- if(_loadingHints.empty())
|
|
|
|
- _loadingHints.push_back(sf::String(""));
|
|
|
|
|
|
+
|
|
|
|
+ _loadingHints.push_back(L"This is a hint. A placeholder.");
|
|
|
|
+ _loadingHints.push_back(L"There are two perfect things: chocolate and 45° isosceles triangle.");
|
|
|
|
+ _loadingHints.push_back(L"Si les trangles faisaient un dieu, ils lui donneraient trois cótés. — Montesquieu");
|
|
|
|
+ _loadingHints.push_back(L"Triangles do not have speed caps, but you will hit the wall eventually.");
|
|
|
|
+ _loadingHints.push_back(L"when patafour pls owocek you lazy piece of shit");
|
|
|
|
+ _loadingHints.push_back(L"Hit left control to switch light types.");
|
|
|
|
+ _loadingHints.push_back(L"S=√(p(p-a)(p-b)(p-c))");
|
|
|
|
+ _loadingHints.push_back(L"S=12141px²");
|
|
|
|
+ _loadingHints.push_back(L"Positive vibes. PMA. Positive mental attitude.");
|
|
|
|
+ _loadingHints.push_back(L"You can lose up to 4856.4px.");
|
|
|
|
+ _loadingHints.push_back(L"Wasted.");
|
|
|
|
+ _loadingHints.push_back(L"Ah, the Scalene Triangle");
|
|
|
|
+ _loadingHints.push_back(L"Δ");
|
|
|
|
+ _loadingHints.push_back(L"Δ\nΔ Δ");
|
|
|
|
+ _loadingHints.push_back(L"The stars act as consolation prizes if you go in the wrong direction.");
|
|
|
|
+ _loadingHints.push_back(L"[](){}(); [](){}(); [](){}();");
|
|
}
|
|
}
|
|
|
|
|
|
void Triangles::passArguments(int argc, char** argv)
|
|
void Triangles::passArguments(int argc, char** argv)
|
|
@@ -97,27 +102,33 @@ void Triangles::passArguments(int argc, char** argv)
|
|
if(argvStr[i].size() < 2)
|
|
if(argvStr[i].size() < 2)
|
|
argvStr[i] = "--kaczka";
|
|
argvStr[i] = "--kaczka";
|
|
}
|
|
}
|
|
- searchArgument(argc, argvStr, 'f', "fullscreen", [this]()
|
|
|
|
|
|
+ searchArgument(argc, argvStr, "f", "fullscreen", [this]()
|
|
{
|
|
{
|
|
_variables.fullscreen = true;
|
|
_variables.fullscreen = true;
|
|
});
|
|
});
|
|
- searchArgument(argc, argvStr, 'w', "window", [this]()
|
|
|
|
|
|
+ searchArgument(argc, argvStr, "w", "window", [this]()
|
|
{
|
|
{
|
|
_variables.fullscreen = false;
|
|
_variables.fullscreen = false;
|
|
});
|
|
});
|
|
- searchArgument(argc, argvStr, 'b', "borderlesswindow", [this]()
|
|
|
|
|
|
+ searchArgument(argc, argvStr, "b", "borderlesswindow", [this]()
|
|
{
|
|
{
|
|
_variables.borderless = true;
|
|
_variables.borderless = true;
|
|
});
|
|
});
|
|
- searchArgument(argc, argvStr, 'v', "vsync", [this]()
|
|
|
|
|
|
+ searchArgument(argc, argvStr, "v", "vsync", [this]()
|
|
{
|
|
{
|
|
_variables.vsync = true;
|
|
_variables.vsync = true;
|
|
});
|
|
});
|
|
- searchArgument(argc, argvStr, 's', "skip", [this]()
|
|
|
|
|
|
+ searchArgument(argc, argvStr, "s", "skip", [this]()
|
|
|
|
+ {
|
|
|
|
+ _initialState = State::Ingame;
|
|
|
|
+ });
|
|
|
|
+ searchArgument(argc, argvStr, "sf", "skipfullscreen", [this]()
|
|
{
|
|
{
|
|
_initialState = State::Ingame;
|
|
_initialState = State::Ingame;
|
|
|
|
+ _variables.fullscreen = true;
|
|
|
|
+ _variables.nevermore = true;
|
|
});
|
|
});
|
|
- searchArgument(argc, argvStr, 'r', "resolution", [this](std::string param)
|
|
|
|
|
|
+ searchArgument(argc, argvStr, "r", "resolution", [this](std::string param)
|
|
{
|
|
{
|
|
if(param == "640x480")
|
|
if(param == "640x480")
|
|
{
|
|
{
|
|
@@ -147,7 +158,7 @@ void Triangles::passArguments(int argc, char** argv)
|
|
|
|
|
|
_window.setSize(w, h);
|
|
_window.setSize(w, h);
|
|
});
|
|
});
|
|
- searchArgument(argc, argvStr, 'h', "help", [this]()
|
|
|
|
|
|
+ searchArgument(argc, argvStr, "h", "help", [this]()
|
|
{
|
|
{
|
|
std::cout << "triangles: triangles [OPTION]..." << std::endl;
|
|
std::cout << "triangles: triangles [OPTION]..." << std::endl;
|
|
std::cout << "A pseudogame not meant to be run by sane people." << std::endl << std::endl;
|
|
std::cout << "A pseudogame not meant to be run by sane people." << std::endl << std::endl;
|
|
@@ -155,32 +166,36 @@ void Triangles::passArguments(int argc, char** argv)
|
|
std::cout << "This program comes with ABSOLUTELY NO WARRANTY;" << std::endl;
|
|
std::cout << "This program comes with ABSOLUTELY NO WARRANTY;" << std::endl;
|
|
std::cout << "This is free software, and you are welcome to redistribute it" << std::endl;
|
|
std::cout << "This is free software, and you are welcome to redistribute it" << std::endl;
|
|
std::cout << "under certain conditions; see LICENSE.md" << std::endl << std::endl;
|
|
std::cout << "under certain conditions; see LICENSE.md" << std::endl << std::endl;
|
|
- std::cout << std::setw(8) << "-f" << " or " << std::setw(16) << "--fullscreen" << " prevents from playing in windowed mode; try F11" << std::endl;
|
|
|
|
- std::cout << std::setw(8) << "-w" << " or " << std::setw(16) << "--window" << " prevents from playing in fullscreen mode; try F11" << std::endl;
|
|
|
|
std::cout << std::setw(8) << "-v" << " or " << std::setw(16) << "--vsync" << " prevents from playing without vertical synchronization; try F10" << std::endl;
|
|
std::cout << std::setw(8) << "-v" << " or " << std::setw(16) << "--vsync" << " prevents from playing without vertical synchronization; try F10" << std::endl;
|
|
std::cout << std::setw(8) << "-s" << " or " << std::setw(16) << "--skip" << " prevents from going to the main menu; try Escape" << std::endl;
|
|
std::cout << std::setw(8) << "-s" << " or " << std::setw(16) << "--skip" << " prevents from going to the main menu; try Escape" << std::endl;
|
|
|
|
+ std::cout << std::setw(8) << "-f" << " or " << std::setw(16) << "--fullscreen" << " prevents from playing in windowed mode; try F11" << std::endl;
|
|
|
|
+ std::cout << std::setw(8) << "-sf" << " or " << std::setw(16) << "--skipfullscreen" << " combines --fullscreen and --skip" << std::endl;
|
|
|
|
+ std::cout << std::setw(8) << "-w" << " or " << std::setw(16) << "--window" << " prevents from playing in fullscreen mode; try F11" << std::endl;
|
|
std::cout << std::setw(8) << "-h" << " or " << std::setw(16) << "--help" << " prevents from running the actual game" << std::endl;
|
|
std::cout << std::setw(8) << "-h" << " or " << std::setw(16) << "--help" << " prevents from running the actual game" << std::endl;
|
|
std::cout << std::setw(8) << "-r WxH" << " or " << std::setw(16) << "--resolution=WxH" << " prevents from running at 640x480" << std::endl;
|
|
std::cout << std::setw(8) << "-r WxH" << " or " << std::setw(16) << "--resolution=WxH" << " prevents from running at 640x480" << std::endl;
|
|
_variables.running = false;
|
|
_variables.running = false;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
-void Triangles::searchArgument(int argc, std::string argvStr[], char callShort, std::string callLong, std::function<void()> lambda)
|
|
|
|
|
|
+void Triangles::searchArgument(int argc, std::string argvStr[], std::string callShort, std::string callLong, std::function<void()> lambda)
|
|
{
|
|
{
|
|
for(int i = 1; i < argc; ++i)
|
|
for(int i = 1; i < argc; ++i)
|
|
{
|
|
{
|
|
- if((argvStr[i][0] == '-' and argvStr[i][1] == callShort) or argvStr[i] == "--" + callLong)
|
|
|
|
|
|
+ if((argvStr[i][0] == '-' && argvStr[i][1] == callShort[0]) || argvStr[i] == "--" + callLong)
|
|
{
|
|
{
|
|
- lambda();
|
|
|
|
- break;
|
|
|
|
|
|
+ if((callShort.size() == 1 && argvStr[i].size() == 2) || argvStr[i][2] == callShort[1])
|
|
|
|
+ {
|
|
|
|
+ lambda();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-void Triangles::searchArgument(int argc, std::string argvStr[], char callShort, std::string callLong, std::function<void(std::string param)> lambda)
|
|
|
|
|
|
+void Triangles::searchArgument(int argc, std::string argvStr[], std::string callShort, std::string callLong, std::function<void(std::string param)> lambda)
|
|
{
|
|
{
|
|
for(int i = 1; i < argc; ++i)
|
|
for(int i = 1; i < argc; ++i)
|
|
{
|
|
{
|
|
- if(argvStr[i][0] == '-' and argvStr[i][1] == callShort and i < argc - 1)
|
|
|
|
|
|
+ if(argvStr[i][0] == '-' && argvStr[i][1] == callShort[0] && i < argc - 1)
|
|
{
|
|
{
|
|
lambda(argvStr[i + 1]);
|
|
lambda(argvStr[i + 1]);
|
|
break;
|
|
break;
|
|
@@ -263,7 +278,7 @@ int Triangles::run()
|
|
|
|
|
|
if(_context.running)
|
|
if(_context.running)
|
|
{
|
|
{
|
|
- Echo::out(Echo::Empty, "Triangles version -0.8.9");
|
|
|
|
|
|
+ Echo::out(Echo::Empty, "Triangles version -0.8.8");
|
|
Echo::out(Echo::Empty, "Copyright (C) 2016 POSITIVE MENTAL ATTITUDE");
|
|
Echo::out(Echo::Empty, "Copyright (C) 2016 POSITIVE MENTAL ATTITUDE");
|
|
Echo::out(Echo::Empty, "This program comes with ABSOLUTELY NO WARRANTY;");
|
|
Echo::out(Echo::Empty, "This program comes with ABSOLUTELY NO WARRANTY;");
|
|
Echo::out(Echo::Empty, "This is free software, and you are welcome to redistribute it");
|
|
Echo::out(Echo::Empty, "This is free software, and you are welcome to redistribute it");
|
|
@@ -313,10 +328,6 @@ void Triangles::coreThink()
|
|
if(_current->status())
|
|
if(_current->status())
|
|
_current->coreThink(event);
|
|
_current->coreThink(event);
|
|
_window.think(event);
|
|
_window.think(event);
|
|
- if(event.type == sf::Event::KeyPressed and event.key.code == sf::Keyboard::F11)
|
|
|
|
- _context.fullscreen = !_context.fullscreen, _variables.fullscreen = _context.fullscreen, _window.recreate();
|
|
|
|
- if(event.type == sf::Event::KeyPressed and event.key.code == sf::Keyboard::F10)
|
|
|
|
- _context.vsync = !_context.vsync, _variables.vsync = _context.vsync, _window.recreate();
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -389,7 +400,7 @@ void Triangles::coreRender()
|
|
{
|
|
{
|
|
_window.clear();
|
|
_window.clear();
|
|
_current->coreRender(_variables.shaders);
|
|
_current->coreRender(_variables.shaders);
|
|
- #ifdef DEBUG
|
|
|
|
|
|
+ #ifdef TRIANGLES_DEBUG
|
|
_window.draw(_fpsRect);
|
|
_window.draw(_fpsRect);
|
|
_window.draw(_fps);
|
|
_window.draw(_fps);
|
|
#endif
|
|
#endif
|