diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index a9b4342af..1605a1e2e 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -682,6 +682,7 @@ Code + Designer @@ -708,6 +709,7 @@ Designer + diff --git a/Artemis/Artemis/Profiles/Lua/Brushes/LuaBrush.cs b/Artemis/Artemis/Profiles/Lua/Brushes/LuaBrush.cs index f8b5273db..21a31f891 100644 --- a/Artemis/Artemis/Profiles/Lua/Brushes/LuaBrush.cs +++ b/Artemis/Artemis/Profiles/Lua/Brushes/LuaBrush.cs @@ -8,6 +8,6 @@ namespace Artemis.Profiles.Lua.Brushes public abstract class LuaBrush { [MoonSharpVisible(false)] - public Brush Brush { get; set; } + public virtual Brush Brush { get; set; } } } \ No newline at end of file diff --git a/Artemis/Artemis/Profiles/Lua/Brushes/LuaBrushWrapper.cs b/Artemis/Artemis/Profiles/Lua/Brushes/LuaBrushWrapper.cs index e6a4f30db..0d183e290 100644 --- a/Artemis/Artemis/Profiles/Lua/Brushes/LuaBrushWrapper.cs +++ b/Artemis/Artemis/Profiles/Lua/Brushes/LuaBrushWrapper.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -using System.Windows.Media; using Artemis.Utilities; -using CUE.NET.Helper; using MoonSharp.Interpreter; namespace Artemis.Profiles.Lua.Brushes diff --git a/Artemis/Artemis/Profiles/Lua/Brushes/LuaLinearGradientBrush.cs b/Artemis/Artemis/Profiles/Lua/Brushes/LuaLinearGradientBrush.cs index bcc784215..0ea3ad65a 100644 --- a/Artemis/Artemis/Profiles/Lua/Brushes/LuaLinearGradientBrush.cs +++ b/Artemis/Artemis/Profiles/Lua/Brushes/LuaLinearGradientBrush.cs @@ -12,9 +12,9 @@ namespace Artemis.Profiles.Lua.Brushes { private LinearGradientBrush _brush; - public LuaLinearGradientBrush(LinearGradientBrush linearGradientBrush) + public LuaLinearGradientBrush(LinearGradientBrush brush) { - LinearGradientBrush = linearGradientBrush; + LinearGradientBrush = brush; } public LuaLinearGradientBrush(Dictionary gradientColors, double startX, double startY, @@ -38,6 +38,12 @@ namespace Artemis.Profiles.Lua.Brushes } } + public override Brush Brush + { + get { return LinearGradientBrush; } + set { LinearGradientBrush = (LinearGradientBrush) value; } + } + /// /// Gets or sets the Brush's GradientStops using a LUA table /// diff --git a/Artemis/Artemis/Profiles/Lua/Brushes/LuaRadialGradientBrush.cs b/Artemis/Artemis/Profiles/Lua/Brushes/LuaRadialGradientBrush.cs index d26b7fc94..2c34abeea 100644 --- a/Artemis/Artemis/Profiles/Lua/Brushes/LuaRadialGradientBrush.cs +++ b/Artemis/Artemis/Profiles/Lua/Brushes/LuaRadialGradientBrush.cs @@ -12,9 +12,9 @@ namespace Artemis.Profiles.Lua.Brushes { private RadialGradientBrush _brush; - public LuaRadialGradientBrush(RadialGradientBrush radialGradientBrush) + public LuaRadialGradientBrush(RadialGradientBrush brush) { - RadialGradientBrush = radialGradientBrush; + RadialGradientBrush = brush; } public LuaRadialGradientBrush(Dictionary gradientColors, double centerX, @@ -38,6 +38,12 @@ namespace Artemis.Profiles.Lua.Brushes } } + public override Brush Brush + { + get { return RadialGradientBrush; } + set { RadialGradientBrush = (RadialGradientBrush) value; } + } + /// /// Gets or sets the Brush's GradientStops using a LUA table /// diff --git a/Artemis/Artemis/Profiles/Lua/Brushes/LuaSolidColorBrush.cs b/Artemis/Artemis/Profiles/Lua/Brushes/LuaSolidColorBrush.cs index a06e1b78e..a6f4f18c2 100644 --- a/Artemis/Artemis/Profiles/Lua/Brushes/LuaSolidColorBrush.cs +++ b/Artemis/Artemis/Profiles/Lua/Brushes/LuaSolidColorBrush.cs @@ -9,11 +9,16 @@ namespace Artemis.Profiles.Lua.Brushes { private SolidColorBrush _brush; + public LuaSolidColorBrush(SolidColorBrush brush) + { + SolidColorBrush = brush; + } + public LuaSolidColorBrush(LuaColor luaColor) { SolidColorBrush = new SolidColorBrush(luaColor.Color); } - + /// /// The underlying brush /// @@ -29,6 +34,12 @@ namespace Artemis.Profiles.Lua.Brushes } } + public override Brush Brush + { + get { return SolidColorBrush; } + set { SolidColorBrush = (SolidColorBrush)value; } + } + public LuaColor Color { get { return new LuaColor(SolidColorBrush.Color); } diff --git a/Artemis/Artemis/Profiles/Lua/Events/LuaEventsWrapper.cs b/Artemis/Artemis/Profiles/Lua/Events/LuaEventsWrapper.cs index d763bead8..6924c3ff2 100644 --- a/Artemis/Artemis/Profiles/Lua/Events/LuaEventsWrapper.cs +++ b/Artemis/Artemis/Profiles/Lua/Events/LuaEventsWrapper.cs @@ -11,7 +11,7 @@ namespace Artemis.Profiles.Lua.Events public class LuaEventsWrapper { private readonly Logger _logger = LogManager.GetCurrentClassLogger(); - private readonly string _invokeLock = string.Empty; + public readonly string InvokeLock = string.Empty; public event EventHandler ProfileUpdating; public event EventHandler ProfileDrawing; public event EventHandler KeyboardKeyPressed; @@ -57,7 +57,7 @@ namespace Artemis.Profiles.Lua.Events private void LuaInvoke(ProfileModel profileModel, Action action) { - lock (_invokeLock) + lock (InvokeLock) { try { diff --git a/Artemis/Artemis/Profiles/Lua/LuaDrawWrapper.cs b/Artemis/Artemis/Profiles/Lua/LuaDrawWrapper.cs index 8d5b91bd6..c99081dbf 100644 --- a/Artemis/Artemis/Profiles/Lua/LuaDrawWrapper.cs +++ b/Artemis/Artemis/Profiles/Lua/LuaDrawWrapper.cs @@ -1,4 +1,6 @@ -using System.Globalization; +using System; +using System.Drawing.Text; +using System.Globalization; using System.Linq; using System.Windows; using System.Windows.Media; @@ -11,10 +13,12 @@ namespace Artemis.Profiles.Lua public class LuaDrawWrapper { private readonly DrawingContext _ctx; + private FontFamily _font; public LuaDrawWrapper(DrawingContext ctx) { _ctx = ctx; + _font = new FontFamily(new Uri("pack://application:,,,/"), "./resources/#Silkscreen"); } public void DrawEllipse(LuaBrush luaBrush, double x, double y, double height, double width) @@ -50,17 +54,16 @@ namespace Artemis.Profiles.Lua _ctx.DrawRectangle(luaBrush.Brush, new Pen(), new Rect(x, y, width, height)); } - public void DrawText(string text, string fontName, int fontSize, LuaBrush luaBrush, double x, double y) + public void DrawText(LuaBrush luaBrush, double x, double y, string text, int fontSize) { x *= 4; y *= 4; + fontSize *= 4; - var font = Fonts.SystemTypefaces.FirstOrDefault(f => f.FontFamily.ToString() == fontName); - if (font == null) - throw new ScriptRuntimeException($"Font '{fontName}' not found"); - - var formatted = new FormattedText(text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, font, + var typeFace = new Typeface(_font, new FontStyle(), new FontWeight(), new FontStretch()); + var formatted = new FormattedText(text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, typeFace, fontSize, luaBrush.Brush); + _ctx.DrawText(formatted, new Point(x, y)); } } diff --git a/Artemis/Artemis/Profiles/Lua/LuaKeyboardWrapper.cs b/Artemis/Artemis/Profiles/Lua/LuaKeyboardWrapper.cs index 5f38bf4ec..95a247c29 100644 --- a/Artemis/Artemis/Profiles/Lua/LuaKeyboardWrapper.cs +++ b/Artemis/Artemis/Profiles/Lua/LuaKeyboardWrapper.cs @@ -38,9 +38,9 @@ namespace Artemis.Profiles.Lua keyMatch.Value.X, keyMatch.Value.Y); } - public void SendKeys(string keys) + public void PressKeys(string keys) { - System.Windows.Forms.SendKeys.SendWait(keys); + SendKeys.SendWait(keys); } } } \ No newline at end of file diff --git a/Artemis/Artemis/Profiles/Lua/LuaLayerWrapper.cs b/Artemis/Artemis/Profiles/Lua/LuaLayerWrapper.cs index 0a5ee5a16..e777f9a3d 100644 --- a/Artemis/Artemis/Profiles/Lua/LuaLayerWrapper.cs +++ b/Artemis/Artemis/Profiles/Lua/LuaLayerWrapper.cs @@ -1,6 +1,8 @@ using System.Collections.Generic; using System.Linq; +using System.Windows.Media; using Artemis.Profiles.Layers.Models; +using Artemis.Profiles.Lua.Brushes; using MoonSharp.Interpreter; namespace Artemis.Profiles.Lua @@ -107,6 +109,23 @@ namespace Artemis.Profiles.Lua set { _layerModel.Properties.AnimationProgress = value; } } + public string BrushType => _layerModel.Properties.Brush?.GetType().Name; + + public LuaBrush Brush + { + get + { + if (_layerModel.Properties.Brush is SolidColorBrush) + return new LuaSolidColorBrush((SolidColorBrush) _layerModel.Properties.Brush); + if (_layerModel.Properties.Brush is LinearGradientBrush) + return new LuaLinearGradientBrush((LinearGradientBrush) _layerModel.Properties.Brush); + if (_layerModel.Properties.Brush is RadialGradientBrush) + return new LuaRadialGradientBrush((RadialGradientBrush) _layerModel.Properties.Brush); + return null; + } + set { _layerModel.Properties.Brush = value.Brush; } + } + #endregion } } \ No newline at end of file diff --git a/Artemis/Artemis/Profiles/Lua/LuaWrapper.cs b/Artemis/Artemis/Profiles/Lua/LuaWrapper.cs index 230fc3c15..55ee632c6 100644 --- a/Artemis/Artemis/Profiles/Lua/LuaWrapper.cs +++ b/Artemis/Artemis/Profiles/Lua/LuaWrapper.cs @@ -51,7 +51,10 @@ namespace Artemis.Profiles.Lua try { - LuaScript.DoString(ProfileModel.LuaScript); + lock (LuaEventsWrapper.InvokeLock) + { + LuaScript.DoString(ProfileModel.LuaScript); + } } catch (InternalErrorException e) { diff --git a/Artemis/Artemis/Properties/AssemblyInfo.cs b/Artemis/Artemis/Properties/AssemblyInfo.cs index 7be9c3d37..26544a55b 100644 --- a/Artemis/Artemis/Properties/AssemblyInfo.cs +++ b/Artemis/Artemis/Properties/AssemblyInfo.cs @@ -1,4 +1,5 @@ -using System.Reflection; +using System.Runtime.CompilerServices; +using System.Reflection; using System.Runtime.InteropServices; using System.Windows; @@ -53,4 +54,7 @@ using System.Windows; // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.4.0.0")] -[assembly: AssemblyFileVersion("1.4.0.0")] \ No newline at end of file +[assembly: AssemblyFileVersion("1.4.0.0")] +[assembly: InternalsVisibleTo("Artemis.Tests")] +[assembly: InternalsVisibleTo("Artemis.Explorables")] + diff --git a/Artemis/Artemis/Resources/Kottke Silkscreen License.txt b/Artemis/Artemis/Resources/Kottke Silkscreen License.txt new file mode 100644 index 000000000..a3d852edd --- /dev/null +++ b/Artemis/Artemis/Resources/Kottke Silkscreen License.txt @@ -0,0 +1,25 @@ +Thank you for downloading Silkscreen, a type family for your Web graphics +by Jason Kottke (jason@kottke.org). + +To install the Silkscreen type family, unzip this file and drag the files +into the Fonts folder in the Control Panel. + +If you encounter any problems in using this font, please email me and I'll +see if I can try and fix it. Please note that I can't help you with any +installation issues. Please consult your system's help files for assistance. + +This font is free for personal and corporate use and may be redistributed in +this unmodified form on your Web site. I would ask that you not modify and +then redistribute this font...although you may modify it for your own +personal use. If you really like this font and use it often, feel free to +mail me (e- or snail mail) some small token of your appreciation. A URL +of your work using Silkscreen would be appreciated as well. + +All future bug fixes, updates, and additions to the Silkscreen type family +will be available on my Web site at the following URL: + +http://www.kottke.org/plus/type/silkscreen/index.html + +Again, thanks for downloading Silkscreen. Enjoy! + +-jason \ No newline at end of file diff --git a/Artemis/Artemis/Resources/slkscr.ttf b/Artemis/Artemis/Resources/slkscr.ttf new file mode 100644 index 000000000..e2dd974b1 Binary files /dev/null and b/Artemis/Artemis/Resources/slkscr.ttf differ diff --git a/Artemis/Artemis/ViewModels/Profiles/ProfileViewModel.cs b/Artemis/Artemis/ViewModels/Profiles/ProfileViewModel.cs index a9fb7e47e..c0b63b4ac 100644 --- a/Artemis/Artemis/ViewModels/Profiles/ProfileViewModel.cs +++ b/Artemis/Artemis/ViewModels/Profiles/ProfileViewModel.cs @@ -12,6 +12,7 @@ using Artemis.Modules.Effects.ProfilePreview; using Artemis.Profiles; using Artemis.Profiles.Layers.Models; using Artemis.Profiles.Layers.Types.Folder; +using Artemis.Profiles.Lua; using Artemis.Properties; using Artemis.Utilities; using Caliburn.Micro; @@ -114,6 +115,8 @@ namespace Artemis.ViewModels.Profiles new Point(layerRect.BottomRight.X - 0.7, layerRect.BottomRight.Y - 0.7)); } + LuaWrapper.LuaEventsWrapper?.InvokeProfileDraw(SelectedProfile, new ProfilePreviewDataModel(), true, drawingContext); + // Remove the clip drawingContext.Pop(); } diff --git a/Artemis/Artemis/Views/WelcomeView.xaml b/Artemis/Artemis/Views/WelcomeView.xaml index 5383ceab9..f0e2d9d70 100644 --- a/Artemis/Artemis/Views/WelcomeView.xaml +++ b/Artemis/Artemis/Views/WelcomeView.xaml @@ -18,7 +18,7 @@ + HorizontalAlignment="Left" MaxWidth="520" TextAlignment="Justify" FontFamily="Te"> Hello, Thanks a bunch for downloading this application. You're going to enjoy this! :)