Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d6da6ca598 | |||
| aa0d04b094 | |||
| e9b915dec5 | |||
| 2f5214d3b2 | |||
| 61407c3aab |
@ -2,10 +2,17 @@
|
|||||||
|
|
||||||
internal static partial class Kernel32
|
internal static partial class Kernel32
|
||||||
{
|
{
|
||||||
|
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static partial bool GetConsoleScreenBufferInfo(nint hConsoleOutput, out ConsoleScreenBufferInfo lpConsoleScreenBufferInfo);
|
||||||
|
|
||||||
|
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||||
|
public static partial nint GetConsoleWindow();
|
||||||
|
|
||||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||||
public static partial uint GetFinalPathNameByHandleA(nint hFile, [MarshalAs(UnmanagedType.LPTStr)] string lpszFilePath,
|
public static partial uint GetFinalPathNameByHandleA(nint hFile, [MarshalAs(UnmanagedType.LPTStr)] string lpszFilePath,
|
||||||
uint cchFilePath, uint dwFlags);
|
uint cchFilePath, uint dwFlags);
|
||||||
|
|
||||||
[LibraryImport("kernel32.dll")]
|
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||||
public static partial nuint GlobalSize(nint hPtr);
|
public static partial nuint GlobalSize(nint hPtr);
|
||||||
}
|
}
|
||||||
|
|||||||
15
SrcMod/Shell/Interop/ObjectModels/ConsoleScreenBufferInfo.cs
Normal file
15
SrcMod/Shell/Interop/ObjectModels/ConsoleScreenBufferInfo.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
namespace SrcMod.Shell.Interop.ObjectModels;
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct ConsoleScreenBufferInfo
|
||||||
|
{
|
||||||
|
[MarshalAs(UnmanagedType.LPStruct)]
|
||||||
|
public Coord dwSize;
|
||||||
|
[MarshalAs(UnmanagedType.LPStruct)]
|
||||||
|
public Coord dwCursorPosition;
|
||||||
|
public int wAttributes;
|
||||||
|
[MarshalAs(UnmanagedType.LPStruct)]
|
||||||
|
public SmallRect srWindow;
|
||||||
|
[MarshalAs(UnmanagedType.LPStruct)]
|
||||||
|
public Coord dwMaximumWindowSize;
|
||||||
|
}
|
||||||
8
SrcMod/Shell/Interop/ObjectModels/Coord.cs
Normal file
8
SrcMod/Shell/Interop/ObjectModels/Coord.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace SrcMod.Shell.Interop.ObjectModels;
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct Coord
|
||||||
|
{
|
||||||
|
public short X;
|
||||||
|
public short Y;
|
||||||
|
}
|
||||||
10
SrcMod/Shell/Interop/ObjectModels/SmallRect.cs
Normal file
10
SrcMod/Shell/Interop/ObjectModels/SmallRect.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace SrcMod.Shell.Interop.ObjectModels;
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct SmallRect
|
||||||
|
{
|
||||||
|
public short Left;
|
||||||
|
public short Top;
|
||||||
|
public short Right;
|
||||||
|
public short Bottom;
|
||||||
|
}
|
||||||
@ -6,6 +6,7 @@ global using SharpCompress.Archives.SevenZip;
|
|||||||
global using SharpCompress.Readers;
|
global using SharpCompress.Readers;
|
||||||
global using SrcMod.Shell.Extensions;
|
global using SrcMod.Shell.Extensions;
|
||||||
global using SrcMod.Shell.Interop;
|
global using SrcMod.Shell.Interop;
|
||||||
|
global using SrcMod.Shell.Interop.ObjectModels;
|
||||||
global using SrcMod.Shell.Modules;
|
global using SrcMod.Shell.Modules;
|
||||||
global using SrcMod.Shell.Modules.ObjectModels;
|
global using SrcMod.Shell.Modules.ObjectModels;
|
||||||
global using SrcMod.Shell.ObjectModels;
|
global using SrcMod.Shell.ObjectModels;
|
||||||
|
|||||||
44
SrcMod/Shell/Modules/Valve/VkvModule.cs
Normal file
44
SrcMod/Shell/Modules/Valve/VkvModule.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
namespace SrcMod.Shell.Modules.Valve;
|
||||||
|
|
||||||
|
[Module("vkv")]
|
||||||
|
public static class VkvModule
|
||||||
|
{
|
||||||
|
[Command("create")]
|
||||||
|
public static void CreateVkv(string path)
|
||||||
|
{
|
||||||
|
if (File.Exists(path)) throw new($"File already exists at \"{path}\". Did you mean to run \"vkv edit\"?");
|
||||||
|
|
||||||
|
VkvNode parentNode = new VkvTreeNode()
|
||||||
|
{
|
||||||
|
{ "key", new VkvSingleNode("value") }
|
||||||
|
};
|
||||||
|
string parentNodeName = "tree";
|
||||||
|
|
||||||
|
VkvModifyWhole(ref parentNode, ref parentNodeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void VkvModifyWhole(ref VkvNode node, ref string nodeName)
|
||||||
|
{
|
||||||
|
VkvDisplayNode(node, nodeName);
|
||||||
|
}
|
||||||
|
private static void VkvDisplayNode(in VkvNode? node, in string nodeName, in int indent = 0)
|
||||||
|
{
|
||||||
|
int spaceCount = indent * 4;
|
||||||
|
|
||||||
|
if (node is null) return;
|
||||||
|
else if (node is VkvSingleNode single)
|
||||||
|
{
|
||||||
|
Write(new string(' ', spaceCount) + $"\"{nodeName}\" \"{single.value}\"");
|
||||||
|
}
|
||||||
|
else if (node is VkvTreeNode tree)
|
||||||
|
{
|
||||||
|
Write(new string(' ', spaceCount) + $"\"{nodeName}\"\n" + new string(' ', spaceCount) + "{");
|
||||||
|
foreach (KeyValuePair<string, VkvNode?> subNode in tree)
|
||||||
|
{
|
||||||
|
VkvDisplayNode(subNode.Value, subNode.Key, indent + 1);
|
||||||
|
}
|
||||||
|
Write(new string(' ', spaceCount) + "}");
|
||||||
|
}
|
||||||
|
else return;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user