Ejemplo n.º 1
0
void DashboardInstrument_Compass::DrawBackground(wxBufferedDC* dc)
{
      wxPen pen;

//      wxBrush brushHatch(*wxLIGHT_GREY, wxTRANSPARENT);

      // Now draw the boat
      wxColour cl;
      GetGlobalColor(_T("GREY1"), &cl);
      pen.SetStyle(wxSOLID);
      pen.SetColour(cl);
      dc->SetPen(pen);
      GetGlobalColor(_T("GREY2"), &cl);
      dc->SetBrush(cl);

      wxPoint points[7];

/*
 *           0
 *          /\
 *         /  \
 *        /    \
 *     6 /      \ 1
 *      |   X    |
 *      |        |
 *    5 |        | 2
 *       \      /
 *        \__ _/
 *        4    3
 */
      points[0].x = m_cx;
      points[0].y = m_cy - m_radius * .50; // a little bit longer than compass rose
      points[1].x = m_cx + m_radius * .15;
      points[1].y = m_cy;
      points[2].x = m_cx + m_radius * .15;
      points[2].y = m_cy + m_radius * .20;
      points[3].x = m_cx + m_radius * .10;
      points[3].y = m_cy + m_radius * .40;
      points[4].x = m_cx - m_radius * .10;
      points[4].y = m_cy + m_radius * .40;
      points[5].x = m_cx - m_radius * .15;
      points[5].y = m_cy + m_radius * .20;
      points[6].x = m_cx - m_radius * .15;
      points[6].y = m_cy;

      dc->DrawPolygon(7, points, 0, 0);

      DrawCompassRose(dc);
}
Ejemplo n.º 2
0
void TacticsInstrument_Compass::DrawBackground(wxGCDC* dc)
{
    DrawBoat( dc, m_cx, m_cy, m_radius );
    DrawCompassRose( dc, m_cx, m_cy, 0.7 * m_radius, m_AngleStart, true );
}
Ejemplo n.º 3
0
void TacticsInstrument_WindCompass::DrawBackground(wxGCDC* dc)
{
      DrawCompassRose(dc, m_cx, m_cy, m_radius * 0.85, m_AngleStart, false);
}
Ejemplo n.º 4
0
void gameDialog::render() {
	static bool first = true; // Only true first time function is called
	// Clear list of special effects. It will be added again automatically every frame
	gShadows.Clear();
	gFogs.Clear();
	gPlayer.UpdatePositionSmooth();

	// Can't select objects that are dead
	if (fSelectedObject && (fSelectedObject->IsDead() || !fSelectedObject->InGame()))
		ClearSelection();
	glm::vec3 playerOffset = gPlayer.GetOffsetToChunk();

	gViewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -fCameraDistance));
	gViewMatrix = glm::rotate(gViewMatrix, _angleVert, glm::vec3(1.0f, 0.0f, 0.0f));
	gViewMatrix = glm::rotate(gViewMatrix, _angleHor, glm::vec3(0.0f, 1.0f, 0.0f));
	gViewMatrix = glm::translate(gViewMatrix, -playerOffset);

	glm::mat4 T1 = glm::translate(glm::mat4(1), playerOffset);
	glm::mat4 R1 = glm::rotate(glm::mat4(1), _angleVert, glm::vec3(-1.0f, 0.0f, 0.0f));
	glm::mat4 R2 = glm::rotate(glm::mat4(1), _angleHor, glm::vec3(0.0f, -1.0f, 0.0f));
	glm::mat4 T2 = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, fCameraDistance));
	glm::vec4 camera = T1 * R2 * R1 * T2 * glm::vec4(0,0,0,1);
	gUniformBuffer.Camera(camera);

	gDrawnQuads = 0;
	gNumDraw = 0;

	gUniformBuffer.Update();

	if (first) {
		gBillboard.InitializeTextures(fShader);
	}

	fRenderControl->Draw(fSelectedObject, fUnderWater, this->ThirdPersonView(), fSelectedObject, fDrawMap && !gDebugOpenGL, fMapWidth);

	//=========================================================================
	// Various effects drawn after the deferred shader
	//=========================================================================

	if (!fDrawMap) {
		this->DrawPlayerStats();
		if (fShowWeapon && gMode.Get() != GameMode::CONSTRUCT && !fShowInventory && !this->ThirdPersonView())
			this->DrawWeapon();
		static bool wasDead = false;
		if (gPlayer.IsDead() && !wasDead) {
			wasDead = true;
			fShowMainDialog = true;
			fHideDialog = false;
			dialog::DispatchDraw(fDrawTexture, 1.0f, new MessageDialog("Oops", "You are dead.\n\nYou will be revived, and transported back to your starting place.\n\nThe place can be changed with a scroll of resurrection point.", revive));
			this->ClearForDialog();
		} else if (fShowInventory)
			gInventory.DrawInventory(fDrawTexture);
		else if (fShowMainDialog)
			dialog::DispatchDraw(fDrawTexture, fHideDialog ? 0.5f : 1.0f);
		else if (sgPopup.length() > 0) {
			// There are some messages that shall be shown in a popup dialog.
			fShowMainDialog = true;
			fHideDialog = false;
			dialog::DispatchDraw(fDrawTexture, 1.0f, new MessageDialog(sgPopupTitle, sgPopup, 0));
			sgPopupTitle = "Ephenation"; // Reset to default.
			sgPopup.clear();
			this->ClearForDialog();
		}

		if (!gPlayer.IsDead())
			wasDead = false;
		DrawCompassRose();
	}

	if (fDrawMap && gDebugOpenGL) {
		// Very inefficient algorithm, computing the map every frame.
		std::unique_ptr<Map> map(new Map);
		float alpha = 1.0f;
		if (!sShowAlternateBitmap)
			sTextureIterator = gDebugTextures.begin();
		glBindTexture(GL_TEXTURE_2D, *sTextureIterator); // Override
		map->Draw(alpha);
	}

	if (fSelectedObject) {
		fSelectedObject->RenderHealthBar(fHealthBar, _angleHor);
	}
	gOtherPlayers.RenderPlayerStats(fHealthBar, _angleHor);
	bool newHealing = false;
	if (gPlayer.fFlags & UserFlagHealed) {
		newHealing = true;
		gPlayer.fFlags &= ~UserFlagHealed;
	}
	this->DrawHealingAnimation(newHealing);

	char buff[1000]; // TODO: Ugly way to create dynamic strings
	static double slAverageFps = 0.0;
	double tm = gCurrentFrameTime;
	static double prevTime = 0.0;
	double deltaTime = tm - prevTime;
	// Use a decay filter on the FPS
	slAverageFps = 0.97*slAverageFps + 0.03/deltaTime;
	prevTime = tm;

	if (gMode.Get() == GameMode::TELEPORT) {
		TeleportClick(fHealthBar, _angleHor, renderViewAngle, 0, 0, false);
	}

	//=========================================================================
	// Various text messages
	//=========================================================================
	{
		// A big chunk with text drawing. But first some background to improve contrast.
		int yOffset = Options::fgOptions.fFontSize*2;
		float totalWinHeight = gViewport[3]; // Measured in pixels
		glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(-1.0f, 1.0f - yOffset*2/totalWinHeight, 0.0f));
		float yScale = yOffset*2/totalWinHeight;
		model = glm::scale(model, glm::vec3(2.0f, yScale, 1.0f));
		this->fHealthBar->DrawSquare(model, 0.0f, 0.0f, 0.0f, 0.3f); // Draw a black square, almost transparent, as a background

		gDrawFont.Enable();
		gDrawFont.UpdateProjection();
		sprintf(buff, "Level %ld, Hp %d%%, Exp %d%%", gPlayer.fLevel, (int)(gPlayer.fHp * 100), (int)(gPlayer.fExp * 100));
		gDrawFont.vsfl.prepareSentence(fPlayerStatusSentence, buff);
		int w = int(strlen(buff)*Options::fgOptions.fFontSize*0.8f); // An approximation
		gDrawFont.SetOffset(gViewport[2]-w, 0);
		gDrawFont.vsfl.renderSentence(fPlayerStatusSentence);

		if (gCurrentPing == 0.0)
			sprintf(buff, "Triangles %7d, draw calls %d. Fps %03d", gDrawnQuads, gNumDraw, int(slAverageFps));
		else
			sprintf(buff, "Triangles %7d, draw calls %d. Fps %03d, ping %.1f ms", gDrawnQuads, gNumDraw, int(slAverageFps), gCurrentPing*1000.0);
		gDrawFont.SetOffset(0,0);
		gDrawFont.vsfl.prepareSentence(fFPSsentence, buff);
		gDrawFont.vsfl.renderSentence(fFPSsentence);
		if (gMode.Get() == GameMode::CONSTRUCT) {
			ChunkCoord cc;
			gPlayer.GetChunkCoord(&cc);
			const chunk *cp = ChunkFind(&cc, false);
			unsigned int uid = 1000000;
			shared_ptr<ChunkBlocks> cb;
			if (cp)
				cb = cp->fChunkBlocks;
			if (cb)
				uid = cb->fOwner;
			gDrawFont.SetOffset(0,float(yOffset));
			sprintf(buff, "Construction mode, Chunk (%d,%d,%d) offset: %.1f,%.1f,%.1f, coord(%.1f,%.1f,%.1f) owner %d",
			        cc.x, cc.y, cc.z, playerOffset.x, playerOffset.y, playerOffset.z, gPlayer.x/100.0, gPlayer.y/100.0, gPlayer.z/100.0, uid);
			gDrawFont.vsfl.renderAndDiscard(buff);
		}

		if (fEnterDebugText) {
			int bottomLine = gViewport[3]-25;
			gDrawFont.SetOffset(0, float(bottomLine));
			gDrawFont.vsfl.renderSentence(fInputPromptSentence);
		}
		gDrawFont.Disable();
		gScrollingMessages.Update();
	}

	if (!fDrawMap && !fShowInventory && (!fShowMainDialog || fHideDialog)) {
		if (gShowMsgWindow)
			gMsgWindow.Render();

		if (gMode.Get() == GameMode::CONSTRUCT)
			fBuildingBlocks->Draw(gProjectionMatrix);
	}

	if (gDebugOpenGL) {
		checkError("gameDialog::render debug", false);
		static double prevPrint = 0.0;
		if (gCurrentFrameTime > prevPrint + 5.0) {
			if (gToggleTesting)
				WorstTime::Report();
			else
				TimeMeasure::Report();
			prevPrint = gCurrentFrameTime;
		}
	}
	chunk::DegradeBusyList_gl();
	first = false;
}