mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added Terraria module
This commit is contained in:
parent
b9ebdeefa1
commit
270e5963a9
@ -384,6 +384,13 @@
|
||||
<DependentUpon>AssettoCorsaView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Modules\Games\AssettoCorsa\AssettoCorsaViewModel.cs" />
|
||||
<Compile Include="Modules\Games\Terraria\TerrariaDataModel.cs" />
|
||||
<Compile Include="Modules\Games\Terraria\TerrariaSettings.cs" />
|
||||
<Compile Include="Modules\Games\Terraria\TerrariaModel.cs" />
|
||||
<Compile Include="Modules\Games\Terraria\TerrariaView.xaml.cs">
|
||||
<DependentUpon>TerrariaView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Modules\Games\Terraria\TerrariaViewModel.cs" />
|
||||
<Compile Include="Modules\General\GeneralProfile\PerformanceInfo.cs" />
|
||||
<Compile Include="Modules\Games\EurotruckSimulator2\Data\Ets2TelemetryData.cs" />
|
||||
<Compile Include="Modules\Games\EurotruckSimulator2\Data\Ets2TelemetryDataReader.cs" />
|
||||
@ -856,6 +863,10 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Modules\Games\Terraria\TerrariaView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Modules\General\Bubbles\BubblesView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@ -88,11 +88,6 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
break;
|
||||
}
|
||||
|
||||
Height = 8;
|
||||
Width = 22;
|
||||
Slug = "corsair-strafe-rgb";
|
||||
PreviewSettings = new PreviewSettings(new Rect(23, 12, 937, 324), Resources.strafe);
|
||||
|
||||
Logger.Debug("Corsair SDK reported device as: {0}", _keyboard.DeviceInfo.Model);
|
||||
_keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush());
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
{
|
||||
if (!SettingsProvider.Load<GeneralSettings>().EnablePointersUpdate)
|
||||
{
|
||||
VersionText = "You disabled pointer updates, this could result in the Rocket League effect not working after a game update.";
|
||||
VersionText = "You disabled pointer updates, this could result in the Rocket League module not working after a game update.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
18
Artemis/Artemis/Modules/Games/Terraria/TerrariaDataModel.cs
Normal file
18
Artemis/Artemis/Modules/Games/Terraria/TerrariaDataModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using Artemis.Modules.Abstract;
|
||||
using MoonSharp.Interpreter;
|
||||
|
||||
namespace Artemis.Modules.Games.Terraria
|
||||
{
|
||||
[MoonSharpUserData]
|
||||
public class TerrariaDataModel : ModuleDataModel
|
||||
{
|
||||
public int Hp { get; set; }
|
||||
public int MaxHp { get; set; }
|
||||
public int Mana { get; set; }
|
||||
public int MaxMana { get; set; }
|
||||
public int Breath { get; set; }
|
||||
public int MaxBreath { get; set; }
|
||||
public bool InWater { get; set; }
|
||||
public bool InLava { get; set; }
|
||||
}
|
||||
}
|
||||
91
Artemis/Artemis/Modules/Games/Terraria/TerrariaModel.cs
Normal file
91
Artemis/Artemis/Modules/Games/Terraria/TerrariaModel.cs
Normal file
@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Artemis.DAL;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.Memory;
|
||||
|
||||
namespace Artemis.Modules.Games.Terraria
|
||||
{
|
||||
public class TerrariaModel : ModuleModel
|
||||
{
|
||||
private Memory _memory;
|
||||
private GamePointersCollection _pointer;
|
||||
|
||||
public TerrariaModel(DeviceManager deviceManager, LuaManager luaManager) : base(deviceManager, luaManager)
|
||||
{
|
||||
Settings = SettingsProvider.Load<TerrariaSettings>();
|
||||
DataModel = new TerrariaDataModel();
|
||||
ProcessNames.Add("Terraria");
|
||||
|
||||
// Generate a new offset when the game is updated
|
||||
//_pointer = new GamePointersCollection
|
||||
//{
|
||||
// Game = "Terraria",
|
||||
// GameVersion = "1.3.4.4",
|
||||
// GameAddresses = new List<GamePointer>
|
||||
// {
|
||||
// new GamePointer
|
||||
// {
|
||||
// Description = "PlayerBase",
|
||||
// BasePointer = new IntPtr(0x0039C078),
|
||||
// Offsets = new[] {0x280, 0x6C0, 0x674, 0x3C}
|
||||
// }
|
||||
// }
|
||||
//};
|
||||
//var res = JsonConvert.SerializeObject(_pointer, Formatting.Indented);
|
||||
}
|
||||
|
||||
public override string Name => "Terraria";
|
||||
public override bool IsOverlay => false;
|
||||
public override bool IsBoundToProcess => true;
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
|
||||
_memory?.Dispose();
|
||||
_memory = null;
|
||||
}
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
Updater.GetPointers();
|
||||
_pointer = SettingsProvider.Load<OffsetSettings>().Terraria;
|
||||
|
||||
base.Enable();
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (_memory == null)
|
||||
{
|
||||
var tempProcess = MemoryHelpers.GetProcessIfRunning(ProcessNames[0]);
|
||||
if (tempProcess == null)
|
||||
return;
|
||||
|
||||
_memory = new Memory(tempProcess);
|
||||
}
|
||||
|
||||
if (ProfileModel == null || DataModel == null || _memory == null)
|
||||
return;
|
||||
|
||||
var offsets = _pointer.GameAddresses.First(ga => ga.Description == "PlayerBase").ToString();
|
||||
var baseAddress = _memory.GetAddress("\"Terraria.exe\"" + offsets);
|
||||
var basePointer = new IntPtr(_memory.ReadInt32(baseAddress));
|
||||
var playerPointer = new IntPtr(_memory.ReadInt32(basePointer + 0x18));
|
||||
|
||||
var dataModel = (TerrariaDataModel) DataModel;
|
||||
dataModel.Hp = _memory.ReadInt32(playerPointer + 0x340);
|
||||
dataModel.MaxHp = _memory.ReadInt32(playerPointer + 0x338);
|
||||
dataModel.Mana = _memory.ReadInt32(playerPointer + 0x344);
|
||||
dataModel.MaxMana = _memory.ReadInt32(playerPointer + 0x348);
|
||||
dataModel.Breath = _memory.ReadInt32(playerPointer + 0x2B4);
|
||||
dataModel.MaxBreath = _memory.ReadInt32(playerPointer + 0x2B0);
|
||||
dataModel.InWater = Convert.ToBoolean(_memory.ReadInt32(playerPointer + 0x1D));
|
||||
dataModel.InLava = Convert.ToBoolean(_memory.ReadInt32(playerPointer + 0x20));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
using Artemis.Modules.Abstract;
|
||||
|
||||
namespace Artemis.Modules.Games.Terraria
|
||||
{
|
||||
public class TerrariaSettings : ModuleSettings
|
||||
{
|
||||
}
|
||||
}
|
||||
48
Artemis/Artemis/Modules/Games/Terraria/TerrariaView.xaml
Normal file
48
Artemis/Artemis/Modules/Games/Terraria/TerrariaView.xaml
Normal file
@ -0,0 +1,48 @@
|
||||
<UserControl x:Class="Artemis.Modules.Games.Terraria.TerrariaView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.Modules.Games.Terraria"
|
||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
mc:Ignorable="d" d:DesignWidth="714.667" d:DesignHeight="384.667" >
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="30" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Header -->
|
||||
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" FontSize="20" HorizontalAlignment="Left">
|
||||
<Label.Content>
|
||||
<AccessText TextWrapping="Wrap" Text="By default does nothing! (default profiles coming soon)" />
|
||||
</Label.Content>
|
||||
</Label>
|
||||
|
||||
<!-- Sub header -->
|
||||
<TextBlock x:Name="VersionText" Grid.Row="1" Grid.Column="0" VerticalAlignment="Bottom" TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold" TextAlignment="Justify" Margin="5,0,0,10" />
|
||||
|
||||
<!-- Enable -->
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Label Content="Enable module" HorizontalAlignment="Right" Margin="0,0,0,3" />
|
||||
<controls:ToggleSwitchButton IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}" cal:Message.Attach="[Event Click] = [Action ToggleModule]"
|
||||
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitchButton.Win10}" ToolTip="Note: You can't enable an module when Artemis is disabled" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Profile editor -->
|
||||
<ContentControl Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" x:Name="ProfileEditor" />
|
||||
|
||||
<!-- Buttons -->
|
||||
<StackPanel Grid.Column="0" Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Bottom">
|
||||
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100" Style="{DynamicResource SquareButtonStyle}" />
|
||||
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100" Margin="10,0,0,0" Style="{DynamicResource SquareButtonStyle}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
28
Artemis/Artemis/Modules/Games/Terraria/TerrariaView.xaml.cs
Normal file
28
Artemis/Artemis/Modules/Games/Terraria/TerrariaView.xaml.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Artemis.Modules.Games.Terraria
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for TerrariaView.xaml
|
||||
/// </summary>
|
||||
public partial class TerrariaView : UserControl
|
||||
{
|
||||
public TerrariaView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
47
Artemis/Artemis/Modules/Games/Terraria/TerrariaViewModel.cs
Normal file
47
Artemis/Artemis/Modules/Games/Terraria/TerrariaViewModel.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using Artemis.DAL;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities;
|
||||
using Ninject;
|
||||
|
||||
namespace Artemis.Modules.Games.Terraria
|
||||
{
|
||||
public sealed class TerrariaViewModel : ModuleViewModel
|
||||
{
|
||||
private string _versionText;
|
||||
|
||||
|
||||
public TerrariaViewModel(MainManager mainManager, [Named(nameof(TerrariaModel))] ModuleModel moduleModel, IKernel kernel) : base(mainManager, moduleModel, kernel)
|
||||
{
|
||||
DisplayName = "Terraria";
|
||||
SetVersionText();
|
||||
}
|
||||
|
||||
public override bool UsesProfileEditor => true;
|
||||
|
||||
public string VersionText
|
||||
{
|
||||
get { return _versionText; }
|
||||
set
|
||||
{
|
||||
if (value == _versionText) return;
|
||||
_versionText = value;
|
||||
NotifyOfPropertyChange(() => VersionText);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetVersionText()
|
||||
{
|
||||
if (!SettingsProvider.Load<GeneralSettings>().EnablePointersUpdate)
|
||||
{
|
||||
VersionText = "You disabled pointer updates, this could result in the Terraria module not working after a game update.";
|
||||
return;
|
||||
}
|
||||
|
||||
Updater.GetPointers();
|
||||
var version = SettingsProvider.Load<OffsetSettings>().Terraria?.GameVersion;
|
||||
VersionText = $"Requires patch {version}. When a new patch is released Artemis downloads new pointers for the latest version (unless disabled in settings).";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,7 @@ namespace Artemis.Settings
|
||||
{
|
||||
public GamePointersCollection RocketLeague { get; set; }
|
||||
public GamePointersCollection WorldOfWarcraft { get; set; }
|
||||
public GamePointersCollection Terraria { get; set; }
|
||||
|
||||
public void Save()
|
||||
{
|
||||
|
||||
@ -148,6 +148,8 @@ namespace Artemis.Utilities
|
||||
offsetSettings.RocketLeague = pointers.FirstOrDefault(p => p.Game == "RocketLeague");
|
||||
if (pointers.FirstOrDefault(p => p.Game == "WorldOfWarcraft") != null)
|
||||
offsetSettings.WorldOfWarcraft = pointers.FirstOrDefault(p => p.Game == "WorldOfWarcraft");
|
||||
if (pointers.FirstOrDefault(p => p.Game == "Terraria") != null)
|
||||
offsetSettings.Terraria = pointers.FirstOrDefault(p => p.Game == "Terraria");
|
||||
|
||||
offsetSettings.Save();
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<ProjectGuid>{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>LightFX2Artemis</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>LogiLed2Artemis</RootNamespace>
|
||||
<ProjectName>LogiLed2Artemis</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{39711909-C1D5-46CE-A9EA-2D561692EA47}</ProjectGuid>
|
||||
<RootNamespace>Razer2Artemis</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user