aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS.WinForms')
-rw-r--r--ShiftOS.WinForms/Applications/Terminal.cs8
-rw-r--r--ShiftOS.WinForms/AudioManager.cs27
-rw-r--r--ShiftOS.WinForms/Program.cs6
-rw-r--r--ShiftOS.WinForms/Tools/DitheringEngine.cs160
4 files changed, 130 insertions, 71 deletions
diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs
index a14cc58..02c4cc0 100644
--- a/ShiftOS.WinForms/Applications/Terminal.cs
+++ b/ShiftOS.WinForms/Applications/Terminal.cs
@@ -491,9 +491,9 @@ namespace ShiftOS.WinForms.Applications
TerminalBackend.InStory = false;
TerminalBackend.PrintPrompt();
bool help_entered = false;
- TerminalBackend.TextSent += (text) =>
+ TerminalBackend.CommandProcessed += (text, args) =>
{
- if (text == "sos.help" && help_entered == false)
+ if (text.EndsWith("sos.help") && help_entered == false)
help_entered = true;
};
while (help_entered == false)
@@ -523,10 +523,10 @@ namespace ShiftOS.WinForms.Applications
TerminalBackend.InStory = false;
bool winopenEntered = false;
TerminalBackend.PrintPrompt();
- TerminalBackend.TextSent += (text) =>
+ TerminalBackend.CommandProcessed += (text, args) =>
{
if (help_entered == true)
- if (text == "win.open" && winopenEntered == false)
+ if (text.EndsWith("win.open") && winopenEntered == false)
winopenEntered = true;
};
while (winopenEntered == false)
diff --git a/ShiftOS.WinForms/AudioManager.cs b/ShiftOS.WinForms/AudioManager.cs
index eb0e798..ec12614 100644
--- a/ShiftOS.WinForms/AudioManager.cs
+++ b/ShiftOS.WinForms/AudioManager.cs
@@ -74,7 +74,19 @@ namespace ShiftOS.WinForms
MemoryStream str = null;
NAudio.Wave.Mp3FileReader mp3 = null;
NAudio.Wave.WaveOut o = null;
- while (!Engine.SaveSystem.ShuttingDown)
+ bool shuttingDown = false;
+
+ Engine.AppearanceManager.OnExit += () =>
+ {
+ shuttingDown = true;
+ o?.Stop();
+ o?.Dispose();
+ mp3?.Close();
+ mp3?.Dispose();
+ str?.Close();
+ str?.Dispose();
+ };
+ while (shuttingDown == false)
{
str = new MemoryStream(GetRandomSong());
mp3 = new NAudio.Wave.Mp3FileReader(str);
@@ -87,14 +99,15 @@ namespace ShiftOS.WinForms
c = true;
};
while (!c)
+ {
+ try
+ {
+ o.Volume = (float)Engine.SaveSystem.CurrentSave.MusicVolume / 100;
+ }
+ catch { }
Thread.Sleep(10);
- str.Dispose();
- o.Dispose();
- mp3.Dispose();
+ }
}
- str?.Dispose();
- o?.Dispose();
- mp3?.Dispose();
});
athread.IsBackground = true;
athread.Start();
diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs
index 73215d4..8f65265 100644
--- a/ShiftOS.WinForms/Program.cs
+++ b/ShiftOS.WinForms/Program.cs
@@ -68,11 +68,7 @@ namespace ShiftOS.WinForms
SkinEngine.SetIconProber(new ShiftOSIconProvider());
ShiftOS.Engine.AudioManager.Init(new ShiftOSAudioProvider());
Localization.RegisterProvider(new WFLanguageProvider());
- AppearanceManager.OnExit += () =>
- {
- Environment.Exit(0);
- };
-
+
TutorialManager.RegisterTutorial(new Oobe());
TerminalBackend.TerminalRequested += () =>
diff --git a/ShiftOS.WinForms/Tools/DitheringEngine.cs b/ShiftOS.WinForms/Tools/DitheringEngine.cs
index f96a45a..d042a40 100644
--- a/ShiftOS.WinForms/Tools/DitheringEngine.cs
+++ b/ShiftOS.WinForms/Tools/DitheringEngine.cs
@@ -226,6 +226,53 @@ namespace ShiftOS.WinForms.Tools
}
#endif
+ public static int GetClosestColor(int gray, bool eightBits, bool sixBits, bool fourBits, bool twoBits)
+ {
+ int newgray = gray;
+ if (!eightBits)
+ {
+ if (sixBits)
+ {
+ newgray = gray >> 2;
+ }
+ else
+ {
+ if (fourBits)
+ {
+ newgray = (int)linear(gray, 0, 255, 0, 15) * 4;
+ }
+ else
+ {
+ if (twoBits)
+ {
+ if (gray > 127 + 63)
+ {
+ newgray = 255;
+ }
+ else if (gray > 127)
+ newgray = 127 + 63;
+ else if (gray > 63)
+ {
+ newgray = 127;
+ }
+ else if (gray > 0)
+ newgray = 63;
+ else
+ newgray = 0;
+ }
+ else
+ {
+ if (gray > 127)
+ newgray = 255;
+ else
+ newgray = 0;
+ }
+ }
+ }
+ }
+ return newgray;
+ }
+
#if FLOYDSTEINBERG
public static Image DitherImage(Image source)
{
@@ -260,75 +307,78 @@ namespace ShiftOS.WinForms.Tools
bool eightBits = Shiftorium.UpgradeInstalled("color_depth_8_bits");
bool color_depth_floydsteinberg = Shiftorium.UpgradeInstalled("color_depth_floyd-steinberg_dithering");
bool dithering = Shiftorium.UpgradeInstalled("color_depth_dithering");
-
- if (!sixteenBits)
+ bool twentyfourbits = Shiftorium.UpgradeInstalled("color_depth_24_bits");
+ if (twentyfourbits)
+ {
+ sourceArr.CopyTo(destArr, 0);
+ }
+ else
{
- if (dithering == true)
+
+ if (!sixteenBits)
{
- if (false == true)
+ if (dithering == true)
{
+ if (false == true)
+ {
+
+ }
+ else
+ {
+ int error = 0;
+ for (int i = 0; i < destArr.Length; i += 3)
+ {
+ byte r = sourceArr[i];
+ byte g = sourceArr[i + 1];
+ byte b = sourceArr[i + 2];
+
+ if (SkinEngine.LoadedSkin.SystemKey == Color.FromArgb(r, g, b))
+ {
+ destArr[i] = r;
+ destArr[i + 1] = g;
+ destArr[i + 2] = b;
+ continue;
+ }
+
+ int gray = (((r + g + b) / 3) + error);
+ int newgray = gray;
+ newgray = GetClosestColor(gray, eightBits, sixBits, fourBits, twoBits);
+ if (newgray > 255)
+ newgray = 255;
+ if (newgray < 0)
+ newgray = 0;
+ error = gray - newgray;
+ destArr[i] = (byte)newgray;
+ destArr[i + 1] = (byte)newgray;
+ destArr[i + 2] = (byte)newgray;
+
+ }
+ }
}
+
else
{
- int error = 0;
- for (int i = 0; i < destArr.Length; i += 3)
+ for (int i = 0; i < sourceArr.Length; i += 3)
{
byte r = sourceArr[i];
byte g = sourceArr[i + 1];
byte b = sourceArr[i + 2];
-
- int gray = (((r + g + b) / 3) + error);
- int newgray = gray;
- if (!eightBits)
+ if (SkinEngine.LoadedSkin.SystemKey == Color.FromArgb(r, g, b))
{
- if (sixBits)
- {
- newgray = gray >> 2;
- }
- else
- {
- if (fourBits)
- {
- newgray = (int)linear(gray, 0, 255, 0, 63) * 4;
- }
- else
- {
- if (twoBits)
- {
- if (gray > 127 + 63)
- {
- newgray = 255;
- }
- else if (gray > 127)
- newgray = 127 + 63;
- else if (gray > 63)
- {
- newgray = 127;
- }
- else if (gray > 0)
- newgray = 63;
- else
- newgray = 0;
- }
- else
- {
- if (gray > 127)
- newgray = 255;
- else
- newgray = 0;
- }
- }
- }
+ destArr[i] = r;
+ destArr[i + 1] = g;
+ destArr[i + 2] = b;
+ continue;
}
- if (newgray > 255)
- newgray = 255;
- if (newgray < 0)
- newgray = 0;
- error = gray - newgray;
+
+ int gray = (r + g + b) / 3;
+ int newgray = GetClosestColor(gray, eightBits, sixBits, fourBits, twoBits);
destArr[i] = (byte)newgray;
- destArr[i+1] = (byte)newgray;
- destArr[i+2] = (byte)newgray;
+ destArr[i + 1] = (byte)newgray;
+ destArr[i + 2] = (byte)newgray;
+
+
}
}