def _createParameterizedAccessorPair(self, id, getter=None, setter=None, values=None): id = BugOptions.qualify(self._id, id) if getter: if values is None: def get(*args): option = self._getOption(id % args) if option.isColor(): return option.getColor() else: return option.getValue() else: def get(*args): option = self._getOption(id % args) return option.getValue() in values setattr(self, getter, get) if setter: def set(value, *args): option = self._getOption(id % args) option.setValue(value) setattr(self, setter, set)
def _createParameterizedAccessorPair(self, optionId, getter=None, setter=None, values=None): 'createParameterizedAccessorPair' optionId = BugOptions.qualify(self._id, optionId) if getter: if values is None: def get_fun(*args): 'getter for plain option' option = self._getOption(optionId % args) if option.isColor(): return option.getColor() return option.getValue() else: def get_fun(*args): 'getter for option in values' option = self._getOption(optionId % args) return option.getValue() in values setattr(self, getter, get_fun) if setter: def set_fun(value, *args): 'setter for option' option = self._getOption(optionId % args) option.setValue(value) setattr(self, setter, set_fun)
def _createParameterizedAccessorPair(self, id, getter=None, setter=None, values=None): id = BugOptions.qualify(self._id, id) if getter: if values is None: def get(*args): option = self._getOption(id % args) if option.isColor(): return option.getColor() else: return option.getValue() else: def get(*args): option = self._getOption(id % args) return option.getValue() in values setattr(self, getter, get) if setter: def set(value, *args): option = self._getOption(id % args) option.setValue(value) setattr(self, setter, set)
def qualify(self, id): return BugOptions.qualify(self._id, id)
## SevoPediaUtil ## ## Creates unsaved options for Sevopedia when it's accessed before BUG initializes. ## ## Copyright (c) 2008 The BUG Mod. ## ## Author: EmperorFool import BugCore import BugOptions import BugUtil AdvisorOpt = BugCore.game.Advisors enabledOption = None sortOption = None if not AdvisorOpt._hasOption("Sevopedia"): BugUtil.debug("BUG: creating stub Sevopedia option") enabledOption = BugOptions.UnsavedOption(AdvisorOpt, BugOptions.qualify(AdvisorOpt._getID(), "Sevopedia"), "boolean", False) AdvisorOpt._addOption(enabledOption) if not AdvisorOpt._hasOption("SevopediaSortItemList"): BugUtil.debug("BUG: creating stub Sevopedia Sort option") sortOption = BugOptions.UnsavedOption(AdvisorOpt, BugOptions.qualify(AdvisorOpt._getID(), "SevopediaSortItemList"), "boolean", True) AdvisorOpt._addOption(sortOption)
def qualify(self, id): return BugOptions.qualify(self._id, id)
## SevoPediaUtil ## ## Creates unsaved options for Sevopedia when it's accessed before BUG initializes. ## ## Copyright (c) 2008 The BUG Mod. ## ## Author: EmperorFool import BugCore import BugOptions import BugUtil AdvisorOpt = BugCore.game.Advisors enabledOption = None sortOption = None if not AdvisorOpt._hasOption("Sevopedia"): BugUtil.debug("BUG: creating stub Sevopedia option") enabledOption = BugOptions.UnsavedOption( AdvisorOpt, BugOptions.qualify(AdvisorOpt._getID(), "Sevopedia"), "boolean", True) AdvisorOpt._addOption(enabledOption) if not AdvisorOpt._hasOption("SevopediaSortItemList"): BugUtil.debug("BUG: creating stub Sevopedia Sort option") sortOption = BugOptions.UnsavedOption( AdvisorOpt, BugOptions.qualify(AdvisorOpt._getID(), "SevopediaSortItemList"), "boolean", True) AdvisorOpt._addOption(sortOption)
def qualify(self, qual_id): "Returns a fully qualified option ID by inserting the mod's ID if necessary." return BugOptions.qualify(self._id, qual_id)