Commits

Andrew Peterson committed b094a14

Client Ref now forwards all ship updates from server to the ViewerState. Revisit this to make it less hardcoded.

  • Participants
  • Parent commits e60b28c

Comments (0)

Files changed (3)

File djlib/game.py

         for state in self.known_states.itervalues():
             state.shutdown()
         state = {}
+
+    def getActiveState(self):
+        return self.curr_state
         
 #end GameClass
 

File pyshipcommand_gui/client.py

 
 # LOCAL
 from states.loading import LoadingState
+from states.viewer import ViewerState
 from cscripts import ClientScriptMgr
 from pyshipcommand.network import PBClient, NetVector, NetShip, NetInit, NetScript, NetCelestialBody
 
         if not net_ships:
             return
         print "Received %d ship updates!" % (len(net_ships))
-        #ship_view.updateShips(net_ships)
+
+        # We only use ship updates when we are in the ViewerState
+        state = self.gc.getActiveState()
+        if isinstance(state, ViewerState):
+            state.updateShips(net_ships)
 
     def remote_log(self, log):
         for l in log:

File pyshipcommand_gui/states/viewer.py

 
         print "Universe contains %d Suns, %d Planets, %d Asteroids, %d Unknowns" % tuple(body_count)
 
+    def updateShips(self, net_ships):
+        self.ship_view.updateShips(net_ships)
 
     def move(self, event):
         vec = Vector(0, 0)