Files
SplitNotes/config.py
T
ApfelTeeSaft ca2a6d93a6 Add Multi Platform Support
MacOS and Linux Support
Refined Build Setup
2025-08-01 10:07:32 +02:00

154 lines
3.8 KiB
Python

# CONFIG FILE WITH CONSTANTS
import platform
import os
# Livesplit connection
HOST = "localhost"
PORT = 16834
# In network communication, time out after this time. (in seconds)
COM_TIMEOUT = 0.5
# Possible commands to send to LiveSplit
LS_COMMANDS = {
"best_possible": "getbestpossibletime\r\n",
"cur_split_index": "getsplitindex\r\n",
"cur_split_name": "getcurrentsplitname\r\n"
}
# Default Window Settings
DEFAULT_WINDOW = {"TITLE": "SplitNotes"}
# Default Welcome Message
DEFAULT_MSG = "Right Click to Open Notes."
# Update time for polling livesplit and other actions (in seconds)
POLLING_TIME = 0.5
# File names and path for resources
RESOURCE_FOLDER = "resources"
ICONS = {"GREEN": "green.png", "RED": "red.png", "SETTINGS": "settings_icon.png"}
SETTINGS_FILE = "config.cfg"
# Default Scrollbar Width
SCROLLBAR_WIDTH = 16
# Popup menu options
MENU_OPTIONS = {
"SINGLE": "Set Single Layout",
"DOUBLE": "Set Double Layout",
"LOAD": "Load Notes",
"BIG": "Big Font",
"SMALL": "Small Font",
"SETTINGS": "Settings"
}
# Error messages
ERRORS = {"NOTES_EMPTY": ("Error!", "Notes empty or can't be loaded!"),
"FONT_SIZE": ("Error!", "Invalid Font Size!"),
"SERVER_PORT": ("Error!", "Invalid server port!"),
"SEPARATOR": ("Error!", "Invalid split separator!")}
# Max file size for notes
MAX_FILE_SIZE = 1000000000 # 1 Giga-Byte
# To be added to title to alert user that timer is running
RUNNING_ALERT = "RUNNING"
# Font for gui widgets
GUI_FONT = ("arial", 12)
# Files that should be displayed and opened as notes
TEXT_FILES = [
("Text Files", ("*.txt", "*.log", "*.asc", "*.conf", "*.cfg")),
('All', '*')
]
# Default content of config.cfg file
DEFAULT_CONFIG = "notes=\nfont_size=12\nfont=arial\ntext_color=#000000\nbackground_color=#FFFFFF\ndouble_layout=False\nserver_port=16834\nwidth=400\nheight=300\nseparator=new_line"
NEWLINE_CONSTANT = "new_line"
# Required settings
REQUIRED_SETTINGS = ("notes",
"font",
"font_size",
"text_color",
"background_color",
"server_port",
"double_layout",
"width",
"height",
"separator"
)
# Settings window options
SETTINGS_WINDOW = {"TITLE": "Settings",
"WIDTH": 360,
"HEIGHT": 410,
"CANCEL": "Cancel",
"SAVE": "Save"}
# OPTIONS IN THE SETTINGS WINDOW
SETTINGS_OPTIONS = {"FONT": "Font",
"FONT_SIZE": "Font Size",
"TEXT_COLOR": "Text Color",
"BG_COLOR": "Background Color",
"SERVER_PORT": "LiveSplit Server port",
"DEFAULT_SERVER_PORT": "(Default is 16834)",
"DOUBLE_LAYOUT": "Use double layout",
"NEW_LINE_SEPARATOR": "Newline as split separator",
"CUSTOM_SEPARATOR": "Custom split separator"}
# Platform-specific fonts
def get_available_fonts():
"""Returns available fonts based on the platform."""
system = platform.system()
if system == "Darwin": # macOS
return ("Arial",
"Courier New",
"Georgia",
"Helvetica",
"Monaco",
"Times New Roman",
"Verdana",
"SF Pro Display")
elif system == "Linux":
return ("Arial",
"Courier New",
"DejaVu Sans",
"Liberation Sans",
"Liberation Serif",
"Ubuntu",
"Times New Roman",
"Verdana")
else: # Windows
return ("arial",
"courier new",
"fixedsys",
"ms sans serif",
"ms serif",
"system",
"times new roman",
"verdana")
AVAILABLE_FONTS = get_available_fonts()
# Platform-specific configurations
PLATFORM = platform.system()
IS_WINDOWS = PLATFORM == "Windows"
IS_MACOS = PLATFORM == "Darwin"
IS_LINUX = PLATFORM == "Linux"
# Default font adjustments for different platforms
if IS_MACOS:
GUI_FONT = ("SF Pro Display", 12)
elif IS_LINUX:
GUI_FONT = ("Ubuntu", 12)
# Application info for packaging
APP_NAME = "SplitNotes"
APP_VERSION = "1.0.0"
APP_AUTHOR = "ApfelTeeSaft"
APP_DESCRIPTION = "Software for syncing notes with LiveSplit using the LiveSplit server component."