Advertisement
AlisaCodeDragon

RefineryWnd.uc

May 8th, 2023
1,429
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class RefineryWnd extends UICommonAPI
  2.     dependson(RefineryWndOption)
  3.     dependson(RefineryWndOption)
  4.     dependson(RefineryWndOption);
  5.  
  6. const TWEENID_SLOT1 = 1;
  7. const TWEENID_SLOT2 = 2;
  8. const TIMEPROGRESS = 1000;
  9. const Adena = 57;
  10. const SHAKEID_ME = 101;
  11. const DWAFT_ID = 19673;
  12. const TIMEID_Confirm = 90;
  13. const TIME_Confirm = 500;
  14.  
  15. enum type_State
  16. {
  17.     stone,
  18.     Target,
  19.     READY,
  20.     ing,
  21.     Result
  22. };
  23.  
  24. struct NewOptionResultInfo
  25. {
  26.     var bool isConfirm;
  27.     var int targetItemSId;
  28.     var int newItemOption1;
  29.     var int newItemOption2;
  30. };
  31.  
  32. var WindowHandle Me;
  33. var string m_WindowName;
  34. var ItemInfo RefineItemInfo;
  35. var ItemInfo RefinerItemInfo;
  36. var ItemInfo GemstoneItemInfo;
  37. var ItemInfo RefinedITemInfo;
  38. var WindowHandle m_DragBox1;
  39. var WindowHandle m_DragBox2;
  40. var WindowHandle m_DragBoxResult;
  41. var WindowHandle m_ResultAnimation1;
  42. var WindowHandle m_ResultAnimation2;
  43. var WindowHandle m_ResultAnimation3;
  44. var WindowHandle m_ResultAnimation4;
  45. var AnimTextureHandle m_RefineAnim;
  46. var AnimTextureHandle m_ResultAnim1;
  47. var AnimTextureHandle m_ResultAnim2;
  48. var AnimTextureHandle m_ResultAnim3;
  49. var AnimTextureHandle m_ResultAnim4;
  50. var ButtonHandle m_RefineryBtn;
  51. var ButtonHandle btnReset;
  52. var ItemWindowHandle m_DragboxItem1;
  53. var ItemWindowHandle m_DragBoxItem2;
  54. var ItemWindowHandle m_ResultBoxItem;
  55. var TextBoxHandle m_InstructionText;
  56. var TextBoxHandle txtOptions;
  57. var TextureHandle optionGradeTexture;
  58. var ItemWindowHandle ItemList;
  59. var WindowHandle ItemListWindow;
  60. var CharacterViewportWindowHandle m_ObjectViewport;
  61. var array<UIControlNeedItem> UIControlNeedItemScripts;
  62. var ProgressCtrlHandle m_hRefineryWndRefineryProgress;
  63. var WindowHandle newOptionsWnd;
  64. var WindowHandle optionBlindWnd;
  65. var WindowHandle newOptionBlindWnd;
  66. var WindowHandle newDisableWnd;
  67. var ButtonHandle newOptionBtn;
  68. var ButtonHandle closeWndBtn;
  69. var TextBoxHandle newTxtOptions;
  70. var TextureHandle newOptionGradeTex;
  71. var TextureHandle preOptionCheckTex;
  72. var AnimTextureHandle newOptionApplyAnimTex;
  73. var RefineryWnd.type_State CurrentState;
  74. var L2UITween l2uiTweenScript;
  75. var L2UIInventoryObjectSimple iObject;
  76. var RefineryWndOption RefineryWndOptionScript;
  77. var NewOptionResultInfo newResultInfo;
  78. var bool bHideAndInventoryShow;
  79.  
  80. function OnRegisterEvent()
  81. {
  82.     RegisterEvent(100000 + class'UIPacket'.337);
  83.     RegisterEvent(100000 + class'UIPacket'.340);
  84.     RegisterEvent(100000 + class'UIPacket'.342);
  85.     RegisterEvent(EV_PacketID(class'UIPacket'.1030));
  86.     return;
  87. }
  88.  
  89. function InitHandleListItems()
  90. {
  91.     local int i;
  92.     local string WindowName;
  93.  
  94.     i = 0;
  95.     J0x07:
  96.  
  97.    
  98.     if(i < 2)
  99.     {
  100.         WindowName = (m_WindowName $ ".NeedItem") $ string(i);
  101.         GetWindowHandle(WindowName).SetScript("UIControlNeedItem");
  102.         UIControlNeedItemScripts[i] = UIControlNeedItem(GetWindowHandle(WindowName).GetScript());
  103.         UIControlNeedItemScripts[i].Init(WindowName);
  104.         UIControlNeedItemScripts[i].__DelegateItemUpdate__Delegate = PeeItemUpdated;
  105.         ++ i;
  106.        
  107.         goto J0x07;
  108.     }
  109.     return;
  110. }
  111.  
  112. function InitHandleCOD()
  113. {
  114.     m_WindowName = getCurrentWindowName(string(self));
  115.     Me = GetWindowHandle(m_WindowName);
  116.     InitHandleListItems();
  117.     m_DragBox1 = GetWindowHandle(m_WindowName $ ".ItemDragBox1Wnd");
  118.     m_DragBox2 = GetWindowHandle(m_WindowName $ ".ItemDragBox2Wnd");
  119.     m_DragBoxResult = GetWindowHandle(m_WindowName $ ".ItemDragBoxResultWnd");
  120.     m_ResultAnimation1 = GetWindowHandle(m_WindowName $ ".RefineResultAnimation01");
  121.     m_ResultAnimation2 = GetWindowHandle(m_WindowName $ ".RefineResultAnimation02");
  122.     m_ResultAnimation3 = GetWindowHandle(m_WindowName $ ".RefineResultAnimation03");
  123.     m_ResultAnimation4 = GetWindowHandle(m_WindowName $ ".RefineResultAnimation04");
  124.     m_RefineAnim = GetAnimTextureHandle(m_WindowName $ ".RefineLoadingAnimation.RefineLoadingAnim");
  125.     m_ResultAnim1 = GetAnimTextureHandle(m_WindowName $ ".RefineResultAnimation01.RefineResult1");
  126.     m_ResultAnim2 = GetAnimTextureHandle(m_WindowName $ ".RefineResultAnimation02.RefineResult2");
  127.     m_ResultAnim3 = GetAnimTextureHandle(m_WindowName $ ".RefineResultAnimation03.RefineResult3");
  128.     m_ResultAnim4 = GetAnimTextureHandle(m_WindowName $ ".RefineResultAnimation04.RefineResult4");
  129.     m_DragboxItem1 = GetItemWindowHandle(m_WindowName $ ".ItemDragBox1Wnd.ItemDragBox");
  130.     m_DragBoxItem2 = GetItemWindowHandle(m_WindowName $ ".ItemDragBox2Wnd.ItemDragBox");
  131.     m_ResultBoxItem = GetItemWindowHandle(m_WindowName $ ".ItemDragBoxResultWnd.ItemRefined");
  132.     btnReset = GetButtonHandle(m_WindowName $ ".btnReset");
  133.     m_RefineryBtn = GetButtonHandle(m_WindowName $ ".btnRefine");
  134.     m_InstructionText = GetTextBoxHandle(m_WindowName $ ".txtInstruction");
  135.     ItemListWindow = GetWindowHandle(m_WindowName $ ".ItemListWindow");
  136.     ItemList = GetItemWindowHandle(m_WindowName $ ".ItemListWindow.ItemList");
  137.     l2uiTweenScript = L2UITween(GetScript("l2UITween"));
  138.     RefineryWndOptionScript = RefineryWndOption(GetScript("RefineryWndOption"));
  139.     m_hRefineryWndRefineryProgress = GetProgressCtrlHandle(m_WindowName $ ".RefineryProgress");
  140.     txtOptions = GetTextBoxHandle(m_WindowName $ ".txtOptions");
  141.     optionGradeTexture = GetTextureHandle(m_WindowName $ ".optionGradeTexture");
  142.     m_ObjectViewport = GetCharacterViewportWindowHandle(m_WindowName $ ".ObjectViewport");
  143.     m_ObjectViewport.SetUISound(true);
  144.     m_RefineAnim.SetLoopCount(1);
  145.     m_ResultAnim1.SetLoopCount(1);
  146.     m_ResultAnim2.SetLoopCount(1);
  147.     m_ResultAnim3.SetLoopCount(1);
  148.     m_ResultAnim4.SetLoopCount(1);
  149.     m_hRefineryWndRefineryProgress.SetProgressTime(1000 - 100);
  150.    
  151.     if(IsSupportedResultChoice())
  152.     {
  153.         newOptionsWnd = GetWindowHandle(m_WindowName $ ".NewOptions_wnd");
  154.         optionBlindWnd = GetWindowHandle(m_WindowName $ ".OptionGradeBlind_wnd");
  155.         newOptionBlindWnd = GetWindowHandle(newOptionsWnd.m_WindowNameWithFullPath $ ".NewOptionGradeBlind_wnd");
  156.         newDisableWnd = GetWindowHandle(m_WindowName $ ".DisableWnd");
  157.         newOptionBtn = GetButtonHandle(newOptionsWnd.m_WindowNameWithFullPath $ ".NewOption_btn");
  158.         closeWndBtn = GetButtonHandle(m_WindowName $ ".exitbutton");
  159.         newTxtOptions = GetTextBoxHandle(newOptionsWnd.m_WindowNameWithFullPath $ ".txtOptions");
  160.         newOptionGradeTex = GetTextureHandle(newOptionsWnd.m_WindowNameWithFullPath $ ".NewOptionGradeTexture");
  161.         newOptionApplyAnimTex = GetAnimTextureHandle(m_WindowName $ ".OptionRgstr_Ani");
  162.         preOptionCheckTex = GetTextureHandle(m_WindowName $ ".CheckTexture");
  163.     }
  164.     return;
  165. }
  166.  
  167. function OnLoad()
  168. {
  169.     SetClosingOnESC();
  170.     InitHandleCOD();
  171.     return;
  172. }
  173.  
  174. function OnEvent(int a_EventID, string a_Param)
  175. {
  176.     switch(a_EventID)
  177.     {
  178.        
  179.         case 100000 + class'UIPacket'.337:
  180.             Decode_S_EX_SHOW_VARIATION_MAKE_WINDOW(a_Param);
  181.            
  182.             break;
  183.        
  184.         case 100000 + class'UIPacket'.340:
  185.             Decode_S_EX_PUT_INTENSIVE_RESULT_FOR_VARIATION_MAKE(a_Param);
  186.            
  187.             break;
  188.        
  189.         case 100000 + class'UIPacket'.342:
  190.             Decode_S_EX_VARIATION_RESULT(a_Param);
  191.            
  192.             break;
  193.        
  194.         case EV_PacketID(class'UIPacket'.1030):
  195.             Rs_S_EX_APPLY_VARIATION_OPTION();
  196.            
  197.             break;
  198.        
  199.         default:
  200.             break;
  201.     }
  202.     return;
  203. }
  204.  
  205. function OnDropItem(string a_WindowID, ItemInfo a_itemInfo, int X, int Y)
  206. {
  207.    
  208.     if(a_itemInfo.ShortcutType == int(4))
  209.     {
  210.         return;
  211.     }
  212.     switch(a_itemInfo.DragSrcName)
  213.     {
  214.        
  215.         case "ItemList":
  216.             HandleOnDropItem(a_itemInfo);
  217.            
  218.             break;
  219.        
  220.         default:
  221.             break;
  222.     }
  223.     return;
  224. }
  225.  
  226. function OnRClickItem(string strID, int Index)
  227. {
  228.     switch(strID)
  229.     {
  230.        
  231.         case "ItemList":
  232.             OnDBClickItem(strID, Index);
  233.            
  234.             break;
  235.        
  236.         default:
  237.             break;
  238.     }
  239.     return;
  240. }
  241.  
  242. function OnDBClickItem(string ControlName, int Index)
  243. {
  244.     local ItemInfo iInfo;
  245.  
  246.     switch(ControlName)
  247.     {
  248.        
  249.         case "ItemList":
  250.             ItemList.GetItem(Index, iInfo);
  251.            
  252.             if(iInfo.Id.ClassID > 0)
  253.             {
  254.                 HandleOnDropItem(iInfo);
  255.             }
  256.            
  257.             break;
  258.        
  259.         default:
  260.             break;
  261.     }
  262.     return;
  263. }
  264.  
  265. function OnHide()
  266. {
  267.     ResetAnims();
  268.     RemObjectSimpleByObject(iObject);
  269.    
  270.     if(IsSupportedResultChoice())
  271.     {
  272.        
  273.         if(DialogIsMine())
  274.         {
  275.             DialogHide();
  276.         }
  277.         PlayNewOptionApplyEffect(false);
  278.         Rq_C_EX_VARIATION_CLOSE_UI();
  279.     }
  280.     return;
  281. }
  282.  
  283. function OnShow()
  284. {
  285.     bHideAndInventoryShow = false;
  286.     Me.SetFocus();
  287.     SetDwaft();
  288.     SetState(0);
  289.     getInstanceL2Util().ItemRelationWindowHide(getCurrentWindowName(string(self)));
  290.     class'UIAPI_WINDOW'.static.HideWindow("PetWnd");
  291.     iObject = AddItemListenerSimple(0);
  292.     iObject.__DelegateOnUpdateItem__Delegate = HandleUpdateItemStone;
  293.    
  294.     if(IsSupportedResultChoice())
  295.     {
  296.         SetDialogModal(false);
  297.         SetNewResultInfo(false, 0, 0, 0);
  298.         PlayNewOptionApplyEffect(false);
  299.         Rq_C_EX_VARIATION_OPEN_UI();
  300.     }
  301.     return;
  302. }
  303.  
  304. function OnClickButton(string strID)
  305. {
  306.     switch(strID)
  307.     {
  308.        
  309.         case "btnRefine":
  310.             HandleClickBtnRefine();
  311.            
  312.             break;
  313.        
  314.         case "btnClose":
  315.             OnClickbtnClose();
  316.            
  317.             break;
  318.        
  319.         case "btnReset":
  320.            
  321.             if(IsSupportedResultChoice())
  322.             {
  323.                 NewResultCheckAndReset();                
  324.             }
  325.             else
  326.             {
  327.                 SetState(0);
  328.             }
  329.          
  330.             break;
  331.        
  332.         case "btnOptions":
  333.             RefineryWndOptionScript.Toggle();
  334.            
  335.             break;
  336.        
  337.         case "NewOption_btn":
  338.             OnNewOptionBtnClicked();
  339.            
  340.             break;
  341.        
  342.         case "exitbutton":
  343.             NewResultCheckAndCloseWnd();
  344.            
  345.             break;
  346.        
  347.         default:
  348.             break;
  349.     }
  350.     return;
  351. }
  352.  
  353. function OnTimer(int TimerID)
  354. {
  355.     switch(TimerID)
  356.     {
  357.        
  358.         case 90:
  359.             Me.KillTimer(90);
  360.            
  361.             if(int(CurrentState) == int(4))
  362.             {
  363.                
  364.                 if(IsSupportedResultChoice())
  365.                 {
  366.                    
  367.                     if(canBuy())
  368.                     {
  369.                         m_RefineryBtn.EnableWindow();
  370.                     }                    
  371.                 }
  372.                 else
  373.                 {
  374.                     m_RefineryBtn.EnableWindow();
  375.                 }
  376.             }
  377.            
  378.             break;
  379.        
  380.         default:
  381.             break;
  382.     }
  383.     return;
  384. }
  385.  
  386. function OnTextureAnimEnd(AnimTextureHandle a_WindowHandle)
  387. {
  388.     switch(a_WindowHandle)
  389.     {
  390.        
  391.         case m_ResultAnim1:
  392.             m_ResultAnimation1.HideWindow();
  393.            
  394.             break;
  395.        
  396.         case m_ResultAnim2:
  397.             m_ResultAnimation2.HideWindow();
  398.            
  399.             break;
  400.        
  401.         case m_ResultAnim3:
  402.             m_ResultAnimation3.HideWindow();
  403.            
  404.             break;
  405.        
  406.         case m_ResultAnim4:
  407.             m_ResultAnimation4.HideWindow();
  408.            
  409.             break;
  410.        
  411.         case newOptionApplyAnimTex:
  412.             newOptionApplyAnimTex.HideWindow();
  413.            
  414.             break;
  415.        
  416.         default:
  417.             break;
  418.     }
  419.     return;
  420. }
  421.  
  422. function OnProgressTimeUp(string strID)
  423. {
  424.     switch(strID)
  425.     {
  426.        
  427.         case "RefineryProgress":
  428.             RequestRefine();
  429.            
  430.             break;
  431.        
  432.         default:
  433.             break;
  434.     }
  435.     return;
  436. }
  437.  
  438. function HandleOnDropItem(ItemInfo iInfo)
  439. {
  440.     switch(CurrentState)
  441.     {
  442.        
  443.         case 0:
  444.             AddItemStone(iInfo);
  445.            
  446.             break;
  447.        
  448.         case 1:
  449.             AddItemTarget(iInfo);
  450.            
  451.             break;
  452.        
  453.         default:
  454.             break;
  455.     }
  456.     return;
  457. }
  458.  
  459. function AddItemStone(ItemInfo iInfo)
  460. {
  461.     PlaySound("ItemSound2.smelting.Smelting_dragin");
  462.     iInfo.bShowCount = true;
  463.     m_DragboxItem1.AddItem(iInfo);
  464.     SetState(1);
  465.     MakeTweenAlpha(m_DragBox1, 1);
  466.     iObject.setId(iInfo.Id);
  467.     return;
  468. }
  469.  
  470. function AddItemTarget(ItemInfo iInfo)
  471. {
  472.     PlaySound("ItemSound2.smelting.Smelting_dragin");
  473.     m_DragBoxItem2.AddItem(iInfo);
  474.     AddRefineryText();
  475.     SetPeeItems();
  476.     SetState(2);
  477.     MakeTweenAlpha(m_DragBox2, 2);
  478.     SetOptionList();
  479.     SetNewResultInfo(false, 0, 0, 0);
  480.     UpdateStateNewResult();
  481.     return;
  482. }
  483.  
  484. function SetPeeItems()
  485. {
  486.     local ItemInfo itemInfoStone, itemInfoTarget;
  487.     local int FeeItemID, FeeItemCount, CancelFee;
  488.     local INT64 feeAdenaCount;
  489.  
  490.    
  491.     if(!GetItemInfoStone(itemInfoStone))
  492.     {
  493.         return;
  494.     }
  495.    
  496.     if(!GetItemInfoTarget(itemInfoTarget))
  497.     {
  498.         return;
  499.     }
  500.     API_GetRefineryFee(itemInfoStone.Id.ClassID, itemInfoTarget.Id.ClassID, FeeItemID, FeeItemCount, feeAdenaCount, CancelFee);
  501.    
  502.     if((FeeItemID == 0) || FeeItemCount == 0)
  503.     {
  504.         UIControlNeedItemScripts[0].setId(GetItemID(57));
  505.         UIControlNeedItemScripts[0].SetNumNeed(feeAdenaCount);
  506.         UIControlNeedItemScripts[1].Me.HideWindow();        
  507.     }
  508.     else
  509.     {
  510.         UIControlNeedItemScripts[0].setId(GetItemID(FeeItemID));
  511.         UIControlNeedItemScripts[0].SetNumNeed((FeeItemCount));
  512.         UIControlNeedItemScripts[1].Me.ShowWindow();
  513.         UIControlNeedItemScripts[1].setId(GetItemID(57));
  514.         UIControlNeedItemScripts[1].SetNumNeed(feeAdenaCount);
  515.     }
  516.     return;
  517. }
  518.  
  519. function SetStones()
  520. {
  521.     local int i, Len;
  522.     local array<ItemInfo> iInfos;
  523.  
  524.     ItemList.Clear();
  525.     Len = API_GetTargetItemListFromInven(iInfos);
  526.     i = 0;
  527.     J0x27:
  528.  
  529.    
  530.     if(i < Len)
  531.     {
  532.         ItemList.AddItem(iInfos[i]);
  533.         ++ i;
  534.        
  535.         goto J0x27;
  536.     }
  537.     return;
  538. }
  539.  
  540. function SetTargetItems()
  541. {
  542.     local int i, Len;
  543.     local array<ItemInfo> iInfos;
  544.     local ItemInfo itemInfoStone;
  545.  
  546.     ItemList.Clear();
  547.    
  548.     if(!GetItemInfoStone(itemInfoStone))
  549.     {
  550.         return;
  551.     }
  552.     Len = API_GetItemListFromInven(itemInfoStone.Id.ClassID, iInfos);
  553.     i = 0;
  554.     J0x48:
  555.  
  556.    
  557.     if(i < Len)
  558.     {
  559.         ItemList.AddItem(iInfos[i]);
  560.         ++ i;
  561.        
  562.         goto J0x48;
  563.     }
  564.     return;
  565. }
  566.  
  567. function int API_GetItemListFromInven(int stoneClassID, out array<ItemInfo> iItems)
  568. {
  569.     return class'RefineryAPI'.static.GetItemListFromInven(stoneClassID, iItems);
  570.     return;
  571. }
  572.  
  573. function int API_GetTargetItemListFromInven(out array<ItemInfo> iItems)
  574. {
  575.     return class'RefineryAPI'.static.GetTargetItemListFromInven(iItems);
  576.     return;
  577. }
  578.  
  579. function bool API_GetRefineryFee(int TargetItemClassID, int RefinerClassID, out int FeeItemID, out int FeeItemCount, out INT64 FeeAdena, out int CancelFee)
  580. {
  581.     return class'RefineryAPI'.static.GetRefineryFee(TargetItemClassID, RefinerClassID, FeeItemID, FeeItemCount, FeeAdena, CancelFee);
  582.     return;
  583. }
  584.  
  585. function API_RequestRefine(ItemID TargetItemID, ItemID refineItemID, ItemID getstoneItemID, INT64 getsonteCount)
  586. {
  587.     class'RefineryAPI'.static.RequestRefine(TargetItemID, refineItemID, getstoneItemID, getsonteCount);
  588.     return;
  589. }
  590.  
  591. function Rq_C_EX_VARIATION_OPEN_UI()
  592. {
  593.     local array<byte> stream;
  594.     local _C_EX_VARIATION_OPEN_UI packet;
  595.  
  596.    
  597.     if(!IsSupportedResultChoice())
  598.     {
  599.         return;
  600.     }
  601.    
  602.     if(!class'UIPacket'.static.Encode_C_EX_VARIATION_OPEN_UI(stream, packet))
  603.     {
  604.         return;
  605.     }
  606.     class'UIPacket'.static.RequestUIPacket(class'UIPacket'.790, stream);
  607.     return;
  608. }
  609.  
  610. function Rq_C_EX_VARIATION_CLOSE_UI()
  611. {
  612.     local array<byte> stream;
  613.     local _C_EX_VARIATION_CLOSE_UI packet;
  614.  
  615.    
  616.     if(!IsSupportedResultChoice())
  617.     {
  618.         return;
  619.     }
  620.    
  621.     if(!class'UIPacket'.static.Encode_C_EX_VARIATION_CLOSE_UI(stream, packet))
  622.     {
  623.         return;
  624.     }
  625.     class'UIPacket'.static.RequestUIPacket(class'UIPacket'.791, stream);
  626.     return;
  627. }
  628.  
  629. function Rq_C_EX_APPLY_VARIATION_OPTION(int variationItemSId, int itemOption1, int itemOption2)
  630. {
  631.     local array<byte> stream;
  632.     local _C_EX_APPLY_VARIATION_OPTION packet;
  633.  
  634.    
  635.     if(!IsSupportedResultChoice())
  636.     {
  637.         return;
  638.     }
  639.     packet.nVariationItemSID = variationItemSId;
  640.     packet.nItemOption1 = itemOption1;
  641.     packet.nItemOption2 = itemOption2;
  642.    
  643.     if(!class'UIPacket'.static.Encode_C_EX_APPLY_VARIATION_OPTION(stream, packet))
  644.     {
  645.         return;
  646.     }
  647.     class'UIPacket'.static.RequestUIPacket(class'UIPacket'.792, stream);
  648.     return;
  649. }
  650.  
  651. function Decode_S_EX_SHOW_VARIATION_MAKE_WINDOW(string a_Param)
  652. {
  653.    
  654.     if(Me.IsShowWindow())
  655.     {
  656.         Me.HideWindow();        
  657.     }
  658.     else
  659.     {
  660.         Me.ShowWindow();
  661.     }
  662.     return;
  663. }
  664.  
  665. function Decode_S_EX_PUT_INTENSIVE_RESULT_FOR_VARIATION_MAKE(string a_Param)
  666. {
  667.     local int targetItemServerID, TargetItemClassID, insertResult;
  668.  
  669.     class'UIPacket'.static.DecodeInt(targetItemServerID);
  670.     class'UIPacket'.static.DecodeInt(TargetItemClassID);
  671.     class'UIPacket'.static.DecodeInt(insertResult);
  672.     Handle_S_EX_PUT_INTENSIVE_RESULT_FOR_VARIATION_MAKE(targetItemServerID, TargetItemClassID, insertResult);
  673.     return;
  674. }
  675.  
  676. function Decode_S_EX_VARIATION_RESULT(string a_Param)
  677. {
  678.     local int Option1, Option2;
  679.     local INT64 GemStoneCount, NecessaryGemStoneCount;
  680.     local int RefineResult;
  681.  
  682.     class'UIPacket'.static.DecodeInt(Option1);
  683.     class'UIPacket'.static.DecodeInt(Option2);
  684.     class'UIPacket'.static.DecodeInt64(GemStoneCount);
  685.     class'UIPacket'.static.DecodeInt64(NecessaryGemStoneCount);
  686.     class'UIPacket'.static.DecodeInt(RefineResult);
  687.     Handle_S_EX_VARIATION_RESULT(Option1, Option2, RefineResult);
  688.     return;
  689. }
  690.  
  691. function Handle_S_EX_PUT_INTENSIVE_RESULT_FOR_VARIATION_MAKE(int targetItemServerID, int TargetItemClassID, int insertResult)
  692. {
  693.     local ItemInfo targetItem;
  694.  
  695.     class'UIDATA_INVENTORY'.static.FindItem(targetItemServerID, targetItem);
  696.     AddItemStone(targetItem);
  697.     return;
  698. }
  699.  
  700. function Handle_S_EX_VARIATION_RESULT(int Option1, int Option2, int RefineResult)
  701. {
  702.     local ItemInfo iInfo;
  703.  
  704.     switch(RefineResult)
  705.     {
  706.        
  707.         case 1:
  708.             SetState(4);
  709.            
  710.             if(GetItemInfoTarget(iInfo))
  711.             {
  712.                
  713.                 if(IsSupportedResultChoice())
  714.                 {
  715.                     SetNewResultInfo(false, iInfo.Id.ServerID, Option1, Option2);
  716.                    
  717.                     if((iInfo.RefineryOp1 == 0) && iInfo.RefineryOp1 == 0)
  718.                     {
  719.                         newOptionBtn.SetEnable(false);
  720.                         Rq_C_EX_APPLY_VARIATION_OPTION(iInfo.Id.ServerID, Option1, Option2);                        
  721.                     }
  722.                     else
  723.                     {
  724.                         UpdateStateNewResult();
  725.                     }                    
  726.                 }
  727.                 else
  728.                 {
  729.                     iInfo.RefineryOp1 = Option1;
  730.                     iInfo.RefineryOp2 = Option2;
  731.                 }
  732.                 m_ResultBoxItem.ShowWindow();
  733.                 m_ResultBoxItem.Clear();
  734.                 m_ResultBoxItem.AddItem(iInfo);
  735.                 m_DragBoxItem2.Clear();
  736.                 m_DragBoxItem2.AddItem(iInfo);
  737.                 AddRefineryText();
  738.             }
  739.            
  740.             if(!IsSupportedResultChoice())
  741.             {
  742.                 PlayResultQualityAnimation(GetOptionQuality(Option2));
  743.             }
  744.            
  745.             break;
  746.        
  747.         case 0:
  748.             SetHideWindow();
  749.            
  750.             break;
  751.        
  752.         default:
  753.             break;
  754.     }
  755.     return;
  756. }
  757.  
  758. function Rs_S_EX_APPLY_VARIATION_OPTION()
  759. {
  760.     local _S_EX_APPLY_VARIATION_OPTION packet;
  761.     local bool IsSuccess;
  762.     local ItemInfo iInfo;
  763.     local int Quality;
  764.  
  765.    
  766.     if(!class'UIPacket'.static.Decode_S_EX_APPLY_VARIATION_OPTION(packet))
  767.     {
  768.         return;
  769.     }
  770.     IsSuccess = bool(packet.bResult);
  771.    
  772.     if(IsSuccess == true)
  773.     {
  774.        
  775.         if(GetItemInfoTarget(iInfo))
  776.         {
  777.             SetNewResultInfo(true, packet.nVariationItemSID, 0, 0);
  778.             iInfo.RefineryOp1 = packet.nItemOption1;
  779.             iInfo.RefineryOp2 = packet.nItemOption2;
  780.             m_ResultBoxItem.ShowWindow();
  781.             m_ResultBoxItem.Clear();
  782.             m_ResultBoxItem.AddItem(iInfo);
  783.             m_DragBoxItem2.Clear();
  784.             m_DragBoxItem2.AddItem(iInfo);
  785.             UpdateStateNewResult();
  786.             AddRefineryText();
  787.             PlayNewOptionApplyEffect(true);
  788.             PlayResultQualityAnimation(GetOptionQuality(packet.nItemOption2));
  789.             getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(13659));
  790.         }        
  791.     }
  792.     else
  793.     {
  794.         Debug("S_EX_APPLY_VARIATION_OPTION FAIL");
  795.     }
  796.     return;
  797. }
  798.  
  799. function SetState(RefineryWnd.type_State State)
  800. {
  801.     CurrentState = State;
  802.     ResetAnims();
  803.     switch(State)
  804.     {
  805.        
  806.         case 0:
  807.             SetStateStone();
  808.            
  809.             break;
  810.        
  811.         case 1:
  812.             SetStateTarget();
  813.            
  814.             break;
  815.        
  816.         case 2:
  817.             SetStateReady();
  818.            
  819.             break;
  820.        
  821.         case 3:
  822.             SetStateIng();
  823.            
  824.             break;
  825.      
  826.         case 4:
  827.             SetStateResult();
  828.            
  829.             break;
  830.        
  831.         default:
  832.             break;
  833.     }
  834.     SetHighLightsEmpty();
  835.     SetButtonSetting();
  836.     SetInstructionText();
  837.     return;
  838. }
  839.  
  840. function SetStateStone()
  841. {
  842.     SetStones();
  843.     m_DragBoxResult.HideWindow();
  844.     ItemListWindow.ShowWindow();
  845.     m_DragboxItem1.Clear();
  846.     iObject.setId();
  847.     m_DragBoxItem2.Clear();
  848.     m_DragBox1.ShowWindow();
  849.     m_DragBox2.ShowWindow();
  850.     ClearRefineryText();
  851.     ClearNewRefineryText();
  852.     SetNewResultInfo(false, 0, 0, 0);
  853.     DelOptionList();
  854.     return;
  855. }
  856.  
  857. function SetStateTarget()
  858. {
  859.     SetTargetItems();
  860.     m_DragBoxResult.HideWindow();
  861.     ItemListWindow.ShowWindow();
  862.     m_DragBox1.ShowWindow();
  863.     m_DragBox2.ShowWindow();
  864.     DelOptionList();
  865.     return;
  866. }
  867.  
  868. function SetStateReady()
  869. {
  870.     m_DragBoxResult.HideWindow();
  871.     ItemListWindow.HideWindow();
  872.     m_hRefineryWndRefineryProgress.Stop();
  873.     m_hRefineryWndRefineryProgress.Reset();
  874.     m_DragBox1.ShowWindow();
  875.     m_DragBox2.ShowWindow();
  876.     SetNewResultInfo(false, 0, 0, 0);
  877.     UpdateStateNewResult();
  878.     bHideAndInventoryShow = false;
  879.     return;
  880. }
  881.  
  882. function SetStateIng()
  883. {
  884.     MakeProgressTween();
  885.     m_DragBoxResult.HideWindow();
  886.     ItemListWindow.HideWindow();
  887.     m_RefineAnim.ShowWindow();
  888.     m_RefineAnim.Stop();
  889.     m_RefineAnim.Play();
  890.     m_hRefineryWndRefineryProgress.Stop();
  891.     m_hRefineryWndRefineryProgress.Reset();
  892.     m_hRefineryWndRefineryProgress.Start();
  893.     PlaySound("Itemsound2.smelting.smelting_loding");
  894.     m_DragBox1.ShowWindow();
  895.     m_DragBox2.ShowWindow();
  896.     DwarfPlayAnimation();
  897.     return;
  898. }
  899.  
  900. function SetStateResult()
  901. {
  902.     MakeShakeTween();
  903.     m_DragBoxResult.ShowWindow();
  904.     ItemListWindow.HideWindow();
  905.     m_DragBox1.HideWindow();
  906.     m_DragBox2.HideWindow();
  907.     return;
  908. }
  909.  
  910. function UpdateStateNewResult()
  911. {
  912.     local string strDesc1, strDesc2, strDesc3, descAll;
  913.     local int ColorR, ColorG, ColorB, Quality, RefineryOp1, RefineryOp2;
  914.  
  915.     local ItemInfo item;
  916.  
  917.    
  918.     if(!IsSupportedResultChoice())
  919.     {
  920.         return;
  921.     }
  922.    
  923.     if(!GetItemInfoTarget(item))
  924.     {
  925.         return;
  926.     }
  927.     RefineryOp1 = newResultInfo.newItemOption1;
  928.     RefineryOp2 = newResultInfo.newItemOption2;
  929.     descAll = "";
  930.    
  931.     if((RefineryOp1 != 0) || RefineryOp2 != 0)
  932.     {
  933.        
  934.         if(RefineryOp2 != 0)
  935.         {
  936.             Quality = GetOptionQuality(RefineryOp2);
  937.             SetNewQuality(Quality);
  938.             ToolTip(GetScript("Tooltip")).GetRefineryColor(Quality, ColorR, ColorG, ColorB);            
  939.         }
  940.         else
  941.         {
  942.            
  943.             if(RefineryOp1 != 0)
  944.             {
  945.                 Quality = GetOptionQuality(RefineryOp1);
  946.                 SetNewQuality(Quality);
  947.                 ToolTip(GetScript("Tooltip")).GetRefineryColor(Quality, ColorR, ColorG, ColorB);
  948.             }
  949.         }
  950.        
  951.         if(RefineryOp1 != 0)
  952.         {
  953.             strDesc1 = "";
  954.             strDesc2 = "";
  955.             strDesc3 = "";
  956.            
  957.             if(class'UIDATA_REFINERYOPTION'.static.GetOptionDescription(RefineryOp1, strDesc1, strDesc2, strDesc3))
  958.             {
  959.                 AddDesc(strDesc1, descAll);
  960.                 AddDesc(strDesc2, descAll);
  961.                 AddDesc(strDesc3, descAll);
  962.             }
  963.         }
  964.        
  965.         if(RefineryOp2 != 0)
  966.         {
  967.             strDesc1 = "";
  968.             strDesc2 = "";
  969.             strDesc3 = "";
  970.            
  971.             if(class'UIDATA_REFINERYOPTION'.static.GetOptionDescription(RefineryOp2, strDesc1, strDesc2, strDesc3))
  972.             {
  973.                 AddDesc(strDesc1, descAll);
  974.                 AddDesc(strDesc2, descAll);
  975.                 AddDesc(strDesc3, descAll);
  976.             }
  977.         }
  978.         newTxtOptions.SetTextColor(GetColor(ColorR, ColorG, ColorB, 255));
  979.         newTxtOptions.SetText(descAll);
  980.        
  981.         if(descAll != "")
  982.         {
  983.             newOptionGradeTex.ShowWindow();
  984.         }
  985.         newOptionBtn.SetEnable(true);
  986.         newOptionBlindWnd.HideWindow();        
  987.     }
  988.     else
  989.     {
  990.         newOptionBtn.SetEnable(false);
  991.         newOptionBlindWnd.ShowWindow();
  992.         ClearNewRefineryText();
  993.         newOptionGradeTex.HideWindow();
  994.     }
  995.     return;
  996. }
  997.  
  998. function PlayNewOptionApplyEffect(bool isPlay)
  999. {
  1000.    
  1001.     if(!IsSupportedResultChoice())
  1002.     {
  1003.         return;
  1004.     }
  1005.    
  1006.     if(isPlay)
  1007.     {
  1008.         newOptionApplyAnimTex.Stop();
  1009.         newOptionApplyAnimTex.SetLoopCount(1);
  1010.         newOptionApplyAnimTex.ShowWindow();
  1011.         newOptionApplyAnimTex.Play();        
  1012.     }
  1013.     else
  1014.     {
  1015.         newOptionApplyAnimTex.Stop();
  1016.         newOptionApplyAnimTex.HideWindow();
  1017.     }
  1018.     return;
  1019. }
  1020.  
  1021. function SetDialogModal(bool isModal)
  1022. {
  1023.    
  1024.     if(!IsSupportedResultChoice())
  1025.     {
  1026.         return;
  1027.     }
  1028.    
  1029.     if(isModal == true)
  1030.     {
  1031.         newDisableWnd.ShowWindow();        
  1032.     }
  1033.     else
  1034.     {
  1035.         newDisableWnd.HideWindow();
  1036.     }
  1037.     return;
  1038. }
  1039.  
  1040. function SetNewResultInfo(bool confirmed, int itemSId, int newOption1, int newOption2)
  1041. {
  1042.     newResultInfo.isConfirm = confirmed;
  1043.     newResultInfo.targetItemSId = itemSId;
  1044.     newResultInfo.newItemOption1 = newOption1;
  1045.     newResultInfo.newItemOption2 = newOption2;
  1046.     return;
  1047. }
  1048.  
  1049. function ShowResultChoiceDialog()
  1050. {
  1051.     DialogShow(1, 0, GetSystemString(14060), string(self));
  1052.     class'DialogBox'.static.Inst().AnchorToOwner(0, 0);
  1053.     class'DialogBox'.static.Inst().__DelegateOnOK__Delegate = OnResultChoiceDialogConfirm;
  1054.     class'DialogBox'.static.Inst().__DelegateOnCancel__Delegate = OnDialogHide;
  1055.     class'DialogBox'.static.Inst().__DelegateOnHide__Delegate = OnDialogHide;
  1056.     class'DialogBox'.static.Inst().SetDefaultAction(2);
  1057.     SetDialogModal(true);
  1058.     return;
  1059. }
  1060.  
  1061. function ShowCloseWndDialog()
  1062. {
  1063.     DialogShow(1, 0, GetSystemString(14061), string(self));
  1064.     class'DialogBox'.static.Inst().AnchorToOwner(0, 0);
  1065.     class'DialogBox'.static.Inst().__DelegateOnOK__Delegate = OnCloseWndDialogConfirm;
  1066.     class'DialogBox'.static.Inst().__DelegateOnCancel__Delegate = OnDialogHide;
  1067.     class'DialogBox'.static.Inst().__DelegateOnHide__Delegate = OnDialogHide;
  1068.     class'DialogBox'.static.Inst().SetDefaultAction(2);
  1069.     SetDialogModal(true);
  1070.     return;
  1071. }
  1072.  
  1073. function ShowResetRefineryDialog()
  1074. {
  1075.     DialogShow(1, 0, GetSystemString(14061), string(self));
  1076.     class'DialogBox'.static.Inst().AnchorToOwner(0, 0);
  1077.     class'DialogBox'.static.Inst().__DelegateOnOK__Delegate = OnResetRefieryDialogConfirm;
  1078.     class'DialogBox'.static.Inst().__DelegateOnCancel__Delegate = OnDialogHide;
  1079.     class'DialogBox'.static.Inst().__DelegateOnHide__Delegate = OnDialogHide;
  1080.     class'DialogBox'.static.Inst().SetDefaultAction(2);
  1081.     SetDialogModal(true);
  1082.     return;
  1083. }
  1084.  
  1085. function bool isPossableInventoryShow()
  1086. {
  1087.    
  1088.     if(((getInstanceUIData().getIsLiveServer() && Me.IsShowWindow()) && newResultInfo.isConfirm == false) && (newResultInfo.newItemOption1 != 0) || newResultInfo.newItemOption2 != 0)
  1089.     {
  1090.         return false;
  1091.     }
  1092.     return true;
  1093.     return;
  1094. }
  1095.  
  1096. function setHideAndInventoryShow(bool bFlag)
  1097. {
  1098.     bHideAndInventoryShow = bFlag;
  1099.     return;
  1100. }
  1101.  
  1102. function NewResultCheckAndCloseWnd()
  1103. {
  1104.    
  1105.     if((newResultInfo.isConfirm == false) && (newResultInfo.newItemOption1 != 0) || newResultInfo.newItemOption2 != 0)
  1106.     {
  1107.         ShowCloseWndDialog();        
  1108.     }
  1109.     else
  1110.     {
  1111.         SetHideWindow();
  1112.     }
  1113.     return;
  1114. }
  1115.  
  1116. function NewResultCheckAndReset()
  1117. {
  1118.    
  1119.     if((newResultInfo.isConfirm == false) && (newResultInfo.newItemOption1 != 0) || newResultInfo.newItemOption2 != 0)
  1120.     {
  1121.         ShowResetRefineryDialog();        
  1122.     }
  1123.     else
  1124.     {
  1125.         SetState(0);
  1126.     }
  1127.     return;
  1128. }
  1129.  
  1130. function SetInstructionText()
  1131. {
  1132.     local int numMsg;
  1133.  
  1134.     switch(CurrentState)
  1135.     {
  1136.        
  1137.         case 0:
  1138.             numMsg = 1958;
  1139.            
  1140.             break;
  1141.        
  1142.         case 1:
  1143.             numMsg = 1957;
  1144.            
  1145.             break;
  1146.        
  1147.         case 2:
  1148.             numMsg = 1984;
  1149.            
  1150.             break;
  1151.        
  1152.         case 3:
  1153.             numMsg = 13276;
  1154.            
  1155.             break;
  1156.        
  1157.         case 4:
  1158.             numMsg = 1962;
  1159.            
  1160.             break;
  1161.        
  1162.         default:
  1163.             break;
  1164.     }
  1165.     m_InstructionText.SetText(GetSystemMessage(numMsg));
  1166.     return;
  1167. }
  1168.  
  1169. function SetButtonSetting()
  1170. {
  1171.     Me.KillTimer(90);
  1172.     switch(CurrentState)
  1173.     {
  1174.        
  1175.         case 0:
  1176.             btnReset.DisableWindow();
  1177.             m_RefineryBtn.DisableWindow();
  1178.             m_RefineryBtn.SetButtonName(1477);
  1179.            
  1180.             break;
  1181.        
  1182.         case 1:
  1183.             btnReset.EnableWindow();
  1184.             m_RefineryBtn.DisableWindow();
  1185.             m_RefineryBtn.SetButtonName(1477);
  1186.            
  1187.             break;
  1188.        
  1189.         case 2:
  1190.             btnReset.EnableWindow();
  1191.            
  1192.             if(canBuy())
  1193.             {
  1194.                 m_RefineryBtn.EnableWindow();                
  1195.             }
  1196.             else
  1197.             {
  1198.                 m_RefineryBtn.DisableWindow();
  1199.             }
  1200.             m_RefineryBtn.SetButtonName(1477);
  1201.            
  1202.             break;
  1203.        
  1204.         case 3:
  1205.             btnReset.DisableWindow();
  1206.             m_RefineryBtn.EnableWindow();
  1207.             m_RefineryBtn.SetButtonName(141);
  1208.            
  1209.             break;
  1210.        
  1211.         case 4:
  1212.             btnReset.EnableWindow();
  1213.             m_RefineryBtn.DisableWindow();
  1214.             Me.SetTimer(90, 500);
  1215.             m_RefineryBtn.SetButtonName(3135);
  1216.            
  1217.             break;
  1218.        
  1219.         default:
  1220.             break;
  1221.     }
  1222.     return;
  1223. }
  1224.  
  1225. function SetHighLightsEmpty()
  1226. {
  1227.     local int i;
  1228.  
  1229.     i = 1;
  1230.     J0x07:
  1231.  
  1232.    
  1233.     if(i < 3)
  1234.     {
  1235.        
  1236.         if(GetItemWindowHandleByIndex(i).GetItemNum() > 0)
  1237.         {
  1238.             GetHighLightSelectedByIndex(i).ShowWindow();            
  1239.         }
  1240.         else
  1241.         {
  1242.             GetHighLightSelectedByIndex(i).HideWindow();
  1243.         }
  1244.         GetHighLightByIndex(i).HideWindow();
  1245.         ++ i;
  1246.        
  1247.         goto J0x07;
  1248.     }
  1249.     switch(CurrentState)
  1250.     {
  1251.        
  1252.         case 0:
  1253.             GetHighLightByIndex(1).ShowWindow();
  1254.            
  1255.             break;
  1256.        
  1257.         case 1:
  1258.             GetHighLightByIndex(2).ShowWindow();
  1259.            
  1260.             break;
  1261.        
  1262.         default:
  1263.             break;
  1264.     }
  1265.     return;
  1266. }
  1267.  
  1268. function RequestRefine()
  1269. {
  1270.     local ItemInfo itemInfoStone, itemInfoTarget;
  1271.  
  1272.    
  1273.     if(!GetItemInfoStone(itemInfoStone))
  1274.     {
  1275.         return;
  1276.     }
  1277.    
  1278.     if(!GetItemInfoTarget(itemInfoTarget))
  1279.     {
  1280.         return;
  1281.     }
  1282.     m_RefineryBtn.DisableWindow();
  1283.     API_RequestRefine(itemInfoTarget.Id, itemInfoStone.Id, UIControlNeedItemScripts[0].GetID(), UIControlNeedItemScripts[0].numNeed);
  1284.     return;
  1285. }
  1286.  
  1287. function HandleClickBtnRefine()
  1288. {
  1289.     local ItemInfo iInfoStone;
  1290.  
  1291.     switch(CurrentState)
  1292.     {
  1293.        
  1294.         case 2:
  1295.             SetState(3);
  1296.            
  1297.             break;
  1298.        
  1299.         case 3:
  1300.             SetCancel();
  1301.            
  1302.             break;
  1303.        
  1304.         case 4:
  1305.            
  1306.             if(!GetItemInfoStone(iInfoStone))
  1307.             {
  1308.                 SetState(0);
  1309.             }
  1310.            
  1311.             if(__NFUN_412__(iInfoStone.ItemNum, (0)))
  1312.             {
  1313.                 SetState(0);                
  1314.             }
  1315.             else
  1316.             {
  1317.                 SetState(2);
  1318.             }
  1319.            
  1320.             break;
  1321.        
  1322.         default:
  1323.             break;
  1324.     }
  1325.     return;
  1326. }
  1327.  
  1328. function OnClickbtnClose()
  1329. {
  1330.     SetHideWindow();
  1331.     return;
  1332. }
  1333.  
  1334. function SetHideWindow()
  1335. {
  1336.     Me.HideWindow();
  1337.     PlaySound("Itemsound2.smelting.smelting_dragout");
  1338.    
  1339.     if(bHideAndInventoryShow)
  1340.     {
  1341.         ExecuteEvent(2631);
  1342.     }
  1343.     return;
  1344. }
  1345.  
  1346. function SetCancel()
  1347. {
  1348.     SetDwaft();
  1349.     SetState(2);
  1350.     return;
  1351. }
  1352.  
  1353. event OnNewOptionBtnClicked()
  1354. {
  1355.     ShowResultChoiceDialog();
  1356.     return;
  1357. }
  1358.  
  1359. event OnResultChoiceDialogConfirm()
  1360. {
  1361.    
  1362.     if((newResultInfo.isConfirm == false) && (newResultInfo.newItemOption1 != 0) || newResultInfo.newItemOption2 != 0)
  1363.     {
  1364.         newOptionBtn.SetEnable(false);
  1365.         Rq_C_EX_APPLY_VARIATION_OPTION(newResultInfo.targetItemSId, newResultInfo.newItemOption1, newResultInfo.newItemOption2);
  1366.     }
  1367.     return;
  1368. }
  1369.  
  1370. event OnCloseWndDialogConfirm()
  1371. {
  1372.     SetHideWindow();
  1373.     return;
  1374. }
  1375.  
  1376. event OnResetRefieryDialogConfirm()
  1377. {
  1378.     SetState(0);
  1379.     return;
  1380. }
  1381.  
  1382. event OnDialogHide()
  1383. {
  1384.     SetDialogModal(false);
  1385.     return;
  1386. }
  1387.  
  1388. function ClearRefineryText()
  1389. {
  1390.     SetQuality(-1);
  1391.     txtOptions.SetText("");
  1392.     return;
  1393. }
  1394.  
  1395. function ClearNewRefineryText()
  1396. {
  1397.    
  1398.     if(!IsSupportedResultChoice())
  1399.     {
  1400.         return;
  1401.     }
  1402.     SetNewQuality(-1);
  1403.     newTxtOptions.SetText("");
  1404.     return;
  1405. }
  1406.  
  1407. function AddRefineryText()
  1408. {
  1409.     local string strDesc1, strDesc2, strDesc3, descAll;
  1410.     local int ColorR, ColorG, ColorB, Quality;
  1411.     local ItemInfo item;
  1412.  
  1413.    
  1414.     if(!GetItemInfoTarget(item))
  1415.     {
  1416.         return;
  1417.     }
  1418.     descAll = "";
  1419.    
  1420.     if((item.RefineryOp1 != 0) || item.RefineryOp2 != 0)
  1421.     {
  1422.        
  1423.         if(__NFUN_412__(item.SlotBitType, (8192)))
  1424.         {
  1425.             Quality = GetOptionQuality(item.RefineryOp1);
  1426.             SetQuality(Quality);
  1427.             ToolTip(GetScript("Tooltip")).GetRefineryColor(Quality, ColorR, ColorG, ColorB);            
  1428.         }
  1429.         else
  1430.         {
  1431.            
  1432.             if(item.RefineryOp2 != 0)
  1433.             {
  1434.                 Quality = GetOptionQuality(item.RefineryOp2);
  1435.                 SetQuality(Quality);
  1436.                 ToolTip(GetScript("Tooltip")).GetRefineryColor(Quality, ColorR, ColorG, ColorB);
  1437.             }
  1438.         }
  1439.        
  1440.         if(item.RefineryOp1 != 0)
  1441.         {
  1442.             strDesc1 = "";
  1443.             strDesc2 = "";
  1444.             strDesc3 = "";
  1445.            
  1446.             if(class'UIDATA_REFINERYOPTION'.static.GetOptionDescription(item.RefineryOp1, strDesc1, strDesc2, strDesc3))
  1447.             {
  1448.                 AddDesc(strDesc1, descAll);
  1449.                 AddDesc(strDesc2, descAll);
  1450.                 AddDesc(strDesc3, descAll);
  1451.             }
  1452.         }
  1453.        
  1454.         if(item.RefineryOp2 != 0)
  1455.         {
  1456.             strDesc1 = "";
  1457.             strDesc2 = "";
  1458.             strDesc3 = "";
  1459.            
  1460.             if(class'UIDATA_REFINERYOPTION'.static.GetOptionDescription(item.RefineryOp2, strDesc1, strDesc2, strDesc3))
  1461.             {
  1462.                 AddDesc(strDesc1, descAll);
  1463.                 AddDesc(strDesc2, descAll);
  1464.                 AddDesc(strDesc3, descAll);
  1465.             }
  1466.         }
  1467.        
  1468.         if(__NFUN_412__(item.SlotBitType, (8192)))
  1469.         {
  1470.             Quality = GetOptionQuality(item.RefineryOp2);
  1471.             SetQuality(Quality);
  1472.             ToolTip(GetScript("Tooltip")).GetRefineryColor(Quality, ColorR, ColorG, ColorB);
  1473.         }
  1474.         txtOptions.SetTextColor(GetColor(ColorR, ColorG, ColorB, 255));
  1475.         txtOptions.SetText(descAll);
  1476.        
  1477.         if(descAll != "")
  1478.         {
  1479.             optionGradeTexture.ShowWindow();
  1480.         }
  1481.        
  1482.         if(IsSupportedResultChoice())
  1483.         {
  1484.            
  1485.             if(descAll != "")
  1486.             {
  1487.                 preOptionCheckTex.ShowWindow();
  1488.                 optionBlindWnd.HideWindow();
  1489.             }
  1490.         }        
  1491.     }
  1492.     else
  1493.     {
  1494.         optionGradeTexture.HideWindow();
  1495.        
  1496.         if(IsSupportedResultChoice())
  1497.         {
  1498.             preOptionCheckTex.HideWindow();
  1499.             optionBlindWnd.ShowWindow();
  1500.         }
  1501.     }
  1502.     return;
  1503. }
  1504.  
  1505. function SetQuality(int Quality)
  1506. {
  1507.     optionGradeTexture.SetTexture(GetGradeTextureByQuality(Quality));
  1508.    
  1509.     if(Quality <= 0)
  1510.     {
  1511.         optionGradeTexture.HideWindow();        
  1512.     }
  1513.     else
  1514.     {
  1515.         optionGradeTexture.ShowWindow();
  1516.     }
  1517.     return;
  1518. }
  1519.  
  1520. function SetNewQuality(int Quality)
  1521. {
  1522.    
  1523.     if(!IsSupportedResultChoice())
  1524.     {
  1525.         return;
  1526.     }
  1527.     newOptionGradeTex.SetTexture(GetGradeTextureByQuality(Quality));
  1528.    
  1529.     if(Quality <= 0)
  1530.     {
  1531.         newOptionGradeTex.HideWindow();        
  1532.     }
  1533.     else
  1534.     {
  1535.         newOptionGradeTex.ShowWindow();
  1536.     }
  1537.     return;
  1538. }
  1539.  
  1540. function string GetGradeTextureByQuality(int Quality)
  1541. {
  1542.     switch(Quality)
  1543.     {
  1544.        
  1545.         case 1:
  1546.             return "L2UI_EPIC.RefineryWnd.RefineryWnd_Frame_Yellow";
  1547.            
  1548.             break;
  1549.        
  1550.         case 2:
  1551.             return "L2UI_EPIC.RefineryWnd.RefineryWnd_Frame_Blue";
  1552.            
  1553.             break;
  1554.        
  1555.         case 3:
  1556.             return "L2UI_EPIC.RefineryWnd.RefineryWnd_Frame_purple";
  1557.            
  1558.             break;
  1559.        
  1560.         case 4:
  1561.             return "L2UI_EPIC.RefineryWnd.RefineryWnd_Frame_Red";
  1562.            
  1563.             break;
  1564.        
  1565.         default:
  1566.             return "L2UI_EPIC.RefineryWnd.RefineryWnd_Frame_Red";
  1567.             break;
  1568.     }    
  1569. }
  1570.  
  1571. function ResetAnims()
  1572. {
  1573.     l2uiTweenScript.StopTween(m_WindowName, 1);
  1574.     l2uiTweenScript.StopTween(m_WindowName, 2);
  1575.     l2uiTweenScript.StopShake(m_WindowName, 101);
  1576.     m_DragBox1.ShowWindow();
  1577.     m_DragBox1.SetAnchor(m_WindowName $ ".MainBg", "CenterCenter", "CenterCenter", -78, 0);
  1578.     m_DragBox1.ClearAnchor();
  1579.     m_DragBox1.SetAlpha(255);
  1580.     m_DragBox2.ShowWindow();
  1581.     m_DragBox2.SetAnchor(m_WindowName $ ".MainBg", "CenterCenter", "CenterCenter", 78, 0);
  1582.     m_DragBox2.ClearAnchor();
  1583.     m_DragBox2.SetAlpha(255);
  1584.     m_RefineAnim.HideWindow();
  1585.     m_RefineAnim.Stop();
  1586.     m_hRefineryWndRefineryProgress.SetPos(0);
  1587.     m_hRefineryWndRefineryProgress.Stop();
  1588.     m_ResultBoxItem.HideWindow();
  1589.     m_ResultAnimation1.HideWindow();
  1590.     m_ResultAnimation2.HideWindow();
  1591.     m_ResultAnimation3.HideWindow();
  1592.     m_ResultAnimation4.HideWindow();
  1593.     return;
  1594. }
  1595.  
  1596. function MakeProgressTween()
  1597. {
  1598.     local TweenObject tweenObj0;
  1599.  
  1600.     ResetAnims();
  1601.     tweenObj0.Owner = m_WindowName;
  1602.     tweenObj0.Id = 1;
  1603.     tweenObj0.Target = m_DragBox1;
  1604.     tweenObj0.Duration = 1000;
  1605.     tweenObj0.MoveX = 78;
  1606.     tweenObj0.ease = l2uiTweenScript.0;
  1607.     l2uiTweenScript.AddTweenObject(tweenObj0);
  1608.     tweenObj0.Id = 2;
  1609.     tweenObj0.Target = m_DragBox2;
  1610.     tweenObj0.MoveX = -tweenObj0.MoveX;
  1611.     tweenObj0.ease = l2uiTweenScript.0;
  1612.     l2uiTweenScript.AddTweenObject(tweenObj0);
  1613.     return;
  1614. }
  1615.  
  1616. function MakeTweenAlpha(WindowHandle targetWindow, int tweenID)
  1617. {
  1618.     local TweenObject tweenObj0;
  1619.  
  1620.     targetWindow.SetAlpha(0);
  1621.     tweenObj0.Owner = m_WindowName;
  1622.     tweenObj0.Id = tweenID;
  1623.     tweenObj0.Target = targetWindow;
  1624.     tweenObj0.Duration = 500;
  1625.     tweenObj0.Alpha = 255;
  1626.     tweenObj0.ease = l2uiTweenScript.1;
  1627.     l2uiTweenScript.AddTweenObject(tweenObj0);
  1628.     return;
  1629. }
  1630.  
  1631. function MakeShakeTween()
  1632. {
  1633.     local ShakeObject shakeObj;
  1634.  
  1635.     shakeObj.Owner = m_WindowName;
  1636.     shakeObj.Target = Me;
  1637.     shakeObj.Duration = 500;
  1638.     shakeObj.shakeSize = 4;
  1639.     shakeObj.Direction = l2uiTweenScript.1;
  1640.     shakeObj.Id = 101;
  1641.     l2uiTweenScript.StartShakeObject(shakeObj);
  1642.     return;
  1643. }
  1644.  
  1645. function PlayResultQualityAnimation(int Grade)
  1646. {
  1647.     switch(Grade)
  1648.     {
  1649.        
  1650.         case 1:
  1651.             m_ResultAnimation1.ShowWindow();
  1652.             PlaySound("ItemSound2.smelting.smelting_finalB");
  1653.             m_ResultAnim1.Stop();
  1654.             m_ResultAnim1.Play();
  1655.            
  1656.             break;
  1657.        
  1658.         case 2:
  1659.             m_ResultAnimation2.ShowWindow();
  1660.             PlaySound("ItemSound2.smelting.smelting_finalC");
  1661.             m_ResultAnim2.Stop();
  1662.             m_ResultAnim2.Play();
  1663.            
  1664.             break;
  1665.        
  1666.         case 3:
  1667.             m_ResultAnimation3.ShowWindow();
  1668.             PlaySound("ItemSound2.smelting.smelting_finalD");
  1669.             m_ResultAnim3.Stop();
  1670.             m_ResultAnim3.Play();
  1671.            
  1672.             break;
  1673.        
  1674.         case 4:
  1675.             m_ResultAnimation4.ShowWindow();
  1676.             PlaySound("ItemSound2.smelting.smelting_finalD");
  1677.             m_ResultAnim4.Stop();
  1678.             m_ResultAnim4.Play();
  1679.            
  1680.             break;
  1681.        
  1682.         default:
  1683.             break;
  1684.     }
  1685.     return;
  1686. }
  1687.  
  1688. function SetDwaft()
  1689. {
  1690.     m_ObjectViewport.SetNPCInfo(19673);
  1691.     m_ObjectViewport.ShowNPC(0.1);
  1692.     m_ObjectViewport.SpawnNPC();
  1693.     m_ObjectViewport.ShowWindow();
  1694.     return;
  1695. }
  1696.  
  1697. function DwarfPlayAnimation()
  1698. {
  1699.     local int randNum;
  1700.  
  1701.     randNum = Rand(10);
  1702.    
  1703.     if(randNum < 2)
  1704.     {
  1705.         m_ObjectViewport.PlayAnimation(2);        
  1706.     }
  1707.     else
  1708.     {
  1709.         m_ObjectViewport.PlayAnimation(1);
  1710.     }
  1711.     return;
  1712. }
  1713.  
  1714. function bool GetItemInfoStone(out ItemInfo iInfo)
  1715. {
  1716.     return GetItemInfoByIndex(1, iInfo);
  1717.     return;
  1718. }
  1719.  
  1720. function bool GetItemInfoTarget(out ItemInfo iInfo)
  1721. {
  1722.     return GetItemInfoByIndex(2, iInfo);
  1723.     return;
  1724. }
  1725.  
  1726. function bool GetItemInfoByIndex(int Index, out ItemInfo iInfo)
  1727. {
  1728.     return GetItemWindowHandleByIndex(Index).GetItem(0, iInfo);
  1729.     return;
  1730. }
  1731.  
  1732. function int GetOptionQuality(int OptionID)
  1733. {
  1734.     local int Quality;
  1735.  
  1736.     Quality = class'UIDATA_REFINERYOPTION'.static.GetQuality(OptionID);
  1737.    
  1738.     if(0 >= Quality)
  1739.     {
  1740.         Quality = 1;        
  1741.     }
  1742.     else
  1743.     {
  1744.        
  1745.         if(4 < Quality)
  1746.         {
  1747.             Quality = 4;
  1748.         }
  1749.     }
  1750.     return Quality;
  1751.     return;
  1752. }
  1753.  
  1754. function ItemWindowHandle GetItemWindowHandleByIndex(int Index)
  1755. {
  1756.     return GetItemWindowHandle(((m_WindowName $ ".ItemDragBox") $ string(Index)) $ "Wnd.ItemDragBox");
  1757.     return;
  1758. }
  1759.  
  1760. function WindowHandle GetHighLightByIndex(int Index)
  1761. {
  1762.     return GetWindowHandle(((m_WindowName $ ".ItemDragBox") $ string(Index)) $ "Wnd.DropHighlight");
  1763.     return;
  1764. }
  1765.  
  1766. function WindowHandle GetHighLightSelectedByIndex(int Index)
  1767. {
  1768.     return GetWindowHandle(((m_WindowName $ ".ItemDragBox") $ string(Index)) $ "Wnd.SelectedItemHighlight");
  1769.     return;
  1770. }
  1771.  
  1772. function HandleUpdateItemStone(optional array<ItemInfo> iInfo, optional int Index)
  1773. {
  1774.     local ItemInfo iInfoStone;
  1775.  
  1776.     iInfoStone = iInfo[0];
  1777.     m_DragboxItem1.Clear();
  1778.    
  1779.     if(__NFUN_412__(iInfoStone.ItemNum, (0)))
  1780.     {
  1781.         switch(CurrentState)
  1782.         {
  1783.            
  1784.             case 4:
  1785.                 iObject.setId();
  1786.                
  1787.                 break;
  1788.            
  1789.             default:
  1790.                 SetState(0);
  1791.                 break;
  1792.         }        
  1793.     }
  1794.     else
  1795.     {
  1796.         iInfoStone.bShowCount = true;
  1797.         m_DragboxItem1.AddItem(iInfoStone);
  1798.     }
  1799.     return;
  1800. }
  1801.  
  1802. function PeeItemUpdated(UIControlNeedItem script)
  1803. {
  1804.     switch(CurrentState)
  1805.     {
  1806.        
  1807.         case 3:
  1808.            
  1809.             if(!canBuy())
  1810.             {
  1811.                 SetState(2);
  1812.             }
  1813.            
  1814.             break;
  1815.        
  1816.         default:
  1817.             SetButtonSetting();
  1818.            
  1819.             break;
  1820.             break;
  1821.     }
  1822.     return;
  1823. }
  1824.  
  1825. function bool canBuy()
  1826. {
  1827.     return UIControlNeedItemScripts[0].canBuy() && UIControlNeedItemScripts[1].canBuy();
  1828.     return;
  1829. }
  1830.  
  1831. function bool IsSupportedResultChoice()
  1832. {
  1833.    
  1834.     if(getInstanceUIData().getIsLiveServer())
  1835.     {
  1836.         return true;
  1837.     }
  1838.     return false;
  1839.     return;
  1840. }
  1841.  
  1842. function AddDesc(string Desc, out string descAll)
  1843. {
  1844.    
  1845.     if(Desc == "")
  1846.     {
  1847.         return;
  1848.     }
  1849.    
  1850.     if(descAll != "")
  1851.     {
  1852.         descAll = (descAll $ "\\n") $ Desc;        
  1853.     }
  1854.     else
  1855.     {
  1856.         descAll = Desc;
  1857.     }
  1858.     return;
  1859. }
  1860.  
  1861. function DelOptionList()
  1862. {
  1863.     RefineryWndOptionScript.DelIds();
  1864.     return;
  1865. }
  1866.  
  1867. function SetOptionList()
  1868. {
  1869.     local ItemInfo iInfoStone, iInfoTarget;
  1870.    
  1871.     if(!GetItemInfoStone(iInfoStone))
  1872.     {
  1873.         DelOptionList();
  1874.         return;
  1875.     }    
  1876.     if(!GetItemInfoTarget(iInfoTarget))
  1877.     {
  1878.         DelOptionList();
  1879.         return;
  1880.     }
  1881.     RefineryWndOptionScript.SetIDs(iInfoStone.Id.ClassID, iInfoTarget.Id.ClassID);
  1882.     return;
  1883. }
  1884.  
  1885. function OnReceivedCloseUI()
  1886. {
  1887.    
  1888.     if(int(CurrentState) == int(3))
  1889.     {
  1890.         SetCancel();        
  1891.     }
  1892.     else
  1893.     {        
  1894.         if(IsSupportedResultChoice())
  1895.         {
  1896.             NewResultCheckAndCloseWnd();            
  1897.         }
  1898.         else
  1899.         {
  1900.             SetHideWindow();
  1901.         }
  1902.     }
  1903.     return;
  1904. }
  1905.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement