mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Merge branch 'development' of https://github.com/SpoinkyNL/Artemis.git
This commit is contained in:
commit
52d30353de
@ -379,6 +379,7 @@
|
|||||||
<DependentUpon>GtaVView.xaml</DependentUpon>
|
<DependentUpon>GtaVView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Modules\Games\GtaV\GtaVViewModel.cs" />
|
<Compile Include="Modules\Games\GtaV\GtaVViewModel.cs" />
|
||||||
|
<Compile Include="Modules\Games\LightFx\Data\LightFxState.cs" />
|
||||||
<Compile Include="Modules\Games\LightFx\LightFxDataModel.cs" />
|
<Compile Include="Modules\Games\LightFx\LightFxDataModel.cs" />
|
||||||
<Compile Include="Modules\Games\LightFx\LightFxModel.cs" />
|
<Compile Include="Modules\Games\LightFx\LightFxModel.cs" />
|
||||||
<Compile Include="Modules\Games\LightFx\LightFxSettings.cs" />
|
<Compile Include="Modules\Games\LightFx\LightFxSettings.cs" />
|
||||||
|
|||||||
40
Artemis/Artemis/Modules/Games/LightFx/Data/LightFxState.cs
Normal file
40
Artemis/Artemis/Modules/Games/LightFx/Data/LightFxState.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
|
namespace Artemis.Modules.Games.LightFx.Data
|
||||||
|
{
|
||||||
|
[MoonSharpUserData]
|
||||||
|
public class LightFxState
|
||||||
|
{
|
||||||
|
public Device[] devices { get; set; }
|
||||||
|
public string game { get; set; }
|
||||||
|
public Mask mask { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[MoonSharpUserData]
|
||||||
|
public class Device
|
||||||
|
{
|
||||||
|
public Light[] lights { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[MoonSharpUserData]
|
||||||
|
public class Mask
|
||||||
|
{
|
||||||
|
public Light light { get; set; }
|
||||||
|
public int location { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[MoonSharpUserData]
|
||||||
|
public class Light
|
||||||
|
{
|
||||||
|
public Color color { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[MoonSharpUserData]
|
||||||
|
public class Color
|
||||||
|
{
|
||||||
|
public int brightness { get; set; }
|
||||||
|
public int red { get; set; }
|
||||||
|
public int green { get; set; }
|
||||||
|
public int blue { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,15 +1,19 @@
|
|||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
|
using Artemis.Modules.Games.LightFx.Data;
|
||||||
using MoonSharp.Interpreter;
|
using MoonSharp.Interpreter;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Artemis.Modules.Games.LightFx
|
namespace Artemis.Modules.Games.LightFx
|
||||||
{
|
{
|
||||||
[MoonSharpUserData]
|
[MoonSharpUserData]
|
||||||
public class LightFxDataModel : IDataModel
|
public class LightFxDataModel : IDataModel
|
||||||
{
|
{
|
||||||
|
[JsonProperty(PropertyName = "lightFxState")]
|
||||||
|
public LightFxState LightFxState { get; set; }
|
||||||
|
|
||||||
public LightFxDataModel()
|
public LightFxDataModel()
|
||||||
{
|
{
|
||||||
|
LightFxState = new LightFxState();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,16 +1,19 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using Artemis.DAL;
|
using Artemis.DAL;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
|
using Artemis.Utilities.DataReaders;
|
||||||
using Artemis.Utilities.GameState;
|
using Artemis.Utilities.GameState;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Artemis.Modules.Games.LightFx
|
namespace Artemis.Modules.Games.LightFx
|
||||||
{
|
{
|
||||||
public class LightFxModel : GameModel
|
public class LightFxModel : GameModel
|
||||||
{
|
{
|
||||||
public LightFxModel(DeviceManager deviceManager, GameStateWebServer gameStateWebServer)
|
public LightFxModel(DeviceManager deviceManager, PipeServer pipeServer)
|
||||||
: base(deviceManager, SettingsProvider.Load<LightFxSettings>(), new LightFxDataModel())
|
: base(deviceManager, SettingsProvider.Load<LightFxSettings>(), new LightFxDataModel())
|
||||||
{
|
{
|
||||||
Name = "LightFX";
|
Name = "LightFX";
|
||||||
@ -20,20 +23,28 @@ namespace Artemis.Modules.Games.LightFx
|
|||||||
Initialized = false;
|
Initialized = false;
|
||||||
|
|
||||||
// This model can enable itself by changing its process name to the currently running Light FX game.
|
// This model can enable itself by changing its process name to the currently running Light FX game.
|
||||||
gameStateWebServer.GameDataReceived += GameStateWebServerOnGameDataReceived;
|
pipeServer.PipeMessage += PipeServerOnPipeMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GameStateWebServerOnGameDataReceived(object sender, GameDataReceivedEventArgs e)
|
private void PipeServerOnPipeMessage(string msg)
|
||||||
{
|
{
|
||||||
var jsonString = e.Json.ToString();
|
|
||||||
// Ensure it's Light FX JSON
|
// Ensure it's Light FX JSON
|
||||||
if (!jsonString.Contains("lightFxState"))
|
if (!msg.Contains("lightFxState"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Deserialize and data
|
// Deserialize and data
|
||||||
|
try
|
||||||
|
{
|
||||||
|
JsonConvert.PopulateObject(msg, DataModel);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger?.Error(ex, "Failed to deserialize LightFX JSON");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup process name
|
// Setup process name
|
||||||
|
ProcessName = Path.GetFileNameWithoutExtension(((LightFxDataModel)DataModel).LightFxState.game);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
|
|||||||
@ -20,14 +20,11 @@ LightFxState::~LightFxState()
|
|||||||
|
|
||||||
json LightFxState::GetJson()
|
json LightFxState::GetJson()
|
||||||
{
|
{
|
||||||
json root;
|
|
||||||
json j;
|
json j;
|
||||||
root["lightFxState"] = { j };
|
|
||||||
|
|
||||||
j["game"] = Game;
|
j["game"] = Game;
|
||||||
j["mask"] = {
|
j["mask"] = {
|
||||||
{ "location", LocationMask },
|
{"location", LocationMask},
|
||||||
{ "light", LocationMaskLight->GetJson() }
|
{"light", LocationMaskLight->GetJson()}
|
||||||
};
|
};
|
||||||
j["devices"] = {};
|
j["devices"] = {};
|
||||||
for (LightFxDevice* device : Devices)
|
for (LightFxDevice* device : Devices)
|
||||||
@ -35,5 +32,5 @@ json LightFxState::GetJson()
|
|||||||
j["devices"].push_back(device->GetJson());
|
j["devices"].push_back(device->GetJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
return j;
|
return json{{"lightFxState", j}};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,7 +81,7 @@ FN_DECLSPEC LFX_RESULT STDCALL LFX_Update()
|
|||||||
|
|
||||||
// Only bother dumping it indented if actually debugging
|
// Only bother dumping it indented if actually debugging
|
||||||
if (FILELog::ReportingLevel() == logDEBUG1)
|
if (FILELog::ReportingLevel() == logDEBUG1)
|
||||||
FILE_LOG(logDEBUG1) << "JSON: " << j.dump(4);
|
FILE_LOG(logDEBUG1) << "JSON: " << j.dump(4);
|
||||||
|
|
||||||
return LFX_SUCCESS;
|
return LFX_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user