Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AttendCheckWnd extends UICommonAPI;
- const SHOW_STEP_PER_PAGE = 7;
- const SHOW_STEP_MINIMUM_PAGE = 1;
- const TIMER_REQUEST_DELAY = 1000;
- const TIMER_ID_REQUEST_DELAY = 1;
- enum EAttendCheckState
- {
- Unchecked,
- Available,
- Checked
- };
- struct AttendCheckStepInfo
- {
- var int Day;
- var int ItemID;
- var INT64 ItemAmount;
- var bool isHighLight;
- var AttendCheckWnd.EAttendCheckState State;
- };
- struct AttendCheckInfo
- {
- var int currentPage;
- var int maxPage;
- var int minimumLevel;
- var int today;
- var int todayPage;
- var int attendDay;
- var bool itemGetEnable;
- var array<AttendCheckStepInfo> stepInfos;
- };
- var WindowHandle Me;
- var WindowHandle scrollAreaContainer;
- var WindowHandle scrollArea;
- var TextBoxHandle infoTextBox;
- var ButtonHandle pagePrevBtn;
- var ButtonHandle pageNextBtn;
- var ButtonHandle attendCheckBtn;
- var UIControlPageNavi pageNaviControl;
- var array<AttendCheckSlot> stepControlList;
- var AttendCheckInfo _attendCheckInfo;
- var bool _isWaitingRequestDelay;
- var int scrollAreaWidth;
- event OnRegisterEvent()
- {
- RegisterEvent(10050);
- RegisterEvent(10051);
- return;
- }
- event OnLoad()
- {
- SetClosingOnESC();
- Initialize();
- return;
- }
- event OnShow()
- {
- _isWaitingRequestDelay = false;
- getInstanceL2Util().ItemRelationWindowHide(getCurrentWindowName(string(self)));
- return;
- }
- function Initialize()
- {
- local string ownerFullPath;
- local int i, tempHeight;
- local WindowHandle targetStepWnd;
- local AttendCheckSlot stepControl;
- local WindowHandle pageNaviControlWnd;
- ownerFullPath = m_hOwnerWnd.m_WindowNameWithFullPath;
- Me = GetWindowHandle("AttendCheckWnd");
- infoTextBox = GetTextBoxHandle(ownerFullPath $ ".Message_TextBox");
- infoTextBox.SetText("");
- pageNaviControlWnd = GetWindowHandle(ownerFullPath $ ".PageNavi_Control");
- pageNaviControlWnd.SetScript("UIControlPageNavi");
- pageNaviControl = UIControlPageNavi(pageNaviControlWnd.GetScript());
- pageNaviControl.Init(ownerFullPath $ ".PageNavi_Control");
- pageNaviControl.__DelegeOnChangePage__Delegate = OnPageNaviChanged;
- pagePrevBtn = GetButtonHandle(ownerFullPath $ ".Prev_Btn");
- pageNextBtn = GetButtonHandle(ownerFullPath $ ".Next_Btn");
- attendCheckBtn = GetButtonHandle(ownerFullPath $ ".RewardBtn");
- scrollAreaContainer = GetWindowHandle(ownerFullPath $ ".ScrollAreaWnd");
- scrollArea = GetWindowHandle(scrollAreaContainer.m_WindowNameWithFullPath $ ".ScrollArea");
- scrollArea.GetWindowSize(scrollAreaWidth, tempHeight);
- _attendCheckInfo.currentPage = 1;
- stepControlList.Length = 0;
- i = 0;
- J0x1E0:
- if(i <= 7)
- {
- targetStepWnd = GetWindowHandle((scrollArea.m_WindowNameWithFullPath $ ".DaySlot_") $ string(i));
- targetStepWnd.SetScript("AttendCheckSlot");
- stepControl = AttendCheckSlot(targetStepWnd.GetScript());
- stepControl.Init(targetStepWnd, self);
- stepControl.__DelegateOnItemClicked__Delegate = OnStepAvailableItemClicked;
- stepControlList[i] = stepControl;
- ++ i;
- goto J0x1E0;
- }
- Debug("AttendCheckWnd Initialize" @ string(stepControlList.Length));
- return;
- }
- function StopAllAniTexture()
- {
- local int i;
- i = 0;
- J0x07:
- if(i < stepControlList.Length)
- {
- stepControlList[i].StopAnimation();
- ++ i;
- goto J0x07;
- }
- return;
- }
- function CheckAndPlayStampAnimaion()
- {
- local int i;
- i = 0;
- J0x07:
- if(i < stepControlList.Length)
- {
- stepControlList[i].CheckAndPlayStampAnimation();
- ++ i;
- goto J0x07;
- }
- return;
- }
- function InitScrollArea()
- {
- scrollArea.SetScrollHeight(scrollAreaWidth * _attendCheckInfo.maxPage);
- scrollArea.SetScrollUnit(scrollAreaWidth, true);
- return;
- }
- function UpdateScrollPosition()
- {
- scrollArea.SetScrollPosition(GetScrollPosByPage(_attendCheckInfo.currentPage));
- return;
- }
- function UpdateUIControls()
- {
- UpdateStepControls();
- UpdateButtonControls();
- UpdateScrollPosition();
- UpdateInfoControls();
- return;
- }
- function UpdateStepControls()
- {
- local int i, infoIndex, infoLength, currentPage;
- currentPage = Max(_attendCheckInfo.currentPage, 1);
- infoLength = _attendCheckInfo.stepInfos.Length;
- infoIndex = (currentPage - 1) * 7;
- i = 0;
- J0x3D:
- if(i < 7)
- {
- if(infoIndex < infoLength)
- {
- stepControlList[i].SetInfo(_attendCheckInfo.stepInfos[infoIndex]);
- }
- else
- {
- stepControlList[i].SetDisable(true);
- }
- ++ infoIndex;
- ++ i;
- goto J0x3D;
- }
- SetPageNaviMaxPage(_attendCheckInfo.maxPage);
- SetPageNaviCurrentPage(currentPage);
- if(_attendCheckInfo.maxPage == 1)
- {
- pagePrevBtn.SetEnable(false);
- pageNextBtn.SetEnable(false);
- }
- else
- {
- if(_attendCheckInfo.currentPage == _attendCheckInfo.maxPage)
- {
- pagePrevBtn.SetEnable(true);
- pageNextBtn.SetEnable(false);
- }
- else
- {
- if(_attendCheckInfo.currentPage == 1)
- {
- pagePrevBtn.SetEnable(false);
- pageNextBtn.SetEnable(true);
- }
- else
- {
- pagePrevBtn.SetEnable(true);
- pageNextBtn.SetEnable(true);
- }
- }
- }
- return;
- }
- function SetPageNaviMaxPage(int maxPage)
- {
- pageNaviControl.SetTotalPage(maxPage);
- return;
- }
- function SetPageNaviCurrentPage(int Page)
- {
- pageNaviControl.Go(Page);
- return;
- }
- function UpdateInfoControls()
- {
- local UserInfo UserInfo;
- local int minimumLevel;
- minimumLevel = _attendCheckInfo.minimumLevel;
- if((_attendCheckInfo.today >= _attendCheckInfo.stepInfos.Length) && _attendCheckInfo.itemGetEnable == false)
- {
- infoTextBox.SetText(GetSystemMessage(6222));
- }
- else
- {
- if(minimumLevel > 0)
- {
- GetPlayerInfo(UserInfo);
- if(minimumLevel > UserInfo.nLevel)
- {
- infoTextBox.SetText(MakeFullSystemMsg(GetSystemMessage(6188), string(minimumLevel)));
- }
- else
- {
- infoTextBox.SetText(GetSystemMessage(6194));
- }
- }
- else
- {
- infoTextBox.SetText(GetSystemMessage(6194));
- }
- }
- return;
- }
- function UpdateButtonControls()
- {
- if(_attendCheckInfo.itemGetEnable == true)
- {
- attendCheckBtn.SetButtonName(5600);
- if(_attendCheckInfo.todayPage == _attendCheckInfo.currentPage)
- {
- attendCheckBtn.SetEnable(true);
- }
- else
- {
- attendCheckBtn.SetEnable(false);
- }
- }
- else
- {
- attendCheckBtn.SetEnable(false);
- attendCheckBtn.SetButtonName(5601);
- }
- if(_attendCheckInfo.maxPage == 1)
- {
- pageNaviControl.SetDisable(true);
- }
- else
- {
- pageNaviControl.SetDisable(false);
- }
- return;
- }
- function int GetPageByScrollPos(int pos)
- {
- return (pos / scrollAreaWidth) + 1;
- return;
- }
- function int GetScrollPosByPage(int Page)
- {
- return (Page - 1) * scrollAreaWidth;
- return;
- }
- function RequestAttendCheck()
- {
- if(_isWaitingRequestDelay == false)
- {
- StartRequestDelayTimer();
- RequestAttendanceCheck();
- }
- return;
- }
- function StartRequestDelayTimer()
- {
- _isWaitingRequestDelay = true;
- Me.SetTimer(1, 1000);
- return;
- }
- function KillRequestDelayTimer()
- {
- Me.KillTimer(1);
- _isWaitingRequestDelay = false;
- return;
- }
- function OnEvent(int Event_ID, string a_Param)
- {
- if(Event_ID == 10050)
- {
- Rs_EV_VipAttendanceItemList(a_Param);
- }
- else
- {
- if(Event_ID == 10051)
- {
- Nt_EV_VipAttendanceCheck(a_Param);
- }
- }
- return;
- }
- function Rs_EV_VipAttendanceItemList(string param)
- {
- local int i, itemTotalCount, itemGetEnable, attendDay, today, ItemID,
- Amount, highLight, minimumLevel, maxPage;
- local AttendCheckStepInfo stepInfo;
- ParseInt(param, "Today", today);
- ParseInt(param, "NormalDay", attendDay);
- ParseInt(param, "ItemCount", itemTotalCount);
- ParseInt(param, "NormalAttendanceEnable", itemGetEnable);
- ParseInt(param, "MinimumLevel", minimumLevel);
- _attendCheckInfo.stepInfos.Length = 0;
- i = 1;
- J0xA7:
- if(i <= itemTotalCount)
- {
- ParseInt(param, "ItemID_" $ string(i), ItemID);
- ParseInt(param, "Amount_" $ string(i), Amount);
- ParseInt(param, "HighLight_" $ string(i), highLight);
- stepInfo.Day = i;
- stepInfo.ItemAmount = (Amount);
- stepInfo.isHighLight = bool(highLight);
- stepInfo.ItemID = ItemID;
- if(today >= i)
- {
- stepInfo.State = 2;
- }
- else
- {
- stepInfo.State = 0;
- }
- if((today == i) && itemGetEnable > 0)
- {
- stepInfo.State = 1;
- }
- _attendCheckInfo.stepInfos[_attendCheckInfo.stepInfos.Length] = stepInfo;
- ++ i;
- goto J0xA7;
- }
- maxPage = Max(appCeil(float(itemTotalCount) / float(7)), 1);
- _attendCheckInfo.minimumLevel = minimumLevel;
- _attendCheckInfo.today = today;
- _attendCheckInfo.attendDay = attendDay;
- _attendCheckInfo.itemGetEnable = bool(itemGetEnable);
- _attendCheckInfo.maxPage = maxPage;
- _attendCheckInfo.todayPage = Min(Max(appCeil(float(today) / float(7)), 1), maxPage);
- _attendCheckInfo.currentPage = _attendCheckInfo.todayPage;
- InitScrollArea();
- UpdateUIControls();
- if(!Me.IsShowWindow())
- {
- Me.ShowWindow();
- Me.SetFocus();
- }
- return;
- }
- function Nt_EV_VipAttendanceCheck(string param)
- {
- local int checkDay, checkType, dayIndex;
- local AttendCheckStepInfo stepInfo;
- ParseInt(param, "CheckDay", checkDay);
- ParseInt(param, "CheckType", checkType);
- if((checkDay > 0) && checkType == 1)
- {
- dayIndex = checkDay - 1;
- if(_attendCheckInfo.stepInfos.Length > dayIndex)
- {
- stepInfo = _attendCheckInfo.stepInfos[dayIndex];
- stepInfo.State = 2;
- _attendCheckInfo.stepInfos[dayIndex] = stepInfo;
- _attendCheckInfo.itemGetEnable = false;
- CheckAndPlayStampAnimaion();
- UpdateButtonControls();
- UpdateInfoControls();
- PlaySound("InterfaceSound.stamp_red");
- getInstanceNoticeWnd().RemoveAttendCheckNotice();
- }
- }
- return;
- }
- event OnHide()
- {
- StopAllAniTexture();
- return;
- }
- event OnScrollMove(string strID, int pos)
- {
- local int targetPage;
- targetPage = GetPageByScrollPos(pos);
- if(pos != (GetScrollPosByPage(targetPage)))
- {
- scrollArea.SetScrollPosition(GetScrollPosByPage(targetPage));
- return;
- }
- if(_attendCheckInfo.currentPage != targetPage)
- {
- _attendCheckInfo.currentPage = targetPage;
- UpdateUIControls();
- }
- return;
- }
- event OnTimer(int TimerID)
- {
- if(TimerID == 1)
- {
- KillRequestDelayTimer();
- }
- return;
- }
- event OnPageNaviChanged(int Page)
- {
- _attendCheckInfo.currentPage = Page;
- UpdateUIControls();
- return;
- }
- event OnPageStepperClicked(bool isNext)
- {
- if(_attendCheckInfo.currentPage < 1)
- {
- return;
- }
- if(isNext == true)
- {
- if(_attendCheckInfo.currentPage < _attendCheckInfo.maxPage)
- {
- ++ _attendCheckInfo.currentPage;
- }
- }
- else
- {
- if(_attendCheckInfo.currentPage > 1)
- {
- -- _attendCheckInfo.currentPage;
- }
- }
- UpdateUIControls();
- return;
- }
- event OnClickButton(string Name)
- {
- switch(Name)
- {
- case "HelpBtn":
- OnHelpBtnClicked();
- break;
- case "CancelBtn":
- OnCancelBtnClicked();
- break;
- case "Prev_Btn":
- OnPageStepperClicked(false);
- break;
- case "Next_Btn":
- OnPageStepperClicked(true);
- break;
- case "RewardBtn":
- OnAttendCheckBtnClicked();
- break;
- default:
- break;
- }
- return;
- }
- event OnAttendCheckBtnClicked()
- {
- RequestAttendCheck();
- return;
- }
- event OnStepAvailableItemClicked(AttendCheckSlot Slot)
- {
- RequestAttendCheck();
- return;
- }
- event OnCancelBtnClicked()
- {
- Me.HideWindow();
- return;
- }
- event OnHelpBtnClicked()
- {
- local string strParam;
- ParamAdd(strParam, "FilePath", GetLocalizedL2TextPathNameUC() $ "g_attendance_help001.htm");
- ExecuteEvent(1210, strParam);
- return;
- }
- event OnReceivedCloseUI()
- {
- PlayConsoleSound(6);
- GetWindowHandle(getCurrentWindowName(string(self))).HideWindow();
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement