Extended the localization system to easily include additional languages in the future

This commit is contained in:
Junior 2023-10-07 00:08:43 -03:00
parent d5ec712d0f
commit ae34584021
50 changed files with 45079 additions and 24129 deletions

View file

@ -1,18 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
public static class NativeMethod
namespace RHLauncher.DynamicLib
{
[DllImport("kernel32.dll", EntryPoint = "LoadLibrary")]
public static extern int LoadLibrary(
[MarshalAs(UnmanagedType.LPStr)] string lpLibFileName);
public static class NativeMethod
{
[DllImport("kernel32.dll", EntryPoint = "LoadLibrary")]
public static extern int LoadLibrary(
[MarshalAs(UnmanagedType.LPStr)] string lpLibFileName);
[DllImport("kernel32.dll", EntryPoint = "GetProcAddress")]
public static extern IntPtr GetProcAddress(int hModule,
[MarshalAs(UnmanagedType.LPStr)] string lpProcName);
[DllImport("kernel32.dll", EntryPoint = "GetProcAddress")]
public static extern IntPtr GetProcAddress(int hModule,
[MarshalAs(UnmanagedType.LPStr)] string lpProcName);
[DllImport("kernel32.dll", EntryPoint = "FreeLibrary")]
public static extern bool FreeLibrary(int hModule);
[DllImport("kernel32.dll", EntryPoint = "FreeLibrary")]
public static extern bool FreeLibrary(int hModule);
}
}

View file

@ -1,41 +1,39 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.IO;
using RHLauncher.DynamicLib;
using System.Runtime.InteropServices;
public static class ZLibDll
namespace RHLauncher.DynamicLib
{
//[DllImport("ZlibDll.dll", CallingConvention = CallingConvention.Cdecl)]
//public static extern int Decompress(byte[] compressed_buffer, int compressed_size, byte[] decompressed_buffer, ref int decompressed_size);
public delegate int DecompressDelegate(byte[] compressed_buffer, int compressed_size, byte[] decompressed_buffer, ref int decompressed_size);
public static DecompressDelegate? Decompress = null;
//[DllImport("ZlibDll.dll", CallingConvention = CallingConvention.Cdecl)]
//public static extern int Compress(byte[] decompressed_buffer, int decompressed_size, byte[] compressed_buffer, ref int compressed_size);
public delegate int CompressDelegate(byte[] decompressed_buffer, int decompressed_size, byte[] compressed_buffer, ref int compressed_size);
public static CompressDelegate? Compress = null;
static ZLibDll()
public static class ZLibDll
{
byte[] libBuffer = ResourceDll.ZlibDll;
string dllPath = Path.Combine(Path.GetTempPath(), "ZlibDll.dll");
try
//[DllImport("ZlibDll.dll", CallingConvention = CallingConvention.Cdecl)]
//public static extern int Decompress(byte[] compressed_buffer, int compressed_size, byte[] decompressed_buffer, ref int decompressed_size);
public delegate int DecompressDelegate(byte[] compressed_buffer, int compressed_size, byte[] decompressed_buffer, ref int decompressed_size);
public static DecompressDelegate? Decompress = null;
//[DllImport("ZlibDll.dll", CallingConvention = CallingConvention.Cdecl)]
//public static extern int Compress(byte[] decompressed_buffer, int decompressed_size, byte[] compressed_buffer, ref int compressed_size);
public delegate int CompressDelegate(byte[] decompressed_buffer, int decompressed_size, byte[] compressed_buffer, ref int compressed_size);
public static CompressDelegate? Compress = null;
static ZLibDll()
{
File.WriteAllBytes(dllPath, libBuffer);
byte[] libBuffer = ResourceDll.ZlibDll;
string dllPath = Path.Combine(Path.GetTempPath(), "ZlibDll.dll");
try
{
File.WriteAllBytes(dllPath, libBuffer);
}
catch { }
int hModule = NativeMethod.LoadLibrary(dllPath);
if (hModule == 0) return;
IntPtr intPtr = NativeMethod.GetProcAddress(hModule, "Decompress");
Decompress = (DecompressDelegate)Marshal.GetDelegateForFunctionPointer(intPtr, typeof(DecompressDelegate));
intPtr = NativeMethod.GetProcAddress(hModule, "Compress");
Compress = (CompressDelegate)Marshal.GetDelegateForFunctionPointer(intPtr, typeof(CompressDelegate));
}
catch { }
int hModule = NativeMethod.LoadLibrary(dllPath);
if (hModule == 0) return;
IntPtr intPtr = NativeMethod.GetProcAddress(hModule, "Decompress");
Decompress = (DecompressDelegate)Marshal.GetDelegateForFunctionPointer(intPtr, typeof(DecompressDelegate));
intPtr = NativeMethod.GetProcAddress(hModule, "Compress");
Compress = (CompressDelegate)Marshal.GetDelegateForFunctionPointer(intPtr, typeof(CompressDelegate));
}
}