2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
6 ////////////////////////////////////////////////////////////
7 // Deep Cover METAGAME MENUS
54 // Some day, I expect this will
55 // deal with levers and other festoonery
58 class cMenuBase
: public cDarkPanel
, public cUiAnim
61 cMenuBase(const sDarkPanelDesc
* desc
)
62 : cDarkPanel(desc
), cUiAnim(desc
->panel_name
,INTERFACE_PATH
)
81 void OnLoopMsg(eLoopMessage msg
, tLoopMessageData data
)
83 cUiAnim::OnLoopMsg(msg
,data
);
84 cDarkPanel::OnLoopMsg(msg
,data
);
88 //------------------------------------------------------------
92 // Avoid name conflicts
94 typedef cDPCMainMenu cMainMenu
;
96 EXTERN
void SwitchToDPCNewGameMode(BOOL push
);
99 class cDPCMainMenu
: public cMenuBase
101 static sDarkPanelDesc gDesc
;
104 cMainMenu() : cMenuBase(&gDesc
)
108 cMainMenu(const sDarkPanelDesc
* pdesc
) : cMenuBase(pdesc
)
128 void OnButtonList(ushort action
, int button
)
130 if (!(action
& BUTTONGADG_LCLICK
))
133 //SchemaPlay((Label *)"menubutt",NULL);
138 SwitchToDPCNewGameMode(TRUE
);
142 SwitchToDPCLoadGameMode(TRUE
);
146 SwitchToDPCOptionsMode(TRUE
);
150 MoviePanel("credits.avi");
154 MoviePanel("cs1.avi");
159 AutoAppIPtr_(Application
,pApp
);
171 void OnEscapeKey() // trap escape
177 // Main Menu descriptor
180 static const char* main_button_names
[] =
190 sDarkPanelDesc
cMainMenu::gDesc
=
193 cMainMenu::kNumRects
,
194 cMainMenu::kNumRects
,
195 cMainMenu::kNumRects
,
202 //------------------------------------------------------------
206 class cDPCNetMainMenu
: public cDPCMainMenu
208 static sDarkPanelDesc gDesc
;
209 typedef cDPCMainMenu cParent
;
212 cDPCNetMainMenu() : cParent(&gDesc
)
232 void OnButtonList(ushort action
, int button
)
234 if (!(action
& BUTTONGADG_LCLICK
))
240 SwitchToDPCMultiplayUIMode(TRUE
);
244 cParent::OnButtonList(action
,button
);
250 void OnLoopMsg(eLoopMessage msg
, tLoopMessageData data
)
252 cParent::OnLoopMsg(msg
,data
);
258 // Disconnect any net session we may be in
259 AutoAppIPtr(NetManager
);
260 pNetManager
->Leave();
261 // If we had network synch disabled, make sure it's normal
274 // Main Menu descriptor
277 static const char* netmain_button_names
[] =
288 sDarkPanelDesc
cDPCNetMainMenu::gDesc
=
291 cDPCNetMainMenu::kNumRects
,
292 cDPCNetMainMenu::kNumRects
,
293 cDPCNetMainMenu::kNumRects
,
294 netmain_button_names
,
303 static cMainMenu
* gpMainMenu
= NULL
;
305 void SwitchToDPCMainMenuMode(BOOL push
)
309 cAutoIPtr
<IPanelMode
> panel
= gpMainMenu
->GetPanelMode();
310 panel
->Switch((push
) ? kLoopModePush
: kLoopModeSwitch
);
315 const sLoopInstantiator
* DescribeDPCMainMenuMode(void)
319 cAutoIPtr
<IPanelMode
> panel
= gpMainMenu
->GetPanelMode();
320 return panel
->Instantiator();
325 //------------------------------------------------------------
329 // Avoid name conflicts
331 typedef cDPCSimMenu cSimMenu
;
333 class cDPCSimMenu
: public cMenuBase
335 static sDarkPanelDesc gDesc
;
338 cSimMenu() : cMenuBase(&gDesc
)
355 void OnButtonList(ushort action
, int button
)
357 if (!(action
& BUTTONGADG_LCLICK
))
360 //SchemaPlay((Label *)"menubutt",NULL);
362 AutoAppIPtr(NetManager
);
368 cAutoIPtr
<IPanelMode
> mode
= GetPanelMode();
375 SwitchToDPCOptionsMode(TRUE
);
379 if (pNetManager
->IsNetworkGame())
382 DPCGetLevelName(levelname
,sizeof(levelname
));
383 // okay this is hack-a-riffic
384 if ((stricmp(levelname
,"station") == 0) || (stricmp(levelname
,"earth") == 0))
387 SwitchToDPCSaveGameMode(TRUE
);
391 SwitchToDPCLoadGameMode(TRUE
);
398 // Unwind to the main menu
399 cAutoIPtr
<IPanelMode
> panel
= gpMainMenu
->GetPanelMode();
400 panel
->Switch(kLoopModeUnwindTo
);
408 Warning(("%s button is unimplemented\n",gDesc
.string_names
[button
]));
416 // Sim Menu descriptor
419 static const char* sim_button_names
[] =
428 sDarkPanelDesc
cSimMenu::gDesc
=
438 static cSimMenu
* gpSimMenu
= NULL
;
440 void SwitchToDPCSimMenuMode(BOOL push
)
444 cAutoIPtr
<IPanelMode
> panel
= gpSimMenu
->GetPanelMode();
445 panel
->Switch((push
) ? kLoopModePush
: kLoopModeSwitch
);
450 const sLoopInstantiator
* DescribeDPCSimMenuMode(void)
454 cAutoIPtr
<IPanelMode
> panel
= gpSimMenu
->GetPanelMode();
455 return panel
->Instantiator();
461 //------------------------------------------------------------
467 #define DIFF2BUTT(x) (((x) < MIN_DIFF) ? MIN_DIFF - 1 : (x) - 1)
468 #define BUTT2DIFF(x) ((x) + 1)
470 class cDPCNewGame
: public cDarkPanel
472 static sDarkPanelDesc gDesc
;
478 memset(&mDiffButtons
,0,sizeof(mDiffButtons
));
488 kDifficulty
= kNumButts
,
496 kNumDiffs
= kNumRects
- kDiff0
,
502 LGadButtonList mDiffButtons
;
503 DrawElement mDiffElems
[kNumDiffs
];
504 cStr mDiffStrs
[kNumDiffs
];
506 static bool DiffCB (ushort action
, int button
, void *data
, LGadBox
*)
508 g_diff
= BUTT2DIFF(button
);
514 cDarkPanel::InitUI();
516 // default to current style colors
517 AssertMsg(GetCurrentStyle(),"No current style for diff defaults");
518 memset(&mDiffStyle
,0,sizeof(mDiffStyle
));
519 memcpy(mDiffStyle
.colors
,GetCurrentStyle()->colors
,sizeof(mDiffStyle
.colors
));
520 uiGameLoadStyle("diff_",&mDiffStyle
,mResPath
);
522 // set up drawlelems for diff
523 for (int i
= 0; i
< kNumDiffs
; i
++)
525 DrawElement
& elem
= mDiffElems
[i
];
526 memset(&elem
,0,sizeof(elem
));
529 sprintf(buf
,"diff_%d",i
);
530 mDiffStrs
[i
] = FetchUIString(panel_name
,buf
,mResPath
);
531 elem
.draw_type
= DRAWTYPE_TEXT
;
532 elem
.draw_data
= (void*)(const char*)mDiffStrs
[i
];
533 elem
.draw_flags
= INTERNAL(DRAWFLAG_INT_TRANSP
);
536 LGadButtonListDesc desc
=
539 &mRects
[(int)kDiff0
],
543 BUTTONLIST_RADIO_FLAG
,
546 LGadCreateButtonListDesc(&mDiffButtons
,LGadCurrentRoot(),&desc
);
548 //set the current difficulty setting
549 if (g_diff
< MIN_DIFF
) g_diff
= MIN_DIFF
;
550 LGadRadioButtonSelect (&mDiffButtons
, DIFF2BUTT(g_diff
));
551 int flags
= LGadBoxFlags(&mDiffButtons
);
552 LGadBoxSetFlags(&mDiffButtons
, flags
| BOXFLAG_CLEAR
);
553 LGadBoxSetStyle(&mDiffButtons
,&mDiffStyle
);
558 g_diff
= BUTT2DIFF(LGadRadioButtonSelection(&mDiffButtons
));
559 LGadDestroyButtonList(&mDiffButtons
);
560 memset(&mDiffElems
,0,sizeof(mDiffElems
));
561 for (int i
= 0; i
< kNumDiffs
; i
++)
564 uiGameUnloadStyle(&mDiffStyle
);
565 cDarkPanel::TermUI();
571 // Draw the difficulty string. This is a lot of code to draw a lousy string.
573 cStr str
= FetchUIString(panel_name
,"difficulty",mResPath
); // copy the string
574 char* s
= (char*)(const char*)str
; // get a mutable pointer
576 Rect
& r
= mRects
[(int)kDifficulty
];
579 GUIsetup(&c
,&r
,GUIcomposeFlags(ComposeFlagClear
|ComposeFlagRead
),GUI_CANV_ANY
);
581 guiStyleSetupFont(&mDiffStyle
,StyleFontTitle
);
582 gr_set_fcolor(guiStyleGetColor(&mDiffStyle
,StyleColorText
));
584 gr_font_string_wrap(gr_get_font(),s
,RectWidth(&r
));
587 gr_string_size(s
,&w
,&h
);
589 gr_string(s
,(RectWidth(&r
) - w
)/2,(RectHeight(&r
) - h
)/2);
590 // gr_string(s,gr_char_width('X'),(RectHeight(&r) - h)/2);
592 guiStyleCleanupFont(&mDiffStyle
,StyleFontTitle
) ;
597 // Make sure the buttonlist gets drawn
599 region_expose(LGadBoxRegion(&mDiffButtons
),LGadBoxRect(&mDiffButtons
));
603 // Actually do the work of starting a game
608 // Push the init game mode, and the initial cutscene
609 // mode to the mode stack. That way the cutscene happens first.
610 SwitchToDPCInitGame(FALSE
);
611 MoviePanel("cs1.avi");
617 void OnButtonList(ushort action
, int button
)
619 if (!(action
& BUTTONGADG_LCLICK
))
622 //SchemaPlay((Label *)"menubutt",NULL);
633 SwitchToDPCOptionsMode(TRUE
);
638 cAutoIPtr
<IPanelMode
> mode
= GetPanelMode();
647 void OnLoopMsg(eLoopMessage msg
, tLoopMessageData data
)
654 case kMsgNormalFrame
:
655 if (mGo
) StartGame();
659 cDarkPanel::OnLoopMsg(msg
,data
);
666 // NewGame Menu descriptor
669 static const char* newgame_button_names
[] =
676 sDarkPanelDesc
cDPCNewGame::gDesc
=
679 cDPCNewGame::kNumButts
,
680 cDPCNewGame::kNumRects
,
681 cDPCNewGame::kNumButts
,
682 newgame_button_names
,
689 static cDPCNewGame
* gpNewGame
= NULL
;
691 void SwitchToDPCNewGameMode(BOOL push
)
695 cAutoIPtr
<IPanelMode
> panel
= gpNewGame
->GetPanelMode();
696 panel
->Switch((push
) ? kLoopModePush
: kLoopModeSwitch
);
701 const sLoopInstantiator
* DescribeDPCNewGameMode(void)
705 cAutoIPtr
<IPanelMode
> panel
= gpNewGame
->GetPanelMode();
706 return panel
->Instantiator();
711 //------------------------------------------------------------------
716 void init_commands();
721 if (config_is_defined("netplay_ui"))
722 gpMainMenu
= new cDPCNetMainMenu
;
724 gpMainMenu
= new cMainMenu
;
725 gpSimMenu
= new cSimMenu
;
726 gpNewGame
= new cDPCNewGame
;
730 // default difficulty
731 g_diff
= MIN_DIFF
+ 1;
733 // What the hell. Initialize the loading screens too
735 DPCMultiplayUIInit();
745 DPCMultiplayUITerm();
749 //----------------------------------------
753 static void do_mainmenu()
755 SwitchToDPCMainMenuMode(TRUE
);
758 static void do_simmenu()
760 // don't do anything if the trigger is pulled
761 AutoAppIPtr(PlayerGun
);
762 ObjID gun
= pPlayerGun
->Get();
763 if ((gun
!= OBJ_NULL
) && pPlayerGun
->IsTriggerPulled())
766 // throw any objects on the cursor into the world
767 if (drag_obj
!= OBJ_NULL
)
769 ThrowObj(drag_obj
,PlayerObject());
772 SwitchToDPCSimMenuMode(TRUE
);
777 static Command commands
[] =
779 { "main_menu", FUNC_VOID
, do_mainmenu
, "Go to main menu.", HK_ALL
},
780 { "sim_menu", FUNC_VOID
, do_simmenu
, "Go to sim menu.", HK_ALL
},
785 static void init_commands()
787 COMMANDS(commands
,HK_ALL
);