GliderPRO/Sources/Tools.c

1 line
11 KiB
C
Raw Normal View History

//============================================================================ //---------------------------------------------------------------------------- // Tools.c //---------------------------------------------------------------------------- //============================================================================ #include <TextUtils.h> #include "Externs.h" #include "Environ.h" #include "RectUtils.h" #include "Utilities.h" #define kToolsHigh 4 #define kToolsWide 4 #define kTotalTools 16 // kToolsHigh * kToolsWide #define kPopUpControl 129 #define kFirstBlower 1 #define kLastBlower 15 #define kBlowerBase 1 #define kFirstFurniture 1 #define kLastFurniture 15 #define kFurnitureBase 21 #define kFirstBonus 1 #define kLastBonus 15 #define kBonusBase 41 #define kFirstTransport 1 #define kLastTransport 12 #define kTransportBase 61 #define kFirstSwitch 1 #define kLastSwitch 9 #define kSwitchBase 81 #define kFirstLight 1 #define kLastLight 8 #define kLightBase 101 #define kFirstAppliance 1 #define kLastAppliance 14 #define kApplianceBase 121 #define kFirstEnemy 1 #define kLastEnemy 9 #define kEnemyBase 141 #define kFirstClutter 1 #define kLastClutter 15 #define kClutterBase 161 #define kToolsPictID 1011 void CreateToolsOffscreen (void); void KillToolsOffscreen (void); void FrameSelectedTool (void); void DrawToolName (void); void DrawToolTiles (void); void SwitchToolModes (short); Rect toolsWindowRect, toolSrcRect, toolTextRect; Rect toolRects[kTotalTools]; ControlHandle classPopUp; GWorldPtr toolSrcMap; WindowPtr toolsWindow; short isToolsH, isToolsV; short toolSelected, toolMode; short firstTool, lastTool, objectBase; Boolean isToolsOpen; //============================================================== Functions //-------------------------------------------------------------- CreateToolsOffscreen #ifndef COMPILEDEMO void CreateToolsOffscreen (void) { CGrafPtr wasCPort; GDHandle wasWorld; OSErr theErr; if (toolSrcMap == nil) { GetGWorld(&wasCPort, &wasWorld); QSetRect(&toolSrcRect, 0, 0, 360, 216); theErr = CreateOffScreenGWorld(&toolSrcMap, &toolSrcRect, kPreferredDepth); SetGWorld(toolSrcMap, nil); LoadGraphic(kToolsPictID); SetGWorld(wasCPort, wasWorld); } } #endif //-------------------------------------------------------------- KillToolsOffscreen #ifndef COMPILEDEMO void KillToolsOffscreen (void) { if (toolSrcMap != nil) { DisposeGWorld(toolSrcMap); // KillOffScreenPixMap(toolSrcMap); toolSrcMap = nil; } } #endif //-------------------------------------------------------------- FrameSelectedTool #ifndef COMPILEDEMO void FrameSelectedTool (void) { Rect theRect; short toolIcon; toolIcon = toolSelected; if ((toolMode == kBlowerMode) && (toolIcon >= 7)) { toolIcon--; } else if ((toolMode == kTransportMode) && (toolIcon >= 7)) { if (toolIcon >= 15) toolIcon -= 4; else toolIcon = ((toolIcon - 7) / 2) + 7; } theRect = toolRects[toolIcon]; PenSize(2, 2); ForeColor(redColor); FrameRect(&theRect); PenNormal(); ForeColor(blackColor); } #endif //-------------------------------------------------------------- DrawToolName #ifndef COMPILEDEMO void DrawToolName (void) { Str255 theString; if (toolSelected == 0) PasStringCopy("\pSelection Tool", theString); else GetIndString(theString, kObjectNameStrings, toolSelected + ((toolMode - 1) * 0x0010)); EraseRect(&toolTextRect); MoveTo(toolTextRect.left + 3, toolTextRect.bottom - 6); TextFont(applFont); TextSize(9); TextFace(bold); ColorText(theString, 171L); } #endif //-------------------------------------------------------------- DrawToolTiles #ifndef COMPILEDEMO void DrawToolTiles (void) { Rect srcRect, destRect; short i; DrawCIcon(2000, toolRects[0].left, toolRects[0].top); // Selection Tool for (i = 0; i < 15; i++) // Other tools { QSetRect(&srcRect, 0, 0, 24, 24); QSetRect(&destRect, 0, 0, 24, 24); QOffsetRect(&srcRect, i * 24, (toolMode - 1) * 24); QOffsetRect(&destR