diff --git a/sys.py/UI/above_all_patch.py b/sys.py/UI/above_all_patch.py index 5cfcf17..1e99cb2 100644 --- a/sys.py/UI/above_all_patch.py +++ b/sys.py/UI/above_all_patch.py @@ -67,36 +67,55 @@ class AboveAllPatch(object): class SoundPatch(AboveAllPatch): - - _ValColor = pygame.Color(131,199,219) - _Segs = [0,15,29, 45,55,65, 75,90,100] + +# _Segs = [0,15,29, 45,55,65, 75,90,100] snd_segs = [ [0,20],[21,40],[41,50],[51,60],[61,70],[71,85],[86,90],[91,95],[96,100] ] - + _Needle = 0 + def Init(self): self.SetCanvasHWND(self._Parent._CanvasHWND) def VolumeUp(self): m = alsaaudio.Mixer() vol = m.getvolume()[0] - vol += 10 - if vol > 100: - vol = 100 - - m.setvolume(vol) - - self._Value = vol - return vol + for i,v in enumerate(self.snd_segs): + if vol >= v[0] and vol <= v[1]: + self._Needle = i + break + + self._Needle += 1 + if self._Needle > len(self.snd_segs) -1: + self._Needle = len(self.snd_segs) -1 + + m.setvolume( self.snd_segs[self._Needle][1] ) ## prefer bigger one + + self._Value = self.snd_segs[self._Needle][1] + +# print( self._Value) + return self._Value def VolumeDown(self): m = alsaaudio.Mixer() vol = m.getvolume()[0] - vol -= 10 + + for i,v in enumerate(self.snd_segs): + if vol >= v[0] and vol <= v[1]: + self._Needle = i + break + + self._Needle -= 1 + if self._Needle < 0: + self._Needle = 0 + + vol = self.snd_segs[self._Needle][0] ## prefer smaller one + if vol < 0: vol = 0 m.setvolume(vol) - print(vol) +# print(vol) + self._Value = vol return vol @@ -104,15 +123,9 @@ class SoundPatch(AboveAllPatch): def Draw(self): # 200 total width # h = 40 - ge = 0 - for i,v in enumerate(self.snd_segs): - if self._Value >= v[0] and self._Value <= v[1]: - ge = i - break - - for i in range(0,ge+1): + for i in range(0,self._Needle+1): #w = 10,h = 40 vol_rect = pygame.Rect(80+i*20, self._Height/2+20,10, 40) - aa_round_rect(self._CanvasHWND,vol_rect, self._ValColor,3,0, self._ValColor) + aa_round_rect(self._CanvasHWND,vol_rect, self._Parent._SkinManager.GiveColor("Front"),3,0, self._Parent._SkinManager.GiveColor("Front"))