annotate plugins/xxminiquicknote.py @ 196:0bc44a57ae6c alpha

Traipse Alpha 'OpenRPG' {100425-00} 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 (Patch-2) New Features: New Namespace method with two new syntaxes New Namespace Internal is context sensitive, always! New Namespace External is 'as narrow as you make it' New PluginDB access for URL2Link plugin New to Forms, they now show their content in Design Mode Fixes: Fix to Server GUI startup errors Fix to Server GUI Rooms tab updating Fix to Chat and Settings if non existant die roller is picked Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated Fix to Alias Lib's Export to Tree, Open, Save features Fix to alias node, now works properly Fix to Splitter node, minor GUI cleanup Fix to Backgrounds not loading through remote loader Fix to Node name errors Fix to rolling dice in chat Whispers Fix to Splitters Sizing issues
author sirebral
date Sun, 25 Apr 2010 23:26:55 -0500
parents b633f4c64aae
children
rev   line source
195
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
1 import os
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
2 import orpg.pluginhandler
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
3 from orpg.mapper.miniatures_handler import *
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
4 from orpg.orpgCore import *
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
5 import wx
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
6
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
7
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
8 class QuickNoteDialog(wx.Dialog):
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
9 def __init__(self):
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
10 wx.Dialog.__init__(self, None, -1, "Quick Note", size=(250, 210))
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
11 self.text = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
12 sizer = wx.BoxSizer(wx.VERTICAL)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
13 sizer.Add(self.text, 1, wx.EXPAND)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
14 self.SetSizer(sizer)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
15
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
16 class Plugin(orpg.pluginhandler.PluginHandler):
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
17 def __init__(self, plugindb, parent):
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
18 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
19 self.name = 'Mini Quick Notes'
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
20 self.author = 'David'
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
21 self.help = """Allows you to add private notes when you right-click on a mini on the map.
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
22
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
23 Note: it will try to save data between sessions but you must load plugin AFTER the map has been loaded
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
24 so do not auto-load this plugin. Also these notes are NOT shared with other users.
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
25
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
26 Look at the mini superscript plugin for an example of how to do that.
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
27
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
28 Modified for Traipse (Prof. Ebral)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
29 EXPERIMENTAL! In the process of being updated."""
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
30 self.save_on_exit = False;
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
31
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
32 def plugin_menu(self):
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
33 pass
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
34
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
35 def plugin_enabled(self):
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
36 m = component.get("map").layer_handlers[2]
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
37 m.set_mini_rclick_menu_item("Quick Notes", self.on_quick_note)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
38
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
39 db_notes_list = self.plugindb.GetList("xxminiquicknote", "notes", [])
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
40 matched = 0;
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
41 for mini in component.get("map").canvas.layers['miniatures'].miniatures:
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
42 print 'label:'+mini.label
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
43 print 'posx:'+str(mini.pos.x)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
44 print 'posy:'+str(mini.pos.y)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
45 for db_note in db_notes_list:
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
46 print 'db_note:'+str(db_note)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
47 if mini.label == db_note[0] and mini.pos.x == db_note[1] and mini.pos.y == db_note[2]:
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
48 mini.quicknote = db_note[3]
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
49 db_notes_list.remove(db_note)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
50 matched += 1
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
51 break
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
52
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
53 def plugin_disabled(self):
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
54 m = component.get("map").layer_handlers[2]
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
55 m.set_mini_rclick_menu_item("Quick Notes", None)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
56
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
57 if self.save_on_exit:
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
58 db_notes_list = []
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
59 for mini in component.get("map").canvas.layers['miniatures'].miniatures:
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
60 if 'quicknote' in mini.__dict__:
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
61 db_notes_list.append([mini.label, mini.pos.x, mini.pos.y, mini.quicknote])
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
62 self.plugindb.SetList("xxminiquicknote", "notes", db_notes_list)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
63
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
64 def on_quick_note(self, event):
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
65 self.save_on_exit = True
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
66 m = component.get("map").layer_handlers[2]
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
67 # m.sel_rmin is the mini that was just right-clicked
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
68 if 'quicknote' not in m.sel_rmin.__dict__:
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
69 m.sel_rmin.quicknote = ''
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
70 dlg = QuickNoteDialog()
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
71 dlg.text.SetValue(m.sel_rmin.quicknote)
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
72 dlg.ShowModal()
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
73 m.sel_rmin.quicknote = dlg.text.GetValue()
b633f4c64aae Traipse Alpha 'OpenRPG' {100219-00}
sirebral
parents:
diff changeset
74 dlg.Destroy()