Pe langa asta unde pot mari poata imaginea de la rafine, upgrade.
Tipologie server:
*Resursă folosită:
*ServerFiles utilizat:
*Syserr:
Poză:
*Detalii suplimentare:

uirafine.py
Cod: Selectaţi tot
[spoiler][quote]import app
import net
import player
import item
import ui
import uiToolTip
import mouseModule
import localeInfo
import uiCommon
import constInfo
import chat
if app.__ENABLE_NEW_OFFLINESHOP__:
import offlineshop
import os
if constInfo.ENABLE_REFINE_ITEM_DESCRIPTION:
TOOLTIP_DATA = {
'materials' : [],
'slot_count': 0
}
if os.path.exists("font.cfg"):
file = open( "font.cfg" , "r")
findfont = file.readline()
if findfont == "Tahoma":
localeInfo.UI_DEF_FONT = "Tahoma:12"
localeInfo.UI_DEF_FONT_LARGE = "Tahoma:14"
localeInfo.UI_DEF_FONT_SMALL = "Tahoma:9"
elif findfont == "TahomaSmall":
localeInfo.UI_DEF_FONT = "Tahoma:11"
localeInfo.UI_DEF_FONT_LARGE = "Tahoma:13"
localeInfo.UI_DEF_FONT_SMALL = "Tahoma:8"
elif findfont == "Arial":
localeInfo.UI_DEF_FONT = "Arial:14"
localeInfo.UI_DEF_FONT_LARGE = "Arial:16"
localeInfo.UI_DEF_FONT_SMALL = "Arial:11"
elif findfont == "Verdana":
localeInfo.UI_DEF_FONT = "Verdana:12"
localeInfo.UI_DEF_FONT_LARGE = "Verdana:16"
localeInfo.UI_DEF_FONT_SMALL = "Verdana:9"
class RefineDialogNew(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__Initialize()
self.isLoaded = False
if app.WJ_ENABLE_TRADABLE_ICON:
self.wndInventory = None
def __Initialize(self):
self.dlgQuestion = None
self.children = []
self.vnum = 0
self.targetItemPos = 0
self.dialogHeight = 0
self.cost = 0
self.percentage = 0
self.type = 0
if app.WJ_ENABLE_TRADABLE_ICON:
self.lockedItem = (-1,-1)
def __LoadScript(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/refinedialog.py")
except:
import exception
exception.Abort("RefineDialog.__LoadScript.LoadObject")
try:
self.board = self.GetChild("Board")
self.titleBar = self.GetChild("TitleBar")
self.probText = self.GetChild("SuccessPercentage")
self.costText = self.GetChild("Cost")
self.successPercentage = self.GetChild("SuccessPercentage")
self.GetChild("AcceptButton").SetEvent(self.OpenQuestionDialog)
self.GetChild("CancelButton").SetEvent(self.CancelRefine)
except:
import exception
exception.Abort("RefineDialog.__LoadScript.BindObject")
## 936 : 개량 확률 표시 안함
##if 936 == app.GetDefaultCodePage():
if constInfo.ENABLE_REFINE_PCT:
self.successPercentage.Show()
else:
self.successPercentage.Hide()
toolTip = uiToolTip.ItemToolTip()
toolTip.SetParent(self)
toolTip.SetFollow(False)
toolTip.SetPosition(15, 38)
toolTip.Show()
self.toolTip = toolTip
self.slotList = []
for i in xrange(3):
slot = self.__MakeSlot()
slot.SetParent(toolTip)
slot.SetWindowVerticalAlignCenter()
self.slotList.append(slot)
itemImage = self.__MakeItemImage()
itemImage.SetParent(toolTip)
itemImage.SetWindowVerticalAlignCenter()
itemImage.SetPosition(-35, 0)
self.itemImage = itemImage
self.titleBar.SetCloseEvent(ui.__mem_func__(self.CancelRefine))
#if constInfo.ENABLE_REFINE_ITEM_DESCRIPTION:
# self.tooltipItem = uiToolTip.ItemToolTip()
# self.tooltipItem.Hide()
# self.checkBox = ui.CheckBoxRefine()
# self.checkBox.SetParent(self)
# self.checkBox.SetPosition(0, 80)
# self.checkBox.SetWindowHorizontalAlignCenter()
# self.checkBox.SetWindowVerticalAlignBottom()
# self.checkBox.SetEvent(ui.__mem_func__(self.AutoRefine), "ON_CHECK", True)
# self.checkBox.SetEvent(ui.__mem_func__(self.AutoRefine), "ON_UNCKECK", False)
# self.checkBox.SetCheckStatus(constInfo.IS_AUTO_REFINE)
# self.checkBox.SetTextInfo(localeInfo.REFINE_KEEP_WINDOW)
# self.checkBox.Show()
self.isLoaded = True
def __del__(self):
ui.ScriptWindow.__del__(self)
def __MakeSlot(self):
slot = ui.ImageBox()
slot.LoadImage("d:/ymir work/ui/public/slot_base.sub")
slot.Show()
self.children.append(slot)
return slot
def __MakeItemImage(self):
itemImage = ui.ImageBox()
itemImage.Show()
self.children.append(itemImage)
return itemImage
if app.__ENABLE_NEW_OFFLINESHOP__:
def __MakeButton(self):
button = ui.Button()
button.Show()
self.children.append(button)
return button
def __MakeThinBoard(self):
thinBoard = ui.ThinBoard()
thinBoard.SetParent(self)
thinBoard.Show()
self.children.append(thinBoard)
return thinBoard
def Destroy(self):
self.ClearDictionary()
self.dlgQuestion = None
self.board = 0
self.probText = 0
self.costText = 0
self.titleBar = 0
self.toolTip = 0
self.successPercentage = None
self.slotList = []
self.children = []
if app.WJ_ENABLE_TRADABLE_ICON:
self.wndInventory = None
self.lockedItem = (-1,-1)
def __InitializeOpen(self):
self.children = []
self.vnum = 0
self.targetItemPos = 0
self.dialogHeight = 0
self.cost = 0
self.percentage = 0
self.type = 0
self.xRefineStart = 0
self.yRefineStart = 0
def Open(self, targetItemPos, nextGradeItemVnum, cost, prob, type):
if False == self.isLoaded:
self.__LoadScript()
self.__InitializeOpen()
self.targetItemPos = targetItemPos
self.vnum = nextGradeItemVnum
self.cost = cost
self.percentage = prob
self.type = type
self.probText.SetText(localeInfo.REFINE_SUCCESS_PROBALITY % (self.percentage))
self.costText.SetText(localeInfo.REFINE_COST % (self.cost))
if app.WJ_ENABLE_TRADABLE_ICON:
self.SetCantMouseEventSlot(targetItemPos)
self.toolTip.ClearToolTip()
metinSlot = []
for i in xrange(player.METIN_SOCKET_MAX_NUM):
metinSlot.append(player.GetItemMetinSocket(targetItemPos, i))
attrSlot = []
for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
attrSlot.append(player.GetItemAttribute(targetItemPos, i))
self.toolTip.AddRefineItemData(nextGradeItemVnum, metinSlot, attrSlot)
item.SelectItem(nextGradeItemVnum)
self.itemImage.LoadImage(item.GetIconImageFileName())
xSlotCount, ySlotCount = item.GetItemSize()
for slot in self.slotList:
slot.Hide()
for i in xrange(min(3, ySlotCount)):
self.slotList[i].SetPosition(-35, i*32 - (ySlotCount-1)*16)
self.slotList[i].Show()
self.dialogHeight = self.toolTip.GetHeight() + 46
self.UpdateDialog()
self.SetTop()
self.Show()
def Close(self):
if self.dlgQuestion:
self.dlgQuestion.Close()
self.dlgQuestion = None
self.Hide()
if app.WJ_ENABLE_TRADABLE_ICON:
self.lockedItem = (-1, -1)
self.SetCanMouseEventSlot(self.targetItemPos)
if constInfo.ENABLE_REFINE_ITEM_DESCRIPTION:
def __MakeItemSlot(self, slotIndex):
slot = ui.SlotWindow()
slot.SetParent(self)
slot.SetSize(32, 32)
slot.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0)
slot.AppendSlot(slotIndex, 0, 0, 32, 32)
slot.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
slot.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
slot.RefreshSlot()
slot.Show()
self.children.append(slot)
return slot
def OverInItem(self, slotIndex):
import grp, nonplayer
if not self.tooltipItem or slotIndex > len(TOOLTIP_DATA['materials']):
return
slotVnum = TOOLTIP_DATA['materials'][slotIndex]
self.tooltipItem.ClearToolTip()
self.tooltipItem.AddItemData(slotVnum, 0, 0, 0, 0, player.INVENTORY)
self.tooltipItem.AlignHorizonalCenter()
self.tooltipItem.ShowToolTip()
def OverOutItem(self):
if self.tooltipItem:
self.tooltipItem.HideToolTip()
def AppendMaterial(self, vnum, count):
if constInfo.ENABLE_REFINE_ITEM_DESCRIPTION:
slotIndex = len(TOOLTIP_DATA['materials'])
slot = self.__MakeItemSlot(slotIndex)
slot.SetPosition(15, self.dialogHeight)
slot.SetItemSlot(slotIndex, vnum, count)
TOOLTIP_DATA['materials'].append(vnum)
else:
slot = self.__MakeSlot()
slot.SetParent(self)
slot.SetPosition(15, self.dialogHeight)
itemImage = self.__MakeItemImage()
itemImage.SetParent(slot)
item.SelectItem(vnum)
itemImage.LoadImage(item.GetIconImageFileName())
thinBoard = self.__MakeThinBoard()
thinBoard.SetPosition(50, self.dialogHeight)
thinBoard.SetSize(191, 20)
textLine = ui.TextLine()
textLine.SetParent(thinBoard)
if os.path.exists("font.cfg"):
file = open( "font.cfg" , "r")
findfont = file.readline()
if findfont == "Tahoma":
localeInfo.UI_DEF_FONT = "Tahoma:12"
localeInfo.UI_DEF_FONT_LARGE = "Tahoma:14"
localeInfo.UI_DEF_FONT_SMALL = "Tahoma:9"
elif findfont == "TahomaSmall":
localeInfo.UI_DEF_FONT = "Tahoma:11"
localeInfo.UI_DEF_FONT_LARGE = "Tahoma:13"
localeInfo.UI_DEF_FONT_SMALL = "Tahoma:8"
elif findfont == "Arial":
localeInfo.UI_DEF_FONT = "Arial:14"
localeInfo.UI_DEF_FONT_LARGE = "Arial:16"
localeInfo.UI_DEF_FONT_SMALL = "Arial:11"
elif findfont == "Verdana":
localeInfo.UI_DEF_FONT = "Verdana:12"
localeInfo.UI_DEF_FONT_LARGE = "Verdana:16"
localeInfo.UI_DEF_FONT_SMALL = "Verdana:9"
textLine.SetFontName(findfont)
textLine.SetPackedFontColor(0xffdddddd)
have_count = player.GetItemCountByVnum(vnum)
if have_count < count:
textLine.SetFontColor(1.0, 0.0, 0.0)
else:
textLine.SetFontColor(0.0, 1.0, 0.0)
textLine.SetText("%s x %02d / %02d" % (item.GetItemName(), count, have_count))
textLine.SetOutline()
textLine.SetFeather(False)
textLine.SetWindowVerticalAlignCenter()
textLine.SetVerticalAlignCenter()
if localeInfo.IsARABIC():
(x,y) = textLine.GetTextSize()
textLine.SetPosition(x, 0)
else:
textLine.SetPosition(15, 0)
textLine.Show()
self.children.append(textLine)
if app.__ENABLE_NEW_OFFLINESHOP__:
searchButton = self.__MakeButton()
searchButton.SetParent(self)
searchButton.SetPosition(200, self.dialogHeight + 5)
searchButton.SetUpVisual("offlineshop/search.tga")
searchButton.SetOverVisual("offlineshop/search_in.tga")
searchButton.SetDownVisual("offlineshop/search_down.tga")
searchButton.SetEvent(lambda arg=item.GetItemName(): self.StartSearch(arg))
self.dialogHeight += 34
self.UpdateDialog()
if app.__ENABLE_NEW_OFFLINESHOP__:
def BindInterface(self, interface):
self.interface = interface
def StartSearch(self, itemName):
if self.interface.offlineshop:
self.interface.offlineshop.OpenSearch()
if self.interface.offlineshop:
self.interface.offlineshop.wndSearchShop.SearchDirect(itemName)
#if offlineshop.GetOfflineshopBoard():
# offlineshop.GetOfflineshopBoard().SearchFilterCheckBoxes["name"].Enable()
# offlineshop.GetOfflineshopBoard().SearchFilterItemNameInput.SetText(itemName)
# offlineshop.GetOfflineshopBoard().OnClickSearchFilterStartSearch()
def UpdateDialog(self):
newWidth = self.toolTip.GetWidth() + 60
newHeight = self.dialogHeight + 85
## 936 : 개량 확률 표시 안함
##if 936 == app.GetDefaultCodePage():
newHeight -= 8
if localeInfo.IsARABIC():
self.board.SetPosition( newWidth, 0 )
(x, y) = self.titleBar.GetLocalPosition()
self.titleBar.SetPosition( newWidth - 15, y )
self.board.SetSize(newWidth, newHeight)
self.toolTip.SetPosition(15 + 35, 38)
self.titleBar.SetWidth(newWidth-15)
self.SetSize(newWidth, newHeight)
(x, y) = self.GetLocalPosition()
self.SetPosition(x, y)
def OpenQuestionDialog(self):
#if 100 == self.percentage:
# self.Accept()
# return
#if 5 == self.type:
# self.Accept()
# return
#dlgQuestion = uiCommon.QuestionDialog2()
#dlgQuestion.SetText2(localeInfo.REFINE_WARNING2)
#dlgQuestion.SetAcceptEvent(ui.__mem_func__(self.Accept))
#dlgQuestion.SetCancelEvent(ui.__mem_func__(dlgQuestion.Close))
#if 3 == self.type: ## 현철
# dlgQuestion.SetText1(localeInfo.REFINE_DESTROY_WARNING_WITH_BONUS_PERCENT_1)
# dlgQuestion.SetText2(localeInfo.REFINE_DESTROY_WARNING_WITH_BONUS_PERCENT_2)
#elif 2 == self.type: ## 축복서
# dlgQuestion.SetText1(localeInfo.REFINE_DOWN_GRADE_WARNING)
#else:
# dlgQuestion.SetText1(localeInfo.REFINE_DESTROY_WARNING)
#dlgQuestion.Open()
#self.dlgQuestion = dlgQuestion
self.Accept()
def Accept(self):
net.SendRefinePacket(self.targetItemPos, self.type)
self.Close()
#def AutoRefine(self, checkType, autoFlag):
# constInfo.IS_AUTO_REFINE = autoFlag
def CancelRefine(self):
if constInfo.ENABLE_REFINE_ITEM_DESCRIPTION:
TOOLTIP_DATA['materials'] = []
constInfo.TEMP_LAST_REFINED_ITEM = 50055
constInfo.TEMP_LAST_REFINED_ITEM_SRC_SLOT_POS = -1
constInfo.TEMP_LAST_REFINED_ITEM_DST_SLOT_POS = -1
net.SendRefinePacket(255, 255)
self.Close()
def OnPressEscapeKey(self):
self.CancelRefine()
return True
if app.WJ_ENABLE_TRADABLE_ICON:
def SetCanMouseEventSlot(self, slotIndex):
itemInvenPage = slotIndex / player.INVENTORY_PAGE_SIZE
localSlotPos = slotIndex - (itemInvenPage * player.INVENTORY_PAGE_SIZE)
self.lockedItem = (-1, -1)
if itemInvenPage == self.wndInventory.GetInventoryPageIndex():
self.wndInventory.wndItem.SetCanMouseEventSlot(localSlotPos)
def SetCantMouseEventSlot(self, slotIndex):
itemInvenPage = slotIndex / player.INVENTORY_PAGE_SIZE
localSlotPos = slotIndex - (itemInvenPage * player.INVENTORY_PAGE_SIZE)
self.lockedItem = (itemInvenPage, localSlotPos)
if itemInvenPage == self.wndInventory.GetInventoryPageIndex():
self.wndInventory.wndItem.SetCantMouseEventSlot(localSlotPos)
def SetInven(self, wndInventory):
from _weakref import proxy
self.wndInventory = proxy(wndInventory)
def RefreshLockedSlot(self):
if self.wndInventory:
itemInvenPage, itemSlotPos = self.lockedItem
if self.wndInventory.GetInventoryPageIndex() == itemInvenPage:
self.wndInventory.wndItem.SetCantMouseEventSlot(itemSlotPos)
self.wndInventory.wndItem.RefreshSlot()
[/quote][/spoiler]


