class MultiSellWnd extends UICommonAPI;
const MAX_BUY = 9999;
const MULTISELLWND_DIALOG_OK = 1122;
const DIALOG_ASK_PRICE = 1123;
struct NeededItem
{
var int ID;
var string Name;
var int Count;
var string IconName;
var string AdditionalName;
var int Enchant;
var int CrystalType;
var int ItemType;
var int RefineryOp1;
var int RefineryOp2;
};
struct ItemList
{
var int MultiSellType;
var int NeededItemNum;
var Array<ItemInfo> ItemInfoList;
var Array<NeededItem> NeededItemList;
};
var string m_WindowName;
var array<itemList> m_itemList;
var int m_shopID;
var int pre_itemList;
var int GlobalItemCount;
var int GlobalAvailable;
var int lastFalseItem;
var int selectedGlobal;
var int indexGlobal;
var bool isExec;
var ItemWindowHandle MultisellTabTotalWnd_ItemWindow;
var ItemWindowHandle MultisellTabEnableWnd_ItemWindow;
var WindowHandle MultisellTabTotalWnd_ListCtrl;
var WindowHandle MultisellTabEnableWnd_ListCtrl;
var TextureHandle listSlotBg1_Texture_MultisellTabTotalIconWnd;
var TextureHandle listSlotBg1_Texture_MultisellTabEnableIconWnd;
var ButtonHandle ListTabIcon_Button;
var ButtonHandle IconTabIcon_Button;
var ButtonHandle MultiSell_Up_Button;
var ButtonHandle MultiSell_Down_Button;
var ButtonHandle MultiSell_Input_Button;
var EditBoxHandle ItemCount_EditBox;
var EditBoxHandle Search_EditBox;
var TabHandle MultisellTab;
var bool isListType;
function OnLoad()
{
RegisterEvent( EV_MultiSellShopID );
RegisterEvent( EV_MultiSellItemList );
RegisterEvent( EV_MultiSellNeededItemList );
RegisterEvent( EV_MultiSellItemListEnd );
RegisterEvent( EV_DialogOK );
MultisellTabTotalWnd_ItemWindow = ItemWindowHandle(GetHandle(m_WindowName$".MultisellTabTotalWnd.MultisellTabTotalWnd_ItemWindow"));
MultisellTabEnableWnd_ItemWindow = ItemWindowHandle(GetHandle(m_WindowName$".MultisellTabEnableWnd.MultisellTabEnableWnd_ItemWindow"));
MultisellTabTotalWnd_ListCtrl = GetHandle(m_WindowName$".MultisellTabTotalWnd.MultisellTabTotalWnd_ListCtrl");
MultisellTabEnableWnd_ListCtrl = GetHandle(m_WindowName$".MultisellTabEnableWnd.MultisellTabEnableWnd_ListCtrl");
ListTabIcon_Button = ButtonHandle(GetHandle(m_WindowName$".ListTabIcon_Button"));
IconTabIcon_Button = ButtonHandle(GetHandle(m_WindowName$".IconTabIcon_Button"));
MultiSell_Up_Button = ButtonHandle(GetHandle(m_WindowName$".MultiSell_Up_Button"));
MultiSell_Down_Button = ButtonHandle(GetHandle(m_WindowName$".MultiSell_Down_Button"));
MultiSell_Input_Button = ButtonHandle(GetHandle(m_WindowName$".MultiSell_Input_Button"));
MultiSell_Input_Button = ButtonHandle(GetHandle(m_WindowName$".MultiSell_Input_Button"));
listSlotBg1_Texture_MultisellTabTotalIconWnd = TextureHandle(GetHandle(m_WindowName$".MultisellTabTotalWnd.listSlotBg1_Texture_MultisellTabIconWnd"));
listSlotBg1_Texture_MultisellTabEnableIconWnd = TextureHandle(GetHandle(m_WindowName$".MultisellTabEnableWnd.listSlotBg1_Texture_MultisellTabIconWnd"));
ItemCount_EditBox = EditBoxHandle(GetHandle(m_WindowName$".ItemCount_EditBox"));
Search_EditBox = EditBoxHandle(GetHandle(m_WindowName$".Search_EditBox"));
MultisellTab = TabHandle(GetHandle(m_WindowName$".MultisellTab"));
ListTabIcon_Button.SetTooltipCustomType(MakeTooltipSimpleText("Change List/Icon View"));
IconTabIcon_Button.SetTooltipCustomType(MakeTooltipSimpleText("Change List/Icon View"));
isListType = GetOptionBool("Custom", "MultiSellViewList");
pre_itemList = -1;
GlobalItemCount = 1;
}
function OnEvent( int Event_ID, string param )
{
switch ( Event_ID )
{
case EV_MultiSellShopID:
HandleShopID( param );
ToggleListWithIconWindow();
break;
case EV_MultiSellItemList:
HandleItemList( param );
break;
case EV_MultiSellNeededItemList:
HandleNeededItemList( param );
break;
case EV_MultiSellItemListEnd:
HandleItemListEnd( param );
break;
case EV_DialogOK:
HandleDialogOK();
break;
}
}
function OnShow()
{
MultisellTab.InitTabCtrl();
ToggleListWithIconWindow();
SetEditStateItemCount();
Search_EditBox.SetString("");
GlobalItemCount = 1;
GlobalAvailable = 0;
lastFalseItem = -1;
}
function OnHide()
{
if ( DialogIsMine() )
DialogHide();
InitListWithItemWindow();
}
function OnClickButton( string strID )
{
switch ( strID )
{
case "Close_Button":
Clear();
HideWindow(m_WindowName);
break;
case "ExChange_Button":
HandleOKButton();
break;
case "IconTabIcon_Button":
case "ListTabIcon_Button":
isListType = !isListType;
ToggleListWithIconWindow();
break;
case "Search_Button":
OnSearch_ButtonClick();
break;
case "Refresh_Button":
OnRefresh_ButtonClick();
break;
case "Clear_Button":
OnClear_ButtonClick();
break;
case "MultiSell_Up_Button":
OnMultiSell_Up_ButtonClick();
break;
case "MultiSell_Down_Button":
OnMultiSell_Down_ButtonClick();
break;
case "MultiSell_Input_Button":
OnPriceEditBtnHandler();
break;
}
if ( Left(strID, 4) == "root" )
{
OnClickItem("MultisellTabTotalWnd_ItemWindow", int(Mid(strID, 5)) - 1);
UpdateUIControl();
}
else if ( Left(strID, 6) == "enable" )
{
OnClickItem("MultisellTabEnableWnd_ItemWindow", int(Mid(strID, 11)) - 1);
UpdateUIControl();
}
}
function ToggleListWithIconWindow()
{
SetDebugMsg("ToggleListWithIconWindow");
SetOptionBool("Custom", "MultiSellViewList", isListType);
if ( isListType )
{
IconTabIcon_Button.ShowWindow();
ListTabIcon_Button.HideWindow();
MultisellTabTotalWnd_ItemWindow.HideWindow();
MultisellTabEnableWnd_ItemWindow.HideWindow();
MultisellTabTotalWnd_ListCtrl.ShowWindow();
MultisellTabTotalWnd_ListCtrl.SetScrollPosition(0);
MultisellTabEnableWnd_ListCtrl.ShowWindow();
MultisellTabEnableWnd_ListCtrl.SetScrollPosition(0);
listSlotBg1_Texture_MultisellTabTotalIconWnd.SetTexture("L2UI_CH3.Etc.dimmer");
listSlotBg1_Texture_MultisellTabTotalIconWnd.SetWindowSize(292, 431);
listSlotBg1_Texture_MultisellTabEnableIconWnd.SetTexture("L2UI_CH3.Etc.dimmer");
listSlotBg1_Texture_MultisellTabEnableIconWnd.SetWindowSize(292, 431);
}
else
{
IconTabIcon_Button.HideWindow();
ListTabIcon_Button.ShowWindow();
MultisellTabTotalWnd_ListCtrl.HideWindow();
MultisellTabEnableWnd_ListCtrl.HideWindow();
MultisellTabTotalWnd_ItemWindow.ShowWindow();
MultisellTabTotalWnd_ItemWindow.SetScrollPosition(0);
MultisellTabEnableWnd_ItemWindow.ShowWindow();
MultisellTabEnableWnd_ItemWindow.SetScrollPosition(0);
listSlotBg1_Texture_MultisellTabTotalIconWnd.SetTexture("L2UI_CH3.MultiSellWnd.slotbox");
listSlotBg1_Texture_MultisellTabTotalIconWnd.SetWindowSize(296, 431);
listSlotBg1_Texture_MultisellTabEnableIconWnd.SetTexture("L2UI_CH3.MultiSellWnd.slotbox");
listSlotBg1_Texture_MultisellTabEnableIconWnd.SetWindowSize(296, 431);
}
}
function SetEditStateItemCount()
{
ItemCount_EditBox.SetString("1");
}
function int FindMultiSellIndex( int ReservedID, int RefineryOp1, int RefineryOp2 )
{
local int i;
for ( i = 0; i < m_itemList.Length; ++i )
{
if ( m_itemList[i].ItemInfoList.Length > 0
&& m_itemList[i].ItemInfoList[0].Reserved == ReservedID
&& m_itemList[i].ItemInfoList[0].RefineryOp1 == RefineryOp1
&& m_itemList[i].ItemInfoList[0].RefineryOp2 == RefineryOp2 )
{
return i;
}
}
return -1;
}
function OnClickItem( string strID, int Index )
{
local string tmp;
local ItemInfo Info;
if ( strID == "MultisellTabTotalWnd_ItemWindow" )
{
if ( MultisellTabTotalWnd_ItemWindow.GetItem(Index, Info) )
{
selectedGlobal = FindMultiSellIndex(Info.Reserved, Info.RefineryOp1, Info.RefineryOp2);
if ( selectedGlobal < 0 )
{
tmp = string(Info.Reserved);
if ( Info.Reserved > MAX_BUY )
tmp = Left(tmp, Len(tmp) - 5);
if ( isExec )
selectedGlobal = Index;
else
selectedGlobal = int(tmp) - 1;
}
indexGlobal = Index;
UpdateUIControl();
}
}
else if ( strID == "MultisellTabEnableWnd_ItemWindow" )
{
if ( MultisellTabEnableWnd_ItemWindow.GetItem(Index, Info) )
{
selectedGlobal = FindMultiSellIndex(Info.Reserved, Info.RefineryOp1, Info.RefineryOp2);
if ( selectedGlobal < 0 )
{
tmp = string(Info.Reserved);
if ( Info.Reserved > MAX_BUY )
tmp = Left(tmp, Len(tmp) - 5);
if ( isExec )
selectedGlobal = Index;
else
selectedGlobal = int(tmp) - 1;
}
indexGlobal = Index;
UpdateUIControl();
}
}
}
function UpdateUIControl()
{
SetEditStateItemCount();
SetTreeNeedItemInfo();
}
function SetTreeNeedItemInfo()
{
local int i, Index, nTmp;
local string param;
local XMLTreeNodeInfo infNode;
local string TextureName, strRetName;
local ItemInfo cItemInfo, rItemInfo;
local ClanWnd scriptClan;
local BottomBar bottomBarScript;
local string iName;
if ( getCurrentSelectedItemInfo(rItemInfo) )
{
class'UIAPI_MULTISELLITEMINFO'.Static.Clear(m_WindowName$".ItemInfo");
ClearXMLNode(m_WindowName$".NeedItem");
InsertXMLNodeRoot(m_WindowName$".NeedItem", "rootNeed", "", 0, 2);
iName = "";
Index = selectedGlobal;
itemCountTextEditEnable(True);
if ( !IsStackableItem(rItemInfo.ConsumeType) )
itemCountTextEditEnable(False);
if ( Index >= 0 && Index < m_itemList.Length )
{
for ( i = 0;i < m_itemList[Index].NeededItemList.Length;++i )
{
param = "";
ParamAdd(param, "Name", m_itemList[Index].NeededItemList[i].Name);
ParamAdd(param, "ID", string(m_itemList[Index].NeededItemList[i].Id));
ParamAdd(param, "Num", string(m_itemList[Index].NeededItemList[i].Count));
ParamAdd(param, "Icon", m_itemList[Index].NeededItemList[i].IconName);
ParamAdd(param, "AdditionalName", m_itemList[Index].NeededItemList[i].AdditionalName);
ParamAdd(param, "Enchant", string(m_itemList[Index].NeededItemList[i].Enchant));
ParamAdd(param, "CrystalType", string(m_itemList[Index].NeededItemList[i].CrystalType));
ParamAdd(param, "ItemType", string(m_itemList[Index].NeededItemList[i].ItemType));
TextureName = GetItemGradeTextureName(m_itemList[Index].NeededItemList[i].CrystalType);
infNode.strName = (""$string(m_itemList[Index].NeededItemList[i].Id))$string(i);
infNode.bFollowCursor = True;
infNode.ToolTip = SetTooltip(m_itemList[Index].NeededItemList[i].Enchant, m_itemList[Index].NeededItemList[i].Name, m_itemList[Index].NeededItemList[i].AdditionalName, m_itemList[Index].NeededItemList[i].CrystalType);
infNode.nOffSetY = 4;
infNode.bShowButton = 0;
strRetName = class'UIAPI_TREECTRL'.Static.InsertNode(m_WindowName$".NeedItem", "rootNeed", infNode);
InsertXMLNodeTexture(m_WindowName$".NeedItem", strRetName, "L2UI_CH3.Etc.Null", "", 257, 38);
InsertXMLNodeTexture(m_WindowName$".NeedItem", strRetName, "L2UI_CH3.MultiSellWnd.Slotbox", "", 36, 36, -251, 1);
InsertXMLNodeTexture(m_WindowName$".NeedItem", strRetName, m_itemList[Index].NeededItemList[i].IconName, "", 32, 32, -34, 4 - 1);
if ( m_itemList[Index].NeededItemList[i].Enchant > 0 )
InsertXMLNodeText(m_WindowName$".NeedItem", strRetName, "+"$string(m_itemList[Index].NeededItemList[i].Enchant), 7, 5, SetColor(170, 110, 230), True);
iName = m_itemList[Index].NeededItemList[i].Name;
if ( Len((string(m_itemList[Index].NeededItemList[i].Enchant)@iName)@m_itemList[Index].NeededItemList[i].AdditionalName) > 32 )
iName = Left(iName, (31 - Len(m_itemList[Index].NeededItemList[i].AdditionalName)) - 4)$"...";
InsertXMLNodeText(m_WindowName$".NeedItem", strRetName, iName, 7, 5, SetColor(byte(255), byte(255), byte(255)), True);
if ( m_itemList[Index].NeededItemList[i].AdditionalName != "" )
InsertXMLNodeText(m_WindowName$".NeedItem", strRetName, m_itemList[Index].NeededItemList[i].AdditionalName, 5, 5, SetColor(240, 214, 54), True);
if ( Len(TextureName) > 0 )
{
if ( (m_itemList[Index].NeededItemList[i].CrystalType == 6) || m_itemList[Index].NeededItemList[i].CrystalType == 7 )
InsertXMLNodeTexture(m_WindowName$".NeedItem", strRetName, TextureName, "", 32, 16, 2, 5);
else
InsertXMLNodeTexture(m_WindowName$".NeedItem", strRetName, TextureName, "", 16, 16, 2, 5);
}
InsertXMLNodeText(m_WindowName$".NeedItem", strRetName, " x "$MakeCostString(string(GlobalItemCount * m_itemList[Index].NeededItemList[i].Count)), 45, -14, SetColor(176, 155, 121), False, True);
if ( !IsStackableItem(m_itemList[Index].NeededItemList[i].ItemType) )
nTmp = FindNoStackableItem(m_itemList[Index].NeededItemList[i].Id);
else
{
GetItemInvInfo(m_itemList[Index].NeededItemList[i].Id, cItemInfo);
nTmp = cItemInfo.ItemNum;
}
if ( m_itemList[Index].NeededItemList[i].IconName == "icon.etc_i.etc_bloodpledge_point_i00" )
{
scriptClan = ClanWnd(GetScript("ClanWnd"));
nTmp = scriptClan.m_clanNameValue;
}
if ( m_itemList[Index].NeededItemList[i].IconName == "icon.etc_i.etc_pccafe_point_i00" )
{
bottomBarScript = BottomBar(GetScript("BottomBar"));
nTmp = bottomBarScript.m_TotalPoint;
}
if ( i == 0 )
GlobalAvailable = nTmp / m_itemList[Index].NeededItemList[i].Count;
if ( i >= 0 )
{
if ( GlobalAvailable > (nTmp / m_itemList[Index].NeededItemList[i].Count) )
GlobalAvailable = nTmp / m_itemList[Index].NeededItemList[i].Count;
}
if ( nTmp < (GlobalItemCount * m_itemList[Index].NeededItemList[i].Count) )
{
InsertXMLNodeText(m_WindowName$".NeedItem", strRetName, (" ("$MakeCostString(string(nTmp)))$")", 4, -14, SetColor(250, 50, 0));
continue;
}
InsertXMLNodeText(m_WindowName$".NeedItem", strRetName, (" ("$MakeCostString(string(nTmp)))$")", 4, -14, SetColor(102, 150, 253));
}
for ( i = 0;i < m_itemList[Index].NeededItemNum;++i )
class'UIAPI_MULTISELLITEMINFO'.Static.SetItemInfo(m_WindowName$".ItemInfo", i, m_itemList[Index].ItemInfoList[i]);
if ( pre_itemList != Index )
{
if ( DialogIsMine() )
DialogHide();
}
}
}
}
/*
function Print()
{
local int i, j;
i = 0;
J0x07:
if ( i < m_itemList.Length )
{
j = 0;
J0x1E:
if ( j < m_itemList[i].NeededItemList.Length )
{
OMG("Print ("$i$","$j$"), "$m_itemList[i].NeededItemList[j].Name);
++j;
goto J0x1E;
}
++i;
goto J0x07;
}
}
function OMG( string Msg )
{
local ChatWindowHandle NormalChat;
local Color iColor;
NormalChat = ChatWindowHandle(GetHandle("ChatWnd.NormalChat"));
iColor.R = 255;
iColor.G = 0;
iColor.B = 255;
iColor.A = 255;
NormalChat.AddString(("LotusInfo: "$Msg),iColor);
}
*/
function HandleShopID( string param )
{
Clear();
ParseInt( param, "shopID", m_shopID );
}
function Clear()
{
m_itemList.Length = 0;
class'UIAPI_MULTISELLITEMINFO'.static.Clear(m_WindowName$".ItemInfo");
MultisellTabTotalWnd_ItemWindow.Clear();
MultisellTabEnableWnd_ItemWindow.Clear();
InitListWithItemWindow();
itemCountTextEditEnable(False);
}
function HandleItemList( string param )
{
local ItemInfo info;
local int index, type, i, ClassID;
local bool bMatchFound;
ParseInt( param, "classID", ClassID );
class'UIDATA_ITEM'.Static.GetItemInfo( ClassID, info );
info.ClassID = ClassID;
ParseInt( param, "index", index );
ParseInt( param, "type", type );
ParseInt( param, "ID", info.Reserved );
ParseInt( param, "slotBitType", info.SlotBitType );
ParseInt( param, "itemType", info.ItemType );
ParseInt( param, "itemCount", info.ItemNum );
ParseInt( param, "enchant", info.Enchanted );
ParseInt( param, "OutputRefineryOp1", info.RefineryOp1 );
ParseInt( param, "OutputRefineryOp2", info.RefineryOp2 );
if ( 0 < info.Durability )
info.CurrentDurability = info.Durability;
if ( index == 0 )
{
i = m_itemList.Length;
m_itemList.Length = i + 1;
m_itemList[i].MultiSellType = type;
m_itemList[i].NeededItemNum = 1;
m_itemList[i].ItemInfoList.Length = index + 1;
m_itemList[i].ItemInfoList[index] = info;
}
else if ( index > 0 )
{
bMatchFound = False;
for ( i = m_itemList.Length - 1;i >= 0;--i )
{
if ( m_itemList[i].ItemInfoList[0].Reserved == info.Reserved
&& m_itemList[i].ItemInfoList[0].RefineryOp1 == info.RefineryOp1
&& m_itemList[i].ItemInfoList[0].RefineryOp2 == info.RefineryOp2 )
{
bMatchFound = True;
break;
}
}
if ( bMatchFound )
{
if ( m_itemList[i].ItemInfoList.Length <= index )
m_itemList[i].ItemInfoList.Length = index + 1;
m_itemList[i].MultiSellType = type;
m_itemList[i].ItemInfoList[index] = info;
++m_ItemList[i].NeededItemNum;
}
}
}
function HandleNeededItemList( string param )
{
local NeededItem item;
local ItemInfo Info;
local int i, ID, index, RefineryOp1, RefineryOp2 ;
ParseInt( param, "ID", ID );
ParseInt( param, "refineryOp1", RefineryOp1 );
ParseInt( param, "refineryOp2", RefineryOp2 );
ParseInt( param, "classID", item.ID );
ParseInt( param, "count", item.Count );
ParseInt( param, "enchant", item.Enchant );
ParseInt( param, "inputRefineryOp1", item.RefineryOp1 );
ParseInt( param, "inputRefineryOp2", item.RefineryOp2 );
if ( item.ID == -100 )
{
item.Name = GetSystemString(1277);
item.IconName = "icon.etc_i.etc_pccafe_point_i00";
item.Enchant = 0;
item.ItemType = -1;
item.ID = 0;
}
else if ( item.ID == -200 )
{
item.Name = GetSystemString(1311);
item.IconName = "icon.etc_i.etc_bloodpledge_point_i00";
item.Enchant = 0;
item.ItemType = -1;
item.ID = 0;
}
else
{
item.Name = class'UIDATA_ITEM'.Static.GetItemName( item.ID );
item.IconName = class'UIDATA_ITEM'.Static.GetItemTextureName( item.ID );
item.AdditionalName = Class'UIDATA_ITEM'.Static.GetItemAdditionalName( item.ID );
}
for ( i = m_itemList.Length - 1;i >= 0;--i )
{
if ( m_itemList[i].ItemInfoList[0].Reserved == ID && m_itemList[i].ItemInfoList[0].RefineryOp1 == RefineryOp1 && m_itemList[i].ItemInfoList[0].RefineryOp2 == RefineryOp2 )
{
Info = m_itemList[i].ItemInfoList[0];
index = m_itemList[i].NeededItemList.Length;
m_itemList[i].NeededItemList.Length = index + 1;
item.ItemType = class'UIDATA_ITEM'.Static.GetItemDataType( item.ID );
item.CrystalType = class'UIDATA_ITEM'.Static.GetItemCrystalType( item.ID );
m_itemList[i].NeededItemList[index] = item;
if ( !compareWithInven(item, Info) )
m_itemList[i].ItemInfoList[0].ForeTexture = "";
else
m_itemList[i].ItemInfoList[0].ForeTexture = "L2UI_CH3.MultiSellWnd.SellablePanel";
break;
}
}
}
function bool compareWithInven( NeededItem item, ItemInfo Info )
{
local ItemInfo InvenItemInfo;
if ( lastFalseItem == Info.ClassID )
return False;
if ( item.Id > 0 )
{
GetItemInvInfo(item.Id, InvenItemInfo);
if ( item.Count > 0 )
{
if ( InvenItemInfo.ItemNum >= item.Count )
return True;
}
}
lastFalseItem = Info.ClassID;
return False;
}
function HandleItemListEnd( string param )
{
if ( IsShowWindow("InventoryWnd") )
HideWindow("InventoryWnd");
ShowWindow(m_WindowName);
class'UIAPI_WINDOW'.Static.SetFocus(m_WindowName);
ShowItemList();
}
function ShowItemList()
{
local ItemInfo Info;
local int i;
ClearXMLNode(m_WindowName$".MultisellTabTotalWnd.MultisellTabTotalWnd_ListCtrl");
ClearXMLNode(m_WindowName$".MultisellTabEnableWnd.MultisellTabEnableWnd_ListCtrl");
InsertXMLNodeRoot(m_WindowName$".MultisellTabTotalWnd.MultisellTabTotalWnd_ListCtrl", "root", "", 0, 3);
InsertXMLNodeRoot(m_WindowName$".MultisellTabEnableWnd.MultisellTabEnableWnd_ListCtrl", "enableroot", "", 0, 3);
for ( i = 0; i < m_itemList.Length;++i )
{
Info = m_itemList[i].ItemInfoList[0];
MultisellTabTotalWnd_ItemWindow.AddItem(Info);
addTreeNode(MultisellTabTotalWnd_ItemWindow.GetItemNum(), Info, "MultiSellWnd.MultisellTabTotalWnd.MultisellTabTotalWnd_ListCtrl");
if ( Info.ForeTexture == "L2UI_CH3.MultiSellWnd.SellablePanel" )
{
MultisellTabEnableWnd_ItemWindow.AddItem(Info);
addTreeNode(MultisellTabEnableWnd_ItemWindow.GetItemNum(), Info, "MultiSellWnd.MultisellTabEnableWnd.MultisellTabEnableWnd_ListCtrl");
}
}
}
function fildAndShowItemList( string searchStr )
{
local ItemInfo Info;
local int i;
local string fullNameString;
class'UIAPI_MULTISELLITEMINFO'.Static.Clear(m_WindowName$".ItemInfo");
MultisellTabTotalWnd_ItemWindow.Clear();
MultisellTabEnableWnd_ItemWindow.Clear();
InitListWithItemWindow();
for ( i = 0;i < m_itemList.Length;++i )
{
Info = m_itemList[i].ItemInfoList[0];
fullNameString = GetItemNameAll(Info);
if ( findMatchString(fullNameString, searchStr) != -1 )
{
MultisellTabTotalWnd_ItemWindow.AddItem(Info);
addTreeNode(MultisellTabTotalWnd_ItemWindow.GetItemNum(), Info, "MultiSellWnd.MultisellTabTotalWnd.MultisellTabTotalWnd_ListCtrl");
if ( Info.ForeTexture == "L2UI_CH3.MultiSellWnd.SellablePanel" )
{
MultisellTabEnableWnd_ItemWindow.AddItem(Info);
addTreeNode(MultisellTabEnableWnd_ItemWindow.GetItemNum(), Info, "MultiSellWnd.MultisellTabEnableWnd.MultisellTabEnableWnd_ListCtrl");
}
}
}
}
function InitListWithItemWindow()
{
ItemCount_EditBox.SetString("1");
ClearXMLNode(m_WindowName$".MultisellTabTotalWnd.MultisellTabTotalWnd_ListCtrl");
ClearXMLNode(m_WindowName$".MultisellTabEnableWnd.MultisellTabEnableWnd_ListCtrl");
ClearXMLNode("rootNeed");
InsertXMLNodeRoot(m_WindowName$".MultisellTabTotalWnd.MultisellTabTotalWnd_ListCtrl", "root", "", 0, 3);
InsertXMLNodeRoot(m_WindowName$".MultisellTabEnableWnd.MultisellTabEnableWnd_ListCtrl", "enableroot", "", 0, 3);
InsertXMLNodeRoot(m_WindowName$".NeedItem", "rootNeed", "", 0, 4);
class'UIAPI_MULTISELLITEMINFO'.Static.Clear(m_WindowName$".ItemInfo");
}
function OnChangeEditBox( string strID )
{
local int SelectedIndex;
switch ( strID )
{
case "ItemCount_EditBox":
SelectedIndex = selectedGlobal;
if ( SelectedIndex >= 0 )
{
if ( int(ItemCount_EditBox.GetString()) > MAX_BUY )
ItemCount_EditBox.SetString(string(MAX_BUY));
GlobalItemCount = int(ItemCount_EditBox.GetString());
pre_itemList = SelectedIndex;
SetTreeNeedItemInfo();
}
break;
}
}
function HandleOKButton()
{
local int selectedIndex, itemNum;
selectedIndex = selectedGlobal;
itemNum = int(ItemCount_EditBox.GetString());
if ( selectedIndex >= 0 )
{
DialogSetReservedInt( selectedIndex );
DialogSetReservedInt2( itemNum );
DialogSetID( MULTISELLWND_DIALOG_OK );
DialogShow(DIALOG_Warning, GetSystemMessage(1383));
pre_itemList = selectedIndex;
}
}
function HandleDialogOK()
{
local string param;
local int SelectedIndex, Id, inputNum;
if ( DialogIsMine() )
{
Id = DialogGetID();
if ( Id == DIALOG_ASK_PRICE )
{
inputNum = int(DialogGetString());
if ( inputNum <= 0 )
inputNum = 1;
if ( inputNum > MAX_BUY )
inputNum = MAX_BUY;
ItemCount_EditBox.SetString(string(inputNum));
SetTreeNeedItemInfo();
}
else
{
SelectedIndex = DialogGetReservedInt();
ParamAdd( param, "ShopID", string(m_shopID) );
ParamAdd( param, "ItemID", string( m_itemList[SelectedIndex].ItemInfoList[0].Reserved ) );
ParamAdd( param, "RefineryOp1", string( m_itemList[SelectedIndex].ItemInfoList[0].RefineryOp1 ) );
ParamAdd( param, "RefineryOp2", string( m_itemList[SelectedIndex].ItemInfoList[0].RefineryOp2 ) );
ParamAdd( param, "ItemCount", string(DialogGetReservedInt2()) );
RequestMultiSellChoose( param );
}
}
}
function GetItemInvInfo( int Id, out ItemInfo Info )
{
local int Index;
local ItemInfo item;
local ItemWindowHandle InvWnd;
InvWnd = ItemWindowHandle(GetHandle("InventoryWnd.InventoryItem"));
Index = InvWnd.FindItemWithClassID(Id);
InvWnd.GetItem(Index, item);
if ( Index > -1 )
Info = item;
else
Info.ItemNum = 0;
}
function CustomTooltip SetTooltip( int Enchant, string Name, string AdditionalName, int CrystalType )
{
local int i;
local CustomTooltip ToolTip;
local DrawItemInfo Info, infoClear;
i = 0;
ToolTip.DrawList.Length = 3;
if ( Enchant > 0 )
{
Info = infoClear;
Info.eType = DIT_TEXT;
Info.t_color.R = 170;
Info.t_color.G = 110;
Info.t_color.B = 230;
Info.t_color.A = byte(255);
Info.t_bDrawOneLine = True;
Info.t_strText = "+"$string(Enchant);
ToolTip.DrawList[i] = Info;
i++;
}
Info = infoClear;
Info.eType = DIT_TEXT;
Info.nOffSetX = 2;
Info.t_bDrawOneLine = True;
Info.t_strText = Name;
ToolTip.DrawList[i] = Info;
i++;
Info = infoClear;
Info.bLineBreak = False;
Info.t_bDrawOneLine = True;
Info.eType = DIT_TEXT;
Info.t_strText = "";
ToolTip.DrawList[i] = Info;
if ( AdditionalName != "" )
{
Info = infoClear;
Info.eType = DIT_TEXT;
Info.t_bDrawOneLine = True;
Info.t_color.R = byte(255);
Info.t_color.G = 215;
Info.t_color.B = 0;
Info.t_color.A = byte(255);
Info.t_strText = " "$AdditionalName;
ToolTip.DrawList[i] = Info;
}
i++;
Info = infoClear;
Info.bLineBreak = False;
Info.t_bDrawOneLine = True;
ToolTip.DrawList[i] = Info;
if ( CrystalType > 0 )
{
Info = infoClear;
Info.eType = DIT_TEXTURE;
Info.nOffSetX = 2;
Info.t_bDrawOneLine = True;
if ( CrystalType == 6 || CrystalType == 7 )
{
Info.u_nTextureWidth = 32;
Info.u_nTextureHeight = 16;
Info.u_nTextureUWidth = 32;
Info.u_nTextureUHeight = 16;
}
else
{
Info.u_nTextureWidth = 16;
Info.u_nTextureHeight = 16;
Info.u_nTextureUWidth = 16;
Info.u_nTextureUHeight = 16;
}
Info.u_strTexture = GetItemGradeTextureName(CrystalType);
ToolTip.DrawList[i] = Info;
}
return ToolTip;
}
function addTreeNode( int nodeLine, ItemInfo Info, string Tree )
{
local string strRetName;
local XMLTreeNodeInfo infNode;
local string fullNameString;
fullNameString = GetItemNameAll(Info);
infNode.strName = string(nodeLine);
infNode.bFollowCursor = True;
infNode.ToolTip = SetTooltip(Info.Enchanted, Info.Name, Info.AdditionalName, Info.CrystalType);
infNode.nOffSetX = 0;
infNode.nOffSetY = 0;
infNode.bShowButton = 0;
infNode.nTexExpandedOffSetX = 0;
infNode.nTexExpandedOffSetY = 0;
infNode.nTexExpandedHeight = 38;
infNode.nTexExpandedRightWidth = 32;
infNode.nTexExpandedLeftUWidth = 16;
infNode.nTexExpandedLeftUHeight = 38;
infNode.nTexExpandedRightUWidth = 32;
infNode.nTexExpandedRightUHeight = 38;
infNode.strTexExpandedLeft = "L2UI_CH3.Etc.iconselect1_over";
infNode.strTexExpandedRight = "L2UI_CH3.Etc.iconselect2_over";
if ( Tree == "MultiSellWnd.MultisellTabTotalWnd.MultisellTabTotalWnd_ListCtrl" )
strRetName = class'UIAPI_TREECTRL'.Static.InsertNode(Tree, "root", infNode);
else
strRetName = class'UIAPI_TREECTRL'.Static.InsertNode(Tree, "enableroot", infNode);
if ( nodeLine % 2 == 0 )
InsertXMLNodeTexture(Tree, strRetName, "L2UI_CH3.Etc.lineback", "", 290, 38);
else
InsertXMLNodeTexture(Tree, strRetName, "L2UI_CH3.Etc.Null", "", 290, 38);
InsertXMLNodeTexture(Tree, strRetName, "L2UI_CH3.MultiSellWnd.slotbox", "", 36, 36, -286, 1);
InsertXMLNodeTexture(Tree, strRetName, Info.IconName, "", 32, 32, -34, 3);
if ( Info.ForeTexture == "L2UI_CH3.MultiSellWnd.SellablePanel" )
InsertXMLNodeTexture(Tree, strRetName, "L2UI_CH3.MultiSellWnd.SellablePanel", "", 32, 32, -32, 3);
if ( Info.Enchanted > 0 && Info.Enchanted <= 50 )
InsertXMLNodeTexture(Tree, strRetName, "L2UI_CH3.ItemEnchant.enchant"$Info.Enchanted, "", 32, 32, -32, 3);
if ( IsStackableItem(Info.ConsumeType) )
{
fullNameString = makeShortStringByPixel(fullNameString, 212, "..");
if ( Info.ItemNum > 0 )
fullNameString = fullNameString$"("$Info.ItemNum$")";
else
fullNameString = fullNameString$"(1)";
}
else
fullNameString = makeShortStringByPixel(fullNameString, 230, "..");
InsertXMLNodeText(Tree, strRetName, fullNameString, 5, 11, SetColor(byte(255), byte(255), byte(255)), True);
if ( Info.CrystalType > 0 )
{
if ( Info.CrystalType == 6 || Info.CrystalType == 7 )
InsertXMLNodeTexture(Tree, strRetName, GetItemGradeTextureName(Info.CrystalType), "", 32, 16, 2, 11);
else
InsertXMLNodeTexture(Tree, strRetName, GetItemGradeTextureName(Info.CrystalType), "", 16, 16, 2, 11);
}
}
function OnSearch_ButtonClick()
{
local string searchStr;
searchStr = Search_EditBox.GetString();
fildAndShowItemList(searchStr);
}
function OnRefresh_ButtonClick()
{
ItemCount_EditBox.SetString("1");
Search_EditBox.SetString("");
fildAndShowItemList("");
}
function OnClear_ButtonClick()
{
ItemCount_EditBox.SetString("1");
SetTreeNeedItemInfo();
}
function OnMultiSell_Up_ButtonClick()
{
local string numStr;
local int Count;
numStr = ItemCount_EditBox.GetString();
Count = int(numStr);
if ( Count < GlobalAvailable )
{
Count++;
if ( Count > MAX_BUY )
Count = MAX_BUY;
ItemCount_EditBox.SetString(string(Count));
SetTreeNeedItemInfo();
}
}
function OnMultiSell_Down_ButtonClick()
{
local int Count;
Count = int(ItemCount_EditBox.GetString());
if ( Count > 1 )
{
Count--;
ItemCount_EditBox.SetString(string(Count));
SetTreeNeedItemInfo();
}
}
function OnPriceEditBtnHandler()
{
local ItemInfo Info;
DialogHide();
DialogSetID(DIALOG_ASK_PRICE);
DialogSetReservedInt(Info.ServerID);
DialogSetParamInt(GlobalAvailable);
DialogShow(EDialogType(6), "Indicate the number of items for exchange.");
}
function OnKeyUp( EInputKey nKey )
{
if ( Search_EditBox.IsFocused() && nKey == 13 )
OnSearch_ButtonClick();
}
function itemCountTextEditEnable( bool bEnable )
{
if ( bEnable )
{
MultiSell_Input_Button.EnableWindow();
ItemCount_EditBox.EnableWindow();
MultiSell_Up_Button.EnableWindow();
MultiSell_Down_Button.EnableWindow();
MultiSell_Input_Button.EnableWindow();
}
else
{
MultiSell_Input_Button.DisableWindow();
ItemCount_EditBox.DisableWindow();
MultiSell_Up_Button.DisableWindow();
MultiSell_Down_Button.DisableWindow();
MultiSell_Input_Button.DisableWindow();
}
}
function bool getCurrentSelectedItemInfo( out ItemInfo rItemInfo )
{
local bool bFlag;
if ( MultisellTab.GetTopIndex() == 0 )
bFlag = MultisellTabTotalWnd_ItemWindow.GetItem(indexGlobal, rItemInfo);
else
bFlag = MultisellTabEnableWnd_ItemWindow.GetItem(indexGlobal, rItemInfo);
return bFlag;
}
function int FindNoStackableItem( int ClassID )
{
local int i;
local int itemCount;
local int invenLimit;
local ItemInfo item;
local ItemWindowHandle InvWnd;
InvWnd = ItemWindowHandle(GetHandle("InventoryWnd.InventoryItem"));
invenLimit = InvWnd.GetItemNum();
itemCount = 0;
for ( i = 0;i < invenLimit;i++ )
{
InvWnd.GetItem(i, item);
if ( item.ClassID == ClassID )
itemCount++;
}
return itemCount;
}
defaultproperties
{
m_WindowName="MultiSellWnd"
}