Skip to content

Commit

Permalink
update enigne (inputs rewrite)
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Jan 31, 2024
1 parent 0bddb0d commit 296d9a1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion externals/cage
Submodule cage updated 96 files
+1 −1 data/cage/shader/engine/engine.assets
+1 −2 data/cage/shader/engine/engine.pack
+48 −0 data/cage/shader/engine/font.glsl
+4 −6 data/cage/shader/gui/font.glsl
+1 −1 externals/avir/avir
+1 −1 externals/cubeb/cubeb
+1 −1 externals/dr_libs/dr_libs
+1 −1 externals/fastnoise/fastnoise
+13 −0 externals/fetch_latest.sh
+1 −1 externals/glfw/glfw
+1 −1 externals/glm/glm
+1 −1 externals/jpeg/jpeg
+1 −1 externals/msdfgen/msdfgen
+1 −1 externals/openxr-sdk/OpenXR-SDK
+1 −1 externals/plf/plf_colony
+1 −1 externals/plf/plf_list
+1 −1 externals/plf/plf_stack
+1 −1 externals/pmp/pmp
+1 −1 externals/png/png
+1 −1 externals/samplerate/libsamplerate
+1 −1 externals/stb/stb
+1 −1 externals/tiff/tiff
+1 −1 externals/unordered_dense/unordered_dense
+1 −1 externals/utfcpp/utfcpp
+1 −1 externals/zlib-ng/zlib-ng
+1 −1 externals/zstd/zstd
+4 −4 sources/asset-processor/animation.cpp
+5 −5 sources/asset-processor/collider.cpp
+28 −28 sources/asset-processor/font.cpp
+7 −11 sources/asset-processor/main.cpp
+26 −26 sources/asset-processor/model.cpp
+0 −2 sources/asset-processor/processor.h
+5 −5 sources/asset-processor/raw.cpp
+7 −7 sources/asset-processor/shader.cpp
+2 −2 sources/asset-processor/skeleton.cpp
+14 −14 sources/asset-processor/sound.cpp
+5 −5 sources/asset-processor/textPack.cpp
+29 −29 sources/asset-processor/texture.cpp
+17 −13 sources/include/cage-core/any.h
+0 −1 sources/include/cage-core/assetManager.h
+1 −1 sources/include/cage-core/entities.h
+0 −2 sources/include/cage-core/entitiesVisitor.h
+6 −3 sources/include/cage-core/events.h
+85 −0 sources/include/cage-core/flatBag.h
+1 −3 sources/include/cage-core/flatSet.h
+3 −3 sources/include/cage-core/skeletalAnimationPreparator.h
+22 −31 sources/include/cage-core/tasks.h
+1 −1 sources/include/cage-core/typeIndex.h
+1 −0 sources/include/cage-engine/assetStructs.h
+2 −1 sources/include/cage-engine/core.h
+1 −2 sources/include/cage-engine/font.h
+4 −38 sources/include/cage-engine/guiBuilder.h
+9 −8 sources/include/cage-engine/guiComponents.h
+214 −207 sources/include/cage-engine/inputs.h
+1 −0 sources/include/cage-engine/model.h
+1 −1 sources/include/cage-engine/window.h
+1 −0 sources/include/cage-simple/engine.h
+4 −5 sources/libcore/assets/assetManager.cpp
+34 −2 sources/libcore/cage-core.natvis
+13 −57 sources/libcore/concurrent/tasks.cpp
+3 −3 sources/libcore/entities.cpp
+17 −2 sources/libcore/events.cpp
+39 −65 sources/libcore/geometry/spatialStructure.cpp
+22 −5 sources/libcore/image/dds.cpp
+3 −0 sources/libcore/mesh/importAssimp.cpp
+0 −1 sources/libcore/mesh/importConvert.cpp
+20 −18 sources/libcore/mesh/skeletalAnimation.cpp
+13 −9 sources/libcore/mesh/skeletalAnimationPreparator.cpp
+1 −0 sources/libengine/assets/model.cpp
+3 −12 sources/libengine/graphics/font.cpp
+15 −12 sources/libengine/graphics/renderPipeline.cpp
+31 −25 sources/libengine/gui/events.cpp
+8 −6 sources/libengine/gui/graphics.cpp
+16 −18 sources/libengine/gui/gui.cpp
+1 −1 sources/libengine/gui/guiBuilder.cpp
+0 −20 sources/libengine/gui/items.cpp
+15 −19 sources/libengine/gui/private.h
+13 −4 sources/libengine/gui/tooltips.cpp
+13 −7 sources/libengine/gui/widgets/input.cpp
+0 −2 sources/libengine/gui/widgets/label.cpp
+19 −13 sources/libengine/gui/widgets/spoiler.cpp
+0 −314 sources/libengine/inputs.cpp
+21 −6 sources/libengine/virtualReality/openxr.cpp
+5 −5 sources/libengine/window/gamepad.cpp
+153 −127 sources/libengine/window/window.cpp
+7 −0 sources/libsimple/externs.cpp
+22 −17 sources/libsimple/fpsCamera.cpp
+12 −12 sources/libsimple/fullscreenSwitcher.cpp
+5 −1 sources/libsimple/gameloop.cpp
+4 −4 sources/libsimple/guiInWorld.cpp
+7 −5 sources/libsimple/statisticsGui.cpp
+113 −0 sources/test-core/flatBag.cpp
+1 −0 sources/test-core/flatSet.cpp
+1 −11 sources/test-core/installConsistentPaths.cpp
+2 −0 sources/test-core/main.cpp
+3 −47 sources/test-core/tasks.cpp
7 changes: 3 additions & 4 deletions sources/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ namespace
Entity *camera;
Holder<FpsCamera> manualCamera;
AutoCamera autoCamera;
EventListener<bool(const GenericInput &)> keyPressListener;

void keyPress(InputKey in)
void keyPress(input::KeyPress in)
{
if (in.key == 32)
{
Expand All @@ -82,6 +81,8 @@ namespace
}
}

EventListener<bool(const GenericInput &)> keyPressListener = engineEvents().listen(inputFilter(keyPress));

const auto engineInitListener = controlThread().initialize.listen(
[]()
{
Expand Down Expand Up @@ -110,8 +111,6 @@ namespace
manualCamera->freeMove = true;
manualCamera->mouseButton = MouseButtonsFlags::Left;
manualCamera->movementSpeed = 3;
keyPressListener.attach(engineWindow()->events);
keyPressListener.bind(inputListener<InputClassEnum::KeyPress, InputKey>(&keyPress));
},
-200);

Expand Down
11 changes: 5 additions & 6 deletions sources/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ namespace

EventListener<bool(const GenericInput &)> guiListener;

void guiEvent(InputGuiWidget in)
void guiEvent(input::GuiValue in)
{
uint32 index = in.widget - 20;
if (index < sizeof(propertyValues) / sizeof(propertyValues[0]))
const uint32 index = in.entity->name() - 20;
if (index < array_size(propertyValues))
{
Entity *e = engineGuiEntities()->get(in.widget);
GuiInputComponent &input = e->value<GuiInputComponent>();
GuiInputComponent &input = in.entity->value<GuiInputComponent>();
if (input.valid)
*propertyValues[index] = toFloat(input.value);
}
Expand All @@ -48,7 +47,7 @@ namespace
Holder<GuiBuilder> g = newGuiBuilder(engineGuiEntities());

guiListener.attach(engineGuiManager()->widgetEvent);
guiListener.bind(inputListener<InputClassEnum::GuiWidget, InputGuiWidget>(&guiEvent));
guiListener.bind(inputFilter(guiEvent));

auto _1 = g->alignment(Vec2());
auto _2 = g->spoiler().text("Ships");
Expand Down
10 changes: 1 addition & 9 deletions sources/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@

using namespace cage;

namespace
{
void windowClose(InputWindow)
{
engineStop();
}
}

int main(int argc, const char *args[])
{
try
Expand All @@ -34,7 +26,7 @@ int main(int argc, const char *args[])
controlThread().updatePeriod(1000000 / 30);
engineAssets()->add(HashString("ants/ants.pack"));

const auto closeListener = engineWindow()->events.listen(inputListener<InputClassEnum::WindowClose, InputWindow>([](auto) { engineStop(); }));
const auto closeListener = engineWindow()->events.listen(inputFilter([](input::WindowClose) { engineStop(); }));
engineWindow()->title("space-ants");

{
Expand Down

0 comments on commit 296d9a1

Please sign in to comment.