ya2 · news · projects · code · about

removed unused files
authorFlavio Calva <f.calva@gmail.com>
Tue, 7 Jun 2022 17:53:24 +0000 (18:53 +0100)
committerFlavio Calva <f.calva@gmail.com>
Tue, 7 Jun 2022 17:53:24 +0000 (18:53 +0100)
42 files changed:
ya2/engine/audio.py [deleted file]
ya2/engine/cbmux.py [deleted file]
ya2/engine/clock.py [deleted file]
ya2/engine/configuration.py [deleted file]
ya2/engine/engine.py [deleted file]
ya2/engine/enginefacade.py [deleted file]
ya2/engine/event.py [deleted file]
ya2/engine/font.py [deleted file]
ya2/engine/gfx.py [deleted file]
ya2/engine/gui/browser.py [deleted file]
ya2/engine/gui/circle.py [deleted file]
ya2/engine/gui/gui.py [deleted file]
ya2/engine/gui/imgbtn.py [deleted file]
ya2/engine/gui/mainpage.py [deleted file]
ya2/engine/gui/menu.py [deleted file]
ya2/engine/gui/page.py [deleted file]
ya2/engine/joystick.py [deleted file]
ya2/engine/logic.py [deleted file]
ya2/engine/network/__init__.py [deleted file]
ya2/engine/network/binary.py [deleted file]
ya2/engine/network/client.py [deleted file]
ya2/engine/network/network.py [deleted file]
ya2/engine/network/server.py [deleted file]
ya2/engine/particle.py [deleted file]
ya2/engine/pause.py [deleted file]
ya2/engine/phys.py [deleted file]
ya2/engine/profiler.py [deleted file]
ya2/engine/shader.py [deleted file]
ya2/engine/vec.py [deleted file]
ya2/facade.py [deleted file]
ya2/game.py [deleted file]
ya2/lib/bullet/__init__.py [deleted file]
ya2/lib/bullet/bullet.py [deleted file]
ya2/lib/ivals.py [deleted file]
ya2/lib/p3d/audio.py [deleted file]
ya2/lib/p3d/ivals.py [deleted file]
ya2/lib/p3d/joystick.py [deleted file]
ya2/lib/p3d/particle.py [deleted file]
ya2/lib/p3d/pause.py [deleted file]
ya2/lib/p3d/shader.py [deleted file]
ya2/lib/p3d/vec.py [deleted file]
ya2/lib/p3d/widget.py [deleted file]

diff --git a/ya2/engine/audio.py b/ya2/engine/audio.py
deleted file mode 100644 (file)
index 9b95eb9..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# from ya2.gameobject import AudioColleague
-# from ya2.lib.p3d.audio import P3dSound
-
-
-# AudioSound = P3dSound
-
-
-# class EngineAudio(AudioColleague):
-
-#     def __init__(self, mediator, vol=1.0):
-#         AudioColleague.__init__(self, mediator)
-#         self.set_volume(vol)
-
-#     def set_volume(self, vol): self.eng.lib.volume = vol
diff --git a/ya2/engine/cbmux.py b/ya2/engine/cbmux.py
deleted file mode 100644 (file)
index 7b59c6a..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-# from threading import Lock
-
-
-# class CallbackMux:
-#     # this is a sort of "multiplexer" i.e. it manages callbacks from threads
-#     # and redirect them to the main thread (this prevents deadlocks)
-
-#     def __init__(self):
-#         self.lock = Lock()
-#         self.callbacks = []
-#         taskMgr.add(self.process_callbacks, 'processing callbacks')
-
-#     def add_cb(self, func, args=None):
-#         args = args or []
-#         with self.lock: self.callbacks += [(func, args)]
-
-#     def process_callbacks(self, task):
-#         with self.lock:
-#             callbacks = self.callbacks[:]
-#             self.callbacks = []
-#         for func, args in callbacks: func(*args)
-#         return task.cont
diff --git a/ya2/engine/clock.py b/ya2/engine/clock.py
deleted file mode 100644 (file)
index 38499ab..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# class Clock:
-
-#     def __init__(self, pause):
-#         self.__paused_time = 0
-#         self.__curr_stopped_time = 0
-#         pause.logic.attach(self.on_pause)
-#         pause.logic.attach(self.on_resume)
-
-#     @property
-#     def time(self): return globalClock.get_frame_time() - self.__paused_time
-
-#     def on_pause(self): self.__curr_stopped_time = globalClock.get_frame_time()
-
-#     def on_resume(self):
-#         self.__paused_time += \
-#             globalClock.get_frame_time() - self.__curr_stopped_time
diff --git a/ya2/engine/configuration.py b/ya2/engine/configuration.py
deleted file mode 100644 (file)
index 0f79818..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-# from panda3d.core import load_prc_file_data
-# from ya2.lib.builder import LibP3d
-
-
-# class GuiCfg:
-
-#     def __init__(self, fps=False, win_size='1280 720', win_orig=None,
-#                  win_title='lib', fullscreen=False, sync_video=None,
-#                  antialiasing=False, shaders=True, volume=1, fixed_fps=0):
-#         self.fps = fps
-#         self.win_size = win_size
-#         self.win_title = win_title
-#         self.win_orig = win_orig
-#         self.fullscreen = fullscreen
-#         self.sync_video = LibP3d.runtime() if sync_video is None \
-#             else sync_video
-#         self.antialiasing = antialiasing
-#         self.shaders = shaders
-#         self.volume = volume
-#         self.fixed_fps = fixed_fps
-
-
-# class ProfilingCfg:
-
-#     def __init__(self, profiling=False, pyprof_percall=False):
-#         self.profiling = profiling  # profiling with panda3d's tools
-#         self.pyprof_percall = pyprof_percall
-
-
-# class LangCfg:
-
-#     def __init__(self, lang='en', lang_path='assets/locale',
-#                  lang_domain='lib_game', languages=[('English', 'en')]):
-#         self.lang = lang
-#         self.lang_path = lang_path
-#         self.lang_domain = lang_domain
-#         self.languages = languages
-
-
-# class CursorCfg:
-
-#     def __init__(self, cursor_hidden=False, cursor_path='',
-#                  cursor_scale=(1, 1, 1), cursor_color=(1, 1, 1, 1),
-#                  cursor_hotspot=(0, 0)):
-#         self.cursor_hidden = cursor_hidden
-#         self.cursor_path = cursor_path
-#         self.cursor_scale = cursor_scale
-#         self.cursor_color = cursor_color
-#         self.cursor_hotspot = cursor_hotspot
-
-
-# class DevCfg:
-
-#     def __init__(
-#             self, mt_render=False, model_path='assets/models', excluded='',
-#             shaders_dev=False, pbr=False, gamma=1.0, menu_joypad=True,
-#             verbose='', verbose_log=False, xmpp_server='', start_wp='',
-#             port=9099, server='localhost:9098', srgb=False, opengl_3_2=False,
-#             gl_debug=False, async_textures=False, show_buffers=False,
-#             anisotropic=8, pbr_normal=True, pbr_occlusion=True,
-#             pbr_shadows=True, pbr_exposure=True, pbr_msaa_samples=4,
-#             pbr_fog=True, offscreen=False, directx=False,
-#             functional_test=False, functional_ref=False):
-#         self.multithreaded_render = mt_render  # multithreaded rendering
-#         self.model_path = model_path
-#         self.excluded = excluded
-#         self.shaders_dev = shaders_dev
-#         self.pbr = pbr
-#         self.pbr_normal = pbr_normal
-#         self.pbr_occlusion = pbr_occlusion
-#         self.pbr_shadows = pbr_shadows
-#         self.pbr_exposure = pbr_exposure
-#         self.pbr_msaa_samples = pbr_msaa_samples
-#         self.pbr_fog = pbr_fog
-#         self.gamma = gamma
-#         self.directx = directx
-#         self.menu_joypad = menu_joypad
-#         self.verbose = verbose
-#         self.verbose_log = verbose_log
-#         self.xmpp_server = xmpp_server
-#         self.port = port
-#         self.server = server
-#         self.start_wp = start_wp
-#         self.srgb = srgb
-#         self.opengl_3_2 = opengl_3_2
-#         self.gl_debug = gl_debug
-#         self.async_textures = async_textures
-#         self.show_buffers = show_buffers
-#         self.anisotropic = anisotropic
-#         self.offscreen = offscreen
-#         self.functional_test = functional_test
-#         self.functional_ref = functional_ref
-
-
-# class Cfg:
-
-#     def __init__(self, gui_cfg=None, profiling_cfg=None, lang_cfg=None,
-#                  cursor_cfg=None, dev_cfg=None):
-#         self.gui_cfg = gui_cfg or GuiCfg()
-#         self.profiling_cfg = profiling_cfg or ProfilingCfg()
-#         self.lang_cfg = lang_cfg or LangCfg()
-#         self.cursor_cfg = cursor_cfg or CursorCfg()
-#         self.dev_cfg = dev_cfg or DevCfg()
-#         self.__configure()
-
-#     @staticmethod
-#     def __set(key, val): load_prc_file_data('', key + ' ' + str(val))
-
-#     def __configure(self):
-#         cfginfo = [
-#             ('texture-anisotropic-degree', self.dev_cfg.anisotropic),
-#             # ('client-sleep', 0.001),
-#             ('texture-minfilter', 'linear_mipmap_linear'),
-#             ('gl-coordinate-system', 'default'),
-#             ('textures-power-2', 'down'),
-#             ('textures-auto-power-2', 1),
-#             ('show-frame-rate-meter', int(self.gui_cfg.fps)),
-#             ('hardware-animated-vertices', 'true'),
-#             ('x-init-threads', 'true'),
-#             # temp workaround for mtrendering (linux)
-#             ('basic-shaders-only', 'false'),
-#             ('default-model-extension', '.bam'),
-#             #('compressed-textures',  1),  # particles don't work
-#             #('model-cache-textures', 1),
-#             #('model-cache-compressed-textures', 1),
-#             #('bam-version', '6 45'),
-#             ('audio-ouput-rate', 44100)]
-#         if self.gui_cfg.win_size:
-#             cfginfo += [('win-size', self.gui_cfg.win_size)]
-#         if self.gui_cfg.win_orig:
-#             cfginfo += [('win-origin', self.gui_cfg.win_orig)]
-#         if self.dev_cfg.srgb:
-#             cfginfo += [('framebuffer-srgb', 'true')]
-#         if self.dev_cfg.opengl_3_2:
-#             cfginfo += [('gl-version', '3 2')]
-#         if self.dev_cfg.gl_debug:
-#             cfginfo += [('gl-debug', 1)]
-#         if self.dev_cfg.show_buffers:
-#             cfginfo += [('show-buffers', 'true')]
-#         if self.dev_cfg.async_textures:
-#             cfginfo += [
-#                 ('preload-textures', 0),
-#                 ('preload-simple-textures', 1),
-#                 ('texture-compression', 1),
-#                 ('allow-incomplete-render', 1)]
-#         if self.dev_cfg.directx:
-#             cfginfo += [
-#                 ('load-display', 'pandadx9')]
-#         cfginfo += [
-#             ('window-title', self.gui_cfg.win_title),
-#             ('cursor-hidden', int(self.cursor_cfg.cursor_hidden)),
-#             ('sync-video', int(self.gui_cfg.sync_video)),
-#             ('framebuffer-multisample', 1),
-#             ('multisamples', 2)]
-#         if self.dev_cfg.multithreaded_render:
-#             cfginfo += [('threading-model', '/Draw')]
-#         if self.dev_cfg.offscreen:
-#             cfginfo += [('window-type', 'offscreen')]
-#         if self.profiling_cfg.profiling:
-#             cfginfo += [
-#                 ('want-pstats', 1),
-#                 ('task-timer-verbose', 1),
-#                 ('pstats-tasks', 1),
-#                 ('gl-finish', 1),
-#                 ('pstats-host', '127.0.0.1')]
-#         for verb in self.dev_cfg.verbose.split(';'):
-#             if not verb: continue
-#             verb_el = verb.strip().split()
-#             if verb_el[0] == 'direct':
-#                 cfginfo += [
-#                     ('default-directnotify-level', verb_el[1])]
-#             elif verb_el[0] == 'panda':
-#                 cfginfo += [
-#                     ('notify-level', verb_el[1])]
-#             else:
-#                 cfginfo += [
-#                     ('notify-level-' + verb_el[0], verb_el[1])]
-#         list(map(lambda args: self.__set(*args), cfginfo))
diff --git a/ya2/engine/engine.py b/ya2/engine/engine.py
deleted file mode 100644 (file)
index 045a386..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-# from sys import path
-# from os.path import dirname, realpath
-# path.append(dirname(realpath(__file__)) + '/../thirdparty')
-
-# from ya2.lib.builder import LibBuilder
-# from ya2.engine.pause import PauseMgr
-# from ya2.engine.profiler import AbsProfiler
-# from ya2.engine.shader import ShaderMgr
-# from ya2.engine.log import LogMgr
-# from ya2.engine.font import FontMgr
-# from ya2.engine.phys import PhysMgr
-# from ya2.engine.gfx import EngineGfx
-# from ya2.engine.network.server import Server
-# from ya2.engine.network.client import Client
-# from ya2.engine.gui.gui import EngineGui
-# from ya2.engine.logic import EngineLogic
-# from ya2.engine.event import EngineEvent
-# from ya2.engine.audio import EngineAudio
-# from ya2.engine.lang import LangMgr
-# from ya2.gameobject import GameObject, Colleague
-# from ya2.engine.enginefacade import EngineFacade
-# from ya2.engine.configuration import Cfg
-# from ya2.engine.cbmux import CallbackMux
-# from ya2.engine.clock import Clock
-
-
-# class Engine(GameObject, EngineFacade):
-
-#     network_priority = -39
-
-#     def __init__(self, cfg=None, end_cb=None, client_cls=None):
-#         self.lib = LibBuilder.build()
-#         self.lib.configure()
-#         self.lib.init(end_cb=end_cb)
-#         Colleague.eng = GameObject.eng = self
-#         cfg = cfg or Cfg()  # use a default conf if not provided
-#         self.shader_mgr = ShaderMgr(cfg.dev_cfg.shaders_dev, cfg.dev_cfg.gamma)
-#         self.profiler = AbsProfiler.build(cfg.profiling_cfg.pyprof_percall)
-#         self.font_mgr = FontMgr()
-#         self.server = Server(cfg.dev_cfg.port)
-#         client_cls = client_cls or Client
-#         self.client = client_cls(cfg.dev_cfg.port, cfg.dev_cfg.server)
-#         self.cb_mux = CallbackMux()
-#         self.logic = EngineLogic(self, cfg)
-#         self.log_mgr = LogMgr.init_cls()(self)
-#         self.gfx = EngineGfx(self, cfg.dev_cfg.model_path,
-#                              cfg.gui_cfg.antialiasing,
-#                              cfg.gui_cfg.shaders,
-#                              cfg.gui_cfg.fixed_fps,
-#                              cfg.dev_cfg.srgb)
-#         self.phys_mgr = PhysMgr(self)
-#         self.event = EngineEvent(self, cfg.dev_cfg.menu_joypad,
-#                                  cfg.dev_cfg.functional_test)
-#         self.gui = EngineGui.init_cls()(self)
-#         self.audio = EngineAudio(self, cfg.gui_cfg.volume)
-#         self.pause = PauseMgr(self)
-#         self.lang_mgr = LangMgr(cfg.lang_cfg.lang,
-#                                 cfg.lang_cfg.lang_domain,
-#                                 cfg.lang_cfg.lang_path)
-#         GameObject.__init__(self)
-#         self.clock = Clock(self.pause)
-
-#     def destroy(self):
-#         GameObject.destroy(self)
-#         self.lib.destroy()
-#         self.shader_mgr.destroy()
-#         self.profiler.destroy()
-#         self.font_mgr.destroy()
-#         self.server.destroy()
-#         self.client.destroy()
-#         # self.xmpp.destroy()
-#         self.logic.destroy()
-#         self.log_mgr.destroy()
-#         self.gfx.destroy()
-#         self.phys_mgr.destroy()
-#         self.event.destroy()
-#         self.gui.destroy()
-#         self.audio.destroy()
-#         self.pause.destroy()
-#         self.lang_mgr.destroy()
-#         self.lib = self.shader_mgr = self.profiler = self.font_mgr = \
-#             self.server = self.client = None
-#         base.destroy()
diff --git a/ya2/engine/enginefacade.py b/ya2/engine/enginefacade.py
deleted file mode 100644 (file)
index e8fcaf5..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-# from math import pi
-
-
-# class EngineFacade:
-
-#     @property
-#     def version(self): return self.logic.version
-
-#     @property
-#     def curr_path(self): return self.logic.curr_path
-
-#     @property
-#     def is_appimage(self): return self.logic.is_appimage
-
-#     @property
-#     def cfg(self): return self.logic.cfg
-
-#     @property
-#     def is_runtime(self): return self.logic.is_runtime
-
-#     @property
-#     def languages(self): return self.logic.cfg.lang_cfg.languages
-
-#     @property
-#     def resolutions(self): return self.gui.resolutions
-
-#     @property
-#     def closest_resolution(self): return self.gui.closest_resolution
-
-#     @property
-#     def joystick_mgr(self): return self.event.joystick_mgr
-
-#     @property
-#     def curr_time(self): return self.clock.time
-
-#     def attach_obs(self, obs_meth, sort=10, rename='', args=None):
-#         args = args or []
-#         return self.event.attach(obs_meth, sort, rename, args)
-
-#     def detach_obs(self, obs_meth, lambda_call=None):
-#         return self.event.detach(obs_meth, lambda_call)
-#     def attach_node(self, name): return self.gfx.root.attach_node(name)
-#     def particle(
-#             self, parent, texture, color=(1, 1, 1, 1), ampl=pi/6, ray=.5,
-#             rate=.0001, gravity=-.85, vel=3.8, part_duration=1.0,
-#             autodestroy=None, size=10):
-#         return self.gfx.particle(
-#             parent, texture, color, ampl, ray, rate, gravity, vel,
-#             part_duration, autodestroy, size)
-#     def init_gfx(self): return self.gfx.init()
-#     def clean_gfx(self): return self.gfx.clean()
-
-#     @staticmethod
-#     def set_cam_pos(pos): return base.camera.set_pos(pos)
-
-#     def load_font(self, fpath, outline=True):
-#         return self.eng.font_mgr.load_font(fpath, outline)
-#     def open_browser(self, url): return self.gui.open_browser(url)
-
-#     def toggle_pause(self, show_frm=True):
-#         return self.pause.logic.toggle(show_frm)
-
-#     def play(self): return self.audio.play()
-#     def set_volume(self, vol): return self.audio.set_volume(vol)
-#     def show_cursor(self): return self.gui.cursor.show()
-#     def show_standard_cursor(self): return self.gui.cursor.show_standard()
-#     def hide_cursor(self): return self.gui.cursor.hide()
-#     def hide_standard_cursor(self): return self.gui.cursor.hide_standard()
-#     def cursor_top(self): return self.gui.cursor.cursor_top()
-#     def set_amb_lgt(self, col): return self.shader_mgr.set_amb_lgt(col)
-
-#     def set_dir_lgt(self, col, direction):
-#         return self.shader_mgr.set_dir_lgt(col, direction)
-
-#     def set_shadow_lgt(self, direction):
-#         return self.shader_mgr.set_shadow_lgt(direction)
-
-#     def clear_lights(self): return self.shader_mgr.clear_lights()
-#     def toggle_shader(self): return self.shader_mgr.toggle_shader()
-
-#     def set_resolution(self, res, fullscreen=None):
-#         return self.gui.set_resolution(res, fullscreen)
-
-#     def toggle_fullscreen(self): return self.gui.toggle_fullscreen()
-#     def send(self, msg): return self.lib.send(msg)
-
-#     def do_later(self, time, meth, args=None):
-#         return self.lib.do_later(time, meth, args)
-
-#     def add_task(self, mth, priority=0):
-#         return self.lib.add_task(mth, priority)
-
-#     def remove_task(self, tsk): return self.lib.remove_task(tsk)
-#     def log(self, msg, verbose=False): return self.log_mgr.log(msg, verbose)
-#     def log_tasks(self): return self.log_mgr.log_tasks()
-
-#     def rm_do_later(self, tsk):
-#         self.pause.remove_task(tsk)
-#         return self.lib.remove_task(tsk)
-
-#     def load_model(self, filename, callback=None, anim=None):
-#         return self.gfx.load_model(filename, callback, anim)
diff --git a/ya2/engine/event.py b/ya2/engine/event.py
deleted file mode 100644 (file)
index 592bae0..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-# from time import time
-# from logging import info
-# from ya2.gameobject import EventColleague
-# from ya2.engine.joystick import JoystickMgr
-
-
-# class EngineEvent(EventColleague):
-
-#     def __init__(self, mediator, emulate_keyboard, functional_test):
-#         EventColleague.__init__(self, mediator)
-#         self.unpaused_time = 0
-#         self._prev_time = time()
-#         self.eng.add_task(self.__on_frame)
-#         taskMgr.setupTaskChain('unpausable')
-#         mth = self.__on_frame_unpausable
-#         taskMgr.add(mth, 'unpausable', taskChain='unpausable')
-#         self.joystick_mgr = JoystickMgr(emulate_keyboard, functional_test)
-
-#     def __on_frame(self, task):  # unused task
-#         self.notify('on_start_frame')
-#         self.notify('on_frame')
-#         self.notify('on_end_frame')
-#         return self.eng.lib.task_cont
-
-#     def __on_frame_unpausable(self, task):
-#         self.unpaused_time += time() - self._prev_time
-#         self._prev_time = time()
-#         try:
-#             self.notify('on_frame_unpausable')
-#             return task.cont
-#         except AttributeError: info("engine has been destroyed")
-
-#     @staticmethod
-#     def key2desc(keystr):
-#         if not keystr.startswith('raw-'): return keystr
-#         keystr = keystr[4:]
-#         kmap = base.win.get_keyboard_map()
-#         virt_key = kmap.get_mapped_button(keystr)
-#         return (kmap.get_mapped_button_label(keystr) or str(virt_key)).lower()
-
-#     @staticmethod
-#     def desc2key(desc):
-#         kmap = base.win.get_keyboard_map()
-#         for i in range(kmap.get_num_buttons()):
-#             if kmap.get_mapped_button_label(i).lower() == desc:
-#                 return str(kmap.get_mapped_button(i))
-#             return desc
-
-#     def destroy(self):
-#         self.joystick_mgr.destroy()
-#         EventColleague.destroy(self)
diff --git a/ya2/engine/font.py b/ya2/engine/font.py
deleted file mode 100644 (file)
index 117ae60..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# from ya2.gameobject import GameObject
-
-
-# class FontMgr(GameObject):
-
-#     def __init__(self):
-#         GameObject.__init__(self)
-#         self.__fonts = {}
-
-#     def load_font(self, fpath, outline=True):
-#         if fpath not in self.__fonts:
-#             self.__fonts[fpath] = self.eng.lib.load_font(fpath, outline)
-#         return self.__fonts[fpath]
-
-#     def destroy(self):
-#         self.__fonts = None
-#         GameObject.destroy(self)
diff --git a/ya2/engine/gfx.py b/ya2/engine/gfx.py
deleted file mode 100755 (executable)
index c210400..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-# from math import pi
-# from panda3d.core import ClockObject
-# from ya2.gameobject import GfxColleague
-# from ya2.engine.particle import Particle
-# from ya2.lib.p3d.gfx import P3dGfxMgr, P3dAnimNode, P3dAmbientLight, \
-#     P3dSpotlight
-
-
-# GfxMgr = P3dGfxMgr
-# AnimNode = P3dAnimNode
-# AmbientLight = P3dAmbientLight
-# Spotlight = P3dSpotlight
-
-
-# class EngineGfx(GfxColleague):
-
-#     def __init__(self, mediator, model_path, antialiasing, shaders, fps, srgb):
-#         GfxColleague.__init__(self, mediator)
-#         self.gfx_mgr = GfxMgr(model_path, antialiasing, shaders, srgb)
-#         self.root = None
-#         self.part2eff = {}
-#         if fps: self.set_frame_rate(fps)
-#         # if self.mediator.cfg.gui_cfg.shaders and \
-#         #         self.eng.lib.version.startswith('1.10'):
-#         #     self.set_toon()
-#         #     self.set_bloom()
-
-#     def init(self):
-#         self.root = self.gfx_mgr.root.attach_node('world')
-
-#     def clean(self): self.root.remove_node()
-
-#     def load_model(self, filename, callback=None, anim=None):
-#         try: return self.gfx_mgr.load_model(filename, callback, anim)
-#         except OSError:
-#             return self.gfx_mgr.load_model(filename + '.bam', callback, anim)
-
-#     def set_toon(self): self.gfx_mgr.set_toon()
-
-#     def set_bloom(self): self.gfx_mgr.set_bloom()
-
-#     def print_stats(self, two_d=True, three_d=True, analyze=True, ls=True):
-#         self.gfx_mgr.print_stats(two_d, three_d, analyze, ls)
-
-#     @staticmethod
-#     def set_frame_rate(fps):
-#         globalClock.setMode(ClockObject.MLimited)
-#         globalClock.set_frame_rate(fps)
-#         # base.set_sleep(.01)
-
-#     @staticmethod
-#     def particle(parent, texture, color=(1, 1, 1, 1), ampl=pi/6, ray=.5,
-#                  rate=.0001, gravity=-.85, vel=3.8, part_duration=1.0,
-#                  autodestroy=None, size=10):
-#         return Particle(parent, texture, color, ampl, ray, rate, gravity, vel,
-#                         part_duration, autodestroy, size)
diff --git a/ya2/engine/gui/browser.py b/ya2/engine/gui/browser.py
deleted file mode 100644 (file)
index 076060c..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# from sys import platform
-# from os import environ, system
-# from webbrowser import open_new_tab
-
-
-# class BrowserStrategy:
-
-#     @staticmethod
-#     def open(url): open_new_tab(url)
-
-
-# class BrowserStrategyLinux(BrowserStrategy):
-
-#     @staticmethod
-#     def open(url):
-#         environ['LD_LIBRARY_PATH'] = ''
-#         system('xdg-open ' + url)
-
-
-# class Browser:
-
-#     @staticmethod
-#     def open(url):
-#         cls = BrowserStrategyLinux if platform.startswith('linux') else \
-#             BrowserStrategy
-#         cls.open(url)
diff --git a/ya2/engine/gui/circle.py b/ya2/engine/gui/circle.py
deleted file mode 100644 (file)
index e5cd744..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-# from os import name
-# from ya2.lib.gui import Frame
-# from ya2.lib.p3d.shader import load_shader
-# from ya2.gameobject import GameObject
-
-
-# class Circle(Frame, GameObject):
-
-#     def __init__(self, size=.4, pos=(0, 0), parent=None, ray=.4, thickness=.05,
-#                  col_start=(1, 1, 1, 1), col_end=(1, 1, 1, 1)):
-#         GameObject.__init__(self)
-#         Frame.__init__(self, pos=(pos[0], pos[1]), texture_coord=True,
-#                        frame_size=(-size, size, -size, size), parent=parent)
-#         path = 'assets/shaders/'
-#         shader = load_shader(path + 'filter.vert', path + 'circle.frag')
-#         drv_lst = [self.eng.lib.driver_vendor, self.eng.lib.driver_renderer,
-#                    self.eng.lib.driver_version]
-#         is_nvidia = any('nvidia' in drv.lower() for drv in drv_lst)
-#         if shader and not (name == 'nt' and is_nvidia):
-#             self.set_shader(shader)
-#             args = [('ray', ray), ('width', thickness), ('progress', 0),
-#                     ('color_start', col_start), ('color_end', col_end)]
-#             list(map(lambda arg: self.set_shader_input(*arg), args))
-#         else: self['frameColor'] = (1, 1, 1, 0)
-#         self.set_transparency(True)
-
-#     @property
-#     def progress(self): return self.get_shader_input('progress')
-
-#     @progress.setter
-#     def progress(self, val): self.set_shader_input('progress', val)
-
-#     def destroy(self):
-#         Frame.destroy(self)
-#         GameObject.destroy(self)
diff --git a/ya2/engine/gui/gui.py b/ya2/engine/gui/gui.py
deleted file mode 100755 (executable)
index 6faaa19..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-# from logging import info
-# from ya2.gameobject import GuiColleague
-# from ya2.engine.gui.cursor import MouseCursor
-# from ya2.engine.gui.browser import Browser
-
-
-# up = (0, 1)
-# down = (0, -1)
-# left = (-1, 0)
-# right = (1, 0)
-
-
-# class EngineGuiBase(GuiColleague):  # no win: EngineGui strictly manages win
-
-#     @staticmethod
-#     def init_cls():
-#         return EngineGui if EngineGuiBase.eng.lib.has_window else EngineGuiBase
-
-#     @staticmethod
-#     def open_browser(url): Browser.open(url)
-
-#     @property
-#     def resolutions(self):
-#         return sorted(list(set(self.eng.lib.resolutions)))
-
-#     @property
-#     def closest_resolution(self):
-#         def distance(res):
-#             curr_res = self.eng.lib.resolution
-#             return abs(res[0] - curr_res[0]) + abs(res[1] - curr_res[1])
-
-#         try:
-#             return min(self.resolutions, key=distance)
-#         except ValueError:  # sometimes we have empty resolutions
-#             return self.eng.lib.resolution
-
-#     def set_resolution_check(self, res):
-#         res_msg = 'resolutions: {curr} (current), {res} (wanted)'
-#         info(res_msg.format(curr=self.eng.lib.resolution, res=res))
-#         if self.eng.lib.resolution == res: return
-#         retry = 'second attempt: {curr} (current) {res} (wanted)'
-#         info(retry.format(curr=self.eng.lib.resolution, res=res))
-#         self.set_resolution(res, False)
-
-#     def toggle_fullscreen(self):
-#         self.set_resolution(self.closest_resolution)
-#         self.eng.lib.toggle_fullscreen()
-
-
-# class EngineGui(EngineGuiBase):
-
-#     def __init__(self, mediator):
-#         EngineGuiBase.__init__(self, mediator)
-#         cfg = self.eng.cfg
-#         res_strings = cfg.gui_cfg.win_size.split()
-#         res_ints = tuple(int(size) for size in res_strings)
-#         self.set_resolution(res_ints, fullscreen=cfg.gui_cfg.fullscreen)
-#         cur_cfg = cfg.cursor_cfg
-#         self.cursor = MouseCursor(
-#             cur_cfg.cursor_path, cur_cfg.cursor_scale, cur_cfg.cursor_color,
-#             cur_cfg.cursor_hotspot)
-
-#     def set_resolution(self, res, check=True, fullscreen=None):
-#         info('setting resolution ' + str(res))
-#         self.eng.lib.set_resolution(res, fullscreen)
-#         if check: self.eng.do_later(3.0, self.set_resolution_check, [res])
diff --git a/ya2/engine/gui/imgbtn.py b/ya2/engine/gui/imgbtn.py
deleted file mode 100644 (file)
index 43a6cf3..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-# from ya2.lib.gui import Btn
-# from ya2.lib.p3d.shader import load_shader
-
-
-# class ImgBtn(Btn):
-
-#     def __init__(self, *args, **kwargs):
-#         Btn.__init__(self, *args, **kwargs)
-#         shader_dirpath = 'assets/shaders/'
-#         shader = load_shader(shader_dirpath + 'filter.vert',
-#                              shader_dirpath + 'imgbtn.frag')
-#         if shader:
-#             self.set_shader(shader)
-#             shader_args = [('col_offset', 0), ('enable', 1)]
-#             list(map(lambda args: self.set_shader_input(*args), shader_args))
-#         self.set_transparency(True)
-
-#     def _on_enter(self, pos):  # pos comes from mouse
-#         self.set_shader_input('col_offset', .25)
-
-#     def _on_exit(self, pos):  # pos comes from mouse
-#         self.set_shader_input('col_offset', 0)
-
-#     def enable(self):
-#         super().enable()
-#         self.set_shader_input('enable', 1)
-
-#     def disable(self):
-#         super().disable()
-#         self.set_shader_input('enable', .2)
diff --git a/ya2/engine/gui/mainpage.py b/ya2/engine/gui/mainpage.py
deleted file mode 100644 (file)
index 934e2ef..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-# from ya2.lib.gui import Text, Img
-# from ya2.engine.gui.page import Page, PageGui, PageFacade
-# from ya2.engine.gui.imgbtn import ImgBtn
-
-
-# class MainPageGui(PageGui):
-
-#     def build(self, back_btn=True, exit_behav=False):
-#         #self.__build_social()
-#         self.__build_version()
-#         self.__build_dependencies()
-#         self._set_widgets()
-#         self.transition_enter()
-
-#     def __build_social(self):
-#         sites = self.props.gameprops.social_sites
-#         menu_props = self.props.gameprops.menu_props
-#         left = (len(sites) - 1) / 2.0 * .15
-#         buttons = [
-#             ImgBtn(
-#                 parent='bottomcenter',
-#                 scale=(.06, .06),
-#                 pos=(-left + i*.15, .1),
-#                 frame_col=(1, 1, 1, 1),
-#                 frame_texture=menu_props.social_imgs_dirpath % site[0],
-#                 cmd=self.eng.open_browser,
-#                 extra_args=[site[1]],
-#                 **menu_props.imgbtn_args)
-#             for i, site in enumerate(sites)]
-#         self.add_widgets(buttons)
-
-#     def __build_version(self):
-#         txt = Text(
-#             _('version: ') + self.eng.version, parent='bottomleft',
-#             pos=(.02, .02), scale=.04, fg=(.8, .8, .8, 1), align='left',
-#             font=self.props.gameprops.menu_props.font, wordwrap=256)
-#         self.add_widgets([txt])
-
-#     def __build_dependencies(self):
-#         txt = Text(
-#             _('made with heart with panda3d, panda3d-simplepbr, panda3d-gltf'),
-#             parent='bottomright', pos=(-.09, .02), scale=.04, wordwrap=128,
-#             fg=(.8, .8, .8, 1), align='right',
-#             font=self.props.gameprops.menu_props.font)
-#         img = Img(
-#             'assets/images/gui/p3d.dds', scale=.04,
-#             parent=base.a2dBottomRight, pos=(-.04, .04))
-#         self.add_widgets([txt, img])
-
-
-# class MainPage(Page, PageFacade):
-#     gui_cls = MainPageGui
-
-#     def __init__(self, mainpage_props):
-#         Page.__init__(self, mainpage_props)
-#         PageFacade.__init__(self)
diff --git a/ya2/engine/gui/menu.py b/ya2/engine/gui/menu.py
deleted file mode 100644 (file)
index 79756d3..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-# from direct.gui.DirectGuiGlobals import FLAT
-# from ya2.gameobject import GuiColleague, LogicColleague, GameObject
-# from ya2.lib.gui import Img
-# from ya2.engine.audio import AudioSound
-
-
-# class NavInfoPerPlayer:
-
-#     def __init__(self, left, right, up, down, fire):
-#         self.left = left
-#         self.right = right
-#         self.up = up
-#         self.down = down
-#         self.fire = fire
-
-
-# class NavInfo:
-
-#     def __init__(self, navinfo_lst):
-#         self.navinfo_lst = navinfo_lst
-
-
-# class MenuProps(GameObject):
-
-#     def __init__(
-#             self, font_path, text_active_col, text_normal_col, text_err_col,
-#             text_scale, btn_size, btn_col, background_img_path, over_sfx_path,
-#             click_sfx_path, social_imgs_dirpath, nav):
-#         GameObject.__init__(self)
-#         self.__font_path = font_path
-#         self.text_active_col = text_active_col
-#         self.text_normal_col = text_normal_col
-#         self.text_err_col = text_err_col
-#         self.text_scale = text_scale
-#         self.btn_size = btn_size
-#         self.btn_col = btn_col
-#         self.background_img_path = background_img_path
-#         self.__over_sfx_path = over_sfx_path
-#         self.__click_sfx_path = click_sfx_path
-#         self.social_imgs_dirpath = social_imgs_dirpath
-#         self.nav = nav
-
-#     @property
-#     def font(self): return self.eng.font_mgr.load_font(self.__font_path)
-
-#     @property
-#     def over_sfx(self): return AudioSound(self.__over_sfx_path).snd
-
-#     @property
-#     def click_sfx(self): return AudioSound(self.__click_sfx_path).snd
-
-#     @property
-#     def btn_args(self):  # it may be used without a menu e.g. results
-#         return {
-#             'scale': (self.text_scale, self.text_scale),
-#             'text_font': self.font,
-#             'text_fg': self.text_active_col,
-#             'frame_col': self.btn_col,
-#             'frame_size': self.btn_size,
-#             'over_snd': self.over_sfx,
-#             'click_snd': self.click_sfx}
-
-#     @property
-#     def imgbtn_args(self):
-#         return {
-#             'over_snd': self.over_sfx,
-#             'click_snd': self.click_sfx}
-
-#     @property
-#     def label_args(self):
-#         return {
-#             'scale': self.text_scale,
-#             'text_fg': self.text_normal_col,
-#             'text_font': self.font,
-#             'frame_col': (1, 1, 1, 0)}
-
-#     @property
-#     def option_args(self):
-#         tfg = self.text_active_col
-#         return {
-#             'scale': self.text_scale,
-#             'text_font': self.font,
-#             'text_fg': tfg,
-#             'frame_col': self.btn_col,
-#             'frame_size': self.btn_size,
-#             'over_snd': self.over_sfx,
-#             'click_snd': self.click_sfx,
-#             'text_scale': .85,
-#             'item_text_font': self.font,
-#             'item_frame_col': tfg,
-#             'item_relief': FLAT,
-#             'popup_marker_col': self.btn_col,
-#             'text_may_change': 1,
-#             'highlight_col': (tfg[0] * 1.2, tfg[1] * 1.2, tfg[2] * 1.2, .2)}
-
-#     @property
-#     def checkbtn_args(self):
-#         return {
-#             'scale': self.text_scale,
-#             'text_font': self.font,
-#             'text_fg': self.text_active_col,
-#             'frame_col': self.btn_col,
-#             'over_snd': self.over_sfx,
-#             'click_snd': self.click_sfx}
-
-#     @property
-#     def text_args(self):
-#         return {
-#             'scale': self.text_scale,
-#             'fg': self.text_normal_col,
-#             'font': self.font}
-
-
-# class MenuGui(GuiColleague):
-
-#     def __init__(self, mediator, menu_props):
-#         GuiColleague.__init__(self, mediator)
-#         self.menu_props = menu_props
-#         self.background = None
-#         if not self.menu_props.background_img_path: return
-#         self.background = Img(self.menu_props.background_img_path,
-#                               scale=(1.77778, 1, 1.0),
-#                               background=True)
-
-#     def destroy(self):
-#         if self.background: self.background.destroy()
-#         self.menu_props = self.background = None
-#         GuiColleague.destroy(self)
-
-
-# class MenuLogic(LogicColleague):
-
-#     def __init__(self, mediator):
-#         LogicColleague.__init__(self, mediator)
-#         self.pages = []
-
-#     def push_page(self, page):
-#         if self.pages:
-#             self.pages[-1].hide()
-#             if len(self.pages) > 1:  # first page doesn't go back
-#                 self.pages[-1].detach_obs(self.on_back)
-#                 self.pages[-1].detach_obs(self.on_quit)
-#         self.pages += [page]
-#         list(map(
-#             page.attach_obs, [self.on_back, self.on_quit, self.on_push_page]))
-
-#     def enable(self): self.pages[-1].enable()
-
-#     def enable_navigation(self): self.pages[-1].enable_navigation()
-
-#     def disable(self): self.pages[-1].disable()
-
-#     def disable_navigation(self): self.pages[-1].disable_navigation()
-
-#     def on_push_page(self, page_code, args=None): pass
-
-#     def __back_quit_tmpl(self, idx, fun):
-#         page = self.pages.pop()
-#         list(map(page.detach_obs, [self.on_back, self.on_quit]))
-#         page.destroy()
-#         fun()
-#         self.pages[idx].show()
-#         list(map(self.pages[idx].attach_obs, [self.on_back, self.on_quit]))
-
-#     def on_back(self):
-#         self.__back_quit_tmpl(-1, lambda: None)
-
-#     def on_quit(self):
-#         def __on_quit():
-#             while len(self.pages) > 1:
-#                 page = self.pages.pop()
-#                 page.destroy()
-#         self.__back_quit_tmpl(0, __on_quit)
-
-#     def destroy(self):
-#         list(map(lambda page: page.destroy(), self.pages))
-#         self.pages = None
-#         LogicColleague.destroy(self)
-
-
-# class MenuFacade:
-
-#     def push_page(self, page): return self.logic.push_page(page)
-#     def attach_obs(self, obs_meth, sort=10, rename='', args=None):
-#         return self.gui.attach(obs_meth, sort, rename, args or [])
-#     def detach_obs(self, obs_meth, lambda_call=None):
-#         return self.gui.detach(obs_meth, lambda_call)
-#     def enable(self): return self.gui.enable()
-#     def enable_navigation(self): return self.gui.enable_navigation()
-
-
-# class Menu(GameObject, MenuFacade):
-#     gui_cls = MenuGui
-#     logic_cls = MenuLogic
-
-#     def __init__(self, menu_props):
-#         GameObject.__init__(self)
-#         self.logic = self.logic_cls(self)
-#         self.__menu_props = menu_props
-#         self._build_gui()
-
-#     def _build_gui(self):
-#         self.gui = self.gui_cls(self, self.__menu_props)
-
-#     def destroy(self):
-#         self.logic.destroy()
-#         self.gui.destroy()
-#         GameObject.destroy(self)
diff --git a/ya2/engine/gui/page.py b/ya2/engine/gui/page.py
deleted file mode 100755 (executable)
index 8cef27f..0000000
+++ /dev/null
@@ -1,273 +0,0 @@
-# from inspect import getmro
-# from ya2.lib.gui import Btn, Slider, CheckBtn, OptionMenu, Entry
-# from ya2.engine.vec import Vec2
-# from ya2.engine.gui.gui import left, right, up, down
-# from ya2.gameobject import GameObject, GuiColleague, EventColleague
-# from ya2.engine.gui.imgbtn import ImgBtn
-
-
-# class PageGui(GuiColleague):
-
-#     def __init__(self, mediator, menu_props, players=[0]):
-#         GuiColleague.__init__(self, mediator)
-#         self.enable_tsk = None
-#         self._back_btn = None
-#         self.menu_props = menu_props
-#         self.players = players
-#         self.widgets = []
-#         self.build()
-#         self.translate()
-#         self.curr_wdgs = []
-#         for player in players:
-#             self.curr_wdgs += [
-#                 self.__next_wdg((-.1, -1), player, Vec2(-3.6, 1))]
-#             if self.curr_wdgs[-1]:
-#                 self.curr_wdgs[-1].on_wdg_enter(None, player)
-
-#     def build(self, back_btn=True, exit_behav=False):
-#         if back_btn: self.__build_back_btn(exit_behav)
-#         self._set_widgets()
-#         self._set_entries()
-#         self.transition_enter()
-#         self.eng.cursor_top()
-
-#     def add_widgets(self, widgets): self.widgets += widgets
-
-#     def on_arrow(self, direction, player):
-#         if not self.curr_wdgs[player]: return
-#         if self.curr_wdgs[player].__class__.__name__ == 'P3dEntryWidget' and \
-#             self.curr_wdgs[player].focused: return
-#         processed_cmd = self.curr_wdgs[player].on_arrow(direction)
-#         # e.g. up/down in a combobox or left/right in a slider
-#         if processed_cmd: return
-#         next_wdg = self.__next_wdg(direction, player)
-#         if not next_wdg: return
-#         self.focus(next_wdg, player)
-
-#     def on_enter(self, player):
-#         if not self.curr_wdgs[player]: return
-#         arg = player if len(self.players) > 1 else None
-#         if self.curr_wdgs[player].on_enter(arg): self.enable([player])
-#         # wdg.on_enter returns True when it is an option widget
-
-#     @property
-#     def buttons(self):
-#         is_btn = lambda wdg: Btn in getmro(wdg.__class__)
-#         return [wdg for wdg in self.widgets if is_btn(wdg)]
-
-#     def focus(self, wdg, player):
-#         self.curr_wdgs[player].on_wdg_exit(None, player)
-#         self.curr_wdgs[player] = wdg
-#         self.curr_wdgs[player].on_wdg_enter(None, player)
-
-#     def __direction_dot_dwg(self, wdg, direction, player, start=None):
-#         if start: start_pos = start
-#         else: start_pos = self.curr_wdgs[player].pos
-#         return (wdg.pos - start_pos).normalized.dot(direction)
-
-#     def __next_weight(self, wdg, direction, player, start=None):
-#         if start: start_pos = start
-#         else: start_pos = self.curr_wdgs[player].global_pos
-#         dot = self.__direction_dot_dwg(wdg, direction, player, start)
-#         if direction in [(-1, 0), (1, 0)]:
-#             proj_dist = abs(wdg.global_pos.x - start_pos.x)
-#         else: proj_dist = abs(wdg.global_pos.y - start_pos.y)
-#         weights = [.5, .5] if direction in [left, right] else [.1, .9]
-#         return weights[0] * (dot * dot) + weights[1] * (1 - proj_dist)
-
-#     def __next_wdg(self, direction, player, start=None):
-#         # interactive classes
-#         iclss = [Btn, CheckBtn, Slider, OptionMenu, ImgBtn, Entry]
-#         inter = lambda wdg: any(pcl in iclss for pcl in getmro(wdg.__class__))
-#         allwdgs = [wdg for wdg in self.widgets if inter(wdg)]
-#         wdgs = list(filter(lambda wdg: wdg.is_enabled, allwdgs))
-#         if player < len(self.curr_wdgs) and self.curr_wdgs[player] \
-#                 and self.curr_wdgs[player] in wdgs:
-#                 # the last check for this case: multiple players appear on the
-#                 # same button, one player clicks it, another moves from it
-#             wdgs.remove(self.curr_wdgs[player])
-#         mth = self.__direction_dot_dwg
-#         in_direction = lambda wdg: mth(wdg, direction, player, start) > .1
-#         dirwdgs = list(filter(in_direction, wdgs))
-#         if not dirwdgs: return None
-#         nextweight = lambda wdg: \
-#                      self.__next_weight(wdg, direction, player, start)
-#         return max(dirwdgs, key=nextweight)
-
-#     def _set_widgets(self):
-#         list(map(lambda wdg: wdg.set_widget(), self.widgets))
-
-#     def _set_entries(self):
-#         for wdg in self.widgets:
-#             if wdg.__class__.__name__ == 'P3dEntryWidget':
-#                 wdg.attach(self.on_entry_enter)
-#                 wdg.attach(self.on_entry_exit)
-
-#     def on_entry_enter(self):
-#         if self.menu_props:  # i.e. not destroyed
-#             self.disable_navigation(self.players)
-
-#     def on_entry_exit(self):
-#         if self.menu_props:  # i.e. not destroyed
-#             self.enable_navigation(self.players)
-
-#     def transition_enter(self):
-#         self.translate()
-#         list(map(lambda wdg: wdg.set_enter_transition(), self.widgets))
-#         self.enable(self.players)
-
-#     def translate(self): list(map(lambda wdg: wdg.translate(), self.widgets))
-
-#     def enable_navigation(self, players):
-#         if self.enable_tsk: self.eng.rm_do_later(self.enable_tsk)
-#         self.enable_tsk = self.eng.do_later(
-#             .01, self.enable_navigation_aux, [players])
-
-#     def update_navigation(self):
-#         self.disable_navigation(self.players)
-#         self.enable_navigation(self.players)
-
-#     def enable_navigation_aux(self, players):
-#         navs = []
-#         for player in players:
-#             nav = self.menu_props.nav.navinfo_lst[player]
-#             evts = [
-#                 (self.eng.lib.remap_str(nav.left), self.on_arrow,
-#                  [left, player]),
-#                 (self.eng.lib.remap_str(nav.right), self.on_arrow,
-#                  [right, player]),
-#                 (self.eng.lib.remap_str(nav.up), self.on_arrow, [up, player]),
-#                 (self.eng.lib.remap_str(nav.down), self.on_arrow,
-#                  [down, player]),
-#                 (self.eng.lib.remap_str(nav.fire), self.on_enter, [player])]
-#             def append_up(evt): return evt + ('' if evt.endswith('-up') else '-up')
-#             evts = [(append_up(evt[0]), evt[1], evt[2]) for evt in evts]
-#             navs += [nav]
-#             list(map(lambda args: self.mediator.event.accept(*args), evts))
-#         self.eng.joystick_mgr.bind_keyboard(navs)
-#         if self.eng.cfg.dev_cfg.menu_joypad and self._back_btn:
-#             self.mediator.event.accept('joypad0-face_b-up', self.__back_wrapper)
-
-#     def __back_wrapper(self):
-#         if not self.eng.joystick_mgr.is_recording: self._back_btn['command']()
-
-#     def disable_navigation(self, players):
-#         if self.enable_tsk:
-#             self.enable_tsk = self.eng.rm_do_later(self.enable_tsk)
-#         for player in players:
-#             nav = self.menu_props.nav.navinfo_lst[player]
-#             # evts = [nav.left, nav.right, nav.up, nav.down, nav.fire]
-#             evts = [
-#                 self.eng.lib.remap_str(nav.left),
-#                 self.eng.lib.remap_str(nav.right),
-#                 self.eng.lib.remap_str(nav.up),
-#                 self.eng.lib.remap_str(nav.down),
-#                 self.eng.lib.remap_str(nav.fire)]
-#             def append_up(evt): return evt + ('' if evt.endswith('-up') else '-up')
-#             evts = [append_up(evt) for evt in evts]
-#             self.eng.joystick_mgr.unbind_keyboard()
-#             list(map(self.mediator.event.ignore, evts))
-#         self.mediator.event.ignore('joypad0-face_b-up')
-
-#     def enable(self, players):
-#         self.enable_navigation(players)
-#         list(map(lambda wdg: wdg.enable(), self.widgets))
-
-#     def disable(self, players):
-#         if self.enable_tsk:
-#             self.enable_tsk = self.eng.rm_do_later(self.enable_tsk)
-#         self.disable_navigation(players)
-#         list(map(lambda wdg: wdg.disable(), self.widgets))
-
-#     def transition_exit(self, destroy=True):
-#         list(map(lambda wdg: wdg.set_exit_transition(destroy), self.widgets))
-#         self.disable(self.players)
-
-#     def __build_back_btn(self, exit_behav):
-#         tra_src = 'Quit' if exit_behav else 'Back'
-#         tra_tra = _('Quit') if exit_behav else _('Back')
-#         callback = self._on_quit if exit_behav else self._on_back
-#         btn = Btn(text='', pos=(0, -.85), cmd=callback,
-#                   tra_src=tra_src, tra_tra=tra_tra, **self.menu_props.btn_args)
-#         self.widgets += [btn]
-#         self._back_btn = btn
-
-#     def _on_back(self, player=0):
-#         self.notify('on_back', self.__class__.__name__)
-
-#     def _on_quit(self): self.notify('on_quit', self.__class__.__name__)
-
-#     def show(self):
-#         visible_widgets = [wdg for wdg in self.widgets if wdg.was_visible]
-#         list(map(lambda wdg: wdg.show(), visible_widgets))
-#         self.transition_enter()
-
-#     def hide(self):
-#         for wdg in self.widgets: wdg.was_visible = not wdg.hidden
-#         self.transition_exit(False)
-#         self.notify('on_hide')
-
-#     def destroy(self):
-#         self.transition_exit()
-#         self.menu_props = None
-
-
-# class PageEvent(EventColleague):
-
-#     def on_back(self): pass
-
-#     def on_quit(self): pass
-
-
-# class PageFacade:
-
-#     def show(self): return self.gui.show()
-#     def hide(self): return self.gui.hide()
-#     def enable(self, players): return self.gui.enable(players)
-#     def disable(self, players): return self.gui.disable(players)
-
-#     def enable_navigation(self, players):
-#         return self.gui.enable_navigation(players)
-
-#     def disable_navigation(self, players):
-#         return self.gui.disable_navigation(players)
-
-#     def attach_obs(self, obs_meth, sort=10, rename='', args=None):
-#         return self.gui.attach(obs_meth, sort, rename, args or [])
-
-#     def detach_obs(self, obs_meth, lambda_call=None):
-#         return self.gui.detach(obs_meth, lambda_call)
-
-
-# class Page(GameObject, PageFacade):
-
-#     gui_cls = PageGui
-#     event_cls = PageEvent
-
-#     def __init__(self, menu_props, players=[0]):
-#         PageFacade.__init__(self)
-#         self.menu_props = menu_props
-#         self.players = players
-#         GameObject.__init__(self)
-#         self._build_event()
-#         self._build_gui()
-#         list(map(self.gui.attach, [self.on_hide, self.on_back, self.on_quit]))
-
-#     def _build_event(self):
-#         self.event = self.event_cls(self)
-
-#     def _build_gui(self):
-#         self.gui = self.gui_cls(self, self.menu_props, self.players)
-
-#     def on_hide(self): self.event.ignoreAll()
-
-#     def on_back(self, cls_name, args=None): self.event.on_back()  # unused arg
-
-#     def on_quit(self, cls_name): self.event.on_quit()  # unused arg
-
-#     def destroy(self):
-#         self.event.destroy()
-#         self.gui.destroy()
-#         bases = [basecls for basecls in Page.__bases__
-#                  if basecls != PageFacade]
-#         for cls in bases: cls.destroy(self)
diff --git a/ya2/engine/joystick.py b/ya2/engine/joystick.py
deleted file mode 100644 (file)
index 674551d..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-# from ya2.gameobject import GameObject
-# from ya2.lib.p3d.joystick import P3dJoystickMgr as JoystickMgrLib
-
-
-# class JoystickState:
-
-#     def __init__(self):
-#         self.x = self.y = self.b0 = self.b1 = self.b2 = self.b3 = \
-#             self.dpad_l = self.dpad_r = self.dpad_u = self.dpad_d = \
-#             self.ltrigger = self.rtrigger = self.ltrigger_known = \
-#             self.rtrigger_known = self.lshoulder = self.rshoulder = \
-#             self.lstick = self.rstick = 0
-#         #TODO: rename bi to btni
-
-
-# class JoystickMgr(GameObject):
-
-#     def __init__(self, emulate_keyboard, functional_test):
-#         GameObject.__init__(self)
-#         self.emulate_keyboard = emulate_keyboard
-#         self._fun_tst = functional_test
-#         self.old = [JoystickState() for i in range(3)]
-#         self.nav = None
-#         self.is_recording = False
-#         self.joystick_lib = JoystickMgrLib()
-#         self.joystick_lib.init_joystick()
-#         self.eng.do_later(.01, self.eng.attach_obs, [self.on_frame])
-#         # eng.event doesn't exist
-#         #if self.emulate_keyboard:
-#         self.set_keyboard_emulation()
-
-#     def set_keyboard_emulation(self):
-#         num_joysticks =1 if self._fun_tst else self.joystick_lib.num_joysticks
-#         for i in range(num_joysticks):
-#             base.accept('joypad%s-dpad_left-up' % i, self.__keyb_evt, [i, 'left'])
-#             base.accept('joypad%s-dpad_right-up' % i, self.__keyb_evt, [i, 'right'])
-#             base.accept('joypad%s-dpad_up-up' % i, self.__keyb_evt, [i, 'up'])
-#             base.accept('joypad%s-dpad_down-up' % i, self.__keyb_evt, [i, 'down'])
-#             base.accept('joypad%s-face_a-up' % i, self.__keyb_evt, [i, 'fire'])
-
-#     def __keyb_evt(self, i, evt):
-#         if not self.is_recording and self.nav:
-#             self.eng.send(str(getattr(self.nav[i], evt)) + '-up')
-#             # if the user chose a number
-
-#     def on_frame(self):
-#         #if not self.emulate_keyboard: return
-#         for i in range(self.joystick_lib.num_joysticks): self.__process(i)
-
-#     def __process(self, i):
-#         j_x, j_y, btn0, btn1, btn2, btn3, dpad_l, dpad_r, dpad_u, dpad_d, \
-#             trigger_l, trigger_r, shoulder_l, shoulder_r, stick_l, stick_r, \
-#             trigger_l_known, trigger_r_known = \
-#             self.joystick_lib.get_joystick(i)
-#         # if not self.is_recording:
-#         #     if self.old[i].x <= -.4 <= j_x or self.old[i].dpad_l and \
-#         #             not dpad_l:
-#         #         if self.nav and i < len(self.nav) and self.nav[i]:
-#         #             self.eng.send(self.nav[i].left)
-#         #     if self.old[i].x >= .4 >= j_x or self.old[i].dpad_r and not dpad_r:
-#         #         if self.nav and i < len(self.nav) and self.nav[i]:
-#         #             self.eng.send(self.nav[i].right)
-#         #     if self.old[i].y >= .4 >= j_y or self.old[i].dpad_d and not dpad_d:
-#         #         if self.nav and i < len(self.nav) and self.nav[i]:
-#         #             self.eng.send(self.nav[i].down)
-#         #     if self.old[i].y <= -.4 <= j_y or self.old[i].dpad_u and not dpad_u:
-#         #         if self.nav and i < len(self.nav) and self.nav[i]:
-#         #             self.eng.send(self.nav[i].up)
-#         # if self.old[i].b0 and not btn0:
-#         #     if self.nav and i < len(self.nav) and self.nav[i] and \
-#         #             not self.is_recording:
-#         #         self.eng.send(self.nav[i].fire)
-#         #     self.eng.send('joypad%s_face_x' % i)
-#         # if self.old[i].b1 and not btn1:
-#         #     self.eng.send('joypad%s_face_y' % i)
-#         # if self.old[i].b2 and not btn2:
-#         #     self.eng.send('joypad%s_face_a' % i)
-#         # if self.old[i].b3 and not btn3:
-#         #     self.eng.send('joypad%s_face_b' % i)
-#         if self.old[i].ltrigger and not trigger_l and not trigger_l_known:
-#             #self.eng.send('joypad_trigger_l')
-#             self.eng.send('joypad%s-ltrigger-up' % i)
-#         if self.old[i].rtrigger and not trigger_r and not trigger_r_known:
-#             #self.eng.send('joypad_trigger_r')
-#             self.eng.send('joypad%s-rtrigger-up' % i)
-#         # if self.old[i].shoulder_l and not shoulder_l:
-#         #     self.eng.send('joypad_shoulder_l')
-#         #     self.eng.send('joypad%s_shoulder_l' % i)
-#         # if self.old[i].shoulder_r and not shoulder_r:
-#         #     self.eng.send('joypad_shoulder_r')
-#         #     self.eng.send('joypad%s_shoulder_r' % i)
-#         # if self.old[i].stick_l and not stick_l:
-#         #     self.eng.send('joypad_stick_l')
-#         #     self.eng.send('joypad%s_stick_l' % i)
-#         # if self.old[i].stick_r and not stick_r:
-#         #     self.eng.send('joypad_stick_r')
-#         #     self.eng.send('joypad%s_stick_r' % i)
-#         self.old[i].x, self.old[i].y, self.old[i].b0, self.old[i].b1, \
-#             self.old[i].b2, self.old[i].b3, self.old[i].dpad_l, \
-#             self.old[i].dpad_r, self.old[i].dpad_u, self.old[i].dpad_d, \
-#             self.old[i].ltrigger, self.old[i].rtrigger, \
-#             self.old[i].lshoulder, self.old[i].rshoulder, \
-#             self.old[i].lstick, self.old[i].rstick = \
-#             j_x, j_y, btn0, btn1, btn2, btn3, dpad_l, dpad_r, dpad_u, dpad_d, \
-#             trigger_l, trigger_r, shoulder_l, shoulder_r, stick_l, stick_r
-
-#     def get_joystick(self, player_idx):
-#         x, y, face_a, face_b, face_x, face_y, dpadl, dpadr, dpadu, dpadd, triggl, \
-#             triggr, shl, shr, st_l, st_r, trl_k, trr_k= \
-#             self.joystick_lib.get_joystick(player_idx)
-#         jstate = JoystickState()
-#         jstate.x = x
-#         jstate.y = y
-#         jstate.face_a = face_a
-#         jstate.face_b = face_b
-#         jstate.face_x = face_x
-#         jstate.face_y = face_y
-#         jstate.dpad_l = dpadl
-#         jstate.dpad_r = dpadr
-#         jstate.dpad_u = dpadu
-#         jstate.dpad_d = dpadd
-#         jstate.ltrigger = triggl
-#         jstate.ltrigger_known = trl_k
-#         jstate.rtrigger = triggr
-#         jstate.rtrigger_known = trr_k
-#         jstate.lshoulder = shl
-#         jstate.rshoulder = shr
-#         jstate.lstick = st_l
-#         jstate.rstick = st_r
-#         return jstate
-
-#     def get_joystick_val(self, player_idx, code):
-#         j_x, j_y, btn0, btn1, btn2, btn3, dpad_l, dpad_r, dpad_u, dpad_d, \
-#             trigger_l, trigger_r, shoulder_l, shoulder_r, stick_l, stick_r = \
-#             self.joystick_lib.get_joystick(player_idx)
-#         code2val = {
-#             'face_x': btn0,
-#             'face_y': btn1,
-#             'face_a': btn2,
-#             'face_b': btn3,
-#             'dpad_l': dpad_l,
-#             'dpad_r': dpad_r,
-#             'dpad_u': dpad_u,
-#             'dpad_d': dpad_d,
-#             'trigger_l': trigger_l,
-#             'trigger_r': trigger_r,
-#             'shoulder_l': shoulder_l,
-#             'shoulder_r': shoulder_r,
-#             'stick_l': stick_l,
-#             'stick_r': stick_r}
-#         return code2val[code]
-
-#     def bind_keyboard(self, nav): self.nav = nav
-
-#     def unbind_keyboard(self): self.nav = None
-
-#     def destroy(self):
-#         try: self.eng.detach_obs(self.on_frame)
-#         except KeyError: pass
-#         # it happens in unit tests since it destroys in the same frame
-#         # remove this catch when i've refactored the object's building
-#         # and i don't use the director anymore
-#         self.joystick_lib.destroy()
-#         GameObject.destroy(self)
diff --git a/ya2/engine/logic.py b/ya2/engine/logic.py
deleted file mode 100755 (executable)
index 87aecd3..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-# from os.path import exists
-# from logging import info
-# from sys import argv
-# from ya2.gameobject import LogicColleague
-# from ya2.engine.configuration import Cfg
-# from ya2.gameobject import GameObject
-# from ya2.computer_proxy import ComputerProxy, compute_once
-
-
-# class VersionChecker(GameObject, ComputerProxy):
-
-#     def __init__(self):
-#         GameObject.__init__(self)
-#         ComputerProxy.__init__(self)
-
-#     @compute_once
-#     def is_uptodate(self):
-#         return True  # currently the server part is not active
-#         self.eng.client.register_rpc('srv_version')
-#         try: ver = self.eng.client.srv_version()
-#         except AttributeError:
-#             print("can't retrieve the version")
-#             return True
-#         major, minor, build = ver.split('.')
-#         major, minor, build = int(major), int(minor), int(build)
-#         curr_ver = self.eng.version
-#         if curr_ver == 'deploy-ng': return True
-#         info('versions: %s %s' % (curr_ver, ver))
-#         return curr_ver >= ver
-#         # curr_major, curr_minor, curr_build = curr_ver.split('-')[0].split('.')
-#         # curr_major = int(curr_major)
-#         # curr_minor = int(curr_minor)
-#         # curr_build = int(curr_build)
-#         # return curr_major > major or \
-#         #     curr_major == major and curr_minor > minor or \
-#         #     curr_major == major and curr_minor == minor and curr_build >= build
-
-#     def destroy(self):
-#         GameObject.destroy(self)
-#         # ComputerProxy.destroy(self)  # raises an exception
-
-
-# class EngineLogic(LogicColleague):
-
-#     @staticmethod
-#     def cmd_line():
-#         return [arg for arg in iter(argv[1:]) if not arg.startswith('-psn_')]
-
-#     def __init__(self, mediator, cfg=None):
-#         LogicColleague.__init__(self, mediator)
-#         self.cfg = cfg or Cfg()  # use a default conf if not provided
-
-#     @property
-#     def version(self):
-#         #if not self.is_runtime:
-#         #    if not exists('assets/version.txt'): return '-'
-#         #    with open('assets/version.txt') as fver:
-#         #        return fver.read().strip() + '-source'
-#         # ^ --version goes here
-#         return self.mediator.lib.build_version
-
-#     @property
-#     def is_runtime(self):
-#         return self.mediator.lib.runtime()
-
-#     @property
-#     def curr_path(self):
-#         return self.mediator.lib.curr_path + '/' \
-#             if self.is_runtime else ''
-
-#     @property
-#     def is_appimage(self):
-#         return self.mediator.lib.is_appimage
-
-#     def destroy(self):
-#         self.cfg = None
-#         LogicColleague.destroy(self)
diff --git a/ya2/engine/network/__init__.py b/ya2/engine/network/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/ya2/engine/network/binary.py b/ya2/engine/network/binary.py
deleted file mode 100644 (file)
index 8234bf5..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-# from struct import Struct, calcsize, unpack
-
-
-# class BinaryData:
-
-#     @staticmethod
-#     def pack(lst):
-#         acc_fmt = '!'
-#         acc_elems = []
-#         acc_header = ''
-#         acc_header = BinaryData._header_lst(lst, acc_header)
-#         lst = [acc_header] + lst
-#         acc_fmt, acc_elems = BinaryData._pack_lst(lst, acc_fmt, acc_elems)
-#         msg_struct = Struct(acc_fmt)
-#         msg_data = msg_struct.pack(*acc_elems)
-#         return msg_struct.size, msg_data
-
-#     @staticmethod
-#     def _header_elm(elm, acc_header):
-#         if elm is None: add = 'n'
-#         elif isinstance(elm, bool): add = 'b'
-#         elif isinstance(elm, int): add = 'i'
-#         elif isinstance(elm, float): add = 'f'
-#         elif isinstance(elm, str): add = 's'
-#         elif isinstance(elm, dict): add = '{}'
-#         elif isinstance(elm, tuple) or isinstance(elm, list):
-#             add = BinaryData._header_lst(elm, acc_header)
-#         return acc_header + add
-
-#     @staticmethod
-#     def _header_lst(elm, acc_header):
-#         add = '('
-#         for sub_elm in elm:
-#             add += BinaryData._header_elm(sub_elm, acc_header)
-#         add += ')'
-#         return acc_header + add
-
-#     @staticmethod
-#     def _pack_lst(lst, acc_fmt, acc_elems):
-#         add_fmt, add_elems = '', []
-#         for sub_elm in lst:
-#             elm_fmt, elm_elems = BinaryData._pack_elm(sub_elm, '', [])
-#             add_fmt += elm_fmt
-#             add_elems += elm_elems
-#         return acc_fmt + add_fmt, acc_elems + add_elems
-
-#     @staticmethod
-#     def _pack_elm(elm, acc_fmt, acc_elems):
-#         if elm is None:
-#             add_fmt = ''
-#             add_elems = []
-#         elif isinstance(elm, bool):
-#             add_fmt = '?'
-#             add_elems = [elm]
-#         elif isinstance(elm, int):
-#             add_fmt = 'i'
-#             add_elems = [elm]
-#         elif isinstance(elm, float):
-#             add_fmt = 'f'
-#             add_elems = [elm]
-#         elif isinstance(elm, str):
-#             b_str = bytes(elm, 'utf-8')
-#             add_fmt = 'i%ds' % len(b_str)
-#             add_elems = [len(b_str), b_str]
-#         elif isinstance(elm, tuple) or isinstance(elm, list):
-#             add_fmt, add_elems = BinaryData._pack_lst(elm, '', [])
-#         elif isinstance(elm, dict): add_fmt, add_elems = '', []
-#         return acc_fmt + add_fmt, acc_elems + add_elems
-
-#     @staticmethod
-#     def unpack(data):
-#         header_length, data = BinaryData.unpack_helper('!i', data)
-#         header_length = header_length[0]
-#         header, data = BinaryData.unpack_helper('!%ds' % header_length, data)
-#         header = header[0].decode('utf-8')
-#         vals = []
-#         curr_lst = vals
-
-#         def parent(sublist, lst):
-#             if sublist in lst: return lst
-#             for _subl in [elm for elm in lst if isinstance(elm, list)]:
-#                 if parent(sublist, _subl): return parent(sublist, _subl)
-#         for elm in header:
-#             if elm == '(':
-#                 curr_lst += [[]]
-#                 curr_lst = curr_lst[-1]
-#             elif elm == ')':
-#                 curr_lst = parent(curr_lst, vals)
-#             elif elm == '{': pass
-#             elif elm == '}': curr_lst += [{}]
-#             else:
-#                 val, data = BinaryData._unpack_elm(elm, data)
-#                 curr_lst += [val]
-#         return vals[0]
-
-#     @staticmethod
-#     def _unpack_elm(elm, data):
-#         if elm == 'n':
-#             val, data = [None], data
-#             val = val[0]
-#         elif elm == 'b':
-#             val, data = BinaryData.unpack_helper('!?', data)
-#             val = val[0]
-#         elif elm == 'i':
-#             val, data = BinaryData.unpack_helper('!i', data)
-#             val = val[0]
-#         elif elm == 'f':
-#             val, data = BinaryData.unpack_helper('!f', data)
-#             val = val[0]
-#         elif elm == 's':
-#             s_len, data = BinaryData.unpack_helper('!i', data)
-#             val, data = BinaryData.unpack_helper('!%ds' % s_len, data)
-#             val = val[0].decode('utf-8')
-#         return val, data
-
-#     @staticmethod
-#     def unpack_helper(fmt, data):
-#         size = calcsize(fmt)
-#         return unpack(fmt, data[:size]), data[size:]
diff --git a/ya2/engine/network/client.py b/ya2/engine/network/client.py
deleted file mode 100644 (file)
index be39dc2..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-# from queue import Queue
-# from ya2.engine.network.network import AbsNetwork, NetworkThread, msg_rpc_call
-# from ya2.engine.network.binary import BinaryData
-
-
-# class ClientThread(NetworkThread):
-
-#     def __init__(self, srv_addr, eng, port):
-#         self.srv_addr = srv_addr
-#         NetworkThread.__init__(self, eng, port)
-#         self.msgs = Queue()
-#         self.rpc_ret = Queue()
-
-#     def _configure_socket(self):
-#         self.tcp_sock.connect((self.srv_addr, self.port))
-
-#     def _rpc_cb(self, data, sock):
-#         self.rpc_ret.put(data)
-
-#     def _queue(self, sock):
-#         return self.msgs
-
-#     def send_msg(self, msg, receiver=None): self.msgs.put(msg)
-
-#     def do_rpc(self, funcname, *args, **kwargs):
-#         args = list(args)
-#         msg_size, msg_data = BinaryData.pack(
-#             [msg_rpc_call, funcname, args, kwargs])
-#         self.msgs.put((msg_size, msg_data))
-#         return self.rpc_ret.get()
-
-
-# class Client(AbsNetwork):
-
-#     def __init__(self, port, srv_addr):
-#         AbsNetwork.__init__(self, port)
-#         self.srv_addr = srv_addr
-#         self._functions = []
-
-#     def start(self, read_cb):
-#         return AbsNetwork.start(self, read_cb)
-
-#     def _bld_netw_thr(self):
-#         srv, port = self.srv_addr.split(':')
-#         return ClientThread(srv, self.eng, int(port))
-
-#     def _configure_udp(self): pass
-
-#     def send_udp(self, data_lst, sender):
-#         host, port = self.srv_addr.split(':')
-#         msg_size, msg_data = BinaryData.pack([sender] + data_lst)
-#         self.udp_sock.sendto(msg_data, (host, int(port)))
-
-#     def register_rpc(self, funcname): self._functions += [funcname]
-
-#     def unregister_rpc(self, funcname): self._functions.remove(funcname)
-
-#     def __getattr__(self, attr):
-#         if attr not in self._functions: raise AttributeError(attr)
-
-#         def do_rpc(*args, **kwargs):
-#             return self.netw_thr.do_rpc(attr, *args, **kwargs)
-#         return do_rpc
diff --git a/ya2/engine/network/network.py b/ya2/engine/network/network.py
deleted file mode 100644 (file)
index b9d32e7..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-# from socket import socket, AF_INET, SOCK_DGRAM, error, SOCK_STREAM, \
-#     SOL_SOCKET, SO_REUSEADDR
-# from traceback import print_exc
-# from logging import info
-# from select import select
-# from time import sleep
-# from queue import Empty
-# from threading import Thread
-# from struct import Struct, error as unpack_error
-# from _thread import interrupt_main
-# from ya2.gameobject import GameObject
-# from ya2.engine.network.binary import BinaryData
-
-
-# msg_rpc_call, msg_rpc_answ = range(2)
-
-
-# class _ConnectionError(Exception): pass
-
-
-# class NetworkThread(Thread):
-
-#     def __init__(self, eng, port):
-#         Thread.__init__(self)
-#         self.port = port
-#         self.daemon = True
-#         self.eng = eng
-#         self.is_running = True
-#         self.size_struct = Struct('!I')
-#         self.tcp_sock = socket(AF_INET, SOCK_STREAM)
-#         self.tcp_sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
-#         self._configure_socket()
-#         self.connections = [self.tcp_sock]
-
-#     def run(self):
-#         while self.is_running:
-#             sleep(.001)
-#             try:
-#                 readable, writable, exceptional = select(
-#                     self.connections, self.connections, self.connections, 1)
-#                 for sock in readable: self._process_read(sock)
-#                 for sock in writable: self._process_write(sock)
-#                 for sock in exceptional: print('exception', sock.getpeername())
-#             except (error, AttributeError) as exc: print_exc()
-#             # AttributeError happens when the server user exits from a race,
-#             # then destroy is being called but _process_read is still alive
-#             # and self.eng.cb_mux.add_cb is invoked, but self.eng in None
-#             except Exception as exc:
-#                 print_exc()
-#                 interrupt_main()
-
-#     def _process_read(self, sock):
-#         try:
-#             data = self.recv_one_msg(sock)
-#             if data:
-#                 try:
-#                     msg = BinaryData.unpack(data)
-#                     if msg[0] == msg_rpc_call:
-#                         funcname, args, kwargs = msg[1:]
-#                         self._rpc_cb(funcname, args, kwargs, sock)
-#                     elif msg[0] == msg_rpc_answ:
-#                         self._rpc_cb(msg[1], sock)
-#                     else:
-#                         args = [msg, sock]
-#                         self.eng.cb_mux.add_cb(self.read_cb, args)
-#                 except unpack_error as exc:
-#                     print(exc)
-#                     print_exc()
-#         except (_ConnectionError, TypeError) as exc:
-#             print_exc()
-#             self.notify('on_disconnected', sock)
-#             self.connections.remove(sock)
-
-#     def _process_write(self, sock):
-#         try:
-#             msg_size, msg_data = self._queue(sock).get_nowait()
-#             sock.sendall(self.size_struct.pack(msg_size))
-#             sock.sendall(msg_data)
-#         except Empty: pass
-
-#     def recv_one_msg(self, sock):
-#         lengthbuf = self.recvall(sock, self.size_struct.size)
-#         try: length = self.size_struct.unpack(lengthbuf)[0]
-#         except unpack_error as exc:
-#             print(exc)
-#             raise _ConnectionError()
-#         return self.recvall(sock, length)
-
-#     @staticmethod
-#     def recvall(sock, cnt):
-#         buf = b''
-#         while cnt:
-#             newbuf = sock.recv(cnt)
-#             if not newbuf: return None
-#             buf, cnt = buf + newbuf, cnt - len(newbuf)
-#         return buf
-
-#     def destroy(self):
-#         self.is_running = False
-#         self.tcp_sock.close()
-#         self.eng = self.tcp_sock = self.connections = None
-
-
-# class AbsNetwork(GameObject):
-
-#     rate = .1
-#     _public_addr = None
-#     _local_addr = None
-
-#     def __init__(self, port):
-#         GameObject.__init__(self)
-#         self.netw_thr = self.read_cb = self.udp_sock = self.tcp_sock = \
-#             self.udp_sock = None
-#         self.port = port
-#         self.addr2conn = {}
-
-#     def start(self, read_cb):
-#         self.eng.attach_obs(self.on_frame, 1)
-#         self.read_cb = read_cb
-#         self.udp_sock = socket(AF_INET, SOCK_DGRAM)
-#         self.udp_sock.setblocking(0)
-#         self._configure_udp()
-#         try:
-#             self.netw_thr = self._bld_netw_thr()
-#             self.netw_thr.start()
-#             self.netw_thr.read_cb = read_cb
-#             args = self.__class__.__name__, self.port
-#             info('%s is up, port %s' % args)
-#             return True
-#         except ValueError:  # e.g. empty server
-#             info("can't start the network")
-
-#     def register_cb(self, callback):
-#         self.read_cb = callback
-#         self.netw_thr.read_cb = callback
-
-#     def send(self, data_lst, receiver=None):
-#         dgram = BinaryData.pack(data_lst)
-#         self.netw_thr.send_msg(dgram, receiver)
-
-#     def on_frame(self): self.process_udp()
-
-#     @property
-#     def is_active(self):
-#         observers = self.eng.event.observers.values()
-#         return self.on_frame in [obs.mth for olst in observers for obs in olst]
-
-#     def stop(self):
-#         if not self.netw_thr:
-#             info('%s was already stopped' % self.__class__.__name__)
-#             return
-#         self.udp_sock.close()
-#         self.netw_thr.destroy()
-#         self.udp_sock = self.tcp_sock = self.netw_thr = None
-#         self.eng.detach_obs(self.on_frame)
-#         self.addr2conn = {}
-#         info('%s has been stopped' % self.__class__.__name__)
-
-#     def process_udp(self):
-#         try: dgram, conn = self.udp_sock.recvfrom(8192)
-#         except error: return
-#         self.on_udp_pck(dgram, conn)
-#         dgram = BinaryData.unpack(dgram)
-#         sender, payload = dgram[0], dgram[1:]
-#         self.read_cb(payload, conn)
-
-#     def on_udp_pck(self, dgram, conn): pass
-
-#     def destroy(self):
-#         self.stop()
-#         info('%s has been destroyed' % self.__class__.__name__)
-#         GameObject.destroy(self)
diff --git a/ya2/engine/network/server.py b/ya2/engine/network/server.py
deleted file mode 100644 (file)
index d9ae028..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-# from socket import error
-# from queue import Queue
-# from ya2.engine.network.network import AbsNetwork, NetworkThread, \
-#     msg_rpc_answ
-# from ya2.engine.network.binary import BinaryData
-# from ya2.gameobject import GameObject
-
-
-# class ServerThread(NetworkThread, GameObject):
-
-#     def __init__(self, eng, rpc_cb, port):
-#         NetworkThread.__init__(self, eng, port)
-#         GameObject.__init__(self)
-#         self.rpc_cb = rpc_cb
-#         self.conn2msgs = {}
-
-#     def _configure_socket(self):
-#         self.tcp_sock.setblocking(0)
-#         self.tcp_sock.bind(('', self.port))
-#         self.tcp_sock.listen(1)
-
-#     def _process_read(self, sock):
-#         if sock is self.tcp_sock:
-#             conn, addr = sock.accept()
-#             conn.setblocking(1)  # required on osx
-#             self.connections += [conn]
-#             self.conn2msgs[conn] = Queue()
-#             self.notify('on_connected', conn)
-#         else:
-#             NetworkThread._process_read(self, sock)
-
-#     def _rpc_cb(self, funcname, args, kwargs, sock):
-#         self.eng.cb_mux.add_cb(self.rpc_cb, [funcname, args, kwargs, sock])
-
-#     def _queue(self, sock):
-#         return self.conn2msgs[sock]
-
-#     def send_msg(self, conn, msg):
-#         self.conn2msgs[conn].put(msg)
-
-
-# class Server(AbsNetwork):
-
-#     def __init__(self, port):
-#         AbsNetwork.__init__(self, port)
-#         self.conn_cb = None
-#         self.fname2ref = {}
-
-#     @property
-#     def connections(self): return self.netw_thr.connections[1:]
-
-#     def start(self, read_cb, conn_cb):
-#         #TODO: parameters differ from overridden start
-#         AbsNetwork.start(self, read_cb)
-#         self.conn_cb = conn_cb
-#         self.netw_thr.attach(self.on_connected)
-#         self.netw_thr.attach(self.on_disconnected)
-
-#     def on_connected(self, conn):
-#         self.notify('on_connected', conn)
-
-#     def on_disconnected(self, conn):
-#         self.notify('on_disconnected', conn)
-
-#     def _bld_netw_thr(self):
-#         return ServerThread(self.eng, self.rpc_cb, self.port)
-
-#     def _configure_udp(self): self.udp_sock.bind(('', self.port))
-
-#     def send(self, data_lst, receiver=None):
-#         receivers = [cln for cln in self.connections if cln == receiver]
-#         dests = receivers if receiver else self.connections
-#         dgram = BinaryData.pack(data_lst)
-#         list(map(lambda cln: self.netw_thr.send_msg(cln, dgram), dests))
-
-#     def rpc_cb(self, funcname, args, kwargs, conn):
-#         kwargs = kwargs or {}
-#         kwargs['sender'] = conn
-#         ret = self.fname2ref[funcname](*args, **kwargs)
-#         msg_size, msg_data = BinaryData.pack([msg_rpc_answ, ret])
-#         self.netw_thr.send_msg(conn, (msg_size, msg_data))
-
-#     def register_rpc(self, func): self.fname2ref[func.__name__] = func
-
-#     def unregister_rpc(self, func): del self.fname2ref[func.__name__]
-
-#     def on_udp_pck(self, dgram, conn):
-#         sender = BinaryData.unpack(dgram)[0]
-#         if sender not in self.addr2conn: self.addr2conn[sender] = conn
-
-#     def process_udp(self):
-#         try: dgram, conn = self.udp_sock.recvfrom(8192)
-#         except error: return
-#         try:
-#             dgram = BinaryData.unpack(dgram)
-#             sender, payload = dgram[0], dgram[1:]
-#             self.read_cb(payload, sender)
-#         except IndexError as exc: print(exc)
-
-#     def send_udp(self, data_lst, receiver):
-#         if receiver[0] not in self.addr2conn: return
-#         msg_size, msg_data = BinaryData.pack(['server'] + data_lst)
-#         self.udp_sock.sendto(msg_data, self.addr2conn[receiver[0]])
diff --git a/ya2/engine/particle.py b/ya2/engine/particle.py
deleted file mode 100755 (executable)
index b5a040c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# # from math import pi
-# # from ..gameobject import GameObject
-# from ya2.lib.p3d.particle import P3dParticle
-# Particle = P3dParticle
-
-
-# # class Particle(GameObject):
-
-# #    def __init__(self, emitter, texture, npart, color=(1, 1, 1, 1), ampl=pi/6,
-# #                 ray=.5, rate=.0001, gravity=-.85, vel=3.8, part_lifetime=1.0,
-# #                 autodestroy=None):
-# #        if not self.eng.lib.version.startswith('1.10'): return
-# #        GameObject.__init__(self)
-# #        LibParticle(
-# #            emitter, texture, npart, color, ampl, ray, rate, gravity, vel,
-# #            part_lifetime, autodestroy)
diff --git a/ya2/engine/pause.py b/ya2/engine/pause.py
deleted file mode 100644 (file)
index bb21a95..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-# from direct.gui.DirectFrame import DirectFrame
-# from ya2.gameobject import GuiColleague, LogicColleague, GameObject, \
-#     Colleague
-# from ya2.lib.p3d.pause import P3dPause
-# LibPause = P3dPause
-
-
-# class PauseGui(GuiColleague):
-
-#     def __init__(self, mediator):
-#         GuiColleague.__init__(self, mediator)
-#         self.pause_frm = None
-
-#     def toggle(self, show_frm=True):
-#         if not self.mediator.logic._pause.paused:
-#             #TODO: don't access protected members
-#             if show_frm:
-#                 self.pause_frm = DirectFrame(frameColor=(.3, .3, .3, .7),
-#                                              frameSize=(-1.8, 1.8, -1, 1))
-#         else:
-#             if self.pause_frm: self.pause_frm.destroy()
-
-#     def destroy(self):
-#         if self.pause_frm: self.pause_frm = self.pause_frm.destroy()
-#         GuiColleague.destroy(self)
-
-
-# class PauseLogic(LogicColleague):
-
-#     def __init__(self, mediator):
-#         LogicColleague.__init__(self, mediator)
-#         self._pause = LibPause()
-
-#     def remove_task(self, tsk):
-#         self._pause.remove_task(tsk)
-
-#     def pause(self):
-#         self.notify('on_pause')
-#         return self._pause.pause()
-
-#     def resume(self):
-#         self.notify('on_resume')
-#         return self._pause.resume()
-
-#     def toggle(self, show_frm=True):
-#         self.mediator.gui.toggle(show_frm)
-#         (self.resume if self._pause.paused else self.pause)()
-
-#     def destroy(self):
-#         self._pause.destroy()
-#         LogicColleague.destroy(self)
-
-
-# class PauseFacade:
-
-#     @property
-#     def paused(self):
-#         return self.logic._pause.paused
-#         #TODO: don't access protected members
-
-
-# class PauseMgr(GameObject, Colleague, PauseFacade):
-
-#     def __init__(self, mediator):
-#         GameObject.__init__(self)
-#         Colleague.__init__(self, mediator)
-#         self.gui = PauseGui(self)
-#         self.logic = PauseLogic(self)
-
-#     def remove_task(self, tsk):
-#         return self.logic.remove_task(tsk)
-
-#     def destroy(self):
-#         self.gui = self.gui.destroy()
-#         self.logic = self.logic.destroy()
-#         GameObject.destroy(self)
-#         Colleague.destroy(self)
diff --git a/ya2/engine/phys.py b/ya2/engine/phys.py
deleted file mode 100644 (file)
index 6a10378..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-# from logging import info
-# from ya2.gameobject import Colleague
-# from ya2.lib.bullet.bullet import (
-#     BulletPhysWorld, BulletTriangleMesh, BulletTriangleMeshShape,
-#     BulletRigidBodyNode, BulletGhostNode)
-
-
-# PhysWorld = BulletPhysWorld
-# TriangleMesh = BulletTriangleMesh
-# TriangleMeshShape = BulletTriangleMeshShape
-# RigidBodyNode = BulletRigidBodyNode
-# GhostNode = BulletGhostNode
-
-
-# class CollInfo:
-
-#     def __init__(self, node, time):
-#         self.node = node
-#         self.time = time
-
-
-# class PhysFacade:
-
-#     def attach_rigid_body(self, rbnode):
-#         return self.root.attach_rigid_body(rbnode)
-
-#     def remove_rigid_body(self, rbnode):
-#         return self.root.remove_rigid_body(rbnode)
-
-#     def attach_ghost(self, gnode): return self.root.attach_ghost(gnode)
-#     def remove_ghost(self, gnode): return self.root.remove_ghost(gnode)
-#     def attach_vehicle(self, vehicle): return self.root.attach_vehicle(vehicle)
-#     def remove_vehicle(self, vehicle): return self.root.remove_vehicle(vehicle)
-
-#     def ray_test_all(self, from_pos, to_pos, mask=None):
-#         return self.root.ray_test_all(from_pos, to_pos, mask)
-
-#     def ray_test_closest(self, from_pos, to_pos, mask=None):
-#         return self.root.ray_test_closest(from_pos, to_pos, mask)
-
-
-# class PhysMgr(Colleague, PhysFacade):
-
-#     def __init__(self, mediator):
-#         Colleague.__init__(self, mediator)
-#         self.collision_objs = []  # objects to be processed
-#         self.__obj2coll = {}  # {obj: [(node, coll_time), ...], ...}
-#         self.root = None
-#         self.__debug_np = None
-#         PhysFacade.__init__(self)
-
-#     def reset(self):
-#         self.collision_objs = []
-#         self.__obj2coll = {}
-#         self.root = PhysWorld()
-#         self.root.set_gravity((0, 0, -8.5))
-#         self.root.init_debug()
-
-#     def start(self):
-#         self.eng.attach_obs(self.on_frame, 2)
-
-#     def on_frame(self):
-#         self.root.do_phys(self.eng.lib.last_frame_dt, 10, 1/180.0)
-#         self.__do_collisions()
-
-#     def ray_test_closest(self, top, bottom):
-#         #TODO: differs from PhysFacade's signature
-#         return self.root.ray_test_closest(top, bottom)
-
-#     def add_collision_obj(self, node): self.collision_objs += [node]
-
-#     def remove_collision_obj(self, node):
-#         try: self.collision_objs.remove(node)
-#         except ValueError:
-#             info("can't remove collision object %s" % node)
-#             # it may happen with weapons during pause
-
-#     def stop(self):
-#         self.root.stop()
-#         self.root = None
-#         self.eng.detach_obs(self.on_frame)
-
-#     def __do_collisions(self):
-#         to_clear = self.collision_objs[:]
-#         # identical collisions are ignored for .25 seconds
-#         for obj in self.collision_objs:
-#             if obj not in self.__obj2coll: self.__obj2coll[obj] = []
-#             # for contact in self.root.get_contacts(obj):
-#             # this doesn't work in 1.9, the following works
-#             # odd, this doesn't work too
-#             # for contact in self.root.wld.contact_test(obj).get_contacts():
-#             result = self.root._wld.contact_test(obj)
-#             #TODO: access a protected member
-#             for contact in result.get_contacts():
-#                 self.__process_contact(obj, contact.get_node0(), to_clear)
-#                 self.__process_contact(obj, contact.get_node1(), to_clear)
-#         for obj in to_clear:
-#             if obj in self.__obj2coll:  # it may be that it isn't here e.g.
-#                 # when you fire a rocket while you're very close to the prev
-#                 # car and the rocket is removed suddenly
-#                 for coll in self.__obj2coll[obj]:
-#                     if self.eng.curr_time - coll.time > .25:
-#                         self.__obj2coll[obj].remove(coll)
-
-#     def __process_contact(self, obj, node, to_clear):
-#         if node == obj: return
-#         if obj in to_clear: to_clear.remove(obj)
-#         if node in [coll.node for coll in self.__obj2coll[obj]]: return
-#         self.__obj2coll[obj] += [CollInfo(node, self.eng.curr_time)]
-#         self.eng.event.notify('on_collision', obj, node)
-
-#     def toggle_dbg(self):
-#         if self.root: self.root.toggle_dbg()
diff --git a/ya2/engine/profiler.py b/ya2/engine/profiler.py
deleted file mode 100644 (file)
index 248c4bb..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-# from os.path import exists
-
-
-# if not exists('main.pyo'):  # we don't deploy cProfile
-#     from cProfile import Profile
-#     from pstats import Stats
-#     from io import StringIO
-
-
-# class AbsProfiler:
-
-#     @staticmethod
-#     def build(percall):
-#         prof_cls = AbsProfiler
-#         if not exists('main.pyo'):
-#             prof_cls = PerCallProfiler if percall else Profiler
-#         return prof_cls(percall)
-
-#     def __init__(self, percall): pass
-
-#     def printstats(self): pass
-
-#     def toggle(self): pass
-
-#     def destroy(self): pass
-
-
-# class Profiler(AbsProfiler):
-
-#     def __init__(self, percall):
-#         AbsProfiler.__init__(self, percall)
-#         self.percall = percall
-#         self.is_profiling = False  # we can't infer from cProfile
-#         self.prof = Profile()
-#         self.stats = None
-
-#     def toggle(self):
-#         if not self.is_profiling: self.__enable()
-#         else:
-#             self.__disable()
-#             self.printstats()
-
-#     def __enable(self):
-#         self.prof.enable()
-#         self.is_profiling = True
-
-#     def __disable(self):
-#         self.prof.disable()
-#         self.is_profiling = False
-
-#     def printstats(self):
-#         self.prof.disable()
-#         sio = StringIO()
-#         self.stats = Stats(self.prof, stream=sio).sort_stats('cumulative')
-#         self.stats.print_stats()
-#         self._print_lines(sio)
-
-#     @staticmethod
-#     def _print_lines(sio): print(sio.getvalue())
-
-
-# class PerCallProfiler(Profiler):
-
-#     def _print_lines(self, sio):
-#         lines = sio.getvalue().split('\n')
-#         header_lines = lines[:5]
-#         content_lines = [line.split() for line in lines[5:] if line]
-#         sorted_lines = sorted(content_lines, key=lambda line: line[4])
-#         sorted_lines = reversed(sorted_lines)
-#         # line[4] is the percall value
-#         joined_lines = ['\t'.join(line) for line in sorted_lines]
-#         print('\n'.join(header_lines + joined_lines))
diff --git a/ya2/engine/shader.py b/ya2/engine/shader.py
deleted file mode 100644 (file)
index b90bb0f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# from ya2.lib.p3d.shader import P3dShaderMgr
-
-
-# ShaderMgr = P3dShaderMgr
diff --git a/ya2/engine/vec.py b/ya2/engine/vec.py
deleted file mode 100644 (file)
index 78f6401..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-# from ya2.lib.p3d.vec import P3dVec2, P3dVec3
-# Vec = P3dVec3
-# Vec2 = P3dVec2
diff --git a/ya2/facade.py b/ya2/facade.py
deleted file mode 100644 (file)
index bb9bd5a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-# class Facade(object):
-
-#     # def _fwd_mth(self, mth_name, tgt_mth):
-#     #     def fun(*args, **kwargs): return tgt_mth(*args, **kwargs)
-#     #     setattr(self, mth_name, fun)
-
-#     # def _fwd_prop(self, prop_name, tgt_prop):
-#     #     setattr(self.__class__, prop_name, property(lambda self: tgt_prop))
-
-#     def __init__(self, prop_lst=[], mth_lst=[]):
-#         list(map(lambda args: self.__fwd_prop(*args), prop_lst))
-#         list(map(lambda args: self.__fwd_mth(*args), mth_lst))
-#         # try detecting if the forwarded item is a prop or a method, so we
-#         # can pass only a single list
-
-#     def __fwd_mth(self, mth_name, tgt_mth):
-#         def fun(*args, **kwargs): return tgt_mth(self)(*args, **kwargs)
-#         setattr(self, mth_name, fun)
-
-#     def __fwd_prop(self, prop_name, tgt_prop):
-#         setattr(self.__class__, prop_name, property(tgt_prop))
-
-#     def destroy(self): pass
diff --git a/ya2/game.py b/ya2/game.py
deleted file mode 100644 (file)
index 8a74de4..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-# from abc import ABCMeta
-# from ya2.gameobject import LogicColleague, GameObject
-# from ya2.engine.engine import Engine
-
-
-# class GameLogic(LogicColleague):
-
-#     def on_start(self): pass
-
-
-# class GameFacade:
-
-#     def demand(self, tgt_state, *args):
-#         return self.fsm.demand(tgt_state, *args)
-
-
-# class GameBase(GameObject, GameFacade):  # it doesn't manage the window
-#     __metaclass__ = ABCMeta
-
-#     def __init__(self, cfg, client_cls=None):
-#         self.logic = LogicColleague(self)
-#         self.eng = Engine(cfg, self.destroy, client_cls)
-#         GameObject.__init__(self)
-
-#     def destroy(self):
-#         self.logic.destroy()
-#         GameObject.destroy(self)
-#         # self.eng = self.eng.destroy()
-#         self.eng.server.destroy()
-#         self.eng.client.destroy()
-
-
-# class Game(GameBase):  # it adds the window
-
-#     def run(self):
-#         self.logic.on_start()
-#         base.run()
diff --git a/ya2/lib/bullet/__init__.py b/ya2/lib/bullet/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/ya2/lib/bullet/bullet.py b/ya2/lib/bullet/bullet.py
deleted file mode 100644 (file)
index f18925a..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-# from panda3d.bullet import \
-#     BulletWorld as BWorld, \
-#     BulletDebugNode as BDebugNode, \
-#     BulletTriangleMesh as BTriangleMesh, \
-#     BulletTriangleMeshShape as BTriangleMeshShape, \
-#     BulletRigidBodyNode as BRigidBodyNode, \
-#     BulletGhostNode as BGhostNode
-
-
-# class BulletPhysWorld:
-
-#     def __init__(self):
-#         self._wld = BWorld()
-#         self.__debug_np = None
-
-#     def attach_rigid_body(self, rbnode):
-#         return self._wld.attach_rigid_body(rbnode)
-
-#     def remove_rigid_body(self, rbnode):
-#         return self._wld.remove_rigid_body(rbnode)
-
-#     def attach_ghost(self, gnode): return self._wld.attach_ghost(gnode)
-#     def remove_ghost(self, gnode): return self._wld.remove_ghost(gnode)
-#     def attach_vehicle(self, vehicle): return self._wld.attach_vehicle(vehicle)
-#     def remove_vehicle(self, vehicle): return self._wld.remove_vehicle(vehicle)
-
-#     def ray_test_closest(self, from_pos, to_pos, mask=None):
-#         if mask is not None:
-#             res = self._wld.ray_test_closest(from_pos, to_pos, mask)
-#         else: res = self._wld.ray_test_closest(from_pos, to_pos)
-#         return res
-
-#     def do_phys(self, dt, max_substeps, stepsize):
-#         return self._wld.do_physics(dt, max_substeps, stepsize)
-
-#     def set_gravity(self, vec): return self._wld.set_gravity(vec)
-
-#     def init_debug(self):
-#         debug_node = BDebugNode('Debug')
-#         debug_node.show_bounding_boxes(True)
-#         self.__debug_np = render.attach_new_node(debug_node)
-#         self._wld.set_debug_node(self.__debug_np.node())
-
-#     def stop(self): self.__debug_np.remove_node()
-
-#     def ray_test_all(self, pt_a, pt_b, mask=None):
-#         args = [pt_a._vec, pt_b._vec, mask] if mask else [pt_a._vec, pt_b._vec]
-#         #TODO: access to protected member
-#         return self._wld.ray_test_all(*args)
-
-#     def toggle_dbg(self):
-#         hidden = self.__debug_np.is_hidden()
-#         (self.__debug_np.show if hidden else self.__debug_np.hide)()
-
-
-# class BulletTriangleMesh:
-
-#     def __init__(self):
-#         self._mesh = BTriangleMesh()
-
-#     def add_geom(self, geom, rm_dupl, xform):
-#         return self._mesh.add_geom(geom, rm_dupl, xform)
-
-
-# class BulletTriangleMeshShape:
-
-#     def __init__(self, mesh, dynamic):
-#         self._mesh_shape = BTriangleMeshShape(mesh._mesh, dynamic=dynamic)
-#         #TODO: access to protected member
-
-
-# class BulletRigidBodyNode:
-
-#     def __init__(self, name): self._node = BRigidBodyNode(name)
-
-
-# class BulletGhostNode:
-
-#     def __init__(self, name): self._node = BGhostNode(name)
diff --git a/ya2/lib/ivals.py b/ya2/lib/ivals.py
deleted file mode 100644 (file)
index 9b6398f..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-# '''This module binds abstract interval classes and actual implementation
-# classes (for the Dependency Inversion Principle).'''
-# from ya2.lib.p3d.ivals import P3dSeq, P3dWait, P3dPosIval, P3dFunc
-
-
-# Seq = P3dSeq
-# Wait = P3dWait
-# PosIval = P3dPosIval
-# Func = P3dFunc
diff --git a/ya2/lib/p3d/audio.py b/ya2/lib/p3d/audio.py
deleted file mode 100644 (file)
index 35f21a4..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# from panda3d.core import AudioSound
-
-
-# class P3dSound:
-
-#     def __init__(self, filepath):
-#         self.snd = loader.loadSfx(filepath)
-
-#     def stop(self): return self.snd.stop()
-#     def set_loop(self, val): return self.snd.set_loop(val)
-#     def set_volume(self, vol): return self.snd.set_volume(vol)
-#     def set_play_rate(self, rate): return self.snd.set_play_rate(rate)
-
-#     def play(self):
-#         if self.snd.status() != AudioSound.PLAYING: return self.snd.play()
-#         return None
-
-#     @property
-#     def playing(self): return self.snd.status() == AudioSound.PLAYING
diff --git a/ya2/lib/p3d/ivals.py b/ya2/lib/p3d/ivals.py
deleted file mode 100644 (file)
index 898d6de..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-# from direct.interval.MetaInterval import Sequence
-# from direct.interval.FunctionInterval import Func, Wait
-# from direct.interval.LerpInterval import LerpPosInterval
-
-
-# class P3dSeq:
-
-#     def __init__(self, *ivals):
-#         self.seq = Sequence(*[ival._ival for ival in ivals])
-#         #TODO: don't access a protected member
-
-#     def start(self): return self.seq.start()
-
-#     def __add__(self, ival):
-#         self.seq.append(ival._ival)  #TODO: don't access a protected member
-#         return self.seq
-
-
-# class P3dWait:
-
-#     def __init__(self, time): self._ival = Wait(time)
-
-
-# class P3dPosIval:
-
-#     def __init__(self, node, time=1.0, pos=(0, 0, 0), blend_type='ease'):
-#         btype = {'ease': 'easeInOut'}[blend_type]
-#         self._ival = LerpPosInterval(node, time, pos=pos, blendType=btype)
-
-
-# class P3dFunc:
-
-#     def __init__(self, fun, *args): self._ival = Func(fun, *args)
diff --git a/ya2/lib/p3d/joystick.py b/ya2/lib/p3d/joystick.py
deleted file mode 100644 (file)
index 676f018..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-# from panda3d.core import InputDevice
-
-
-# class P3dJoystickMgr:
-
-#     def __init__(self):
-#         self.joysticks = []
-#         self.curr_vibration = {}
-#         self.__is_vibrating = [False, False, False, False]
-
-#     def init_joystick(self):
-#         for i, dev in enumerate(base.devices.getDevices(InputDevice.DeviceClass.gamepad)):
-#             base.attachInputDevice(dev, prefix='joypad%s' % i)
-#         taskMgr.add(self._update, 'update joysticks')
-#         # pygame.init()
-#         # joystick.init()
-#         # self.joysticks = [
-#         #     joystick.Joystick(idx) for idx in range(joystick.get_count())]
-#         # list(map(lambda joystick: joystick.init(), self.joysticks))
-
-#     @property
-#     def num_joysticks(self):
-#         return len(base.devices.getDevices(InputDevice.DeviceClass.gamepad))
-
-#     @staticmethod
-#     def get_joystick(player_idx):
-#         devices = base.devices.getDevices(InputDevice.DeviceClass.gamepad)
-#         if player_idx > len(devices) - 1:
-#             return 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-#         gamepad = devices[player_idx]
-#         face_a = gamepad.findButton('face_a')
-#         face_b = gamepad.findButton('face_b')
-#         face_x = gamepad.findButton('face_x')
-#         face_y = gamepad.findButton('face_y')
-#         dpad_l = gamepad.findButton('dpad_left')
-#         dpad_r = gamepad.findButton('dpad_right')
-#         dpad_u = gamepad.findButton('dpad_up')
-#         dpad_d = gamepad.findButton('dpad_down')
-#         trigger_l = gamepad.findButton('ltrigger')
-#         trigger_r = gamepad.findButton('rtrigger')
-#         shoulder_l = gamepad.findButton('lshoulder')
-#         shoulder_r = gamepad.findButton('rshoulder')
-#         stick_l = gamepad.findButton('lstick')
-#         stick_r = gamepad.findButton('rstick')
-#         left_x = gamepad.findAxis(InputDevice.Axis.left_x)
-#         left_y = gamepad.findAxis(InputDevice.Axis.left_y)
-#         trigger_l_axis = gamepad.findAxis(InputDevice.Axis.left_trigger)
-#         trigger_r_axis = gamepad.findAxis(InputDevice.Axis.right_trigger)
-#         trigger_l_known = trigger_l.known
-#         trigger_r_known = trigger_r.known
-#         return (left_x.value, -left_y.value, face_a.pressed, face_b.pressed,
-#                 face_x.pressed, face_y.pressed,
-#                 dpad_l.pressed, dpad_r.pressed, dpad_u.pressed, dpad_d.pressed,
-#                 trigger_l.pressed or trigger_l_axis.value > .5,
-#                 trigger_r.pressed or trigger_r_axis.value > .5,
-#                 shoulder_l.pressed, shoulder_r.pressed, stick_l.pressed,
-#                 stick_r.pressed, trigger_l_known, trigger_r_known)
-#         # for _ in pygame.event.get(): pass
-#         # if not self.joysticks: return 0, 0, 0, 0
-#         # jstick = self.joysticks[0]
-#         # axis, btn = jstick.get_axis, jstick.get_button
-#         # return axis(0), axis(1), btn(0), btn(1)
-
-#     def set_vibration(self, player_idx, code, time=-1):
-#         devices = base.devices.getDevices(InputDevice.DeviceClass.gamepad)
-#         if player_idx < 0 or player_idx > len(devices) - 1: return
-#         if player_idx in self.curr_vibration and \
-#                code in self.curr_vibration[player_idx]: return
-#         if player_idx not in self.curr_vibration:
-#             self.curr_vibration[player_idx] = {}
-#         self.curr_vibration[player_idx][code] = time
-
-#     def clear_vibration(self, player_idx, code=None):
-#         devices = base.devices.getDevices(InputDevice.DeviceClass.gamepad)
-#         if player_idx < 0 or player_idx > len(devices) - 1: return
-#         if player_idx not in self.curr_vibration or \
-#            code not in self.curr_vibration[player_idx]: return
-#         if code is None: del self.curr_vibration[player_idx]
-#         else: del self.curr_vibration[player_idx][code]
-
-#     def _update(self, task):
-#         devices = base.devices.getDevices(InputDevice.DeviceClass.gamepad)
-#         for player_idx in self.curr_vibration:
-#             for code in self.curr_vibration[player_idx]:
-#                 if self.curr_vibration[player_idx][code] != -1:
-#                     dt = globalClock.getDt()
-#                     self.curr_vibration[player_idx][code] -= dt
-#         for player_idx in self.curr_vibration:
-#             for code in list(self.curr_vibration[player_idx])[:]:
-#                 if self.curr_vibration[player_idx][code] != -1:
-#                     if self.curr_vibration[player_idx][code] < 0:
-#                         del self.curr_vibration[player_idx][code]
-#         for player_idx in list(self.curr_vibration)[:]:
-#             if not self.curr_vibration[player_idx]:
-#                 del self.curr_vibration[player_idx]
-#         for player_idx, dev in enumerate(devices):
-#             gamepad = devices[player_idx]
-#             if player_idx in self.curr_vibration and \
-#                     not self.__is_vibrating[player_idx]:
-#                 gamepad.set_vibration(.2, .4)
-#                 self.__is_vibrating[player_idx] = True
-#             elif player_idx not in self.curr_vibration:
-#                 gamepad.set_vibration(0, 0)
-#                 self.__is_vibrating[player_idx] = False
-#         return task.cont
-
-#     def destroy(self):
-#         pass
-#         # joystick.quit()
-#         # pygame.quit()
-#         # self.joysticks = []
diff --git a/ya2/lib/p3d/particle.py b/ya2/lib/p3d/particle.py
deleted file mode 100755 (executable)
index 9cc9208..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-# from math import pi, sin, cos
-# from array import array
-# from random import uniform
-# from itertools import chain
-# from logging import info
-# from panda3d.core import Geom, GeomVertexFormat, GeomVertexData, GeomPoints, \
-#     OmniBoundingVolume, GeomNode, Vec3, ShaderAttrib, TexGenAttrib, \
-#     TextureStage, Texture, GeomEnums, NodePath
-# from ya2.lib.p3d.shader import load_shader
-# from ya2.lib.p3d.gfx import P3dNode
-# from ya2.gameobject import GameObject
-
-
-# class P3dParticle(GameObject):
-
-#     _vdata = {}  # don't regenerate input structures
-
-#     def __init__(
-#             self, emitter, texture, color=(1, 1, 1, 1), ampl=pi/6,
-#             ray=.5, rate=.001, gravity=-9.81, vel=1.0, part_duration=1.0,
-#             autodestroy=None, size=10):
-#         GameObject.__init__(self)
-#         self.__tex_pos = self.__tex_curr_pos = self.__tex_times = \
-#             self.__tex_start_vel = self.__tex_curr_vel = self.__emitternode = \
-#             None
-#         self.__texture = texture
-#         self.__color = color
-#         self.__ampl = ampl
-#         self.__ray = ray
-#         self.__rate = rate
-#         self.__gravity = gravity
-#         self.__vel = vel
-#         self.__part_duration = part_duration
-#         self.__size = size
-#         self.__npart = int(round(part_duration * 1 / rate))
-#         if emitter.__class__ != P3dNode:  # emitter is a position
-#             self.__emitternode = P3dNode(NodePath('tmp'))
-#             self.__emitternode.set_pos(emitter)
-#             self.__emitternode.reparent_to(self.eng.gfx.root)
-#             emitter = self.__emitternode
-#         self.__emitter = emitter
-#         self.__old_pos = (0, 0, 0)
-#         self._nodepath = render.attach_new_node(self.__node())
-#         self._nodepath.set_transparency(True)
-#         self._nodepath.set_bin('fixed', 0)
-#         self.__set_shader()
-#         self._nodepath.set_render_mode_thickness(10)
-#         self._nodepath.set_tex_gen(TextureStage.getDefault(),
-#                                    TexGenAttrib.MPointSprite)
-#         self._nodepath.set_depth_write(False)
-#         self.upd_tsk = taskMgr.add(self._update, 'update')
-#         if autodestroy: self.eng.do_later(autodestroy, self.destroy)
-
-#     def __node(self):
-#         points = GeomPoints(GeomEnums.UH_static)
-#         points.add_next_vertices(self.__npart)
-#         geom = Geom(self.__vdata())
-#         geom.add_primitive(points)
-#         geom.set_bounds(OmniBoundingVolume())
-#         node = GeomNode('node')
-#         node.add_geom(geom)
-#         return node
-
-#     def __vdata(self):
-#         entry = (self.__texture, self.__npart, self.__color, self.__ampl,
-#                  self.__ray, self.__rate, self.__gravity)
-#         if entry in P3dParticle._vdata:
-#             vdata, pos, times, vels = P3dParticle._vdata[entry]
-#             self.__set_textures(pos, times, vels)
-#             return vdata
-#         pos, times, vels = self.__init_textures()
-#         self.__set_textures(pos, times, vels)
-#         format_ = GeomVertexFormat.get_empty()
-#         vdata = GeomVertexData('abc', format_, GeomEnums.UH_static)
-#         P3dParticle._vdata[self.__texture, self.__npart, self.__color,
-#                            self.__ampl, self.__ray, self.__rate,
-#                            self.__gravity] = \
-#             vdata, pos, times, vels
-#         return P3dParticle._vdata[self.__texture, self.__npart, self.__color,
-#                                   self.__ampl, self.__ray, self.__rate,
-#                                   self.__gravity][0]
-
-#     def __init_textures(self):
-#         positions = [self.__rnd_pos() for i in range(self.__npart)]
-#         pos_lst = [[pos.x, pos.y, pos.z, 1] for pos in positions]
-#         pos_lst = list(chain.from_iterable(pos_lst))
-#         emission_times = [
-#             (self.__rate * i, 0, 0, 0) for i in range(self.__npart)]
-#         times_lst = list(chain.from_iterable(emission_times))
-#         velocities = self.__init_velocities()
-#         vel_lst = [[v_vel[0], v_vel[1], v_vel[2], 1] for v_vel in velocities]
-#         vel_lst = list(chain.from_iterable(vel_lst))
-#         return pos_lst, times_lst, vel_lst
-
-#     def __set_textures(self, pos_lst, times_lst, vel_lst):
-#         self.__tex_pos = self.__buff_tex(pos_lst)
-#         self.__tex_curr_pos = self.__buff_tex(pos_lst)
-#         self.__tex_times = self.__buff_tex(times_lst)
-#         self.__tex_start_vel = self.__buff_tex(vel_lst)
-#         self.__tex_curr_vel = self.__buff_tex(vel_lst)
-
-#     def __buff_tex(self, vals):
-#         data = array('f', vals)
-#         tex = Texture('tex')
-#         tex.setup_buffer_texture(
-#             self.__npart, Texture.T_float, Texture.F_rgba32,
-#             GeomEnums.UH_static)
-#         tex.set_ram_image(data)
-#         return tex
-
-#     def __rnd_pos(self):
-#         ro = uniform(0, self.__ray)
-#         alpha = uniform(0, 2 * pi)
-#         return Vec3(ro * cos(alpha), ro * sin(alpha), 0)
-
-#     def __init_velocities(self):
-#         vels = []
-#         for _ in range(self.__npart):
-#             vec = self.__rnd_vel()
-#             vels += [(vec.x, vec.y, vec.z)]
-#         return vels
-
-#     def __rnd_vel(self):
-#         theta = uniform(0, self.__ampl)
-#         phi = uniform(0, 2 * pi)
-#         vec = Vec3(
-#             sin(theta) * cos(phi),
-#             sin(theta) * sin(phi),
-#             cos(theta))
-#         return vec * uniform(self.__vel * .8, self.__vel * 1.2)
-
-#     def __set_shader(self):
-#         path = 'assets/shaders/'
-#         shader = load_shader(path + 'particle.vert', path + 'particle.frag')
-#         if not shader: return
-#         self._nodepath.set_shader(shader)
-#         sha_attr = ShaderAttrib.make(shader)
-#         sha_attr = sha_attr.set_flag(ShaderAttrib.F_shader_point_size, True)
-#         self._nodepath.set_attrib(sha_attr)
-#         img = loader.loadTexture('assets/images/game/%s.dds' % self.__texture)
-#         self._nodepath.set_shader_inputs(
-#             start_pos=self.__tex_pos,
-#             positions=self.__tex_curr_pos,
-#             emitter_old_pos=self.__old_pos,
-#             emitter_pos=self.__emitter.get_pos(P3dNode(render)),
-#             start_vel=self.__tex_start_vel,
-#             velocities=self.__tex_curr_vel,
-#             accel=(0, 0, self.__gravity),
-#             start_time=globalClock.get_frame_time(),
-#             emission_times=self.__tex_times,
-#             part_duration=self.__part_duration,
-#             emitting=1,
-#             col=self.__color,
-#             image=img,
-#             size=self.__size)
-
-#     def _update(self, task):
-#         if self.__emitter and not self.__emitter.is_empty:
-#             pos = self.__emitter.get_pos(P3dNode(render))
-#         else: pos = (0, 0, 0)
-#         try:
-#             self._nodepath.set_shader_inputs(
-#                 emitter_old_pos=self.__old_pos,
-#                 emitter_pos=pos)
-#             self.__old_pos = pos
-#             return task.again
-#         except AttributeError:
-#             # _nodepath may be None on menu/pause
-#             info('_nodepath: %s' % self._nodepath)
-
-#     def destroy(self, now=False):
-#         #TODO: the signature differs from the parent's one
-#         try:
-#             self._nodepath.set_shader_input('emitting', 0)
-#         except AttributeError:
-#             # _nodepath may be None on menu/pause
-#             info('_nodepath: %s' % self._nodepath)
-#         self.eng.do_later(0 if now else 1.2 * self.__part_duration,
-#                           self.__destroy)
-
-#     def __destroy(self):
-#         try:
-#             self.upd_tsk = taskMgr.remove(self.upd_tsk)
-#         except TypeError:
-#             info("can't remove %s" % self.upd_tsk)
-#             # it may happen on pause/menu
-#         try:
-#             self._nodepath = self._nodepath.remove_node()
-#         except AttributeError:
-#             info("_nodepath %s" % self._nodepath)
-#             # it may happen on pause/menu
-#         if self.__emitternode:
-#             self.__emitternode = self.__emitternode.destroy()
-#         GameObject.destroy(self)
diff --git a/ya2/lib/p3d/pause.py b/ya2/lib/p3d/pause.py
deleted file mode 100644 (file)
index 7d00212..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-# from os import pardir  # pardir is .. (parent directory)
-# from os.path import dirname, abspath, join
-# from sys import modules
-# from direct.task import Task
-# from direct.interval.IntervalGlobal import ivalMgr
-# from ya2.gameobject import GameObject
-
-
-# class TaskDec:
-
-#     paused_taskchain = 'paused tasks'
-
-#     def __init__(self, tsk):
-#         self.tsk = tsk
-#         path = dirname(modules[Task.__name__].__file__)
-#         self.__direct_dir = abspath(join(path, pardir))  # path of direct.*
-
-#     def process(self):
-#         func = self.tsk.get_function()  # ordinary tasks
-#         mod = func.__module__
-#         modfile = ''
-#         if "from '" in str(modules[mod]):
-#             modfile = str(modules[mod]).split("from '")[1][:-2]
-#         sys_mod = modfile.find(self.__direct_dir) < 0
-#         actor_ival = False
-#         if hasattr(func, 'im_class'):
-#             actor_ival = func.im_class.__name__ == 'ActorInterval'
-#         if mod.find('direct.interval') == 0 and not actor_ival:
-#             self.tsk.interval.pause()  # python-based intervals
-#             return self.tsk
-#         if mod not in modules or sys_mod: return self.tsk
-#         return None
-
-#     def pause(self):
-#         tsk = self.tsk
-#         has_args = hasattr(tsk, 'getArgs')
-#         tsk.stored_extraArgs = tsk.get_args() if has_args else None
-#         if hasattr(tsk, 'getFunction'): tsk.stored_call = tsk.get_function()
-#         has_p = hasattr(tsk, '_priority')
-#         tsk.stored_priority = tsk._priority if has_p else tsk.get_sort()
-#         if hasattr(tsk, 'remainingTime'): tsk.remove()  # do_later tasks
-#         else:  # ordinary tasks
-#             tsk.lastactivetime = -tsk.time if hasattr(tsk, 'time') else 0
-#             tsk.setTaskChain(TaskDec.paused_taskchain)
-
-#     def __resume_do_later(self):
-#         tsk = self.tsk
-#         d_t = globalClock.get_real_time() - globalClock.get_frame_time()
-#         tmp_delay = tsk.remainingTime - d_t
-#         upon_death = tsk.uponDeath if hasattr(tsk, 'uponDeath') else None
-#         new_task = taskMgr.doMethodLater(
-#             tmp_delay, tsk.stored_call, tsk.name, uponDeath=upon_death,
-#             priority=tsk.stored_priority, extraArgs=tsk.stored_extraArgs)
-#         if hasattr(tsk, 'remainingTime'): new_task.delayTime = tsk.delayTime
-
-#     def resume(self):
-#         tsk = self.tsk
-#         if hasattr(tsk, 'interval'):
-#             tsk.interval.resume()
-#             if hasattr(tsk, 'stored_call'): tsk.set_function(tsk.stored_call)
-#             return
-#         if hasattr(tsk, 'remainingTime'):
-#             self.__resume_do_later()
-#             return
-#         tsk.set_delay(tsk.lastactivetime)  # ordinary tasks
-#         tsk.set_task_chain('default')
-#         tsk.clear_delay()  # to avoid assertion error on resume
-
-
-# class P3dPause(GameObject):
-
-#     def __init__(self):
-#         GameObject.__init__(self)
-#         taskMgr.setupTaskChain(TaskDec.paused_taskchain, frameBudget=0)
-#         self.__paused_ivals = []
-#         self.__paused_tasks = []
-
-#     @property
-#     def paused(self):
-#         tsk = taskMgr.getTasksNamed('__on_frame')[0]
-#         return tsk.getTaskChain() == TaskDec.paused_taskchain
-
-#     def pause_tasks(self):
-#         is_tsk = lambda tsk: tsk and hasattr(tsk, 'getFunction')
-#         tasks = [TaskDec(tsk) for tsk in taskMgr.getTasks() if is_tsk(tsk)]
-#         tasks = [tsk for tsk in tasks
-#                  if tsk.tsk.get_task_chain() != 'unpausable']
-#         namefilter = ['igLoop', 'dataLoop', 'ivalLoop', 'collisionLoop',
-#                       'garbageCollectStates', 'audioLoop',
-#                       'resetPrevTransform', 'eventManager']
-#         tasks = [tsk for tsk in tasks
-#                  if tsk.tsk.get_name_prefix() not in namefilter]
-#         not_none = lambda tsk: tsk is not None
-#         paused_tasks = list(filter(not_none, [tsk.process() for tsk in tasks]))
-#         self.__paused_tasks = list(map(TaskDec, paused_tasks))
-#         for tsk in list(filter(is_tsk, taskMgr.getDoLaters())):
-#             self.__paused_tasks += [TaskDec(tsk)]
-#             tsk.remainingTime = tsk.wakeTime - globalClock.get_frame_time()
-#         list(map(lambda tsk: tsk.pause(), self.__paused_tasks))
-
-#     def remove_task(self, tsk):
-#         list(map(self.__paused_tasks.remove, [ptsk for ptsk in self.__paused_tasks if ptsk.tsk == tsk]))
-
-#     def pause(self):
-#         self.__paused_ivals = ivalMgr.getIntervalsMatching('*')
-#         self.pause_tasks()
-#         return self.paused
-
-#     def resume(self):
-#         list(map(lambda ival: ival.resume(), self.__paused_ivals))
-#         list(map(lambda tsk: tsk.resume(), self.__paused_tasks))
-#         return self.paused
-
-#     def destroy(self): GameObject.destroy(self)
diff --git a/ya2/lib/p3d/shader.py b/ya2/lib/p3d/shader.py
deleted file mode 100644 (file)
index 3eae60f..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-# from os.path import isfile, dirname
-# from panda3d.core import AmbientLight, DirectionalLight, PointLight, \
-#     Spotlight, LVector4f, LVector3f, Vec3, Shader, TextureStage, \
-#     TexMatrixAttrib
-# from direct.filter.FilterManager import FilterManager
-# from ya2.lib.builder import LibP3d
-
-
-# def load_shader(vert, frag):
-
-#     def is_file(path):
-#         joinchar = '/' if LibP3d.runtime() and not path.startswith('/') else ''
-#         dpath = LibP3d.runtime() and dirname(__file__)
-#         return isfile((dpath or '') + joinchar + path)
-#     if is_file(vert) and is_file(frag):
-#         shader = Shader.load(Shader.SLGLSL, vert, frag)
-#     else: shader = Shader.make(Shader.SLGLSL, vert, frag)
-#     return shader
-
-
-# class P3dShaderMgr:
-
-#     def __init__(self, shaders, gamma):
-#         self.filter_mgr = None
-#         self.gamma, self.buffer, self.lcam, self.lights = gamma, None, None, []
-#         if shaders: self.setup_post_fx()
-
-#     def __set_lgt(self, lgt, col):
-#         if type(col) in [int, float]: lgt.set_color_temperature(col)
-#         else: lgt.set_color(col)
-#         self.lights += [render.attach_new_node(lgt)]
-#         render.set_light(self.lights[-1])
-
-#     def set_amb_lgt(self, col):
-#         self.__set_lgt(AmbientLight('ambient light'), col)
-
-#     def set_dir_lgt(self, col, direction):
-#         self.__set_lgt(DirectionalLight('directional light'), col)
-#         self.lights[-1].set_hpr(*direction)
-
-#     def set_shadow_lgt(self, direction):
-#         self.__set_lgt(DirectionalLight('directional light'), (1, 1, 1, 1))
-#         self.lights[-1].node().set_shadow_caster(True, 8192, 8192)
-#         self.lights[-1].node().get_lens().set_film_size(2048, 2048)
-#         self.lights[-1].node().get_lens().set_near_far(1, 2048)
-#         #self.lights[-1].node().show_frustum()
-#         self.lights[-1].set_hpr(*direction)
-#         return self.lights[-1]
-
-#     def set_pnt_lgt(self, col, pos):
-#         self.__set_lgt(PointLight('point light'), col)
-#         self.lights[-1].set_pos(*pos)
-
-#     def set_spotlight(self, col, exp, cutoff, pos, look_at):
-#         self.__set_lgt(Spotlight('spotlight'), col)
-#         self.lights[-1].set_exponent(exp)
-#         self.lights[-1].get_lens().set_fov(cutoff, cutoff)
-#         self.lights[-1].set_pos(*pos)
-#         self.lights[-1].look_at(*look_at)
-
-#     @staticmethod
-#     def set_default_args(idx):
-#         pref = 'lights[%s].' % idx
-#         args = [(pref + 'pos', LVector4f(0, 0, 0, 1)),
-#                 (pref + 'amb', LVector3f(0, 0, 0)),
-#                 (pref + 'diff', LVector3f(0, 0, 0)),
-#                 (pref + 'spec', LVector3f(0, 0, 0)),
-#                 (pref + 'dir', LVector3f(0, 0, 0)),
-#                 (pref + 'exp', .0),
-#                 (pref + 'cutoff', .0)]
-#         list(map(lambda _args: render.set_shader_input(*_args), args))
-
-#     def set_lgt_args(self, idx, lgt):
-#         self.set_default_args(idx)
-#         ShaderSetter.build(lgt).set('lights[%s].' % idx, lgt)
-
-#     def clear_lights(self):
-#         for lgt in self.lights:
-#             base.render.clear_light(lgt)
-#             lgt.removeNode()
-#         self.lights = []
-
-#     def setup_post_fx(self):
-#         self.filter_mgr = FilterManager(base.win, base.cam)
-#         # rendered_scene = Texture()
-#         # aa_scene = Texture()
-#         # filtered_scene = Texture()
-#         # filter_quad = self.filter_mgr.renderQuadInto(colortex=filtered_scene)
-#         # aa_quad = self.filter_mgr.renderQuadInto(colortex=aa_scene)
-#         # final_quad = self.filter_mgr.renderSceneInto(colortex=rendered_scene)
-#         # filter_quad.set_shader(self.__load_shader('filter', 'sobel_filter'))
-#         # filter_quad.set_shader_input('in_tex', rendered_scene)
-#         # aa_quad.set_shader(self.__load_shader('fxaa', 'fxaa'))
-#         # aa_quad.set_shader_input('in_tex', filtered_scene)
-#         # final_quad.set_shader(self.__load_shader('filter', 'pass'))
-#         # final_quad.set_shader_input('gamma', self.gamma)
-#         # final_quad.set_shader_input('in_tex', aa_scene)
-
-#     @staticmethod
-#     def __load_shader(vshad, fshad):
-#         with open('assets/shaders/%s.vert' % vshad) as vfile:
-#             fvert = vfile.read()
-#         with open('assets/shaders/%s.frag' % fshad) as ffile:
-#             ffrag = ffile.read()
-#         return load_shader(fvert, ffrag)
-
-#     def apply(self):
-#         # winprops = WindowProperties.size(2048, 2048)
-#         # props = FrameBufferProperties()
-#         # props.set_rgb_color(1)
-#         # props.set_alpha_bits(1)
-#         # props.set_depth_bits(1)
-#         # lbuffer = base.graphicsEngine.make_output(
-#         #     base.pipe, 'offscreen buffer', -2, props, winprops,
-#         #     GraphicsPipe.BFRefuseWindow, base.win.getGsg(), base.win)
-#         # self.buffer = lbuffer
-#         # ldepthmap = Texture()
-#         # lbuffer.addRenderTexture(ldepthmap, GraphicsOutput.RTMBindOrCopy,
-#         #                          GraphicsOutput.RTPDepthStencil)
-#         # ldepthmap.set_minfilter(Texture.FTShadow)
-#         # ldepthmap.set_magfilter(Texture.FTShadow)
-
-#         # base.camLens.set_near_far(1.0, 10000)
-#         # base.camLens.set_fov(75)
-
-#         # self.lcam = base.makeCamera(lbuffer)
-#         # self.lcam.node().set_scene(render)
-#         # self.lcam.node().get_lens().set_fov(45)
-#         # self.lcam.node().get_lens().set_near_far(1, 100)
-
-#         # render.set_shader_input('light', self.lcam)
-#         # render.set_shader_input('depthmap', ldepthmap)
-#         # render.set_shader_input('ambient', .15, .15, .15, 1.0)
-
-#         # lci = NodePath(PandaNode('light camera initializer'))
-#         # lci.set_shader(self.__load_shader('caster', 'caster'))
-#         # self.lcam.node().set_initial_state(lci.get_state())
-
-#         # mci = NodePath(PandaNode('main camera initializer'))
-#         # # use PTALVecBaseX instead
-#         # # setShaderInput('vec3argname', PTALVecBase3(((0, 0, 0), (1, 1, 1))))
-#         render.set_shader(self.__main_shader())
-#         # render.set_shader_input('num_lights', len(self.lights))
-#         # self.set_shader_pars(render)
-#         # list(map(
-#         #     lambda lgt: self.set_lgt_args(*lgt), enumerate(self.lights)))
-#         # mci.setShader(self.__main_shader())
-#         # base.cam.node().set_initial_state(mci.getState())
-
-#         # self.lcam.set_pos(15, 30, 45)
-#         # self.lcam.look_at(0, 15, 0)
-#         # self.lcam.node().get_lens().set_near_far(1, 100)
-
-#     def __main_shader(self):
-#         with open('assets/shaders/main.vert') as fvert:
-#             vert = fvert.read()
-#         with open('assets/shaders/main.frag') as ffrag:
-#             frag = ffrag.read()
-#         frag = frag.replace('<LIGHTS>', str(len(self.lights)))
-#         return load_shader(vert, frag)
-
-#     def toggle_shader(self):
-#         if render.get_shader():
-#             render.set_shader_off()
-#             render.set_shader_auto()
-#             return
-#         self.apply()
-
-#     def set_shader_pars(self, model):
-#         texture_stages = model.find_all_texture_stages()
-#         model.set_shader_input('gloss_slot', 0)
-#         model.set_shader_input('detail_slot', 0)
-#         model.set_shader_input('detail_scale', (1, 1))
-#         for tstage in texture_stages:
-#             if tstage.getSort() == 0: continue
-#             self.__set_slots(tstage, model, 1 if tstage.getSort() == 10 else 2)
-
-#     @staticmethod
-#     def __set_slots(tstage, model, slot):
-#         if tstage.getMode() == TextureStage.MGloss:
-#             model.set_shader_input('gloss_slot', slot)
-#         else:
-#             model.set_shader_input('detail_slot', slot)
-#             attrib_type = TexMatrixAttrib.get_class_type()
-#             for geom_np in model.find_all_matches('**/+GeomNode'):
-#                 geom_node = geom_np.node()
-#                 for i in range(geom_node.get_num_geoms()):
-#                     state = geom_node.get_geom_state(i)
-#                     if state.has_attrib(attrib_type):
-#                         attrib = state.get_attrib(attrib_type)
-#                         for j in range(attrib.get_num_stages()):
-#                             stage = attrib.get_stage(j)
-#                             scale = attrib.get_transform(stage).get_scale()
-#                             model.set_shader_input('detail_scale', scale)
-
-#     def destroy(self): self.clear_lights()
-
-
-# class ShaderSetter:
-
-#     @staticmethod
-#     def build(lgt):
-#         cls2sett = {
-#             AmbientLight: ShaderSetterAmbient,
-#             PointLight: ShaderSetterPointLight,
-#             DirectionalLight: ShaderSetterDirectionalLight,
-#             Spotlight: ShaderSetterSpotlight}
-#         return cls2sett[lgt.node().__class__]()
-
-#     @staticmethod
-#     def _set_pars(pref, lgt_pos, lgt):
-#         render.set_shader_input(pref + 'pos', lgt_pos)
-#         render.set_shader_input(pref + 'diff', lgt.node().get_color())
-#         render.set_shader_input(pref + 'spec', lgt.node().get_color())
-
-
-# class ShaderSetterAmbient(ShaderSetter):
-
-#     @staticmethod
-#     def set(pref, lgt):
-#         render.set_shader_input(pref + 'amb', lgt.node().get_color())
-
-
-# class ShaderSetterPointLight(ShaderSetter):
-
-#     @staticmethod
-#     def set(pref, lgt):
-#         lgt_pos = lgt.get_mat(base.cam).xform(LVector4f(0, 0, 0, 1))
-#         ShaderSetter._set_pars(pref, lgt_pos, lgt)
-
-
-# class ShaderSetterDirectionalLight(ShaderSetter):
-
-#     @staticmethod
-#     def set(pref, lgt):
-#         lgt_vec = -render.get_relative_vector(lgt, Vec3(0, 1, 0))
-#         lgt_pos = LVector4f(lgt_vec[0], lgt_vec[1], lgt_vec[2], 0)
-#         ShaderSetter._set_pars(pref, lgt_pos, lgt)
-
-
-# class ShaderSetterSpotlight(ShaderSetter):
-
-#     @staticmethod
-#     def set(pref, lgt):
-#         lgt_vec = base.cam.get_relative_vector(lgt, Vec3(0, 1, 0))
-#         lgt_pos = lgt.get_mat(base.cam).xform(LVector4f(0, 0, 0, 1))
-#         ShaderSetter._set_pars(pref, lgt_pos, lgt)
-#         render.set_shader_input(pref + 'dir', lgt_vec)
-#         render.set_shader_input(pref + 'exp', lgt.node().get_exponent())
-#         cutoff = lgt.node().get_lens().get_fov()[0]
-#         render.set_shader_input(pref + 'cutoff', cutoff)
diff --git a/ya2/lib/p3d/vec.py b/ya2/lib/p3d/vec.py
deleted file mode 100755 (executable)
index 0ad992d..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-# from panda3d.core import Vec2, Vec3, Mat4, LVector2f, LVector3f
-
-
-# class P3dVec2:
-
-#     attr_lst = ['x', 'y']
-#     p3d_cls = Vec2
-
-#     def __init__(self, *args):
-#         self._vec = self.p3d_cls(*args)
-
-#     @property
-#     def x(self): return self._vec.x
-
-#     @property
-#     def y(self): return self._vec.y
-
-#     @property
-#     def xy(self): return P3dVec2(self._vec.x, self._vec.y)
-
-#     def signed_angle_deg(self, vec):
-#         return self._vec.signed_angle_deg(LVector2f(vec.x, vec.y))
-
-#     def dot(self, other):
-#         if isinstance(other, tuple): other = self.__class__(*other)
-#         return self._vec.dot(other._vec)
-#         #TODO: don't access a protected member
-
-#     def __neg__(self):
-#         nvec = - self._vec
-#         return self.__class__(*[getattr(nvec, attr) for attr in self.attr_lst])
-
-#     def __add__(self, vec):
-#         if isinstance(vec, tuple): vec = self.__class__(*vec)
-#         svec = self._vec + vec._vec  #TODO: don't access a protected member
-#         return self.__class__(*[getattr(svec, attr) for attr in self.attr_lst])
-
-#     def __sub__(self, vec):
-#         if isinstance(vec, tuple): vec = self.__class__(*vec)
-#         svec = self._vec - vec._vec  #TODO: don't access a protected member
-#         return self.__class__(*[getattr(svec, attr) for attr in self.attr_lst])
-
-#     def __mul__(self, val):
-#         svec = self._vec * val
-#         return self.__class__(*[getattr(svec, attr) for attr in self.attr_lst])
-
-#     def normalize(self):
-#         self._vec.normalize()
-#         return self.__class__(*self.attrs)
-
-#     @property
-#     def attrs(self): return [getattr(self._vec, fld) for fld in self.attr_lst]
-
-#     @property
-#     def normalized(self):
-#         vec = self.p3d_cls(*self.attrs)
-#         vec.normalize()
-#         return self.__class__(*[getattr(vec, fld) for fld in self.attr_lst])
-
-#     def rotate(self, deg):
-#         rot_mat = Mat4()
-#         rot_mat.set_rotate_mat(deg, (0, 0, 1))
-#         self._vec = rot_mat.xform_vec(self._vec)
-
-#     def length(self): return self._vec.length()
-
-#     def __repr__(self):
-#         tmpl = '%s(' + \
-#                ', '.join(['%s' for _ in range(len(self.attr_lst))]) + ')'
-#         rnd = lambda x: round(x, 3)
-#         vals = [rnd(getattr(self._vec, attr)) for attr in self.attr_lst]
-#         pars = tuple([self.__class__.__name__] + vals)
-#         return tmpl % pars
-
-
-# class P3dVec3(P3dVec2):
-
-#     attr_lst = ['x', 'y', 'z']
-#     p3d_cls = Vec3
-
-#     @property
-#     def z(self): return self._vec.z
-
-#     def signed_angle_deg(self, vec):
-#         v_up = LVector3f(0, 0, 1)
-#         return self._vec.signed_angle_deg(LVector3f(vec.x, vec.y, vec.z), v_up)
diff --git a/ya2/lib/p3d/widget.py b/ya2/lib/p3d/widget.py
deleted file mode 100755 (executable)
index 3c26e16..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-# from panda3d.core import LVecBase4f
-# from direct.gui.DirectGuiGlobals import NORMAL, DISABLED
-# from ya2.engine.vec import Vec2
-
-
-# class WidgetMixin:
-
-#     highlight_color_offset = [
-#         LVecBase4f(.4, .4, 0, .4),
-#         LVecBase4f(0, 0, .4, .4),
-#         LVecBase4f(0, .4, 0, .4),
-#         LVecBase4f(.4, 0, 0, .4)]
-
-#     def __init__(self):
-#         self.start_txt_color = self.start_frame_color = None
-#         self.was_visible = True
-#         self.curr_offset = LVecBase4f(0, 0, 0, 0)
-
-#     def get_np(self): return self.img
-
-#     def enable(self): pass
-
-#     def disable(self): pass
-
-#     @property
-#     def pos(self):
-#         try: pos = self.get_pos(self.wdg.get_parent())
-#         except AttributeError: pos = self.get_pos(self.img.get_parent())
-#         return Vec2(pos[0], pos[2])
-
-#     @property
-#     def global_pos(self):
-#         pos = self.get_pos(render2d)
-#         return Vec2(pos[0], pos[2])
-
-
-# class ImgMixin(WidgetMixin):
-
-#     def init(self, wdg): pass
-
-
-# class FrameMixin(WidgetMixin):
-
-#     def init(self, wdg):
-#         self.curr_offset = LVecBase4f(0, 0, 0, 0)
-#         self.start_frame_color = wdg.get_np()['frameColor']
-
-#     def enable(self):
-#         self['state'] = NORMAL
-#         if hasattr(self, 'set_alpha_scale'): self.set_alpha_scale(1)
-#         self.get_np()['frameColor'] = self.start_frame_color
-
-#     def disable(self):
-#         self['state'] = DISABLED
-#         if hasattr(self, 'set_alpha_scale'): self.set_alpha_scale(.25)
-#         col = self.start_frame_color
-#         self.get_np()['frameColor'] = (col[0], col[1], col[2], col[3] * .4)
-
-#     def on_wdg_enter(self, pos=None, player=0): pass
-
-#     def on_wdg_exit(self, pos=None, player=0): pass
-
-
-# class ScrolledFrameMixin(WidgetMixin):
-
-#     def init(self, wdg): pass
-
-#     def enable(self): self['state'] = NORMAL
-
-#     def disable(self): self['state'] = DISABLED
-
-#     def on_wdg_enter(self, pos=None, player=0): pass
-
-#     def on_wdg_exit(self, pos=None, player=0): pass
-
-
-# class BtnMixin(FrameMixin):
-
-#     def init(self, wdg):
-#         FrameMixin.init(self, wdg)
-#         wdg = wdg.get_np()
-#         self.start_txt_color = wdg.component('text0').textNode.get_text_color()
-#         self.start_txt_scale = wdg.component('text0').textNode.get_text_scale()
-
-#     def on_arrow(self, direction): pass
-
-#     def on_wdg_enter(self, pos=None, player=0):  # pos: mouse's position
-#         self.curr_offset += WidgetMixin.highlight_color_offset[player]
-#         col = LVecBase4f(self.start_frame_color)
-#         self.get_np()['frameColor'] = col + self.curr_offset
-#         self.get_np()['text_fg'] = self.start_txt_color + self.curr_offset
-#         self.get_np()['text_scale'] = self.start_txt_scale * 1.04
-#         self.get_np().set_shader_input('col_offset', self.curr_offset)
-#         self.get_np().component('text0').textNode.set_shadow(.064, .064)
-#         self.get_np().component('text0').textNode.set_shadow_color(.2, .2, 0, .8)
-
-#     def on_wdg_exit(self, pos=None, player=0):  # pos: mouse's position
-#         self.curr_offset -= WidgetMixin.highlight_color_offset[player]
-#         col = LVecBase4f(self.start_frame_color)
-#         self.get_np()['frameColor'] = col + self.curr_offset
-#         self.get_np()['text_fg'] = self.start_txt_color
-#         self.get_np()['text_scale'] = self.start_txt_scale
-#         self.get_np()['frameColor'] = self.start_frame_color
-#         self.get_np().set_shader_input('col_offset', self.curr_offset)
-#         self.get_np().component('text0').textNode.set_shadow(0, 0)
-#         self.get_np().component('text0').textNode.set_shadow_color(1, 1, 1, 1)
-
-#     def on_enter(self, player):
-#         if self['command'] and self['state'] == NORMAL:
-#             lst_arg = [player] if player is not None else []
-#             self['command'](*self['extraArgs'] + lst_arg)
-
-#     def enable(self):
-#         FrameMixin.enable(self)
-#         t0n = self.get_np().component('text0').textNode
-#         t0n.set_text_color(self.start_txt_color)
-#         t0n.set_text_scale(self.start_txt_scale)
-
-#     def disable(self):
-#         FrameMixin.disable(self)
-#         col = self.start_txt_color
-#         self.get_np()['text_fg'] = (col[0], col[1], col[2], col[3] * .4)
-#         t0n = self.get_np().component('text0').textNode
-#         t0n.set_text_scale(self.start_txt_scale)
-
-
-# class EntryMixin(FrameMixin):
-
-#     def on_arrow(self, direction): pass
-
-#     def on_wdg_enter(self, pos=None, player=0):  # pos: mouse's position
-#         FrameMixin.on_wdg_enter(self, pos, player)
-#         self.curr_offset += WidgetMixin.highlight_color_offset[player]
-#         col = LVecBase4f(self.start_frame_color)
-#         self.get_np()['frameColor'] = col + self.curr_offset
-#         # self.get_np()['focus'] = 1  # it focuses it if mouse over
-#         # self.get_np().setFocus()
-
-#     def on_wdg_exit(self, pos=None, player=0):  # pos: mouse's position
-#         FrameMixin.on_wdg_exit(self, pos, player)
-#         self.curr_offset -= WidgetMixin.highlight_color_offset[player]
-#         col = LVecBase4f(self.start_frame_color)
-#         self.get_np()['frameColor'] = col + self.curr_offset
-#         # self.get_np()['focus'] = 0
-#         # self.get_np().setFocus()
-
-#     def on_enter(self, player=0):
-#         self['focus'] = 1
-#         if self['command'] and self['state'] == NORMAL:
-#             self['command'](*self['extraArgs'])
-
-
-# class CheckBtnMixin(BtnMixin):
-
-#     def on_enter(self, player=0):
-#         self['indicatorValue'] = not self['indicatorValue']
-#         BtnMixin.on_enter(self, player)
-
-
-# class SliderMixin(FrameMixin):
-
-#     def on_arrow(self, direction):
-#         if direction in [(-1, 0), (1, 0)]:
-#             n_p = self.get_np()
-#             delta = (n_p['range'][1] - n_p['range'][0]) / 10.0
-#             n_p['value'] += -delta if direction == (-1, 0) else delta
-#         return direction in [(-1, 0), (1, 0)]
-
-#     def on_enter(self, player=0): pass
-
-
-# class OptionMenuMixin(BtnMixin):
-
-#     def on_arrow(self, direction):
-#         is_hor = direction in [(-1, 0), (1, 0)]
-#         nodepath = self.get_np()
-#         if is_hor or nodepath.popupMenu.is_hidden(): return False
-#         old_idx = nodepath.highlightedIndex
-#         dir2offset = {(0, -1): 1, (0, 1): -1}
-#         idx = nodepath.highlightedIndex + dir2offset[direction]
-#         idx = min(len(nodepath['items']) - 1, max(0, idx))
-#         if old_idx == idx: return True
-#         fcol = nodepath.component('item%s' % idx)['frameColor']
-#         old_cmp = nodepath.component('item%s' % old_idx)
-#         nodepath._unhighlightItem(old_cmp, fcol)
-#         nodepath._highlightItem(nodepath.component('item%s' % idx), idx)
-#         return True
-
-#     def on_enter(self, player=0):
-#         nodepath = self.get_np()
-#         if nodepath.popupMenu.is_hidden():
-#             nodepath.showPopupMenu()
-#             nodepath._highlightItem(nodepath.component('item0'), 0)
-#         else:
-#             nodepath.selectHighlightedIndex()
-#             idx = nodepath.selectedIndex
-#             if nodepath['command']: nodepath['command'](nodepath['items'][idx])
-#             nodepath.hidePopupMenu()
-#             idx += -1 if idx else 1
-#             try:
-#                 fcol = nodepath.component('item%s' % idx)['frameColor']
-#                 curr_name = 'item%s' % nodepath.selectedIndex
-#                 nodepath._unhighlightItem(nodepath.component(curr_name), fcol)
-#             except KeyError:  # when there is only one element
-#                 pass
-#         return not nodepath.popupMenu.is_hidden()