Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TF2CDownloader.spec
tf2c_downloader.spec
build
dist
__pycache__
Expand Down
45 changes: 20 additions & 25 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
asking questions, generally handling any sort
of communication or interactivity with the user.
"""
from os import environ, makedirs, path, rmdir
import os
from sys import exit
from time import sleep
from rich import print
from lang import lang


def message(msg, delay = 0):
"""
Expand All @@ -18,30 +16,32 @@ def message(msg, delay = 0):
print("[bold yellow]" + msg)
sleep(delay)

def message_yes_no(msg, default = None):
def message_yes_no(msg):
"""
Show a message to user and get yes/no answer.
"""
valid = lang["prompt_valid"]
prompt = lang["prompt_prompt"][default]
msg += prompt
# dont know for now how to make it properly, leaving all of pain to future-me
valid_yes = _("yes y").split()
valid_no = _("no n").split()
prompt = _("{y/n}")
msg += ' ' + prompt

while True:
print(msg)
choice = input().lower()
if default is not None and choice == "":
return valid[default]
elif choice in valid:
return valid[choice]
if choice in valid_yes:
return True
elif choice in valid_no:
return False
else:
print(lang["prompt_invalid"])
print("[bold blue]" + _("Please respond with 'yes' or 'no' (or 'y' or 'n').") + "[/bold blue]")


def message_input(msg):
"""
Show a message and get input from user.
"""
return input(msg + ' >')
return input(msg + ' > ')

def message_dir(msg):
"""
Expand All @@ -50,25 +50,20 @@ def message_dir(msg):
while True:
dir = input(msg + ": ")
if dir.count("~") > 0:
dir = path.expanduser(dir)
dir = os.path.expanduser(dir)
if dir.count("$") > 0:
dir = path.expandvars(dir)
if path.isdir(dir):
return dir
try:
makedirs(dir)
rmdir(dir)
dir = os.path.expandvars(dir)
if os.path.isdir(dir):
return dir
except Exception:
pass
message(_("The specified extraction location does not exist."))

def message_end(msg, code):
"""
Show a message and exit.
"""
print("[bold green]" + msg)
if environ.get("WT_SESSION"):
print(lang["exit_safe"])
if os.environ.get("WT_SESSION"):
print("[bold]" + _("You are safe to close this window."))
else:
input(lang["exit"])
input(_("Press Enter to exit."))
exit(code)
13 changes: 5 additions & 8 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"""
from os import path
from platform import system
from shutil import disk_usage, rmtree
from shutil import disk_usage
from subprocess import run
from lang import lang
import gui
import vars

Expand All @@ -22,17 +21,15 @@ def free_space_check():
minimum_free_download_bytes = 4831838208
minimum_free_install_bytes = 12884901888
if disk_usage(vars.TEMP_PATH)[2] < minimum_free_download_bytes:
gui.message_end(lang["free_space_download"], 1)
if not path.isdir(vars.INSTALL_PATH):
gui.message_end(lang["location_doesnt_exist"], 1)
gui.message_end(_("You don't have enough free space to download TF2 Classic. A minimum of 4.5GB on your primary drive is required."), 1)
elif disk_usage(vars.INSTALL_PATH)[2] < minimum_free_install_bytes:
gui.message_end(lang["free_space_extract"], 1)
gui.message_end(_("You don't have enough free space to extract TF2 Classic. A minimum of 12GB at your chosen extraction site is required."), 1)

def tf2c_download():
"""
Download TF2C archive.
"""
gui.message(lang["starting_download"], 3)
gui.message(_("Starting the download for TF2 Classic... You may see some errors that are safe to ignore."), 3)
run([vars.ARIA2C_BINARY, '--max-connection-per-server=16', '-UTF2CDownloaderGit', '--max-concurrent-downloads=16', '--optimize-concurrent-downloads=true', '--check-certificate=false', '--check-integrity=true', '--auto-file-renaming=false', '--continue=true', '--console-log-level=error', '--summary-interval=0', '--bt-hash-check-seed=false', '--seed-time=0',
'-d' + vars.TEMP_PATH,
'https://wiki.tf2classic.com/misc/tf2classic-latest-zst.meta4'], check=True)
Expand All @@ -41,7 +38,7 @@ def tf2c_extract():
"""
Extract archive and delete it.
"""
gui.message(lang["starting_extract"], 1)
gui.message(_("Extracting the downloaded archive, please wait patiently."), 1)
if system() == 'Windows':
run([vars.ARC_BINARY, '-overwrite', 'unarchive', path.join(vars.TEMP_PATH, 'tf2classic.tar.zst'), vars.INSTALL_PATH], check=True)
else:
Expand Down
26 changes: 0 additions & 26 deletions lang.py

This file was deleted.

35 changes: 0 additions & 35 deletions langs/el.py

This file was deleted.

35 changes: 0 additions & 35 deletions langs/en.py

This file was deleted.

35 changes: 0 additions & 35 deletions langs/es.py

This file was deleted.

35 changes: 0 additions & 35 deletions langs/fr.py

This file was deleted.

35 changes: 0 additions & 35 deletions langs/hu.py

This file was deleted.

Loading