-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainRoom.cs
755 lines (626 loc) · 30.8 KB
/
MainRoom.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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
//Graphical stuff
using OpenTK;
//Engine calls
using OlegEngine;
using OlegEngine.Entity;
using OlegEngine.GUI;
using WheelOfSteamGames.Entity;
namespace WheelOfSteamGames
{
class MainRoom
{
public static Mesh WorldMesh;
public static ent_spotlight spotlight;
public static ent_spinner Spinner;
public static bool Started = false;
public static bool Loaded = false;
public static bool IsLoadingData = false;
public static bool IsCreatingCache = false;
private static string CurrentGame = "No Game";
private static float StartupDelay = 0.0f;
private static GUI.PauseMenu Menu;
public delegate bool ReturnCriteria(SteamCommunity.Game game);
private static List<SteamCommunity.Game> AllGames = new List<SteamCommunity.Game>(); //Keep a list of ALL steam games handy. Do not edit this list
private static Material LoadingMat;
private static Text LoadingText;
private static Text LongLoadingText;
private static Text CurrentGameText;
private static act_announcer Actor;
private static Window usernameWindow;
public static void Initialize()
{
//Create the player
ent_camera cam = EntManager.Create<ent_camera>();
cam.Spawn();
cam.SetPos(new OpenTK.Vector2(0, 4));
//Set the player as the object that'll be controlling the view
View.SetLocalPlayer(cam);
SetUpScene();
Utilities.window.Keyboard.KeyDown += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyDown);
GUIManager.PostDrawHUD += new GUIManager.OnDrawHUD(GUIManager_PostDrawHUD);
SteamCommunity.OnLoadGame += new Action<SteamCommunity.Game>(SteamCommunity_OnLoadGame);
//On startup, ask for steam community username
CreateUserSelectDialogue();
}
public static Window CreateUserSelectDialogue()
{
if (usernameWindow) return usernameWindow;
usernameWindow = GUIManager.Create<Window>();
usernameWindow.SetTitle("Enter Username");
usernameWindow.Resizable = false;
usernameWindow.SetWidth(380);
usernameWindow.SetHeight(115);
usernameWindow.SetEnableCloseButton(false);
usernameWindow.SetPos(Utilities.window.Width / 2 - usernameWindow.Width / 2, Utilities.window.Height / 2 - usernameWindow.Height / 2);
usernameWindow.MinimumSize = new Vector2(289, 115);
usernameWindow.OnRemove += new Action<Panel>(usernameWindow_OnRemove);
#region Connection panel (For accessing an account over the internet)
//Create a panel that will hold all of the connect online related things
Panel connectPanel = GUIManager.Create<Panel>(usernameWindow);
connectPanel.DockPadding(2, 2, 2, 2);
connectPanel.Dock(Panel.DockStyle.FILL);
connectPanel.ShouldDraw = false;
connectPanel.Name = "panel_connect";
Label questionText = GUIManager.Create<Label>(connectPanel);
questionText.Autosize = true;
questionText.SetText("Please enter your community URL");
questionText.SetPos(15, 10);
/*
Label exampleText = GUIManager.Create<Label>(connectPanel);
exampleText.Autosize = true;
exampleText.SetText("http://steamcommunity.com/id/");
exampleText.SetPos(15, questionText.Position.Y + 15);
exampleText.SetColor(110, 110, 110);
Label exampleTextImportant = GUIManager.Create<Label>(connectPanel);
exampleTextImportant.Autosize = true;
exampleTextImportant.SetText("YOURNAMEHERE");
exampleTextImportant.SetPos(exampleText.Width + exampleText.Position.X, exampleText.Position.Y);
*/
TextInput input = GUIManager.Create<TextInput>(connectPanel);
input.SetAnchorStyle(Panel.Anchors.Left | Panel.Anchors.Top | Panel.Anchors.Right);
input.SetPos(new Vector2(20, questionText.Position.Y + 20));
input.SetWidth(connectPanel.Width - 40);
input.Name = "community_input";
Button localSaveBtn = GUIManager.Create<Button>(connectPanel);
localSaveBtn.SetText("Local Saves...");
localSaveBtn.SetWidth(120);
localSaveBtn.SetHeight(20);
localSaveBtn.SetPos(new Vector2(0, connectPanel.Height - (localSaveBtn.Height + 20)));
localSaveBtn.AlignRight(20);
localSaveBtn.SetAnchorStyle(Panel.Anchors.Bottom | Panel.Anchors.Right);
localSaveBtn.OnButtonPress += new Button.OnButtonPressDel(localSaveBtn_OnButtonPress);
Button acceptBtn = GUIManager.Create<Button>(connectPanel);
acceptBtn.SetText("Go");
acceptBtn.SetWidth(localSaveBtn.Position.X - 40);
acceptBtn.SetHeight(20);
acceptBtn.SetPos(new Vector2(20, localSaveBtn.Position.Y));
acceptBtn.AlignLeft(20);
acceptBtn.SetAnchorStyle(Panel.Anchors.Bottom | Panel.Anchors.Right | Panel.Anchors.Left);
acceptBtn.OnButtonPress += new Button.OnButtonPressDel(acceptBtn_OnButtonPress);
Label progressText = GUIManager.Create<Label>(connectPanel);
progressText.SetWidth(connectPanel.Width);
progressText.Below(input, 4);
progressText.SetAlignment(Label.TextAlign.TopCenter);
progressText.SetAnchorStyle(Panel.Anchors.Left | Panel.Anchors.Top | Panel.Anchors.Right);
progressText.SetColor(255, 0, 0);
progressText.Name = "progress_text";
usernameWindow.SetEnabled(true, true);
#endregion
#region Local Saves panel (For using pre-existing saves of games)
//Create a panel that will hold a list of local saves to load from
Panel savesPanel = GUIManager.Create<Panel>(usernameWindow);
savesPanel.DockPadding(2, 2, 2, 2);
savesPanel.Dock(Panel.DockStyle.FILL);
savesPanel.ShouldDraw = false;
savesPanel.ShouldDrawChildren = false;
savesPanel.SetEnabled(false);
savesPanel.Name = "panel_saves";
Label infoText = GUIManager.Create<Label>(savesPanel);
infoText.Autosize = true;
infoText.SetText("Select a pre-existing save from your saves folder");
infoText.SetPos(15, 10);
ListView savesList = GUIManager.Create<ListView>(savesPanel);
savesList.SetHeight(30);
savesList.SetWidth(savesPanel.Width - 40);
savesList.SetPos(20, 30);
savesList.SetAnchorStyle(Panel.Anchors.Left | Panel.Anchors.Bottom | Panel.Anchors.Top | Panel.Anchors.Right);
savesList.Name = "list_saves";
var saves = SteamCommunity.GetLocalSaves();
foreach (var Save in saves)
{
savesList.AddListItem(Save, Save.Value, Save.Key);
}
Button connectPanelBtn = GUIManager.Create<Button>(savesPanel);
connectPanelBtn.SetText("Connect to steam...");
connectPanelBtn.SetWidth(120);
connectPanelBtn.SetHeight(20);
connectPanelBtn.SetPos(new Vector2(0, savesPanel.Height - (localSaveBtn.Height + 20)));
connectPanelBtn.AlignRight(20);
connectPanelBtn.SetAnchorStyle(Panel.Anchors.Bottom | Panel.Anchors.Right);
connectPanelBtn.OnButtonPress += new Button.OnButtonPressDel(connectPanelBtn_OnButtonPress);
Button acceptSavesBtn = GUIManager.Create<Button>(savesPanel);
acceptSavesBtn.SetText("Go");
acceptSavesBtn.SetWidth(localSaveBtn.Position.X - 40);
acceptSavesBtn.SetHeight(20);
acceptSavesBtn.SetPos(new Vector2(20, localSaveBtn.Position.Y));
acceptSavesBtn.AlignLeft(20);
acceptSavesBtn.SetAnchorStyle(Panel.Anchors.Bottom | Panel.Anchors.Right | Panel.Anchors.Left);
acceptSavesBtn.OnButtonPress += new Button.OnButtonPressDel(acceptSavesBtn_OnButtonPress);
progressText = GUIManager.Create<Label>(savesPanel);
progressText.SetWidth(savesPanel.Width);
progressText.Below(input, 4);
progressText.SetAlignment(Label.TextAlign.TopCenter);
progressText.SetAnchorStyle(Panel.Anchors.Left | Panel.Anchors.Top | Panel.Anchors.Right);
progressText.SetColor(255, 0, 0);
progressText.Name = "progress_text";
savesPanel.SetEnabled(false, true);
#endregion
return usernameWindow;
}
static void usernameWindow_OnRemove(Panel obj)
{
usernameWindow.OnRemove -= new Action<Panel>(usernameWindow_OnRemove);
usernameWindow = null;
}
static void acceptSavesBtn_OnButtonPress(Panel sender)
{
if (IsLoadingData) return;
ListView listView = sender.Parent.GetChildByName("list_saves") as ListView;
if (!listView) { Utilities.Print("Could not get list view panel!"); return; }
ListViewItem item = listView.SelectedPanel;
if (!item) { Utilities.Print("Could not get list view item!"); return; }
var data = (KeyValuePair<string, string>)item.Userdata;
string communityname = data.Value;
string communityid = data.Key;
if (usernameWindow)
{
usernameWindow.Remove();
usernameWindow = null;
}
GenericLoadCommunityID(communityname, communityid);
}
private const float LoadingSize = 30f;
private const float LoadingOffset = 30f;
static void GUIManager_PostDrawHUD(EventArgs e)
{
if (LoadingMat == null) { LoadingMat = Resource.GetMaterial("gui/loading"); }
if (LoadingText == null) { LoadingText = new Text("game_large", "Loading data..."); LoadingText.SetScale(0.25f, 0.25f); }
if (LongLoadingText == null) { LongLoadingText = new Text("defaultTitle", "Loading/Caching game data from the internet. Please be patient, this only happens once." ); }
if (CurrentGameText == null) { CurrentGameText = new Text("title", ""); }
if (IsLoadingData)
{
Surface.SetDrawColor(255, 255, 255);
Surface.SetTexture(LoadingMat.GetCurrentTexture());
Surface.DrawRect(Utilities.window.Width - (LoadingSize + LoadingOffset), Utilities.window.Height - (LoadingSize + LoadingOffset), LoadingSize, LoadingSize);
LoadingText.SetPos(Utilities.window.Width - (LoadingText.GetTextLength() * LoadingText.ScaleW + LoadingSize + LoadingOffset + 10), Utilities.window.Height - (LoadingText.GetTextHeight() / 2 + LoadingSize / 2 + LoadingOffset));
LoadingText.Draw();
if (IsCreatingCache)
{
LongLoadingText.SetPos(Utilities.window.Width/2 - (LongLoadingText.GetTextLength() / 2), Utilities.window.Height/2 - (LongLoadingText.GetTextHeight() / 2));
LongLoadingText.Draw();
CurrentGameText.SetPos(LongLoadingText.X, LongLoadingText.Y + LongLoadingText.GetTextHeight() + 2);
CurrentGameText.SetText(CurrentGame);
CurrentGameText.Draw();
}
}
}
//If we're loading some data from the ~internet~ inform the user while they wait
static void SteamCommunity_OnLoadGame(SteamCommunity.Game obj)
{
CurrentGame = obj.Name;
}
delegate bool loadIsValidDel(string name, out string failReason, out bool outOfDate);
static void acceptBtn_OnButtonPress(Panel sender)
{
if (IsLoadingData) return;
string username = "";
TextInput input = sender.Parent.GetChildByName("community_input") as TextInput;
if (input)
{
username = input.TextLabel.Text;
}
IsLoadingData = true;
loadIsValidDel loadFunc = new loadIsValidDel(SteamCommunity.IsValidName);
string FailReason = "Username is blank!";
bool OutOfDate = true;
IAsyncResult item = loadFunc.BeginInvoke(username, out FailReason, out OutOfDate, null, sender);
TaskManager.AddTask(item, (IAsyncResult res) =>
{
IsLoadingData = false;
if (loadFunc.EndInvoke(out FailReason, out OutOfDate, res) && !string.IsNullOrEmpty(username))
{
if (usernameWindow)
{
usernameWindow.Remove();
usernameWindow = null;
}
//If the local cache is out of date, pop open a dialogue asking if they'd like to update
if (OutOfDate && SteamCommunity.GetSaveExists(SteamCommunity.CommunityID))
{
ShowShouldUpdateCacheDialogue();
}
else BeginLoadData(SteamCommunity.CommunityID);
}
else
{
Console.WriteLine("Failed to retrieve profile. {0}", FailReason);
Label progressText = sender.Parent.GetChildByName("progress_text") as Label;
if (progressText)
{
progressText.SetText(FailReason);
}
}
});
}
static void connectPanelBtn_OnButtonPress(Panel sender)
{
Utilities.Print("Setting to connect tab", Utilities.PrintCode.INFO);
Panel savesPanel = sender.Parent;
Panel connectPanel = sender.Parent.Parent.GetChildByName("panel_connect");
if (!connectPanel) { Utilities.Print("Saves panel not found!", Utilities.PrintCode.WARNING); return; }
//Disable the saves panel
savesPanel.SetEnabled(false, true);
savesPanel.ShouldDrawChildren = false;
//Enable the connect panel
connectPanel.SetEnabled(true, true);
connectPanel.ShouldDrawChildren = true;
connectPanel.Parent.SetHeight(115);
}
static void localSaveBtn_OnButtonPress(Panel sender)
{
Utilities.Print("Setting to saves tab", Utilities.PrintCode.INFO);
Panel connectPanel = sender.Parent;
Panel savesPanel = sender.Parent.Parent.GetChildByName("panel_saves");
if (!savesPanel) { Utilities.Print("Saves panel not found!", Utilities.PrintCode.WARNING); return; }
//Enable the saves panel
savesPanel.Parent.SetHeight(145);
savesPanel.SetEnabled(true, true);
savesPanel.ShouldDrawChildren = true;
//Disable the connect panel
connectPanel.SetEnabled(false, true);
connectPanel.ShouldDrawChildren = false;
}
public static void GenericLoadCommunityID(string CommunityName, string CommunityID)
{
IsLoadingData = true;
loadIsValidDel loadFunc = new loadIsValidDel(SteamCommunity.IsValidCommunityID);
string FailReason = "Username is blank!";
bool OutOfDate = true;
IAsyncResult item = loadFunc.BeginInvoke(CommunityID, out FailReason, out OutOfDate, null, null);
TaskManager.AddTask(item, (IAsyncResult res) =>
{
IsLoadingData = false;
if (loadFunc.EndInvoke(out FailReason, out OutOfDate, res) && !string.IsNullOrEmpty(CommunityID))
{
if (usernameWindow)
{
usernameWindow.Remove();
usernameWindow = null;
}
//If the local cache is out of date, pop open a dialogue asking if they'd like to update
if (OutOfDate && SteamCommunity.GetSaveExists(SteamCommunity.CommunityID))
{
ShowShouldUpdateCacheDialogue();
}
else BeginLoadData(SteamCommunity.CommunityID);
}
else
{
Utilities.Print("Failed to load profile information. {0}", Utilities.PrintCode.WARNING, FailReason);
//Try loading the data directly from a save anyway
BeginLoadData(CommunityID);
}
});
}
delegate List<SteamCommunity.Game> LoadSteamDataDel( string communityID, bool refresh=false );
public static void BeginLoadData( string CommunityID, bool RefreshCache = false )
{
if (string.IsNullOrEmpty(CommunityID))
{
Utilities.Print("Error loading data! Community ID is null. Something is wrong, tell foohy.", Utilities.PrintCode.ERROR);
return;
}
IsCreatingCache = RefreshCache ? RefreshCache : !SteamCommunity.GetLoadFromCache(CommunityID);
Menu.HideToLeft();
IsLoadingData = true;
LoadSteamDataDel loadFunc = new LoadSteamDataDel(SteamCommunity.GetGames);
IAsyncResult item = loadFunc.BeginInvoke(CommunityID, IsCreatingCache, null, null);
TaskManager.AddTask(item, (IAsyncResult res) =>
{
var Games = loadFunc.EndInvoke(res);
IsLoadingData = false;
EndSteamDataLoad(Games);
} );
}
public static void ShowShouldUpdateCacheDialogue()
{
Window window = GUIManager.Create<Window>();
window.SetTitle("Cache out of date");
window.Resizable = false;
window.SetWidth(380);
window.SetHeight(115);
window.SetEnableCloseButton(false);
window.SetPos(Utilities.window.Width / 2 - window.Width / 2, Utilities.window.Height / 2 - window.Height / 2);
window.MinimumSize = new Vector2(289, 115);
Label questionText = GUIManager.Create<Label>(window);
questionText.Autosize = true;
questionText.SetText("Local cache is out of date. Would you like to update it?");
questionText.SetPos(15, 10);
Button noBtn = GUIManager.Create<Button>(window);
noBtn.SetText("No");
noBtn.SetWidth(120);
noBtn.SetHeight(20);
noBtn.SetPos(new Vector2(0, window.Height - (noBtn.Height + 20)));
noBtn.AlignRight(20);
noBtn.SetAnchorStyle(Panel.Anchors.Bottom | Panel.Anchors.Right);
noBtn.OnButtonPress += (Panel sender) =>
{
if (IsLoadingData) return;
BeginLoadData(SteamCommunity.CommunityID, false);
window.Remove();
};
Button yesBtn = GUIManager.Create<Button>(window);
yesBtn.SetText("Yes");
yesBtn.SetWidth(noBtn.Position.X - 40);
yesBtn.SetHeight(20);
yesBtn.SetPos(new Vector2(20, noBtn.Position.Y));
yesBtn.AlignLeft(20);
yesBtn.SetAnchorStyle(Panel.Anchors.Bottom | Panel.Anchors.Right | Panel.Anchors.Left);
yesBtn.OnButtonPress += (Panel sender) =>
{
if (IsLoadingData) return;
BeginLoadData(SteamCommunity.CommunityID, true);
window.Remove();
};
}
public static void EndSteamDataLoad(List<SteamCommunity.Game> Games)
{
AllGames = Games;
CurrentGame = "No Game";
Console.WriteLine("GOT SOME GAMES FOR YA: {0}", AllGames != null ? AllGames.Count.ToString() : "NULL");
//Create the spinner elements
var FilteredGames = GetFilteredGamesList();
Spinner.CreateElements(FilteredGames);
//If we're just starting up, tell the lights to turn on
StartupDelay = (float)Utilities.Time + 1.5f;
Loaded = true;
}
static void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs e)
{
if (Loaded && !IsLoadingData)
{
if (!Spinner.IsSpinning)
{
//If we press space, let's spin da wheel
if (e.Key == OpenTK.Input.Key.Space)
{
if (Spinner.Games.Count > 0)
{
Spinner.Spin(0.095f);
}
else
{
Actor.SayLine("Woah there tiger, you don't have any games on the board!");
}
HintManager.RemoveHintNice("spin_controls_hint");
}
//If we press enter, start the currently selected game
if (e.Key == OpenTK.Input.Key.Enter || e.Key == OpenTK.Input.Key.KeypadEnter)
{
var Game = Spinner.GetCurrentGame();
if (Game == null || Game.AppID < 1) return;
System.Diagnostics.ProcessStartInfo start = new System.Diagnostics.ProcessStartInfo(string.Format("steam://run/{0}", Game.AppID ) );
System.Diagnostics.Process.Start(start);
//Have fun!
Utilities.window.Exit();
}
//Make the a-meow-nncer say the next/previous line of a stack of lines about a nerd game.
if (e.Key == OpenTK.Input.Key.Left || e.Key == OpenTK.Input.Key.A)
Actor.SayPreviousPage();
else if (e.Key == OpenTK.Input.Key.Right || e.Key == OpenTK.Input.Key.D)
Actor.SayNextPage();
}
if (e.Key == OpenTK.Input.Key.F1)
{
Steam.App[] apps = Steam.RefreshGames();
if (apps != null && apps.Length > 0)
{
foreach (Steam.App app in apps)
{
Console.WriteLine(app.Name);
}
}
else Console.WriteLine("Failed to get steam game list!");
}
if (e.Key == OpenTK.Input.Key.Escape)
{
if (Menu.IsShown)
{
Menu.HideToLeft();
}
else
{
Menu.ShowToLeft();
}
}
}
}
private static void SetUpScene()
{
//Load the world
WorldMesh = Resource.GetMesh("stage.obj");
WorldMesh.mat = Resource.GetMaterial("models/stage");
//Turn on the lights
DirectionalLight light = new DirectionalLight();
light.AmbientIntensity = 0.4f;
light.DiffuseIntensity = 0.9f;
light.Color = new Vector3(0.845f, 0.745f, 0.745f); //new Vector3(0.745f, 0.820f, 0.847f);
light.Direction = new Vector3(0.0f, -1.0f, -1.0f);
light.Direction.Normalize();
LightingTechnique.SetEnvironmentLight(light);
LightingTechnique.EnableEnvironmentLight(false);
ent_pointlight pointlight = EntManager.Create<ent_pointlight>();
pointlight.Spawn();
pointlight.AmbientIntensity = 0.4f;
pointlight.DiffuseIntensity = 20.0f; //0.85f
pointlight.Color = new Vector3(1.0f, 0.5f, 0.00f);
pointlight.Linear = 2.7f;
pointlight.Enabled = false;
spotlight = EntManager.Create<ent_spotlight>();
spotlight.Spawn();
spotlight.Color = new Vector3(1.0f, 1.0f, 1.0f);
spotlight.Constant = 1.0f;
spotlight.Cutoff = 20.0f;
spotlight.SetAngle( new Angle(-42.2f, -110.9349f, 0) );
spotlight.SetPos(new Vector3(7.56424f, 22.80356f, 33.25445f));
spotlight.Enabled = false;
Audio.Precache("Resources/Audio/light_on.mp3");
Spinner = EntManager.Create<ent_spinner>();
Spinner.Spawn();
Spinner.SetAngle(new Angle( 0, -90, 0 ));
Spinner.SetPos(new Vector3(-2.8f, -(float)Spinner.Model.BBox.Negative.Y, 18));
Spinner.OnSpinnerStop += new Action<SteamCommunity.Game>(Spinner_OnSpinnerStop);
Spinner.OnSpin += new Action<bool>(Spinner_OnSpin);
Spinner.OnWheelGrab += new Action(Spinner_OnWheelGrab);
Spinner.Enabled = false;
View.Player.SetPos(new Vector3(0.807714f, 10.01533f, 50.94458f));
View.Player.SetAngle(new Angle(-3.26675f, -90.13329f, 0));
//View.Player.SetPos(new Vector3(-13.50925f, 5.614059f, 2.610255f));
//View.Player.SetAngle(new Angle(0, 0, 0));
//Notable camera positions
//Pos: -13.50925f, 5.614059f, 2.610255
//Ang: 0.9982005f, -0.03713433f, 0.05996396f
//Spawn the meow meow
Actor = EntManager.Create<act_announcer>();
Actor.Spawn();
Actor.SetAnimation("announcer_idle_player");
Actor.SetAngle(new Angle( 0, 0, 0));
Actor.Scale = new Vector3(10, 10, 10);
Actor.SetPos(new Vector3(Spinner.Position.X + 8, -0.6f, Spinner.Position.Z));
Actor.ShouldDraw = false;
//Create some hint text
HintManager.Initialize();
//Create a panel holding filter options
Menu = GUIManager.Create<GUI.PauseMenu>();
Menu.SetWidth(220);
Menu.SetHeight(400);
Menu.SetPos(-Menu.Width - 200, Menu.Position.Y);
Menu.SetTitle("Filters");
Menu.AddCheckBox("Show Singleplayer Games", "game_single");
Menu.AddCheckBox("Show Multiplayer Games", "game_multi");
Menu.AddCheckBox("Show Games with VAC", "game_vac");
//Menu.AddCheckBox("Show Favorites only", "game_favorites");
Menu.AddCheckBox("Show Games with HDR", "game_hdr");
Menu.AddCheckBox("Show Recently played games", "game_2weeks");
Menu.AddCheckBox("Show Games never played", "game_never");
Menu.AddCheckBox("Show Games with trading cards", "game_tradecards");
Menu.AddCheckBox("Show Games with custom text", "game_meow_text");
Menu.HideToLeft();
Menu.OnAcceptPress += new Action(Menu_OnAcceptPress);
}
/// <summary>
/// Event for when the spinner stops, so we can retrieve its information and DO STUFF
/// </summary>
/// <param name="obj">The chosen game</param>
static void Spinner_OnSpinnerStop(SteamCommunity.Game game)
{
Actor.SetTransitionAnimation("announcer_wheel_to_player", "announcer_idle_player");
if (game != null)
{
Actor.SayLine(game.AppID);
HintManager.AddHint("Press enter to start game!", 0, 4, "hint_startgame");
Console.WriteLine(string.Format("Landed on \"{0}\" ({1})", game.Name, game.AppID));
}
}
static void Spinner_OnWheelGrab()
{
Actor.SetTransitionAnimation("announcer_player_to_wheel", "announcer_idle_wheel");
}
static void Spinner_OnSpin( bool WasMouseSpin )
{
if (!WasMouseSpin)
Actor.SetTransitionAnimation("announcer_player_to_wheel", "announcer_idle_wheel");
Actor.FadeLine();
HintManager.RemoveHintNice("hint_startgame");
}
static List<SteamCommunity.Game> GetFilteredGames(ReturnCriteria rc)
{
List<SteamCommunity.Game> FilteredGames = new List<SteamCommunity.Game>();
foreach (SteamCommunity.Game game in AllGames)
{
//if (!Steam.IsAppSubscribed( (uint)game.AppID ))
// continue;
if (!rc(game))
continue;
FilteredGames.Add(game);
}
return FilteredGames;
}
public static List<SteamCommunity.Game> GetFilteredGamesList()
{
//Save settings?
List<SteamCommunity.Game> FilteredGames = GetFilteredGames((game) =>
{
if (Menu.GetCheckboxChecked("game_single") && !game.IsSingleplayer)
return false;
if (Menu.GetCheckboxChecked("game_multi") && !game.IsMultiplayer)
return false;
if (Menu.GetCheckboxChecked("game_vac") && !game.HasVAC)
return false;
if (Menu.GetCheckboxChecked("game_hdr") && !game.HasHDR)
return false;
if (Menu.GetCheckboxChecked("game_tradecards") && !game.HasTradingCards)
return false;
if (Menu.GetCheckboxChecked("game_2weeks") && game.HoursLast2Weeks <= 0)
return false;
if (Menu.GetCheckboxChecked("game_never") && game.HoursOnRecord > 0)
return false;
if( Menu.GetCheckboxChecked("game_meow_text") && !Actor.HasDialogue( game.AppID ) )
return false;
return true;
});
return FilteredGames;
}
static void Menu_OnAcceptPress()
{
Menu.HideToLeft();
var FilteredGames = GetFilteredGamesList();
Spinner.CreateElements(FilteredGames);
}
public static void Think()
{
TaskManager.PollTasks();
if (spotlight != null && Utilities.window.Keyboard[OpenTK.Input.Key.Q])
{
Console.WriteLine(View.Player.Position);
Console.WriteLine(View.Angles);
spotlight.SetAngle(View.Angles);
spotlight.SetPos(View.Player.Position);
}
if (Utilities.Time > StartupDelay && !Started && Loaded)
{
HintManager.AddHint("Press space to spin!", 2.0f, 5.0f, "spin_controls_hint");
Started = true;
spotlight.Enabled = true;
Spinner.Enabled = true;
Audio.PlaySound("Resources/Audio/light_on.mp3");
Actor.ShouldDraw = true;
LightingTechnique.EnableEnvironmentLight(true);
}
}
private static Vector3 worldpos = new Vector3(0, -1.35f, 0); //QUICK WORLD OFFSET
public static void Draw()
{
if (WorldMesh != null)
{
WorldMesh.Position = worldpos;
WorldMesh.Draw();
}
}
}
}