annotate gui/inventorygui.py @ 189:4381be70e1bb tip

Fixed incompatibility with latest changes to bgrease.
author Beliar <KarstenBock@gmx.net>
date Sun, 08 Apr 2012 20:30:43 +0200
parents 5b880b8cff6d
children
rev   line source
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
1 # This file is part of PARPG.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
2
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
3 # PARPG is free software: you can redistribute it and/or modify
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
4 # it under the terms of the GNU General Public License as published by
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
5 # the Free Software Foundation, either version 3 of the License, or
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
6 # (at your option) any later version.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
7
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
8 # PARPG is distributed in the hope that it will be useful,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
11 # GNU General Public License for more details.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
12
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
13 # You should have received a copy of the GNU General Public License
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>.
119
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
15 import logging
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
16 from types import StringTypes
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
17
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
18 from fife.extensions.pychan.tools import callbackWithArguments as cbwa
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
19 from fife.extensions import pychan
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
20 from slot import Slot
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
21 from fife.extensions.pychan.attrs import UnicodeAttr
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
22
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
23 from parpg.gui import drag_drop_data as data_drag
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
24 from parpg.gui.containergui_base import ContainerGUIBase
148
2241722311bf Moved the action module into the entities package.
KarstenBock@gmx.net
parents: 147
diff changeset
25 from parpg.entities.action import ACTIONS
144
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
26 from parpg.components import equip, equipable, container
123
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
27 from parpg.entities import General
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
28
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
29 logger = logging.getLogger('action')
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
30
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
31 class EquipmentSlot(pychan.VBox):
119
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
32 def __init__(self, min_size=(50, 50),
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
33 max_size=(50, 50), margins=None,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
34 **kwargs):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
35 pychan.VBox.__init__(self, min_size=min_size, max_size=max_size,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
36 **kwargs)
2
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
37 self.background_image = 'gui/inv_images/inv_background.png'
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
38 icon = Slot(name="Icon")
119
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
39 self.addChild(icon)
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
40 self.adaptLayout()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
41 if self.parent is not None:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
42 self.beforeShow()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
43
119
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
44 @property
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
45 def image(self):
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
46 icon = self.findChildByName("Icon")
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
47 return icon.image
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
48
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
49 @image.setter
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
50 def image(self, image):
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
51 icon = self.findChildByName("Icon")
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
52 icon.image = image
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
53
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
54 class InventoryGrid(pychan.VBox):
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
55 ATTRIBUTES = pychan.VBox.ATTRIBUTES + [pychan.attrs.PointAttr('grid_size'),
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
56 pychan.attrs.PointAttr('cell_size')]
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
57
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
58
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
59 def _setNColumns(self, n_columns):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
60 n_rows = self.grid_size[1]
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
61 self.grid_size = (n_columns, n_rows)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
62
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
63 def _getNColumns(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
64 n_columns = self.grid_size[0]
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
65 return n_columns
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
66 n_columns = property(fget=_getNColumns, fset=_setNColumns)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
67
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
68 def _setNRows(self, n_rows):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
69 n_columns = self.grid_size[0]
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
70 self.grid_size = (n_columns, n_rows)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
71
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
72 def _getNRows(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
73 n_rows = self.grid_size[1]
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
74 return n_rows
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
75 n_rows = property(fget=_getNRows, fset=_getNColumns)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
76
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
77 def _setGridSize(self, grid_size):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
78 n_columns, n_rows = grid_size
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
79 self.removeAllChildren()
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
80 for row_n in xrange(n_rows):
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
81 row_size = (n_columns * self.cell_size[0], self.cell_size[1])
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
82 row = pychan.HBox(min_size=row_size, max_size=row_size,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
83 padding=self.padding)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
84 row.border_size = 1
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
85 row.opaque = 0
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
86 for column_n in xrange(n_columns):
123
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
87 index = (row_n * n_columns + column_n)
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
88 slot = Slot(min_size=(self.cell_size),
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
89 max_size=(self.cell_size))
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
90 slot.border_size = 1
123
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
91 slot.name = "Slot_%d" % index
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
92 slot.index = index
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
93 slot.image = None
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
94 slot.size = self.cell_size
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
95 row.addChild(slot)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
96 self.addChild(row)
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
97 self.min_size = ((n_columns * self.cell_size[0]) + 2,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
98 (n_rows * self.cell_size[1]) + 2)
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
99 self.max_size = self.min_size
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
100
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
101 def _getGridSize(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
102 n_rows = len(self.children)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
103 n_columns = len(self.children[0].children)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
104 return (n_rows, n_columns)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
105 grid_size = property(fget=_getGridSize, fset=_setGridSize)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
106
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
107 def getSlot(self, row_or_index, col=None):
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
108 if col:
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
109 index = row * self.n_columns + col
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
110 else:
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
111 index = row_or_index
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
112 return self.findChildByName("Slot_%d" % index)
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
113
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
114 def __init__(self,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
115 grid_size=(2, 2),
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
116 cell_size=(50, 50),
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
117 parent = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
118 name = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
119 size = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
120 min_size = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
121 max_size = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
122 helptext = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
123 position = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
124 style = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
125 hexpand = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
126 vexpand = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
127 font = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
128 base_color = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
129 background_color = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
130 foreground_color = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
131 selection_color = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
132 position_technique = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
133 is_focusable = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
134 comment = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
135 background_image = None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
136 _real_widget = None):
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
137 pychan.VBox.__init__(self,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
138 parent=parent,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
139 name=name,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
140 size=size,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
141 min_size=min_size,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
142 max_size=max_size,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
143 helptext=helptext,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
144 position=position,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
145 style=style,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
146 hexpand=hexpand,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
147 vexpand=vexpand,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
148 font=font,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
149 base_color=base_color,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
150 background_color=background_color,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
151 foreground_color=foreground_color,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
152 selection_color=selection_color,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
153 border_size=1,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
154 position_technique=position_technique,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
155 is_focusable=is_focusable,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
156 comment=comment,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
157 padding=0,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
158 background_image=background_image,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
159 opaque=0,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
160 margins=None,
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
161 _real_widget=_real_widget)
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
162 self.cell_size = cell_size
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
163 self.grid_size = grid_size
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
164
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
165
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
166 class EquipmentGUI(ContainerGUIBase):
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
167 def __init__(self, controller, gui, equip, callbacks, slot_size = (50, 50)):
119
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
168 ContainerGUIBase.__init__(self, controller, gui)
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
169 self.equip = equip
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
170 self.equip_to_gui = {
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
171 "head": "headSlot",
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
172 "neck": "neckSlot",
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
173 "body": "shirtSlot",
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
174 "belt": "beltSlot",
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
175 "leg": "pantsSlot",
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
176 "feet": "bootsSlot",
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
177 "l_arm": "leftHandSlot",
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
178 "r_arm": "rightHandSlot",
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
179 }
144
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
180 self.setSlotEvents()
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
181 self.slot_size = slot_size
119
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
182
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
183 def updateImages(self):
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
184 for eq_slot, gui_slot in self.equip_to_gui.iteritems():
144
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
185 widget = self.gui.findChildByName(gui_slot)
119
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
186 equipable = equip.get_equipable(self.equip, eq_slot)
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
187 widget.item = equipable.entity if equipable else None
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
188 self.updateImage(widget)
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
189
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
190 def updateImage(self, slot):
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
191 assert(isinstance(slot, EquipmentSlot))
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
192 if (slot.item):
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
193 image = slot.item.containable.image
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
194 else:
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
195 image = None
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
196 slot.image = image
144
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
197
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
198 def dragObject(self, obj):
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
199 """Drag the selected object.
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
200 @type obj: string
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
201 @param obj: The name of the object
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
202 @return: None"""
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
203 # get the widget from the gui with the name obj
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
204 drag_widget = self.gui.findChildByName(obj)
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
205 drag_item = drag_widget.item
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
206 # only drag if the widget is not empty
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
207 if (drag_item != None):
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
208 if isinstance(drag_item, General):
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
209 drag_item = drag_item.containable
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
210 elif isinstance(drag_item, equipable):
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
211 drag_item = drag_item.entity.containable
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
212 drag_eq = drag_item.entity.equipable
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
213 # get the image of the widget
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
214 image = drag_widget.image
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
215 self.setDragData(drag_item, image, image)
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
216 equip.take_equipable(self.equip, drag_eq.in_slot)
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
217
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
218 # after dragging the 'item', set the widgets' images
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
219 # so that it has it's default 'empty' images
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
220 drag_widget.item = None
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
221 self.updateImage(drag_widget)
119
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
222
144
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
223 def dropObject(self, obj):
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
224 """Drops the object being dropped
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
225 @type obj: string
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
226 @param obj: The name of the object
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
227 @return: None"""
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
228 try:
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
229 drop_widget = self.gui.findChildByName(obj)
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
230 drop_slot = drop_widget.slot
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
231 replace_item = None
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
232
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
233 if data_drag.dragging:
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
234 drag_item = data_drag.dragged_item.entity
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
235 if drag_item.equipable:
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
236 drag_item = drag_item.equipable
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
237 else:
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
238 return
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
239 #this will get the replacement item and the data for drag_drop
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
240 #if there is an item all ready occupying the slot
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
241 replace_item = (
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
242 equip.equip(self.equip, drag_item, drop_slot)
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
243 )
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
244
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
245 #if there was no item the stop dragging and reset cursor
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
246 if replace_item:
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
247 image = drop_widget.image
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
248 self.setDragData(replace_item.entity.containable, image, image)
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
249 else:
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
250 data_drag.dragging = False
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
251 #reset the mouse cursor to the normal cursor
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
252 self.controller.resetMouseCursor()
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
253 drop_widget.item = drag_item.entity
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
254 self.updateImage(drop_widget)
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
255 except (equip.AlreadyEquippedError, equip.CannotBeEquippedInSlot):
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
256 #Do we want to notify the player why the item can't be dropped?
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
257 pass
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
258
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
259 def mousePressedOnSlot(self, event, widget):
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
260 if event.getButton() == event.LEFT:
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
261 self.dragDrop(widget.name)
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
262
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
263 def setSlotEvents(self):
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
264 events_to_map = {}
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
265 for eq_slot, gui_slot in self.equip_to_gui.iteritems():
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
266 widget = self.gui.findChildByName(gui_slot)
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
267 slot_name = widget.name
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
268 widget.slot = eq_slot
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
269 events_to_map[slot_name + "/mousePressed"] = (
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
270 self.mousePressedOnSlot
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
271 )
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
272 events_to_map[slot_name + "/mouseReleased"] = self.showContextMenu
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
273
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
274 self.gui.mapEvents(events_to_map)
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
275
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
276 class InventoryGUI(ContainerGUIBase):
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
277 def __init__(self, controller, gui, container, callbacks):
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
278 ContainerGUIBase.__init__(self, controller, gui)
123
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
279 self.grid = self.gui.findChildByName("Grid")
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
280 assert(isinstance(self.grid, InventoryGrid))
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
281 self.container = container
123
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
282 self.setSlotEvents()
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
283
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
284 def setSlotEvents(self):
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
285 slot_count = self.grid.n_rows * self.grid.n_columns
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
286 events_to_map = {}
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
287 for counter in xrange(0, slot_count):
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
288 widget = self.grid.getSlot(counter)
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
289 slot_name = widget.name
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
290 widget.index = counter
135
9e86c37f5506 Added context menu to the inventory.
KarstenBock@gmx.net
parents: 133
diff changeset
291 events_to_map[slot_name + "/mousePressed"] = (
9e86c37f5506 Added context menu to the inventory.
KarstenBock@gmx.net
parents: 133
diff changeset
292 self.mousePressedOnSlot
9e86c37f5506 Added context menu to the inventory.
KarstenBock@gmx.net
parents: 133
diff changeset
293 )
9e86c37f5506 Added context menu to the inventory.
KarstenBock@gmx.net
parents: 133
diff changeset
294 events_to_map[slot_name + "/mouseReleased"] = self.showContextMenu
123
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
295
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
296 self.grid.mapEvents(events_to_map)
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
297 self.updateImages()
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
298
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
299 def updateImages(self):
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
300 for index, child in enumerate(self.container.children):
123
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
301 slot = self.grid.getSlot(index)
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
302 if child:
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
303 slot.item = child.entity
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
304 else:
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
305 slot.item = None
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
306 self.updateImage(slot)
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
307
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
308 def updateImage(self, slot):
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
309 assert(isinstance(slot, Slot))
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
310 if (slot.item):
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
311 image = slot.item.containable.image
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
312
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
313 else:
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
314 image = None
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
315 slot.image = image
123
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
316
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
317 def mousePressedOnSlot(self, event, widget):
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
318 if event.getButton() == event.LEFT:
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
319 self.dragDrop(widget.name)
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
320
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
321 def dragObject(self, obj):
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
322 """Drag the selected object.
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
323 @type obj: string
144
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
324 @param obj: The name of the object
123
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
325 @return: None"""
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
326 # get the widget from the gui with the name obj
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
327 drag_widget = self.gui.findChild(name = obj)
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
328 drag_item = drag_widget.item
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
329 # only drag if the widget is not empty
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
330 if (drag_item != None):
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
331 if isinstance(drag_item, General):
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
332 drag_item = drag_item.containable
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
333 # get the image of the widget
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
334 image = drag_widget.image
142
c28e29056218 Removed source_container value from data_drag.
KarstenBock@gmx.net
parents: 135
diff changeset
335 self.setDragData(drag_item, image, image)
123
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
336 container.take_item(self.container, drag_item.slot)
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
337
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
338 # after dragging the 'item', set the widgets' images
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
339 # so that it has it's default 'empty' images
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
340 drag_widget.item = None
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
341 self.updateImage(drag_widget)
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
342
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
343 def dropObject(self, obj):
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
344 """Drops the object being dropped
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
345 @type obj: string
144
86b9b181ad1c Added drag and drop and context menu to the equipment part of the character screen.
KarstenBock@gmx.net
parents: 142
diff changeset
346 @param obj: The name of the object
123
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
347 @return: None"""
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
348 try:
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
349 drop_widget = self.gui.findChildByName(obj)
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
350 drop_index = drop_widget.index
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
351 replace_item = None
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
352
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
353 if data_drag.dragging:
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
354 drag_item = data_drag.dragged_item
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
355 #this will get the replacement item and the data for drag_drop if
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
356 ## there is an item all ready occupying the slot
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
357 replace_item = (
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
358 container.put_item(self.container, drag_item, drop_index)
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
359 )
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
360
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
361 #if there was no item the stop dragging and reset cursor
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
362 if replace_item:
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
363 image = drop_widget.image
142
c28e29056218 Removed source_container value from data_drag.
KarstenBock@gmx.net
parents: 135
diff changeset
364 self.setDragData(replace_item, image, image)
123
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
365 else:
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
366 data_drag.dragging = False
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
367 #reset the mouse cursor to the normal cursor
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
368 self.controller.resetMouseCursor()
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
369 drop_widget.item = drag_item.entity
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
370 self.updateImage(drop_widget)
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
371 except (container.BulkLimitError):
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
372 #Do we want to notify the player why the item can't be dropped?
1efe0c42927f Added drag and drop functionality to the players inventory grid.
KarstenBock@gmx.net
parents: 120
diff changeset
373 pass
146
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
374
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
375 def createMenuItems(self, item, actions):
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
376 """Creates context menu items for the InventoryGUI"""
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
377 menu_actions = ContainerGUIBase.createMenuItems(self, item, actions)
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
378 param_dict = {}
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
379 param_dict["controller"] = self.controller
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
380 param_dict["commands"] = {}
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
381 param_dict["item"] = item.containable
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
382 param_dict["container_gui"] = self
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
383 menu_actions.append(["Drop",
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
384 "Drop",
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
385 self.executeMenuItem,
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
386 ACTIONS["DropFromInventory"](**param_dict)])
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
387 return menu_actions
abfeac863dd6 Items can now be dropped on the ground from the players inventory.
KarstenBock@gmx.net
parents: 144
diff changeset
388
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
389 class CharacterGUI(object):
119
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
390 def __init__(self, controller, gui, container, equip, callbacks):
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
391 self.engine = controller.engine
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
392 self.inventory_shown = False
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
393 if isinstance(gui, pychan.Widget):
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
394 self.gui = gui
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
395 elif isinstance(gui, StringTypes):
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
396 xml_file = vfs.VFS.open(gui)
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
397 self.gui = pychan.loadXML(xml_file)
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
398 else:
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
399 self.gui = pychan.loadXML(gui)
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
400
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
401 render_backend = self.engine.getRenderBackend()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
402 screen_mode = render_backend.getCurrentScreenMode()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
403 screen_width, screen_height = (screen_mode.getWidth(),
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
404 screen_mode.getHeight())
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
405 widget_width, widget_height = self.gui.size
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
406 self.gui.position = ((screen_width - widget_width) / 2,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
407 (screen_height - widget_height) / 2)
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
408 self.equip_gui = EquipmentGUI(
119
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
409 controller,
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
410 self.gui.findChildByName("equipmentPage"),
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
411 equip, callbacks
2399a8c3da0c Modified EquipmentSlot to display an image instead of a text.
KarstenBock@gmx.net
parents: 112
diff changeset
412 )
120
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
413 self.inv_gui = InventoryGUI(
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
414 controller,
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
415 self.gui.findChildByName("inventoryPage"),
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
416 container, callbacks
adbcdb900fa9 Modified InventoryGrid to set a name for each slot containing the index.
KarstenBock@gmx.net
parents: 119
diff changeset
417 )
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
418
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
419 def toggleInventory(self, toggleImage=True):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
420 """Pause the game and enter the inventory screen, or close the
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
421 inventory screen and resume the game.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
422 @type toggleImage: bool
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
423 @param toggleImage:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
424 Call toggleInventoryCallback if True. Toggling via a
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
425 keypress requires that we toggle the Hud inventory image
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
426 explicitly. Clicking on the Hud inventory button toggles the
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
427 image implicitly, so we don't change it.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
428 @return: None"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
429 if not self.inventory_shown:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
430 self.showInventory()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
431 self.inventory_shown = True
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
432 else:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
433 self.closeInventory()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
434 self.inventory_shown = False
133
18391ebe137b Added updateImages method to CharacterGUI.
KarstenBock@gmx.net
parents: 123
diff changeset
435
18391ebe137b Added updateImages method to CharacterGUI.
KarstenBock@gmx.net
parents: 123
diff changeset
436 def updateImages(self):
18391ebe137b Added updateImages method to CharacterGUI.
KarstenBock@gmx.net
parents: 123
diff changeset
437 self.equip_gui.updateImages()
18391ebe137b Added updateImages method to CharacterGUI.
KarstenBock@gmx.net
parents: 123
diff changeset
438 self.inv_gui.updateImages()
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
439
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
440 def showInventory(self):
133
18391ebe137b Added updateImages method to CharacterGUI.
KarstenBock@gmx.net
parents: 123
diff changeset
441 self.updateImages()
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
442 self.gui.show()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
443
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
444 def closeInventory(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
445 self.gui.hide()
169
5b880b8cff6d Fixes to make PARPG compatible with changes made to fife.
Beliar <KarstenBock@gmx.net>
parents: 148
diff changeset
446