ya2 · news · projects · code · about

domino
[pmachines.git] / pmachines / items / item.py
index 9d06be6adabd076169e920716b73387fd9d4b28f..b3c711db74092288bfbe2fc725f5bfdc4acfeab8 100644 (file)
@@ -14,7 +14,7 @@ class Command:
 
 class Item:
 
-    def __init__(self, world, plane_node, count, cb_inst, curr_bottom, model_path):
+    def __init__(self, world, plane_node, count, cb_inst, curr_bottom, scene_repos, model_path):
         self._world = world
         self._plane_node = plane_node
         self._count = count
@@ -24,6 +24,7 @@ class Item:
         self._first_command = True
         self.repos_done = False
         self._curr_bottom = curr_bottom
+        self._scene_repos = scene_repos
         self._model_path = model_path
         self._commands = []
         self._command_idx = -1
@@ -85,6 +86,14 @@ class Item:
         self._txt['pos'] = p2d
         self.repos_done = True
 
+    def repos_x(self, x):
+        self._np.set_x(x)
+        bounds = self._np.get_tight_bounds()
+        bounds = bounds[0] - self._np.get_pos(), bounds[1] - self._np.get_pos()
+        pos = self._np.get_pos() + (bounds[1][0], bounds[0][1], bounds[0][2])
+        p2d = P3dGfxMgr.screen_coord(pos)
+        self._txt['pos'] = p2d
+
     def get_bottom(self):
         bounds = self._np.get_tight_bounds()
         bounds = bounds[0] - self._np.get_pos(), bounds[1] - self._np.get_pos()
@@ -150,8 +159,9 @@ class Item:
             self._txt.destroy()
             self._count -= 1
             if self._count:
-                item = self.__class__(self._world, self._plane_node, self._count, self._cb_inst)  # pylint: disable=no-value-for-parameter
+                item = self.__class__(self._world, self._plane_node, self._count, self._cb_inst, self._curr_bottom, self._scene_repos)  # pylint: disable=no-value-for-parameter
                 self._cb_inst(item)
+            self._scene_repos()
 
     def on_click_r(self, pos):
         if self._paused: return