Skip to content

Commit a6f5e60

Browse files
committed
Added Credits and click / hover sounds to main menu.
1 parent 0dbb2f2 commit a6f5e60

15 files changed

+220
-29
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,11 @@ ModelManifest.xml
240240

241241
# FAKE - F# Make
242242
.fake/
243+
244+
# Content files
245+
*.png
246+
*.exe
247+
*.wav
248+
*.ogg
249+
*.psd
250+
*.stp

src/Game/GameLogic/Game Logic.csproj

+19-1
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@
101101
<Compile Include="items\BatteryB.cs" />
102102
<Compile Include="items\BatteryA.cs" />
103103
<Compile Include="items\SawKit.cs" />
104+
<Compile Include="menu\MenuButton.cs" />
104105
<Compile Include="menu\ExitConfirmation.cs" />
105106
<Compile Include="menu\MenuItems.cs" />
106107
<Compile Include="menu\SaveLoadGame.cs" />
108+
<Compile Include="menu\CreditsWindow.cs" />
107109
<Compile Include="menu\SettingsWindow.cs" />
108110
<Compile Include="Properties\Basement.Resources.Designer.cs">
109111
<AutoGen>True</AutoGen>
@@ -196,6 +198,7 @@
196198
<Compile Include="rooms\basement\RFIDAntennaCabinet.cs" />
197199
<Compile Include="rooms\jailcell\Foreground.cs" />
198200
<Compile Include="rooms\jailcell\Scene.cs" />
201+
<Compile Include="rooms\office\RyanState.cs" />
199202
<Compile Include="rooms\office\RyanEyes.cs" />
200203
<Compile Include="rooms\paddedcell\Scene.cs" />
201204
<Compile Include="rooms\sunset\Scene.cs" />
@@ -410,7 +413,22 @@
410413
<LastGenOutput>Resources_Session_2.Designer.cs</LastGenOutput>
411414
</EmbeddedResource>
412415
</ItemGroup>
413-
<ItemGroup />
416+
<ItemGroup>
417+
<Folder Include="content\audio\" />
418+
<Folder Include="content\characters\mouse\" />
419+
<Folder Include="content\characters\ryan\" />
420+
<Folder Include="content\fonts\" />
421+
<Folder Include="content\inventory\" />
422+
<Folder Include="content\rooms\basement\" />
423+
<Folder Include="content\rooms\jailcell\" />
424+
<Folder Include="content\rooms\letter\" />
425+
<Folder Include="content\rooms\office\anim\day\" />
426+
<Folder Include="content\rooms\office\anim\night\" />
427+
<Folder Include="content\rooms\paddedcell\" />
428+
<Folder Include="content\rooms\sunset\" />
429+
<Folder Include="content\rooms\title\" />
430+
<Folder Include="content\ui\" />
431+
</ItemGroup>
414432
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
415433
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
416434
Other similar extension points exist, see Microsoft.Common.targets.

src/Game/GameLogic/SessionSeven.cs

+8
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ protected override void OnStart()
132132
MainMenu = new Menu(Engine);
133133
}
134134

135+
public override void OnExit()
136+
{
137+
if (null != MainMenu)
138+
{
139+
MainMenu.Dispose();
140+
}
141+
}
142+
135143
protected override void OnWorldInitialized(bool restore)
136144
{
137145
if (restore)

src/Game/GameLogic/content/build.bat

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
REM ------------------------------------------------------------------------------
33
REM <auto-generated>
4-
REM This code was generated by a tool on 11.05.2018 18:14:00.
4+
REM This code was generated by a tool on 25.05.2018 11:40:42.
55
REM
66
REM Changes to this file may cause incorrect behavior and will be lost if
77
REM the code is regenerated.
@@ -45,6 +45,8 @@ ContentCompiler.exe audio\hammer_wood.wav bin\audio\hammer_wood WavImporter Soun
4545
ContentCompiler.exe audio\light_off.wav bin\audio\light_off WavImporter SoundEffectProcessor true
4646
ContentCompiler.exe audio\light_on.wav bin\audio\light_on WavImporter SoundEffectProcessor true
4747
ContentCompiler.exe audio\lock_pick.wav bin\audio\lock_pick WavImporter SoundEffectProcessor true
48+
ContentCompiler.exe audio\menu_click.wav bin\audio\menu_click WavImporter SoundEffectProcessor true
49+
ContentCompiler.exe audio\menu_focus.wav bin\audio\menu_focus WavImporter SoundEffectProcessor true
4850
ContentCompiler.exe audio\mouse_eat.wav bin\audio\mouse_eat WavImporter SoundEffectProcessor true
4951
ContentCompiler.exe audio\open_panel.wav bin\audio\open_panel WavImporter SoundEffectProcessor true
5052
ContentCompiler.exe audio\rustling1.wav bin\audio\rustling1 WavImporter SoundEffectProcessor true

src/Game/GameLogic/content/tree.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
// ------------------------------------------------------------------------------
33
// <auto-generated>
4-
// This code was generated by a tool on 11.05.2018 18:14:02.
4+
// This code was generated by a tool on 25.05.2018 11:40:44.
55
//
66
// Changes to this file may cause incorrect behavior and will be lost if
77
// the code is regenerated.
@@ -52,6 +52,8 @@ public static partial class audio
5252
public const string light_off = "audio\\light_off";
5353
public const string light_on = "audio\\light_on";
5454
public const string lock_pick = "audio\\lock_pick";
55+
public const string menu_click = "audio\\menu_click";
56+
public const string menu_focus = "audio\\menu_focus";
5557
public const string mouse_eat = "audio\\mouse_eat";
5658
public const string open_panel = "audio\\open_panel";
5759
public const string rustling1 = "audio\\rustling1";
+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
using Microsoft.Xna.Framework;
2+
using System;
3+
using TomShane.Neoforce.Controls;
4+
using GlblRes = global::SessionSeven.Properties.Resources;
5+
6+
namespace SessionSeven
7+
{
8+
public partial class Menu
9+
{
10+
private Bevel CreditsWindow;
11+
12+
void AddCreditsWindow(Manager gui)
13+
{
14+
CreditsWindow = new Bevel(gui);
15+
CreditsWindow.Parent = MainMenuBackground;
16+
CreditsWindow.Height = MainMenuBackground.ClientHeight;
17+
CreditsWindow.Color = Color.Black;
18+
CreditsWindow.Style = BevelStyle.None;
19+
CreditsWindow.Visible = false;
20+
CreditsWindow.Top = 0;
21+
CreditsWindow.StayOnTop = true;
22+
CreditsWindow.Width = MainMenuBackground.ClientWidth;
23+
24+
int i = 0;
25+
26+
foreach (var CreditsText in Cutscenes.Director.GetCreditTexts())
27+
{
28+
var Top = 110 + i * 23 + (i > 3 ? 23 : 0);
29+
var Text = CreditsText.Split(new string[] { System.Environment.NewLine + System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
30+
if (Text.Length == 2)
31+
{
32+
var Label = new Label(gui);
33+
Label.Init();
34+
Label.Width = 250;
35+
Label.Alignment = Alignment.MiddleLeft;
36+
Label.TextColor = Color.Black;
37+
Label.Parent = CreditsWindow;
38+
Label.Text = Text[0];
39+
Label.Top = Top;
40+
Label.Left = MainMenuBackground.ClientWidth / 2 - Label.Width / 2;
41+
42+
Label = new Label(gui);
43+
Label.Init();
44+
Label.Width = 250;
45+
Label.Alignment = Alignment.MiddleRight;
46+
Label.TextColor = new Color(188, 22, 0, 255);
47+
Label.Parent = CreditsWindow;
48+
Label.Text = Text[1];
49+
Label.Top = Top;
50+
Label.Left = MainMenuBackground.ClientWidth / 2 - Label.Width / 2;
51+
}
52+
else
53+
{
54+
var Label = new Label(gui);
55+
Label.Init();
56+
Label.Width = 300;
57+
Label.Alignment = Alignment.MiddleCenter;
58+
Label.TextColor = Color.Black;
59+
Label.Parent = CreditsWindow;
60+
Label.Text = Text[0];
61+
Label.Top = Top;
62+
Label.Left = MainMenuBackground.ClientWidth / 2 - Label.Width / 2;
63+
}
64+
i++;
65+
}
66+
67+
var OKButton = new MenuButton(gui, ClickSound, FocusSound);
68+
OKButton.Init();
69+
OKButton.Parent = CreditsWindow;
70+
OKButton.Text = GlblRes.OK;
71+
OKButton.Click += (s, e) =>
72+
{
73+
CreditsWindow.Hide();
74+
ShowLogo(true);
75+
};
76+
77+
OKButton.Width = 120;
78+
OKButton.Height = 24;
79+
OKButton.Left = (MainMenuBackground.ClientWidth) - (OKButton.Width) - 6;
80+
OKButton.Top = MainMenuBackground.ClientHeight - OKButton.Height - 6 - (30 * 0);
81+
OKButton.Anchor = Anchors.Top;
82+
83+
gui.Add(CreditsWindow);
84+
}
85+
}
86+
}

src/Game/GameLogic/menu/ExitConfirmation.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void AddExitConfirmationWindow(Manager gui)
2323
ExitConfirmationWindow.Visible = false;
2424
ExitConfirmationWindow.CloseButtonVisible = false;
2525

26-
Bevel Bevel = new Bevel(gui);
26+
var Bevel = new Bevel(gui);
2727
Bevel.Parent = ExitConfirmationWindow;
2828
Bevel.Anchor = Anchors.Bottom | Anchors.Left | Anchors.Right;
2929
Bevel.Height = 35;
@@ -32,15 +32,15 @@ void AddExitConfirmationWindow(Manager gui)
3232
Bevel.Width = ExitConfirmationWindow.ClientWidth;
3333

3434

35-
Label Text = new Label(gui);
35+
var Text = new Label(gui);
3636
Text.Text = GlblRes.Do_you_really_want_to_quit_the_game;
3737
Text.Parent = ExitConfirmationWindow;
3838
Text.Top = 10;
3939
Text.Left = 10;
4040
Text.Width = ExitConfirmationWindow.ClientWidth - 20;
4141
Text.Height = 20;
4242

43-
Button Yes = new Button(gui);
43+
var Yes = new MenuButton(gui, ClickSound, FocusSound);
4444
Yes.Parent = Bevel;
4545
Yes.Width = 100;
4646
Yes.Text = GlblRes.Yes;
@@ -51,7 +51,8 @@ void AddExitConfirmationWindow(Manager gui)
5151
Engine.Exit();
5252
};
5353

54-
Button No = new Button(gui);
54+
55+
var No = new MenuButton(gui, ClickSound, FocusSound);
5556
No.Parent = Bevel;
5657
No.Text = GlblRes.Menu_AddExitConfirmationWindow_No;
5758
No.Width = 100;

src/Game/GameLogic/menu/MainMenu.cs

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
using Microsoft.Xna.Framework;
2+
using Microsoft.Xna.Framework.Audio;
23
using Microsoft.Xna.Framework.Graphics;
34
using STACK;
5+
using System;
46
using TomShane.Neoforce.Controls;
57

68
namespace SessionSeven
79
{
8-
public partial class Menu
10+
public partial class Menu : IDisposable
911
{
1012
private StackEngine Engine;
1113
private ImageBox MainMenuBackground;
1214
private Label MainMenuLabel;
15+
private SoundEffect FocusSound, ClickSound;
1316

1417
public void Show()
1518
{
@@ -56,8 +59,23 @@ private void ShowLogo(bool show)
5659
}
5760
}
5861

62+
public void Dispose()
63+
{
64+
if (null != FocusSound)
65+
{
66+
FocusSound.Dispose();
67+
}
68+
if (null != ClickSound)
69+
{
70+
FocusSound.Dispose();
71+
}
72+
}
73+
5974
public Menu(StackEngine engine)
6075
{
76+
FocusSound = engine.EngineContent.Load<SoundEffect>(content.audio.menu_click);
77+
ClickSound = engine.EngineContent.Load<SoundEffect>(content.audio.menu_focus);
78+
6179
Engine = engine;
6280
GameSettings = engine.GameSettings;
6381

@@ -90,6 +108,7 @@ public Menu(StackEngine engine)
90108
AddLoadGameWindow(GUI);
91109
AddSaveGameWindow(GUI);
92110
AddSettingsWindow(GUI);
111+
AddCreditsWindow(GUI);
93112
RefreshSaveGames();
94113
InitMenuButtons(GUI);
95114

src/Game/GameLogic/menu/MenuButton.cs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Microsoft.Xna.Framework.Audio;
2+
using TomShane.Neoforce.Controls;
3+
4+
namespace SessionSeven
5+
{
6+
/// <summary>
7+
/// Button with hover and click sounds
8+
/// </summary>
9+
public class MenuButton : Button
10+
{
11+
public MenuButton(Manager manager, SoundEffect clickSound, SoundEffect focusSound) : base(manager)
12+
{
13+
Click += (a, e) => PlaySoundIfAvaiable(clickSound);
14+
MouseOver += (a, e) => PlaySoundIfAvaiable(focusSound);
15+
}
16+
17+
private void PlaySoundIfAvaiable(SoundEffect sound)
18+
{
19+
if (null != sound && !sound.IsDisposed)
20+
{
21+
sound.Play();
22+
}
23+
}
24+
}
25+
}

src/Game/GameLogic/menu/MenuItems.cs

+22-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ private bool GameRunning
3232

3333
IEnumerable<Item> GetMenuItems()
3434
{
35-
Item Item = new Item(GlblRes.Quit);
35+
// Quit
36+
var Item = new Item(GlblRes.Quit);
3637
Item.OnClick = () =>
3738
{
3839
if (GameRunning)
@@ -49,10 +50,18 @@ IEnumerable<Item> GetMenuItems()
4950

5051
yield return Item;
5152

52-
//Item = new Item("Credits");
53+
// Credits
54+
Item = new Item("Credits");
55+
Item.OnClick = () =>
56+
{
57+
CreditsWindow.Show();
58+
ShowLogo(false);
59+
CreditsWindow.Focused = true;
60+
};
5361

54-
//yield return Item;
62+
yield return Item;
5563

64+
// Settings
5665
Item = new Item(GlblRes.Settings);
5766
Item.OnClick = () =>
5867
{
@@ -63,6 +72,7 @@ IEnumerable<Item> GetMenuItems()
6372

6473
yield return Item;
6574

75+
// Load
6676
Item = new Item(GlblRes.Load);
6777
Item.IsVisible = () => { return SaveGames.Count > 0; };
6878
Item.OnClick = () =>
@@ -73,6 +83,7 @@ IEnumerable<Item> GetMenuItems()
7383
};
7484
yield return Item;
7585

86+
// Save
7687
Item = new Item(GlblRes.Save);
7788
Item.IsVisible = () => { return GameRunning; };
7889
Item.OnClick = () =>
@@ -83,6 +94,7 @@ IEnumerable<Item> GetMenuItems()
8394

8495
yield return Item;
8596

97+
// Continue
8698
Item = new Item(GlblRes.Continue);
8799
Item.OnClick = () =>
88100
{
@@ -93,6 +105,7 @@ IEnumerable<Item> GetMenuItems()
93105
Item.IsVisible = () => { return GameRunning; };
94106
yield return Item;
95107

108+
// New Game
96109
Item = new Item(GlblRes.New_Game);
97110
Item.OnClick = () =>
98111
{
@@ -122,13 +135,16 @@ void InitMenuButtons(Manager gui)
122135

123136
foreach (var Item in GetMenuItems().Where(it => it.IsVisible()))
124137
{
125-
var MenuButton = new Button(gui);
138+
var MenuButton = new MenuButton(gui, ClickSound, FocusSound);
126139

127140
MenuButton.Init();
128141
MenuButton.Text = Item.Text;
129142
if (Item.OnClick != null)
130143
{
131-
MenuButton.Click += (s, e) => Item.OnClick();
144+
MenuButton.Click += (s, e) =>
145+
{
146+
Item.OnClick();
147+
};
132148
}
133149
MenuButton.Width = 120;
134150
MenuButton.Height = 24;
@@ -142,5 +158,6 @@ void InitMenuButtons(Manager gui)
142158
i++;
143159
}
144160
}
161+
145162
}
146163
}

0 commit comments

Comments
 (0)