home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Scripts / PickInit.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-10-27  |  8.4 KB  |  210 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Bladex
  5. import copy_reg
  6. import types
  7. GlobalModulesCache = None
  8. GlobalFunctionsCache = None
  9. GlobalCFunctionsCache = None
  10.  
  11. def GetGlobalsAux():
  12.     import sys
  13.     
  14.     try:
  15.         1 + ''
  16.     except:
  17.         frame = sys.exc_info()[2].tb_frame.f_back
  18.  
  19.     while frame:
  20.         globs = frame.f_globals
  21.         frame = frame.f_back
  22.     return globs
  23.  
  24.  
  25. def GetGlobalsAux2(req_type):
  26.     g = GetGlobalsAux()
  27.     elems = []
  28.     for i in g.items():
  29.         pass
  30.     
  31.     return elems
  32.  
  33.  
  34. def ConstSound(sound_name, sound_file, volume, base_volume, min_distance, max_distance, scale, send_notify):
  35.     s = Bladex.CreateSound(sound_file, sound_name)
  36.     if not s:
  37.         return None
  38.     
  39.     s.Volume = volume
  40.     s.BaseVolume = base_volume
  41.     s.MinDistance = min_distance
  42.     s.MaxDistance = max_distance
  43.     s.Scale = scale
  44.     s.SendNotify = send_notify
  45.     return s
  46.  
  47.  
  48. def RedSound(s):
  49.     return (ConstSound, (s.Name, '', s.Volume, s.BaseVolume, s.MinDistance, s.MaxDistance, s.Scale, s.SendNotify))
  50.  
  51.  
  52. def RegisterPickSound():
  53.     gmadlig = Bladex.CreateSound('../../sounds/golpe-madera-mediana.wav', 'GolpeMaderaMediana')
  54.     copy_reg.pickle(type(gmadlig), RedSound, ConstSound)
  55.  
  56.  
  57. def ConstEntity(ent_name):
  58.     e = Bladex.GetEntity(ent_name)
  59.     return e
  60.  
  61.  
  62. def RedEntity(e):
  63.     if e:
  64.         
  65.         try:
  66.             return (ConstEntity, (e.Name,))
  67.         except:
  68.             print 'PickInit.RedEntity() can not get entity name'
  69.             return (ConstEntity, ('Invalid Entity',))
  70.  
  71.     
  72.     return (ConstEntity, ('Invalid Entity',))
  73.  
  74.  
  75. def RegisterPickEntity():
  76.     gmadlig = Bladex.GetEntity(0)
  77.     copy_reg.pickle(type(gmadlig), RedEntity, ConstEntity)
  78.  
  79.  
  80. def FindFunctionAux(module, fun_name):
  81.     if module.__dict__.has_key(fun_name):
  82.         return module.__dict__[fun_name]
  83.     
  84.     return None
  85.  
  86.  
  87. def ConstFunction(fun_name, lib_name):
  88.     funcs = GetGlobalsAux2(types.FunctionType)
  89.     for i in funcs:
  90.         pass
  91.     
  92.     global_mods = GetGlobalsAux2(types.ModuleType)
  93.     for i in global_mods:
  94.         pass
  95.     
  96.     for i in global_mods:
  97.         func = FindFunctionAux(i[1], fun_name)
  98.     
  99.     print "Warning, can't find global function", fun_name, lib_name
  100.     return None
  101.  
  102.  
  103. def RedFunction(f):
  104.     import GameStateAux
  105.     s = GameStateAux.GetFunctionFile(f)
  106.     return (ConstFunction, (f.func_name, s))
  107.  
  108.  
  109. def RegisterPickFunction():
  110.     import types
  111.     copy_reg.pickle(types.FunctionType, RedFunction, ConstFunction)
  112.  
  113.  
  114. def ConstMethod(obj_id, method_name):
  115.     import types
  116.     import ObjStore
  117.     
  118.     try:
  119.         obj = ObjStore.ObjectsStore[obj_id]
  120.         assign_func = eval('obj.' + method_name)
  121.         return assign_func
  122.     except Exception:
  123.         exc = None
  124.         print 'PickInit.ConstMethod() can not find method', obj_id, method_name
  125.         print 'Exception', exc
  126.         return None
  127.  
  128.  
  129.  
  130. def RedMethod(f):
  131.     
  132.     try:
  133.         return (ConstMethod, (f.im_class.persistent_id(f.im_self), f.im_func.func_name))
  134.     except:
  135.         print 'PickInit.RedMethod() can not register method', f
  136.         return (ConstMethod, (None, None))
  137.  
  138.  
  139.  
  140. def RegisterPickMethod():
  141.     import types
  142.     copy_reg.pickle(types.MethodType, RedMethod, ConstMethod)
  143.  
  144.  
  145. def ConstCFunction(fun_name):
  146.     print 'ConstCFunction', fun_name
  147.     funcs = GetGlobalsAux2(types.BuiltinFunctionType)
  148.     for i in funcs:
  149.         pass
  150.     
  151.     import Bladex
  152.     import Traps_C
  153.     import B3DLib
  154.     mods = (Bladex, B3DLib, Traps_C)
  155.     for i in mods:
  156.         func = FindFunctionAux(i, fun_name)
  157.     
  158.     global_mods = GetGlobalsAux2(types.ModuleType)
  159.     for i in global_mods:
  160.         pass
  161.     
  162.     print "Warning, can't find global function", fun_name
  163.     return None
  164.  
  165.  
  166. def RedCFunction(f):
  167.     return (ConstCFunction, (f.__name__,))
  168.  
  169.  
  170. def RegisterPickCFunction():
  171.     import types
  172.     copy_reg.pickle(types.BuiltinFunctionType, RedCFunction, ConstCFunction)
  173.  
  174.  
  175. def ConstSector(sec_idx):
  176.     e = Bladex.GetSector(sec_idx)
  177.     return e
  178.  
  179.  
  180. def RedSector(s):
  181.     return (ConstSector, (s.Index,))
  182.  
  183.  
  184. def RegisterPickSector():
  185.     gmadlig = Bladex.GetSector(0)
  186.     if not gmadlig:
  187.         print 'ERROR in RegisterPickSector()'
  188.         return None
  189.     
  190.     copy_reg.pickle(type(gmadlig), RedSector, ConstSector)
  191.  
  192.  
  193. def ClearCaches():
  194.     global GlobalModulesCache, GlobalFunctionsCache, GlobalCFunctionsCache
  195.     GlobalModulesCache = None
  196.     GlobalFunctionsCache = None
  197.     GlobalCFunctionsCache = None
  198.  
  199.  
  200. def Init():
  201.     ClearCaches()
  202.     RegisterPickSound()
  203.     RegisterPickEntity()
  204.     RegisterPickFunction()
  205.     RegisterPickSector()
  206.     RegisterPickMethod()
  207.     RegisterPickCFunction()
  208.     print 'Executed PickInit.Init()'
  209.  
  210.