Example #1
0
bool ConsoleFinder::FindConsole(const wxString &title, wxString &consoleName)
{
	int pid = RunConsole(title);
	if (pid > 0) {
		consoleName = m_ConsoleTty;
		return true;
	}
	return false;
}
STDMETHODIMP CContextMenuHandler::InvokeCommand(CMINVOKECOMMANDINFO *pici)
{
	f_log(__FUNCTION__);

	BOOL fEx = FALSE;
	BOOL fUnicode = FALSE;

	if (pici->cbSize = sizeof(CMINVOKECOMMANDINFOEX)) {
		fEx = TRUE;
		if ((pici->fMask & CMIC_MASK_UNICODE)) {
			fUnicode = TRUE;
		}
	}

	if (!fUnicode && HIWORD(pici->lpVerb)) {
		if (StrCmpIA(pici->lpVerb, szVerbRunConsoleA) == 0) {
			if (!sPath.IsEmpty()) {
				RunConsole(sPath, false);
			}
			return S_OK;
		}
		else if (StrCmpIA(pici->lpVerb, szVerbPostConsoleA) == 0) {
			if (!sPath.IsEmpty()) {
				RunConsole(sPath, true);
			}
			return S_OK;
		}
		return E_FAIL;
	}
	
	if (fUnicode && HIWORD(reinterpret_cast<CMINVOKECOMMANDINFOEX*>(pici)->lpVerbW)) {
		if (StrCmpIW(reinterpret_cast<CMINVOKECOMMANDINFOEX*>(pici)->lpVerbW, szVerbRunConsoleW) == 0) {
			if (!sPath.IsEmpty()) {
				RunConsole(sPath, false);
			}
			return S_OK;
		}
		else if (StrCmpIW(reinterpret_cast<CMINVOKECOMMANDINFOEX*>(pici)->lpVerbW, szVerbRunConsoleW) == 0) {
			if (!sPath.IsEmpty()) {
				RunConsole(sPath, true);
			}
			return S_OK;
		}
		return E_FAIL;
	}

	if (LOWORD(pici->lpVerb) == eMC_RunConsole) {
		// Run console with default tab
		if(!sPath.IsEmpty())
		{
			RunConsole(sPath, false);
		}
	}
	else if (LOWORD(pici->lpVerb) == eMC_PostConsole) {
		// Run console with default tab
		if(!sPath.IsEmpty())
		{
			RunConsole(sPath, true);
		}
	}
	else if (LOWORD(pici->lpVerb) >= eMC_RunConsoleWithTab && LOWORD(pici->lpVerb) < eMC_RunConsoleWithTab + 50) {
		// Run console with specified tab
		if (!sPath.IsEmpty()) {
			wstring sTabName;

			// get tab name
			{
				// synchronization
				syncAutoLock oLock(g_oSync);

				if ((LOWORD(pici->lpVerb) - eMC_RunConsoleWithTab) < (int)g_vTabs.size())
					sTabName = g_vTabs[LOWORD(pici->lpVerb) - eMC_RunConsoleWithTab]->sName;
			}

			// run
			RunConsole(sPath, false, sTabName.c_str());
		}
	}
	else if (LOWORD(pici->lpVerb) >= eMC_PostConsoleWithTab && LOWORD(pici->lpVerb) < eMC_PostConsoleWithTab + 50) {
		// Run console with specified tab
		if (!sPath.IsEmpty()) {
			wstring sTabName;

			// get tab name
			{
				// synchronization
				syncAutoLock oLock(g_oSync);

				if ((LOWORD(pici->lpVerb) - eMC_PostConsoleWithTab) < (int)g_vTabs.size())
					sTabName = g_vTabs[LOWORD(pici->lpVerb) - eMC_PostConsoleWithTab]->sName;
			}

			// run
			RunConsole(sPath, true, sTabName.c_str());
		}
	}

	return S_OK;
}
//----------------------------------------------------------------------------
bool NonlocalBlowup::OnInitialize ()
{
    if (!WindowApplication3::OnInitialize())
    {
        return false;
    }
#ifdef RUN_CONSOLE
    RunConsole();
    return false;
#endif

    mScene = new0 Node();
    mScene->LocalTransform.SetRotate(HMatrix(
        0.80475128f, 0.59107417f, -0.054833174f, 0.0f,
        -0.17529237f, 0.32487807f, 0.92936903f, 0.0f,
        0.56714010f, -0.73829913f, 0.36505684f, 0.0f,
        0.0f, 0.0f, 0.0f, 1.0f));
    mWireState = new0 WireState();
    mRenderer->SetOverrideWireState(mWireState);

    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);

    TriMesh* mesh = StandardMesh(vformat).Rectangle(256, 256, 16.0f, 16.0f);
    mScene->AttachChild(mesh);

    std::string gridName = Environment::GetPathR("Grid.wmtf");
    Texture2D* gridTexture = Texture2D::LoadWMTF(gridName);
    gridTexture->GenerateMipmaps();

    Texture1D* colorTexture = new0 Texture1D(Texture::TF_A8R8G8B8, 8, 1);
    unsigned char* color = (unsigned char*)colorTexture->GetData(0);
    color[ 0] = 128;  color[ 1] = 128;  color[ 2] = 128;  color[ 3] = 255;
    color[ 4] = 255;  color[ 5] =   0;  color[ 6] = 128;  color[ 7] = 255;
    color[ 8] = 255;  color[ 9] =   0;  color[10] =   0;  color[11] = 255;
    color[12] =   0;  color[13] = 255;  color[14] =   0;  color[15] = 255;
    color[16] =   0;  color[17] = 255;  color[18] = 255;  color[19] = 255;
    color[20] =   0;  color[21] = 128;  color[22] = 255;  color[23] = 255;
    color[24] =   0;  color[25] =   0;  color[26] = 255;  color[27] = 255;
    color[28] = 255;  color[29] = 255;  color[30] = 255;  color[31] = 255;

    float dt = 0.01f, dx = 1.0f, dy = 1.0f;
    // Uncomment only one of these at a time.
    NonconvexDomain0p50(dt, dx, dy);
    //SquareSymmetric0p01(dt, dx, dy);
    //SquareSymmetric0p50(dt, dx, dy);
    //SquareSymmetric0p99(dt, dx, dy);
    //SquareGaussX0p50(dt, dx, dy);
    //SquareGaussXY0p50(dt, dx, dy);
    //SquareGaussFour0p50(dt, dx, dy);

    DisplacementEffect* effect = new0 DisplacementEffect();
    mesh->SetEffectInstance(effect->CreateInstance(mHeightTexture,
        gridTexture, colorTexture, mDomainTexture));

    // Set up the camera so that it looks at the graph from slightly above
    // the xy-plane and at a skewed angle/direction of view.
    mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 10000.0f);
    APoint camPosition(0.0f, 3.46f, 42.97f);
    AVector camDVector(0.0f, 0.0f, -1.0f);
    AVector camUVector(0.0f, 1.0f, 0.0f);
    AVector camRVector = camDVector.Cross(camUVector);
    mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);

    // Initial update of objects.
    mScene->Update();

    // Initial culling of scene.
    mCuller.SetCamera(mCamera);
    mCuller.ComputeVisibleSet(mScene);

    InitializeCameraMotion(0.01f, 0.01f);
    InitializeObjectMotion(mScene);
    return true;
}