Çoklu İtem Ayırma Sistemi Burada bulunan Kreton-SplitAllItems sisteminin
Linkleri görebilmek için
giriş yap veya kayıt ol.
için entegre edilmiş, define edilerek düzenlenmiş ve özellikle cmd_general.cpp ve uiinventory.py eklemeleri daha farklı yapılmış halidir. Ayırmayı paket anlamında hala yavaş ve verimsiz yapmakta ancak Client crash vermedi bende.
splitallitemsfix.cpp:
//PDx Split All Items Special Inventory and Bug Fix
// char.h
// Arat:
int GetEmptyInventory(BYTE size) const;
//Altına Ekle:
#ifdef __SPLIT_ITEMS_SYSTEM__
int GetEmptyInventoryFromIndex(WORD index, BYTE itemSize) const;
#endif
//char.h SON
// char_item.cpp
// Arat:
int CHARACTER::GetEmptyInventory(BYTE size) const
//Altına Ekle:
#ifdef __SPLIT_ITEMS_SYSTEM__
int CHARACTER::GetEmptyInventoryFromIndex(WORD index, BYTE itemSize) const
{
if (index >= INVENTORY_MAX_NUM)
return -1;
for (WORD i = index; i < INVENTORY_MAX_NUM; ++i)
{
if (IsEmptyItemGrid(TItemPos(INVENTORY, i), itemSize))
return i;
}
return -1;
}
#endif
// char_item.cpp SON
// cmd.cpp
// Arat:
ACMD (do_clear_affect);
//Altına Ekle:
#ifdef __SORT_INVENTORY_ITEMS__
ACMD(do_sort_inventory);
ACMD(do_sort_special_inventory);
#endif
// Arat:
{ "do_clear_affect", do_clear_affect, 0, POS_DEAD, GM_LOW_WIZARD},
//Altına Ekle:
#ifdef __SPLIT_ITEMS_SYSTEM__
{ "split_items", do_split_items, 0, POS_DEAD, GM_PLAYER }, //SPLIT ITEMS
#endif
// cmd.cpp SON
// cmd_general.cpp
// Arat:
ACMD(do_ride)
//Altına Ekle:
#ifdef __SPLIT_ITEMS_SYSTEM__
ACMD(do_split_items)
{
if (!ch)
return;
const char *line;
char arg1[256], arg2[256], arg3[256];
line = two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
one_argument(line, arg3, sizeof(arg3));
if (!*arg1 || !*arg2 || !*arg3)
{
ch->ChatPacket(CHAT_TYPE_INFO, "Wrong command use.");
return;
}
if (!ch->CanHandleItem())
{
ch->ChatPacket(CHAT_TYPE_INFO, "Tum pencereleri kapat ve biraz bekle.");
return;
}
if (!ch->CanWarp())
{
ch->ChatPacket(CHAT_TYPE_INFO, "Tum pencereleri kapat ve biraz bekle.");
return;
}
// Pazar ve Ticaret kontrolu (MoveItem hatasını onlemek icin ?art)
if (ch->GetExchange() || ch->GetMyShop() || ch->GetShopOwner())
{
ch->ChatPacket(CHAT_TYPE_INFO, "Bu islem icin ticaret/pazar kapali olmalidir.");
return;
}
WORD cell = 0;
WORD splitCount = 0;
WORD destIndex = 0;
str_to_number(cell, arg1);
str_to_number(splitCount, arg2);
str_to_number(destIndex, arg3);
if (splitCount == 0)
return;
// K envanteri slotları (60000+) INVENTORY_MAX_NUM'dan buyuk oldu?u icin
// buradaki cell >= INVENTORY_MAX_NUM kontrolunu yapmıyoruz.
// LPITEM item = ch->GetInventoryItem(cell); <-- Bu sadece normal envantere bakar, yanlı?tır.
// A?a?ıdaki kod tum pencerelerde (K dahil) itemi cell uzerinden bulur:
LPITEM item = ch->GetItem(TItemPos(INVENTORY, cell));
if (!item)
return;
if (!item || item->GetCount() <= 1)
return;
DWORD totalCount = item->GetCount();
if (splitCount >= totalCount)
return;
DWORD stackAmount = totalCount / splitCount;
for (DWORD i = 0; i < stackAmount; ++i)
{
if (!item || item->GetCount() < splitCount)
break;
int emptySlot = -1;
// K Envanteri Kategorisine Gore Bo? Slot Bulma (Senin char.h tanımına gore)
#ifdef ENABLE_SPLIT_INVENTORY_SYSTEM
if (item->IsSkillBook())
emptySlot = ch->GetEmptySkillBookInventory(item->GetSize());
else if (item->IsUpgradeItem())
emptySlot = ch->GetEmptyUpgradeItemsInventory(item->GetSize());
else if (item->IsStone())
emptySlot = ch->GetEmptyStoneInventory(item->GetSize());
else if (item->IsBox())
emptySlot = ch->GetEmptyBoxInventory(item->GetSize());
else if (item->IsEfsun())
emptySlot = ch->GetEmptyEfsunInventory(item->GetSize());
else if (item->IsCicek())
emptySlot = ch->GetEmptyCicekInventory(item->GetSize());
else
#endif
{
// E?er normal envanter itemi ise orijinal fonksiyonu kullanıyoruz
emptySlot = ch->GetEmptyInventoryFromIndex(destIndex, item->GetSize());
}
if (emptySlot == -1)
{
ch->ChatPacket(CHAT_TYPE_INFO, "Envanterde yeterli bos yer yok.");
break;
}
LPITEM newItem = ITEM_MANAGER::instance().CreateItem(item->GetVnum(), splitCount);
if (!newItem)
break;
item->SetCount(item->GetCount() - splitCount);
newItem->AddToCharacter(ch, TItemPos(item->GetWindow(), emptySlot));
}
}
#endif
// cmd_general.cpp SON
//ui.py
ENABLE_SPLIT_ITEMS_SYSTEM = True // importların oraya bi yere
// Arat:
def GetHeight(self):
return wndMgr.GetWindowHeight(self.hWnd)
//Altına Ekle:
if ENABLE_SPLIT_ITEMS_SYSTEM:
class CheckBox(Window):
def __init__(self):
Window.__init__(self)
self.backgroundImage = None
self.checkImage = None
self.eventFunc = {"ON_CHECK": None, "ON_UNCKECK": None}
self.eventArgs = {"ON_CHECK": None, "ON_UNCKECK": None}
self.CreateElements()
def __del__(self):
Window.__del__(self)
self.backgroundImage = None
self.checkImage = None
self.eventFunc = {"ON_CHECK": None, "ON_UNCKECK": None}
self.eventArgs = {"ON_CHECK": None, "ON_UNCKECK": None}
def CreateElements(self):
self.backgroundImage = ImageBox()
self.backgroundImage.SetParent(self)
self.backgroundImage.AddFlag("not_pick")
self.backgroundImage.LoadImage("d:/ymir work/ui/game/refine/checkbox.tga")
self.backgroundImage.Show()
self.checkImage = ImageBox()
self.checkImage.SetParent(self)
self.checkImage.AddFlag("not_pick")
self.checkImage.SetPosition(0, -4)
self.checkImage.LoadImage("d:/ymir work/ui/game/refine/checked.tga")
self.checkImage.Hide()
self.textInfo = TextLine()
self.textInfo.SetParent(self)
self.textInfo.SetPosition(20, -2)
self.textInfo.Show()
self.SetSize(
self.backgroundImage.GetWidth() + self.textInfo.GetTextSize()[0],
self.backgroundImage.GetHeight() + self.textInfo.GetTextSize()[1]
)
def SetTextInfo(self, info):
if self.textInfo:
self.textInfo.SetText(info)
self.SetSize(
self.backgroundImage.GetWidth() + self.textInfo.GetTextSize()[0],
self.backgroundImage.GetHeight() + self.textInfo.GetTextSize()[1]
)
def SetCheckStatus(self, flag):
if flag:
self.checkImage.Show()
else:
self.checkImage.Hide()
def GetCheckStatus(self):
if self.checkImage:
return self.checkImage.IsShow()
return False
def SetEvent(self, func, *args):
if self.eventFunc.has_key(args[0]):
self.eventFunc[args[0]] = func
self.eventArgs[args[0]] = args
else:
print "[ERROR] ui.py SetEvent, Can`t Find has_key : %s" % args[0]
def OnMouseLeftButtonUp(self):
if self.checkImage:
if self.checkImage.IsShow():
self.checkImage.Hide()
if self.eventFunc["ON_UNCKECK"]:
apply(self.eventFunc["ON_UNCKECK"], self.eventArgs["ON_UNCKECK"])
else:
self.checkImage.Show()
if self.eventFunc["ON_CHECK"]:
apply(self.eventFunc["ON_CHECK"], self.eventArgs["ON_CHECK"])
//ui.py SON
//uiinventory.py
import uiPickItem // importlara ekle
// Arat class ExtendedInventoryWındow içerisinde:
dlgPickMoney = None
// Altına Ekle:
dlgPickItem = None
//Arat:
dlgPickItem.Hide()
//Altına Ekle:
self.dlgSplitItems = uiPickItem.PickItemDialog()
self.dlgSplitItems.LoadDialog()
self.dlgSplitItems.Hide()
//Arat:
def OnPickItem(self, count):
//Altına Ekle:
def OnPickItemSplit(self, count):
itemSlotIndex = self.dlgSplitItems.itemGlobalSlotIndex
selectedItemVNum = player.GetItemIndex(itemSlotIndex)
# K Envanteri tipini belirleyip mouse'a takıyoruz
attachedSlotType = player.SLOT_TYPE_INVENTORY # Varsayılan
if self.inventoryType == 0: attachedSlotType = player.SLOT_TYPE_SKILL_BOOK_INVENTORY
elif self.inventoryType == 2: attachedSlotType = player.SLOT_TYPE_STONE_INVENTORY
elif self.inventoryType == 3: attachedSlotType = player.SLOT_TYPE_BOX_INVENTORY
elif self.inventoryType == 4: attachedSlotType = player.SLOT_TYPE_EFSUN_INVENTORY
elif self.inventoryType == 5: attachedSlotType = player.SLOT_TYPE_CICEK_INVENTORY
else: attachedSlotType = player.SLOT_TYPE_UPGRADE_ITEMS_INVENTORY
mouseModule.mouseController.AttachObject(self, attachedSlotType, itemSlotIndex, selectedItemVNum, count)
//Arat def SelectEmptySlot içerisinde
if player.SLOT_TYPE_SKILL_BOOK_INVENTORY == attachedSlotType or\
player.SLOT_TYPE_UPGRADE_ITEMS_INVENTORY == attachedSlotType or\
player.SLOT_TYPE_STONE_INVENTORY == attachedSlotType or\
player.SLOT_TYPE_BOX_INVENTORY == attachedSlotType or\
player.SLOT_TYPE_EFSUN_INVENTORY == attachedSlotType or\
player.SLOT_TYPE_CICEK_INVENTORY == attachedSlotType:
itemCount = player.GetItemCount(attachedSlotPos)
attachedCount = mouseModule.mouseController.GetAttachedItemCount()
//Altına Ekle:
if self.dlgSplitItems and self.dlgSplitItems.IsSplitAll():
net.SendChatPacket("/split_items %d %d %d" % (attachedSlotPos, attachedCount, selectedSlotPos))
self.dlgSplitItems.SplitClear()
else:
self.__SendMoveItemPacket(attachedSlotPos, selectedSlotPos, attachedCount)
//Arat def SelectItemSlot içerisinde
if player.GetItemCount(itemSlotIndex) > attachedItemCount:
return
// Yorum satırı içerisine al. Büyük küçük birleşme sorunu fix.
//Arat def SelectItemSlot içerisinde
elif app.IsPressed(app.DIK_LSHIFT):
//Değiştir:
elif app.IsPressed(app.DIK_LSHIFT):
itemCount = player.GetItemCount(itemSlotIndex)
if itemCount > 1:
# Orijinal dlgPickItem'i (uiPickEtc) değil, kendi sistemimizi açıyoruz
self.dlgSplitItems.SetTitleName(localeInfo.PICK_ITEM_TITLE)
self.dlgSplitItems.SetAcceptEvent(ui.__mem_func__(self.OnPickItemSplit)) # Yeni callback
self.dlgSplitItems.Open(itemCount)
self.dlgSplitItems.itemGlobalSlotIndex = itemSlotIndex
self.dlgSplitItems.SplitClear() # Açılırken checkbox'ı sıfırla
//Arat class InventoryWindow içerisinde
dlgPickMoney.LoadDialog()
dlgPickMoney.Hide()
//Altına Ekle:
self.dlgSplitItems = uiPickItem.PickItemDialog()
self.dlgSplitItems.LoadDialog()
self.dlgSplitItems.Hide()
//Arat:
def OnPickItem(self, count):
// Altına Ekle:
def OnPickItemSplit(self, count):
itemSlotIndex = self.dlgSplitItems.itemGlobalSlotIndex
selectedItemVNum = player.GetItemIndex(itemSlotIndex)
# Normal envanter olduğu için sabit tip
mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, count)
//Arat def SelectEmptySlot(self, selectedSlotPos): içerisinde
itemCount = player.GetItemCount(attachedSlotPos)
attachedCount = mouseModule.mouseController.GetAttachedItemCount()
// Altına Ekle:
if self.dlgSplitItems and self.dlgSplitItems.IsSplitAll():
net.SendChatPacket("/split_items %d %d %d" % (attachedSlotPos, attachedCount, selectedSlotPos))
self.dlgSplitItems.SplitClear()
else:
self.__SendMoveItemPacket(attachedSlotPos, selectedSlotPos, attachedCount)
//Arat def SelectItemSlot(self, itemSlotIndex): içerisinde
elif app.IsPressed(app.DIK_LALT):
link = player.GetItemLink(itemSlotIndex)
ime.PasteString(link)
// Altına Ekle:
elif app.IsPressed(app.DIK_LSHIFT):
itemCount = player.GetItemCount(itemSlotIndex)
if itemCount > 1:
# dlgPickMoney yerine dlgSplitItems kullanıyoruz
self.dlgSplitItems.SetTitleName(localeInfo.PICK_ITEM_TITLE)
# Yine yeni fonksiyonumuzu (OnPickItemSplit) çağırıyoruz
self.dlgSplitItems.SetAcceptEvent(ui.__mem_func__(self.OnPickItemSplit))
self.dlgSplitItems.Open(itemCount)
self.dlgSplitItems.itemGlobalSlotIndex = itemSlotIndex
self.dlgSplitItems.SplitClear() # Checkbox'ı sıfırla
//uiinventory.py SON
//uipickitem.py ROOT içerisine gidecek
import wndMgr
import ui
import ime
import localeInfo
class PickItemDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.unitValue = 1
self.maxValue = 0
self.eventAccept = 0
self.doAll = False
def __del__(self):
ui.ScriptWindow.__del__(self)
def LoadDialog(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/PickItemDialog.py")
except:
import exception
exception.Abort("MoneyDialog.LoadDialog.LoadScript")
try:
self.board = self.GetChild("board")
self.maxValueTextLine = self.GetChild("max_value")
self.pickValueEditLine = self.GetChild("money_value")
self.acceptButton = self.GetChild("accept_button")
self.cancelButton = self.GetChild("cancel_button")
except:
import exception
exception.Abort("MoneyDialog.LoadDialog.BindObject")
self.pickValueEditLine.SetReturnEvent(ui.__mem_func__(self.OnAccept))
self.pickValueEditLine.SetEscapeEvent(ui.__mem_func__(self.Close))
self.acceptButton.SetEvent(ui.__mem_func__(self.OnAccept))
self.cancelButton.SetEvent(ui.__mem_func__(self.Close))
self.board.SetCloseEvent(ui.__mem_func__(self.Close))
self.checkBox = ui.CheckBox()
self.checkBox.SetParent(self)
self.checkBox.SetPosition(25, 50)
self.checkBox.SetWindowVerticalAlignBottom()
self.checkBox.SetEvent(ui.__mem_func__(self.SetSplitFunction), "ON_CHECK", True)
self.checkBox.SetEvent(ui.__mem_func__(self.SetSplitFunction), "ON_UNCKECK", False)
self.checkBox.SetCheckStatus(self.doAll)
self.checkBox.SetTextInfo("Tumunu bol")
self.checkBox.Show()
def SplitClear(self):
self.doAll = False
self.checkBox.SetCheckStatus(self.doAll)
def SetSplitFunction(self, checkType, autoFlag):
self.doAll = autoFlag
def IsSplitAll(self):
return self.doAll
def Destroy(self):
self.ClearDictionary()
self.eventAccept = 0
self.maxValue = 0
self.pickValueEditLine = 0
self.acceptButton = 0
self.cancelButton = 0
self.board = None
self.doAll = False
def SetTitleName(self, text):
self.board.SetTitleName(text)
def SetAcceptEvent(self, event):
self.eventAccept = event
def SetMax(self, max):
self.pickValueEditLine.SetMax(max)
def Open(self, maxValue, unitValue=1):
if localeInfo.IsYMIR() or localeInfo.IsCHEONMA() or localeInfo.IsHONGKONG():
unitValue = ""
width = self.GetWidth()
(mouseX, mouseY) = wndMgr.GetMousePosition()
if mouseX + width/2 > wndMgr.GetScreenWidth():
xPos = wndMgr.GetScreenWidth() - width
elif mouseX - width/2 < 0:
xPos = 0
else:
xPos = mouseX - width/2
self.SetPosition(xPos, mouseY - self.GetHeight() - 20)
if localeInfo.IsARABIC():
self.maxValueTextLine.SetText("/" + str(maxValue))
else:
self.maxValueTextLine.SetText(" / " + str(maxValue))
self.pickValueEditLine.SetText(str(unitValue))
self.pickValueEditLine.SetFocus()
text_length = len(str(unitValue)) // Cursor fix
ime.SetCursorPosition(text_length + 1)
self.unitValue = unitValue
self.maxValue = maxValue
self.Show()
self.SetTop()
def Close(self):
self.pickValueEditLine.KillFocus()
self.Hide()
def OnAccept(self):
text = self.pickValueEditLine.GetText()
if len(text) > 0 and text.isdigit():
money = int(text)
money = min(money, self.maxValue)
if money > 0:
if self.eventAccept:
self.eventAccept(money)
self.Close()
// uipickitem.py SON
//pickitemdialog.py UISCRIPT içerisine
import uiScriptLocale
window = {
"name" : "PickMoneyDialog",
"x" : 100,
"y" : 100,
"style" : ("movable", "float",),
"width" : 170,
"height" : 90+20,
"children" :
(
{
"name" : "board",
"type" : "board_with_titlebar",
"x" : 0,
"y" : 0,
"width" : 170,
"height" : 90+20,
"title" : uiScriptLocale.PICK_MONEY_TITLE,
"children" :
(
## Money Slot
{
"name" : "money_slot",
"type" : "image",
"x" : 20,
"y" : 34,
"image" : "d:/ymir work/ui/public/Parameter_Slot_02.sub",
"children" :
(
{
"name" : "money_value",
"type" : "editline",
"x" : 3,
"y" : 2,
"width" : 60,
"height" : 18,
"input_limit" : 6,
"only_number" : 1,
"text" : "1",
},
{
"name" : "max_value",
"type" : "text",
"x" : 63,
"y" : 3,
"text" : "/ 999999",
},
),
},
## Button
{
"name" : "accept_button",
"type" : "button",
"x" : 170/2 - 61 - 5,
"y" : 58+20,
"text" : uiScriptLocale.OK,
"default_image" : "d:/ymir work/ui/public/middle_button_01.sub",
"over_image" : "d:/ymir work/ui/public/middle_button_02.sub",
"down_image" : "d:/ymir work/ui/public/middle_button_03.sub",
},
{
"name" : "cancel_button",
"type" : "button",
"x" : 170/2 + 5,
"y" : 58+20,
"text" : uiScriptLocale.CANCEL,
"default_image" : "d:/ymir work/ui/public/middle_button_01.sub",
"over_image" : "d:/ymir work/ui/public/middle_button_02.sub",
"down_image" : "d:/ymir work/ui/public/middle_button_03.sub",
},
),
},
),
}
//pickitemdialog.py SON
// service.h COMMON
#define __SPLIT_ITEMS_SYSTEM__ // Toplu Item Ayirma
Son düzenleme: