Orx - Portable Game Engine
Welcome, Guest
Please Login or Register.    Lost Password?
Quiting out of Run() and Exit()
(1 viewing) 1 Guest
Go to bottom
TOPIC: Quiting out of Run() and Exit()
#8675
sausage
Moderator
Posts: 698
graphgraph
User Offline Click here to see the profile of this user
Gender: Male sausagejohnson http://waynejohnson.net Location: Near Canberra, Australia
Quiting out of Run() and Exit() 3 Months, 2 Weeks ago Karma: 3
Curious to know how to deal with the following:

While in Run() I can check a keyboard shortcut for Yes/No to see if the user wants to quit, perform some kind of tidy up, eg: save something to a file, then return orxSTATUS_FAILURE it order to trigger an exit.

Then Exit() will be hit.

But I notice that if you click the window close gadget, or (under windows) Alt-F4, then only the Exit() function is triggered.

There doesn't seem to be a way to detect a close event, allow the user to be presented with a choice to cancel the close.

It could be that Orx is not able to tie in that intimately with the parent window system?

This isn't a deal breaker but would be good to have all ways of closing an application do the same thing or to cancel a close.
 
Logged Logged
 
Indie gamedev with Orx at night. Always feel free to come and say hi over in gitter.im/orx/orx gitter chat or drop me a message.
  The administrator has disabled public write access.
#8676
iarwain
Administrator
Posts: 3114
graph
User Offline Click here to see the profile of this user
Gender: Male Orx - Portable Game Engine Location: Montreal
Re:Quiting out of Run() and Exit() 3 Months, 2 Weeks ago Karma: 71
Another way to quit is to listen to the system event orxSYSTEM_EVENT_CLOSE.
This event will be sent when the user closes the window with Alt-F4/X button. However there's no way to ignore it as GLFW handles it on its side without letting orx make a decision.
That has changed with GLFW 3.x, where the decision can be delegated to the application (in our case orx and the user).

Until then, if you need a single notification point that is not the Exit() function, you could send this event yourself from within the Run() function and set a flag somewhere when handling it (similar to what orx launcher does in orxMain.c).

I guess I could see to modify the helper to send this event when Run() returns orxSTATUS_FAILURE and it'll be the users' responsibility to make sure they don't send the event multiple times.
 
Logged Logged
 
Want to follow orx's development? Go subscribe to the orx-dev group at: https://groups.google.com/forum/?fromgroups#!forum/orx-dev
  The administrator has disabled public write access.
#8677
sausage
Moderator
Posts: 698
graphgraph
User Offline Click here to see the profile of this user
Gender: Male sausagejohnson http://waynejohnson.net Location: Near Canberra, Australia
Re:Quiting out of Run() and Exit() 3 Months, 2 Weeks ago Karma: 3
I think for now, the autosave function I have can sit in Exit() so that it works no matter how you quit.

But for now the user can only get the "Are you sure you want to quit?" dialog if they use the keyboard shortcut to exit.

(That was an easier explanation )

This will be fine for now, I'll wait to try out GLFW 3.
 
Logged Logged
 
Indie gamedev with Orx at night. Always feel free to come and say hi over in gitter.im/orx/orx gitter chat or drop me a message.
  The administrator has disabled public write access.
Go to top