Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Architecture #1

Open
g-tejas opened this issue Sep 13, 2024 · 1 comment
Open

Architecture #1

g-tejas opened this issue Sep 13, 2024 · 1 comment

Comments

@g-tejas
Copy link

g-tejas commented Sep 13, 2024

Are there plans to document how fenestra works and how one can get started w extending this beauty of a project? Would like to understand the event system a little better

@WerWolv
Copy link
Owner

WerWolv commented Sep 13, 2024

Hey! Absolutely yeah.
For now, the Fenestra-Template repo has some comments about how to use everything and also ImHex serves as a great example of how things work. Especially the event system is basically 1:1 identical.

The event system basically lets you define events using EVENT_DEF(EventName, ParameterType1, ParameterType2); in a header and then other code can subscribe to that event using EventName::subscribe([](auto x, auto y){ });. Then every time something calls EventName::post(1, 2);, all subscribers get executed with those parameters

EVENT_DEF(EventTest, std::string, int);

int main() {
    EventTest::subscribe([](const std::string &value1, int value2) {
        fene::log::info("First function called with '{}' and '{}'", value1, value2);
    });

    EventTest::subscribe([](const std::string &value1, int value2) {
        fene::log::info("Second function called with '{}' and '{}'", value1, value2);
    });

    EventTest::post("Hello World", 123); // Prints "First function called with 'Hello World' and '123'" and "Second function called with 'Hello World' and '123'"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants