コード例 #1
0
ファイル: Program.cs プロジェクト: CloseUpDK/iRTVO
        static void Main(string[] args)
        {
            if (args.Length < 1)
                return;

            Bookmarks myBookmarks = new Bookmarks(); ;
            Bookmark thisEvent = null;
            int currentIndex = 0;
            int CurrentFrame = 0;
            bool run = true;
            using (StreamReader sw = new StreamReader(args[0], Encoding.UTF8))
            {
                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(myBookmarks.GetType());
                myBookmarks = x.Deserialize(sw) as Bookmarks;
            }

            Console.WriteLine("Waiting for iRacing to come up ....");
            sdk = new iRacingSDK();
            while (!Console.KeyAvailable && run)
            {
                //Check if the SDK is connected
                if (sdk.IsConnected())
                {
                    while (sdk.GetData("SessionNum") == null)
                    {
                        Console.WriteLine("Waiting for Session...");
                        Thread.Sleep(200); // Allow other windows to initialize more faster
                        
                    }
                    
                    thisEvent = myBookmarks.List[currentIndex];

                    switch (thisEvent.BookmarkType)
                    {
                        case BookmarkType.Start:
                            ReplaySeek( thisEvent );
                            currentIndex++;
                            break;
                        case BookmarkType.Play:                            
                            CurrentFrame = (Int32)sdk.GetData("ReplayFrameNum");
                            if (CurrentFrame < thisEvent.ReplayPos)
                                continue;
                            sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.CamSwitchNum, thisEvent.DriverIdx, thisEvent.CamIdx);
                            SetPlaySpeed(thisEvent.PlaySpeed);
                            currentIndex++;
                            break;
                        case BookmarkType.Stop:
                            CurrentFrame = (Int32)sdk.GetData("ReplayFrameNum");
                            if (CurrentFrame < thisEvent.ReplayPos)
                                continue;
                            sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, 0, 0);
                            Console.WriteLine("End");
                            run = false;
                            break;
                        default:
                            run = false;
                            break;
                    }
                            
                    
                }
                else
                {                    
                    if ( sdk.Startup() )
                    {
                        Console.WriteLine("iRacing up and running.");
                    }
                    else
                        Thread.Sleep(2000);
                }
            }
            sdk.Shutdown();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                return;
            }

            Bookmarks myBookmarks  = new Bookmarks();;
            Bookmark  thisEvent    = null;
            int       currentIndex = 0;
            int       CurrentFrame = 0;
            bool      run          = true;

            using (StreamReader sw = new StreamReader(args[0], Encoding.UTF8))
            {
                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(myBookmarks.GetType());
                myBookmarks = x.Deserialize(sw) as Bookmarks;
            }

            Console.WriteLine("Waiting for iRacing to come up ....");
            sdk = new iRacingSDK();
            while (!Console.KeyAvailable && run)
            {
                //Check if the SDK is connected
                if (sdk.IsConnected())
                {
                    while (sdk.GetData("SessionNum") == null)
                    {
                        Console.WriteLine("Waiting for Session...");
                        Thread.Sleep(200); // Allow other windows to initialize more faster
                    }

                    thisEvent = myBookmarks.List[currentIndex];

                    switch (thisEvent.BookmarkType)
                    {
                    case BookmarkType.Start:
                        ReplaySeek(thisEvent);
                        currentIndex++;
                        break;

                    case BookmarkType.Play:
                        CurrentFrame = (Int32)sdk.GetData("ReplayFrameNum");
                        if (CurrentFrame < thisEvent.ReplayPos)
                        {
                            continue;
                        }
                        sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.CamSwitchNum, thisEvent.DriverIdx, thisEvent.CamIdx);
                        SetPlaySpeed(thisEvent.PlaySpeed);
                        currentIndex++;
                        break;

                    case BookmarkType.Stop:
                        CurrentFrame = (Int32)sdk.GetData("ReplayFrameNum");
                        if (CurrentFrame < thisEvent.ReplayPos)
                        {
                            continue;
                        }
                        sdk.BroadcastMessage(iRSDKSharp.BroadcastMessageTypes.ReplaySetPlaySpeed, 0, 0);
                        Console.WriteLine("End");
                        run = false;
                        break;

                    default:
                        run = false;
                        break;
                    }
                }
                else
                {
                    if (sdk.Startup())
                    {
                        Console.WriteLine("iRacing up and running.");
                    }
                    else
                    {
                        Thread.Sleep(2000);
                    }
                }
            }
            sdk.Shutdown();
        }