예제 #1
0
from menus import PagedMenu
from cvars import ConVar
from configobj import ConfigObj
from listeners import OnConVarChanged
from paths import PLUGIN_PATH
import wcs
from wcs import changerace
import core

global chosen_player
chosen_player = 0
global cats
global cat_to_change_to
cats = 0
categories_on = ConVar('wcs_activate_categories')
if categories_on.get_string() == "1":
	cats = os.path.join(PLUGIN_PATH+'/wcs', 'categories', 'categories.ini')
	cats = ConfigObj(cats)
	
unassigned_cat = ConVar('wcs_unassigned_category')

@OnConVarChanged
def on_convar_changed(convar, old_value):
	if categories_on.get_int() == 1:
		global cats
		cats = os.path.join(PLUGIN_PATH+'/wcs', 'categories', 'categories.ini')
		cats = ConfigObj(cats)


def wcsadmin_changerace_menu_build(menu, index):
	menu.clear()
예제 #2
0
class _HostnameManager(object):
    """Class used to set the hostname."""
    def __init__(self):
        """Store the base delay."""
        self._convar = ConVar('hostname')
        self._original_hostname = self._convar.get_string()
        self.delay = Delay(0.1, self._set_hostname)

    def reset_hostname(self):
        """Sets the hostname back to the original value on unload."""
        self._convar.set_string(self._original_hostname)

    def set_hostname(self):
        """Delay changing the hostname."""
        # Is there currently a delay?
        if self.delay is not None:

            # Cancel the delay
            self.delay.cancel()

        # Delay before setting the hostname
        self.delay = Delay(0.2, self._set_hostname)

    def _set_hostname(self):
        """Set the hostname to show GunGame and Included/Custom Plugins."""
        # Set the delay back to None
        self.delay = None

        # Set the hostname to the new value
        self._convar.set_string(self.get_hostname_value())

    @staticmethod
    def get_hostname_value():
        """Return the full value of the new hostname."""
        # Get the basename
        value = database['Settings']['base_name']

        # Create an empty dictionary
        plugin_values = dict()

        # Loop through all plugins in the database
        for plugin_name, values in database.items():

            # Is the plugin loaded?
            if plugin_name in gg_plugin_manager:

                if (plugin_name == 'gg_bombing_objective'
                        and not len(EntityIter('func_bomb_target'))):
                    continue

                if (plugin_name == 'gg_hostage_objective'
                        and not len(EntityIter('func_hostage_rescue'))):
                    continue

                # Store the plugin's name and priority
                plugin_values[values['name']] = int(values['priority'])

        # Are there any plugins that are loaded?
        if plugin_values:

            # Add the base_break to the string
            value += database['Settings']['base_break']

            # Sort the loaded plugins by their priority
            plugins = sorted(
                plugin_values,
                key=lambda plugin: plugin_values[plugin],
            )

            # Add all loaded plugins to the string
            # Separate each with the feature_break
            value += database['Settings']['feature_break'].join(plugins)

        return value
예제 #3
0
def load():
    global SV_MAPDL_PATH
    SV_MAPDL_PATH = ConVar("sv_mapdl_path", "tf/custom/mapdl/maps/")

    if not os.path.exists(SV_MAPDL_PATH.get_string()):
        os.makedirs(SV_MAPDL_PATH.get_string())