From 41de333be68a85f96829678cdb22d0cc906a3e8b Mon Sep 17 00:00:00 2001 From: cutekibry Date: Sun, 18 Feb 2024 19:17:07 +0800 Subject: [PATCH] =?UTF-8?q?refactor(chapter=5Fmenu)!:=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=AB=A0=E8=8A=82=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 由于 level_menu 已经可以支持切换章节,故删除 chapter_menu。 --- levels/chapter_menu/chapter_menu.gd | 40 --------------------------- levels/chapter_menu/chapter_menu.tscn | 17 ------------ 2 files changed, 57 deletions(-) delete mode 100644 levels/chapter_menu/chapter_menu.gd delete mode 100644 levels/chapter_menu/chapter_menu.tscn diff --git a/levels/chapter_menu/chapter_menu.gd b/levels/chapter_menu/chapter_menu.gd deleted file mode 100644 index ffe5b78..0000000 --- a/levels/chapter_menu/chapter_menu.gd +++ /dev/null @@ -1,40 +0,0 @@ -extends Node2D - -class_name ChapterMenu - -const BaseLevelScn := preload("res://levels/base_level/base_level.tscn") -const LevelButtonScn := preload("res://levels/chapter_menu/level_menu/level_button/level_button.tscn") -const LevelMenuScn := preload("res://levels/chapter_menu/level_menu/level_menu.tscn") - -# Called when the node enters the scene tree for the first time. - -@export var chapter_id : int = 0 -const button_width : int = 50 -const button_heigth : int = 50 - -func init() -> void: - var chap_num : int = LevelData.get_chapter_count() - for chap_id in range(0, chap_num): - # print(chap_id) - var level_num : int = LevelData.get_chapter_level_count(chap_id) - var button = LevelButtonScn.instantiate(); - var x : int = button_width * (chap_id % 9) + 60 - var y : int = button_heigth * (chap_id / 9) + 100 - button.init(chap_id, level_num, Vector2(x, y), 0) - button.enter_chapter.connect(_is_choose_chapter) - add_child(button) - - -func _ready(): - # print("ready") - init() - #print(LevelData.LEVEL_DATA[chapter_id]) - # print(chapter_num) - - -func _is_choose_chapter(chap_id : int, level_num : int): - var level_menu = LevelMenuScn.instantiate() - level_menu.init(chap_id, level_num) - # print("here ready to change scene to ", chapter_id) - get_tree().root.add_child(level_menu) - queue_free() diff --git a/levels/chapter_menu/chapter_menu.tscn b/levels/chapter_menu/chapter_menu.tscn deleted file mode 100644 index 86aed30..0000000 --- a/levels/chapter_menu/chapter_menu.tscn +++ /dev/null @@ -1,17 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://d138qs4pakk22"] - -[ext_resource type="Script" path="res://levels/chapter_menu/chapter_menu.gd" id="1_sfx21"] -[ext_resource type="FontFile" uid="uid://1000owdyvwfg" path="res://fonts/unifont-15.1.04.otf" id="2_y2jwf"] - -[node name="ChapterMenu" type="Node2D"] -script = ExtResource("1_sfx21") - -[node name="Label" type="Label" parent="."] -custom_minimum_size = Vector2(480, 1) -offset_top = 8.0 -offset_right = 480.0 -offset_bottom = 31.0 -theme_override_fonts/font = ExtResource("2_y2jwf") -text = "Chapter Select" -horizontal_alignment = 1 -vertical_alignment = 1