Beispiel #1
0
UINT32 LoadSaveScreenHandle(void)
{
	FDLG_LIST *FListNode;
	INT32 x;
	InputAtom DialogEvent;

	if( fEnteringLoadSaveScreen )
	{
		LoadSaveScreenEntry();
	}

	if( gbCurrentFileIOStatus ) //loading or saving map
	{
		UINT32 uiScreen;
		uiScreen = ProcessFileIO();
		if( uiScreen == EDIT_SCREEN && gbCurrentFileIOStatus == LOADING_MAP )
			RemoveProgressBar( 0 );
		return uiScreen;
	}

	if( gubMessageBoxStatus )
	{
		if( MessageBoxHandled() )
			return ProcessLoadSaveScreenMessageBoxResult();
		return LOADSAVE_SCREEN;
	}

	//handle all key input.
	while( DequeueEvent(&DialogEvent) )
	{
		if( !HandleTextInput(&DialogEvent) && (DialogEvent.usEvent == KEY_DOWN || DialogEvent.usEvent == KEY_REPEAT) )
		{
			HandleMainKeyEvents( &DialogEvent );
		}
	}

	HandleMouseWheelEvents();//dnl ch36 150909

	DrawFileDialog();

	// Skip to first filename to show
	FListNode = FileList;
	for(x=0;x<iTopFileShown && x<iTotalFiles && FListNode != NULL;x++)
	{
		FListNode = FListNode->pNext;
	}

	// Show up to 8 filenames in the window
	SetFont( FONT12POINT1 );
	if( gfNoFiles )
	{
		SetFontForeground( FONT_LTRED );
		SetFontBackground( 142 );
	  mprintf( iScreenWidthOffset + 226, iScreenHeightOffset + 126, L"NO FILES IN \\MAPS DIRECTORY" );
	}
	else for(x=iTopFileShown;x<(iTopFileShown+8) && x<iTotalFiles && FListNode != NULL; x++)
	{
		if( !EditingText() && x == iCurrFileShown  )
		{
			SetFontForeground( FONT_GRAY2 );
			SetFontBackground( FONT_METALGRAY );
		}
		else
		{
			SetFontForeground( FONT_BLACK );
			SetFontBackground( 142 );
		}
		mprintf( iScreenWidthOffset + 186,(iScreenHeightOffset + 73+ (x-iTopFileShown)*15 ), L"%S", FListNode->FileInfo.zFileName);
		FListNode = FListNode->pNext;
	}

	RenderAllTextFields();

	InvalidateScreen();

	ExecuteBaseDirtyRectQueue();
	EndFrameBufferRender();

	switch( iFDlgState )
	{
		case DIALOG_CANCEL:
			RemoveFileDialog();
			fEnteringLoadSaveScreen = TRUE;
			return EDIT_SCREEN;
		case DIALOG_DELETE:
			sprintf( gszCurrFilename, "MAPS\\%S", gzFilename );
			if( GetFileFirst(gszCurrFilename, &FileInfo) )
			{
				CHAR16 str[40];
				if( FileInfo.uiFileAttribs & (FILE_IS_READONLY|FILE_IS_HIDDEN|FILE_IS_SYSTEM) )
				{
					swprintf( str, L" Delete READ-ONLY file %s? ", gzFilename );
					gfReadOnly = TRUE;
				}
				else
					swprintf( str, L" Delete file %s? ", gzFilename );
				gfDeleteFile = TRUE;
				CreateMessageBox( str );
			}
			return LOADSAVE_SCREEN;
		case DIALOG_SAVE://dnl ch37 230909
		{
			if(!ExtractFilenameFromFields())
			{
				CreateMessageBox(L" Illegal filename.  Try another filename? ");
				gfIllegalName = TRUE;
				iFDlgState = DIALOG_NONE;
				return(LOADSAVE_SCREEN);
			}
			sprintf(gszCurrFilename, "MAPS\\%S", gzFilename);
			gfFileExists = FALSE;
#ifndef USE_VFS
			gfReadOnly = FALSE;
			if(FileExists(gszCurrFilename))
			{
				gfFileExists = TRUE;
				if(GetFileFirst(gszCurrFilename, &FileInfo))
				{
					if(FileInfo.uiFileAttribs & (FILE_IS_READONLY|FILE_IS_DIRECTORY|FILE_IS_HIDDEN|FILE_IS_SYSTEM|FILE_IS_OFFLINE|FILE_IS_TEMPORARY))
						gfReadOnly = TRUE;
					GetFileClose(&FileInfo);
				}
			}
#else
			gfReadOnly = TRUE;
			vfs::CProfileStack* st = getVFS()->getProfileStack();
			vfs::CProfileStack::Iterator it = st->begin();
			while(!it.end())
			{
				vfs::CVirtualProfile* prof = it.value();
				if(prof->cWritable == true)
				{
					gfReadOnly = FALSE;
					vfs::Path const& path = gszCurrFilename;
					vfs::IBaseFile *file = prof->getFile(path);
					if(file)
					{
						gfFileExists = TRUE;
						if(file->implementsWritable() == false)
							gfReadOnly = TRUE;
					}
					break;
				}
				it.next();
			}
#endif
			if(gfReadOnly)
			{
				CreateMessageBox(L" File is read only!  Choose a different name? ");
				return( LOADSAVE_SCREEN);
			}
			else if(gfFileExists)
			{
				CreateMessageBox(L" File exists, Overwrite? ");
				return(LOADSAVE_SCREEN);
			}
			RemoveFileDialog();
			gbCurrentFileIOStatus = INITIATE_MAP_SAVE;
			return(LOADSAVE_SCREEN);
		}
		case DIALOG_LOAD:
			if( !ExtractFilenameFromFields() )
			{
				CreateMessageBox( L" Illegal filename.  Try another filename? " );
				gfIllegalName = TRUE;
				iFDlgState = DIALOG_NONE;
				return LOADSAVE_SCREEN;
			}
			RemoveFileDialog();
			CreateProgressBar( 0, iScreenWidthOffset + 118, iScreenHeightOffset + 183, iScreenWidthOffset + 522, iScreenHeightOffset + 202 );
			DefineProgressBarPanel( 0, 65, 79, 94, iScreenWidthOffset + 100, iScreenHeightOffset + 155, iScreenWidthOffset + 540, iScreenHeightOffset + 235 );
			swprintf( zOrigName, L"Loading map:  %s", gzFilename );
			SetProgressBarTitle( 0, zOrigName, BLOCKFONT2, FONT_RED, FONT_NEARBLACK );
			gbCurrentFileIOStatus = INITIATE_MAP_LOAD;
			return LOADSAVE_SCREEN ;
		default:
			iFDlgState = DIALOG_NONE;
	}
	iFDlgState = DIALOG_NONE;
	return LOADSAVE_SCREEN ;
}
Beispiel #2
0
UINT32 LoadSaveScreenHandle(void)
{
    FDLG_LIST *FListNode;
    INT32 x;
    InputAtom DialogEvent;

    if( fEnteringLoadSaveScreen )
    {
        LoadSaveScreenEntry();
    }

    if( gbCurrentFileIOStatus ) //loading or saving map
    {
        UINT32 uiScreen;
        uiScreen = ProcessFileIO();
        if( uiScreen == EDIT_SCREEN && gbCurrentFileIOStatus == LOADING_MAP )
            RemoveProgressBar( 0 );
        return uiScreen;
    }

    if( gubMessageBoxStatus )
    {
        if( MessageBoxHandled() )
            return ProcessLoadSaveScreenMessageBoxResult();
        return LOADSAVE_SCREEN;
    }

    //handle all key input.
    while( DequeueEvent(&DialogEvent) )
    {
        if( !HandleTextInput(&DialogEvent) && (DialogEvent.usEvent == KEY_DOWN || DialogEvent.usEvent == KEY_REPEAT) )
        {
            HandleMainKeyEvents( &DialogEvent );
        }
    }

    DrawFileDialog();

    // Skip to first filename to show
    FListNode = FileList;
    for(x=0; x<iTopFileShown && x<iTotalFiles && FListNode != NULL; x++)
    {
        FListNode = FListNode->pNext;
    }

    // Show up to 8 filenames in the window
    SetFont( FONT12POINT1 );
    if( gfNoFiles )
    {
        SetFontForeground( FONT_LTRED );
        SetFontBackground( 142 );
        mprintf( 226, 126, L"NO FILES IN \\MAPS DIRECTORY" );
    }
    else for(x=iTopFileShown; x<(iTopFileShown+8) && x<iTotalFiles && FListNode != NULL; x++)
        {
            if( !EditingText() && x == iCurrFileShown  )
            {
                SetFontForeground( FONT_GRAY2 );
                SetFontBackground( FONT_METALGRAY );
            }
            else
            {
                SetFontForeground( FONT_BLACK );
                SetFontBackground( 142 );
            }
            mprintf( 186,(73+ (x-iTopFileShown)*15 ), L"%S", FListNode->FileInfo.zFileName);
            FListNode = FListNode->pNext;
        }

    RenderAllTextFields();

    InvalidateScreen();

    ExecuteBaseDirtyRectQueue();
    EndFrameBufferRender();

    switch( iFDlgState )
    {
    case DIALOG_CANCEL:
        RemoveFileDialog();
        fEnteringLoadSaveScreen = TRUE;
        return EDIT_SCREEN;
    case DIALOG_DELETE:
        sprintf( gszCurrFilename, "MAPS\\%S", gzFilename );
        if( GetFileFirst(gszCurrFilename, &FileInfo) )
        {
            UINT16 str[40];
            if( FileInfo.uiFileAttribs & (FILE_IS_READONLY|FILE_IS_HIDDEN|FILE_IS_SYSTEM) )
            {
                swprintf( str, L" Delete READ-ONLY file %s? ", gzFilename );
                gfReadOnly = TRUE;
            }
            else
                swprintf( str, L" Delete file %s? ", gzFilename );
            gfDeleteFile = TRUE;
            CreateMessageBox( str );
        }
        return LOADSAVE_SCREEN;
    case DIALOG_SAVE:
        if( !ExtractFilenameFromFields() )
        {
            CreateMessageBox( L" Illegal filename.  Try another filename? " );
            gfIllegalName = TRUE;
            iFDlgState = DIALOG_NONE;
            return LOADSAVE_SCREEN;
        }
        sprintf( gszCurrFilename, "MAPS\\%S", gzFilename );
        if ( FileExists( gszCurrFilename ) )
        {
            gfFileExists = TRUE;
            gfReadOnly = FALSE;
            if( GetFileFirst(gszCurrFilename, &FileInfo) )
            {
                if( FileInfo.uiFileAttribs & (FILE_IS_READONLY|FILE_IS_DIRECTORY|FILE_IS_HIDDEN|FILE_IS_SYSTEM|FILE_IS_OFFLINE|FILE_IS_TEMPORARY) )
                    gfReadOnly = TRUE;
                GetFileClose(&FileInfo);
            }
            if( gfReadOnly )
                CreateMessageBox( L" File is read only!  Choose a different name? " );
            else
                CreateMessageBox( L" File exists, Overwrite? " );
            return( LOADSAVE_SCREEN );
        }
        RemoveFileDialog();
        gbCurrentFileIOStatus = INITIATE_MAP_SAVE;
        return LOADSAVE_SCREEN ;
    case DIALOG_LOAD:
        if( !ExtractFilenameFromFields() )
        {
            CreateMessageBox( L" Illegal filename.  Try another filename? " );
            gfIllegalName = TRUE;
            iFDlgState = DIALOG_NONE;
            return LOADSAVE_SCREEN;
        }
        RemoveFileDialog();
        CreateProgressBar( 0, 118, 183, 522, 202 );
        DefineProgressBarPanel( 0, 65, 79, 94, 100, 155, 540, 235 );
        swprintf( zOrigName, L"Loading map:  %s", gzFilename );
        SetProgressBarTitle( 0, zOrigName, BLOCKFONT2, FONT_RED, FONT_NEARBLACK );
        gbCurrentFileIOStatus = INITIATE_MAP_LOAD;
        return LOADSAVE_SCREEN ;
    default:
        iFDlgState = DIALOG_NONE;
    }
    iFDlgState = DIALOG_NONE;
    return LOADSAVE_SCREEN ;
}