Skip to content

Commit

Permalink
Merge pull request #3 from Midrooms/main
Browse files Browse the repository at this point in the history
v2.2
  • Loading branch information
Midrooms authored Feb 27, 2024
2 parents b1c683e + 277a665 commit 7dc614c
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 540 deletions.
3 changes: 1 addition & 2 deletions AstralExpress.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@echo off
cd %CD%\Resources\Astral

cd %CD% \Resources\Astral
python -c "import pkg_resources" 2> nul
if errorlevel 1 (
echo "Python is not installed. Please install Python first."
Expand Down
134 changes: 101 additions & 33 deletions Resources/Astral/AstralExpress.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,123 @@
import customtkinter
import subprocess
from customtkinter import *
import tkinter as tk
import subprocess
import configparser
import os
import time
from pypresence import Presence
from pypresence.exceptions import DiscordNotFound

rpc = Presence(client_id="1200190629897052181")
rpc.connect()
rpc.update(
large_image="plus",
details="Space anime game server tool!",
buttons=[
{"label": "Github", "url": "https://github.com/AstralPlus/AstralExpress"}
]
)

try:
rpc.connect()
rpc.update(
large_image="plus",
details="Space anime game server tool",
buttons=[
{"label": "Github", "url": "https://github.com/AstralPlus/AstralExpress"}
]
)
except DiscordNotFound:
print("Discord not detected. RPC will not run.")

customtkinter.set_appearance_mode("dark")
customtkinter.set_default_color_theme("blue")
current_dir = os.path.dirname(os.path.abspath(__file__))

app = customtkinter.CTk()
app.geometry("325x160")
app.configure(bg="#242424")
app.resizable(False, False)
app = CTk()
app.geometry("355x255")
app.resizable(True, False)

current_dir = os.path.dirname(os.path.abspath(__file__))
app.wm_iconbitmap(os.path.join(current_dir, 'astral.ico'))
app.wm_title("Astral Express v2.1")
title = tk.Label(app, text="Welcome to Astral Express", font=("Arial", 20, "bold"), bg="#242424", fg="white")
title.pack()
set_default_color_theme("blue")
app.wm_title("Astral Express v2.2")

current_dir = os.path.dirname(os.path.realpath(__file__))
tabview = CTkTabview(master=app)
tabview.pack(padx=0, pady=0)
tabview.add("Game")
tabview.add("Settings")

def button_callback1():
subprocess.run(f'cmd /c start cmd /k "cd /d {current_dir} && scripts.bat 1"', shell=True)
launch_game = tk.BooleanVar()
game_path = tk.StringVar()
close_game_on_exit = tk.BooleanVar()
script_dir = os.path.dirname(os.path.realpath(__file__))
scripts_path = os.path.join(script_dir, 'scripts.bat')

def button_callback2():
subprocess.run(f'cmd /c start cmd /k "cd /d {current_dir} && scripts.bat 2"', shell=True)
def launch_program():
subprocess.Popen(f'"{scripts_path}" 1', shell=True)

if launch_game.get() and game_path.get():
time.sleep(5)
game_path_full = game_path.get()
subprocess.Popen(game_path_full, shell=True)

def button_callback3():
subprocess.run(f'cmd /c start cmd /k "cd /d {current_dir} && scripts.bat 3"', shell=True)
def rebuild_server():
cmd = f'{scripts_path} 2'
subprocess.Popen(["start", "cmd", "/k", cmd], shell=True)

def proxyOFF_exit():
subprocess.Popen(f'"{scripts_path}" 3', shell=True)
app.destroy()

button1 = CTkButton(master=tabview.tab("Game"), text="Start server", command=launch_program, fg_color="#C6829B", hover_color="#843E58")
button2 = CTkButton(master=tabview.tab("Game"), text="Rebuild server", command=rebuild_server, fg_color="#668cbd", hover_color="#37506F")
button3 = CTkButton(master=tabview.tab("Game"), text="Stop proxy & exit", command=proxyOFF_exit, fg_color="#A60003", hover_color="dark red")
button1.pack(padx=10, pady=10)
button2.pack(padx=10, pady=10)
button3.pack(padx=10, pady=10)


def update_button_text(*args):
if launch_game.get() and game_path.get():
button1.configure(text="Start server & launch game")
else:
button1.configure(text="Start server")

launch_game.trace_add("write", update_button_text)
game_path.trace_add("write", update_button_text)

label1 = CTkLabel(master=tabview.tab("Settings"), text="Launch game with server")
label1.grid(row=0, column=0, sticky='w', padx=10, pady=10)
checkbox = CTkCheckBox(master=tabview.tab("Settings"), text="", variable=launch_game)
checkbox.grid(row=0, column=1, sticky='e', padx=10, pady=10)

label2 = CTkLabel(master=tabview.tab("Settings"), text="Game Path")
label2.grid(row=1, column=0, sticky='w', padx=10, pady=0)
textbox = CTkEntry(master=tabview.tab("Settings"), textvariable=game_path)
textbox.grid(row=1, column=1, sticky='e', padx=10, pady=0)

def update_game_path_visibility(*args):
if launch_game.get():
label2.grid()
textbox.grid()
else:
label2.grid_remove()
textbox.grid_remove()

launch_game.trace_add("write", update_game_path_visibility)

def save_settings():
config = configparser.ConfigParser()
config['DEFAULT'] = {'LaunchGame': launch_game.get(),
'CloseGameOnExit': close_game_on_exit.get(),
'GamePath': game_path.get().replace("\\", "\\\\")}
script_dir = os.path.dirname(os.path.realpath(__file__))
settings_path = os.path.join(script_dir, 'settings.ini')
with open(settings_path, 'w') as configfile:
config.write(configfile)

button1 = customtkinter.CTkButton(app, text="Start server & enable proxy", command=button_callback1, fg_color="#C6829B", hover_color="#843E58")
button1.pack(pady=5)
save_button = CTkButton(master=tabview.tab("Settings"), text="Save Settings", command=save_settings)
save_button.grid(row=3, column=0, columnspan=2, padx=10, pady=10)

button2 = customtkinter.CTkButton(app, text="Build/repair server", command=button_callback2, fg_color="#7DABE6", hover_color="#37506F")
button2.pack(pady=5)
config = configparser.ConfigParser()
script_dir = os.path.dirname(os.path.realpath(__file__))
settings_path = os.path.join(script_dir, 'settings.ini')
config.read(settings_path)
if 'DEFAULT' in config:
launch_game.set(config['DEFAULT'].getboolean('LaunchGame', False))
close_game_on_exit.set(config['DEFAULT'].getboolean('CloseGameOnExit', False))
game_path.set(config['DEFAULT'].get('GamePath', ''))

button3 = customtkinter.CTkButton(app, text="Stop proxy & exit", command=button_callback3, fg_color="#A60003", hover_color="dark red")
button3.pack(pady=5)
update_button_text()
update_game_path_visibility()

app.mainloop()
7 changes: 1 addition & 6 deletions Resources/Astral/scripts.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ goto end
cd ..\LunarCore
start cmd /k "java -jar LunarCore.jar"
cd ..\Astral\proxy
call StarRail.HttpProxy.exe
start StarRail.HttpProxy.exe
exit
goto end

Expand All @@ -31,11 +31,6 @@ taskkill /f /im StarRail.HttpProxy.exe
certutil -user -delstore root ae8fe14dc72938ad5b1ed3889dd8e2ec619a50cf
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "" /f
cls
color 3
echo The proxy has been disabled.
echo You have to close the server terminal manually.
pause
exit
goto end

Expand Down
4 changes: 4 additions & 0 deletions Resources/Astral/settings.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[DEFAULT]
launchgame = False
gamepath =

83 changes: 0 additions & 83 deletions Resources/LunarCore/docs/README_fr-FR.md

This file was deleted.

83 changes: 0 additions & 83 deletions Resources/LunarCore/docs/README_ja-JP.md

This file was deleted.

Loading

0 comments on commit 7dc614c

Please sign in to comment.