-
Notifications
You must be signed in to change notification settings - Fork 2
/
frmNewDateStamp.frm
328 lines (280 loc) · 8.21 KB
/
frmNewDateStamp.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
VERSION 5.00
Begin VB.Form frmNewDateStamp
BorderStyle = 1 'Fixed Single
Caption = "New Date Stamp"
ClientHeight = 3480
ClientLeft = 45
ClientTop = 375
ClientWidth = 2445
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3480
ScaleWidth = 2445
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdCancel
Caption = "Cancel"
Height = 375
Left = 120
TabIndex = 17
Top = 3000
Width = 975
End
Begin VB.CommandButton cmdOK
Caption = "OK"
Height = 375
Left = 1320
TabIndex = 16
Top = 3000
Width = 975
End
Begin VB.TextBox txtMillisecond
Height = 285
Left = 1320
TabIndex = 15
Text = "0"
Top = 2640
Width = 975
End
Begin VB.TextBox txtSecond
Height = 285
Left = 1320
TabIndex = 14
Text = "0"
Top = 2280
Width = 975
End
Begin VB.TextBox txtMinute
Height = 285
Left = 1320
TabIndex = 13
Text = "0"
Top = 1920
Width = 975
End
Begin VB.TextBox txtHour
Height = 285
Left = 1320
TabIndex = 12
Text = "0"
Top = 1560
Width = 975
End
Begin VB.TextBox txtDay
Height = 285
Left = 1320
TabIndex = 11
Text = "0"
Top = 1200
Width = 975
End
Begin VB.TextBox txtDayOfWeek
Height = 285
Left = 1320
TabIndex = 10
Text = "0"
Top = 840
Width = 975
End
Begin VB.TextBox txtMonth
Height = 285
Left = 1320
TabIndex = 9
Text = "1"
Top = 480
Width = 975
End
Begin VB.TextBox txtYear
Height = 285
Left = 1320
TabIndex = 8
Text = "0"
Top = 120
Width = 975
End
Begin VB.Label lblMillisecond
AutoSize = -1 'True
Caption = "Millisecond"
Height = 195
Left = 360
TabIndex = 7
Top = 2640
Width = 780
End
Begin VB.Label lblSecond
AutoSize = -1 'True
Caption = "Second"
Height = 195
Left = 585
TabIndex = 6
Top = 2280
Width = 555
End
Begin VB.Label lblMinute
AutoSize = -1 'True
Caption = "Minute"
Height = 195
Left = 660
TabIndex = 5
Top = 1920
Width = 480
End
Begin VB.Label lblHour
AutoSize = -1 'True
Caption = "Hour"
Height = 195
Left = 795
TabIndex = 4
Top = 1560
Width = 345
End
Begin VB.Label lblDay
AutoSize = -1 'True
Caption = "Day"
Height = 195
Left = 855
TabIndex = 3
Top = 1200
Width = 285
End
Begin VB.Label lblDayOfWeek
AutoSize = -1 'True
Caption = "Day of Week"
Height = 195
Left = 195
TabIndex = 2
Top = 840
Width = 945
End
Begin VB.Label lblMonth
AutoSize = -1 'True
Caption = "Month"
Height = 195
Left = 690
TabIndex = 1
Top = 480
Width = 450
End
Begin VB.Label lblYear
AutoSize = -1 'True
Caption = "Year"
Height = 195
Left = 810
TabIndex = 0
Top = 120
Width = 330
End
End
Attribute VB_Name = "frmNewDateStamp"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' OSE - Oblivion Save Editor
' Copyright (C) 2012, 2013 Grahame White
'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 2 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License along
' with this program; if not, write to the Free Software Foundation, Inc.,
' 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Option Explicit
DefObj A-Z
Public Mode As Integer
Private Sub Form_Load()
Select Case Mode
Case DATE_STAMP_MODE_EXE
UpdateDisplay SaveFileData.FileHeader.EXETime
Case DATE_STAMP_MODE_GAME
UpdateDisplay SaveFileData.SaveHeader.GameTime
End Select
End Sub
Private Sub UpdateDisplay(ByRef DateStamp As SystemTime)
txtYear.Text = DateStamp.Year
txtMonth.Text = DateStamp.Month
txtDayOfWeek.Text = DateStamp.DayOfWeek
txtDay.Text = DateStamp.Day
txtHour.Text = DateStamp.Hour
txtMinute.Text = DateStamp.Minute
txtSecond.Text = DateStamp.Second
txtMillisecond.Text = DateStamp.MilliSecond
End Sub
Private Sub txtYear_Change()
ValidateInput txtYear, YEAR_MIN, YEAR_MAX
End Sub
Private Sub txtMonth_Change()
ValidateInput txtMonth, MONTH_MIN, MONTH_MAX
End Sub
Private Sub txtDayOfWeek_Change()
ValidateInput txtDayOfWeek, DAY_OF_WEEK_MIN, DAY_OF_WEEK_MAX
End Sub
Private Sub txtDay_Change()
ValidateInput txtDay, DAY_MIN, DAY_MAX
End Sub
Private Sub txtHour_Change()
ValidateInput txtHour, HOUR_MIN, HOUR_MAX
End Sub
Private Sub txtMinute_Change()
ValidateInput txtMinute, MINUTE_MIN, MINUTE_MAX
End Sub
Private Sub txtSecond_Change()
ValidateInput txtSecond, SECOND_MIN, SECOND_MAX
End Sub
Private Sub txtMillisecond_Change()
ValidateInput txtMillisecond, MILLISECOND_MIN, MILLISECOND_MAX
End Sub
Private Sub cmdCancel_Click()
frmNewDateStamp.Hide
End Sub
Private Sub cmdOK_Click()
' Fix the minimum year if it's too low
If txtYear.Text < 1601 Then
txtYear.Text = 1601
End If
' Fix any problems in the day number
CheckDaysInMonth
' Set new date
Select Case Mode
Case DATE_STAMP_MODE_EXE
ModifySaveFileEXETime frmNewDateStamp
Case DATE_STAMP_MODE_GAME
ModifySaveFileGameTime frmNewDateStamp
End Select
frmNewDateStamp.Hide
End Sub
Private Sub CheckDaysInMonth()
Select Case txtMonth.Text
Case 4, 6, 9, 11
If txtDay.Text > 30 Then
txtDay.Text = 30
End If
Case 2
If IsLeapYear Then
If txtDay.Text > 29 Then
txtDay.Text = 29
End If
Else
If txtDay.Text > 28 Then
txtDay.Text = 28
End If
End If
End Select
End Sub
Private Function IsLeapYear() As Boolean
If txtYear.Text Mod 4 = 0 And txtYear.Text Mod 100 <> 0 Then
IsLeapYear = True
ElseIf (txtYear.Text / 100) Mod 4 = 0 Then
IsLeapYear = True
Else
IsLeapYear = False
End If
End Function