somewhat working console, fully developed from the ground up some things work with it, but its still pretty buggy currently runs on global autoload because its the easiest way rn, later on have to change it so that only if the player is in the game and console is enabled it can be toggled
63 lines
2.1 KiB
GDScript
63 lines
2.1 KiB
GDScript
extends Node
|
|
|
|
@export_category("UI")
|
|
@export var UI_SCALE: float = 1 ##rational scale of the ui
|
|
@export var UI_MOVEMENT_SENSITIVITY = 0.5 ##how much the UI moves when you move the camera
|
|
@export var UI_MOVEMENT_SPEED = 15.0 ##how fast the UI moves when you move the camera
|
|
@export var UI_MOVEMENT_VELOCITY_MULTIPLIER = 2.0 ##how much the ui leans when walking or strafing
|
|
|
|
@export var GRAB_PANEL: PackedScene
|
|
|
|
@onready var in_game_menu: Control = %InGameMenu
|
|
@onready var ui: Control = %PlayerUi
|
|
@onready var popup_panels: Control = %PopupPanels
|
|
@onready var player_state: Node = %PlayerState
|
|
@onready var player_manager: Node = %PlayerManager
|
|
@onready var player: CharacterBody3D = $"../.."
|
|
@onready var cursor: TextureRect = %Cursor
|
|
@onready var player_camera: Camera3D = %PlayerCamera
|
|
|
|
const SELECTED_COLOR = 0xcfcfcf78
|
|
const UNSELECTED_COLOR = 0x3d3d3d78
|
|
|
|
var grabbable_panel = null
|
|
var grabbable_panel_body = null
|
|
|
|
func _on_grabbable_finder_body_entered(body: Node3D) -> void:
|
|
if body.is_in_group("grabbable"):
|
|
grabbable_panel = GRAB_PANEL.instantiate()
|
|
popup_panels.add_child(grabbable_panel)
|
|
grabbable_panel_body = body
|
|
|
|
func _on_grabbable_finder_body_exited(body: Node3D) -> void:
|
|
if body == grabbable_panel_body:
|
|
popup_panels.remove_child(grabbable_panel)
|
|
grabbable_panel = null
|
|
grabbable_panel_body = null
|
|
|
|
func _process(delta: float) -> void:
|
|
if grabbable_panel != null:
|
|
var target_position = cursor.position - player_camera.unproject_position(grabbable_panel_body.global_position)
|
|
grabbable_panel.position = grabbable_panel.position.lerp(-target_position / 2, delta * 50)
|
|
|
|
func toggle_menu():
|
|
if !in_game_menu.visible:
|
|
ui.visible = false
|
|
popup_panels.visible = false
|
|
in_game_menu.visible = true
|
|
cursor.visible = false
|
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
|
player_state.in_menu = true
|
|
else:
|
|
ui.visible = true
|
|
popup_panels.visible = true
|
|
in_game_menu.visible = false
|
|
cursor.visible = true
|
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
player_state.in_menu = false
|
|
|
|
func put_item(index: int, item: PackedScene):
|
|
player_manager.inventory[index] = item
|
|
|
|
func set_ui_scale(scale:float) -> void:
|
|
pass
|