2012-09-21 12:01:16 +00:00
|
|
|
'''
|
|
|
|
Plugin showing tool learning hints in console
|
|
|
|
'''
|
|
|
|
|
2012-09-19 12:10:51 +00:00
|
|
|
from Tank.Core import AbstractPlugin
|
|
|
|
from Tank.Plugins.ConsoleOnline import ConsoleOnlinePlugin, AbstractInfoWidget
|
|
|
|
import os
|
|
|
|
import random
|
|
|
|
import textwrap
|
|
|
|
|
|
|
|
class TipsAndTricksPlugin(AbstractPlugin, AbstractInfoWidget):
|
2012-09-21 12:01:16 +00:00
|
|
|
'''
|
|
|
|
Tips showing plugin
|
|
|
|
'''
|
2012-09-19 12:28:28 +00:00
|
|
|
SECTION = 'tips'
|
|
|
|
|
2012-09-19 12:10:51 +00:00
|
|
|
def __init__(self, core):
|
|
|
|
AbstractPlugin.__init__(self, core)
|
2012-09-21 12:01:16 +00:00
|
|
|
AbstractInfoWidget.__init__(self)
|
2012-09-19 12:10:51 +00:00
|
|
|
lines = open(os.path.dirname(__file__) + '/tips.txt').readlines()
|
2012-09-19 12:40:00 +00:00
|
|
|
line = random.choice(lines)
|
|
|
|
self.section = line[:line.index(':')]
|
2012-09-20 10:16:27 +00:00
|
|
|
self.tip = line[line.index(':') + 1:].strip()
|
2012-09-19 12:46:10 +00:00
|
|
|
self.disable = 0
|
2012-09-19 12:10:51 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_key():
|
2012-09-19 12:46:10 +00:00
|
|
|
return __file__
|
2012-09-19 12:10:51 +00:00
|
|
|
|
|
|
|
def configure(self):
|
2012-09-19 12:28:28 +00:00
|
|
|
self.disable = int(self.get_option('disable', '0'))
|
2012-09-19 12:10:51 +00:00
|
|
|
|
|
|
|
def prepare_test(self):
|
2012-09-19 12:28:28 +00:00
|
|
|
if not self.disable:
|
|
|
|
try:
|
|
|
|
console = self.core.get_plugin_of_type(ConsoleOnlinePlugin)
|
2012-09-19 12:46:10 +00:00
|
|
|
except KeyError, ex:
|
2012-09-19 12:28:28 +00:00
|
|
|
self.log.debug("Console not found: %s", ex)
|
|
|
|
console = None
|
|
|
|
|
|
|
|
if console:
|
|
|
|
console.add_info_widget(self)
|
2012-09-19 12:10:51 +00:00
|
|
|
|
|
|
|
def get_index(self):
|
2012-09-21 13:40:29 +00:00
|
|
|
return 10000 # really last index
|
2012-09-19 12:10:51 +00:00
|
|
|
|
|
|
|
def render(self, screen):
|
2012-09-19 13:19:57 +00:00
|
|
|
line = screen.markup.WHITE + "Tips & Tricks => " + self.section + screen.markup.RESET + ":\n "
|
2012-09-20 10:16:27 +00:00
|
|
|
line += "\n ".join(textwrap.wrap(self.tip, screen.right_panel_width - 1))
|
2012-09-19 12:10:51 +00:00
|
|
|
return line
|
|
|
|
|