Warn user about settings not being as required (#363)
This commit is contained in:
@@ -2,9 +2,9 @@ import os
|
||||
import threading
|
||||
import time
|
||||
|
||||
import keyboard
|
||||
from cv2 import cv2
|
||||
|
||||
from utils.auto_settings import check_settings
|
||||
from bot import Bot
|
||||
from config import Config
|
||||
from death_manager import DeathManager
|
||||
@@ -81,6 +81,11 @@ class GameController:
|
||||
os._exit(1)
|
||||
|
||||
def start(self):
|
||||
# Check if we user should update the d2r settings
|
||||
diff = check_settings(self._config)
|
||||
if len(diff) > 0:
|
||||
Logger.warning("Your D2R settings differ from the requiered ones. Please use Auto Settings to adjust them. The differences are:")
|
||||
Logger.warning(f"{diff}")
|
||||
self.screen = Screen(self._config.general["monitor"])
|
||||
# Run health monitor thread
|
||||
self.health_manager = HealthManager(self.screen)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import threading
|
||||
|
||||
import keyboard
|
||||
import os
|
||||
from beautifultable import BeautifulTable
|
||||
|
||||
@@ -76,6 +76,26 @@ def adjust_settings(config: Config):
|
||||
json.dump(curr_settings, outfile)
|
||||
print("Adapted settings succesfully. You can now restart D2R.")
|
||||
|
||||
def check_settings(config: Config) -> dict:
|
||||
# find monitor res
|
||||
sct = mss()
|
||||
monitor_idx = config.general["monitor"] + 1 # sct saves the whole screen (including both monitors if available at index 0, then monitor 1 at 1 and 2 at 2)
|
||||
if len(sct.monitors) == 1:
|
||||
print("How do you not have a monitor connected?!")
|
||||
os._exit(1)
|
||||
if monitor_idx >= len(sct.monitors):
|
||||
monitor_idx = 1
|
||||
d2_saved_games = get_d2r_folder(config)
|
||||
# adjust settings
|
||||
f = open(d2_saved_games + "\\Settings.json")
|
||||
curr_settings = json.load(f)
|
||||
f = open("assets/d2r_settings.json")
|
||||
new_settings = json.load(f)
|
||||
diff_settings = {}
|
||||
for key in new_settings:
|
||||
if key != "Window Mode" and curr_settings[key] != new_settings[key]:
|
||||
diff_settings[key] = [curr_settings[key], new_settings[key]]
|
||||
return diff_settings
|
||||
|
||||
if __name__ == "__main__":
|
||||
adjust_settings()
|
||||
|
||||
Reference in New Issue
Block a user