from packageLoader import PakObject, ExportData, ParseData, desc_parse import BEE2_config from tooltip import add_tooltip import tkMarkdown import utils import srctools.logger import img import sound from typing import Union, Callable, List, Tuple, Optional LOGGER = srctools.logger.get_logger(__name__) # Functions for each widget. # The function is passed a parent frame, StringVar, and Property block. WidgetLookup = utils.FuncLookup('Widgets') # Override for timer-type widgets to be more compact - passed a num:var dict # of StringVars instead. The widgets should insert themselves into the parent # frame. WidgetLookupMulti = utils.FuncLookup('Multi-Widgets') CONFIG = BEE2_config.ConfigFile('item_cust_configs.cfg') CONFIG_ORDER = [] # type: List[ConfigGroup] TIMER_NUM = ['inf'] + list(map(str, range(3, 31))) INF = '∞' # For itemvariant, we need to refresh on style changes. ITEM_VARIANT_LOAD = []
Most functions are also altered to allow defaults instead of erroring. """ from configparser import ConfigParser, NoOptionError, SectionProxy from typing import Any, Mapping from srctools import AtomicWriter, Property import utils import srctools.logger LOGGER = srctools.logger.get_logger(__name__) # Functions for saving or loading application settings. # Call with a block to load, or with no args to return the current # values. option_handler = utils.FuncLookup('OptionHandlers') # type: utils.FuncLookup def get_curr_settings() -> Property: """Return a property tree defining the current options.""" props = Property('', []) for opt_id, opt_func in option_handler.items(): opt_prop = opt_func() # type: Property opt_prop.name = opt_id.title() props.append(opt_prop) return props def apply_settings(props: Property):
List, Tuple, Optional, Iterable, Set, ) import utils if TYPE_CHECKING: from precomp.tiling import TileDef LOGGER = srctools.logger.get_logger(__name__) # Algorithms to use. GEN_CLASSES: utils.FuncLookup['Generator'] = utils.FuncLookup('Generators') # These can just be looked up directly. SPECIAL: 'Generator' OVERLAYS: 'Generator' class GenCat(Enum): """Categories of textures, each with a generator.""" NORMAL = 'normal' # Normal tiles PANEL = 'panel' # Different textures for on panels, similar things. BULLSEYE = 'bullseye' # With a Faith Plate target. # Non-wall/floor/ceiling SPECIAL = 'special' # Assorted textures for various purposes. OVERLAYS = 'overlays' # info_overlay materials.
List, Tuple, Optional, Iterable, Set, ) import utils if TYPE_CHECKING: from tiling import TileDef LOGGER = srctools.logger.get_logger(__name__) # Algorithms to use. GEN_CLASSES = utils.FuncLookup('Generators') # These can just be looked up directly. SPECIAL: 'Generator' OVERLAYS: 'Generator' Clump = namedtuple('Clump', 'x1 y1 z1 x2 y2 z2 seed') class GenCat(Enum): """Categories of textures, each with a generator.""" NORMAL = 'normal' # Normal tiles PANEL = 'panel' # Different textures for on panels, similar things. BULLSEYE = 'bullseye' # With a Faith Plate target. # Non-wall/floor/ceiling
from configparser import ConfigParser, NoOptionError, SectionProxy, ParsingError from pathlib import Path from typing import Any, Mapping, Optional, Callable, Iterator from threading import Lock, Event from atomicwrites import atomic_write from srctools import Property, KeyValError import utils import srctools.logger LOGGER = srctools.logger.get_logger(__name__) # Functions for saving or loading application settings. # The palette attribute indicates if this will be persisted in palettes. OPTION_LOAD: utils.FuncLookup[Callable[[Property], None]] = utils.FuncLookup( 'LoadHandler', attrs=['from_palette']) OPTION_SAVE: utils.FuncLookup[Callable[[], Property]] = utils.FuncLookup( 'SaveHandler', attrs=['to_palette']) def get_curr_settings(*, is_palette: bool) -> Property: """Return a property tree defining the current options.""" props = Property.root() for opt_id, opt_func in OPTION_SAVE.items(): # Skip if it opts out of being on the palette. if is_palette and not getattr(opt_func, 'to_palette', True): continue opt_prop = opt_func() opt_prop.name = opt_id.title() props.append(opt_prop)