Some snapshot tools (#680)

variable for easily toggling on and off snapshot mode, and also some simple prints for things like unix time and what snapshot build the game would currently be on upon launch
This commit is contained in:
SkyanUltra 2025-11-22 11:38:40 -05:00 committed by GitHub
parent 7ca6fe8611
commit c41d6fda47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 10 deletions

View file

@ -917,12 +917,11 @@ color = Color(0, 0, 0, 1)
autostart = true
[node name="DevBuildWarning" type="Label" parent="CanvasLayer2/VersionLabel"]
visible = false
layout_mode = 1
offset_top = 16.0
offset_right = 56.0
offset_bottom = 32.0
text = "DEVELOPMENT BUILD! EXPECT BUGS!"
layout_mode = 0
offset_top = 14.0
offset_right = 128.0
offset_bottom = 30.0
text = "SNAPSHOT BUILD - EXPECT BUGS!"
uppercase = true
[node name="ColorRect" type="ColorRect" parent="CanvasLayer2/VersionLabel/DevBuildWarning"]
@ -934,7 +933,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 1)
color = Color(0, 0, 0, 0.49803922)
[node name="DropShadow" parent="." instance=ExtResource("5_8t4ah")]

View file

@ -39,6 +39,7 @@ const ROM_ASSETS_VERSION := 1
var server_version := -1
var current_version := -1
var version_number := ""
var is_snapshot := true
const LEVEL_THEMES := {
"SMB1": SMB1_LEVEL_THEMES,
@ -175,10 +176,10 @@ var p_switch_timer_paused := false
var debug_mode := false
func _ready() -> void:
if is_snapshot: get_build_time()
if OS.is_debug_build(): debug_mode = false
current_version = get_version_number()
get_server_version()
if OS.is_debug_build():
debug_mode = false
setup_config_dirs()
check_for_rom()
@ -279,7 +280,25 @@ func handle_p_switch(delta: float) -> void:
AudioManager.stop_music_override(AudioManager.MUSIC_OVERRIDES.PSWITCH)
func get_build_time() -> void:
print(int(Time.get_unix_time_from_system()))
# SkyanUltra: Slightly expanded function to make it easier to get snapshot build numbers.
var date = Time.get_date_dict_from_system()
var year_last_two = date.year % 100
var now = Time.get_unix_time_from_system()
print("[b][color=cyan]Current unix time:[/color][/b] ", int(now))
var start_of_year = Time.get_unix_time_from_datetime_dict({
"year": date.year,
"month": 1,
"day": 1,
"hour": 0,
"minute": 0,
"second": 0
})
var days_since_year_start = int((now - start_of_year) / 86400)
@warning_ignore("integer_division")
var week = int(days_since_year_start / 7) + 1
var build_date = "%02dw%02d" % [year_last_two, week]
print_rich("[b][color=cyan]Partial snapshot build ID:[/color][/b] ", build_date)
func get_version_number() -> int:
var number = (FileAccess.open("res://version.txt", FileAccess.READ).get_as_text())

View file

@ -27,6 +27,7 @@ func _enter_tree() -> void:
func _ready() -> void:
setup_stars()
$CanvasLayer2/VersionLabel/DevBuildWarning.visible = Global.is_snapshot
Global.level_theme_changed.connect(setup_stars)
DiscoLevel.in_disco_level = false
get_tree().paused = false