-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67969d9
commit 38a6ec5
Showing
5 changed files
with
168 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |