First commit 🎉

This commit is contained in:
Tony Bark 2025-07-17 01:49:18 -04:00
commit 43ea213f9b
728 changed files with 37080 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bocign602kxhh"
path="res://.godot/imported/simple_click_cursor.png-8572f1aad61238225b3f0102a5d54ba7.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/popochiu/engine/objects/gui/templates/simple_click/images/simple_click_cursor.png"
dest_files=["res://.godot/imported/simple_click_cursor.png-8572f1aad61238225b3f0102a5d54ba7.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -0,0 +1,60 @@
class_name SimpleClickCommands
extends PopochiuCommands
## Defines the commands and fallback methods for the 2-click Context-sensitive GUI.
##
## In this GUI, players interact with objects in the game based on the clicked mouse button.
## Usually, the left click is used to INTERACT with objects, while the RIGHT click is used to
## EXAMINE objects. This behavior is based on the one used in Beneath A Steel Sky and Broken Sword.
#region Public #####################################################################################
## Called by [Popochiu] when a command doesn't have an associated method.
func fallback() -> void:
if is_instance_valid(PopochiuUtils.e.clicked):
if PopochiuUtils.e.clicked.last_click_button == MOUSE_BUTTON_LEFT:
await click_clickable()
elif PopochiuUtils.e.clicked.last_click_button == MOUSE_BUTTON_RIGHT:
await right_click_clickable()
else:
await RenderingServer.frame_post_draw
if is_instance_valid(PopochiuUtils.i.clicked):
if PopochiuUtils.i.clicked.last_click_button == MOUSE_BUTTON_LEFT:
await click_inventory_item()
elif PopochiuUtils.i.clicked.last_click_button == MOUSE_BUTTON_RIGHT:
await right_click_inventory_item()
else:
await RenderingServer.frame_post_draw
## Called when players click (LMB) a [PopochiuClickable].
func click_clickable() -> void:
if PopochiuUtils.i.active:
await PopochiuUtils.g.show_system_text("Can't USE %s with %s" % [
PopochiuUtils.i.active.description, PopochiuUtils.e.clicked.description
])
else:
await PopochiuUtils.g.show_system_text("Can't INTERACT with it")
## Called when players right click (RMB) a [PopochiuClickable].
func right_click_clickable() -> void:
await PopochiuUtils.g.show_system_text("Can't EXAMINE it")
## Called when players click (LMB) a [PopochiuInvenoryItem].
func click_inventory_item() -> void:
if PopochiuUtils.i.active and PopochiuUtils.i.active != PopochiuUtils.i.clicked:
await PopochiuUtils.g.show_system_text("Can't USE %s with %s" % [
PopochiuUtils.i.active.description, PopochiuUtils.i.clicked.description
])
else:
PopochiuUtils.i.clicked.set_active()
## Called when players right click (RMB) a [PopochiuInvenoryItem].
func right_click_inventory_item() -> void:
await PopochiuUtils.g.show_system_text('Nothing to see in this item')
#endregion

View file

@ -0,0 +1 @@
uid://dqghvoqnyj6ct

View file

@ -0,0 +1,212 @@
class_name SimpleClickGUI
extends PopochiuGraphicInterface
## Defines the behavior of the 2-click Context-sensitive GUI.
##
## In this GUI, players interact with objects in the game based on the clicked mouse button. The
## inventory bar is in the top left corner of the screen, and the settings bar is in the top right
## corner of the screen.
@onready var settings_bar: Control = %SettingsBar
@onready var save_and_load_popup: Control = %SaveAndLoadPopup
@onready var text_settings_popup: Control = %TextSettingsPopup
@onready var sound_settings_popup: Control = %SoundSettingsPopup
@onready var history_popup: Control = %HistoryPopup
@onready var quit_popup: Control = %QuitPopup
#region Godot ######################################################################################
func _ready() -> void:
super()
# Connect to children's signals
settings_bar.option_selected.connect(_on_settings_option_selected)
# Connect to autoloads' signals
PopochiuUtils.cursor.replace_frames($Cursor)
PopochiuUtils.cursor.show_cursor()
$Cursor.hide()
#endregion
#region Virtual ####################################################################################
## Called when the GUI is blocked and not intended to handle input events.
func _on_blocked(props := { blocking = true }) -> void:
PopochiuUtils.cursor.show_cursor("wait")
PopochiuUtils.cursor.is_blocked = true
## Called when the GUI is unblocked and can handle input events again.
func _on_unblocked() -> void:
PopochiuUtils.cursor.is_blocked = false
if PopochiuUtils.i.active:
PopochiuUtils.cursor.hide_main_cursor()
PopochiuUtils.cursor.show_secondary_cursor()
elif PopochiuUtils.e.hovered:
# Fixes #315 by showing the right cursor when it is over a PopochiuClickable after closing
# the SystemText component
PopochiuUtils.cursor.show_cursor(
PopochiuUtils.cursor.get_type_name(PopochiuUtils.e.hovered.cursor)
)
else:
PopochiuUtils.cursor.show_cursor(get_cursor_name())
## Called when a text is shown in the [SystemText] component. This erases the text in the
## [HoverText] component and shows the [code]"wait"[/code] cursor.
func _on_system_text_shown(msg: String) -> void:
PopochiuUtils.g.show_hover_text()
PopochiuUtils.cursor.show_cursor("wait", true)
## Called when the [SystemText] component hides. If an [PopochiuInventoryItem] is active, the cursor
## takes its texture, otherwise it takes its default one.
func _on_system_text_hidden() -> void:
if PopochiuUtils.i.active:
PopochiuUtils.cursor.hide_main_cursor()
PopochiuUtils.cursor.show_secondary_cursor()
else:
PopochiuUtils.cursor.show_cursor()
## Called when the mouse enters (hovers) [param clickable]. It changes the texture of the cursor
## and displays a message with the [member PopochiuClickable.description] on the [HoverText]
## component.
func _on_mouse_entered_clickable(clickable: PopochiuClickable) -> void:
if PopochiuUtils.g.is_blocked: return
if not (PopochiuUtils.i.active or is_showing_dialog_line):
PopochiuUtils.cursor.show_cursor(PopochiuUtils.cursor.get_type_name(clickable.cursor))
if not PopochiuUtils.i.active:
PopochiuUtils.g.show_hover_text(clickable.description)
else:
PopochiuUtils.g.show_hover_text(
'Use %s with %s' % [PopochiuUtils.i.active.description, clickable.description]
)
## Called when the mouse exits [param clickable]. Clears the text in the [HoverText] component and
## shows the default cursor texture if there is no [PopochiuInventoryItem] active.
func _on_mouse_exited_clickable(clickable: PopochiuClickable) -> void:
PopochiuUtils.g.show_hover_text()
if PopochiuUtils.i.active or is_showing_dialog_line: return
PopochiuUtils.cursor.show_cursor("gui" if PopochiuUtils.d.current_dialog else "normal")
## Called when the mouse enters (hovers) [param inventory_item]. It changes the texture of the
## cursor and displays a message with the [member PopochiuInventoryItem.description] on the
## [HoverText] component.
func _on_mouse_entered_inventory_item(inventory_item: PopochiuInventoryItem) -> void:
if PopochiuUtils.g.is_blocked: return
if not PopochiuUtils.i.active:
PopochiuUtils.cursor.show_cursor(PopochiuUtils.cursor.get_type_name(inventory_item.cursor))
PopochiuUtils.g.show_hover_text(inventory_item.description)
elif PopochiuUtils.i.active != inventory_item:
PopochiuUtils.g.show_hover_text(
'Use %s with %s' % [PopochiuUtils.i.active.description, inventory_item.description]
)
else:
PopochiuUtils.g.show_hover_text(inventory_item.description)
## Called when the mouse exits [param inventory_item]. Clears the text in the [HoverText] component
## and shows the default cursor texture if there is no [PopochiuInventoryItem] active.
func _on_mouse_exited_inventory_item(inventory_item: PopochiuInventoryItem) -> void:
if PopochiuUtils.g.is_blocked: return
PopochiuUtils.g.show_hover_text()
if PopochiuUtils.i.active or $SettingsBar.is_open(): return
PopochiuUtils.cursor.show_cursor()
## Called when a dialog line starts. It shows the [code]"wait"[/code] cursor.
func _on_dialog_line_started() -> void:
is_showing_dialog_line = true
PopochiuUtils.cursor.show_cursor("wait")
## Called when a dialog line finishes. It shows the [code]"normal"[/code] cursor if there is no
## [PopochiuDialog] active, otherwise shows the [code]"use"[/code] cursor.
func _on_dialog_line_finished() -> void:
is_showing_dialog_line = false
if PopochiuUtils.d.current_dialog:
PopochiuUtils.cursor.show_cursor("gui")
elif PopochiuUtils.e.hovered:
PopochiuUtils.cursor.show_cursor(
PopochiuUtils.cursor.get_type_name(PopochiuUtils.e.hovered.cursor)
)
else:
PopochiuUtils.cursor.show_cursor("normal")
## Called when a [PopochiuDialog] starts. It shows the [code]"use"[/code] cursor and clears the
## [HoverText] component.
func _on_dialog_started(dialog: PopochiuDialog) -> void:
PopochiuUtils.cursor.show_cursor("gui")
PopochiuUtils.g.show_hover_text()
## Called when the running [PopochiuDialog] shows its options on screen. It shows the
## [code]"gui"[/code] cursor.
func _on_dialog_options_shown() -> void:
PopochiuUtils.cursor.unblock()
PopochiuUtils.cursor.show_cursor("gui")
## Called when a [PopochiuDialog] finishes. It shows the default cursor.
func _on_dialog_finished(dialog: PopochiuDialog) -> void:
PopochiuUtils.cursor.show_cursor()
## Called when the active [PopochiuInventoryItem] changes. If there is one, it hides the main cursor
## to show the one that shows the [member PopochiuInventoryItem.texture], otherwise it shows the
## default cursor.
func _on_inventory_item_selected(item: PopochiuInventoryItem) -> void:
if is_instance_valid(item):
PopochiuUtils.cursor.set_secondary_cursor_texture(item.texture)
PopochiuUtils.cursor.hide_main_cursor()
else:
PopochiuUtils.cursor.remove_secondary_cursor_texture()
PopochiuUtils.cursor.show_cursor()
## Called when the game is saved. By default, it shows [code]Game saved[/code] in the SystemText
## component.
func _on_game_saved() -> void:
PopochiuUtils.g.show_system_text("Game saved")
## Called when a game is loaded. [param loaded_game] has the loaded data. By default, it shows
## [code]Game loaded[/code] in the SystemText component.
func _on_game_loaded(loaded_game: Dictionary) -> void:
await PopochiuUtils.g.show_system_text("Game loaded")
super(loaded_game)
func _on_settings_option_selected(option_script_name: String) -> void:
match option_script_name:
"save":
save_and_load_popup.open_save()
"load":
save_and_load_popup.open_load()
"text_settings":
text_settings_popup.open()
"sound_settings":
sound_settings_popup.open()
"history":
history_popup.open()
"quit":
quit_popup.open()
#endregion

View file

@ -0,0 +1 @@
uid://b2bq0iyql0miu

View file

@ -0,0 +1,299 @@
[gd_scene load_steps=35 format=3 uid="uid://cwvuu8g0ih3i8"]
[ext_resource type="Script" path="res://addons/popochiu/engine/objects/gui/templates/simple_click/simple_click_gui.gd" id="1_268ni"]
[ext_resource type="Theme" uid="uid://dpequqav4rjaf" path="res://addons/popochiu/engine/objects/gui/resources/base_gui_theme.tres" id="1_uf1ey"]
[ext_resource type="PackedScene" uid="uid://esorelppu4hw" path="res://addons/popochiu/engine/objects/gui/components/hover_text/hover_text.tscn" id="2_6qu0l"]
[ext_resource type="Texture2D" uid="uid://bocign602kxhh" path="res://addons/popochiu/engine/objects/gui/templates/simple_click/images/simple_click_cursor.png" id="3_718yk"]
[ext_resource type="PackedScene" uid="uid://bdgs3xsbq3gdd" path="res://addons/popochiu/engine/objects/gui/components/system_text/system_text.tscn" id="4_o82xq"]
[ext_resource type="PackedScene" uid="uid://dhsfl8ot4j5fj" path="res://addons/popochiu/engine/objects/gui/components/dialog_menu/dialog_menu.tscn" id="5_ayg0j"]
[ext_resource type="PackedScene" uid="uid://bpl3qjbxonfpb" path="res://addons/popochiu/engine/objects/gui/components/dialog_text/dialog_caption/dialog_caption.tscn" id="5_t54kn"]
[ext_resource type="PackedScene" uid="uid://ciar5j7qm85bc" path="res://addons/popochiu/engine/objects/gui/components/inventory_bar/inventory_bar.tscn" id="6_ovwnh"]
[ext_resource type="PackedScene" uid="uid://0cqerawlxb3o" path="res://addons/popochiu/engine/objects/gui/components/settings_bar/settings_bar.tscn" id="7_mtpwc"]
[ext_resource type="PackedScene" uid="uid://dfrsiyyqncspo" path="res://addons/popochiu/engine/objects/gui/components/popups/history_popup/history_popup.tscn" id="8_207hf"]
[ext_resource type="PackedScene" uid="uid://cndputybyj57n" path="res://addons/popochiu/engine/objects/gui/components/popups/save_and_load_popup/save_and_load_popup.tscn" id="9_ueme0"]
[ext_resource type="PackedScene" uid="uid://dwxm2p1iyhpx6" path="res://addons/popochiu/engine/objects/gui/components/popups/sound_settings_popup/sound_settings_popup.tscn" id="10_csjib"]
[ext_resource type="PackedScene" uid="uid://de68lx1xqv7fb" path="res://addons/popochiu/engine/objects/gui/components/popups/text_settings_popup/text_settings_popup.tscn" id="13_dn3wu"]
[ext_resource type="PackedScene" uid="uid://bnjo044fkdcq7" path="res://addons/popochiu/engine/objects/gui/components/popups/quit_popup/quit_popup.tscn" id="14_m3nqq"]
[sub_resource type="AtlasTexture" id="10"]
atlas = ExtResource("3_718yk")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="11"]
atlas = ExtResource("3_718yk")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="12"]
atlas = ExtResource("3_718yk")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="15"]
atlas = ExtResource("3_718yk")
region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="16"]
atlas = ExtResource("3_718yk")
region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_t3qtx"]
atlas = ExtResource("3_718yk")
region = Rect2(576, 0, 32, 32)
[sub_resource type="AtlasTexture" id="4"]
atlas = ExtResource("3_718yk")
region = Rect2(192, 0, 32, 32)
[sub_resource type="AtlasTexture" id="5"]
atlas = ExtResource("3_718yk")
region = Rect2(224, 0, 32, 32)
[sub_resource type="AtlasTexture" id="18"]
atlas = ExtResource("3_718yk")
region = Rect2(256, 0, 32, 32)
[sub_resource type="AtlasTexture" id="17"]
atlas = ExtResource("3_718yk")
region = Rect2(288, 0, 32, 32)
[sub_resource type="AtlasTexture" id="9"]
atlas = ExtResource("3_718yk")
region = Rect2(160, 0, 32, 32)
[sub_resource type="AtlasTexture" id="2"]
atlas = ExtResource("3_718yk")
region = Rect2(320, 0, 32, 32)
[sub_resource type="AtlasTexture" id="3"]
atlas = ExtResource("3_718yk")
region = Rect2(352, 0, 32, 32)
[sub_resource type="AtlasTexture" id="14"]
atlas = ExtResource("3_718yk")
region = Rect2(384, 0, 32, 32)
[sub_resource type="AtlasTexture" id="19"]
atlas = ExtResource("3_718yk")
region = Rect2(416, 0, 32, 32)
[sub_resource type="AtlasTexture" id="6"]
atlas = ExtResource("3_718yk")
region = Rect2(448, 0, 32, 32)
[sub_resource type="AtlasTexture" id="7"]
atlas = ExtResource("3_718yk")
region = Rect2(480, 0, 32, 32)
[sub_resource type="AtlasTexture" id="13"]
atlas = ExtResource("3_718yk")
region = Rect2(512, 0, 32, 32)
[sub_resource type="AtlasTexture" id="8"]
atlas = ExtResource("3_718yk")
region = Rect2(544, 0, 32, 32)
[sub_resource type="SpriteFrames" id="SpriteFrames_1bbe3"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("10")
}, {
"duration": 1.0,
"texture": SubResource("11")
}, {
"duration": 1.0,
"texture": SubResource("12")
}, {
"duration": 1.0,
"texture": SubResource("12")
}, {
"duration": 1.0,
"texture": SubResource("11")
}],
"loop": true,
"name": &"active",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("15")
}, {
"duration": 1.0,
"texture": SubResource("16")
}],
"loop": true,
"name": &"down",
"speed": 4.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_t3qtx")
}],
"loop": true,
"name": &"gui",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("4")
}, {
"duration": 1.0,
"texture": SubResource("5")
}],
"loop": true,
"name": &"left",
"speed": 4.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("18")
}],
"loop": false,
"name": &"look",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("17")
}],
"loop": false,
"name": &"none",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("9")
}],
"loop": false,
"name": &"normal",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("2")
}, {
"duration": 1.0,
"texture": SubResource("3")
}],
"loop": true,
"name": &"right",
"speed": 4.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("14")
}],
"loop": false,
"name": &"search",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("19")
}],
"loop": false,
"name": &"talk",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("6")
}, {
"duration": 1.0,
"texture": SubResource("7")
}],
"loop": true,
"name": &"up",
"speed": 4.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("13")
}],
"loop": false,
"name": &"use",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("8")
}],
"loop": false,
"name": &"wait",
"speed": 5.0
}]
[node name="SimpleClickGUI" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
theme = ExtResource("1_uf1ey")
script = ExtResource("1_268ni")
[node name="Cursor" type="AnimatedSprite2D" parent="."]
texture_filter = 1
sprite_frames = SubResource("SpriteFrames_1bbe3")
animation = &"wait"
[node name="HoverText" parent="." instance=ExtResource("2_6qu0l")]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
offset_top = -19.0
offset_bottom = -4.0
grow_vertical = 0
hide_during_dialogs = true
[node name="DialogCaption" parent="." instance=ExtResource("5_t54kn")]
layout_mode = 1
[node name="DialogMenu" parent="." instance=ExtResource("5_ayg0j")]
visible = false
layout_mode = 1
[node name="InventoryBar" parent="." instance=ExtResource("6_ovwnh")]
layout_mode = 1
[node name="SettingsBar" parent="." instance=ExtResource("7_mtpwc")]
unique_name_in_owner = true
layout_mode = 1
[node name="SystemText" parent="." instance=ExtResource("4_o82xq")]
layout_mode = 1
[node name="Popups" type="Control" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="SaveAndLoadPopup" parent="Popups" instance=ExtResource("9_ueme0")]
unique_name_in_owner = true
visible = false
layout_mode = 1
[node name="TextSettingsPopup" parent="Popups" instance=ExtResource("13_dn3wu")]
unique_name_in_owner = true
visible = false
layout_mode = 1
[node name="SoundSettingsPopup" parent="Popups" instance=ExtResource("10_csjib")]
unique_name_in_owner = true
visible = false
layout_mode = 1
[node name="HistoryPopup" parent="Popups" instance=ExtResource("8_207hf")]
unique_name_in_owner = true
visible = false
layout_mode = 1
[node name="QuitPopup" parent="Popups" instance=ExtResource("14_m3nqq")]
unique_name_in_owner = true
visible = false
layout_mode = 1

View file

@ -0,0 +1,15 @@
[gd_resource type="Resource" script_class="PopochiuGUIInfo" load_steps=3 format=3 uid="uid://b8ywbuj4wcljy"]
[ext_resource type="Script" path="res://addons/popochiu/engine/others/popochiu_gui_info.gd" id="1_bvg81"]
[ext_resource type="Texture2D" uid="uid://d0kfwop28dwxj" path="res://addons/popochiu/icons/ico_simple_click.png" id="1_sp7kq"]
[resource]
script = ExtResource("1_bvg81")
title = "Simple Click"
description = "- [b]Left click[/b] to interact.
- [b]Right click[/b] to examine.
- [b]Inventory bar[/b] on top-left corner (by default).
- [b]Settings bar[/b] on top-right corner (by default).
Like in games such as Beneath A Steel Sky, Broken Sword, Samorost, Machinarium."
icon = ExtResource("1_sp7kq")