diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e4fdbdb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.import diff --git a/assets/activated border.bmp b/assets/activated border.bmp new file mode 100644 index 0000000..404d5a7 Binary files /dev/null and b/assets/activated border.bmp differ diff --git a/assets/alien.kra b/assets/alien.kra new file mode 100644 index 0000000..b8ddc17 Binary files /dev/null and b/assets/alien.kra differ diff --git a/assets/alien.png b/assets/alien.png new file mode 100644 index 0000000..be47f9a Binary files /dev/null and b/assets/alien.png differ diff --git a/assets/blackhole pressed.png b/assets/blackhole pressed.png new file mode 100644 index 0000000..5da8daa Binary files /dev/null and b/assets/blackhole pressed.png differ diff --git a/assets/blackhole.kra b/assets/blackhole.kra new file mode 100644 index 0000000..d33505b Binary files /dev/null and b/assets/blackhole.kra differ diff --git a/assets/blackhole.png b/assets/blackhole.png new file mode 100644 index 0000000..d73ef2c Binary files /dev/null and b/assets/blackhole.png differ diff --git a/assets/blackhole_icon.png b/assets/blackhole_icon.png new file mode 100644 index 0000000..77e70f3 Binary files /dev/null and b/assets/blackhole_icon.png differ diff --git a/assets/captain.png b/assets/captain.png new file mode 100644 index 0000000..96b7452 Binary files /dev/null and b/assets/captain.png differ diff --git a/assets/comet.kra b/assets/comet.kra new file mode 100644 index 0000000..39dd75f Binary files /dev/null and b/assets/comet.kra differ diff --git a/assets/comet.png b/assets/comet.png new file mode 100644 index 0000000..325cb98 Binary files /dev/null and b/assets/comet.png differ diff --git a/assets/crewPlaceholder.png b/assets/crewPlaceholder.png new file mode 100644 index 0000000..5e6f4e8 Binary files /dev/null and b/assets/crewPlaceholder.png differ diff --git a/assets/debris.kra b/assets/debris.kra new file mode 100644 index 0000000..e3cd50c Binary files /dev/null and b/assets/debris.kra differ diff --git a/assets/debris.png b/assets/debris.png new file mode 100644 index 0000000..e6a0d13 Binary files /dev/null and b/assets/debris.png differ diff --git a/assets/encounterIconAlien.png b/assets/encounterIconAlien.png new file mode 100644 index 0000000..6148fd0 Binary files /dev/null and b/assets/encounterIconAlien.png differ diff --git a/assets/encounterIconAlien_pressed.png b/assets/encounterIconAlien_pressed.png new file mode 100644 index 0000000..72f34ba Binary files /dev/null and b/assets/encounterIconAlien_pressed.png differ diff --git a/assets/encounterIconArtificialSatellite.png b/assets/encounterIconArtificialSatellite.png new file mode 100644 index 0000000..1a6d264 Binary files /dev/null and b/assets/encounterIconArtificialSatellite.png differ diff --git a/assets/encounterIconArtificialSatellite_pressed.png b/assets/encounterIconArtificialSatellite_pressed.png new file mode 100644 index 0000000..1b0bd97 Binary files /dev/null and b/assets/encounterIconArtificialSatellite_pressed.png differ diff --git a/assets/encounterIconComet.png b/assets/encounterIconComet.png new file mode 100644 index 0000000..226cc56 Binary files /dev/null and b/assets/encounterIconComet.png differ diff --git a/assets/encounterIconComet_pressed.png b/assets/encounterIconComet_pressed.png new file mode 100644 index 0000000..ff577f1 Binary files /dev/null and b/assets/encounterIconComet_pressed.png differ diff --git a/assets/encounterIconDebris.png b/assets/encounterIconDebris.png new file mode 100644 index 0000000..25b9607 Binary files /dev/null and b/assets/encounterIconDebris.png differ diff --git a/assets/encounterIconDebris_pressed.png b/assets/encounterIconDebris_pressed.png new file mode 100644 index 0000000..2d2162e Binary files /dev/null and b/assets/encounterIconDebris_pressed.png differ diff --git a/assets/encounterIconGases.png b/assets/encounterIconGases.png new file mode 100644 index 0000000..2279b5e Binary files /dev/null and b/assets/encounterIconGases.png differ diff --git a/assets/encounterIconGases_pressed.png b/assets/encounterIconGases_pressed.png new file mode 100644 index 0000000..2881c5f Binary files /dev/null and b/assets/encounterIconGases_pressed.png differ diff --git a/assets/encounterIconLocationSpecific.png b/assets/encounterIconLocationSpecific.png new file mode 100644 index 0000000..3446be4 Binary files /dev/null and b/assets/encounterIconLocationSpecific.png differ diff --git a/assets/encounterIconLocationSpecific_pressed.png b/assets/encounterIconLocationSpecific_pressed.png new file mode 100644 index 0000000..dac9e00 Binary files /dev/null and b/assets/encounterIconLocationSpecific_pressed.png differ diff --git a/assets/encounterIconMystery.png b/assets/encounterIconMystery.png new file mode 100644 index 0000000..87c61ec Binary files /dev/null and b/assets/encounterIconMystery.png differ diff --git a/assets/encounterIconMystery_pressed.png b/assets/encounterIconMystery_pressed.png new file mode 100644 index 0000000..28f4def Binary files /dev/null and b/assets/encounterIconMystery_pressed.png differ diff --git a/assets/encounterIconNaturalSatellite.png b/assets/encounterIconNaturalSatellite.png new file mode 100644 index 0000000..32aed3f Binary files /dev/null and b/assets/encounterIconNaturalSatellite.png differ diff --git a/assets/encounterIconNaturalSatellite_pressed.png b/assets/encounterIconNaturalSatellite_pressed.png new file mode 100644 index 0000000..75e7d87 Binary files /dev/null and b/assets/encounterIconNaturalSatellite_pressed.png differ diff --git a/assets/encounterIconPlaceholder0_pressed.png b/assets/encounterIconPlaceholder0_pressed.png new file mode 100644 index 0000000..faac245 Binary files /dev/null and b/assets/encounterIconPlaceholder0_pressed.png differ diff --git a/assets/encounterIconPlaceholder1_pressed.png b/assets/encounterIconPlaceholder1_pressed.png new file mode 100644 index 0000000..45050b2 Binary files /dev/null and b/assets/encounterIconPlaceholder1_pressed.png differ diff --git a/assets/encounterIconPlaceholder2_pressed.png b/assets/encounterIconPlaceholder2_pressed.png new file mode 100644 index 0000000..4db7392 Binary files /dev/null and b/assets/encounterIconPlaceholder2_pressed.png differ diff --git a/assets/encounterIconRescueOperation.png b/assets/encounterIconRescueOperation.png new file mode 100644 index 0000000..fd2e891 Binary files /dev/null and b/assets/encounterIconRescueOperation.png differ diff --git a/assets/encounterIconRescueOperation_pressed.png b/assets/encounterIconRescueOperation_pressed.png new file mode 100644 index 0000000..96f382d Binary files /dev/null and b/assets/encounterIconRescueOperation_pressed.png differ diff --git a/assets/encounterIconShip.png b/assets/encounterIconShip.png new file mode 100644 index 0000000..c133cd8 Binary files /dev/null and b/assets/encounterIconShip.png differ diff --git a/assets/encounterIconShip_pressed.png b/assets/encounterIconShip_pressed.png new file mode 100644 index 0000000..f81ebea Binary files /dev/null and b/assets/encounterIconShip_pressed.png differ diff --git a/assets/encounterIconStation.png b/assets/encounterIconStation.png new file mode 100644 index 0000000..482c013 Binary files /dev/null and b/assets/encounterIconStation.png differ diff --git a/assets/encounterIconStation_pressed.png b/assets/encounterIconStation_pressed.png new file mode 100644 index 0000000..9cede23 Binary files /dev/null and b/assets/encounterIconStation_pressed.png differ diff --git a/assets/encounterIconTemplate.png b/assets/encounterIconTemplate.png new file mode 100644 index 0000000..40f6d32 Binary files /dev/null and b/assets/encounterIconTemplate.png differ diff --git a/assets/encounterPlaceholder0.png b/assets/encounterPlaceholder0.png new file mode 100644 index 0000000..5c49b93 Binary files /dev/null and b/assets/encounterPlaceholder0.png differ diff --git a/assets/encounterPlaceholder1.png b/assets/encounterPlaceholder1.png new file mode 100644 index 0000000..d82a596 Binary files /dev/null and b/assets/encounterPlaceholder1.png differ diff --git a/assets/encounterPlaceholder2.png b/assets/encounterPlaceholder2.png new file mode 100644 index 0000000..bcb7547 Binary files /dev/null and b/assets/encounterPlaceholder2.png differ diff --git a/assets/encounters.xcf b/assets/encounters.xcf new file mode 100644 index 0000000..4b3af16 Binary files /dev/null and b/assets/encounters.xcf differ diff --git a/assets/facePlaceholder.png b/assets/facePlaceholder.png new file mode 100644 index 0000000..d528991 Binary files /dev/null and b/assets/facePlaceholder.png differ diff --git a/assets/gases.kra b/assets/gases.kra new file mode 100644 index 0000000..0e11a3e Binary files /dev/null and b/assets/gases.kra differ diff --git a/assets/gases.png b/assets/gases.png new file mode 100644 index 0000000..32f7a8f Binary files /dev/null and b/assets/gases.png differ diff --git a/assets/iconArtificialSatellite.png b/assets/iconArtificialSatellite.png new file mode 100644 index 0000000..ef4405d Binary files /dev/null and b/assets/iconArtificialSatellite.png differ diff --git a/assets/iconSatellite.kra b/assets/iconSatellite.kra new file mode 100644 index 0000000..ae1cd5d Binary files /dev/null and b/assets/iconSatellite.kra differ diff --git a/assets/location.kra b/assets/location.kra new file mode 100644 index 0000000..44d74a9 Binary files /dev/null and b/assets/location.kra differ diff --git a/assets/location.png b/assets/location.png new file mode 100644 index 0000000..44417e8 Binary files /dev/null and b/assets/location.png differ diff --git a/assets/moon icon.kra b/assets/moon icon.kra new file mode 100644 index 0000000..f3375e3 Binary files /dev/null and b/assets/moon icon.kra differ diff --git a/assets/moon icon.png b/assets/moon icon.png new file mode 100644 index 0000000..0f00754 Binary files /dev/null and b/assets/moon icon.png differ diff --git a/assets/moon pressed.png b/assets/moon pressed.png new file mode 100644 index 0000000..c07b3a4 Binary files /dev/null and b/assets/moon pressed.png differ diff --git a/assets/moon.png b/assets/moon.png new file mode 100644 index 0000000..1aa6d46 Binary files /dev/null and b/assets/moon.png differ diff --git a/assets/naturalSatellite.kra b/assets/naturalSatellite.kra new file mode 100644 index 0000000..162712a Binary files /dev/null and b/assets/naturalSatellite.kra differ diff --git a/assets/naturalSatellite.png b/assets/naturalSatellite.png new file mode 100644 index 0000000..ef82c7a Binary files /dev/null and b/assets/naturalSatellite.png differ diff --git a/assets/planet icon.kra b/assets/planet icon.kra new file mode 100644 index 0000000..0c7cf59 Binary files /dev/null and b/assets/planet icon.kra differ diff --git a/assets/planet icon.png b/assets/planet icon.png new file mode 100644 index 0000000..5055d0c Binary files /dev/null and b/assets/planet icon.png differ diff --git a/assets/planet placeholder.png b/assets/planet placeholder.png new file mode 100644 index 0000000..8893f79 Binary files /dev/null and b/assets/planet placeholder.png differ diff --git a/assets/planet pressed.png b/assets/planet pressed.png new file mode 100644 index 0000000..4da5c07 Binary files /dev/null and b/assets/planet pressed.png differ diff --git a/assets/planet.png b/assets/planet.png new file mode 100644 index 0000000..8e418f3 Binary files /dev/null and b/assets/planet.png differ diff --git a/assets/planets.xcf b/assets/planets.xcf new file mode 100644 index 0000000..c910a74 Binary files /dev/null and b/assets/planets.xcf differ diff --git a/assets/ship.kra b/assets/ship.kra new file mode 100644 index 0000000..217e1b6 Binary files /dev/null and b/assets/ship.kra differ diff --git a/assets/ship.png b/assets/ship.png new file mode 100644 index 0000000..f8077b1 Binary files /dev/null and b/assets/ship.png differ diff --git a/assets/star background.kra b/assets/star background.kra new file mode 100644 index 0000000..a058b39 Binary files /dev/null and b/assets/star background.kra differ diff --git a/assets/starfield.kra b/assets/starfield.kra new file mode 100644 index 0000000..4056e09 Binary files /dev/null and b/assets/starfield.kra differ diff --git a/assets/starfield.png b/assets/starfield.png new file mode 100644 index 0000000..a3e864a Binary files /dev/null and b/assets/starfield.png differ diff --git a/assets/station.kra b/assets/station.kra new file mode 100644 index 0000000..2f062da Binary files /dev/null and b/assets/station.kra differ diff --git a/assets/station.png b/assets/station.png new file mode 100644 index 0000000..4ab2efa Binary files /dev/null and b/assets/station.png differ diff --git a/default_env.tres b/default_env.tres index 98f26a7..20207a4 100644 --- a/default_env.tres +++ b/default_env.tres @@ -1,5 +1,7 @@ [gd_resource type="Environment" load_steps=2 format=2] + [sub_resource type="ProceduralSky" id=1] + [resource] background_mode = 2 background_sky = SubResource( 1 ) diff --git a/project.godot b/project.godot index e0abe8f..682bb6c 100644 --- a/project.godot +++ b/project.godot @@ -16,11 +16,17 @@ _global_script_class_icons={ [application] config/name="LD48" +boot_splash/fullsize=false +boot_splash/use_filter=false config/icon="res://icon.png" +[autoload] + +GameState="*res://src/GameState.tscn" + [rendering] -quality/driver/driver_name="GLES2" +quality/driver/fallback_to_gles2=true vram_compression/import_etc=true vram_compression/import_etc2=false environment/default_environment="res://default_env.tres" diff --git a/src/GameState.gd b/src/GameState.gd new file mode 100644 index 0000000..730083a --- /dev/null +++ b/src/GameState.gd @@ -0,0 +1,226 @@ +extends Node + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" +var current_scene = null + +var difficulty = null +var difficulties = { + "Easy": 0, + "Medium": 1, + "Hard": 2, +} +var difficulty_data = { + 0: { + "planet": "res://assets/moon.png", + "starting_altitude": 60000, + "starting_crew": 5, + "starting_drag": 1, + "drag_function": funcref(self, "moon_drag"), + "rescue_altitude": 10000, + "maximum_crew": 15, + "minimum_altitude": 1000, + }, + 1: { + "planet": "res://assets/planet.png", + "starting_altitude": 600000, + "starting_crew": 4, + "starting_drag": 10, + "drag_function": funcref(self, "planet_drag"), + "rescue_altitude": 100000, + "maximum_crew": 10, + "minimum_altitude": 30000, + }, + 2: { + "planet": "res://assets/blackhole.png", + "starting_altitude": 200000001000000, + "starting_crew": 3, + "starting_drag": 100, + "drag_function": funcref(self, "blackhole_drag"), + "rescue_altitude": 200000000100000, + "maximum_crew": 6, + "minimum_altitude": 200000000000000, + } +} + +var current_depth = 0 +const OptionsPerLevel = 3 +const TreeDepth = 5 + +const EncounterTypes = [ + "ArtificialSatellite", + "NaturalSatellite", + "Comet", + "Debris", + #"Gases", + "Mystery", + "Alien", + "Ship", + "Station", + "LocationSpecific", # Eg., Moon, Planet, Blackhole... +] +const EncounterData = { + "ArtificialSattelite" : { + "tooltip": "" + }, + "NaturalSattelite" : {}, + "Comet" : {}, + "Debris" : {}, + #"Gases" : {}, + "Mystery" : {}, + "Alien" : {}, + "Ship" : {}, + "Station" : {}, + "LocationSpecific" : {}, +} + +var rng = RandomNumberGenerator.new() +var encounters = { + # 0: [ + # { + # "type": EncounterTypeString, + # "instance": EncounterNode, + # "selected": Boolean (false), + # "visited": Boolean (false), + # }, ... + # ], ... + +} + +var current_state = 0 +var states = { + 0: "Choose Difficulty", + 1: "Generate Map", + 2: "Intro", + 3: "Set Resources and Generate Crew", + 4: "Choose flight-path In", + 5: "Encounters", + 6: "Choose flight-path Out", + 7: "End Game", +} + +const default_ship_stats = { + "health": 1000, + "deltav": 1000, + "supplies": 1000, + "crew": [], + "next_crew_id": 2, +} + +var target_point = null +var ship_stats = Dictionary(default_ship_stats) +var orbit_stats = { + "altitude": 0, + "drag": 0, + "estimated_escape_dv": 0 +} + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass + +func initialize(d): + self.difficulty = d + # Generate a map + var i = 0 + while i < self.TreeDepth: + var n = 0 + self.encounters[i] = [] + while n < self.OptionsPerLevel: + var type = self.EncounterTypes[self.rng.randi_range(0, len(self.EncounterTypes)-1)] + var encounter = { + "type": type, + "instance": null, + "visited": false, + "selected": false, + "locked": false, + } + self.encounters[i].append(encounter) + n += 1 + i += 1 + self.encounters[i] = [] + self.encounters[i].append({ + "type": "RescueOperation", + "instance": null, + "visited": false, + "selected": true, + "locked": true, + }) + for level in encounters.keys(): + print("Encounter level " + str(level)) + for e in self.encounters[level]: + print("\tOption: " + e.type) + + # Set the orbit stats + self.orbit_stats["altitude"] = get_difficulty_data("starting_altitude") + self.orbit_stats["drag"] = get_difficulty_data("starting_drag") + self.generate_crew() + get_tree().get_root().call_deferred("add_child", ResourceLoader.load("res://src/ui/Background.tscn").instance()) + +func get_difficulty_data(key): + return self.difficulty_data[self.difficulty][key] + +func generate_crew(): + self.ship_stats["crew"].append({ + "name": "Wellspring's Captain", + "may_be_sacrified": false, + "picture": null, + "personality": "paragon", + "position": null, + "morale": null, + "tooltip": "This is you", + "upkeep": 10, + "id": 1, + }) + var x = 0 + while x < self.get_difficulty_data("starting_crew"): + self.ship_stats["crew"].append({ + "name": "Xxx", + "may_be_sacrified": true, + "picture": null, + "position": null, + "upkeep": 10, + "morale": 100, + "tooltip": null, + "personality": null, + "id": self.ship_stats['next_crew_id'], + }) + x += 1 + self.ship_stats['next_crew_id'] += 1 + +func goto_scene(scene, current = null): + call_deferred("_deferred_goto_scene", scene, current) + +func _deferred_goto_scene(scene, current = null): + get_tree().get_root().print_tree_pretty() + if current: + current.free() + elif self.current_scene: + self.current_scene.free() + var next = ResourceLoader.load(scene).instance() + get_tree().get_root().add_child(next) + get_tree().set_current_scene(next) + self.current_scene = next + +func start_introduction(): + self.current_state = 2 + self.goto_scene("res://src/ui/Intro.tscn") + +func end_introduction(): + self.current_state = 4 + self.goto_scene("res://src/ui/ChooseFlightIn.tscn") + +func start_encounters(picks): + var x = 0 + while x < len(self.encounters): + self.encounters[x][picks[x]]["selected"] = true + self.encounters[x][picks[x]]["locked"] = true + x += 1 + self.current_state = 5 + self.goto_scene("res://src/ui/Encounters.tscn") + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/src/GameState.tscn b/src/GameState.tscn new file mode 100644 index 0000000..e832222 --- /dev/null +++ b/src/GameState.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/GameState.gd" type="Script" id=1] + +[node name="GameState" type="Node"] +script = ExtResource( 1 ) diff --git a/src/Ship.tscn b/src/Ship.tscn new file mode 100644 index 0000000..3f593a9 --- /dev/null +++ b/src/Ship.tscn @@ -0,0 +1,3 @@ +[gd_scene format=2] + +[node name="Ship" type="Node2D"] diff --git a/src/ui/Background.tscn b/src/ui/Background.tscn new file mode 100644 index 0000000..814c772 --- /dev/null +++ b/src/ui/Background.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://assets/starfield.png" type="Texture" id=1] + +[node name="Background" type="Node2D"] +z_index = -1 + +[node name="TextureRect" type="TextureRect" parent="."] +margin_left = -108.0 +margin_top = 7.62939e-06 +margin_right = 1892.0 +margin_bottom = 1000.0 +rect_scale = Vector2( 0.6, 0.6 ) +texture = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/src/ui/ChooseFlightIn.gd b/src/ui/ChooseFlightIn.gd new file mode 100644 index 0000000..78d4ddd --- /dev/null +++ b/src/ui/ChooseFlightIn.gd @@ -0,0 +1,37 @@ +extends Node2D + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + if GameState.difficulty == null: + GameState.initialize(0) + get_node("Ready").set_disabled(true) + get_node("Ready").connect("pressed", self, "_on_ready_pressed") + for c in get_node("Map").get_children(): + if c.get_name().match("Level?"): + c.activate_options() + c.connect("encounter_choice_changed", self, "_update_ready_state") + +func _update_ready_state(): + var all_ready = true + for c in get_node("Map").get_children(): + if c.get_name().match("Level?"): + all_ready = all_ready and c.has_active() + get_node("Ready").set_disabled(not all_ready) + +func _on_ready_pressed(): + get_node("Ready").set_disabled(true) + var picks = [] + for c in get_node("Map").get_children(): + if c.get_name().match("Level?"): + picks.append(c.get_active_option_index()) + GameState.start_encounters(picks) + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/src/ui/ChooseFlightIn.tscn b/src/ui/ChooseFlightIn.tscn new file mode 100644 index 0000000..c226027 --- /dev/null +++ b/src/ui/ChooseFlightIn.tscn @@ -0,0 +1,44 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://src/ui/ChooseFlightIn.gd" type="Script" id=1] +[ext_resource path="res://src/ui/Map.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/ui/ShipStats.tscn" type="PackedScene" id=3] +[ext_resource path="res://src/ui/CrewUI.tscn" type="PackedScene" id=4] + +[node name="ChooseFlightIn" type="Node2D"] +script = ExtResource( 1 ) + +[node name="RichTextLabel" type="RichTextLabel" parent="."] +margin_left = -2.0 +margin_right = 1022.0 +margin_bottom = 123.0 +bbcode_enabled = true +bbcode_text = " +[center]Our scanners have detected points of interest along the flight path to the [b]Diligent[/b]. +Plot a course to the rendezvous with the [b]Diligent[/b] by selecting an encounter from each group. + +Hit \"Engage\" when everything is plotted to confirm the course.[/center]" +text = " +Our scanners have detected points of interest along the flight path to the Diligent. +Plot a course to the rendezvous with the Diligent by selecting an encounter from each group. + +Hit \"Engage\" when everything is plotted to confirm the course." +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Map" parent="." instance=ExtResource( 2 )] + +[node name="ShipStats" parent="." instance=ExtResource( 3 )] + +[node name="CrewUI" parent="." instance=ExtResource( 4 )] + +[node name="Ready" type="Button" parent="."] +margin_left = 447.0 +margin_top = 536.0 +margin_right = 586.0 +margin_bottom = 584.0 +text = "Engage" +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/src/ui/CrewEntry.gd b/src/ui/CrewEntry.gd new file mode 100644 index 0000000..4eaa3b7 --- /dev/null +++ b/src/ui/CrewEntry.gd @@ -0,0 +1,31 @@ +extends Control + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + +func initialize(data): + find_node("Name").set_bbcode("[center]" + data['name'] + "[/center]") + if data['morale']: + find_node("Morale").set_value(data['morale']) + else: + get_node("Container/Morale").set_visible(false) + if data['picture']: + get_node("Container/Image").set_texture(ResourceLoader.load(data['picture'])) + else: + get_node("Container/Image").set_texture(ResourceLoader.load("res://assets/crewPlaceholder.png")) + var tt = "" + if data['tooltip']: + tt = data['tooltip'] + tt += "\n\n" + for i in data.keys(): + if i == "tooltip": + continue + tt += i + ": " + str(data[i]) + "\n\n" + find_node("Image").set_tooltip(tt) diff --git a/src/ui/CrewEntry.tscn b/src/ui/CrewEntry.tscn new file mode 100644 index 0000000..d113a74 --- /dev/null +++ b/src/ui/CrewEntry.tscn @@ -0,0 +1,42 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/ui/CrewEntry.gd" type="Script" id=1] + +[node name="Crew" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Container" type="VBoxContainer" parent="."] +margin_right = 40.0 +margin_bottom = 40.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Image" type="TextureRect" parent="Container"] +margin_right = 100.0 +margin_bottom = 100.0 +rect_min_size = Vector2( 100, 100 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Name" type="RichTextLabel" parent="Container"] +margin_top = 104.0 +margin_right = 100.0 +margin_bottom = 119.0 +bbcode_enabled = true +fit_content_height = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Morale" type="ProgressBar" parent="Container"] +margin_top = 123.0 +margin_right = 100.0 +margin_bottom = 137.0 +step = 1.0 diff --git a/src/ui/CrewUI.gd b/src/ui/CrewUI.gd new file mode 100644 index 0000000..eeb2632 --- /dev/null +++ b/src/ui/CrewUI.gd @@ -0,0 +1,43 @@ +extends Control + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +const crew_per_page = 4 +var current_page = 0 +var entries = {} + +func _ready(): + self.entries = {} + var count = len(GameState.ship_stats['crew']) + self.current_page = 0 + var max_pages = (count / self.crew_per_page) + 1 + self.print_tree_pretty() + if self.current_page == 0: + get_node("Container/Pager/Previous").set_disabled(true) + get_node("Container/Display").set_text(str(self.current_page + 1 ) + " / " + str(max_pages)) + print(max_pages) + if max_pages < 2 or ((current_page+1) >= max_pages): + get_node("Container/Pager/Previous").set_disabled(true) + var crew_entry_ui = ResourceLoader.load("res://src/ui/CrewEntry.tscn") + for c in GameState.ship_stats['crew']: + var e = crew_entry_ui.instance(); + e.initialize(c) + entries[c['id']] = e + e.set_custom_minimum_size(Vector2(100, 137)) + var x = 0 + (current_page * crew_per_page); + var limit = x + crew_per_page + while x < limit: + if x >= len(entries.keys()): + break; + var key = entries.keys()[x] + get_node("Container/Crew").add_child(entries[key]) + x += 1 + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/src/ui/CrewUI.tscn b/src/ui/CrewUI.tscn new file mode 100644 index 0000000..ae84bfb --- /dev/null +++ b/src/ui/CrewUI.tscn @@ -0,0 +1,47 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/ui/CrewUI.gd" type="Script" id=1] + +[node name="CrewUI" type="Control"] +margin_left = 918.0 +margin_right = 1020.0 +margin_bottom = 599.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Container" type="VBoxContainer" parent="."] +margin_right = 40.0 +margin_bottom = 40.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Crew" type="VBoxContainer" parent="Container"] +margin_right = 44.0 + +[node name="Display" type="RichTextLabel" parent="Container"] +margin_top = 4.0 +margin_right = 44.0 +margin_bottom = 19.0 +bbcode_enabled = true +fit_content_height = true + +[node name="Pager" type="HBoxContainer" parent="Container"] +margin_top = 23.0 +margin_right = 44.0 +margin_bottom = 43.0 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 0.0 + +[node name="Previous" type="Button" parent="Container/Pager"] +margin_right = 20.0 +margin_bottom = 20.0 +text = "<" + +[node name="Next" type="Button" parent="Container/Pager"] +margin_left = 24.0 +margin_right = 44.0 +margin_bottom = 20.0 +text = ">" diff --git a/src/ui/Dialogue.gd b/src/ui/Dialogue.gd new file mode 100644 index 0000000..2f5453f --- /dev/null +++ b/src/ui/Dialogue.gd @@ -0,0 +1,68 @@ +extends Control + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +var timer = 0 +var waiting = true +var wait_condition = null +var data = null + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +func start(d): + self.data = d + self.timer = 0 + self.process_step("init") + self.waiting = false + +func end(): + self.waiting = true + +func _input(ev): + if self.waiting: + if self.wait_condition is String and self.wait_condition == "space" and Input.is_key_pressed(KEY_SPACE): + self.waiting = false + self.wait_condition = null + if self.wait_condition is Array and ev is InputEventKey and ev.pressed: + self.waiting = false + self.wait_condition[0].call_func() + self.wait_condition = null + + +func process_step(id): + print(self.data.keys()) + if not self.data.keys().has(id): + print("Step '" + id + "' not found. Skipping") + return + for action in self.data[id]: + print("Running action: " + action["type"]) + if action["type"] == "set_speaker": + self.find_node("Speaker").set_texture(ResourceLoader.load(action["args"])) + elif action["type"] == "reset_text": + self.find_node("Text").set_bbcode("") + elif action["type"] == "add_line": + self.find_node("Text").append_bbcode("[b]" + action["args"][0] + ": [/b]") + self.find_node("Text").append_bbcode(action["args"][1] + "\n") + elif action["type"] == "wait_for_space": + self.find_node("Text").append_bbcode("[center][i]Hit space to continue[/i][/center]\n") + self.waiting = true + self.wait_condition = "space" + elif action["type"] == "wait_for_key": + self.find_node("Text").append_bbcode("[center][i]Press any key to continue[/i][/center]\n") + self.waiting = true + self.wait_condition = action["args"] + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + if not waiting: + var old_timer = self.timer + self.timer += delta + for k in self.data.keys(): + if str(k) != "init" and k > old_timer and k <= self.timer: + self.process_step(k) diff --git a/src/ui/Dialogue.tscn b/src/ui/Dialogue.tscn new file mode 100644 index 0000000..4292b2f --- /dev/null +++ b/src/ui/Dialogue.tscn @@ -0,0 +1,36 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/ui/Dialogue.gd" type="Script" id=1] + +[node name="Control" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +margin_left = 825.0 +margin_right = 1025.0 +margin_bottom = 600.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Speaker" type="TextureRect" parent="VBoxContainer"] +margin_right = 200.0 +margin_bottom = 200.0 +rect_min_size = Vector2( 0, 200 ) + +[node name="Text" type="RichTextLabel" parent="VBoxContainer"] +margin_top = 204.0 +margin_right = 200.0 +margin_bottom = 564.0 +rect_min_size = Vector2( 0, 360 ) +bbcode_enabled = true + +[node name="ChoiceContainer" type="HBoxContainer" parent="VBoxContainer"] +margin_top = 568.0 +margin_right = 200.0 +margin_bottom = 568.0 diff --git a/src/ui/DifficultySelector.gd b/src/ui/DifficultySelector.gd new file mode 100644 index 0000000..6ec7ca3 --- /dev/null +++ b/src/ui/DifficultySelector.gd @@ -0,0 +1,36 @@ +extends Control + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +var buttonNames = [ + "EasyButton", + "MediumButton", + "HardButton" +] +# Called when the node enters the scene tree for the first time. +func _ready(): + # Bind button callbacks + for n in buttonNames: + var button = self.find_node(n) + button.connect("toggled", self, "_on_difficulty_button_pressed", [n]) + self.find_node("MediumButton").set_pressed(true) + self.find_node("StartButton").connect("pressed", self, "_on_start_button_pressed") + +func _on_difficulty_button_pressed(state, buttonName): + var any_active = state + for n in buttonNames: + if n != buttonName: + if state: + self.find_node(n).set_pressed(false) + any_active = any_active or self.find_node(n).is_pressed() + self.find_node("StartButton").disabled = not any_active + +func _on_start_button_pressed(): + pass + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/src/ui/DifficultySelector.tscn b/src/ui/DifficultySelector.tscn new file mode 100644 index 0000000..7246eac --- /dev/null +++ b/src/ui/DifficultySelector.tscn @@ -0,0 +1,114 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://assets/blackhole_icon.png" type="Texture" id=1] +[ext_resource path="res://assets/planet icon.png" type="Texture" id=2] +[ext_resource path="res://assets/moon icon.png" type="Texture" id=3] +[ext_resource path="res://assets/moon pressed.png" type="Texture" id=4] +[ext_resource path="res://assets/blackhole pressed.png" type="Texture" id=5] +[ext_resource path="res://assets/planet pressed.png" type="Texture" id=6] +[ext_resource path="res://src/ui/DifficultySelector.gd" type="Script" id=7] + +[node name="DifficultySelector" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = -1.0 +margin_bottom = -1.0 +script = ExtResource( 7 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +margin_right = 40.0 +margin_bottom = 40.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] +margin_right = 908.0 +margin_bottom = 404.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"] +margin_right = 300.0 +margin_bottom = 404.0 +rect_min_size = Vector2( 300, 400 ) + +[node name="EasyButton" type="TextureButton" parent="VBoxContainer/HBoxContainer/VBoxContainer"] +margin_right = 300.0 +margin_bottom = 300.0 +rect_min_size = Vector2( 0, 300 ) +toggle_mode = true +texture_normal = ExtResource( 3 ) +texture_pressed = ExtResource( 4 ) +__meta__ = { +"_editor_description_": "Easy" +} + +[node name="RichTextLabel" type="RichTextLabel" parent="VBoxContainer/HBoxContainer/VBoxContainer"] +margin_top = 304.0 +margin_right = 300.0 +margin_bottom = 404.0 +rect_min_size = Vector2( 0, 100 ) +text = "Easy" + +[node name="VBoxContainer3" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"] +margin_left = 304.0 +margin_right = 604.0 +margin_bottom = 404.0 +rect_min_size = Vector2( 300, 400 ) + +[node name="MediumButton" type="TextureButton" parent="VBoxContainer/HBoxContainer/VBoxContainer3"] +margin_right = 300.0 +margin_bottom = 300.0 +rect_min_size = Vector2( 0, 300 ) +toggle_mode = true +texture_normal = ExtResource( 2 ) +texture_pressed = ExtResource( 6 ) +__meta__ = { +"_editor_description_": "Easy" +} + +[node name="RichTextLabel" type="RichTextLabel" parent="VBoxContainer/HBoxContainer/VBoxContainer3"] +margin_top = 304.0 +margin_right = 300.0 +margin_bottom = 404.0 +rect_min_size = Vector2( 0, 100 ) +text = "Medium" + +[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"] +margin_left = 608.0 +margin_right = 908.0 +margin_bottom = 404.0 +rect_min_size = Vector2( 300, 400 ) + +[node name="HardButton" type="TextureButton" parent="VBoxContainer/HBoxContainer/VBoxContainer2"] +margin_right = 300.0 +margin_bottom = 300.0 +rect_min_size = Vector2( 0, 300 ) +toggle_mode = true +texture_normal = ExtResource( 1 ) +texture_pressed = ExtResource( 5 ) +__meta__ = { +"_editor_description_": "Easy" +} + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/HBoxContainer/VBoxContainer2"] +margin_top = 304.0 +margin_right = 300.0 +margin_bottom = 404.0 + +[node name="RichTextLabel" type="RichTextLabel" parent="VBoxContainer/HBoxContainer/VBoxContainer2/MarginContainer"] +margin_right = 300.0 +margin_bottom = 100.0 +rect_min_size = Vector2( 0, 100 ) +text = "Hard" + +[node name="StartButton" type="Button" parent="VBoxContainer"] +margin_top = 408.0 +margin_right = 908.0 +margin_bottom = 428.0 +text = "Start" diff --git a/src/ui/EncounterChoice.gd b/src/ui/EncounterChoice.gd new file mode 100644 index 0000000..f5ad01f --- /dev/null +++ b/src/ui/EncounterChoice.gd @@ -0,0 +1,69 @@ +extends Node2D + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +signal encounter_choice_changed + +var choices = 3 +var buttonNames = [ + "Option0", + "Option1", + "Option2", +] +# Called when the node enters the scene tree for the first time. +func _ready(): + # Bind button callbacks + for n in buttonNames: + var button = self.find_node(n) + button.connect("toggled", self, "_on_option_button_pressed", [n]) + +func initialize(nOptions = null): + if nOptions != null: + self.choices = nOptions + var x = 0 + while x < 3: + self.find_node("Option" + str(x)).visible = x < nOptions + x += 1 + +func activate_options(): + if self.choices > 1: + for c in self.get_children(): + if c.visible: + c.set_disabled(false) + +func disable_options(): + for c in self.get_children(): + if c.visible: + c.set_disabled(true) + +func get_active_option_index(): + var x = 0 + for c in self.get_children(): + if c.is_pressed(): + return x + else: + x += 1 + return null + +func has_active(): + var active = false + for n in buttonNames: + active = active or self.get_node(n).is_pressed() + return active + +func _on_option_button_pressed(state, buttonName): + for n in buttonNames: + if n != buttonName: + if state: + self.find_node(n).set_pressed(false) + emit_signal("encounter_choice_changed") + #for n in buttonNames: + # if self.find_node(n).is_pressed(): + # print("Button" + n + " is pressed") + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/src/ui/EncounterChoice.tscn b/src/ui/EncounterChoice.tscn new file mode 100644 index 0000000..602bbdc --- /dev/null +++ b/src/ui/EncounterChoice.tscn @@ -0,0 +1,52 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://src/ui/EncounterChoice.gd" type="Script" id=1] +[ext_resource path="res://assets/encounterPlaceholder2.png" type="Texture" id=2] +[ext_resource path="res://assets/encounterPlaceholder0.png" type="Texture" id=3] +[ext_resource path="res://assets/encounterPlaceholder1.png" type="Texture" id=4] +[ext_resource path="res://assets/encounterIconPlaceholder0_pressed.png" type="Texture" id=5] +[ext_resource path="res://assets/encounterIconPlaceholder1_pressed.png" type="Texture" id=6] +[ext_resource path="res://assets/encounterIconPlaceholder2_pressed.png" type="Texture" id=7] + +[node name="EncounterChoice" type="Node2D"] +position = Vector2( -0.5, 0.5 ) +script = ExtResource( 1 ) + +[node name="Option0" type="TextureButton" parent="."] +margin_left = -28.8286 +margin_top = 14.3104 +margin_right = 11.1714 +margin_bottom = 54.3104 +hint_tooltip = "Option 0" +toggle_mode = true +texture_normal = ExtResource( 3 ) +texture_pressed = ExtResource( 5 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Option1" type="TextureButton" parent="."] +margin_left = 24.2782 +margin_top = 16.5904 +margin_right = 64.2782 +margin_bottom = 56.5904 +hint_tooltip = "Option 1" +toggle_mode = true +texture_normal = ExtResource( 4 ) +texture_pressed = ExtResource( 6 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Option2" type="TextureButton" parent="."] +margin_left = 17.7514 +margin_top = -36.9294 +margin_right = 57.7514 +margin_bottom = 3.07064 +hint_tooltip = "Option 2" +toggle_mode = true +texture_normal = ExtResource( 2 ) +texture_pressed = ExtResource( 7 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/src/ui/Encounters.tscn b/src/ui/Encounters.tscn new file mode 100644 index 0000000..f83b4fe --- /dev/null +++ b/src/ui/Encounters.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://src/ui/Map.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/ui/ShipStats.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/ui/CrewUI.tscn" type="PackedScene" id=3] + +[node name="Encounters" type="Node2D"] + +[node name="Map" parent="." instance=ExtResource( 1 )] + +[node name="CrewUI" parent="." instance=ExtResource( 3 )] + +[node name="Control" parent="." instance=ExtResource( 2 )] diff --git a/src/ui/GameMenu.tscn b/src/ui/GameMenu.tscn new file mode 100644 index 0000000..6389cf3 --- /dev/null +++ b/src/ui/GameMenu.tscn @@ -0,0 +1,76 @@ +[gd_scene format=2] + +[node name="GameMenu" type="Control"] +anchor_right = 0.5 +anchor_bottom = 0.5 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ContinueButton" type="MenuButton" parent="."] +margin_left = 158.967 +margin_top = 115.601 +margin_right = 397.967 +margin_bottom = 135.601 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="RichTextLabel" type="RichTextLabel" parent="ContinueButton"] +margin_right = 76.0 +margin_bottom = 40.0 +text = "Continue" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="HelpButton" type="MenuButton" parent="."] +margin_left = 160.494 +margin_top = 140.127 +margin_right = 448.494 +margin_bottom = 160.127 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="RichTextLabel" type="RichTextLabel" parent="HelpButton"] +anchor_right = 0.069 +anchor_bottom = 1.0 +margin_right = 20.128 +margin_bottom = 20.0 +text = "Help" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="LeaveGameButton" type="MenuButton" parent="."] +anchor_right = 0.246 +anchor_bottom = 0.033 +margin_right = -239.904 +margin_bottom = 0.200001 + +[node name="RichTextLabel" type="RichTextLabel" parent="LeaveGameButton"] +margin_left = 157.858 +margin_top = 167.583 +margin_right = 297.858 +margin_bottom = 192.583 +text = "Abandon Game" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ExitGameButton" type="MenuButton" parent="."] +margin_left = 90.8717 +margin_top = 99.7807 +margin_right = 114.872 +margin_bottom = 124.781 + +[node name="RichTextLabel" type="RichTextLabel" parent="ExitGameButton"] +margin_left = 67.7083 +margin_top = 96.2171 +margin_right = 238.708 +margin_bottom = 118.217 +text = "End Program" +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/src/ui/Intro.gd b/src/ui/Intro.gd new file mode 100644 index 0000000..a80f335 --- /dev/null +++ b/src/ui/Intro.gd @@ -0,0 +1,90 @@ +extends Node2D + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +var dialogue = { + "init": [ + { + "type": "set_speaker", + "args": "res://assets/captain.png", + }, + { + "type": "reset_text", + }, + ], + 0.5: [ + { + "type": "add_line", + "args": [ + "Diligent's Captain", + "[i]*bzzt*[/i] Mayday! Mayday! [i]*crackle*[/i]", + ] + }, + { + "type": "wait_for_space", + } + ], + 1.0: [ + { + "type": "add_line", + "args": [ + "You", + "This is the captain of the [b]Wellspring[/b]. What's your situation?", + ] + }, + { + "type": "add_line", + "args": [ + "Diligent's Captain", + "We've lost power and we're being dragged deeper into this gravity [i]*bzzt*[/i].\n" \ + + "[i]*crack*[/i] warp crystal, if you can get here and take us out." + ], + }, + { + "type": "wait_for_space", + } + ], + 1.5: [ + { + "type": "add_line", + "args": [ + "You", + "Acknowledged, we're on our way. Wellspring out.\n\n", + ] + }, + { + "type": "add_line", + "args": [ + "Narrator", + "[color=a20d0d]With your ship and crew, and the resources you have at and. You start plotting a course to rendezvous with the [b]Diligent[/b].[/color]" + ] + }, + { + "type": "wait_for_key", + "args": [ + funcref(self, "end") + ] + } + ], +} +# Called when the node enters the scene tree for the first time. +func _ready(): + find_node("Dialogue").start(self.dialogue) + + +func _input(_ev): + if Input.is_key_pressed(KEY_ESCAPE): + self.end() + +func end(): + # Leave introduction + find_node("Dialogue").end() + GameState.end_introduction() + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/src/ui/Intro.tscn b/src/ui/Intro.tscn new file mode 100644 index 0000000..e93b9c5 --- /dev/null +++ b/src/ui/Intro.tscn @@ -0,0 +1,26 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://src/ui/Map.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/ui/Dialogue.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/ui/Intro.gd" type="Script" id=3] + +[node name="Intro" type="Node2D"] +script = ExtResource( 3 ) + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +margin_right = 40.0 +margin_bottom = 40.0 +rect_min_size = Vector2( 150, 0 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="RichTextLabel" type="RichTextLabel" parent="HBoxContainer"] +margin_right = 150.0 +margin_bottom = 40.0 +rect_min_size = Vector2( 150, 0 ) +text = "Hit \"Escape\" to skip" + +[node name="Dialogue" parent="." instance=ExtResource( 2 )] + +[node name="Map" parent="." instance=ExtResource( 1 )] diff --git a/src/ui/MainMenu.gd b/src/ui/MainMenu.gd new file mode 100644 index 0000000..9b8b0a9 --- /dev/null +++ b/src/ui/MainMenu.gd @@ -0,0 +1,25 @@ +extends Node2D + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +# Called when the node enters the scene tree for the first time. +func _ready(): + # Connect start button with our callback + self.find_node("DifficultySelector").find_node("StartButton").connect("pressed", self, "_on_start_button_pressed") + GameState.current_scene = self + +func _on_start_button_pressed(): + # Get the difficulty button that is pressed + var chosen_difficulty = 0 + #var state = get_tree().get_root().find_node("GameState") + for d in GameState.difficulties.keys(): + if self.find_node(d+ "Button").is_pressed(): + chosen_difficulty = GameState.difficulties[d] + break + print("Chosen difficulty: " + GameState.difficulties.keys()[chosen_difficulty] + "(" + str(chosen_difficulty) + ")") + self.find_node("DifficultySelector").find_node("StartButton").disconnect("pressed", self, "_on_start_button_pressed") + GameState.initialize(chosen_difficulty) + GameState.start_introduction() diff --git a/src/ui/MainMenu.tscn b/src/ui/MainMenu.tscn new file mode 100644 index 0000000..09413bd --- /dev/null +++ b/src/ui/MainMenu.tscn @@ -0,0 +1,24 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://src/ui/MainMenu.gd" type="Script" id=1] +[ext_resource path="res://src/ui/DifficultySelector.tscn" type="PackedScene" id=2] + +[node name="MainMenu" type="Node2D"] +script = ExtResource( 1 ) + +[node name="DifficultySelector" parent="." instance=ExtResource( 2 )] +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 56.1231 +margin_top = 130.328 +margin_right = 56.1231 +margin_bottom = 130.328 + +[node name="Title" type="RichTextLabel" parent="."] +margin_right = 1026.0 +margin_bottom = 129.0 +text = "Title: Gravity Well Diver +" +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/src/ui/Map.gd b/src/ui/Map.gd new file mode 100644 index 0000000..8aa096f --- /dev/null +++ b/src/ui/Map.gd @@ -0,0 +1,56 @@ +extends Node2D + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + # For testing + if GameState.difficulty == null: + GameState.initialize(0) + self.find_node("Planet").set_texture(ResourceLoader.load(GameState.get_difficulty_data("planet"))) + var encounterChoice = ResourceLoader.load("res://src/ui/EncounterChoice.tscn") + for level in GameState.encounters.keys(): + print(level) + var name = "Level" + str(level) + var choice = encounterChoice.instance() + choice.name = name + choice.initialize(len(GameState.encounters[level])) + choice.set_global_position(get_node("Level" + str(level) + "Location").get_global_position()) + choice.set_global_rotation(get_node("Level" + str(level) + "Location").get_global_rotation()) + choice.set_global_scale(get_node("Level" + str(level) + "Location").get_global_scale()) + var x = 0 + while x < len(GameState.encounters[level]): + # Fixes the rotation of the individual buttons + var n = choice.find_node("Option" + str(x)) + if not n: + continue + n.set_rotation( + -(find_node("Level" + str(level) + "Location").get_global_rotation()) + ) + # Set icon and tooltip + print("Checking for icons related to '" + GameState.encounters[level][x]["type"] + "'") + var texture = ResourceLoader.load("res://assets/encounterIcon" + GameState.encounters[level][x]["type"] + ".png") + var texture_pressed = ResourceLoader.load("res://assets/encounterIcon" + GameState.encounters[level][x]["type"] + "_pressed.png") + if texture: + n.set_normal_texture(texture) + if texture_pressed: + n.set_pressed_texture(texture_pressed) + n.set_disabled(true) + n.set_tooltip(GameState.encounters[level][x]["type"]) + if GameState.encounters[level][x]["selected"]: + # The texture change is used since when disabled the normal_texture is shown regardless of press state. + n.set_pressed(true) + n.set_normal_texture(n.get_pressed_texture()) + x += 1 + if GameState.current_state == 4: # picking course + choice.activate_options() + self.add_child(choice) + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/src/ui/Map.tscn b/src/ui/Map.tscn new file mode 100644 index 0000000..32cdea7 --- /dev/null +++ b/src/ui/Map.tscn @@ -0,0 +1,50 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://assets/planet placeholder.png" type="Texture" id=1] +[ext_resource path="res://src/ui/Map.gd" type="Script" id=2] + +[node name="Map" type="Node2D"] +script = ExtResource( 2 ) + +[node name="Planet" type="TextureRect" parent="."] +margin_left = 298.328 +margin_top = 212.136 +margin_right = 598.328 +margin_bottom = 512.136 +rect_scale = Vector2( 0.66, 0.66 ) +texture = ExtResource( 1 ) +stretch_mode = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Level0Location" type="Node2D" parent="."] +position = Vector2( 81.8951, 64.2559 ) +scale = Vector2( 0.9, 0.9 ) + +[node name="Level1Location" type="Node2D" parent="."] +position = Vector2( 686.657, 109.613 ) +scale = Vector2( 0.95, 0.95 ) + +[node name="Level2Location" type="Node2D" parent="."] +position = Vector2( 633.741, 343.958 ) +rotation = 1.22173 +scale = Vector2( 1.05, 1.05 ) + +[node name="Level3Location" type="Node2D" parent="."] +position = Vector2( 371.677, 463.651 ) +scale = Vector2( 1.15, 1.15 ) + +[node name="Level4Location" type="Node2D" parent="."] +position = Vector2( 265.844, 239.385 ) +rotation = 2.79253 +scale = Vector2( 1.05, 1.05 ) + +[node name="Level5Location" type="Node2D" parent="."] +position = Vector2( 506.488, 220.486 ) + +[node name="Line2D" type="Line2D" parent="."] +visible = false +points = PoolVector2Array( 674.571, 84.9249, 667.428, 67.4635, 654.729, 50.0021, 622.187, 36.5092, 550.754, 19.8415, 449.16, 13.4919, 357.091, 18.2541, 229.305, 36.5092, 118.981, 68.2572 ) +width = 5.0 +default_color = Color( 0.545098, 1, 0.4, 1 ) diff --git a/src/ui/ShipStats.gd b/src/ui/ShipStats.gd new file mode 100644 index 0000000..189803f --- /dev/null +++ b/src/ui/ShipStats.gd @@ -0,0 +1,31 @@ +extends Control + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + connect("ship_stats_changed", self, "_on_update_stats") + self.update_stats() + +func _on_update_stats(): + self.update_stats() + +func update_stats(): + get_node("Container/Health").set_value(GameState.ship_stats["health"]) + get_node("Container/Supplies").set_value(GameState.ship_stats["supplies"]) + get_node("Container/Crew").set_value(len(GameState.ship_stats["crew"])) + get_node("Container/Crew").set_max(GameState.get_difficulty_data("maximum_crew")) + get_node("Container/DeltaV").set_bbcode("[center]" + str(GameState.ship_stats["deltav"]) + " DeltaV[/center]") + get_node("Container/Altitude").set_value(GameState.orbit_stats["altitude"]) + get_node("Container/Altitude").set_max(GameState.get_difficulty_data("starting_altitude")) + get_node("Container/Altitude").set_min(GameState.get_difficulty_data("minimum_altitude")) + get_node("Container/AltitudeLabel").set_bbcode("[center]xxx / yyy[/center]") + get_node("Container/DragContainer/Drag").set_text(str(GameState.orbit_stats["drag"])) + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/src/ui/ShipStats.tscn b/src/ui/ShipStats.tscn new file mode 100644 index 0000000..7876b9f --- /dev/null +++ b/src/ui/ShipStats.tscn @@ -0,0 +1,130 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://src/ui/ShipStats.gd" type="Script" id=1] + +[node name="Control" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 1.68188 +margin_top = -0.840912 +margin_right = 1.68188 +margin_bottom = -0.840942 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Container" type="VBoxContainer" parent="."] +margin_left = -1.0 +margin_top = 407.0 +margin_right = 254.0 +margin_bottom = 601.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="RichTextLabel" type="RichTextLabel" parent="Container"] +margin_right = 255.0 +margin_bottom = 15.0 +grow_horizontal = 2 +grow_vertical = 2 +bbcode_enabled = true +bbcode_text = "[center]Ship Statistics[/center]" +text = "Ship Statistics" +fit_content_height = true + +[node name="Health" type="ProgressBar" parent="Container"] +margin_top = 19.0 +margin_right = 255.0 +margin_bottom = 33.0 +max_value = 1000.0 +step = 1.0 + +[node name="Supplies" type="ProgressBar" parent="Container"] +margin_top = 37.0 +margin_right = 255.0 +margin_bottom = 51.0 +max_value = 1000.0 +step = 1.0 + +[node name="Crew" type="ProgressBar" parent="Container"] +margin_top = 55.0 +margin_right = 255.0 +margin_bottom = 69.0 +min_value = 1.0 +max_value = 15.0 +step = 1.0 +value = 1.0 + +[node name="DeltaV" type="RichTextLabel" parent="Container"] +margin_top = 73.0 +margin_right = 255.0 +margin_bottom = 88.0 +bbcode_enabled = true +bbcode_text = "[center]X / Y Δv[/center]" +text = "X / Y Δv" +fit_content_height = true + +[node name="Label" type="RichTextLabel" parent="Container"] +margin_top = 92.0 +margin_right = 255.0 +margin_bottom = 107.0 +bbcode_enabled = true +bbcode_text = "[center]Orbit Statistics[/center]" +text = "Orbit Statistics" +fit_content_height = true + +[node name="Altitude" type="HSlider" parent="Container"] +margin_top = 111.0 +margin_right = 255.0 +margin_bottom = 127.0 +grow_horizontal = 2 +grow_vertical = 2 +rect_min_size = Vector2( 200, 0 ) +step = 1.0 +editable = false +scrollable = false + +[node name="AltitudeLabel" type="RichTextLabel" parent="Container"] +margin_top = 131.0 +margin_right = 255.0 +margin_bottom = 146.0 +bbcode_enabled = true +fit_content_height = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="DragContainer" type="HBoxContainer" parent="Container"] +margin_top = 150.0 +margin_right = 255.0 +margin_bottom = 165.0 + +[node name="Label" type="Label" parent="Container/DragContainer"] +margin_right = 29.0 +margin_bottom = 14.0 +text = "Drag" + +[node name="Drag" type="RichTextLabel" parent="Container/DragContainer"] +margin_left = 33.0 +margin_right = 233.0 +margin_bottom = 15.0 +rect_min_size = Vector2( 200, 0 ) +fit_content_height = true + +[node name="DvContainer" type="HBoxContainer" parent="Container"] +margin_top = 169.0 +margin_right = 255.0 +margin_bottom = 184.0 + +[node name="Label" type="Label" parent="Container/DvContainer"] +margin_right = 49.0 +margin_bottom = 14.0 +text = "escp dv" + +[node name="EstEscapeDV" type="RichTextLabel" parent="Container/DvContainer"] +margin_left = 53.0 +margin_right = 253.0 +margin_bottom = 15.0 +rect_min_size = Vector2( 200, 0 ) +fit_content_height = true