def _test() -> None: """Test the GUI.""" from srctools.logger import init_logging from tk_tools import TK_ROOT from BEE2_config import GEN_OPTS from packageLoader import find_packages, PACKAGE_SYS init_logging() # Setup images to read from packages. print('Loading packages for images.') GEN_OPTS.load() find_packages(GEN_OPTS['Directories']['package']) img.load_filesystems(PACKAGE_SYS.values()) print('Done.') left_frm = ttk.Frame(TK_ROOT) right_canv = tkinter.Canvas(TK_ROOT) left_frm.grid(row=0, column=0, sticky='NSEW', padx=8) right_canv.grid(row=0, column=1, sticky='NSEW', padx=8) TK_ROOT.rowconfigure(0, weight=1) TK_ROOT.columnconfigure(1, weight=1) slot_dest = [] slot_src = [] class TestItem: def __init__( self, name: str, icon: str, group: str=None, group_icon: str=None, ) -> None: self.name = name self.dnd_icon = img.png('items/clean/{}.png'.format(icon)) self.dnd_group = group if group_icon: self.dnd_group_icon = img.png('items/clean/{}.png'.format(group_icon)) def __repr__(self) -> str: return '<Item {}>'.format(self.name) manager = Manager[TestItem](TK_ROOT, config_icon=True) def func(ev): def call(slot): print('Cback: ', ev, slot) return call for event in Event: manager.reg_callback(event, func(event)) items = [ TestItem('Dropper', 'dropper'), TestItem('Entry', 'entry_door'), TestItem('Exit', 'exit_door'), TestItem('Large Obs', 'large_obs_room'), TestItem('Faith Plate', 'faithplate'), TestItem('Standard Cube', 'cube', 'ITEM_CUBE', 'cubes'), TestItem('Companion Cube', 'companion_cube', 'ITEM_CUBE', 'cubes'), TestItem('Reflection Cube', 'reflection_cube', 'ITEM_CUBE', 'cubes'), TestItem('Edgeless Cube', 'edgeless_safety_cube', 'ITEM_CUBE', 'cubes'), TestItem('Franken Cube', 'frankenturret', 'ITEM_CUBE', 'cubes'), TestItem('Repulsion Gel', 'paintsplat_bounce', 'ITEM_PAINT_SPLAT', 'paints'), TestItem('Propulsion Gel', 'paintsplat_speed', 'ITEM_PAINT_SPLAT', 'paints'), TestItem('Reflection Gel', 'paintsplat_reflection', 'ITEM_PAINT_SPLAT', 'paints'), TestItem('Conversion Gel', 'paintsplat_portal', 'ITEM_PAINT_SPLAT', 'paints'), TestItem('Cleansing Gel', 'paintsplat_water', 'ITEM_PAINT_SPLAT', 'paints'), ] for y in range(8): for x in range(4): slot = manager.slot(left_frm, source=False, label=(format(x + 4*y, '02') if y < 3 else '')) slot.grid(column=x, row=y, padx=1, pady=1) slot_dest.append(slot) for i, item in enumerate(items): slot = manager.slot(right_canv, source=True, label=format(i+1, '02')) slot_src.append(slot) slot.contents = item def configure(e): manager.flow_slots(right_canv, slot_src) configure(None) right_canv.bind('<Configure>', configure) ttk.Button( TK_ROOT, text='Debug', command=lambda: print('Dest:', [slot.contents for slot in slot_dest]) ).grid(row=2, column=0) ttk.Button( TK_ROOT, text='Debug', command=lambda: print('Source:', [slot.contents for slot in slot_src]) ).grid(row=2, column=1) name_lbl = ttk.Label(TK_ROOT, text='') name_lbl.grid(row=3, column=0) def enter(slot): if slot.contents is not None: name_lbl['text'] = 'Name: ' + slot.contents.name def exit(slot): name_lbl['text'] = '' manager.reg_callback(Event.HOVER_ENTER, enter) manager.reg_callback(Event.HOVER_EXIT, exit) manager.reg_callback(Event.CONFIG, lambda slot: messagebox.showinfo('Hello World', str(slot.contents))) TK_ROOT.deiconify() TK_ROOT.mainloop()
"""Replacement for Valve's VRAD. This allows us to change the arguments passed in, edit the BSP after instances are collapsed, and pack files. """ # Run as early as possible to catch errors in imports. from srctools.logger import init_logging LOGGER = init_logging('bee2/vrad.log') import os import shutil import subprocess import sys from datetime import datetime from io import BytesIO, StringIO from zipfile import ZipFile from typing import Iterator, List, Tuple, Set import srctools import utils from srctools import Property, Vec from srctools.bsp import BSP, BSP_LUMPS from srctools.filesys import ( RawFileSystem, VPKFileSystem, ZipFileSystem, FileSystem, ) from srctools.packlist import PackList, FileType as PackType, load_fgd from srctools.game import find_gameinfo from srctools.bsp_transform import run_transformations
import tkMarkdown from srctools.logger import init_logging, get_logger import tk_tools import utils if __name__ == '__main__': utils.fix_cur_directory() LOGGER = init_logging( '../logs/compiler_pane.log', __name__, on_error=tk_tools.on_error ) utils.setup_localisations(LOGGER) else: LOGGER = get_logger(__name__) from tkinter import * from tk_tools import TK_ROOT, FileField from tkinter import ttk from tkinter import filedialog from PIL import Image, ImageTk from typing import Dict, Tuple import os from BEE2_config import ConfigFile, GEN_OPTS from packageLoader import CORRIDOR_COUNTS, CorrDesc from tooltip import add_tooltip, set_tooltip import selectorWin import SubPane
"""Replaces VRAD, to run operations on the final BSP.""" from srctools.logger import init_logging LOGGER = init_logging('srctools/vrad.log') import sys import os from srctools.bsp import BSP, BSP_LUMPS from srctools.bsp_transform import run_transformations from srctools.game import find_gameinfo from srctools.packlist import PackList, load_fgd def main(argv): LOGGER.info('Srctools VRAD hook started!') game_info = find_gameinfo(argv) fsys = game_info.get_filesystem() fsys.open_ref() packlist = PackList(fsys) LOGGER.info('Gameinfo: {}\nSearch path: \n{}', game_info.path, '\n'.join([sys[0].path for sys in fsys.systems])) fgd = load_fgd() LOGGER.info('Loading soundscripts...')
"""Runs before VRAD, to run operations on the final BSP.""" import argparse import datetime import sys from collections import defaultdict from io import BytesIO from logging import FileHandler from pathlib import Path from zipfile import ZipFile from srctools import Property from srctools.filesys import ZipFileSystem from srctools.logger import init_logging, Formatter # Put the logs in the executable folders. LOGGER = init_logging(Path(sys.argv[0]).with_name('postcompiler.log')) from srctools.fgd import FGD from srctools.bsp import BSP, BSP_LUMPS from srctools.bsp_transform import run_transformations from srctools.packlist import PackList from srctools.scripts import config from srctools.compiler import propcombine from typing import List, Dict def main(argv: List[str]) -> None: parser = argparse.ArgumentParser( description="Modifies the BSP file, allowing additional entities " "and bugfixes.", )
"""Replaces VRAD, to run operations on the final BSP.""" from srctools.logger import init_logging LOGGER = init_logging('srctools/vrad.log') import sys import os from srctools.bsp import BSP, BSP_LUMPS from srctools.bsp_transform import run_transformations from srctools.game import find_gameinfo from srctools.packlist import PackList, load_fgd def main(argv): LOGGER.info('Srctools VRAD hook started!') game_info = find_gameinfo(argv) fsys = game_info.get_filesystem() fsys.open_ref() packlist = PackList(fsys) LOGGER.info('Gameinfo: {}\nSearch path: \n{}', game_info.path, '\n'.join([sys[0].path for sys in fsys.systems])) fgd = load_fgd() LOGGER.info('Loading soundscripts...') packlist.load_soundscript_manifest('srctools_sndscript_data.vdf')
"""Replacement for Valve's VRAD. This allows us to change the arguments passed in, edit the BSP after instances are collapsed, and pack files. """ # Run as early as possible to catch errors in imports. from srctools.logger import init_logging LOGGER = init_logging('bee2/vrad.log') import os import shutil import subprocess import sys from datetime import datetime from io import BytesIO, StringIO from zipfile import ZipFile from typing import Iterator, List, Tuple, Set import srctools import utils from srctools import Property, Vec from srctools.bsp import BSP, BSP_LUMPS from srctools.filesys import ( RawFileSystem, VPKFileSystem, ZipFileSystem, FileSystem, ) from srctools.packlist import PackList, FileType as PackType, load_fgd from srctools.game import find_gameinfo from srctools.bsp_transform import run_transformations
import tk_tools import utils from srctools.logger import init_logging, get_logger if __name__ == '__main__': utils.fix_cur_directory() LOGGER = init_logging(str(utils.install_path('logs/compiler_pane.log')), __name__, on_error=tk_tools.on_error) utils.setup_localisations(LOGGER) else: LOGGER = get_logger(__name__) from tkinter import * from tk_tools import TK_ROOT, FileField from tkinter import ttk from tkinter import filedialog from PIL import Image, ImageTk from BEE2_config import ConfigFile, GEN_OPTS, option_handler from packageLoader import CORRIDOR_COUNTS, CorrDesc from tooltip import add_tooltip, set_tooltip from srctools import Property, AtomicWriter import selectorWin import tkMarkdown import SubPane import img import base64 from typing import Dict, Tuple, Optional