Skip to content

Commit 6c3bc2c

Browse files
authored
1.1.0.0 Update
1 parent 5f308c6 commit 6c3bc2c

20 files changed

+496
-255
lines changed

MultiBloxy/Config.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ public class Config
99
private static readonly string ConfigFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.xml");
1010
private static XDocument configDocument;
1111

12+
// Static constructor to initialize the config document
1213
static Config()
1314
{
1415
Load();
1516
}
1617

18+
// Loads the configuration from the config file
1719
public static void Load()
1820
{
1921
if (File.Exists(ConfigFilePath))
@@ -26,6 +28,7 @@ public static void Load()
2628
}
2729
}
2830

31+
// Saves the configuration to the config file
2932
public static void Save()
3033
{
3134
if (!configDocument.Root.HasElements)
@@ -41,6 +44,7 @@ public static void Save()
4144
}
4245
}
4346

47+
// Sets a configuration value for a given key
4448
public static void Set(string key, object value)
4549
{
4650
var element = configDocument.Root.Element(key);
@@ -55,6 +59,7 @@ public static void Set(string key, object value)
5559
Save();
5660
}
5761

62+
// Gets a configuration value for a given key, with default value
5863
public static T Get<T>(string key, T defaultValue = default)
5964
{
6065
var element = configDocument.Root.Element(key);
@@ -65,6 +70,13 @@ public static T Get<T>(string key, T defaultValue = default)
6570
return defaultValue;
6671
}
6772

73+
// Checks if a configuration key exists
74+
public static bool Has(string key)
75+
{
76+
return configDocument.Root.Element(key) != null;
77+
}
78+
79+
// Removes a configuration key
6880
public static void Remove(string key)
6981
{
7082
var element = configDocument.Root.Element(key);

MultiBloxy/HandleCloser.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static void CloseAllHandles()
7676
while (true)
7777
{
7878
// Query system information for handles
79-
uint status = NtQuerySystemInformation(SystemHandleInformation, buffer, size, out uint returnLength);
79+
uint status = NtQuerySystemInformation(SystemHandleInformation, buffer, size, out uint _);
8080

8181
// If the buffer is too small, double its size and retry
8282
if (status == 0xC0000004)
@@ -113,9 +113,8 @@ public static void CloseAllHandles()
113113
continue;
114114
}
115115

116-
IntPtr dupHandle = IntPtr.Zero;
117116
// Duplicate the handle to the current process
118-
bool success = DuplicateHandle(processHandle, new IntPtr(handleInfo.Handle), GetCurrentProcess(), out dupHandle, 0, false, DUPLICATE_SAME_ACCESS);
117+
bool success = DuplicateHandle(processHandle, new IntPtr(handleInfo.Handle), GetCurrentProcess(), out IntPtr dupHandle, 0, false, DUPLICATE_SAME_ACCESS);
119118
if (!success)
120119
{
121120
// Close the process handle and move to the next handle if duplication fails
@@ -128,7 +127,7 @@ public static void CloseAllHandles()
128127
IntPtr nameBuffer = Marshal.AllocHGlobal((int)bufferSize);
129128

130129
// Query the object name information for the duplicated handle
131-
uint status = NtQueryObject(dupHandle, ObjectNameInformation, nameBuffer, bufferSize, out uint returnLength);
130+
uint status = NtQueryObject(dupHandle, ObjectNameInformation, nameBuffer, bufferSize, out uint _);
132131

133132
if (status != 0)
134133
{
@@ -149,7 +148,7 @@ public static void CloseAllHandles()
149148
if (name.Contains("ROBLOX_singletonEvent"))
150149
{
151150
// Close the handle if it matches the target name
152-
bool success2 = DuplicateHandle(processHandle, new IntPtr(handleInfo.Handle), IntPtr.Zero, out _, 0, false, DUPLICATE_CLOSE_SOURCE);
151+
DuplicateHandle(processHandle, new IntPtr(handleInfo.Handle), IntPtr.Zero, out _, 0, false, DUPLICATE_CLOSE_SOURCE);
153152
}
154153
}
155154

MultiBloxy/Localization.cs

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,27 @@ namespace MultiBloxy
55
{
66
public class Localization
77
{
8-
private readonly Dictionary<string, Dictionary<string, string>> _translations;
9-
private string _currentLocale;
8+
public readonly Dictionary<string, Dictionary<string, string>> Locales;
9+
public string CurrentLocale;
1010

11+
// Constructor to initialize the Localization class
1112
public Localization()
1213
{
13-
_translations = new Dictionary<string, Dictionary<string, string>>();
14-
_currentLocale = CultureInfo.CurrentCulture.Name;
15-
LoadTranslations();
14+
Locales = new Dictionary<string, Dictionary<string, string>>();
15+
AutoCurrentLocale();
16+
LoadLocales();
1617
}
1718

18-
private void LoadTranslations()
19+
// Automatically sets the current locale based on the system's culture settings
20+
public void AutoCurrentLocale()
1921
{
20-
_translations["en"] = new Dictionary<string, string>
22+
CurrentLocale = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
23+
}
24+
25+
// Loads predefined locales into the Locales dictionary
26+
private void LoadLocales()
27+
{
28+
Locales["en"] = new Dictionary<string, string>
2129
{
2230
{ "ContextMenu.StatusMenuItem.Running", "Status: Running" },
2331
{ "ContextMenu.StatusMenuItem.Paused", "Status: Paused" },
@@ -31,6 +39,8 @@ private void LoadTranslations()
3139
{ "ContextMenu.SettingsMenuItem.Settings", "Settings" },
3240
{ "ContextMenu.SettingsMenuItem.PauseOnLaunchMenuItem.PauseOnLaunch", "Pause on Launch" },
3341
{ "ContextMenu.SettingsMenuItem.ResetRememberedMenuItem.ResetRemembered", "Reset Remembered Options" },
42+
{ "ContextMenu.SettingsMenuItem.LanguageMenuItem.Language", "Language" },
43+
{ "ContextMenu.SettingsMenuItem.LanguageMenuItem.AutoDetectMenuItem.AutoDetect", "Auto Detect" },
3444
{ "ContextMenu.ExitMenuItem.Exit", "Exit" },
3545
{ "Error.Mutex.Caption", "Failed to Create Mutex" },
3646
{ "Error.Mutex.Message", "An error occurred while creating the Mutex. This likely happened because when {0} was launched, Roblox was already running and had registered its handle. You can do the following:" },
@@ -44,7 +54,7 @@ private void LoadTranslations()
4454
{ "Error.Singleton.Message", "{0} is already running. Try looking in the system tray." }
4555
};
4656

47-
_translations["ru"] = new Dictionary<string, string>
57+
Locales["ru"] = new Dictionary<string, string>
4858
{
4959
{ "ContextMenu.StatusMenuItem.Running", "Статус: Работает" },
5060
{ "ContextMenu.StatusMenuItem.Paused", "Статус: Приостановлено" },
@@ -58,6 +68,8 @@ private void LoadTranslations()
5868
{ "ContextMenu.SettingsMenuItem.Settings", "Настройки" },
5969
{ "ContextMenu.SettingsMenuItem.PauseOnLaunchMenuItem.PauseOnLaunch", "Приостановить при запуске" },
6070
{ "ContextMenu.SettingsMenuItem.ResetRememberedMenuItem.ResetRemembered", "Сбросить запомненные параметры" },
71+
{ "ContextMenu.SettingsMenuItem.LanguageMenuItem.Language", "Язык" },
72+
{ "ContextMenu.SettingsMenuItem.LanguageMenuItem.AutoDetectMenuItem.AutoDetect", "Определять автоматически" },
6173
{ "ContextMenu.ExitMenuItem.Exit", "Выход" },
6274
{ "Error.Mutex.Caption", "Не удалось создать Mutex" },
6375
{ "Error.Mutex.Message", "Произошла ошибка при создании Mutex. Скорее всего, это связано с тем, что при запуске {0} Roblox уже был запущен и успел зарегистрировать свой дескриптор. Вы можете сделать следующее:" },
@@ -72,33 +84,29 @@ private void LoadTranslations()
7284
};
7385
}
7486

75-
public string GetTranslation(string key)
87+
// Retrieves the localized string for the given key
88+
public string GetLocaleString(string key)
7689
{
77-
string locale = GetLocaleWithoutRegion(_currentLocale);
78-
79-
if (_translations.ContainsKey(locale) && _translations[locale].ContainsKey(key))
90+
if (Locales.ContainsKey(CurrentLocale) && Locales[CurrentLocale].ContainsKey(key))
8091
{
81-
return _translations[locale][key];
92+
return Locales[CurrentLocale][key];
8293
}
8394

84-
// Fallback to English if the translation is not found
85-
if (_translations.ContainsKey("en") && _translations["en"].ContainsKey(key))
95+
// Fallback to English if the locale string is not found
96+
if (Locales.ContainsKey("en") && Locales["en"].ContainsKey(key))
8697
{
87-
return _translations["en"][key];
98+
return Locales["en"][key];
8899
}
89100

90-
// Fallback to the key if the translation is not found
101+
// Fallback to the key if the locale string is not found
91102
return key;
92103
}
93104

94-
private string GetLocaleWithoutRegion(string locale)
105+
// Returns a stylized name for the given locale
106+
public string GetStylizedLocaleName(string locale)
95107
{
96-
int index = locale.IndexOf('-');
97-
if (index != -1)
98-
{
99-
return locale.Substring(0, index);
100-
}
101-
return locale;
108+
CultureInfo cultureInfo = new CultureInfo(locale);
109+
return $"{cultureInfo.DisplayName} ({cultureInfo.NativeName})";
102110
}
103111
}
104112
}

MultiBloxy/MultiBloxy.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
<ErrorReport>prompt</ErrorReport>
3434
<WarningLevel>4</WarningLevel>
3535
</PropertyGroup>
36+
<PropertyGroup>
37+
<ApplicationIcon>Resources\MultiBloxy.ico</ApplicationIcon>
38+
</PropertyGroup>
3639
<ItemGroup>
3740
<Reference Include="System" />
3841
<Reference Include="System.Drawing" />
@@ -43,10 +46,12 @@
4346
<ItemGroup>
4447
<Compile Include="Config.cs" />
4548
<Compile Include="HandleCloser.cs" />
46-
<Compile Include="HandleCloser.cs" />
4749
<Compile Include="Localization.cs" />
4850
<Compile Include="Program.cs" />
4951
<Compile Include="Properties\AssemblyInfo.cs" />
5052
</ItemGroup>
53+
<ItemGroup>
54+
<EmbeddedResource Include="Resources\**\*.*" Exclude="Resources\MultiBloxy.ico" />
55+
</ItemGroup>
5156
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
5257
</Project>

0 commit comments

Comments
 (0)