Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. internal static class Logger
  2. {
  3. private string prefix = "Plugin Prefix";
  4.  
  5. internal static void LogConsoleMessage(string message)
  6. {
  7. Game.DisplayNotification($"{prefix} {message}");
  8. }
  9. }
  10.  
  11.  
  12.  
  13. namespace PursuitDeterrence
  14. {
  15. /// <summary>
  16. /// Responsible for handling user defined settings.
  17. /// </summary>
  18. internal static class Config
  19. {
  20. private static InitializationFile ini;
  21.  
  22. //The file path for our config file.
  23. //If this is an LSPDFR plugin (which it is), then we must make sure that
  24. //the path is pointing into the lspdfr folder under the plugins directory.
  25.  
  26. /// <summary>
  27. /// Gets the desired key setting.
  28. /// </summary>
  29. internal static Keys KeySetting
  30. {
  31. get
  32. {
  33. Logger.LogConsoleMessage("GetKeySetting()");
  34.  
  35. //Here, we get our Key setting. If nothing is given, then the LSHIFTKEY will be set.
  36. return ini.ReadEnum<Keys>("Bindings", "KeyBoardKey", Keys.LShiftKey);
  37. }
  38. }
  39.  
  40. /// <summary>
  41. /// Gets the desired controller button setting.
  42. /// </summary>
  43. internal static ControllerButtons ControllerButtonSetting
  44. {
  45. get
  46. {
  47. Logger.LogConsoleMessage("GetControllerSetting()");
  48.  
  49. //Here, we get our Controller setting. If nothing is given, then the X button will be set.
  50. return ini.ReadEnum<ControllerButtons>("Bindings", "ControllerButton", ControllerButtons.X);
  51. }
  52. }
  53.  
  54. /// <summary>
  55. /// Gets whether the script is in debug mode.
  56. /// Not implemented yet.
  57. /// </summary>
  58. internal static bool IsInDebug
  59. {
  60. get
  61. {
  62. Logger.LogConsoleMessage("GetDebugEnabled()");
  63.  
  64. //A debug option.. used for developer mode.
  65. //Will print more messages to screen.
  66. return ini.ReadBoolean("Debug", "IsDebug", false);
  67. }
  68. }
  69.  
  70. /// <summary>
  71. /// Gets the % likeliness that the script will execute successfully.
  72. /// Overriden by the GUI version.
  73. /// </summary>
  74. internal static int Randomness
  75. {
  76. get
  77. {
  78. Logger.LogConsoleMessage("GetRandomness()");
  79.  
  80. // 1- 101 (100 %)
  81. return ini.ReadInt32("Randomness", "RandomChance", 25);
  82. }
  83. }
  84.  
  85. /// <summary>
  86. /// Gets whether the GUI version of the script is enabled.
  87. /// Overides the % version.
  88. /// </summary>
  89. internal static bool IsGuiEnabled
  90. {
  91. get
  92. {
  93. Logger.LogConsoleMessage("GetGuiEnabled()");
  94.  
  95. return ini.ReadBoolean("GUI", "Enabled", false);
  96. }
  97. }
  98.  
  99. //Setting up our config file.
  100. //Called in the Main class.
  101. internal static void SetupConfigFile(string fileLocation)
  102. {
  103. if (ini == null)
  104. {
  105. try
  106. {
  107. //Creating the ini file in the defined location.
  108. ini = new InitializationFile(fileLocation);
  109.  
  110. if (!ini.Exists())
  111. {
  112.  
  113. ini.Create();
  114. Logger.LogConsoleMessage($"INI generated in {fileLocation}.");
  115. }
  116.  
  117. else
  118. {
  119. Logger.LogConsoleMessage($"Error, INI already in {fileLocation}.");
  120. }
  121. }
  122.  
  123. catch (Exception ex)
  124. {
  125. Logger.LogConsoleMessage("Error generating INI! " + ex.ToString());
  126. }
  127. }
  128. }
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement