[longomatch] Make the game units manager work



commit c63f74681161f9724bb9d155cc97fc1dd878b63c
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue Nov 29 22:07:45 2011 +0100

    Make the game units manager work

 LongoMatch.Services/Services/GameUnitsManager.cs |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/LongoMatch.Services/Services/GameUnitsManager.cs b/LongoMatch.Services/Services/GameUnitsManager.cs
index 6d951fa..c3af4bc 100644
--- a/LongoMatch.Services/Services/GameUnitsManager.cs
+++ b/LongoMatch.Services/Services/GameUnitsManager.cs
@@ -30,6 +30,7 @@ namespace LongoMatch.Services
 		PlayerBin player;
 		Project openedProject;
 		Dictionary<GameUnit, Time> gameUnitsStarted;
+		ushort fps;
 		
 		
 		public GameUnitsManager (MainWindow mainWindow, PlayerBin player)
@@ -37,14 +38,19 @@ namespace LongoMatch.Services
 			this.mainWindow = mainWindow;
 			this.player = player;
 			gameUnitsStarted = new Dictionary<GameUnit, Time>();
+			mainWindow.GameUnitEvent += HandleMainWindowGameUnitEvent;
 		}
 		
 		public Project OpenedProject{
 			set {
 				openedProject = value;
 				gameUnitsStarted.Clear();
-				if (openedProject != null)
-					mainWindow.UpdateGameUnits(value.GameUnits);
+				
+				if (openedProject == null)
+					return;
+				
+				fps = openedProject.Description.File.Fps;
+				mainWindow.UpdateGameUnits(value.GameUnits);
 			}
 		}
 	
@@ -56,6 +62,7 @@ namespace LongoMatch.Services
 			if (gameUnitsStarted.ContainsKey(gameUnit)){
 				Log.Warning("Trying to start a game unit that was already started");
 			} else {
+				gameUnitsStarted.Add(gameUnit, new Time{MSeconds=(int)player.CurrentTime});
 			}
 		}
 		
@@ -72,12 +79,14 @@ namespace LongoMatch.Services
 			TimelineNode timeInfo;
 			Time start, stop;
 			
-			if (gameUnitsStarted.ContainsKey(gameUnit))
+			if (!gameUnitsStarted.ContainsKey(gameUnit)) {
 				Log.Warning("Tryed to stop a game unit that was not started: " + gameUnit);
+				return;
+			}
 			
 			start = gameUnitsStarted[gameUnit];
 			stop = new Time{MSeconds=(int)player.CurrentTime};
-			timeInfo = new TimelineNode {Start=start, Stop=stop};
+			timeInfo = new TimelineNode {Name=gameUnit.Name, Fps=fps, Start=start, Stop=stop};
 			
 			gameUnit.Add(timeInfo);
 			gameUnitsStarted.Remove(gameUnit);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]