int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int cmdShow)
{
    gui.reset(new GUI::GuiWrapper());
    simulation.reset(new Simulation());

    runSimulation = 
        InitialiseWindow(&hInstance) && 
        InitialiseDirectX() &&  
        simulation->CreateSimulation(hInstance, hWnd, d3ddev) &&
        InitialiseGUI();

    while(runSimulation && gui->Update())
    {
        simulation->Update();
        simulation->Render();
    }

    d3ddev->Release();
    d3d->Release();
    backBuffer->Release();

    #ifdef _DEBUG
    OutputDebugString("Exiting Simulation\n");
    #endif
}
Exemple #2
0
void App::ReinitialiseWindow()
{
#ifdef TARGET_OS_LINUX
    // Resolution/Fullscreen switching is broken on linux, pop up a dialog box
    // asking the user to restart to get the effect.

    EclRegisterWindow( new MessageDialog( "Restart Required", "dialog_restart_required_caption", true, "dialog_restart_required_title", true ) );
    return;
#endif
    

	g_windowManager->DestroyWin();
    g_resource->Restart();

    InitialiseWindow();
    InitFonts();

    m_mapRenderer->Init();
    m_interface->Init(); 
    
}
BOOL CConfigMsgLogDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
    m_ChkbEnableLogOnConnect.SetCheck(m_bLogOnConnect == TRUE? BST_CHECKED : BST_UNCHECKED);
    m_odStartMsgID.vSetConfigData(IDC_EDIT_STARTMSGID);
    m_odStopMsgID.vSetConfigData(IDC_EDIT_STOPMSGID);
    m_odStartMsgID.vSetBase(BASE_HEXADECIMAL);
    m_odStopMsgID.vSetBase(BASE_HEXADECIMAL);
    m_odStartMsgID.vSetSigned(false);
    m_odStopMsgID.vSetSigned(false);

    vCreateFileList();
    InitialiseWindow();

    USHORT LogBlocks = GetLoggingBlockCount();
    if (LogBlocks > 0)
    {
        for (USHORT i = 0; i < LogBlocks; i++)
        {
            SLOGINFO sLogObject;
            HANDLE hFind;
            WIN32_FIND_DATA FindData;
            CStdioFile omStdiofile;

            GetLoggingBlock(i, sLogObject);

            // check for valid log file
            CString strTempLog = sLogObject.m_sLogFileName;

            hFind = FindFirstFile(strTempLog, &FindData);

            if(hFind == INVALID_HANDLE_VALUE )//file not found
            {
                DWORD dError = GetLastError();
                if(dError == ERROR_FILE_NOT_FOUND)//file not found
                {
                    BOOL bFileOpen = omStdiofile.Open(strTempLog,
                                                      CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);

                    if(bFileOpen == TRUE)///file created, add in the list
                    {
                        omStdiofile.Close();
                        AddNewItem_GUI(sLogObject, i);
                    }
                    else //not a valid file
                    {
                        RemoveLoggingBlock(i--); //remove the old log data
                        LogBlocks = GetLoggingBlockCount(); //refresh the log count
                    }
                }
                else //not a valid filepath / file folder is removed
                {
                    RemoveLoggingBlock(i--); //remove the old log data
                    LogBlocks = GetLoggingBlockCount(); //refresh the log count
                }
            }
            else ///file found add in the list
            {
                AddNewItem_GUI(sLogObject, i);
            }

        }
        m_nLogIndexSel = 0;
        if(m_omListLogFiles.GetItemCount() > 0 )//check for log files exists
        {
            m_omListLogFiles.SetItemState(m_nLogIndexSel,
                                          LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
        }
        else
        {
            vEnableDisableControls(FALSE);//disable controls if no log files exists
        }
    }
    else
    {
        vEnableDisableControls(FALSE);
    }

    SetWindowText(m_strCurrWndText);

    if (m_bLogON)
    {
        vEnableDisableControls(FALSE);

        if(m_omListLogFiles.GetItemCount()>0)
        {
            vUpdate_GUI_From_Datastore(0);
        }

        GetDlgItem(IDC_CBTN_ADDLOG)->EnableWindow(FALSE);
        GetDlgItem(IDC_CHECK_RESET_TIMESTAMP)->EnableWindow(FALSE);
        GetDlgItem(IDC_EDIT_NO_OF_FILES)->EnableWindow(FALSE);
        GetWindowText(m_strCurrWndText);
        m_strCurrWndText+=_(" - Read Only as Logging is ON");
        SetWindowText(m_strCurrWndText);

        // If Logging is on
        GetDlgItem(IDOK)->EnableWindow(FALSE);

        m_unDispUpdateTimerId = SetTimer(600, 600, nullptr);
    }
    else
    {
        // If Logging is on
        GetDlgItem(IDOK)->EnableWindow(TRUE);
    }

    // Hide or show the Filters button in the dialog based on the protocol

    GetDlgItem(IDC_LOG_FILTER)->ShowWindow(SW_SHOWNORMAL);

    /*if (J1939 == m_eCurrBus)
    {
        GetDlgItem(IDC_LOG_FILTER)->ShowWindow(0);
    }*/

    return TRUE;
}
Exemple #4
0
void App::MinimalInit()
{
#ifdef DUMP_DEBUG_LOG
	AppDebugOutRedirect("debug.txt");
#endif
    AppDebugOut("Defcon %s built %s\n", APP_VERSION, __DATE__ );
		
    //
    // Turn everything on

	InitialiseFloatingPointUnit();
    InitialiseHighResTime();

    g_fileSystem = new FileSystem();
    g_fileSystem->ParseArchive( "main.dat" );
    g_fileSystem->ParseArchives( "localisation/", "*.dat" );

    g_preferences = new Preferences();

    g_preferences->Load( "data/prefs_default.txt" );
#ifdef TARGET_OS_MACOSX
	g_preferences->Load( "data/prefs_default_macosx.txt" );
#endif
#if defined(LANG_DEFAULT) && defined(PREF_LANG)
	g_preferences->Load( "data/prefs_default_" LANG_DEFAULT ".txt" );
#endif

    //
    // Load Language from Inno Setup
    g_preferences->Load( "DefconLang.ini" );

#ifdef TESTBED
    g_preferences->Load( "data/prefs_testbed.txt" );
#else
	g_preferences->Load( GetPrefsPath() );
#endif

    g_modSystem = new ModSystem();
    g_modSystem->Initialise();
    
    g_languageTable = new LanguageTable();
    g_languageTable->SetAdditionalTranslation( "data/earth/cities_%s.txt" );
#if defined(LANG_DEFAULT) && defined(LANG_DEFAULT_ONLY_SELECTABLE)
	g_languageTable->SetDefaultLanguage( LANG_DEFAULT, true );
#elif defined(LANG_DEFAULT)
	g_languageTable->SetDefaultLanguage( LANG_DEFAULT );
#endif
    g_languageTable->Initialise();
	g_languageTable->LoadCurrentLanguage();
    
    g_resource = new Resource();
    g_styleTable = new StyleTable();
    g_styleTable->Load( "default.txt" );
    bool success = g_styleTable->Load( g_preferences->GetString(PREFS_INTERFACE_STYLE) );

    m_clientToServer = new ClientToServer();
    m_clientToServer->OpenConnections();

    m_game = new Game();

    m_earthData = new EarthData();
    m_earthData->Initialise();
    
    g_windowManager = WindowManager::Create();
    InitialiseWindow();
    
    g_renderer = new Renderer();
    InitFonts();

    m_mapRenderer = new MapRenderer();
    m_mapRenderer->Init();

    m_lobbyRenderer = new LobbyRenderer();
    m_lobbyRenderer->Initialise();
    
    g_inputManager = InputManager::Create();

}