-
Notifications
You must be signed in to change notification settings - Fork 0
/
NuReplay.bas
251 lines (219 loc) · 5.84 KB
/
NuReplay.bas
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
#include "NuReplay.bi"
declare sub loadTurnKB(KBCount as integer, Players as ubyte)
#include "LoadTurn.bi"
#IFDEF __NR_AUDIO__
#include "NRAudio.bas"
#ENDIF
#include "NREngine.bas"
#include "NRClient.bas"
#include "ListGames.bi"
#include "NuStatic.bi"
sub cleaning destructor
open "Settings.csv" for output as #1
print #1, quote("Login");",";quote(Username)
print #1, quote("Key");",";quote(APIKey)
print #1, quote("Preferred Type");",";quote(PreferType)
print #1, quote("Simple View");",";SimpleView
print #1, quote("Exclude Blitz Games");",";ExcludeBlitzes
print #1, quote("Exclude MvM Games");",";ExcludeMvM
print #1, quote("Exclude Dataless Games");",";ExcludeNodata
print #1, quote("Legacy Race Names");",";LegacyRaceNames
print #1, quote("Borderless");",";BorderlessFS
print #1, quote("Slideshow Delay");",";SlideshowDelay
close #1
#IFNDEF __FB_DOS__
ThreadDetach ConvertorSes
MutexDestroy ConvertorLock
#ENDIF
ImageDestroy(IslandMap)
ImageDestroy(Indeterminate)
ImageDestroy(Cursor)
#IFNDEF __FORCE_OFFLINE__
SDLNet_Quit
#ENDIF
#IFDEF __NR_AUDIO__
Mix_CloseAudio
SDL_Quit
#ENDIF
end sub
WindowStr = BROWSER_LONG
if FileExists("Login.csv") AND FileExists("Settings.csv") = 0 then name("Login.csv","Settings.csv")
Username = "guest"
APIKey = ""
PreferType = "Seasonal Championship"
SimpleView = 0
ExcludeBlitzes = 1
ExcludeMvM = 1
ExcludeNodata = 0
LegacyRaceNames = 0
SlideshowDelay = 1000
if FileExists("Settings.csv") then
open "Settings.csv" for input as #1
do
input #1, NullStr
select case NullStr
case "Login"
input #1, Username
case "Key"
input #1, APIKey
case "Preferred Type"
input #1, PreferType
case "Simple View"
input #1, SimpleView
case "Exclude Blitz Games"
input #1, ExcludeBlitzes
case "Exclude MvM Games"
input #1, ExcludeMvM
case "Exclude Dataless Games"
input #1, ExcludeNodata
case "Legacy Race Names"
input #1, LegacyRaceNames
case "Borderless"
input #1, BorderlessFS
case "Slideshow Delay"
input #1, SlideshowDelay
end select
loop until eof(1)
close #1
'Personal games are available only with an API Key
if APIKey = "" then
Username = "guest"
if PreferType = "Personal" then
PreferType = "Seasonal Championship"
end if
end if
'Academy games are now deprecated - Fall back to Seasonal Championship
if PreferType = "Academy" then
PreferType = "Seasonal Championship"
end if
'Chmapionship games have been split into two categories.
'The oldest 12 championship matches are now called the Zodiac Wars.
if PreferType = "Championship" then
PreferType = "Seasonal Championship"
end if
if Command(1) = "--dev" then
DevMode = 1
end if
end if
'Checks desktop size and acts accordingly
with BaseScreen
Screencontrol GET_DESKTOP_SIZE, .Wideth, .Height
if .Wideth < 800 OR .Height < 600 then
/'
'If desktop size does not meet program requirements, it reports an
'error and closes
'/
open "stderr.txt" for output as #9
print #9, "Nu Replayer requires 800x600 in order to run."
close #9
cleaning
end -2
elseif .Wideth <= 1024 OR .Height <= 800 then
/'
' If the desktop size is equal to the hub requirements on
' either side, then it forces fullscreen. Access to most
' features are disabled
'/
prepCanvas(.Wideth,.Height,GFX_FULLSCREEN OR (GFX_NO_FRAME AND sgn(BorderlessFS)))
else
/'
' If the desktop size is greater than the hub requirements on
' both sides, then it forces to a window to allow a graceful
' switch in window size.
'/
prepCanvas(1024,768)
end if
end with
if screenptr = 0 then
'Error setting video mode
open "stderr.txt" for output as #9
print #9, "Video mode was not successfully established"
close #9
cleaning
end -2
end if
'Creates an empty island map
IslandMap = ImageCreate(4096,2160)
'Additional auxillary assets
Indeterminate = ImageCreate(50,20)
line Indeterminate,(0,0)-(49,19),rgb(0,0,0),bf
for Plot as byte = 0 to 24
line Indeterminate,(Plot,19)-(Plot+19,0),rgb(48,48,80)
next Plot
Cursor = ImageCreate(21,21)
line Cursor,(0,10)-(7,10),rgb(224,224,224)
line Cursor,(13,10)-(21,10),rgb(224,224,224)
line Cursor,(10,0)-(10,7),rgb(224,224,224)
line Cursor,(10,13)-(10,21),rgb(224,224,224)
/'
' If Nu Replayer has online support, then it attempts to initialize
' SDL and connect to Planets Nu's servers
'/
#IFDEF __FORCE_OFFLINE__
OfflineMode = 1
ErrorMsg = "Nu Replayer network connectivity is disabled in this build."
#ELSE
if SDLNet_Init <> 0 AND OfflineMode = 0 then
OfflineMode = 1
ErrorMsg = "Nu Replayer is unable to initialize SDL, which it needs to connect online."
end if
if SDLNet_ResolveHost( @NuIP, DEFAULT_HOST, 80 ) <> 0 AND OfflineMode = 0 then
OfflineMode = 1
ErrorMsg = "Nu Replayer is unable to successfully resolve a connection with Planets Nu's servers."
end if
#ENDIF
updateGameList
if APIkey <> "" then
recordPersonalGames
end if
resetViewport
'In case some people don't like the music, a command option has been provided
#IFDEF __NR_AUDIO__
if cmdLine("-s") = 0 AND cmdLine("--silent") = 0 then
loadMusic("Menu")
end if
#ENDIF
#IFNDEF __FB_DOS__
ConvertorLock = MutexCreate
#ENDIF
#IF __FB_DEBUG__
kill("stdout.txt")
#ENDIF
do
select case ReplayerMode
case MODE_MENU, MODE_QUICK, MODE_DOWNLOAD, MODE_SETTINGS
menu
if GameID > 0 then
clearData
loadGame(GameID)
prepClientScreen
end if
case MODE_HUB_VIEW
replayHub
if GameID > 0 then
clearData
loadGame(GameID)
if TurnWIP then
TurnWIP = 0
else
prepClientScreen
end if
if QueueNextSong then
QueueNextSong = 0
#IFDEF __NR_AUDIO__
cycleMusic
#ENDIF
end if
end if
while screenevent(@e):wend
case MODE_HUB_DL
replayHub(1)
while screenevent(@e):wend
case else
renderClient
while screenevent(@e):wend
end select
if (multikey(SC_ALT) AND multikey(SC_F4)) then
exit do
end if
loop until ReplayerMode = MODE_EXIT