From 5a8e4d85abec58faabe086170d4bb518e93e306c Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Fri, 24 Mar 2023 19:16:22 +0000 Subject: [PATCH] Image cache preference * Added image cache size preference * Increased default image cache size 300MB-> 512MB * Fixed get_gpu_info function to encode bytes to string before joining * Fixed missing bar images --- game/scripts/gui/_images_.rpy | 2 + game/scripts/gui/preferences.rpy | 97 +++++++++++++++++-------------- game/scripts/options.rpy | 5 ++ game/scripts/utility/devtools.rpy | 2 +- 4 files changed, 61 insertions(+), 45 deletions(-) diff --git a/game/scripts/gui/_images_.rpy b/game/scripts/gui/_images_.rpy index 6b8ed217..525d3b65 100644 --- a/game/scripts/gui/_images_.rpy +++ b/game/scripts/gui/_images_.rpy @@ -204,6 +204,8 @@ image light_slider_full = "gui/slider/light_full.png" image scrollbar_horizontal_idle_thumb = "gui/scrollbar/vertical_idle_bar.png" #Solid(gui.accent_color) image scrollbar_horizontal_hover_thumb = image_hover("gui/scrollbar/vertical_idle_bar.png") #Solid(gui.hover_color) image scrollbar_horizontal_insensitive_thumb = "scrollbar_horizontal_idle_thumb" +image scrollbar_horizontal_selected_insensitive_thumb = "scrollbar_horizontal_idle_thumb" +image scrollbar_horizontal_selected_idle_thumb = "gui/scrollbar/vertical_idle_bar.png" image scrollbar_horizontal_selected_hover_thumb = "scrollbar_horizontal_hover_thumb" image scrollbar_horizontal_idle_bar = Solid(gui.muted_color) image scrollbar_horizontal_selected_idle_bar = "scrollbar_horizontal_idle_bar" diff --git a/game/scripts/gui/preferences.rpy b/game/scripts/gui/preferences.rpy index 7155b208..5385f23a 100644 --- a/game/scripts/gui/preferences.rpy +++ b/game/scripts/gui/preferences.rpy @@ -111,64 +111,73 @@ screen preferences_general(): style_prefix gui.theme("check") screen preferences_visuals(): - hbox: - box_wrap True + vbox: + hbox: + box_wrap True - if renpy.variant("pc") or renpy.variant("web"): - vbox: - style_prefix gui.theme("radio") - label _("Display") - textbutton _("Fullscreen") action Preference("display", "fullscreen") - textbutton _("Windowed") action Preference("display", "any window") - textbutton _("V-Sync") action [ InvertSelected(ToggleField(_preferences, "gl_tearing")), _DisplayReset() ] style gui.theme("check_button") + if renpy.variant("pc") or renpy.variant("web"): + vbox: + style_prefix gui.theme("radio") + label _("Display") + textbutton _("Fullscreen") action Preference("display", "fullscreen") + textbutton _("Windowed") action Preference("display", "any window") + textbutton _("V-Sync") action [ InvertSelected(ToggleField(_preferences, "gl_tearing")), _DisplayReset() ] style gui.theme("check_button") - # Probably redundant now that we have aspect ratio preservation. - # if not preferences.fullscreen: - # textbutton _("Reset window"): - # action Preference("display", "window") - # sensitive (renpy.get_physical_size() != (config.screen_width, config.screen_height)) + # Probably redundant now that we have aspect ratio preservation. + # if not preferences.fullscreen: + # textbutton _("Reset window"): + # action Preference("display", "window") + # sensitive (renpy.get_physical_size() != (config.screen_width, config.screen_height)) - vbox: - style_prefix gui.theme("radio") - - default fps_msg = "Framerate preference may take effect after restarting the game" - - label "Framerate" - - textbutton ("{} fps".format(int(renpy.get_refresh_rate()))) action [Preference("gl framerate", None), Notify(fps_msg)] - if renpy.get_refresh_rate() > 60: - textbutton "60 fps" action [Preference("gl framerate", 60), Notify(fps_msg)] - textbutton "30 fps" action [Preference("gl framerate", 30), Notify(fps_msg)] - - if not renpy.mobile: vbox: style_prefix gui.theme("radio") - label "Renderer" + default fps_msg = "Framerate preference may take effect after restarting the game" - default renderer_used = renpy.get_renderer_info()["renderer"] + label "Framerate" - textbutton _("OpenGL"): - selected renderer_used == "gl2" - action Confirm("Changing renderer requires a full restart, do it now?\nUnsaved progress will be lost.", Function(set_renderer, "gl2")) - textbutton _("DirectX"): - sensitive renpy.windows - selected renderer_used == "angle2" - action Confirm("Changing renderer requires a full restart, do it now?\nUnsaved progress will be lost.", Function(set_renderer, "angle2")) + textbutton ("{} fps".format(int(renpy.get_refresh_rate()))) action [Preference("gl framerate", None), Notify(fps_msg)] + if renpy.get_refresh_rate() > 60: + textbutton "60 fps" action [Preference("gl framerate", 60), Notify(fps_msg)] + textbutton "30 fps" action [Preference("gl framerate", 30), Notify(fps_msg)] + + if not renpy.mobile: + vbox: + style_prefix gui.theme("radio") + + label _("Renderer") + + default renderer_used = renpy.get_renderer_info()["renderer"] + + textbutton _("OpenGL"): + selected renderer_used == "gl2" + action Confirm("Changing renderer requires a full restart, do it now?\nUnsaved progress will be lost.", Function(set_renderer, "gl2")) + textbutton _("DirectX"): + sensitive renpy.windows + selected renderer_used == "angle2" + action Confirm("Changing renderer requires a full restart, do it now?\nUnsaved progress will be lost.", Function(set_renderer, "angle2")) + + vbox: + style_prefix gui.theme("check") + + label "Advanced" + + textbutton _("Transitions") action Preference("transitions", "toggle") + textbutton _("Videos") action InvertSelected(Preference("video sprites", "toggle")) + textbutton _("Power-saving") action Preference("gl powersave", "toggle") + #if not renpy.mobile: + #textbutton _("Preserve Aspect Ratio") action [settings.Toggle("preserve_aspect_ratio"), _DisplayReset()] vbox: - style_prefix gui.theme("check") + style_prefix gui.theme("slider") - label "Advanced" + label _("Image cache ([persistent.custom_settings[image_cache_size]]MB)") - textbutton _("Transitions") action Preference("transitions", "toggle") - textbutton _("Videos") action InvertSelected(Preference("video sprites", "toggle")) - textbutton _("Power-saving") action Preference("gl powersave", "toggle") - #if not renpy.mobile: - #textbutton _("Preserve Aspect Ratio") action [settings.Toggle("preserve_aspect_ratio"), _DisplayReset()] + hbox: + bar value DictValue(persistent.custom_settings, "image_cache_size", range=1792, max_is_zero=False, style="slider", offset=256, step=128, force_step=True, action=Notify("Restart the game to apply image cache size changes.")) tooltip "Improves performance at a cost of higher memory usage." - text get_gpu_info() yalign 1.0 size 10 + text get_gpu_info() yalign 1.0 size 10 screen preferences_sound(): hbox: diff --git a/game/scripts/options.rpy b/game/scripts/options.rpy index 01b8712e..d37c98df 100644 --- a/game/scripts/options.rpy +++ b/game/scripts/options.rpy @@ -20,6 +20,7 @@ init python: settings.default("preserve_aspect_ratio", True) settings.default("animations", True) settings.default("updates", True) + settings.default("image_cache_size", 512) renpy.music.register_channel("background", "sfx", True) renpy.music.register_channel("sound2", "sfx", True) @@ -121,6 +122,10 @@ define config.say_attribute_transition = d3 # Python define config.open_file_encoding = "utf-8" +define config.image_cache_size_mb = settings.get("image_cache_size") + +# Debug +# define config.profile = True # Garbage Collector # define config.manage_gc = True diff --git a/game/scripts/utility/devtools.rpy b/game/scripts/utility/devtools.rpy index c4772885..a5c5e98f 100644 --- a/game/scripts/utility/devtools.rpy +++ b/game/scripts/utility/devtools.rpy @@ -6,7 +6,7 @@ init -999 python early: def get_gpu_info(): try: - info = "\n".join([glGetString(GL_VENDOR), glGetString(GL_RENDERER), glGetString(GL_VERSION)]) + info = "\n".join([glGetString(GL_VENDOR).decode("utf-8"), glGetString(GL_RENDERER).decode("utf-8"), glGetString(GL_VERSION).decode("utf-8")]) except: info = "ERR: Unknown or incompatible driver." return info