Hello.
So this is my situation. Previously I had this (pretty standard) :
int main (int argc, char **argv) {
Big_Drawable BD_1;
Big_Drawable BD_2;
...
Big_Drawable BD_n; // n is pretty large !
while (window.isOpen()) {
while (window.pollEvent (event) {
switch (event) {
case Event::MouseButtonPressed:
// Do tons of stuff with BD_n and thounsands of other local variables.
// etc..
}
}
}
}
This is perfect.
Now : I want to include another feature. This app should receive signals not only from the OS, but also from other computers (let's say from the network).
I have somthing like this :
void clickedCallback () {
// Here I want to do exactly the same stuff
// as in the MouseButtonPressed.
// But it's large code with huge amount of variables
// That I can't easily put in an external function
}
// ... other callbacks for keyboards etc...
int main (int argc, char **argv) {
Big_Drawable BD_1;
Big_Drawable BD_2;
...
Big_Drawable BD_n; // n is pretty large !
RegisterCallback (clickedCallback);
while (window.isOpen()) {
while (listenToNetwork()); // Listen and call the callbacks when necessary
while (window.pollEvent (event) {
switch (event) {
case Event::MouseButtonPressed:
// Do tons of stuff with BD_n and thounsands of other local variables.
// etc..
}
}
}
}
So I really would enjoy doing just this :
void clickedCallback () {
// Here I want to do exactly the same stuff
// as in the MouseButtonPressed.
// But it's large code with huge amount of variables
// That I can't easily put in an external function
Event event;
event.type = Event::MouseButtonPressed;
window.pushEvent (event); // <---- Yupi!
}
And that's it !
Instead, I have to put all the code in external functions, with tons and tons of parameters to get all my datas.