Skip to content

Commit

Permalink
Ported some important fixes from the master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Iniquitatis committed Jun 14, 2021
1 parent ed28dcf commit ad43f54
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 24 deletions.
3 changes: 2 additions & 1 deletion Source/common/main/python-packages/comfy_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
################################################################################
import json
import os
import renpy

from zipfile import ZipFile

_game_dir = "game"
_game_dir = os.path.join(renpy.config.basedir, "game")
_meta_dir = os.path.join(_game_dir, "comfy_meta")
_config_path = os.path.join(_meta_dir, "settings.json")

Expand Down
60 changes: 53 additions & 7 deletions Source/common/theme/comfy_ui/image_scaling.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@
# See LICENSE file for the licensing information
#
################################################################################

# HACK: monkey patch for handling an image scaling/replacement
init -999 python in comfy_ui:
import os

from renpy.display.im import Image
from renpy.display.transform import Transform

def monkey_new(cls, filename = "", **properties):
has_replacement = os.path.exists(os.path.join("game", "comfy_ui", "replacers", filename))
def comfy_path(filename):
replacer_filename = "comfy_ui/replacers/%s" % filename

has_replacement = renpy.loadable(replacer_filename)
is_comfy_asset = filename.startswith("comfy_ui") or has_replacement

if has_replacement:
filename = "comfy_ui/replacers/%s" % filename
filename = replacer_filename

return filename, is_comfy_asset

# HACK: monkey patch for handling an image scaling/replacement
def monkey_new(cls, filename = "", **properties):
filename, is_comfy_asset = comfy_path(filename)

new_instance = super(Image, cls).__new__(cls, filename, **properties)
new_instance.__init__(filename, **properties)
Expand All @@ -29,3 +33,45 @@ init -999 python in comfy_ui:
return new_instance

Image.__new__ = staticmethod(monkey_new)

# HACK: monkey patch for dynamic image path interpolation
def monkey_dynamic_image(d, scope = None, prefix = None):
if not isinstance(d, list):
d = [d]

for i in d:
if not isinstance(i, basestring):
continue

if (prefix is not None) and ("[prefix_" in i):
if scope:
scope = dict(scope)
else:
scope = {}

for p in renpy.styledata.stylesets.prefix_search[prefix]:
scope["prefix_"] = p

rv = renpy.substitutions.substitute(i, scope = scope, force = True, translate = False)[0]
rv, _ = comfy_path(rv)

if renpy.loader.loadable(rv):
return renpy.easy.displayable_or_none(rv)

if renpy.exports.image_exists(rv):
return renpy.easy.displayable_or_none(rv)

else:
rv = renpy.substitutions.substitute(i, scope = scope, force = True, translate = False)[0]
rv, _ = comfy_path(rv)

if renpy.loader.loadable(rv):
return renpy.easy.displayable_or_none(rv)

if renpy.exports.image_exists(rv):
return renpy.easy.displayable_or_none(rv)

else:
return renpy.easy.displayable_or_none(d[-1], dynamic = False)

renpy.easy.dynamic_image = monkey_dynamic_image
2 changes: 1 addition & 1 deletion Source/mas/main/comfy_ui.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ init -990 python in mas_submod_utils:
author = "Dominus Iniquitatis",
name = "Comfy UI",
description = "Smooth and customizable UI add-on.",
version = "1.2.0",
version = "2.0.1",
dependencies = {},
settings_pane = "comfy_ui_mas_settings_pane",
version_updates = {}
Expand Down
21 changes: 6 additions & 15 deletions Source/mas/theme/comfy_ui/styles.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -172,33 +172,24 @@ init 999 style slot_button:
init 999 style slot_button_dark:
background "gui/button/slot_[prefix_]background_d.png"

init 999 style slot_time_text:
init 999 style slot_button_text:
idle_color comfy_ui.button_text.light.idle_color
hover_color comfy_ui.button_text.light.hover_color
selected_color comfy_ui.button_text.light.selected_color
insensitive_color comfy_ui.button_text.light.insensitive_color
outlines comfy_ui.button_text.light.outlines

init 999 style slot_time_text_dark:
init 999 style slot_button_text_dark:
idle_color comfy_ui.button_text.dark.idle_color
hover_color comfy_ui.button_text.dark.hover_color
selected_color comfy_ui.button_text.dark.selected_color
insensitive_color comfy_ui.button_text.dark.insensitive_color
outlines comfy_ui.button_text.dark.outlines

init 999 style slot_name_text:
idle_color comfy_ui.button_text.light.idle_color
hover_color comfy_ui.button_text.light.hover_color
selected_color comfy_ui.button_text.light.selected_color
insensitive_color comfy_ui.button_text.light.insensitive_color
outlines comfy_ui.button_text.light.outlines

init 999 style slot_name_text_dark:
idle_color comfy_ui.button_text.dark.idle_color
hover_color comfy_ui.button_text.dark.hover_color
selected_color comfy_ui.button_text.dark.selected_color
insensitive_color comfy_ui.button_text.dark.insensitive_color
outlines comfy_ui.button_text.dark.outlines
init 999 style slot_time_text is slot_button_text
init 999 style slot_time_text_dark is slot_button_text_dark
init 999 style slot_name_text is slot_button_text
init 999 style slot_name_text_dark is slot_button_text_dark

init 999 style page_button_text:
idle_color comfy_ui.button_text.light.idle_color
Expand Down

0 comments on commit ad43f54

Please sign in to comment.