mirror of
https://github.com/zhenyan121/SporeBG-Conid.git
synced 2026-04-10 06:14:08 +08:00
feat: add validation for badapple inputs
This commit is contained in:
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
#include "ui/managers/debug/DebugData.h"
|
#include "ui/managers/debug/DebugData.h"
|
||||||
#include "input/InputState.h"
|
#include "input/InputState.h"
|
||||||
|
#include "scenes/base/SceneEvent.h"
|
||||||
struct CoreData {
|
struct CoreData {
|
||||||
DebugData debugData;
|
DebugData debugData;
|
||||||
InputState inputState;
|
InputState inputState;
|
||||||
|
SceneType sceneType = SceneType::MainMenuScene;
|
||||||
};
|
};
|
||||||
@@ -31,7 +31,7 @@ bool GameApplication::initialize() {
|
|||||||
|
|
||||||
|
|
||||||
// 输入管理
|
// 输入管理
|
||||||
m_inputManager = std::make_unique<InputManager>(m_coreData.inputState);
|
m_inputManager = std::make_unique<InputManager>(m_coreData);
|
||||||
// 窗口管理
|
// 窗口管理
|
||||||
m_windowManager = std::make_unique<WindowManager>();
|
m_windowManager = std::make_unique<WindowManager>();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#include "InputManager.h"
|
#include "InputManager.h"
|
||||||
|
|
||||||
InputManager::InputManager(InputState& inputState) :
|
InputManager::InputManager(CoreData& coreData) :
|
||||||
m_currentInputState(inputState)
|
m_currentInputState(coreData.inputState),
|
||||||
|
m_coreData(coreData)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -31,10 +32,49 @@ SDL_AppResult InputManager::handleInputEvent(const SDL_Event* event) {
|
|||||||
static_cast<float>(event->motion.y)};
|
static_cast<float>(event->motion.y)};
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_KEY_DOWN:
|
case SDL_EVENT_KEY_DOWN:
|
||||||
if (event->key.key == SDLK_F11) {
|
switch(event->key.key) {
|
||||||
m_currentInputState.isFullscreen = !m_currentInputState.isFullscreen;
|
case SDLK_F11:
|
||||||
|
m_currentInputState.isFullscreen = !m_currentInputState.isFullscreen;
|
||||||
|
break;
|
||||||
|
case SDLK_B:
|
||||||
|
if (m_coreData.sceneType == SceneType::MainMenuScene) {
|
||||||
|
m_isStartBadApple = true;
|
||||||
|
m_badapple.push_back('b');
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SDLK_A:
|
||||||
|
if (m_isStartBadApple) {
|
||||||
|
m_badapple.push_back('a');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SDLK_D:
|
||||||
|
if (m_isStartBadApple) {
|
||||||
|
m_badapple.push_back('d');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SDLK_P:
|
||||||
|
if (m_isStartBadApple) {
|
||||||
|
m_badapple.push_back('p');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SDLK_L:
|
||||||
|
if (m_isStartBadApple) {
|
||||||
|
m_badapple.push_back('l');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SDLK_E:
|
||||||
|
if (m_isStartBadApple) {
|
||||||
|
m_badapple.push_back('e');
|
||||||
|
if (m_badapple == "badapple") {
|
||||||
|
m_currentInputState.isBadApplePress = true;
|
||||||
|
}
|
||||||
|
m_badapple.clear();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
return SDL_APP_CONTINUE;
|
return SDL_APP_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
|
#include "core/CoreData.h"
|
||||||
#include "InputState.h"
|
#include "InputState.h"
|
||||||
class InputManager {
|
class InputManager {
|
||||||
public:
|
public:
|
||||||
InputManager(InputState& inputState);
|
InputManager(CoreData& coreData);
|
||||||
SDL_AppResult handleInputEvent(const SDL_Event* event);
|
SDL_AppResult handleInputEvent(const SDL_Event* event);
|
||||||
|
|
||||||
InputState GetInputState() const;
|
InputState GetInputState() const;
|
||||||
private:
|
private:
|
||||||
InputState& m_currentInputState;
|
InputState& m_currentInputState;
|
||||||
|
CoreData& m_coreData;
|
||||||
|
bool m_isStartBadApple = false;
|
||||||
|
|
||||||
|
std::string m_badapple; // 彩蛋
|
||||||
};
|
};
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
#include <string>
|
||||||
struct InputState
|
struct InputState
|
||||||
{
|
{
|
||||||
glm::vec2 mouseCilckOn;
|
glm::vec2 mouseCilckOn;
|
||||||
@@ -8,4 +9,5 @@ struct InputState
|
|||||||
glm::vec2 mouseCurrentPosition;
|
glm::vec2 mouseCurrentPosition;
|
||||||
glm::ivec2 mouseCurrentLogicalPosition;
|
glm::ivec2 mouseCurrentLogicalPosition;
|
||||||
bool isFullscreen = false;
|
bool isFullscreen = false;
|
||||||
|
bool isBadApplePress = false;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user