示例#1
0
void Global::LoadIniFile(AnsiString asFileName)
{
    int i;
    for (i = 0; i < 10; ++i)
    { // zerowanie pozycji kamer
        pFreeCameraInit[i] = vector3(0, 0, 0); // wspó³rzêdne w scenerii
        pFreeCameraInitAngle[i] = vector3(0, 0, 0); // k¹ty obrotu w radianach
    }
    TFileStream *fs;
    fs = new TFileStream(asFileName, fmOpenRead | fmShareCompat);
    if (!fs)
        return;
    AnsiString str = "";
    int size = fs->Size;
    str.SetLength(size);
    fs->Read(str.c_str(), size);
    // str+="";
    delete fs;
    TQueryParserComp *Parser;
    Parser = new TQueryParserComp(NULL);
    Parser->TextToParse = str;
    // Parser->LoadStringToParse(asFile);
    Parser->First();
    ConfigParse(Parser);
    delete Parser; // Ra: tego jak zwykle nie by³o wczeœniej :]
};
示例#2
0
文件: Curve.cpp 项目: shaxbee/maszyna
bool TCurve::LoadFromFile(AnsiString asName)
{
    DecimalSeparator = '.';
    TFileStream *fs;
    fs = new TFileStream(asName, fmOpenRead | fmShareCompat);
    AnsiString str = "xxx";
    int size = fs->Size;
    str.SetLength(size);
    fs->Read(str.c_str(), size);
    str += "";
    delete fs;
    TQueryParserComp *Parser;
    Parser = new TQueryParserComp(NULL);
    Parser->TextToParse = str;
    Parser->First();
    Load(Parser);

    delete Parser;
    DecimalSeparator = ',';
}
示例#3
0
文件: EU07.cpp 项目: enbik/maszyna
int WINAPI WinMain(HINSTANCE hInstance, // instance
                   HINSTANCE hPrevInstance, // previous instance
                   LPSTR lpCmdLine, // command line parameters
                   int nCmdShow) // window show state
{
    MSG msg; // windows message structure
    BOOL done = FALSE; // bool variable to exit loop
    fullscreen = true;
    DecimalSeparator = '.';
    /* //Ra: tutaj to nie dzia³a - zwraca NULL
     //najpierw ustalmy wersjê OpenGL
     AnsiString glver=((char*)glGetString(GL_VERSION));
     while (glver.LastDelimiter(".")>glver.Pos("."))
      glver=glver.SubString(1,glver.LastDelimiter(".")-1); //obciêcie od drugiej kropki
     try {Global::fOpenGL=glver.ToDouble();} catch (...) {Global::fOpenGL=0.0;}
     Global::bOpenGL_1_5=(Global::fOpenGL>=1.5);
    */
    DeleteFile("errors.txt"); // usuniêcie starego
    Global::LoadIniFile("eu07.ini"); // teraz dopiero mo¿na przejrzeæ plik z ustawieniami
    Global::InitKeys("keys.ini"); // wczytanie mapowania klawiszy - jest na sta³e

    // hunter-271211: ukrywanie konsoli
    if (Global::iWriteLogEnabled & 2)
    {
        AllocConsole();
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
    }
    AnsiString str = lpCmdLine; // parametry uruchomienia
    if (!str.IsEmpty())
    { // analizowanie parametrów
        TQueryParserComp *Parser;
        Parser = new TQueryParserComp(NULL);
        Parser->TextToParse = lpCmdLine;
        Parser->First();
        while (!Parser->EndOfFile)
        {
            str = Parser->GetNextSymbol().LowerCase();
            if (str == AnsiString("-s"))
            { // nazwa scenerii
                str = Parser->GetNextSymbol().LowerCase();
                strcpy(Global::szSceneryFile, str.c_str());
            }
            else if (str == AnsiString("-v"))
            { // nazwa wybranego pojazdu
                str = Parser->GetNextSymbol().LowerCase();
                Global::asHumanCtrlVehicle = str;
            }
            else if (str == AnsiString("-modifytga"))
            { // wykonanie modyfikacji wszystkich plików TGA
                Global::iModifyTGA = -1; // specjalny tryb wykonania totalnej modyfikacji
            }
            else if (str == AnsiString("-e3d"))
            { // wygenerowanie wszystkich plików E3D
                if (Global::iConvertModels > 0)
                    Global::iConvertModels = -Global::iConvertModels; // specjalny tryb
                else
                    Global::iConvertModels = -7; // z optymalizacj¹, bananami i prawid³owym Opacity
            }
            else
                Error(
                    "Program usage: EU07 [-s sceneryfilepath] [-v vehiclename] [-modifytga] [-e3d]",
                    !Global::iWriteLogEnabled);
        }
        delete Parser; // ABu 050205: tego wczesniej nie bylo
    }
    /* MC: usunalem tymczasowo bo sie gryzlo z nowym parserem - 8.6.2003
        AnsiString csp=AnsiString(Global::szSceneryFile);
        csp=csp.Delete(csp.Pos(AnsiString(strrchr(Global::szSceneryFile,'/')))+1,csp.Length());
        Global::asCurrentSceneryPath=csp;
    */

    fullscreen = Global::bFullScreen;
    WindowWidth = Global::iWindowWidth;
    WindowHeight = Global::iWindowHeight;
    Bpp = Global::iBpp;
    if (Bpp != 32)
        Bpp = 16;
    // create our OpenGL window
    if (!CreateGLWindow(Global::asHumanCtrlVehicle.c_str(), WindowWidth, WindowHeight, Bpp,
                        fullscreen))
        return 0; // quit if window was not created
    SetForegroundWindow(hWnd);
    // McZapkie: proba przeplukania klawiatury
    Console *pConsole = new Console(); // Ra: nie wiem, czy ma to sens, ale jakoœ zainicjowac trzeba
    while (Console::Pressed(VK_F10))
        Error("Keyboard buffer problem - press F10"); // na Windows 98 lubi siê to pojawiaæ
    int iOldSpeed, iOldDelay;
    SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &iOldSpeed, 0);
    SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &iOldDelay, 0);
    SystemParametersInfo(SPI_SETKEYBOARDSPEED, 20, NULL, 0);
    // SystemParametersInfo(SPI_SETKEYBOARDDELAY,10,NULL,0);
    if (!joyGetNumDevs())
        WriteLog("No joystick");
    if (Global::iModifyTGA < 0)
    { // tylko modyfikacja TGA, bez uruchamiania symulacji
        Global::iMaxTextureSize = 64; //¿eby nie zamulaæ pamiêci
        World.ModifyTGA(); // rekurencyjne przegl¹danie katalogów
    }
    else
    {
        if (Global::iConvertModels < 0)
        {
            Global::iConvertModels = -Global::iConvertModels;
            World.CreateE3D("models\\"); // rekurencyjne przegl¹danie katalogów
            World.CreateE3D("dynamic\\", true);
        } // po zrobieniu E3D odpalamy normalnie sceneriê, by j¹ zobaczyæ
        // else
        //{//g³ówna pêtla programu
        Console::On(); // w³¹czenie konsoli
        while (!done) // loop that runs while done=FALSE
        {
            if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) // is there a message waiting?
            {
                if (msg.message == WM_QUIT) // have we received a quit message?
                    done = TRUE; // if so
                else // if not, deal with window messages
                {
                    // if (msg.message==WM_CHAR)
                    // World.OnKeyDown(msg.wParam);
                    TranslateMessage(&msg); // translate the message
                    DispatchMessage(&msg); // dispatch the message
                }
            }
            else // if there are no messages
            {
                // draw the scene, watch for quit messages
                // DrawGLScene()
                // if (!pause)
                // if (Global::bInactivePause?Global::bActive:true) //tak nie, bo spada z góry
                if (World.Update()) // Was There A Quit Received?
                    SwapBuffers(hDC); // Swap Buffers (Double Buffering)
                else
                    done = true; //[F10] or DrawGLScene signalled a quit
            }
        }
        Console::Off(); // wy³¹czenie konsoli (komunikacji zwrotnej)
    }
    SystemParametersInfo(SPI_SETKEYBOARDSPEED, iOldSpeed, NULL, 0);
    SystemParametersInfo(SPI_SETKEYBOARDDELAY, iOldDelay, NULL, 0);
    delete pConsole; // deaktywania sterownika
    // shutdown
    KillGLWindow(); // kill the window
    return (msg.wParam); // exit the program
}