Advertisement
AlisaCodeDragon

AttendCheckWnd

Mar 7th, 2023
1,481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
UnrealScript 13.58 KB | Source Code | 0 0
  1. class AttendCheckWnd extends UICommonAPI;
  2.  
  3. const SHOW_STEP_PER_PAGE = 7;
  4. const SHOW_STEP_MINIMUM_PAGE = 1;
  5. const TIMER_REQUEST_DELAY = 1000;
  6. const TIMER_ID_REQUEST_DELAY = 1;
  7.  
  8. enum EAttendCheckState
  9. {
  10.     Unchecked,
  11.     Available,
  12.     Checked
  13. };
  14.  
  15. struct AttendCheckStepInfo
  16. {
  17.     var int Day;
  18.     var int ItemID;
  19.     var INT64 ItemAmount;
  20.     var bool isHighLight;
  21.     var AttendCheckWnd.EAttendCheckState State;
  22. };
  23.  
  24. struct AttendCheckInfo
  25. {
  26.     var int currentPage;
  27.     var int maxPage;
  28.     var int minimumLevel;
  29.     var int today;
  30.     var int todayPage;
  31.     var int attendDay;
  32.     var bool itemGetEnable;
  33.     var array<AttendCheckStepInfo> stepInfos;
  34. };
  35.  
  36. var WindowHandle Me;
  37. var WindowHandle scrollAreaContainer;
  38. var WindowHandle scrollArea;
  39. var TextBoxHandle infoTextBox;
  40. var ButtonHandle pagePrevBtn;
  41. var ButtonHandle pageNextBtn;
  42. var ButtonHandle attendCheckBtn;
  43. var UIControlPageNavi pageNaviControl;
  44. var array<AttendCheckSlot> stepControlList;
  45. var AttendCheckInfo _attendCheckInfo;
  46. var bool _isWaitingRequestDelay;
  47. var int scrollAreaWidth;
  48.  
  49. event OnRegisterEvent()
  50. {
  51.     RegisterEvent(10050);
  52.     RegisterEvent(10051);
  53.     return;
  54. }
  55.  
  56. event OnLoad()
  57. {
  58.     SetClosingOnESC();
  59.     Initialize();
  60.     return;
  61. }
  62.  
  63. event OnShow()
  64. {
  65.     _isWaitingRequestDelay = false;
  66.     getInstanceL2Util().ItemRelationWindowHide(getCurrentWindowName(string(self)));
  67.     return;
  68. }
  69.  
  70. function Initialize()
  71. {
  72.     local string ownerFullPath;
  73.     local int i, tempHeight;
  74.     local WindowHandle targetStepWnd;
  75.     local AttendCheckSlot stepControl;
  76.     local WindowHandle pageNaviControlWnd;
  77.  
  78.     ownerFullPath = m_hOwnerWnd.m_WindowNameWithFullPath;
  79.     Me = GetWindowHandle("AttendCheckWnd");
  80.     infoTextBox = GetTextBoxHandle(ownerFullPath $ ".Message_TextBox");
  81.     infoTextBox.SetText("");
  82.     pageNaviControlWnd = GetWindowHandle(ownerFullPath $ ".PageNavi_Control");
  83.     pageNaviControlWnd.SetScript("UIControlPageNavi");
  84.     pageNaviControl = UIControlPageNavi(pageNaviControlWnd.GetScript());
  85.     pageNaviControl.Init(ownerFullPath $ ".PageNavi_Control");
  86.     pageNaviControl.__DelegeOnChangePage__Delegate = OnPageNaviChanged;
  87.     pagePrevBtn = GetButtonHandle(ownerFullPath $ ".Prev_Btn");
  88.     pageNextBtn = GetButtonHandle(ownerFullPath $ ".Next_Btn");
  89.     attendCheckBtn = GetButtonHandle(ownerFullPath $ ".RewardBtn");
  90.     scrollAreaContainer = GetWindowHandle(ownerFullPath $ ".ScrollAreaWnd");
  91.     scrollArea = GetWindowHandle(scrollAreaContainer.m_WindowNameWithFullPath $ ".ScrollArea");
  92.     scrollArea.GetWindowSize(scrollAreaWidth, tempHeight);
  93.     _attendCheckInfo.currentPage = 1;
  94.     stepControlList.Length = 0;
  95.     i = 0;
  96.     J0x1E0:
  97.  
  98.    
  99.     if(i <= 7)
  100.     {
  101.         targetStepWnd = GetWindowHandle((scrollArea.m_WindowNameWithFullPath $ ".DaySlot_") $ string(i));
  102.         targetStepWnd.SetScript("AttendCheckSlot");
  103.         stepControl = AttendCheckSlot(targetStepWnd.GetScript());
  104.         stepControl.Init(targetStepWnd, self);
  105.         stepControl.__DelegateOnItemClicked__Delegate = OnStepAvailableItemClicked;
  106.         stepControlList[i] = stepControl;
  107.         ++ i;
  108.        
  109.         goto J0x1E0;
  110.     }
  111.     Debug("AttendCheckWnd Initialize" @ string(stepControlList.Length));
  112.     return;
  113. }
  114.  
  115. function StopAllAniTexture()
  116. {
  117.     local int i;
  118.  
  119.     i = 0;
  120.     J0x07:
  121.  
  122.    
  123.     if(i < stepControlList.Length)
  124.     {
  125.         stepControlList[i].StopAnimation();
  126.         ++ i;
  127.        
  128.         goto J0x07;
  129.     }
  130.     return;
  131. }
  132.  
  133. function CheckAndPlayStampAnimaion()
  134. {
  135.     local int i;
  136.  
  137.     i = 0;
  138.     J0x07:
  139.  
  140.    
  141.     if(i < stepControlList.Length)
  142.     {
  143.         stepControlList[i].CheckAndPlayStampAnimation();
  144.         ++ i;
  145.        
  146.         goto J0x07;
  147.     }
  148.     return;
  149. }
  150.  
  151. function InitScrollArea()
  152. {
  153.     scrollArea.SetScrollHeight(scrollAreaWidth * _attendCheckInfo.maxPage);
  154.     scrollArea.SetScrollUnit(scrollAreaWidth, true);
  155.     return;
  156. }
  157.  
  158. function UpdateScrollPosition()
  159. {
  160.     scrollArea.SetScrollPosition(GetScrollPosByPage(_attendCheckInfo.currentPage));
  161.     return;
  162. }
  163.  
  164. function UpdateUIControls()
  165. {
  166.     UpdateStepControls();
  167.     UpdateButtonControls();
  168.     UpdateScrollPosition();
  169.     UpdateInfoControls();
  170.     return;
  171. }
  172.  
  173. function UpdateStepControls()
  174. {
  175.     local int i, infoIndex, infoLength, currentPage;
  176.  
  177.     currentPage = Max(_attendCheckInfo.currentPage, 1);
  178.     infoLength = _attendCheckInfo.stepInfos.Length;
  179.     infoIndex = (currentPage - 1) * 7;
  180.     i = 0;
  181.     J0x3D:
  182.  
  183.    
  184.     if(i < 7)
  185.     {
  186.        
  187.         if(infoIndex < infoLength)
  188.         {
  189.             stepControlList[i].SetInfo(_attendCheckInfo.stepInfos[infoIndex]);            
  190.         }
  191.         else
  192.         {
  193.             stepControlList[i].SetDisable(true);
  194.         }
  195.         ++ infoIndex;
  196.         ++ i;
  197.        
  198.         goto J0x3D;
  199.     }
  200.     SetPageNaviMaxPage(_attendCheckInfo.maxPage);
  201.     SetPageNaviCurrentPage(currentPage);
  202.    
  203.     if(_attendCheckInfo.maxPage == 1)
  204.     {
  205.         pagePrevBtn.SetEnable(false);
  206.         pageNextBtn.SetEnable(false);        
  207.     }
  208.     else
  209.     {
  210.        
  211.         if(_attendCheckInfo.currentPage == _attendCheckInfo.maxPage)
  212.         {
  213.             pagePrevBtn.SetEnable(true);
  214.             pageNextBtn.SetEnable(false);            
  215.         }
  216.         else
  217.         {
  218.            
  219.             if(_attendCheckInfo.currentPage == 1)
  220.             {
  221.                 pagePrevBtn.SetEnable(false);
  222.                 pageNextBtn.SetEnable(true);                
  223.             }
  224.             else
  225.             {
  226.                 pagePrevBtn.SetEnable(true);
  227.                 pageNextBtn.SetEnable(true);
  228.             }
  229.         }
  230.     }
  231.     return;
  232. }
  233.  
  234. function SetPageNaviMaxPage(int maxPage)
  235. {
  236.     pageNaviControl.SetTotalPage(maxPage);
  237.     return;
  238. }
  239.  
  240. function SetPageNaviCurrentPage(int Page)
  241. {
  242.     pageNaviControl.Go(Page);
  243.     return;
  244. }
  245.  
  246. function UpdateInfoControls()
  247. {
  248.     local UserInfo UserInfo;
  249.     local int minimumLevel;
  250.  
  251.     minimumLevel = _attendCheckInfo.minimumLevel;
  252.    
  253.     if((_attendCheckInfo.today >= _attendCheckInfo.stepInfos.Length) && _attendCheckInfo.itemGetEnable == false)
  254.     {
  255.         infoTextBox.SetText(GetSystemMessage(6222));        
  256.     }
  257.     else
  258.     {
  259.        
  260.         if(minimumLevel > 0)
  261.         {
  262.             GetPlayerInfo(UserInfo);
  263.            
  264.             if(minimumLevel > UserInfo.nLevel)
  265.             {
  266.                 infoTextBox.SetText(MakeFullSystemMsg(GetSystemMessage(6188), string(minimumLevel)));                
  267.             }
  268.             else
  269.             {
  270.                 infoTextBox.SetText(GetSystemMessage(6194));
  271.             }            
  272.         }
  273.         else
  274.         {
  275.             infoTextBox.SetText(GetSystemMessage(6194));
  276.         }
  277.     }
  278.     return;
  279. }
  280.  
  281. function UpdateButtonControls()
  282. {
  283.    
  284.     if(_attendCheckInfo.itemGetEnable == true)
  285.     {
  286.         attendCheckBtn.SetButtonName(5600);
  287.        
  288.         if(_attendCheckInfo.todayPage == _attendCheckInfo.currentPage)
  289.         {
  290.             attendCheckBtn.SetEnable(true);            
  291.         }
  292.         else
  293.         {
  294.             attendCheckBtn.SetEnable(false);
  295.         }        
  296.     }
  297.     else
  298.     {
  299.         attendCheckBtn.SetEnable(false);
  300.         attendCheckBtn.SetButtonName(5601);
  301.     }
  302.    
  303.     if(_attendCheckInfo.maxPage == 1)
  304.     {
  305.         pageNaviControl.SetDisable(true);        
  306.     }
  307.     else
  308.     {
  309.         pageNaviControl.SetDisable(false);
  310.     }
  311.     return;
  312. }
  313.  
  314. function int GetPageByScrollPos(int pos)
  315. {
  316.     return (pos / scrollAreaWidth) + 1;
  317.     return;
  318. }
  319.  
  320. function int GetScrollPosByPage(int Page)
  321. {
  322.     return (Page - 1) * scrollAreaWidth;
  323.     return;
  324. }
  325.  
  326. function RequestAttendCheck()
  327. {
  328.    
  329.     if(_isWaitingRequestDelay == false)
  330.     {
  331.         StartRequestDelayTimer();
  332.         RequestAttendanceCheck();
  333.     }
  334.     return;
  335. }
  336.  
  337. function StartRequestDelayTimer()
  338. {
  339.     _isWaitingRequestDelay = true;
  340.     Me.SetTimer(1, 1000);
  341.     return;
  342. }
  343.  
  344. function KillRequestDelayTimer()
  345. {
  346.     Me.KillTimer(1);
  347.     _isWaitingRequestDelay = false;
  348.     return;
  349. }
  350.  
  351. function OnEvent(int Event_ID, string a_Param)
  352. {
  353.    
  354.     if(Event_ID == 10050)
  355.     {
  356.         Rs_EV_VipAttendanceItemList(a_Param);        
  357.     }
  358.     else
  359.     {
  360.        
  361.         if(Event_ID == 10051)
  362.         {
  363.             Nt_EV_VipAttendanceCheck(a_Param);
  364.         }
  365.     }
  366.     return;
  367. }
  368.  
  369. function Rs_EV_VipAttendanceItemList(string param)
  370. {
  371.     local int i, itemTotalCount, itemGetEnable, attendDay, today, ItemID,
  372.         Amount, highLight, minimumLevel, maxPage;
  373.  
  374.     local AttendCheckStepInfo stepInfo;
  375.  
  376.     ParseInt(param, "Today", today);
  377.     ParseInt(param, "NormalDay", attendDay);
  378.     ParseInt(param, "ItemCount", itemTotalCount);
  379.     ParseInt(param, "NormalAttendanceEnable", itemGetEnable);
  380.     ParseInt(param, "MinimumLevel", minimumLevel);
  381.     _attendCheckInfo.stepInfos.Length = 0;
  382.     i = 1;
  383.     J0xA7:
  384.  
  385.    
  386.     if(i <= itemTotalCount)
  387.     {
  388.         ParseInt(param, "ItemID_" $ string(i), ItemID);
  389.         ParseInt(param, "Amount_" $ string(i), Amount);
  390.         ParseInt(param, "HighLight_" $ string(i), highLight);
  391.         stepInfo.Day = i;
  392.         stepInfo.ItemAmount = (Amount);
  393.         stepInfo.isHighLight = bool(highLight);
  394.         stepInfo.ItemID = ItemID;
  395.        
  396.         if(today >= i)
  397.         {
  398.             stepInfo.State = 2;            
  399.         }
  400.         else
  401.         {
  402.             stepInfo.State = 0;
  403.         }
  404.        
  405.         if((today == i) && itemGetEnable > 0)
  406.         {
  407.             stepInfo.State = 1;
  408.         }
  409.         _attendCheckInfo.stepInfos[_attendCheckInfo.stepInfos.Length] = stepInfo;
  410.         ++ i;
  411.        
  412.         goto J0xA7;
  413.     }
  414.     maxPage = Max(appCeil(float(itemTotalCount) / float(7)), 1);
  415.     _attendCheckInfo.minimumLevel = minimumLevel;
  416.     _attendCheckInfo.today = today;
  417.     _attendCheckInfo.attendDay = attendDay;
  418.     _attendCheckInfo.itemGetEnable = bool(itemGetEnable);
  419.     _attendCheckInfo.maxPage = maxPage;
  420.     _attendCheckInfo.todayPage = Min(Max(appCeil(float(today) / float(7)), 1), maxPage);
  421.     _attendCheckInfo.currentPage = _attendCheckInfo.todayPage;
  422.     InitScrollArea();
  423.     UpdateUIControls();
  424.    
  425.     if(!Me.IsShowWindow())
  426.     {
  427.         Me.ShowWindow();
  428.         Me.SetFocus();
  429.     }
  430.     return;
  431. }
  432.  
  433. function Nt_EV_VipAttendanceCheck(string param)
  434. {
  435.     local int checkDay, checkType, dayIndex;
  436.     local AttendCheckStepInfo stepInfo;
  437.  
  438.     ParseInt(param, "CheckDay", checkDay);
  439.     ParseInt(param, "CheckType", checkType);
  440.    
  441.     if((checkDay > 0) && checkType == 1)
  442.     {
  443.         dayIndex = checkDay - 1;
  444.        
  445.         if(_attendCheckInfo.stepInfos.Length > dayIndex)
  446.         {
  447.             stepInfo = _attendCheckInfo.stepInfos[dayIndex];
  448.             stepInfo.State = 2;
  449.             _attendCheckInfo.stepInfos[dayIndex] = stepInfo;
  450.             _attendCheckInfo.itemGetEnable = false;
  451.             CheckAndPlayStampAnimaion();
  452.             UpdateButtonControls();
  453.             UpdateInfoControls();
  454.             PlaySound("InterfaceSound.stamp_red");
  455.             getInstanceNoticeWnd().RemoveAttendCheckNotice();
  456.         }
  457.     }
  458.     return;
  459. }
  460.  
  461. event OnHide()
  462. {
  463.     StopAllAniTexture();
  464.     return;
  465. }
  466.  
  467. event OnScrollMove(string strID, int pos)
  468. {
  469.     local int targetPage;
  470.  
  471.     targetPage = GetPageByScrollPos(pos);
  472.    
  473.     if(pos != (GetScrollPosByPage(targetPage)))
  474.     {
  475.         scrollArea.SetScrollPosition(GetScrollPosByPage(targetPage));
  476.         return;
  477.     }
  478.    
  479.     if(_attendCheckInfo.currentPage != targetPage)
  480.     {
  481.         _attendCheckInfo.currentPage = targetPage;
  482.         UpdateUIControls();
  483.     }
  484.     return;
  485. }
  486.  
  487. event OnTimer(int TimerID)
  488. {
  489.    
  490.     if(TimerID == 1)
  491.     {
  492.         KillRequestDelayTimer();
  493.     }
  494.     return;
  495. }
  496.  
  497. event OnPageNaviChanged(int Page)
  498. {
  499.     _attendCheckInfo.currentPage = Page;
  500.     UpdateUIControls();
  501.     return;
  502. }
  503.  
  504. event OnPageStepperClicked(bool isNext)
  505. {
  506.    
  507.     if(_attendCheckInfo.currentPage < 1)
  508.     {
  509.         return;
  510.     }
  511.    
  512.     if(isNext == true)
  513.     {
  514.        
  515.         if(_attendCheckInfo.currentPage < _attendCheckInfo.maxPage)
  516.         {
  517.             ++ _attendCheckInfo.currentPage;
  518.         }        
  519.     }
  520.     else
  521.     {
  522.        
  523.         if(_attendCheckInfo.currentPage > 1)
  524.         {
  525.             -- _attendCheckInfo.currentPage;
  526.         }
  527.     }
  528.     UpdateUIControls();
  529.     return;
  530. }
  531.  
  532. event OnClickButton(string Name)
  533. {
  534.     switch(Name)
  535.     {
  536.        
  537.         case "HelpBtn":
  538.             OnHelpBtnClicked();
  539.            
  540.             break;
  541.        
  542.         case "CancelBtn":
  543.             OnCancelBtnClicked();
  544.            
  545.             break;
  546.        
  547.         case "Prev_Btn":
  548.             OnPageStepperClicked(false);
  549.            
  550.             break;
  551.        
  552.         case "Next_Btn":
  553.             OnPageStepperClicked(true);
  554.            
  555.             break;
  556.        
  557.         case "RewardBtn":
  558.             OnAttendCheckBtnClicked();
  559.            
  560.             break;
  561.        
  562.         default:
  563.             break;
  564.     }
  565.     return;
  566. }
  567.  
  568. event OnAttendCheckBtnClicked()
  569. {
  570.     RequestAttendCheck();
  571.     return;
  572. }
  573.  
  574. event OnStepAvailableItemClicked(AttendCheckSlot Slot)
  575. {
  576.     RequestAttendCheck();
  577.     return;
  578. }
  579.  
  580. event OnCancelBtnClicked()
  581. {
  582.     Me.HideWindow();
  583.     return;
  584. }
  585.  
  586. event OnHelpBtnClicked()
  587. {
  588.     local string strParam;
  589.  
  590.     ParamAdd(strParam, "FilePath", GetLocalizedL2TextPathNameUC() $ "g_attendance_help001.htm");
  591.     ExecuteEvent(1210, strParam);
  592.     return;
  593. }
  594.  
  595. event OnReceivedCloseUI()
  596. {
  597.     PlayConsoleSound(6);
  598.     GetWindowHandle(getCurrentWindowName(string(self))).HideWindow();
  599.     return;
  600. }
  601.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement