### Load Application Configuration (Python) Source: https://context7.com/zyonoob/zyonsrs3necrogauge/llms.txt The `loadConfig` function reads the `config.json` file to load application settings. If the file does not exist, it returns an empty dictionary, indicating that initial setup is required. ```python import json import os config_path = 'config.json' def loadConfig(): if os.path.exists(config_path): with open(config_path, 'r') as f: return json.load(f) else: return {} # Usage config = loadConfig() if config: print(f"Loaded resolution: {config.get('resolution')}") print(f"Update rate: {config.get('update_rate')}ms") else: print("No config found, starting setup wizard...") ``` -------------------------------- ### Get Available Resolutions (Python) Source: https://context7.com/zyonoob/zyonsrs3necrogauge/llms.txt The `getAvailableResolutions` function scans the 'assets' directory to identify and return a list of supported resolution presets. These presets are used for configuring the UI overlay. ```python import os import re base_path = os.path.abspath(".") def getAvailableResolutions(): resolutions = [] for folder in os.listdir(os.path.join(base_path, 'assets')): if re.match(r'reso_*', folder): resolutions.append(folder) return resolutions # Usage available = getAvailableResolutions() print(f"Available resolutions: {available}") # Output: ['reso_1920x1080', 'reso_2560x1440', 'reso_3840x2160'] ``` -------------------------------- ### Get Windows Scaling Options (Python) Source: https://context7.com/zyonoob/zyonsrs3necrogauge/llms.txt The `getWindowsScalingOptions` function retrieves a list of available Windows display scaling options (e.g., '100', '125', '150') for a specified resolution preset. This helps in adapting the UI to different display settings. ```python import os base_path = os.path.abspath(".") def getWindowsScalingOptions(resolution): scaling_options = [] path = os.path.join(base_path, 'assets', resolution) if os.path.exists(path): for folder in os.listdir(path): scaling_options.append(folder) return scaling_options # Usage scaling = getWindowsScalingOptions('reso_1920x1080') print(f"Available scaling options: {scaling}") # Output: ['100', '125', '150'] ``` -------------------------------- ### Get Buff Bar Size Options (Python) Source: https://context7.com/zyonoob/zyonsrs3necrogauge/llms.txt The `getBuffbarSizeOptions` function returns the available buff bar size presets (e.g., 'small', 'medium', 'large') for a given resolution and Windows scaling combination. This allows customization of the buff tracking area. ```python import os base_path = os.path.abspath(".") def getBuffbarSizeOptions(resolution, windows_scaling): buffbar_sizes = [] path = os.path.join(base_path, 'assets', resolution, windows_scaling) if os.path.exists(path): for folder in os.listdir(path): buffbar_sizes.append(folder) return buffbar_sizes # Usage sizes = getBuffbarSizeOptions('reso_1920x1080', '100') print(f"Available buff bar sizes: {sizes}") # Output: ['large', 'medium', 'small'] ``` -------------------------------- ### Build and Run Application with UV and PyInstaller (Bash) Source: https://context7.com/zyonoob/zyonsrs3necrogauge/llms.txt Provides command-line instructions for managing project dependencies using 'uv sync' and running the Python application. It also details how to build a standalone executable using PyInstaller, including adding data files and an icon, and how to run the generated executable. ```bash # Install dependencies with uv uv sync # Run the application directly uv run python necro_gauge.py # Build standalone executable uv run pyinstaller --onefile --noconsole --add-data "assets:assets" necro_gauge.py --icon="assets/appicon.png" # Run the built executable (found in dist/ folder) ./dist/necro_gauge.exe # Quit the application while running # Press Ctrl+Shift+Q or use Task Manager ``` -------------------------------- ### Template Matching for Image Detection (Python) Source: https://context7.com/zyonoob/zyonsrs3necrogauge/llms.txt Implements template matching using OpenCV to find specific images (like buff icons) within a larger screenshot. It converts images to grayscale for efficient matching and returns the location and confidence score of the best match. This is crucial for identifying game elements. ```python import cv2 def findImage(template, screenshot): template_gray = cv2.cvtColor(template, cv2.COLOR_BGR2GRAY) screenshot_gray = cv2.cvtColor(screenshot, cv2.COLOR_BGR2GRAY) result = cv2.matchTemplate(screenshot_gray, template_gray, cv2.TM_CCOEFF_NORMED) _, max_val, _, max_loc = cv2.minMaxLoc(result) h, w = template_gray.shape top_left = max_loc return top_left[0], top_left[1], w, h, max_val def matchTemplates(template_list, game_screen): score_list = [] match_list = [] for template in template_list: M = findImage(template, game_screen) match_list.append(M) score_list.append(M[-1]) max_index, max_value = max(enumerate(score_list), key=lambda x: x[1]) return max_index, max_value, match_list # Usage - Detecting soul stacks template_list_souls = [] asset_path = 'assets/reso_1920x1080/100/medium' for i in range(1, 6): template_list_souls.append(cv2.imread(f'{asset_path}/soul_{i}.png', cv2.IMREAD_COLOR)) template_list_souls.append(cv2.imread(f'{asset_path}/soul_{i}_alt.png', cv2.IMREAD_COLOR)) game_screen = captureScreen() max_index, max_value, _ = matchTemplates(template_list_souls, game_screen) if max_value > 0.9: soul_count = (max_index // 2) + 1 print(f"Detected {soul_count} soul stacks (confidence: {max_value:.2f})") else: print("No soul stacks detected") ``` -------------------------------- ### Save Application Configuration (Python) Source: https://context7.com/zyonoob/zyonsrs3necrogauge/llms.txt The `saveConfig` function persists the current application settings to the `config.json` file. This ensures that user preferences are retained across application launches. ```python import json config_path = 'config.json' def saveConfig(config): with open(config_path, 'w') as f: json.dump(config, f) # Usage - Save custom configuration config = { 'resolution': 'reso_1920x1080', 'windows_scaling': '100', 'buffbar_size': 'small', 'update_rate': 50, 'track_souls': True, 'track_necrosis': True, 'track_deathsparks': True, 'main_roi': {'left': 0, 'top': 0, 'width': 795, 'height': 160}, 'scale': 0.15, 'image_position': {'x': 100, 'y': 100} } saveConfig(config) print("Configuration saved successfully") ``` -------------------------------- ### Play Audio Alerts with Pygame (Python) Source: https://context7.com/zyonoob/zyonsrs3necrogauge/llms.txt Provides functionality to play sound alerts for specific in-game events using the pygame mixer. It loads predefined sound files ('wav') for different alerts and plays them when triggered. This helps in notifying the user of important game state changes. ```python import pygame import os pygame.mixer.init() base_path = os.path.abspath(".") soul_alert_sound_path = os.path.join(base_path, 'assets', 'soul_alert.wav') necrosis_alert_sound_path = os.path.join(base_path, 'assets', 'necrosis_alert.wav') def playAlert(alert_type): if alert_type == 'soul': pygame.mixer.music.load(soul_alert_sound_path) pygame.mixer.music.play() elif alert_type == 'necrosis': pygame.mixer.music.load(necrosis_alert_sound_path) pygame.mixer.music.play() # Usage with alert state tracking soul_alert_played = False soul_count = 5 # Current detected stacks if soul_count == 5 and not soul_alert_played: playAlert('soul') soul_alert_played = True print("Soul stack alert triggered!") elif soul_count < 5: soul_alert_played = False ``` -------------------------------- ### Configuration File Structure (JSON) Source: https://context7.com/zyonoob/zyonsrs3necrogauge/llms.txt The `config.json` file stores user preferences for the RS3 Necro Gauge application. It includes settings for resolution, scaling, buff bar size, update rate, which buffs to track, and region of interest (ROI) for image processing. ```json { "resolution": "reso_3840x2160", "windows_scaling": "150", "buffbar_size": "medium", "update_rate": 50, "track_souls": true, "track_necrosis": true, "track_deathsparks": true, "main_roi": { "left": 1524, "top": 1606, "width": 795, "height": 213 }, "scale": 0.15, "image_position": { "x": 1221, "y": 1530 } } ``` -------------------------------- ### Capture Screen Region with MSS (Python) Source: https://context7.com/zyonoob/zyonsrs3necrogauge/llms.txt Captures a specified region of the screen using the mss library. This function is essential for acquiring the game's visual data for further processing. It takes a dictionary defining the region's coordinates and dimensions and returns the captured image as a NumPy array. ```python import mss import numpy as np main_roi = {'left': 1524, 'top': 1606, 'width': 795, 'height': 213} def captureScreen(): with mss.mss() as sct: screenshot = sct.grab(main_roi) return np.array(screenshot) # Usage game_screen = captureScreen() print(f"Captured screen region: {game_screen.shape}") # Output: Captured screen region: (213, 795, 4) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.