#include "MenuManager.h" #include "GameManager.h" void InitMenu(VMenu * m) { long result = 0; m->aboutWindow = NULL; m->menus[0] = NewMenu(APPLEMENU, "\p\x14"); AppendMenu(m->menus[0], "\pAbout Infiltration"); /* What should the name of our application be? */ SetMenuItemCommandID(m->menus[0], 1, kHICommandAbout); AppendMenu(m->menus[0], "\p(-"); InsertMenu(m->menus[0], 0); m->menus[1] = NewMenu(FILEMENU, "\pFile"); AppendMenu(m->menus[1], "\pFullscreen/F"); SetMenuItemCommandID(m->menus[1], 1, 'FScn'); AppendMenu(m->menus[1], "\pClose/W"); SetMenuItemCommandID(m->menus[1], 2, kHICommandClose); AppendMenu(m->menus[1], "\p(-"); AppendMenu(m->menus[1], "\pEnd game/E"); SetMenuItemCommandID(m->menus[1], 4, 'EndG'); EnableMenuCommand(NULL, kHICommandPreferences); Gestalt(gestaltMenuMgrAttr, &result); if (result & gestaltMenuMgrAquaLayoutMask) { MenuRef menu; MenuItemIndex itemIndex; GetIndMenuItemWithCommandID(NULL, kHICommandPreferences, 1, &menu, &itemIndex); SetMenuItemCommandKey(menu, itemIndex, 0, ','); } else { AppendMenu(m->menus[1], "\p(-"); AppendMenu(m->menus[1], "\pPreferences/;"); SetMenuItemCommandID(m->menus[1], 6, kHICommandPreferences); AppendMenu(m->menus[1], "\p(-"); AppendMenu(m->menus[1], "\pQuit/Q"); SetMenuItemCommandID(m->menus[1], 8, kHICommandQuit); } InsertMenu(m->menus[1], 0); CreateStandardWindowMenu(0, &m->menus[2]); InsertMenu(m->menus[2], 0); DrawMenuBar(); } void CleanUpMenu(VMenu * m) { int i; for(i = 0; i < NUMBEROFMENUS; i++) { if (m->menus[i] != NULL) { DisposeMenu(m->menus[i]); } } } /* About window code copied from Water Tower */ static pascal OSStatus aboutWindowContentDrawHandler(EventHandlerCallRef nextEvent, EventRef theEvent, void * userData) { #pragma unused(nextEvent, theEvent) VMenu * m; m = (VMenu *) userData; DrawAboutWindow(m); return noErr; } void OpenAboutWindow(VMenu * m) { Rect bounds; EventTypeSpec eventType; GDHandle mainDevice; if (m->aboutWindow != NULL) { BringToFront(m->aboutWindow); HiliteWindow(m->aboutWindow, 1); return; } mainDevice = GetMainDevice(); if (mainDevice == NULL) return; SetRect(&bounds, (((**mainDevice).gdRect.right / 2) - 142), (((**mainDevice).gdRect.bottom / 2) - 92), (((**mainDevice).gdRect.right / 2) + 142), (((**mainDevice).gdRect.bottom / 2) + 92)); CreateNewWindow(kDocumentWindowClass, kWindowCollapseBoxAttribute + kWindowCloseBoxAttribute, &bounds, &m->aboutWindow); SetWindowTitleWithCFString(m->aboutWindow, CFSTR("About")); TransWindow(m->aboutWindow, true); //m->aboutWindow = NewCWindow(NULL, &bounds, "\pAbout", 1, noGrowDocProc, (WindowPtr) -1, 1, 0); if (m->aboutWindow == NULL) return; /* Suppress minimize/collapse button */ //ChangeWindowAttributes(m->aboutWindow, kWindowNoAttributes, kWindowCollapseBoxAttribute); InstallStandardEventHandler(GetWindowEventTarget(m->aboutWindow)); eventType.eventClass = kEventClassWindow; eventType.eventKind = kEventWindowDrawContent; InstallWindowEventHandler(m->aboutWindow, NewEventHandlerUPP(aboutWindowContentDrawHandler), 1, &eventType, m, NULL); DrawAboutWindow(m); } void DrawAboutWindow(VMenu * m) { GWorldPtr origGWorld; GDHandle origGDev; FontInfo fInfo; Str255 theString; Rect theRect; Boolean antiAliasEnabled; short minFontSize, fontNum; //PicHandle pict; long result = 0; SInt16 FontSize = 0; Style FontStyle; Str255 FontName; GetGWorld(&origGWorld, &origGDev); antiAliasEnabled = IsAntiAliasedTextEnabled(&minFontSize); SetAntiAliasedTextEnabled(1, 12); SetPortWindowPort(m->aboutWindow); GetWindowPortBounds(m->aboutWindow, &theRect); EraseRect(&theRect); /* Draw the pretty striped background */ SetThemeBackground(kThemeBrushDialogBackgroundActive, 32, 1); /* Draw "Icon" with lines */ MoveTo(126, 28); LineTo(140, 58); LineTo(144, 58); LineTo(158, 28); LineTo(154, 28); MoveTo(158, 28); LineTo(158, 26); LineTo(153, 26); LineTo(154, 28); LineTo(142, 52); LineTo(130, 28); LineTo(126, 28); LineTo(126, 26); LineTo(131, 26); MoveTo(130, 28); LineTo(131, 26); LineTo(142, 48); LineTo(153, 26); ForeColor(blackColor); Gestalt(gestaltSystemVersion, &result); /* Easier way of doing this: */ /* Works for me. */ /* Main Application Title -- emphasized system font */ /* Application Version -- label font */ /* Application Description -- small system font */ /* Copyright -- label font */ GetThemeFont(kThemeEmphasizedSystemFont, smSystemScript, FontName, &FontSize, &FontStyle); GetFNum(FontName, &fontNum); TextFont(fontNum); TextSize(FontSize); TextFace(FontStyle); GetFontInfo(&fInfo); MoveTo((140 - (StringWidth("\pInfiltration") / 2)), (84 + fInfo.ascent)); DrawString("\pInfiltration"); GetThemeFont(kThemeLabelFont, smSystemScript, FontName, &FontSize, &FontStyle); GetFNum(FontName, &fontNum); TextFont(fontNum); TextSize(FontSize); TextFace(FontStyle); /*if (result > 0x1000) { TextSize(12); TextFace(normal); } else { GetFNum("\pGeneva", &fontNum); TextFont(fontNum); TextSize(9); }*/ GetFontInfo(&fInfo); theString[0] = sprintf((char *) &theString[1], "Version 1.0.1"); MoveTo((140 - (StringWidth(theString) / 2)), (108 + fInfo.ascent)); DrawString(theString); theString[0] = sprintf((char *) &theString[1], "Written by Alex Diener and Will P."); MoveTo((140 - (StringWidth(theString) / 2)), (128 + fInfo.ascent)); DrawString(theString); /* theString[0] = sprintf((char *) &theString[1], "adiener@sacredsoftware.net"); MoveTo((140 - (StringWidth(theString) / 2)), ((128 + fInfo.ascent) + (fInfo.ascent + fInfo.descent + fInfo.leading))); DrawString(theString); theString[0] = sprintf((char *) &theString[1], "http://www.sacredsoftware.net/"); MoveTo((140 - (StringWidth(theString) / 2)), ((128 + fInfo.ascent) + ((fInfo.ascent + fInfo.descent + fInfo.leading) * 2))); DrawString(theString); */ SetAntiAliasedTextEnabled(antiAliasEnabled, minFontSize); SetGWorld(origGWorld, origGDev); }