mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
LUA changes, added font for DrawText
This commit is contained in:
parent
3a01536d85
commit
39f7d180d8
@ -682,6 +682,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Resource Include="Resources\Kottke Silkscreen License.txt" />
|
||||
<None Include="Resources\lua-placeholder.lua" />
|
||||
<None Include="NLog.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
@ -708,6 +709,7 @@
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
<Resource Include="Resources\slkscr.ttf" />
|
||||
<Resource Include="Resources\bow.png" />
|
||||
<Content Include="lib\CUE.NET.dll" />
|
||||
<Content Include="lib\Ets2SdkClient.dll" />
|
||||
|
||||
@ -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; }
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -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<LuaColor, double> 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; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Brush's GradientStops using a LUA table
|
||||
/// </summary>
|
||||
|
||||
@ -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<LuaColor, double> gradientColors, double centerX,
|
||||
@ -38,6 +38,12 @@ namespace Artemis.Profiles.Lua.Brushes
|
||||
}
|
||||
}
|
||||
|
||||
public override Brush Brush
|
||||
{
|
||||
get { return RadialGradientBrush; }
|
||||
set { RadialGradientBrush = (RadialGradientBrush) value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Brush's GradientStops using a LUA table
|
||||
/// </summary>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The underlying brush
|
||||
/// </summary>
|
||||
@ -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); }
|
||||
|
||||
@ -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<LuaProfileUpdatingEventArgs> ProfileUpdating;
|
||||
public event EventHandler<LuaProfileDrawingEventArgs> ProfileDrawing;
|
||||
public event EventHandler<LuaKeyPressEventArgs> KeyboardKeyPressed;
|
||||
@ -57,7 +57,7 @@ namespace Artemis.Profiles.Lua.Events
|
||||
|
||||
private void LuaInvoke(ProfileModel profileModel, Action action)
|
||||
{
|
||||
lock (_invokeLock)
|
||||
lock (InvokeLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
@ -51,7 +51,10 @@ namespace Artemis.Profiles.Lua
|
||||
|
||||
try
|
||||
{
|
||||
LuaScript.DoString(ProfileModel.LuaScript);
|
||||
lock (LuaEventsWrapper.InvokeLock)
|
||||
{
|
||||
LuaScript.DoString(ProfileModel.LuaScript);
|
||||
}
|
||||
}
|
||||
catch (InternalErrorException e)
|
||||
{
|
||||
|
||||
@ -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")]
|
||||
[assembly: AssemblyFileVersion("1.4.0.0")]
|
||||
[assembly: InternalsVisibleTo("Artemis.Tests")]
|
||||
[assembly: InternalsVisibleTo("Artemis.Explorables")]
|
||||
|
||||
|
||||
25
Artemis/Artemis/Resources/Kottke Silkscreen License.txt
Normal file
25
Artemis/Artemis/Resources/Kottke Silkscreen License.txt
Normal file
@ -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
|
||||
BIN
Artemis/Artemis/Resources/slkscr.ttf
Normal file
BIN
Artemis/Artemis/Resources/slkscr.ttf
Normal file
Binary file not shown.
@ -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();
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
</Label>
|
||||
|
||||
<TextBlock Grid.Row="1" VerticalAlignment="Center" Margin="0,8" TextWrapping="Wrap"
|
||||
HorizontalAlignment="Left" MaxWidth="520" TextAlignment="Justify">
|
||||
HorizontalAlignment="Left" MaxWidth="520" TextAlignment="Justify" FontFamily="Te">
|
||||
Hello, <LineBreak /><LineBreak />
|
||||
Thanks a bunch for downloading this application. You're going to enjoy this! :)<LineBreak />
|
||||
<LineBreak />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user