- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg) - LoginPanel: InputField placeholder本地化、字体颜色保持 - HistoryPanel: 用时数据本地化、placeholder本地化 - RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建) - AppraiseWindowBase: 评价等级本地化、操作消息重建 - EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized - StudentOperateRecorder: 新增InjectOperateMsgLocalized方法 - LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选 - 字体切换时保留颜色和verticalOverflow
193 lines
6.0 KiB
C#
193 lines
6.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
//用户操作窗口
|
|
public class OperateUserWindowCtrl : MonoBasePanel
|
|
{
|
|
InputField userInput;
|
|
InputField passwordInput;
|
|
InputField repeatPasswordInput;
|
|
|
|
//取消按钮
|
|
Button cancelButton;
|
|
|
|
//添加按钮
|
|
Button addButton;
|
|
|
|
//修改按钮
|
|
Button changeButton;
|
|
|
|
Text titleText;//窗口标题
|
|
Text promptText;//下方提示文字
|
|
|
|
//选择编辑模式时记录当前选择用户名
|
|
string cUser;
|
|
|
|
MessagePrefabCtrl prefabCtrl1;//待修改的对象
|
|
UserType userType;
|
|
// Start is called before the first frame update
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
}
|
|
|
|
protected override void InitComponent()
|
|
{
|
|
userInput = this.transform.Find("Image_bg/InputField_user").GetComponent<InputField>();
|
|
passwordInput = this.transform.Find("Image_bg/InputField_pass").GetComponent<InputField>();
|
|
repeatPasswordInput = this.transform.Find("Image_bg/InputField_repeatPass").GetComponent<InputField>();
|
|
changeButton = this.transform.Find("Image_bg/Button_change").GetComponent<Button>();
|
|
cancelButton = this.transform.Find("Image_bg/Button_cancle").GetComponent<Button>();
|
|
addButton = this.transform.Find("Image_bg/Button_add").GetComponent<Button>();
|
|
|
|
this.transform.Find("Image_bg/Button_Close").GetComponent<Button>().onClick.AddListener(CloseButtonOn);
|
|
titleText = this.transform.Find("Image_bg/Text_panelTitle").GetComponent<Text>();
|
|
promptText = this.transform.Find("Image_bg/Text_prompt").GetComponent<Text>();
|
|
addButton.onClick.AddListener(AddButtonOn);
|
|
changeButton.onClick.AddListener(ChangeBttonOn);
|
|
cancelButton.onClick.AddListener(CancleButtonOn);
|
|
CloseButtonOn();
|
|
}
|
|
|
|
|
|
//添加新学员显示面板
|
|
public void StartAddStudent(UserType userType)
|
|
{
|
|
this.gameObject.SetActive(true);
|
|
InitPanel();
|
|
this.userType = userType;
|
|
switch (userType)
|
|
{
|
|
case UserType.student:
|
|
titleText.text = LocalizationManager.Get("新增学员");
|
|
break;
|
|
case UserType.Teacher:
|
|
titleText.text = LocalizationManager.Get("新增教员");
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
SetInputValue("", "");
|
|
userInput.interactable = true;
|
|
addButton.gameObject.SetActive(true);
|
|
promptText.text = "";
|
|
}
|
|
|
|
//修改现有学员信息显示面板
|
|
public void StartChangeStudent(User userMsg,MessagePrefabCtrl prefabCtrl)
|
|
{
|
|
this.gameObject.SetActive(true);
|
|
InitPanel();
|
|
userInput.interactable = false;
|
|
switch (userMsg.userType)
|
|
{
|
|
case UserType.student:
|
|
titleText.text = LocalizationManager.Get("修改学员用户");
|
|
break;
|
|
case UserType.Teacher:
|
|
titleText.text = LocalizationManager.Get("修改教员用户");
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
cUser = userMsg.user;
|
|
this.userType = userMsg.userType;
|
|
SetInputValue(cUser, "");
|
|
promptText.text = "";
|
|
changeButton.gameObject.SetActive(true);
|
|
cancelButton.gameObject.SetActive(true);
|
|
prefabCtrl1 = prefabCtrl;
|
|
}
|
|
|
|
void SetInputValue(string stname,string className)
|
|
{
|
|
userInput.text = stname;
|
|
passwordInput.text = className;
|
|
repeatPasswordInput.text = className;
|
|
}
|
|
|
|
void CloseButtonOn()
|
|
{
|
|
this.gameObject.SetActive(false);
|
|
addButton.gameObject.SetActive(false);
|
|
changeButton.gameObject.SetActive(false);
|
|
}
|
|
|
|
void AddButtonOn()
|
|
{
|
|
if (string.IsNullOrEmpty(userInput.text.Trim()) || string.IsNullOrEmpty(passwordInput.text.Trim()))
|
|
{
|
|
promptText.color = Color.red;
|
|
promptText.text = LocalizationManager.Get("用户名/密码不能为空!");
|
|
return;
|
|
}
|
|
|
|
if (passwordInput.text.Trim() != repeatPasswordInput.text.Trim())
|
|
{
|
|
promptText.color = Color.red;
|
|
promptText.text = LocalizationManager.Get("两次输入密码不一致!");
|
|
return;
|
|
}
|
|
User newUser = GetUser();
|
|
bool result = DBManager.Instance. InsterUser(newUser);
|
|
if (result)
|
|
{
|
|
promptText.text = LocalizationManager.Get("添加成功!");
|
|
promptText.color = Color.green;
|
|
EventCenter.Instance.EventTrigger<User>("AddUser", newUser);
|
|
}
|
|
else
|
|
{
|
|
promptText.color = Color.red;
|
|
promptText.text = LocalizationManager.Get("添加失败,该用户已存在!");
|
|
}
|
|
}
|
|
|
|
private User GetUser()
|
|
{
|
|
User newUser = new User();
|
|
newUser.user = userInput.text.Trim();
|
|
newUser.password = passwordInput.text.Trim();
|
|
newUser.userType = this.userType;
|
|
return newUser;
|
|
}
|
|
|
|
//修改信息
|
|
void ChangeBttonOn()
|
|
{
|
|
if (passwordInput.text.Trim() != repeatPasswordInput.text.Trim())
|
|
{
|
|
promptText.color = Color.red;
|
|
promptText.text = LocalizationManager.Get("两次输入密码不一致!");
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(repeatPasswordInput.text.Trim()) || string.IsNullOrEmpty(passwordInput.text.Trim()))
|
|
{
|
|
promptText.color = Color.red;
|
|
promptText.text = LocalizationManager.Get("新密码不能为空!");
|
|
return;
|
|
}
|
|
promptText.text = LocalizationManager.Get("密码修改成功!");
|
|
promptText.color = Color.green;
|
|
User newUser = GetUser();
|
|
DBManager.Instance.UpdateUser(newUser);
|
|
EventCenter.Instance.EventTrigger<User>("ChangeUser", newUser);
|
|
prefabCtrl1.SetMessage(newUser);
|
|
}
|
|
|
|
//取消修改时,关闭窗口
|
|
void CancleButtonOn()
|
|
{
|
|
CloseButtonOn();
|
|
}
|
|
|
|
}
|
|
|
|
public enum StSex
|
|
{
|
|
男,
|
|
女,
|
|
}
|