/********************************************************************************************
    Function Name: Reset
    Parameters: see function definition
    Return: void

    Description:  Resets the 'GPS_Calculations' class.

    *********************************************************************************************/
    public void Reset()
    {
        strAcronym = NULL_ACRONYM;
        strSBAS = NULL_ACRONYM;
        gyGPSCalculationsInitialised = false;
        clsLocalKerbalGPSReference = null;
    }
Exemple #2
0
    // must be unique for Unity to not mash two nametag windows togehter.
    // ReSharper enable RedundantDefaultFieldInitializer
    public void Invoke(KSPSensor module, string oldValue)
    {
        attachedModule = module;
        tagValue = oldValue;
        myWindowId = GetInstanceID (); // Use the Id of this MonoBehaviour to guarantee unique window ID.

        Vector3 screenPos = GetViewportPosFor (attachedModule.part.transform.position);

        // screenPos is in coords from 0 to 1, 0 to 1, not screen pixel coords.
        // Transform it to pixel coords:
        float xPixelPoint = screenPos.x * UnityEngine.Screen.width;
        float yPixelPoint = (1 - screenPos.y) * UnityEngine.Screen.height;
        const float WINDOW_WIDTH = 200;

        // windowRect = new Rect(xPixelWindow, yPixelPoint, windowWidth, 130);
        windowRect = new Rect (xPixelPoint, yPixelPoint, WINDOW_WIDTH, 130);

        // Please don't delete these.  They're not being used, but that's because we haven't
        // finished prettying up the interface with the tag line and so the coords aren't
        // being made use of yet.  But keep this in the code so I can remember how I did the math:
        // --------------------------------------------------------------------------------------
        // bool drawOnLeft = (screenPos.x > 0.5f);
        // float xPixelWindow = (drawOnLeft ? screenPos.x - 0.3f : screenPos.x + 0.2f) * UnityEngine.Screen.width;
        // float tagLineWidth = (drawOnLeft) ? (xPixelPoint - xPixelWindow) : (xPixelWindow - xPixelPoint - windowWidth);
        // tagLineRect = new Rect(xPixelPoint, yPixelPoint, tagLineWidth, 3);
        // SafeHouse.Logger.Log("tagLineRect = " + tagLineRect );

        SetEnabled (true);

        if (HighLogic.LoadedSceneIsEditor)
            attachedModule.part.SetHighlight (false, false);
    }
    /////////////////////////////////////////////////////////////////////////////////////////////
    //
    //    Implementation - Public functions
    //
    /////////////////////////////////////////////////////////////////////////////////////////////
    /********************************************************************************************
    Function Name: Initialise
    Parameters: see function definition
    Return: void

    Description:  Initialises the 'GPS_Calculations' class.

    *********************************************************************************************/
    public void Initialise(KSPSensor clsKerbalGPSReference, string strGNSSacronym, string strSBASacronym)
    {
        if (!gyGPSCalculationsInitialised)
        {
            strAcronym = strGNSSacronym;
            strSBAS = strSBASacronym;
            gyGPSCalculationsInitialised = true;
            clsLocalKerbalGPSReference = clsKerbalGPSReference;
        }
    }