This commit is contained in:
2026-07-09 21:33:33 +02:00
commit 84a2a365f3
2364 changed files with 950134 additions and 0 deletions
@@ -0,0 +1,81 @@
using UnityEngine;
using UnityEngine.UIElements;
using VOID.Generic;
using VOID.Generic.SaveLoad;
namespace VOID.UserInterface.MainMenu
{
public class MainMenuUI : MonoBehaviour
{
public static MainMenuUI current { get; private set; }
// Visual Elements
private VisualElement _rootElement;
private Button _newGameButton;
private Button _profileButton;
private Label _currentProfileLabel;
private Button _settingsButton;
private Button _exitButton;
private void Awake()
{
current = this;
var uiDocument = gameObject.GetComponent<UIDocument>();
var templateElement = uiDocument.rootVisualElement;
// Find all important elements
_rootElement = templateElement.Q("root-main-menu");
_newGameButton = templateElement.Q<Button>("new-game");
_newGameButton.clicked += NewGameButton;
_profileButton = templateElement.Q<Button>("profile");
_profileButton.clicked += ProfileButton;
_currentProfileLabel = templateElement.Q<Label>("current-profile-name");
_settingsButton = templateElement.Q<Button>("settings");
_settingsButton.clicked += SettingsButton;
_exitButton = templateElement.Q<Button>("exit");
_exitButton.clicked += ExitButton;
}
private void Start()
{
// Force update active profile name on game start
OnProfileChange(PlayerProfileManager.current.activeProfile);
// Update selected profile when we change it
PlayerProfileManager.current.OnProfileChange += OnProfileChange;
}
private void OnProfileChange(PlayerProfile profile)
{
_newGameButton.style.opacity = profile != null ? 1f : 0.2f;
_currentProfileLabel.text = profile != null ? profile.name : "--- BRAK ---";
}
private void NewGameButton()
{
if (PlayerProfileManager.current.activeProfile == null)
{
Debug.LogWarning("Profile not selected!");
return;
}
GameLoopManager.current.LoadLobby();
}
private void ProfileButton()
{
ProfileSelectorUI.current.Toggle();
}
private void SettingsButton()
{
Debug.Log("TODO: nie ma ustawień :c");
}
private void ExitButton()
{
Application.Quit();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b898bbf0bed54dbca9f5dc56d1fb8f31
timeCreated: 1730207492
@@ -0,0 +1,17 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance"
engine="UnityEngine.UIElements" editor="UnityEditor.UIElements"
noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/MainMenu/MainMenuUIStyle.uss?fileID=7433441132597879392&amp;guid=71bd534bbfc445b439fa7a42dcde75d1&amp;type=3#MainMenuUIStyle" />
<ui:VisualElement name="main-menu-root">
<ui:VisualElement class="background">
<ui:Button text="Rozpocznij Grę" name="new-game" class="main-menu-button" />
<ui:Button text="Profile" name="profile" class="main-menu-button" />
<ui:VisualElement class="current-profile">
<ui:Label text="Wybrany profil:" picking-mode="Ignore" />
<ui:Label text="{PROFILE_NAME}" name="current-profile-name" picking-mode="Ignore" />
</ui:VisualElement>
<ui:Button text="Ustawienia" name="settings" class="main-menu-button" />
<ui:Button text="Wyjście" name="exit" class="main-menu-button" />
</ui:VisualElement>
</ui:VisualElement>
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: bceeb92f01660954c8dc5f927f3f4a21
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
@@ -0,0 +1,45 @@
#main-menu-root {
height: 100%;
justify-content: center;
align-items: flex-start;
align-self: flex-start;
}
.background {
background-image: url('project://database/Assets/_ADDONS/MedievalKingdomUI/Artworks/White_gold_Skin/UI_elements_W/Login_bar.png?fileID=2800000&guid=9e73dfeeb2b076a45b9f4f939bc1cd58&type=3#Login_bar');
padding-top: 20px;
padding-right: 80px;
padding-bottom: 20px;
padding-left: 80px;
align-items: center;
}
.main-menu-button {
width: 300px;
height: 60px;
font-size: 24px;
-unity-font-style: bold;
background-image: url('project://database/Assets/_ADDONS/MedievalKingdomUI/Artworks/Classic_Skin/Buttons_C/Button_longer.png?fileID=2800000&guid=ffd030649606bc34d8171bad77a1cc86&type=3#Button_longer');
-unity-background-scale-mode: stretch-to-fill;
background-color: rgba(0, 0, 0, 0);
color: rgb(255, 255, 255);
margin-top: 20px;
margin-bottom: 20px;
border-top-width: 0;
border-right-width: 0;
border-bottom-width: 0;
border-left-width: 0;
}
.current-profile {
flex-direction: row;
align-items: center;
font-size: 18px;
-unity-font-style: normal;
color: rgb(255, 255, 255);
margin-top: -30px;
}
.current-profile > #current-profile-name {
-unity-font-style: bold;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 71bd534bbfc445b439fa7a42dcde75d1
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0
@@ -0,0 +1,85 @@
using UnityEngine;
using UnityEngine.UIElements;
using VOID.Generic.SaveLoad;
namespace VOID.UserInterface.MainMenu
{
public class ProfileSelectorUI : MonoBehaviour
{
public static ProfileSelectorUI current { get; private set; }
// Visual Elements
private VisualElement _rootElement;
private Button _closeButton;
private VisualElement _profileListElement;
private TextField _profileAddNameTextField;
private Button _profileAddButton;
private void Awake()
{
current = this;
var uiDocument = gameObject.GetComponent<UIDocument>();
var templateElement = uiDocument.rootVisualElement;
// Find all important elements
_rootElement = templateElement.Q("root-profile-selector");
_closeButton = templateElement.Q<Button>("close");
_closeButton.clicked += Close;
_profileListElement = templateElement.Q<VisualElement>("profile-list");
_profileAddNameTextField = templateElement.Q<TextField>("profile-add-name");
_profileAddButton = templateElement.Q<Button>("profile-add");
_profileAddButton.clicked += AddProfile;
Close();
}
public void Open()
{
Close();
// Show if hidden
_rootElement.style.display = DisplayStyle.Flex;
// Populate UI with existing profiles
PlayerProfileManager.current.GetProfiles().ForEach(profile =>
ProfileUI.InitNew(gameObject, _profileListElement, profile, SelectProfile, DeleteProfile));
}
public void Close()
{
// Close profile selector and clear its content
_profileListElement.Clear();
_rootElement.style.display = DisplayStyle.None;
}
public void Toggle()
{
if (_rootElement.style.display == DisplayStyle.Flex)
Close();
else
Open();
}
private void SelectProfile(PlayerProfile profile)
{
PlayerProfileManager.current.SelectProfile(profile);
Close();
}
private void DeleteProfile(PlayerProfile profile)
{
PlayerProfileManager.current.DeleteProfile(profile);
}
private void AddProfile()
{
// Init and add new profile to list
var profile = PlayerProfileManager.current.CreateProfile(_profileAddNameTextField.text);
ProfileUI.InitNew(gameObject, _profileListElement, profile, SelectProfile, DeleteProfile);
// Clear text field
_profileAddNameTextField.SetValueWithoutNotify("");
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 67d12c072e6441d795f22c832a104fa4
timeCreated: 1730227320
@@ -0,0 +1,20 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance"
engine="UnityEngine.UIElements" editor="UnityEditor.UIElements"
noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:Template name="ProfileUI" src="project://database/Assets/92%20-%20UserInterface/Generic/MainMenu/ProfileUI.uxml?fileID=9197481963319205126&amp;guid=647093481b18a0545a317b213681c4ae&amp;type=3#ProfileUI" />
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/MainMenu/ProfileSelectorUIStyle.uss?fileID=7433441132597879392&amp;guid=6e9a57985c8e7944882a40f65b6ce1fa&amp;type=3#ProfileSelectorUIStyle" />
<ui:VisualElement name="root-profile-selector">
<ui:VisualElement class="background">
<ui:Button text="X" name="close" style="border-top-width: 0; border-right-width: 0; border-bottom-width: 0; border-left-width: 0;" />
<ui:VisualElement name="profile-list" style="flex-grow: 1;">
<ui:Instance template="ProfileUI" />
<ui:Instance template="ProfileUI" />
<ui:Instance template="ProfileUI" />
</ui:VisualElement>
<ui:VisualElement class="profile-add-row">
<ui:TextField placeholder-text="Nazwa nowego profilu..." name="profile-add-name" max-length="32" />
<ui:Button name="profile-add" text="+" />
</ui:VisualElement>
</ui:VisualElement>
</ui:VisualElement>
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: b1339bf6d1a92da478f12091b7453502
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
@@ -0,0 +1,58 @@
#root-profile-selector {
height: 100%;
justify-content: center;
align-items: flex-start;
align-self: flex-start;
left: 475px;
width: 400px;
}
.background {
background-image: url('project://database/Assets/_ADDONS/MedievalKingdomUI/Artworks/White_gold_Skin/UI_elements_W/Main_bar.png?fileID=2800000&guid=2989a4dc4115a014490b11afadbdb163&type=3#Main_bar');
padding-top: 20px;
padding-right: 20px;
padding-bottom: 20px;
padding-left: 20px;
align-items: center;
width: 100%;
}
#close {
position: absolute;
right: -15px;
top: -15px;
width: 30px;
height: 30px;
background-image: url('project://database/Assets/_ADDONS/MedievalKingdomUI/Artworks/White_gold_Skin/Buttons_W/Button_round.png?fileID=2800000&guid=e4017002311fb1b44b1347e0c7e1e44a&type=3#Button_round');
background-color: rgba(0, 0, 0, 0);
-unity-font-style: bold;
color: rgb(164, 164, 164);
}
#profile-list {
width: 100%;
}
#profile-list > TemplateContainer {
}
.profile-add-row {
width: 100%;
flex-direction: row;
margin-top: 20px;
}
.profile-add-row > #profile-add-name {
height: 50px;
flex-grow: 1;
}
.profile-add-row > #profile-add {
align-self: flex-end;
width: 50px;
height: 50px;
-unity-font-style: bold;
font-size: 50px;
color: rgb(44, 101, 39);
-unity-text-align: middle-center;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6e9a57985c8e7944882a40f65b6ce1fa
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0
@@ -0,0 +1,42 @@
using System;
using UnityEngine;
using UnityEngine.UIElements;
using VOID.Generic.SaveLoad;
namespace VOID.UserInterface.MainMenu
{
public class ProfileUI : MonoBehaviour
{
public static ProfileUI InitNew(
GameObject gameObject,
VisualElement parentWrapperElement,
PlayerProfile profile,
Action<PlayerProfile> onSelect,
Action<PlayerProfile> onDelete
)
{
// New instance to manage this option
var instance = gameObject.AddComponent<ProfileUI>();
// Get all needed visual elements
var templateElement = GameUI.current.profileTemplate.CloneTree().contentContainer;
templateElement.Q<Button>("select-profile").text = profile.name;
templateElement.Q<Button>("select-profile").clicked += () => onSelect.Invoke(profile);
templateElement.Q<Button>("delete-profile").clicked += () =>
{
onDelete.Invoke(profile);
parentWrapperElement.Remove(templateElement);
Destroy(instance);
};
// Put this option into LevelUpUI
parentWrapperElement.Add(templateElement);
// Bind UI to this script + make it pickable
templateElement.dataSource = instance;
templateElement.pickingMode = PickingMode.Position;
return instance;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f3600bf750a54535b62e8455c694d130
timeCreated: 1730322424
@@ -0,0 +1,9 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance"
engine="UnityEngine.UIElements" editor="UnityEditor.UIElements"
noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/92%20-%20UserInterface/Generic/MainMenu/ProfileUIStyle.uss?fileID=7433441132597879392&amp;guid=bd4b2829bb1800546acd8aafd57ed4d7&amp;type=3#ProfileUIStyle" />
<ui:VisualElement name="root-profile">
<ui:Button text="{PROFILE_NAME}" name="select-profile" />
<ui:Button name="delete-profile" text="X" />
</ui:VisualElement>
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 647093481b18a0545a317b213681c4ae
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
@@ -0,0 +1,19 @@
#root-profile {
justify-content: flex-start;
align-items: flex-start;
flex-direction: row;
width: 100%;
}
#select-profile {
height: 50px;
flex-grow: 1;
}
#delete-profile {
height: 50px;
width: 50px;
font-size: 30px;
-unity-font-style: bold;
color: rgb(188, 0, 0);
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bd4b2829bb1800546acd8aafd57ed4d7
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0