// ==============================================================
// ORBITER MODULE: DialogTemplate
// Part of the ORBITER SDK
// Copyright (C) 2003 Martin Schweiger
// All rights reserved
//
// MFDTemplate.cpp
//
// This module demonstrates how to build an Orbiter plugin which
// inserts a new MFD (multi-functional display) mode. The code
// is not very useful in itself, but it can be used as a starting
// point for your own MFD developments.
// ==============================================================
#define STRICT
#define ORBITER_MODULE
#include "windows.h"
#include "orbitersdk.h"
#include "MFDTemplate.h"
// ==============================================================
// Global variables
int g_MFDmode; // identifier for new MFD mode
// ==============================================================
// API interface
DLLCLBK void opcDLLInit (HINSTANCE hDLL)
{
static char *name = "MFD Template"; // MFD mode name
MFDMODESPEC spec;
spec.name = name;
spec.key = OAPI_KEY_T; // MFD mode selection key
spec.msgproc = MFDTemplate::MsgProc; // MFD mode callback function
// Register the new MFD mode with Orbiter
g_MFDmode = oapiRegisterMFDMode (spec);
}
DLLCLBK void opcDLLExit (HINSTANCE hDLL)
{
// Unregister the custom MFD mode when the module is unloaded
oapiUnregisterMFDMode (g_MFDmode);
}
// ==============================================================
// MFD class implementation
// Constructor
MFDTemplate::MFDTemplate (DWORD w, DWORD h, VESSEL *vessel)
: MFD (w, h, vessel)
{
// Add MFD initialisation here
}
// Destructor
MFDTemplate::~MFDTemplate ()
{
// Add MFD cleanup code here
}
// Return button labels
char *MFDTemplate::ButtonLabel (int bt)
{
// The labels for the two buttons used by our MFD mode
static char *label[2] = {"UP", "DN"};
return (bt < 2 ? label[bt] : 0);
}
// Return button menus
int MFDTemplate::ButtonMenu (const MFDBUTTONMENU **menu) const
{
// The menu descriptions for the two buttons
static const MFDBUTTONMENU mnu[2] = {
{"Move up", 0, '['},
{"Move down", 0, ']'}
};
if (menu) *menu = mnu;
return 2; // return the number of buttons used
}
// Repaint the MFD
void MFDTemplate::Update (HDC hDC)
{
Title (hDC, "MFD Template");
// Draws the MFD title
// Add MFD display routines here.
// Use the device context (hDC) for Windows GDI paint functions.
}
// MFD message parser
int MFDTemplate::MsgProc (UINT msg, UINT mfd, WPARAM wparam, LPARAM lparam)
{
switch (msg) {
case OAPI_MSG_MFD_OPENED:
// Our new MFD mode has been selected, so we create the MFD and
// return a pointer to it.
return (int)(new MFDTemplate (LOWORD(wparam), HIWORD(wparam), (VESSEL*)lparam));
}
return 0;
}