-
Notifications
You must be signed in to change notification settings - Fork 1
/
menu.cs
381 lines (324 loc) · 14.2 KB
/
menu.cs
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
/* SUPER SMASH BROS. BRAWL 3D MODEL VIEWER
* Programmers: Michael Yoon Huh (huhx0015), Steve Chou (azntofu2000/chou0069)
* Last Updated: 12/15/2011 */
// Menu GUI interface programming by chou0069. Modified by huhx0015.
namespace _3DPoringModel{
public class Menu : Microsoft.Xna.Framework.Game
{
//private static int MAX = 20;
//private static int MAXLEVEL = 2;
//Base menu
private List<worldobj> m_base;
//sub menus
private List<worldobj> m_lstItem1;
private List<worldobj> m_lstItem2;
private List<worldobj> m_lstItem3;
private List<worldobj> m_lstItem4;
private List<worldobj> m_lstItem5;
private Vector2 curpos;
private Rectangle[] m_rcSource, subSource;
//Textures for the menu items.
Texture2D menuicon;
Texture2D Sub1;
Texture2D Sub2;
Texture2D Sub3;
Texture2D Sub4;
Texture2D Sub5;
//Frame information for the texture.
Rectangle mainFrame;
worldobj obj1;
//scale for the items.
private Vector2 m_vScale;
//color items
MouseState mPreviousMouseState; // Previous mouse state.
Input menu = new Input(); // Input object for actions triggered by the menu.
// Publically accessible variables.
public bool bounceSwitch = false; // Used for enabling the bouncing option.
public string songString = " "; // Stores the string for the currently played song.
public bool songEnabled = false; // Used for displaying the song name onscreen.
public bool stageSwitch = false; // Used for switching stages.
// Song list array variables.
int songCount = 0;
int songCountMax = 9;
string[] songList = new string[9] { "Battlefield", "Battlefield_II", "Final_Destination", "Final_Destination_II", "Final_Destination_III", "Final_Destination_IV", "Menu_1", "Menu_2", "Menu_3" };
string[] songListName = new string[9] { "SONG: Battlefield [Super Smash Bros. Brawl]",
"SONG: Battlefield II [Super Smash Bros. Brawl]",
"SONG: Final Destination [Super Smash Bros. Brawl]",
"SONG: Final Destination II [Super Smash Bros. Brawl]",
"SONG: Final Destination (Another) [Super Smash Bros. Brawl]",
"SONG: Final Destination [Super Smash Bros. Melee]",
"SONG: Menu 1 [Super Smash Bros. Brawl]",
"SONG: Menu 1 [Super Smash Bros. Melee]",
"SONG: Menu 2 [Super Smash Bros. Brawl]"};
// Sound list array variables.
int soundCount = 0;
int soundCountMax = 6;
string[] soundList = new string[6] { "MarioSFX", "DonkeyKongSFX", "KirbySFX", "NessSFX", "PeachSFX", "FoxSFX" };
public Menu()
{
m_base = new List<worldobj>();
}
//initializer
public void init()
{
m_base = new List<worldobj>();
m_lstItem1 = new List<worldobj>();
m_lstItem2 = new List<worldobj>();
m_lstItem3 = new List<worldobj>();
m_lstItem4 = new List<worldobj>();
m_lstItem5 = new List<worldobj>();
curpos = new Vector2(0, 0);
obj1 = new worldobj();
obj1.spritePosition = Vector2.Zero;
}
public Rectangle[] Source
{
get { return m_rcSource; }
set { m_rcSource = value; }
}
public Rectangle[] Submenu
{
get { return subSource; }
set { subSource = value; }
}
public Rectangle Frame
{
get { return mainFrame; }
set { mainFrame = value; }
}
//add an item to the index
public void Add(worldobj item)
{
m_base.Add(item);
}
public void AddSub1(worldobj item)
{
m_lstItem1.Add(item);
}
public void AddSub2(worldobj item)
{
m_lstItem2.Add(item);
}
public void AddSub3(worldobj item)
{
m_lstItem3.Add(item);
}
public void AddSub4(worldobj item)
{
m_lstItem4.Add(item);
}
public void AddSub5(worldobj item)
{
m_lstItem5.Add(item);
}
public void checkTint(MouseState aMouse)
{
for (int i = 0; i < m_base.Count; i++)
{
m_base[i].tint.R = 255;
m_base[i].tint.G = 255;
m_base[i].tint.B = 255;
m_base[i].tint.A = 255;
//mouse position > menu base sprite's left x, x + width, and Y + height.
if ((aMouse.X > m_base[i].spritePosition.X) &&
(aMouse.X < m_base[i].spritePosition.X + m_base[i].width) &&
(aMouse.Y < m_base[i].spritePosition.Y + m_base[i].height)
)
{
m_base[i].tint.R = 255;
m_base[i].tint.G = 55;
m_base[i].tint.B = 155;
m_base[i].tint.A = 255;
// If a user presses one of the menu buttons...
if (aMouse.LeftButton == ButtonState.Pressed && mPreviousMouseState.LeftButton == ButtonState.Released)
{
switch(i){
case 0:
// Action for Button 1 (Controls). Enables and disables the characters' bouncing motion.
menu.soundEffects("Menu"); // Outputs the menu select sound when button is pressed.
// Enable character bouncing.
if (bounceSwitch == false)
{
bounceSwitch = true;
}
// Disable character bouncing.
else if (bounceSwitch == true)
{
bounceSwitch = false;
}
break;
case 1:
// Action for Button 2 (Deflicker). Changes the stage and background.
menu.soundEffects("Menu"); // Outputs the menu select sound when button is pressed.
// If the current stage is Stadium (default stage), switch to Final Destination.
if (stageSwitch == false)
{
stageSwitch = true;
}
// If the current stage is Final Destination, switch to Stadium.
else if (stageSwitch == true)
{
stageSwitch = false;
}
break;
case 2:
// Action for Button 3 (Sound).
menu.soundEffects("Menu"); // Outputs the menu select sound when button is pressed.
for (int j = 0; j < m_lstItem3.Count; j++)
{
if (m_lstItem3[j].show)
{
m_lstItem3[j].show = false;
}
else
{
m_lstItem3[j].show = true;
}
m_lstItem2[j].show = false;
m_lstItem1[j].show = false;
m_lstItem4[j].show = false;
m_lstItem5[j].show = false;
}
break;
case 3:
// Action for Button 4 (My Music). Changes the song being played.
menu.soundEffects("Menu"); // Outputs the menu select sound when button is pressed.
// If songCount is greater than songCountMax, reset the count to 0.
if (songCount >= songCountMax)
{
songCount = 0;
}
menu.musicPlay(songList[songCount]);
songString = songListName[songCount]; // Play the specified music file in the songList.
songEnabled = true;
songCount++;
break;
case 4:
// Action for Button 5 (My Music). Outputs a narrator sound effect.
menu.soundEffects("Menu"); // Outputs the menu select sound when button is pressed.
// If soundCount is greater than soundCountMax, reset the count to 0.
if (soundCount >= soundCountMax)
{
soundCount = 0;
}
menu.soundEffects(soundList[soundCount]);
soundCount++;
break;
}
}
}
}
mPreviousMouseState = aMouse; // Store the previous mouse state
}
public Texture2D Texture
{
get { return menuicon; }
set { menuicon = value; }
}
public Texture2D setSub1
{
get { return Sub1; }
set { Sub1 = value; }
}
public Texture2D setSub2
{
get { return setSub2; }
set { Sub2 = value; }
}
public Texture2D setSub3
{
get { return Sub3; }
set { Sub3 = value; }
}
public Texture2D setSub4
{
get { return Sub4; }
set { Sub4 = value; }
}
public Texture2D setSub5
{
get { return Sub5; }
set { Sub5 = value; }
}
//remove the item from the menu
public void RemoveAt(int index)
{
m_base.RemoveAt(index);
}
//public void setgraphic(Texture2D newtexture)
//{
//m_circleTex = newtexture;
//}
public void draw(GameTime gameTime, SpriteBatch spritebatch)
{
for (int i = 0; i < m_base.Count; i++)
{
//draw the object if its enabled
if (m_base[i].show)
{
spritebatch.Draw(menuicon, new Vector2(m_base[i].spritePosition.X, m_base[i].spritePosition.Y),
m_rcSource[i], m_base[i].tint); // Draws the background.
}
}
//submenu checkers
for (int i = 0; i < m_lstItem1.Count; i++)
{
//draw the object if its enabled
if (m_lstItem1[i].show)
{
m_vScale = new Vector2(0.5f);
spritebatch.Draw(Sub1, new Vector2(m_lstItem1[i].spritePosition.X, m_lstItem1[i].spritePosition.Y),
subSource[i], m_lstItem1[i].tint, 0f, Vector2.Zero, m_vScale, SpriteEffects.None, 0f); // Draws the background.
}
if (m_lstItem2[i].show)
{
spritebatch.Draw(Sub1, new Vector2(m_lstItem2[i].spritePosition.X, m_lstItem2[i].spritePosition.Y),
subSource[i], m_lstItem2[i].tint); // Draws the background.
}
if (m_lstItem3[i].show)
{
spritebatch.Draw(Sub1, new Vector2(m_lstItem3[i].spritePosition.X, m_lstItem3[i].spritePosition.Y),
subSource[i], m_lstItem3[i].tint); // Draws the background.
}
if (m_lstItem4[i].show)
{
spritebatch.Draw(Sub1, new Vector2(m_lstItem4[i].spritePosition.X, m_lstItem4[i].spritePosition.Y),
subSource[i], m_lstItem4[i].tint); // Draws the background.
}
if (m_lstItem5[i].show)
{
spritebatch.Draw(Sub1, new Vector2(m_lstItem5[i].spritePosition.X, m_lstItem5[i].spritePosition.Y),
subSource[i], m_lstItem5[i].tint); // Draws the background.
}
}
//checking to see if we have a drag and drop event?
}
//pass in the mouse position and the list we're checking
public void DragThis(MouseState aMouse, List<worldobj> dragList)
{
//go through the list
for (int i = 0; i < dragList.Count; i++)
{
//check if the position is right.
if ((aMouse.X > dragList[i].spritePosition.X) &&
(aMouse.X < dragList[i].spritePosition.X + dragList[i].width) &&
(aMouse.Y < dragList[i].spritePosition.Y + dragList[i].height))
{
//draw an additional texture thing here.
}
//if not here then i guess we don't drag
}
}
}
}