4
# Copyright (C) 2010, 2011 Levi D. Smith
6
# TetraCity is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# TetraCity is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with TetraCity. If not, see <http://www.gnu.org/licenses/gpl.txt>.
28
def initialize(i1, i2)
30
@soundEffectsVolume = i2
34
@pieceGeneration = GEN_BAG
36
@piecePreviewCount = 5
39
def soundEffectsVolume
68
attr_accessor :soundEffectsVolume
69
attr_accessor :musicVolume
70
attr_accessor :useLighting
72
attr_accessor :ghostPieceOn
73
attr_accessor :pieceGeneration
74
attr_accessor :colorScheme
75
attr_accessor :piecePreviewCount
91
while event = SDL::Event2.poll
96
when SDL::Event::KeyDown
101
if ($selected_option < 0)
105
$selected_option += 1
108
if ($selected_option > MAX_OPTIONS - 1)
109
$selected_option = MAX_OPTIONS - 1
114
if ($selected_option == 0)
116
elsif ($selected_option == 1)
117
decreaseSoundEffectsVolume
119
elsif ($selected_option == 2)
120
setUseLighting(false)
122
elsif ($selected_option == 3)
123
$theOptions.ghostPieceOn = false
125
elsif ($selected_option == 4)
126
$theOptions.pieceGeneration = Options::GEN_BAG
128
elsif ($selected_option == 5)
129
$theOptions.colorScheme -= 1
130
if ($theOptions.colorScheme < 0)
131
$theOptions.colorScheme = 0
134
elsif ($selected_option == 6)
135
$theOptions.piecePreviewCount -= 1
136
if ($theOptions.piecePreviewCount < 0)
137
$theOptions.piecePreviewCount = 0
144
if ($selected_option == 0)
146
elsif ($selected_option == 1)
147
increaseSoundEffectsVolume
149
elsif ($selected_option == 2)
152
elsif ($selected_option == 3)
153
$theOptions.ghostPieceOn = true
155
elsif ($selected_option == 4)
156
$theOptions.pieceGeneration = Options::GEN_RANDOM
158
elsif ($selected_option == 5)
159
$theOptions.colorScheme += 1
160
if ($theOptions.colorScheme > 6)
161
$theOptions.colorScheme = 6
164
elsif ($selected_option == 6)
165
$theOptions.piecePreviewCount += 1
166
if ($theOptions.piecePreviewCount > 5)
167
$theOptions.piecePreviewCount = 5
175
if ($selected_option == 7)
179
when SDL::Key::Q, SDL::Key::ESCAPE
192
glClearColor(0.5, 0.5, 0.5, 1.0);
193
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
195
colorHighlight = [1.0, 1.0, 1.0]
196
colorNormal = [0.5, 0.5, 0.5]
197
colorFg=[1.0, 1.0, 1.0]
202
glOrtho(0, 1024, 768, 0, -1, 1)
203
glColor(1.0, 1.0, 1.0)
210
iCol1 = x_offset + 32
211
iCol2 = x_offset + 400
218
glVertex(x_offset, y_offset, z)
219
glVertex(x_offset + width, y_offset, z)
220
glVertex(x_offset + width, y_offset + height, z)
221
glVertex(x_offset, y_offset + height, z)
227
glColor(1.0, 0.0, 0.0)
228
glVertex(x_offset, y_offset, z)
229
glVertex(x_offset + width, y_offset, z)
231
glColor(0.0, 0.0, 1.0)
232
glVertex(x_offset + width, y_offset, z)
233
glVertex(x_offset + width, y_offset + height, z)
235
glVertex(x_offset + width, y_offset + height, z)
236
glVertex(x_offset, y_offset + height, z)
238
glColor(1.0, 0.0, 0.0)
239
glVertex(x_offset, y_offset + height, z)
240
glVertex(x_offset, y_offset, z)
244
drawMenuText("OPTIONS", 200, 150, 128, 16, colorHighlight)
251
if ($selected_option == 0)
252
colorFg = colorHighlight
254
colorFg = colorNormal
257
drawMenuText("Music Volume", x, y, 128, 16, colorFg)
259
drawRectangle(iCol2, y, iCol2 + 128, y + 16, 0.0, 0.5, 0.5, 0.5)
261
drawRectangle(iCol2, y, iCol2 + $theOptions.musicVolume, y + 16, 0.0, 1, 1, 1)
264
if ($selected_option == 1)
265
colorFg = colorHighlight
267
colorFg = colorNormal
270
drawMenuText("Sound Effects Vol", x, y, 128, 16, colorFg)
272
drawRectangle(iCol2, y, iCol2 + 128, y + 16, 0.0, 0.5, 0.5, 0.5)
273
drawRectangle(iCol2, y, iCol2 + $theOptions.soundEffectsVolume, y + 16, 0.0, 1, 1, 1)
277
if ($selected_option == 2)
278
colorFg = colorHighlight
280
colorFg = colorNormal
284
drawMenuText("Use Lighting", iCol1, y, 128, 16, colorFg)
286
if (! $theOptions.useLighting)
287
colorFg = colorHighlight
289
colorFg = colorNormal
291
drawMenuText("OFF", iCol2, y, 128, 16, colorFg)
293
if ($theOptions.useLighting)
294
colorFg = colorHighlight
296
colorFg = colorNormal
298
drawMenuText("ON", iCol2 + 128, y, 128, 16, colorFg)
303
if ($selected_option == 3)
304
colorFg = colorHighlight
306
colorFg = colorNormal
310
drawMenuText("Ghost Piece", iCol1, y, 128, 16, colorFg)
312
if (! $theOptions.ghostPieceOn)
313
colorFg = colorHighlight
315
colorFg = colorNormal
317
drawMenuText("OFF", iCol2, y, 128, 16, colorFg)
319
if ($theOptions.ghostPieceOn)
320
colorFg = colorHighlight
322
colorFg = colorNormal
324
drawMenuText("ON", iCol2 + 128, y, 128, 16, colorFg)
326
### PIECE GENERATION ###
329
if ($selected_option == 4)
330
colorFg = colorHighlight
332
colorFg = colorNormal
336
drawMenuText("Piece Generation", iCol1, y, 128, 16, colorFg)
338
if ($theOptions.pieceGeneration == Options::GEN_BAG)
339
colorFg = colorHighlight
341
colorFg = colorNormal
343
drawMenuText("BAG", iCol2, y, 128, 16, colorFg)
345
if ($theOptions.pieceGeneration == Options::GEN_RANDOM)
346
colorFg = colorHighlight
348
colorFg = colorNormal
350
drawMenuText("RANDOM", iCol2 + 128, y, 128, 16, colorFg)
357
if ($selected_option == 5)
358
colorFg = colorHighlight
360
colorFg = colorNormal
364
drawMenuText("Color Scheme", iCol1, y, 128, 16, colorFg)
366
iColorSchemeChoice = 0
367
if ($theOptions.colorScheme == iColorSchemeChoice)
368
colorFg = colorHighlight
370
colorFg = colorNormal
372
drawMenuText("#{iColorSchemeChoice}", iCol2 + (iColorSchemeChoice * 32), y, 32, 16, colorFg)
375
iColorSchemeChoice = 1
376
if ($theOptions.colorScheme == iColorSchemeChoice)
377
colorFg = colorHighlight
379
colorFg = colorNormal
381
drawMenuText("#{iColorSchemeChoice}", iCol2 + (iColorSchemeChoice * 32), y, 32, 16, colorFg)
384
iColorSchemeChoice = 2
385
if ($theOptions.colorScheme == iColorSchemeChoice)
386
colorFg = colorHighlight
388
colorFg = colorNormal
390
drawMenuText("#{iColorSchemeChoice}", iCol2 + (iColorSchemeChoice * 32), y, 32, 16, colorFg)
393
iColorSchemeChoice = 3
394
if ($theOptions.colorScheme == iColorSchemeChoice)
395
colorFg = colorHighlight
397
colorFg = colorNormal
399
drawMenuText("#{iColorSchemeChoice}", iCol2 + (iColorSchemeChoice * 32), y, 32, 16, colorFg)
402
iColorSchemeChoice = 4
403
if ($theOptions.colorScheme == iColorSchemeChoice)
404
colorFg = colorHighlight
406
colorFg = colorNormal
408
drawMenuText("#{iColorSchemeChoice}", iCol2 + (iColorSchemeChoice * 32), y, 32, 16, colorFg)
411
iColorSchemeChoice = 5
412
if ($theOptions.colorScheme == iColorSchemeChoice)
413
colorFg = colorHighlight
415
colorFg = colorNormal
417
drawMenuText("#{iColorSchemeChoice}", iCol2 + (iColorSchemeChoice * 32), y, 32, 16, colorFg)
420
iColorSchemeChoice = 6
421
if ($theOptions.colorScheme == iColorSchemeChoice)
422
colorFg = colorHighlight
424
colorFg = colorNormal
426
drawMenuText("#{iColorSchemeChoice}", iCol2 + (iColorSchemeChoice * 32), y, 32, 16, colorFg)
429
### PIECE PREVIEW ###
432
if ($selected_option == 6)
433
colorFg = colorHighlight
435
colorFg = colorNormal
439
drawMenuText("iPiecePreview", iCol1, y, 128, 16, colorFg)
441
iPiecePreviewChoice = 0
442
if ($theOptions.piecePreviewCount == iPiecePreviewChoice)
443
colorFg = colorHighlight
445
colorFg = colorNormal
447
drawMenuText("OFF", iCol2 + (iPiecePreviewChoice * 32), y, 32, 16, colorFg)
450
iPiecePreviewChoice = 1
451
if ($theOptions.piecePreviewCount == iPiecePreviewChoice)
452
colorFg = colorHighlight
454
colorFg = colorNormal
456
drawMenuText("#{iPiecePreviewChoice}", iCol2 + (iPiecePreviewChoice * 32) + 64, y, 32, 16, colorFg)
459
iPiecePreviewChoice = 2
460
if ($theOptions.piecePreviewCount == iPiecePreviewChoice)
461
colorFg = colorHighlight
463
colorFg = colorNormal
465
drawMenuText("#{iPiecePreviewChoice}", iCol2 + (iPiecePreviewChoice * 32) + 64, y, 32, 16, colorFg)
468
iPiecePreviewChoice = 3
469
if ($theOptions.piecePreviewCount == iPiecePreviewChoice)
470
colorFg = colorHighlight
472
colorFg = colorNormal
474
drawMenuText("#{iPiecePreviewChoice}", iCol2 + (iPiecePreviewChoice * 32) + 64, y, 32, 16, colorFg)
477
iPiecePreviewChoice = 4
478
if ($theOptions.piecePreviewCount == iPiecePreviewChoice)
479
colorFg = colorHighlight
481
colorFg = colorNormal
483
drawMenuText("#{iPiecePreviewChoice}", iCol2 + (iPiecePreviewChoice * 32) + 64, y, 32, 16, colorFg)
486
iPiecePreviewChoice = 5
487
if ($theOptions.piecePreviewCount == iPiecePreviewChoice)
488
colorFg = colorHighlight
490
colorFg = colorNormal
492
drawMenuText("#{iPiecePreviewChoice}", iCol2 + (iPiecePreviewChoice * 32) + 64, y, 32, 16, colorFg)
502
if ($selected_option == 7)
503
colorFg = colorHighlight
505
colorFg = colorNormal
509
drawMenuText("Back to Menu", iCol1, y, 128, 16, colorFg)
516
def drawRectangle(x1, y1, x2, y2, z, r, g, b)