I had to take a break from Orbiter due to real life but I'm back now and working getting my Lunar Module's VC up and running.
As the title says, the topic of this thread is MFD buttons. I already have them registered and responding to mouse events, the only thing left is to display the labels.
As with much of this project I started by copy/pasting from OrbiterSDK sample but I need help with parsing and trouble-shooting.
here's the function as copied from the stock DG, at first glance it seemed pretty straight-forward. I simply commented out the "isVC" boolean as it was un-needed (no 2D panel) and matched the x/y values my button texture.
When I went to compile I got the following errors
Now 'g_Param' has already been declared as a global in my vessel's primary cpp file (I split everything associated with the cockpit into it's own file just for the sake of readability but VS finds it just fine when i click "go to def" so I don't know why it's complaining.
Here's the definition as it appears in my header
and here's the global declaration in my primary cpp file
The '.font' however was a new one to me so I went digging through the Delta Glider's source to find it.
this is what I found...
I recognize the DLLCLBK init/exit functions and thier purpose but what exactly is goining on and how do I make it do what I want?
I tried simply copy/pasting into my own API callback interface and commenting out the DG reference but that didn't work.
As always any insight would be greatly appreciated.
As the title says, the topic of this thread is MFD buttons. I already have them registered and responding to mouse events, the only thing left is to display the labels.
As with much of this project I started by copy/pasting from OrbiterSDK sample but I need help with parsing and trouble-shooting.
here's the function as copied from the stock DG, at first glance it seemed pretty straight-forward. I simply commented out the "isVC" boolean as it was un-needed (no 2D panel) and matched the x/y values my button texture.
Code:
void LEM::RedrawMFDButtons (SURFHANDLE surf, int mfd, int side) // (Copied from stock DG)
{
HDC hDC = oapiGetDC (surf);
HFONT pFont = (HFONT)SelectObject (hDC, g_Param.font[1]);
SetTextColor (hDC, RGB(196, 196, 196));
SetTextAlign (hDC, TA_CENTER);
SetBkMode (hDC, TRANSPARENT);
const char *label;
//bool isVC = (oapiCockpitMode() == COCKPIT_VIRTUAL);
//int x = (isVC ? 12:13);
//int y = (isVC ? 0:3);
int x = 16;
int y = 4;
for (int bt = 0; bt < 6; bt++)
{
if (label = oapiMFDButtonLabel(mfd, bt + side*6))
{
TextOut (hDC, x, y, label, strlen (label));
//if (isVC) x += 24;
//else y += 41;
y += 40;
}
else break;
}
SelectObject (hDC, pFont);
oapiReleaseDC (surf, hDC);
}
When I went to compile I got the following errors
Code:
1>c:\users\hlynkacg\documents\visual studio 2010\projects\lunarlanders\lemcockpit.cpp(280): error C2065: 'g_Param' : undeclared identifier
1>c:\users\hlynkacg\documents\visual studio 2010\projects\lunarlanders\lemcockpit.cpp(280): error C2228: left of '.font' must have class/struct/union
Now 'g_Param' has already been declared as a global in my vessel's primary cpp file (I split everything associated with the cockpit into it's own file just for the sake of readability but VS finds it just fine when i click "go to def" so I don't know why it's complaining.
Here's the definition as it appears in my header
Code:
// I don't know what exactly this does but it's associated with graphics in some way and apperently it is important. I copied it from the stock DG's header file
typedef struct
{
HINSTANCE hDLL;
HFONT font[2];
DWORD col[4];
HBRUSH brush[4];
HPEN pen[2];
} GDIParams;
and here's the global declaration in my primary cpp file
Code:
//==============================================================
// ORBITER MODULE: HlynkaCG's 'SPIDER' LUNAR EXCURSION MODULE
// A custom Vessel For Orbiter 2010/11
//
// SpiderLEM.cpp
// Implementation of Lunar Excursion Module vessel class
//==============================================================
#define STRICT
#define ORBITER_MODULE
#include "Orbitersdk.h"
#include "SpiderLEM.h"
#include "LEMcockpit.h"
GDIParams g_Param; // this does something
The '.font' however was a new one to me so I went digging through the Delta Glider's source to find it.
this is what I found...
Code:
// --------------------------------------------------------------
// Module initialisation
// --------------------------------------------------------------
DLLCLBK void InitModule (HINSTANCE hModule)
{
g_Param.hDLL = hModule;
oapiRegisterCustomControls (hModule);
// allocate GDI resources
g_Param.font[0] = CreateFont (-13, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
g_Param.font[1] = CreateFont (-10, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
g_Param.brush[0] = CreateSolidBrush (RGB(0,255,0)); // green
g_Param.brush[1] = CreateSolidBrush (RGB(255,0,0)); // red
g_Param.brush[2] = CreateSolidBrush (RGB(80,80,224)); // blue
g_Param.brush[3] = CreateSolidBrush (RGB(160,120,64)); // brown
g_Param.pen[0] = CreatePen (PS_SOLID, 1, RGB(224,224,224));
g_Param.pen[1] = CreatePen (PS_SOLID, 3, RGB(164,164,164));
// allocate textures
DeltaGlider::panel2dtex = oapiLoadTexture ("DG\\dg_panel.dds");
}
// --------------------------------------------------------------
// Module cleanup
// --------------------------------------------------------------
DLLCLBK void ExitModule (HINSTANCE hModule)
{
oapiUnregisterCustomControls (hModule);
int i;
// deallocate GDI resources
for (i = 0; i < 2; i++) DeleteObject (g_Param.font[i]);
for (i = 0; i < 4; i++) DeleteObject (g_Param.brush[i]);
for (i = 0; i < 2; i++) DeleteObject (g_Param.pen[i]);
// deallocate textures
oapiDestroySurface (DeltaGlider::panel2dtex);
}
I recognize the DLLCLBK init/exit functions and thier purpose but what exactly is goining on and how do I make it do what I want?
I tried simply copy/pasting into my own API callback interface and commenting out the DG reference but that didn't work.
As always any insight would be greatly appreciated.
Last edited: