-
Notifications
You must be signed in to change notification settings - Fork 17
feat: add MelonLoader version check to prevent crashes (#36) #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,6 +158,25 @@ private void StartClicked(object? sender, EventArgs? e) | |
| return; | ||
| } | ||
|
|
||
| string mlDllPath = Path.Combine(StaticSettings.GamePath, "..", "MelonLoader", "MelonLoader.dll"); | ||
| if (File.Exists(mlDllPath)) | ||
|
sourcery-ai[bot] marked this conversation as resolved.
Outdated
|
||
| { | ||
| var versionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(mlDllPath); | ||
| string? version = versionInfo.ProductVersion; | ||
|
|
||
| if (version == null || !version.StartsWith("0.6.4")) | ||
| { | ||
| var dialougResult = MessageBox.Show( | ||
| // Add i8n pls :) | ||
| $"Detected MelonLoader version {version}, but 0.6.4 is recommended for stability. Continue anyway?", | ||
| "MelonLoader Version Warning", | ||
| MessageBoxButtons.YesNo, | ||
| MessageBoxIcon.Warning); | ||
|
|
||
| if (dialougResult == DialogResult.No) return; | ||
|
sourcery-ai[bot] marked this conversation as resolved.
Outdated
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The MessageBox strings are hardcoded in English, and there is a typo in the variable name Note: You will need to add the keys var dialogResult = MessageBox.Show(
string.Format(Locale.MelonLoaderVersionWarning, version ?? "unknown"),
Locale.MelonLoaderVersionWarningTitle,
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning);
if (dialogResult == DialogResult.No) return; |
||
| } | ||
| } | ||
|
|
||
| if (ContainsSpecialCharacters(StaticSettings.GamePath)) | ||
| { | ||
| MessageBox.Show(Locale.PathContainsSpecialChars, Locale.PathContainsSpecialCharsTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path construction for
MelonLoader.dllusing..assumes the game files are always in a subfolder (e.g.,Package). In a standard installation whereSinmai_Datais in the root folder,StaticSettings.GamePathwill be the root, and..will point to the parent directory of the game, causing the check to fail. Consider checking both the currentGamePathand its parent to support both installation layouts.