mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
More layer performance improvements, fixed The Witcher 3 support
This commit is contained in:
parent
aa7746e70a
commit
96faa8b084
@ -651,8 +651,7 @@
|
||||
<Resource Include="Resources\Keyboards\blackwidow.png" />
|
||||
<None Include="Resources\Keyboards\none.png" />
|
||||
<None Include="Resources\Keyboards\demo-gif.gif" />
|
||||
<Content Include="Resources\Witcher3\playerWitcher.txt" />
|
||||
<Content Include="Resources\Witcher3\artemis.txt" />
|
||||
<EmbeddedResource Include="Resources\Witcher3\Witcher3Artemis.zip" />
|
||||
<None Include="Settings\Offsets.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Offsets.Designer.cs</LastGenOutput>
|
||||
|
||||
@ -40,7 +40,7 @@ namespace Artemis.Models.Profiles
|
||||
switch (Type)
|
||||
{
|
||||
case "Enum":
|
||||
var enumType = _interpreter.Eval<Type>($"subject.{Field}.GetType()", new Parameter("subject", typeof(T), subject));
|
||||
var enumType = GeneralHelpers.GetPropertyValue(subject, Field).GetType();
|
||||
rightParam = new Parameter("value", Enum.Parse(enumType, Value));
|
||||
break;
|
||||
case "Boolean":
|
||||
@ -51,7 +51,8 @@ namespace Artemis.Models.Profiles
|
||||
break;
|
||||
}
|
||||
|
||||
return _interpreter.Eval<bool>($"subject.{Field} {Operator} value", new Parameter("subject", typeof(T), subject), rightParam);
|
||||
return _interpreter.Eval<bool>($"subject.{Field} {Operator} value",
|
||||
new Parameter("subject", typeof(T), subject), rightParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,11 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
public class Witcher3DataModel : IDataModel
|
||||
{
|
||||
public WitcherSign WitcherSign { get; set; }
|
||||
public int MaxHealth { get; set; }
|
||||
public int Health { get; set; }
|
||||
public int Stamina { get; set; }
|
||||
public int Toxicity { get; set; }
|
||||
public int Vitality { get; set; }
|
||||
}
|
||||
|
||||
public enum WitcherSign
|
||||
|
||||
@ -1,22 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Artemis.Models.Profiles;
|
||||
using Artemis.Utilities.Keyboard;
|
||||
|
||||
namespace Artemis.Modules.Games.Witcher3
|
||||
{
|
||||
public class Witcher3Model : GameModel
|
||||
{
|
||||
private readonly Regex _signRegex;
|
||||
private readonly Stopwatch _updateSw;
|
||||
private KeyboardRectangle _signRect;
|
||||
private readonly Regex _configRegex;
|
||||
private string _witcherSettings;
|
||||
|
||||
public Witcher3Model(MainManager mainManager, Witcher3Settings settings)
|
||||
@ -29,7 +27,7 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
Initialized = false;
|
||||
|
||||
_updateSw = new Stopwatch();
|
||||
_signRegex = new Regex("ActiveSign=(.*)", RegexOptions.Compiled);
|
||||
_configRegex = new Regex("\\[Artemis\\](.+?)\\[", RegexOptions.Singleline);
|
||||
}
|
||||
|
||||
public int Scale { get; set; }
|
||||
@ -46,13 +44,6 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
{
|
||||
Initialized = false;
|
||||
|
||||
_signRect = new KeyboardRectangle(MainManager.DeviceManager.ActiveKeyboard, 0, 0, new List<Color>(),
|
||||
LinearGradientMode.Horizontal)
|
||||
{
|
||||
Rotate = true,
|
||||
LoopSpeed = 0.5
|
||||
};
|
||||
|
||||
// Ensure the config file is found
|
||||
var witcherSettings = Environment.GetFolderPath(Environment.SpecialFolder.Personal) +
|
||||
@"\The Witcher 3\user.settings";
|
||||
@ -80,28 +71,69 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
var configContent = reader.ReadToEnd();
|
||||
reader.Close();
|
||||
|
||||
var signRes = _signRegex.Match(configContent);
|
||||
if (signRes.Groups.Count < 2)
|
||||
return;
|
||||
var sign = signRes.Groups[1].Value;
|
||||
var signRes = _configRegex.Match(configContent);
|
||||
var parts = signRes.Value.Split('\n').Skip(1).Select(v => v.Replace("\r", "")).ToList();
|
||||
parts.RemoveAt(parts.Count - 1);
|
||||
|
||||
switch (sign)
|
||||
// Update sign
|
||||
var sign = parts.FirstOrDefault(p => p.Contains("ActiveSign="));
|
||||
if (sign != null)
|
||||
{
|
||||
case "ST_Aard\r":
|
||||
gameDataModel.WitcherSign = WitcherSign.Aard;
|
||||
break;
|
||||
case "ST_Yrden\r":
|
||||
gameDataModel.WitcherSign = WitcherSign.Yrden;
|
||||
break;
|
||||
case "ST_Igni\r":
|
||||
gameDataModel.WitcherSign = WitcherSign.Igni;
|
||||
break;
|
||||
case "ST_Quen\r":
|
||||
gameDataModel.WitcherSign = WitcherSign.Quen;
|
||||
break;
|
||||
case "ST_Axii\r":
|
||||
gameDataModel.WitcherSign = WitcherSign.Axii;
|
||||
break;
|
||||
var singString = sign.Split('=')[1];
|
||||
switch (singString)
|
||||
{
|
||||
case "ST_Aard":
|
||||
gameDataModel.WitcherSign = WitcherSign.Aard;
|
||||
break;
|
||||
case "ST_Yrden":
|
||||
gameDataModel.WitcherSign = WitcherSign.Yrden;
|
||||
break;
|
||||
case "ST_Igni":
|
||||
gameDataModel.WitcherSign = WitcherSign.Igni;
|
||||
break;
|
||||
case "ST_Quen":
|
||||
gameDataModel.WitcherSign = WitcherSign.Quen;
|
||||
break;
|
||||
case "ST_Axii":
|
||||
gameDataModel.WitcherSign = WitcherSign.Axii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Update max health
|
||||
var maxHealth = parts.FirstOrDefault(p => p.Contains("MaxHealth="));
|
||||
if (maxHealth != null)
|
||||
{
|
||||
var healthInt = int.Parse(maxHealth.Split('=')[1].Split('.')[0]);
|
||||
gameDataModel.MaxHealth = healthInt;
|
||||
}
|
||||
// Update health
|
||||
var health = parts.FirstOrDefault(p => p.Contains("Health="));
|
||||
if (health != null)
|
||||
{
|
||||
var healthInt = int.Parse(health.Split('=')[1].Split('.')[0]);
|
||||
gameDataModel.Health = healthInt;
|
||||
}
|
||||
// Update stamina
|
||||
var stamina = parts.FirstOrDefault(p => p.Contains("Stamina="));
|
||||
if (stamina != null)
|
||||
{
|
||||
var staminaInt = int.Parse(stamina.Split('=')[1].Split('.')[0]);
|
||||
gameDataModel.Stamina = staminaInt;
|
||||
}
|
||||
// Update stamina
|
||||
var toxicity = parts.FirstOrDefault(p => p.Contains("Toxicity="));
|
||||
if (toxicity != null)
|
||||
{
|
||||
var toxicityInt = int.Parse(toxicity.Split('=')[1].Split('.')[0]);
|
||||
gameDataModel.Toxicity = toxicityInt;
|
||||
}
|
||||
// Update vitality
|
||||
var vitality = parts.FirstOrDefault(p => p.Contains("Vitality="));
|
||||
if (vitality != null)
|
||||
{
|
||||
var vitalityInt = int.Parse(vitality.Split('=')[1].Split('.')[0]);
|
||||
gameDataModel.Vitality = vitalityInt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.InjectionFactories;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.ViewModels.Abstract;
|
||||
using Caliburn.Micro;
|
||||
|
||||
@ -20,8 +22,6 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
MainManager.EffectManager.EffectModels.Add(GameModel);
|
||||
}
|
||||
|
||||
public static string Name => "The Witcher 3";
|
||||
|
||||
public async void AutoInstall()
|
||||
{
|
||||
// Request The Witcher 3 folder
|
||||
@ -48,6 +48,13 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
return;
|
||||
}
|
||||
|
||||
// Load the ZIP from resources
|
||||
var stream = Assembly.GetExecutingAssembly()
|
||||
.GetManifestResourceStream("Artemis.Resources.Witcher3.Witcher3Artemis.zip");
|
||||
if (stream == null)
|
||||
throw new FileNotFoundException("Couldn't load the Witcher 3 mod files from resources.");
|
||||
var archive = new ZipArchive(stream);
|
||||
|
||||
// Look for any conflicting mods
|
||||
if (Directory.Exists(dialog.SelectedPath + @"\mods"))
|
||||
{
|
||||
@ -62,28 +69,16 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
var viewHelp = await
|
||||
DialogService.ShowQuestionMessageBox("Conflicting mod found",
|
||||
"Oh no, you have a conflicting mod!\n\n" +
|
||||
"Conflicting file: " + file.Remove(0, dialog.SelectedPath.Length) +
|
||||
"\n\nWould you like to view instructions on how to manually install the mod?");
|
||||
$"Conflicting file: {file.Remove(0, dialog.SelectedPath.Length)}\n\n" +
|
||||
"Would you like to view instructions on how to manually install the mod?");
|
||||
if (!viewHelp.Value)
|
||||
return;
|
||||
|
||||
// Put the mod in the documents folder instead
|
||||
// Create the directory structure
|
||||
var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Artemis";
|
||||
if (
|
||||
!Directory.Exists(folder + @"\Witcher3\mods\modArtemis\content\scripts\game\player"))
|
||||
Directory.CreateDirectory(folder +
|
||||
@"\Witcher3\mods\modArtemis\content\scripts\game\player");
|
||||
if (
|
||||
!Directory.Exists(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc"))
|
||||
Directory.CreateDirectory(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc");
|
||||
|
||||
// Install the mod files
|
||||
File.WriteAllText(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc\artemis.xml",
|
||||
Resources.artemisXml);
|
||||
File.WriteAllText(
|
||||
folder + @"\Witcher3\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",
|
||||
Resources.playerWitcherWs);
|
||||
archive.ExtractToDirectory(folder + @"witcher3-mod", true);
|
||||
|
||||
Process.Start(new ProcessStartInfo("https://github.com/SpoinkyNL/Artemis/wiki/The-Witcher-3"));
|
||||
return;
|
||||
@ -91,18 +86,7 @@ namespace Artemis.Modules.Games.Witcher3
|
||||
}
|
||||
}
|
||||
|
||||
// Create the directory structure
|
||||
if (!Directory.Exists(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player"))
|
||||
Directory.CreateDirectory(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player");
|
||||
if (!Directory.Exists(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc"))
|
||||
Directory.CreateDirectory(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc");
|
||||
|
||||
// Install the mod files
|
||||
File.WriteAllText(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc\artemis.xml",
|
||||
Resources.artemisXml);
|
||||
File.WriteAllText(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",
|
||||
Resources.playerWitcherWs);
|
||||
|
||||
archive.ExtractToDirectory(dialog.SelectedPath, true);
|
||||
DialogService.ShowMessageBox("Success", "The mod was successfully installed!");
|
||||
}
|
||||
}
|
||||
|
||||
51
Artemis/Artemis/Properties/Resources.Designer.cs
generated
51
Artemis/Artemis/Properties/Resources.Designer.cs
generated
@ -60,23 +60,6 @@ namespace Artemis.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <?xml version="1.0" encoding="UTF-16"?>
|
||||
///<!-- Used by Artemis to get the active Sign -->
|
||||
///<UserConfig>
|
||||
/// <Group id="Artemis" displayName="Artemis">
|
||||
/// <VisibleVars>
|
||||
/// <Var id="ActiveSign" displayName="ActiveSign" displayType="SLIDER:0:1:1000000"/>
|
||||
/// </VisibleVars>
|
||||
/// </Group>
|
||||
///</UserConfig>.
|
||||
/// </summary>
|
||||
internal static string artemisXml {
|
||||
get {
|
||||
return ResourceManager.GetString("artemisXml", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
@ -285,30 +268,6 @@ namespace Artemis.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to /***********************************************************************/
|
||||
////** © 2015 CD PROJEKT S.A. All rights reserved.
|
||||
////** THE WITCHER® is a trademark of CD PROJEKT S. A.
|
||||
////** The Witcher game is based on the prose of Andrzej Sapkowski.
|
||||
////***********************************************************************/
|
||||
///
|
||||
///
|
||||
///
|
||||
///
|
||||
///statemachine class W3PlayerWitcher extends CR4Player
|
||||
///{
|
||||
///
|
||||
/// private saved var craftingSchematics : array<name>;
|
||||
///
|
||||
///
|
||||
/// private saved var alchemyRecipes : array<name>; [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string playerWitcherWs {
|
||||
get {
|
||||
return ResourceManager.GetString("playerWitcherWs", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
@ -328,5 +287,15 @@ namespace Artemis.Properties {
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] Witcher3Artemis {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Witcher3Artemis", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,9 +118,6 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="artemisXml" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\resources\witcher3\artemis.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
<data name="bow" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\bow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
@ -139,9 +136,6 @@
|
||||
<data name="logo_disabled" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\logo-disabled.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="playerWitcherWs" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\resources\witcher3\playerwitcher.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
|
||||
</data>
|
||||
<data name="k65" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\resources\keyboards\k65.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
@ -184,4 +178,7 @@
|
||||
<data name="demo_gif" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Keyboards\demo-gif.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Witcher3Artemis" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Witcher3\Witcher3Artemis.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
</root>
|
||||
BIN
Artemis/Artemis/Resources/Witcher3/Witcher3Artemis.zip
Normal file
BIN
Artemis/Artemis/Resources/Witcher3/Witcher3Artemis.zip
Normal file
Binary file not shown.
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-16"?>
|
||||
<!-- Used by Artemis to get the active Sign -->
|
||||
<UserConfig>
|
||||
<Group id="Artemis" displayName="Artemis">
|
||||
<VisibleVars>
|
||||
<Var id="ActiveSign" displayName="ActiveSign" displayType="SLIDER:0:1:1000000"/>
|
||||
</VisibleVars>
|
||||
</Group>
|
||||
</UserConfig>
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user