Openage: Use wine to determine original game path

Created on 14 Aug 2015  ·  18Comments  ·  Source: SFTtech/openage

The convert script could use wine to read the registry key where the original game is installed. This should work for both HD and AoC.

This is of course an optional step, we don't want to depend on wine.

When media conversion is required, the user could be prompted to "use wine?" or enter the path directly.

Currently favored idea:

A simple readline-based interface:

…Media needs to be converted…
Select an Age of Kings installation directory [or a setup folder]:
(0) Use previously used path "..."
(1) Insert manually
(2) $WINEPREFIX/drive_c/Program Files (x86)/Microsoft Games/Age of Empires II/
(3) $HOME/.wine/drive_c/Program Files (x86)/Microsoft Games/Age of Empires II/
[default: 0] > _

The list could be populated programmatically:

  • If $WINEPREFIX is set, offer something like (1)
  • If wine is in PATH, offer wine (I'd suggest offering it always, instead)
  • Once reg query is implemented, use the value it returns, if any
  • Once we can import from installation media, add it in the query & offer common CD drive locations and loop-mount locations (or maybe XDG has a means for getting a CD mount path?)
  • ...
assets just do it python

Most helpful comment

Sorry for re-opening this, I came across this through a Google search. Have you thought about using regedit?

wine regedit /E aoe.reg "HKLM\Software\Microsoft\Microsoft Games\Age of Empires\2.0"

You should then be able to parse aoe.reg using ConfigParser.

All 18 comments

I tried querying for the installation directory using the following command. Unfortunately reg query does not seem to be implemented in wine yet: https://bugs.winehq.org/show_bug.cgi?id=24017, it is just a stub implementation.

$ wine reg query "HKLM\Software\Microsoft\Microsoft Games\Age of Empires\2.0"
STUB QUERY - HKLM\Software\Microsoft\Microsoft Games\Age of Empires\2.0 0 0

The value could be read directly from the text file ~/.wine/system.reg, with a little bit of parsing.

To be precise, if you search for [Software\\Wow6432Node\\Microsoft\\Microsoft Games\\Age of Empires\\2.0], the InstallationDirectory key-value pair is a few lines below it. Other users might not have the Wow6432Node in there.

Hmm kay, wine does support registry keys though, i can't imagine they don't have a working query function. If they just don't have a cli program supporting this, we either ship a program to query via winapi function xor implement this reg query upstream for them (yaaay).

I'll give the first option a try, i.e. write codez to use RegQueryValueEx or similar.

You can use Python ctypes for that, might be totally easy with that.

Btw we have to watch out that many users use custom wineprefixes. if we can't find the registry entry in the default prefix (used by empty WINEPREFIX=), we still have to ask the user what the path of the correct wineprefix is. We can of course also honor the already-set WINEPREFIX env variable.

I think a more simple, still useful change would be to propose $WINEPREFIX/drive_c/Program Files (x86)/Microsoft Games/Age of Empires II/
That way, you can keep/configure a custom wineprefix.
I'd assume most people don't change an installation path if installing on wine.

Good idea! Ideally we should launch a simple gtk3 gui that lets a user select the path with the gtk-file-chooser and also offers to just select a predefined path.

The "standard" path can be checked if it's a valid age2 dir then, a green mark says wheee it'll probably work.

@TheJJ when you introduce a launcher, merge this selection into the GUI - until then, I'd advise against using such a single-spot GUI. It will only confuse people and break the current CLI-only workflow.
I imagine a simple readline-based interface:

…Media needs to be converted…
Select an Age of Kings installation directory [or a setup folder]:
(0) Insert manually
(1) $WINEPREFIX/drive_c/Program Files (x86)/Microsoft Games/Age of Empires II/
(2) $HOME/.wine/drive_c/Program Files (x86)/Microsoft Games/Age of Empires II/
[default: 0] > _

The list could be populated programmatically:

  • If $WINEPREFIX is set, offer something like (1)
  • If wine is in PATH, offer wine (I'd suggest offering it always, instead)
  • Once reg query is implemented, use the value it returns, if any
  • Once we can import from installation media, add it in the query & offer common CD drive locations and loop-mount locations (or maybe XDG has a means for getting a CD mount path?)
  • ...

Maybe I'll submit a patch for this later.

Yea, good thoughts, that seems to be a user-friendly variant for now. Do you think it'd be hard implementing some tab completion for the path entry? I have never done that before :)

Do you think it'd be hard implementing some tab completion for the path entry?

Yes, I wouldn't even try to do this by hand.
Maybe we could get something here if we'd move the whole CLI user interaction to a library like ncurses, but idk and details.

I imagined in my proposal that you could copy from the displayed proposals if they only fit you partially.

I copied your idea, a bit changed, to the top post now.

thx. Also, we should support/evaluate environment variables in the user-supplied path. Currently both of these die with a traceback:

$HOME/.wine/drive_c/Program Files (x86)/Microsoft Games/Age of Empires II/
~/.wine/drive_c/Program Files (x86)/Microsoft Games/Age of Empires II/

I think it would be cool if it checked this (if ~/.wine exists) and suggests it, otherwise the user can choose to launch a zenity file dialogue or just type the path in? (if people don't mind adding a zenity dependency?)

Mind there should be multiple wine prefixes that are not named ~/.wine.

My advice here is to use https://docs.python.org/3/library/curses.html for now and do this within our rendered GUI frontend once it's in place.

So you can select between:

  • use windows installation (invokes the current folder selection)
  • use cd image (read from some iso file)
  • use wine installation (query the prefix (if not set) and then use the registry lookup)

in some interactive terminal selection.

@TheJJ implemented proposals based on ~/.wine and $WINEPREFIX. Expansion of ~ and $VARIABLE already worked, I added paths relative to the current working directory.

I had a quick look on curses, it seems way too low-level. In doubt, I'd settle with zenity (you call zenity --file-selection --directory, it opens a GTK dialog & prints the selected dir). However, the current interface seems good to me.


What's left for future work from this issue:

  • Once reg query is implemented, propose the value it returns
  • Once we can import from installation media, offer CD drive locations and loop-mount locations (e.g. search /proc/mounts for iso9660)
  • offer "Use previously used path" -- is this stored in the converted files somewhere?

Sorry for re-opening this, I came across this through a Google search. Have you thought about using regedit?

wine regedit /E aoe.reg "HKLM\Software\Microsoft\Microsoft Games\Age of Empires\2.0"

You should then be able to parse aoe.reg using ConfigParser.

Cool idea, we should add this additionally.

Implemented it, but didn't test. Please do before merging https://github.com/SFTtech/openage/pull/528

Was this page helpful?
0 / 5 - 0 ratings

Related issues

k3x picture k3x  ·  7Comments

okias picture okias  ·  3Comments

heinezen picture heinezen  ·  13Comments

ShadowCreator picture ShadowCreator  ·  3Comments

heinezen picture heinezen  ·  8Comments