Skip to content

Commit

Permalink
Merge pull request #337 from kubilus1/xplane_path
Browse files Browse the repository at this point in the history
Add separate setting for XPlane install dir.
  • Loading branch information
kubilus1 authored Aug 26, 2023
2 parents 39708e3 + 1670265 commit 87ff4d8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 19 deletions.
21 changes: 10 additions & 11 deletions autoortho/aoconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class AOConfig(object):
debug = False
[paths]
# X-Plane Custom Scenery path
# X-Plane install path
xplane_path =
# Scenery install path (X-Plane Custom Scenery or other.)
scenery_path =
# Directory where satellite images are cached
cache_dir = {os.path.join(os.path.expanduser("~"), ".autoortho-data", "cache")}
Expand Down Expand Up @@ -140,15 +142,20 @@ def get_config(self):
"z_autoortho",
"scenery"
)


self.xplane_custom_scenery_path = os.path.abspath(os.path.join(
self.paths.xplane_path,
"Custom Scenery"
))

sceneries = []
if os.path.exists(self.ao_scenery_path):
sceneries = os.listdir(self.ao_scenery_path)
print(f"Found sceneries: {sceneries}")

self.scenery_mounts = [{
"root":os.path.join(self.ao_scenery_path, s),
"mount":os.path.join(self.paths.scenery_path, s)
"mount":os.path.join(self.xplane_custom_scenery_path, s)
} for s in sceneries]
print(self.scenery_mounts)

Expand All @@ -158,14 +165,6 @@ def get_config(self):
os.makedirs(self.ao_scenery_path)
return

self.z_autoortho_path = os.path.join(self.paths.scenery_path, 'z_autoortho')
self.root = os.path.join(self.z_autoortho_path, '_textures')
self.mountpoint = os.path.join(self.z_autoortho_path, 'textures')

if not os.path.exists(self.z_autoortho_path):
log.info(f"Creating dir {self.z_autoortho_path}")
os.makedirs(self.z_autoortho_path)


def save(self):
print("Saving config ... ")
Expand Down
32 changes: 24 additions & 8 deletions autoortho/config_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ def setup(self, headless=False):
log.info("-"*28)
log.info(f"Running setup!")
log.info("-"*28)
scenery_path = input(f"Enter path to X-Plane 11 custom_scenery directory ({scenery_path}) : ") or scenery_path
scenery_path = input(f"Enter path to scenery install directory ({scenery_path}) : ") or scenery_path
xplane_path = input(f"Enter path to X-Plane install directory ({xplane_path}) : ") or xplane_path

self.config['paths']['scenery_path'] = scenery_path
self.config['paths']['xplane_path'] = xplane_path
self.config['general']['showconfig'] = str(showconfig)
self.config['autoortho']['maptype_override'] = maptype

Expand Down Expand Up @@ -115,11 +117,17 @@ def ui_loop(self):
#[sg.Image(os.path.join(CUR_PATH, 'imgs', 'flight1.png'), subsample=3)],
[sg.HorizontalSeparator(pad=5)],
[
sg.Text('X-Plane scenery dir:', size=(18,1)),
sg.Text('Scenery install dir:', size=(18,1)),
sg.InputText(scenery_path, size=(45,1), key='scenery_path',
metadata={'section':self.cfg.paths}),
sg.FolderBrowse(key="scenery_b", target='scenery_path', initial_folder=scenery_path)
],
[
sg.Text('X-Plane install dir:', size=(18,1)),
sg.InputText(self.cfg.paths.xplane_path, size=(45,1), key='xplane_path',
metadata={'section':self.cfg.paths}),
sg.FolderBrowse(key="xplane_b", target='xplane_path', initial_folder=self.cfg.paths.xplane_path)
],
[
sg.Text('Image cache dir:', size=(18,1)),
sg.InputText(self.cfg.paths.cache_dir, size=(45,1),
Expand Down Expand Up @@ -375,7 +383,12 @@ def save(self):


def verify(self):
self._check_xplane_dir(self.cfg.paths.scenery_path)
self._check_xplane_dir(self.cfg.paths.xplane_path)
for scenery in self.cfg.scenery_mounts:
self._check_ortho_dir(scenery.get('root'))

if not self.cfg.scenery_mounts:
self.errors.append(f"No installed scenery detcted!")

msg = []
if self.warnings:
Expand Down Expand Up @@ -456,13 +469,16 @@ def _check_ortho_dir(self, path):
return ret

def _check_xplane_dir(self, path):
ret = True

if os.path.basename(path) != "Custom Scenery":
self.warnings.append(f"XPlane Custom Scenery directory {path} seems wrong. This may cause issues.")
ret = False
if not os.path.isdir(path):
self.errors.append(f"XPlane install directory '{path}' is not a directory.")
return False

return ret
if not "Custom Scenery" in os.listdir(path):
self.errors.append(f"XPlane install directory '{path}' seems wrong.")
return False

return True



0 comments on commit 87ff4d8

Please sign in to comment.