From 8fc3db922922e87fa5f8bdb09e4a3b6b2d4cf96e Mon Sep 17 00:00:00 2001 From: tpart Date: Sun, 6 Oct 2024 21:21:51 +0200 Subject: Categorize interact marker; Fix misplaced file --- client/menu/auto_setup/scroll_container_custom.gd | 45 +++++++++++++++++++++++ client/menu/book/book.tscn | 2 +- client/menu/communicate/chat/chat_open.tscn | 2 +- client/menu/credits.tscn | 2 +- client/menu/lobby.tscn | 2 +- client/menu/play.tscn | 2 +- client/menu/scroll_container_custom.gd | 45 ----------------------- client/menu/setup.tscn | 2 +- 8 files changed, 51 insertions(+), 51 deletions(-) create mode 100644 client/menu/auto_setup/scroll_container_custom.gd delete mode 100644 client/menu/scroll_container_custom.gd (limited to 'client/menu') diff --git a/client/menu/auto_setup/scroll_container_custom.gd b/client/menu/auto_setup/scroll_container_custom.gd new file mode 100644 index 00000000..a456f644 --- /dev/null +++ b/client/menu/auto_setup/scroll_container_custom.gd @@ -0,0 +1,45 @@ +# Hurry Curry! - a game about cooking +# Copyright 2024 tpart +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +extends ScrollContainer +class_name ScrollContainerCustom + +# Adds support for scrolling with joypad and touch + +const SCROLL_SPEED := 1000. +var velocity := 0. + +@export var auto_scroll_to_bottom := false + +func _init(): + follow_focus = true + +func _ready(): + if auto_scroll_to_bottom: + call_deferred("scroll_to_bottom") + +func scroll_to_bottom(): + set_deferred("scroll_vertical", get_v_scroll_bar().max_value) + +func _process(delta): + velocity = G.interpolate(velocity, 0., delta * 5.) + velocity = 0. if abs(velocity) < .001 else velocity + if Input.get_axis("scroll_up", "scroll_down") != 0.: + velocity = Input.get_axis("scroll_up", "scroll_down") + set_deferred("scroll_vertical", scroll_vertical + velocity * delta * SCROLL_SPEED) + +func _input(event): + if event is InputEventScreenDrag: + velocity = -(scroll_vertical - (scroll_vertical - event.relative.y)) * .1 diff --git a/client/menu/book/book.tscn b/client/menu/book/book.tscn index 824c062d..366959a4 100644 --- a/client/menu/book/book.tscn +++ b/client/menu/book/book.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://bdggwo8un3mys"] [ext_resource type="Script" path="res://menu/book/book.gd" id="1_gyisx"] -[ext_resource type="Script" path="res://menu/scroll_container_custom.gd" id="2_0d0p0"] +[ext_resource type="Script" path="res://menu/auto_setup/scroll_container_custom.gd" id="2_0d0p0"] [node name="Book" type="Control"] layout_mode = 3 diff --git a/client/menu/communicate/chat/chat_open.tscn b/client/menu/communicate/chat/chat_open.tscn index 8830c4f7..09cc4526 100644 --- a/client/menu/communicate/chat/chat_open.tscn +++ b/client/menu/communicate/chat/chat_open.tscn @@ -5,7 +5,7 @@ [ext_resource type="Script" path="res://menu/auto_setup/blur_setup.gd" id="2_urbd2"] [ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme/theme.tres" id="3_v7xmg"] [ext_resource type="StyleBox" uid="uid://bw4jamyna1top" path="res://menu/theme/style/panel_style_sidebar.tres" id="4_ew1yx"] -[ext_resource type="Script" path="res://menu/scroll_container_custom.gd" id="5_3mths"] +[ext_resource type="Script" path="res://menu/auto_setup/scroll_container_custom.gd" id="5_3mths"] [node name="ChatOpen" type="Control"] layout_mode = 3 diff --git a/client/menu/credits.tscn b/client/menu/credits.tscn index ddbc8ebe..783b308b 100644 --- a/client/menu/credits.tscn +++ b/client/menu/credits.tscn @@ -4,7 +4,7 @@ [ext_resource type="Script" path="res://menu/credits.gd" id="2_alvab"] [ext_resource type="Material" uid="uid://beea1pc5nt67r" path="res://menu/theme/materials/dark_blur_material.tres" id="3_nwoiv"] [ext_resource type="Script" path="res://menu/auto_setup/blur_setup.gd" id="4_8sii3"] -[ext_resource type="Script" path="res://menu/scroll_container_custom.gd" id="4_bfcw8"] +[ext_resource type="Script" path="res://menu/auto_setup/scroll_container_custom.gd" id="4_bfcw8"] [node name="CreditsMenu" type="Control"] layout_mode = 3 diff --git a/client/menu/lobby.tscn b/client/menu/lobby.tscn index 9f4e14c9..83284357 100644 --- a/client/menu/lobby.tscn +++ b/client/menu/lobby.tscn @@ -12,7 +12,7 @@ [ext_resource type="PackedScene" uid="uid://b1f7bgn65j7b5" path="res://menu/controller_buttons/controller_button.tscn" id="7_t6mox"] [ext_resource type="FontFile" uid="uid://5ixo6b3bd3km" path="res://menu/theme/fonts/font-josefin-sans.woff2" id="8_cwbpa"] [ext_resource type="Texture2D" uid="uid://bsx6fo7mv2u6a" path="res://menu/controller_buttons/x.svg" id="9_q14bw"] -[ext_resource type="Script" path="res://menu/scroll_container_custom.gd" id="10_bgene"] +[ext_resource type="Script" path="res://menu/auto_setup/scroll_container_custom.gd" id="10_bgene"] [ext_resource type="Texture2D" uid="uid://cr2a6ide6vnnv" path="res://menu/controller_buttons/y.svg" id="11_5uugf"] [sub_resource type="FontVariation" id="FontVariation_5xxr2"] diff --git a/client/menu/play.tscn b/client/menu/play.tscn index 958eab8e..94801dfb 100644 --- a/client/menu/play.tscn +++ b/client/menu/play.tscn @@ -3,7 +3,7 @@ [ext_resource type="Theme" uid="uid://b0qmvo504e457" path="res://menu/theme/theme/theme.tres" id="1_cckds"] [ext_resource type="Script" path="res://menu/play.gd" id="2_phxx0"] [ext_resource type="Material" uid="uid://2j8a0c0a2ta5" path="res://menu/theme/materials/blur_material.tres" id="3_fsbt7"] -[ext_resource type="Script" path="res://menu/scroll_container_custom.gd" id="5_cm120"] +[ext_resource type="Script" path="res://menu/auto_setup/scroll_container_custom.gd" id="5_cm120"] [ext_resource type="FontFile" uid="uid://bo4vh5xkpvrh1" path="res://menu/theme/fonts/font-sansita-swashed.woff2" id="5_ojpbf"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ukani"] diff --git a/client/menu/scroll_container_custom.gd b/client/menu/scroll_container_custom.gd deleted file mode 100644 index a456f644..00000000 --- a/client/menu/scroll_container_custom.gd +++ /dev/null @@ -1,45 +0,0 @@ -# Hurry Curry! - a game about cooking -# Copyright 2024 tpart -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, version 3 of the License only. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -extends ScrollContainer -class_name ScrollContainerCustom - -# Adds support for scrolling with joypad and touch - -const SCROLL_SPEED := 1000. -var velocity := 0. - -@export var auto_scroll_to_bottom := false - -func _init(): - follow_focus = true - -func _ready(): - if auto_scroll_to_bottom: - call_deferred("scroll_to_bottom") - -func scroll_to_bottom(): - set_deferred("scroll_vertical", get_v_scroll_bar().max_value) - -func _process(delta): - velocity = G.interpolate(velocity, 0., delta * 5.) - velocity = 0. if abs(velocity) < .001 else velocity - if Input.get_axis("scroll_up", "scroll_down") != 0.: - velocity = Input.get_axis("scroll_up", "scroll_down") - set_deferred("scroll_vertical", scroll_vertical + velocity * delta * SCROLL_SPEED) - -func _input(event): - if event is InputEventScreenDrag: - velocity = -(scroll_vertical - (scroll_vertical - event.relative.y)) * .1 diff --git a/client/menu/setup.tscn b/client/menu/setup.tscn index 9e09a050..0ad994a5 100644 --- a/client/menu/setup.tscn +++ b/client/menu/setup.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://menu/setup.gd" id="1_mo46n"] [ext_resource type="Theme" uid="uid://ci2qajdoa1an1" path="res://menu/theme/theme/paper.tres" id="1_yq0aa"] -[ext_resource type="Script" path="res://menu/scroll_container_custom.gd" id="2_4caf2"] +[ext_resource type="Script" path="res://menu/auto_setup/scroll_container_custom.gd" id="2_4caf2"] [ext_resource type="FontFile" uid="uid://bo4vh5xkpvrh1" path="res://menu/theme/fonts/font-sansita-swashed.woff2" id="3_2vg4d"] [ext_resource type="AudioStream" uid="uid://do7ii5hx71p0m" path="res://menu/sounds/page.ogg" id="5_xac6d"] [ext_resource type="AudioStream" uid="uid://5b3noxjmasmu" path="res://menu/sounds/sign.ogg" id="6_wf0gh"] -- cgit v1.2.3-70-g09d2