Fixes
This commit is contained in:
@ -62,10 +62,8 @@ namespace ia::iae
|
||||
|
||||
Vec2 InputManager::GetAxis()
|
||||
{
|
||||
return Vec2{
|
||||
IsKeyDown(s_axisInputs[3]) + IsKeyDown(s_axisInputs[2]) * -1,
|
||||
IsKeyDown(s_axisInputs[1]) + IsKeyDown(s_axisInputs[0]) * -1
|
||||
};
|
||||
return Vec2{IsKeyDown(s_axisInputs[3]) + IsKeyDown(s_axisInputs[2]) * -1,
|
||||
IsKeyDown(s_axisInputs[1]) + IsKeyDown(s_axisInputs[0]) * -1};
|
||||
}
|
||||
|
||||
VOID InputManager::SwitchModeToText()
|
||||
@ -100,42 +98,42 @@ namespace ia::iae
|
||||
|
||||
BOOL InputManager::IsActionDown(IN Handle action)
|
||||
{
|
||||
const auto& t = s_actions[action];
|
||||
for(const auto& k : t)
|
||||
if(IsKeyDown(k))
|
||||
const auto &t = s_actions[action];
|
||||
for (const auto &k : t)
|
||||
if (IsKeyDown(k))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOL InputManager::WasActionPressed(IN Handle action)
|
||||
{
|
||||
const auto& t = s_actions[action];
|
||||
for(const auto& k : t)
|
||||
if(WasKeyPressed(k))
|
||||
const auto &t = s_actions[action];
|
||||
for (const auto &k : t)
|
||||
if (WasKeyPressed(k))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOL InputManager::WasActionReleased(IN Handle action)
|
||||
{
|
||||
const auto& t = s_actions[action];
|
||||
for(const auto& k : t)
|
||||
if(WasKeyReleased(k))
|
||||
const auto &t = s_actions[action];
|
||||
for (const auto &k : t)
|
||||
if (WasKeyReleased(k))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOL InputManager::IsActionDown(IN CONST String& action)
|
||||
BOOL InputManager::IsActionDown(IN CONST String &action)
|
||||
{
|
||||
return IsActionDown(s_actionNames[action]);
|
||||
}
|
||||
|
||||
BOOL InputManager::WasActionPressed(IN CONST String& action)
|
||||
BOOL InputManager::WasActionPressed(IN CONST String &action)
|
||||
{
|
||||
return WasActionPressed(s_actionNames[action]);
|
||||
}
|
||||
|
||||
BOOL InputManager::WasActionReleased(IN CONST String& action)
|
||||
BOOL InputManager::WasActionReleased(IN CONST String &action)
|
||||
{
|
||||
return WasActionReleased(s_actionNames[action]);
|
||||
}
|
||||
@ -155,6 +153,39 @@ namespace ia::iae
|
||||
s_axisInputs[2] = leftKey;
|
||||
s_axisInputs[3] = rightKey;
|
||||
}
|
||||
|
||||
VOID InputManager::SetKey(IN InputKey key, IN BOOL state)
|
||||
{
|
||||
s_keys[(UINT8) key] = state;
|
||||
}
|
||||
|
||||
VOID InputManager::SetAxis(IN BOOL up, IN BOOL down, IN BOOL left, IN BOOL right)
|
||||
{
|
||||
s_keys[(UINT8) s_axisInputs[0]] = up;
|
||||
s_keys[(UINT8) s_axisInputs[1]] = down;
|
||||
s_keys[(UINT8) s_axisInputs[2]] = left;
|
||||
s_keys[(UINT8) s_axisInputs[3]] = right;
|
||||
}
|
||||
|
||||
VOID InputManager::SetAxisUp(IN BOOL v)
|
||||
{
|
||||
s_keys[(UINT8) s_axisInputs[0]] = v;
|
||||
}
|
||||
|
||||
VOID InputManager::SetAxisDown(IN BOOL v)
|
||||
{
|
||||
s_keys[(UINT8) s_axisInputs[1]] = v;
|
||||
}
|
||||
|
||||
VOID InputManager::SetAxisLeft(IN BOOL v)
|
||||
{
|
||||
s_keys[(UINT8) s_axisInputs[2]] = v;
|
||||
}
|
||||
|
||||
VOID InputManager::SetAxisRight(IN BOOL v)
|
||||
{
|
||||
s_keys[(UINT8) s_axisInputs[3]] = v;
|
||||
}
|
||||
} // namespace ia::iae
|
||||
|
||||
namespace ia::iae
|
||||
@ -209,17 +240,17 @@ namespace ia::iae
|
||||
return InputManager::WasActionReleased(action);
|
||||
}
|
||||
|
||||
BOOL Engine::IsInputActionDown(IN CONST String& action)
|
||||
BOOL Engine::IsInputActionDown(IN CONST String &action)
|
||||
{
|
||||
return InputManager::IsActionDown(action);
|
||||
}
|
||||
|
||||
BOOL Engine::WasInputActionPressed(IN CONST String& action)
|
||||
BOOL Engine::WasInputActionPressed(IN CONST String &action)
|
||||
{
|
||||
return InputManager::WasActionPressed(action);
|
||||
}
|
||||
|
||||
BOOL Engine::WasInputActionReleased(IN CONST String& action)
|
||||
BOOL Engine::WasInputActionReleased(IN CONST String &action)
|
||||
{
|
||||
return InputManager::WasActionReleased(action);
|
||||
}
|
||||
@ -233,4 +264,34 @@ namespace ia::iae
|
||||
{
|
||||
InputManager::BindAxis(upKey, downKey, leftKey, rightKey);
|
||||
}
|
||||
|
||||
VOID Engine::SetKey(IN InputKey key, IN BOOL state)
|
||||
{
|
||||
InputManager::SetKey(key, state);
|
||||
}
|
||||
|
||||
VOID Engine::SetAxis(IN BOOL up, IN BOOL down, IN BOOL left, IN BOOL right)
|
||||
{
|
||||
InputManager::SetAxis(up, down, left, right);
|
||||
}
|
||||
|
||||
VOID Engine::SetAxisUp(IN BOOL v)
|
||||
{
|
||||
InputManager::SetAxisUp(v);
|
||||
}
|
||||
|
||||
VOID Engine::SetAxisDown(IN BOOL v)
|
||||
{
|
||||
InputManager::SetAxisDown(v);
|
||||
}
|
||||
|
||||
VOID Engine::SetAxisLeft(IN BOOL v)
|
||||
{
|
||||
InputManager::SetAxisLeft(v);
|
||||
}
|
||||
|
||||
VOID Engine::SetAxisRight(IN BOOL v)
|
||||
{
|
||||
InputManager::SetAxisRight(v);
|
||||
}
|
||||
} // namespace ia::iae
|
||||
@ -57,33 +57,33 @@ namespace ia::iae
|
||||
|
||||
VOID AddClickListener(IN Rml::Element *element, IN std::function<VOID()> callback)
|
||||
{
|
||||
element->AddEventListener("click", this);
|
||||
element->AddEventListener(Rml::EventId::Click, this);
|
||||
m_clickCallbacks[element->GetId().c_str()] = callback;
|
||||
}
|
||||
|
||||
// VOID AddHoverEnterListener(IN PCCHAR elementId, IN std::function<VOID()> callback)
|
||||
//{
|
||||
// m_document->GetElementById(elementId)->AddEventListener("mouseover", this);
|
||||
// m_hoverEnterCallbacks[elementId] = callback;
|
||||
// }
|
||||
//
|
||||
// VOID AddHoverExitListener(IN PCCHAR elementId, IN std::function<VOID()> callback)
|
||||
//{
|
||||
// m_document->GetElementById(elementId)->AddEventListener("mouseout", this);
|
||||
// m_hoverExitCallbacks[elementId] = callback;
|
||||
//}
|
||||
//
|
||||
// VOID AddPointerDownListener(IN PCCHAR elementId, IN std::function<VOID()> callback)
|
||||
//{
|
||||
// m_document->GetElementById(elementId)->AddEventListener("mousedown", this);
|
||||
// m_pointerDownCallbacks[elementId] = callback;
|
||||
//}
|
||||
//
|
||||
// VOID AddPointerUpListener(IN PCCHAR elementId, IN std::function<VOID()> callback)
|
||||
//{
|
||||
// m_document->GetElementById(elementId)->AddEventListener("mouseup", this);
|
||||
// m_pointerUpCallbacks[elementId] = callback;
|
||||
//}
|
||||
VOID AddPointerDownListener(IN Rml::Element *element, IN std::function<VOID()> callback)
|
||||
{
|
||||
element->AddEventListener(Rml::EventId::Mousedown, this);
|
||||
m_pointerDownCallbacks[element->GetId().c_str()] = callback;
|
||||
}
|
||||
|
||||
VOID AddPointerUpListener(IN Rml::Element *element, IN std::function<VOID()> callback)
|
||||
{
|
||||
element->AddEventListener(Rml::EventId::Mouseup, this);
|
||||
m_pointerUpCallbacks[element->GetId().c_str()] = callback;
|
||||
}
|
||||
|
||||
VOID AddPointerEnterListener(IN Rml::Element *element, IN std::function<VOID()> callback)
|
||||
{
|
||||
element->AddEventListener(Rml::EventId::Mouseover, this);
|
||||
m_hoverEnterCallbacks[element->GetId().c_str()] = callback;
|
||||
}
|
||||
|
||||
VOID AddPointerExitListener(IN Rml::Element *element, IN std::function<VOID()> callback)
|
||||
{
|
||||
element->AddEventListener(Rml::EventId::Mouseout, this);
|
||||
m_hoverExitCallbacks[element->GetId().c_str()] = callback;
|
||||
}
|
||||
|
||||
VOID ProcessEvent(IN Rml::Event &event)
|
||||
{
|
||||
@ -101,13 +101,15 @@ namespace ia::iae
|
||||
m_hoverExitCallbacks[event.GetTargetElement()->GetId().c_str()]();
|
||||
break;
|
||||
|
||||
case Rml::EventId::Mousedown:
|
||||
case Rml::EventId::Mousedown: {
|
||||
m_pointerDownCallbacks[event.GetTargetElement()->GetId().c_str()]();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Rml::EventId::Mouseup:
|
||||
case Rml::EventId::Mouseup: {
|
||||
m_pointerUpCallbacks[event.GetTargetElement()->GetId().c_str()]();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@ -490,6 +492,26 @@ namespace ia::iae
|
||||
{
|
||||
g_eventListener.AddClickListener(g_document->GetElementById(elementId), callback);
|
||||
}
|
||||
|
||||
VOID UI::AddPointerUpEvent(IN PCCHAR elementId, IN std::function<VOID()> callback)
|
||||
{
|
||||
g_eventListener.AddPointerUpListener(g_document->GetElementById(elementId), callback);
|
||||
}
|
||||
|
||||
VOID UI::AddPointerDownEvent(IN PCCHAR elementId, IN std::function<VOID()> callback)
|
||||
{
|
||||
g_eventListener.AddPointerDownListener(g_document->GetElementById(elementId), callback);
|
||||
}
|
||||
|
||||
VOID UI::AddPointerExitEvent(IN PCCHAR elementId, IN std::function<VOID()> callback)
|
||||
{
|
||||
g_eventListener.AddPointerExitListener(g_document->GetElementById(elementId), callback);
|
||||
}
|
||||
|
||||
VOID UI::AddPointerEnterEvent(IN PCCHAR elementId, IN std::function<VOID()> callback)
|
||||
{
|
||||
g_eventListener.AddPointerEnterListener(g_document->GetElementById(elementId), callback);
|
||||
}
|
||||
} // namespace ia::iae
|
||||
|
||||
namespace ia::iae
|
||||
|
||||
@ -46,6 +46,13 @@ namespace ia::iae
|
||||
STATIC Handle BindAction(IN CONST String &name, IN InputKey key);
|
||||
STATIC VOID BindAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey);
|
||||
|
||||
STATIC VOID SetAxisUp(IN BOOL v);
|
||||
STATIC VOID SetAxisDown(IN BOOL v);
|
||||
STATIC VOID SetAxisLeft(IN BOOL v);
|
||||
STATIC VOID SetAxisRight(IN BOOL v);
|
||||
STATIC VOID SetKey(IN InputKey key, IN BOOL state);
|
||||
STATIC VOID SetAxis(IN BOOL up, IN BOOL down, IN BOOL left, IN BOOL right);
|
||||
|
||||
private:
|
||||
STATIC BOOL s_keys[256];
|
||||
STATIC BOOL s_prevKeys[256];
|
||||
|
||||
@ -117,6 +117,12 @@ namespace ia::iae
|
||||
STATIC BOOL WasInputActionReleased(IN CONST String &action);
|
||||
STATIC Handle BindInputAction(IN CONST String &name, IN InputKey key);
|
||||
STATIC VOID BindInputAxis(IN InputKey upKey, IN InputKey downKey, IN InputKey leftKey, IN InputKey rightKey);
|
||||
STATIC VOID SetAxisUp(IN BOOL v);
|
||||
STATIC VOID SetAxisDown(IN BOOL v);
|
||||
STATIC VOID SetAxisLeft(IN BOOL v);
|
||||
STATIC VOID SetAxisRight(IN BOOL v);
|
||||
STATIC VOID SetKey(IN InputKey key, IN BOOL state);
|
||||
STATIC VOID SetAxis(IN BOOL up, IN BOOL down, IN BOOL left, IN BOOL right);
|
||||
|
||||
// Utility Functions
|
||||
STATIC String ReadTextAsset(IN CONST String& path);
|
||||
|
||||
@ -28,6 +28,10 @@ namespace ia::iae
|
||||
STATIC VOID SetMarkup(IN CONST String &markup, IN CONST String &styles);
|
||||
|
||||
STATIC VOID AddClickEvent(IN PCCHAR elementId, IN std::function<VOID()> callback);
|
||||
STATIC VOID AddPointerUpEvent(IN PCCHAR elementId, IN std::function<VOID()> callback);
|
||||
STATIC VOID AddPointerDownEvent(IN PCCHAR elementId, IN std::function<VOID()> callback);
|
||||
STATIC VOID AddPointerExitEvent(IN PCCHAR elementId, IN std::function<VOID()> callback);
|
||||
STATIC VOID AddPointerEnterEvent(IN PCCHAR elementId, IN std::function<VOID()> callback);
|
||||
|
||||
public:
|
||||
STATIC VOID Initialize();
|
||||
|
||||
BIN
Resources/HUD/gamepad_dir_down.png
Normal file
BIN
Resources/HUD/gamepad_dir_down.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
BIN
Resources/HUD/gamepad_dir_left.png
Normal file
BIN
Resources/HUD/gamepad_dir_left.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
Resources/HUD/gamepad_dir_right.png
Normal file
BIN
Resources/HUD/gamepad_dir_right.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
BIN
Resources/HUD/gamepad_dir_up.png
Normal file
BIN
Resources/HUD/gamepad_dir_up.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
10
Vendor/CMakeLists.txt
vendored
10
Vendor/CMakeLists.txt
vendored
@ -1,3 +1,5 @@
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
|
||||
# -----------------------------------------------
|
||||
# IACore
|
||||
# -----------------------------------------------
|
||||
@ -7,7 +9,6 @@ add_subdirectory(IACore/)
|
||||
# SDL3
|
||||
# -----------------------------------------------
|
||||
set(SDL_TEST_LIBRARY OFF)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
add_subdirectory(SDL/)
|
||||
|
||||
# -----------------------------------------------
|
||||
@ -22,10 +23,15 @@ add_subdirectory(SDL_mixer/)
|
||||
add_subdirectory(freetype/)
|
||||
add_library(Freetype::Freetype ALIAS freetype)
|
||||
|
||||
# -----------------------------------------------
|
||||
# LunaSVG
|
||||
# -----------------------------------------------
|
||||
set(LUNASVG_BUILD_EXAMPLES OFF)
|
||||
add_subdirectory(lunasvg/)
|
||||
|
||||
# -----------------------------------------------
|
||||
# RmlUI
|
||||
# -----------------------------------------------
|
||||
add_subdirectory(lunasvg/)
|
||||
set(RMLUI_SVG_PLUGIN ON)
|
||||
add_subdirectory(RmlUI/)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user