Hello everyone,After several months of development (and several episodes), I announce the release of the open-source library
Zeven.
I'm Thiziri, main coder of the project, and I must thank Danman (a Zinlibs team member) for his help throughout this work, without nothing would have been possible. Thank you buddy.
My thanks also to Lolo (great programmer
) for the advice and SFML, who seems well on the way to dethrone SDL in the months to come.
Please, forgive me if I don't write english very good, this is not my native langage (I'm french). :oops:
- But in fact, what is Zeven ? :?:
Well,
Zeven is an extensible library (based on sigc++), which allow the use of behaviors, triggers and listeners to organize the way events are managed and set some actions in return.
- But, in a simply way ? :oops:
Basically this allows you to assign a behavior to an object, for example, that certain actions are automatically launched when the behavior or a part of the behavior is satisfied.
- Zeven, Why ? :?:
Zeven was born because we needed (the team responsible for the Zinlibs API) to process the events returned by any windowing API / GUI, in a simply way, ergonomic, programmable and modern. In addition,
Zeven is modular, allowing you to use modules for each situation. The module allows for example SFML to treat sf::Events, and has many dedicated Auditors and Triggers thoose make your life easier. In addition,
Zeven is a contraction of the words Zinlibs and Events.
- What are Listeners and Triggers ? :shock:
Listeners are the smallest elements of
Zeven. They are responsible for listening to the event which they are sensitive and initiate action previously defined if they "hear" this particulary event.
Triggers are larger items, they are composed of two or more listeners to manage complex networks (the programmable side of
Zeven).
Note that the behavior can manage a complex network (of triggers) too.
- How does the return-actions system work ? :roll:
We think the signals and slots are a necessary evolution in
Zeven, so we chose the library sigc++, which is very easy to use, to assign functions (or methods) to each behavior.
- A little piece of code to have an idea of how operate Zeven ? :twisted:
A tutorial is being written on the wiki SFML, and the sample provided on the
SVN repository (GIT soon) allow you to better understand the mechanisms, but here for you (beloved community) an overview of what you can do with
Zeven (and especially its sfZeven module) :
// Creation of the event handler :
zin::sfEventHandler& EventHandler = zin::sfEventHandler::GetInstance();
// Creation of a behavior :
zin::Behavior behavior;
// Creation of some pre-programmed triggers :
zin::sfDoubleClickTrigger trigger1;
zin::sfDragAndDropTrigger trigger2;
// Creation of a custom trigger :
zin::sfTrigger trigger3;
// Creation of some listeners :
zin::sfTextEnteredListener listener1(sf::Key::Code::Space);
zin::sfTimeReachedListener listener2(3.54);
// Connection of the listener to the trigger's input :
trigger3.SetInput(listener1);
// Connection of the listener to the triggers's output :
trigger3.SetOutput(listener2);
// Connection of the both listeners each-other (to form a gateway) :
listener1.ConnectTo(listener2); // Note that you can connect as listener as you want !
// Connection of a function to one of the listeners :
listener2.ConnectTo(sigc::ptr_fun(&HelloWorld));
// Creation an area of action :
sf::FloatRect(20, 20, 80, 80) area;
// Settings of the action's area of the triggers :
trigger1.SetArea(area);
trigger2.SetArea(area);
// Connection of the behavior to a trigger :
behavior.ConnectTo(trigger1);
// Connection between the both (to create a chronology) :
trigger1.ConnectTo(trigger2);
// Connection of a function to a pre-programmed trigger :
trigger2.OnRelease(sigc::hide(sigc::ptr_fun(&ExitProgram));
// Register of the triggers by the event handler :
EventHandler.Register(trigger1);
EventHandler.Register(trigger2);
EventHandler.Register(trigger3);
// Creation of a carry event :
sf::Event event;
while( App.GetEvent(event) )
{
// Add an SFML event in the event handler :
EventHandler.Recept(event);
...
}
// Update of the behavior :
behavior.Update(events);
- The final word? :idea:
What is the worst first name that you know in English? (in french, certainly Gertrude) !
No, seriously, your feedbacks are very welcome (if you have), suggestions, ideas for improvement, and issue various modules (in example if you have problems to compile with cmake); I will answer you with pleasure (and Danman).
I hope you will enjoy
Zeven; and wish you good luck for all your projects !