From f750eeced6dfce36a6d6fd2483807d84b3018381 Mon Sep 17 00:00:00 2001 From: oier Date: Fri, 25 Aug 2023 20:07:31 +0200 Subject: [PATCH] more item things --- ...ol_inventario.esc => turno_cocina_bol.esc} | 0 ..._inventario.tscn => turno_cocina_bol.tscn} | 6 +- .../items/inventory/turno_cocina_peso.tscn | 16 ++-- .../turno_cocina_peso_bol_inventario.esc | 6 -- .../turno_cocina_peso_bol_inventario.tscn | 34 ------- .../turno_cocina_peso_inventario.esc | 6 -- .../turno_cocina_peso_inventario.tscn | 34 ------- .../rooms/trasera_cocina/trasera_cocina.tscn | 7 +- scripts/generate-items.py | 92 +++++++++++-------- 9 files changed, 72 insertions(+), 129 deletions(-) rename gymkhana/items/inventory/{turno_cocina_bol_inventario.esc => turno_cocina_bol.esc} (100%) rename gymkhana/items/inventory/{turno_cocina_bol_inventario.tscn => turno_cocina_bol.tscn} (85%) delete mode 100644 gymkhana/items/inventory/turno_cocina_peso_bol_inventario.esc delete mode 100644 gymkhana/items/inventory/turno_cocina_peso_bol_inventario.tscn delete mode 100644 gymkhana/items/inventory/turno_cocina_peso_inventario.esc delete mode 100644 gymkhana/items/inventory/turno_cocina_peso_inventario.tscn diff --git a/gymkhana/items/inventory/turno_cocina_bol_inventario.esc b/gymkhana/items/inventory/turno_cocina_bol.esc similarity index 100% rename from gymkhana/items/inventory/turno_cocina_bol_inventario.esc rename to gymkhana/items/inventory/turno_cocina_bol.esc diff --git a/gymkhana/items/inventory/turno_cocina_bol_inventario.tscn b/gymkhana/items/inventory/turno_cocina_bol.tscn similarity index 85% rename from gymkhana/items/inventory/turno_cocina_bol_inventario.tscn rename to gymkhana/items/inventory/turno_cocina_bol.tscn index ff35e0d9..17a7ee3a 100644 --- a/gymkhana/items/inventory/turno_cocina_bol_inventario.tscn +++ b/gymkhana/items/inventory/turno_cocina_bol.tscn @@ -7,11 +7,11 @@ [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 22.5, 12.5 ) -[node name="turno_cocina_bol_inventario" type="Area2D"] +[node name="turno_cocina_bol" type="Area2D"] pause_mode = 1 script = ExtResource( 1 ) -global_id = "turno_cocina_bol_inventario" -esc_script = "res://gymkhana/items/inventory/turno_cocina_bol_inventario.esc" +global_id = "turno_cocina_bol" +esc_script = "res://gymkhana/items/inventory/turno_cocina_bol.esc" inventory_texture = ExtResource( 2 ) dialog_color = Color( 1, 1, 1, 1 ) action1_text = "¿Que es esto?" diff --git a/gymkhana/items/inventory/turno_cocina_peso.tscn b/gymkhana/items/inventory/turno_cocina_peso.tscn index a280f719..677c4f03 100644 --- a/gymkhana/items/inventory/turno_cocina_peso.tscn +++ b/gymkhana/items/inventory/turno_cocina_peso.tscn @@ -2,17 +2,16 @@ [ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/esc_item_with_tooltip.gd" type="Script" id=1] [ext_resource path="res://gymkhana/items/inventory/assets/turno_cocina_peso.png" type="Texture" id=2] -[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=3] - -[sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 22.5, 12.5 ) +[ext_resource path="res://gymkhana/items/inventory/assets/turno_cocina_peso_inventario.png" type="Texture" id=3] +[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=4] [node name="turno_cocina_peso" type="Area2D"] pause_mode = 1 script = ExtResource( 1 ) global_id = "turno_cocina_peso" esc_script = "res://gymkhana/items/inventory/turno_cocina_peso.esc" -inventory_texture = ExtResource( 2 ) +combine_when_selected_action_is_in = [ ] +inventory_texture = ExtResource( 3 ) dialog_color = Color( 1, 1, 1, 1 ) action1_text = "¿Que es esto?" action2_text = "Coger" @@ -25,10 +24,9 @@ position = Vector2( -2, 0 ) scale = Vector2( 0.5, 0.5 ) texture = ExtResource( 2 ) -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2( -1.5, -0.5 ) -shape = SubResource( 1 ) +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +polygon = PoolVector2Array( -21, -20, -19, -20, -19, -23, -17, -24, 19, -22, 20, -18, 22, -18, 23, -16, 23, -10, 22, 23, 19, 25, -25, 22, -23, -18 ) [node name="ESCLocation" type="Position2D" parent="."] position = Vector2( -51, 69 ) -script = ExtResource( 3 ) \ No newline at end of file +script = ExtResource( 4 ) diff --git a/gymkhana/items/inventory/turno_cocina_peso_bol_inventario.esc b/gymkhana/items/inventory/turno_cocina_peso_bol_inventario.esc deleted file mode 100644 index db47f32c..00000000 --- a/gymkhana/items/inventory/turno_cocina_peso_bol_inventario.esc +++ /dev/null @@ -1,6 +0,0 @@ -:action1 -say player "Que cosa tan curiosa" - -:action2 -say player "No lo quiero coger" - diff --git a/gymkhana/items/inventory/turno_cocina_peso_bol_inventario.tscn b/gymkhana/items/inventory/turno_cocina_peso_bol_inventario.tscn deleted file mode 100644 index a3ed9d61..00000000 --- a/gymkhana/items/inventory/turno_cocina_peso_bol_inventario.tscn +++ /dev/null @@ -1,34 +0,0 @@ -[gd_scene load_steps=5 format=2] - -[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/esc_item_with_tooltip.gd" type="Script" id=1] -[ext_resource path="res://gymkhana/items/inventory/assets/turno_cocina_peso_bol_inventario.png" type="Texture" id=2] -[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=3] - -[sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 22.5, 12.5 ) - -[node name="turno_cocina_peso_bol_inventario" type="Area2D"] -pause_mode = 1 -script = ExtResource( 1 ) -global_id = "turno_cocina_peso_bol_inventario" -esc_script = "res://gymkhana/items/inventory/turno_cocina_peso_bol_inventario.esc" -inventory_texture = ExtResource( 2 ) -dialog_color = Color( 1, 1, 1, 1 ) -action1_text = "¿Que es esto?" -action2_text = "Coger" -action3_text = "Mirar" -action4_text = "Usar" -animations = null - -[node name="Sprite" type="Sprite" parent="."] -position = Vector2( -2, 0 ) -scale = Vector2( 0.5, 0.5 ) -texture = ExtResource( 2 ) - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2( -1.5, -0.5 ) -shape = SubResource( 1 ) - -[node name="ESCLocation" type="Position2D" parent="."] -position = Vector2( -51, 69 ) -script = ExtResource( 3 ) \ No newline at end of file diff --git a/gymkhana/items/inventory/turno_cocina_peso_inventario.esc b/gymkhana/items/inventory/turno_cocina_peso_inventario.esc deleted file mode 100644 index db47f32c..00000000 --- a/gymkhana/items/inventory/turno_cocina_peso_inventario.esc +++ /dev/null @@ -1,6 +0,0 @@ -:action1 -say player "Que cosa tan curiosa" - -:action2 -say player "No lo quiero coger" - diff --git a/gymkhana/items/inventory/turno_cocina_peso_inventario.tscn b/gymkhana/items/inventory/turno_cocina_peso_inventario.tscn deleted file mode 100644 index 94714266..00000000 --- a/gymkhana/items/inventory/turno_cocina_peso_inventario.tscn +++ /dev/null @@ -1,34 +0,0 @@ -[gd_scene load_steps=5 format=2] - -[ext_resource path="res://gymkhana/addons/escoria-ui-return-monkey-island/esc_item_with_tooltip.gd" type="Script" id=1] -[ext_resource path="res://gymkhana/items/inventory/assets/turno_cocina_peso_inventario.png" type="Texture" id=2] -[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=3] - -[sub_resource type="RectangleShape2D" id=1] -extents = Vector2( 22.5, 12.5 ) - -[node name="turno_cocina_peso_inventario" type="Area2D"] -pause_mode = 1 -script = ExtResource( 1 ) -global_id = "turno_cocina_peso_inventario" -esc_script = "res://gymkhana/items/inventory/turno_cocina_peso_inventario.esc" -inventory_texture = ExtResource( 2 ) -dialog_color = Color( 1, 1, 1, 1 ) -action1_text = "¿Que es esto?" -action2_text = "Coger" -action3_text = "Mirar" -action4_text = "Usar" -animations = null - -[node name="Sprite" type="Sprite" parent="."] -position = Vector2( -2, 0 ) -scale = Vector2( 0.5, 0.5 ) -texture = ExtResource( 2 ) - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2( -1.5, -0.5 ) -shape = SubResource( 1 ) - -[node name="ESCLocation" type="Position2D" parent="."] -position = Vector2( -51, 69 ) -script = ExtResource( 3 ) \ No newline at end of file diff --git a/gymkhana/rooms/trasera_cocina/trasera_cocina.tscn b/gymkhana/rooms/trasera_cocina/trasera_cocina.tscn index cf99ccda..7951ec87 100644 --- a/gymkhana/rooms/trasera_cocina/trasera_cocina.tscn +++ b/gymkhana/rooms/trasera_cocina/trasera_cocina.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=18 format=2] +[gd_scene load_steps=19 format=2] [ext_resource path="res://addons/escoria-core/game/core-scripts/esc_room.gd" type="Script" id=1] [ext_resource path="res://addons/escoria-core/game/core-scripts/esc_background.gd" type="Script" id=2] @@ -7,6 +7,7 @@ [ext_resource path="res://addons/escoria-core/game/core-scripts/resources/esc_animationresource.gd" type="Script" id=5] [ext_resource path="res://gymkhana/rooms/trasera_cocina/assets/background trasera cocina-1500x577-noItems.jpg" type="Texture" id=6] [ext_resource path="res://gymkhana/characters/oier/oier.tscn" type="PackedScene" id=7] +[ext_resource path="res://gymkhana/items/inventory/turno_cocina_bol_inventario.tscn" type="PackedScene" id=8] [ext_resource path="res://gymkhana/rooms/trasera_cocina/assets/columna.png" type="Texture" id=25] [ext_resource path="res://gymkhana/rooms/trasera_cocina/assets/background trasera cocina-pix-height.png" type="Texture" id=26] [ext_resource path="res://gymkhana/items/inventory/bombona.tscn" type="PackedScene" id=27] @@ -147,3 +148,7 @@ position = Vector2( 507, 522 ) position = Vector2( -51, 69 ) script = ExtResource( 3 ) global_id = "caja_herramientas" + +[node name="turno_cocina_bol_inventario" parent="." instance=ExtResource( 8 )] +position = Vector2( 343, 479 ) +combine_when_selected_action_is_in = [ ] diff --git a/scripts/generate-items.py b/scripts/generate-items.py index 55c74a61..828a5bb8 100755 --- a/scripts/generate-items.py +++ b/scripts/generate-items.py @@ -15,8 +15,6 @@ class bcolors: BOLD = '\033[1m' UNDERLINE = '\033[4m' -def printHelp(): - print ('./generate-items -i -o -p ') overWrite=False @@ -30,6 +28,61 @@ inputDir = params[1] outputDir = params[2] itemPrefix = params[3] +def printHelp(): + print ('./generate-items -i -o -p ') + +def generateItem(inputFile): + baseName = itemPrefix + "_" + Path(inputFile).resolve().stem + print(f"Generating: {bcolors.BOLD}{baseName}{bcolors.ENDC}") + + generateImage(inputFile, baseName) + + if(baseName.find("_inventario") != -1): + return + + generateESCScript(baseName) + generateScene(baseName) + + + +def generateImage(inputFile, baseName): + + + originalImage = Image.open(inputFile) + scale = 0.15 + newImage = originalImage.resize((math.ceil(originalImage.width * scale),math.ceil(originalImage.height * scale))) + newImageOutputPath = outputDir + "assets/" + baseName + ".png" + print(f"{bcolors.OKCYAN}Image:{bcolors.ENDC} {newImageOutputPath} {bcolors.OKGREEN}generated.{bcolors.ENDC}") + newImage.save(newImageOutputPath) + +def generateESCScript(baseName): + + + scriptName = baseName + ".esc" + scriptOutputPath = outputDir + scriptName + if(os.path.isfile(scriptOutputPath) and not(overWrite)): + print(f"{bcolors.OKCYAN}Script:{bcolors.ENDC} {scriptOutputPath} {bcolors.WARNING}already exists.{bcolors.ENDC}") + return + + print(f"{bcolors.OKCYAN}Script:{bcolors.ENDC} {scriptOutputPath} {bcolors.OKGREEN}generated.{bcolors.ENDC}") + shutil.copy('item-template.esc', scriptOutputPath) + +def generateScene(baseName): + esceneName = baseName + ".tscn" + esceneOutputPath = outputDir + esceneName + if(os.path.isfile(esceneOutputPath) and not(overWrite)): + print(f"{bcolors.OKCYAN}Scene:{bcolors.ENDC} {esceneOutputPath} {bcolors.WARNING}already exists.{bcolors.ENDC}") + return + + newScene = open(esceneOutputPath, mode='wt', encoding='utf-8') + newSceneTemplate = esceneTemplate + newSceneTemplate = newSceneTemplate.replace("BASENAME", baseName) + newScene.write(newSceneTemplate) + newScene.close() + print(f"{bcolors.OKCYAN}Scene:{bcolors.ENDC} {esceneOutputPath} {bcolors.OKGREEN}generated.{bcolors.ENDC}") + + + if inputDir == "": print ('Input directory is required') printHelp() @@ -52,40 +105,7 @@ esceneTemplate = esceneFile.read() files = glob.glob(inputDir + "*.png") for file in files: - baseName = itemPrefix + "_" + Path(file).resolve().stem - - print(f"Generating: {bcolors.BOLD}{baseName}{bcolors.ENDC}") - - - originalImage = Image.open(file) - scale = 0.15 - newImage = originalImage.resize((math.ceil(originalImage.width * scale),math.ceil(originalImage.height * scale))) - newImageOutputPath = outputDir + "assets/" + baseName + ".png" - print(f"{bcolors.OKCYAN}Image:{bcolors.ENDC} {newImageOutputPath} {bcolors.OKGREEN}generated.{bcolors.ENDC}") - newImage.save(newImageOutputPath) - - scriptName = baseName + ".esc" - scriptOutputPath = outputDir + scriptName - if(os.path.isfile(scriptOutputPath) and not(overWrite)): - print(f"{bcolors.OKCYAN}Script:{bcolors.ENDC} {scriptOutputPath} {bcolors.WARNING}already exists.{bcolors.ENDC}") - else: - print(f"{bcolors.OKCYAN}Script:{bcolors.ENDC} {scriptOutputPath} {bcolors.OKGREEN}generated.{bcolors.ENDC}") - shutil.copy('item-template.esc', scriptOutputPath) - - - esceneName = baseName + ".tscn" - esceneOutputPath = outputDir + esceneName - - if(os.path.isfile(esceneOutputPath) and not(overWrite)): - print(f"{bcolors.OKCYAN}Scene:{bcolors.ENDC} {esceneOutputPath} {bcolors.WARNING}already exists.{bcolors.ENDC}") - else: - newScene = open(esceneOutputPath, mode='wt', encoding='utf-8') - newSceneTemplate = esceneTemplate - newSceneTemplate = newSceneTemplate.replace("BASENAME", baseName) - newScene.write(newSceneTemplate) - newScene.close() - print(f"{bcolors.OKCYAN}Scene:{bcolors.ENDC} {esceneOutputPath} {bcolors.OKGREEN}generated.{bcolors.ENDC}") - + generateItem(file) esceneFile.close()