Skip to content

Commit

Permalink
Fixes and some additions
Browse files Browse the repository at this point in the history
  • Loading branch information
loco-choco committed Nov 10, 2020
1 parent df37b5b commit 0f1291c
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 43 deletions.
114 changes: 72 additions & 42 deletions DIMOWA/DIMOWA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace IMOWA
// 1 - Deu erro
// 2 - Não Deu certo, mas não por erro

static Target ModInnitTarget(Type modClass, string modName, Patcher p, string modMethodToTarget, string modClassToTarget, string modNamespaceToTarget = "", int indiceOfIntructions = 0)
static Target ModInnitTarget(Type modClass,string modInnitMethod, string modName, Patcher p, string modMethodToTarget, string modClassToTarget, string modNamespaceToTarget = "", int indiceOfIntructions = 0)
{


Expand All @@ -33,7 +33,7 @@ static Target ModInnitTarget(Type modClass, string modName, Patcher p, string mo

Instruction.Create(OpCodes.Ldstr , modName),

Instruction.Create(OpCodes.Call, p.BuildCall(modClass, "ModInnit", typeof(void), new[] { typeof(string) }))
Instruction.Create(OpCodes.Call, p.BuildCall(modClass, modInnitMethod, typeof(void), new[] { typeof(string) }))


};
Expand Down Expand Up @@ -64,7 +64,7 @@ static Target ModInnitTarget(Type modClass, string modName, Patcher p, string mo

static Target ModInnitTarget(MOWAP modMOWAP, Patcher modPatcher)
{
return ModInnitTarget(modMOWAP.ModType, modMOWAP.ModName, modPatcher, modMOWAP.ModMethodToTarget, modMOWAP.ModClassToTarget, modMOWAP.ModNamespaceToTarget, modMOWAP.IndiceOfIntructions);
return ModInnitTarget(modMOWAP.ModType, modMOWAP.ModInnitMethod, modMOWAP.ModName, modPatcher, modMOWAP.ModMethodToTarget, modMOWAP.ModClassToTarget, modMOWAP.ModNamespaceToTarget, modMOWAP.IndiceOfIntructions);
}

//PORQUE ISSO NÃO PODE SER UM POINTER AHAHAHAH
Expand Down Expand Up @@ -256,6 +256,9 @@ static void Main(string[] args)

string caminhoDessePrograma = Directory.GetCurrentDirectory();

if (!Directory.Exists(caminhoDessePrograma + @"\mods"))
Directory.CreateDirectory(caminhoDessePrograma + @"\mods");

string[] todosOsDlls = Directory.GetFiles(caminhoDessePrograma +@"\mods\", "*.dll");


Expand Down Expand Up @@ -301,6 +304,8 @@ static void Main(string[] args)
{
ModType = classeDoDll,

ModInnitMethod = mInfo.Name,

ModName = ((IMOWAModInnit)attr).modName,

ModMethodToTarget = ((IMOWAModInnit)attr).methodToPatch,
Expand All @@ -311,15 +316,22 @@ static void Main(string[] args)

IndiceOfIntructions = ((IMOWAModInnit)attr).indiceOfPatch,

dllFileName = filePath.Remove(0, caminhoDessePrograma.Count() + 6),
DllFileName = filePath.Remove(0, caminhoDessePrograma.Count() + 6),

});

//Ver os atributos dos modInnit de cada mod
//Console.WriteLine(((IMOWAModInnit)attr).modName + " " + ((IMOWAModInnit)attr).methodToPatch + " "+ ((IMOWAModInnit)attr).classToPatch + " "+((IMOWAModInnit)attr).namespaceToPatch );

//Se achar o atributo não tem o porque continuar procurando, só se aceita um por vez
break;
}
}

//Se achar o método não tem o porque continuar procurando, só se aceita um por vez
if(listOfMods.Count>0) // Para não dar erro de que não tem elemento na lista
if (listOfMods.Last().ModInnitMethod == mInfo.Name)
break;
}
}
}
Expand Down Expand Up @@ -354,7 +366,7 @@ static void Main(string[] args)
if ((resposta == "listademods" || resposta == "recarregar" || resposta == "refresh" || resposta == "menu" || resposta == "r") && indexofmod < 0)
{
Console.Clear();
Console.WriteLine(" --- DIMOWA v.3 --- ");
Console.WriteLine(" --- DIMOWA v.1.0.1 --- ");
for (int i = 0; i < listOfMods.Count; i++)
{
indexOfModInnits[i] = CheckIfModInstalled(listOfModTarget[i], patcher);
Expand All @@ -376,61 +388,79 @@ static void Main(string[] args)

}
//instalar todos os mods
else if ((resposta == "instalar todos" || resposta == "it" || resposta == "install all" || resposta == "ia") && indexofmod < 0)
else if ((resposta == "instalar todos" || resposta == "it" || resposta == "install all" || resposta == "ia") && indexofmod < 0 && amountOfMods > 0)
{
Console.Clear();

for (int i = 0; i < listOfModTarget.Length; i++)
if (amountOfMods < 0)
{
if (indexOfModInnits[i] < 0)
Console.WriteLine("Nao ha mods para instalar");
Console.WriteLine("There are no mods to install");
}
else
{
Console.Clear();

for (int i = 0; i < listOfModTarget.Length; i++)
{
Console.WriteLine('\n' + $"Instalando / Installing {listOfMods[i].ModName} . . .");
InstallOrUninstallMod(listOfModTarget[i], patcher, indexOfModInnits[i],listOfMods[i].dllFileName, caminhoDessePrograma);
if (indexOfModInnits[i] < 0)
{
Console.WriteLine('\n' + $"Instalando / Installing {listOfMods[i].ModName} . . .");
InstallOrUninstallMod(listOfModTarget[i], patcher, indexOfModInnits[i], listOfMods[i].DllFileName, caminhoDessePrograma);
}
}
}

patcher.Save(false);
patcher = new Patcher("Assembly-CSharp.dll");
patcher.Save(false);
patcher = new Patcher("Assembly-CSharp.dll");

Console.WriteLine('\n' + "Todos os mods estao agora instalados");
Console.WriteLine('\n' + "Todos os mods estao agora instalados");

Console.WriteLine('\n' + "Digite [recarregar / r / menu] para recarregar o menu");
Console.WriteLine("Write [refresh / r / menu] to reload the menu");
Console.WriteLine("E se voce quer sair do programa digite [sair / s]");
Console.WriteLine("And if you want to close the program, write [close / c]");
indexofmod = -1;
Console.WriteLine('\n' + "Digite [recarregar / r / menu] para recarregar o menu");
Console.WriteLine("Write [refresh / r / menu] to reload the menu");
Console.WriteLine("E se voce quer sair do programa digite [sair / s]");
Console.WriteLine("And if you want to close the program, write [close / c]");
indexofmod = -1;
}
}

//desinstalar todos os mods
else if ((resposta == "desinstalar todos" || resposta == "dt" || resposta == "uninstall all" || resposta == "ua") && indexofmod < 0)
else if ((resposta == "desinstalar todos" || resposta == "dt" || resposta == "uninstall all" || resposta == "ua") && indexofmod < 0 )
{
Console.Clear();

for (int i = 0; i < listOfModTarget.Length; i++)
if (amountOfMods < 0)
{
if (indexOfModInnits[i] > -1)
Console.WriteLine("Nao ha mods para desinstalar");
Console.WriteLine("There are no mods to uninstall");
}
else
{
Console.Clear();



for (int i = 0; i < listOfModTarget.Length; i++)
{
Console.WriteLine('\n' + $"Desinstalando / Unistalling {listOfMods[i].ModName} . . .");
InstallOrUninstallMod(listOfModTarget[i], patcher, indexOfModInnits[i], listOfMods[i].dllFileName,caminhoDessePrograma);
if (indexOfModInnits[i] > -1)
{
Console.WriteLine('\n' + $"Desinstalando / Unistalling {listOfMods[i].ModName} . . .");
InstallOrUninstallMod(listOfModTarget[i], patcher, indexOfModInnits[i], listOfMods[i].DllFileName, caminhoDessePrograma);
}
}
}
patcher.Save(false);
patcher = new Patcher("Assembly-CSharp.dll");
patcher.Save(false);
patcher = new Patcher("Assembly-CSharp.dll");

Console.WriteLine('\n' + "Todos os mods estao agora desinstalados");
Console.WriteLine('\n' + "Todos os mods estao agora desinstalados");

Console.WriteLine('\n' + "Digite [recarregar / r / menu] para recarregar o menu");
Console.WriteLine("Write [refresh / r / menu] to reload the menu");
Console.WriteLine("E se voce quer sair do programa digite [sair / s]");
Console.WriteLine("And if you want to close the program, write [close / c]");
indexofmod = -1;
Console.WriteLine('\n' + "Digite [recarregar / r / menu] para recarregar o menu");
Console.WriteLine("Write [refresh / r / menu] to reload the menu");
Console.WriteLine("E se voce quer sair do programa digite [sair / s]");
Console.WriteLine("And if you want to close the program, write [close / c]");
indexofmod = -1;
}
}

//Se a resposta da pessoa for uma dessas e um mod tiver sido escolhido, entao instalar ou desinstalar
else if ((resposta == "sim" || resposta == "s" || resposta == "yes" || resposta == "y") && indexofmod > -1)
{

InstallOrUninstallMod(listOfModTarget[indexofmod], patcher, indexOfModInnits[indexofmod], listOfMods[indexofmod].dllFileName, caminhoDessePrograma);
InstallOrUninstallMod(listOfModTarget[indexofmod], patcher, indexOfModInnits[indexofmod], listOfMods[indexofmod].DllFileName, caminhoDessePrograma);
patcher.Save(false);
patcher = new Patcher("Assembly-CSharp.dll");

Expand Down Expand Up @@ -461,7 +491,7 @@ static void Main(string[] args)
{
try
{
if (indexofmod < 0)
if (indexofmod < 0 )
{
indexofmod = Convert.ToInt32(resposta);

Expand All @@ -472,14 +502,14 @@ static void Main(string[] args)
bool isModinstalled = indexOfModInnits[indexofmod] > -1;

Console.WriteLine('\n' + $"Mod {listOfMods[indexofmod].ModName} is " + (isModinstalled ? "" : "not ") + "installed. Would you like to " + (isModinstalled ? "unnistall " : "install ") + "it?");
Console.WriteLine($"O mod {listOfMods[indexofmod].ModName} " + (isModinstalled ? "" : "não ") + "está instalado.Voce gostaria de " + (isModinstalled ? "desinstalar " : "instalar ") + "ele?");
Console.WriteLine('\n' + "For Yes -> yes / y | Para No -> no / n");
Console.WriteLine($"O mod {listOfMods[indexofmod].ModName} " + (isModinstalled ? "" : "não ") + "está instalado. Voce gostaria de " + (isModinstalled ? "desinstalar " : "instalar ") + "ele?");
Console.WriteLine('\n' + "For Yes -> yes / y | For No -> no / n");
Console.WriteLine("Para Sim -> sim / s | Para Nao -> nao / n");
}
else
{
Console.WriteLine("Esse numero nao e um index da lista");
Console.WriteLine("That number is not a index of the list");
Console.WriteLine("That number is not an index of the list");
indexofmod = -1;
}

Expand Down
4 changes: 3 additions & 1 deletion DIMOWA/MOWAP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ public struct MOWAP

public Type ModType { get; set; }

public string ModInnitMethod { get; set; }

public string ModName { get; set; }

public string dllFileName { get; set; }
public string DllFileName { get; set; }

public string ModMethodToTarget { get; set; }

Expand Down

0 comments on commit 0f1291c

Please sign in to comment.