Adds Notch Support to Vintage Story for notchful laptops.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Initial commit of v1.0.1.

Different55 baec150e

+511
+8
.gitignore
··· 1 + *.af 2 + *.DS_Store 3 + *.sln.DotSettings.user 4 + 5 + bin/ 6 + obj/ 7 + .idea/ 8 + Releases/
+7
.vscode/extensions.json
··· 1 + { 2 + "recommendations": [ 3 + "ms-dotnettools.csdevkit", 4 + "ms-dotnettools.csharp", 5 + "ms-dotnettools.vscode-dotnet-runtime" 6 + ] 7 + }
+59
.vscode/launch.json
··· 1 + { 2 + // Use IntelliSense to learn about possible attributes. 3 + // Hover to view descriptions of existing attributes. 4 + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 + "version": "0.2.0", 6 + "configurations": [ 7 + { 8 + "name": "Launch Client", 9 + "type": "coreclr", 10 + "request": "launch", 11 + "program": "${env:VINTAGE_STORY}/Vintagestory.exe", 12 + "linux": { 13 + "program": "${env:VINTAGE_STORY}/Vintagestory" 14 + }, 15 + "osx": { 16 + "program": "${env:VINTAGE_STORY}/Vintagestory" 17 + }, 18 + "preLaunchTask": "build", 19 + "args": [ 20 + "--tracelog", 21 + "--addModPath", 22 + "${workspaceFolder}/NotchForVintageStory/bin/Debug/Mods" 23 + ], 24 + "console": "internalConsole", 25 + "stopAtEntry": false 26 + }, 27 + { 28 + "name": "Launch Server", 29 + "type": "coreclr", 30 + "request": "launch", 31 + "program": "${env:VINTAGE_STORY}/VintagestoryServer.exe", 32 + "linux": { 33 + "program": "${env:VINTAGE_STORY}/VintagestoryServer" 34 + }, 35 + "osx": { 36 + "program": "${env:VINTAGE_STORY}/VintagestoryServer" 37 + }, 38 + "preLaunchTask": "build", 39 + "args": [ 40 + "--tracelog", 41 + "--addModPath", 42 + "${workspaceFolder}/NotchForVintageStory/bin/Debug/Mods" 43 + ], 44 + "console": "internalConsole", 45 + "stopAtEntry": false 46 + }, 47 + { 48 + "name": "CakeBuild", 49 + "type": "coreclr", 50 + "request": "launch", 51 + "preLaunchTask": "build (Cake)", 52 + "program": "${workspaceFolder}/CakeBuild/bin/Debug/net7.0/CakeBuild.dll", 53 + "args": [], 54 + "cwd": "${workspaceFolder}/CakeBuild", 55 + "stopAtEntry": false, 56 + "console": "internalConsole" 57 + } 58 + ] 59 + }
+40
.vscode/tasks.json
··· 1 + { 2 + "version": "2.0.0", 3 + "tasks": [ 4 + { 5 + "label": "build", 6 + "command": "dotnet", 7 + "type": "process", 8 + "args": [ 9 + "build", 10 + "-c", 11 + "Debug", 12 + "${workspaceFolder}/NotchForVintageStory/NotchForVintageStory.csproj" 13 + ], 14 + "problemMatcher": "$msCompile" 15 + }, 16 + { 17 + "label": "package", 18 + "command": "dotnet", 19 + "type": "process", 20 + "args": [ 21 + "run", 22 + "--project", 23 + "${workspaceFolder}/CakeBuild/CakeBuild.csproj" 24 + ], 25 + "problemMatcher": "$msCompile" 26 + }, 27 + { 28 + "label": "build (Cake)", 29 + "command": "dotnet", 30 + "type": "process", 31 + "args": [ 32 + "build", 33 + "-c", 34 + "Debug", 35 + "${workspaceFolder}/CakeBuild/CakeBuild.csproj" 36 + ], 37 + "problemMatcher": "$msCompile" 38 + } 39 + ] 40 + }
Banner.png

This is a binary file and will not be displayed.

+19
CakeBuild/CakeBuild.csproj
··· 1 + <Project Sdk="Microsoft.NET.Sdk"> 2 + <PropertyGroup> 3 + <OutputType>Exe</OutputType> 4 + <TargetFramework>net10.0</TargetFramework> 5 + <RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> 6 + </PropertyGroup> 7 + 8 + <ItemGroup> 9 + <PackageReference Include="Cake.Frosting" Version="5.0.0"/> 10 + <PackageReference Include="Cake.Json" Version="7.0.1"/> 11 + <PackageReference Include="Newtonsoft.Json" Version="13.0.3"/> 12 + </ItemGroup> 13 + 14 + <ItemGroup> 15 + <Reference Include="VintagestoryAPI"> 16 + <HintPath>$(VINTAGE_STORY)/VintagestoryAPI.dll</HintPath> 17 + </Reference> 18 + </ItemGroup> 19 + </Project>
+124
CakeBuild/Program.cs
··· 1 + using System; 2 + using System.IO; 3 + using Cake.Common; 4 + using Cake.Common.IO; 5 + using Cake.Common.Tools.DotNet; 6 + using Cake.Common.Tools.DotNet.Clean; 7 + using Cake.Common.Tools.DotNet.Publish; 8 + using Cake.Core; 9 + using Cake.Frosting; 10 + using Cake.Json; 11 + using Newtonsoft.Json; 12 + using Newtonsoft.Json.Linq; 13 + using Vintagestory.API.Common; 14 + 15 + namespace CakeBuild; 16 + 17 + public static class Program 18 + { 19 + public static int Main(string[] args) 20 + { 21 + return new CakeHost() 22 + .UseContext<BuildContext>() 23 + .Run(args); 24 + } 25 + } 26 + 27 + public class BuildContext : FrostingContext 28 + { 29 + public const string ProjectName = "NotchForVintageStory"; 30 + public string BuildConfiguration { get; } 31 + public string Version { get; } 32 + public string Name { get; } 33 + public bool SkipJsonValidation { get; } 34 + 35 + public BuildContext(ICakeContext context) 36 + : base(context) 37 + { 38 + BuildConfiguration = context.Argument("configuration", "Release"); 39 + SkipJsonValidation = context.Argument("skipJsonValidation", false); 40 + var modInfo = context.DeserializeJsonFromFile<ModInfo>($"../{ProjectName}/modinfo.json"); 41 + Version = modInfo.Version; 42 + Name = modInfo.ModID; 43 + } 44 + } 45 + 46 + [TaskName("ValidateJson")] 47 + public sealed class ValidateJsonTask : FrostingTask<BuildContext> 48 + { 49 + public override void Run(BuildContext context) 50 + { 51 + if (context.SkipJsonValidation) 52 + { 53 + return; 54 + } 55 + 56 + var jsonFiles = context.GetFiles($"../{BuildContext.ProjectName}/assets/**/*.json"); 57 + foreach (var file in jsonFiles) 58 + { 59 + try 60 + { 61 + var json = File.ReadAllText(file.FullPath); 62 + JToken.Parse(json); 63 + } 64 + catch (JsonException ex) 65 + { 66 + throw new Exception( 67 + $"Validation failed for JSON file: {file.FullPath}{Environment.NewLine}{ex.Message}", ex); 68 + } 69 + } 70 + } 71 + } 72 + 73 + [TaskName("Build")] 74 + [IsDependentOn(typeof(ValidateJsonTask))] 75 + public sealed class BuildTask : FrostingTask<BuildContext> 76 + { 77 + public override void Run(BuildContext context) 78 + { 79 + context.DotNetClean($"../{BuildContext.ProjectName}/{BuildContext.ProjectName}.csproj", 80 + new DotNetCleanSettings 81 + { 82 + Configuration = context.BuildConfiguration 83 + }); 84 + 85 + 86 + context.DotNetPublish($"../{BuildContext.ProjectName}/{BuildContext.ProjectName}.csproj", 87 + new DotNetPublishSettings 88 + { 89 + Configuration = context.BuildConfiguration 90 + }); 91 + } 92 + } 93 + 94 + [TaskName("Package")] 95 + [IsDependentOn(typeof(BuildTask))] 96 + public sealed class PackageTask : FrostingTask<BuildContext> 97 + { 98 + public override void Run(BuildContext context) 99 + { 100 + context.EnsureDirectoryExists("../Releases"); 101 + context.CleanDirectory("../Releases"); 102 + context.EnsureDirectoryExists($"../Releases/{context.Name}"); 103 + context.CopyFiles($"../{BuildContext.ProjectName}/bin/{context.BuildConfiguration}/Mods/mod/publish/*", 104 + $"../Releases/{context.Name}"); 105 + if (context.DirectoryExists($"../{BuildContext.ProjectName}/assets")) 106 + { 107 + context.CopyDirectory($"../{BuildContext.ProjectName}/assets", $"../Releases/{context.Name}/assets"); 108 + } 109 + 110 + context.CopyFile($"../{BuildContext.ProjectName}/modinfo.json", $"../Releases/{context.Name}/modinfo.json"); 111 + if (context.FileExists($"../{BuildContext.ProjectName}/modicon.png")) 112 + { 113 + context.CopyFile($"../{BuildContext.ProjectName}/modicon.png", $"../Releases/{context.Name}/modicon.png"); 114 + } 115 + 116 + context.Zip($"../Releases/{context.Name}", $"../Releases/{context.Name}_{context.Version}.zip"); 117 + } 118 + } 119 + 120 + [TaskName("Default")] 121 + [IsDependentOn(typeof(PackageTask))] 122 + public class DefaultTask : FrostingTask 123 + { 124 + }
ModIcon.png

This is a binary file and will not be displayed.

+27
NotchForVintageStory.sln
··· 1 + Microsoft Visual Studio Solution File, Format Version 12.00 2 + # Visual Studio Version 17 3 + VisualStudioVersion = 17.0.31903.59 4 + MinimumVisualStudioVersion = 10.0.40219.1 5 + Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotchForVintageStory", "NotchForVintageStory\NotchForVintageStory.csproj", "{CB2100BC-F653-402A-9FBA-EA463C2BD4FC}" 6 + EndProject 7 + Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CakeBuild", "CakeBuild\CakeBuild.csproj", "{BC68EDF6-C294-4819-B7F4-9EA99B73E69D}" 8 + EndProject 9 + Global 10 + GlobalSection(SolutionConfigurationPlatforms) = preSolution 11 + Debug|Any CPU = Debug|Any CPU 12 + Release|Any CPU = Release|Any CPU 13 + EndGlobalSection 14 + GlobalSection(SolutionProperties) = preSolution 15 + HideSolutionNode = FALSE 16 + EndGlobalSection 17 + GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 + {BC68EDF6-C294-4819-B7F4-9EA99B73E69D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 + {BC68EDF6-C294-4819-B7F4-9EA99B73E69D}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 + {BC68EDF6-C294-4819-B7F4-9EA99B73E69D}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 + {BC68EDF6-C294-4819-B7F4-9EA99B73E69D}.Release|Any CPU.Build.0 = Release|Any CPU 22 + {CB2100BC-F653-402A-9FBA-EA463C2BD4FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 + {CB2100BC-F653-402A-9FBA-EA463C2BD4FC}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 + {CB2100BC-F653-402A-9FBA-EA463C2BD4FC}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 + {CB2100BC-F653-402A-9FBA-EA463C2BD4FC}.Release|Any CPU.Build.0 = Release|Any CPU 26 + EndGlobalSection 27 + EndGlobal
+49
NotchForVintageStory/NotchForVintageStory.csproj
··· 1 + <Project Sdk="Microsoft.NET.Sdk"> 2 + 3 + <PropertyGroup> 4 + <TargetFramework>net10.0</TargetFramework> 5 + <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> 6 + <OutputPath>bin\$(Configuration)\Mods\mod</OutputPath> 7 + </PropertyGroup> 8 + 9 + <ItemGroup> 10 + <Reference Include="VintagestoryAPI"> 11 + <HintPath>$(VINTAGE_STORY)/VintagestoryAPI.dll</HintPath> 12 + <Private>false</Private> 13 + </Reference> 14 + <Reference Include="VSSurvivalMod"> 15 + <HintPath>$(VINTAGE_STORY)/Mods/VSSurvivalMod.dll</HintPath> 16 + <Private>False</Private> 17 + </Reference> 18 + <Reference Include="VSEssentials"> 19 + <HintPath>$(VINTAGE_STORY)/Mods/VSEssentials.dll</HintPath> 20 + <Private>False</Private> 21 + </Reference> 22 + <Reference Include="VSCreativeMod"> 23 + <HintPath>$(VINTAGE_STORY)/Mods/VSCreativeMod.dll</HintPath> 24 + <Private>False</Private> 25 + </Reference> 26 + <Reference Include="VintagestoryLib"> 27 + <HintPath>$(VINTAGE_STORY)/VintagestoryLib.dll</HintPath> 28 + <Private>false</Private> 29 + </Reference> 30 + <Reference Include="0Harmony"> 31 + <HintPath>$(VINTAGE_STORY)/Lib/0Harmony.dll</HintPath> 32 + <Private>False</Private> 33 + </Reference> 34 + </ItemGroup> 35 + 36 + 37 + <ItemGroup> 38 + <Content Include="assets\**"> 39 + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 40 + </Content> 41 + <Content Include="modinfo.json"> 42 + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 43 + </Content> 44 + <Content Include="modicon.png"> 45 + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 46 + </Content> 47 + </ItemGroup> 48 + 49 + </Project>
+56
NotchForVintageStory/NotchMod.cs
··· 1 + using System; 2 + using HarmonyLib; 3 + using Vintagestory.API.Client; 4 + using Vintagestory.API.Common; 5 + 6 + namespace NotchForVintageStory; 7 + 8 + public class NotchMod : ModSystem 9 + { 10 + public static ICoreClientAPI Capi { get; private set; } 11 + public static Harmony HarmonyInstance { get; private set; } 12 + public static double NotchHeight; 13 + 14 + public override void StartPre(ICoreAPI api) 15 + { 16 + base.StartPre(api); 17 + Capi = api as ICoreClientAPI; 18 + HarmonyInstance = new Harmony(Mod.Info.ModID); 19 + HarmonyInstance.PatchAll(); 20 + } 21 + 22 + public override void Start(ICoreAPI api) 23 + { 24 + base.Start(api); 25 + LoadConfig(api); 26 + SaveConfig(api); 27 + } 28 + 29 + public void LoadConfig(ICoreAPI api) 30 + { 31 + try 32 + { 33 + NotchHeight = api.LoadModConfig<double>("notch.json"); 34 + if (NotchHeight == 0.0) NotchHeight = 30.0; 35 + } 36 + catch (Exception e) 37 + { 38 + Mod.Logger.Error("Could not load config! Loading default settings instead."); 39 + Mod.Logger.Error(e); 40 + NotchHeight = 30.0; 41 + } 42 + } 43 + 44 + public void SaveConfig(ICoreAPI api) 45 + { 46 + api.StoreModConfig(NotchHeight, "notch.json"); 47 + } 48 + 49 + public override void Dispose() 50 + { 51 + HarmonyInstance?.UnpatchAll(Mod.Info.ModID); 52 + HarmonyInstance = null; 53 + Capi = null; 54 + base.Dispose(); 55 + } 56 + }
+91
NotchForVintageStory/NotchPatch.cs
··· 1 + using System; 2 + using HarmonyLib; 3 + using Vintagestory.API.Client; 4 + using Vintagestory.API.Common; 5 + using Vintagestory.API.Common.Entities; 6 + using Vintagestory.API.Config; 7 + using Vintagestory.API.MathTools; 8 + using Vintagestory.Client.NoObf; 9 + 10 + namespace NotchForVintageStory; 11 + 12 + [HarmonyPatch(typeof(HudElementBlockAndEntityInfo))] 13 + [HarmonyPatch("ComposeBlockInfoHud")] 14 + public class NotchPatch 15 + { 16 + public static bool Prefix(string ___title, string ___detail, Block ___currentBlock, Entity ___currentEntity, 17 + BlockPos ___currentPos, ref GuiComposer ___composer, HudElementBlockAndEntityInfo __instance) 18 + { 19 + string newTitle = ""; 20 + string newDetail = ""; 21 + if (___currentBlock != null) 22 + { 23 + if (___currentBlock.Code == null) 24 + { 25 + newTitle = "Unknown block ID " + NotchMod.Capi.World.BlockAccessor.GetBlockId(___currentPos); 26 + newDetail = ""; 27 + } 28 + else 29 + { 30 + newTitle = ___currentBlock.GetPlacedBlockName(NotchMod.Capi.World, ___currentPos) ?? "Unknown"; 31 + newDetail = ___currentBlock.GetPlacedBlockInfo(NotchMod.Capi.World, ___currentPos, NotchMod.Capi.World.Player) ?? ""; 32 + } 33 + } 34 + 35 + if (___currentEntity != null) 36 + { 37 + newTitle = ___currentEntity.GetName() ?? ("Unknown Entity code " + ___currentEntity.Code); 38 + newDetail = ___currentEntity.GetInfoText() ?? ""; 39 + } 40 + 41 + if (___title != newTitle || ___detail != newDetail) 42 + { 43 + ___title = newTitle; 44 + ___detail = newDetail; 45 + ElementBounds textBounds = ElementBounds.Fixed(EnumDialogArea.CenterFixed, 0.0, 0.0, 500.0, 24.0); 46 + ElementBounds detailTextBounds = textBounds.BelowCopy(0.0, 10.0); 47 + detailTextBounds.Alignment = EnumDialogArea.None; 48 + ElementBounds overlayBounds = new ElementBounds(); 49 + overlayBounds.BothSizing = ElementSizing.FitToChildren; 50 + overlayBounds.WithFixedPadding(5.0, 5.0); 51 + ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterTop) 52 + .WithFixedAlignmentOffset(0.0, GuiStyle.DialogToScreenPadding + NotchMod.NotchHeight / RuntimeEnv.GUIScale); 53 + LoadedTexture reuseRichTextTexture = null; 54 + GuiElementRichtext rtElem; 55 + if (___composer == null) 56 + { 57 + ___composer = NotchMod.Capi.Gui.CreateCompo("blockinfohud", dialogBounds); 58 + } 59 + else 60 + { 61 + rtElem = ___composer.GetRichtext("rt"); 62 + reuseRichTextTexture = rtElem.richtTextTexture; 63 + rtElem.richtTextTexture = null; 64 + ___composer.Clear(dialogBounds); 65 + } 66 + 67 + __instance.Composers["blockinfohud"] = ___composer; 68 + ___composer.AddGameOverlay(overlayBounds).BeginChildElements(overlayBounds).AddStaticTextAutoBoxSize(___title, 69 + CairoFont.WhiteSmallishText(), EnumTextOrientation.Left, textBounds) 70 + .AddRichtext(___detail, CairoFont.WhiteDetailText(), detailTextBounds, "rt") 71 + .EndChildElements(); 72 + rtElem = ___composer.GetRichtext("rt"); 73 + if (___detail.Length == 0) 74 + { 75 + detailTextBounds.fixedY = 0.0; 76 + detailTextBounds.fixedHeight = 0.0; 77 + } 78 + 79 + if (reuseRichTextTexture != null) 80 + { 81 + rtElem.richtTextTexture = reuseRichTextTexture; 82 + } 83 + 84 + rtElem.BeforeCalcBounds(); 85 + detailTextBounds.fixedWidth = Math.Min(500.0, rtElem.MaxLineWidth / RuntimeEnv.GUIScale + 1.0); 86 + ___composer.Compose(); 87 + } 88 + 89 + return false; 90 + } 91 + }
+16
NotchForVintageStory/Properties/launchSettings.json
··· 1 + { 2 + "profiles": { 3 + "Client": { 4 + "commandName": "Executable", 5 + "executablePath": "$(VINTAGE_STORY)/Vintagestory", 6 + "commandLineArgs": "--tracelog --addModPath \"$(ProjectDir)/bin/$(Configuration)/Mods\"", 7 + "workingDirectory": "$(VINTAGE_STORY)" 8 + }, 9 + "Server": { 10 + "commandName": "Executable", 11 + "executablePath": "$(VINTAGE_STORY)/VintagestoryServer", 12 + "commandLineArgs": "--tracelog --addModPath \"$(ProjectDir)/bin/$(Configuration)/Mods\"", 13 + "workingDirectory": "$(VINTAGE_STORY)" 14 + } 15 + } 16 + }
+5
NotchForVintageStory/changelog.txt
··· 1 + v1.0.1 Changelog 2 + - Update for 1.22.0 3 + 4 + v1.0.0 Changelog 5 + - Initial release
NotchForVintageStory/modicon.png

This is a binary file and will not be displayed.

+10
NotchForVintageStory/modinfo.json
··· 1 + { 2 + "type": "code", 3 + "modid": "notchforvintagestory", 4 + "name": "Notch for Vintage Story", 5 + "side": "client", 6 + "authors": [ "different55" ], 7 + "description": "Adds padding to the Entity and Block Info HUD for devices with notches.", 8 + "version": "1.0.1", 9 + "dependencies": { "game": "" } 10 + }
Screenshot After.png

This is a binary file and will not be displayed.

Screenshot Before.png

This is a binary file and will not be displayed.