Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- # Не удалять эту строку - для правильного определения кодировки " 65001 (UTF-8) без BOM "
- from Components.config import config, ConfigNumber, ConfigSubsection, ConfigYesNo
- from Plugins.Plugin import PluginDescriptor
- from . import _
- config.plugins.Animation = ConfigSubsection()
- config.plugins.Animation.enabled = ConfigYesNo(default=False)
- config.plugins.Animation.delay = ConfigNumber(default=500)
- config.plugins.Animation.aspect = ConfigYesNo(default=True)
- ##From Animation.py##
- from os.path import exists
- from enigma import ePicLoad, eTimer, getDesktop
- from Components.config import config
- from Components.Pixmap import Pixmap
- from Screens.Screen import Screen
- from Tools.Directories import resolveFilename, SCOPE_PLUGINS
- class AnimationScreen(Screen):
- def __init__(self, session):
- Screen.__init__(self, session)
- self.screenWidth = getDesktop(0).size().width()
- self.screenHeight = getDesktop(0).size().height()
- self.skin = """<screen position="fill" zPosition="-7" flags="wfNoBorder" backgroundColor="#ffffffff">
- <widget name="Animation" position="0,0" size="%s,%s" transparent="1"/>
- </screen>""" % (self.screenWidth, self.screenHeight)
- self['Animation'] = Pixmap()
- self['Animation'].hide()
- self.pixmapCount = 0
- self.picload = None
- self.pixmaps = {}
- if config.plugins.Animation.aspect.value:
- from Components.AVSwitch import AVSwitch
- self.sc = AVSwitch().getFramebufferScale()
- else:
- self.sc = [0, 0]
- self.pixmapTaimer = eTimer()
- self.pixmapTaimer.timeout.callback.append(self.updatePixmaps)
- self.animeTimer = eTimer()
- self.animeTimer.callback.append(self.startAnimation)
- self.onLayoutFinish.append(self.decodeAllPixmaps)
- def decodeAllPixmaps(self):
- animePixmap = resolveFilename(SCOPE_PLUGINS,
- 'Extensions/Animation/anime/anime-%02d.png' % self.pixmapCount)
- if exists(animePixmap):
- self.decodePixmap(animePixmap)
- else:
- if self.pixmapCount == 0:
- print '[AnimationScreen] ERROR: Pixmaps not fund', animePixmap
- self.close()
- else:
- self.pixmapCount = 0
- self['Animation'].show()
- self.animeTimer.start(config.plugins.Animation.delay.value, False)
- def decodePixmap(self, animePixmap):
- self.picload = ePicLoad()
- self.picload.PictureData.get().append(self.finishDecode)
- self.picload.setPara((
- self.screenWidth, self.screenHeight,
- self.sc[0], self.sc[1], False, 1, '#ff000000'))
- self.picload.startDecode(animePixmap)
- def finishDecode(self, picInfo=None):
- ptr = self.picload.getData()
- if ptr:
- self.pixmaps[self.pixmapCount] = ptr
- self.picload = None
- self.pixmapTaimer.start(1)
- def updatePixmaps(self):
- self.pixmapTaimer.stop()
- if self.picload is not None:
- self.pixmapTaimer.start(1)
- else:
- self.pixmapCount += 1
- self.decodeAllPixmaps()
- def startAnimation(self):
- self['Animation'].instance.setPixmap(self.pixmaps[self.pixmapCount].__deref__())
- self.pixmapCount += 1
- if self.pixmapCount == len(self.pixmaps):
- self.pixmapCount = 0
- class Animation():
- def __init__(self):
- self.dialog = None
- def startSession(self, session):
- self.dialog = session.instantiateDialog(AnimationScreen)
- self.dialog.show()
- def stopSession(self, session):
- session.deleteDialog(self.dialog)
- self.dialog = None
- AnimationSession = Animation()
- ##From AnimationSetup.py##
- from Components.ActionMap import ActionMap
- from Components.config import config, getConfigListEntry
- from Components.ConfigList import ConfigListScreen
- from Components.Label import Label
- from Components.Sources.StaticText import StaticText
- from Screens.Screen import Screen
- from . import _
- #from Animation import AnimationSession
- class AnimationSetup(ConfigListScreen, Screen):
- def __init__(self, session):
- Screen.__init__(self, session)
- self.session = session
- self.skinName = ['AnimationSetup', 'Setup']
- self['key_red'] = StaticText(_('Cancel'))
- self['key_green'] = StaticText(_('Ok'))
- self['description'] = Label('')
- self['setupActions'] = ActionMap(['SetupActions', 'ColorActions'],
- {
- 'cancel': self.keyCancel,
- 'red': self.keyCancel,
- 'ok': self.ok,
- 'green': self.ok
- }, -2)
- configlist = []
- ConfigListScreen.__init__(self, configlist, session=session)
- configlist.append(getConfigListEntry(_('Start animation'),
- config.plugins.Animation.enabled,
- _('Start showing an animation.\nIt will work also after restart.')))
- configlist.append(getConfigListEntry(_('Dealey between animations'),
- config.plugins.Animation.delay,
- _('How long you will see one animated picture.\nAnimation will be faster at less value.')))
- configlist.append(getConfigListEntry(_('Keep aspect ratio'),
- config.plugins.Animation.aspect,
- _('Keep animation picture aspect ratio when scale it over the whole screen.')))
- self['config'].list = configlist
- self['config'].l.setList(configlist)
- self.setTitle(_('Animation setup'))
- def ok(self):
- if AnimationSession.dialog is not None:
- AnimationSession.stopSession(self.session)
- if config.plugins.Animation.delay.value < 1:
- config.plugins.Animation.delay.value = 1
- if config.plugins.Animation.enabled.value:
- AnimationSession.startSession(self.session)
- self.keySave()
- #####################
- def sessionstart(reason, **kwargs):
- if reason == 0:
- #from Animation import AnimationSession
- AnimationSession.startSession(kwargs['session'])
- def main(session, **kwargs):
- #from AnimationSetup import AnimationSetup
- session.open(AnimationSetup)
- def Plugins(**kwargs):
- plugin = [PluginDescriptor(
- name=_('Snow'),
- description=_('Show the "Snow" on the screen'),
- where=[PluginDescriptor.WHERE_PLUGINMENU],
- #PluginDescriptor.WHERE_EXTENSIONSMENU],
- icon='plugin.png',
- fnc=main)]
- if config.plugins.Animation.enabled.value:
- plugin.append(PluginDescriptor(
- where=[PluginDescriptor.WHERE_SESSIONSTART],
- fnc=sessionstart))
- return plugin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement