improved error handling

This commit is contained in:
Frank Skare
2019-08-01 11:47:01 +02:00
parent d90025e8fe
commit 8626b8283f
10 changed files with 20 additions and 29 deletions

View File

@@ -100,11 +100,6 @@ namespace mpvnet
}
}
public static void UnknownModule(string path)
{
Msg.ShowError("Failed to load script or extension", "Only scripts and extensions that ship with mpv.net are allowed in <startup>\\scripts or <startup>\\extensions.\n\nUser scripts or extensions have to use <config folder>\\scripts or <config folder>\\extensions.\n\nNever copy a new mpv.net version over a old mpv.net version.\n\nNever install a new mpv.net version on top of a old mpv.net version.\n\n" + path);
}
public static bool ProcessProperty(string name, string value)
{
switch (name)

View File

@@ -16,7 +16,7 @@ namespace mpvnet
{
switch (id)
{
case "manage-file-associations": ManageFileAssociations(); break;
case "manage-file-associations": ManageFileAssociations(); break; // deprecated 2019
case "cycle-audio": CycleAudio(); break;
case "load-audio": LoadAudio(); break;
case "load-sub": LoadSubtitle(); break;

View File

@@ -30,7 +30,7 @@ namespace mpvnet
if (knownExtensions.Contains(Path.GetFileName(path)))
catalog.Catalogs.Add(new DirectoryCatalog(path, "*Extension.dll"));
else
App.UnknownModule(path);
Msg.ShowError("Failed to load extension", path + "\n\nOnly extensions that ship with mpv.net are allowed in <startup>\\extensions\n\nUser extensions have to use <config folder>\\extensions\n\nNever copy or install a new mpv.net version over a old mpv.net version.");
}
}

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.0.0.0")]
[assembly: AssemblyFileVersion("5.0.0.0")]
[assembly: AssemblyVersion("5.1.0.0")]
[assembly: AssemblyFileVersion("5.1.0.0")]

View File

@@ -150,6 +150,7 @@
F1 script-message mpv.net show-command-palette #menu: Tools > Show All Commands
h script-message mpv.net show-history #menu: Tools > Show History
Ctrl+r script-message-to repl type "" #menu: Tools > Show REPL
l ab-loop #menu: Tools > Set/clear A-B loop points
L cycle-values loop-file "inf" "no" #menu: Tools > Toggle infinite file looping
Ctrl+h cycle-values hwdec "auto" "no" #menu: Tools > Toggle Hardware Decoding

View File

@@ -311,6 +311,9 @@ namespace mpvnet
{
if (WindowState != FormWindowState.Maximized || FormBorderStyle != FormBorderStyle.None)
{
if (WindowState == FormWindowState.Maximized)
WindowState = FormWindowState.Minimized;
FormBorderStyle = FormBorderStyle.None;
WindowState = FormWindowState.Maximized;
}
@@ -324,7 +327,7 @@ namespace mpvnet
if (mp.Border)
FormBorderStyle = FormBorderStyle.Sizable;
else
FormBorderStyle = FormBorderStyle.None;
FormBorderStyle = FormBorderStyle.None;
SetFormPosAndSize();
}

View File

@@ -235,15 +235,12 @@ namespace mpvnet
string[] startupScripts = Directory.GetFiles(PathHelp.StartupPath + "Scripts");
foreach (string path in startupScripts)
if (path.EndsWith(".lua") || path.EndsWith(".js"))
if (KnownScripts.Contains(Path.GetFileName(path)))
commandv("load-script", $"{path}");
else
App.UnknownModule(path);
if ((path.EndsWith(".lua") || path.EndsWith(".js")) && KnownScripts.Contains(Path.GetFileName(path)))
commandv("load-script", $"{path}");
}
}
public static string[] KnownScripts { get; } = { "osc-visibility.js", "show-playlist.js", "seek-show-position.py" };
public static string[] KnownScripts { get; } = { "osc-visibility.js", "show-playlist.js", "seek-show-position.py", "repl.lua" };
public static void LoadScripts()
{
@@ -259,7 +256,7 @@ namespace mpvnet
PowerShellScript.Init(path);
}
else
App.UnknownModule(path);
Msg.ShowError("Failed to load script", path + "\n\nOnly scripts that ship with mpv.net are allowed in <startup>\\scripts\n\nUser scripts have to use <config folder>\\scripts\n\nNever copy or install a new mpv.net version over a old mpv.net version.");
}
}