summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/RequestDlg.cs
blob: 9f507bb365d99f5fd12ab8ea6b360e3b3cab7d8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class RequestDlg : DlgBase<RequestDlg, RequestBehaviour>
	{
		public override bool autoload
		{
			get
			{
				return true;
			}
		}

		public override string fileName
		{
			get
			{
				return "Guild/GuildCollect/RequestDlg";
			}
		}

		private XRequestDocument _doc;

		protected override void Init()
		{
			base.Init();
			this._doc = XDocuments.GetSpecificDocument<XRequestDocument>(XRequestDocument.uuID);
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			base.uiBehaviour.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseBtnClick));
			base.uiBehaviour.m_WrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.DesWrapListUpdated));
			base.uiBehaviour.m_ClearBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClearBtnClick));
		}

		protected override void OnShow()
		{
			base.OnShow();
			this._doc.QueryRequestList();
		}

		protected override void OnHide()
		{
			base.OnHide();
		}

		protected override void OnUnload()
		{
			base.OnUnload();
		}

		public void Refresh(bool resetScrollPos = true)
		{
			base.uiBehaviour.m_WrapContent.SetContentCount(this._doc.List.Count, false);
			if (resetScrollPos)
			{
				base.uiBehaviour.m_ScrollView.ResetPosition();
			}
		}

		private void DesWrapListUpdated(Transform t, int index)
		{
			PartyExchangeItemInfo partyExchangeItemInfo = this._doc.List[index];
			IXUISprite ixuisprite = t.Find("Head").GetComponent("XUISprite") as IXUISprite;
			IXUILabel ixuilabel = t.Find("Name").GetComponent("XUILabel") as IXUILabel;
			IXUILabel ixuilabel2 = t.Find("Level").GetComponent("XUILabel") as IXUILabel;
			IXUILabel ixuilabel3 = t.Find("Prof").GetComponent("XUILabel") as IXUILabel;
			IXUILabel ixuilabel4 = t.Find("Time").GetComponent("XUILabel") as IXUILabel;
			IXUIButton ixuibutton = t.Find("YesBtn").GetComponent("XUIButton") as IXUIButton;
			IXUIButton ixuibutton2 = t.Find("NoBtn").GetComponent("XUIButton") as IXUIButton;
			ixuisprite.spriteName = XSingleton<XProfessionSkillMgr>.singleton.GetProfHeadIcon((int)partyExchangeItemInfo.profession_id);
			ixuilabel.SetText(partyExchangeItemInfo.name);
			ixuilabel2.SetText(partyExchangeItemInfo.level.ToString());
			ixuilabel3.SetText(XSingleton<XProfessionSkillMgr>.singleton.GetProfName((int)partyExchangeItemInfo.profession_id));
			ixuilabel4.SetText(XSingleton<UiUtility>.singleton.TimeAccFormatString((int)partyExchangeItemInfo.time, 3, 0) + XStringDefineProxy.GetString("AGO"));
			ixuibutton.ID = partyExchangeItemInfo.role_id;
			ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnYesBtnClick));
			ixuibutton2.ID = partyExchangeItemInfo.role_id;
			ixuibutton2.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnNoBtnClick));
		}

		private bool OnCloseBtnClick(IXUIButton btn)
		{
			this.SetVisibleWithAnimation(false, null);
			return true;
		}

		private bool OnClearBtnClick(IXUIButton btn)
		{
			this._doc.ClearList();
			return true;
		}

		private bool OnYesBtnClick(IXUIButton btn)
		{
			this._doc.QueryAcceptExchange(btn.ID);
			return true;
		}

		private bool OnNoBtnClick(IXUIButton btn)
		{
			this._doc.QueryRefuseExchange(btn.ID);
			return true;
		}
	}
}