Esempio n. 1
0
CIEBrowserEngine::CIEBrowserEngine(HWND hParentWnd, HINSTANCE hInstance) :
        m_parentHWND(NULL),
        m_hparentInst(NULL),
        m_bLoadingComplete(FALSE),
        m_hNavigated(NULL),
        m_dwNavigationTimeout(45000),
        m_urlList(NULL),
	m_currentPage(NULL)
{
    m_parentHWND = hParentWnd;    
    m_hparentInst = hInstance;
    m_tabID = 0; //tabID;

	m_textZoomValue = ZOOM_TEXT_MEDIUM; //By default the text zoom value is set to ZOOM_TEXT_MEDIUM

    GetWindowRect(hParentWnd, &m_rcViewSize);

    m_tcNavigatedURL[0] = 0;
	convertFromStringW(rho_wmimpl_getNavTimeOutVal(),m_dwNavigationTimeout);
	if(m_dwNavigationTimeout<=0)
	{
		LOG(WARNING)+" NavigationTimeout  value  from config.xml not correct "+m_dwNavigationTimeout;
		m_dwNavigationTimeout=45000;
	}
    CreateEngine();
}
Esempio n. 2
0
int main(int argc,char **argv)
{
    mutil_thread = 0;
    setup_signal_handler();
    init_clients();
    InitNetSystem();
    ENGINE engine = CreateEngine();
    int csize = atoi(argv[3]);
    int i = 0;
    for(; i < csize; ++i)
        EConnect(engine,argv[1],atoi(argv[2]),(void*)engine,on_connect,1000);
    uint32_t tick,now;
    tick = now = GetSystemMs();
    while(!stop) {
        EngineRun(engine,50);
        sendpacket();
        now = GetSystemMs();
        if(now - tick > 1000)
        {
            printf("ava_interval:%d\n",ava_interval);
            tick = now;
        }
    }
    CleanNetSystem();
    return 0;
}
Esempio n. 3
0
int main(int argc,char **argv)
{

	HANDLE engine;
	uint32_t n;
	
	ip = argv[1];
	port = atoi(argv[2]);
	signal(SIGPIPE,SIG_IGN);
	if(InitNetSystem() != 0)
	{
		printf("Init error\n");
		return 0;
	}
	wpacket_allocator = (allocator_t)create_block_obj_allocator(0,sizeof(struct wpacket));	

	uint32_t i = 0;
	//getchar();
	//init_wpacket_pool(100000);
	//init_rpacket_pool(50000);
	//buffer_init_maxbuffer_size(2000);
	//buffer_init_64(2000);
	init_clients();

	engine = CreateEngine();
	thread_run(_Listen,&engine);
	tick = GetSystemMs();
	while(1)
	{
		EngineRun(engine,15);
		now = GetSystemMs();
		if(now - tick > 1000)
		{
			printf("recv:%u,send:%u,s_req:%u\n",packet_recv,packet_send,send_request);
			tick = now;
			packet_recv = 0;
			packet_send = 0;
			send_request = 0;
			s_p = 0;
			iocp_count = 0;
			recv_count = 0;
		}
		/*if(now - last_send_tick > 50)
		{
			//心跳,每50ms集中发一次包
			last_send_tick = now;
			for(i=0; i < MAX_CLIENT; ++i)
			{
				if(clients[i])
				{
					//++send_request;
					connection_send(clients[i],0,0);
				}
			}
		}*/
		
	}
	return 0;
}
QRadioTuner::Error XARadioSessionImpl::PostConstruct()
{
    XAresult res = CreateEngine();
    if (res != KErrNone)
        return QRadioTuner::ResourceError;
    else
        return QRadioTuner::NoError;
}
JavascriptInstance::JavascriptInstance(const QString &fileName, JavascriptModule *module) :
    engine_(0),
    sourceFile(fileName),
    module_(module),
    evaluated(false)
{
    CreateEngine();
    Load();
}
Esempio n. 6
0
int main(int argc, const char **argv)
{
	VariantMap settings;
	settings["appName"] = "Puzzle Moppet";
	settings["windowTitle"] = "Puzzle Moppet Configuration";
	settings["screenWidth"] = 250;
	settings["screenHeight"] = 330;
#ifndef __APPLE__
	// Software renderer doesn't seem to work on Mac...
	settings["softwareMode"] = true;
#endif
	
	IEngine *engine = CreateEngine(argc, argv, &settings);
	
	IrrlichtDevice *device = engine->GetIrrlichtDevice();
	
	// Filesystem...
	// Irrlicht needs this so it can load textures from same dir as font xml.
	engine->GetIrrlichtDevice()->getFileSystem()->addFileArchive("../projects/ConfigApp/");
	
	// Show the cursor
	device->getCursorControl()->setVisible(true);
	
	// Pause World, not needed for GUI app.
	// (pausing World also disables mouse centring)
	engine->GetWorld()->Pause();
	
	// Load GUI
	gui::IGUIEnvironment *guienv = device->getGUIEnvironment();
	ASSERT( guienv->loadGUI("gui.xml") );
	
	// Get pointers to important elements within the loaded GUI.
	// Ideally in the future we'll have a layout manager and won't need the GUI
	// defined in xml.
	FindGUIElementPointers();
	
	// Default font
	guienv->getSkin()->setFont( guienv->getFont("lucida.xml") );
	
	// Change background colour...
	engine->GetRenderSystem()->SetBackgroundCol(video::SColor(0, 200,200,200));
	
	// Receive GUI events.
	// This prevents Litha Engine from receiving GUI events, but that doesn't matter.
	IEventReceiver *eventReceiver = new EventReceiver(engine);
	guienv->setUserEventReceiver(eventReceiver);
	
	// Init
	InitSettings();
	InitGUI();
	
	engine->Run();
	engine->drop();
	delete eventReceiver;
	
	return 0;
}
Esempio n. 7
0
STDMETHODIMP ActiveScriptImpl::put_ScriptType(BSTR newVal)
{
	scriptType = newVal;
	CreateEngine();

	if (LoadAndRun())
		return S_OK;
	else
		return E_INVALIDARG;
}
void JavascriptInstance::Load()
{
    PROFILE(JSInstance_Load);
    if (!engine_)
        CreateEngine();

    if (sourceFile.isEmpty() && scriptRefs_.empty())
    {
        LogError("JavascriptInstance::Load: No script content to load!");
        return;
    }
    // Can't specify both a file source and an Asset API source.
    if (!sourceFile.isEmpty() && !scriptRefs_.empty())
    {
        LogError("JavascriptInstance::Load: Cannot specify both an local input source file and a list of script refs to load!");
        return;
    }

    bool useAssetAPI = !scriptRefs_.empty();
    size_t numScripts = useAssetAPI ? scriptRefs_.size() : 1;

    // Determine based on code origin whether it can be trusted with system access or not
    if (useAssetAPI)
    {
        trusted_ = true;
        for(unsigned i = 0; i < scriptRefs_.size(); ++i)
            trusted_ = trusted_ && scriptRefs_[i]->IsTrusted();
    }
    else // Local file: always trusted.
    {
        program_ = LoadScript(sourceFile);
        trusted_ = true; // This is a file on the local filesystem. We are making an assumption nobody can inject untrusted code here.
        // Actually, we are assuming the attacker does not know the absolute location of the asset cache locally here, since if he makes
        // the client to load a script into local cache, he could use this code path to automatically load that unsafe script from cache, and make it trusted. -jj.
    }

    // Check the validity of the syntax in the input.
    for (size_t i = 0; i < numScripts; ++i)
    {
        QString scriptSourceFilename = (useAssetAPI ? scriptRefs_[i]->Name() : sourceFile);
        QString &scriptContent = (useAssetAPI ? scriptRefs_[i]->scriptContent : program_);

        QScriptSyntaxCheckResult syntaxResult = engine_->checkSyntax(scriptContent);
        if (syntaxResult.state() != QScriptSyntaxCheckResult::Valid)
        {
            LogError("Syntax error in script " + scriptSourceFilename + "," + QString::number(syntaxResult.errorLineNumber()) +
                ": " + syntaxResult.errorMessage());

            // Delete our loaded script content (if any exists).
            program_ == "";
        }
    }
}
JavascriptInstance::JavascriptInstance(const std::vector<ScriptAssetPtr>& scriptRefs, JavascriptModule *module) :
    engine_(0),
    module_(module),
    evaluated(false)
{
    // Make sure we do not push null or empty script assets as sources
    for (unsigned i = 0; i < scriptRefs.size(); ++i)
        if (scriptRefs[i] && !scriptRefs[i]->scriptContent.isEmpty()) scriptRefs_.push_back(scriptRefs[i]);
    
    CreateEngine();
    Load();
}
Esempio n. 10
0
int main(int argc,char **argv)
{

	HANDLE engine;
	uint32_t n;
	init_system_time(10);
	ip = argv[1];
	port = atoi(argv[2]);
	signal(SIGPIPE,SIG_IGN);
	if(InitNetSystem() != 0)
	{
		printf("Init error\n");
		return 0;
	}
	wpacket_allocator = (allocator_t)create_block_obj_allocator(SINGLE_THREAD,sizeof(struct wpacket));	

	uint32_t i = 0;
	init_clients();

	engine = CreateEngine();
	thread_run(_Listen,&engine);
	tick = GetSystemMs();
	while(1)
	{
		EngineRun(engine,100);
		now = GetSystemMs();
		if(now - tick > 1000)
		{
			printf("recv:%u,send:%u,s_req:%u,total_recv:%u\n",packet_recv,packet_send,send_request,total_bytes_recv/1024/1024);
			tick = now;
			packet_recv = 0;
			packet_send = 0;
			send_request = 0;
			iocp_count = 0;
			total_bytes_recv = 0;
			//printf("w:%d,r:%d,b:%d\n",wpacket_count,rpacket_count,buf_count);
		}
		/*
		if(now - last_send_tick > 10)
		{
			last_send_tick = now;
			for(i=0; i < MAX_CLIENT; ++i)
			{
				if(clients[i])
				{
					connection_send(clients[i],NULL,NULL);
				}
			}
		}*/
		
	}
	return 0;
}
Esempio n. 11
0
JavascriptInstance::JavascriptInstance(ScriptAssetPtr scriptRef, JavascriptModule *module) :
    engine_(0),
    module_(module),
    evaluated(false)
{
    // Make sure we do not push null or empty script assets as sources
    if (scriptRef && !scriptRef->scriptContent.isEmpty())
        scriptRefs_.push_back(scriptRef);
    
    CreateEngine();
    Load();
}
Esempio n. 12
0
void DrapeSurface::exposeEvent(QExposeEvent *e)
{
  Q_UNUSED(e);

  if (isExposed())
  {
    if (m_contextFactory.IsNull())
    {
      dp::ThreadSafeFactory * factory = new dp::ThreadSafeFactory(new QtOGLContextFactory(this));
      m_contextFactory = dp::MasterPointer<dp::OGLContextFactory>(factory);
      CreateEngine();
    }
  }
}
Esempio n. 13
0
CIEBrowserEngine::CIEBrowserEngine(HWND hParentWnd, HINSTANCE hInstance) :
        m_parentHWND(NULL),
        m_hparentInst(NULL),
        m_bLoadingComplete(FALSE),
        m_hNavigated(NULL),
        m_dwNavigationTimeout(0)
{
    m_parentHWND = hParentWnd;    
    m_hparentInst = hInstance;
    m_tabID = 0; //tabID;

    GetWindowRect(hParentWnd, &m_rcViewSize);

    m_tcNavigatedURL[0] = 0;

    CreateEngine();
}
Esempio n. 14
0
HRESULT EngineApp::Initialize(const ZString& strCommandLine, HWND hWindow )
{
    //
    // Initialize the pane code
    //

    Pane::Initialize();

    //
    // Parse the command line for device options
    //

    bool bSoftwareOnly;
    bool bPrimaryOnly;
    DWORD dwBPP = 0; // KGJV 32B - forced bpp, 16, 32 or 0 = use desktop
    ParseCommandLine(strCommandLine, bSoftwareOnly, bPrimaryOnly, dwBPP);

    //
    // Create the engine
    m_pengine = CreateEngine(!bSoftwareOnly, !bPrimaryOnly, dwBPP, hWindow );

    if (!m_pengine->IsValid()) {
        return E_FAIL;
    }

    //
    // Create the modeler
    //

    m_pmodeler = Modeler::Create(m_pengine);

    //
    // Create the popup container
    //

    m_ppopupContainer = CreatePopupContainer();

    return S_OK;
}
Esempio n. 15
0
int main(int argc,char **argv)
{

	HANDLE engine;
	uint32_t n;
	ip = argv[1];
	port = atoi(argv[2]);
	signal(SIGPIPE,SIG_IGN);
	init_system_time(10);
	if(InitNetSystem() != 0)
	{
		printf("Init error\n");
		return 0;
	}
	wpacket_allocator = (allocator_t)create_block_obj_allocator(SINGLE_THREAD,sizeof(struct wpacket));	
	engine = CreateEngine();
	thread_run(_Listen,&engine);
	while(1)
	{
		EngineRun(engine,100);
	}
	return 0;
}
Esempio n. 16
0
    void android_main(struct android_app* app)
    {
        // Make sure glue isn't stripped
        app_dummy();

        // Create application manager
        AppManager manager;
        app->userData = &manager;
        app->onAppCmd = engine_handle_cmd;
        app->onInputEvent = engine_handle_input;

        // Create x2d engine
        X2DEngine *engine = CreateEngine(0);
        engine->app  = new AndroidApp(&manager);
        engine->gfx = new AndroidRender(&manager);
        engine->sfx = new AndroidSound;
        engine->debug = new AndroidDebug;
        engine->assetLoader = new AndroidAssetLoader(&manager);
        // NOTE: engine->init() can be found in engine_handle_cmd

        manager.android = app;
        manager.engine = engine;
        manager.display = NULL;

        // Prepare to monitor accelerometer
        manager.sensorManager = ASensorManager_getInstance();
        manager.accelerometerSensor = ASensorManager_getDefaultSensor(manager.sensorManager, ASENSOR_TYPE_ACCELEROMETER);
        manager.sensorEventQueue = ASensorManager_createEventQueue(manager.sensorManager, app->looper, LOOPER_ID_USER, NULL, NULL);

        if(app->savedState != NULL)
        {
            // We are starting from a previous saved state; restore from it.
            manager.state = *(SaveState*)app->savedState;
        }

        // Loop waiting for stuff to do.
        while(true)
        {
            // Read all pending events.
            int ident;
            int events;
            struct android_poll_source* source;

            // If not animating, we will block forever waiting for events.
            // If animating, we loop until all events are read, then continue
            // to draw the next frame of animation.
            while((ident = ALooper_pollAll(manager.animating ? 0 : -1, NULL, &events, (void**)&source)) >= 0)
            {
                // Process this event.
                if (source != NULL)
                    source->process(app, source);

                // If a sensor has data, process it now.
                if(ident == LOOPER_ID_USER)
                {
                    if(manager.accelerometerSensor != NULL)
                    {
                        ASensorEvent event;
                        while(ASensorEventQueue_getEvents(manager.sensorEventQueue, &event, 1) > 0) {
                            iosystem::print("accelerometer: x=%f y=%f z=%f", event.acceleration.x, event.acceleration.y,  event.acceleration.z);
                        }
                    }
                }

                // Check if we are exiting.
                if(app->destroyRequested != 0)
                {
                    engine_term_display(&manager);
                    return;
                }
            }

            if(manager.display != NULL && manager.animating)
            {
                // Drawing is throttled to the screen update rate, so there
                // is no need to do timing here.
                //engine_draw_frame(&manager);
                engine->draw();
            }
        }
    }
Esempio n. 17
0
int main(int argc, const char **argv)
{
	// Command line parameters
	
	bool editor = false;
	core::stringc levelFileName;
	
// Mac passes a -psn (process serial number) argument when running from a .app directory,
// which messes this up. So we just ignore command line arguments on mac for now.
// Ideally though, we'd just strip that out and ignore it.
#ifndef __APPLE__
	if (argc == 3)
	{
		// Edit?
		if (core::stringc(argv[1]) == "-e")
		{
			editor = true;
			globalIsInEditor = true;
		}
		
		levelFileName = argv[2];
	}
	else if (argc == 2)
	{
		levelFileName = argv[1];
	}
#endif
	
	VariantMap settings;
	settings["appName"] = "Puzzle Moppet";
	settings["screenWidth"] = 1024;
	settings["screenHeight"] = 768;
	settings["fullScreen"] = false;
	
	IEngine *engine = CreateEngine(argc, argv, &settings);
	
	
	
	
	engine->GetIrrlichtDevice()->getFileSystem()->addFileArchive(PROJECT_DIR"/Puzzle/media/");
	
	
	IWorld *world = engine->GetWorld();
	IRenderSystem *renderSystem = engine->GetRenderSystem();
	
	renderSystem->SetShaderLevel(ESL_LOW);
	
	
	// Loading text. Hacked in! Uses add_static_text2 from MainState.cpp
	
	{
		video::IVideoDriver *driver = engine->GetIrrlichtDevice()->getVideoDriver();
		gui::IGUIEnvironment *guienv = engine->GetIrrlichtDevice()->getGUIEnvironment();
		
		s32 screenHeight = driver->getScreenSize().Height;
		s32 screenWidth = driver->getScreenSize().Width;
		
		gui::IGUIElement *loadingGUI = add_static_text(L"Loading...");
		core::rect<s32> rect = loadingGUI->getRelativePosition();
		rect += core::vector2di( screenWidth/2 - rect.getWidth()/2, screenHeight/2 - rect.getHeight()/2 );
		loadingGUI->setRelativePosition(rect);
		
		// Render the gui once.
		driver->beginScene(true, true, video::SColor(0,0,0,0));
		guienv->drawAll();
		driver->endScene();
		
		// We can remove the element now we've rendered.
		loadingGUI->remove();
	}
	
	
	// Set up post processing.
	if (renderSystem->ShadersAreAvailable()
			&& renderSystem->PostProcessingEnabled())
	{
		// bool flag indicates whether rendering to screen still occurs first before post processing
		IPostProcessingChain *chain = renderSystem->CreatePostProcessingChain(true);
		
		// Materials need:
		// - Lighting = false
		// - ZBuffer = false
		// - ZWriteEnable = false
		
		// For bloom, need:
		// - bright filter
		// - BlurH
		// - BlurV
		// (final one blended additively on to the screen)
		
		
		video::SMaterial material;
		material.Lighting		= false;
		material.ZBuffer		= false;
		material.ZWriteEnable	= false;
		material.AntiAliasing	= video::EAAM_OFF;
		
		IShader *shader;
		
		// Bright filter
		shader = renderSystem->CreateShader("ScreenQuad.vert", "Brightfilter.frag");
		chain->AddEffect(material, shader, 2);
		shader->drop();
		
		// Horizontal blur
		shader = renderSystem->CreateShader("ScreenQuad.vert", "BlurH.frag");
		chain->AddEffect(material, shader, 2);
		shader->drop();
		
		// Vertical blur
		// As this is the last effect it is rendered additively on to the screen.
		shader = renderSystem->CreateShader("ScreenQuad.vert", "BlurV.frag", video::EMT_TRANSPARENT_ADD_COLOR);
		chain->AddEffect(material, shader, 2);
		shader->drop();
		
		renderSystem->SetActivePostProcessingChain(chain);
		chain->drop();
	}
	
	// Some sky
	// Maybe this should be in Level?
	// --> move it only when it is needed...
	
	core::stringc skyDir = "skies/Set 42/";
	core::stringc skyExt = "png";
	
	world->SetSkyBox(
			skyDir+"6."+skyExt,
			skyDir+"5."+skyExt,
			skyDir+"1."+skyExt,
			skyDir+"3."+skyExt,
			skyDir+"2."+skyExt,
			skyDir+"4."+skyExt
			);
	
	// load sky effects enabled flag
	{
		VariantMap creationSettings = engine->GetCreationSettings();
		
		if (creationSettings.count("skyEffects"))
			skyEffectsEnabled = creationSettings["skyEffects"];
		else
			skyEffectsEnabled = true;
	}
	
	if (renderSystem->ShadersAreAvailable() && skyEffectsEnabled)
	{
		IShader *skyShader = renderSystem->CreateShader("SkyBox.vert", "SkyBox.frag", video::EMT_SOLID);
		
		LowLevelShaderRegisterMap rmap;
		rmap.PushSingleRegister("rippleScroll", "brightness", nullptr,nullptr);
		
		skyShader->SetPixelRegisterMap(rmap);
		
		IShaderCallback *skyShaderCallback = new SkyBoxShaderCallback(engine);
		skyShader->SetCallback( skyShaderCallback );
		skyShaderCallback->drop();
		
		world->SetSkyBoxShader(skyShader);
		skyShader->drop();
		
		// sky box ripple texture !!
		
		video::IVideoDriver *driver = engine->GetIrrlichtDevice()->getVideoDriver();
		video::ITexture *rippleTexture = driver->getTexture("cloudshadow.png");
		
		for (u8 i = 0; i < 6; i ++)
			world->GetSkyBoxMaterial(i).setTexture(1, rippleTexture);
	}
	
	
	// ********** PRELOAD EVERYTHING!! ***********
	
	NOTE << "Preloading media...";
	
	// Meshes
	{
		scene::ISceneManager *smgr = engine->GetIrrlichtDevice()->getSceneManager();
		smgr->getMesh("ground_single_sideless.b3d");
		smgr->getMesh("ground_single.b3d");
		smgr->getMesh("ground_single_fall.b3d");
		smgr->getMesh("box.b3d");
		smgr->getMesh("icybox.irrmesh");
		smgr->getMesh("icybox_inner.irrmesh");
		smgr->getMesh("balloon.irrmesh");
		smgr->getMesh("magicfan_base.b3d");
		smgr->getMesh("magicfan_blades.b3d");
		smgr->getMesh("magicfan_orb.irrmesh");
		smgr->getMesh("lift.b3d");
		smgr->getMesh("lift_glow.irrmesh");
		smgr->getMesh("nothing.irrmesh");
		smgr->getMesh("teleport.irrmesh");
		smgr->getMesh("player.b3d");
		smgr->getMesh("sea.b3d");
		smgr->getMesh("land.irrmesh");
		smgr->getMesh("cliff.irrmesh");
		smgr->getMesh("titletext.b3d");
		smgr->getMesh("gridarrow.irrmesh");
	}
	
	// Textures (stand alone, others are loaded with meshes)
	{
		video::IVideoDriver *driver = engine->GetIrrlichtDevice()->getVideoDriver();
		driver->getTexture("brass_spheremap.png");
		driver->getTexture("watersand.png");
		driver->getTexture("water.png");
		driver->getTexture("watersand_add.png");
		driver->getTexture("dust.png");
		driver->getTexture("sparkle.png");
		driver->getTexture("fog.png");
		driver->getTexture("cloudshadow.png");
		driver->getTexture("mud.jpg");
		
		// Final sky box textures
		{
			core::stringc skyDir = "skies/Set 26/final_";
			core::stringc skyExt = "png";
			driver->getTexture(skyDir+"6."+skyExt);
			driver->getTexture(skyDir+"5."+skyExt);
			driver->getTexture(skyDir+"1."+skyExt);
			driver->getTexture(skyDir+"3."+skyExt);
			driver->getTexture(skyDir+"2."+skyExt);
			driver->getTexture(skyDir+"4."+skyExt);
		}
	}
	
	// Fonts
	{
		gui::IGUIEnvironment *guienv = engine->GetIrrlichtDevice()->getGUIEnvironment();
		guienv->getFont("font2.xml");
		guienv->getFont("fontlarge2.xml");
	}
	
	// Sounds
	{
		ISoundSystem *soundSystem = engine->GetSoundSystem();
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/sea.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/beep.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/fallblock.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/buttonflutter_micro.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/hithard.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/liftrun.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/balloonpush.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/slide.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/windy.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/speedcore.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/bell.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/stepballoon.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/step.ogg");
		
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/appear.ogg");
		
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/laugh.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/fair.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/good.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/excellent.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/perfect.ogg");
		soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/sfx/extraordinary.ogg");
		
		//soundSystem->PreloadSound(PROJECT_DIR"/Puzzle/media/music.ogg");
	}
	
	// Shaders!?
	/*
	if (renderSystem->ShadersAreAvailable())
	{
		IShader *shader;
		
		shader = renderSystem->CreateShader("Hemisphere.vert", "Hemisphere.frag", video::EMT_SOLID);
		shader->drop();
		
		shader = renderSystem->CreateShader("HemisphereBalloon.vert", "HemisphereBalloon.frag", video::EMT_SOLID);
		shader->drop();
		
		shader = renderSystem->CreateShader("HemisphereLand.vert", "Hemisphere.frag", video::EMT_SOLID);
		shader->drop();
		
		shader = renderSystem->CreateShader("Hemisphere.vert", "HemisphereWood.frag", video::EMT_SOLID);
		shader->drop();
		
		shader = renderSystem->CreateShader("PlainWithAlpha.vert", "PlainWithAlpha.frag", video::EMT_SOLID);
		shader->drop();
	}
	*/
	
	NOTE << "Finished preloading!";
	
	
	// Default sound volume
	engine->GetSoundSystem()->SetGlobalVolume(5.0);
	
	
	// background sfx
	bgAmbientSound = engine->GetSoundSystem()->CreateSound2D();
	bgAmbientSound->SetIsLooped(true);
	//bgAmbientSound->SetVolume(0.035);
	
	bgMusic = engine->GetSoundSystem()->CreateSound2D();
	bgMusic->SetIsLooped(true);
	
	// Load sfx volume
	set_volumes_from_settings(engine->GetCreationSettings());
	
	bgAmbientSound->Play(PROJECT_DIR"/Puzzle/media/sfx/windy.ogg");
	bgMusic->Play(PROJECT_DIR"/Puzzle/media/sfx/speedcore.ogg");
	
	// load default movement type
	{
		VariantMap creationSettings = engine->GetCreationSettings();
		
		if (creationSettings.count("gridBasedMovement"))
			gridBasedMovement = creationSettings["gridBasedMovement"];
		else
			gridBasedMovement = true;
		
		// mouse axis inversion?
		
		if (creationSettings.count("invertMouseX"))
			invertMouseX = creationSettings["invertMouseX"];
		else
			invertMouseX = false;
		
		if (creationSettings.count("invertMouseY"))
			invertMouseY = creationSettings["invertMouseY"];
		else
			invertMouseY = false;
	}
	
	
	// Now, instead of going straight into the game we have a start screen.
	// ...unless the game was started by command line, in which case we jump straight in.
	
	MainState *mainState = nullptr;
	
	if (levelFileName.size())
	{
		NOTE << "Started with command line parameter, will skip start screen.";
		mainState = new MainState(&mainState);
		mainState->StartLevel(levelFileName, editor);
	}
	else
	{
		NOTE << "Entering start screen...";
		// StartScreen *MAY* create a MainState, returning the pointer to mainState
		// so that we can delete it from here in main.cpp
		// (why do we want to delete it from main? because we always have...)
		StartScreen *startScreen = new StartScreen(&mainState);
		engine->GetLogicUpdater().AddUpdatable(startScreen);
		startScreen->drop();
	}
	
	// Main loop
	engine->Run();
	
	// MainState may not exist if StartScreen was entered but no level was played.
	if (mainState)
		delete mainState;
	
	if (bgAmbientSound)
		bgAmbientSound->drop();
	
	if (bgMusic)
		bgMusic->drop();

	engine->drop();
		
	return 0;
}
Esempio n. 18
0
NET_ERROR_CODE SFEngine::Intialize(ILogicEntry* pLogicEntry, ILogicDispatcher* pDispatcher)
{
	LOG(INFO) << "Engine Initialize... ";

	SetLogFolder();	

	if (NULL == pLogicEntry)
		return NET_ERROR_CODE::ENGINE_INIT_LOGIC_ENTRY_NULL;	

	if (pDispatcher == NULL)
	{
		pDispatcher = new SFCasualGameDispatcher();
	}

	SetLogicDispathcer(pDispatcher);

	m_pServerConnectionManager = new SFServerConnectionManager();

	LOG(INFO) << "Logic Entry Initialize";
	if (false == pLogicEntry->Initialize())
	{
		LOG(ERROR) << "LogicEntry Intialize Fail!!";
		return NET_ERROR_CODE::ENGINE_INIT_LOGIC_ENTRY_FAIL;
	}
	
	
	_EngineConfig* pInfo = m_Config.GetConfigureInfo();
	
	LOG(INFO) << "Basic Port: " << pInfo->serverPort;

	std::string szNetworkEngineName = StringConversion::ToASCII(pInfo->engineName);
	LOG(INFO) << "NetworkEngine Create : " << szNetworkEngineName.c_str();

	LOG(INFO) << "MaxAccept : " << pInfo->maxAccept;

	if (pInfo->maxAccept <= 0 || pInfo->maxAccept > MAX_USER_ACCEPT)
	{
		LOG(WARNING) << "MaxAccept Value Abnormal : " << pInfo->maxAccept;
		SetMaxUserAccept(DEFALUT_USER_ACCEPT);
	}
	else
		SetMaxUserAccept(pInfo->maxAccept);
		
	auto errorCode = CreateEngine((char*)szNetworkEngineName.c_str(), true);
	if (errorCode != NET_ERROR_CODE::SUCCESS)
	{
		LOG(ERROR) << "NetworkEngine : " << szNetworkEngineName.c_str() << " Creation FAIL!!";
		return errorCode;
	}

	LOG(INFO) << "NetworkEngine : " << szNetworkEngineName.c_str() << " Creation Success!!";

	if (false == pDispatcher->CreateLogicSystem(pLogicEntry))
	{
		LOG(ERROR) << "Logic System Creation FAIL!!";
		return NET_ERROR_CODE::ENGINE_INIT_CREAT_LOGIC_SYSTEM_FAIL;
	}

	CreatePacketSendThread();

	LOG(INFO) << "Engine Initialize Complete!! ";
	return NET_ERROR_CODE::SUCCESS;
}
Esempio n. 19
0
//-------------------------------- Framework ----------------------------------
//
// The Framework constructor creates the Context and Engine Objects
//
Framework::Framework(void* hinst, int show) {

    context = CreateContext();
    engine  = CreateEngine(hinst, show, context);
}
Esempio n. 20
0
bool Compiler::Compile() {
    return CompileInstructions() &&
           VerifyModule() &&
           OptimizeModule() &&
           CreateEngine();
}