✨ | Added image loading fixes.
This commit is contained in:
parent
946dac5e8d
commit
9d5083d306
@ -1,7 +1,9 @@
|
|||||||
**FinnWarsLauncher**
|
**FinnWarsLauncher**
|
||||||
====
|
====
|
||||||
## Less fiddling, more battling
|
## Less fiddling, more battling
|
||||||

|
<p align="center">
|
||||||
|
<img width="460" height="300" src="https://git.huitsinnevada.fi/NikkeDoy/FinnWarsLauncher/raw/branch/main/assets/repository/application-window.webp">
|
||||||
|
</p>
|
||||||
|
|
||||||
[EN]
|
[EN]
|
||||||
FinnWarsLauncher is a graphical user interface (GUI) application designed to launch the FinnWars game with custom server address and username settings.
|
FinnWarsLauncher is a graphical user interface (GUI) application designed to launch the FinnWars game with custom server address and username settings.
|
||||||
|
16
main.py
16
main.py
@ -5,6 +5,12 @@ import re
|
|||||||
import userdata
|
import userdata
|
||||||
import asyncio
|
import asyncio
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def resource_path(relative_path):
|
||||||
|
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
return os.path.join(base_path, relative_path)
|
||||||
|
|
||||||
def save_preferences():
|
def save_preferences():
|
||||||
userdata.save_preferences({"server": server_address_field.get(), "username": username_field.get()})
|
userdata.save_preferences({"server": server_address_field.get(), "username": username_field.get()})
|
||||||
@ -28,8 +34,9 @@ def launch_exe():
|
|||||||
print("IP Address: " + server_address_field.get())
|
print("IP Address: " + server_address_field.get())
|
||||||
print("Username: " + username_field.get())
|
print("Username: " + username_field.get())
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
["BF1942.exe","+game","FinnWars","+restart","1","+game","FinnWars","+joinServer",server_address_field.get()]
|
["./Battlefield 1942/Battlefield 1942/BF1942.exe","+game","FinnWars","+restart","1","+game","FinnWars","+joinServer",server_address_field.get()]
|
||||||
)
|
)
|
||||||
|
root.quit
|
||||||
|
|
||||||
def validate_server_address(server_address):
|
def validate_server_address(server_address):
|
||||||
ip_regex = r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"
|
ip_regex = r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"
|
||||||
@ -63,6 +70,7 @@ preferences = userdata.get_preferences()
|
|||||||
# Create the main window
|
# Create the main window
|
||||||
root = Tk()
|
root = Tk()
|
||||||
root.title("FinnWarsLauncher | Koitelinkoski (v0.0.1)")
|
root.title("FinnWarsLauncher | Koitelinkoski (v0.0.1)")
|
||||||
|
root.resizable(False, False)
|
||||||
#width = 720
|
#width = 720
|
||||||
#height = 360
|
#height = 360
|
||||||
|
|
||||||
@ -73,7 +81,7 @@ window_height = int(360*scaling)
|
|||||||
root.geometry(str(window_width) + "x" + str(window_height))
|
root.geometry(str(window_width) + "x" + str(window_height))
|
||||||
|
|
||||||
# Background image scaled correctly
|
# Background image scaled correctly
|
||||||
image = Image.open("./assets/background.png")
|
image = Image.open(resource_path("assets/background.png"))
|
||||||
resized_image = image.resize((window_width, window_height))
|
resized_image = image.resize((window_width, window_height))
|
||||||
photo = ImageTk.PhotoImage(resized_image)
|
photo = ImageTk.PhotoImage(resized_image)
|
||||||
|
|
||||||
@ -108,9 +116,7 @@ menu_bar = Menu(root)
|
|||||||
root.config(menu=menu_bar)
|
root.config(menu=menu_bar)
|
||||||
|
|
||||||
file_menu = Menu(root, tearoff=0)
|
file_menu = Menu(root, tearoff=0)
|
||||||
file_menu.add_command(label="Open")
|
file_menu.add_command(label="Settings")
|
||||||
file_menu.add_command(label="Save")
|
|
||||||
file_menu.add_separator()
|
|
||||||
file_menu.add_command(label="Exit", command=root.quit)
|
file_menu.add_command(label="Exit", command=root.quit)
|
||||||
menu_bar.add_cascade(label="File", menu=file_menu)
|
menu_bar.add_cascade(label="File", menu=file_menu)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user