Skip to content

Commit

Permalink
Merge pull request #152 from alvindimas05/main
Browse files Browse the repository at this point in the history
Many Fixes of Error
  • Loading branch information
MaxLastBreath authored Aug 26, 2024
2 parents 5df6eda + 095f205 commit 5165937
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 74 deletions.
15 changes: 2 additions & 13 deletions .github/workflows/build-multiplatform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,10 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.12.0"
- name: Install dependencies Linux
if: startsWith(matrix.name, 'Linux' )
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests patool screeninfo packaging wmi GPUtil psutil pyinstaller https://github.com/MaxLastBreath/ttkbootstrapFIX/zipball/master
- name: Install dependencies Windows
if: startsWith(matrix.name, 'Windows' )
run: |
python -m pip install --upgrade pip
pip install requests patool screeninfo packaging wmi GPUtil psutil pyinstaller https://github.com/MaxLastBreath/ttkbootstrapFIX/zipball/master
- name: Install dependencies MacOS
if: startsWith(matrix.name, 'MacOS' )
run: |
python -m pip install --upgrade pip
pip install requests patool screeninfo packaging wmi GPUtil psutil pyinstaller https://github.com/MaxLastBreath/ttkbootstrapFIX/zipball/master
pip install requests patool screeninfo packaging wmi GPUtil psutil pyperclip pyinstaller https://github.com/MaxLastBreath/ttkbootstrapFIX/zipball/master
- name: Build ${{ matrix.name }}
run: |
cd ./src/
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
- Remove and reinstall Tears Of The Kingdoms Update file.
- Do not use Game Version 1.0.0.

***If you cant copy benchmark on Linux...***
- Install xclip using the command below in Terminal
- ```sudo apt install xclip```

# <p align=center> 🐬 More Information 🐬 </p>
## <p align=center> 🐋 Mod Settings and More 🐋 </p>
### **Presets and Preset Settings**
Expand Down
1 change: 1 addition & 0 deletions src/modules/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def load_last_benchmark(self, name):

def load_benchmark(self):
benchmark_file = os.path.join(self.sdmc_dir, "TOTKBenchmark.txt")
print(benchmark_file)
Last_Found = None
try:
with open(benchmark_file, "r") as benchmarks:
Expand Down
52 changes: 27 additions & 25 deletions src/modules/checkpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ def checkpath(self, mode):
if self.os_platform == "Linux":
if mode == "Legacy":
flatpak = os.path.join(home_directory, ".var", "app", "org.yuzu_emu.yuzu", "config", "yuzu")
flatpak_torzu = os.path.join(home_directory, ".var", "app", "onion.torzu_emu.torzu", "config", "yuzu")
steamdeckdir = os.path.join(home_directory, ".config", "yuzu", "qt-config.ini")
sudachi = os.path.join(home_directory, ".local", "share", "sudachi")

self.Globaldir = os.path.join(home_directory, ".local", "share", "yuzu")
self.configdir = os.path.join(self.Globaldir, "config", "qt-config.ini")
Expand All @@ -39,29 +37,33 @@ def checkpath(self, mode):
self.configdir = steamdeckdir
self.TOTKconfig = os.path.join(home_directory, ".config", "yuzu", "custom")

# Check for a flatpak.
if os.path.exists(flatpak):
log.info("Detected a Legacy flatpak!")
self.configdir = os.path.join(flatpak, "qt-config.ini")
self.TOTKconfig = os.path.join(flatpak, "custom")
new_path = os.path.dirname(os.path.dirname(flatpak))
self.Globaldir = os.path.join(new_path, "data", "yuzu")

# Check for sudachi version
if os.path.exists(sudachi):
log.info("Detected a Sudachi version!")
self.configdir = os.path.join(sudachi, "qt-config.ini")
self.TOTKconfig = os.path.join(sudachi, "custom")
new_path = os.path.dirname(os.path.dirname(sudachi))
self.Globaldir = os.path.join(new_path, "data", "yuzu")

# Check for flatpack version of Torzu
if os.path.exists(flatpak_torzu):
log.info("Detected a Legacy flatpack of Torzu!")
self.configdir = os.path.join(flatpak_torzu, "qt-config.ini")
self.TOTKconfig = os.path.join(flatpak_torzu, "custom")
new_path = os.path.dirname(os.path.dirname(flatpak_torzu))
self.Globaldir = os.path.join(new_path, "data", "yuzu")
# Find any "Legacy Emulators"...
local_dir = os.path.join(home_directory, ".local", "share")
for folder in os.listdir(local_dir):
self.Globaldir = os.path.join(local_dir, folder)
if os.path.exists(os.path.join(self.Globaldir, "load", "0100F2C0115B6000")):
print(f"Found Legacy Emu folder at: {self.Globaldir}")
self.configdir = os.path.join(self.Globaldir, "qt-config.ini")
self.TOTKconfig = os.path.join(self.Globaldir, "custom")
new_path = os.path.dirname(os.path.dirname(self.Globaldir))
self.Globaldir = os.path.join(new_path, "data", "yuzu")
break
else:
self.Globaldir = os.path.join(home_directory, ".local", "share", "yuzu")

# Find any "Legacy Emulators" on flatpak...
flatpak_dir = os.path.join(home_directory, ".var", "app")
for folder in os.listdir(local_dir):
self.Globaldir = os.path.join(local_dir, folder, "config", "yuzu")
if os.path.exists(os.path.join(self.Globaldir, "load", "0100F2C0115B6000")):
print(f"Found Legacy Emu folder at: {self.Globaldir}")
self.configdir = os.path.join(self.Globaldir, "qt-config.ini")
self.TOTKconfig = os.path.join(self.Globaldir, "custom")
new_path = os.path.dirname(os.path.dirname(self.Globaldir))
self.Globaldir = os.path.join(new_path, "data", "yuzu")
break
else:
self.Globaldir = os.path.join(home_directory, ".local", "share", "yuzu")

config_parser = configparser.ConfigParser()
config_parser.read(self.configdir, encoding="utf-8")
Expand Down
43 changes: 43 additions & 0 deletions src/modules/hwinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import platform
import subprocess
import GPUtil

def get_cpu_info(log) -> [str, str]:
try:
if platform.system() == "Windows":
import wmi
w = wmi.WMI()
CPU = w.Win32_Processor()[0].Name
FREQUENCY = w.Win32_PhysicalMemory()[0].ConfiguredClockSpeed
elif platform.system() == "Darwin":
CPU = subprocess.getoutput("sysctl -n machdep.cpu.brand_string")
FREQUENCY = subprocess.getoutput("echo $(system_profiler SPMemoryDataType | grep Speed | awk '{print $2}') | awk '{print $1}'")
elif platform.system() == "Linux":
CPU = subprocess.getoutput("lscpu | grep 'Model name' | cut -f 2 -d \":\" | awk '{$1=$1}1'")
FREQUENCY = "-"
except Exception as e:
CPU = "Undetected"
FREQUENCY = "-"
log.warning(f"The GPU was not detected, nothing to be concerned about. {e}")
return CPU, FREQUENCY

def get_gpu_name(log) -> str:
# Ignore GPU on MacOS
if platform.system() == "Darwin": return ""

try:
# For NVIDIA GPU only
gpus = GPUtil.getGPUs()
gpu_name = gpus[0].name
return gpu_name
except Exception as e:
return _get_gpu_name(log)

def _get_gpu_name(log) -> str:
try:
if platform.system() == "Windows":
return subprocess.run("wmic path win32_VideoController get name").split("\n\n")[-2].lstrip()
elif platform.system() == "Linux":
return subprocess.getoutput("glxinfo | grep \"Device\"").split("(")[0].lstrip().replace("Device: ", "")
except Exception as e:
log.warning(f"The GPU was not detected, nothing to be concerned about. {e}")
47 changes: 27 additions & 20 deletions src/modules/load_elements.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pyperclip

from configuration.settings import *
from modules.benchmarks import *
from modules.util import *
Expand Down Expand Up @@ -53,27 +55,32 @@ def copy(self):
resolution = self.BEYOND_Patches["resolution"].get()
shadows = int(self.BEYOND_Patches["shadow resolution"].get().split("x")[0])

ARR = self.BEYOND_Patches["aspect ratio"].get().split("x")
New_Resolution = patch_info["resolution"]["Values"][
patch_info["resolution"]["Name_Values"].index(resolution)].split("x")
New_Resolution = convert_resolution(int(New_Resolution[0]), int(New_Resolution[1]), int(ARR[0]), int(ARR[1]))

log.info(self.Curr_Benchmark)
benchmark_result = (
f"## **{self.Curr_Benchmark}** Tears Of The Kingdom on {platform.system()}\n"
f"- **{gpu_name}**\n"
f"- **{CPU}**\n"
f"- **{total_memory}** GB RAM at **{FREQUENCY}** MHz\n"
f"- **{New_Resolution[0]}x{New_Resolution[1]}** and Shadows: **{shadows}**, FPS CAP: **{self.BEYOND_Patches['fps'].get()}**\n"
f"## Results:\n"
f"- Total Frames **{self.benchmarks[self.Curr_Benchmark]['Total Frames']}**\n"
f"- Average FPS **{self.benchmarks[self.Curr_Benchmark]['Average FPS']}**\n"
f"- 1% Lows **{self.benchmarks[self.Curr_Benchmark]['1% Low FPS']}** FPS\n"
f"- 0.1% Lows **{self.benchmarks[self.Curr_Benchmark]['0.1% Lowest FPS']}** FPS\n"
)

subprocess.run(['clip'], input=benchmark_result.strip().encode('utf-16'), check=True)
if "aspect ratio" in self.BEYOND_Patches:
ARR = self.BEYOND_Patches["aspect ratio"].get().split("x")
Resolution = patch_info["resolution"]["Values"][
patch_info["resolution"]["Name_Values"].index(resolution)].split("x")
Resolution = convert_resolution(int(Resolution[0]), int(Resolution[1]), int(ARR[0]),
int(ARR[1]))
New_Resolution = f"{Resolution[0]}x{Resolution[1]}"
else:
New_Resolution = resolution

system_os = "MacOS" if platform.system() == "Darwin" else platform.system()
benchmark_result = f"## **{self.Curr_Benchmark}** Tears Of The Kingdom on {system_os}\n"

if platform.system() != "Darwin": benchmark_result += f"- **{gpu_name}**\n"
benchmark_result += (
f"- **{CPU}**\n"
f"- **{total_memory}** GB RAM at **{FREQUENCY}** MHz\n"
f"- **{New_Resolution}** and Shadows: **{shadows}**, FPS CAP: **{self.BEYOND_Patches['fps'].get()}**\n"
f"## Results:\n"
f"- Total Frames **{self.benchmarks[self.Curr_Benchmark]['Total Frames']}**\n"
f"- Average FPS **{self.benchmarks[self.Curr_Benchmark]['Average FPS']}**\n"
f"- 1% Lows **{self.benchmarks[self.Curr_Benchmark]['1% Low FPS']}** FPS\n"
f"- 0.1% Lows **{self.benchmarks[self.Curr_Benchmark]['0.1% Lowest FPS']}** FPS\n"
)

pyperclip.copy(benchmark_result)
self.on_canvas.create_label(
master=self.window, canvas=canvas,
text=f"{gpu_name}\n"
Expand Down
20 changes: 4 additions & 16 deletions src/modules/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import os
from modules.scaling import *
from modules.macos import macos_path
import subprocess
import modules.hwinfo as hwinfo

def start_logger():
filename = "logger.txt"
Expand All @@ -27,12 +29,8 @@ def start_logger():

log = start_logger()

try:
gpus = GPUtil.getGPUs()
gpu_name = gpus[0].name
except Exception as e:
log.warning(f"The GPU was not detected, nothing to be concerned about. {e}")
gpu_name = "Undetected"
CPU, FREQUENCY = hwinfo.get_cpu_info(log)
gpu_name = hwinfo.get_gpu_name(log)

# Print Memory
try:
Expand All @@ -43,16 +41,6 @@ def start_logger():
log.warning(f"The System Memory was not detected, nothing to be concerned about. {e}")
total_memory = "Undetected"

try:
import wmi
w = wmi.WMI()
CPU = w.Win32_Processor()[0].Name
FREQUENCY = w.Win32_PhysicalMemory()[0].ConfiguredClockSpeed
except Exception as e:
CPU = "Linux Undetected"
FREQUENCY = ""
log.info("Failed to import wmi, most likely LINUX.")

log.info(f"\n\n\n\nAttempting to start Application.\n"
f"__SystemINFO__\n"
f"System: {platform.system()}\n"
Expand Down
1 change: 1 addition & 0 deletions src/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pyinstaller==6.9.0
pyinstaller-hooks-contrib==2024.7
pyobjc-core==10.3.1
pyobjc-framework-Cocoa==10.3.1
pyperclip==1.9.0
requests==2.31.0
screeninfo==0.8.1
setuptools==70.2.0
Expand Down

0 comments on commit 5165937

Please sign in to comment.