aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/GraphicsSubsystem/UIManager.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-07-05 08:43:35 -0400
committerMichael <[email protected]>2017-07-05 08:43:35 -0400
commit4f41f51267e04d752d3d438f70f06a7a37975f5d (patch)
tree22036cb834d9915d44c527da55adfdab58a3d529 /ShiftOS.Frontend/GraphicsSubsystem/UIManager.cs
parent2adb8859edb95921e8f6d3cbb41fdc349825d6f8 (diff)
downloadshiftos_thereturn-4f41f51267e04d752d3d438f70f06a7a37975f5d.tar.gz
shiftos_thereturn-4f41f51267e04d752d3d438f70f06a7a37975f5d.tar.bz2
shiftos_thereturn-4f41f51267e04d752d3d438f70f06a7a37975f5d.zip
HEAVILY optimize skins
Diffstat (limited to 'ShiftOS.Frontend/GraphicsSubsystem/UIManager.cs')
-rw-r--r--ShiftOS.Frontend/GraphicsSubsystem/UIManager.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/ShiftOS.Frontend/GraphicsSubsystem/UIManager.cs b/ShiftOS.Frontend/GraphicsSubsystem/UIManager.cs
index bd173d2..12738a8 100644
--- a/ShiftOS.Frontend/GraphicsSubsystem/UIManager.cs
+++ b/ShiftOS.Frontend/GraphicsSubsystem/UIManager.cs
@@ -100,6 +100,14 @@ namespace ShiftOS.Frontend.GraphicsSubsystem
ctrl.Layout();
}
+ public static void InvalidateAll()
+ {
+ foreach(var ctrl in topLevels)
+ {
+ ctrl.Invalidate();
+ }
+ }
+
public static void ProcessMouseState(MouseState state)
{
foreach(var ctrl in topLevels.ToArray())
@@ -110,11 +118,50 @@ namespace ShiftOS.Frontend.GraphicsSubsystem
public static void ProcessKeyEvent(KeyEvent e)
{
+ if (e.ControlDown && e.Key == Keys.T)
+ {
+ AppearanceManager.SetupWindow(new Apps.Terminal());
+ return;
+ }
FocusedControl?.ProcessKeyEvent(e);
}
private static Texture2D DesktopBackground = null;
+ public static Dictionary<string, Texture2D> SkinTextures = new Dictionary<string, Texture2D>();
+
+ public static void ResetSkinTextures(GraphicsDevice graphics)
+ {
+ SkinTextures.Clear();
+ foreach(var byteArray in SkinEngine.LoadedSkin.GetType().GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).Where(x=>x.FieldType == typeof(byte[])))
+ {
+ var imgAttrib = byteArray.GetCustomAttributes(false).FirstOrDefault(x => x is ImageAttribute) as ImageAttribute;
+ if(imgAttrib != null)
+ {
+ var img = SkinEngine.GetImage(imgAttrib.Name);
+ if(img != null)
+ {
+ var bmp = (System.Drawing.Bitmap)img;
+ var lck = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+ var data = new byte[Math.Abs(lck.Stride) * lck.Height];
+ Marshal.Copy(lck.Scan0, data, 0, data.Length);
+ bmp.UnlockBits(lck);
+ var tex2 = new Texture2D(graphics, bmp.Width, bmp.Height);
+ for(int i = 0; i < data.Length; i += 4)
+ {
+ byte r = data[i];
+ byte b = data[i + 2];
+ data[i] = b;
+ data[i + 2] = r;
+ }
+ tex2.SetData<byte>(data);
+ SkinTextures.Add(imgAttrib.Name, tex2);
+ }
+ }
+ }
+ }
+
+
public static Queue<Action> CrossThreadOperations = new Queue<Action>();
public static void DrawBackgroundLayer(GraphicsDevice graphics, SpriteBatch batch, int width, int height)