def LocalSvcCall(self, args): import htmlwriter import service kw = htmlwriter.PythonizeArgs(args) if 'service' not in kw: log.LogError('Invalid LocalSvc args:', args, ' (missing service)') return sv = kw['service'] del kw['service'] if 'method' not in kw: log.LogError('Invalid LocalSvc args:', args, ' (missing method)') return method = kw['method'] del kw['method'] svc = sm.GetService(sv) access = svc.__exportedcalls__.get(method, []) if access and type(access) in (types.ListType, types.TupleType): access = access[0] elif type(access) == types.DictType: access = access.get('role', 0) else: access = 0 if access & service.ROLE_IGB: apply(getattr(svc, method), (), kw) else: log.LogError('Invalid LocalSvc args:', args, ' (method not allowed)')
def LoadTypeIcon(self, *args): attrs = self.attrs src = attrs.src typeID = None try: typeID = int(src[9:]) except: log.LogInfo("couldn't convert string to typeID, looking up constvalue, Img::Load", src) typeID = util.LookupConstValue('type%s' % attrs.src[9:].strip().capitalize(), None) bumped = getattr(attrs, 'bumped', 0) showFitting = getattr(attrs, 'showfitting', 0) showTechLevel = getattr(attrs, 'showtechlevel', 0) isCopy = getattr(attrs, 'iscopy', 0) if not typeID: kw = htmlwriter.PythonizeArgs(src[9:]) typeID = kw.get('typeID', None) bumped = kw.get('bumped', 0) isCopy = kw.get('isCopy', 0) showFitting = kw.get('showFitting', 0) showTechLevel = kw.get('showTechLevel', 0) if typeID: if bumped: if hasattr(self, 'icon') and self.icon: self.icon.Close() self.icon = DraggableIcon(parent=self, typeID=typeID, isCopy=True if isCopy == 1 else False, state=uiconst.UI_DISABLED) if showFitting: powerEffect = None powerIcon = None powerEffects = [const.effectHiPower, const.effectMedPower, const.effectLoPower] for effect in cfg.dgmtypeeffects.get(typeID, []): if effect.effectID in powerEffects: powerEffect = cfg.dgmeffects.Get(effect.effectID, None) powerIcon = {const.effectHiPower: 11, const.effectMedPower: 10, const.effectLoPower: 9}.get(powerEffect.effectID, None) break if powerIcon: c = uiprimitives.Container(name='powericon', align=uiconst.BOTTOMRIGHT, parent=self.icon, width=attrs.width / 4, height=attrs.width / 4, idx=0) uiprimitives.Line(parent=c, align=uiconst.TOLEFT, color=(1.0, 1.0, 1.0, 0.5)) uiprimitives.Line(parent=c, align=uiconst.TOTOP, color=(1.0, 1.0, 1.0, 0.5)) uiprimitives.Fill(parent=c, padRight=2, padBottom=2, color=(0.0, 0.0, 0.0, 1.0)) pwrIcon = uicontrols.Icon(icon='ui_8_64_%s' % powerIcon, parent=c, align=uiconst.TOALL, idx=0, hint=localization.GetByLabel('UI/Common/FitsToSlot', slotType=powerEffect.displayName), ignoreSize=True) if showTechLevel: techSprite = uix.GetTechLevelIcon(None, 0, typeID) if techSprite: c = uiprimitives.Container(name='techIcon', align=uiconst.TOPLEFT, parent=self.icon, width=16, height=16, idx=0) c.children.append(techSprite) else: uicontrols.Icon(parent=self, align=uiconst.TOALL, state=uiconst.UI_DISABLED, pos=(0, 0, 0, 0), typeID=typeID, size=attrs.width, isCopy=isCopy) else: log.LogInfo('Couldnt convert', attrs.src[9:], 'to typeID')