Exemplo n.º 1
0
 public MSLOVRDModes(MFD mfd1, MFD mfd2, MFD mfd3, MFD mfd4)
 {
     MFD1 = mfd1;
     MFD2 = mfd2;
     MFD3 = mfd3;
     MFD4 = mfd4;
 }
Exemplo n.º 2
0
 public MSLOVRDModes()
 {
     MFD1 = new MFD();
     MFD2 = new MFD();
     MFD3 = new MFD();
     MFD4 = new MFD();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Initialize the MFD
        /// </summary>
        /// <param name="configString">A config string to assign buttons, labels</param>
        /// <param name="ip">The IP address of the SCJoyServer</param>
        /// <param name="port">The first Joystick port</param>
        /// <returns>True if successfull</returns>
        public bool InitMFD(UC_MFDflight owner, MfdInstance mfd, string configString, string ip, uint port)
        {
            m_owner = owner;

            Initialized = MFD.Init(owner, mfd, configString, ip, port);
            if (!Initialized)
            {
                return(false);
            }

            // Init Drawing stuff for this panel

            // A frame around the usable area
            MFD.GProc.Drawings.Add(MfdBase.Frame(Color.BlueViolet));
            // Create all labels with a prototype font and color
            MFD.GProc.Drawings.Add(MfdLabels.LabelList(
                                       new TextItem( )
            {
                Font            = m_owner.Font,                  //   the font to use for button labels
                TextBrush       = new SolidBrush(Color.Violet),  // the text label color
                TextBrushActive = new SolidBrush(Color.Fuchsia), // the active text label color
                FillBrush       = null,                          // new SolidBrush( ControlPaint.Dark( Color.Fuchsia , 0.7F) ) // the text label background fill (or null)
            },
                                       MFD.ButtonLabelList));
            // Change individual items..

            // Add more to draw

            return(Initialized);
        }
Exemplo n.º 4
0
 public NavMasterModes(MFD mfd1, MFD mfd2, MFD mfd3, MFD mfd4)
 {
     MFD1 = mfd1;
     MFD2 = mfd2;
     MFD3 = mfd3;
     MFD4 = mfd4;
 }
Exemplo n.º 5
0
 public NavMasterModes()
 {
     MFD1 = new MFD();
     MFD2 = new MFD();
     MFD3 = new MFD();
     MFD4 = new MFD();
 }
Exemplo n.º 6
0
        /// <summary>
        /// Initialize the MFD
        /// </summary>
        /// <param name="configString">A config string to assign buttons, labels</param>
        /// <param name="ip">The IP address of the SCJoyServer</param>
        /// <param name="port">The first Joystick port</param>
        /// <returns>True if successfull</returns>
        public bool InitMFD(UC_MFDtest owner, MfdInstance mfd, string configString, string ip, uint port)
        {
            m_owner = owner;

            Initialized = MFD.Init(owner, mfd, configString, ip, port);
            if (!Initialized)
            {
                return(false);
            }

            // Init Drawing stuff for this panel

            // A frame around the usable area
            MFD.GProc.Drawings.Add(MfdBase.Frame(Color.Green));
            // Create all labels with a prototype font and color
            MFD.GProc.Drawings.Add(MfdLabels.LabelList(
                                       new TextItem( )
            {
                Font            = m_owner.Font,
                TextBrush       = new SolidBrush(Color.LimeGreen),
                TextBrushActive = null,
                FillBrush       = null
            },
                                       MFD.ButtonLabelList));
            // Change individual items..

            // Add more to draw

            return(Initialized);
        }
Exemplo n.º 7
0
 public DGFTOVRDModes(MFD mfd1, MFD mfd2)
 {
     MFD1 = mfd1;
     MFD2 = mfd2;
 }
Exemplo n.º 8
0
 public MSLOVRDModes(MFD mfd1, MFD mfd2)
 {
     MFD1 = mfd1;
     MFD2 = mfd2;
 }
Exemplo n.º 9
0
 public NavMasterModes(MFD mfd1, MFD mfd2)
 {
     MFD1 = mfd1;
     MFD2 = mfd2;
 }
        public static void ReceiveOldMessage(List<MFD> MFDList)
        {
            #if DEBUG_MGS
            string output = string.Format("Enter ReceiveOldMessage");
            lock (_locker)
            {
                Console.WriteLine(output);
                Debug.Print(output + string.Format("\r\n"));
            }
            #endif

            // Navico NSS 2.0: Multicast 239.2.1.1, port 2050
            UdpClient client = new UdpClient();
            client.Client.ReceiveTimeout = 2000;

            IPEndPoint localEp = new IPEndPoint(IPAddress.Any, 2050);
            client.Client.Bind(localEp);

            IPAddress multicastaddress = IPAddress.Parse("239.2.1.1");
            client.JoinMulticastGroup(multicastaddress);

            DateTime timeLastNewFound = DateTime.Now;
            while (timeLastNewFound.AddSeconds(2) > DateTime.Now)
            {
                Byte[] data = null;
                try
                {
                    data = client.Receive(ref localEp);
                }
                catch (Exception ex)
                {
                    break;
                }
                if (data.Length > 0)
                {
                    string strData = Encoding.ASCII.GetString(data);
                    char[] lineEnd = { '\r', '\n' };
                    strData = strData.TrimEnd(lineEnd);
                    string[] strParams = strData.Split(',');
                    if (strParams.Count() >= 4)
                    {
                        bool foundMFD = false;
                        bool foundService = false;
                        foreach (MFD mfd in MFDList)
                        {
                            if (strParams[2] == mfd.IP)
                            {
                                foundMFD = true;
                                foreach (MFDService service in mfd.Services)
                                {
                                    if (strParams[0] == service.Service)
                                    {
                                        foundService = true;
                                    }
                                }
                                break;
                            }
                        }

                        if (foundMFD)
                        {
                            if (!foundService)
                            {
                                timeLastNewFound = DateTime.Now;
                                foreach (MFD mfd in MFDList)
                                {
                                    if (strParams[2] == mfd.IP)
                                    {
                                        lock (_locker)
                                        {
                                            MFDService[] newList = new MFDService[mfd.Services.Count() + 1];
                                            for (int service = 0; service < mfd.Services.Count(); service++)
                                            {
                                                newList[service] = mfd.Services[service];
                                            }
                                            newList[mfd.Services.Count()].Service = strParams[0];
                                            newList[mfd.Services.Count()].Port = Convert.ToUInt32(strParams[3]);
                                            mfd.Services = newList;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            timeLastNewFound = DateTime.Now;
                            MFD mfd = new MFD();
                            mfd.IP = strParams[2];
                            mfd.Services = new MFDService[1];
                            mfd.Services[0] = new MFDService(strParams[0], 0, Convert.ToUInt32(strParams[3]));
            #if DEBUG_MGS
                            output = string.Format("Service: {0}\tVersion: {1}\tIP: {2}\tPort: {3}", strParams[0], strParams[1], strParams[2], strParams[3]);
            #endif
                            lock (_locker)
                            {
                                MFDList.Add(mfd);

            #if DEBUG_MGS
                                Console.WriteLine(output);
                                Debug.Print(output + string.Format("\r\n"));
            #endif
                            }
                        }
                    }
                }
            }

            #if DEBUG_MGS
            output = string.Format("Exit ReceiveOldMessage");
            lock (_locker)
            {
                Console.WriteLine(output);
                Debug.Print(output + string.Format("\r\n"));
            }
            #endif
        }
Exemplo n.º 11
0
    private IEnumerator main()
    {
        while (VTMapManager.fetch == null || !VTMapManager.fetch.scenarioReady || FlightSceneManager.instance.switchingScene)
        {
            yield return(null);
        }
        // Main code here
        buttonMade = false;
        Debug.Log("AAAAAAAA");
        wm             = VTOLAPI.GetPlayersVehicleGameObject().GetComponent <WeaponManager>();
        inf            = VTOLAPI.GetPlayersVehicleGameObject().AddComponent <infAmmo>();
        inf.enabled    = false;
        paired         = VTOLAPI.GetPlayersVehicleGameObject().AddComponent <PairedGuns>();
        paired.enabled = false;
        if (VTOLAPI.GetPlayersVehicleEnum() != VTOLVehicles.F45A)
        {
            WeaponManagerUI wmUI = wm.ui;
            Debug.Log("wmUI");
            mfd = wmUI.mfdPage;
            if (mfd == null)
            {
                Debug.LogError("OOPIES.");
            }
            mfd.OnActivatePage.AddListener(new UnityAction(() =>
            {
                lastMFD = mfd.mfd;
                Debug.Log("=");
                MFDPage.MFDButtonInfo[] allButtons = mfd.buttons;
                MFDPage.MFDButtonInfo newButton    = new MFDPage.MFDButtonInfo();
                newButton.button  = MFD.MFDButtons.T4;
                newButton.toolTip = "Toggle infinite ammo";
                newButton.label   = "infAmmo";
                newButton.OnPress.AddListener(new UnityAction(() =>
                {
                    AEAT.inf.enabled = !AEAT.inf.enabled;
                    mfd.mfd.buttons[13].GetComponentInChildren <Text>().color = AEAT.inf.enabled ? Color.green : Color.red;
                }));
                if (mfd.mfd == null)
                {
                    Debug.LogError("FOUND YA!");
                }
                MFDPage.MFDButtonInfo newButton2 = new MFDPage.MFDButtonInfo();
                newButton2.button  = MFD.MFDButtons.T2;
                newButton2.toolTip = "Pair all guns";
                newButton2.label   = "pairGuns";
                newButton2.OnPress.AddListener(new UnityAction(() =>
                {
                    AEAT.paired.enabled = !AEAT.paired.enabled;
                    Debug.Log("Button pressed.");
                    mfd.mfd.buttons[11].GetComponentInChildren <Text>().color = AEAT.paired.enabled && wm.equippedGun ? Color.green : Color.red;
                }));
                mfd.SetPageButton(newButton);
                mfd.SetPageButton(newButton2);
                mfd.mfd.buttons[13].GetComponentInChildren <Text>().color = AEAT.inf.enabled ? Color.green : Color.red;
                mfd.mfd.buttons[11].GetComponentInChildren <Text>().color = AEAT.paired.enabled ? Color.green : Color.red;
            }));
            mfd.OnDeactivatePage.AddListener(new UnityAction(() =>
            {
                if (lastMFD != null)
                {
                    lastMFD.buttons[13].GetComponentInChildren <Text>().color = Color.white;
                    lastMFD.buttons[11].GetComponentInChildren <Text>().color = Color.white;
                    lastMFD = null;
                }
            }));
        }
        else
        {
            AEAT.MFDP = wm.gameObject.GetComponentInChildren <MFDPortalManager>();
            MFDPStoresManagement MFDP = (MFDPStoresManagement)AEAT.MFDP.gameObject.GetComponentInChildren <MFDPortalManager>().pages[5];
            Debug.Log("got MFPD");
            GameObject toCopy = null;
            foreach (var resource in Resources.FindObjectsOfTypeAll <VRInteractable>())
            {
                if (resource.interactableName == "Weapon Bay Door Overrides")
                {
                    toCopy = resource.gameObject;
                    break;
                }
            }
            if (toCopy == null)
            {
                Debug.LogError("To copy is null");
            }
            GameObject    emptyButton = Instantiate(toCopy, MFDP.displayObj.gameObject.transform);
            RectTransform rt          = emptyButton.GetComponent <RectTransform>();
            AEAT.text1       = emptyButton.gameObject.GetComponentInChildren <Text>();
            rt.localPosition = new Vector3(rt.localPosition.x - 50, rt.localPosition.y, rt.localPosition.z);
            rt.localScale    = new Vector3(rt.localScale.x * 0.85f, rt.localScale.y * 0.85f, rt.localScale.z * 0.85f);
            rt.GetComponentInChildren <Image>().color = Color.black;
            Debug.Log("instantiate");
            VRInteractable interactable = emptyButton.GetComponentInChildren <VRInteractable>();
            Debug.Log("vr interactable");
            Text text = emptyButton.GetComponentInChildren <Text>();
            Debug.Log("text");
            text.text = "infAmmo";
            Debug.Log("infAmmo");
            interactable.OnInteract = new UnityEvent();
            Debug.Log("new UnityEvent()");
            interactable.interactableName = "Toggle infinite ammo";
            Debug.Log("toggle infinite ammo");
            interactable.OnInteract.AddListener(new UnityAction(() =>
            {
                AEAT.inf.enabled = !AEAT.inf.enabled;
                AEAT.MFDP.PlayInputSound();
                AEAT.text1.color = AEAT.inf.enabled ? Color.green : Color.red;
            }));
            Debug.Log("listener");
            AEAT.text1.color = AEAT.inf.enabled ? Color.green : Color.red;

            GameObject    emptyButton2 = Instantiate(toCopy, MFDP.displayObj.gameObject.transform);
            RectTransform rt2          = emptyButton2.GetComponent <RectTransform>();
            rt2.localPosition = new Vector3(rt2.localPosition.x - 85, rt.localPosition.y, rt.localPosition.z);
            rt2.localScale    = new Vector3(rt2.localScale.x * 0.85f, rt2.localScale.y * 0.85f, rt2.localScale.z * 0.85f);
            rt2.GetComponentInChildren <Image>().color = Color.black;
            Debug.Log("instantiate");
            VRInteractable interactable2 = emptyButton2.GetComponentInChildren <VRInteractable>();
            Debug.Log("vr interactable");
            text2 = emptyButton2.GetComponentInChildren <Text>();
            Debug.Log("text");
            text2.text = "pairGuns";
            Debug.Log("pairGuns");
            interactable2.OnInteract = new UnityEvent();
            Debug.Log("new UnityEvent()");
            interactable2.interactableName = "Pair All Guns";
            Debug.Log("Pair all guns");
            interactable2.OnInteract.AddListener(new UnityAction(() =>
            {
                AEAT.paired.enabled = !AEAT.paired.enabled;
                AEAT.MFDP.PlayInputSound();
                AEAT.text2.color = AEAT.paired.enabled ? Color.green : Color.red;
            }));
            AEAT.text2.color = AEAT.paired.enabled ? Color.green : Color.red;
        }
    }
        public static void ReceiveOldMessage(List<MFD> MFDList)
        {
#if DEBUG_MGS
            string output = string.Format("Enter ReceiveOldMessage");
            lock (_locker)
            {
                Console.WriteLine(output);
                Debug.Print(output + string.Format("\r\n"));
            }
#endif

            // Navico NSS 2.0: Multicast 239.2.1.1, port 2050
            UdpClient client = new UdpClient();
            client.Client.ReceiveTimeout = 2000;

            IPEndPoint localEp = new IPEndPoint(IPAddress.Any, 2050);
            client.Client.Bind(localEp);

            IPAddress multicastaddress = IPAddress.Parse("239.2.1.1");
            client.JoinMulticastGroup(multicastaddress);

            DateTime timeLastNewFound = DateTime.Now;
            while (timeLastNewFound.AddSeconds(2) > DateTime.Now)
            {
                Byte[] data = null;
                try
                {
                    data = client.Receive(ref localEp);
                }
                catch (Exception ex)
                {
                    break;
                }
                if (data.Length > 0)
                {
                    string strData = Encoding.ASCII.GetString(data);
                    char[] lineEnd = { '\r', '\n' };
                    strData = strData.TrimEnd(lineEnd);
                    string[] strParams = strData.Split(',');
                    if (strParams.Count() >= 4)
                    {
                        bool foundMFD = false;
                        bool foundService = false;
                        foreach (MFD mfd in MFDList)
                        {
                            if (strParams[2] == mfd.IP)
                            {
                                foundMFD = true;
                                foreach (MFDService service in mfd.Services)
                                {
                                    if (strParams[0] == service.Service)
                                    {
                                        foundService = true;
                                    }
                                }
                                break;
                            }
                        }

                        if (foundMFD)
                        {
                            if (!foundService)
                            {
                                timeLastNewFound = DateTime.Now;
                                foreach (MFD mfd in MFDList)
                                {
                                    if (strParams[2] == mfd.IP)
                                    {
                                        lock (_locker)
                                        {
                                            MFDService[] newList = new MFDService[mfd.Services.Count() + 1];
                                            for (int service = 0; service < mfd.Services.Count(); service++)
                                            {
                                                newList[service] = mfd.Services[service];
                                            }
                                            newList[mfd.Services.Count()].Service = strParams[0];
                                            newList[mfd.Services.Count()].Port = Convert.ToUInt32(strParams[3]);
                                            mfd.Services = newList;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            timeLastNewFound = DateTime.Now;
                            MFD mfd = new MFD();
                            mfd.IP = strParams[2];
                            mfd.Services = new MFDService[1];
                            mfd.Services[0] = new MFDService(strParams[0], 0, Convert.ToUInt32(strParams[3]));
#if DEBUG_MGS
                            output = string.Format("Service: {0}\tVersion: {1}\tIP: {2}\tPort: {3}", strParams[0], strParams[1], strParams[2], strParams[3]);
#endif
                            lock (_locker)
                            {
                                MFDList.Add(mfd);

#if DEBUG_MGS
                                Console.WriteLine(output);
                                Debug.Print(output + string.Format("\r\n"));
#endif
                            }
                        }
                    }
                }
            }

#if DEBUG_MGS
            output = string.Format("Exit ReceiveOldMessage");
            lock (_locker)
            {
                Console.WriteLine(output);
                Debug.Print(output + string.Format("\r\n"));
            }
#endif
        }
        public static void ReceiveNewMessage(List<MFD> MFDList)
        {
#if DEBUG_MGS
            string output = string.Format("Enter ReceiveNewMessage");
            lock (_locker)
            {
                Console.WriteLine(output);
                Debug.Print(output + string.Format("\r\n"));
            }
#endif

            // Navico NSS 2.5: Multicast 239.2.1.1, port 2052
            UdpClient client = new UdpClient();
            client.Client.ReceiveTimeout = 2000;

            IPEndPoint localEp = new IPEndPoint(IPAddress.Any, 2052);
            client.Client.Bind(localEp);

            IPAddress multicastaddress = IPAddress.Parse("239.2.1.1");
            client.JoinMulticastGroup(multicastaddress);

            DateTime timeLastNewFound = DateTime.Now;
            while (timeLastNewFound.AddSeconds(2) > DateTime.Now)
            {
                Byte[] data = null;
                try
                {
                    data = client.Receive(ref localEp);
                }
                catch (Exception ex)
                {
                    break;
                }
                if (data.Length > 0)
                {
                    string strData = Encoding.ASCII.GetString(data);
                    MFD deserializedMFD = JsonConvert.DeserializeObject<MFD>(strData);

                    bool found = false;
                    foreach (MFD mfd in MFDList)
                    {
                        if (deserializedMFD.IP == mfd.IP)
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        timeLastNewFound = DateTime.Now;
#if DEBUG_MGS
                        output = string.Format("MFD: {0}\tModel: {1}\tIP: {2}", deserializedMFD.Name, deserializedMFD.Model, deserializedMFD.IP);
#endif
                        lock (_locker)
                        {
                            MFDList.Add(deserializedMFD);

#if DEBUG_MGS
                            Console.WriteLine(output);
                            Debug.Print(output);
                            for (uint service = 0; service < deserializedMFD.Services.Count(); service++)
                            {
                                output = string.Format("\tService {0}: {1}\tVersion: {2}\tPort: {3}", service, deserializedMFD.Services[service].Service, deserializedMFD.Services[service].Version, deserializedMFD.Services[service].Port);
                                Console.WriteLine(output);
                                Debug.Print(output);
                            }
#endif
                        }
                    }
                }
            }

#if DEBUG_MGS
            output = string.Format("Exit ReceiveNewMessage");
            lock (_locker)
            {
                Console.WriteLine(output);
                Debug.Print(output + string.Format("\r\n"));
            }
#endif
        }