|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using TMPro;
|
|
|
|
|
using ArabicSupport;
|
|
|
|
|
|
|
|
|
|
public class UserActionLogger : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public static UserActionLogger Instance;
|
|
|
|
|
|
|
|
|
|
private List<string> logs = new List<string>();
|
|
|
|
|
public TextMeshProUGUI summaryText;
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
if (Instance == null)
|
|
|
|
|
Instance = this;
|
|
|
|
|
else
|
|
|
|
|
Destroy(gameObject);
|
|
|
|
|
}
|
|
|
|
|
public void Log(string englishLog, string arabicLog = null)
|
|
|
|
|
{
|
|
|
|
|
bool isArabic = LanguageManager.Instance != null &&
|
|
|
|
|
LanguageManager.Instance.currentLanguage == "Arabic";
|
|
|
|
|
|
|
|
|
|
string logToUse = isArabic && !string.IsNullOrEmpty(arabicLog)
|
|
|
|
|
? ArabicFixer.Fix(arabicLog)
|
|
|
|
|
: englishLog;
|
|
|
|
|
|
|
|
|
|
logs.Add(logToUse);
|
|
|
|
|
Debug.Log($"📜 Action Logged: {logs.Count}. {logToUse}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//public void Log(string action)
|
|
|
|
|
//{
|
|
|
|
|
// logs.Add(action);
|
|
|
|
|
// Debug.Log($"📜 Action Logged: {logs.Count}. {action}");
|
|
|
|
|
//}
|
|
|
|
|
public void LogQuizAnswer(string answerEnglish, string answerArabic = null)
|
|
|
|
|
{
|
|
|
|
|
string englishLog = $"Answered quiz: {answerEnglish}";
|
|
|
|
|
string arabicLog = answerArabic != null ? $"أجاب على السؤال: {answerArabic}" : null;
|
|
|
|
|
|
|
|
|
|
Log(englishLog, arabicLog);
|
|
|
|
|
}
|
|
|
|
|
//public void LogQuizAnswer(string answerText)
|
|
|
|
|
//{
|
|
|
|
|
// //Log($"Answered quiz: {answerText}");
|
|
|
|
|
// string englishLog = $"Answered quiz: {answerEnglish}";
|
|
|
|
|
// string arabicLog = answerArabic != null ? $"أجاب على السؤال: {answerArabic}" : null;
|
|
|
|
|
|
|
|
|
|
// Log(englishLog, arabicLog);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
public string GetFullLog()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < logs.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine($"{i + 1}. {logs[i]}");
|
|
|
|
|
}
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ContextMenu("ShowSummary")]
|
|
|
|
|
public void ShowSummary()
|
|
|
|
|
{
|
|
|
|
|
if (summaryText == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
string logs = GetFullLog();
|
|
|
|
|
|
|
|
|
|
// Default to showing original logs
|
|
|
|
|
summaryText.text = logs;
|
|
|
|
|
|
|
|
|
|
// If Arabic language is active, fix and apply Arabic font
|
|
|
|
|
if (LanguageManager.Instance != null &&
|
|
|
|
|
LanguageManager.Instance.currentLanguage == "Arabic")
|
|
|
|
|
{
|
|
|
|
|
summaryText.text = ArabicFixer.Fix(logs);
|
|
|
|
|
summaryText.font = LanguageManager.Instance.fontArabic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
summaryText.ForceMeshUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//public void ShowSummary()
|
|
|
|
|
//{
|
|
|
|
|
// if (summaryText != null)
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
// bool isArabic = LanguageManager.Instance != null &&
|
|
|
|
|
// LanguageManager.Instance.currentLanguage == "Arabic";
|
|
|
|
|
// string logs = GetFullLog();
|
|
|
|
|
// if (isArabic)
|
|
|
|
|
// {
|
|
|
|
|
// summaryText.text = ArabicFixer.Fix(logs);
|
|
|
|
|
// summaryText.font = LanguageManager.Instance.fontArabic;
|
|
|
|
|
// summaryText.ForceMeshUpdate();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
public void ClearLog()
|
|
|
|
|
{
|
|
|
|
|
logs.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|