ui Changes

This commit is contained in:
2024-09-29 23:33:11 +03:00
parent 8678db83f5
commit 1aa9048c40
22 changed files with 156 additions and 82 deletions
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c347a40ca3c44cf4da082942f26de978
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+50
View File
@@ -0,0 +1,50 @@
using Assets.Scripts.Interfaces;
using UnityEngine;
using UnityEngine.UIElements;
public class TopPanel : MonoBehaviour
{
private Label _timeLabel;
private Label _moneyLabel;
private Label _locationLabel;
private VisualElement _energy;
private VisualElement _food;
void Start()
{
GameManager.Instance.Time.OnMinuteChanged -= UpdateTime;
GameManager.Instance.Time.OnMinuteChanged += UpdateTime;
var root = GetComponent<UIDocument>().rootVisualElement;
_timeLabel = root.Q<Label>("TimeLabel");
_locationLabel= root.Q<Label>("LocationLabel");
_moneyLabel = root.Q<Label>("MoneyLabel");
_energy = root.Q<VisualElement>("EnergyProgressFill");
_food = root.Q<VisualElement>("HungerProgressFill");
}
private void OnDisable()
{
GameManager.Instance.Time.OnMinuteChanged -= UpdateTime;
}
// Update is called once per frame
void Update()
{
_moneyLabel.text = $"${(Player.Instance.Stats[StatsId.Money] as INumericStat).Value}";
_locationLabel.text= $"{(Player.Instance.Stats[StatsId.LocationName] as IStringStat).Value}";
}
private void UpdateTime()
{
if (_timeLabel != null)
{
_timeLabel.text = $"{GameManager.Instance.Time.CurrentTime.GetDayName()} {GameManager.Instance.Time.CurrentTime.ToString(@"hh\:mm")} day ({GameManager.Instance.Time.CurrentTime.Days})";
}
//progressBarFill.style.width = new Length(progress * 100, LengthUnit.Percent);
_energy.style.width = new Length((Player.Instance.Stats[StatsId.Energy] as INumericStat).Value , LengthUnit.Percent);
_food.style.width = new Length((Player.Instance.Stats[StatsId.Food] as INumericStat).Value, LengthUnit.Percent);
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b12a25de2b34933489e52900d32221dd
+6
View File
@@ -0,0 +1,6 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<Style src="project://database/Assets/UI/progressBar.uss?fileID=7433441132597879392&amp;guid=755fc3f2b04b5014794dec9f2787b86e&amp;type=3#progressBar" />
<ui:VisualElement name="VisualElement">
<ui:Button text="Button" style="border-top-left-radius: 20px; border-top-right-radius: 20px; border-bottom-right-radius: 20px; border-bottom-left-radius: 20px; background-color: rgb(255, 255, 255); color: rgb(0, 2, 255); width: 150px;" />
</ui:VisualElement>
</ui:UXML>
+10
View File
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 257b45a55d104c846b4c2a03096e6afa
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
+4 -4
View File
@@ -8,14 +8,14 @@
<Style src="project://database/Assets/UI/progressBar.uss?fileID=7433441132597879392&amp;guid=755fc3f2b04b5014794dec9f2787b86e&amp;type=3#progressBar" />
<ui:VisualElement name="icon" class="progress-icon" style="background-image: url(&quot;project://database/Assets/3dAssets/Textures/EnergyIcon.png?fileID=2800000&amp;guid=dfe1a973babd6cc4bb1a418ed2f3562e&amp;type=3#EnergyIcon&quot;);" />
<ui:VisualElement name="progressBarContainer" class="progress-bar-container">
<ui:VisualElement name="progressFill" class="progress-bar-fill" />
<ui:VisualElement name="EnergyProgressFill" class="progress-bar-fill" />
</ui:VisualElement>
</ui:VisualElement>
<ui:VisualElement name="HungerProgress" template="progressBar" class="stat-container">
<Style src="project://database/Assets/UI/progressBar.uss?fileID=7433441132597879392&amp;guid=755fc3f2b04b5014794dec9f2787b86e&amp;type=3#progressBar" />
<ui:VisualElement name="icon" class="progress-icon" style="background-image: url(&quot;project://database/Assets/3dAssets/Textures/FoodIcon.png?fileID=2800000&amp;guid=bc479ad3f781c4540995d023a62d8c1d&amp;type=3#FoodIcon&quot;);" />
<ui:VisualElement name="progressBarContainer" class="progress-bar-container">
<ui:VisualElement name="progressFill" class="progress-bar-fill" />
<ui:VisualElement name="HungerProgressFill" class="progress-bar-fill" />
</ui:VisualElement>
</ui:VisualElement>
<ui:VisualElement name="MoneyPanel" class="stat-container">
@@ -24,12 +24,12 @@
</ui:VisualElement>
</ui:VisualElement>
<ui:VisualElement name="LocationInfo" class="top-elements-block justify-center">
<ui:Label text="Nowhere" name="AdressLabel" class="top-bar-label justify-center" />
<ui:Label text="Nowhere" name="LocationLabel" class="top-bar-label justify-center" />
</ui:VisualElement>
<ui:VisualElement name="TimeInfo" class="top-elements-block justify-right">
<ui:VisualElement name="TimePanel" class="stat-container">
<ui:VisualElement name="icon" style="background-image: url(&quot;project://database/Assets/3dAssets/Textures/CalendarIcon.png?fileID=2800000&amp;guid=40259e4947454c74bb483b1fab03888e&amp;type=3#CalendarIcon&quot;); height: 20px; width: 20px;" />
<ui:Label text="Nowhere" name="ClockLabel" class="top-bar-label" />
<ui:Label text="Nowhere" name="TimeLabel" class="top-bar-label" />
</ui:VisualElement>
</ui:VisualElement>
</ui:VisualElement>