Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove need for settings.txt? #40

Open
Revel8804 opened this issue Mar 9, 2021 · 4 comments
Open

Remove need for settings.txt? #40

Revel8804 opened this issue Mar 9, 2021 · 4 comments

Comments

@Revel8804
Copy link

So in theory this should work for both steam and MS store if I am reading right.
I don't have the Steam version so I can not confirm.
It is basically importing the windows environment variable for localappdata and using that instead of having to specify in the settings.txt file.

Let me know your thoughts. I hope this marks up correctly.

so glass_server.py..... At the beginning I added....

from flask import Flask, jsonify, render_template, request
from SimConnect import *
from time import sleep, localtime
import random
import logging
import math
import socket
import asyncio
from threading import Thread, local
import datetime
import os   #######My Additions are right here#######
localappdata = os.getenv('localappdata')   #######My Additions are right here#######

print (socket.gethostbyname(socket.gethostname()))

ui_friendly_dictionary = {}
event_name = None
value_to_use = None)

Then in the load_fltpln function i changed it to......

    fltpln = []
    @app.route('/fltpln', methods=["POST"])
    def load_fltpln():
        # Load Settings - MSFS Install Location
        try:
            fltpln_dir = localappdata + "\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe" ##My Additions are right here##
            print(fltpln_dir)
            try:
                # MS Store
                fltpln_dir_full = fltpln_dir + "\LocalState\MISSIONS\Custom\CustomFlight\CUSTOMFLIGHT.FLT"
                with open(fltpln_dir_full, 'r') as fltpln:
                    fltpln_lines = fltpln.readlines()
            except:
                # Steam
                fltpln_dir_full = fltpln_dir + "\MISSIONS\Custom\CustomFlight\CUSTOMFLIGHT.FLT"
                with open(fltpln_dir_full, 'r') as fltpln:
                    fltpln_lines = fltpln.readlines()

            # Process Flight Plan Function
            def latlong_dec_convert(to_convert):
@mracko
Copy link
Owner

mracko commented Apr 18, 2021

Thanks for the tip! I've been thinking about doing something similar, however, I don't know if this works when you have:
a) custom install folder for Windows Store
b) custom install folder for Steam

I wanted to make it as flexible as possible, so I've decided to go with a text file. I'll leave the issue/suggestion open because I might revisit it later.

@Revel8804
Copy link
Author

oh have an update on this one. Its been a minute and I forgot to add it.
While working on my magic painting for the planes I learned about the file.

MSFSdir\localcache\User.Cfg.opt

From my understanding at least on the windows store version. the game will always install to C:\Users<username>\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe and will have the usercfg.opt file.

The last line in that file will have the external location that you want your packages installed to.

InstalledPackagesPath "C:\Users\kenny\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages"

I know the steam version will have that file there too, but if you tell steam to install to another location or drive, other than a file search I'm not sure how to find it.

i can not test the steam version either since I don't own it on steam.

@Revel8804
Copy link
Author

also I have been out for a bit. The new updates and changes, ARE AMAZING!.

Just wanted to say good work and I appreciate that you are making and updating this.

@E1xP
Copy link

E1xP commented Nov 14, 2021

I have a steam version it seem whatever you place the game the CUSTOMFLIGHT.FLT will at the same place. (except the username)
And got another problem. In python \ is a convert chart. And when it use in locate a file should use r before the string or using \ or / in the string. It seem in this programe if reading fail. It also tell user to check the setting path.
Maybe using except FileNotFoundError: to tell user about config wrong will better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants