Hikayeler

Reklam vermek için turkmmo@gmail.com

Refine İstediği Malzemeyi Çoğaltma [REFINE_MATERIAL_MAX_NUM]

5.00 yıldız(lar) 3 Değerlendirme Değerlendirenler
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...

Metin2 EP, Valorant VP dahil tüm oyun ürünlerini en uygun fiyatlarla bulabilir, Item ve Karakterlerinizi hızlıca satabilirsiniz. HEMEN TIKLA!

Yapmak zaman alır, isteyip yapmak yetenek işidir. Eline sağlık.
 
Elinize sağlık. Ancak böylesi çok da uygun görünmüyor. Küçük ekranlarda pencere önizlemede sıkıntı yaşanabilir.

O yüzden böylesi daha uygun olacaktır.


Orijinalinde 4 adet malzemeye göre ayarlıydı ben de 5 ve sonrası için scrollbar'a bağladım.

Sökmek isteyen olursa diye py dosyalarımı iletiyorum.

uirefine.py:
import app
import net
import player
import item
import ui
import uiToolTip
import mouseModule
import localeInfo
import uiCommon
import constInfo

class RefineDialog(ui.ScriptWindow):

    makeSocketSuccessPercentage = ( 100, 33, 20, 15, 10, 5, 0 )
    upgradeStoneSuccessPercentage = ( 30, 29, 28, 27, 26, 25, 24, 23, 22 )
    upgradeArmorSuccessPercentage = ( 99, 66, 33, 33, 33, 33, 33, 33, 33 )
    upgradeAccessorySuccessPercentage = ( 99, 88, 77, 66, 33, 33, 33, 33, 33 )
    upgradeSuccessPercentage = ( 99, 66, 33, 33, 33, 33, 33, 33, 33 )
  
    def __init__(self):
        ui.ScriptWindow.__init__(self)
        self.__LoadScript()

        self.scrollItemPos = 0
        self.targetItemPos = 0
        self.dialogHeight = 0

    def __LoadScript(self):

        self.__LoadQuestionDialog()

        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.successPercentage = self.GetChild("SuccessPercentage")
            self.GetChild("AcceptButton").SetEvent(self.OpenQuestionDialog)
            self.GetChild("CancelButton").SetEvent(self.Close)
        except:
            import exception
            exception.Abort("RefineDialog.__LoadScript.BindObject")

        if constInfo.ENABLE_REFINE_PCT:
            self.successPercentage.Show()
        else:
            self.successPercentage.Hide()

        toolTip = uiToolTip.ItemToolTip()
        toolTip.SetParent(self)
        toolTip.SetPosition(15, 38)
        toolTip.SetFollow(False)
        toolTip.Show()
        self.toolTip = toolTip

        self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))

    def __del__(self):
        ui.ScriptWindow.__del__(self)

    def __LoadQuestionDialog(self):
        self.dlgQuestion = ui.ScriptWindow()

        try:
            pyScrLoader = ui.PythonScriptLoader()
            pyScrLoader.LoadScriptFile(self.dlgQuestion, "uiscript/questiondialog2.py")
        except:
            import exception
            exception.Abort("RefineDialog.__LoadQuestionDialog.LoadScript")

        try:
            GetObject=self.dlgQuestion.GetChild
            GetObject("message1").SetText(localeInfo.REFINE_DESTROY_WARNING)
            GetObject("message2").SetText(localeInfo.REFINE_WARNING2)
            GetObject("accept").SetEvent(ui.__mem_func__(self.Accept))
            GetObject("cancel").SetEvent(ui.__mem_func__(self.dlgQuestion.Hide))
        except:
            import exception
            exception.Abort("SelectCharacterWindow.__LoadQuestionDialog.BindObject")

    @ui.WindowDestroy
    def Destroy(self):
        self.ClearDictionary()
        self.board = 0
        self.successPercentage = 0
        self.titleBar = 0
        self.toolTip = 0
        self.dlgQuestion = 0

    def GetRefineSuccessPercentage(self, scrollSlotIndex, itemSlotIndex):

        if -1 != scrollSlotIndex:
            if player.IsRefineGradeScroll(scrollSlotIndex):
                curGrade = player.GetItemGrade(itemSlotIndex)
                itemIndex = player.GetItemIndex(itemSlotIndex)

                item.SelectItem(itemIndex)
                itemType = item.GetItemType()
                itemSubType = item.GetItemSubType()

                if item.ITEM_TYPE_METIN == itemType:

                    if curGrade >= len(self.upgradeStoneSuccessPercentage):
                        return 0
                    return self.upgradeStoneSuccessPercentage[curGrade]

                elif item.ITEM_TYPE_ARMOR == itemType:

                    if item.ARMOR_BODY == itemSubType:
                        if curGrade >= len(self.upgradeArmorSuccessPercentage):
                            return 0
                        return self.upgradeArmorSuccessPercentage[curGrade]
                    else:
                        if curGrade >= len(self.upgradeAccessorySuccessPercentage):
                            return 0
                        return self.upgradeAccessorySuccessPercentage[curGrade]

                else:

                    if curGrade >= len(self.upgradeSuccessPercentage):
                        return 0
                    return self.upgradeSuccessPercentage[curGrade]

        for i in xrange(player.METIN_SOCKET_MAX_NUM+1):
            if 0 == player.GetItemMetinSocket(itemSlotIndex, i):
                break

        return self.makeSocketSuccessPercentage[i]

    def Open(self, scrollItemPos, targetItemPos):
        self.scrollItemPos = scrollItemPos
        self.targetItemPos = targetItemPos

        percentage = self.GetRefineSuccessPercentage(scrollItemPos, targetItemPos)
        if 0 == percentage:
            return
        self.successPercentage.SetText(localeInfo.REFINE_SUCCESS_PROBALITY % (percentage))

        itemIndex = player.GetItemIndex(targetItemPos)
        self.toolTip.ClearToolTip()
        metinSlot = []
        for i in xrange(player.METIN_SOCKET_MAX_NUM):
            metinSlot.append(player.GetItemMetinSocket(targetItemPos, i))
        self.toolTip.AddItemData(itemIndex, metinSlot)

        self.UpdateDialog()
        self.SetTop()
        self.Show()

    def OpenQuestionDialog(self):
        percentage = self.GetRefineSuccessPercentage(-1, self.targetItemPos)
        if 100 == percentage:
            self.Accept()
            return

        self.dlgQuestion.SetTop()
        self.dlgQuestion.Show()

    def Accept(self):
        net.SendItemUseToItemPacket(self.scrollItemPos, self.targetItemPos)
        self.Close()

    def Close(self):
        self.dlgQuestion.Hide()
        self.Hide()

    def OnPressEscapeKey(self):
        self.Close()
        return True

class RefineDialogNew(ui.ScriptWindow):

    MATERIAL_SLOT_HEIGHT = 34
    MATERIAL_WINDOW_HEIGHT = 136
    SCROLLBAR_WIDTH = 17

    def __init__(self):
        ui.ScriptWindow.__init__(self)
        self.__Initialize()
        self.isLoaded = False

    def __Initialize(self):
        self.dlgQuestion = None
        self.children = []
      
        self.material_widgets = []
        self.materialList = []
        self.materialWindow = None
        self.materialScrollBar = None
        self.scrollable_widgets = []
      
        self.vnum = 0
        self.targetItemPos = 0
        self.dialogHeight = 0
        self.cost = 0
        self.percentage = 0
        self.type = 0

    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)
          
            self.materialWindow = self.GetChild("MaterialWindow")
            self.materialScrollBar = self.GetChild("MaterialScrollBar")
            self.materialScrollBar.SetScrollEvent(ui.__mem_func__(self.OnScroll))
        except:
            import exception
            exception.Abort("RefineDialog.__LoadScript.BindObject")

        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.__MakeRefineSlot()
            slot.SetParent(toolTip)
            slot.SetWindowVerticalAlignCenter()
            self.slotList.append(slot)

        itemImage = self.__MakeRefineItemImage()
        itemImage.SetParent(toolTip)
        itemImage.SetWindowVerticalAlignCenter()
        itemImage.SetPosition(-35, 0)
        self.itemImage = itemImage

        self.titleBar.SetCloseEvent(ui.__mem_func__(self.CancelRefine))
        self.isLoaded = True

    def __MakeRefineSlot(self):
        slot = ui.ImageBox()
        slot.LoadImage("d:/ymir work/ui/public/slot_base.sub")
        slot.Show()
        return slot

    def __MakeRefineItemImage(self):
        itemImage = ui.ImageBox()
        itemImage.Show()
        return itemImage
      
    def __MakeSlot(self):
        slot = ui.ImageBox()
        slot.LoadImage("d:/ymir work/ui/public/slot_base.sub")
        slot.SetWindowName("MaterialSlot")
        slot.Show()
        return slot

    def __MakeItemImage(self):
        itemImage = ui.ImageBox()
        itemImage.SetWindowName("MaterialItemImage")
        itemImage.Show()
        return itemImage
      
    def __MakeThinBoard(self):
        thinBoard = ui.ThinBoard()
        thinBoard.SetWindowName("MaterialThinBoard")
        thinBoard.Show()
        return thinBoard

    def __del__(self):
        ui.ScriptWindow.__del__(self)

    @ui.WindowDestroy
    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 = []
      
        self.materialList = []
        self.scrollable_widgets = []
      
        if hasattr(self, 'material_widgets'):
            self.material_widgets = []
          
        self.materialWindow = None
        self.materialScrollBar = None

    def ClearMaterial(self):
        for widget in self.material_widgets:
            try:
                widget.Hide()
                widget.SetParent(None)
            except AttributeError:
                pass
            except TypeError:
                pass

        self.material_widgets = []
        self.materialList = []
        self.scrollable_widgets = []
      
        if self.materialScrollBar:
            self.materialScrollBar.SetPos(0.0)
            self.materialScrollBar.Hide()

    def Open(self, targetItemPos, nextGradeItemVnum, cost, prob, type):

        if False == self.isLoaded:
            self.__LoadScript()

        self.ClearMaterial()

        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))

        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):
        self.ClearMaterial()
        if self.dlgQuestion:
            self.dlgQuestion.Close()
        self.Hide()

    def AppendMaterial(self, vnum, count):
        self.materialList.append((vnum, count))
        self.UpdateMaterialDisplay()

    def UpdateMaterialDisplay(self):
        for widget in self.material_widgets:
            try:
                widget.Hide()
                widget.SetParent(None)
            except AttributeError:
                pass
            except TypeError:
                pass
              
        self.material_widgets = []
        self.scrollable_widgets = []

        for i, (vnum, count) in enumerate(self.materialList):
            material_draw_y = i * self.MATERIAL_SLOT_HEIGHT
          
            slot = self.__MakeSlot()
            slot.SetParent(self.materialWindow)
            slot.SetPosition(30, material_draw_y)
            self.material_widgets.append(slot)
            self.scrollable_widgets.append(slot)

            itemImage = self.__MakeItemImage()
            itemImage.SetParent(slot)
            itemImage.SetPosition(1, 1)
            item.SelectItem(vnum)
            itemImage.LoadImage(item.GetIconImageFileName())
            self.material_widgets.append(itemImage)

            thinBoard = self.__MakeThinBoard()
            thinBoard.SetParent(self.materialWindow)
            thinBoard.SetPosition(30 + 39, material_draw_y)
            thinBoard.SetSize(191, 32)
            self.material_widgets.append(thinBoard)
            self.scrollable_widgets.append(thinBoard)
          
            textLine = ui.TextLine()
            textLine.SetParent(thinBoard)
            textLine.SetFontName(localeInfo.UI_DEF_FONT)
            textLine.SetPackedFontColor(0xffdddddd)
            item.SelectItem(vnum)
            textLine.SetText("%s x %d" % (item.GetItemName(), count))
            textLine.SetOutline()
            textLine.SetFeather(False)
            textLine.SetWindowVerticalAlignCenter()
            textLine.SetVerticalAlignCenter()

            if localeInfo.IsARABIC():
                (x,y) = textLine.GetTextSize()
                textLine.SetPosition(thinBoard.GetWidth() - x - 5, 0)
            else:
                textLine.SetPosition(15, 0)

            textLine.Show()
            self.material_widgets.append(textLine)
          
        total_material_count = len(self.materialList)
        total_material_height = total_material_count * self.MATERIAL_SLOT_HEIGHT
      
        if total_material_count > 4:
            self.materialScrollBar.Show()
            self.materialScrollBar.SetMiddleBarSize(
                float(self.MATERIAL_WINDOW_HEIGHT) / float(total_material_height)
            )
        else:
            self.materialScrollBar.Hide()
          
        self.materialScrollBar.SetPos(0.0)
        self.OnScroll()
      
    def OnScroll(self):
        scrollPos = self.materialScrollBar.GetPos()
        total_material_height = len(self.materialList) * self.MATERIAL_SLOT_HEIGHT
        max_scroll_offset = max(0, total_material_height - self.MATERIAL_WINDOW_HEIGHT)
        y_offset = int(scrollPos * max_scroll_offset)
        if y_offset > max_scroll_offset:
            y_offset = max_scroll_offset

        VIEW_TOP = 0
        VIEW_BOTTOM = self.MATERIAL_WINDOW_HEIGHT
        for i in xrange(len(self.materialList)):
            slot = self.scrollable_widgets[i*2]
            thinBoard = self.scrollable_widgets[i*2 + 1]
            slot_y = i * self.MATERIAL_SLOT_HEIGHT
            new_y_top = slot_y - y_offset
            new_y_bottom = new_y_top + self.MATERIAL_SLOT_HEIGHT
            is_visible = (new_y_bottom > VIEW_TOP) and (new_y_top < VIEW_BOTTOM)
            if is_visible:
                slot.SetPosition(slot.GetLocalPosition()[0], new_y_top)
                thinBoard.SetPosition(thinBoard.GetLocalPosition()[0], new_y_top)
                slot.Show()
                thinBoard.Show()
            else:
                slot.Hide()
                thinBoard.Hide()

    def UpdateDialog(self):
        newWidth = self.toolTip.GetWidth() + 80
        TOOLTIP_START_Y = 38
        PADDING = 15
        material_start_y = TOOLTIP_START_Y + self.toolTip.GetHeight() + PADDING
        OFFSET_X = 50
        OFFSET_X_2 = 0
        self.toolTip.SetPosition(OFFSET_X, TOOLTIP_START_Y)
        self.materialWindow.SetPosition(OFFSET_X_2 - 17, material_start_y)
        self.materialScrollBar.SetPosition(OFFSET_X_2 + 245, material_start_y + 15)
        self.materialScrollBar.SetSize(self.SCROLLBAR_WIDTH, self.MATERIAL_WINDOW_HEIGHT)
        BOTTOM_CONTROL_SPACE = 80
        newHeight = material_start_y + self.MATERIAL_WINDOW_HEIGHT + BOTTOM_CONTROL_SPACE
        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.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

    def Accept(self):
        net.SendRefinePacket(self.targetItemPos, self.type)
        self.Close()

    def CancelRefine(self):
        net.SendRefinePacket(255, 255)
        self.Close()

    def OnPressEscapeKey(self):
        self.CancelRefine()
        return True

refinedialog.py:
import uiScriptLocale

window = {
    "name" : "RefineDialog",
    "style" : ("movable", "float",),

    "x" : SCREEN_WIDTH - 400,
    "y" : 70 * 800 / SCREEN_HEIGHT,

    "width" : 0,
    "height" : 0,

    "children" :
    (
        {
            "name" : "Board",
            "type" : "board",
            "style" : ("attach",),

            "x" : 0,
            "y" : 0,

            "width" : 0,
            "height" : 0,

            "children" :
            (
                {
                    "name" : "TitleBar",
                    "type" : "titlebar",
                    "style" : ("attach",),

                    "x" : 8,
                    "y" : 8,

                    "width" : 0,
                    "color" : "red",

                    "children" :
                    (
                        {
                            "name" : "TitleName",
                            "type" : "text",
                            "text" : uiScriptLocale.REFINE_TTILE,
                            "horizontal_align" : "center",
                            "text_horizontal_align" : "center",
                            "x" : 0,
                            "y" : 3,
                        },
                    ),
                },
                {
                    "name" : "MaterialWindow",
                    "type" : "window",
                    "x" : 15,
                    "y" : 240,
                    "width" : 230,
                    "height" : 105,
                },
                {
                    "name" : "MaterialScrollBar",
                    "type" : "scrollbar",
                    "x" : 248,
                    "y" : 240,
                    "size" : 105,
                },
                {
                    "name" : "SuccessPercentage",
                    "type" : "text",
                    "text" : uiScriptLocale.REFINE_INFO,
                    "horizontal_align" : "center",
                    "vertical_align" : "bottom",
                    "text_horizontal_align" : "center",
                    "x" : 0,
                    "y" : 70,
                },
                {
                    "name" : "Cost",
                    "type" : "text",
                    "text" : uiScriptLocale.REFINE_COST,
                    "horizontal_align" : "center",
                    "vertical_align" : "bottom",
                    "text_horizontal_align" : "center",
                    "x" : 0,
                    "y" : 54,
                },
                {
                    "name" : "AcceptButton",
                    "type" : "button",

                    "x" : -35,
                    "y" : 35,

                    "text" : uiScriptLocale.OK,
                    "horizontal_align" : "center",
                    "vertical_align" : "bottom",

                    "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" : "CancelButton",
                    "type" : "button",

                    "x" : 35,
                    "y" : 35,

                    "text" : uiScriptLocale.CANCEL,
                    "horizontal_align" : "center",
                    "vertical_align" : "bottom",

                    "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",
                },
            ),
        },
    ),
}
paylaşım için teşekkür ederim.
Yapmak zaman alır, isteyip yapmak yetenek işidir. Eline sağlık.
teşekkür ederim iyi kullanımlar <3
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...

Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)

Geri
Üst