<commit_before>﻿//
// Copyright (c) 2013-2014 <NAME>
// See LICENSE for more information.
//

#ifndef RJ_CORE_GAME_WINDOW_HPP
#define RJ_CORE_GAME_WINDOW_HPP


#include "game_updater.hpp"
#include <rectojump/shared/input.hpp>

#include <mlk/log/log.h>
#include <mlk/signals_slots/slot.h>
#include <mlk/time/time.h>
#include <mlk/types/types.h>

#include <SFML/Graphics.hpp>


namespace rj
{
	class game_window
	{
		mlk::uint m_width{1280}, m_height{720};
		std::string m_title{"Recto Jump"};
		sf::RenderWindow m_window;
		bool m_running{false};
		bool m_fullscreen{false};
		bool m_need_recreate{false};

		input& m_input{input::get()};

		game_updater m_game_updater;

	public:
		mlk::slot<> on_stop;

		game_window() :
			m_window{{m_width, m_height}, m_title}
		{ }

		// interface
		void start()
		{
			if(m_running) return;

			this->prepare_start();
			while(m_running)
			{
				if(m_need_recreate)
					this->recreate();

				m_game_updater.start_pt();

				// update
				this->update_events();
				m_input.update(m_window.mapPixelToCoords(sf::Mouse::getPosition(m_window)));
				m_game_updater.update();

				// render
				m_window.clear();
				m_game_updater.render();
				m_window.display();

				m_game_updater.end_pt();
			}
		}

		void stop() noexcept
		{m_running = false; on_stop();}

		void draw(const sf::Drawable& object)
		{m_window.draw(object);}

		void toggle_fullscreen() noexcept
		{
			m_fullscreen = !m_fullscreen;
			m_need_recreate = true;
		}

		// setters
		void set_framereate_limit(mlk::uint limit) noexcept
		{m_window.setFramerateLimit(limit);}

		void set_size(const vec2u& size) noexcept
		{m_window.setSize(size);}

		void set_position(const vec2i& position) noexcept
		{m_window.setPosition(position);}

		void set_fullscreen(bool b) noexcept
		{
			if(b == m_fullscreen)
				return;
			m_fullscreen = b;
			m_need_recreate = true;
		}

		// getters<commit_msg>switched order<commit_after>﻿//
// Copyright (c) 2013-2014 <NAME>
// See LICENSE for more information.
//

#ifndef RJ_CORE_GAME_WINDOW_HPP
#define RJ_CORE_GAME_WINDOW_HPP


#include "game_updater.hpp"
#include <rectojump/shared/input.hpp>

#include <mlk/log/log.h>
#include <mlk/signals_slots/slot.h>
#include <mlk/time/time.h>
#include <mlk/types/types.h>

#include <SFML/Graphics.hpp>


namespace rj
{
	class game_window
	{
		mlk::uint m_width{1280}, m_height{720};
		std::string m_title{"Recto Jump"};
		sf::RenderWindow m_window;
		bool m_running{false};
		bool m_fullscreen{false};
		bool m_need_recreate{false};

		input& m_input{input::get()};

		game_updater m_game_updater;

	public:
		mlk::slot<> on_stop;

		game_window() :
			m_window{{m_width, m_height}, m_title}
		{ }

		// interface
		void start()
		{
			if(m_running) return;

			this->prepare_start();
			while(m_running)
			{
				if(m_need_recreate)
					this->recreate();

				m_game_updater.start_pt();

				// update
				this->update_events();
				m_input.update(m_window.mapPixelToCoords(sf::Mouse::getPosition(m_window)));
				m_game_updater.update();

				// render
				m_window.clear();
				m_game_updater.render();
				m_window.display();

				m_game_updater.end_pt();
			}
		}

		void stop() noexcept
		{on_stop(); m_running = false;}

		void draw(const sf::Drawable& object)
		{m_window.draw(object);}

		void toggle_fullscreen() noexcept
		{
			m_fullscreen = !m_fullscreen;
			m_need_recreate = true;
		}

		// setters
		void set_framereate_limit(mlk::uint limit) noexcept
		{m_window.setFramerateLimit(limit);}

		void set_size(const vec2u& size) noexcept
		{m_window.setSize(size);}

		void set_position(const vec2i& position) noexcept
		{m_window.setPosition(position);}

		void set_fullscreen(bool b) noexcept
		{
			if(b == m_fullscreen)
				return;
			m_fullscreen = b;
			m_need_recreate = true;
		}

		// getters
{'fraction_non_alphanumeric': 0.13627992633517497, 'fraction_numerical': 0.008945014469876349, 'mean_word_length': 3.9505208333333335, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5548868', 'n_tokens_mistral': 1730, 'n_tokens_neox': 1481, 'n_words': 248}