2026-03-05 20:13:45 +03:00
|
|
|
extends Control
|
|
|
|
|
|
2026-05-05 23:49:12 +03:00
|
|
|
const OWNIVERSE_ITEM = preload("uid://d3xjfxwe3w16v")
|
2026-03-30 00:48:20 +03:00
|
|
|
|
2026-05-31 10:57:44 +03:00
|
|
|
const SPEED_TEXTURE_NAME_TEMPLATE = "res://ui/topmenu/time&speed/time%s.png"
|
2026-04-05 20:15:07 +03:00
|
|
|
|
2026-09-15 22:01:45 +03:00
|
|
|
const ItemDescription = preload("res://world/owniverse/item_description.gd")
|
|
|
|
|
var description_targets: Dictionary = {}
|
|
|
|
|
var description_samples: Dictionary = {}
|
|
|
|
|
var description_rates: Dictionary = {}
|
|
|
|
|
var description_elapsed: float = 0.0
|
|
|
|
|
|
2026-03-09 16:10:35 +03:00
|
|
|
const PAGE_COUNT = 5
|
2026-09-14 07:47:21 +03:00
|
|
|
const RESOURCE_PAGE = 1
|
2026-03-09 16:10:35 +03:00
|
|
|
const PAGE_WIDTH = 1080
|
|
|
|
|
const DRAG_TOLERANCE = 360
|
2026-05-05 23:49:12 +03:00
|
|
|
const SWIPE_DURATION: float = 0.4
|
2026-03-09 16:10:35 +03:00
|
|
|
|
2026-04-05 20:15:07 +03:00
|
|
|
@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
|
|
|
|
|
]
|
|
|
|
|
|
2026-06-03 23:26:44 +03:00
|
|
|
@onready var page_actions: Dictionary[int, OwniverseAction] = {
|
|
|
|
|
2: $StageRows/PageScroller/HBoxContainer/StarPage/Actions,
|
|
|
|
|
3: $StageRows/PageScroller/HBoxContainer/StructurePage/Actions,
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-08 00:23:22 +03:00
|
|
|
@onready var g_item_descriptions: Array = [
|
2026-03-30 00:48:20 +03:00
|
|
|
$StageRows/PageScroller/HBoxContainer/ForcePage/Description,
|
|
|
|
|
$StageRows/PageScroller/HBoxContainer/ResourcePage/Description,
|
|
|
|
|
$StageRows/PageScroller/HBoxContainer/StarPage/Description,
|
|
|
|
|
$StageRows/PageScroller/HBoxContainer/StructurePage/Description,
|
|
|
|
|
$StageRows/PageScroller/HBoxContainer/LifePage/Description
|
|
|
|
|
]
|
|
|
|
|
|
2026-04-05 20:15:07 +03:00
|
|
|
@onready var date_time: Label = $StageRows/TopMenu/InfoPanel/DateTime
|
|
|
|
|
|
|
|
|
|
@onready var g_speed_icons: Array = [
|
2026-04-05 23:26:43 +03:00
|
|
|
$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,
|
2026-04-05 20:15:07 +03:00
|
|
|
$StageRows/TopMenu/InfoPanel/Speed/Speed8
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
@onready var g_time_minus: TextureButton = $StageRows/TopMenu/TimeMinus
|
|
|
|
|
@onready var g_time_plus: TextureButton = $StageRows/TopMenu/TimePlus
|
|
|
|
|
|
2026-03-30 00:48:20 +03:00
|
|
|
|
2026-03-09 16:10:35 +03:00
|
|
|
var g_tween: Tween = null
|
|
|
|
|
var g_dragged_start: Vector2 = Vector2.ZERO
|
|
|
|
|
var g_scroll_start: int = 0
|
2026-06-03 23:26:44 +03:00
|
|
|
#var g_current_page: int = 0
|
2026-03-09 16:10:35 +03:00
|
|
|
|
|
|
|
|
var g_last_scroll_updated: int = 0
|
|
|
|
|
|
|
|
|
|
var f_check_swipe: bool = false
|
|
|
|
|
var g_swipe_time_delta: float = 0
|
|
|
|
|
|
|
|
|
|
var g_counters: Dictionary[String, Counter] = {
|
|
|
|
|
"swipe": Counter.new(),
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-05 23:49:12 +03:00
|
|
|
var g_active_items: Dictionary = {}
|
|
|
|
|
|
2026-09-13 22:57:25 +03:00
|
|
|
var pending_page: int = -1
|
|
|
|
|
|
2026-05-05 23:49:12 +03:00
|
|
|
var owniverse:Owniverse = Owniverse.new()
|
|
|
|
|
var owniverse_items: Dictionary[String, OwniverseItem] = {}
|
2026-08-27 23:04:56 +03:00
|
|
|
var locked_items: Array = []
|
2026-05-05 23:49:12 +03:00
|
|
|
|
2026-03-09 16:10:35 +03:00
|
|
|
|
2026-06-24 23:25:55 +03:00
|
|
|
func set_datetime(value: float):
|
2026-09-15 08:27:04 +03:00
|
|
|
date_time.text = Global.format_number(value, 5) if value != 0.0 else "0.0"
|
2026-04-05 20:15:07 +03:00
|
|
|
|
2026-05-05 23:49:12 +03:00
|
|
|
#region Item manipulations: update and visibility
|
2026-04-05 20:15:07 +03:00
|
|
|
|
|
|
|
|
|
2026-05-05 23:49:12 +03:00
|
|
|
func set_owniverse_item_value() -> void:
|
2026-09-13 22:57:25 +03:00
|
|
|
for item_id in owniverse.items_to_update:
|
|
|
|
|
if owniverse_items.has(item_id):
|
|
|
|
|
owniverse_items[item_id].set_label(owniverse.items_to_update[item_id])
|
|
|
|
|
owniverse.items_to_update.clear()
|
2026-08-28 00:07:18 +03:00
|
|
|
|
2026-05-05 23:49:12 +03:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2026-08-27 23:04:56 +03:00
|
|
|
|
|
|
|
|
func _unlock_items():
|
2026-08-28 00:07:18 +03:00
|
|
|
if locked_items.size() == 0: return
|
2026-08-27 23:04:56 +03:00
|
|
|
var _new_locked_items = []
|
2026-09-13 22:57:25 +03:00
|
|
|
var display_totals: Dictionary = owniverse.get_item_amounts(true)
|
2026-08-27 23:04:56 +03:00
|
|
|
for _item_id in locked_items:
|
|
|
|
|
#print(_item_id ' | ', _entity.unlock)
|
|
|
|
|
var _flag_to_unlock = true
|
|
|
|
|
for _elem in owniverse.entities[_item_id].unlock:
|
2026-09-13 22:57:25 +03:00
|
|
|
if maxf(owniverse.state.stats.total_amount.get(_elem, 0.0), display_totals.get(_elem, 0.0)) < owniverse.entities[_item_id].unlock[_elem]:
|
2026-08-27 23:04:56 +03:00
|
|
|
_flag_to_unlock = false
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if _flag_to_unlock:
|
2026-09-13 22:57:25 +03:00
|
|
|
var item_id: String = owniverse.entities[_item_id].count_as
|
|
|
|
|
if item_id == "":
|
|
|
|
|
item_id = _item_id
|
|
|
|
|
if owniverse_items.has(item_id):
|
|
|
|
|
owniverse_items[item_id].set_visible(true)
|
2026-08-27 23:04:56 +03:00
|
|
|
else:
|
|
|
|
|
_new_locked_items.append(_item_id)
|
2026-08-28 00:07:18 +03:00
|
|
|
locked_items = _new_locked_items
|
2026-08-27 23:04:56 +03:00
|
|
|
|
|
|
|
|
|
2026-05-05 23:49:12 +03:00
|
|
|
func _on_indicator_pressed(indicator_name: String, page: int = 0):
|
|
|
|
|
_set_description(indicator_name, page)
|
2026-03-09 16:10:35 +03:00
|
|
|
|
2026-04-05 23:26:43 +03:00
|
|
|
|
2026-04-08 00:23:22 +03:00
|
|
|
func _set_item_description(item: OwniverseItem) -> void:
|
2026-09-15 22:01:45 +03:00
|
|
|
var category: String = "Entity" if owniverse.entities.has(item.item_id) else "Force"
|
|
|
|
|
var id: String = item.item_id if category == "Entity" else item.item_name.capitalize()
|
|
|
|
|
var page: int = clampi(item.item_page, 0, 4)
|
|
|
|
|
if description_targets.get(page, {}).get("id", "") != id:
|
|
|
|
|
description_samples.erase(id)
|
|
|
|
|
description_rates.erase(id)
|
|
|
|
|
description_targets[page] = {"id": id, "category": category}
|
|
|
|
|
_refresh_descriptions()
|
2026-04-05 23:26:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _set_description(item_name: String, page: int) -> void:
|
2026-09-15 22:01:45 +03:00
|
|
|
description_targets[page] = {"id": item_name, "category": "Indicator"}
|
|
|
|
|
_refresh_descriptions()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _refresh_descriptions() -> void:
|
|
|
|
|
for page in description_targets:
|
|
|
|
|
var target: Dictionary = description_targets[page]
|
|
|
|
|
var label: RichTextLabel = g_item_descriptions[page]
|
|
|
|
|
label.bbcode_enabled = true
|
|
|
|
|
label.text = ItemDescription.render(owniverse, Global, target.id, target.category, description_rates.get(target.id, 0.0))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _update_descriptions(delta: float) -> void:
|
|
|
|
|
description_elapsed += delta
|
|
|
|
|
if description_elapsed < 0.25:
|
|
|
|
|
return
|
|
|
|
|
for page in description_targets:
|
|
|
|
|
var id: String = description_targets[page].id
|
|
|
|
|
var total: float = ItemDescription.quantities(owniverse, id).total
|
|
|
|
|
description_rates[id] = (total - description_samples[id]) / description_elapsed if description_samples.has(id) else 0.0
|
|
|
|
|
description_samples[id] = total
|
|
|
|
|
description_elapsed = 0.0
|
|
|
|
|
_refresh_descriptions()
|
2026-04-05 23:26:43 +03:00
|
|
|
|
2026-03-09 16:10:35 +03:00
|
|
|
|
2026-04-08 00:23:22 +03:00
|
|
|
func _control_page(item: OwniverseItem) -> void:
|
2026-05-05 23:49:12 +03:00
|
|
|
# TODO переписать это ↓
|
|
|
|
|
if !g_active_items.has(item.item_page):
|
|
|
|
|
g_active_items[item.item_page] = null
|
2026-03-30 00:48:20 +03:00
|
|
|
|
2026-05-05 23:49:12 +03:00
|
|
|
var current_item: OwniverseItem = g_active_items[item.item_page]
|
2026-04-08 00:23:22 +03:00
|
|
|
if current_item == item:
|
2026-03-30 00:48:20 +03:00
|
|
|
return
|
2026-03-09 16:10:35 +03:00
|
|
|
|
2026-05-05 23:49:12 +03:00
|
|
|
g_active_items[item.item_page] = item
|
2026-03-30 00:48:20 +03:00
|
|
|
|
2026-04-08 00:23:22 +03:00
|
|
|
if current_item != null and current_item.item_page == item.item_page:
|
|
|
|
|
current_item.set_selection(false)
|
2026-03-30 00:48:20 +03:00
|
|
|
|
2026-04-08 00:23:22 +03:00
|
|
|
item.set_selection(true)
|
2026-03-30 00:48:20 +03:00
|
|
|
|
|
|
|
|
# subpages
|
2026-04-08 00:23:22 +03:00
|
|
|
if item.item_sub_page != -1:
|
|
|
|
|
item_pages[item.item_sub_page].visible = true
|
2026-03-30 00:48:20 +03:00
|
|
|
|
2026-04-08 00:23:22 +03:00
|
|
|
if current_item == null \
|
|
|
|
|
or current_item.item_sub_page == -1 \
|
|
|
|
|
or current_item.item_sub_page == item.item_sub_page:
|
2026-03-30 00:48:20 +03:00
|
|
|
return
|
2026-04-08 00:23:22 +03:00
|
|
|
item_pages[current_item.item_sub_page].visible = false
|
2026-03-30 00:48:20 +03:00
|
|
|
|
|
|
|
|
|
2026-05-05 23:49:12 +03:00
|
|
|
func _init_owniverse_items() -> bool:
|
|
|
|
|
owniverse_items = {}
|
2026-04-08 00:23:22 +03:00
|
|
|
for item_id in Global.OwniverseItems:
|
|
|
|
|
var item_props: Dictionary = Global.OwniverseItems[item_id]
|
2026-05-05 23:49:12 +03:00
|
|
|
var item: OwniverseItem = OWNIVERSE_ITEM.instantiate()
|
2026-04-08 00:23:22 +03:00
|
|
|
if !item_props.has("page"):
|
|
|
|
|
printerr("Item `", item_id, "` has no `page` key.")
|
2026-03-30 00:48:20 +03:00
|
|
|
return false
|
2026-04-08 00:23:22 +03:00
|
|
|
var page: int = int(item_props.page)
|
|
|
|
|
item_pages[page].add_child(item)
|
|
|
|
|
item.init_button(item_props)
|
2026-05-05 23:49:12 +03:00
|
|
|
item.item_activated.connect(item_activated)
|
|
|
|
|
|
|
|
|
|
owniverse_items[item_id] = item
|
2026-08-27 23:04:56 +03:00
|
|
|
|
2026-03-30 00:48:20 +03:00
|
|
|
return false
|
2026-05-05 23:49:12 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func item_activated(item: OwniverseItem) -> void:
|
|
|
|
|
_control_page(item)
|
|
|
|
|
_set_item_description(item)
|
2026-03-09 16:10:35 +03:00
|
|
|
|
2026-05-05 23:49:12 +03:00
|
|
|
if item.item_id == "S" or item.item_id == "H":
|
2026-08-28 00:07:18 +03:00
|
|
|
var _value = owniverse.produce_hs(item.item_id, 100_000)
|
|
|
|
|
|
2026-03-09 16:10:35 +03:00
|
|
|
|
|
|
|
|
func _check_counters(delta: float) -> Array:
|
|
|
|
|
var actions: Array = []
|
|
|
|
|
for k in g_counters:
|
|
|
|
|
var cnt: Counter = g_counters[k]
|
|
|
|
|
if not cnt.is_active:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
cnt.value += delta
|
|
|
|
|
if cnt.value >= cnt.sec:
|
|
|
|
|
actions.append(k)
|
|
|
|
|
cnt.value = 0
|
|
|
|
|
cnt.is_active = false
|
|
|
|
|
|
|
|
|
|
return actions
|
|
|
|
|
|
2026-04-05 20:15:07 +03:00
|
|
|
|
2026-08-27 23:04:56 +03:00
|
|
|
#region Swipe and page
|
2026-06-03 23:26:44 +03:00
|
|
|
|
2026-03-09 16:10:35 +03:00
|
|
|
func _do_actions(actions: Array) -> void:
|
|
|
|
|
for action: String in actions:
|
|
|
|
|
match action:
|
2026-04-05 23:26:43 +03:00
|
|
|
"swipe":
|
2026-03-09 16:10:35 +03:00
|
|
|
_swipe_to_nearest_page()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _swipe_to_nearest_page() -> void:
|
|
|
|
|
if stage_page_scroller.scroll_horizontal % PAGE_WIDTH == 0: return
|
|
|
|
|
|
|
|
|
|
var new_page: int = round(1.0 * stage_page_scroller.scroll_horizontal / PAGE_WIDTH)
|
|
|
|
|
|
|
|
|
|
if g_tween != null:
|
|
|
|
|
if g_tween.is_running():
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
g_tween = stage_page_scroller.get_tree().create_tween()
|
2026-04-05 23:26:43 +03:00
|
|
|
g_tween.tween_property(stage_page_scroller, "scroll_horizontal",
|
2026-03-09 16:10:35 +03:00
|
|
|
new_page * PAGE_WIDTH, SWIPE_DURATION).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
|
|
|
if event is InputEventScreenDrag:
|
|
|
|
|
stage_page_scroller.scroll_horizontal = clamp(
|
|
|
|
|
stage_page_scroller.scroll_horizontal - PAGE_COUNT * event.screen_relative.x,
|
|
|
|
|
0, PAGE_WIDTH * (PAGE_COUNT - 1))
|
|
|
|
|
g_counters.swipe.is_active = true
|
|
|
|
|
g_counters.swipe.value = 0
|
|
|
|
|
elif event is InputEventPanGesture:
|
|
|
|
|
g_counters.swipe.is_active = true
|
|
|
|
|
g_counters.swipe.value = 0
|
|
|
|
|
elif event is InputEventScreenTouch:
|
|
|
|
|
pass
|
2026-08-27 23:04:56 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _set_active_page_actions() -> void:
|
|
|
|
|
for pa in page_actions:
|
|
|
|
|
if !g_active_items.has(pa): continue
|
|
|
|
|
|
|
|
|
|
var item_id: String = g_active_items[pa].item_id
|
2026-09-01 21:29:07 +03:00
|
|
|
var entity: OwniverseEntity = owniverse.entities[item_id]
|
|
|
|
|
|
|
|
|
|
#var amount = owniverse.get_available_to_produce(item_id)
|
|
|
|
|
|
|
|
|
|
#var amount = owniverse.get_available_to_produce(entity)
|
|
|
|
|
var amount = owniverse.calculate_max_producible(entity)
|
2026-09-01 23:53:05 +03:00
|
|
|
#print(item_id, " : ", amount)
|
2026-09-14 07:47:21 +03:00
|
|
|
if item_id == "SMBH":
|
|
|
|
|
var preview: Callable = func(requested: float) -> float:
|
|
|
|
|
return owniverse.calculate_max_producible(entity, requested)
|
|
|
|
|
page_actions[pa].set_actions(item_id, amount, preview)
|
|
|
|
|
else:
|
|
|
|
|
page_actions[pa].set_actions(item_id, amount)
|
2026-08-27 23:04:56 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _page_action_pressed(page_id: int, action_amount: float) -> void:
|
|
|
|
|
if !g_active_items.has(page_id):
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
var item_id: String = g_active_items[page_id].item_id
|
|
|
|
|
|
|
|
|
|
if action_amount > 0:
|
|
|
|
|
owniverse.produce(item_id, action_amount)
|
|
|
|
|
|
|
|
|
|
|
2026-03-30 00:48:20 +03:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
2026-09-11 09:31:37 +03:00
|
|
|
var inited_result = init_enitities()
|
2026-09-01 23:53:05 +03:00
|
|
|
locked_items = inited_result.locked_items
|
2026-09-11 09:31:37 +03:00
|
|
|
load_data()
|
2026-05-05 23:49:12 +03:00
|
|
|
_init_owniverse_items()
|
2026-09-13 22:57:25 +03:00
|
|
|
owniverse.refresh_item_amounts()
|
|
|
|
|
_change_speed(0)
|
|
|
|
|
set_datetime(owniverse.state.time.year)
|
|
|
|
|
set_owniverse_item_value()
|
|
|
|
|
_unlock_items()
|
2026-05-05 23:49:12 +03:00
|
|
|
|
|
|
|
|
g_counters.swipe.sec = 0.2
|
2026-04-05 20:15:07 +03:00
|
|
|
|
2026-06-03 23:26:44 +03:00
|
|
|
for pa in page_actions:
|
|
|
|
|
page_actions[pa].action_pressed.connect(_page_action_pressed)
|
|
|
|
|
page_actions[pa].page_id = pa
|
|
|
|
|
|
2026-03-30 00:48:20 +03:00
|
|
|
|
|
|
|
|
func _process(delta: float) -> void:
|
2026-05-26 23:21:44 +03:00
|
|
|
|
2026-09-01 23:53:05 +03:00
|
|
|
owniverse.evolute(delta)
|
2026-09-15 22:01:45 +03:00
|
|
|
_update_descriptions(delta)
|
2026-09-13 22:57:25 +03:00
|
|
|
set_owniverse_item_value()
|
2026-09-11 09:31:37 +03:00
|
|
|
set_datetime(owniverse.state.time.year)
|
2026-08-25 00:26:31 +03:00
|
|
|
|
2026-08-28 00:07:18 +03:00
|
|
|
#owniverse.cycle(delta)
|
2026-08-25 00:26:31 +03:00
|
|
|
|
|
|
|
|
#owniverse.cycle_legacy(year_delta)
|
2026-03-30 00:48:20 +03:00
|
|
|
|
|
|
|
|
var actions = _check_counters(delta)
|
|
|
|
|
_do_actions(actions)
|
2026-06-03 23:26:44 +03:00
|
|
|
|
|
|
|
|
_set_active_page_actions()
|
2026-04-05 20:15:07 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _change_speed(delta: int) -> void:
|
2026-08-25 00:26:31 +03:00
|
|
|
|
|
|
|
|
owniverse.speed = owniverse.speed + delta
|
|
|
|
|
|
|
|
|
|
var speed: int = owniverse.speed
|
2026-04-05 20:15:07 +03:00
|
|
|
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))
|
2026-05-05 23:49:12 +03:00
|
|
|
|
|
|
|
|
|
2026-09-14 07:47:21 +03:00
|
|
|
func _on_topmenu_button_pressed(_ButtonName) -> void:
|
2026-09-13 21:09:42 +03:00
|
|
|
print("Debug → ")
|
|
|
|
|
#, owniverse.state)
|
|
|
|
|
for id in owniverse.state.batches:
|
|
|
|
|
var s = owniverse.state.batches[id].size()
|
|
|
|
|
if s != 0:
|
|
|
|
|
print(id, " → ", s)
|
|
|
|
|
#, owniverse.state.batches[id])
|
|
|
|
|
if id == 'HG':
|
|
|
|
|
print(owniverse.state.batches[id])
|
|
|
|
|
|
2026-08-17 08:12:43 +03:00
|
|
|
#var s: float = 1E15
|
|
|
|
|
#var z = 1.0
|
|
|
|
|
#for i in range(30):
|
|
|
|
|
#print(i, " | ", z, " | ", " | ", s - z)
|
|
|
|
|
#z *= 10
|
2026-09-13 21:09:42 +03:00
|
|
|
print("-------")
|
2026-07-10 20:36:44 +03:00
|
|
|
|
|
|
|
|
|
2026-08-27 23:04:56 +03:00
|
|
|
func _on_unlock_and_save_timeout() -> void:
|
2026-09-11 09:31:37 +03:00
|
|
|
save_data()
|
2026-08-27 23:04:56 +03:00
|
|
|
_unlock_items()
|
2026-09-11 09:31:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Init save load routines
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func load_data() -> bool:
|
|
|
|
|
var game_data: Dictionary = SaveManager.load_data("owniverse", "qwerty")
|
2026-09-13 22:57:25 +03:00
|
|
|
if game_data.is_empty():
|
2026-09-14 07:47:21 +03:00
|
|
|
if SaveManager.last_error == "":
|
|
|
|
|
pending_page = RESOURCE_PAGE
|
|
|
|
|
_restore_page.call_deferred()
|
2026-09-11 09:31:37 +03:00
|
|
|
return false
|
2026-09-13 22:57:25 +03:00
|
|
|
var restored: Dictionary = game_data.state
|
|
|
|
|
# Current definitions are initialized first; reject incompatible saves before publishing.
|
|
|
|
|
for id in owniverse.state.amount:
|
|
|
|
|
if not restored.amount.has(id) or not restored.stats.total_amount.has(id):
|
|
|
|
|
SaveManager.blocked_saves["owniverse"] = true
|
|
|
|
|
push_error("Save is missing the current entity: " + id)
|
|
|
|
|
return false
|
|
|
|
|
var complete: Dictionary = owniverse.state.duplicate(true)
|
|
|
|
|
complete.merge(restored, true)
|
|
|
|
|
owniverse.state = complete
|
|
|
|
|
owniverse.new_state = complete
|
2026-09-15 08:27:04 +03:00
|
|
|
owniverse.migrate_time_precision()
|
2026-09-13 22:57:25 +03:00
|
|
|
owniverse.refresh_item_amounts()
|
|
|
|
|
pending_page = clampi(int(game_data.get("ui", {}).get("current_page", 0)), 0, PAGE_COUNT - 1)
|
|
|
|
|
_restore_page.call_deferred()
|
2026-09-11 09:31:37 +03:00
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
|
2026-09-13 22:57:25 +03:00
|
|
|
func _restore_page() -> void:
|
|
|
|
|
# Wait until containers have calculated the scrollable width.
|
|
|
|
|
await get_tree().process_frame
|
|
|
|
|
if pending_page >= 0:
|
|
|
|
|
stage_page_scroller.scroll_horizontal = pending_page * PAGE_WIDTH
|
|
|
|
|
pending_page = -1
|
|
|
|
|
|
|
|
|
|
|
2026-09-11 09:31:37 +03:00
|
|
|
func save_data() -> void:
|
2026-09-13 22:57:25 +03:00
|
|
|
var page: int = pending_page
|
|
|
|
|
if page < 0:
|
|
|
|
|
page = clampi(roundi(float(stage_page_scroller.scroll_horizontal) / PAGE_WIDTH), 0, PAGE_COUNT - 1)
|
|
|
|
|
SaveManager.save_data("owniverse", "qwerty", {
|
|
|
|
|
"state": owniverse.state,
|
|
|
|
|
"ui": {"current_page": page},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _notification(what: int) -> void:
|
|
|
|
|
if is_node_ready() and (what == NOTIFICATION_WM_CLOSE_REQUEST or what == NOTIFICATION_APPLICATION_PAUSED):
|
|
|
|
|
save_data()
|
2026-09-11 09:31:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func init_enitities() -> Dictionary:
|
|
|
|
|
var _result := {
|
|
|
|
|
'locked_items': [],
|
|
|
|
|
}
|
|
|
|
|
for entity_id in Global.OwniverseEntities:
|
|
|
|
|
var entity = OwniverseEntity.new(Global.OwniverseEntities[entity_id])
|
|
|
|
|
owniverse.entities[entity_id] = entity
|
|
|
|
|
|
|
|
|
|
owniverse.state.stats.total_amount[entity_id] = 0
|
|
|
|
|
owniverse.state.amount[entity_id] = 0
|
|
|
|
|
if entity.lifespan > 0:
|
|
|
|
|
owniverse.state.batches[entity.id] = []
|
|
|
|
|
owniverse.add_entity_to_batch(entity_id, 0, 0)
|
|
|
|
|
if entity.group_as != "":
|
|
|
|
|
owniverse.state.amount[entity.group_as] = 0
|
|
|
|
|
|
|
|
|
|
owniverse.state.stats.total_amount[entity.group_as] = 0
|
|
|
|
|
|
|
|
|
|
if entity.unlock != {}:
|
|
|
|
|
owniverse.locked_entities.append(entity)
|
|
|
|
|
_result.locked_items.append(entity.id)
|
|
|
|
|
|
|
|
|
|
if entity.product_per_year_type != "":
|
|
|
|
|
owniverse.auto_production.append(entity)
|
|
|
|
|
|
|
|
|
|
# groups
|
|
|
|
|
if entity.group_as != "":
|
|
|
|
|
if !owniverse.entity_groups.has(entity.group_as):
|
|
|
|
|
owniverse.entity_groups[entity.group_as] = []
|
|
|
|
|
owniverse.entity_groups[entity.group_as].append(entity_id)
|
|
|
|
|
|
|
|
|
|
if entity.event_group != "":
|
|
|
|
|
if !owniverse.entity_event_groups.has(entity.event_group):
|
|
|
|
|
owniverse.entity_event_groups[entity.event_group] = []
|
|
|
|
|
owniverse.entity_event_groups[entity.event_group].append(entity_id)
|
|
|
|
|
|
|
|
|
|
return _result
|
|
|
|
|
|
|
|
|
|
#endregion
|