oldschool-toontown/toontown/shtiker/InGameNewsFrame.py

40 lines
1.2 KiB
Python
Raw Permalink Normal View History

2019-11-02 17:27:54 -05:00
import datetime
from toontown.shtiker import HtmlView
class InGameNewsFrame(HtmlView.HtmlView):
TaskName = 'HtmlViewUpdateTask'
def __init__(self, parent = aspect2d):
HtmlView.HtmlView.__init__(self, parent)
self.initialLoadDone = False
self.accept('newsSnapshot', self.doSnapshot)
def activate(self):
self.quad.show()
self.calcMouseLimits()
if not self.initialLoadDone:
inGameNewsUrl = self.getInGameNewsUrl()
self.webView.loadURL2(inGameNewsUrl)
self.initialLoadDone = True
taskMgr.add(self.update, self.TaskName)
def deactivate(self):
self.quad.hide()
taskMgr.remove(self.TaskName)
def unload(self):
self.deactivate()
HtmlView.HtmlView.unload(self)
self.ignore('newsSnapshot')
def doSnapshot(self):
curtime = datetime.datetime.now()
filename = 'news_snapshot_' + curtime.isoformat()
filename = filename.replace(':', '-')
filename = filename.replace('.', '-')
pngfilename = filename + '.png'
self.writeTex(pngfilename)
jpgfilename = filename + '.png'
2019-11-02 17:27:54 -05:00
self.writeTex(jpgfilename)
return jpgfilename