Commit c80893cd authored by saad's avatar saad

Merge branch 'NewUI' into pt_bugs

parents 9d58f7e6 3bd840a6
...@@ -51,6 +51,30 @@ public class AppRouter : MonoBehaviour ...@@ -51,6 +51,30 @@ public class AppRouter : MonoBehaviour
HandleBackButton(); HandleBackButton();
} }
private void OnApplicationPause(bool pause)
{
if (!pause && SupabaseManager.Instance?.IsInitialized == true)
{
RefreshSessionOnResume().Forget();
}
}
private async UniTaskVoid RefreshSessionOnResume()
{
if (SupabaseManager.Instance?.Supabase()?.Auth?.CurrentUser == null)
return;
try
{
await SupabaseManager.Instance.Supabase().Auth.RefreshSession();
Debug.Log("[AppRouter] Session refreshed on resume");
}
catch (Exception e)
{
Debug.LogWarning($"[AppRouter] Session refresh failed on resume: {e.Message}");
}
}
private void HandleBackButton() private void HandleBackButton()
{ {
// Safety: Don't let the back button break an active game session // Safety: Don't let the back button break an active game session
...@@ -85,8 +109,10 @@ public class AppRouter : MonoBehaviour ...@@ -85,8 +109,10 @@ public class AppRouter : MonoBehaviour
// Execution halts here until isConnected is true // Execution halts here until isConnected is true
await EnsureNetworkConnection(); await EnsureNetworkConnection();
await SupabaseManager.Instance.Initialize();
// --- STEP 2: Authentication Session --- // --- STEP 2: Authentication Session ---
UpdateStatus("Checking session...");
var authResult = await SupabaseAuthentication.Instance.EnsureSession(); var authResult = await SupabaseAuthentication.Instance.EnsureSession();
if (authResult.IsT1) // No valid session found if (authResult.IsT1) // No valid session found
...@@ -102,13 +128,11 @@ public class AppRouter : MonoBehaviour ...@@ -102,13 +128,11 @@ public class AppRouter : MonoBehaviour
} }
// --- STEP 3: Load User Profile --- // --- STEP 3: Load User Profile ---
UpdateStatus("Fetching profile...");
var prof = await UserService.Instance.GetCurrentUser(); var prof = await UserService.Instance.GetCurrentUser();
prof.Switch( prof.Switch(
async success => async success =>
{ {
UpdateStatus("Welcome back!");
TransitionManager.Instance().Transition("MainMenu", transitionSettings, 0.5f); TransitionManager.Instance().Transition("MainMenu", transitionSettings, 0.5f);
UserService.Instance.StartListening(); UserService.Instance.StartListening();
}, },
...@@ -168,16 +192,22 @@ public class AppRouter : MonoBehaviour ...@@ -168,16 +192,22 @@ public class AppRouter : MonoBehaviour
{ {
attempts++; attempts++;
UpdateStatus(attempts == 1 ? "Connecting..." : "Waiting for network...");
if (simulateNetworkFailure) switch (Application.internetReachability)
{ {
Debug.LogWarning("[TEST] simulateNetworkFailure is ON. Mocking connection failure."); case NetworkReachability.NotReachable:
isConnected = false; isConnected = false;
break;
case NetworkReachability.ReachableViaCarrierDataNetwork:
case NetworkReachability.ReachableViaLocalAreaNetwork:
isConnected = true;
break;
} }
else
if (simulateNetworkFailure)
{ {
isConnected = await SupabaseManager.Instance.Initialize(); Debug.LogWarning("[TEST] simulateNetworkFailure is ON. Mocking connection failure.");
isConnected = false;
} }
if (!isConnected) if (!isConnected)
...@@ -197,15 +227,9 @@ public class AppRouter : MonoBehaviour ...@@ -197,15 +227,9 @@ public class AppRouter : MonoBehaviour
AnimateOut(); AnimateOut();
} }
}
UpdateStatus("Connected!");
await UniTask.Delay(500); // Visual polish
} }
private void UpdateStatus(string message)
{
Debug.Log($"[AppRouter] {message}");
} }
// ─── Auth State Listener (Safety Net) ─────────────────────────── // ─── Auth State Listener (Safety Net) ───────────────────────────
......
using System.Linq;
using com.al_arcade.shared; using com.al_arcade.shared;
using Cysharp.Threading.Tasks;
using DG.Tweening;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; using UnityEngine.UIElements;
...@@ -11,26 +8,6 @@ public class HomeController : MonoBehaviour ...@@ -11,26 +8,6 @@ public class HomeController : MonoBehaviour
[SerializeField] private GameObject challengePrefab; [SerializeField] private GameObject challengePrefab;
[SerializeField] private int minQuestionsPerType = 5; [SerializeField] private int minQuestionsPerType = 5;
private Label username;
private Label xp;
private Label rank;
private Label xpRankEnd;
private CustomProgressBar nextRankProgressBar;
private Button challengeButton;
private Button practiceButton;
private Label nameMenuPanel;
private Label xpMenuPanel;
private Label rankMenuPanel;
private ScrollView activityScrollView;
private Button logoutButton;
private VisualElement menuPanel;
// Navigation guard — prevents concurrent Challenge + Practice clicks
public static bool IsNavigating { get; private set; } public static bool IsNavigating { get; private set; }
void Start() void Start()
...@@ -38,49 +15,42 @@ public class HomeController : MonoBehaviour ...@@ -38,49 +15,42 @@ public class HomeController : MonoBehaviour
QualitySettings.vSyncCount = 0; QualitySettings.vSyncCount = 0;
var root = mainMenuDocument.rootVisualElement.Q("Home"); var root = mainMenuDocument.rootVisualElement.Q("Home");
menuPanel = mainMenuDocument.rootVisualElement.Q("MenuPanel");
username = root.Q<Label>("Username");
rank = root.Q<Label>("Rank");
xp = root.Q<Label>("XP");
xpRankEnd = root.Q<Label>("XPRankEnd");
nextRankProgressBar = root.Q<CustomProgressBar>("NextRankProgressBar");
UserService.Instance.OnUserChanged += OnUserChange;
challengeButton = root.Q<Button>("Challenge"); root.Q<Button>("Challenge").clicked += OnChallengeButtonClicked;
challengeButton.clicked += OnChallengeButtonClicked; root.Q<Button>("OpenChallengePanel").clicked += OnChallengePanelButtonClicked;
practiceButton = root.Q<Button>("OpenPracticeButton");
SetPlayButtonsEnabled(false); SetPlayButtonsEnabled(false);
UserService.Instance.OnUserChanged += OnUserChange;
OnUserChange(UserService.Instance.CurrentUser); OnUserChange(UserService.Instance.CurrentUser);
} }
private void OnUserChange(User user) private void OnUserChange(User user)
{ {
if (user == null) if (user == null)
{ {
Debug.LogWarning("[HomeController] No user logged in"); Debug.LogWarning("[HomeController] No user logged in");
return; return;
} }
username.text = user.Username; var root = mainMenuDocument.rootVisualElement.Q("Home");
xp.text = user.Points.ToString();
rank.text = user.Rank;
xpRankEnd.text = $"{user.Points} / {Rank.FromXP(user.Points).EndXP}";
nextRankProgressBar.Value = Rank.FromXP(user.Points).Progress(user.Points); root.Q<Label>("Username").text = user.Username;
nextRankProgressBar.LeftText = Rank.FromXP(user.Points).StartXP.ToString() + " " + Rank.FromXP(user.Points).Name; root.Q<Label>("XP").text = user.Points.ToString();
nextRankProgressBar.RightText = Rank.FromXP(user.Points).Next?.StartXP.ToString() + " " + Rank.FromXP(user.Points).Next?.Name; root.Q<Label>("Rank").text = user.Rank;
root.Q<Label>("XPRankEnd").text = $"{user.Points} / {Rank.FromXP(user.Points).EndXP}";
var progressBar = root.Q<CustomProgressBar>("NextRankProgressBar");
progressBar.Value = Rank.FromXP(user.Points).Progress(user.Points);
progressBar.LeftText = Rank.FromXP(user.Points).StartXP.ToString() + " " + Rank.FromXP(user.Points).Name;
progressBar.RightText = Rank.FromXP(user.Points).Next?.StartXP.ToString() + " " + Rank.FromXP(user.Points).Next?.Name;
CheckQuestionAvailability(user); CheckQuestionAvailability(user);
} }
private void CheckQuestionAvailability(User user) private void CheckQuestionAvailability(User user)
{ {
Debug.Log("Checking question availability for user: " + user.Username + " (Grade: " + user.Grade + ", Term: " + user.Term + ")"); Debug.Log("Checking question availability for user: " + user.Username + " (Grade: " + user.Grade + ", Term: " + user.Term + user.Curriculum);
StartCoroutine(SSApiManager.EnsureInstance().GetChapters( StartCoroutine(SSApiManager.EnsureInstance().GetChapters(
chapters => chapters =>
{ {
...@@ -96,7 +66,11 @@ public class HomeController : MonoBehaviour ...@@ -96,7 +66,11 @@ public class HomeController : MonoBehaviour
&& cs >= minQuestionsPerType; && cs >= minQuestionsPerType;
SetPlayButtonsEnabled(enough); SetPlayButtonsEnabled(enough);
}, },
_ => SetPlayButtonsEnabled(false), _ =>
{
Debug.LogError("Failed to load chapters for user: " + user.Username);
SetPlayButtonsEnabled(false);
},
curriculumId: user.Curriculum, curriculumId: user.Curriculum,
gradeId: user.Grade, gradeId: user.Grade,
termId: user.Term termId: user.Term
...@@ -105,11 +79,16 @@ public class HomeController : MonoBehaviour ...@@ -105,11 +79,16 @@ public class HomeController : MonoBehaviour
private void SetPlayButtonsEnabled(bool enabled) private void SetPlayButtonsEnabled(bool enabled)
{ {
if (challengeButton != null) var root = mainMenuDocument.rootVisualElement.Q("Home");
var openChallengePanelButton = root.Q<Button>("OpenChallengePanel");
var practiceButton = root.Q<Button>("OpenPracticeButton");
if (openChallengePanelButton != null)
{ {
challengeButton.SetEnabled(enabled); openChallengePanelButton.SetEnabled(enabled);
challengeButton.style.opacity = enabled ? 1f : 0.35f; openChallengePanelButton.style.opacity = enabled ? 1f : 0.35f;
} }
if (practiceButton != null) if (practiceButton != null)
{ {
practiceButton.SetEnabled(enabled); practiceButton.SetEnabled(enabled);
...@@ -123,38 +102,11 @@ public class HomeController : MonoBehaviour ...@@ -123,38 +102,11 @@ public class HomeController : MonoBehaviour
{ {
if (SupabaseManager.Instance.Supabase().Auth.CurrentUser.IsAnonymous) if (SupabaseManager.Instance.Supabase().Auth.CurrentUser.IsAnonymous)
{ {
challengeButton.style.opacity = 0.35f; var root = mainMenuDocument.rootVisualElement.Q("Home");
root.Q<Button>("OpenChallengePanel").style.opacity = 0.35f;
} }
} }
// private void OnNewActivityReceived(Activity activity)
// {
// var name = activity.Message.Split(" ")[0];
// var label = new Label($"<color=#FED700>{name}</color> {activity.Message[name.Length..]}");
// activityScrollView.Add(label);
// activityScrollView.contentContainer.RegisterCallbackOnce<GeometryChangedEvent>(_ =>
// {
// var targetScroll = activityScrollView.horizontalScroller.highValue;
// var currentScroll = activityScrollView.scrollOffset;
// activityScrollView.schedule.Execute(() =>
// {
// var newOffset = Mathf.Lerp(currentScroll.x, targetScroll, 0.15f);
// if (Mathf.Abs(targetScroll - newOffset) < 1f)
// {
// activityScrollView.scrollOffset = new Vector2(targetScroll, currentScroll.y);
// return;
// }
// currentScroll.x = newOffset;
// activityScrollView.scrollOffset = currentScroll;
// }).Every(16).Until(() => Mathf.Abs(activityScrollView.scrollOffset.x - targetScroll) < 1f);
// });
// }
private void OnChallengeButtonClicked() private void OnChallengeButtonClicked()
{ {
if (SupabaseManager.Instance.Supabase().Auth.CurrentUser.IsAnonymous) if (SupabaseManager.Instance.Supabase().Auth.CurrentUser.IsAnonymous)
...@@ -166,8 +118,10 @@ public class HomeController : MonoBehaviour ...@@ -166,8 +118,10 @@ public class HomeController : MonoBehaviour
if (IsNavigating) return; if (IsNavigating) return;
IsNavigating = true; IsNavigating = true;
challengeButton.SetEnabled(false); // var root = mainMenuDocument.rootVisualElement.Q("Home");
if (practiceButton != null) practiceButton.SetEnabled(false); // root.Q<Button>("Challenge").SetEnabled(false);
// var practiceButton = root.Q<Button>("OpenPracticeButton");
// practiceButton?.SetEnabled(false);
var challenge = Instantiate(challengePrefab); var challenge = Instantiate(challengePrefab);
var challengeManager = challenge.GetComponent<ChallengeManager>(); var challengeManager = challenge.GetComponent<ChallengeManager>();
...@@ -175,10 +129,17 @@ public class HomeController : MonoBehaviour ...@@ -175,10 +129,17 @@ public class HomeController : MonoBehaviour
challengeManager.StartChallenge(); challengeManager.StartChallenge();
} }
private void OnChallengePanelButtonClicked()
{
if (SupabaseManager.Instance.Supabase().Auth.CurrentUser.IsAnonymous)
{
ShowUIMessage.Instance.ShowMessage("سجل حساب أو سجل دخولك لتتمكن من الوصول إلى التحدي", true);
}
}
private void OnDestroy() private void OnDestroy()
{ {
IsNavigating = false; IsNavigating = false;
UserService.Instance.OnUserChanged -= OnUserChange; UserService.Instance.OnUserChanged -= OnUserChange;
challengeButton.clicked -= OnChallengeButtonClicked;
} }
} }
using System; using System;
using System.Collections.Generic;
using System.Threading; using System.Threading;
using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks;
using UnityEngine; using UnityEngine;
...@@ -30,13 +29,14 @@ public class LeaderboardController : MonoBehaviour, IDisposable ...@@ -30,13 +29,14 @@ public class LeaderboardController : MonoBehaviour, IDisposable
Button myRankButton = root.Q<Button>("MyRankButton"); Button myRankButton = root.Q<Button>("MyRankButton");
myRankButton.clicked += () => myRankButton.clicked += () =>
{ {
if(currentPlayerSlot == null) if (currentPlayerSlot == null)
{ {
ShowUIMessage.Instance.ShowMessage("حسابك ليس من ضمن افضل 100 لاعب"); ShowUIMessage.Instance.ShowMessage("حسابك ليس من ضمن افضل 100 لاعب");
} }
else else
{ {
leaderBoardScrollView.experimental.animation.Start(leaderBoardScrollView.scrollOffset.y, currentPlayerSlot.layout.y, 300, (v, t) => { leaderBoardScrollView.experimental.animation.Start(leaderBoardScrollView.scrollOffset.y, currentPlayerSlot.layout.y, 300, (v, t) =>
{
leaderBoardScrollView.scrollOffset = new Vector2(leaderBoardScrollView.scrollOffset.x, t); leaderBoardScrollView.scrollOffset = new Vector2(leaderBoardScrollView.scrollOffset.x, t);
}); });
} }
...@@ -75,7 +75,7 @@ public class LeaderboardController : MonoBehaviour, IDisposable ...@@ -75,7 +75,7 @@ public class LeaderboardController : MonoBehaviour, IDisposable
return; return;
result.Switch( result.Switch(
(List<LeaderboardPlayerModel> players) => players =>
{ {
currentPlayerSlot = null; currentPlayerSlot = null;
...@@ -104,10 +104,9 @@ public class LeaderboardController : MonoBehaviour, IDisposable ...@@ -104,10 +104,9 @@ public class LeaderboardController : MonoBehaviour, IDisposable
allPlayersContainer.Add(entry); allPlayersContainer.Add(entry);
} }
}, },
(string error) => error =>
{ {
var errorLabel = new Label($"Error loading leaderboard: {error}"); Debug.LogError($"Failed to load leaderboard: {error}");
allPlayersContainer.Add(errorLabel);
} }
); );
} }
......
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; using UnityEngine.UIElements;
public class ProfileController : MonoBehaviour public class ProfileController : MonoBehaviour
{ {
[SerializeField] private UIDocument profileDocument; [SerializeField] private UIDocument profileDocument;
private Label name;
private Button logoutButton;
private Button updateProfileButton;
private TextField UsernameLabel;
private DropdownField Grade;
private DropdownField Term;
private DropdownField Curriculum;
private CustomSwitch musicSwitch;
private CustomSwitch sfxSwitch;
private Button sure;
void Start() void Start()
{ {
var root = profileDocument.rootVisualElement.Q("Settings"); var root = profileDocument.rootVisualElement.Q("Settings");
name = root.Q<Label>("Username");
logoutButton = root.Q<Button>("LogoutButton");
logoutButton.clicked += AppRouter.Logout;
updateProfileButton = root.Q<Button>("UpdateProfile"); root.Q<Button>("LogoutButton").clicked += AppRouter.Logout;
updateProfileButton.clicked += () => root.Q<Button>("UpdateProfile").clicked += () => UpdateProfile();
{
UpdateProfile();
};
UsernameLabel = root.Q<TextField>("Name");
Grade = root.Q<DropdownField>("Grade");
Term = root.Q<DropdownField>("TermDrop");
Curriculum = root.Q<DropdownField>("Curriculum");
musicSwitch = root.Q<CustomSwitch>("MusicSwitch"); root.Q<CustomSwitch>("MusicSwitch").IsOn = SettingsCache.MusicEnabled;
sfxSwitch = root.Q<CustomSwitch>("SFXSwitch"); root.Q<CustomSwitch>("SFXSwitch").IsOn = SettingsCache.SfxEnabled;
musicSwitch.IsOn = SettingsCache.MusicEnabled; root.Q<CustomSwitch>("MusicSwitch").onValueChanged += (value) => SettingsCache.MusicEnabled = value;
sfxSwitch.IsOn = SettingsCache.SfxEnabled; root.Q<CustomSwitch>("SFXSwitch").onValueChanged += (value) => SettingsCache.SfxEnabled = value;
musicSwitch.onValueChanged += (value) => SettingsCache.MusicEnabled = value; profileDocument.rootVisualElement.Q<Button>("Sure").clicked += DeleteAccount;
sfxSwitch.onValueChanged += (value) => SettingsCache.SfxEnabled = value;
sure = profileDocument.rootVisualElement.Q<Button>("Sure");
sure.clicked += DeleteAccount;
UserService.Instance.OnUserChanged += OnUserChange; UserService.Instance.OnUserChanged += OnUserChange;
OnUserChange(UserService.Instance.CurrentUser); OnUserChange(UserService.Instance.CurrentUser);
...@@ -57,39 +28,47 @@ public class ProfileController : MonoBehaviour ...@@ -57,39 +28,47 @@ public class ProfileController : MonoBehaviour
{ {
if (user == null) return; if (user == null) return;
name.text = user.Username; var root = profileDocument.rootVisualElement.Q("Settings");
UsernameLabel.value = user.Username;
Grade.value = EducationManager.GetGradeName(user.Grade); root.Q<Label>("Username").text = user.Username;
Term.value = EducationManager.GetTermName(user.Term); root.Q<Label>("Email").text = user.Email;
Curriculum.value = EducationManager.GetCurriculumName(user.Curriculum); root.Q<TextField>("Name").value = user.Username;
root.Q<DropdownField>("Grade").value = EducationManager.GetGradeName(user.Grade);
root.Q<DropdownField>("TermDrop").value = EducationManager.GetTermName(user.Term);
root.Q<DropdownField>("Curriculum").value = EducationManager.GetCurriculumName(user.Curriculum);
} }
private async void UpdateProfile() private async void UpdateProfile()
{ {
var root = profileDocument.rootVisualElement.Q("Settings");
var updateProfileButton = root.Q<Button>("UpdateProfile");
updateProfileButton.SetEnabled(false); updateProfileButton.SetEnabled(false);
int gradeId = EducationManager.GetGradeId(Grade.value); var gradeValue = root.Q<DropdownField>("Grade").value;
int termId = EducationManager.GetTermId(Term.value); var termValue = root.Q<DropdownField>("TermDrop").value;
int curriculumId = EducationManager.GetCurriculumId(Curriculum.value); var curriculumValue = root.Q<DropdownField>("Curriculum").value;
print("Updating profile with: " + UsernameLabel.value + ", Grade: " + gradeId + ", Term: " + termId); int gradeId = EducationManager.GetGradeId(gradeValue);
int termId = EducationManager.GetTermId(termValue);
int curriculumId = EducationManager.GetCurriculumId(curriculumValue);
print("Updating profile with: " + root.Q<TextField>("Name").value + ", Grade: " + gradeId + ", Term: " + termId);
if (gradeId < 0 || termId < 0 || curriculumId < 0) if (gradeId < 0 || termId < 0 || curriculumId < 0)
{ {
updateProfileButton.SetEnabled(true); updateProfileButton.SetEnabled(true);
Debug.LogWarning("[Profile] Invalid grade or term selection"); Debug.LogWarning("[Profile] Invalid grade or term selection");
return; return;
} }
await UserService.Instance.UpdateProfile( await UserService.Instance.UpdateProfile(
username: UsernameLabel.value, username: root.Q<TextField>("Name").value,
grade: gradeId, grade: gradeId,
term: termId, term: termId,
curriculum: curriculumId curriculum: curriculumId
); );
updateProfileButton.SetEnabled(true); updateProfileButton.SetEnabled(true);
ShowUIMessage.Instance.ShowMessage("تم تحديث البيانات بنجاح", false); ShowUIMessage.Instance.ShowMessage("تم تحديث البيانات بنجاح", false);
} }
...@@ -102,9 +81,5 @@ public class ProfileController : MonoBehaviour ...@@ -102,9 +81,5 @@ public class ProfileController : MonoBehaviour
private void OnDestroy() private void OnDestroy()
{ {
UserService.Instance.OnUserChanged -= OnUserChange; UserService.Instance.OnUserChanged -= OnUserChange;
logoutButton.clicked -= AppRouter.Logout;
updateProfileButton.clicked -= UpdateProfile;
} }
} }
...@@ -180,7 +180,7 @@ public class LoginPageAnimation : MonoBehaviour ...@@ -180,7 +180,7 @@ public class LoginPageAnimation : MonoBehaviour
if (PlayerPrefs.GetInt("IsGuest") == 0) if (PlayerPrefs.GetInt("IsGuest") == 0)
{ {
var Username = registerRoot.Q<TextField>("Username").text; var Username = registerRoot.Q<TextField>("Username").text;
if (ShowErrorIfEmpty(Username, "اسم المستخدم")) if (ShowErrorIfTrue(() => string.IsNullOrEmpty(Username), "يرجي أدخال اسم المستخدم"))
{ {
registerButton.SetEnabled(true); registerButton.SetEnabled(true);
registerButton.text = "تسجيل"; registerButton.text = "تسجيل";
...@@ -188,7 +188,7 @@ public class LoginPageAnimation : MonoBehaviour ...@@ -188,7 +188,7 @@ public class LoginPageAnimation : MonoBehaviour
} }
var email = registerRoot.Q<TextField>("Email").text; var email = registerRoot.Q<TextField>("Email").text;
if (ShowErrorIfEmpty(email, "البريد الألكتروني")) if (ShowErrorIfTrue(() => string.IsNullOrEmpty(email), "يرجي أدخال البريد الألكتروني"))
{ {
registerButton.SetEnabled(true); registerButton.SetEnabled(true);
registerButton.text = "تسجيل"; registerButton.text = "تسجيل";
...@@ -196,7 +196,7 @@ public class LoginPageAnimation : MonoBehaviour ...@@ -196,7 +196,7 @@ public class LoginPageAnimation : MonoBehaviour
} }
var password = registerRoot.Q<TextField>("Password").text; var password = registerRoot.Q<TextField>("Password").text;
if (ShowErrorIfEmpty(password, "كلمة المرور")) if (ShowErrorIfTrue(() => string.IsNullOrEmpty(password), "يرجي أدخال كلمة المرور"))
{ {
registerButton.SetEnabled(true); registerButton.SetEnabled(true);
registerButton.text = "تسجيل"; registerButton.text = "تسجيل";
...@@ -204,45 +204,49 @@ public class LoginPageAnimation : MonoBehaviour ...@@ -204,45 +204,49 @@ public class LoginPageAnimation : MonoBehaviour
} }
var rePassword = registerRoot.Q<TextField>("RePassword").text; var rePassword = registerRoot.Q<TextField>("RePassword").text;
if (ShowErrorIfEmpty(rePassword, "تأكيد كلمة المرور")) if (ShowErrorIfTrue(() => string.IsNullOrEmpty(rePassword), "يرجي أدخال تأكيد كلمة المرور"))
{ {
registerButton.SetEnabled(true); registerButton.SetEnabled(true);
registerButton.text = "تسجيل"; registerButton.text = "تسجيل";
return; return;
} }
if(password != rePassword) if (password != rePassword)
{ {
ShowUIMessage.Instance.ShowMessage("كلمة المرور غير متطابقة"); ShowUIMessage.Instance.ShowMessage("كلمة المرور غير متطابقة");
return; return;
} }
var sex = registerRoot.Q<DropdownField>("Sex").value; var sexDropdownField = registerRoot.Q<DropdownField>("Sex");
if (ShowErrorIfEmpty(sex, "النوع")) var sex = sexDropdownField.value;
if (ShowErrorIfTrue(() => sexDropdownField.index == 0, "يرجي أدخال النوع"))
{ {
registerButton.SetEnabled(true); registerButton.SetEnabled(true);
registerButton.text = "تسجيل"; registerButton.text = "تسجيل";
return; return;
} }
var curriculum = registerRoot.Q<DropdownField>("Curriculum").value; var currDropdownField = registerRoot.Q<DropdownField>("Curriculum");
if (ShowErrorIfEmpty(curriculum, "المنهج")) var curriculum = currDropdownField.value;
if (ShowErrorIfTrue(() => currDropdownField.index == 0, "يرجي أدخال المنهج"))
{ {
registerButton.SetEnabled(true); registerButton.SetEnabled(true);
registerButton.text = "تسجيل"; registerButton.text = "تسجيل";
return; return;
} }
var term = registerRoot.Q<DropdownField>("Term").value; var termDropdownField = registerRoot.Q<DropdownField>("Term");
if (ShowErrorIfEmpty(term, "المرحلة")) var term = termDropdownField.value;
if (ShowErrorIfTrue(() => termDropdownField.index == 0, "يرجي أدخال المرحلة"))
{ {
registerButton.SetEnabled(true); registerButton.SetEnabled(true);
registerButton.text = "تسجيل"; registerButton.text = "تسجيل";
return; return;
} }
var grade = registerRoot.Q<DropdownField>("Grade").value; var gradeDropdownField = registerRoot.Q<DropdownField>("Grade");
if (ShowErrorIfEmpty(grade, "الصف")) var grade = gradeDropdownField.value;
if (ShowErrorIfTrue(() => gradeDropdownField.index == 0, "يرجي أدخال الصف"))
{ {
registerButton.SetEnabled(true); registerButton.SetEnabled(true);
registerButton.text = "تسجيل"; registerButton.text = "تسجيل";
...@@ -326,7 +330,7 @@ public class LoginPageAnimation : MonoBehaviour ...@@ -326,7 +330,7 @@ public class LoginPageAnimation : MonoBehaviour
{ {
var Username = registerRoot.Q<TextField>("Username").text; var Username = registerRoot.Q<TextField>("Username").text;
if (ShowErrorIfEmpty(Username, "اسم المستخدم")) if (ShowErrorIfTrue(() => string.IsNullOrEmpty(Username), "يرجي أدخال اسم المستخدم"))
{ {
registerButton.SetEnabled(true); registerButton.SetEnabled(true);
registerButton.text = "تسجيل"; registerButton.text = "تسجيل";
...@@ -334,7 +338,7 @@ public class LoginPageAnimation : MonoBehaviour ...@@ -334,7 +338,7 @@ public class LoginPageAnimation : MonoBehaviour
} }
var sex = registerRoot.Q<DropdownField>("Sex").value; var sex = registerRoot.Q<DropdownField>("Sex").value;
if (ShowErrorIfEmpty(sex, "النوع")) if (ShowErrorIfTrue(() => string.IsNullOrEmpty(sex), "يرجي أدخال النوع"))
{ {
registerButton.SetEnabled(true); registerButton.SetEnabled(true);
registerButton.text = "تسجيل"; registerButton.text = "تسجيل";
...@@ -342,7 +346,7 @@ public class LoginPageAnimation : MonoBehaviour ...@@ -342,7 +346,7 @@ public class LoginPageAnimation : MonoBehaviour
} }
var curriculum = registerRoot.Q<DropdownField>("Curriculum").value; var curriculum = registerRoot.Q<DropdownField>("Curriculum").value;
if (ShowErrorIfEmpty(curriculum, "المنهج")) if (ShowErrorIfTrue(() => string.IsNullOrEmpty(curriculum), "يرجي أدخال المنهج"))
{ {
registerButton.SetEnabled(true); registerButton.SetEnabled(true);
registerButton.text = "تسجيل"; registerButton.text = "تسجيل";
...@@ -350,7 +354,7 @@ public class LoginPageAnimation : MonoBehaviour ...@@ -350,7 +354,7 @@ public class LoginPageAnimation : MonoBehaviour
} }
var term = registerRoot.Q<DropdownField>("Term").value; var term = registerRoot.Q<DropdownField>("Term").value;
if (ShowErrorIfEmpty(term, "المرحلة")) if (ShowErrorIfTrue(() => string.IsNullOrEmpty(term), "يرجي أدخال المرحلة"))
{ {
registerButton.SetEnabled(true); registerButton.SetEnabled(true);
registerButton.text = "تسجيل"; registerButton.text = "تسجيل";
...@@ -358,7 +362,7 @@ public class LoginPageAnimation : MonoBehaviour ...@@ -358,7 +362,7 @@ public class LoginPageAnimation : MonoBehaviour
} }
var grade = registerRoot.Q<DropdownField>("Grade").value; var grade = registerRoot.Q<DropdownField>("Grade").value;
if (ShowErrorIfEmpty(grade, "الصف")) if (ShowErrorIfTrue(() => string.IsNullOrEmpty(grade), "يرجي أدخال الصف"))
{ {
registerButton.SetEnabled(true); registerButton.SetEnabled(true);
registerButton.text = "تسجيل"; registerButton.text = "تسجيل";
...@@ -410,14 +414,14 @@ public class LoginPageAnimation : MonoBehaviour ...@@ -410,14 +414,14 @@ public class LoginPageAnimation : MonoBehaviour
} }
private bool ShowErrorIfEmpty(string content, string fieldName) private bool ShowErrorIfTrue(Func<bool> condition, string errorMessage)
{ {
if (string.IsNullOrEmpty(content)) if (condition())
{ {
ShowUIMessage.Instance.ShowMessage($"يرجي أدخال {fieldName}"); ShowUIMessage.Instance.ShowMessage(errorMessage);
} }
return string.IsNullOrEmpty(content); return condition();
} }
private void HandleForgetPasswordPanel() private void HandleForgetPasswordPanel()
...@@ -506,7 +510,7 @@ public class LoginPageAnimation : MonoBehaviour ...@@ -506,7 +510,7 @@ public class LoginPageAnimation : MonoBehaviour
return; return;
} }
if(newPasswordField.text.Length < 6) if (newPasswordField.text.Length < 6)
{ {
ShowUIMessage.Instance.ShowMessage("كلمة المرور يجب أن تكون 6 أحرف على الأقل"); ShowUIMessage.Instance.ShowMessage("كلمة المرور يجب أن تكون 6 أحرف على الأقل");
return; return;
......
using System; using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.UIElements; using UnityEngine.UIElements;
...@@ -238,6 +237,13 @@ public class MainmenuAnimation : MonoBehaviour ...@@ -238,6 +237,13 @@ public class MainmenuAnimation : MonoBehaviour
openChallengePanel.clicked += () => openChallengePanel.clicked += () =>
{ {
// Don't allow anonymous users to access the challenge panel
if (SupabaseManager.Instance.Supabase().Auth.CurrentUser.IsAnonymous)
{
return;
}
challengePanel.style.display = DisplayStyle.Flex; challengePanel.style.display = DisplayStyle.Flex;
challengePanel.experimental.animation.Start(0, 1, 200, (v, t) => challengePanel.experimental.animation.Start(0, 1, 200, (v, t) =>
{ {
......
...@@ -261,13 +261,13 @@ MonoBehaviour: ...@@ -261,13 +261,13 @@ MonoBehaviour:
_feedbackBg: {fileID: 6230069461127900939} _feedbackBg: {fileID: 6230069461127900939}
_timerFill: {fileID: 8270471139914111552} _timerFill: {fileID: 8270471139914111552}
_loadingText: {fileID: 1751919878724748659} _loadingText: {fileID: 1751919878724748659}
_errorText: {fileID: 4122106323195278334}
_resultTitle: {fileID: 8550221328754262388} _resultTitle: {fileID: 8550221328754262388}
_resultScore: {fileID: 6936749377702287481} _resultScore: {fileID: 6936749377702287481}
_resultStats: {fileID: 7171110102599213074} _resultStats: {fileID: 7171110102599213074}
_countDownText: {fileID: 3204408586701157358} _countDownText: {fileID: 3204408586701157358}
_timerText: {fileID: 2314289485684795983} _timerText: {fileID: 2314289485684795983}
_timerUpdateText: {fileID: 8731479965789433114} _timerUpdateText: {fileID: 8731479965789433114}
_errorText: {fileID: 2178552260234958699}
_optionsContainer: {fileID: 5542623615299663718} _optionsContainer: {fileID: 5542623615299663718}
_restartButton: {fileID: 79392514635604134} _restartButton: {fileID: 79392514635604134}
_returnToHomeButton: {fileID: 2926549481658228636} _returnToHomeButton: {fileID: 2926549481658228636}
...@@ -1151,7 +1151,7 @@ GameObject: ...@@ -1151,7 +1151,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 8472510025336300182} - component: {fileID: 8472510025336300182}
- component: {fileID: 2626825708328038760} - component: {fileID: 2626825708328038760}
- component: {fileID: 4122106323195278334} - component: {fileID: 2178552260234958699}
m_Layer: 0 m_Layer: 0
m_Name: Txt m_Name: Txt
m_TagString: Untagged m_TagString: Untagged
...@@ -1186,7 +1186,7 @@ CanvasRenderer: ...@@ -1186,7 +1186,7 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2729787420965937121} m_GameObject: {fileID: 2729787420965937121}
m_CullTransparentMesh: 1 m_CullTransparentMesh: 1
--- !u!114 &4122106323195278334 --- !u!114 &2178552260234958699
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
...@@ -1195,9 +1195,9 @@ MonoBehaviour: ...@@ -1195,9 +1195,9 @@ MonoBehaviour:
m_GameObject: {fileID: 2729787420965937121} m_GameObject: {fileID: 2729787420965937121}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0e20cc1eab1d04e7c9515c000ca5ba22, type: 3} m_Script: {fileID: 11500000, guid: beaa34cb0e58d624bb3a264b28600785, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: Assembly-CSharp::ALArcade.ArabicTMP.ArabicTextMeshProUGUI m_EditorClassIdentifier: LightSide.UniText::LightSide.UniText
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1 m_RaycastTarget: 1
...@@ -1206,83 +1206,35 @@ MonoBehaviour: ...@@ -1206,83 +1206,35 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_text: "\uFEA7\uFEC4\uFE84" text:
m_isRightToLeft: 1 fontStack: {fileID: 0}
m_fontAsset: {fileID: 11400000, guid: 8b4edeefed0fc9f60b1084045988b4cb, type: 2} appearance: {fileID: 0}
m_sharedMaterial: {fileID: 2623560040057873289, guid: 8b4edeefed0fc9f60b1084045988b4cb, type: 2} fontSize: 36
m_fontSharedMaterials: [] baseDirection: 2
m_fontMaterial: {fileID: 0} wordWrap: 1
m_fontMaterials: [] horizontalAlignment: 1
m_fontColor32: verticalAlignment: 1
serializedVersion: 2 overEdge: 0
rgba: 4294967295 underEdge: 0
m_fontColor: {r: 1, g: 1, b: 1, a: 1} leadingDistribution: 0
m_enableVertexGradient: 0 autoSize: 0
m_colorMode: 3 minFontSize: 10
m_fontColorGradient: maxFontSize: 72
topLeft: {r: 1, g: 1, b: 1, a: 1} modRegisters:
topRight: {r: 1, g: 1, b: 1, a: 1} items: []
bottomLeft: {r: 1, g: 1, b: 1, a: 1} modRegisterConfigs:
bottomRight: {r: 1, g: 1, b: 1, a: 1} items: []
m_fontColorGradientPreset: {fileID: 0} highlighter:
m_spriteAsset: {fileID: 0} rid: 5227943948359565493
m_tintAllSprites: 0 references:
m_StyleSheet: {fileID: 0} version: 2
m_TextStyleHashCode: -1183493901 RefIds:
m_overrideHtmlColors: 0 - rid: 5227943948359565493
m_faceColor: type: {class: DefaultTextHighlighter, ns: LightSide, asm: LightSide.UniText}
serializedVersion: 2 data:
rgba: 4294967295 clickColor: {r: 0.2, g: 0.5, b: 1, a: 0.6}
m_fontSize: 24 fadeDuration: 0.25
m_fontSizeBase: 24 hoverColor: {r: 0.2, g: 0.5, b: 1, a: 0.1}
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_characterHorizontalScale: 1
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
m_ArabicText: "\u062E\u0637\u0623"
m_ShowTashkeel: 1
m_PreserveNumbers: 1
m_FixTags: 1
m_ForceRTL: 1
--- !u!1 &2745728593025828598 --- !u!1 &2745728593025828598
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -588,7 +588,7 @@ MonoBehaviour: ...@@ -588,7 +588,7 @@ MonoBehaviour:
overEdge: 0 overEdge: 0
underEdge: 0 underEdge: 0
leadingDistribution: 0 leadingDistribution: 0
autoSize: 0 autoSize: 1
minFontSize: 10 minFontSize: 10
maxFontSize: 72 maxFontSize: 72
modRegisters: modRegisters:
...@@ -1020,10 +1020,10 @@ RectTransform: ...@@ -1020,10 +1020,10 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 5665338920870028329} m_Father: {fileID: 5665338920870028329}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 22.572838, y: 0} m_AnchoredPosition: {x: 22.572838, y: -25.96685}
m_SizeDelta: {x: 51.9337, y: 0} m_SizeDelta: {x: 0, y: 51.9337}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1367268893384981932 --- !u!222 &1367268893384981932
CanvasRenderer: CanvasRenderer:
...@@ -1971,7 +1971,7 @@ MonoBehaviour: ...@@ -1971,7 +1971,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.GraphicRaycaster m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.GraphicRaycaster
m_IgnoreReversedGraphics: 1 m_IgnoreReversedGraphics: 0
m_BlockingObjects: 0 m_BlockingObjects: 0
m_BlockingMask: m_BlockingMask:
serializedVersion: 2 serializedVersion: 2
...@@ -2321,7 +2321,7 @@ GameObject: ...@@ -2321,7 +2321,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!224 &2126029859342928170 --- !u!224 &2126029859342928170
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -2331,8 +2331,8 @@ RectTransform: ...@@ -2331,8 +2331,8 @@ RectTransform:
m_GameObject: {fileID: 4807635275847702964} m_GameObject: {fileID: 4807635275847702964}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.5625, y: 0.5625, z: 0.5625} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 1
m_Children: m_Children:
- {fileID: 37626301424459968} - {fileID: 37626301424459968}
m_Father: {fileID: 6025958000610179652} m_Father: {fileID: 6025958000610179652}
...@@ -2340,7 +2340,7 @@ RectTransform: ...@@ -2340,7 +2340,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 840, y: 1493.3333} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1697728672160704455 --- !u!222 &1697728672160704455
CanvasRenderer: CanvasRenderer:
...@@ -3351,10 +3351,10 @@ RectTransform: ...@@ -3351,10 +3351,10 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 5665338920870028329} m_Father: {fileID: 5665338920870028329}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 83.71851, y: 0} m_AnchoredPosition: {x: 83.71851, y: -25.96685}
m_SizeDelta: {x: 51.9337, y: 0} m_SizeDelta: {x: 0, y: 51.9337}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6044436298841298018 --- !u!222 &6044436298841298018
CanvasRenderer: CanvasRenderer:
...@@ -3441,10 +3441,10 @@ RectTransform: ...@@ -3441,10 +3441,10 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 5665338920870028329} m_Father: {fileID: 5665338920870028329}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 267.15555, y: 0} m_AnchoredPosition: {x: 267.15555, y: -25.96685}
m_SizeDelta: {x: 51.9337, y: 0} m_SizeDelta: {x: 0, y: 51.9337}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7681831561278972478 --- !u!222 &7681831561278972478
CanvasRenderer: CanvasRenderer:
...@@ -3903,10 +3903,10 @@ RectTransform: ...@@ -3903,10 +3903,10 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 5665338920870028329} m_Father: {fileID: 5665338920870028329}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 206.00986, y: 0} m_AnchoredPosition: {x: 206.00986, y: -25.96685}
m_SizeDelta: {x: 51.9337, y: 0} m_SizeDelta: {x: 0, y: 51.9337}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8749602556167845090 --- !u!222 &8749602556167845090
CanvasRenderer: CanvasRenderer:
...@@ -4068,10 +4068,10 @@ RectTransform: ...@@ -4068,10 +4068,10 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 5665338920870028329} m_Father: {fileID: 5665338920870028329}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 144.8642, y: 0} m_AnchoredPosition: {x: 144.8642, y: -25.96685}
m_SizeDelta: {x: 51.9337, y: 0} m_SizeDelta: {x: 0, y: 51.9337}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8187631058268110602 --- !u!222 &8187631058268110602
CanvasRenderer: CanvasRenderer:
......
...@@ -2386,11 +2386,11 @@ MonoBehaviour: ...@@ -2386,11 +2386,11 @@ MonoBehaviour:
_streakText: {fileID: 3088443959907424236} _streakText: {fileID: 3088443959907424236}
_scoreLbl: {fileID: 5924483057703210132} _scoreLbl: {fileID: 5924483057703210132}
_loadingText: {fileID: 7759164263249432265} _loadingText: {fileID: 7759164263249432265}
_errorText: {fileID: 2594165393456477704}
_progressLabel: {fileID: 7501656307173425929} _progressLabel: {fileID: 7501656307173425929}
_resultTitle: {fileID: 3377821766872872317} _resultTitle: {fileID: 3377821766872872317}
_resultScore: {fileID: 2058651398905202117} _resultScore: {fileID: 2058651398905202117}
_resultStats: {fileID: 2189195751882486028} _resultStats: {fileID: 2189195751882486028}
_errorText: {fileID: 1805088816235923994}
_feedbackText: {fileID: 2715045871399486055} _feedbackText: {fileID: 2715045871399486055}
_feedbackBg: {fileID: 609508365388699558} _feedbackBg: {fileID: 609508365388699558}
_restartButton: {fileID: 2142933248170327394} _restartButton: {fileID: 2142933248170327394}
...@@ -3535,7 +3535,7 @@ GameObject: ...@@ -3535,7 +3535,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 2090849387953898811} - component: {fileID: 2090849387953898811}
- component: {fileID: 3573761653700519801} - component: {fileID: 3573761653700519801}
- component: {fileID: 2594165393456477704} - component: {fileID: 1805088816235923994}
m_Layer: 0 m_Layer: 0
m_Name: Txt m_Name: Txt
m_TagString: Untagged m_TagString: Untagged
...@@ -3560,7 +3560,7 @@ RectTransform: ...@@ -3560,7 +3560,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 600, y: 100} m_SizeDelta: {x: 600, y: 225.9419}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3573761653700519801 --- !u!222 &3573761653700519801
CanvasRenderer: CanvasRenderer:
...@@ -3570,7 +3570,7 @@ CanvasRenderer: ...@@ -3570,7 +3570,7 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8205817321969538790} m_GameObject: {fileID: 8205817321969538790}
m_CullTransparentMesh: 1 m_CullTransparentMesh: 1
--- !u!114 &2594165393456477704 --- !u!114 &1805088816235923994
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
...@@ -3579,9 +3579,9 @@ MonoBehaviour: ...@@ -3579,9 +3579,9 @@ MonoBehaviour:
m_GameObject: {fileID: 8205817321969538790} m_GameObject: {fileID: 8205817321969538790}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0e20cc1eab1d04e7c9515c000ca5ba22, type: 3} m_Script: {fileID: 11500000, guid: beaa34cb0e58d624bb3a264b28600785, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: Assembly-CSharp::ALArcade.ArabicTMP.ArabicTextMeshProUGUI m_EditorClassIdentifier: LightSide.UniText::LightSide.UniText
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1 m_RaycastTarget: 1
...@@ -3590,83 +3590,35 @@ MonoBehaviour: ...@@ -3590,83 +3590,35 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_text: "\uFEA7\uFEC4\uFE84" text:
m_isRightToLeft: 1 fontStack: {fileID: 0}
m_fontAsset: {fileID: 11400000, guid: 8b4edeefed0fc9f60b1084045988b4cb, type: 2} appearance: {fileID: 0}
m_sharedMaterial: {fileID: 2623560040057873289, guid: 8b4edeefed0fc9f60b1084045988b4cb, type: 2} fontSize: 36
m_fontSharedMaterials: [] baseDirection: 2
m_fontMaterial: {fileID: 0} wordWrap: 1
m_fontMaterials: [] horizontalAlignment: 1
m_fontColor32: verticalAlignment: 1
serializedVersion: 2 overEdge: 0
rgba: 4294967295 underEdge: 0
m_fontColor: {r: 1, g: 1, b: 1, a: 1} leadingDistribution: 0
m_enableVertexGradient: 0 autoSize: 0
m_colorMode: 3 minFontSize: 10
m_fontColorGradient: maxFontSize: 72
topLeft: {r: 1, g: 1, b: 1, a: 1} modRegisters:
topRight: {r: 1, g: 1, b: 1, a: 1} items: []
bottomLeft: {r: 1, g: 1, b: 1, a: 1} modRegisterConfigs:
bottomRight: {r: 1, g: 1, b: 1, a: 1} items: []
m_fontColorGradientPreset: {fileID: 0} highlighter:
m_spriteAsset: {fileID: 0} rid: 5227943948359565962
m_tintAllSprites: 0 references:
m_StyleSheet: {fileID: 0} version: 2
m_TextStyleHashCode: -1183493901 RefIds:
m_overrideHtmlColors: 0 - rid: 5227943948359565962
m_faceColor: type: {class: DefaultTextHighlighter, ns: LightSide, asm: LightSide.UniText}
serializedVersion: 2 data:
rgba: 4294967295 clickColor: {r: 0.2, g: 0.5, b: 1, a: 0.6}
m_fontSize: 24 fadeDuration: 0.25
m_fontSizeBase: 24 hoverColor: {r: 0.2, g: 0.5, b: 1, a: 0.1}
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_characterHorizontalScale: 1
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
m_ArabicText: "\u062E\u0637\u0623"
m_ShowTashkeel: 1
m_PreserveNumbers: 1
m_FixTags: 1
m_ForceRTL: 1
--- !u!1 &9048445354178813042 --- !u!1 &9048445354178813042
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -24,8 +24,8 @@ namespace com.al_arcade.cs ...@@ -24,8 +24,8 @@ namespace com.al_arcade.cs
[SerializeField] protected UniText _feedbackText; [SerializeField] protected UniText _feedbackText;
[SerializeField] protected Image _feedbackBg, _timerFill; [SerializeField] protected Image _feedbackBg, _timerFill;
[SerializeField] protected ArabicTextMeshProUGUI _loadingText, _errorText; [SerializeField] protected ArabicTextMeshProUGUI _loadingText;
[SerializeField] protected UniText _resultTitle, _resultScore, _resultStats, _countDownText, _timerText, _timerUpdateText; [SerializeField] protected UniText _resultTitle, _resultScore, _resultStats, _countDownText, _timerText, _timerUpdateText, _errorText;
[SerializeField] protected Transform _optionsContainer; [SerializeField] protected Transform _optionsContainer;
[SerializeField] protected Button _restartButton; [SerializeField] protected Button _restartButton;
...@@ -445,7 +445,7 @@ namespace com.al_arcade.cs ...@@ -445,7 +445,7 @@ namespace com.al_arcade.cs
{ _loadingUI.DOFade(0f, 0.3f).OnComplete(() => _loadingUI.gameObject.SetActive(false)); } { _loadingUI.DOFade(0f, 0.3f).OnComplete(() => _loadingUI.gameObject.SetActive(false)); }
public void ShowError(string msg) public void ShowError(string msg)
{ _errorUI.gameObject.SetActive(true); if (_errorText != null) _errorText.arabicText = msg; _errorUI.DOFade(1f, 0.3f); } { _errorUI.gameObject.SetActive(true); if (_errorText != null) _errorText.Text = msg; _errorUI.DOFade(1f, 0.3f); }
public IEnumerator ShowCountDown() public IEnumerator ShowCountDown()
{ {
......
...@@ -151,7 +151,7 @@ namespace com.al_arcade.shared ...@@ -151,7 +151,7 @@ namespace com.al_arcade.shared
if (!HasValidQuestions() || error != null) if (!HasValidQuestions() || error != null)
{ {
OnShowError(error ?? "لا توجد أسئلة"); OnShowError("فشل تحميل الأسئلة. الرجاء المحاولة مرة أخرى.");
yield break; yield break;
} }
...@@ -220,7 +220,7 @@ namespace com.al_arcade.shared ...@@ -220,7 +220,7 @@ namespace com.al_arcade.shared
protected void ResetBaseState() protected void ResetBaseState()
{ {
StopAllCoroutines(); StopAllCoroutines();
_score = _streak = _correctCount = _wrongCount = _currentIndex = _totalAsked =_bestStreak= 0; _score = _streak = _correctCount = _wrongCount = _currentIndex = _totalAsked = _bestStreak = 0;
_timeLeft = 0f; _timeLeft = 0f;
_timerRunning = false; _timerRunning = false;
} }
......
...@@ -306,7 +306,7 @@ namespace com.al_arcade.tf ...@@ -306,7 +306,7 @@ namespace com.al_arcade.tf
protected override IEnumerator NoChallengeLoseSequence() protected override IEnumerator NoChallengeLoseSequence()
{ {
yield return new WaitForSeconds(1f); yield return new WaitForSeconds(1f);
uiManager?.ShowResults(_score, _correctCount, _wrongCount,_questions.Length, _bestStreak, false); uiManager?.ShowResults(_score, _correctCount, _wrongCount, _questions.Length, _bestStreak, false);
onGameOver?.Invoke(); onGameOver?.Invoke();
} }
...@@ -328,7 +328,7 @@ namespace com.al_arcade.tf ...@@ -328,7 +328,7 @@ namespace com.al_arcade.tf
protected override IEnumerator NoChallengeVictorySequence() protected override IEnumerator NoChallengeVictorySequence()
{ {
yield return new WaitForSeconds(1.5f); yield return new WaitForSeconds(1.5f);
uiManager?.ShowResults(_score, _correctCount, _wrongCount,_questions.Length ,_bestStreak); uiManager?.ShowResults(_score, _correctCount, _wrongCount, _questions.Length, _bestStreak);
onGameComplete?.Invoke(); onGameComplete?.Invoke();
} }
......
...@@ -16,9 +16,9 @@ namespace com.al_arcade.tf ...@@ -16,9 +16,9 @@ namespace com.al_arcade.tf
[SerializeField] private Canvas _canvas; [SerializeField] private Canvas _canvas;
[SerializeField] private CanvasGroup _gameUI, _loadingUI, _errorUI, _resultsUI, _feedbackGroup; [SerializeField] private CanvasGroup _gameUI, _loadingUI, _errorUI, _resultsUI, _feedbackGroup;
[SerializeField] private UniText _scoreText, _streakText, _scoreLbl; [SerializeField] private UniText _scoreText, _streakText, _scoreLbl;
[SerializeField] private ArabicTextMeshProUGUI _loadingText, _errorText; [SerializeField] private ArabicTextMeshProUGUI _loadingText;
[SerializeField] private UniText _progressLabel; [SerializeField] private UniText _progressLabel;
[SerializeField] private UniText _resultTitle, _resultScore, _resultStats; [SerializeField] private UniText _resultTitle, _resultScore, _resultStats, _errorText;
[SerializeField] private UniText _feedbackText; [SerializeField] private UniText _feedbackText;
[SerializeField] private Image _feedbackBg; [SerializeField] private Image _feedbackBg;
[SerializeField] private Button _restartButton; [SerializeField] private Button _restartButton;
...@@ -223,7 +223,7 @@ namespace com.al_arcade.tf ...@@ -223,7 +223,7 @@ namespace com.al_arcade.tf
public void ShowError(string m) public void ShowError(string m)
{ {
_errorUI.gameObject.SetActive(true); _errorUI.gameObject.SetActive(true);
if (_errorText != null) _errorText.arabicText = m; if (_errorText != null) _errorText.Text = m;
_errorUI.DOFade(1, 0.3f); _errorUI.DOFade(1, 0.3f);
} }
...@@ -350,11 +350,11 @@ namespace com.al_arcade.tf ...@@ -350,11 +350,11 @@ namespace com.al_arcade.tf
go.AddComponent<Image>().color = go.AddComponent<Image>().color =
SSColorPalette.WithAlpha(SSColorPalette.Danger, 0.9f); SSColorPalette.WithAlpha(SSColorPalette.Danger, 0.9f);
_errorText = MkTxt(go.transform, "Txt", "خطأ", 24, // _errorText = MkTxt(go.transform, "Txt", "خطأ", 24,
new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(600, 90)); // new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(600, 90));
_errorText.alignment = TMPro.TextAlignmentOptions.Center; // _errorText.alignment = TMPro.TextAlignmentOptions.Center;
_errorText.color = Color.white; // _errorText.color = Color.white;
_errorText.enableWordWrapping = true; // _errorText.enableWordWrapping = true;
} }
private void BuildResultsPanel(Transform parent) private void BuildResultsPanel(Transform parent)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment