Indicators
This commit is contained in:
+94
-12
@@ -1,16 +1,31 @@
|
||||
extends Control
|
||||
|
||||
@export var item_pages: Array[Control]
|
||||
@export var stage_page_scroller: ScrollContainer
|
||||
|
||||
const ITEM_BUTTON = preload("uid://d3xjfxwe3w16v")
|
||||
|
||||
const SPEED_TEXTURE_NAME_TEMPLATE = "res://UI/TopMenu/Time&Speed/Time%s.png"
|
||||
|
||||
const PAGE_COUNT = 5
|
||||
const PAGE_WIDTH = 1080
|
||||
const DRAG_TOLERANCE = 360
|
||||
const SWIPE_DURATION: float = 2
|
||||
const SWIPE_DELAY = 2000 # msec
|
||||
|
||||
@onready var stage_page_scroller: ScrollContainer = $StageRows/PageScroller
|
||||
|
||||
@onready var item_pages: Array[Control] = [
|
||||
$StageRows/PageScroller/HBoxContainer/ForcePage/Forces,
|
||||
$StageRows/PageScroller/HBoxContainer/ResourcePage/HBoxContainer/Resources,
|
||||
$StageRows/PageScroller/HBoxContainer/StarPage/Stars,
|
||||
$StageRows/PageScroller/HBoxContainer/StructurePage/Structures,
|
||||
$StageRows/PageScroller/HBoxContainer/LifePage/Planets/Life,
|
||||
$StageRows/PageScroller/HBoxContainer/LifePage/Planets/LivingPlanet,
|
||||
$StageRows/PageScroller/HBoxContainer/LifePage/Planets/Civ0,
|
||||
$StageRows/PageScroller/HBoxContainer/LifePage/Planets/Civ1,
|
||||
$StageRows/PageScroller/HBoxContainer/LifePage/Planets/Civ2,
|
||||
$StageRows/PageScroller/HBoxContainer/LifePage/Planets/Civ3,
|
||||
$StageRows/PageScroller/HBoxContainer/LifePage/Planets/Civ4
|
||||
]
|
||||
|
||||
@onready var g_entity_descriptions: Array = [
|
||||
$StageRows/PageScroller/HBoxContainer/ForcePage/Description,
|
||||
$StageRows/PageScroller/HBoxContainer/ResourcePage/Description,
|
||||
@@ -19,7 +34,22 @@ const SWIPE_DELAY = 2000 # msec
|
||||
$StageRows/PageScroller/HBoxContainer/LifePage/Description
|
||||
]
|
||||
|
||||
@onready var g_top_menu: TopMenu = $StageRows/TopMenu
|
||||
@onready var date_time: Label = $StageRows/TopMenu/InfoPanel/DateTime
|
||||
|
||||
@onready var g_speed_icons: Array = [
|
||||
$StageRows/TopMenu/InfoPanel/Speed/Speed1,
|
||||
$StageRows/TopMenu/InfoPanel/Speed/Speed2,
|
||||
$StageRows/TopMenu/InfoPanel/Speed/Speed3,
|
||||
$StageRows/TopMenu/InfoPanel/Speed/Speed4,
|
||||
$StageRows/TopMenu/InfoPanel/Speed/Speed5,
|
||||
$StageRows/TopMenu/InfoPanel/Speed/Speed6,
|
||||
$StageRows/TopMenu/InfoPanel/Speed/Speed7,
|
||||
$StageRows/TopMenu/InfoPanel/Speed/Speed8
|
||||
]
|
||||
|
||||
@onready var g_time_minus: TextureButton = $StageRows/TopMenu/TimeMinus
|
||||
@onready var g_time_plus: TextureButton = $StageRows/TopMenu/TimePlus
|
||||
|
||||
|
||||
|
||||
var g_tween: Tween = null
|
||||
@@ -40,6 +70,20 @@ var ActiveEntities: Dictionary = {}
|
||||
|
||||
var owniverse = Owniverse.new()
|
||||
|
||||
func set_datetime(value: String):
|
||||
date_time.text = value
|
||||
|
||||
func on_putton_pressed(button_name: String):
|
||||
#emit_signal("button_pressed", button_name)
|
||||
print(button_name)
|
||||
#SaveManager.save_settings()
|
||||
#SaveManager.ch()
|
||||
#print(Global.filename)
|
||||
|
||||
|
||||
#func _on_speed_change(delta: int) -> void:
|
||||
#print(delta)
|
||||
|
||||
|
||||
func entity_activated(entity: OwniverseEntity) -> void:
|
||||
_control_page(entity)
|
||||
@@ -111,6 +155,7 @@ func _check_counters(delta: float) -> Array:
|
||||
|
||||
return actions
|
||||
|
||||
|
||||
func _do_actions(actions: Array) -> void:
|
||||
for action: String in actions:
|
||||
match action:
|
||||
@@ -153,17 +198,54 @@ func _input(event: InputEvent) -> void:
|
||||
|
||||
func _ready() -> void:
|
||||
_init_entities()
|
||||
|
||||
func _on_button_pressed(extra_param): # теперь 1 параметр
|
||||
print("Кнопка нажата! Параметр:", extra_param)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
# Update date
|
||||
var dt: float = owniverse.add_time_delta(delta)
|
||||
if owniverse.g_speed > 1:
|
||||
dt = round(dt)
|
||||
else:
|
||||
dt = snapped(dt, 0.1)
|
||||
|
||||
g_top_menu.set_datetime(str(dt))
|
||||
|
||||
var sdt: String = str(snapped(owniverse.add_time_delta(delta), 0.1))
|
||||
set_datetime(sdt)
|
||||
|
||||
var actions = _check_counters(delta)
|
||||
_do_actions(actions)
|
||||
|
||||
|
||||
func _on_burger_button_pressed() -> void:
|
||||
print("b")
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_report_button_pressed() -> void:
|
||||
print("r")
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_time_minus_pressed() -> void:
|
||||
_change_speed(-1)
|
||||
|
||||
|
||||
func _on_time_plus_pressed() -> void:
|
||||
_change_speed(+1)
|
||||
|
||||
|
||||
func _change_speed(delta: int) -> void:
|
||||
var speed: int = owniverse.change_speed(delta)
|
||||
var ind: int = 1
|
||||
for icon in g_speed_icons:
|
||||
if ind <= speed:
|
||||
icon.visible = true
|
||||
else:
|
||||
icon.visible = false
|
||||
ind += 1
|
||||
if speed == 1:
|
||||
g_time_minus.texture_normal = load(SPEED_TEXTURE_NAME_TEMPLATE % "x")
|
||||
g_time_plus.texture_normal = load(SPEED_TEXTURE_NAME_TEMPLATE % "2")
|
||||
elif speed == Global.SPEED_LIMIT:
|
||||
g_time_minus.texture_normal = load(SPEED_TEXTURE_NAME_TEMPLATE % str(Global.SPEED_LIMIT - 1))
|
||||
g_time_plus.texture_normal = load(SPEED_TEXTURE_NAME_TEMPLATE % "x")
|
||||
else:
|
||||
g_time_minus.texture_normal = load(SPEED_TEXTURE_NAME_TEMPLATE % str(speed - 1))
|
||||
g_time_plus.texture_normal = load(SPEED_TEXTURE_NAME_TEMPLATE % str(speed + 1))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user