Compare commits
3 Commits
fb0451d49f
...
main
Author | SHA1 | Date | |
---|---|---|---|
e3c4e2d808 | |||
a8287c29ce | |||
97cb856212 |
62
ProfileManager.py
Normal file
62
ProfileManager.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
default_settings_location = "./Mods/bf1942/Settings"
|
||||||
|
default_profile_location = default_settings_location + "/Profiles"
|
||||||
|
default_profile = "FinnWarsLauncher"
|
||||||
|
|
||||||
|
def check_directory_exists(directory_path):
|
||||||
|
return os.path.isdir(directory_path)
|
||||||
|
|
||||||
|
def change_username(username):
|
||||||
|
if not os.path.exists(default_profile_location):
|
||||||
|
print("Launcher is not installed correctly!")
|
||||||
|
print("Please, move finnwarslauncher.exe to the same folder as bf1942.exe!!!")
|
||||||
|
print("Thanks! :)")
|
||||||
|
return
|
||||||
|
|
||||||
|
if not os.path.exists(default_profile_location + "/" + default_profile):
|
||||||
|
print("Profile not found... Creating \"FinnWarsLauncher\"-profile!")
|
||||||
|
os.makedirs("./Mods/bf1942/Settings/Profiles/FinnWarsLauncher")
|
||||||
|
|
||||||
|
if not os.path.exists(default_profile_location + "/" + default_profile + "/GeneralOptions.con"):
|
||||||
|
print("GeneralOptions.con missing... Creating it!")
|
||||||
|
try:
|
||||||
|
with open(default_profile_location + "/" + default_profile + "/GeneralOptions.con", "w") as file:
|
||||||
|
file.write(f"game.setPlayerName \"{username}\"")
|
||||||
|
file.close()
|
||||||
|
except:
|
||||||
|
print("GeneralOptions.con could not be created... error, obviously.")
|
||||||
|
else:
|
||||||
|
print("GeneralOptions.con found! Changing the name.")
|
||||||
|
with open(default_profile_location + "/" + default_profile + "/GeneralOptions.con", "r") as file:
|
||||||
|
lines = file.readlines()
|
||||||
|
|
||||||
|
if 0 < 2 <= len(lines):
|
||||||
|
lines[2] = "game.setPlayerName \"{username}\""
|
||||||
|
|
||||||
|
with open(default_profile_location + "/" + default_profile + "/GeneralOptions.con", "w") as file:
|
||||||
|
file.writelines(lines)
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
if not os.path.exists(default_settings_location + "/GeneralOptions.con"):
|
||||||
|
print("GeneralOptions.con from Profiles is missing... Creating it!")
|
||||||
|
try:
|
||||||
|
with open(default_settings_location + "/GeneralOptions.con", "w") as file:
|
||||||
|
file.write("rem ** NikkeDoy **\n")
|
||||||
|
file.write(f"run Profiles/{default_profile}/GeneralOptions.con")
|
||||||
|
file.close()
|
||||||
|
except:
|
||||||
|
print("GeneralOptions.con could not be created... error, obviously.")
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
with open(default_settings_location + "/GeneralOptions.con", "r") as file:
|
||||||
|
lines = file.readlines()
|
||||||
|
|
||||||
|
if 0 < 1 <= len(lines):
|
||||||
|
lines[1] = f"run Profiles/{default_profile}/GeneralOptions.con"
|
||||||
|
|
||||||
|
with open(default_settings_location + "/GeneralOptions.con", "w") as file:
|
||||||
|
file.writelines(lines)
|
||||||
|
file.close()
|
||||||
|
except:
|
||||||
|
print(f"Couldn't set {default_profile} as default profile. Something is wrong.")
|
@ -80,7 +80,7 @@ Useat järjestelmät käyttävät `python3`-komentoa `python` sijaan, joten pid
|
|||||||
----
|
----
|
||||||
[EN]
|
[EN]
|
||||||
|
|
||||||
0. Be sure that you are currently using created virtual environment (if you don't create it then no worries.)
|
0. Be sure that you are currently using created virtual environment (if you didn't create it then no worries.)
|
||||||
1. Run the application with:
|
1. Run the application with:
|
||||||
```
|
```
|
||||||
python main.py
|
python main.py
|
||||||
|
4
main.py
4
main.py
@ -5,6 +5,8 @@ import pyautogui
|
|||||||
|
|
||||||
import UserData
|
import UserData
|
||||||
import ResourceManager
|
import ResourceManager
|
||||||
|
import ProfileManager
|
||||||
|
|
||||||
|
|
||||||
def save_preferences():
|
def save_preferences():
|
||||||
UserData.save_preferences({"server": server_address_field.get(), "username": username_field.get(), "windowed": windowed.get()})
|
UserData.save_preferences({"server": server_address_field.get(), "username": username_field.get(), "windowed": windowed.get()})
|
||||||
@ -30,6 +32,8 @@ def launch_exe():
|
|||||||
username_field.insert(0, UserData.default_username)
|
username_field.insert(0, UserData.default_username)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
ProfileManager.change_username(username_field.get())
|
||||||
|
|
||||||
# If game needs to be windowed then we use BF42Plus provided "workaround."
|
# If game needs to be windowed then we use BF42Plus provided "workaround."
|
||||||
if windowed.get():
|
if windowed.get():
|
||||||
pyautogui.keyDown("shift")
|
pyautogui.keyDown("shift")
|
||||||
|
Reference in New Issue
Block a user