The Cockpit Manager Class

The cockpit manager class is used 2 times from within the OTWDriver class global Instance. One is used for the 2D cockpit the other for the 3D cockpit.
 


#ifdef USE_SH_POOLS
        public:
                // Overload new/delete to use a SmartHeap pool
                void *operator new(size_t size) { return MemAllocPtr(gCockMemPool,size,FALSE);  };
                void operator delete(void *mem) { if (mem) MemFreePtr(mem); };
#endif
private:

        //====================================================//
        // Temporary pointers, used mainly during initialization
        // and cleanup
        //====================================================//

        int                             mLoadBufferHeight;
        int                             mLoadBufferWidth;
        int                             mSurfaceTally;
        int                             mPanelTally;
        int                             mObjectTally;
        int                             mCursorTally;
        int                             mButtonTally;
        int                             mButtonViewTally;

        int                             mNumSurfaces;
        int                             mNumPanels;
        int                             mNumObjects;
        int                             mNumCursors;
        int                             mNumButtons;
        int                             mNumButtonViews;
        int            mHudFont;
        int            mMFDFont;
        int            mDEDFont;
        int            mGeneralFont;
        int            mPopUpFont;
        int            mKneeFont;
        int            mSABoxFont;
        int            mLabelFont;

        CPSurface               **mpSurfaces;
        CPPanel                 **mpPanels;
        CPObject                        **mpObjects;
        CPCursor                        **mpCursors;
        CPButtonObject  **mpButtonObjects;
        CPButtonView    **mpButtonViews;
 

        //====================================================//
        // Internal Pointers, Used Mainly for Runtime
        //====================================================//

        CPPanel                 *mpActivePanel;
        CPPanel                 *mpNextActivePanel;

        //====================================================//
        // Lighting Stuff
        //====================================================//

        float                           lightLevel;
        BOOL                            inNVGmode;

        //====================================================//
        // Control Variables
        //====================================================//

        BOOL                            mIsInitialized;
        BOOL                            mIsNextInitialized;
        RECT                            mMouseBounds;
        int                             mCycleBit;

        //====================================================//
        // Pointer to buffer for Texture Loading
        //====================================================//

        GLubyte                 *mpLoadBuffer;

        //====================================================//
        // Initialization Member Functions
        //====================================================//

        void CreateText(int, FILE*);
        void CreateChevron(int, FILE*);
        void CreateLiftLine(int, FILE*);
        void CreateSurface(int, FILE*);
        void CreatePanel(int, FILE*);
        void CreateSwitch(int, FILE*);
        void CreateLight(int, FILE*);
        void CreateButton(int, FILE*);
        void CreateButtonView(int, FILE*);
        void CreateIndicator(int, FILE*);
        void CreateDial(int, FILE*);
        void CreateMulti(int, FILE*);
        void CreateCursor(int, FILE*);
        void CreateDed(int, FILE*);
        void CreateAdi(int, FILE*);
        void CreateMachAsi(int, FILE*);
        void CreateHsiView(int, FILE*);
        void CreateDigits(int, FILE*);
        void CreateSound(int, FILE*);
        void CreateKneeView(int, FILE*);
        void LoadBuffer(FILE*);
        void SetupControlTemplate(char*, int, int);
        void ParseManagerInfo(FILE*);
        void ResolveReferences(void);
        static void     TimeUpdateCallback( void *self );

public:
        //====================================================//
        // Dimensions specific to the Cockpit
        //====================================================//

        int                             mTemplateWidth;
        int                             mTemplateHeight;
        int                             mMouseBorder;
        int                             mScale; // for stretched cockpits

        //====================================================//
        // Miscellaneous State Information
        //====================================================//
        CPMisc                      mMiscStates;
        CPSoundList               *mpSoundList;
        BOOL                           mViewChanging;
        F4CSECTIONHANDLE*  mpCockpitCritSec;

        //====================================================//
        // Pointer to Device Viewport Boundaries
        //====================================================//

        ViewportBounds  *mpViewBounds[BOUNDS_TOTAL];
 

        //====================================================//
        // Pointers to special avionics devices
        //====================================================//

        ICPClass                        *mpIcp;
        CPHsi                           *mpHsi;
        DrawableBSP             *mpGeometry;            // Pointer to wings and reflections
        KneeBoard               *mpKneeBoard;

        float                           ADIGpDevReading;
        float                           ADIGsDevReading;
        BOOL                            mHiddenFlag;

        //====================================================//
        // Pointers to the Outside World
        //====================================================//

        ImageBuffer             *mpOTWImage;
        SimBaseClass           *mpOwnship;

        //====================================================//
        // Public Constructors and Destructions
        //====================================================//

        ~CockpitManager();

#if DO_HIRESCOCK_HACK
        CockpitManager(ImageBuffer*, char*, BOOL, int, BOOL);
#else
        CockpitManager(ImageBuffer*, char*, BOOL, int);
#endif

        //====================================================//
        // Public Runtime Functions
        //====================================================//

        void                    Exec(void);                                             // Called by main sim thread
        void                    DisplayBlit(void);                              // Called by display thread
        void                    DisplayDraw(void);                              // Called by display thread
        void                    GeometryDraw(void);                             // Called by display thread for drawing wings and reflections
        int                     Dispatch(int, int, int);                // Called by input thread
        void                    Dispatch(int, int);
        int                     POVDispatch(int, int, int);

        //====================================================//
        // Public Auxillary Functions
        //====================================================//

        CPButtonObject* GetButtonPointer(int);
        void            BoundMouseCursor(int*, int*);
        void            SetActivePanel(int);
        void            SetDefaultPanel(int defaultPanel) {SetActivePanel(defaultPanel);}
        void            SetOwnship(SimBaseClass*);
        BOOL            ShowHud();
        BOOL           ShowMfd();
        BOOL            ShowRwr();
        CPPanel*        GetActivePanel()        {return mpActivePanel;}
        int             GetCockpitWidth() {return DisplayOptions.DispWidth;};
        int             GetCockpitHeight(){return DisplayOptions.DispHeight;};
        BOOL            GetViewportBounds(ViewportBounds*, int);
        float           GetCockpitMaskTop(void);
        void            SetNextView(void);
        float           GetPan(void);
        float           GetTilt(void);
        void            SetTOD(float);
        void            ImageCopy(GLubyte*, GLubyte*, int, RECT*);
   void     LoadCockpitDefaults (void);
   void     SaveCockpitDefaults (void);
        int      HudFont(void);
        int      MFDFont(void);
        int      DEDFont(void);
        int      GeneralFont(void) { return mGeneralFont;};
        int      PopUpFont(void) { return mPopUpFont;};
        int      KneeFont(void) { return mKneeFont;};
        int      SABoxFont(void) { return mSABoxFont;};
        int      LabelFont(void) { return mLabelFont;};