/*
================
DialogAFProperties::LoadFile
================
*/
void DialogAFProperties::LoadFile( idDeclAF *af )
{
    idStr str;

    file = af;

    if ( !file )
    {
        ClearFile();
        return;
    }
    m_editModel.SetWindowText( file->model.c_str() );
    m_editSkin.SetWindowText( file->skin.c_str() );
    m_selfCollision = file->selfCollision;
    idDeclAF::ContentsToString( file->contents, str );
    m_editContents.SetWindowText( str );
    idDeclAF::ContentsToString( file->clipMask, str );
    m_editClipMask.SetWindowText( str );
    m_linearFriction = file->defaultLinearFriction;
    m_angularFriction = file->defaultAngularFriction;
    m_contactFriction = file->defaultContactFriction;
    m_constraintFriction = file->defaultConstraintFriction;
    m_totalMass = file->totalMass;
    m_suspendLinearVelocity = file->suspendVelocity[0];
    m_suspendAngularVelocity = file->suspendVelocity[1];
    m_suspendLinearAcceleration = file->suspendAcceleration[0];
    m_suspendAngularAcceleration = file->suspendAcceleration[1];
    m_noMoveTime = file->noMoveTime;
    m_minMoveTime = file->minMoveTime;
    m_maxMoveTime = file->maxMoveTime;
    m_linearTolerance = file->noMoveTranslation;
    m_angularTolerance = file->noMoveRotation;
    UpdateData( FALSE );
}
Ejemplo n.º 2
0
bool NBFFileOsImageWriter::Close()
{
    if (m_bootloaderBytes!=0x40000)
    {
		g_err.Set("erased target file because I could not find a bootloader to add");
        // make sure file cannot be used, when no bootloader found
        ClearFile();
		LinearFileImageWriter::Close();
        DeleteFile();
		return false;
    }

	// todo: calculate checksum
	const char*header= "PW10A1-ENG-3.16-007";
	UpdateNBFChecksum(m_checksum, ByteVector(header, header+strlen(header)));

	string headercheck=stringformat("%s-%04x------------", header, m_checksum&0xffff);

	if (!LinearFileImageWriter::WriteData(0x7fffffe0, ByteVector(headercheck.begin(), headercheck.begin()+0x20)))
	{
		g_err.Set("error writing nbf header");
		return false;
	}
	if (!LinearFileImageWriter::Close())
		return false;
	return true;
}
Ejemplo n.º 3
0
void Environment:: ClearFiles()
{
	ClearFile("TreeCoordinates.cpp");
	ClearFile("MountainCoordinates.cpp");
	ClearFile("FenceCoordinates.cpp");
	ClearFile("QuestionBlockCoordinates.cpp");
	ClearFile("SplitBoxCoordinates.cpp");
	ClearFile("PipeCoordinates.cpp");
	ClearFile("CoinsCoordinates.cpp");
	ClearFile("HoleCoordinates.cpp");
}
Ejemplo n.º 4
0
void CWZStep4::PostNcDestroy() 
{
	// TODO: Add your specialized code here and/or call the base class

#if 1
	ClearFile();
#endif

   CPropertyPageEx::PostNcDestroy();
}
Ejemplo n.º 5
0
// clears the current log file
void CDXLog::Clear()
{
    switch (m_LogType) {
    case CDXLOG_TYPE_FILE:
        ClearFile();
        break;

    case CDXLOG_TYPE_STDOUT:
    case CDXLOG_TYPE_STDERR:
        // don't think these can be cleared
        break;
    };
}
Ejemplo n.º 6
0
void ProcessWJDFile(const char *wjdfile, int action)
{
    char Buffer[MAX_LINE_LEN]= "\0";
    char Source[MAX_LINE_LEN]= "\0";
    char Target[MAX_LINE_LEN]= "\0";
    int FoundSource = 0;

    FILE *list;
    list = fopen(wjdfile, "rt");
    if(list == NULL) {
        printf("Error: unable to open %s\n",wjdfile);
        return;
    }

    while( !feof(list) ) {
        fgets(Buffer, MAX_LINE_LEN, list);
        if(strnicmp(Buffer,"S", 1) == 0)
        {
            if(FoundSource == 1) {
                printf("Error: unable to find target for %s\n",Source);
                fclose(list);
                return;
            }
            strncpy(Source, &Buffer[2],MAX_LINE_LEN);
            FoundSource = 1;
        } else if(strnicmp(Buffer,"T", 1) == 0) {
            if(FoundSource == 1) {
                // we have a source/target pair.
                strncpy(Target,&Buffer[2],MAX_LINE_LEN);
                ProcessFilenames(Source, Target);

                if(0 == stricmp(Source,Target)) {
                    // it's the same file. Do nothing!
                } else if(action == COPY) {
                    CopyFile(Source, Target);
                } else if(action == CLEAR) {
                    ClearFile(Target);
                }
                FoundSource=0;
            }
        }

    }

}
Ejemplo n.º 7
0
int KJxUpdaterDlg::ClearFile(const CString &strPath)
{
	int nRetCode = FALSE;
	CString strPathName;
	CString strFullPathFile;
	CString strFile;
	WIN32_FIND_DATA FindFileData;
	HANDLE hFindFile  = NULL;

	strPathName = strPath + _T("*.*");

	hFindFile = FindFirstFile(strPathName.GetString(), &FindFileData);
	if (hFindFile != INVALID_HANDLE_VALUE)
	{
		while (true)
		{
			strFile = FindFileData.cFileName;
			if (
				(strFile != _T(".")) &&
				(strFile != _T(".."))
				)
			{
				strFullPathFile = strPath + strFile;
				if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
				{
					_tremove(strFullPathFile.GetString());
				}
				else
				{
					strFullPathFile += _T("\\");
					ClearFile(strFullPathFile);
				}
			}

			nRetCode = FindNextFile(hFindFile, &FindFileData);
			if (!nRetCode)
			{
				if (GetLastError() == ERROR_NO_MORE_FILES)
					break;
			}
		}
	}

	return TRUE;
}
Ejemplo n.º 8
0
void KJxUpdaterDlg::CheckUpdate()
{
	int nRetCode = false;
	int nResult  = false;

	::GetCurrentDirectory(MAX_PATH, m_szAppPath);
	
	_sntprintf(m_szUpdatePath, MAX_PATH, "%s%s%s", m_szAppPath, 
		CONFIG_PATH, "\\");

	nRetCode = CreateLogPath(m_szUpdatePath);
	KG_PROCESS_ERROR(nRetCode);
	nRetCode = ClearFile(m_szUpdatePath);
	KG_PROCESS_ERROR(nRetCode);
	InitParam();
// 	nRetCode = LoadConfig();
// 	KG_PROCESS_ERROR(nRetCode);
// 	nRetCode = CheckVersion();
// 	KG_PROCESS_ERROR(nRetCode);

	if (m_bNeedUpdate)
	{
		nRetCode = Update();
		KG_PROCESS_ERROR(nRetCode);
		m_CtrlStatus.SetWindowText(MSG_SUCCESS);
	}
	else
	{
		//m_CtrlStatus.SetWindowText(MSG_ISNEW);
		//OnBnClickedQuit();
		EndDialog(TRUE);
	}

	nResult = true;
Exit0:
	if (!nResult)
		m_CtrlStatus.SetWindowText(MSG_ERROR);
	return;
}
Ejemplo n.º 9
0
LONG AsmView::OpenFile(TCHAR *szFileName)
{
	ClearFile();

	if(m_pTextDoc->init(szFileName))
	{
		m_nLineCount   = m_pTextDoc->linecount();
		m_nLongestLine = m_pTextDoc->longestline(4);

		m_nVScrollPos  = 0;
		m_nHScrollPos  = 0;

		m_nSelectionStart	= 0;
		m_nSelectionEnd		= 0;
		m_nCursorOffset		= 0;

		UpdateMetrics();
		UpdateMarginWidth();
		return TRUE;
	}

	return FALSE;
}
Ejemplo n.º 10
0
MRESULT EXPENTRY ClientWndProc ( HWND hwndWnd, ULONG ulMsg, MPARAM mpParm1, MPARAM mpParm2 )
{
   switch ( ulMsg )
   {
   // For HELP debugging
   #if 0
      case HM_ERROR:
         {
            CHAR     szTempBuffer[256];

            sprintf( szTempBuffer, "Received HM_ERROR message, mp1=0X%8.8X", (ULONG)mpParm1 );
            WinMessageBox ( HWND_DESKTOP, HWND_DESKTOP, szTempBuffer, "HM_ERROR", 0, MB_OK );
         }
         break;

      case HM_EXT_HELP_UNDEFINED:
         WinMessageBox ( HWND_DESKTOP, HWND_DESKTOP, "Received HM_EXT_HELP_UNDEFINED message", "HM_EXT_HELP_UNDEFINED", 0, MB_OK );
         break;

      case HM_HELPSUBITEM_NOT_FOUND:
         WinMessageBox ( HWND_DESKTOP, HWND_DESKTOP, "Received HM_HELPSUBITEM_NOT_FOUND message", "HM_HELPSUBITEM_NOT_FOUND", 0, MB_OK );
         break;
   #endif

      case HM_QUERY_KEYS_HELP:
         return (MRESULT)IDP_KEYS_INFO;
         break;

      case WM_BUTTON1CLICK:
         MoveCursorToPointer( hwndWnd, (*(POINTS *)&mpParm1).x, (*(POINTS *)&mpParm1).y );
         break;

   #if 0
      case WM_BUTTON2CLICK:
         {
            HPS      hpsClient;
            POINTL   ptl;
            INT      xC, yC;


            xC = ( ( (*(POINTS *)&mpParm1).x - cxChar) / cxChar );
            yC = ( ( cyClient - (*(POINTS *)&mpParm1).y ) / cyChar );

            hpsClient = WinGetPS( hwndWnd );
            GpiSetColor( hpsClient, CLR_PALEGRAY );
            if ( xC < 10 )
               GpiSetMix( hpsClient, FM_XOR );
            else if ( xC < 20 )
               GpiSetMix( hpsClient, FM_INVERT );
            else if ( xC < 30 )
               GpiSetMix( hpsClient, FM_NOTXORSRC );
            else if ( xC < 40 )
               GpiSetMix( hpsClient, FM_NOTMASKSRC );
            else if ( xC < 50 )
               GpiSetMix( hpsClient, FM_SUBTRACT );
///            GpiSetBackColor( hpsClient, CLR_PALEGRAY );
///            GpiSetBackMix( hpsClient, BM_OVERPAINT );
///            ptl.x = ( ( (*(POINTS *)&mpParm1).x - cxChar ) / cxChar ) * cxChar + cxChar;
///            ptl.y = ( ( (*(POINTS *)&mpParm1).y - cyClient ) / cyChar - 1 ) * cyChar + cyClient;
            ptl.x = cxChar + ( xC * cxChar );
            ptl.y = cyClient - ( ( yC + 1) * cyChar );
            GpiMove( hpsClient, &ptl );
            ptl.x += cxChar;
            ptl.y += cyChar;
            if ( yC < 5 )
               GpiBox( hpsClient, DRO_FILL, &ptl, 0, 0 );
            else
               GpiBox( hpsClient, DRO_OUTLINE, &ptl, 0, 0 );
///            GpiSetBackColor( hpsClient, CLR_BACKGROUND );
///            GpiSetMix( hpsClient, FM_DEFAULT );
            WinReleasePS( hpsClient );
         }
         break;
   #endif

      case WM_CHAR:
         if ( !( CHARMSG(&ulMsg)->fs & KC_KEYUP ) )
         {
            if ( CHARMSG(&ulMsg)->fs & KC_CHAR )
            {
               ProcessCharMsg( hwndWnd, ulMsg, mpParm1, mpParm2 );
            }
            else if ( CHARMSG(&ulMsg)->fs & KC_VIRTUALKEY )
            {
               if ( !ProcessCursorMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ) )
               {
                  return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
               }
            }
         }
         break;

      case WM_CLOSE:
         if ( QueryAbandonChanges( hwndWnd ) )
            return WinDefWindowProc ( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      case WM_COMMAND:
         return ProcessCommandMsg( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      case WM_CREATE:
         hwndMenu = WinWindowFromID( WinQueryWindow( hwndWnd, QW_PARENT ), FID_MENU );
         hwndHScroll = WinWindowFromID( WinQueryWindow( hwndWnd, QW_PARENT ), FID_HORZSCROLL );
         hwndVScroll = WinWindowFromID( WinQueryWindow( hwndWnd, QW_PARENT ), FID_VERTSCROLL );
         SetWindowTitle( hwndWnd );
         break;

      case WM_DESTROY:
         ClearFile( hwndWnd );
         break;

      case WM_ERASEBACKGROUND:
         return MRFROMSHORT ( TRUE ) ;

      case WM_HELP:
         ProcessHelpMessage( hwndWnd, mpParm1, mpParm2 );
         break;

      case WM_HSCROLL:
         if ( !ProcessHScrollMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ) )
            return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      case WM_PAINT:
         PaintScreen( hwndWnd );
         break;

      case WM_SAVEAPPLICATION:
         SaveSettings( hwndWnd, habAnchor );
         return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      case WM_SETFOCUS:
         if ( SHORT1FROMMP( mpParm2 ) )
            CreateCursor( hwndWnd );
         else
            DestroyCursor( hwndWnd );
         break;

      case WM_SIZE:
         UpdateWindowSize( hwndWnd, SHORT1FROMMP( mpParm2), SHORT2FROMMP( mpParm2 ) );
         if ( hwndWnd == WinQueryFocus( HWND_DESKTOP ) )
         {
            DestroyCursor( hwndWnd );
            CreateCursor( hwndWnd );
         }
         break;

      case WM_VSCROLL:
         if ( !ProcessVScrollMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ) )
            return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      default:
         return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;
   }

   return MRFROMSHORT ( FALSE ) ;
}
Ejemplo n.º 11
0
bool TextViewBase::HandleWndProc(UINT msg, WPARAM wParam, LPARAM lParam, LONG *pResult)
{
	HIMC hIMC = NULL;
	switch (msg)
	{
		// Draw contents of TextView whenever window needs updating
	case WM_ERASEBKGND:
		*pResult = 1;
		return true;
		// Need to custom-draw the border for XP/Vista themes
	case WM_NCPAINT:
		*pResult = OnNcPaint((HRGN)wParam);
		return true;

	case WM_PAINT:
		*pResult = OnPaint();
		return true;
		// Set a new font 
	case WM_SETFONT:
		*pResult = OnSetFont((HFONT)wParam);
		return true;

	case WM_SIZE:
		*pResult = OnSize(wParam, LOWORD(lParam), HIWORD(lParam));
		return true;

	case WM_VSCROLL:
		*pResult = OnVScroll(LOWORD(wParam), HIWORD(wParam));
		return true;

	case WM_HSCROLL:
		*pResult = OnHScroll(LOWORD(wParam), HIWORD(wParam));
		return true;

	case WM_MOUSEACTIVATE:
		*pResult = OnMouseActivate((HWND)wParam, LOWORD(lParam), HIWORD(lParam));
		return true;

		//case WM_CONTEXTMENU:
		//	return OnContextMenu((HWND)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));

	case WM_MOUSEWHEEL:
		if (IsKeyPressed(VK_CONTROL))
			return false;
		else
			*pResult = OnMouseWheel((short)HIWORD(wParam));
		return true;

	case WM_SETFOCUS:
		*pResult = OnSetFocus((HWND)wParam);
		return true;

	case WM_KILLFOCUS:
		*pResult = OnKillFocus((HWND)wParam);
		return true;

		// make sure we get arrow-keys, enter, tab, etc when hosted inside a dialog
	case WM_GETDLGCODE:
		*pResult = DLGC_WANTALLKEYS;//DLGC_WANTMESSAGE;//DLGC_WANTARROWS;
		return true;

	case WM_LBUTTONDOWN:
		*pResult = OnLButtonDown(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;

	case WM_LBUTTONUP:
		*pResult = OnLButtonUp(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;

	case WM_LBUTTONDBLCLK:
		*pResult = OnLButtonDblClick(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;

	case WM_RBUTTONDOWN:
		*pResult = OnRButtonDown(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;
	case WM_MOUSEMOVE:
		*pResult = OnMouseMove(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;

	case WM_KEYDOWN:
		*pResult = OnKeyDown(wParam, lParam);
		return true;

	case WM_UNDO: case TXM_UNDO: case EM_UNDO:
		*pResult = Undo();
		return true;

	case TXM_REDO : case EM_REDO:
		*pResult = Redo();
		return true;

	case TXM_CANUNDO: case EM_CANUNDO:
		*pResult = CanUndo();
		return true;

	case TXM_CANREDO: case EM_CANREDO:
		*pResult = CanRedo();
		return true;

	case WM_CHAR:
		OutputDebugString(L"WM_CHAR\n");
		*pResult = OnChar(wParam, lParam);
		return true;

	case WM_SETCURSOR:

		if (LOWORD(lParam) == HTCLIENT)
		{
			*pResult = TRUE;
			return true;
		}
		else
			return false;
	case WM_COPY:
		*pResult = OnCopy();
		return true;

	case WM_CUT:
		*pResult = OnCut();
		return true;

	case WM_PASTE:
		*pResult = OnPaste();
		return true;

	case WM_CLEAR:
		*pResult = OnClear();
		return true;
	
	case WM_GETTEXT:
		*pResult = GetText((WCHAR*)lParam, 0, (ULONG)wParam);
		return true;

	case WM_SETTEXT:
		*pResult = OnSetText((WCHAR*)lParam, lstrlen((WCHAR*)lParam));
		return true;
		//case TXM_SETTEXT:
		//	{
		//		ClearFile();
		//		EnterText((WCHAR*)lParam, (LONG)wParam);
		//		return 0;
		//	}
	case WM_TIMER:
		*pResult = OnTimer(wParam);
		return true;

	case WM_IME_STARTCOMPOSITION:
		OutputDebugString(L"WM_IME_STARTCOMPOSITION\n");
		*pResult = OnStartComposition(wParam, lParam);
		return true;
		//return DefWindowProc(m_hWnd, WM_IME_STARTCOMPOSITION, wParam, lParam);

	case WM_IME_COMPOSITION:
		OutputDebugString(L"WM_IME_COMPOSITION\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_COMPOSITION, wParam, lParam);
		return true;
		//return OnComposition(wParam, lParam);

	case WM_IME_ENDCOMPOSITION:
		OutputDebugString(L"WM_IME_ENDCOMPOSITION\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_ENDCOMPOSITION, wParam, lParam);
		return true;
		//return OnEndComposition(wParam, lParam);

	case WM_IME_CHAR:
		OutputDebugString(L"WM_IME_CHAR\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_CHAR, wParam, lParam);
		return true;

	case WM_IME_CONTROL:
		OutputDebugString(L"WM_IME_CONTROL\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_CONTROL, wParam, lParam);
		return true;


	case WM_IME_NOTIFY:
		OutputDebugString(L"WM_IME_NOTIFY\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_NOTIFY, wParam, lParam);
		return true;
		//return HandleImeNotify(wParam, lParam);

	case WM_IME_REQUEST:
		OutputDebugString(L"WM_IME_REQUEST\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_REQUEST, wParam, lParam);
		return true;
	case WM_INPUTLANGCHANGE:
		*pResult = OnInputLanChange(wParam, lParam);
		return true;

	case TXM_PRINT:
		*pResult = OnPrint((HDC)wParam, (int)lParam);
		return true;

		//
	case TXM_OPENFILE:
		*pResult = OpenFile((TCHAR *)lParam);
		return true;


	case TXM_SAVEFILE:
		*pResult = SaveFile((TCHAR *)lParam);
		return true;

	case TXM_IMPORTFILE:
		*pResult = ImportFile((TCHAR *)lParam, (int)wParam);
		return true;

	case TXM_EXPORTFILE:
	{
		int convertype = LOWORD(wParam);
		int utf_type = HIWORD(wParam);
		*pResult = ExportFile((TCHAR *)lParam, convertype, utf_type);
		return true;
	}

	case TXM_CLEAR:
		*pResult = ClearFile();
		return true;

	case TXM_GETFORMAT:
		*pResult = m_pTextDoc->getformat();
		return true;

	case TXM_SETFORMAT:
		*pResult = m_pTextDoc->setformat((int)wParam);
		return true;

	case TXM_GETSELSIZE:
		*pResult = SelectionSize();
		return true;

	case TXM_SETSELALL:
		*pResult = SelectAll();
		return true;

	case TXM_GETCURPOS:
		*pResult = m_CurrentCharPos.get();
		return true;

	case TXM_GETCURLINE_D:
		*pResult = m_nCurrentLine_D;
		return true;

	case TXM_GETCURLINE_V:
		*pResult = OnGetCurLineV();
		return true;

	case TXM_GETCURCOL:
		*pResult = OnGetCurCol();
		return true;

	case TXM_GETEDITMODE:
		*pResult = m_nEditMode;
		return true;

	case TXM_SETEDITMODE:
		lParam = m_nEditMode;
		m_nEditMode = wParam;
		*pResult = lParam;
		return true;
	case TXM_FIND_INIT:
		FindInitial((WCHAR*)lParam);
		*pResult = 0;
		return true;
	case TXM_FIND:
	{
		BOOL m = (BOOL)LOWORD(wParam);
		BOOL b = (BOOL)HIWORD(wParam);
		//FindText()
		if (b)
			*pResult = FindBackward(m, NULL);
		else
			*pResult = FindForward(m, NULL);
		return true;
	}
	case TXM_FIND_TEXT:
	{
		FIND_OPTION* fp = (FIND_OPTION*)(lParam);
		*pResult = Find_Text(fp->text, lstrlen(fp->text), fp->fBackward, fp->fMachCase, fp->fWarp);
		return true;
	}
	case TXM_REPLACE_TEXT:
	{
		*pResult = Replace_Text((REPLACE_OPTION*)(lParam));
		return true;
	}
	case TXM_SETRESMODULE:
	{
		*pResult = OnSetResModule((HMODULE)lParam);
		return true;
	}
	case WM_GETTEXTLENGTH:
	case TXM_GETTEXTLEN:
	{
		*pResult = OnGetTextLen();
		return true;
	}
	case TXM_REPLACE:
	{
		BOOL ra = (BOOL)LOWORD(wParam);
		WORD mb = (WORD)HIWORD(wParam);
		BOOL m = (BOOL)LOBYTE(mb);
		BOOL b = (BOOL)HIBYTE(mb);
		if (b)
			*pResult = FindBackward(m, (WCHAR*)lParam, ra);
		else
			*pResult = FindForward(m, (WCHAR*)lParam, ra);
		return true;
	}
	case TXM_FIND_GETTEXTLENGTH:
		*pResult = m_pFndIterator->find_text_length();
		return true;
	case TXM_GETSELSTART:
		*pResult = m_nSelectionStart;
		return true;
	case TXM_GETSELEND:
		*pResult = m_nSelectionEnd;
		return true;
	case TXM_GETSELTEXT:
		*pResult = OnGetSelText((WCHAR*)wParam, ULONG(lParam));
		return true;
	case TXM_SETTESTERMODE:
		OnTesterMode((bool)wParam);
		*pResult = 0;
		return true;
	case TXM_SETCONTEXTMENU:
		m_hUserMenu = (HMENU)wParam;
		*pResult = 0;
		return true;
	case TXM_STATISTIC:
		*pResult = OnDoStatistic((STATISTIC*)(lParam));
		return true;
	case TXM_GETCONVERTTYPES:
		*pResult = OnGetConvertTypes((convert_type*)(lParam));
		return true;
	case EM_GETSEL:
		*pResult = OnMsg_EM_GETSEL((ULONG*)wParam, (ULONG*)lParam);
		return true;
	case EM_SETSEL:
		*pResult = OnMsg_EM_SETSEL((LONG)wParam, (LONG)lParam);
		return true;
	default:
		return false;
	}
}
Ejemplo n.º 12
0
//Loads a Level
void GameWorld::LoadLevel()
{
	string file;
	sprintf((char*)file.c_str(), "maps/%s%i.mrl", m_levelname.c_str(), m_level);

	//Load Data
	int id;
	int e;
	char p[256];
	int bi=0; //butterfly id

	//Clear the background of any decals
	SDL_BlitSurface(gConMgr.GetSurface("sprites/grid.fif"), 0, m_surf_background, &renderarea);

	//Reset Player Anim State
	m_players[0].ResetAnim();

	//Clear level data
    for(int y = 0; y < 11; y++)
    {
		for(int x = 0; x < 17; x++)
		{
			m_gamegrid[x][y].ent = NULL;
		}
    }

	//Reset some data
	memset(&m_description, 0x00, sizeof(m_description));
	for(int i = 0; i < MAX_CELLS; i++){m_mushrooms[i].SetVisible(0);}
	m_totalmushrooms = 0;
	m_totalboxes = 0;
	m_totalbutterflys = 0;
	m_totalhats = 0;
	m_totalwells = 0;
	m_well[0].SetVisible(0);
	m_hat[0].SetVisible(0);

	//If level doesnt exist:
	FILE* ec = fopen((char*)file.c_str(), "r");
	if(ec != NULL){fclose(ec);}else
	{
		//It doesnt exist
		gGameWorld.gScores.AddScore(m_players[0].GetScore(), gGameWorld.GetLevel(), m_players[0].GetLife());
		gGameWorld.gScores.m_enabled = 1;
		gGameWorld.gMenu.m_selected = 2;
		gGameWorld.gMenu.m_enabled = 1;
		return;
	}


	//Decrypt
	XorCrypt((char*)file.c_str(), "temp.dat", 471);

	//Open Map File
	char out[32];
	FILE* open = fopen("temp.dat", "r");
	if(open != NULL)
	{
		for(int x = 0; x < 17; x++)
		{
			for(int y = 0; y < 11; y++)
			{
				fscanf(open, "%s", out);
				id = atoi(out);

				if(id == 9)
				{
					fscanf(open, "%s", out);
					e = atoi(out);
				}

				if(id == 2)
				{
					memset(&p, 0x00, sizeof(p));
					fscanf(open, "%s", p);
				}

				//Add object to the game
				if(id == 0){AddBoxX(x, y, 1);}
				if(id == 1){AddBoxX(x, y, 0);}
				if(id == 2){AddButterflyX(x, y, p, bi); bi++;}

				if(id == 3)
				{
					m_gamegrid[x][y].ent = &m_players[0];
					m_players[0].SetPos(x, y);
				}

				if(id == 4){AddWellX(x, y);} // well
				if(id == 5){AddMushroomX(x, y, MUSHROOM_BLACK);}
				if(id == 6){AddMushroomX(x, y, MUSHROOM_RED);}
				if(id == 7){AddMushroomX(x, y, MUSHROOM_PINK);}
				if(id == 8){AddMushroomX(x, y, MUSHROOM_PURPLE);}
				if(id == 9){Vector2D tp; tp.Set(x, y); AddBlueBonus(tp, e);}
				if(id == 10){AddHatX(x, y, 4);} // mexican hat
				if(id == 11){AddHatX(x, y, 3);} // fez hat
				if(id == 12){AddHatX(x, y, 2);} // diving hat
				if(id == 13){AddHatX(x, y, 5);} // nightcap
				if(id == 14){AddHatX(x, y, 6);} // skullcap
				if(id == 15){AddHatX(x, y, 1);} // dunce hat
			}
		}

		//Load Description
		fscanf(open, "%s", m_description);
		for(int i = 0; i < sizeof(m_description); i++){if(m_description[i] == '^'){m_description[i] = ' ';}}

		//Break description down into lines
		memset(&line1, 0x00, sizeof(line1));
		memset(&line2, 0x00, sizeof(line2));
		memset(&line3, 0x00, sizeof(line3));
		memset(&line4, 0x00, sizeof(line4));
		memset(&line5, 0x00, sizeof(line5));

		int line=0;
		int lc=0;
		int lsp=0; //last space pos
		int lcsp=0;
		for(int i = 0; i < strlen(m_description); i++)
		{
			if(m_description[i] ==  ' '){lsp = i; lcsp = lc;}

			if(line == 0){line1[lc] = m_description[i];}
			if(line == 1){line2[lc] = m_description[i];}
			if(line == 2){line3[lc] = m_description[i];}
			if(line == 3){line4[lc] = m_description[i];}
			if(line == 4){line5[lc] = m_description[i];}
			
			lc++;
			
			if(lc >= 36)
			{
				i = lsp;
				if(line == 0){line1[lcsp] = 0x00;}
				if(line == 1){line2[lcsp] = 0x00;}
				if(line == 2){line3[lcsp] = 0x00;}
				if(line == 3){line4[lcsp] = 0x00;}
				if(line == 4){line5[lcsp] = 0x00;}

				line++;
				lsp=0;
				lc=0;
			}
			
			if(line > 5){break;}
		}

		fclose(open);
	}

	//Delete Temp
	ClearFile("temp.dat");

	//Get Ready!!
	if(firstgen == 0)
	{
		m_readyreg = GetTicks();
		m_ready = 0;
	}else{firstgen=0;}

	m_beginscore = m_players[0].GetScore();

	m_gamemode = 1;
}
Ejemplo n.º 13
0
CUser::~CUser()
{
    ClearFile();

};
Ejemplo n.º 14
0
void CopyFile(const char *source, const char *dest)
{
    char Buffer[BUFFER_SIZE];
    int numBytes=BUFFER_SIZE+1;
    struct stat fileInfo;
    time_t fileTime;
    struct utimbuf times;
    FILE *in;
    FILE *out;


    time_t time_of_day;
    char buf[26];
    time_of_day = time( NULL );
    _ctime( &time_of_day, buf );
    buf[24]= '\0';


    // see if file is already present.
    if( access( dest, F_OK ) == 0 ) {
        printf("Found existing copy of %s\n",dest);
        ClearFile(dest);
    }



    printf("Copying file: %s.\n to %s.\n",source, dest);

    in = fopen(source,"rt");
    out = fopen(dest,"wt");

    if((in == NULL) )
    {
        printf("Error opening source file for copying: %s\n",source);
        return;
    }
    if( (out == NULL))
    {
        printf("Error opening destination file for copying: %s\n",dest);
        return;
    }

    // print status message
    fprintf(out,Marker,buf );
    while(numBytes >= BUFFER_SIZE) {
        numBytes = fread(Buffer,1,BUFFER_SIZE,in);
        fwrite(Buffer,1,numBytes,out);
    }
    fclose(in);
    fclose(out);

    // set fake file creation time.
    if(-1 != stat( source, &fileInfo) ) {
        times.actime = fileInfo.st_mtime;
        times.modtime = fileInfo.st_mtime;
        utime( dest, &times);
    }



    // set file access:
    chmod(dest,S_IRUSR | S_IRGRP | S_IROTH);

}
Ejemplo n.º 15
0
int main ()
{
    int x = 1;
    ClearFile();

    int proc1;

    switch (fork())
    {
        case 0:
            printf ("first fork()\n");
            double exp = CalculateExp(-(pow(x, 2.0))/2, 180);
            printf ("exp = %f\n", exp);

            char text [40];
            sprintf(text, "%d exp %f", getpid(), exp);

            WriteFile(text);

            exit (0);
        case -1:
            printf ("Error!!!!!! Close program!");
            return -1;
    }

    int proc2;
    switch (fork())
    {
        case 0:
            printf ("second fork()\n");
            //double pi = CalculatePI (1000000000);
            double pi = CalculatePI (1000000000);
            printf ("pi = %f\n", pi);

            char text [40];
            sprintf(text, "@%d pi %f", getpid(), pi);

            WriteFile(text);

            exit (0);
        case -1:
            printf ("Error!!!!!! Close program!");
            return -1;
    }

    wait(&proc1);
    wait(&proc2);

    FILE* file = fopen("/home/codeserfer/Dropbox/Code_Blocks/HW-11/file", "r");
    if (file == NULL)
    {
        printf ("Can't open file! file is %d\n", file);
    }

    while (1)
    {

        char buffer [1024];
        size_t nread;

        rewind (file);

        if (nread = fread(buffer, 1, sizeof buffer, file) <= 0)
        {
            continue;
        }
        else
        {
            char* e = strchr (buffer, '@');

            if (e == NULL)
            {
                continue;
            }
            else
            {
                int index = (int)(e - buffer);
                printf ("found!\n");


                int pID1 = 0;
                int pID2 = 0;
                char fname1 [4];
                char fname2 [4];
                double result1 = 0;
                double result2 = 0;

                rewind (file);

                int fscanf_result = fscanf(file, "%d %s %lf@%d %s %lf", &pID1, fname1, &result1, &pID2, fname2, &result2);

                if (fscanf_result < 6)
                {
                    printf ("Something went wrong...\n");
                    return 0;
                }

                //printf ("first:  %d  %s  %lf \n", pID1, fname1, result1);
                //printf ("second: %d  %s  %lf \n", pID2, fname2, result2);

                double exp = 0, pi = 0;

                if (!strcmp (fname1, "exp"))
                {
                    exp = result1;
                    pi = result2;
                }
                else
                {
                    exp = result2;
                    pi = result1;
                }

                double final_result = exp/sqrt(2*pi);
                printf ("result: %lf\n", final_result);

                break;
            }
        }
    }

    printf ("Close program\n");

    return 0;
}
Ejemplo n.º 16
0
int main()
{
	bool fileExists = false;
	FILE* fp;
	char* pFileName = "0";
	int choice = MainMenu();

	//While the user doesn't want to quit
	while(choice != 5)
	{
		switch(choice)
		{
			case 1: //Rewrite (or create) a new database
				pFileName = ClearFile(fp, fileExists, pFileName);
				break;
			case 2: //User can change a single record of their choice
				if(fileExists)
				{
					EditSingleRecord(fp, pFileName);
				}
				break;
			case 3: //Display a single record of the user's choice
				if(fileExists)
				{
					ReadSingleRecord(fp, pFileName);
				}
				break;
			case 4: //User can reset a single record of their choice
				if(fileExists)
				{
					DeleteSingleRecord(fp, pFileName);
				}
				break;
			case 5://Quit the program
				break;
			default:
				printf("ERROR: Invalid given. The variable \"option\" must be between 1 and 5. Quiting program.\n");
				break;
		}
		if((choice != 1) && (!fileExists))//Check to see if a database exists
		{
			printf("No database exists. One must be created first from Option 1 \"Wipe whole blank file\"\n");
		}
		 //Note: This caused an error on my computer at home, and due to being unable to resolve it after many hours of research I'm going to comment it out. If I forget to comment it back in when I hand it in, that's why.
		//printf("\nEnter any key to return to the main menu.");
		//while(!_kbhit())//While no key has been entered. I use _khbit() or khbit as kkhbit is prior to 2005, and as a result does not include the escape key when called.
		//{
		//}
		fflush(fp);//Explained in reference at bottom of cpp
		//system("pause");//Another method I was testing that also caused issues.
		//std::system("CLS");

		choice = MainMenu();
	}

	printf("Thank you for using Daniel Schenker's Client Manager Service.\n");
	printf("Goodbye.\n");


	return 0;
}
Ejemplo n.º 17
0
MRESULT ProcessCommandMsg ( HWND hwndWnd, ULONG ulMsg, MPARAM mpParm1, MPARAM mpParm2 )
{
   switch ( SHORT1FROMMP( mpParm1 ) )
   {
      /*
       * First, the menu selections.
       */

      case IDM_FILE_OPEN:
         if ( QueryAbandonChanges( hwndWnd ) )
         {
            if ( FileOpenDialog( hwndWnd, NULL ) )
            {
               SetWindowTitle( hwndWnd );
               UpdateScreenLimits( hwndWnd, TRUE );
            }
         }
         break;

      case IDM_FILE_SAVE:
         FileSaveDialog( hwndWnd, szFileName );
         SetWindowTitle( hwndWnd );
         break;

      case IDM_FILE_SAVE_AS:
         FileSaveDialog( hwndWnd, NULL );
         SetWindowTitle( hwndWnd );
         break;

      case IDM_FILE_CLEAR:
         if ( QueryAbandonChanges( hwndWnd ) )
         {
            ClearFile( hwndWnd );
            SetWindowTitle( hwndWnd );
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_FILE_ALLOCATE:
         if ( QueryAbandonChanges( hwndWnd ) )
         {
            if ( FileAllocateDialog( hwndWnd ) )
            {
               SetWindowTitle( hwndWnd );
               UpdateScreenLimits( hwndWnd, TRUE );
            }
         }
         break;

      case IDM_FILE_RESIZE:
         if ( FileResizeDialog( hwndWnd ) )
         {
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_FILE_EXIT:
         if ( QueryAbandonChanges( hwndWnd ) )
         {
            ClearFile( hwndWnd );
            WinPostMsg(hwndWnd, WM_QUIT, 0L, 0L);
         }
         break;

      case IDM_EDIT_CUT:
         if ( EditCut( hwndWnd ) )
         {
            SetWindowTitle( hwndWnd );
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_EDIT_COPY:
         if ( EditCopy( hwndWnd ) )
         {
            SetWindowTitle( hwndWnd );
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_EDIT_PASTE:
         if ( EditPaste( hwndWnd ) )
         {
            SetWindowTitle( hwndWnd );
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_EDIT_DELETE:
         if ( EditDelete( hwndWnd ) )
         {
            SetWindowTitle( hwndWnd );
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_EDIT_INSERT:
         if ( EditInsert( hwndWnd ) )
         {
            SetWindowTitle( hwndWnd );
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_SEARCH_FORWARD:
         SearchForward( hwndWnd );
         break;

      case IDM_SEARCH_BACKWARD:
         SearchBackward( hwndWnd );
         break;

      case IDM_SEARCH_AGAIN:
         SearchAgain( hwndWnd );
         break;

      case IDM_REPLACE_FORWARD:
         ReplaceForward( hwndWnd );
         break;

      case IDM_REPLACE_BACKWARD:
         ReplaceBackward( hwndWnd );
         break;

      case IDM_REPLACE_AGAIN:
         ReplaceAgain( hwndWnd );
         break;

      case IDM_GOTO_OFFSET:
         GotoOffset( hwndWnd );
         break;

      case IDM_OPTIONS_FONT:
         FontSelectDialog( hwndWnd );
         break;

      case IDM_OPTIONS_READONLY:
         bReadOnly ^= TRUE;
         WinSendMsg( hwndMenu, MM_SETITEMATTR,
                     MPFROM2SHORT( IDM_OPTIONS_READONLY, TRUE ),
                     MPFROM2SHORT( MIA_CHECKED, bReadOnly ? MIA_CHECKED : 0 ) );
         break;

      case IDM_OPTIONS_AUTORESIZE:
         bAutoResize ^= TRUE;
         WinSendMsg( hwndMenu, MM_SETITEMATTR,
                     MPFROM2SHORT( IDM_OPTIONS_AUTORESIZE, TRUE ),
                     MPFROM2SHORT( MIA_CHECKED, bAutoResize ? MIA_CHECKED : 0 ) );
         if ( bAutoResize )
            UpdateScreenLimits( hwndWnd, TRUE );
         break;

      case IDM_OPTIONS_REGISTER:
         DisplayRegistrationPanel( hwndWnd );
         break;

      case IDM_DISPLAY:
         DisplayModeDialog( hwndWnd );
         break;

      /*
       * Next, the DISPLAY dialog accelerator keys
       */

      case IDD_DISPLAY_OFFSET_OCTAL:
      case IDD_DISPLAY_OFFSET_DECIMAL:
      case IDD_DISPLAY_OFFSET_HEX:
      case IDD_DISPLAY_ENTITY_OCTAL:
      case IDD_DISPLAY_ENTITY_DECIMAL:
      case IDD_DISPLAY_ENTITY_HEX:
      case IDD_DISPLAY_1_BYTE:
      case IDD_DISPLAY_2_BYTE:
      case IDD_DISPLAY_4_BYTE:
         DisplayModeAccelKey( hwndWnd, SHORT1FROMMP( mpParm1 ) );
         break;

      /*
       * And the default
       */

      default:
         return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;
   }

   return MRFROMSHORT ( FALSE ) ;
}