mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Noise brush - Greatly improved performance on large layouts
Profiles core - Pass real delta time brushes/effects Profiles core - Allow main segment to be disabled on layers General module - Removed test data model General module - Removed expensive open window scan, was fun to try :P Profile editor - Refactored segments Profile editor - Updated segment visuals to scale well when really narrow
This commit is contained in:
1 parent
72d606f40d
commit
2045b230c2
13 files changed
+584
-396
No files matched your search
@@ -73,6 +73,19 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
var height = (int) Math.Floor(path.Bounds.Height * _renderScale);
|
||||
|
||||
CreateBitmap(width, height);
|
||||
|
||||
var clipPath = new SKPath(Layer.Path);
|
||||
Layer.ExcludePathFromTranslation(clipPath);
|
||||
clipPath = new SKPath(clipPath);
|
||||
clipPath.Transform(SKMatrix.MakeTranslation(Layer.Path.Bounds.Left * -1, Layer.Path.Bounds.Top * -1));
|
||||
|
||||
// Fill a canvas matching the final area that will be rendered
|
||||
using var bitmapCanvas = new SKCanvas(_bitmap);
|
||||
using var clipPaint = new SKPaint {Color = new SKColor(0, 0, 0, 255)};
|
||||
bitmapCanvas.Clear();
|
||||
bitmapCanvas.Scale(_renderScale);
|
||||
bitmapCanvas.DrawPath(clipPath, clipPaint);
|
||||
|
||||
for (var y = 0; y < height; y++)
|
||||
{
|
||||
for (var x = 0; x < width; x++)
|
||||
@@ -84,6 +97,10 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
if (double.IsInfinity(evalX) || double.IsNaN(evalX) || double.IsNaN(evalY) || double.IsInfinity(evalY))
|
||||
continue;
|
||||
|
||||
var pixel = _bitmap.GetPixel(x, y);
|
||||
if (pixel.Alpha != 255)
|
||||
continue;
|
||||
|
||||
var v = (float) _noise.Evaluate(evalX, evalY, _z) * hardness;
|
||||
var amount = Math.Max(0f, Math.Min(1f, v));
|
||||
if (Properties.ColorType.BaseValue == ColorMappingType.Simple)
|
||||
|
||||
@@ -1,62 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
|
||||
using Artemis.Plugins.Modules.General.DataModel.Windows;
|
||||
using SkiaSharp;
|
||||
using Artemis.Plugins.Modules.General.DataModel.Windows;
|
||||
|
||||
namespace Artemis.Plugins.Modules.General.DataModel
|
||||
{
|
||||
public class GeneralDataModel : Core.Plugins.Abstract.DataModels.DataModel
|
||||
{
|
||||
public TestDataModel TestDataModel { get; set; }
|
||||
public WindowsDataModel Windows { get; set; }
|
||||
|
||||
|
||||
public GeneralDataModel()
|
||||
{
|
||||
TestDataModel = new TestDataModel();
|
||||
Windows = new WindowsDataModel();
|
||||
}
|
||||
}
|
||||
|
||||
public class TestDataModel
|
||||
{
|
||||
public TestDataModel()
|
||||
{
|
||||
PlayerInfo = new PlayerInfo();
|
||||
IntsList = new List<int>();
|
||||
PlayerInfosList = new List<PlayerInfo>();
|
||||
}
|
||||
|
||||
[DataModelProperty(Name = "A test string", Description = "This is a test string that's not of any use outside testing!")]
|
||||
public string TestString { get; set; }
|
||||
|
||||
[DataModelProperty(Name = "A test boolean", Description = "This is a test boolean that's not of any use outside testing!")]
|
||||
public bool TestBoolean { get; set; }
|
||||
|
||||
public SKColor TestColor { get; set; } = new SKColor(221, 21, 152);
|
||||
|
||||
[DataModelProperty(Name = "Player info", Description = "[TEST] Contains information about the player")]
|
||||
public PlayerInfo PlayerInfo { get; set; }
|
||||
|
||||
public double UpdatesDividedByFour { get; set; }
|
||||
public int Updates { get; set; }
|
||||
|
||||
public List<int> IntsList { get; set; }
|
||||
public List<PlayerInfo> PlayerInfosList { get; set; }
|
||||
}
|
||||
|
||||
public class PlayerInfo
|
||||
{
|
||||
[DataModelProperty(Name = "A test string", Description = "This is a test string that's not of any use outside testing!")]
|
||||
public string TestString { get; set; }
|
||||
|
||||
[DataModelProperty(Name = "A test boolean", Description = "This is a test boolean that's not of any use outside testing!")]
|
||||
public bool TestBoolean { get; set; }
|
||||
|
||||
[DataModelProperty(Affix = "%", MinValue = 0, MaxValue = 100)]
|
||||
public int Health { get; set; }
|
||||
|
||||
public SKPoint Position { get; set; }
|
||||
public WindowDataModel ActiveWindow { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ namespace Artemis.Plugins.Modules.General.DataModel.Windows
|
||||
ProcessName = process.ProcessName;
|
||||
|
||||
// Accessing MainModule requires admin privileges, this way does not
|
||||
ProgramLocation = WindowMonitor.GetProcessFilename(process);
|
||||
ProgramLocation = WindowUtilities.GetProcessFilename(process);
|
||||
}
|
||||
|
||||
public string WindowTitle { get; set; }
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace Artemis.Plugins.Modules.General.DataModel.Windows
|
||||
{
|
||||
public class WindowsDataModel
|
||||
{
|
||||
public WindowDataModel ActiveWindow { get; set; }
|
||||
public List<WindowDataModel> OpenWindows { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Interop;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Plugins.Modules.General.DataModel;
|
||||
using Artemis.Plugins.Modules.General.DataModel.Windows;
|
||||
using Artemis.Plugins.Modules.General.Utilities;
|
||||
using Artemis.Plugins.Modules.General.ViewModels;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.Modules.General
|
||||
{
|
||||
public class GeneralModule : ProfileModule<GeneralDataModel>
|
||||
{
|
||||
private readonly PluginSettings _settings;
|
||||
private readonly Random _rand;
|
||||
|
||||
|
||||
public GeneralModule(PluginSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
_rand = new Random();
|
||||
}
|
||||
|
||||
public override IEnumerable<ModuleViewModel> GetViewModels()
|
||||
{
|
||||
return new List<ModuleViewModel> {new GeneralViewModel(this)};
|
||||
@@ -35,19 +18,7 @@ namespace Artemis.Plugins.Modules.General
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
DataModel.TestDataModel.UpdatesDividedByFour += 0.25;
|
||||
DataModel.TestDataModel.Updates += 1;
|
||||
DataModel.TestDataModel.PlayerInfo.Position = new SKPoint(_rand.Next(100), _rand.Next(100));
|
||||
DataModel.TestDataModel.PlayerInfo.Health++;
|
||||
if (DataModel.TestDataModel.PlayerInfo.Health > 200)
|
||||
DataModel.TestDataModel.PlayerInfo.Health = 0;
|
||||
|
||||
DataModel.TestDataModel.IntsList[0] = _rand.Next();
|
||||
DataModel.TestDataModel.IntsList[2] = _rand.Next();
|
||||
|
||||
UpdateCurrentWindow();
|
||||
UpdateBackgroundWindows();
|
||||
|
||||
base.Update(deltaTime);
|
||||
}
|
||||
|
||||
@@ -56,11 +27,6 @@ namespace Artemis.Plugins.Modules.General
|
||||
DisplayName = "General";
|
||||
DisplayIcon = "AllInclusive";
|
||||
ExpandsDataModel = true;
|
||||
|
||||
DataModel.TestDataModel.IntsList = new List<int> {_rand.Next(), _rand.Next(), _rand.Next()};
|
||||
DataModel.TestDataModel.PlayerInfosList = new List<PlayerInfo> {new PlayerInfo()};
|
||||
|
||||
var testSetting = _settings.GetSetting("TestSetting", DateTime.Now);
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
@@ -69,31 +35,11 @@ namespace Artemis.Plugins.Modules.General
|
||||
|
||||
#region Open windows
|
||||
|
||||
private DateTime _lastBackgroundWindowsUpdate;
|
||||
|
||||
public void UpdateCurrentWindow()
|
||||
{
|
||||
var processId = WindowMonitor.GetActiveProcessId();
|
||||
if (DataModel.Windows.ActiveWindow == null || DataModel.Windows.ActiveWindow.Process.Id != processId)
|
||||
DataModel.Windows.ActiveWindow = new WindowDataModel(Process.GetProcessById(processId));
|
||||
}
|
||||
|
||||
public void UpdateBackgroundWindows()
|
||||
{
|
||||
// This is kinda slow so lets not do it very often and lets do it in a task
|
||||
if (DateTime.Now - _lastBackgroundWindowsUpdate < TimeSpan.FromSeconds(5))
|
||||
return;
|
||||
|
||||
_lastBackgroundWindowsUpdate = DateTime.Now;
|
||||
Task.Run(() =>
|
||||
{
|
||||
// All processes with a main window handle are considered open windows
|
||||
DataModel.Windows.OpenWindows = Process.GetProcesses()
|
||||
.Where(p => p.MainWindowHandle != IntPtr.Zero)
|
||||
.Select(p => new WindowDataModel(p))
|
||||
.Where(w => !string.IsNullOrEmpty(w.WindowTitle))
|
||||
.ToList();
|
||||
});
|
||||
var processId = WindowUtilities.GetActiveProcessId();
|
||||
if (DataModel.ActiveWindow == null || DataModel.ActiveWindow.Process.Id != processId)
|
||||
DataModel.ActiveWindow = new WindowDataModel(Process.GetProcessById(processId));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace Artemis.Plugins.Modules.General.Utilities
|
||||
{
|
||||
public static class WindowMonitor
|
||||
public static class WindowUtilities
|
||||
{
|
||||
public static int GetActiveProcessId()
|
||||
{
|
||||
Reference in new issue
Block a user