diff --git a/Ray2Mod.sln b/Ray2Mod.sln index f4588ef..ac4bbed 100644 --- a/Ray2Mod.sln +++ b/Ray2Mod.sln @@ -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 @@ -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} diff --git a/Ray2Mod/Properties/AssemblyInfo.cs b/Ray2Mod/Properties/AssemblyInfo.cs index b3c9e3c..30a1bc8 100644 --- a/Ray2Mod/Properties/AssemblyInfo.cs +++ b/Ray2Mod/Properties/AssemblyInfo.cs @@ -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")] diff --git a/samples/TextOverlays/Properties/AssemblyInfo.cs b/samples/TextOverlays/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d86d1da --- /dev/null +++ b/samples/TextOverlays/Properties/AssemblyInfo.cs @@ -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")] diff --git a/samples/TextOverlays/TextOverlays.cs b/samples/TextOverlays/TextOverlays.cs new file mode 100644 index 0000000..d3036d6 --- /dev/null +++ b/samples/TextOverlays/TextOverlays.cs @@ -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"); + } + } + } +} diff --git a/samples/TextOverlays/TextOverlays.csproj b/samples/TextOverlays/TextOverlays.csproj new file mode 100644 index 0000000..3ad4eb2 --- /dev/null +++ b/samples/TextOverlays/TextOverlays.csproj @@ -0,0 +1,57 @@ + + + + + Debug + AnyCPU + {0309FE7D-FC81-4AD8-BBBF-C10B37FD935C} + Library + Properties + TextOverlays + TextOverlays + v4.5.2 + 512 + true + + + true + ..\..\bin\Debug\samples\ + DEBUG;TRACE + full + x86 + 7.3 + prompt + MinimumRecommendedRules.ruleset + + + ..\..\bin\Release\samples\ + TRACE + true + pdbonly + x86 + 7.3 + prompt + MinimumRecommendedRules.ruleset + + + + + + + + + + + + + + + + + + {a88b3b19-48b3-4d6b-a217-8af81926be25} + Ray2Mod + + + + \ No newline at end of file