You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
3.2 KiB
C#
97 lines
3.2 KiB
C#
using UnityEngine;
|
|
using TMPro;
|
|
using UnityEngine.UI;
|
|
using ArabicSupport;
|
|
|
|
public class EmailOpenPanel : MonoBehaviour
|
|
{
|
|
public TextMeshProUGUI senderName;
|
|
public TextMeshProUGUI senderEmail;
|
|
public TextMeshProUGUI subject;
|
|
public TextMeshProUGUI bodyText;
|
|
public TextMeshProUGUI linkPreview;
|
|
public GameObject phishingIcon;
|
|
|
|
public TextMeshProUGUI senderInitial;
|
|
public Image senderBg;
|
|
|
|
public Button reportBtn;
|
|
public Button ignoreBtn;
|
|
|
|
private EmailData emailData;
|
|
public EmailData Email => emailData;
|
|
|
|
public void Setup(EmailData data, string initial, Sprite iconSprite)
|
|
{
|
|
emailData = data;
|
|
senderName.text = data.senderName;
|
|
// senderEmail.text = data.senderEmail;
|
|
LocalizeTMP(subject, data.subject, data.subjectAr);
|
|
LocalizeTMP(bodyText, data.fullBodyText, data.fullBodyTextAr);
|
|
//linkPreview.text=data.linkPreview;
|
|
if (phishingIcon != null)
|
|
phishingIcon.SetActive(data.isPhishing);
|
|
|
|
senderInitial?.SetText(initial);
|
|
if (senderBg != null)
|
|
senderBg.sprite = iconSprite;
|
|
|
|
reportBtn?.onClick.RemoveAllListeners();
|
|
reportBtn?.onClick.AddListener(() => OnAction("report"));
|
|
|
|
ignoreBtn?.onClick.RemoveAllListeners();
|
|
ignoreBtn?.onClick.AddListener(() => OnAction("ignore"));
|
|
}
|
|
|
|
void OnAction(string action)
|
|
{
|
|
gameObject.SetActive(false);
|
|
|
|
string summary = $"{action.ToUpper()} clicked on email from '{emailData.senderName}' with subject '{emailData.subject}'";
|
|
UserActionLogger.Instance?.Log(summary);
|
|
|
|
bool isCorrect =
|
|
(action == "report" && emailData.isPhishing) ||
|
|
(action == "ignore" && !emailData.isPhishing);
|
|
|
|
if (isCorrect)
|
|
{
|
|
// ✅ Correct choice → Show instruction
|
|
InstructionManager.Instance?.ShowScreenInstruction("correct_choice", 3f);
|
|
}
|
|
|
|
switch (action)
|
|
{
|
|
case "report":
|
|
SceneOutcomeManager.Instance.Reported(emailData);
|
|
break;
|
|
case "ignore":
|
|
SceneOutcomeManager.Instance.Ignored(emailData);
|
|
break;
|
|
}
|
|
}
|
|
|
|
//void LocalizeTMP(TextMeshProUGUI tmp, string english, string arabic)
|
|
//{
|
|
// if (tmp == null) return;
|
|
|
|
// bool isArabic = LanguageManager.Instance != null && LanguageManager.Instance.currentLanguage == "Arabic";
|
|
// tmp.text = isArabic ? ArabicFixer.Fix(arabic) : english;
|
|
// tmp.font = LanguageManager.Instance?.GetCurrentFont();
|
|
// //tmp.isRightToLeftText = isArabic;
|
|
// //tmp.alignment = isArabic ? TextAlignmentOptions.Right : TextAlignmentOptions.Left;
|
|
//}
|
|
void LocalizeTMP(TextMeshProUGUI tmp, string english, string arabic)
|
|
{
|
|
if (tmp == null) return;
|
|
|
|
bool isArabic = LanguageManager.Instance.currentLanguage == "Arabic";
|
|
|
|
tmp.text = isArabic ? ArabicFixerHelper.FixPreservingTags(arabic) : english;
|
|
tmp.font = LanguageManager.Instance.GetCurrentFont();
|
|
// tmp.isRightToLeftText = isArabic;
|
|
//tmp.alignment = isArabic ? TextAlignmentOptions.Right : TextAlignmentOptions.Left;
|
|
}
|
|
|
|
}
|