8000 添加配色板,配色主题以及根据主题更改配色功能;并更改默认主题色为蓝色 by cutekibry · Pull Request #53 · ligen131/equal_to_p · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

添加配色板,配色主题以及根据主题更改配色功能;并更改默认主题色为蓝色 #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bg/dynamic_bg/dynamic_bg.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Node2D
extends ColorRect

signal victory_change(v: bool)

Expand All @@ -24,8 +24,8 @@ func spawn(x_offset, y_offset):
new_pattern.position = Vector2(pat_x, pat_y)
new_pattern.velocity = VELOCITY
victory_change.connect(new_pattern._on_victory_change)
new_pattern._on_victory_change(is_victory)
add_child(new_pattern)
new_pattern._on_victory_change(is_victory)

pat_x += W_STEP
pat_y += H_STEP
Expand All @@ -38,6 +38,8 @@ func set_victory(v: bool):
func _ready():
var x_offset = 0
var y_offset = 0
self.color = ImageLib.get_palette_color_by_name("darkest")

while HEIGHT + y_offset + (WIDTH / W_STEP) * H_STEP > -50:
spawn(x_offset, y_offset)
x_offset += $Timer.wait_time * VELOCITY.x
Expand Down
13 changes: 11 additions & 2 deletions bg/dynamic_bg/dynamic_bg.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@

[ext_resource type="Script" path="res://bg/dynamic_bg/dynamic_bg.gd" id="1_g3cph"]

[node name="DynamicBg" type="Node2D"]
z_index = -4096
[node name="DynamicBg" type="ColorRect"]
z_index = -50
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -1440.0
offset_bottom = -810.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
color = Color(0.141176, 0.223529, 0.4, 1)
script = ExtResource("1_g3cph")

[node name="Timer" type="Timer" parent="."]
Expand Down
10 changes: 6 additions & 4 deletions bg/dynamic_bg/dynamic_bg_pattern/dynamic_bg_pattern.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ func _ready():
else:
$Word1.set_word("qd<"[randi_range(0, 2)])
$Word2.set_word("=*"[randi_range(0, 1)])
$Word1.set_color(ImageLib.get_palette_color_by_name("mid"))
$Word2.set_color(ImageLib.get_palette_color_by_name("mid"))

func _process(delta):
position += velocity * delta
Expand All @@ -19,9 +21,9 @@ func _process(delta):

func _on_victory_change(v: bool):
if v:
$Word1.set_color(ImageLib.PALETTE["golden"])
$Word2.set_color(ImageLib.PALETTE["golden"])
$Word1.set_color(ImageLib.get_palette_color_by_name("light"))
$Word2.set_color(ImageLib.get_palette_color_by_name("light"))
else:
$Word1.set_color(ImageLib.PALETTE["default"])
$Word2.set_color(ImageLib.PALETTE["default"])
$Word1.set_color(ImageLib.get_palette_color_by_name("mid"))
$Word2.set_color(ImageLib.get_palette_color_by_name("mid"))

5 changes: 4 additions & 1 deletion bg/dynamic_bg/dynamic_bg_pattern/dynamic_bg_pattern.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
[ext_resource type="PackedScene" uid="uid://cvx7wowcbfo0r" path="res://objects/word/word.tscn" id="2_7jm3n"]

[node name="DynamicBgPattern" type="Node2D"]
modulate = Color(1, 1, 1, 0.12549)
script = ExtResource("1_hrrmh")

[node name="Word1" parent="." instance=ExtResource("2_7jm3n")]
position = Vector2(-6, 0)
text_id = null
color = null

[node name="Word2" parent="." instance=ExtResource("2_7jm3n")]
position = Vector2(6, 0)
text_id = null
color = null
Binary file added jehkoba64-1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions jehkoba64-1x.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://ds4iv57l5rrm7"
path="res://.godot/imported/jehkoba64-1x.png-02dcbbcc07ceb7ec900cbcaf48b21f3a.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://jehkoba64-1x.png"
dest_files=["res://.godot/imported/jehkoba64-1x.png-02dcbbcc07ceb7ec900cbcaf48b21f3a.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
4 changes: 2 additions & 2 deletions levels/base_level/base_level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ func _on_block_occupied_card_changed(_node) -> void:
if i != 0:
if ExprValidator.is_smile(expr[i-1]+expr[i]):
# print(expr[i-1]+expr[i])
block_array[i-1].set_color(ImageLib.PALETTE["golden"])
block_array[i].set_color(ImageLib.PALETTE["golden"])
block_array[i-1].set_color(ImageLib.get_palette_color_by_name("golden"))
block_array[i].set_color(ImageLib.get_palette_color_by_name("golden"))

func _input(event: InputEvent):
if event is InputEventKey:
Expand Down
2 changes: 1 addition & 1 deletion main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ func _on_main_menu_enter_level():
func _on_bgm_player_finished():
$BGMPlayer.play()
func set_victory(v: bool):
$Bg/DynamicBg.set_victory(v)
$DynamicBg.set_victory(v)
8 changes: 4 additions & 4 deletions main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
[node name="Main" type="Node"]
script = ExtResource("1_nb6uf")

[node name="MainMenu" parent="." instance=ExtResource("1_fk6j6")]

[node name="Bg" type="Node" parent="."]
[node name="DynamicBg" parent="." instance=ExtResource("2_8k4il")]
offset_right = 0.0
offset_bottom = 0.0

[node name="DynamicBg" parent="Bg" instance=ExtResource("2_8k4il")]
[node name="MainMenu" parent="." instance=ExtResource("1_fk6j6")]

[node name="BGMPlayer" type="AudioStreamPlayer2D" parent="."]
position = Vector2(234, 150)
Expand Down
4 changes: 2 additions & 2 deletions objects/block/block.gd
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func shake(is_frame_red: bool) -> void:
if self.occupied_card != null:
self.occupied_card.shake(not is_frame_red, SHAKE_AMOUNT, $ShakeTimer.wait_time) # 若框不红,则里面的字要红
elif not is_frame_red:
$Word.set_color(ImageLib.PALETTE["red"])
$Word.set_color(ImageLib.get_palette_color_by_name("red"))

if is_frame_red:
$GoalFrameSprite.animation = "red"
Expand All @@ -120,5 +120,5 @@ func _process(_delta):
func _on_shake_timer_timeout() -> void:
self.is_shaking = false
$GoalFrameSprite.animation = "default"
$Word.set_color(ImageLib.PALETTE["default"])
$Word.set_color(ImageLib.get_palette_color_by_name("black"))

21 changes: 13 additions & 8 deletions objects/card/card.gd
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func shake(is_letter_red: bool, amount: float, duration: float) -> void:
self.is_shaking = true

if is_letter_red:
$Word.set_color(ImageLib.PALETTE["red"])
$Word.set_color(ImageLib.get_palette_color_by_name("red"))
else:
$HighlightSprite.visible = false

Expand All @@ -102,12 +102,17 @@ func set_victory(v: bool):
## 设置字符为 [param value],同时更新卡背颜色。
func set_word(value: String) -> void:
$Word.set_word(value)
var card_type := "card-%s" % ExprValidator.get_char_type_as_str(get_word()).to_lower() # 根据单词类型获取卡牌类型
if ImageLib.PALETTE.has(card_type): # 如果配色盘中包含该卡牌类型对应颜色,则更新卡背颜色
ImageLib.update_animation(
$CardBackSprite, 1, 3, 1, "res://objects/card/card%d.png",
ImageLib.PALETTE["lightblue"], ImageLib.PALETTE[card_type]
)
var new_color_name: String
if ExprValidator.get_char_type_as_str(get_word()) in ["VAR", "CONST"]:
new_color_name = "light"
else:
new_color_name = "lightest"

ImageLib.update_animation(
$CardBackSprite, 1, 3, 1, "res://objects/card/card%d.png",
ImageLib.get_palette_color_by_info("blue", "light"),
ImageLib.get_palette_color_by_name(new_color_name)
)


## 获取字符。
Expand Down Expand Up @@ -166,4 +171,4 @@ func _on_tree_exiting():

func _on_shake_timer_timeout():
self.is_shaking = false
$Word.set_color(ImageLib.PALETTE["default"])
$Word.set_color(ImageLib.get_palette_color_by_name("black"))
12 changes: 6 additions & 6 deletions objects/card/card.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

[ext_resource type="Script" path="res://objects/card/card.gd" id="1_0bviv"]
[ext_resource type="PackedScene" uid="uid://cvx7wowcbfo0r" path="res://objects/word/word.tscn" id="1_ns36n"]
[ext_resource type="Texture2D" uid="uid://cfbqh1k0etr6g" path="res://objects/card/card1.png" id="3_o4f0v"]
[ext_resource type="Texture2D" uid="uid://c8qjbksyn1bqt" path="res://objects/card/card2.png" id="4_c30j1"]
[ext_resource type="Texture2D" uid="uid://bevrfq1hhyqwe" path="res://objects/card/card3.png" id="5_w81n3"]
[ext_resource type="Texture2D" uid="uid://mmtuv34pq4t2" path="res://objects/card/card1.png" id="2_m034v"]
[ext_resource type="Texture2D" uid="uid://ct5w4n7kylfuc" path="res://objects/card/card2.png" id="3_2vd1f"]
[ext_resource type="Texture2D" uid="uid://c6f6j4aln0qvp" path="res://objects/card/card3.png" id="4_wleyv"]
[ext_resource type="Texture2D" uid="uid://pmapbo480in1" path="res://objects/card/card_highlight_border.png" id="7_kix4t"]
[ext_resource type="AudioStream" uid="uid://cj4v8ehypq3sk" path="res://objects/card/put_down.wav" id="7_u4ylf"]

[sub_resource type="SpriteFrames" id="SpriteFrames_fo0r0"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_o4f0v")
"texture": ExtResource("2_m034v")
}, {
"duration": 1.0,
"texture": ExtResource("4_c30j1")
"texture": ExtResource("3_2vd1f")
}, {
"duration": 1.0,
"texture": ExtResource("5_w81n3")
"texture": ExtResource("4_wleyv")
}],
"loop": true,
"name": &"default",
Expand Down
Binary file modified objects/card/card1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion objects/card/card1.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

importer="texture"
type="CompressedTexture2D"
uid="uid://cfbqh1k0etr6g"
uid="uid://mmtuv34pq4t2"
path="res://.godot/imported/card1.png-a70bfeaf7072e44918be31de484a175d.ctex"
metadata={
"vram_texture": false
Expand Down
Binary file modified objects/card/card2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion objects/card/card2.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

importer="texture"
type="CompressedTexture2D"
uid="uid://c8qjbksyn1bqt"
uid="uid://ct5w4n7kylfuc"
path="res://.godot/imported/card2.png-ac2767fabcf91e439932ee4b59f788bf.ctex"
metadata={
"vram_texture": false
Expand Down
Binary file modified objects/card/card3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion objects/card/card3.png.import
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

importer="texture"
type="CompressedTexture2D"
uid="uid://bevrfq1hhyqwe"
uid="uid://c6f6j4aln0qvp"
path="res://.godot/imported/card3.png-d9431fdb530fc93bbd1398924fd9c0a1.ctex"
metadata={
"vram_texture": false
Expand Down
18 changes: 13 additions & 5 deletions objects/card_base/card_base.gd
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,19 @@ func draw_card():
## 设置字符为 e,并更新卡背颜色。
func set_word(e: String) -> void:
$Word.set_word(e)

var new_color_name: String
if ExprValidator.get_char_type_as_str(e) in ["VAR", "CONST"]:
new_color_name = "light"
else:
new_color_name = "lightest"
ImageLib.update_animation(
$CardBaseSprite, 1, 3, 1, "res://objects/card_base/card_base.png",
ImageLib.get_palette_color_by_info("blue", "light"),
ImageLib.get_palette_color_by_name(new_color_name)
)

var card_type := "card-%s" % ExprValidator.get_char_type_as_str(e).to_lower()
if ImageLib.PALETTE.has(card_type):
ImageLib.update_animation($CardBaseSprite, 1, 1, 1, "res://objects/card_base/card_base%d.png",
ImageLib.PALETTE["lightblue"], ImageLib.PALETTE[card_type])
$DisabledSprite.texture = ImageLib.replace_palette_colors_in_image($DisabledSprite.texture)


## 获取字符。
Expand Down Expand Up @@ -129,5 +137,5 @@ func _on_mouse_exited():
available_stat = DEFAULT


func _on_cards_child_exiting_tree(node: Node) -> void:
func _on_cards_child_exiting_tree(_node: Node) -> void:
set_card_count(self.card_count + 1)
Binary file added objects/card_base/card_base.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions objects/card_base/card_base.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bf6r7pnuuk5kr"
path="res://.godot/imported/card_base.png-a60b964691c8dbc2cdebd8962b3939cb.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://objects/card_base/card_base.png"
dest_files=["res://.godot/imported/card_base.png-a60b964691c8dbc2cdebd8962b3939cb.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
6 changes: 4 additions & 2 deletions objects/card_base/card_base.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[gd_scene load_steps=10 format=3 uid="uid://d35prv6j48a2y"]

[ext_resource type="Script" path="res://objects/card_base/card_base.gd" id="1_k5qn1"]
[ext_resource type="Texture2D" uid="uid://bf6r7pnuuk5kr" path="res://objects/card_base/card_base.png" id="2_jovan"]
[ext_resource type="PackedScene" uid="uid://cvx7wowcbfo0r" path="res://objects/word/word.tscn" id="2_jvsp3"]
[ext_resource type="FontFile" uid="uid://1000owdyvwfg" path="res://fonts/unifont-15.1.04.otf" id="3_0qykx"]
[ext_resource type="Texture2D" uid="uid://b5d2rfms7vyfi" path="res://objects/card_base/card_base1.png" id="3_h7i1h"]
[ext_resource type="Texture2D" uid="uid://bkjbrw1ppac5q" path="res://objects/card_base/card_base_disabled.png" id="4_0unxr"]
[ext_resource type="Texture2D" uid="uid://bkuwo3g8pyuyi" path="res://objects/card_base/card_base_highlight_border.png" id="5_r41oe"]
[ext_resource type="AudioStream" uid="uid://0sefo32v1jne" path="res://objects/card_base/pick_up.wav" id="7_0c7kt"]
Expand All @@ -15,7 +15,7 @@ size = Vector2(28, 26)
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_h7i1h")
"texture": ExtResource("2_jovan")
}],
"loop": true,
"name": &"default",
Expand All @@ -42,6 +42,8 @@ sprite_frames = SubResource("SpriteFrames_bhb3x")

[node name="Word" parent="." instance=ExtResource("2_jvsp3")]
frame_progress = 0.953211
text_id = null
color = null

[node name="HighlightSprite" type="Sprite2D" parent="."]
visible = false
Expand Down
Binary file removed objects/card_base/card_base1.png
Binary file not shown.
Binary file modified objects/card_base/card_base_disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified objects/styled_button/button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added objects/styled_button/button_disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions objects/styled_button/button_disabled.png.import
629A
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://hld6oeivwkrn"
path="res://.godot/imported/button_disabled.png-f5ba9e08bceb4e66e56efb835a6e9274.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://objects/styled_button/button_disabled.png"
dest_files=["res://.godot/imported/button_disabled.png-f5ba9e08bceb4e66e56efb835a6e9274.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file modified objects/styled_button/button_highlighted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
0