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 ###################################################
25 from GUIDefines
import *
28 ###################################################
34 ###################################################
35 def OpenJournalWindow ():
36 global StartTime
, StartYear
37 global JournalWindow
, Chapter
39 Table
= GemRB
.LoadTable("YEARS")
40 #StartTime is the time offset for ingame time, beginning from the startyear
41 StartTime
= Table
.GetValue("STARTTIME", "VALUE") / 4500
42 #StartYear is the year of the lowest ingame date to be printed
43 StartYear
= Table
.GetValue("STARTYEAR", "VALUE")
45 if GUICommon
.CloseOtherWindow (OpenJournalWindow
):
48 JournalWindow
.Unload ()
50 GemRB
.SetVar ("OtherWindow", -1)
56 GemRB
.LoadWindowPack ("GUIJRNL", 800, 600)
57 JournalWindow
= Window
= GemRB
.LoadWindow (2)
58 GemRB
.SetVar("OtherWindow", JournalWindow
.ID
)
61 Button
= Window
.GetControl (3)
62 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, JournalPrevSectionPress
)
64 Button
= Window
.GetControl (4)
65 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, JournalNextSectionPress
)
67 Chapter
= GemRB
.GetGameVar("chapter")
68 UpdateJournalWindow ()
72 ###################################################
73 def UpdateJournalWindow ():
74 Window
= JournalWindow
77 Title
= Window
.GetControl (5)
78 Title
.SetText (16202 + Chapter
)
81 Text
= Window
.GetControl (1)
84 for i
in range (GemRB
.GetJournalSize (Chapter
)):
85 je
= GemRB
.GetJournalEntry (Chapter
, i
)
90 hours
= je
['GameTime'] / 4500
92 year
= str (StartYear
+ int(days
/365))
93 dayandmonth
= StartTime
+ days
%365
94 GemRB
.SetToken("GAMEDAY", str(days
) )
95 GemRB
.SetToken("HOUR",str(hours
%24 ) )
96 GemRB
.SetVar("DAYANDMONTH",dayandmonth
)
97 GemRB
.SetToken("YEAR",year
)
98 Text
.Append ("[color=FFFF00]"+GemRB
.GetString(15980)+"[/color]", 3*i
)
99 Text
.Append (je
['Text'], 3*i
+ 1)
100 Text
.Append ("", 3*i
+ 2)
103 ###################################################
104 def JournalPrevSectionPress ():
108 Chapter
= Chapter
- 1
109 UpdateJournalWindow ()
112 ###################################################
113 def JournalNextSectionPress ():
116 #if GemRB.GetJournalSize (Chapter + 1) > 0:
117 if Chapter
< GemRB
.GetGameVar("chapter"):
118 Chapter
= Chapter
+ 1
119 UpdateJournalWindow ()
122 ###################################################
123 # End of file GUIJRNL.py