2 # GemRB - Infinity Engine Emulator
3 # Copyright (C) 2003 The GemRB Project
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 # Portrait.py - scripts to control portrait selection and scrolling
23 ###################################################
27 ###################################################
33 # initializes gender and portrait table
34 # PortraitGender: 1 Male
36 def Init (PortraitGender
):
37 global PortraitsTable
, PortraitCount
, Gender
39 if PortraitsTable
is None:
40 PortraitsTable
= GemRB
.LoadTable ("PICTURES")
43 Gender
= PortraitGender
45 # sets index to given protraitname
46 def Set (PortraitName
):
49 # removes l or s character at the end
50 PortraitName
= PortraitName
.rstrip ("[ls]")
52 # capitalize PortraitName
53 PortraitName
= PortraitName
.upper ()
56 for i
in range(0, PortraitsTable
.GetRowCount ()):
57 if PortraitName
== PortraitsTable
.GetRowName (i
).upper ():
63 # returns next portrait name
68 PortraitCount
= PortraitCount
+ 1
69 if PortraitCount
== PortraitsTable
.GetRowCount ():
71 if PortraitsTable
.GetValue (PortraitCount
, 0) == Gender
:
74 # return previous portrait name
79 PortraitCount
= PortraitCount
- 1
81 PortraitCount
= PortraitsTable
.GetRowCount () - 1
82 if PortraitsTable
.GetValue (PortraitCount
, 0) == Gender
:
85 # gets current portrait name
89 # if portrait matches not current gender, it will be skipped to
90 # the next portrait that matches
91 while PortraitsTable
.GetValue (PortraitCount
, 0) != Gender
:
92 PortraitCount
= PortraitCount
+ 1
94 PortraitName
= PortraitsTable
.GetRowName (PortraitCount
)