Advertisement
AlisaCodeDragon

RefineryWndOption.uc

May 8th, 2023
1,400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class RefineryWndOption extends UICommonAPI;
  2.  
  3. var string m_WindowName;
  4. var WindowHandle Me;
  5. var WindowHandle RefineryWndProbability;
  6. var RichListCtrlHandle List_ListCtrl;
  7. var RichListCtrlHandle ProbabilityList_ListCtrl;
  8. var TextBoxHandle txtInstruction;
  9. var ButtonHandle DetailInfo_BTN;
  10.  
  11. function OnLoad()
  12. {
  13.     Initialize();
  14.     return;
  15. }
  16.  
  17. function Initialize()
  18. {
  19.     m_WindowName = getCurrentWindowName(string(self));
  20.     Me = GetWindowHandle(m_WindowName);
  21.     List_ListCtrl = GetRichListCtrlHandle(m_WindowName $ ".List_ListCtrl");
  22.     txtInstruction = GetTextBoxHandle(m_WindowName $ ".txtInstruction");
  23.     RefineryWndProbability = GetWindowHandle(m_WindowName $ ".RefineryWndProbability");
  24.     ProbabilityList_ListCtrl = GetRichListCtrlHandle(m_WindowName $ ".ProbabilityList_ListCtrl");
  25.     DetailInfo_BTN = GetButtonHandle(m_WindowName $ ".DetailInfo_BTN");
  26.     List_ListCtrl.SetSelectable(false);
  27.     List_ListCtrl.SetAppearTooltipAtMouseX(true);
  28.     List_ListCtrl.SetSelectedSelTooltip(false);
  29.     ProbabilityList_ListCtrl.SetSelectable(false);
  30.     ProbabilityList_ListCtrl.SetAppearTooltipAtMouseX(true);
  31.     ProbabilityList_ListCtrl.SetSelectedSelTooltip(false);
  32.     toggleProbability(false);
  33.     return;
  34. }
  35.  
  36. function toggleProbability(bool bProbability)
  37. {
  38.    
  39.     if(bProbability)
  40.     {
  41.         RefineryWndProbability.ShowWindow();
  42.         List_ListCtrl.HideWindow();
  43.         txtInstruction.HideWindow();
  44.         DetailInfo_BTN.SetButtonName(13959);
  45.         updateProbabilityList();        
  46.     }
  47.     else
  48.     {
  49.         RefineryWndProbability.HideWindow();
  50.         List_ListCtrl.ShowWindow();
  51.         DetailInfo_BTN.SetButtonName(13960);
  52.        
  53.         if(List_ListCtrl.GetRecordCount() > 0)
  54.         {
  55.             txtInstruction.HideWindow();            
  56.         }
  57.         else
  58.         {
  59.             txtInstruction.ShowWindow();
  60.         }
  61.     }
  62.     return;
  63. }
  64.  
  65. function updateProbabilityList()
  66. {
  67.     local ItemInfo stoneInfo, TargetInfo;
  68.     local array<VariationProbUIData> Variation1, Variation2;
  69.     local int i, N;
  70.     local string oDesc1, oDesc2, oDesc3, descAll, probabilityStr, OptionStr;
  71.  
  72.     RefineryWnd(GetScript("RefineryWnd")).GetItemInfoStone(stoneInfo);
  73.     RefineryWnd(GetScript("RefineryWnd")).GetItemInfoTarget(TargetInfo);
  74.     Variation1.Length = 0;
  75.     Variation2.Length = 0;
  76.     class'RefineryAPI'.static.GetOptionProbability(stoneInfo.Id.ClassID, TargetInfo.Id.ClassID, Variation1, Variation2);
  77.     ProbabilityList_ListCtrl.DeleteAllItem();
  78.    
  79.     if(Variation1.Length > 0)
  80.     {
  81.         OptionStr = "1" $ GetSystemString(397);
  82.        
  83.         if((int(GetLanguage()) == int(8)) || int(GetLanguage()) == int(9))
  84.         {
  85.             OptionStr = GetSystemString(397) @ "1";
  86.         }
  87.         i = 0;
  88.         J0x107:
  89.  
  90.        
  91.         if(i < Variation1.Length)
  92.         {
  93.            
  94.             if(i == 0)
  95.             {
  96.                 ProbabilityList_ListCtrl.InsertRecord(makeTitleListItem(OptionStr, ""));
  97.             }
  98.             N = 0;
  99.             J0x145:
  100.  
  101.            
  102.             if(N < Variation1[i].Options.Length)
  103.             {
  104.                 class'RefineryAPI'.static.GetOptionDescByOptionID(Variation1[i].Options[N].OptionID, oDesc1, oDesc2, oDesc3);
  105.                
  106.                 if(oDesc1 != "")
  107.                 {
  108.                     descAll = oDesc1;
  109.                 }
  110.              
  111.                 if(oDesc2 != "")
  112.                 {
  113.                     descAll = (descAll $ ",") $ oDesc2;
  114.                 }
  115.                
  116.                 if(oDesc3 != "")
  117.                 {
  118.                     descAll = (descAll $ ",") $ oDesc3;
  119.                 }
  120.                 descAll = Locs(descAll, "\\n", " ", false);
  121.                 probabilityStr = getInstanceL2Util().CutFloatIntByString(Variation1[i].Options[N].Probablity);
  122.                 ProbabilityList_ListCtrl.InsertRecord(makeRecordProbability(descAll, probabilityStr));
  123.                 ++ N;
  124.                
  125.                 goto J0x145;
  126.             }
  127.             ++ i;
  128.            
  129.             goto J0x107;
  130.         }
  131.     }
  132.    
  133.     if(Variation2.Length > 0)
  134.     {
  135.         OptionStr = "2" $ GetSystemString(397);
  136.        
  137.         if((int(GetLanguage()) == int(8)) || int(GetLanguage()) == int(9))
  138.         {
  139.             OptionStr = GetSystemString(397) @ "2";
  140.         }
  141.         i = 0;
  142.         J0x2D2:
  143.  
  144.        
  145.         if(i < Variation2.Length)
  146.         {
  147.            
  148.             if(i == 0)
  149.             {
  150.                 ProbabilityList_ListCtrl.InsertRecord(makeTitleListItem(OptionStr, ""));
  151.             }
  152.             N = 0;
  153.             J0x310:
  154.  
  155.            
  156.             if(N < Variation2[i].Options.Length)
  157.             {
  158.                 class'RefineryAPI'.static.GetOptionDescByOptionID(Variation2[i].Options[N].OptionID, oDesc1, oDesc2, oDesc3);
  159.                
  160.                 if(oDesc1 != "")
  161.                 {
  162.                     descAll = oDesc1;
  163.                 }
  164.                
  165.                 if(oDesc2 != "")
  166.                 {
  167.                     descAll = (descAll $ ", ") $ oDesc2;
  168.                 }
  169.                
  170.                 if(oDesc3 != "")
  171.                 {
  172.                     descAll = (descAll $ ", ") $ oDesc3;
  173.                 }
  174.                 descAll = Locs(descAll, "\\n", " ", false);
  175.                 probabilityStr = getInstanceL2Util().CutFloatIntByString(Variation2[i].Options[N].Probablity);
  176.                 ProbabilityList_ListCtrl.InsertRecord(makeRecordProbability(descAll, probabilityStr));
  177.                 ++ N;
  178.                
  179.                 goto J0x310;
  180.             }
  181.             ++ i;
  182.            
  183.             goto J0x2D2;
  184.         }
  185.     }
  186.     return;
  187. }
  188.  
  189. function RichListCtrlRowData makeRecordProbability(string Text, string percentStr)
  190. {
  191.     local RichListCtrlRowData RowData;
  192.     local string textShort;
  193.  
  194.     textShort = Text;
  195.     RowData.cellDataList.Length = 2;
  196.     textShort = makeShortStringByPixel(Text, 210, "..");
  197.    
  198.     if(textShort != Text)
  199.     {
  200.         RowData.szReserved = Text;
  201.     }
  202.     addRichListCtrlString(RowData.cellDataList[0].drawitems, textShort, GTColor().White, false, 0, 0);
  203.     addRichListCtrlString(RowData.cellDataList[1].drawitems, percentStr, GTColor().White, false, 20, 0);
  204.     return RowData;
  205.     return;
  206. }
  207.  
  208. function RichListCtrlRowData makeTitleListItem(string Str, string percentStr)
  209. {
  210.     local Color applyColor;
  211.     local RichListCtrlRowData RowData;
  212.  
  213.     RowData.cellDataList.Length = 2;
  214.     RowData.sOverlayTex = "L2UI_EPIC.DethroneWnd.List_HeaderBg_Blue";
  215.     applyColor = GTColor().BrightWhite;
  216.     addRichListCtrlString(RowData.cellDataList[0].drawitems, Str, applyColor, false, 0, 0);
  217.     addRichListCtrlString(RowData.cellDataList[1].drawitems, percentStr, GTColor().White, false, 20, 0);
  218.     RowData.OverlayTexU = 635;
  219.     RowData.OverlayTexV = 26;
  220.     return RowData;
  221.     return;
  222. }
  223.  
  224. function DelIds()
  225. {
  226.     List_ListCtrl.DeleteAllItem();
  227.     txtInstruction.ShowWindow();
  228.     toggleProbability(false);
  229.     return;
  230. }
  231.  
  232. function SetIDs(int stoneClassID, int targetClassID)
  233. {
  234.     local array<string> Options, optionsDetail;
  235.     local int i, j;
  236.  
  237.     API_GetOptionDesc(stoneClassID, targetClassID, Options);
  238.     i = 0;
  239.     J0x1C:
  240.  
  241.    
  242.     if(i < Options.Length)
  243.     {
  244.         Debug("SetList" @ Options[i]);
  245.         ++ i;
  246.        
  247.         goto J0x1C;
  248.     }
  249.     List_ListCtrl.DeleteAllItem();
  250.     i = 0;
  251.     J0x68:
  252.  
  253.    
  254.     if(i < Options.Length)
  255.     {
  256.         optionsDetail.Length = 0;
  257.         StringIntoArray(Options[i], "\\n", optionsDetail);
  258.        
  259.         if(optionsDetail.Length > 0)
  260.         {
  261.             setList(optionsDetail, i + 1);
  262.         }
  263.         ++ i;
  264.        
  265.         goto J0x68;
  266.     }
  267.     return;
  268. }
  269.  
  270. function setList(array<string> Options, int Quality)
  271. {
  272.     local int i;
  273.  
  274.     i = 0;
  275.     J0x07:
  276.  
  277.    
  278.     if(i < Options.Length)
  279.     {
  280.        
  281.         if(Right(Options[i], 1) == "\\")
  282.         {
  283.             Options[i] = Left(Options[i], Len(Options[i]) - 1);
  284.         }
  285.        
  286.         if(Options[i] != "")
  287.         {
  288.             List_ListCtrl.InsertRecord(makeRecord(Options[i], Quality));
  289.         }
  290.         ++ i;
  291.        
  292.         goto J0x07;
  293.     }
  294.    
  295.     if(RefineryWndProbability.IsShowWindow())
  296.     {
  297.         toggleProbability(false);        
  298.     }
  299.     else
  300.     {
  301.         toggleProbability(true);
  302.     }
  303.     return;
  304. }
  305.  
  306. function Toggle()
  307. {
  308.    
  309.     if(Me.IsShowWindow())
  310.     {
  311.         Me.HideWindow();        
  312.     }
  313.     else
  314.     {
  315.         Me.ShowWindow();
  316.         Me.SetFocus();
  317.     }
  318.     return;
  319. }
  320.  
  321. event OnClickButton(string strID)
  322. {
  323.     Debug("OnClickButton" @ strID);
  324.    
  325.     if(strID == "DetailInfo_BTN")
  326.     {
  327.        
  328.         if(RefineryWndProbability.IsShowWindow())
  329.         {
  330.             toggleProbability(false);            
  331.         }
  332.         else
  333.         {
  334.             toggleProbability(true);
  335.         }
  336.     }
  337.     return;
  338. }
  339.  
  340. function RichListCtrlRowData makeRecord(string Option, int Quality)
  341. {
  342.     local RichListCtrlRowData Record;
  343.     local Color tmpTextColor;
  344.     local string optionResult;
  345.     local int R, G, B;
  346.  
  347.     Record.cellDataList.Length = 1;
  348.     ToolTip(GetScript("Tooltip")).GetRefineryColor(Quality, R, G, B);
  349.     tmpTextColor = GetColor(R, G, B, 255);
  350.     optionResult = makeShortStringByPixel(Option, 320, "..");
  351.    
  352.     if(optionResult != Option)
  353.     {
  354.         Record.szReserved = Option;
  355.     }
  356.     addRichListCtrlString(Record.cellDataList[0].drawitems, optionResult, tmpTextColor, false);
  357.     return Record;
  358.     return;
  359. }
  360.  
  361. function bool API_GetOptionDesc(int TargetItemClassID, int targetClassID, out array<string> Options)
  362. {
  363.     local string str1, str2, str3, str4;
  364.     local bool optionExist;
  365.  
  366.     optionExist = class'RefineryAPI'.static.GetOptionDesc(TargetItemClassID, targetClassID, str1, str2, str3, str4);
  367.     Options[0] = str1;
  368.     Options[1] = str2;
  369.     Options[2] = str3;
  370.     Options[3] = str4;
  371.     return optionExist;
  372.     return;
  373. }
  374.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement