News:

Welcome to World of Banished!

Main Menu

Mod manager

Started by JM, September 16, 2018, 05:23:20 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

JM

I do not need exe. Need WinData to be able to make list of existing mods. It's easier to find the exe using the standard windows open dialog.
I am searching Software\Microsoft\Windows\CurrentVersion\Uninstall for all installed programs, looking for DisplayName = Banished, then extract uninstall directory from UninstallString. Maybe Steam installation differs grom my installation.

I do not have access to a computer with a game installed from Steam.

Dropping an icon works?
Steam users use an exe or launcher to start the game?



embx61

Probably he needs the path to find the Banished registry entrees.

Long, long time that i used Delphi so bear with me if i screwed up somewhere :)
If the name of the executable is known it is easy to get the path of the application.


procedure TForm1.Button1Click(Sender: TObject);
begin
   var AppDir: string;
begin
   AppDir := ExtractFileDir(Application.ExeName); <--- So Application.Application-steam-x64.exe
  // Do something with useful here with the path. for example Edit1.text := AppDir;
   ShowMessage(AppDir);  // <--- just show a message as test :)
   end;
end;


Of course this is useless pseudo code with a onclick event handler what is not needed by itself so JM has to do it all behind the scene at init stage as Mod Manager starts so the user not even know the path is taken and used.

Can always raise an exception if something goes wrong or the exe does not exist by putting the code above in an exception handler block.
[size=8pt][color=teal]My beloved Kathy
As you were you will always be
Treasured forever in my memory[/color][/size]

[size=10pt]For my list of Mods with download links go here[/size]

Tom Sawyer

It can be started via Steam launcher or from file.. As I wrote in C:\Program Files (x86)\Steam\SteamApps\common\Banished\Application-steam-x64.exe

kid1293

Just a small thought. Easy solution.
Why not put it in Banished directory and look only in current directory for Application (Steam or Vanilla)?
Are people so computer illiterate they can not follow a simple instruction?

JM

#34
Originally I read and displayed only registry entries and I did not care about mod files, but the registry also contains a lot of entries of  mods I once tried and then deleted. This 0.0 version was not published.

Now I search for existing files in WinData and for each one I search for ModIndex and ModEnabled in the registry. If mod does not have these items in the registry because I just added it and did not play the game yet, I add the mod to the end of the list. That's why I need a WinData directory.

When path in ModMan.ini not found, because it is the first start, I look for the path to exe as follows:
I browse all the keys in 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall' and look for DisplayName REG_SZ 'Banished'. If found, I use the UninstallString value to get the path to the uninstall file. For me, it's 'D:\Games\Banished\unins000.exe'.
I have Application-x32.exe in the same directory **, so the mods are in 'D:\Games\Banished\WinData'. Then I look for 'data0.pkg', 'data1pkg', 'patch0.pkg' and 'patch1.pkg'. When I find all this ***, the path to the file is used as the starting directory when using the file dialog. If I do not find what I was looking for, the initial directory is the ModMan directory.

/** I do not know how it is in Steam installation. Is there a 'UninstallString' entry in the uninstall record in the registry? If so, is the target in the same directory as Applicationxxxx.exe and WinData? Is there anything at all in the registry that can be used to find path to WinData?

/*** Perhaps, at this point, I could recognize the path as valid and not force the user to confirm it.


function GetBanishedDirectory: string;
const
  UPath = 'Software\Microsoft\Windows\CurrentVersion\Uninstall';
var
  R: TRegistry;
  SL: TStringList;
  i: integer;
  S,WS: string;
begin
  Result := '';
  R := TRegistry.Create;
  try
    R.RootKey := HKEY_LOCAL_MACHINE;
    if not R.OpenKey(UPath,False) then Exit;
    SL := TStringList.Create;
    try
      R.GetKeyNames(SL);
      for i := 0 to SL.Count-1 do begin
        R.CloseKey;
        if R.OpenKey(UPath+'\'+SL[i],False) then begin
          try S := R.ReadString('DisplayName') except S := ''; end;
          if SameText(S,'Banished') then begin
            try S := R.ReadString('UninstallString') except S := ''; end;
            if S = '' then Continue;
            if Copy(S,1,1) = '"' then Delete(S,1,1);
            if Copy(S,Length(S),1) = '"' then Delete(S,Length(S),1);
            S := ExtractFilePath(S);
            WS := S+'WinData';
            if not DirectoryExists(WS) then Continue;
            WS := WS + '\';
            if not FileExists(WS+'data0.pkg') then Continue;
            if not FileExists(WS+'data1.pkg') then Continue;
            if not FileExists(WS+'patch0.pkg') then Continue;
            if not FileExists(WS+'patch1.pkg') then Continue;
            Result := S;
            Break;
          end;
        end;
      end;
    finally
      SL.Free;
    end;
  finally
    R.Free;
  end;
end;


================

Change:

If  'C:\Program Files (x86)\Steam\SteamApps\common\Banished\Application-steam-x64.exe' exists and in WinData there are four pkg files, I'll take it.


Tom Sawyer

Quote from: JM on September 24, 2018, 04:24:02 PM
Change: If  'C:\Program Files (x86)\Steam\SteamApps\common\Banished\Application-steam-x64.exe' exists and in WinData there are four pkm files, I'll take it.

That's what I was talking about. It works now for my installation and I guess for all other Steam users as well. Just copy ModMan where ever you like and run it. :)

The only thing I noticed is that your searching the registry seems to takes some time. Maybe to try Steam folder first and only if it doesn't exist to search in registry. But that's really a tiny thing.

RedKetchup

Quote from: JM on September 24, 2018, 04:24:02 PM
If  'C:\Program Files (x86)\Steam\SteamApps\common\Banished\Application-steam-x64.exe' exists and in WinData there are four pkm files, I'll take it.

my game is install :'D:\Steam\SteamApps\common\Banished\Application-steam-x64.exe'

how you will find it ?

did you checked the REG_SZ there : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 242920\
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

JM

Tom:
That's what I'm doing, first of all the Steam folder and then looking in the registry.
On my 10 year old computer - Core 2 duo, 2GB of memory, WinXP 32bit -  it takes almost no time.

RK:
Is there 'UninstallString'  item in 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 242920\'?
Is yes, what's it's value? Is it 'D:\Steam\SteamApps\common\Banished\something.exe'?


RedKetchup

Quote from: JM on September 24, 2018, 05:31:36 PM
RK:
Is there 'UninstallString'  item in 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 242920\'?
Is yes, what's it's value? Is it 'D:\Steam\SteamApps\common\Banished\something.exe'?

you will find a REG_SZ there named "InstallLocation" and the value inside this REG_SZ is the folder it has been installed : my value is "D:\Steam\steamapps\common\Banished"

then you add "\Bin\WinData\" to it and you've got the folder where are the mods.
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

Tom Sawyer

Mr. Red can set it manually, it's not a problem. ;D

RedKetchup

Quote from: Tom Sawyer on September 25, 2018, 01:54:36 AM
Mr. Red can set it manually, it's not a problem. ;D

but it is not a problem.... it is just for him if he wants to help the people who dont know how to do it... and make his program a perfect automated program :)
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

JM

When I examined the contents of the registry, I found that all the installations of all programs have UninstallString, but not all of them have InstallLocation. And I did not think the installation from Steam was different.
InstallLocation is also different. You would have to add "\Bin\WinData\", I just "WinData\" (without the initial backslash).

I can change it yet. I can take the InstallString and try to find WinData or Bin\WinData and remake the manual procedure to search the directory, for example via a directory tree.

Please help. Is there someone who bought the game directly from Luke's site? If so, does this installation have an InstallLocation entry in the uninstall info in the registry? If so, where is the target? How to get to WinData from there?

Search procedure: run regedit, open the "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" key and look for "Banished" (search data, not keys or values) . It should find DisplayName REG_SZ Banished. In the same place, there should be InstallString REG_SZ "that's what I'm looking for".

Quote.. make his program a perfect automated program ..
Yes. I will add automatic weekly updates that can not be turned off  :D

Hawk

Quote from: JM on September 24, 2018, 04:24:02 PM
When path in ModMan.ini not found, because it is the first start, I look for the path to exe as follows:
I browse all the keys in 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall' and look for DisplayName REG_SZ 'Banished'.

On my machine, it's not found there. It's found in 'HKEY_LOCAL_MACHINE\Software\Wow6432Mode\Microsoft\Windows\CurrentVersion\Uninstall' as well as where I mentioned in Post 21 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\GOG.com\Games\1207660783'

I did a full registry search using Banished as the Find term with a check mark in the Data box only, plus the Match whole string only box. It is not in 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall'
[b][i]Hawk[/i][/b]

[color=#800000][i]Yes, I can multitask. I can listen, ignore and forget all at the same time.[/i][/color]

Hawk

I tried ModMan 03 and it worked great.

I clicked on the desktop shortcut and got the first window below, as expected. Then on the second window below, even though the path was right, I first tried File Dialog to locate the Application-x64.exe, which immediately gave me the contents of the WinData folder.

Then I deleted the ModMan.ini file and the second time I dragged the desktop shortcut to the window and again got the WinData folder.

So it looks like ModMan is finding the location just fine.  ;D
[b][i]Hawk[/i][/b]

[color=#800000][i]Yes, I can multitask. I can listen, ignore and forget all at the same time.[/i][/color]

RedKetchup

Quote from: JM on September 25, 2018, 03:43:45 AM
InstallLocation is also different. You would have to add "\Bin\WinData\", I just "WinData\" (without the initial backslash).

oh ya sorry ! so sorry there is no /bin/ it is just /WinData/
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .