generated from m4gr3d/Godot-Android-Plugin-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add player functionality to demo project Refactor friend package to player package Some other small refactors everywhere Signed-off-by: Jacob Ibáñez Sánchez <jacobibanez@jacobibanez.com>
- Loading branch information
Showing
22 changed files
with
740 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
extends Control | ||
|
||
@onready var id_label: Label = %IdLabel | ||
@onready var name_label: Label = %NameLabel | ||
@onready var title_label: Label = %TitleLabel | ||
@onready var status_label: Label = %StatusLabel | ||
@onready var level_label: Label = %LevelLabel | ||
@onready var xp_label: Label = %XpLabel | ||
|
||
@onready var compare_button: Button = %CompareButton | ||
|
||
var friend: PlayersClient.Player | ||
|
||
func _ready() -> void: | ||
if friend: | ||
_set_up_display() | ||
compare_button.pressed.connect(func(): | ||
PlayersClient.compare_profile_with(friend.player_id) | ||
) | ||
|
||
func _set_up_display() -> void: | ||
id_label.text = friend.player_id | ||
name_label.text = friend.display_name | ||
title_label.text = friend.title | ||
status_label.text = PlayersClient.PlayerFriendStatus.find_key(friend.friend_status) | ||
level_label.text = str(friend.level_info.current_level.level_number) | ||
xp_label.text = str(friend.level_info.current_xp_total) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://cipu5ch2lo1ne"] | ||
|
||
[ext_resource type="Theme" uid="uid://bmm3mvq11y045" path="res://theme.tres" id="1_ylrpt"] | ||
[ext_resource type="Script" path="res://scenes/players/FriendDisplay.gd" id="2_nfjqs"] | ||
|
||
[node name="FriendDisplay" type="PanelContainer"] | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
mouse_filter = 1 | ||
theme = ExtResource("1_ylrpt") | ||
script = ExtResource("2_nfjqs") | ||
|
||
[node name="MarginContainer" type="MarginContainer" parent="."] | ||
layout_mode = 2 | ||
theme_override_constants/margin_left = 25 | ||
theme_override_constants/margin_top = 25 | ||
theme_override_constants/margin_right = 25 | ||
theme_override_constants/margin_bottom = 25 | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] | ||
layout_mode = 2 | ||
theme_override_constants/separation = 25 | ||
|
||
[node name="Id" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/Id"] | ||
layout_mode = 2 | ||
text = "ID:" | ||
|
||
[node name="IdLabel" type="Label" parent="MarginContainer/VBoxContainer/Id"] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
text_overrun_behavior = 3 | ||
|
||
[node name="Name" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/Name"] | ||
layout_mode = 2 | ||
text = "Name:" | ||
|
||
[node name="NameLabel" type="Label" parent="MarginContainer/VBoxContainer/Name"] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
text_overrun_behavior = 3 | ||
|
||
[node name="Title" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/Title"] | ||
layout_mode = 2 | ||
text = "Title:" | ||
|
||
[node name="TitleLabel" type="Label" parent="MarginContainer/VBoxContainer/Title"] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
|
||
[node name="Status" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/Status"] | ||
layout_mode = 2 | ||
text = "Status:" | ||
|
||
[node name="StatusLabel" type="Label" parent="MarginContainer/VBoxContainer/Status"] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
|
||
[node name="Level" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/Level"] | ||
layout_mode = 2 | ||
text = "Level:" | ||
|
||
[node name="LevelLabel" type="Label" parent="MarginContainer/VBoxContainer/Level"] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
|
||
[node name="Xp" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/Xp"] | ||
layout_mode = 2 | ||
text = "XP:" | ||
|
||
[node name="XpLabel" type="Label" parent="MarginContainer/VBoxContainer/Xp"] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
|
||
[node name="HSeparator" type="HSeparator" parent="MarginContainer/VBoxContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="Compare" type="VBoxContainer" parent="MarginContainer/VBoxContainer"] | ||
layout_mode = 2 | ||
theme_override_constants/separation = 25 | ||
|
||
[node name="CompareButton" type="Button" parent="MarginContainer/VBoxContainer/Compare"] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
theme = ExtResource("1_ylrpt") | ||
text = "Compare" | ||
text_overrun_behavior = 3 | ||
|
||
[node name="HSeparator2" type="HSeparator" parent="MarginContainer/VBoxContainer"] | ||
visible = false | ||
layout_mode = 2 | ||
|
||
[node name="Variants" type="VBoxContainer" parent="MarginContainer/VBoxContainer"] | ||
visible = false | ||
layout_mode = 2 | ||
theme_override_constants/separation = 25 | ||
|
||
[node name="TimeSpan" type="VBoxContainer" parent="MarginContainer/VBoxContainer/Variants"] | ||
layout_mode = 2 | ||
|
||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/Variants/TimeSpan"] | ||
layout_mode = 2 | ||
text = "Time Span" | ||
|
||
[node name="TimeSpan" type="OptionButton" parent="MarginContainer/VBoxContainer/Variants/TimeSpan"] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
|
||
[node name="Collection" type="VBoxContainer" parent="MarginContainer/VBoxContainer/Variants"] | ||
layout_mode = 2 | ||
|
||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/Variants/Collection"] | ||
layout_mode = 2 | ||
text = "Collection" | ||
|
||
[node name="Collection" type="OptionButton" parent="MarginContainer/VBoxContainer/Variants/Collection"] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
|
||
[node name="ShowVariant" type="Button" parent="MarginContainer/VBoxContainer/Variants"] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
theme = ExtResource("1_ylrpt") | ||
disabled = true | ||
text = "Show Leaderboard Variant" | ||
text_overrun_behavior = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
extends Control | ||
|
||
@onready var back_button: Button = %Back | ||
|
||
@onready var friends_display: VBoxContainer = %FriendsDisplay | ||
|
||
var _friends_cache: Array[PlayersClient.Player] = [] | ||
var _friend_display := preload("res://scenes/players/FriendDisplay.tscn") | ||
|
||
func _ready() -> void: | ||
if _friends_cache.is_empty(): | ||
PlayersClient.load_friends(10, true, true) | ||
PlayersClient.friends_loaded.connect( | ||
func cache_and_display(friends: Array[PlayersClient.Player]): | ||
_friends_cache = friends | ||
if not _friends_cache.is_empty() and friends_display.get_child_count() == 0: | ||
for friend: PlayersClient.Player in _friends_cache: | ||
var container := _friend_display.instantiate() as Control | ||
container.friend = friend | ||
friends_display.add_child(container) | ||
) | ||
|
||
back_button.pressed.connect(func(): | ||
get_tree().change_scene_to_file("res://scenes/MainMenu.tscn") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://ewhiun7ljryy"] | ||
|
||
[ext_resource type="Theme" uid="uid://bmm3mvq11y045" path="res://theme.tres" id="1_i7feq"] | ||
[ext_resource type="Script" path="res://scenes/players/Players.gd" id="2_xda1v"] | ||
|
||
[node name="Players" type="Control"] | ||
layout_mode = 3 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
theme = ExtResource("1_i7feq") | ||
script = ExtResource("2_xda1v") | ||
|
||
[node name="MarginContainer" type="MarginContainer" parent="."] | ||
layout_mode = 1 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
theme_override_constants/margin_left = 50 | ||
theme_override_constants/margin_top = 150 | ||
theme_override_constants/margin_right = 50 | ||
theme_override_constants/margin_bottom = 50 | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] | ||
layout_mode = 2 | ||
theme_override_constants/separation = 50 | ||
|
||
[node name="NavBar" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] | ||
layout_mode = 2 | ||
|
||
[node name="Back" type="Button" parent="MarginContainer/VBoxContainer/NavBar"] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
theme = ExtResource("1_i7feq") | ||
text = "Back" | ||
|
||
[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/VBoxContainer"] | ||
layout_mode = 2 | ||
size_flags_vertical = 3 | ||
horizontal_scroll_mode = 0 | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer"] | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
size_flags_vertical = 3 | ||
theme_override_constants/separation = 25 | ||
|
||
[node name="ShowAchievements" type="Button" parent="MarginContainer/VBoxContainer/ScrollContainer/VBoxContainer"] | ||
unique_name_in_owner = true | ||
visible = false | ||
custom_minimum_size = Vector2(500, 200) | ||
layout_mode = 2 | ||
theme = ExtResource("1_i7feq") | ||
text = "Show Achievements" | ||
|
||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/ScrollContainer/VBoxContainer"] | ||
layout_mode = 2 | ||
text = "Friends" | ||
horizontal_alignment = 1 | ||
|
||
[node name="FriendsDisplay" type="VBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer/VBoxContainer"] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
size_flags_vertical = 3 | ||
theme_override_constants/separation = 25 |
Oops, something went wrong.