<commit_before>// Copyright (C) 2016 <NAME>
// This file is part of the Ouzel engine.

#include "Application.h"
#include "MainMenu.h"
#include "SpritesSample.h"
#include "GUISample.h"
#include "RTSample.h"
#include "AnimationsSample.h"
#include "InputSample.h"

using namespace std;
using namespace ouzel;

Application::~Application()
{
}

void Application::begin(const std::string& sample)
{
    sharedEngine->getInput()->startGamepadDiscovery();

#if defined(OUZEL_PLATFORM_WINDOWS) || defined(OUZEL_PLATFORM_LINUX)
    sharedEngine->getFileSystem()->addResourcePath("Resources");
#endif

    sharedEngine->getRenderer()->setClearColor(graphics::Color(64, 0, 0));
    sharedEngine->getWindow()->setTitle("Samples");

    eventHandler = make_shared<EventHandler>();

    eventHandler->keyboardHandler = bind(&Application::handleKeyboard, this, placeholders::_1, placeholders::_2, placeholders::_3);

    sharedEngine->getEventDispatcher()->addEventHandler(eventHandler);

    mainMenu = make_shared<MainMenu>(*this);

    scene::ScenePtr newScene;

    if (!sample.empty())
    {
        if (sample == "sprites")
        {
            newScene = make_shared<SpritesSample>(*this);
        }
        else if (sample == "gui")
        {
            newScene = make_shared<GUISample>(*this);
        }
        else if (sample == "render_target")
        {
            newScene = make_shared<RTSample>(*this);
        }
        else if (sample == "animations")
        {
            newScene = make_shared<AnimationsSample>(*this);
        }
        else if (sample == "input")
        {
            newScene = make_shared<InputSample>(*this);
        }
    }

    if (newScene)
    {
        sharedEngine->getSceneManager()->setScene(newScene);
    }
    else
    {
        sharedEngine->getSceneManager()->setScene(mainMenu);
    }
}

void Application::back()
{
    sharedEngine->getInput()->setCursorVisible(true);
    sharedEngine->getSceneManager()->setScene(mainMenu);
}

bool Application::handleKeyboard(Event::Type type, const KeyboardEvent& event, const VoidPtr& sender)
{
    OUZEL_UNUSED(sender);

    if (type == Event::Type::KEY_DOWN && event.key == ouzel::input::KeyboardKey::ESCAPE)
    {
        if (sharedEngine->getSceneManager()->getScene() != mainMenu)
        {
            back();
        }
        else
        {
            sharedEngine->exit();
        }

        return false;
    }
    
    return true;
}<commit_msg>Don't propagate any events of escape key<commit_after>// Copyright (C) 2016 <NAME>
// This file is part of the Ouzel engine.

#include "Application.h"
#include "MainMenu.h"
#include "SpritesSample.h"
#include "GUISample.h"
#include "RTSample.h"
#include "AnimationsSample.h"
#include "InputSample.h"

using namespace std;
using namespace ouzel;

Application::~Application()
{
}

void Application::begin(const std::string& sample)
{
    sharedEngine->getInput()->startGamepadDiscovery();

#if defined(OUZEL_PLATFORM_WINDOWS) || defined(OUZEL_PLATFORM_LINUX)
    sharedEngine->getFileSystem()->addResourcePath("Resources");
#endif

    sharedEngine->getRenderer()->setClearColor(graphics::Color(64, 0, 0));
    sharedEngine->getWindow()->setTitle("Samples");

    eventHandler = make_shared<EventHandler>();

    eventHandler->keyboardHandler = bind(&Application::handleKeyboard, this, placeholders::_1, placeholders::_2, placeholders::_3);

    sharedEngine->getEventDispatcher()->addEventHandler(eventHandler);

    mainMenu = make_shared<MainMenu>(*this);

    scene::ScenePtr newScene;

    if (!sample.empty())
    {
        if (sample == "sprites")
        {
            newScene = make_shared<SpritesSample>(*this);
        }
        else if (sample == "gui")
        {
            newScene = make_shared<GUISample>(*this);
        }
        else if (sample == "render_target")
        {
            newScene = make_shared<RTSample>(*this);
        }
        else if (sample == "animations")
        {
            newScene = make_shared<AnimationsSample>(*this);
        }
        else if (sample == "input")
        {
            newScene = make_shared<InputSample>(*this);
        }
    }

    if (newScene)
    {
        sharedEngine->getSceneManager()->setScene(newScene);
    }
    else
    {
        sharedEngine->getSceneManager()->setScene(mainMenu);
    }
}

void Application::back()
{
    sharedEngine->getInput()->setCursorVisible(true);
    sharedEngine->getSceneManager()->setScene(mainMenu);
}

bool Application::handleKeyboard(Event::Type type, const KeyboardEvent& event, const VoidPtr& sender)
{
    OUZEL_UNUSED(sender);

    if (event.key == ouzel::input::KeyboardKey::ESCAPE)
    {
        if (type == Event::Type::KEY_DOWN)
        {
            if (sharedEngine->getSceneManager()->getScene() != mainMenu)
            {
                back();
            }
            else
            {
                sharedEngine->exit();
            }
        }

        return false;
    }
    
    return true;
}
{'fraction_non_alphanumeric': 0.14101790384228524, 'fraction_numerical': 0.004425668879501106, 'mean_word_length': 2.881342701014832, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 63, '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': '4893623', 'n_tokens_mistral': 1504, 'n_tokens_neox': 1472, 'n_words': 259}