Skip to content

Commit

Permalink
Merge branch 'development' into prerelease-into-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsnider committed Oct 14, 2020
2 parents 47c539b + 44e4a5f commit 36a1830
Show file tree
Hide file tree
Showing 239 changed files with 9,531 additions and 1,678 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
141 changes: 141 additions & 0 deletions Examples/Intersect.Examples.ClientPlugin/ExampleClientPluginEntry.cs
@@ -0,0 +1,141 @@
using Intersect.Client.Framework.Content;
using Intersect.Client.Framework.Graphics;
using Intersect.Client.Framework.Gwen;
using Intersect.Client.Framework.Gwen.Control;
using Intersect.Client.Plugins;
using Intersect.Client.Plugins.Interfaces;
using Intersect.Plugins;
using JetBrains.Annotations;
using Microsoft;
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Intersect.Client.General;
using Intersect.Client.Interface;

namespace Intersect.Examples.ClientPlugin
{
/// <summary>
/// Demonstrates basic plugin functionality for the client.
/// </summary>
[SuppressMessage("Globalization", "CA1303:Do not pass literals as localized parameters")]
public class ExampleClientPluginEntry : ClientPluginEntry
{
private bool mDisposed;
[UsedImplicitly] private Mutex mMutex;

private GameTexture mButtonTexture;

/// <inheritdoc />
public override void OnBootstrap([NotNull, ValidatedNotNull] IPluginBootstrapContext context)
{
context.Logging.Application.Info(
$@"{nameof(ExampleClientPluginEntry)}.{nameof(OnBootstrap)} writing to the application log!");

context.Logging.Plugin.Info(
$@"{nameof(ExampleClientPluginEntry)}.{nameof(OnBootstrap)} writing to the plugin log!");

mMutex = new Mutex(true, "testplugin", out var createdNew);
if (!createdNew)
{
Environment.Exit(-1);
}

var exampleCommandLineOptions = context.CommandLine.ParseArguments<ExampleCommandLineOptions>();
if (!exampleCommandLineOptions.ExampleFlag)
{
context.Logging.Plugin.Warn("Client wasn't started with the start-up flag!");
}

context.Logging.Plugin.Info(
$@"{nameof(exampleCommandLineOptions.ExampleVariable)} = {exampleCommandLineOptions.ExampleVariable}");
}

/// <inheritdoc />
public override void OnStart([NotNull, ValidatedNotNull] IClientPluginContext context)
{
context.Logging.Application.Info(
$@"{nameof(ExampleClientPluginEntry)}.{nameof(OnStart)} writing to the application log!");

context.Logging.Plugin.Info(
$@"{nameof(ExampleClientPluginEntry)}.{nameof(OnStart)} writing to the plugin log!");

mButtonTexture = context.ContentManager.LoadEmbedded<GameTexture>(
context, ContentTypes.Interface, "Assets/join-our-discord.png");

context.Lifecycle.LifecycleChangeState += HandleLifecycleChangeState;
}

/// <inheritdoc />
public override void OnStop([NotNull, ValidatedNotNull] IClientPluginContext context)
{
context.Logging.Application.Info(
$@"{nameof(ExampleClientPluginEntry)}.{nameof(OnStop)} writing to the application log!");

context.Logging.Plugin.Info(
$@"{nameof(ExampleClientPluginEntry)}.{nameof(OnStop)} writing to the plugin log!");
}

private void HandleLifecycleChangeState([NotNull, ValidatedNotNull] IClientPluginContext context,
[NotNull, ValidatedNotNull] LifecycleChangeStateArgs lifecycleChangeStateArgs)
{
Debug.Assert(mButtonTexture != null, nameof(mButtonTexture) + " != null");

var activeInterface = context.Lifecycle.Interface;
if (activeInterface == null)
{
return;
}

switch (lifecycleChangeStateArgs.State)
{
case GameStates.Menu:
AddButtonToMainMenu(context, activeInterface);
break;
}
}

private void AddButtonToMainMenu([NotNull, ValidatedNotNull] IClientPluginContext context,
[NotNull, ValidatedNotNull] IMutableInterface activeInterface)
{
var button = activeInterface.Create<Button>("DiscordButton");
Debug.Assert(button != null, nameof(button) + " != null");

var discordInviteUrl = context.GetTypedConfiguration<ExamplePluginConfiguration>()?.DiscordInviteUrl;
button.Clicked += (sender, args) =>
{
if (string.IsNullOrWhiteSpace(discordInviteUrl))
{
context.Logging.Plugin.Error($@"DiscordInviteUrl configuration property is null/empty/whitespace.");
return;
}
Process.Start(discordInviteUrl);
};

button.SetImage(mButtonTexture, mButtonTexture.Name, Button.ControlState.Normal);
button.SetSize(mButtonTexture.GetWidth(), mButtonTexture.GetHeight());
button.CurAlignments?.Add(Alignments.Bottom);
button.CurAlignments?.Add(Alignments.Right);
button.ProcessAlignments();
}

protected override void Dispose(bool disposing)
{
base.Dispose(true);

if (mDisposed)
{
return;
}

if (disposing)
{
mMutex.Dispose();
}

mDisposed = true;
}
}
}
@@ -0,0 +1,48 @@
using CommandLine;

using Intersect.Utilities;

using JetBrains.Annotations;

using System;

namespace Intersect.Examples.ClientPlugin
{
/// <summary>
/// Example immutable command line options structure.
/// </summary>
public struct ExampleCommandLineOptions : IEquatable<ExampleCommandLineOptions>
{
[UsedImplicitly]
public ExampleCommandLineOptions(bool exampleFlag, int exampleVariable)
{
ExampleFlag = exampleFlag;
ExampleVariable = exampleVariable;
}

/// <summary>
/// Flag that is true if the application was started with --example-flag
/// </summary>
[Option("example-flag", Default = false, Required = false)]
public bool ExampleFlag { get; }

/// <summary>
/// Integer argument that corresponds to --example-variable
/// </summary>
[Option("example-variable", Default = 100, Required = false)]
public int ExampleVariable { get; }

public override bool Equals(object obj) => obj is ExampleCommandLineOptions other && Equals(other);

public override int GetHashCode() => ValueUtils.ComputeHashCode(ExampleFlag, ExampleVariable);

public static bool operator ==(ExampleCommandLineOptions left, ExampleCommandLineOptions right) =>
left.Equals(right);

public static bool operator !=(ExampleCommandLineOptions left, ExampleCommandLineOptions right) =>
!(left == right);

public bool Equals(ExampleCommandLineOptions other) =>
ExampleFlag == other.ExampleFlag && ExampleVariable == other.ExampleVariable;
}
}
@@ -0,0 +1,22 @@
using Intersect.Plugins;

using Newtonsoft.Json;

namespace Intersect.Examples.ClientPlugin
{

/// <summary>
/// Example configuration class for a plugin.
/// </summary>
internal class ExamplePluginConfiguration : PluginConfiguration
{

/// <summary>
/// Link to discord invite that should open when discord button is clicked
/// </summary>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string DiscordInviteUrl { get; set; } = "https://discord.gg/fAwDR5v";

}

}
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" />
<Import Project="..\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props')" />
<Import Project="..\packages\Microsoft.NetCore.Analyzers.3.0.0\build\Microsoft.NetCore.Analyzers.props" Condition="Exists('..\packages\Microsoft.NetCore.Analyzers.3.0.0\build\Microsoft.NetCore.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeQuality.Analyzers.3.0.0\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeQuality.Analyzers.3.0.0\build\Microsoft.CodeQuality.Analyzers.props')" />
<Import Project="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4208A6E4-D72C-4E8C-88EE-61F939777062}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Intersect.Examples.ClientPlugin</RootNamespace>
<AssemblyName>Intersect.Examples.ClientPlugin</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>false</RunCodeAnalysis>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
<ItemGroup>
<Reference Include="Ceras, Version=4.0.40.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Ceras.4.0.40\lib\net45\Ceras.dll</HintPath>
</Reference>
<Reference Include="CommandLine, Version=2.7.82.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.2.7.82\lib\net461\CommandLine.dll</HintPath>
</Reference>
<Reference Include="Intersect Client Framework, Version=0.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\AscensionGameDev.Intersect.Client.Framework.0.7.0.3-beta\lib\net461\Intersect Client Framework.dll</HintPath>
</Reference>
<Reference Include="Intersect Core, Version=0.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\AscensionGameDev.Intersect.Client.Framework.0.7.0.3-beta\lib\net461\Intersect Core.dll</HintPath>
</Reference>
<Reference Include="JetBrains.Annotations, Version=2020.1.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
<HintPath>..\packages\JetBrains.Annotations.2020.1.0\lib\net20\JetBrains.Annotations.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Validation, Version=15.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Validation.15.5.31\lib\netstandard2.0\Microsoft.VisualStudio.Validation.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Semver, Version=2.0.6.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Semver.2.0.6\lib\net452\Semver.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ExampleClientPluginEntry.cs" />
<Compile Include="ExampleCommandLineOptions.cs" />
<Compile Include="ExamplePluginConfiguration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Manifest.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Assets\join-our-discord.png" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.VersionCheckAnalyzer.resources.dll" />
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\analyzers\dotnet\Microsoft.CodeAnalysis.VersionCheckAnalyzer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.3.0.0\analyzers\dotnet\cs\Humanizer.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeQuality.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.NetCore.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetCore.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.NetCore.CSharp.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.NetFramework.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.3.0.0\analyzers\dotnet\cs\Microsoft.NetFramework.CSharp.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.VersionCheckAnalyzer.3.0.0\build\Microsoft.CodeAnalysis.VersionCheckAnalyzer.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeQuality.Analyzers.3.0.0\build\Microsoft.CodeQuality.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeQuality.Analyzers.3.0.0\build\Microsoft.CodeQuality.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetCore.Analyzers.3.0.0\build\Microsoft.NetCore.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetCore.Analyzers.3.0.0\build\Microsoft.NetCore.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NetFramework.Analyzers.3.0.0\build\Microsoft.NetFramework.Analyzers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.FxCopAnalyzers.3.0.0\build\Microsoft.CodeAnalysis.FxCopAnalyzers.props'))" />
<Error Condition="!Exists('..\packages\AscensionGameDev.Intersect.Client.Framework.0.7.0.3-beta\build\AscensionGameDev.Intersect.Client.Framework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\AscensionGameDev.Intersect.Client.Framework.0.7.0.3-beta\build\AscensionGameDev.Intersect.Client.Framework.targets'))" />
</Target>
<Import Project="..\packages\AscensionGameDev.Intersect.Client.Framework.0.7.0.3-beta\build\AscensionGameDev.Intersect.Client.Framework.targets" Condition="Exists('..\packages\AscensionGameDev.Intersect.Client.Framework.0.7.0.3-beta\build\AscensionGameDev.Intersect.Client.Framework.targets')" />
</Project>

0 comments on commit 36a1830

Please sign in to comment.