mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-05 03:15:07 -04:00
support hooks on user exit
This commit is contained in:
parent
8d21735bf4
commit
4328dd4f63
@ -59,6 +59,10 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
self.wantDIRECT = self.config.GetBool('want-directtools', 0)
|
self.wantDIRECT = self.config.GetBool('want-directtools', 0)
|
||||||
self.wantStats = self.config.GetBool('want-stats', 0)
|
self.wantStats = self.config.GetBool('want-stats', 0)
|
||||||
|
|
||||||
|
# Fill this in with a function to invoke when the user "exits"
|
||||||
|
# the program by closing the main window.
|
||||||
|
self.exitFunc = None
|
||||||
|
|
||||||
taskMgr.taskTimerVerbose = self.config.GetBool('task-timer-verbose', 0)
|
taskMgr.taskTimerVerbose = self.config.GetBool('task-timer-verbose', 0)
|
||||||
taskMgr.extendedExceptions = self.config.GetBool('extended-exceptions', 0)
|
taskMgr.extendedExceptions = self.config.GetBool('extended-exceptions', 0)
|
||||||
|
|
||||||
@ -1061,8 +1065,8 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
if win == self.win:
|
if win == self.win:
|
||||||
if not properties.getOpen():
|
if not properties.getOpen():
|
||||||
# If the user closes the main window, we should exit.
|
# If the user closes the main window, we should exit.
|
||||||
self.notify.info("User closed main window, exiting.")
|
self.notify.info("User closed main window.")
|
||||||
sys.exit()
|
self.userExit()
|
||||||
|
|
||||||
if properties.getMinimized() and not self.mainWinMinimized:
|
if properties.getMinimized() and not self.mainWinMinimized:
|
||||||
# If the main window is minimized, throw an event to
|
# If the main window is minimized, throw an event to
|
||||||
@ -1076,6 +1080,12 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
self.mainWinMinimized = 0
|
self.mainWinMinimized = 0
|
||||||
messenger.send('PandaRestarted')
|
messenger.send('PandaRestarted')
|
||||||
|
|
||||||
|
def userExit(self):
|
||||||
|
# The user has requested we exit the program. Deal with this.
|
||||||
|
if self.exitFunc:
|
||||||
|
self.exitFunc()
|
||||||
|
self.notify.info("Exiting ShowBase.")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.taskMgr.run()
|
self.taskMgr.run()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user