[SOLVED]Reset physical size problem on Android/Ios for Ren'py 7.4.0

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
User avatar
birctreel
Regular
Posts: 53
Joined: Wed Dec 20, 2017 7:17 am
Projects: Knell of st.Godhrkar
Organization: -Andinomie-
Tumblr: birctreel
Location: Beijing, China
Contact:

[SOLVED]Reset physical size problem on Android/Ios for Ren'py 7.4.0

#1 Post by birctreel »

Hello everyone! I just update my renpy to 7.4.0, and notice there are a little difference (or problem) when I launch my game on renpy 7.3.5/7.4.0: reset physical size didn't work (or it works different from 7.3.5)
As we know, the mobile devices' ratio are different, mostly is 16:9 or 21:9. To fit this two ratio, I made a system to toggle the display reatio between 1920x1080 and 1920x900, by using gui.rebuild and reset physical size on renpy 7.3.5. The code would be like:

Code: Select all

init python:
    def screenheight():
        if persistent.displayss==1:#if player chooses 16:9
            config.screen_height=1080#adjust the height to 1080, so the size would be 1920x1080
            gui.ratio=1.0#I define this variable to adjust the position of all the items in my screen
            gui.rebuild
            renpy.reset_physical_size()#adjust the physical size
            preferences.fullscreen = True
            renpy.force_full_redraw
        else:#if the play choose 21:9
            config.screen_height=900#adjust the height to 900, so the size would be 1920x900
            renpy.reset_physical_size()
            gui.ratio=0.5
            gui.rebuild
            preferences.fullscreen = True
            renpy.force_full_redraw
So, if players choose 16:9, it would be like:
Image
if players choose 21:9, it would be like:
Image


However, this reset physical size didn't work like above in renpy 7.4.0.
In renpy 7.4.0, if I set gui(1920,1080), it would be always in this physical size. The code is the same, but here is the difference when I launch 16:9 and 21:9
In 16:9, it works just as above.
Image

but in 21:9, it would be like:
Image
Which you can see, the physical size is still 1920x1080(16:9), the only thing adjusted is the position of every object.


(and plus, I don't know why but for some reasons perference.fullscreen also didn't work well: even the code I only set "preferences.fullscreen=True", it works like toggling from False to True, like the first click = False, and second =True.

Is there any way the physical size can be adjust as renpy 7.3.5?

I hope I explain my problem well. If not, I'm happy to share some videos to show the difference of the same code work on renpy 7.3.5 and renpy 7.4.0.

Thank you very much for reading! Hope we can solve this problem together :D
Last edited by birctreel on Wed Jan 20, 2021 8:39 am, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: Reset physical size problem on Android/Ios for Ren'py 7.4.0

#2 Post by PyTom »

Changing config variables after Ren'Py starts isn't supported.
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

User avatar
birctreel
Regular
Posts: 53
Joined: Wed Dec 20, 2017 7:17 am
Projects: Knell of st.Godhrkar
Organization: -Andinomie-
Tumblr: birctreel
Location: Beijing, China
Contact:

Re: Reset physical size problem on Android/Ios for Ren'py 7.4.0

#3 Post by birctreel »

PyTom wrote: Wed Jan 20, 2021 12:47 am Changing config variables after Ren'Py starts isn't supported.
Thank you very much for answering!
So if I want to change physical size, I must restart the game, right?
Like write these in my gui.rpy and then restart:

Code: Select all

init python:
    if persistent.displayss==1:#if player chooses 16:9
        gui.init(1920, 1080)
    else:
        gui.init(1920,900)

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: Reset physical size problem on Android/Ios for Ren'py 7.4.0

#4 Post by PyTom »

Correct, you'd need to do 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

User avatar
birctreel
Regular
Posts: 53
Joined: Wed Dec 20, 2017 7:17 am
Projects: Knell of st.Godhrkar
Organization: -Andinomie-
Tumblr: birctreel
Location: Beijing, China
Contact:

Re: Reset physical size problem on Android/Ios for Ren'py 7.4.0

#5 Post by birctreel »

Thanks to my friend, I now figure out a way to adjust the ratio before the game start:
by using pygame.display.list_modes() to get the physical width and height.
Since my game is auto set the width=1920, adjusting the ratio by different height, so it would be like:

set:
t= pygame.display.list_modes()
so physical width= t[0][0], physical height=t[0][1]
and real width=1920, to count height,
real height = t[0][1]*1920/t[0][0].
And that's what I need to count in gui.init(real width,real height).

Just like below:

Code: Select all

init python:
    import pygame
    pygame.init()
    t = pygame.display.list_modes()
    gui.init(1920,int(t[0][1]*1920/t[0][0]))
On the other hand, I can get the real ratio by t[0][0]/t[0][1] too!

Post Reply

Who is online

Users browsing this forum: No registered users