Skip to content

Commit

Permalink
✨ Implement settings window
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinbreiz committed Mar 4, 2024
1 parent 95036b1 commit 5009baa
Show file tree
Hide file tree
Showing 10 changed files with 282 additions and 19 deletions.
2 changes: 1 addition & 1 deletion SRC/Aura_OS/Properties/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace Aura_OS
{
public class VersionInfo
{
public static string revision = "040320240916";
public static string revision = "040320241052";
}
}
69 changes: 69 additions & 0 deletions SRC/Aura_OS/System/Graphics/UI/GUI/Components/Checkbox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* PROJECT: Aura Operating System Development
* CONTENT: Label class
* PROGRAMMERS: Valentin Charbonnier <[email protected]>
*/

using Cosmos.System.Graphics.Fonts;
using System;
using System.Drawing;

namespace Aura_OS.System.Graphics.UI.GUI.Components
{
public class Checkbox : Component
{
public Color TextColor;
public string Text = "";
public bool Checked = false;

private Button _check;

public Checkbox(string text, Color color, int x, int y) : base(x, y, (text.Length * Kernel.font.Width) + 13 + 6, 13)
{
_check = new Button((text.Length * Kernel.font.Width) + 3, 0, 13, 13);
_check.SetNormalFrame(Kernel.ThemeManager.GetFrame("check.off.normal"));
_check.SetHighlightedFrame(Kernel.ThemeManager.GetFrame("check.off.highlighted"));
_check.Click = new Action(() =>
{
Checked = !Checked;

if (Checked)
{
_check.SetNormalFrame(Kernel.ThemeManager.GetFrame("check.on.normal"));
_check.SetHighlightedFrame(Kernel.ThemeManager.GetFrame("check.on.highlighted"));
_check.Draw(this);
MarkDirty();
}
else
{
_check.SetNormalFrame(Kernel.ThemeManager.GetFrame("check.off.normal"));
_check.SetHighlightedFrame(Kernel.ThemeManager.GetFrame("check.off.highlighted"));
_check.Draw(this);
MarkDirty();
}
});

AddChild(_check);

TextColor = color;
Text = text;
}

public override void Update()
{
_check.Update();
}

public override void Draw()
{
Clear(Color.Transparent);

_check.Draw(this);

if (Text != "")
{
DrawString(Text, Kernel.font, TextColor, 0, 0);
}
}
}
}
1 change: 1 addition & 0 deletions SRC/Aura_OS/System/Graphics/UI/GUI/Components/Component.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public Component(int x, int y, int width, int height)
Children = new List<Component>();
zIndex = 0;
Explorer.WindowManager.AddComponent(this);
State = State.Normal;
}

public virtual void Update()
Expand Down
33 changes: 33 additions & 0 deletions SRC/Aura_OS/System/Graphics/UI/GUI/Components/Label.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* PROJECT: Aura Operating System Development
* CONTENT: Label class
* PROGRAMMERS: Valentin Charbonnier <[email protected]>
*/

using Cosmos.System.Graphics.Fonts;
using System.Drawing;

namespace Aura_OS.System.Graphics.UI.GUI.Components
{
public class Label : Component
{
public Color TextColor;
public string Text = "";

public Label(string text, Color color, int x, int y) : base(x, y, text.Length * Kernel.font.Width, Kernel.font.Height)
{
TextColor = color;
Text = text;
}

public override void Draw()
{
Clear(Color.Transparent);

if (Text != "")
{
DrawString(Text, Kernel.font, TextColor, 0, 0);
}
}
}
}
12 changes: 11 additions & 1 deletion SRC/Aura_OS/System/Graphics/UI/GUI/Dialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Aura_OS.System.Graphics.UI.GUI
{
internal class Dialog : Window
public class Dialog : Window
{
private string _title;
private string _message;
Expand All @@ -26,6 +26,16 @@ public Dialog(string title, string message, int x, int y) : base(title, x, y, 30
AlertIcon = Kernel.ResourceManager.GetIcon("32-dialog-information.bmp");
}

public override void Update()
{
base.Update();

foreach (var button in _buttons)
{
button.Update();
}
}

public List<Button> GetButtons()
{
return _buttons;
Expand Down
16 changes: 7 additions & 9 deletions SRC/Aura_OS/System/Graphics/UI/GUI/Skin/SkinParsing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,26 @@ private void loadResources(NanoXMLNode resourcesNode)
string bitmapName = node.GetAttribute("name").Value;
_skinName = node.GetAttribute("contentPath").Value;

string bmpPath = "";

if (Kernel.Installed)
{
Settings config = new Settings(@"0:\System\settings.ini");
bmpPath = config.GetValue("themeBmpPath");
Kernel.ThemeManager.BmpPath = config.GetValue("themeBmpPath");

if (!File.Exists(bmpPath))
if (!File.Exists(Kernel.ThemeManager.BmpPath))
{
bmpPath = Files.IsoVolume + "UI\\Themes\\" + _skinName + ".bmp";
Kernel.ThemeManager.BmpPath = Files.IsoVolume + "UI\\Themes\\" + _skinName + ".bmp";
}
}
else
{
bmpPath = Files.IsoVolume + "UI\\Themes\\" + _skinName + ".bmp";
Kernel.ThemeManager.BmpPath = Files.IsoVolume + "UI\\Themes\\" + _skinName + ".bmp";
}

CustomConsole.WriteLineInfo("Loading bitmap: " + bmpPath);
CustomConsole.WriteLineInfo("Loading bitmap: " + Kernel.ThemeManager.BmpPath);

try
{
Bitmap bitmap = new Bitmap(File.ReadAllBytes(bmpPath));
Bitmap bitmap = new Bitmap(File.ReadAllBytes(Kernel.ThemeManager.BmpPath));
_bitmaps.Add(bitmapName, bitmap);
CustomConsole.WriteLineOK("Bitmap '" + bitmapName + "' added successfully!");
}
Expand All @@ -91,7 +89,7 @@ private void loadFrames(NanoXMLNode framesNode)
{
string name = node.GetAttribute("name").Value;

if (name.StartsWith("window") || name.StartsWith("button") || name.StartsWith("cursor") || name.StartsWith("input"))
if (name.StartsWith("window") || name.StartsWith("button") || name.StartsWith("check") || name.StartsWith("input"))
{
Frame.Region[] regions = RegionListBuilder.Build(node, _bitmaps);
Frame.Text[] texts = null;
Expand Down
15 changes: 8 additions & 7 deletions SRC/Aura_OS/System/Graphics/UI/GUI/Skin/ThemeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public class ThemeManager : IManager
/// </summary>
private SkinParsing _skinParser;

public string XmlPath;
public string BmpPath;

/// <summary>
/// Loads the default theme and initializes the theme management system.
/// </summary>
Expand All @@ -28,24 +31,22 @@ public void Initialize()

_skinParser = new SkinParsing();

string xmlPath = "";

if (Kernel.Installed)
{
Settings config = new Settings(@"0:\System\settings.ini");
xmlPath = config.GetValue("themeXmlPath");
XmlPath = config.GetValue("themeXmlPath");

if (!File.Exists(xmlPath))
if (!File.Exists(XmlPath))
{
xmlPath = Files.IsoVolume + "UI\\Themes\\Suave.skin.xml";
XmlPath = Files.IsoVolume + "UI\\Themes\\Suave.skin.xml";
}
}
else
{
xmlPath = Files.IsoVolume + "UI\\Themes\\Suave.skin.xml";
XmlPath = Files.IsoVolume + "UI\\Themes\\Suave.skin.xml";
}

_skinParser.loadSkin(File.ReadAllText(xmlPath));
_skinParser.loadSkin(File.ReadAllText(XmlPath));
}

/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions SRC/Aura_OS/System/Processing/ApplicationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void LoadApplications()
RegisterApplication(typeof(CubeApp), 40, 40, 200, 200);
RegisterApplication(typeof(GameBoyApp), 40, 40, 160 + 6, 144 + 26);
RegisterApplication(typeof(SampleApp), 40, 40, 500, 500);
RegisterApplication(typeof(SettingsApp), 40, 40, 450, 350);
}

public void RegisterApplication(ApplicationConfig config)
Expand Down Expand Up @@ -137,6 +138,10 @@ public Application Instantiate(ApplicationConfig config)
{
app = new SampleApp(config.Weight, config.Height, config.X, config.Y);
}
else if (config.Template == typeof(SettingsApp))
{
app = new SettingsApp(config.Weight, config.Height, config.X, config.Y);
}
/*else if (config.Template == typeof(ExplorerApp))
{
app = new ExplorerApp(Kernel.CurrentVolume, config.Weight, config.Height, config.X, config.Y);
Expand Down
2 changes: 1 addition & 1 deletion SRC/Aura_OS/System/Processing/Applications/PictureApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override void Draw()
{
base.Draw();

DrawImage(_image, 0 + (int)(Width / 2 - _image.Width / 2), 0 + (int)(Height / 2 - _image.Height / 2));
DrawImage(_image, 0, 0);
}
}
}
Loading

0 comments on commit 5009baa

Please sign in to comment.