Skip to content

Commit

Permalink
Add TextOverlays sample
Browse files Browse the repository at this point in the history
  • Loading branch information
spitfirex86 committed Apr 10, 2020
1 parent 67969d9 commit 38a6ec5
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 15 deletions.
21 changes: 7 additions & 14 deletions Ray2Mod.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,42 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HudIcons", "samples\HudIcon
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pointers", "samples\Pointers\Pointers.csproj", "{1C0A9FBF-4DBB-43EB-AF58-E03A2F4BD9A5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextOverlays", "samples\TextOverlays\TextOverlays.csproj", "{0309FE7D-FC81-4AD8-BBBF-C10B37FD935C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A88B3B19-48B3-4D6B-A217-8AF81926BE25}.Debug|Any CPU.ActiveCfg = Debug|x86
{A88B3B19-48B3-4D6B-A217-8AF81926BE25}.Debug|x86.ActiveCfg = Debug|x86
{A88B3B19-48B3-4D6B-A217-8AF81926BE25}.Debug|x86.Build.0 = Debug|x86
{A88B3B19-48B3-4D6B-A217-8AF81926BE25}.Release|Any CPU.ActiveCfg = Release|x86
{A88B3B19-48B3-4D6B-A217-8AF81926BE25}.Release|x86.ActiveCfg = Release|x86
{A88B3B19-48B3-4D6B-A217-8AF81926BE25}.Release|x86.Build.0 = Release|x86
{8466F3F6-880D-46E1-93BC-47E8B5C97195}.Debug|Any CPU.ActiveCfg = Debug|x86
{8466F3F6-880D-46E1-93BC-47E8B5C97195}.Debug|x86.ActiveCfg = Debug|x86
{8466F3F6-880D-46E1-93BC-47E8B5C97195}.Debug|x86.Build.0 = Debug|x86
{8466F3F6-880D-46E1-93BC-47E8B5C97195}.Release|Any CPU.ActiveCfg = Release|x86
{8466F3F6-880D-46E1-93BC-47E8B5C97195}.Release|x86.ActiveCfg = Release|x86
{8466F3F6-880D-46E1-93BC-47E8B5C97195}.Release|x86.Build.0 = Release|x86
{3F23F2BB-BF9A-4CA9-9A3C-14C1A74FF98A}.Debug|Any CPU.ActiveCfg = Debug|x86
{3F23F2BB-BF9A-4CA9-9A3C-14C1A74FF98A}.Debug|x86.ActiveCfg = Debug|x86
{3F23F2BB-BF9A-4CA9-9A3C-14C1A74FF98A}.Debug|x86.Build.0 = Debug|x86
{3F23F2BB-BF9A-4CA9-9A3C-14C1A74FF98A}.Release|Any CPU.ActiveCfg = Release|x86
{3F23F2BB-BF9A-4CA9-9A3C-14C1A74FF98A}.Release|x86.ActiveCfg = Release|x86
{3F23F2BB-BF9A-4CA9-9A3C-14C1A74FF98A}.Release|x86.Build.0 = Release|x86
{43B48BE4-5AAB-474D-AF04-2B794AF2AD8F}.Debug|Any CPU.ActiveCfg = Debug|x86
{43B48BE4-5AAB-474D-AF04-2B794AF2AD8F}.Debug|x86.ActiveCfg = Debug|x86
{43B48BE4-5AAB-474D-AF04-2B794AF2AD8F}.Debug|x86.Build.0 = Debug|x86
{43B48BE4-5AAB-474D-AF04-2B794AF2AD8F}.Release|Any CPU.ActiveCfg = Release|x86
{43B48BE4-5AAB-474D-AF04-2B794AF2AD8F}.Release|x86.ActiveCfg = Release|x86
{43B48BE4-5AAB-474D-AF04-2B794AF2AD8F}.Release|x86.Build.0 = Release|x86
{70BB4075-F09B-44B2-B61D-6599A3FC0FD3}.Debug|Any CPU.ActiveCfg = Debug|x86
{70BB4075-F09B-44B2-B61D-6599A3FC0FD3}.Debug|x86.ActiveCfg = Debug|x86
{70BB4075-F09B-44B2-B61D-6599A3FC0FD3}.Debug|x86.Build.0 = Debug|x86
{70BB4075-F09B-44B2-B61D-6599A3FC0FD3}.Release|Any CPU.ActiveCfg = Release|x86
{70BB4075-F09B-44B2-B61D-6599A3FC0FD3}.Release|x86.ActiveCfg = Release|x86
{70BB4075-F09B-44B2-B61D-6599A3FC0FD3}.Release|x86.Build.0 = Release|x86
{1C0A9FBF-4DBB-43EB-AF58-E03A2F4BD9A5}.Debug|Any CPU.ActiveCfg = Debug|x86
{1C0A9FBF-4DBB-43EB-AF58-E03A2F4BD9A5}.Debug|x86.ActiveCfg = Debug|x86
{1C0A9FBF-4DBB-43EB-AF58-E03A2F4BD9A5}.Debug|x86.Build.0 = Debug|x86
{1C0A9FBF-4DBB-43EB-AF58-E03A2F4BD9A5}.Release|Any CPU.ActiveCfg = Release|x86
{1C0A9FBF-4DBB-43EB-AF58-E03A2F4BD9A5}.Release|x86.ActiveCfg = Release|x86
{1C0A9FBF-4DBB-43EB-AF58-E03A2F4BD9A5}.Release|x86.Build.0 = Release|x86
{0309FE7D-FC81-4AD8-BBBF-C10B37FD935C}.Debug|x86.ActiveCfg = Debug|x86
{0309FE7D-FC81-4AD8-BBBF-C10B37FD935C}.Debug|x86.Build.0 = Debug|x86
{0309FE7D-FC81-4AD8-BBBF-C10B37FD935C}.Release|x86.ActiveCfg = Release|x86
{0309FE7D-FC81-4AD8-BBBF-C10B37FD935C}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -69,6 +61,7 @@ Global
{43B48BE4-5AAB-474D-AF04-2B794AF2AD8F} = {A3995D66-9136-47E7-B180-22E419532C5E}
{70BB4075-F09B-44B2-B61D-6599A3FC0FD3} = {A3995D66-9136-47E7-B180-22E419532C5E}
{1C0A9FBF-4DBB-43EB-AF58-E03A2F4BD9A5} = {A3995D66-9136-47E7-B180-22E419532C5E}
{0309FE7D-FC81-4AD8-BBBF-C10B37FD935C} = {A3995D66-9136-47E7-B180-22E419532C5E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6F5E3E32-BBC8-41B0-B0BB-E41DD6097B39}
Expand Down
2 changes: 1 addition & 1 deletion Ray2Mod/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.31.0")]
[assembly: AssemblyFileVersion("1.4.32.0")]
36 changes: 36 additions & 0 deletions samples/TextOverlays/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TextOverlays")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TextOverlays")]
[assembly: AssemblyCopyright("Copyright © RayTools 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("0309fe7d-fc81-4ad8-bbbf-c10b37fd935c")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
67 changes: 67 additions & 0 deletions samples/TextOverlays/TextOverlays.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using Ray2Mod;
using Ray2Mod.Components.Text;

namespace TextOverlays
{
public class TextOverlays : IMod
{
private RemoteInterface Interface { get; set; }

public void Run(RemoteInterface remoteInterface)
{
Interface = remoteInterface;

// Regular, static text.
// The X and Y values are coordinates on the screen space, mapped to a 1000x1000 area.
TextOverlay plain = new TextOverlay("Regular text", 10, 5 ,5).Show();

// Dynamically updating text.
// The delegate TextOverlay.UpdateText is evaluated on every frame (if assigned).
// It can be assigned instead of text in the constructor, or later at any point.
int frames = 0;
TextOverlay counter = new TextOverlay((previousText) =>
{
string newText = $"Frame counter={frames}";
frames++;
return newText;
}, 10, 5 ,35).Show();

// Previous text is passed to the UpdateText method as a parameter.
// This example appends 1 dot to the text every 10 frames, up to a total of 20.
// It also uses the frame counter from the previous example.
int dots = 0;
TextOverlay append = new TextOverlay("Some dots", 10, 5, 65).Show();
append.UpdateText = (text) =>
{
if (frames % 10 == 0 && dots < 20)
{
text += '.';
dots++;
}
return text;
};

// The delegate TextOverlay.UpdateProperties can be used for advanced text manipulation.
// It is evaluated on every frame, after UpdateText.
// The TextOverlay object itself is passed as a parameter.
// This lets you reuse functions and delegates for multiple text objects.
plain.UpdateProperties = MoveTextOffscreen;
}

// This example will move the text object to the right
// and hide it once it's no longer visible on screen.
private void MoveTextOffscreen(TextOverlay overlay)
{
overlay.X += 3;
Interface.Log($"Text overlay visible at X:{overlay.X}");
if (overlay.X > 1000)
{
// Note: While the text overlay is hidden, both UpdateText and UpdateProperties
// are _not_ evaluated - notice the "Text overlay visible" messages
// are no longer sent after calling Hide().
overlay.Hide();
Interface.Log($"Text overlay hidden");
}
}
}
}
57 changes: 57 additions & 0 deletions samples/TextOverlays/TextOverlays.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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>{0309FE7D-FC81-4AD8-BBBF-C10B37FD935C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TextOverlays</RootNamespace>
<AssemblyName>TextOverlays</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\bin\Debug\samples\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>..\..\bin\Release\samples\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="TextOverlays.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Ray2Mod\Ray2Mod.csproj">
<Project>{a88b3b19-48b3-4d6b-a217-8af81926be25}</Project>
<Name>Ray2Mod</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit 38a6ec5

Please sign in to comment.