Mobile: perfom operations when the app lost focus [SOLVED]

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Jibus
Regular
Posts: 135
Joined: Tue May 26, 2015 9:45 am
Contact:

Mobile: perfom operations when the app lost focus [SOLVED]

#1 Post by Jibus »

Is it possible de perfom operations when the app lost focus on mobile phone ?
Last edited by Jibus on Wed Oct 19, 2016 3:51 am, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Mobile: perfom operations when the app lost focus

#2 Post by PyTom »

What sort of operation? There generally isn't time to do anything other than save the state when the application loses focus on mobile.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Jibus
Regular
Posts: 135
Joined: Tue May 26, 2015 9:45 am
Contact:

Re: Mobile: perfom operations when the app lost focus

#3 Post by Jibus »

I would like to connect to a server in order to update some data.

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Mobile: perfom operations when the app lost focus

#4 Post by PyTom »

You can take a look at check_suspend in renpy/display/core.py, and hook in before the second save on line 2297. There's no guarantees it will work - once the power button is pushed, the app is supposed to get to sleep ASAP, and contacting a server seems the opposite of that.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Jibus
Regular
Posts: 135
Joined: Tue May 26, 2015 9:45 am
Contact:

Re: Mobile: perfom operations when the app lost focus

#5 Post by Jibus »

Ok, thank you ! I am not a huge fan of changing core file but I will have a look !

Post Reply

Who is online

Users browsing this forum: No registered users