-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.adept
162 lines (136 loc) · 4.23 KB
/
main.adept
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
pragma compiler_version '2.4'
#default release false
#default fullscreen true
#default monitor_fps false
#default ignore_NAME_txt false
#default no_music false
#default enable_music_hotkeys true
#default enable_debugging_hotkeys false
#default enable_credits_hd_hover false
#default auto_name false
#default random_use_mt19937 true
#default use_connect_timeout true
#default connect_timeout_seconds 3
#default do_try_to_connect false // (If server is unresponsive, this will help)
#unless release
#print "[BUILD] Using develop configuration..."
#set fullscreen false
#set ignore_NAME_txt true
#set auto_name true
#set no_music true
#set enable_debugging_hotkeys true
#set settings_immutable true
#end
import basics
import captain
import List
import Matrix4f
import audio
import random
import 'sys/csignal.adept'
import 'NetworkManager.adept'
import 'NetworkInterpreter.adept'
import 'RoomListing.adept'
import 'GameData.adept'
import 'Textures.adept'
import 'Models.adept'
import 'Scene.adept'
import 'Text.adept'
import 'where.adept'
import 'strings.adept'
import 'lines.adept'
import 'SoundTrack.adept'
import 'SoundEffects.adept'
import 'Loader.adept'
import 'Settings.adept'
func main(argc int, argv **ubyte) {
repeat static argc - 1 {
arg String = stringConstant(argv[idx + 1])
if arg.startsWith("--host="), gamedata.override_host = arg.decapitated(7)
else if arg.startsWith("--port="), gamedata.override_port = arg.decapitated(7)
else print("bad argument: %" % arg)
}
unless gamedata.override_host.empty(), print("OVERRIDE: override_host=%" % gamedata.override_host)
unless gamedata.override_port.empty(), print("OVERRIDE: override_port=%" % gamedata.override_port)
captOnSetup(func &onSetup)
captOnExit(func &onExit)
captOnStep(func &onStep, 60)
captOnClick(func &onClick, true)
captOnRelease(func &onRelease, true)
captOnKey(func &onKey)
captOnChar(func &onChar)
captOnScroll(func &onScroll)
captOnDraw(func &onDraw)
captMultisample(4)
// Load settings
settings.load()
if settings.windowed {
captStart('Generic Card Game', 1280, 720, false)
} else {
#if fullscreen
captStart('Generic Card Game', true)
#else
captStart('Generic Card Game', 1280, 720, false)
#end
}
}
func onSetup {
// Ensure constant aspect ratio for windowed mode
if settings.windowed, glfwSetWindowAspectRatio(_captain_window, 16, 9)
signal(SIGPIPE, SIG_IGN)
audioInit()
textures.load()
models.load()
loader.create()
}
func onExit {
loader.stop()
loader.destroy()
textures.unload()
dynamic_textures.unload()
models.unload()
gamedata.exit()
sfx.unload()
soundtrack.stop()
soundtrack.destroy()
audioTerminate()
}
func onStep {
if loader.didFinishLoading() {
soundtrack.start()
gamedata.loadDeck()
settings.apply()
}
if loader.isComplete() {
gamedata.step()
soundtrack.update()
sfx.update()
}
}
func onClick(x, y float, button int) {
if loader.isComplete(), gamedata.click(x, y, button)
}
func onRelease(x, y float, button int) {
if loader.isComplete(), gamedata.release(x, y, button)
}
func onKey(key, scancode, action, mods int) {
unless loader.isComplete(), return
gamedata.key(key, scancode, action, mods)
#if enable_music_hotkeys
if key == GLFW_KEY_SPACE && action == GLFW_PRESS && mods & GLFW_MOD_CONTROL, soundtrack.fadeOutIntoNextSong()
if key == GLFW_KEY_M && action == GLFW_PRESS && mods & GLFW_MOD_CONTROL, soundtrack.toggle()
if key == GLFW_KEY_N && action == GLFW_PRESS && mods & GLFW_MOD_CONTROL, sfx.toggle()
#end
}
func onChar(c uint) {
if loader.isComplete(), gamedata.char(c)
}
func onScroll(x float, y float) {
if loader.isComplete(), gamedata.scroll(x, y)
}
func onDraw {
captClearColor(captColor(0.75f, 0.75f, 0.75f))
captDrawTexture(textures.background, 0.0f, 0.0f, captViewWidth(), captViewHeight())
if loader.isComplete(), gamedata.draw()
else loader.drawLoadingAnimation()
}