Commit c830991c authored by Pavel's avatar Pavel

Fixed several bugs, also multiple mods editing now possible

parent f8852114
......@@ -465,15 +465,9 @@ namespace VivaldiModManager
modEd.WindowState = this.setman.Settings.EditorState;
modEd.WindowStartupLocation = WindowStartupLocation.Manual;
}
modEd.ShowDialog();
this.setman.Settings.EditorWidth = modEd.Width;
this.setman.Settings.EditorHeight = modEd.Height;
this.setman.Settings.EditorLeft = modEd.Left;
this.setman.Settings.EditorTop = modEd.Top;
this.setman.Settings.EditorState = modEd.WindowState;
app.searchMods();
this.reconnectUI();
modEd = null;
modEd.SetMan = this.setman;
modEd.ModCreated = () => this.reconnectUI(true);
modEd.Show();
}
private void mainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
......
......@@ -10,7 +10,7 @@
xmlns:local="clr-namespace:VivaldiModManager"
mc:Ignorable="d"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="Mod Editor" Height="438" Width="739" MinHeight="298" MinWidth="569" WindowStartupLocation="CenterScreen">
Title="Mod Editor" Height="438" Width="739" MinHeight="298" MinWidth="569" WindowStartupLocation="CenterScreen" Closing="modEdWindow_Closing">
<Controls:MetroWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
......
......@@ -26,7 +26,10 @@ namespace VivaldiModManager
public string filePath { get; set; }
public string fileRealPath { get; set; }
public bool IsNewFile { get; set; }
public SettingsManager SetMan { get; set; }
public Action ModCreated { get; set; }
private bool IsModDisabled = false;
public ModEditor(string path = "", string realPath = "")
{
InitializeComponent();
......@@ -34,9 +37,10 @@ namespace VivaldiModManager
this.fileRealPath = realPath;
if (File.Exists(this.filePath))
{
if (this.filePath.EndsWith(".disabled")) this.IsModDisabled = true;
modEditor.Load(this.filePath);
this.fileName = Path.GetFileNameWithoutExtension(this.filePath);
this.fileExt = Path.GetExtension(this.filePath);
this.fileName = Path.GetFileNameWithoutExtension(this.filePath.Replace(".disabled", ""));
this.fileExt = Path.GetExtension(this.filePath.Replace(".disabled", ""));
this.IsNewFile = false;
}
else
......@@ -85,8 +89,10 @@ namespace VivaldiModManager
else
{
string type = this.fileExt.Substring(1);
modEditor.Save(Path.Combine(this.filePath, type, this.fileName + this.fileExt));
modEditor.Save(Path.Combine(this.fileRealPath, type, this.fileName + this.fileExt));
string appendix = this.IsModDisabled ? ".disabled" : "";
modEditor.Save(Path.Combine(this.filePath, type, this.fileName + this.fileExt + appendix));
modEditor.Save(Path.Combine(this.fileRealPath, type, this.fileName + this.fileExt + appendix));
if (this.IsNewFile) this.ModCreated();
return true;
}
}
......@@ -107,5 +113,14 @@ namespace VivaldiModManager
{
this.SaveFile();
}
private void modEdWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
this.SetMan.Settings.EditorWidth = this.Width;
this.SetMan.Settings.EditorHeight = this.Height;
this.SetMan.Settings.EditorLeft = this.Left;
this.SetMan.Settings.EditorTop = this.Top;
this.SetMan.Settings.EditorState = this.WindowState;
}
}
}
......@@ -48,6 +48,7 @@ namespace VivaldiModManager
{
string newPath = this.filePath + ".disabled";
string newRealpath = this.fileRealpath + ".disabled";
if (!File.Exists(this.filePath) || !File.Exists(this.fileRealpath)) return;
File.Move(this.filePath, newPath);
File.Move(this.fileRealpath, newRealpath);
this.filePath = newPath;
......@@ -58,6 +59,7 @@ namespace VivaldiModManager
{
string newPath = this.filePath.Replace(".disabled", "");
string newRealpath = this.fileRealpath.Replace(".disabled", "");
if (!File.Exists(this.filePath) || !File.Exists(this.fileRealpath)) return;
File.Move(this.filePath, newPath);
File.Move(this.fileRealpath, newRealpath);
this.filePath = newPath;
......@@ -79,13 +81,8 @@ namespace VivaldiModManager
modEd.WindowState = this.SetMan.Settings.EditorState;
modEd.WindowStartupLocation = WindowStartupLocation.Manual;
}
modEd.ShowDialog();
this.SetMan.Settings.EditorWidth = modEd.Width;
this.SetMan.Settings.EditorHeight = modEd.Height;
this.SetMan.Settings.EditorLeft = modEd.Left;
this.SetMan.Settings.EditorTop = modEd.Top;
this.SetMan.Settings.EditorState = modEd.WindowState;
modEd = null;
modEd.SetMan = this.SetMan;
modEd.Show();
}
public void ExtractMod()
......@@ -97,7 +94,8 @@ namespace VivaldiModManager
{
try
{
File.Copy(this.filePath, sfd.FileName);
if(File.Exists(this.filePath))
File.Copy(this.filePath, sfd.FileName, true);
}
catch { }
}
......@@ -277,14 +275,14 @@ namespace VivaldiModManager
{
if (mod.EndsWith(".css"))
{
File.Copy(mod, Path.Combine(this.modsPersistentDir + "\\css\\", Path.GetFileName(mod)));
File.Copy(mod, Path.Combine(this.modsDir + "\\css\\", Path.GetFileName(mod)));
File.Copy(mod, Path.Combine(this.modsPersistentDir + "\\css\\", Path.GetFileName(mod)), true);
File.Copy(mod, Path.Combine(this.modsDir + "\\css\\", Path.GetFileName(mod)), true);
if (refresh) this.searchMods();
}
if (mod.EndsWith(".js"))
{
File.Copy(mod, Path.Combine(this.modsPersistentDir + "\\js\\", Path.GetFileName(mod)));
File.Copy(mod, Path.Combine(this.modsDir + "\\js\\", Path.GetFileName(mod)));
File.Copy(mod, Path.Combine(this.modsPersistentDir + "\\js\\", Path.GetFileName(mod)), true);
File.Copy(mod, Path.Combine(this.modsDir + "\\js\\", Path.GetFileName(mod)), true);
if (refresh) this.searchMods();
}
}
......@@ -387,10 +385,11 @@ namespace VivaldiModManager
public void ToggleMods(bool parameter)
{
if(!parameter)
if (!parameter)
{
string browserHtmlText = File.ReadAllText(this.browserHtml);
browserHtmlText = browserHtmlText.Replace("<script src=\"injectMods.js\"></script>", "");
Regex matchModLoader = new Regex(@"(\s+)?\<script\ssrc\=\""injectMods.js\""\>\<\/script\>", RegexOptions.Multiline);
browserHtmlText = matchModLoader.Replace(browserHtmlText, "");
File.WriteAllText(this.browserHtml, browserHtmlText);
this.isModsEnabled = false;
this.installedScripts.Clear();
......@@ -399,8 +398,10 @@ namespace VivaldiModManager
else
{
string browserHtmlText = File.ReadAllText(this.browserHtml);
Regex indentRegex = new Regex(@"(\s+)\<script\ssrc\=\""bundle.js\""\>\<\/script\>", RegexOptions.Multiline);
string indent = indentRegex.Match(browserHtmlText).Groups[1].Value;
browserHtmlText = browserHtmlText.Replace("<script src=\"bundle.js\"></script>",
"<script src=\"bundle.js\"></script><script src=\"injectMods.js\"></script>");
"<script src=\"bundle.js\"></script>" + indent + "<script src=\"injectMods.js\"></script>");
File.WriteAllText(this.browserHtml, browserHtmlText);
this.initModsEnabled();
this.isModsEnabled = true;
......
......@@ -51,7 +51,7 @@ using System.Windows;
// Можно задать все значения или принять номер сборки и номер редакции по умолчанию.
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.2.3.0")]
[assembly: AssemblyFileVersion("0.2.3.0")]
[assembly: AssemblyVersion("0.2.4.0")]
[assembly: AssemblyFileVersion("0.2.4.0")]
[assembly: Guid("40ad3bd5-c96a-4dbf-93d5-450b68c3c8ed")]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment