diff --git a/AssettoServer.sln b/AssettoServer.sln index cac89acb..6b756c46 100644 --- a/AssettoServer.sln +++ b/AssettoServer.sln @@ -1,39 +1,41 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30420.98 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34701.34 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssettoServer", "AssettoServer\AssettoServer.csproj", "{7FDA59D8-BF5B-4B50-8F61-37611D087D24}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssettoServer", "AssettoServer\AssettoServer.csproj", "{7FDA59D8-BF5B-4B50-8F61-37611D087D24}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscordAuditPlugin", "DiscordAuditPlugin\DiscordAuditPlugin.csproj", "{9C7F1530-DF2D-41D4-A6F1-857955106869}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscordAuditPlugin", "DiscordAuditPlugin\DiscordAuditPlugin.csproj", "{9C7F1530-DF2D-41D4-A6F1-857955106869}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamplePlugin", "SamplePlugin\SamplePlugin.csproj", "{DAF372D3-E030-4911-8537-A55325B4F6B5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SamplePlugin", "SamplePlugin\SamplePlugin.csproj", "{DAF372D3-E030-4911-8537-A55325B4F6B5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VotingWeatherPlugin", "VotingWeatherPlugin\VotingWeatherPlugin.csproj", "{1C5C55F2-C818-4277-9DBE-0EAFF35F59AA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VotingWeatherPlugin", "VotingWeatherPlugin\VotingWeatherPlugin.csproj", "{1C5C55F2-C818-4277-9DBE-0EAFF35F59AA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveWeatherPlugin", "LiveWeatherPlugin\LiveWeatherPlugin.csproj", "{02FEF3DC-BCEC-4888-9B4E-BDE31DD6E58D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LiveWeatherPlugin", "LiveWeatherPlugin\LiveWeatherPlugin.csproj", "{02FEF3DC-BCEC-4888-9B4E-BDE31DD6E58D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WordFilterPlugin", "WordFilterPlugin\WordFilterPlugin.csproj", "{C16217E0-D82B-43EF-A5E0-836ED135AA8C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WordFilterPlugin", "WordFilterPlugin\WordFilterPlugin.csproj", "{C16217E0-D82B-43EF-A5E0-836ED135AA8C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RaceChallengePlugin", "RaceChallengePlugin\RaceChallengePlugin.csproj", "{2F522CD8-2890-4E00-97DB-4E2E1B407677}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RaceChallengePlugin", "RaceChallengePlugin\RaceChallengePlugin.csproj", "{2F522CD8-2890-4E00-97DB-4E2E1B407677}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeoIPPlugin", "GeoIPPlugin\GeoIPPlugin.csproj", "{F0F4ECA0-24FA-4913-92CB-B48A0DD129F3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeoIPPlugin", "GeoIPPlugin\GeoIPPlugin.csproj", "{F0F4ECA0-24FA-4913-92CB-B48A0DD129F3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportPlugin", "ReportPlugin\ReportPlugin.csproj", "{AF514EA8-5FC5-4A1B-9065-EC0AD34639B1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReportPlugin", "ReportPlugin\ReportPlugin.csproj", "{AF514EA8-5FC5-4A1B-9065-EC0AD34639B1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastLaneUtils", "FastLaneUtils\FastLaneUtils.csproj", "{12A71A2F-CB26-4452-8B24-D3DA2A32466E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastLaneUtils", "FastLaneUtils\FastLaneUtils.csproj", "{12A71A2F-CB26-4452-8B24-D3DA2A32466E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimeDilationPlugin", "TimeDilationPlugin\TimeDilationPlugin.csproj", "{F479976E-7BB0-49EB-A97E-5389C0601D91}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TimeDilationPlugin", "TimeDilationPlugin\TimeDilationPlugin.csproj", "{F479976E-7BB0-49EB-A97E-5389C0601D91}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoModerationPlugin", "AutoModerationPlugin\AutoModerationPlugin.csproj", "{59C320A4-11D8-4BAE-81F1-226D012F5484}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoModerationPlugin", "AutoModerationPlugin\AutoModerationPlugin.csproj", "{59C320A4-11D8-4BAE-81F1-226D012F5484}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RandomWeatherPlugin", "RandomWeatherPlugin\RandomWeatherPlugin.csproj", "{7289448F-D8EF-4EB7-AFE3-4EDB27EE75E0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RandomWeatherPlugin", "RandomWeatherPlugin\RandomWeatherPlugin.csproj", "{7289448F-D8EF-4EB7-AFE3-4EDB27EE75E0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssettoServer.Shared", "AssettoServer.Shared\AssettoServer.Shared.csproj", "{C7A903BD-6640-460A-BDD1-DFF6FC407E31}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssettoServer.Shared", "AssettoServer.Shared\AssettoServer.Shared.csproj", "{C7A903BD-6640-460A-BDD1-DFF6FC407E31}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssettoServer.Tests", "AssettoServer.Tests\AssettoServer.Tests.csproj", "{DA97DFBB-EA56-468C-BEDE-7CBEB360DD0E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssettoServer.Tests", "AssettoServer.Tests\AssettoServer.Tests.csproj", "{DA97DFBB-EA56-468C-BEDE-7CBEB360DD0E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VotingPresetPlugin", "VotingPresetPlugin\VotingPresetPlugin.csproj", "{458FEEA8-D472-4FA9-8E50-63F04F05180A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VotingPresetPlugin", "VotingPresetPlugin\VotingPresetPlugin.csproj", "{458FEEA8-D472-4FA9-8E50-63F04F05180A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChangeWeatherPlugin", "ChangeWeatherPlugin\ChangeWeatherPlugin.csproj", "{EA2EF463-13B2-42ED-8923-1B880C44403B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -105,6 +107,10 @@ Global {458FEEA8-D472-4FA9-8E50-63F04F05180A}.Debug|Any CPU.Build.0 = Debug|Any CPU {458FEEA8-D472-4FA9-8E50-63F04F05180A}.Release|Any CPU.ActiveCfg = Release|Any CPU {458FEEA8-D472-4FA9-8E50-63F04F05180A}.Release|Any CPU.Build.0 = Release|Any CPU + {EA2EF463-13B2-42ED-8923-1B880C44403B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA2EF463-13B2-42ED-8923-1B880C44403B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA2EF463-13B2-42ED-8923-1B880C44403B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA2EF463-13B2-42ED-8923-1B880C44403B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ChangeWeatherPlugin/ChangeWeatherModule.cs b/ChangeWeatherPlugin/ChangeWeatherModule.cs new file mode 100644 index 00000000..0e2954a9 --- /dev/null +++ b/ChangeWeatherPlugin/ChangeWeatherModule.cs @@ -0,0 +1,12 @@ +using AssettoServer.Server.Plugin; +using Autofac; + +namespace ChangeWeatherPlugin; + +public class ChangeWeatherModule : AssettoServerModule +{ + protected override void Load(ContainerBuilder builder) + { + builder.RegisterType().AsSelf().AutoActivate().SingleInstance(); + } +} diff --git a/ChangeWeatherPlugin/ChangeWeatherPlugin.cs b/ChangeWeatherPlugin/ChangeWeatherPlugin.cs new file mode 100644 index 00000000..10fd7ac3 --- /dev/null +++ b/ChangeWeatherPlugin/ChangeWeatherPlugin.cs @@ -0,0 +1,15 @@ +using System.Reflection; +using AssettoServer.Server; + +namespace ChangeWeatherPlugin; + +public class ChangeWeatherPlugin +{ + public ChangeWeatherPlugin(CSPServerScriptProvider scriptProvider) + { + scriptProvider.AddScript( + new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("ChangeWeatherPlugin.lua.change-weather.lua")!).ReadToEnd(), + "change-weather.lua" + ); + } +} diff --git a/ChangeWeatherPlugin/ChangeWeatherPlugin.csproj b/ChangeWeatherPlugin/ChangeWeatherPlugin.csproj new file mode 100644 index 00000000..57c4134b --- /dev/null +++ b/ChangeWeatherPlugin/ChangeWeatherPlugin.csproj @@ -0,0 +1,35 @@ + + + + net8.0 + enable + enable + true + false + embedded + ..\out-$(RuntimeIdentifier)\plugins\$(MSBuildProjectName)\ + $(MSBuildProjectDirectory)=$(MSBuildProjectName) + + + + false + ..\AssettoServer\bin\$(Configuration)\$(TargetFramework)\plugins\$(MSBuildProjectName) + + + + + false + runtime + + + false + runtime + + + + + + + + + diff --git a/ChangeWeatherPlugin/README.md b/ChangeWeatherPlugin/README.md new file mode 100644 index 00000000..6cd6db70 --- /dev/null +++ b/ChangeWeatherPlugin/README.md @@ -0,0 +1,9 @@ +# ChangeWeatherPlugin +Plugin to let admins change the weather with a GUI. + +## Configuration +Enable the plugin in `extra_cfg.yml` +```yaml +EnablePlugins: +- ChangeWeatherPlugin +``` diff --git a/ChangeWeatherPlugin/lua/change-weather.lua b/ChangeWeatherPlugin/lua/change-weather.lua new file mode 100644 index 00000000..e7338394 --- /dev/null +++ b/ChangeWeatherPlugin/lua/change-weather.lua @@ -0,0 +1,28 @@ +-- Copyright 2024 + +local selectedWeather = nil ---@type ac.WeatherType +local transitionDuration = 0.0 ---@type number + +local function ChangeWeatherHUD() + ui.text('Select Weather:') + + --ac.INIConfig() + + ui.childWindow('##weathers', vec2(ui.availableSpaceX(), 250), function () + for name, id in pairs(ac.WeatherType) do + if ui.selectable(name, refbool(selectedWeather == name)) then + selectedWeather = name + end + end + end) + + transitionDuration = ui.slider('##someSliderID', transitionDuration, 0, 60, 'Transition Duration: %.0f mins') +end + +local function ChangeWeatherHUDClosed(okClicked) + if okClicked and selectedWeather then + ac.sendChatMessage(string.format('/setcspweather %s %d', selectedWeather, transitionDuration * 60)) + end +end + +ui.registerOnlineExtra(ui.Icons.FastForward, 'Change Weather', nil, ChangeWeatherHUD, ChangeWeatherHUDClosed, ui.OnlineExtraFlags.Admin)