From d6aa65cec18510ac4943aa7e3edb816e8a1e1236 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Wed, 23 Dec 2020 18:34:03 -0300 Subject: Rudimentary support for square images being fetch from remote server. --- game/03_init.rpy | 35 ++++++++++++++++++++++++++++++++--- game/gfx/square/0.png | Bin 0 -> 84957 bytes game/gfx/square/10000000.png | Bin 0 -> 222603 bytes game/gfx/square/units/0.png | Bin 84957 -> 0 bytes game/gfx/square/units/10000000.png | Bin 222603 -> 0 bytes game/inventory.rpy | 16 ++++++++++------ 6 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 game/gfx/square/0.png create mode 100644 game/gfx/square/10000000.png delete mode 100644 game/gfx/square/units/0.png delete mode 100644 game/gfx/square/units/10000000.png diff --git a/game/03_init.rpy b/game/03_init.rpy index 43e67e5..d659afa 100644 --- a/game/03_init.rpy +++ b/game/03_init.rpy @@ -49,6 +49,32 @@ init python: "sphere": %s }""" % (json.dumps(u), json.dumps(s)) + def square_composite(cid, path, ei=False): + # We need to try to get rarity + try: + r=allunits[int(cid)]["rare"] + except: + r=4 # FIXME + + # We need to try to get the element + try: + e=allunits[int(cid)]["attribute"] + except: + e=0 + + if not ei: + return Composite( + (340, 340), + (0, 0), "gfx/square/bg.png", + (0, 0), path, + (0, 0), "gfx/square/%d.png" % r) + else: + return Composite( + (340, 340), + (0, 0), "gfx/square/bg.png", + (0, 0), ExtraImage(path), + (0, 0), "gfx/square/%d.png" % r) + def card_composite(cid, path): # We need to try to get rarity try: @@ -196,7 +222,8 @@ init python: if file.startswith('gfx/square/'): if file.endswith('.png') or file.endswith('.webp'): name = "square_"+fn - renpy.image(name, Image(file, yanchor=1.0)) + #renpy.image(name, Image(file, yanchor=1.0)) + renpy.image(name, square_composite(fn, file)) dl=dl_search(persistent.allfiles, 0, name) if dl is ERR_INVALID: persistent.allfiles.append((name, file)) @@ -215,13 +242,13 @@ init python: # Overrides renpy.image() method - def new_img(name, where): + def new_img(name, where, isimage=True): # d: Downloaded path if not isinstance(name, tuple): name = tuple(name.split()) #d = renpy.renpy.easy.displayable(where) - if True or renpy.android: + if isimage: d=ExtraImage(where) else: d = renpy.renpy.easy.displayable(where) @@ -312,6 +339,8 @@ init python: # Maybe it is an unit if img.startswith("unit_"): new_img(img, card_composite(img.replace("unit_", ""), path[1])) + elif img.startswith("square_"): + new_img(img, square_composite(img.replace("square_", ""), path[1], ei=True), isimage=False) else: new_img(img, path[1]) diff --git a/game/gfx/square/0.png b/game/gfx/square/0.png new file mode 100644 index 0000000..c50dcb1 Binary files /dev/null and b/game/gfx/square/0.png differ diff --git a/game/gfx/square/10000000.png b/game/gfx/square/10000000.png new file mode 100644 index 0000000..ff8b137 Binary files /dev/null and b/game/gfx/square/10000000.png differ diff --git a/game/gfx/square/units/0.png b/game/gfx/square/units/0.png deleted file mode 100644 index c50dcb1..0000000 Binary files a/game/gfx/square/units/0.png and /dev/null differ diff --git a/game/gfx/square/units/10000000.png b/game/gfx/square/units/10000000.png deleted file mode 100644 index ff8b137..0000000 Binary files a/game/gfx/square/units/10000000.png and /dev/null differ diff --git a/game/inventory.rpy b/game/inventory.rpy index 8551079..c67b031 100644 --- a/game/inventory.rpy +++ b/game/inventory.rpy @@ -84,13 +84,17 @@ screen inventory(blank=False, filters="True"): #print str(item) #print str(alu) if evl: + python: + show_img("square_%d" % item["unit_id"], False) + try: + btn=At("square_%d" % item["unit_id"], czoom_70) + except: + btn=At("square_0", czoom_70) + traceback.print_exc() + stdout("[ERROR] ATCODE FOR square_%d is INVALID" % item["unit_id"]) + #btn=At("square_10000300", czoom_70) imagebutton: - idle At(Composite( - (340, 340), - (0, 0), "gfx/square/bg.png", - (0, 0), "gfx/square/units/%d.png" % item["unit_id"], - (0, 0), "gfx/square/%d.png" % allunits[item["unit_id"]]["rare"], - ), czoom_70) + idle btn action Return(i) #alternate "Show the char data chart" -- cgit v1.2.3-70-g09d2