Kinda save settings

This commit is contained in:
2021-04-25 02:07:37 +02:00
parent 1265db9095
commit f3b5139724
12 changed files with 79 additions and 7 deletions
Binary file not shown.
Binary file not shown.
+7 -1
View File
@@ -3,18 +3,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30907.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EvilSatellites", "EvilSatellites\EvilSatellites.csproj", "{48DE0A06-5D79-4EB1-B16A-4807A15AEBD0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EvilSatellites", "EvilSatellites\EvilSatellites.csproj", "{48DE0A06-5D79-4EB1-B16A-4807A15AEBD0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{48DE0A06-5D79-4EB1-B16A-4807A15AEBD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48DE0A06-5D79-4EB1-B16A-4807A15AEBD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48DE0A06-5D79-4EB1-B16A-4807A15AEBD0}.Debug|x86.ActiveCfg = Debug|x86
{48DE0A06-5D79-4EB1-B16A-4807A15AEBD0}.Debug|x86.Build.0 = Debug|x86
{48DE0A06-5D79-4EB1-B16A-4807A15AEBD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48DE0A06-5D79-4EB1-B16A-4807A15AEBD0}.Release|Any CPU.Build.0 = Release|Any CPU
{48DE0A06-5D79-4EB1-B16A-4807A15AEBD0}.Release|x86.ActiveCfg = Release|x86
{48DE0A06-5D79-4EB1-B16A-4807A15AEBD0}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+4
View File
@@ -4,6 +4,7 @@
<TargetFramework>net5.0</TargetFramework>
<PublishReadyToRun>false</PublishReadyToRun>
<TieredCompilation>false</TieredCompilation>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
@@ -12,6 +13,9 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath></OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<OutputPath />
</PropertyGroup>
<ItemGroup>
<None Remove="Icon.ico" />
<None Remove="Icon.bmp" />
+48
View File
@@ -3,13 +3,61 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace EvilSatellites
{
public static class GameSettings
{
public static string SettingsDirectory = Environment.SpecialFolder.Personal + "/EvilSatellites";
public static string SettingsFile = SettingsDirectory + "/settings.dat";
public static bool PreferSAPI = true;
public static bool UseForceFeedback = true;
public static bool EnableAI = true;
public static void SaveSettings()
{
if (!Directory.Exists(SettingsDirectory))
{
Directory.CreateDirectory(SettingsDirectory);
}
try
{
var file = new BinaryWriter(File.Open(SettingsFile, FileMode.Create));
file.Write(PreferSAPI);
file.Write(UseForceFeedback);
file.Write(EnableAI);
file.Close();
} catch (Exception e)
{
DavyKager.Tolk.Output("Error saving settings: " + e.Message);
}
}
public static void ReadSettings()
{
if (!Directory.Exists(SettingsDirectory))
{
return;
}
if (!File.Exists(SettingsFile))
{
return;
}
try
{
var file = new BinaryReader(File.OpenRead(SettingsFile));
PreferSAPI = file.ReadBoolean();
UseForceFeedback = file.ReadBoolean();
EnableAI = file.ReadBoolean();
file.Close();
} catch (Exception e)
{
return;
}
}
}
}
+5 -4
View File
@@ -80,6 +80,7 @@ namespace EvilSatellites.Objects
sfxTaps.Destroy();
sfxElevator.Destroy();
sfxDamage.Destroy();
CurrentWeapon.Destroy();
return;
}
override public void Update(GameTime gameTime)
@@ -109,19 +110,19 @@ namespace EvilSatellites.Objects
Move(Movement);
if (Turning == -1)
{
RotateY(0.035f);
RotateY(0.025f);
}
if (Turning == 1)
{
RotateY(-0.035f);
RotateY(-0.025f);
}
if (Elevating == -1)
{
RotateX(-0.035f);
RotateX(-0.025f);
}
if (Elevating == 1)
{
RotateX(0.035f);
RotateX(0.025f);
}
sfxEngine.Pitch = 0.5 + (Movement.Length() / MaxSpeed.Length()) * 4;
sfxWhine.Pitch = 0.5 + (Movement.Length() / MaxSpeed.Length()) * 1;
+1 -1
View File
@@ -7,7 +7,7 @@ namespace EvilSatellites
[STAThread]
static void Main()
{
GameSettings.ReadSettings();
DavyKager.Tolk.Load();
if (GameSettings.PreferSAPI)
{
+1 -1
View File
@@ -25,7 +25,7 @@ namespace EvilSatellites.Screens
public virtual void Activate()
{
CursorPosition = 0;
Tolk.Output(MenuOptions.Title, true);
Tolk.Output(MenuOptions.Title, false);
Tolk.Output(MenuOptions.Description, false);
Tolk.Output(MenuOptions.Entries[CursorPosition].Name);
Manager.Sound.PlayOneshot(@"sfx/ui/menuOpen.wav");
+1
View File
@@ -42,6 +42,7 @@ namespace EvilSatellites.Screens
}
if (CursorPosition == 4)
{
GameSettings.SaveSettings();
Manager.RemoveScreen(this);
Manager.AddScreen(new MainMenuScreen());
}
+1
View File
@@ -30,5 +30,6 @@ namespace EvilSatellites.Weapons
public virtual void Stop() { }
public virtual void Update(GameTime time) { }
public abstract void Reload(int amount);
public abstract void Destroy();
}
}
+1
View File
@@ -18,5 +18,6 @@ namespace EvilSatellites.Weapons
int MaxAmmo { get; set; }
int RemainingAmmo { get; set; }
WeaponState State { get; set; }
void Destroy();
}
}
+10
View File
@@ -130,5 +130,15 @@ namespace EvilSatellites.Weapons
sfxReload.Play();
Screen.Manager.Vibrations.AddVibration(1, 1, 500);
}
public override void Destroy()
{
sfxEmpty.Destroy();
sfxReload.Destroy();
sfxShoot.Destroy();
sfxSpindown.Destroy();
sfxSpinning.Destroy();
sfxSpinup.Destroy();
}
}
}