factored out the EFFv2 saving into EFFImporter
[gemrb.git] / gemrb / GUIScripts / iwd2 / GUIJRNL.py
blob6e4479f999b0e8b7a978319ef61ac3b3640b7ad5
1 # -*-python-*-
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 ###################################################
24 import GemRB
25 from GUIDefines import *
26 import GUICommon
28 ###################################################
29 JournalWindow = None
30 Chapter = 0
31 StartTime = 0
32 StartYear = 0
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):
46 GemRB.HideGUI ()
47 if JournalWindow:
48 JournalWindow.Unload ()
49 JournalWindow = None
50 GemRB.SetVar ("OtherWindow", -1)
52 GemRB.UnhideGUI ()
53 return
55 GemRB.HideGUI ()
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 ()
69 GemRB.UnhideGUI ()
72 ###################################################
73 def UpdateJournalWindow ():
74 Window = JournalWindow
76 # Title
77 Title = Window.GetControl (5)
78 Title.SetText (16202 + Chapter)
80 # text area
81 Text = Window.GetControl (1)
82 Text.Clear ()
84 for i in range (GemRB.GetJournalSize (Chapter)):
85 je = GemRB.GetJournalEntry (Chapter, i)
87 if je == None:
88 continue
90 hours = je['GameTime'] / 4500
91 days = int(hours/24)
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 ():
105 global Chapter
107 if Chapter > 0:
108 Chapter = Chapter - 1
109 UpdateJournalWindow ()
112 ###################################################
113 def JournalNextSectionPress ():
114 global Chapter
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