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.
21 # GUIJRNL.py - scripts to control journal/diary windows from GUIJRNL winpack
23 ###################################################
26 import GUICommonWindows
27 from GUIDefines
import *
29 ###################################################
33 OldPortraitWindow
= None
34 OldOptionsWindow
= None
40 ###################################################
41 def OpenJournalWindow ():
42 global StartTime
, StartYear
43 global JournalWindow
, PortraitWindow
, OptionsWindow
44 global OldPortraitWindow
, OldOptionsWindow
47 if GUICommon
.CloseOtherWindow (OpenJournalWindow
):
49 JournalWindow
.Unload ()
51 OptionsWindow
.Unload ()
53 PortraitWindow
.Unload ()
56 GemRB
.SetVar ("OtherWindow", -1)
57 GUICommon
.GameWindow
.SetVisible(WINDOW_VISIBLE
)
59 GUICommonWindows
.PortraitWindow
= OldPortraitWindow
60 OldPortraitWindow
= None
61 GUICommonWindows
.OptionsWindow
= OldOptionsWindow
62 OldOptionsWindow
= None
66 GUICommon
.GameWindow
.SetVisible(WINDOW_INVISIBLE
)
68 GemRB
.LoadWindowPack ("GUIJRNL", 640, 480)
69 JournalWindow
= Window
= GemRB
.LoadWindow (2)
70 GemRB
.SetVar ("OtherWindow", JournalWindow
.ID
)
71 #saving the original portrait window
72 OldOptionsWindow
= GUICommonWindows
.OptionsWindow
73 OptionsWindow
= GemRB
.LoadWindow (0)
74 GUICommonWindows
.SetupMenuWindowControls (OptionsWindow
, 0, OpenJournalWindow
)
75 OptionsWindow
.SetFrame ()
76 OldPortraitWindow
= GUICommonWindows
.PortraitWindow
77 PortraitWindow
= GUICommonWindows
.OpenPortraitWindow (0)
79 Table
= GemRB
.LoadTable("YEARS")
80 #StartTime is the time offset for ingame time, beginning from the startyear
81 StartTime
= Table
.GetValue("STARTTIME", "VALUE") / 4500
82 #StartYear is the year of the lowest ingame date to be printed
83 StartYear
= Table
.GetValue("STARTYEAR", "VALUE")
85 Button
= Window
.GetControl (3)
86 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, JournalPrevSectionPress
)
88 Button
= Window
.GetControl (4)
89 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, JournalNextSectionPress
)
91 Chapter
= GemRB
.GetGameVar("chapter")
92 UpdateJournalWindow ()
93 OptionsWindow
.SetVisible (WINDOW_VISIBLE
)
94 Window
.SetVisible (WINDOW_VISIBLE
)
95 PortraitWindow
.SetVisible (WINDOW_VISIBLE
)
97 ###################################################
98 def UpdateJournalWindow ():
99 Window
= JournalWindow
102 Title
= Window
.GetControl (5)
103 Title
.SetText (16202 + Chapter
)
106 Text
= Window
.GetControl (1)
109 for i
in range (GemRB
.GetJournalSize (Chapter
)):
110 je
= GemRB
.GetJournalEntry (Chapter
, i
)
115 hours
= je
['GameTime'] / 4500
117 year
= str (StartYear
+ int(days
/365))
118 dayandmonth
= StartTime
+ days
%365
119 GemRB
.SetToken("GAMEDAY", str(days
) )
120 GemRB
.SetToken("HOUR",str(hours
%24 ) )
121 GemRB
.SetVar("DAYANDMONTH",dayandmonth
)
122 GemRB
.SetToken("YEAR",year
)
123 Text
.Append (GemRB
.GetString(15980), 3*i
)
125 Text
.Append (je
['Text'], 3*i
+ 1)
126 Text
.Append ("", 3*i
+ 2)
129 ###################################################
130 def JournalPrevSectionPress ():
134 Chapter
= Chapter
- 1
135 UpdateJournalWindow ()
138 ###################################################
139 def JournalNextSectionPress ():
142 #if GemRB.GetJournalSize (Chapter + 1) > 0:
143 if Chapter
< GemRB
.GetGameVar("chapter"):
144 Chapter
= Chapter
+ 1
145 UpdateJournalWindow ()
148 ###################################################
149 # End of file GUIJRNL.py