Skip to content

Commit

Permalink
Merge branch 'dev' into feature/discord
Browse files Browse the repository at this point in the history
  • Loading branch information
diogotr7 authored Dec 18, 2019
2 parents 55ec5b0 + 0bfee98 commit 60ff49f
Show file tree
Hide file tree
Showing 11 changed files with 427 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ public bool Initialize()
new CloneHero.CloneHero(),
new Osu.Osu(),
new Slime_Rancher.Slime_Rancher(),
new Discord.Discord()
new Terraria.Terraria(),
new Discord.Discord()
});

RegisterLayerHandlers(new List<LayerHandlerEntry> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<UserControl x:Class="Aurora.Profiles.Terraria.Control_Terraria"
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:Aurora.Settings"
xmlns:System="clr-namespace:System;assembly=mscorlib"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="850" Height="Auto" Width="Auto">

<Grid>
<TabControl>
<TabItem Header="Overview for Terraria">
<StackPanel Margin="10">
<CheckBox x:Name="GameEnabled" Content="Enable Aurora to provide lighting effects with Terraria. Ensure you have read the below text." Checked="GameEnabled_Checked" Unchecked="GameEnabled_Checked" />
<TextBlock HorizontalAlignment="Left" Margin="0,10" TextWrapping="Wrap" MaxWidth="824">
<Run Text="Support for Terraria requires a mod so that Aurora is able to fetch the variables from the game. This mod requires TModLoader." />
<Run Text="These mods are not authored by the main Aurora developers and any issues with these mods should not be directed at them, but posted on the relevant Github site for the mod." />
<Run Text="You can also install the mod through the in-game Mod Browser"/>
</TextBlock>
<Button Content="TModLoader download" HorizontalAlignment="Left" Margin="0,0,0,0" Padding="10,2" Click="GoToTModLoaderPage_Click" Width="224" />
<Button Content="Aurora GSI Mod for Terraria download" HorizontalAlignment="Left" Margin="0,5,0,0" Padding="10,2" Click="GoToModDownloadPage_Click" />
</StackPanel>
</TabItem>
</TabControl>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Aurora.Profiles.Terraria.GSI;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
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;
using Xceed.Wpf.Toolkit;

namespace Aurora.Profiles.Terraria {
public partial class Control_Terraria : UserControl
{
private Application profile;

public Control_Terraria(Application profile)
{
this.profile = profile;

InitializeComponent();
SetSettings();

profile.ProfileChanged += (sender, e) => SetSettings();
}

private void SetSettings()
{
GameEnabled.IsChecked = profile.Settings.IsEnabled;
}

private void GameEnabled_Checked(object sender, RoutedEventArgs e)
{
if (IsLoaded)
{
profile.Settings.IsEnabled = GameEnabled.IsChecked ?? false;
profile.SaveProfiles();
}
}

private void GoToTModLoaderPage_Click(object sender, RoutedEventArgs e)
{
Process.Start(@"https://tmodloader.net/");
}

private void GoToModDownloadPage_Click(object sender, RoutedEventArgs e)
{
Process.Start(@"https://github.com/diogotr7/AuroraGSI-Terraria/releases");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Aurora.Profiles.Terraria.GSI.Nodes;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aurora.Profiles.Terraria.GSI {
public class GameState_Terraria : GameState<GameState_Terraria> {
private ProviderNode _Provider;
private WorldNode _World;
private PlayerNode _Player;

public ProviderNode Provider => _Provider ?? (_Provider = new ProviderNode(_ParsedData["provider"]?.ToString() ?? ""));

public WorldNode World => _World ?? (_World = new WorldNode(_ParsedData["world"]?.ToString() ?? ""));

public PlayerNode Player => _Player ?? (_Player = new PlayerNode(_ParsedData["player"]?.ToString() ?? ""));

public GameState_Terraria() : base() { }

/// <summary>
/// Creates a GameState_Terraria instance based on the passed JSON data.
/// </summary>
/// <param name="JSONstring"></param>
public GameState_Terraria(string JSONstring) : base(JSONstring) { }

/// <summary>
/// Creates a GameState_Terraria instance based on the data from the passed GameState instance.
/// </summary>
public GameState_Terraria(IGameState other) : base(other) { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aurora.Profiles.Terraria.GSI.Nodes {
public enum TerrariaBiome
{
None = -1,
Forest = 0,
Beach = 1,
Jungle = 2,
Snow = 3,
Desert = 4
}

public enum TerrariaDepth
{
None = -1,
Underworld = 0,
Cavern = 1,
Underground = 2,
Overworld = 3,
Sky = 4
}

public class PlayerNode : Node<PlayerNode> {
public bool InGame;

#region Stats
public int Health;
public int MaxHealth;
public int Mana;
public int MaxMana;
public int Defense;
#endregion

#region Location
public int Depth;
public TerrariaDepth DepthLayer;
public int MaxDepth;
public TerrariaBiome Biome;
#endregion

#region Microbiomes
public bool InGlowshroom;
public bool InUndergroundDesert;
public bool InSandstorm;
public bool InMeteor;
public bool InDungeon;
#endregion

#region Local Events
public bool InTowerSolar;
public bool InTowerVortex;
public bool InTowerNebula;
public bool InTowerStardust;
public bool InOldOneArmy;
#endregion

#region Local Corruption Status
public bool InCorruption;
public bool InCrimson;
public bool InHalllow;
#endregion

internal PlayerNode(string json) : base(json)
{
InGame = GetBool("inGame");

Health = GetInt("health");
MaxHealth = GetInt("maxHealth");
Mana = GetInt("mana");
MaxMana = GetInt("maxMana");
Defense = GetInt("defense");

Depth = GetInt("depth");
DepthLayer = (TerrariaDepth)GetInt("depthLayer");
MaxDepth = GetInt("maxdepth");
Biome = (TerrariaBiome)GetInt("biome");

InGlowshroom = GetBool("zoneGlowshroom");
InUndergroundDesert = GetBool("zoneUndergroundDesert");
InSandstorm = GetBool("zoneSandstorm");
InMeteor = GetBool("zoneMeteor");
InDungeon = GetBool("zoneDungeon");

InTowerSolar = GetBool("zoneTowerSolar");
InTowerVortex = GetBool("zoneTowerVortex");
InTowerNebula = GetBool("zoneTowerNebula");
InTowerStardust = GetBool("zoneTowerStardust");
InOldOneArmy = GetBool("zoneOldOneArmy");

InCorruption = GetBool("zoneCorrupt");
InCrimson = GetBool("zoneCrimson");
InHalllow = GetBool("zoneHoly");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aurora.Profiles.Terraria.GSI.Nodes {
public class ProviderNode : Node<ProviderNode> {
public string Name;
public int AppID;

internal ProviderNode(string json) : base(json) {
Name = GetString("name");
AppID = GetInt("appid");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aurora.Profiles.Terraria.GSI.Nodes {
public enum TerrariaBoss
{
None = -1,
KingSlime = 0,
EyeOfCthulu = 1,
EaterOfWorlds = 2,
BrainOfCthulu = 3,
QueenBee = 4,
Skeletron = 5,
WallOfFlesh = 6,
Twins = 7,
Destroyer = 8,
SkeletronPrime = 9,
Plantera = 10,
Golem = 11,
DukeFishron = 12,
LunaticCultist = 13,
MoonLord = 14
}

public class WorldNode : Node<WorldNode> {
public double Time;
public bool Raining;
public bool HardMode;
public bool ExpertMode;
public bool Eclipse;
public bool BloodMoon;
public bool PumpkinMoon;
public bool SnowMoon;
public bool SlimeRain;
public TerrariaBoss Boss;

internal WorldNode(string json) : base(json) {
Eclipse = GetBool("eclipse");
HardMode = GetBool("hardMode");
ExpertMode = GetBool("expertMode");
Time = GetFloat("time");
BloodMoon = GetBool("bloodMoon");
PumpkinMoon = GetBool("pumpkinMoon");
SnowMoon = GetBool("snowMoon");
Raining = GetBool("raining");
SlimeRain = GetBool("slimeRain");
Boss = (TerrariaBoss)GetInt("boss");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aurora.Profiles.Terraria {
public class Terraria : Application {
public Terraria() : base(new LightEventConfig
{
Name = "Terraria",
ID = "terraria",
AppID = "105600",
ProcessNames = new[] { "Terraria.exe" },
ProfileType = typeof(TerrariaProfile),
OverviewControlType = typeof(Control_Terraria),
GameStateType = typeof(GSI.GameState_Terraria),
Event = new GameEvent_Generic(),
IconURI = "Resources/terraria_512x512.png"
})
{
}
}
}
Loading

0 comments on commit 60ff49f

Please sign in to comment.