示例#1
0
BOOL WINPROC EXPORT DlgRoomPuzzleStart (HWND hWnd,UINT wMsg,WPARAM wParam,LPARAM lParam)
{
    BOOL bHandled = TRUE;

    switch (wMsg)
    {
        case WM_COMMAND:
            switch (wParam)
            {
                case HS_PUZZLE_EASY:
				case IDOK:
                    iHardness = 1;
                    if (CheckRegistration (TRUE))
                        GoRoom (hInstAstral, RM_PUZZLE, FALSE);
                    break;                    
                case HS_PUZZLE_TOUGH:
                    iHardness = 2;
                    if (CheckRegistration (TRUE))
                        GoRoom (hInstAstral, RM_PUZZLE, FALSE);
                    break;                    
                case HS_PUZZLE_HARD:
                    iHardness = 3;
                    if (CheckRegistration (TRUE))
                        GoRoom (hInstAstral, RM_PUZZLE, FALSE);
                    break;                    
                default:
                    bHandled = FALSE;
            }
            break;
        default:
            bHandled = FALSE;    
    }

    if (!bHandled)
        bHandled = DefRoomProc (hWnd,wMsg,wParam,lParam);
    return bHandled;
}
示例#2
0
BOOL HandleCommandLine(
/***********************************************************************/
HWND 	hWindow,
LPSTR 	lpszCmdLine,
LPINT 	lpPrint)
{
FNAME szFileName;
LPSTR lp;
BOOL bPassedByClient, bGotImage;
LPIMAGE lpImageDoc;
HWND hWnd;
int i;

bPaintAppActive = TRUE;

*lpPrint = NO;
if ( !lpszCmdLine )
	{ // If no command line, bring up an empty image
	SendMessage( hWindow, WM_COMMAND, IDM_NEW, 0L );
	if ( (hWnd = AstralDlgGet(IDD_MAIN)) && !IsWindowVisible( hWnd ) )
		ShowWindow( hWnd, SW_SHOW );
	return( TRUE );
	}

// Check if we have "[/ | -]embedding" and a possible filename.
// usage: PP ["[-/]embedding"] file1 file2 ...

// See if the command line is being passed by a client
bPassedByClient = NO;
if ( (lp = lstrfind( lpszCmdLine, "embedding" )) &&
	 (lp == lpszCmdLine || lp == (lpszCmdLine+1)) )
	{ // Command line passed by a client
	bPassedByClient = YES;
	lpszCmdLine = SkipSpaces( lp + 9 ); // skip over "embedding"
	}

bGotImage = NO;
while ( *lpszCmdLine )
	{ // Process any files and switches on the command line

	// Skip white space and see if we're done...
	lpszCmdLine = SkipSpaces( lpszCmdLine );
	if ( !(*lpszCmdLine ) )
		break; // If NULL get out

	// Check for any switches preceeding the file name: only /p for now
	while ( *lpszCmdLine == '/' )
		{ // a switch...
		lpszCmdLine++; // Skip over the slash
		if ( !*lpszCmdLine )
			break; // If NULL get out
		if ( *lpszCmdLine == 'p' || *lpszCmdLine == 'P' )
			*lpPrint = YES;
		lpszCmdLine++; // Skip the option character
		lpszCmdLine = SkipSpaces( lpszCmdLine );
		}

	// Skip white space and see if we're done...
	lpszCmdLine = SkipSpaces( lpszCmdLine );
	if ( !(*lpszCmdLine ) )
		break; // If NULL get out

	// Try to zap the space after a single file name
	if ( (lp = lstrfind( lpszCmdLine, " " )) )
		*lp = '\0'; // If we found a space, zap it

	// Copy the full path name into szFileName
#ifdef _MAC
	lstrcpy( szFileName, lpszCmdLine );
#else	
	if ( lstrchr( lpszCmdLine, '\\' ) )
		lstrcpy( szFileName, lpszCmdLine );
	else
		{ // If not a full path name...
		GetCurrentDir( szFileName, sizeof(FNAME) );
		FixPath( szFileName );
		lstrcat( szFileName, lpszCmdLine );
		}
#endif

	// Now we're done with lpszCmdLine, so set it up for the next loop
	if ( lp ) // If we had found a space, there might be more file names
			lpszCmdLine = lp + 1;
	else	lpszCmdLine += lstrlen(lpszCmdLine); // Point to nothing

	// Special handling of documents passed by a client
////if ( bPassedByClient )
////	{ // Loop through documents to see if it's already open
		for ( i=0; i<NumDocs(); i++ )
			{
			hWnd = GetDoc(i);
			if ( !(lpImageDoc = (LPIMAGE)GetWindowLong( hWnd, GWL_IMAGEPTR )))
				continue;
			if ( !StringsEqual( lpImageDoc->CurFile, szFileName ) )
				continue;
			// It's already open....
			SendMessage( hClientAstral, WM_MDIACTIVATE, (WPARAM)hWnd, 0L );
			if ( bPassedByClient )
				lpImageDoc->fOwnedByClient = YES;
			szFileName[0] = '\0'; // Zap it
			bGotImage = YES;
			break;
			}
////	}

	// If we have a file name, open it...
	if ( *szFileName )
		{
		if ( AstralImageLoad( NULL, szFileName, MAYBE, YES ) )
			bGotImage = YES;
		}

	// If the printing option was passed, print it and close it
	if ( *lpPrint && lpImage )
		{
		SendMessage(hWndAstral, WM_COMMAND, IDM_PRINT, 0L );
		CloseImage( NO, NULL );
		}
	}

if ( !bGotImage )
	{
	if ( !idCurrentRoom )
		{
	    GoRoom (hInstAstral, -1, FALSE);
		return( FALSE );
		}
	// If no image was opened via the command line, go to the opening screen
	SendMessage( hWindow, WM_COMMAND, IDM_NEW, 0L );
	}

if ( (hWnd = AstralDlgGet(IDD_MAIN)) && !IsWindowVisible( hWnd ) )
	ShowWindow( hWnd, SW_SHOW );

return( TRUE );
}
示例#3
0
BOOL WINPROC EXPORT DlgRoomPuzzle (HWND hWnd,UINT wMsg,WPARAM wParam,LPARAM lParam)
{
    BOOL bHandled = TRUE;

    switch (wMsg)
    {
        case WM_COMMAND:
            switch (wParam)
            {
                case HS_COVER:
                    // There is no cover in this room, but this keeps
                    // DefRoomProc from disabling ShowMe.
                    break;
                    
                case HS_BACKPUZZLE:
				case IDCANCEL:
                    GoRoom (hInstAstral, RM_PUZZLESTART, FALSE);
                    break;                    
                case HS_PUZZLE_NEWGAME:
                    ShowAllObjects(hWnd, TRUE);
                    LoadBackgroundImage(hWnd);
                    PrepareGuesses(hWnd);
                    break;                    
                case HS_SHOWME:
                case HS_SHOWMEPUZZLE:
                    bFinished = TRUE;
                    SetDlgItemText(hWnd, IDC_PUZZLE_NAME, szGuess);
                    ShowAllObjects(hWnd, FALSE);
                    break;                    
                default:
                    bHandled = FALSE;
            } // switch (wParam)
            break;
            
        case WM_KEYDOWN:
            ProcessKey(hWnd, wParam);
            break;

        case WM_INITDIALOG:
            hPuzzleWnd = hWnd;
            SetPuzzleFonts(hWnd);
            LoadPuzzleImage(hWnd);
            LoadBackgroundImage(hWnd);
            PrepareGuesses(hWnd);
            SetFocus(hWnd);
            bHandled = FALSE;           // allow DefRoomProc to be called.
            break;

        case WM_DESTROY:
            if (hItalicFont)
                DeleteObject(hItalicFont);
            if (hNormalFont)
                DeleteObject(hNormalFont);
            bHandled = FALSE;   // allow DefRoomProc to be called
			hPuzzleWnd = 0;
            break;
            
        default:
            bHandled = FALSE;    
    } // switch (wMsg)

    if (!bHandled)
        bHandled = DefRoomProc (hWnd,wMsg,wParam,lParam);

// ----------This crap hangs the app-----------
//    if (wMsg != WM_KILLFOCUS  && 
//        wMsg != WM_CLOSE      &&
//        wMsg != WM_SYSKEYDOWN &&
//        wMsg != WM_SYSKEYUP   &&
//        wMsg != WM_SYSCHAR    &&
//        wMsg != WM_DESTROY    &&
//        wMsg != WM_NCDESTROY)
//        SetFocus(hWnd);

    return bHandled;
}
示例#4
0
BOOL WINPROC EXPORT DlgRoomWhoAreYou (HWND hWnd,UINT wMsg,WPARAM wParam,LPARAM lParam)
{
	STRING	szTmp;
	WORD	wKey;
	int		iTmp;
    BOOL	bHandled = TRUE;
	int		iPtSize = 30;

	if (wMsg == WM_INITDIALOG)
	{
#ifdef _MAC	
		RECT rEdit;
#endif		
		DefRoomProc (hWnd, wMsg, wParam, lParam);

		if (LoadString (hInstAstral, IDS_FONT_NORMAL, szTmp, sizeof(szTmp)))
		{
			hDlgFont = (HFONT)NULL;
			hDlgFont = CreateFont (-iPtSize,		// Height
									0,				// Width
									0,				// Escapement
									0,				// Orientation
									0,				// Weight
									0,				// Italic
									0,				// Underline
									0,				// Strikeout
									0,				// Charset
									0,				// OutputPrecision
									0,				// ClipPrecision
									0,				// Quality
									0,				// PitchAndFamily
		  							(PSTR)szTmp);	// Typeface Name

			if (hDlgFont != NULL)
			{
				SendDlgItemMessage (hWnd, IDC_WHO_BUTTON1, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_BUTTON2, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_BUTTON3, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_BUTTON4, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_NEWBUTTON, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_EDIT, WM_SETFONT, (WPARAM)hDlgFont, 0L);
			}
		}
		
		
#ifdef _MAC	
		// Make sure the edit control is exactly the same size as the radio button.
		// Without this hack, it is smaller on the mac.
		
		if (LoadString (hInstAstral, IDS_IM_NEW, szTmp, sizeof(szTmp)))
			SetDlgItemText (hWnd, IDC_WHO_EDIT, szTmp);

		GetClientRect(GetDlgItem(hWnd, IDC_WHO_NEWBUTTON), &rEdit);	
		SetWindowPos(
			GetDlgItem(hWnd, IDC_WHO_EDIT),
			NULL,
			0, 0,
			RectWidth(&rEdit),
			RectHeight(&rEdit),
			SWP_NOMOVE | SWP_NOZORDER);
#endif		
		
		// initially hide the edit control
    	ShowWindow (GetDlgItem(hWnd, IDC_WHO_EDIT), SW_HIDE);

		if (LoadString (hInstAstral, IDS_IM_NEW, szTmp, sizeof(szTmp)))
			SetDlgItemText (hWnd, IDC_WHO_NEWBUTTON, szTmp);

		DoInit (hWnd);

    	ShowWindow (GetDlgItem(hWnd, IDOK), SW_HIDE);
		fButtonHidden = FALSE;
		bHandled = TRUE;
	}
    else if (wMsg == WM_CLOSE)
    {
        AstralDlgEnd (hWnd,TRUE|2);
		bHandled = TRUE;
    }
    else if (wMsg == WM_COMMAND)
    {
		switch (wParam)
		{
			// Go To Room hotspot
			case HS_WHO:
				if (CheckUsername (hWnd))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				bHandled = TRUE;
				break;

			// I'm New button
			case IDC_WHO_NEWBUTTON:
#ifndef _MAC	// This problem doesn't exist on the mac			
				if (! fNoUsers)	// hack for Windows focus problem
#endif				
				{
					CheckRadioButton (hWnd, IDC_WHO_BUTTON1,
					  IDC_WHO_NEWBUTTON, IDC_WHO_NEWBUTTON);
    				ShowWindow (GetDlgItem(hWnd, IDC_WHO_NEWBUTTON), SW_HIDE);
    				ShowWindow (GetDlgItem(hWnd, IDC_WHO_EDIT), SW_SHOW);

					if (LoadString (hInstAstral, IDS_YOUR_NAME, szTmp,
				  	sizeof(szTmp)))
						SetDlgItemText (hWnd, IDC_WHO_EDIT, szTmp);

					SetFocus (GetDlgItem (hWnd, IDC_WHO_EDIT));
					SendDlgItemMessage (hWnd, IDC_WHO_EDIT, EM_SETSEL, 0,
				  	  MAKELONG(0, -1) );
				}
				iButtonIndex = 4;
				fNoUsers = FALSE;
				bHandled = TRUE;
				fButtonHidden = TRUE;
				break;

			// Scroll names down
			case HS_WHO_UPARROW:
				if (iUserCount > 4)
				{
					iTmp = iUserIndex;
					if (iUserIndex > 0)
                    {
						iUserIndex--;
                    	ShowWindow (GetDlgItem(hWnd, HS_WHO_DNARROW), SW_SHOW);

						if (iUserIndex == 0)
                    		ShowWindow (GetDlgItem(hWnd, HS_WHO_UPARROW), SW_HIDE);
                    }
                    else
            			ShowWindow (GetDlgItem(hWnd, HS_WHO_UPARROW), SW_HIDE);

					if (iUserIndex != iTmp)
						UpdateButtons (hWnd, iUserIndex, iUserCount);
				}
				bHandled = TRUE;
				break;

			// Scroll names up
			case HS_WHO_DNARROW:
				if (iUserCount > 4)
				{
					iTmp = iUserIndex;
					if (iUserIndex < (iUserCount - 4))
                    {
						iUserIndex++;
                    	ShowWindow (GetDlgItem(hWnd, HS_WHO_UPARROW), SW_SHOW);

						if (iUserIndex +4 >= iUserCount)
                    		ShowWindow (GetDlgItem(hWnd, HS_WHO_DNARROW), SW_HIDE);
                    }
                    else
            			ShowWindow (GetDlgItem(hWnd, HS_WHO_DNARROW), SW_HIDE);

					if (iUserIndex != iTmp)
						UpdateButtons (hWnd, iUserIndex, iUserCount);
				}
				bHandled = TRUE;
				break;

			case IDC_WHO_BUTTON1:
				HandleButton (hWnd, 0);
        		bHandled = TRUE;
				// if they click twice on same control - validate and continue
				if ((iButtonIndex == 0) && (CheckUsername (hWnd)))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				iButtonIndex = 0;
				break;

			case IDC_WHO_BUTTON2:
				HandleButton (hWnd, 1);
        		bHandled = TRUE;
				if ((iButtonIndex == 1) && (CheckUsername (hWnd)))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				iButtonIndex = 1;
				break;

			case IDC_WHO_BUTTON3:
				HandleButton (hWnd, 2);
        		bHandled = TRUE;
				if ((iButtonIndex == 2) && (CheckUsername (hWnd)))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				iButtonIndex = 2;
				break;

			case IDC_WHO_BUTTON4:
				HandleButton (hWnd, 3);
        		bHandled = TRUE;
				if ((iButtonIndex == 3) && (CheckUsername (hWnd)))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				iButtonIndex = 3;
				break;

			case IDC_WHO_DELNAME:
				if (Control.CurrentUser[0] != 0)
				{
					if (! (GetNumberIniEntries() ))
					{
						if (GetUserNameByDir (Control.CurrentUser, szTmp))
						{
							DeleteUserName (szTmp);
							lstrcpy (szTmp, Control.WorkPath);
							lstrcat (szTmp, Control.CurrentUser);
#ifdef WIN32
							RemoveDirectory (szTmp);
#else
							_rmDir (szTmp);
#endif							
							clr ((LPTR)Control.CurrentUser, sizeof(Control.CurrentUser));
							DoInit (hWnd);
						}
					}
				}
        		bHandled = TRUE;
				break;

			case IDOK:
				bHandled = TRUE;
				if (CheckUsername (hWnd))
				{
					DeleteObject (hDlgFont);
       				GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				break;

			default:
        		bHandled = FALSE;
				break;
		}
    }
    else if (wMsg == WM_CHAR)
	{
		wKey = (WORD)lParam;
		if (wKey == VK_DELETE)
		{
			GetUserNameString (iUserIndex, szTmp);
		}
	}
    else
        bHandled = FALSE;

    if (! bHandled)
        bHandled = DefRoomProc (hWnd, wMsg, wParam, lParam);

    return bHandled;
}