Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
OOF
Browse files Browse the repository at this point in the history
  • Loading branch information
LimitLost committed Mar 14, 2020
1 parent 1e4e7d5 commit 770b1ec
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 146 deletions.
223 changes: 113 additions & 110 deletions ResourceHubLauncher/MainForm.Designer.cs

Large diffs are not rendered by default.

62 changes: 42 additions & 20 deletions ResourceHubLauncher/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,12 @@ public partial class MainForm : MetroForm
foundObj.InstalledMod = true;
disableToolStripMenuItem1.Text = "Disable";
}
if (File.Exists(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ModsFiles", (string)mod["name"], "Configurator.dll"))) {
foundObj.hasConfigurator = true;
}


} else {
}
else {
ModButtonStates statee = File.Exists(Path.Combine(pMod, modName + ".dll.RHLdisabled")) ? ModButtonStates.Disabled : ModButtonStates.Installed;
ModButton newMod = new ModButton(modName, 0, statee, ModClick, ModHover);
metroPanel2.Controls.Add(newMod);
Expand All @@ -141,8 +144,13 @@ public partial class MainForm : MetroForm
disableToolStripMenuItem1.Enabled = false;
}
newMod.fromOutside = true;
if (File.Exists(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ModsFiles", (string)mod["name"], "Configurator.dll"))) {
newMod.hasConfigurator = true;
}
}




}
Config.Theme(this);
Expand Down Expand Up @@ -190,7 +198,7 @@ public partial class MainForm : MetroForm
actualModButton = modsButtons.Find(actualMod);
changeModDescription();

if(actualModButton.InstalledMod) {
if(actualModButton.InstalledMod || actualModButton.DisabledMod) {
installToolStripMenuItem.Text = "Uninstall";
disableToolStripMenuItem1.Enabled = true;
openInModsToolStripMenuItem1.Enabled = true;
Expand Down Expand Up @@ -257,10 +265,7 @@ public partial class MainForm : MetroForm

public static string actualModPath = "";
public static string actualZipFilePath = "";
public static string modName = "";/// <summary>
/// /////////////////////////////////////////////////////////////////////////////////////////////
/// </summary>
/// <returns></returns>
public static string modName = "";

public static string GetGooseFolder() {
return (string)Config.Options["gpath"];
Expand Down Expand Up @@ -363,7 +368,7 @@ public partial class MainForm : MetroForm
installToolStripMenuItem.Text = "Uninstall";
configureModToolStripMenuItem.Enabled = true;
actualModButton.Refresh();
actualModButton.configurable = true;
actualModButton.hasConfigurator = true;
dataPath = Path.Combine(dataPath, "RHLInfo.json");
Expand Down Expand Up @@ -415,7 +420,7 @@ public partial class MainForm : MetroForm
actualModButton.InstalledMod = true;
installToolStripMenuItem.Text = "Uninstall";
actualModButton.Refresh();
actualModButton.configurable = true;
actualModButton.hasConfigurator = true;
configureModToolStripMenuItem.Enabled = true;
openInModsToolStripMenuItem1.Enabled = true;
dataPath = Path.Combine(dataPath, "RHLInfo.json");
Expand Down Expand Up @@ -543,7 +548,7 @@ public partial class MainForm : MetroForm

private void installToolStripMenuItem_Click(object sender, EventArgs e) {

if( actualModButton.InstalledMod) {
if( actualModButton.InstalledMod || actualModButton.DisabledMod) {
toolStripMenuItem1_Click(sender, e);
} else {
install();
Expand Down Expand Up @@ -624,9 +629,14 @@ public partial class MainForm : MetroForm
toolStripMenuItem3_Click(sender, e);
try {
if (Directory.Exists(path)) Directory.Delete(path, true);
actualModButton.InstalledMod = false;
installToolStripMenuItem.Text = "Install";
actualModButton.Refresh();
if(actualModButton.fromOutside) {
modsButtons.Remove(actualModButton.modName);
} else {
actualModButton.InstalledMod = false;
installToolStripMenuItem.Text = "Install";
actualModButton.Refresh();
}

} catch (Exception ex) {
MsgBox($"Error while uninstalling {modd}.\r\nPlease make sure you have Desktop Goose closed.\r\nError: {ex.Message}", "Uninstall error.", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Expand Down Expand Up @@ -855,37 +865,49 @@ public partial class MainForm : MetroForm
}

private void configureModToolStripMenuItem_Click(object sender, EventArgs e) {
//Assembly
Assembly configurator = Assembly.LoadFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ModsFiles", (string)mod["name"], "Configurator.dll"));

foreach (Type type in configurator.GetTypes()) {
if (type.GetInterface("ConfiguratorBasic") != null) {
ConfiguratorBasic configuratorIns = (ConfiguratorBasic)Activator.CreateInstance(type);
modName = (string)mod["name"];
actualModPath = Path.Combine(modPath, actualModButton.modName);
Hide();
new ModConfigForm(configuratorIns).ShowDialog();
Show();

}
}
}

private void toolStripMenuItem1_Click_1(object sender, EventArgs e) {
if(installedToolStripMenuItem.Checked) {
installedToolStripMenuItem.ForeColor = Color.FromArgb(0, 170, 0);
modsButtons.ShowOnly((B) => { return (B.InstalledMod&& installedToolStripMenuItem.Checked) || (!B.EnabledMod&& disabledToolStripMenuItem.Checked) ||(!B.InstalledMod&& availableToolStripMenuItem.Checked); });
modsButtons.ShowOnly((B) => { return (B.InstalledMod&& installedToolStripMenuItem.Checked) || (B.DisabledMod&& disabledToolStripMenuItem.Checked) ||(!B.InstalledMod&& !B.DisabledMod && availableToolStripMenuItem.Checked); });
}
else {
installedToolStripMenuItem.ForeColor = Color.FromArgb(170, 0, 0);
modsButtons.ShowOnly((B) => { return (B.InstalledMod && installedToolStripMenuItem.Checked) || (!B.EnabledMod && disabledToolStripMenuItem.Checked) || (!B.InstalledMod && availableToolStripMenuItem.Checked); });
modsButtons.ShowOnly((B) => { return (B.InstalledMod && installedToolStripMenuItem.Checked) || (B.DisabledMod && disabledToolStripMenuItem.Checked) || (!B.InstalledMod && !B.DisabledMod && availableToolStripMenuItem.Checked); });
}
}

private void disabledToolStripMenuItem_Click(object sender, EventArgs e) {
if (disabledToolStripMenuItem.Checked) {
disabledToolStripMenuItem.ForeColor = Color.FromArgb(0, 170, 0);
modsButtons.ShowOnly((B) => { return (B.InstalledMod && installedToolStripMenuItem.Checked) || (!B.EnabledMod && disabledToolStripMenuItem.Checked) || (!B.InstalledMod && availableToolStripMenuItem.Checked); });
modsButtons.ShowOnly((B) => { return (B.InstalledMod && installedToolStripMenuItem.Checked) || (B.DisabledMod && disabledToolStripMenuItem.Checked) || (!B.InstalledMod && !B.DisabledMod && availableToolStripMenuItem.Checked); });
} else {
disabledToolStripMenuItem.ForeColor = Color.FromArgb(170, 0, 0);
modsButtons.ShowOnly((B) => { return (B.InstalledMod && installedToolStripMenuItem.Checked) || (!B.EnabledMod && disabledToolStripMenuItem.Checked) || (!B.InstalledMod && availableToolStripMenuItem.Checked); });
modsButtons.ShowOnly((B) => { return (B.InstalledMod && installedToolStripMenuItem.Checked) || (B.DisabledMod && disabledToolStripMenuItem.Checked) || (!B.InstalledMod && !B.DisabledMod && availableToolStripMenuItem.Checked); });
}
}

private void availableToolStripMenuItem_Click(object sender, EventArgs e) {
if (availableToolStripMenuItem.Checked) {
availableToolStripMenuItem.ForeColor = Color.FromArgb(0, 170, 0);
modsButtons.ShowOnly((B) => { return (B.InstalledMod && installedToolStripMenuItem.Checked) || (!B.EnabledMod && disabledToolStripMenuItem.Checked) || (!B.InstalledMod && availableToolStripMenuItem.Checked); });
modsButtons.ShowOnly((B) => { return (B.InstalledMod && installedToolStripMenuItem.Checked) || (B.DisabledMod && disabledToolStripMenuItem.Checked) || (!B.InstalledMod && !B.DisabledMod && availableToolStripMenuItem.Checked); });
} else {
availableToolStripMenuItem.ForeColor = Color.FromArgb(170, 0, 0);
modsButtons.ShowOnly((B) => { return (B.InstalledMod && installedToolStripMenuItem.Checked) || (!B.EnabledMod && disabledToolStripMenuItem.Checked) || (!B.InstalledMod && availableToolStripMenuItem.Checked); });
modsButtons.ShowOnly((B) => { return (B.InstalledMod && installedToolStripMenuItem.Checked) || (B.DisabledMod && disabledToolStripMenuItem.Checked) || (!B.InstalledMod && !B.DisabledMod && availableToolStripMenuItem.Checked); });
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions ResourceHubLauncher/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
<metadata name="ShowedModsMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>635, 20</value>
</metadata>
<metadata name="styleExtender.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>128, 17</value>
</metadata>
<metadata name="linksContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>927, 43</value>
</metadata>
Expand Down
22 changes: 17 additions & 5 deletions ResourceHubLauncher/ModButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class ModButton : MetroPanel {
Action<string> clickR;
Action<string> hoverR;

public bool configurable = false;

public ModButton(string _modName, int _modSafety, ModButtonStates _modState, Action<string> clickResult, Action<string> hoverResult) {

modNameColor = Color.FromArgb(170, 170, 170);
Expand Down Expand Up @@ -109,7 +107,7 @@ class ModButton : MetroPanel {
}

public bool InstalledMod {
get { return modState == "Installed"|| modState == "Disabled"; }
get { return modState == "Installed"; }
set {
if (value) {
modState = "Installed";
Expand All @@ -122,7 +120,7 @@ class ModButton : MetroPanel {
}

public bool EnabledMod {
get { return modState == "Installed"|| modState == "Available"; }
get { return modState == "Installed"; }
set {
if (value) {
modState = "Installed";
Expand All @@ -134,6 +132,19 @@ class ModButton : MetroPanel {
}
}

public bool DisabledMod {
get { return modState == "Disabled"; }
set {
if (!value) {
modState = "Installed";
modStateColor = Color.Green;
} else {
modState = "Disabled";
modStateColor = Color.Red;
}
}
}

private void button1_Click(object sender, System.EventArgs e) {
clickR(modName);

Expand Down Expand Up @@ -214,10 +225,11 @@ class ModButtonList {
int actualMemberListN = 0;
for(int i=0;i< list.Count;i++) {
if(how(list[i])) {
list[i].Visible = true;
list[i].setLocation(new Point(latestAddedPos.X, 88 * actualMemberListN));
actualMemberListN++;
} else {
list[i].setLocation(new Point(300, 0));
list[i].Visible=false;
}
}
latestAddedPos = new Point(latestAddedPos.X, 0 - 88+ actualMemberListN*88);
Expand Down
43 changes: 39 additions & 4 deletions ResourceHubLauncher/ModConfigClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ namespace ResourceHubLauncher
class ConfigFile
{
public ConfigFile(string fileLocation) {
options = new List<KeyValuePair<string, string>>();
fileLocationPath = fileLocation;
StreamReader file = new StreamReader(fileLocationPath);
string[] lines = file.ReadToEnd().Split('\n');
file.Close();
foreach (string line in lines) {
int equal = line.IndexOf('=');
string key = line.Substring(0, equal);
string value = line.Substring(equal + 1);
options.Add(new KeyValuePair<string, string>(key, value));
if(equal!=-1) {
string key = line.Substring(0, equal);
string value = line.Substring(equal + 1);
options.Add(new KeyValuePair<string, string>(key, value));
}

}
}

Expand Down Expand Up @@ -74,14 +78,17 @@ class ConfigFile
}
class ModConfigClasses
{

public interface ModConfigBox
{
void Apply(List<KeyValuePair<string, ConfigFile>> configFiles);
Point GetNextBoxLocation();
void SetLocation(Point newLocation);
void ApplyValue(List<KeyValuePair<string, ConfigFile>> configFiles);

void setContextMenuStrip(ContextMenuStrip newMenuStrip);
}

public class StringBox : MetroTextBox, ModConfigBox
{
public StringBox(string fileWithConfig, string configOptionName, string showedName) {
Expand All @@ -98,6 +105,10 @@ public class StringBox : MetroTextBox, ModConfigBox
Text = configFiles.Find((p) => { return p.Key == configFilePath; }).Value.getOption(configOption);
}

void ModConfigBox.setContextMenuStrip(ContextMenuStrip newMenuStrip) {
ContextMenuStrip = newMenuStrip;
}

void ModConfigBox.SetLocation(Point newLocation) {
BoxName.Location = newLocation;
Location = new Point(newLocation.X, newLocation.Y + BoxName.Size.Height + 3);
Expand Down Expand Up @@ -145,6 +156,9 @@ public class Comment : MetroLabel, ModConfigBox {
Text = comment;
}

void ModConfigBox.setContextMenuStrip(ContextMenuStrip newMenuStrip) {
}

void ModConfigBox.SetLocation(Point newLocation) {
Location = newLocation;
}
Expand Down Expand Up @@ -177,6 +191,10 @@ public class IntBox : MetroTextBox, ModConfigBox
MouseDown += MouseDown_;
}

void ModConfigBox.setContextMenuStrip(ContextMenuStrip newMenuStrip) {
ContextMenuStrip = newMenuStrip;
}

void ModConfigBox.ApplyValue(List<KeyValuePair<string, ConfigFile>> configFiles) {
Text = configFiles.Find((p) => { return p.Key == configFilePath; }).Value.getOption(configOption);
}
Expand Down Expand Up @@ -250,6 +268,10 @@ public class FloatBox : MetroTextBox, ModConfigBox
MouseDown += MouseDown_;
}

void ModConfigBox.setContextMenuStrip(ContextMenuStrip newMenuStrip) {
ContextMenuStrip = newMenuStrip;
}

void ModConfigBox.ApplyValue(List<KeyValuePair<string, ConfigFile>> configFiles) {
Text = configFiles.Find((p) => { return p.Key == configFilePath; }).Value.getOption(configOption);
}
Expand Down Expand Up @@ -363,6 +385,10 @@ public class BoolBox : MetroCheckBox, ModConfigBox
MouseDown += MouseDown_;
}

void ModConfigBox.setContextMenuStrip(ContextMenuStrip newMenuStrip) {
ContextMenuStrip = newMenuStrip;
}

void ModConfigBox.ApplyValue(List<KeyValuePair<string, ConfigFile>> configFiles) {

Checked = configFiles.Find((p) => { return p.Key == configFilePath; }).Value.getOption(configOption).ToLower()=="true";
Expand Down Expand Up @@ -441,6 +467,10 @@ public class FileBox : MetroTextBox, ModConfigBox
MouseDown += MouseDown_;
}

void ModConfigBox.setContextMenuStrip(ContextMenuStrip newMenuStrip) {
ContextMenuStrip = newMenuStrip;
}

void ModConfigBox.ApplyValue(List<KeyValuePair<string, ConfigFile>> configFiles) {
//Text = configFiles.Find((p) => { return p.Key == configFilePath; }).Value.getOption(configOption);
string ModsFilesPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ModsFiles");
Expand Down Expand Up @@ -524,6 +554,10 @@ public class ColorBox : MetroButton, ModConfigBox
MouseDown += MouseDown_;
}

void ModConfigBox.setContextMenuStrip(ContextMenuStrip newMenuStrip) {
ContextMenuStrip = newMenuStrip;
}

void ModConfigBox.ApplyValue(List<KeyValuePair<string, ConfigFile>> configFiles) {
SetButtonColor(ColorTranslator.FromHtml(configFiles.Find((p) => { return p.Key == configFilePath; }).Value.getOption(configOption)));
}
Expand Down Expand Up @@ -594,7 +628,8 @@ public class LinkButton : MetroButton, ModConfigBox

}


void ModConfigBox.setContextMenuStrip(ContextMenuStrip newMenuStrip) {
}

void OnClick(object sender, EventArgs e) {
if (MsgBox("This will open a link: "+'"' + link + '"' + ". Do you want to proceed?", "Hold up!", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.Yes) {
Expand Down
Loading

0 comments on commit 770b1ec

Please sign in to comment.