void LanguageManager::initFromContext(const ApplicationContext& ctx)
{
	// Initialise these members
	_languageSettingFile = ctx.getSettingsPath() + LANGUAGE_SETTING_FILE;
	_curLanguage = loadLanguageSetting();

	rMessage() << "Current language setting: " << _curLanguage << std::endl;

    // No handling of POSIX needed, since we don't use the LanguageManager on
    // POSIX
	_i18nPath = os::standardPathWithSlash(
        ctx.getApplicationPath() + "i18n"
    );

    // Set the LANG environment. As GLIB/GTK+ (in Win32) is using its own C
    // runtime, we need to call their GLIB setenv function for the environment
    // variable to take effect.
	g_setenv("LANG", _curLanguage.c_str(), TRUE);

	// Tell glib to load stuff from the given i18n path
	bindtextdomain(GETTEXT_PACKAGE, _i18nPath.c_str());

    // set encoding to utf-8 to prevent errors for Windows
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
}
Exemple #2
0
// Emulates the old operator<<(ostream &, const DottedRule &) function.  The
// output format is a bit odd (reverse order and double spacing between symbols)
// but there are scripts and tools that expect the output of -T to look like
// that.
void BaseManager::WriteApplicationContext(std::ostream &out,
    const ApplicationContext &context) const
{
  assert(!context.empty());
  ApplicationContext::const_reverse_iterator p = context.rbegin();
  while (true) {
    out << p->second << "=" << p->first << " ";
    if (++p == context.rend()) {
      break;
    }
    out << " ";
  }
}
Exemple #3
0
void SoundManager::initialiseModule(const ApplicationContext& ctx) 
{
	globalOutputStream() << "SoundManager::initialiseModule called\n";
	// Pass a SoundFileLoader to the filesystem
	SoundFileLoader loader(*this);
	GlobalFileSystem().forEachFile(
		SOUND_FOLDER,			// directory
		"*", 				// required extension
		loader,				// loader callback
		99						// max depth
	);

 	globalOutputStream() << _soundFiles.size() << " sound files found." << std::endl;

    // Create the SoundPlayer if sound is not disabled
    const ApplicationContext::ArgumentList& args = ctx.getCmdLineArgs();
    ApplicationContext::ArgumentList::const_iterator found(
        std::find(args.begin(), args.end(), "--disable-sound")
    );
    if (found == args.end())
    {
        globalOutputStream() << "SoundManager: initialising sound playback"
                             << std::endl;
        _soundPlayer = boost::shared_ptr<SoundPlayer>(new SoundPlayer);
    }
    else
    {
        globalOutputStream() << "SoundManager: sound ouput disabled" 
                             << std::endl;
    }
}
STEPEntity *
ApplicationContext::Create(STEPWrapper *sw, SDAI_Application_instance *sse)
{
    Factory::OBJECTS::iterator i;
    if ((i = Factory::FindObject(sse->STEPfile_id)) == Factory::objects.end()) {
	ApplicationContext *object = new ApplicationContext(sw, sse->STEPfile_id);

	Factory::AddObject(object);

	if (!object->Load(sw, sse)) {
	    std::cerr << CLASSNAME << ":Error loading class in ::Create() method." << std::endl;
	    delete object;
	    return NULL;
	}
	return static_cast<STEPEntity *>(object);
    } else {
	return (*i).second;
    }
}
void LanguageManager::initFromContext(const ApplicationContext& ctx)
{
	// Initialise these members
	_languageSettingFile = ctx.getSettingsPath() + LANGUAGE_SETTING_FILE;
	_curLanguage = loadLanguageSetting();

	rMessage() << "Current language setting: " << _curLanguage << std::endl;

    // No handling of POSIX needed, since we don't use the LanguageManager on
    // POSIX
	_i18nPath = os::standardPathWithSlash(
        ctx.getApplicationPath() + "i18n"
    );

	wxFileTranslationsLoader::AddCatalogLookupPathPrefix(_i18nPath);
	
	// Keep locale set to "C" for faster stricmp in Windows builds
	_wxLocale.reset(new wxLocale(_curLanguage, _curLanguage, "C"));
	_wxLocale->AddCatalog(GETTEXT_PACKAGE);
}
//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                     void* pUserContext )
{
    HRESULT hr;

    hr = DXUTGetDXGIFactory()->MakeWindowAssociation(DXUTGetHWND(), DXGI_MWA_NO_ALT_ENTER);

    ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
    V_RETURN( g_SettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
    g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );

    // Create AMD_SDK resources here
    g_HUD.OnCreateDevice( pd3dDevice );

	g_Context.Init(pd3dDevice, pd3dImmediateContext);
	g_Background.Init(pd3dDevice, &g_Context);
	g_Character.Init(pd3dDevice, pd3dImmediateContext, &g_Context);

	TIMER_Init(pd3dDevice)

	// Generate shaders ( this is an async operation - call AMD::ShaderCache::ShadersReady() to find out if they are complete ) 
    static bool bFirstPass = true;
    if( bFirstPass )
    {
		// Add the applications shaders to the cache
		g_Context.m_ShaderCache.GenerateShaders(AMD::ShaderCache::CREATE_TYPE_COMPILE_CHANGES);    // Only compile shaders that have changed (development mode)
        bFirstPass = false;
    } 
	g_Context.m_Affinity.SetUseAffinity(true);

	// Set toggle whether to render using Affinity MGPU
	g_HUD.m_GUI.GetCheckBox(IDC_CHECKBOX_ENABLE_MGPU)->SetChecked(g_Context.m_Affinity.GetUseAffinity());
	g_HUD.m_GUI.GetCheckBox(IDC_CHECKBOX_ENABLE_MGPU)->SetEnabled(g_Context.m_Affinity.IsEnabled());


    g_HUD.m_GUI.GetRadioButton(IDC_RADIO_SYNC_TYPE_AUTOMATIC)->SetEnabled(g_Context.m_Affinity.GetUseAffinity());
    g_HUD.m_GUI.GetRadioButton(IDC_RADIO_SYNC_TYPE_MANUAL)->SetEnabled(g_Context.m_Affinity.GetUseAffinity());
    g_HUD.m_GUI.GetRadioButton(IDC_RADIO_SYNC_TYPE_NONE)->SetEnabled(g_Context.m_Affinity.GetUseAffinity());

    wchar_t text[1000];
    swprintf_s(text, _countof(text), L"%s : %s", APPLICATION_TITLE, g_Context.m_Affinity.IsEnabled() ? L"MGPU available" : L"MGPU not available");
    ::SetWindowTextW(::DXUTGetHWND(), text);

    return S_OK;
}
void SoundManager::initialiseModule(const ApplicationContext& ctx)
{
    // Create the SoundPlayer if sound is not disabled
    const ApplicationContext::ArgumentList& args = ctx.getCmdLineArgs();
    ApplicationContext::ArgumentList::const_iterator found(
        std::find(args.begin(), args.end(), "--disable-sound")
    );
    if (found == args.end())
    {
        rMessage() << "SoundManager: initialising sound playback"
                             << std::endl;
        _soundPlayer = boost::shared_ptr<SoundPlayer>(new SoundPlayer);
    }
    else
    {
        rMessage() << "SoundManager: sound ouput disabled"
                             << std::endl;
    }
}
Exemple #8
0
void
AAssociate
::set_application_context(ApplicationContext const & value)
{
    auto const & old_items = this->_item.as_items("Variable-items");
    std::vector<Item> new_items;

    new_items.push_back(value.get_item());

    std::copy_if(
        old_items.begin(), old_items.end(), std::back_inserter(new_items),
        [](Item const & item) {
            return item.as_unsigned_int_8("Item-type") == 0x21; });

    std::copy_if(
        old_items.begin(), old_items.end(), std::back_inserter(new_items),
        [](Item const & item) {
            return item.as_unsigned_int_8("Item-type") == 0x50; });

    this->_item.as_items("Variable-items") = new_items;

    this->_item.as_unsigned_int_32("PDU-length") = this->_compute_length();
}
HRESULT CLRPrivBinderAssemblyLoadContext::BindUsingPEImage( /* in */ PEImage *pPEImage,
        /* in */ BOOL fIsNativeImage,
        /* [retval][out] */ ICLRPrivAssembly **ppAssembly)
{
    HRESULT hr = S_OK;

    EX_TRY
    {
        ReleaseHolder<BINDER_SPACE::Assembly> pCoreCLRFoundAssembly;
        ReleaseHolder<BINDER_SPACE::AssemblyName> pAssemblyName;
        ReleaseHolder<IMDInternalImport> pIMetaDataAssemblyImport;

        PEKIND PeKind = peNone;

        // Get the Metadata interface
        DWORD dwPAFlags[2];
        IF_FAIL_GO(BinderAcquireImport(pPEImage, &pIMetaDataAssemblyImport, dwPAFlags, fIsNativeImage));
        IF_FAIL_GO(AssemblyBinder::TranslatePEToArchitectureType(dwPAFlags, &PeKind));

        _ASSERTE(pIMetaDataAssemblyImport != NULL);

        // Using the information we just got, initialize the assemblyname
        SAFE_NEW(pAssemblyName, AssemblyName);
        IF_FAIL_GO(pAssemblyName->Init(pIMetaDataAssemblyImport, PeKind));

        // Validate architecture
        if (!BINDER_SPACE::Assembly::IsValidArchitecture(pAssemblyName->GetArchitecture()))
        {
            IF_FAIL_GO(HRESULT_FROM_WIN32(ERROR_BAD_FORMAT));
        }

        // Ensure we are not being asked to bind to a TPA assembly
        //
        // Easy out for mscorlib
        if (pAssemblyName->IsMscorlib())
        {
            IF_FAIL_GO(HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND));
        }

        {
            SString& simpleName = pAssemblyName->GetSimpleName();
            ApplicationContext *pTPAApplicationContext = m_pTPABinder->GetAppContext();
            SimpleNameToFileNameMap * tpaMap = pTPAApplicationContext->GetTpaList();
            if (tpaMap->LookupPtr(simpleName.GetUnicode()) != NULL)
            {
                // The simple name of the assembly being requested to be bound was found in the TPA list.
                // Now, perform the actual bind to see if the assembly was really in the TPA assembly or not.
                // Don't search app paths when using the TPA binder because the actual binder is using a host assembly resolver.
                hr = m_pTPABinder->BindAssemblyByNameWorker(pAssemblyName, &pCoreCLRFoundAssembly, true /* excludeAppPaths */);
                if (SUCCEEDED(hr))
                {
                    if (pCoreCLRFoundAssembly->GetIsInGAC())
                    {
                        // If we were able to bind to a TPA assembly, then fail the load
                        IF_FAIL_GO(HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND));
                    }
                }
            }

            hr = AssemblyBinder::BindUsingPEImage(&m_appContext, pAssemblyName, pPEImage, PeKind, pIMetaDataAssemblyImport, &pCoreCLRFoundAssembly);
            if (hr == S_OK)
            {
                _ASSERTE(pCoreCLRFoundAssembly != NULL);
                pCoreCLRFoundAssembly->SetBinder(this);
                *ppAssembly = pCoreCLRFoundAssembly.Extract();
            }
        }
Exit:
        ;
    }
    EX_CATCH_HRESULT(hr);

    return hr;
}
Exemple #10
0
void InitialiseApplicationContext( int localMachineID, int user, const std::string& config, paulst::LoggingService* log,
    UserAdvisor* userAdvisor )
{
	paulstdb::throwUnlessOK( CoInitializeEx( NULL, COINIT_MULTITHREADED ) );

    if ( applicationContext )
    {
        throw Exception( L"Application context already initialised." );
    }
    else
    {
		ApplicationContext* ac = new ApplicationContext();
        ac->config = new paulst::Config( config );
        std::string connectionFactoryType = ac->getProperty("ConnectionFactoryType");
        paulst::trim( connectionFactoryType );
        if ( connectionFactoryType == "ADO" )
        {
            ac->connectionFactory = new paulstdb::DBConnectionFactory();
        }
        else if ( connectionFactoryType == "Mock" )
        {
            ac->connectionFactory = new valc::MockConnectionFactory();
        }
        else
        {
            throw Exception( L"ConnectionFactoryType (in config) is not valid.  Valid values are 'ADO' or 'Mock'." );
        }

        if ( "true" == ac->getProperty("LogAllDatabaseStatements") )
        {
            ac->connectionFactory = new paulstdb::ConnectionFactoryWithLogging( ac->connectionFactory, log );
        }

        if ( "true" == ac->getProperty("CacheConnections") )
        {
            ac->connectionFactory = new paulstdb::ConnectionFactoryWithCaching( ac->connectionFactory );
        }

        ac->localMachineID                      = localMachineID;
        ac->user                                = user;
        ac->userAdvisor                         = userAdvisor;
        ac->taskExceptionUserAdvisor            = new TaskExceptionUserAdvisor( userAdvisor, log );
        ac->log                                 = log;
        ac->sampleRunIDResolutionService        = new SampleRunIDResolutionService();
        ac->initialisationQueries               = new stef::ThreadPool(0, 1);
        ac->initialisationQueries->addDefaultTaskExceptionHandler( ac->taskExceptionUserAdvisor );
        ac->dbTransactionHandler                = new DBTransactionHandler(
                                                    ac->connectionFactory->createConnection( 
                                                        ac->getProperty("DBUpdateThreadConnectionString"),
                                                        ac->getProperty("DBUpdateThreadSessionReadLockSetting") ),
                                                    ac->log,
                                                    SnapshotUpdateHandle(),
                                                    paulst::toInt(ac->getProperty("DBUpdateThreadShutdownTimeoutSecs")),
                                                    std::string("true") == ac->getProperty("DBUpdateThreadCancelPendingUpdatesOnShutdown"),
                                                    ac->taskExceptionUserAdvisor,
                                                    ac->config );
        ac->resultAttributes                    = new ResultAttributes();
        ac->clusterIDs                          = new ClusterIDs();
        ac->projects                            = new Projects();
        ac->testNames                           = new TestNames();
        ac->controlModel                        = new ControlModelImpl();
        ac->controlModelQueueListenerAdapter    = new ControlModel::RuleEngineQueueListenerAdapter( ac->controlModel );
        ac->controlModelResultPublisherAdapter  = new ControlModel::RuleResultPublisherAdapter( ac->controlModel );
        ac->compositeRuleEngineQueueListener    = new CompositeRuleEngineQueueListener();
        ac->compositeRuleEngineQueueListener->add( ac->controlModelQueueListenerAdapter );
        ac->compositeRuleResultPublisher        = new CompositeRuleResultPublisher();
        ac->compositeRuleResultPublisher->add( ac->resultAttributes );
        ac->compositeRuleResultPublisher->add( ac->controlModelResultPublisherAdapter );
        ac->qcGates                             = new QCGates(  
                                                    ac->initialisationQueries,
                                                    ac->config,
                                                    ac->connectionFactory,
                                                    ac->log,
                                                    ac->localMachineID );
        ac->ruleEngineContainer                 = new RuleEngineContainer(  
                                                    ac->initialisationQueries,
                                                    ac->config,
                                                    ac->connectionFactory,
                                                    ac->log,
                                                    ac->compositeRuleResultPublisher,
                                                    ac->compositeRuleEngineQueueListener,
                                                    ac->qcGates,
                                                    ac->taskExceptionUserAdvisor );
        ac->initialisationQueries->addTask(
            new DBQueryTask( "Projects", ac->connectionFactory, ac->config, boost::bind( addProject, _1, ac->projects ) ) );
        ac->initialisationQueries->addTask(
            new DBQueryTask( "ClusterIDs", ac->connectionFactory, ac->config, boost::bind( addCluster, _1, ac->clusterIDs ) ) );
        ac->initialisationQueries->addTask(
            new DBQueryTask( "TestNames", ac->connectionFactory, ac->config, boost::bind( addTestName, _1, ac->testNames ) ) );
        
		applicationContext = ac;
    }
}
void ScriptingSystem::initialiseModule(const ApplicationContext& ctx)
{
	rMessage() << getName() << "::initialiseModule called." << std::endl;

	// Subscribe to get notified as soon as Radiant is fully initialised
	GlobalRadiant().signal_radiantStarted().connect(
		sigc::mem_fun(this, &ScriptingSystem::initialise)
	);

	// Construct the script path
#if defined(POSIX) && defined(PKGLIBDIR)
	_scriptPath = std::string(PKGLIBDIR) + "/scripts/";
#else
	_scriptPath = ctx.getRuntimeDataPath() + "scripts/";
#endif

	// When Python asks for the object, let's register our interfaces to the py::module
	PythonModule::RegisterToPython(
		std::bind(&ScriptingSystem::addInterfacesToModule, this, std::placeholders::_1, std::placeholders::_2));

	// Add the built-in interfaces (the order is important, as we don't have dependency-resolution yet)
	addInterface("Math", std::make_shared<MathInterface>());
	addInterface("GameManager", std::make_shared<GameInterface>());
	addInterface("CommandSystem", std::make_shared<CommandSystemInterface>());
	addInterface("SceneGraph", std::make_shared<SceneGraphInterface>());
	addInterface("GlobalRegistry", std::make_shared<RegistryInterface>());
	addInterface("GlobalEntityClassManager", std::make_shared<EClassManagerInterface>());
	addInterface("GlobalSelectionSystem", std::make_shared<SelectionInterface>());
	addInterface("Brush", std::make_shared<BrushInterface>());
	addInterface("Patch", std::make_shared<PatchInterface>());
	addInterface("Entity", std::make_shared<EntityInterface>());
	addInterface("Radiant", std::make_shared<RadiantInterface>());
	addInterface("Map", std::make_shared<MapInterface>());
	addInterface("FileSystem", std::make_shared<FileSystemInterface>());
	addInterface("Grid", std::make_shared<GridInterface>());
	addInterface("ShaderSystem", std::make_shared<ShaderSystemInterface>());
	addInterface("Model", std::make_shared<ModelInterface>());
	addInterface("ModelSkinCacheInterface", std::make_shared<ModelSkinCacheInterface>());
	addInterface("SoundManager", std::make_shared<SoundManagerInterface>());
	addInterface("DialogInterface", std::make_shared<DialogManagerInterface>());
	addInterface("SelectionSetInterface", std::make_shared<SelectionSetInterface>());
	addInterface("SelectionGroupInterface", std::make_shared<SelectionGroupInterface>());

	GlobalCommandSystem().addCommand(
		"RunScript",
		std::bind(&ScriptingSystem::runScriptFile, this, std::placeholders::_1),
		cmd::ARGTYPE_STRING
	);

	GlobalCommandSystem().addCommand(
		"ReloadScripts",
		std::bind(&ScriptingSystem::reloadScriptsCmd, this, std::placeholders::_1)
	);

	GlobalCommandSystem().addCommand(
		"RunScriptCommand",
		std::bind(&ScriptingSystem::runScriptCommand, this, std::placeholders::_1),
		cmd::ARGTYPE_STRING
	);

	// Bind the reloadscripts command to the menu
	GlobalEventManager().addCommand("ReloadScripts", "ReloadScripts");

	// Add the menu item
	IMenuManager& mm = GlobalUIManager().getMenuManager();
	mm.insert("main/file/refreshShaders", 	// menu location path
			"ReloadScripts", // name
			ui::menuItem,	// type
			_("Reload Scripts"),	// caption
			"",	// icon
			"ReloadScripts"); // event name

	SceneNodeBuffer::Instance().clear();
}