view plugins/xxnote.py @ 190:15488fe94f52 beta

Traipse Beta 'OpenRPG' {100125-01} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Beta) New Features: New Bookmarks Feature New 'boot' command to remote admin New confirmation window for sent nodes Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG New Zoom Mouse plugin added New Images added to Plugin UI Switching to Element Tree New Map efficiency, from FlexiRPG New Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) New Portable Mercurial New Tip of the Day, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added New Dieroller structure from Core New DieRoller portability for odd Dice New 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added New vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Beta!) New Grids act more like Spreadsheets in Use mode, with Auto Calc Fixes: Fix to allow for portability to an OpenSUSE linux OS Fix to mplay_client for Fedora and OpenSUSE Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fix to Whiteboard ID to prevent random line or text deleting. Fixes to Server, Remote Server, and Server GUI Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image Fix to whiteboard ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml
author sirebral
date Mon, 25 Jan 2010 12:07:48 -0600
parents c54768cffbd4
children
line wrap: on
line source

import os
import orpg.pluginhandler

class Plugin(orpg.pluginhandler.PluginHandler):
    # Initialization subroutine.
    #
    # !self : instance of self
    # !openrpg : instance of the the base openrpg control
    def __init__(self, plugindb, parent):
        orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent)

        # The Following code should be edited to contain the proper information
        self.name = 'Quick Notes'
        self.author = 'Dj Gilcrease'
        self.help = "This plugin lets you take quick notes on a subject"
        self.notes = {}


    def plugin_enabled(self):
        self.notes = self.plugindb.GetDict("xxnote", "notes", {})

        self.plugin_addcommand('/newnote', self.on_newnote, '{Subject} - Will create a new note subject')
        self.plugin_addcommand('/appendnote', self.on_appendnote, '{Subject}={Note} - Will append a note to {Subject}')
        self.plugin_addcommand('/delnote', self.on_delnote, '{Subject}={Note_id}|all - Will delete {Note_id} from {Subject} or will delete the subject compleatly')
        self.plugin_addcommand('/editnote', self.on_editnote, '{Subject}={Note_id} {Note} - Will replace {Note_id} with {Note} for {Subject}')
        self.plugin_addcommand('/clearnotes', self.on_clearnotes, '- Will clear all of your notes')
        self.plugin_addcommand('/listnotes', self.on_listnotes, '- Will list all of the note subjects you have')
        self.plugin_addcommand('/viewnote', self.on_viewnote, '{Subject} - Will display the notes you have for {Subject}')
        self.plugin_addcommand('/notetonode', self.on_notetonode, '{Subject} - Will create a text node containing your notes for {Subject}')
        self.plugin_addcommand('/notehelp', self.on_notehelp, '- Will Display the help for each command of this plugin!')


    def plugin_disabled(self):
        self.plugin_removecmd('/newnote')
        self.plugin_removecmd('/appendnote')
        self.plugin_removecmd('/editnote')
        self.plugin_removecmd('/delnote')
        self.plugin_removecmd('/listnotes')
        self.plugin_removecmd('/viewnote')
        self.plugin_removecmd('/notetonode')
        self.plugin_removecmd('/notehelp')
        self.plugin_removecmd('/clearnotes')

    def on_newnote(self, cmdargs):
        if len(cmdargs) == 0:
            self.on_notehelp('')
            return

        subject = cmdargs
        if not self.notes.has_key(subject):
            self.notes[subject] = []
            self.plugindb.SetDict("xxnote", "notes", self.notes)
            self.chat.InfoPost("Created new note for " + subject)
        else:
            self.chat.InfoPost("You already have a note with the subject " + subject)

    def on_appendnote(self, cmdargs):
        args = cmdargs.split("=",-1)
        if len(args) < 2:
            self.on_notehelp('')
            return

        subject = args[0]
        note = args[1]
        if not self.notes.has_key(subject):
            self.notes[subject] = []
            self.notes[subject].append(note)
            self.plugindb.SetDict("xxnote", "notes", self.notes)
            self.chat.InfoPost("Created new note for " + subject)
        else:
            self.notes[subject].append(note)
            self.plugindb.SetDict("xxnote", "notes", self.notes)
            self.chat.InfoPost("Appended <i>" + note + "</i> to <b>" + subject + "</b>")

        self.on_viewnote(subject)

    def on_editnote(self, cmdargs):
        args = cmdargs.split("=",-1)
        if len(args) < 2:
            self.on_notehelp('')
            return

        s = args[1].find(" ")
        subject = args[0]
        note_id = int(args[1][:s])
        note = args[1][s:]
        if not self.notes.has_key(subject):
            self.notes[subject] = []
            self.notes[subject].append(note)
            self.plugindb.SetDict("xxnote", "notes", self.notes)
            self.chat.InfoPost("Created new note for " + subject)
        else:
            self.notes[subject][note_id] = note
            self.plugindb.SetDict("xxnote", "notes", self.notes)
            self.chat.InfoPost("Edited <i>" + str(note_id) + ': ' + note + "</i> to <b>" + subject + "</b>")

        self.on_viewnote(subject)

    def on_delnote(self, cmdargs):
        args = cmdargs.split("=",-1)
        if len(args) < 2:
            self.on_notehelp('')
            return

        subject = args[0]
        noteid = args[1]

        if noteid == 'all':
            del self.notes[subject]
            self.plugindb.SetDict("xxnote", "notes", self.notes)
            self.chat.InfoPost("Removed subject " + subject)
        else:
            del self.notes[subject][int(noteid)]
            self.plugindb.SetDict("xxnote", "notes", self.notes)
            self.chat.InfoPost("Removed note " + noteid + " from subject " + subject)
            self.on_viewnote(subject)

    def on_clearnotes(self, cmdargs):
        self.notes = {}
        self.plugindb.SetDict("xxnote", "notes", self.notes)
        self.chat.InfoPost("Cleared all of your notes")

    def on_listnotes(self, cmdargs):
        if len(self.notes) == 0:
            self.chat.InfoPost("You have no notes at this time, use /newnote to create one")
            return
        self.chat.InfoPost("The subjects you have notes on are:")
        for subject in self.notes.keys():
            self.chat.InfoPost("** " + subject)

    def on_viewnote(self, cmdargs):
        if len(cmdargs) == 0:
            self.on_notehelp('')
            return

        subject = cmdargs
        if self.notes.has_key(subject):
            msg = '<table bgcolor="#cccccc"><tr><td colspan="2"><b><font color="#000000">Notes for '
            msg += subject
            msg += ':</font></b></td></tr><tr><td width="10">ID</td><td>Note Text</td></tr>'
            noteid = 0
            for n in self.notes[subject]:
                msg += '<tr><td width="10"><font color="#000000">'
                msg += str(noteid)
                msg += '</font></td>'
                msg += '<td><font color="#000000">'
                msg += n
                msg += '</font></td></tr>'
                noteid += 1

            msg += '</table>'
            self.chat.InfoPost(msg)
        else:
            self.chat.InfoPost("You have no notes for " + subject)

    def on_notetonode(self, cmdargs):
        if len(cmdargs) == 0:
            self.on_notehelp('')
            return

        subject = cmdargs
        if self.notes.has_key(subject):
            node = '<nodehandler class="textctrl_handler" icon="note" module="forms" name="'
            node += subject
            node += '" version="1.0"><text multiline="1" send_button="1">'
            for note in self.notes[subject]:
                node += note + "\n"
            node += '</text></nodehandler>'
            self.gametree.insert_xml(node)
        else:
            self.chat.InfoPost("You have no notes for " + subject)

    def on_notehelp(self, cmdargs):
        self.chat.InfoPost('/newnote ' + self.cmdlist['/newnote']['help'])
        self.chat.InfoPost('/appendnote ' + self.cmdlist['/appendnote']['help'])
        self.chat.InfoPost('/delnote ' + self.cmdlist['/delnote']['help'])
        self.chat.InfoPost('/listnotes ' + self.cmdlist['/listnotes']['help'])
        self.chat.InfoPost('/clearnotes ' + self.cmdlist['/clearnotes']['help'])
        self.chat.InfoPost('/notetonode ' + self.cmdlist['/notetonode']['help'])
        self.chat.InfoPost('/viewnote ' + self.cmdlist['/viewnote']['help'])