Commit MetaInfo

Revisionfb6411c1855624c9a5d1e11620640bca67a0dec5 (tree)
Time2014-07-16 02:29:44
AuthorFace
CommiterFace

Log Message

Module: minor code cleanup

Change Summary

Incremental Difference

diff -r d6616fbb9a18 -r fb6411c18556 Orbitersdk/samples/AscensionUltra/Module.cpp
--- a/Orbitersdk/samples/AscensionUltra/Module.cpp Tue Jul 15 19:29:22 2014 +0200
+++ b/Orbitersdk/samples/AscensionUltra/Module.cpp Tue Jul 15 19:29:44 2014 +0200
@@ -33,15 +33,13 @@
3333 // Global parameters
3434 // ==============================================================
3535
36-struct GDIParams {
36+struct GDIParams
37+{
3738 HINSTANCE hDLL;
38- /*HFONT font[2];
39- DWORD col[4];
40- HBRUSH brush[4];
41- HPEN pen[2];*/
4239 } g_Param;
4340
44-static HELPCONTEXT g_hc = {
41+static HELPCONTEXT g_hc =
42+{
4543 "html/vessels/AscensionUltra.chm",
4644 0,
4745 "html/vessels/AscensionUltra.chm::/AscensionUltra.hhc",
@@ -59,21 +57,7 @@
5957 DLLCLBK void InitModule (HINSTANCE hModule)
6058 {
6159 srand((unsigned)time(0)); //Seed the random generator with a timestamp
62-
6360 g_Param.hDLL = hModule;
64-
65-// oapiRegisterCustomControls (hModule);
66-
67- // allocate GDI resources
68- /*g_Param.font[0] = CreateFont (-13, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
69- g_Param.font[1] = CreateFont (-10, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
70- g_Param.brush[0] = CreateSolidBrush (RGB(0,255,0)); // green
71- g_Param.brush[1] = CreateSolidBrush (RGB(255,0,0)); // red
72- g_Param.brush[2] = CreateSolidBrush (RGB(80,80,224)); // blue
73- g_Param.brush[3] = CreateSolidBrush (RGB(160,120,64)); // brown
74- g_Param.pen[0] = CreatePen (PS_SOLID, 1, RGB(224,224,224));
75- g_Param.pen[1] = CreatePen (PS_SOLID, 3, RGB(164,164,164));*/
76-
7761 }
7862
7963 void RotateMesh(MESHHANDLE mesh, float angle, VECTOR3 v, VECTOR3 ref)
@@ -401,41 +385,13 @@
401385 }
402386 }
403387
404-// --------------------------------------------------------------
405-// Module cleanup
406-// --------------------------------------------------------------
407-DLLCLBK void ExitModule (HINSTANCE hModule)
408-{
409-// oapiUnregisterCustomControls (hModule);
410-
411- /*int i;
412- // deallocate GDI resources
413- for (i = 0; i < 2; i++) DeleteObject (g_Param.font[i]);
414- for (i = 0; i < 4; i++) DeleteObject (g_Param.brush[i]);
415- for (i = 0; i < 2; i++) DeleteObject (g_Param.pen[i]);*/
416-}
388+DLLCLBK void ExitModule (HINSTANCE hModule){}
417389
418-// --------------------------------------------------------------
419-// Vessel initialisation
420-// --------------------------------------------------------------
421-DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
422-{
423- // need to init device-dependent resources here in case the screen mode has changed
424- /*g_Param.col[2] = oapiGetColour(80,80,224);
425- g_Param.col[3] = oapiGetColour(160,120,64);*/
390+DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel){return new AscensionUltra (hvessel, flightmodel);}
426391
427- return new AscensionUltra (hvessel, flightmodel);
428-}
392+DLLCLBK void ovcExit (VESSEL *vessel){if (vessel) delete (AscensionUltra*)vessel;}
429393
430-// --------------------------------------------------------------
431-// Vessel cleanup
432-// --------------------------------------------------------------
433-DLLCLBK void ovcExit (VESSEL *vessel)
434-{
435- if (vessel) delete (AscensionUltra*)vessel;
436-}
437-
438-AscensionUltra *GetDG (HWND hDlg)
394+AscensionUltra *GetBase (HWND hDlg)
439395 {
440396 // retrieve AscensionUltra interface from scenario editor
441397 OBJHANDLE hVessel;
@@ -454,10 +410,10 @@
454410 oapiOpenHelp (&g_hc);
455411 return TRUE;
456412 case IDC_OLOCK_CLOSE:
457- GetDG(hTab)->GetHangar(HANGARTYPETA, 0)->GetDoor(0)->Close();
413+ GetBase(hTab)->GetHangar(HANGARTYPETA, 0)->GetDoor(0)->Close();
458414 return TRUE;
459415 case IDC_OLOCK_OPEN:
460- GetDG(hTab)->GetHangar(HANGARTYPETA, 0)->GetDoor(0)->Open();
416+ GetBase(hTab)->GetHangar(HANGARTYPETA, 0)->GetDoor(0)->Open();
461417 return TRUE;
462418 }
463419 break;
@@ -480,11 +436,11 @@
480436 // Message procedure for editor page 3 (damage)
481437 BOOL CALLBACK EdPg3Proc (HWND hTab, UINT uMsg, WPARAM wParam, LPARAM lParam)
482438 {
483- AscensionUltra *dg;
439+ AscensionUltra *au;
484440
485441 switch (uMsg) {
486442 case WM_INITDIALOG: {
487- dg = (AscensionUltra*)oapiGetVesselInterface ((OBJHANDLE)lParam);
443+ au = (AscensionUltra*)oapiGetVesselInterface ((OBJHANDLE)lParam);
488444 } break;
489445 case WM_COMMAND:
490446 break;
@@ -498,7 +454,7 @@
498454 // Add vessel-specific pages into scenario editor
499455 DLLCLBK void secInit (HWND hEditor, OBJHANDLE hVessel)
500456 {
501- AscensionUltra *dg = (AscensionUltra*)oapiGetVesselInterface (hVessel);
457+ AscensionUltra *au = (AscensionUltra*)oapiGetVesselInterface (hVessel);
502458
503459 EditorPageSpec eps1 = {"Animations", g_Param.hDLL, IDD_EDITOR_PG1, EdPg1Proc};
504460 SendMessage (hEditor, WM_SCNEDITOR, SE_ADDPAGEBUTTON, (LPARAM)&eps1);
@@ -510,12 +466,12 @@
510466 // Message callback function for control dialog box
511467 BOOL CALLBACK Ctrl_DlgProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
512468 {
513- AscensionUltra *dg = (uMsg == WM_INITDIALOG ? (AscensionUltra*)lParam : (AscensionUltra*)oapiGetDialogContext (hWnd));
469+ AscensionUltra *au = (uMsg == WM_INITDIALOG ? (AscensionUltra*)lParam : (AscensionUltra*)oapiGetDialogContext (hWnd));
514470 // pointer to vessel instance was passed as dialog context
515471
516472 switch (uMsg) {
517473 case WM_INITDIALOG:
518- UpdateCtrlDialog (dg, hWnd);
474+ UpdateCtrlDialog (au, hWnd);
519475 return FALSE;
520476 case WM_COMMAND:
521477 switch (LOWORD(wParam)) {
@@ -523,10 +479,10 @@
523479 oapiCloseDialog (hWnd);
524480 return TRUE;
525481 case IDC_OLOCK_CLOSE:
526- dg->GetHangar(HANGARTYPETA, 0)->GetDoor(0)->Close();
482+ au->GetHangar(HANGARTYPETA, 0)->GetDoor(0)->Close();
527483 return 0;
528484 case IDC_OLOCK_OPEN:
529- dg->GetHangar(HANGARTYPETA, 0)->GetDoor(0)->Open();
485+ au->GetHangar(HANGARTYPETA, 0)->GetDoor(0)->Open();
530486 return 0;
531487 }
532488 break;
@@ -534,7 +490,7 @@
534490 return oapiDefDialogProc (hWnd, uMsg, wParam, lParam);
535491 }
536492
537-void UpdateCtrlDialog (AscensionUltra *dg, HWND hWnd)
493+void UpdateCtrlDialog (AscensionUltra *au, HWND hWnd)
538494 {
539495 static int bstatus[2] = {BST_UNCHECKED, BST_CHECKED};
540496
@@ -543,7 +499,7 @@
543499
544500 int op;
545501
546- op = dg->GetHangar(HANGARTYPETA, 0)->GetDoor(0)->GetPosition()==0.0?0:1;
502+ op = au->GetHangar(HANGARTYPETA, 0)->GetDoor(0)->GetPosition()==0.0?0:1;
547503 SendDlgItemMessage (hWnd, IDC_OLOCK_OPEN, BM_SETCHECK, bstatus[op], 0);
548504 SendDlgItemMessage (hWnd, IDC_OLOCK_CLOSE, BM_SETCHECK, bstatus[1-op], 0);
549-}
505+}
\ No newline at end of file
Show on old repository browser