annotate orpg/gametree/gametree.py @ 141:2ffc5de126c8 alpha

Traipse Alpha 'OpenRPG' {091123-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 (Cleaning up for Beta) Added Bookmarks Fix to Remote Admin Commands Minor fix to text based Server Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager default_manifest.xml renamed to default_upmana.xml Cleaner clode for saved repositories New TrueDebug Class in orpg_log (See documentation for usage) Mercurial's hgweb folder is ported to upmana Pretty important update that can help remove thousands of dead children from your gametree. Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and look for dead children!! New Gametree Recursion method, mapping, and context sensitivity. !Infinite Loops return error instead of freezing the software! New Syntax added for custom PC sheets Tip of the Day added, from Core and community Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix.
author sirebral
date Mon, 23 Nov 2009 12:19:56 -0600
parents b4e02e8cd314
children 06f10429eedc
rev   line source
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1 # Copyright (C) 2000-2001 The OpenRPG Project
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
3 # openrpg-dev@lists.sourceforge.net
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
4 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
5 # This program is free software; you can redistribute it and/or modify
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
6 # it under the terms of the GNU General Public License as published by
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
8 # (at your option) any later version.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
9 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
10 # This program is distributed in the hope that it will be useful,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
13 # GNU General Public License for more details.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
14 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
16 # along with this program; if not, write to the Free Software
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
18 # --
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
19 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
20 # File: gametree.py
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
21 # Author: Chris Davis
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
22 # Maintainer:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
23 # Version:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
24 # $Id: gametree.py,v 1.68 2007/12/07 20:39:48 digitalxero Exp $
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
25 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
26 # Description: The file contains code fore the game tree shell
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
27 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
28
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
29 from __future__ import with_statement
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
30
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
31 __version__ = "$Id: gametree.py,v 1.68 2007/12/07 20:39:48 digitalxero Exp $"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
32
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
33 from orpg.orpg_wx import *
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
34 from orpg.orpg_windows import *
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 0
diff changeset
35 from orpg.orpgCore import component
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 0
diff changeset
36 from orpg.dirpath import dir_struct
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
37 from nodehandlers import core
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
38 import string
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
39 import urllib
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
40 import time
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
41 import os
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
42
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
43 from orpg.orpg_xml import xml
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
44 from orpg.tools.validate import validate
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
45 from orpg.tools.orpg_log import logger, debug
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
46 from orpg.tools.orpg_settings import settings
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
47 from orpg.gametree.nodehandlers import containers, forms, dnd3e, dnd35, chatmacro
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
48 from orpg.gametree.nodehandlers import map_miniature_nodehandler
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
49 from orpg.gametree.nodehandlers import minilib, rpg_grid, d20, StarWarsd20, voxchat
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
50
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
51 from gametree_version import GAMETREE_VERSION
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
52
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
53 from xml.etree.ElementTree import ElementTree, Element, parse
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
54 from xml.etree.ElementTree import fromstring, tostring, XML, iselement
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
55 from xml.parsers.expat import ExpatError
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
56
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
57 STD_MENU_DELETE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
58 STD_MENU_DESIGN = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
59 STD_MENU_USE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
60 STD_MENU_PP = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
61 STD_MENU_RENAME = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
62 STD_MENU_SEND = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
63 STD_MENU_SAVE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
64 STD_MENU_ICON = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
65 STD_MENU_CLONE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
66 STD_MENU_ABOUT = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
67 STD_MENU_HTML = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
68 STD_MENU_EMAIL = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
69 STD_MENU_CHAT = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
70 STD_MENU_WHISPER = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
71 STD_MENU_WIZARD = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
72 STD_MENU_NODE_SUBMENU = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
73 STD_MENU_NODE_USEFUL = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
74 STD_MENU_NODE_USELESS = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
75 STD_MENU_NODE_INDIFFERENT = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
76 STD_MENU_MAP = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
77 TOP_IFILE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
78 TOP_INSERT_URL = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
79 TOP_NEW_TREE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
80 TOP_SAVE_TREE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
81 TOP_SAVE_TREE_AS = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
82 TOP_TREE_PROP = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
83 TOP_FEATURES = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
84
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
85 class game_tree(wx.TreeCtrl):
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
86
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
87 def __init__(self, parent, id):
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
88 wx.TreeCtrl.__init__(self,parent,id, wx.DefaultPosition,
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 0
diff changeset
89 wx.DefaultSize,style=wx.TR_EDIT_LABELS | wx.TR_HAS_BUTTONS)
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
90 #self.xml = component.get('xml') #
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 0
diff changeset
91 self.settings = component.get('settings')
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 0
diff changeset
92 self.session = component.get('session')
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 0
diff changeset
93 self.chat = component.get('chat')
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 0
diff changeset
94 self.mainframe = component.get('frame')
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
95 self.build_img_list()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
96 self.build_std_menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
97 self.nodehandlers = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
98 self.nodes = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
99 self.init_nodehandlers()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
100 self.Bind(wx.EVT_LEFT_DCLICK, self.on_ldclick)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
101 self.Bind(wx.EVT_RIGHT_DOWN, self.on_rclick)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
102 self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.on_drag, id=id)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
103 self.Bind(wx.EVT_LEFT_UP, self.on_left_up)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
104 self.Bind(wx.EVT_LEFT_DOWN, self.on_left_down)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
105 self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.on_label_change, id=self.GetId())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
106 self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.on_label_begin, id=self.GetId())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
107 self.Bind(wx.EVT_CHAR, self.on_char)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
108 self.Bind(wx.EVT_KEY_UP, self.on_key_up)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
109 self.id = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
110 self.dragging = False
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 0
diff changeset
111 self.last_save_dir = dir_struct["user"]
136
b4e02e8cd314 Traipse Alpha 'OpenRPG' {091016-00}
sirebral
parents: 133
diff changeset
112 self.tree_map = {}
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
113
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
114 #Create tree from default if it does not exist
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
115 validate.config_file("tree.xml","default_tree.xml")
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 0
diff changeset
116 component.add("tree", self)
130
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 129
diff changeset
117
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
118 #build tree
130
d54e1328dbb1 Traipse Alpha 'OpenRPG' {091003-02}
sirebral
parents: 129
diff changeset
119 self.root = self.AddRoot("Game Tree", self.icons['gear'])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
120 self.was_labeling = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
121 self.rename_flag = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
122 self.image_cache = {}
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
123 logger.debug("Exit game_tree")
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
124
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
125 def add_nodehandler(self, nodehandler, nodeclass):
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
126 if not self.nodehandlers.has_key(nodehandler): self.nodehandlers[nodehandler] = nodeclass
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
127 else: logger.debug("Nodehandler for " + nodehandler + " already exists!")
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
128
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
129 def remove_nodehandler(self, nodehandler):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
130 if self.nodehandlers.has_key(nodehandler):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
131 del self.nodehandlers[nodehandler]
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
132 else: logger.debug("No nodehandler for " + nodehandler + " exists!")
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
133
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
134 def init_nodehandlers(self):
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
135 self.add_nodehandler('group_handler', containers.group_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
136 self.add_nodehandler('tabber_handler', containers.tabber_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
137 self.add_nodehandler('splitter_handler', containers.splitter_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
138 self.add_nodehandler('form_handler', forms.form_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
139 self.add_nodehandler('textctrl_handler', forms.textctrl_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
140 self.add_nodehandler('listbox_handler', forms.listbox_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
141 self.add_nodehandler('link_handler', forms.link_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
142 self.add_nodehandler('webimg_handler', forms.webimg_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
143 self.add_nodehandler('dnd3echar_handler', dnd3e.dnd3echar_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
144 self.add_nodehandler('dnd35char_handler', dnd35.dnd35char_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
145 self.add_nodehandler('macro_handler', chatmacro.macro_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
146 self.add_nodehandler('map_miniature_handler', map_miniature_nodehandler.map_miniature_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
147 self.add_nodehandler('minilib_handler', minilib.minilib_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
148 self.add_nodehandler('mini_handler', minilib.mini_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
149 self.add_nodehandler('rpg_grid_handler', rpg_grid.rpg_grid_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
150 self.add_nodehandler('d20char_handler', d20.d20char_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
151 self.add_nodehandler('SWd20char_handler', StarWarsd20.SWd20char_handler)
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
152 self.add_nodehandler('voxchat_handler', voxchat.voxchat_handler)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
153 self.add_nodehandler('file_loader', core.file_loader)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
154 self.add_nodehandler('node_loader', core.node_loader)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
155 self.add_nodehandler('url_loader', core.url_loader)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
156 self.add_nodehandler('min_map', core.min_map)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
157
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
158 # event = wxKeyEvent
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
159 # set to be called by wxWindows by EVT_CHAR macro in __init__
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
160
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
161 def on_key_up(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
162 key_code = evt.GetKeyCode()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
163 if self.dragging and (key_code == wx.WXK_SHIFT):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
164 curSelection = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
165 cur = wx.StockCursor(wx.CURSOR_ARROW)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
166 self.SetCursor(cur)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
167 self.dragging = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
168 obj = self.GetPyData(curSelection)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
169 self.SelectItem(curSelection)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
170 if(isinstance(obj,core.node_handler)):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
171 obj.on_drop(evt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
172 self.drag_obj = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
173 evt.Skip()
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
174
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
175 def on_char(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
176 key_code = evt.GetKeyCode()
119
9314d63c0941 Traipse Alpha 'OpenRPG' {091029-00}
sirebral
parents: 118
diff changeset
177 curSelection = self.GetSelection() # Get the current selection
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
178 if evt.ShiftDown() and ((key_code == wx.WXK_UP) or (key_code == wx.WXK_DOWN)) and not self.dragging:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
179 curSelection = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
180 obj = self.GetPyData(curSelection)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
181 self.SelectItem(curSelection)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
182 if(isinstance(obj,core.node_handler)):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
183 self.dragging = True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
184 cur = wx.StockCursor(wx.CURSOR_HAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
185 self.SetCursor(cur)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
186 self.drag_obj = obj
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
187 elif key_code == wx.WXK_LEFT: self.Collapse(curSelection)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
188 elif key_code == wx.WXK_DELETE: # Handle the delete key
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
189 if curSelection:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
190 nextSelect = self.GetItemParent(curSelection)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
191 self.on_del(evt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
192 try:
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
193 if self.GetItemText(nextSelect) != "": self.SelectItem(nextSelect)
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
194 except: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
195 elif key_code == wx.WXK_F2:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
196 self.rename_flag = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
197 self.EditLabel(curSelection)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
198 evt.Skip()
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
199
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
200 def locate_valid_tree(self, error, msg): ## --Snowdog 3/05
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
201 """prompts the user to locate a new tree file or create a new one"""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
202 response = wx.MessageDialog(self, msg, error, wx.YES|wx.NO|wx.ICON_ERROR)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
203 if response == wx.YES:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
204 file = None
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
205 dlg = wx.FileDialog(self, "Locate Gametree file", dir_struct["user"],
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
206 filename[ ((filename.rfind(os.sep))+len(os.sep)):],
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
207 "Gametree (*.xml)|*.xml|All files (*.*)|*.*",
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
208 wx.OPEN | wx.CHANGE_DIR)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
209 if dlg.ShowModal() == wx.ID_OK: file = dlg.GetPath()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
210 dlg.Destroy()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
211 if not file: self.load_tree(error=1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
212 else: self.load_tree(file)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
213 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
214 else:
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
215 validate.config_file("tree.xml","default_tree.xml")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
216 self.load_tree(error=1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
217 return
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
218
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
219
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 0
diff changeset
220 def load_tree(self, filename=dir_struct["user"]+'tree.xml', error=0):
125
ed4c3606ad1f Traipse Alpha 'OpenRPG' {091001-02}
sirebral
parents: 119
diff changeset
221 self.settings.change("gametree", filename)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
222 #check file exists
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
223 if not os.path.exists(filename):
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
224 emsg = "Gametree Missing!\n"+filename+" cannot be found.\n\n"\
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
225 "Would you like to locate it?\n"\
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
226 "(Selecting 'No' will cause a new default gametree to be generated)"
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
227 self.locate_valid_tree("Gametree Error", emsg)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
228 return
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
229 try:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
230 f = open(filename, "rb")
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
231 tree = parse(f)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
232 self.xml_root = tree.getroot()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
233 except:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
234 f.close()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
235 self.xml_root = None
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
236 ### Alpha ### Doing some work on Gametree to add Element Tree, slowly at first.
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
237
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
238 if not self.xml_root:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
239 os.rename(filename,filename+".corrupt")
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
240 emsg = "Your gametree is being regenerated.\n\n"\
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
241 "To salvage a recent version of your gametree\n"\
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
242 "exit OpenRPG and copy the lastgood.xml file in\n"\
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
243 "your myfiles directory to "+filename+ "\n"\
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
244 "in your myfiles directory.\n\n"\
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
245 "lastgood.xml WILL BE OVERWRITTEN NEXT TIME YOU RUN OPENRPG.\n\n"\
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
246 "Would you like to select a different gametree file to use?\n"\
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
247 "(Selecting 'No' will cause a new default gametree to be generated)"
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
248 self.locate_valid_tree("Corrupt Gametree!", emsg)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
249 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
250
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
251 if self.xml_root.tag != "gametree":
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
252 emsg = filename+" does not appear to be a valid gametree file.\n\n"\
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
253 "Would you like to select a different gametree file to use?\n"\
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
254 "(Selecting 'No' will cause a new default gametree to be generated)"
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
255 self.locate_valid_tree("Invalid Gametree!", emsg)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
256 return
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
257 try:
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
258 # version = self.xml_root.get("version")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
259 # see if we should load the gametree
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
260 loadfeatures = int(settings.get_setting("LoadGameTreeFeatures"))
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
261 if loadfeatures:
125
ed4c3606ad1f Traipse Alpha 'OpenRPG' {091001-02}
sirebral
parents: 119
diff changeset
262 features_tree = parse(orpg.dirpath.dir_struct["template"]+"feature.xml")
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
263 self.xml_root.append(features_tree.getroot())
125
ed4c3606ad1f Traipse Alpha 'OpenRPG' {091001-02}
sirebral
parents: 119
diff changeset
264 settings.change("LoadGameTreeFeatures","0")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
265
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
266 ## load tree
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
267 logger.debug("Features loaded (if required)")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
268 self.CollapseAndReset(self.root)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
269 logger.note("Parsing Gametree Nodes ", True)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
270 for xml_child in self.xml_root:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
271 logger.note('.', True)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
272 self.load_xml(xml_child,self.root)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
273 logger.note("done", True)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
274
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
275 self.Expand(self.root)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
276 self.SetPyData(self.root,self.xml_root)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
277 if error != 1:
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
278 with open(filename, "rb") as infile:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
279 with open(dir_struct["user"]+"lastgood.xml", "wb") as outfile:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
280 outfile.write(infile.read())
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
281 else: logger.info("Not overwriting lastgood.xml file.", True)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
282
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
283 except Exception, e:
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
284 logger.exception(traceback.format_exc())
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
285 wx.MessageBox("Corrupt Tree!\nYour game tree is being regenerated. To\nsalvage a recent version of your gametree\nexit OpenRPG and copy the lastgood.xml\nfile in your myfiles directory\nto "+filename+ "\nin your myfiles directory.\nlastgood.xml WILL BE OVERWRITTEN NEXT TIME YOU RUN OPENRPG.")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
286 os.rename(filename,filename+".corrupt")
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
287 validate.config_file("tree.xml","default_tree.xml")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
288 self.load_tree(error=1)
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
289
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
290 def build_std_menu(self, obj=None):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
291 # build useful menu
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
292 useful_menu = wx.Menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
293 useful_menu.Append(STD_MENU_NODE_USEFUL,"Use&ful")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
294 useful_menu.Append(STD_MENU_NODE_USELESS,"Use&less")
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
295 useful_menu.Append(STD_MENU_NODE_INDIFFERENT,"&Indifferent")
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
296
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
297 # build standard menu
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
298 self.std_menu = wx.Menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
299 self.std_menu.SetTitle("game tree")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
300 self.std_menu.Append(STD_MENU_USE,"&Use")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
301 self.std_menu.Append(STD_MENU_DESIGN,"&Design")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
302 self.std_menu.Append(STD_MENU_PP,"&Pretty Print")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
303 self.std_menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
304 self.std_menu.Append(STD_MENU_SEND,"Send To Player")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
305 self.std_menu.Append(STD_MENU_MAP,"Send To Map")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
306 self.std_menu.Append(STD_MENU_CHAT,"Send To Chat")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
307 self.std_menu.Append(STD_MENU_WHISPER,"Whisper To Player")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
308 self.std_menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
309 self.std_menu.Append(STD_MENU_ICON,"Change &Icon")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
310 self.std_menu.Append(STD_MENU_DELETE,"D&elete")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
311 self.std_menu.Append(STD_MENU_CLONE,"&Clone")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
312 self.std_menu.AppendMenu(STD_MENU_NODE_SUBMENU,"Node &Usefulness",useful_menu)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
313 self.std_menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
314 self.std_menu.Append(STD_MENU_SAVE,"&Save Node")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
315 self.std_menu.Append(STD_MENU_HTML,"E&xport as HTML")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
316 self.std_menu.AppendSeparator()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
317 self.std_menu.Append(STD_MENU_ABOUT,"&About")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
318 self.Bind(wx.EVT_MENU, self.on_send_to, id=STD_MENU_SEND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
319 self.Bind(wx.EVT_MENU, self.indifferent, id=STD_MENU_NODE_INDIFFERENT)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
320 self.Bind(wx.EVT_MENU, self.useful, id=STD_MENU_NODE_USEFUL)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
321 self.Bind(wx.EVT_MENU, self.useless, id=STD_MENU_NODE_USELESS)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
322 self.Bind(wx.EVT_MENU, self.on_del, id=STD_MENU_DELETE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
323 self.Bind(wx.EVT_MENU, self.on_send_to_map, id=STD_MENU_MAP)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
324 self.Bind(wx.EVT_MENU, self.on_node_design, id=STD_MENU_DESIGN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
325 self.Bind(wx.EVT_MENU, self.on_node_use, id=STD_MENU_USE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
326 self.Bind(wx.EVT_MENU, self.on_node_pp, id=STD_MENU_PP)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
327 self.Bind(wx.EVT_MENU, self.on_save, id=STD_MENU_SAVE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
328 self.Bind(wx.EVT_MENU, self.on_icon, id=STD_MENU_ICON)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
329 self.Bind(wx.EVT_MENU, self.on_clone, id=STD_MENU_CLONE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
330 self.Bind(wx.EVT_MENU, self.on_about, id=STD_MENU_ABOUT)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
331 self.Bind(wx.EVT_MENU, self.on_send_to_chat, id=STD_MENU_CHAT)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
332 self.Bind(wx.EVT_MENU, self.on_whisper_to, id=STD_MENU_WHISPER)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
333 self.Bind(wx.EVT_MENU, self.on_export_html, id=STD_MENU_HTML)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
334 self.top_menu = wx.Menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
335 self.top_menu.SetTitle("game tree")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
336 self.top_menu.Append(TOP_IFILE,"&Insert File")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
337 self.top_menu.Append(TOP_INSERT_URL,"Insert &URL")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
338 self.top_menu.Append(TOP_FEATURES, "Insert &Features Node")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
339 self.top_menu.Append(TOP_NEW_TREE, "&Load New Tree")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
340 self.top_menu.Append(TOP_SAVE_TREE,"&Save Tree")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
341 self.top_menu.Append(TOP_SAVE_TREE_AS,"Save Tree &As...")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
342 self.top_menu.Append(TOP_TREE_PROP,"&Tree Properties")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
343 self.Bind(wx.EVT_MENU, self.on_insert_file, id=TOP_IFILE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
344 self.Bind(wx.EVT_MENU, self.on_insert_url, id=TOP_INSERT_URL)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
345 self.Bind(wx.EVT_MENU, self.on_save_tree_as, id=TOP_SAVE_TREE_AS)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
346 self.Bind(wx.EVT_MENU, self.on_save_tree, id=TOP_SAVE_TREE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
347 self.Bind(wx.EVT_MENU, self.on_load_new_tree, id=TOP_NEW_TREE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
348 self.Bind(wx.EVT_MENU, self.on_tree_prop, id=TOP_TREE_PROP)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
349 self.Bind(wx.EVT_MENU, self.on_insert_features, id=TOP_FEATURES)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
350
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
351
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
352 def do_std_menu(self, evt, obj):
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
353 try: self.std_menu.Enable(STD_MENU_MAP, obj.checkToMapMenu())
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
354 except: self.std_menu.Enable(STD_MENU_MAP, obj.map_aware())
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
355 self.std_menu.Enable(STD_MENU_CLONE, obj.can_clone())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
356 self.PopupMenu(self.std_menu)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
357
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
358
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
359 def strip_html(self, player):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
360 ret_string = ""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
361 x = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
362 in_tag = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
363 for x in xrange(len(player[0])) :
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
364 if player[0][x] == "<" or player[0][x] == ">" or in_tag == 1 :
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
365 if player[0][x] == "<" : in_tag = 1
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
366 elif player[0][x] == ">" : in_tag = 0
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
367 else: pass
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
368 else: ret_string = ret_string + player[0][x]
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
369 logger.debug(ret_string)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
370 return ret_string
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
371
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
372
133
37d26a98883f Traipse Alpha 'OpenRPG' {091010-00}
sirebral
parents: 132
diff changeset
373 def on_receive_data(self, data):
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
374 self.insert_xml(data)
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
375
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
376 def on_send_to_chat(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
377 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
378 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
379 obj.on_send_to_chat(evt)
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
380
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
381 def on_whisper_to(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
382 players = self.session.get_players()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
383 opts = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
384 myid = self.session.get_id()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
385 me = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
386 for p in players:
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
387 if p[2] != myid: opts.append("("+p[2]+") " + self.strip_html(p))
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
388 else: me = p
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
389 if len(opts): players.remove(me)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
390 if len(opts):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
391 dlg = orpgMultiCheckBoxDlg( self.GetParent(),opts,"Select Players:","Whisper To",[] )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
392 if dlg.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
393 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
394 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
395 selections = dlg.get_selections()
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
396 if len(selections) == len(opts): self.chat.ParsePost(obj.tohtml(),True,True)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
397 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
398 player_ids = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
399 for s in selections:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
400 player_ids.append(players[s][2])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
401 self.chat.whisper_to_players(obj.tohtml(),player_ids)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
402
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
403
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
404 def on_export_html(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
405 f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","HTML (*.html)|*.html",wx.SAVE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
406 if f.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
407 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
408 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
409 type = f.GetFilterIndex()
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
410 with open(f.GetPath(),"w") as f:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
411 data = "<html><head><title>"+obj.xml.get("name")+"</title></head>"
136
b4e02e8cd314 Traipse Alpha 'OpenRPG' {091016-00}
sirebral
parents: 133
diff changeset
412 data += "<body bgcolor='#FFFFFF' >"+obj.tohtml()+"</body></html>"
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
413 for tag in ("</tr>","</td>","</th>","</table>","</html>","</body>"):
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
414 data = data.replace(tag,tag+"\n")
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
415 f.write(data)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
416 self.last_save_dir, throwaway = os.path.split( f.GetPath() )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
417 f.Destroy()
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
418 os.chdir(dir_struct["home"])
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
419
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
420
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
421 def indifferent(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
422 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
423 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
424 obj.usefulness("indifferent")
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
425
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
426
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
427 def useful(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
428 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
429 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
430 obj.usefulness("useful")
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
431
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
432
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
433 def useless(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
434 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
435 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
436 obj.usefulness("useless")
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
437
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
438
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
439 def on_email(self,evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
440 pass
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
441
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
442
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
443 def on_send_to(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
444 players = self.session.get_players()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
445 opts = []
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
446 myid = self.session.get_id()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
447 me = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
448 for p in players:
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
449 if p[2] != myid: opts.append("("+p[2]+") " + self.strip_html(p))
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
450 else: me = p
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
451 if len(opts):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
452 players.remove(me)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
453 dlg = orpgMultiCheckBoxDlg( None, opts, "Select Players:", "Send To", [] )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
454 if dlg.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
455 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
456 obj = self.GetPyData(item)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
457 xmldata = "<tree>" + tostring(obj.xml) + "</tree>"
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
458 selections = dlg.get_selections()
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
459 if len(selections) == len(opts): self.session.send(xmldata)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
460 else:
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
461 for s in selections: self.session.send(xmldata,players[s][2])
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
462 dlg.Destroy()
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
463
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
464
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
465 def on_icon(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
466 icons = self.icons.keys()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
467 icons.sort()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
468 dlg = wx.SingleChoiceDialog(self,"Choose Icon?","Change Icon",icons)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
469 if dlg.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
470 key = dlg.GetStringSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
471 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
472 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
473 obj.change_icon(key)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
474 dlg.Destroy()
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
475
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
476
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
477 def on_wizard(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
478 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
479 obj = self.GetPyData(item)
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
480 name = "New " + obj.xml_root.get("name")
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
481 icon = obj.xml_root.get("icon")
136
b4e02e8cd314 Traipse Alpha 'OpenRPG' {091016-00}
sirebral
parents: 133
diff changeset
482 xml_data = "<nodehandler name='"+name+"' icon='" + icon + "' module='core' class='node_loader' >"
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
483 xml_data += xml.toxml(obj)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
484 xml_data += "</nodehandler>"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
485 self.insert_xml(xml_data)
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
486 logger.debug(xml_data)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
487
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
488
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
489 def on_clone(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
490 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
491 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
492 if obj.can_clone():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
493 parent_node = self.GetItemParent(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
494 prev_sib = self.GetPrevSibling(item)
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
495 if not prev_sib.IsOk(): prev_sib = parent_node
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
496 clone_xml = XML(tostring(obj.xml))
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
497 if parent_node == self.root: parent_xml = self.GetPyData(parent_node)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
498 else: parent_xml = self.GetPyData(parent_node).xml
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
499 for i in range(len(parent_xml)):
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
500 if parent_xml[i] is obj.xml:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
501 parent_xml.insert(i, clone_xml)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
502 break
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
503 self.load_xml(clone_xml, parent_node, prev_sib)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
504
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
505
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
506 def on_save(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
507 """save node to a xml file"""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
508 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
509 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
510 obj.on_save(evt)
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
511 os.chdir(dir_struct["home"])
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
512
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
513
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
514 def on_save_tree_as(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
515 f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","*.xml",wx.SAVE)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
516 if f.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
517 self.save_tree(f.GetPath())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
518 self.last_save_dir, throwaway = os.path.split( f.GetPath() )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
519 f.Destroy()
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
520 os.chdir(dir_struct["home"])
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
521
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
522
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
523 def on_save_tree(self, evt=None):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
524 filename = self.settings.get_setting("gametree")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
525 self.save_tree(filename)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
526
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
527
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 0
diff changeset
528 def save_tree(self, filename=dir_struct["user"]+'tree.xml'):
133
37d26a98883f Traipse Alpha 'OpenRPG' {091010-00}
sirebral
parents: 132
diff changeset
529 self.xml_root.set("version", GAMETREE_VERSION)
37d26a98883f Traipse Alpha 'OpenRPG' {091010-00}
sirebral
parents: 132
diff changeset
530 settings.change("gametree", filename)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
531 ElementTree(self.xml_root).write(filename)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
532
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
533
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
534 def on_load_new_tree(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
535 f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","*.xml",wx.OPEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
536 if f.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
537 self.load_tree(f.GetPath())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
538 self.last_save_dir, throwaway = os.path.split( f.GetPath() )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
539 f.Destroy()
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
540 os.chdir(dir_struct["home"])
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
541
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
542
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
543 def on_insert_file(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
544 """loads xml file into the tree"""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
545 if self.last_save_dir == ".":
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 0
diff changeset
546 self.last_save_dir = dir_struct["user"]
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
547 f = wx.FileDialog(self,"Select a file", self.last_save_dir,"","*.xml",wx.OPEN)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
548 if f.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
549 self.insert_xml(open(f.GetPath(),"r").read())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
550 self.last_save_dir, throwaway = os.path.split( f.GetPath() )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
551 f.Destroy()
71
449a8900f9ac Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
sirebral
parents: 66
diff changeset
552 os.chdir(dir_struct["home"])
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
553
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
554
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
555 def on_insert_url(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
556 """loads xml url into the tree"""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
557 dlg = wx.TextEntryDialog(self,"URL?","Insert URL", "http://")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
558 if dlg.ShowModal() == wx.ID_OK:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
559 path = dlg.GetValue()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
560 file = urllib.urlopen(path)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
561 self.insert_xml(file.read())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
562 dlg.Destroy()
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
563
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
564
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
565 def on_insert_features(self, evt):
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 0
diff changeset
566 self.insert_xml(open(dir_struct["template"]+"feature.xml","r").read())
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
567
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
568
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
569 def on_tree_prop(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
570 dlg = gametree_prop_dlg(self, self.settings)
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
571 if dlg.ShowModal() == wx.ID_OK: pass
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
572 dlg.Destroy()
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
573
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
574
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
575 def on_node_design(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
576 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
577 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
578 obj.on_design(evt)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
579
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
580
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
581 def on_node_use(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
582 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
583 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
584 obj.on_use(evt)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
585
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
586
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
587 def on_node_pp(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
588 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
589 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
590 obj.on_html_view(evt)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
591
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
592
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
593 def on_del(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
594 status_value = "none"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
595 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
596 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
597 if item:
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
598 handler = self.GetPyData(item)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
599 status_value = handler.xml.get('status')
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
600 name = handler.xml.get('name')
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
601 parent_item = self.GetItemParent(item)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
602 while parent_item.IsOk() and status_value!="useful" and status_value!="useless":
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
603 try:
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
604 parent_handler = self.GetPyData(parent_item)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
605 status_value = parent_handler.get('status')
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
606 name = parent_handler.get('name')
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
607 if status_value == "useless":
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
608 break
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
609 elif status_value == "useful":
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
610 break
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
611 except:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
612 status_value = "none"
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
613 parent_item = self.GetItemParent(parent_item)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
614 if status_value == "useful":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
615 dlg = wx.MessageDialog(self, `name` + " And everything beneath it are considered useful. \n\nAre you sure you want to delete this item?",'Important Item',wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
616 if dlg.ShowModal() == wx.ID_YES: handler.delete()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
617 else: handler.delete()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
618 except:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
619 if self.GetSelection() == self.GetRootItem():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
620 msg = wx.MessageDialog(None,"You can't delete the root item.","Delete Error",wx.OK)
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
621 else: msg = wx.MessageDialog(None,"Unknown error deleting node.","Delete Error",wx.OK)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
622 msg.ShowModal()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
623 msg.Destroy()
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
624
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
625
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
626 def on_about(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
627 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
628 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
629 about = MyAboutBox(self,obj.about())
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
630 about.ShowModal()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
631 about.Destroy()
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
632
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
633 def on_send_to_map(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
634 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
635 obj = self.GetPyData(item)
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
636 if hasattr(obj,"on_send_to_map"): obj.on_send_to_map(evt)
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
637
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
638 def insert_xml(self, txt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
639 #Updated to allow safe merging of gametree files
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
640 #without leaving an unusable and undeletable node.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
641 # -- Snowdog 8/03
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
642 if not txt:
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
643 wx.MessageBox("Import Failed: Invalid or missing node data")
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
644 logger.general("Import Failed: Invalid or missing node data")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
645 return
132
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
646 try: new_xml = XML(txt)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
647 except ExpatError:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
648 wx.MessageBox("Error Importing Node or Tree")
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
649 logger.general("Error Importing Node or Tree")
133
37d26a98883f Traipse Alpha 'OpenRPG' {091010-00}
sirebral
parents: 132
diff changeset
650 return
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
651
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
652 if new_xml.tag == "gametree":
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
653 for xml_child in new_xml:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
654 self.load_xml(xml_child, self.root)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
655 return
133
37d26a98883f Traipse Alpha 'OpenRPG' {091010-00}
sirebral
parents: 132
diff changeset
656
37d26a98883f Traipse Alpha 'OpenRPG' {091010-00}
sirebral
parents: 132
diff changeset
657 if new_xml.tag == "tree":
37d26a98883f Traipse Alpha 'OpenRPG' {091010-00}
sirebral
parents: 132
diff changeset
658 self.xml_root.append(new_xml.find('nodehandler'))
37d26a98883f Traipse Alpha 'OpenRPG' {091010-00}
sirebral
parents: 132
diff changeset
659 for xml_child in new_xml:
37d26a98883f Traipse Alpha 'OpenRPG' {091010-00}
sirebral
parents: 132
diff changeset
660 self.load_xml(xml_child, self.root)
37d26a98883f Traipse Alpha 'OpenRPG' {091010-00}
sirebral
parents: 132
diff changeset
661 return
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
662
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
663 self.xml_root.append(new_xml)
132
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
664 self.load_xml(new_xml, self.root, self.root)
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
665
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
666 def build_img_list(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
667 """make image list"""
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
668 helper = img_helper()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
669 self.icons = { }
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
670 self._imageList= wx.ImageList(16,16,False)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
671 icons_xml = parse(orpg.dirpath.dir_struct["icon"]+"icons.xml")
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
672 for icon in icons_xml.getroot():
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
673 key = icon.get("name")
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
674 path = orpg.dirpath.dir_struct["icon"] + icon.get("file")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
675 img = helper.load_file(path)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
676 self.icons[key] = self._imageList.Add(img)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
677 self.SetImageList(self._imageList)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
678
132
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
679 def get_tree_map(self, parent):
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
680 ## Could be a little cleaner ##
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
681 family_tree = []
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
682 test = parent
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
683 while test != self.root:
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
684 parent = self.GetItemText(test)
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
685 test = self.GetItemParent(test)
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
686 family_tree.append(parent)
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
687 return family_tree
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
688
133
37d26a98883f Traipse Alpha 'OpenRPG' {091010-00}
sirebral
parents: 132
diff changeset
689 def load_xml(self, xml_element, parent_node, prev_node=None):
136
b4e02e8cd314 Traipse Alpha 'OpenRPG' {091016-00}
sirebral
parents: 133
diff changeset
690 if parent_node == self.root:
b4e02e8cd314 Traipse Alpha 'OpenRPG' {091016-00}
sirebral
parents: 133
diff changeset
691 self.tree_map[xml_element.get('name')] = {}
b4e02e8cd314 Traipse Alpha 'OpenRPG' {091016-00}
sirebral
parents: 133
diff changeset
692 self.tree_map[xml_element.get('name')]['node'] = xml_element
132
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
693 if parent_node != self.root:
133
37d26a98883f Traipse Alpha 'OpenRPG' {091010-00}
sirebral
parents: 132
diff changeset
694 ## Loading XML seems to lag on Grids and Images need a cache for load speed ##
132
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
695 family_tree = self.get_tree_map(parent_node)
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
696 family_tree.reverse()
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
697 map_str = '' #'!@'
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
698 for member in family_tree:
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
699 map_str += member +'::'
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
700 map_str = map_str[:len(map_str)-2] #+'@!'
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
701 xml_element.set('map', map_str)
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
702
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
703 #add the first tree node
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
704 i = 0
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
705 name = xml_element.get("name")
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
706 icon = xml_element.get("icon")
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
707 if self.icons.has_key(icon): i = self.icons[icon]
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
708
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
709 if prev_node:
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
710 if prev_node == parent_node: new_tree_node = self.PrependItem(parent_node, name, i, i)
132
fe4dc5817d5e Traipse Alpha 'OpenRPG' {091005-00}
sirebral
parents: 130
diff changeset
711 else: new_tree_node = self.InsertItem(parent_node, prev_node, name, i, i)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
712 else: new_tree_node = self.AppendItem(parent_node, name, i, i)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
713
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
714 logger.debug("Node Added to tree")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
715 #create a nodehandler or continue loading xml into tree
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
716 if xml_element.tag == "nodehandler":
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
717 try:
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
718 py_class = xml_element.get("class")
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
719 logger.debug("nodehandler class: " + py_class)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
720 if not self.nodehandlers.has_key(py_class):
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
721 raise Exception("Unknown Nodehandler for " + py_class)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
722 self.nodes[self.id] = self.nodehandlers[py_class](xml_element, new_tree_node)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
723 self.SetPyData(new_tree_node, self.nodes[self.id])
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
724 logger.debug("Node Data set")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
725 bmp = self.nodes[self.id].get_scaled_bitmap(16,16)
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
726 if bmp: self.cached_load_of_image(bmp,new_tree_node,)
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
727 logger.debug("Node Icon loaded")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
728 self.id = self.id + 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
729 except Exception, er:
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
730 logger.exception(traceback.format_exc())
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
731 # was deleted -- should we delete non-nodehandler nodes then?
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
732 #self.Delete(new_tree_node)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
733 #parent = xml_dom._get_parentNode()
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
734 #parent.removeChild(xml_dom)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
735 return new_tree_node
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
736
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
737 def cached_load_of_image(self, bmp_in, new_tree_node):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
738 image_list = self.GetImageList()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
739 img = wx.ImageFromBitmap(bmp_in)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
740 img_data = img.GetData()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
741 image_index = None
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
742 for key in self.image_cache.keys():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
743 if self.image_cache[key] == str(img_data):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
744 image_index = key
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
745 break
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
746 if image_index is None:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
747 image_index = image_list.Add(bmp_in)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
748 self.image_cache[image_index] = img_data
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
749 self.SetItemImage(new_tree_node,image_index)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
750 self.SetItemImage(new_tree_node,image_index, wx.TreeItemIcon_Selected)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
751 return image_index
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
752
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
753 def on_rclick(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
754 pt = evt.GetPosition()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
755 (item, flag) = self.HitTest(pt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
756 if item.IsOk():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
757 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
758 self.SelectItem(item)
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
759 if(isinstance(obj,core.node_handler)): obj.on_rclick(evt)
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
760 else: self.PopupMenu(self.top_menu)
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
761 else: self.PopupMenu(self.top_menu,pt)
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
762
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
763 def on_ldclick(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
764 self.rename_flag = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
765 pt = evt.GetPosition()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
766 (item, flag) = self.HitTest(pt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
767 if item.IsOk():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
768 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
769 self.SelectItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
770 if(isinstance(obj,core.node_handler)):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
771 if not obj.on_ldclick(evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
772 action = self.settings.get_setting("treedclick")
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
773 if action == "use": obj.on_use(evt)
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
774 elif action == "design": obj.on_design(evt)
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
775 elif action == "print": obj.on_html_view(evt)
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
776 elif action == "chat": self.on_send_to_chat(evt)
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
777
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
778 def on_left_down(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
779 pt = evt.GetPosition()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
780 (item, flag) = self.HitTest(pt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
781 if item.IsOk() and self.was_labeling:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
782 self.SelectItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
783 self.rename_flag = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
784 self.was_labeling = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
785 elif (flag & wx.TREE_HITTEST_ONITEMLABEL) == wx.TREE_HITTEST_ONITEMLABEL and self.IsSelected(item):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
786 # this next if tests to ensure that the mouse up occurred over a label, and not the icon
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
787 self.rename_flag = 1
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
788 else: self.SelectItem(item)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
789 evt.Skip()
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
790
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
791 def on_left_up(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
792 if self.dragging:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
793 cur = wx.StockCursor(wx.CURSOR_ARROW)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
794 self.SetCursor(cur)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
795 self.dragging = False
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
796 pt = evt.GetPosition()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
797 (item, flag) = self.HitTest(pt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
798 if item.IsOk():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
799 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
800 self.SelectItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
801 if(isinstance(obj,core.node_handler)):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
802 obj.on_drop(evt)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
803 self.drag_obj = None
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
804
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
805 def traverse(self, root, function, data=None, recurse=True):
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
806 child, cookie = self.GetFirstChild(root)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
807 while child.IsOk():
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
808 function(child, data)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
809 if recurse:
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
810 self.traverse(child, function, data)
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
811 child, cookie = self.GetNextChild(root, cookie)
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
812
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
813 def on_label_change(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
814 item = evt.GetItem()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
815 txt = evt.GetLabel()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
816 self.was_labeling = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
817 self.rename_flag = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
818 if txt != "":
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
819 obj = self.GetPyData(item)
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
820 obj.xml_root.setAttribute('name',txt)
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
821 else: evt.Veto()
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
822
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
823 def on_label_begin(self, evt):
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
824 if not self.rename_flag: evt.Veto()
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
825 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
826 self.was_labeling = 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
827 item = evt.GetItem()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
828 if item == self.GetRootItem():
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
829 evt.Veto()
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
830
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
831 def on_drag(self, evt):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
832 self.rename_flag = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
833 item = self.GetSelection()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
834 obj = self.GetPyData(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
835 self.SelectItem(item)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
836 if(isinstance(obj,core.node_handler) and obj.drag):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
837 self.dragging = True
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
838 cur = wx.StockCursor(wx.CURSOR_HAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
839 self.SetCursor(cur)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
840 self.drag_obj = obj
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
841
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
842 def is_parent_node(self, node, compare_node):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
843 parent_node = self.GetItemParent(node)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
844 if compare_node == parent_node:
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
845 logger.debug("parent node")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
846 return 1
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
847 elif parent_node == self.root:
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
848 logger.debug("not parent")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
849 return 0
76
37a11fea3304 More clean up. Images now posts a Chat Info post if image doesn't load.
sirebral
parents: 71
diff changeset
850 else: return self.is_parent_node(parent_node, compare_node)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
851
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
852 CTRL_TREE_FILE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
853 CTRL_YES = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
854 CTRL_NO = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
855 CTRL_USE = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
856 CTRL_DESIGN = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
857 CTRL_CHAT = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
858 CTRL_PRINT = wx.NewId()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
859
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
860 class gametree_prop_dlg(wx.Dialog):
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
861
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
862 def __init__(self, parent, settings):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
863 wx.Dialog.__init__(self, parent, wx.ID_ANY, "Game Tree Properties")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
864 self.settings = settings
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
865
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
866 #sizers
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
867 sizers = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
868 sizers['but'] = wx.BoxSizer(wx.HORIZONTAL)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
869 sizers['main'] = wx.BoxSizer(wx.VERTICAL)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
870
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
871 #box sizers
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
872 box_sizers = {}
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
873 box_sizers["save"] = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Save On Exit"), wx.HORIZONTAL)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
874 box_sizers["file"] = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Tree File"), wx.HORIZONTAL)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
875 box_sizers["dclick"] = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Double Click Action"), wx.HORIZONTAL)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
876 self.ctrls = { CTRL_TREE_FILE : FileBrowseButtonWithHistory(self, wx.ID_ANY, labelText="" ) ,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
877 CTRL_YES : wx.RadioButton(self, CTRL_YES, "Yes", style=wx.RB_GROUP),
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
878 CTRL_NO : wx.RadioButton(self, CTRL_NO, "No"),
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
879 CTRL_USE : wx.RadioButton(self, CTRL_USE, "Use", style=wx.RB_GROUP),
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
880 CTRL_DESIGN : wx.RadioButton(self, CTRL_DESIGN, "Desgin"),
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
881 CTRL_CHAT : wx.RadioButton(self, CTRL_CHAT, "Chat"),
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
882 CTRL_PRINT : wx.RadioButton(self, CTRL_PRINT, "Pretty Print")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
883 }
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
884 self.ctrls[CTRL_TREE_FILE].SetValue(settings.get_setting("gametree"))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
885 opt = settings.get_setting("SaveGameTreeOnExit")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
886 self.ctrls[CTRL_YES].SetValue(opt=="1")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
887 self.ctrls[CTRL_NO].SetValue(opt=="0")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
888 opt = settings.get_setting("treedclick")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
889 self.ctrls[CTRL_DESIGN].SetValue(opt=="design")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
890 self.ctrls[CTRL_USE].SetValue(opt=="use")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
891 self.ctrls[CTRL_CHAT].SetValue(opt=="chat")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
892 self.ctrls[CTRL_PRINT].SetValue(opt=="print")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
893 box_sizers['save'].Add(self.ctrls[CTRL_YES],0, wx.EXPAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
894 box_sizers['save'].Add(wx.Size(10,10))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
895 box_sizers['save'].Add(self.ctrls[CTRL_NO],0, wx.EXPAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
896 box_sizers['file'].Add(self.ctrls[CTRL_TREE_FILE], 0, wx.EXPAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
897 box_sizers['dclick'].Add(self.ctrls[CTRL_USE],0, wx.EXPAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
898 box_sizers['dclick'].Add(wx.Size(10,10))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
899 box_sizers['dclick'].Add(self.ctrls[CTRL_DESIGN],0, wx.EXPAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
900 box_sizers['dclick'].Add(wx.Size(10,10))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
901 box_sizers['dclick'].Add(self.ctrls[CTRL_CHAT],0, wx.EXPAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
902 box_sizers['dclick'].Add(wx.Size(10,10))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
903 box_sizers['dclick'].Add(self.ctrls[CTRL_PRINT],0, wx.EXPAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
904
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
905 # buttons
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
906 sizers['but'].Add(wx.Button(self, wx.ID_OK, "Apply"), 1, wx.EXPAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
907 sizers['but'].Add(wx.Size(10,10))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
908 sizers['but'].Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.EXPAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
909 sizers['main'].Add(box_sizers['save'], 1, wx.EXPAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
910 sizers['main'].Add(box_sizers['file'], 1, wx.EXPAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
911 sizers['main'].Add(box_sizers['dclick'], 1, wx.EXPAND)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
912 sizers['main'].Add(sizers['but'], 0, wx.EXPAND|wx.ALIGN_BOTTOM )
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
913
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
914 #sizers['main'].SetDimension(10,10,csize[0]-20,csize[1]-20)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
915 self.SetSizer(sizers['main'])
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
916 self.SetAutoLayout(True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
917 self.Fit()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
918 self.Bind(wx.EVT_BUTTON, self.on_ok, id=wx.ID_OK)
118
217fb049bd00 Traipse Alpha 'OpenRPG' {091028-00}
sirebral
parents: 76
diff changeset
919
129
43ad912b7c17 Traipse Alpha 'OpenRPG' {091003-01}
sirebral
parents: 125
diff changeset
920
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
921 def on_ok(self,evt):
125
ed4c3606ad1f Traipse Alpha 'OpenRPG' {091001-02}
sirebral
parents: 119
diff changeset
922 self.settings.change("gametree",self.ctrls[CTRL_TREE_FILE].GetValue())
ed4c3606ad1f Traipse Alpha 'OpenRPG' {091001-02}
sirebral
parents: 119
diff changeset
923 self.settings.change("SaveGameTreeOnExit",str(self.ctrls[CTRL_YES].GetValue()))
ed4c3606ad1f Traipse Alpha 'OpenRPG' {091001-02}
sirebral
parents: 119
diff changeset
924 if self.ctrls[CTRL_USE].GetValue(): self.settings.change("treedclick","use")
ed4c3606ad1f Traipse Alpha 'OpenRPG' {091001-02}
sirebral
parents: 119
diff changeset
925 elif self.ctrls[CTRL_DESIGN].GetValue(): self.settings.change("treedclick","design")
ed4c3606ad1f Traipse Alpha 'OpenRPG' {091001-02}
sirebral
parents: 119
diff changeset
926 elif self.ctrls[CTRL_PRINT].GetValue(): self.settings.change("treedclick","print")
ed4c3606ad1f Traipse Alpha 'OpenRPG' {091001-02}
sirebral
parents: 119
diff changeset
927 elif self.ctrls[CTRL_CHAT].GetValue(): self.settings.change("treedclick","chat")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
928 self.EndModal(wx.ID_OK)