Is what open source? The answer is yes, because all of the things mentioned that you could possibly be referring to are open source (ChessPlusPlus, SFML, Boost, Lacewing).
There is a library called SFGUI that claims it is for SFML applications.
That might be worth trying out.[/quote]I could never get SFGUI to compile. I was planning on writing a quick and dirty GUI module that works well enough for our purposes (a menu, a quit button, pause screen, etc). That said, I haven't gotten around to it just yet, so if that's something you can/want to do, go at it.
L B wrote:
if each state class had a static function changeTo that too the application, and it would call changeState for you.
Yeah I would do that in the actual implementation. I threw this together for RB without thinking too much about it -- it was meant to be almost purely conceptual.
template<class NewState, typename... Args>
void changeState(Args... args)
{
//make sure we can create the new state first
std::unique_ptr<AppState> temp {new NewState(std::forward<Args>(args)...)};
//then swap ownership
state.swap(temp);
//temp properly deletes the old state at the end of its scope
}
I'm not too familiar with variadic templates or std::forward but it looks like it's creating a unique_ptr from a state passed as template arg and swapping it with the classes unique_ptr.
@ResidentBiscuit: it's a use-case for perfect forwarding. It's a lot like .emplace(...) in most C++ containers, except in this case we're creating a new state from the passed arguments, swapping it with the current state, and letting the old state go out of scope and get destroyed.
EDIT: The only issue is, I forgot the && between "Args" and "..." in the parameter list, so it isn't actually perfect forwarding until I fix it :)
In case anyone is interested, the project can be built with VS2013 by removing all the noexcept's, defaulted move ctors and defaulted assignment operators plus a few other minor changes.
The project compiles but only runs for me in release, but debug gives "map/set iterators incompatible" exception.