// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2021-07-16
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
//
//
// ***********************************************************************
//#define GM_TEST_SERVER
using F;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
namespace G
{
///
/// GM界面
///
public class KGMWindow : KUIWidget
{
#if UNITY_EDITOR
static System.Tuple> _CopyInfo;
class ArchiveWidget : KUIWidget
{
[KUIFlag]
Text _txtName;
[KUIFlag]
Text _txtContent;
[KUIFlag]
Button _btnLoad;
[KUIFlag]
Button _btnCopy;
public override void Refresh()
{
if (this.data is System.Tuple> info)
{
var archive = info.Item2;
_txtName.text = archive.GetString("name");
_txtContent.text = archive.GetString("data");
}
}
private void OnLoadBtnClick()
{
if (this.data is System.Tuple> info)
{
var archiveInfo = info.Item1;
var archive = info.Item2;
ArchiveProxy.Instance.LoadServerText(archiveInfo, archive.GetString("data"));
}
}
void OnCopyBtnClick()
{
if (this.data is System.Tuple> info)
{
_CopyInfo = info;
}
}
private void Awake()
{
SetViewData();
_btnLoad.onClick.AddListener(this.OnLoadBtnClick);
_btnCopy.onClick.AddListener(this.OnCopyBtnClick);
}
}
class RankingWidget : KUIWidget
{
[KUIFlag]
Text _txtName;
[KUIFlag]
Text _txtScore;
[KUIFlag]
Button _btnQuery;
private string _uid;
public override void Refresh()
{
if (this.data is IDictionary info)
{
_uid = info.GetString("uid");
_txtScore.text = info.GetString("score");
var rankingInfo = new RankingProxy.RankingInfo
{
userKey = info.GetString("user_key")
};
_txtName.text = rankingInfo.name;
}
else
_uid = null;
}
void OnQueryBtnClick()
{
if (!string.IsNullOrEmpty(_uid))
{
_Instance.SetAccount(_uid, true);
}
}
private void Awake()
{
SetViewData();
_btnQuery.onClick.AddListener(this.OnQueryBtnClick);
}
}
#region Field
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
[KUIFlag]
GameObject _goLogin;
[KUIFlag]
Button _btnGMLogin;
[KUIFlag]
InputField _inGMToken;
[KUIFlag]
Toggle _tgServer;
[KUIFlag]
GameObject _goManger;
[KUIFlag]
KUIToggleGroup _goPages;
#region Account
[KUIFlag]
GameObject _goAccount;
[KUIFlag]
InputField _inPlayer;
[KUIFlag]
Button _btnQuery;
[KUIFlag]
KUIList __listArchives;
[KUIFlag]
Text _txtStatus;
[KUIFlag]
Text _txtToken;
[KUIFlag]
Button _btnUpload;
[KUIFlag]
Button _btnUploadCopy;
[KUIFlag]
Button _btnClear;
[KUIFlag]
Button _btnBlock;
[KUIFlag]
Button _btnUnblock;
[KUIFlag]
Toggle _tgUID;
[KUIFlag]
Text _txtUserInfo;
[KUIFlag]
Button _btnGod;
[KUIFlag]
Button _btnUngod;
#endregion
#region Mail
[KUIFlag]
GameObject _goMail;
[KUIFlag]
InputField _inMailTitle;
[KUIFlag]
InputField _inMailContent;
[KUIFlag]
InputField _inMailRewards;
[KUIFlag]
InputField _inMailId;
[KUIFlag]
Button _btnMailSend;
#endregion
#region Ranking
[KUIFlag]
GameObject _goRanking;
[KUIFlag]
KUIList __listRanking;
[KUIFlag]
Button _btnPullRanking;
[KUIFlag]
Button _btnDelRanking;
[KUIFlag]
Dropdown _ddRankingId;
#endregion
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
private string _userInfo;
private bool _loginSuccess => !string.IsNullOrEmpty(gmToken);
private object _rankingData;
#endregion
#region Method
public override void Refresh()
{
_goLogin.SetActive(!_loginSuccess);
_goManger.SetActive(_loginSuccess);
}
void ShowLogin()
{
_inGMToken.text = gmToken;
_goLogin.SetActive(true);
_goManger.SetActive(false);
}
void SetAccount(string account, bool isUID)
{
_goPages.toggles[0].isOn = true;
_inPlayer.text = account;
_tgUID.isOn = isUID;
}
int GetRankId()
{
int rank_id = 0;
switch (_ddRankingId.value)
{
case 0:
rank_id = 1;
break;
case 1:
rank_id = 2;
break;
case 2:
rank_id = 3;
break;
case 3:
rank_id = 101;
break;
case 4:
rank_id = 102;
break;
case 5:
rank_id = 103;
break;
case 6:
rank_id = 105;
break;
case 7:
rank_id = 5;
break;
case 8:
rank_id = 201;
break;
case 9:
rank_id = 202;
break;
case 10:
rank_id = 203;
break;
case 11:
rank_id = 205;
break;
}
return rank_id;
}
void OnLoginBtnClick()
{
var token = _inGMToken.text;
if (!string.IsNullOrEmpty(token))
{
this.gmToken = token;
Refresh();
}
else
{
if (_tgServer.isOn)
Application.OpenURL("https://dev-cdn-shaoxia.lanfeitech.com/gm/dev/index.html");
else
Application.OpenURL("https://dev-cdn-shaoxia.lanfeitech.com/gm/prod/index.html");
Debug.Log($"输入GMToken {(_tgServer.isOn ? "测试服" : "正式服")}");
}
}
void OnQueryBtnClick()
{
var account = _inPlayer.text;
if (!string.IsNullOrEmpty(account))
{
QueryArchive(OnQueryArchive);
QueryBanInfo(OnQueryBanInfo);
_txtStatus.text = "查询存档";
}
}
void OnQueryArchive(int error, string message, object data)
{
if (error == 0)
{
if (data is IList