diff --git a/SDVWM_Example_Addon.sln b/SDVWM_Example_Addon.sln new file mode 100644 index 0000000..2e6574c --- /dev/null +++ b/SDVWM_Example_Addon.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDVWM_Example_Addon", "SDVWM_Example_Addon\SDVWM_Example_Addon.csproj", "{CF87A4D0-C6C0-4AB0-8C97-60F657E7973D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CF87A4D0-C6C0-4AB0-8C97-60F657E7973D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CF87A4D0-C6C0-4AB0-8C97-60F657E7973D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF87A4D0-C6C0-4AB0-8C97-60F657E7973D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CF87A4D0-C6C0-4AB0-8C97-60F657E7973D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AFD811B0-AF06-4A2F-B894-4BFD7E7D59BD} + EndGlobalSection +EndGlobal diff --git a/SDVWM_Example_Addon/Extension/Configuration.cs b/SDVWM_Example_Addon/Extension/Configuration.cs new file mode 100644 index 0000000..0c6c69e --- /dev/null +++ b/SDVWM_Example_Addon/Extension/Configuration.cs @@ -0,0 +1,17 @@ + +namespace SDVWM_Example_Addon.Extension +{ + class Configuration + { + /// + // Get Weather Data from Weather Machine + /// + + private string summary; + public string Weather_Summary + { + get { return summary; } + set { summary = value; } + } + } +} diff --git a/SDVWM_Example_Addon/Extension/Extension_Loader.cs b/SDVWM_Example_Addon/Extension/Extension_Loader.cs new file mode 100644 index 0000000..a653e0f --- /dev/null +++ b/SDVWM_Example_Addon/Extension/Extension_Loader.cs @@ -0,0 +1,70 @@ +using System.IO; +using System.Linq; + +namespace SDVWM_Example_Addon.Extension +{ + class Extension_Loader + { + Configuration config = new Configuration(); + + public bool Load_Configuration() + { + string APP_BASE = System.AppDomain.CurrentDomain.BaseDirectory; + + string APP = "StarDewValleyWeatherMachine"; // Name of the Master Application to get data from + string config_file = "SDVWM.ini"; + + string extension_folder = APP_BASE + "Mods" + "\\" + APP; + string config_directory = APP_BASE + "Mods" + "\\" + APP + "\\" + config_file; + + + //File.ReadAllText(filepath); + if (Directory.Exists(extension_folder)) + { + if (File.Exists(config_directory)) + { + return true; + } + + + } + + return false; + + } + + + public string Load_Weather_Summary() + { + string APP_BASE = System.AppDomain.CurrentDomain.BaseDirectory; + + string APP = "StarDewValleyWeatherMachine"; // Name of the Master Application to get data from + string config_file = "SDVWM.ini"; + + string extension_folder = APP_BASE + "Mods" + "\\" + APP; + string config_directory = APP_BASE + "Mods" + "\\" + APP + "\\" + config_file; + + string[] result; + + //File.ReadAllText(filepath); + if (Directory.Exists(extension_folder)) + { + if (File.Exists(config_directory)) + { + result = File.ReadLines(config_directory).ToArray(); + + config.Weather_Summary = result[0]; + + return config.Weather_Summary; + } + + + } + + return "No weather reported"; + + } + + + } +} diff --git a/SDVWM_Example_Addon/ModEntry.cs b/SDVWM_Example_Addon/ModEntry.cs new file mode 100644 index 0000000..5347aa3 --- /dev/null +++ b/SDVWM_Example_Addon/ModEntry.cs @@ -0,0 +1,69 @@ +using StardewModdingAPI; +using StardewModdingAPI.Events; +using SDVWM_Example_Addon.Extension; + +namespace SDVWM_Example_Addon +{ + + /// The mod entry point. + public class ModEntry : Mod + { + public static bool gamelaunched = false; + + // Base Configuration + Extension_Loader _Loader = new Extension_Loader(); // Load config from Master + + + /********* + ** Public methods + *********/ + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. + public override void Entry(IModHelper helper) + { + + /* Event Helpers */ + helper.Events.GameLoop.DayStarted += this.OnDayStarted; + helper.Events.GameLoop.GameLaunched += this.GameLaunched; + + } + + + /********* + ** Private methods + *********/ + /// Raised after the player presses a button on the keyboard, controller, or mouse. + /// The event sender. + /// The event data. + + private void GameLaunched(object sender, GameLaunchedEventArgs e) + { + /// ########################################### /// + /// Check if SDVWM is installed /// + /// ########################################## /// + + if (_Loader.Load_Configuration() == true) + { + this.Monitor.Log("Hello SDVWM!", LogLevel.Info); + } + + if (_Loader.Load_Configuration() == false) + { + this.Monitor.Log("Hello World, where is SDVWM?", LogLevel.Info); + } + + } + + private void OnDayStarted(object sender, DayStartedEventArgs e) + { + + // Display the weather summary from SDVWM.ini file whenever a new day starts. + this.Monitor.Log("It's currently: " + _Loader.Load_Weather_Summary(), LogLevel.Info); + + } + + } + + +} + diff --git a/SDVWM_Example_Addon/Properties/AssemblyInfo.cs b/SDVWM_Example_Addon/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..464e6b1 --- /dev/null +++ b/SDVWM_Example_Addon/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("SDVWM_Example_Addon")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SDVWM_Example_Addon")] +[assembly: AssemblyCopyright("Copyright © 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("cf87a4d0-c6c0-4ab0-8c97-60f657e7973d")] + +// 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/SDVWM_Example_Addon/SDVWM_Example_Addon.csproj b/SDVWM_Example_Addon/SDVWM_Example_Addon.csproj new file mode 100644 index 0000000..e8f6587 --- /dev/null +++ b/SDVWM_Example_Addon/SDVWM_Example_Addon.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {CF87A4D0-C6C0-4AB0-8C97-60F657E7973D} + Library + Properties + SDVWM_Example_Addon + SDVWM_Example_Addon + v4.7.2 + 512 + true + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/SDVWM_Example_Addon/manifest.json b/SDVWM_Example_Addon/manifest.json new file mode 100644 index 0000000..cd4eaa3 --- /dev/null +++ b/SDVWM_Example_Addon/manifest.json @@ -0,0 +1,10 @@ +{ + "Name": "SDVWM_Example_Addon", + "Author": "SixthTitan", + "Version": "1.0", + "Description": "Example Add-on Project for SDVWM", + "UniqueID": "SixthTitan.SDVWM_Example_Addon", + "EntryDll": "SDVWM_Example_Addon.dll", + "MinimumApiVersion": "2.9", + "UpdateKeys": [ "" ] +} diff --git a/SDVWM_Example_Addon/packages.config b/SDVWM_Example_Addon/packages.config new file mode 100644 index 0000000..19c0195 --- /dev/null +++ b/SDVWM_Example_Addon/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file