Bvural41 1
Bvural41
mavzermete 1
mavzermete
Fethi Polat 1
Fethi Polat
xranzei 1
xranzei
BlackFullMoon 1
BlackFullMoon
noisiv 1
noisiv
Manwe Work 1
Manwe Work
Hikaye Ekle

Animasyonlu Geçiş Anahtarı - Python

HERAKLES Otomatik Avlı kalıcı sunucu. 19 Haziran'da açılıyor. Atius & Wizard güvencesiyle hemen kayıt ol, ön kayıt ödülleri aktif. HEMEN TIKLA!


CheckBox sınıfına çok benzer, bu yüzden onu kullanmak için tek yapmanız gereken kullanıcı arayüzünü değiştirmek. ui.CheckBox() -> ui.ToggleSwitch()

ve "ON_UNCKECK" ile ilgili herhangi bir sorununuz varsa

self.checkBox.SetEvent(ui.__mem_func__(self.SetAllColor), "ON_UNCKECK", False)​

sadece düzeltin

self.checkBox.SetEvent(ui.__mem_func__(self.SetAllColor), "ON_UNCHECK", False)

picture (1).gif



İçerik Hakkında Önemli Bilgilendirme

  1. Raporlama: Bu içerik daha önce paylaşılmışsa veya tekrar eden bir gönderi olduğunu düşünüyorsanız, durumu bildirerek rapor edebilirsiniz.
  2. Kaynak Uyarısı: İçerik, farklı bir kaynaktan alınmıştır. Bu nedenle içeriğin doğruluğunda eksiklikler veya hatalar olabileceğini lütfen göz önünde bulundurun.
  3. Bağlantı Geçerliliği: Paylaşılan indirme bağlantıları zaman içinde geçersiz hale gelebilir. Böyle bir durumla karşılaşırsanız, bildirmeniz halinde bağlantı güncellenecektir.
  4. Uzmanlık Sınırlaması: Metin2 geliştiriciliği konusunda profesyonel bir uzmanlık alanına sahip değilim. Bu nedenle karşılaşabileceğiniz hataları veya önerilerinizi, konu altından iletmeniz durumunda elimden gelen desteği sağlamaya çalışırım.
Anlayışınız ve iş birliğiniz için teşekkür ederim!
Kod:
import math
MAIN_PATH = "d:/ymir work/ui/game/toggle_switch/special/"
class ToggleSwitch(Window):
    def __init__(self):
        Window.__init__(self)
        self._Initialize()
        self.CreateElements()
     
    def __del__(self):
        Window.__del__(self)
        self._Initialize()
 
    def _Initialize(self):
        self.backgroundImage = None
        self.checkImage = None
     
        self.eventFunc = { "ON_CHECK" : None, "ON_UNCHECK" : None, }
        self.eventArgs = { "ON_CHECK" : None, "ON_UNCHECK" : None, }
     
        self.isChecked = False
        self.animationProgress = 0
        self.animationDuration = 10
        self.isAnimating = False
     
        self.uncheckedXPosition = 0
        self.checkedXPosition = 13
        self.animationDistance = self.checkedXPosition - self.uncheckedXPosition
 
    def CreateElements(self):
        self.backgroundImage = ImageBox()
        self.backgroundImage.SetParent(self)
        self.backgroundImage.AddFlag("not_pick")
        self.backgroundImage.SetPosition(0, 0)
        self.backgroundImage.LoadImage(MAIN_PATH + "bg.png")
        self.backgroundImage.Show()
     
        self.checkImage = ImageBox()
        self.checkImage.SetParent(self.backgroundImage)
        self.checkImage.AddFlag("not_pick")
        self.checkImage.SetPosition(self.uncheckedXPosition, 0)
        self.checkImage.LoadImage(MAIN_PATH + "Unchecked.png")
        self.checkImage.Show()
     
        self.textInfo = TextLine()
        self.textInfo.SetParent(self)
        self.textInfo.SetPosition(0, 0)
        self.textInfo.SetWindowHorizontalAlignRight()
        self.textInfo.Show()
     
        self.SetSize(self.backgroundImage.GetWidth(), self.backgroundImage.GetHeight())
     
        self.backgroundImage.SetWindowHorizontalAlignCenter()
     
    def SetTextInfo(self, info, x = 50, y = 0):
        if self.textInfo:
            self.textInfo.SetText(info)
            self.textInfo.SetPosition(x, y)
     
    def SetCheckStatus(self, flag):
        if flag != self.isChecked:
            self.isChecked = flag
            self.StartAnimation()
 
    def GetCheckStatus(self):
        if self.checkImage:
            return self.isChecked
         
        return False
     
    def SetEvent(self, func, *args) :
        result = self.eventFunc.has_key(args[0])    
        if result :
            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 not self.isAnimating:
            self.isChecked = not self.isChecked
            self.StartAnimation()

            if self.isChecked and self.eventFunc["ON_CHECK"]:
                apply(self.eventFunc["ON_CHECK"], self.eventArgs["ON_CHECK"])
            elif not self.isChecked and self.eventFunc["ON_UNCHECK"]:
                apply(self.eventFunc["ON_UNCHECK"], self.eventArgs["ON_UNCHECK"])

    def StartAnimation(self):
        self.isAnimating = True
        self.animationProgress = 0
        self.checkImage.Show()

    def OnRender(self):
        if self.isAnimating:
            self.animationProgress += 1
            progress = float(self.animationProgress) / self.animationDuration

            if progress <= 1:
                x_offset = int(math.sin(progress * math.pi / 2) * self.animationDistance)
             
                if self.isChecked:
                    self.checkImage.SetPosition(self.uncheckedXPosition + x_offset, 0)
                    self.checkImage.LoadImage(MAIN_PATH + "Checked.png")
                else:
                    self.checkImage.SetPosition(self.checkedXPosition - x_offset, 0)
                    self.checkImage.LoadImage(MAIN_PATH + "Unchecked.png")
            else:
                self.isAnimating = False
                self.animationProgress = 0
             
                if self.isChecked:
                    self.checkImage.SetPosition(self.checkedXPosition, 0)
                    self.checkImage.LoadImage(MAIN_PATH + "Checked.png")
                else:
                    self.checkImage.SetPosition(self.uncheckedXPosition, 0)
                    self.checkImage.LoadImage(MAIN_PATH + "Unchecked.png")
 

Ekli dosyalar

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

Geri
Üst