完善消息提示功能

This commit is contained in:
cakipaul 2024-12-24 09:16:06 +08:00
parent d42e40a4a0
commit cdac22503b
16 changed files with 173 additions and 86 deletions

File diff suppressed because one or more lines are too long

View File

@ -18,13 +18,14 @@ class EntityActionConfig:
var next_state: String = "" # empty means keep current state
var animation: String = ""
var sound: String = ""
var callback: String = ""
var callback_args := []
var callback: Callable
@export var entity_name: String = ""
@export var placeholder_rect: Rect2 = Rect2(0, 0, 0, 0)
@export var placeholder_size: Vector2 = Vector2(32, 64)
@export var offset: Vector2 = Vector2(0, 0)
@export var entity_title: String = ""
@export var entity_note: String = ""
@export var initializer: Callable
@export var entity_states: Array[EntityStateConfig]
@export var entity_actions: Array[EntityActionConfig]

View File

@ -1,11 +1,22 @@
class_name SceneConfig extends Resource
@export var scene_name: String = ""
## ground
@export var foreground_scale: Vector2 = Vector2(1.2, 1.2)
@export var foreground_position: Vector2 = Vector2(0, 0)
@export var foreground_scene: PackedScene
@export var background_scale: Vector2 = Vector2(1.0, 1.0)
@export var background_position: Vector2 = Vector2(0, 0)
@export var background_scene: PackedScene
## player and camera
@export var player_initial_position: Vector2 = Vector2(300, 186)
@export var player_initial_direction: Vector2 = Vector2(1, -1)
@export var player_movement_rect: Rect2 = Rect2(0, 0, 0, 0)
@export var camera_rect: Rect2 = Rect2(0, -1000, 664, 2317) # 564*317, 16:9
## sound
@export_enum("none", "normal", "carpet", "concrete", "grass", "snow")
var footstep_type: String = "grass"
var bgm: String = ""

View File

@ -1,5 +1,26 @@
{
"items": [
{
"event_date": "12/24/2024",
"item_id": "17350028043797",
"log_content": "* 完善消息提示功能\n * 0.5s 浮现,显示 3s0.5s 隐藏(通过调整 alpha 通道实现)\n * 支持堆积消息\n * 如果有堆积的消息,显示 2s而不是 3s",
"tags": [
"2@ui",
"2@code"
],
"update_date": "12/24/2024"
},
{
"event_date": "12/23/2024",
"item_id": "4123576587",
"log_content": "动画资产管理:分页加载资源\n\n定义基本的规格配置、组装部署、资产填充数据结构",
"tags": [
"2@ui",
"3@art_tool",
"2@design"
],
"update_date": "12/24/2024"
},
{
"event_date": "12/22/2024",
"item_id": "876528753689",

View File

@ -21,6 +21,7 @@ var managers = {
var autosave_timer := Timer.new()
func _ready() -> void:
accessible = _check_archive_dirs()
if !accessible:
@ -34,8 +35,6 @@ func _ready() -> void:
GlobalConfigManager.config.current_selected_save_changed.connect(_check_autosave_options)
GlobalConfigManager.config.auto_save_seconds_changed.connect(_check_autosave_options)
load_all()
SceneManager.pop_notification("预加载完成")
func _check_autosave_options():

View File

@ -1,23 +1,18 @@
class_name GlobalConfig extends Resource
const DEBUG = true
# const DEBUG = false
# .res would be binary encoded, .tres is text encoded
const RES_FILE_FORMAT = ".tres"
const CONFIG_FILE_NAME = "config"
const DEBUG = true
#const DEBUG = false
## layers
const CANVAS_LAYER_VIGNETTE = 1000
const CANVAS_LAYER_PROP_INSPECTOR = 100
const CANVAS_LAYER_UI = 99
const CANVAS_LAYER_FG = 50
const CANVAS_LAYER_BG = -100
const COLOR_BOARDER = Color.BLACK
const _ART_RESOURCE_BASE_DIR = "res://asset/art/"
signal current_selected_save_changed
signal auto_save_seconds_changed

View File

@ -0,0 +1,10 @@
extends Node
enum VIBE {
NORAML,
MYSTERY,
DANGEROUS,
TOUCHING,
}
# light and wind

View File

@ -42,6 +42,7 @@ DialogManager="*res://manager/assemble/dialog/dialog_manager.gd"
CameraManager="*res://manager/camera_manager/camera_manager.gd"
CgManager="*res://manager/cg_manager/cg_manager.gd"
InputManager="*res://manager/input/input_manager.gd"
VibeManager="*res://manager/vibe/vibe_manager.gd"
ArchiveManager="*res://manager/archive_manager/archive_manager.gd"
[display]

View File

@ -2,5 +2,5 @@ extends Marker2D
func tweak_position(velocity, facing_direction):
position.x = facing_direction.x * abs(velocity.x) * 0.3
position.y = facing_direction.y * abs(velocity.y) * 0.3
position.x = facing_direction.x * abs(velocity.x) * 0.2
position.y = facing_direction.y * abs(velocity.y) * 0.2

View File

@ -3,6 +3,3 @@ extends Control
@onready var color_top := %ColorRectTop as ColorRect
@onready var color_bottom := %ColorRectBottom as ColorRect
func _ready() -> void:
color_top.color = GlobalConfig.COLOR_BOARDER
color_bottom.color = GlobalConfig.COLOR_BOARDER

View File

@ -24,7 +24,7 @@ offset_right = 282.0
offset_bottom = 40.0
grow_horizontal = 2
mouse_filter = 2
color = Color(0.372549, 0.0156863, 0.0156863, 1)
color = Color(0.0519829, 0.0179176, 0.00269875, 1)
[node name="ColorRectBottom" type="ColorRect" parent="."]
unique_name_in_owner = true
@ -41,4 +41,4 @@ offset_right = 282.0
grow_horizontal = 2
grow_vertical = 0
mouse_filter = 2
color = Color(0.372549, 0.0156863, 0.0156863, 1)
color = Color(0.0519829, 0.0179176, 0.00269875, 1)

View File

@ -1,4 +1,23 @@
extends Node2D
@export var scene_config: SceneConfig:
set(val):
scene_config = val
_load_scene_config()
@export var deployment_config: DeploymentConfig:
set(val):
deployment_config = val
_load_deployment_config()
func _ready() -> void:
$UILayer.layer = GlobalConfig.CANVAS_LAYER_VIGNETTE
_load_scene_config()
_load_deployment_config()
func _load_scene_config() -> void:
if !scene_config:
return
func _load_deployment_config() -> void:
if !deployment_config:
return

View File

@ -37,13 +37,6 @@ mouse_filter = 2
[node name="MainPlayer" parent="." instance=ExtResource("6_6geb0")]
unique_name_in_owner = true
position = Vector2(300, 187)
current_status = 0
facing_direction = Vector2(1, -1)
running_locked = false
speed_walking = 100.0
speed_runnig = 170.0
speed_laying = 60.0
speed_climbing = 60.0
[node name="CameraFocusMarker" parent="MainPlayer" instance=ExtResource("7_n7qcv")]
unique_name_in_owner = true

View File

@ -1,6 +1,46 @@
extends Control
@onready var label := %RichTextLabel as RichTextLabel
var pending_notifications = []
var tweening := false
func _ready() -> void:
modulate = Color(1, 1, 1, 0)
# test notification in editor
if GlobalConfig.DEBUG:
call_deferred("test")
func test():
show_notification("Hello, 1!", 42)
show_notification("Hello, 2! very very long message, very very loooonnnggggggg!", 2)
show_notification("Hello, 3!", 24)
func show_notification(msg, number):
#TODO: Implement this method
print("show_notification:", msg, number)
if tweening:
pending_notifications.append([msg, number])
else:
label.text = msg
tweening = true
var tween = create_tween()
# 0.5s to show the notification
tween.tween_property(self, "modulate:a", 1, 0.5).set_trans(Tween.TRANS_CUBIC)
# keep the notification
if pending_notifications.size() > 0:
tween.tween_interval(2)
else:
tween.tween_interval(3)
# 0.5s to hide the notification
tween.tween_property(self, "modulate:a", 0, 0.5).set_trans(Tween.TRANS_CUBIC)
# callback
tween.tween_callback(self._check_next)
func _check_next():
if pending_notifications.size() > 0:
var n = pending_notifications.pop_front()
tweening = false
show_notification(n[0], n[1])

View File

@ -26,7 +26,8 @@ theme_override_constants/margin_top = 12
theme_override_constants/margin_right = 24
[node name="RichTextLabel" type="RichTextLabel" parent="MarginContainer"]
custom_minimum_size = Vector2(200, 0)
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 0)
layout_mode = 2
size_flags_horizontal = 8
mouse_filter = 2
@ -34,4 +35,3 @@ text = "notification"
fit_content = true
scroll_active = false
autowrap_mode = 0
text_direction = 2