Advertisement
sewer56lol

Reloaded Drawing Example

Apr 24th, 2018
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.20 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3. using System.Drawing;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using Reloaded;
  7. using Reloaded.Overlay;
  8. using Reloaded.Overlay.External;
  9. using Reloaded.Process;
  10. using SharpDX.Direct2D1;
  11. using SharpDX.DirectWrite;
  12. using SharpDX.DXGI;
  13. using SharpDX.Mathematics.Interop;
  14. using Font = System.Drawing.Font;
  15. using FontStyle = SharpDX.DirectWrite.FontStyle;
  16.  
  17. namespace Reloaded_Mod_Template
  18. {
  19. public static class Program
  20. {
  21. /*
  22. * Reloaded Mod Loader DLL Modification Template
  23. * Sewer56, 2018 ©
  24. *
  25. * -------------------------------------------------------------------------------
  26. *
  27. * Here starts your own mod loader DLL code.
  28. *
  29. * The Init function below is ran at the initialization stage of the game.
  30. *
  31. * The game at this point suspended and frozen in memory. There is no execution
  32. * of game code currently ongoing.
  33. *
  34. * This is where you do your hot-patches such as graphics stuff, patching the
  35. * window style of the game to borderless, setting up your initial variables, etc.
  36. *
  37. * -------------------------------------------------------------------------------
  38. *
  39. * Important Note:
  40. *
  41. * This function is executed once during startup and SHOULD return as the
  42. * mod loader awaits successful completion of the main function.
  43. *
  44. * If you want your mod/code to sit running in the background, please initialize
  45. * another thread and run your code in the background on that thread, otherwise
  46. * please remember to return from the function.
  47. *
  48. * There is also some extra code, including DLL stubs for Reloaded, classes
  49. * to interact with the Mod Loader Server as well as other various loader related
  50. * utilities available.
  51. *
  52. * -------------------------------------------------------------------------------
  53. *
  54. * Brief Walkthrough:
  55. *
  56. * > Reloaded/Initializer.cs
  57. * Stores Reloaded Mod Loader DLL Template/Initialization Code.
  58. * You are not required/should not (need) to modify any of the code.
  59. *
  60. * > Reloaded/Client.cs
  61. * Contains various pieces of code to interact with the mod loader server.
  62. *
  63. * For convenience it's recommended you import Client static(ally) into your
  64. * classes by doing it as such `Reloaded_Mod_Template.Reloaded_Code.Client`.
  65. *
  66. * This will avoid you typing the full class name and let you simply type
  67. * e.g. Print("SomeTextToConsole").
  68. *
  69. * Reloaded Wiki:
  70. * <TBA>
  71. *
  72. * -------------------------------------------------------------------------------
  73. *
  74. * If you like Reloaded, please consider giving a helping hand. This has been
  75. * my sole project taking up most of my free time for months. Being the programmer,
  76. * artist, tester, quality assurance, alongside various other roles is pretty hard
  77. * and time consuming, not to mention that I am doing all of this for free.
  78. *
  79. * Well, alas, see you when Reloaded releases.
  80. *
  81. * Please keep this notice here for future contributors or interested parties.
  82. * If it bothers you, consider wrapping it in a #region.
  83. */
  84.  
  85. /*
  86. Default Variables:
  87. These variables are automatically assigned by the mod template, you do not
  88. need to assign those manually.
  89. */
  90.  
  91. /// <summary>
  92. /// Holds the game process for us to manipulate.
  93. /// Allows you to read/write memory, perform pattern scans, etc.
  94. /// See libReloaded/GameProcess (folder)
  95. /// </summary>
  96. public static ReloadedProcess GameProcess;
  97.  
  98. /// <summary>
  99. /// Specifies the full directory location that the current mod
  100. /// is contained in.
  101. /// </summary>
  102. public static string ModDirectory;
  103.  
  104. /// <summary>
  105. /// Your own user code starts here.
  106. /// If this is your first time, do consider reading the notice above.
  107. /// It contains some very useful information.
  108. /// </summary>
  109. public static async void Init()
  110. {
  111. externalWindowOverlay = await ExternalWindowOverlay.CreateExternalWindowOverlay(CustomRenderDelegate);
  112. }
  113.  
  114. public static ExternalWindowOverlay externalWindowOverlay;
  115.  
  116. private static void CustomRenderDelegate(WindowRenderTarget direct2DWindowTarget)
  117. {
  118. TextFormat textFormat = new TextFormat(new SharpDX.DirectWrite.Factory(), "Times New Roman", FontWeight.ExtraBold, FontStyle.Normal, 36);
  119. textFormat.TextAlignment = TextAlignment.Center;
  120.  
  121. direct2DWindowTarget.DrawText("Drawing Test", textFormat, new RawRectangleF(300, 300, 600, 600),
  122. new SolidColorBrush(direct2DWindowTarget, new RawColor4(0.3F, 0.7F, 0.5F, 1F)));
  123. }
  124. }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement