Code Monkey home page Code Monkey logo

ultraengine-widget-event-system's Introduction

UltraEngine Widget Event System

Ultra Engine Event System is a powerful event handling library designed for the Ultra Engine. It introduces the ability to use lambdas instead of traditional function pointers, making event handling in your Ultra Engine projects more flexible and expressive.

Getting Started

To integrate the Ultra Engine Event System into your project, follow these simple steps:

  1. Clone the repository:
git clone https://github.com/Andy16823/UltraEngine-Widget-Event-System.git
  1. Initialize the event handler:
g_eventHandler = UIEventHandler::CreateUIEventHandler();
  1. Integrate the event handling loop into your main loop:
while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
{
    while (PeekEvent())
    {
        const Event ev = WaitEvent();
        g_eventHandler->ProcessEvent(g_ui->GetInterface(), ev);
    }
    g_world->Update();
    g_world->Render(framebuffer);

    #ifdef STEAM_API_H
        Steamworks::Update();
    #endif
}

Example Usage

Here's an example demonstrating how to use the Ultra Engine Event System to create a main UI with buttons:

void CreateMainUI(shared_ptr<Framebuffer> framebuffer) {
    g_mainUI = CreatePanel(0, 0, framebuffer->size.width, framebuffer->size.height, g_ui->GetInterface()->root);
    g_mainUI->SetColor(Vec4(0, 0, 0, 0));

    auto btn = CreateButton("Start Game", 15, 15, 150, 30, g_mainUI);
    g_eventHandler->AddEvent(UIEvent::CreateUIEvent(btn, [](shared_ptr<Widget> widget, Event e) {
        g_scene = LoadMap(g_world, "maps/start.ultra");
        g_mainUI->SetHidden(true);
    }));

    auto mpBtn = CreateButton("Multiplayer", 15, 55, 150, 30, g_mainUI);
    g_eventHandler->AddEvent(UIEvent::CreateUIEvent(mpBtn, [](shared_ptr<Widget> widget, Event e) {
        Print("Start Multiplayer");
    }));
}

License

This project is licensed under the MIT License - see the LICENSE file for details. Feel free to customize and enhance the Ultra Engine Event System to suit your project's needs. If you encounter any issues or have suggestions for improvement, please open an issue.

Happy coding!

ultraengine-widget-event-system's People

Contributors

andy16823 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.