Skip to content

Commit

Permalink
feat: pull metsys context reset into Vania static func
Browse files Browse the repository at this point in the history
This helper isn't perfect yet (not yet working when switching games),
but it somewhat resets the editor context, so it's a start.
  • Loading branch information
russmatney committed Nov 22, 2024
1 parent ec05daf commit 334972e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
14 changes: 14 additions & 0 deletions src/dino/modes/vania/Vania.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
extends Node2D
class_name Vania

## static #############################################

## NOTE this doesn't completely work yet!
static func reset_metsys_context(metsys_settings):
Log.info("resetting MetSys context")
MetSys.settings = metsys_settings

# this is typically already connected
U._connect(MetSys.settings.theme_changed, MetSys._update_theme)
MetSys._update_theme()
# MetSys.map_data = MapData.new()
MetSys.map_data.load_data()

## vars ##################################################3

Expand Down
13 changes: 3 additions & 10 deletions src/dino/vania/VaniaGame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var ready_for_next: bool = false
var room_defs: Array[VaniaRoomDef] = []
@export var map_def: MapDef

@export var MetSysSettings = preload("res://src/dino/vania/VaniaMetSysSettings.tres")
@export var vania_metsys_settings = preload("res://src/dino/vania/VaniaMetSysSettings.tres")

@onready var hud = $%DinoHUD
var time: float = 0
Expand Down Expand Up @@ -84,15 +84,8 @@ func all_rooms_visited():
func _enter_tree():
# if Engine.is_editor_hint():
# return
Log.warn("adjusting MetSys settings for Vania Game")
# set expected metsys settings
MetSys.settings = MetSysSettings

# TODO ignore if already connected
MetSys.settings.theme_changed.connect(MetSys._update_theme)
MetSys._update_theme()
# MetSys.map_data = MapData.new()
MetSys.map_data.load_data()

Vania.reset_metsys_context(vania_metsys_settings)

## ready #######################################################

Expand Down
10 changes: 2 additions & 8 deletions src/games/hatbot/HatBotGame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@ class_name HatBotGame
# this script based initially on MetSys/SampleProject/Scripts/Game.gd

@export var first_room: String = "RoomZero.tscn"
@export var MetSysSettings = preload("res://src/games/hatbot/HatBotMetSysSettings.tres")
@export var hatbot_metsys_settings = preload("res://src/games/hatbot/HatBotMetSysSettings.tres")
@export var player_entity: DinoPlayerEntity

func _enter_tree():
# if Engine.is_editor_hint():
# return
Log.warn("adjusting MetSys settings for HatBot Game")
MetSys.settings = MetSysSettings

# TODO ignore if already connected
MetSys.settings.theme_changed.connect(MetSys._update_theme)
MetSys._update_theme()
# MetSys.map_data = MapData.new()
MetSys.map_data.load_data()
Vania.reset_metsys_context(hatbot_metsys_settings)

func _ready():
if Engine.is_editor_hint():
Expand Down
11 changes: 2 additions & 9 deletions src/games/shirt/ShirtGame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,14 @@ class_name ShirtGame
# this script based initially on MetSys/SampleProject/Scripts/Game.gd

@export var first_room: String = "RoomZero.tscn"
@export var MetSysSettings = preload("res://src/games/shirt/ShirtMetSysSettings.tres")
@export var shirt_metsys_settings = preload("res://src/games/shirt/ShirtMetSysSettings.tres")
@export var player_entity: DinoPlayerEntity

func _enter_tree():
# if Engine.is_editor_hint():
# return

Log.warn("adjusting MetSys settings for Shirt Game")
MetSys.settings = MetSysSettings

# TODO ignore if already connected
MetSys.settings.theme_changed.connect(MetSys._update_theme)
MetSys._update_theme()
# MetSys.map_data = MapData.new()
MetSys.map_data.load_data()
Vania.reset_metsys_context(shirt_metsys_settings)

func _ready():
if Engine.is_editor_hint():
Expand Down

0 comments on commit 334972e

Please sign in to comment.