annotate orpg/gametree/gametree.py @ 36:d02e9197c066 ornery-orc

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