diff --git a/common/game_data/scripts/settings_data.gd b/common/game_data/scripts/settings_data.gd index 11be536..b4b2640 100644 --- a/common/game_data/scripts/settings_data.gd +++ b/common/game_data/scripts/settings_data.gd @@ -10,6 +10,7 @@ signal sound_changed(settings : SettingsData) signal video_changed(settings : SettingsData) signal game_changed(settings : SettingsData) signal fov_changed(value : float) +signal twitch_changed(settings : SettingsData) #region ------------------ Language ------------------ @@ -97,4 +98,16 @@ func close_help_container(help_container_name : String): func open_help_container(help_container_name : String): if help_container_name in closed_help_containers: closed_help_containers.erase(help_container_name) - game_changed.emit(self) \ No newline at end of file + game_changed.emit(self) + +#region ------------------ Twitch ------------------ + +@export var activate_twitch_integration := false : + set(v): + activate_twitch_integration = v + twitch_changed.emit(self) + +@export var twitch_channel := "" : + set(v): + twitch_channel = v + twitch_changed.emit(self) diff --git a/common/icons/brand-twitch.svg b/common/icons/brand-twitch.svg new file mode 100644 index 0000000..11d8966 --- /dev/null +++ b/common/icons/brand-twitch.svg @@ -0,0 +1,35 @@ + + + + + + + + diff --git a/common/icons/brand-twitch.svg.import b/common/icons/brand-twitch.svg.import new file mode 100644 index 0000000..c6b68e1 --- /dev/null +++ b/common/icons/brand-twitch.svg.import @@ -0,0 +1,43 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cvvnrj8wi3f3r" +path="res://.godot/imported/brand-twitch.svg-a028bcfb5c21b506b9222ac521f85c82.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://common/icons/brand-twitch.svg" +dest_files=["res://.godot/imported/brand-twitch.svg-a028bcfb5c21b506b9222ac521f85c82.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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 +svg/scale=2.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/common/tools/scripts/random.gd b/common/tools/scripts/random.gd index 02ffab9..9d04925 100644 --- a/common/tools/scripts/random.gd +++ b/common/tools/scripts/random.gd @@ -8,6 +8,13 @@ const CONSONANTS = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", static func generate_random_word(_random_seed = randi()) -> String: + if ( + GameInfo + and GameInfo.settings_data.activate_twitch_integration + and len(TwitchConnection.pseudo_gathered) + ): + return TwitchConnection.pseudo_gathered.pick_random() + var word_len = randf_range(4,8) var word = '' var last_letter_is_vowel = false diff --git a/common/twitch_connection/twitch_connection.gd b/common/twitch_connection/twitch_connection.gd new file mode 100644 index 0000000..6138242 --- /dev/null +++ b/common/twitch_connection/twitch_connection.gd @@ -0,0 +1,24 @@ +extends Node + +signal pseudo_gathered_updated(pseudos) + +var pseudo_gathered : Array[String] = [] + +func _ready(): + VerySimpleTwitch.chat_message_received.connect(_on_message_received) + GameInfo.settings_data.twitch_changed.connect(connect_to_twitch) + +func connect_to_twitch(settings : SettingsData): + pseudo_gathered = [] + pseudo_gathered_updated.emit(pseudo_gathered) + VerySimpleTwitch.end_chat_client() + if settings.activate_twitch_integration: + connect_to_twitch_account(settings.twitch_channel) + +func connect_to_twitch_account(channel_name: String): + VerySimpleTwitch.login_chat_anon(channel_name) + +func _on_message_received(chatter: VSTChatter): + if not chatter.login in pseudo_gathered: + pseudo_gathered.append(chatter.login) + pseudo_gathered_updated.emit(pseudo_gathered) diff --git a/common/twitch_connection/twitch_connection.gd.uid b/common/twitch_connection/twitch_connection.gd.uid new file mode 100644 index 0000000..cd6b866 --- /dev/null +++ b/common/twitch_connection/twitch_connection.gd.uid @@ -0,0 +1 @@ +uid://fm17qbe4kqqo diff --git a/gui/menu/settings/scripts/settings.gd b/gui/menu/settings/scripts/settings.gd index e741bc1..2c644b7 100644 --- a/gui/menu/settings/scripts/settings.gd +++ b/gui/menu/settings/scripts/settings.gd @@ -12,6 +12,8 @@ func _ready(): setup_sound() setup_video() setup_controls() + setup_twitch() + update_twitch_pseudo() show() %SettingsWindow.hide() %SettingsWindow.closed.connect( @@ -19,10 +21,17 @@ func _ready(): GameInfo.save_settings() ) + TwitchConnection.pseudo_gathered_updated.connect( + func (_p):update_twitch_pseudo() + ) + func open_settings(): setup_languages() setup_sound() + setup_video() setup_controls() + setup_twitch() + update_twitch_pseudo() show() %SettingsWindow.open_window() @@ -51,6 +60,17 @@ func setup_controls(): %FovSlider.value = settings.fov %SensibilitySlider.value = settings.mouse_sensivity +func setup_twitch(): + %TwitchActivationCheckBox.button_pressed = settings.activate_twitch_integration + %TwitchChannelLineEdit.text = settings.twitch_channel + +func update_twitch_pseudo(): + if GameInfo.settings_data.activate_twitch_integration: + %TwitchPseudoCount.text = tr("PSEUDO_GATHERED_%d") % len(TwitchConnection.pseudo_gathered) + else: + %TwitchPseudoCount.text = "TWITCH_NOT_CONNECTED" + + func _on_language_option_button_item_selected(index: int): settings.language = SettingsData.AVAILABLE_LANGUAGES[index] @@ -85,3 +105,10 @@ func _on_sensibility_slider_value_changed(value: float): func _on_ui_size_slider_value_changed(value: float): settings.ui_size = %UiSizeSlider.value + +func _on_twitch_activation_check_box_toggled(toggled_on: bool): + settings.activate_twitch_integration = toggled_on + +func _on_twitch_channel_line_edit_editing_toggled(toggled_on: bool): + if not toggled_on: + settings.twitch_channel = %TwitchChannelLineEdit.text diff --git a/gui/menu/settings/settings.tscn b/gui/menu/settings/settings.tscn index 151c6e2..ea8e2bf 100644 --- a/gui/menu/settings/settings.tscn +++ b/gui/menu/settings/settings.tscn @@ -7,9 +7,8 @@ [ext_resource type="PackedScene" uid="uid://d3agt2njfgddb" path="res://gui/menu/window/content_label.tscn" id="4_rbiwc"] [ext_resource type="AudioStream" uid="uid://8juy5ev3rdfh" path="res://common/audio_manager/assets/sfx/plant_points/plant_point_1.wav" id="6_8f00b"] -[node name="Settings" type="Control" unique_id=1832300574] +[node name="Settings" type="MarginContainer" unique_id=1374154672] process_mode = 3 -layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -17,16 +16,19 @@ grow_horizontal = 2 grow_vertical = 2 size_flags_horizontal = 3 size_flags_vertical = 3 -mouse_filter = 1 +theme_override_constants/margin_left = 100 +theme_override_constants/margin_top = 100 +theme_override_constants/margin_right = 100 +theme_override_constants/margin_bottom = 100 script = ExtResource("1_7t8mv") [node name="SettingsWindow" parent="." unique_id=798514856 instance=ExtResource("1_gkn1k")] unique_name_in_owner = true process_mode = 3 -custom_minimum_size = Vector2(900, 667.77) -layout_mode = 1 -offset_left = -349.99994 -offset_right = 350.00055 +visible = false +custom_minimum_size = Vector2(800, 0) +layout_mode = 2 +size_flags_vertical = 1 mouse_filter = 0 title = "SETTINGS" @@ -144,7 +146,7 @@ size_flags_horizontal = 3 size_flags_vertical = 3 theme = ExtResource("2_7t8mv") min_value = 0.5 -max_value = 1.5 +max_value = 2.5 step = 0.01 value = 1.5 @@ -198,6 +200,45 @@ size_flags_horizontal = 10 size_flags_vertical = 4 theme = ExtResource("2_7t8mv") +[node name="TwitchIntegrationTitle" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent" unique_id=1569982523 instance=ExtResource("3_rbiwc")] +layout_mode = 2 +title = "TWITCH_INTEGRATION" + +[node name="GridContainer" type="GridContainer" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent" unique_id=522476269] +layout_mode = 2 +columns = 2 + +[node name="TwitchActivation" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GridContainer" unique_id=845492722 instance=ExtResource("4_rbiwc")] +layout_mode = 2 +size_flags_horizontal = 3 +text = "ACTIVATE_TWITCH_INTERACTION" + +[node name="TwitchActivationCheckBox" type="CheckBox" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GridContainer" unique_id=41914098] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 10 +size_flags_vertical = 4 +theme = ExtResource("2_7t8mv") + +[node name="TwitchChannel" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GridContainer" unique_id=761410855 instance=ExtResource("4_rbiwc")] +layout_mode = 2 +size_flags_horizontal = 3 +text = "TWITCH_CHANNEL" + +[node name="TwitchChannelLineEdit" type="LineEdit" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GridContainer" unique_id=1533093934] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="TwitchPseudoCount" parent="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent" unique_id=1953595699 instance=ExtResource("4_rbiwc")] +unique_name_in_owner = true +modulate = Color(1, 1, 1, 0.5882353) +layout_mode = 2 +size_flags_horizontal = 3 +text = "PSEUDO_GATHERED " +horizontal_alignment = 1 +vertical_alignment = 1 + [node name="MusicTestPlayer" type="AudioStreamPlayer" parent="." unique_id=1716804039] unique_name_in_owner = true stream = ExtResource("6_8f00b") @@ -222,5 +263,7 @@ bus = &"Sfx" [connection signal="value_changed" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/VideoSettings/FovSlider" to="." method="_on_fov_slider_value_changed"] [connection signal="value_changed" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GameSettings/SensibilitySlider" to="." method="_on_sensibility_slider_value_changed"] [connection signal="toggled" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GameSettings/AutoPickupCheckBox" to="." method="_on_auto_pickup_check_box_toggled"] +[connection signal="toggled" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GridContainer/TwitchActivationCheckBox" to="." method="_on_twitch_activation_check_box_toggled"] +[connection signal="editing_toggled" from="SettingsWindow/WindowContent/MarginContainer/ContentContainer/MarginContainer/SettingsContent/GridContainer/TwitchChannelLineEdit" to="." method="_on_twitch_channel_line_edit_editing_toggled"] [editable path="SettingsWindow"] diff --git a/gui/menu/window/scripts/window.gd b/gui/menu/window/scripts/window.gd index 516bda3..9b7d808 100644 --- a/gui/menu/window/scripts/window.gd +++ b/gui/menu/window/scripts/window.gd @@ -21,11 +21,15 @@ func _on_close_button_pressed(): func open_window(): show() - %ControlAnimationPlayer.appear() + modulate.a = 0. + var tween = create_tween() + tween.tween_property(self, 'modulate:a', 1, 0.3) func close_window(): if visible: - %ControlAnimationPlayer.disappear(0.3) - await get_tree().create_timer(0.3).timeout + modulate.a = 1. + var tween = create_tween() + tween.tween_property(self, 'modulate:a', 0, 0.3) + await tween.finished hide() closed.emit() diff --git a/project.godot b/project.godot index c506542..7053a1c 100644 --- a/project.godot +++ b/project.godot @@ -36,6 +36,8 @@ LoadingScreen="*res://gui/loading_screen/loading_screen.tscn" SceneManager="*res://common/scene_manager/scene_manager.tscn" SteamConnection="*uid://bq12bubjof2mo" GameInfo="*res://common/game_info/game_info.gd" +VerySimpleTwitch="*uid://cbrqfun2syqju" +TwitchConnection="*uid://fm17qbe4kqqo" [dialogic] @@ -122,7 +124,7 @@ translation/intern/translation_folder="res://translation/dialogs" [editor_plugins] -enabled=PackedStringArray("res://addons/dialogic/plugin.cfg") +enabled=PackedStringArray("res://addons/dialogic/plugin.cfg", "res://addons/very-simple-twitch/plugin.cfg") [input] @@ -261,3 +263,13 @@ initialization/app_id=4452760 initialization/initialize_on_startup=true initialization/embed_callbacks=true multiplayer_peer/max_channels=4 + +[twitcher] + +editor/game_oauth_token="res://common/twitch_connection/twitch_oauth_token.tres" +editor/game_oauth_setting="res://common/twitch_connection/twitch_oauth_setting.tres" +editor/resource_folder="res://common/twitch_connection" + +[very_simple_twitch] + +config/client_id="xg0yviwuskvnw1y6s6h5cmvalyfteb" diff --git a/stages/title_screen/title_screen.tscn b/stages/title_screen/title_screen.tscn index 02182c2..06bff4a 100644 --- a/stages/title_screen/title_screen.tscn +++ b/stages/title_screen/title_screen.tscn @@ -4,6 +4,8 @@ [ext_resource type="Script" uid="uid://cwmp2une7hobe" path="res://stages/title_screen/scripts/title_screen.gd" id="1_6yuhi"] [ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://common/icons/bolt.svg" id="3_6yuhi"] [ext_resource type="Texture2D" uid="uid://cdpqg3pkjcw2h" path="res://stages/title_screen/assets/textures/title.png" id="3_lwj2x"] +[ext_resource type="Texture2D" uid="uid://cvvnrj8wi3f3r" path="res://common/icons/brand-twitch.svg" id="3_gn4uv"] +[ext_resource type="FontFile" uid="uid://qt80w6o01q5s" path="res://gui/ressources/fonts/TitanOne-Regular.ttf" id="4_ofiho"] [ext_resource type="Texture2D" uid="uid://bewr0t1wi8pff" path="res://common/icons/rotate.svg" id="5_6yuhi"] [ext_resource type="PackedScene" uid="uid://cm5b7w7j6527f" path="res://stages/title_screen/planet_3d.tscn" id="5_7a1qq"] [ext_resource type="Texture2D" uid="uid://cixd5j8yqpavg" path="res://common/icons/settings.svg" id="6_3aitq"] @@ -23,6 +25,83 @@ [sub_resource type="ViewportTexture" id="ViewportTexture_6yuhi"] viewport_path = NodePath("SubViewport") +[sub_resource type="LabelSettings" id="LabelSettings_1xafb"] +font = ExtResource("4_ofiho") +font_size = 18 + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_g4v7s"] + +[sub_resource type="Animation" id="Animation_5icsl"] +length = 0.001 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("HSeparator:theme_override_constants/separation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} + +[sub_resource type="Animation" id="Animation_0vds4"] +resource_name = "bounce" +loop_mode = 1 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("HSeparator:theme_override_constants/separation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0, 3, 0), +"points": PackedFloat32Array(0, -0.25, 0, 0.43333334, 0.0279046, 10, -0.18480387, 0, 0.18480387, 0, 0, -0.5333333, -0.073566735, 0, 0), +"times": PackedFloat32Array(0, 0.46666667, 1) +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_0j8fm"] +_data = { +&"RESET": SubResource("Animation_5icsl"), +&"bounce": SubResource("Animation_0vds4") +} + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_rf16a"] +bg_color = Color(1, 0, 0.43137255, 1) +border_width_left = 10 +border_width_top = 10 +border_width_right = 10 +border_width_bottom = 10 +border_color = Color(1, 0, 0.43137255, 1) +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gn4uv"] +bg_color = Color(0.78039217, 0, 0.3372549, 1) +border_width_left = 10 +border_width_top = 10 +border_width_right = 10 +border_width_bottom = 10 +border_color = Color(0.78, 0, 0.33800003, 1) +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ofiho"] +bg_color = Color(1, 0.24000001, 0.5693334, 1) +border_width_left = 10 +border_width_top = 10 +border_width_right = 10 +border_width_bottom = 10 +border_color = Color(1, 0.23921569, 0.5686275, 1) +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 + [sub_resource type="ShaderMaterial" id="ShaderMaterial_lwj2x"] shader = ExtResource("8_pjo5j") shader_parameter/strength = 5.00000023424012 @@ -263,6 +342,37 @@ size_flags_horizontal = 8 size_flags_vertical = 0 text = "Version" +[node name="TwitchContainer" type="VBoxContainer" parent="MarginContainer" unique_id=1193568878] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 8 +theme_override_constants/separation = 0 + +[node name="TwitchInfo" type="HBoxContainer" parent="MarginContainer/TwitchContainer" unique_id=1516020408] +layout_mode = 2 +size_flags_horizontal = 0 +size_flags_vertical = 8 +alignment = 2 + +[node name="TextureRect" type="TextureRect" parent="MarginContainer/TwitchContainer/TwitchInfo" unique_id=1757288448] +modulate = Color(0.54509807, 0.1764706, 1, 1) +layout_mode = 2 +texture = ExtResource("3_gn4uv") + +[node name="Label" type="Label" parent="MarginContainer/TwitchContainer/TwitchInfo" unique_id=1597620585] +layout_mode = 2 +text = "TWITCH_INTEGRATION_IN_THE_SETTINGS" +label_settings = SubResource("LabelSettings_1xafb") + +[node name="HSeparator" type="HSeparator" parent="MarginContainer/TwitchContainer" unique_id=1913605901] +layout_mode = 2 +theme_override_constants/separation = 0 +theme_override_styles/separator = SubResource("StyleBoxEmpty_g4v7s") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="MarginContainer/TwitchContainer" unique_id=1532371629] +libraries/ = SubResource("AnimationLibrary_0j8fm") +autoplay = &"bounce" + [node name="GridContainer" type="HBoxContainer" parent="MarginContainer" unique_id=975183276] layout_mode = 2 alignment = 1 diff --git a/translation/game/gui.csv b/translation/game/gui.csv index ae04a52..417729c 100644 --- a/translation/game/gui.csv +++ b/translation/game/gui.csv @@ -20,6 +20,7 @@ RESUME_GAME,Resume,Reprendre RESTART,Restart,Recommencer RESTART_DEMO,Restart demo,Recommencer la démo QUIT,Quit,Quitter +TWITCH_INTEGRATION_IN_THE_SETTINGS,Twitch integration in the settings!,Intégration twitch dans les paramètres ! THIS_GAME_USE_AUTOSAVE,This game use autosave,Ce jeu sauvegarde votre progression automatiquement CHOOSE_GAME_MODE,Choose game mode,Choisissez le mode de jeu STORY_MODE,Story Mode,Mode Histoire @@ -193,6 +194,11 @@ UI_SIZE,Ui Size,Taille de l'UI GAME,Game,Jeu MOUSE_SENSIVITY,Mouse Sensivity in 3D scenes,Sensibilité de la souris dans les scènes en 3D AUTO_PICKUP,Auto pickup seeds,Récolte automatique des graines +TWITCH_INTEGRATION,Twitch integration (beta),Intégration Twitch (béta) +ACTIVATE_TWITCH_INTERACTION,Activate Twitch Integration,Activer l'intégration Twitch +TWITCH_CHANNEL,Twitch channel name,Nom de la chaine Twitch +PSEUDO_GATHERED_%d,"Connected, %d pseudos gathered","Connecté, %d pseudos récupérés" +TWITCH_NOT_CONNECTED,"Twitch not connected","Non connecté à Twitch" CONTROLS,Controls,Contrôles MOVE_RIGHT,Move right,Déplacement à droite MOVE_LEFT,Move left,Déplacement à gauche