///	Funktion erstellt zur aktuellen Mouse-Position einen HTML Tooltip
/// @return	der erstellte Tooltip-Text
CString CShipDesignMenuView::CreateTooltip(void)
{
	if (!m_pShownShip)
		return "";

	CBotEDoc* pDoc = resources::pDoc;
	ASSERT(pDoc);

	if (!pDoc->m_bDataReceived)
		return "";

	// Wo sind wir
	CPoint pt;
	GetCursorPos(&pt);
	ScreenToClient(&pt);
	CalcLogicalPoint(pt);

	if (CRect(388, 90, 388 + 200, 90 + 150).PtInRect(pt))
	{
		// Schiff erzeugen und Spezialforschungen einbeziehen
		CShips ship(pDoc->m_ShipInfoArray[m_pShownShip->GetID() - 10000]);
		pDoc->AddSpecialResearchBoniToShip(&ship, m_pPlayersRace);
		return ship.GetTooltip();
	}

	return "";
}
Пример #2
0
LRESULT CMainFrame::ShowCombatView(WPARAM /*wParam*/, LPARAM /*lParam*/)
{
    MYTRACE("general")(MT::LEVEL_INFO, "Getting Message to Show CombatView...");

    CBotEDoc* pDoc = resources::pDoc;
    AssertBotE(pDoc);

    // Combat View anzeigen
    FullScreenMainView(true);
    SelectMainView(VIEWS::COMBAT_VIEW, pDoc->GetPlayersRaceID());
    // wurde Rundenende geklickt zurücksetzen
    resources::pClientWorker->SetToEmpireViewFor(*pDoc->GetPlayersRace());
    pDoc->m_bRoundEndPressed = false;
    pDoc->m_bDataReceived = true;

    // Zuletzt gedrückten Button zurücksetzen
    CCombatMenuView* pView = ((CCombatMenuView*)GetView(RUNTIME_CLASS(CCombatMenuView)));
    pView->OnNewRound();

    pDoc->UpdateAllViews(NULL);

    MYTRACE("general")(MT::LEVEL_INFO, "Showing CombatView\n");

    return TRUE;
}
Пример #3
0
void CRandomEventCtrl::CalcExploreEvent(const CPoint &ko, CMajor *pRace, CShipMap* ships) const
{
	if (!IsActivated())
		return;

	if(rand() % 99 >= static_cast<int>(m_uiGlobalProb))
		return; //Es findet kein Ereignis statt

	CBotEDoc* pDoc = resources::pDoc;
	AssertBotE(pDoc);

	//ko=Koordinate wo es passiert, pRace = die Rasse der es passiert
	int eventnumber=rand()%2;
	CString sMessageText = "";
	EMPIRE_NEWS_TYPE::Typ typ = EMPIRE_NEWS_TYPE::NO_TYPE;

	if (eventnumber == ALIENTEC)
	{
		// Forschung insgesamt um (50 bis 150) * Anzahl Systeme erhöhen
		int nSystemCount = pRace->GetEmpire()->GetSystemList()->GetSize();
		int nAdd = (50 + rand()%101) * nSystemCount;
		pRace->GetEmpire()->AddFP(nAdd);

		const CString& sSectorName = pDoc->GetSystem(ko.x, ko.y).CoordsName(true);

		sMessageText = CLoc::GetString("ALIENTEC",false,sSectorName);
		typ = EMPIRE_NEWS_TYPE::RESEARCH;

		if (pRace->IsHumanPlayer())
		{
			const boost::shared_ptr<CEventRandom> EmpireEvent = boost::make_shared<CEventRandom>(
				pRace->GetRaceID(),"alientech",CLoc::GetString("ALIENTECHEADLINE"),CLoc::GetString("ALIENTECLONG",false,sSectorName));
			pRace->GetEmpire()->PushEvent(EmpireEvent);
		}
	}
	else if(eventnumber == EVENTSHIPXP)
	{
		for (CShipMap::iterator i = ships->begin(); i != ships->end(); ++i)
		{
			if (i->second->OwnerID() == pRace->GetRaceID() && i->second->GetCo()==ko)
			{
				const int additional_experience = rand() % 401 + 50;
				i->second->SetCrewExperiance(additional_experience);
			}
		}

		sMessageText = CLoc::GetString("EVENTSHIPXP",false,pDoc->GetSystem(ko.x, ko.y).CoordsName(true));
		typ = EMPIRE_NEWS_TYPE::MILITARY;
	}

	if (!sMessageText.IsEmpty())
	{
		CEmpireNews message;
		message.CreateNews(sMessageText,typ,"",ko);//Nachricht erstellen
		pRace->GetEmpire()->AddMsg(message);

		resources::pClientWorker->SetToEmpireViewFor(*pRace);
	}
}
Пример #4
0
void CMainFrame::SelectMainView(VIEWS::MAIN_VIEWS whichView, const CString& sRace)
{
    if (sRace.IsEmpty())
        return;

    AssertBotE(VIEWS::NULL_VIEW <= whichView && whichView <= VIEWS::COMBAT_VIEW);

    CBotEDoc* pDoc = resources::pDoc;
    AssertBotE(pDoc);

    if (pDoc->GetPlayersRaceID() == sRace)
    {
        resources::pClientWorker->SetSelectedViewForTo(sRace, whichView);
        // konnte in die neue View gewechselt werden
        if (m_wndSplitter.SwitchView(whichView, 0, 1))
        {
            switch (whichView)
            {
            case VIEWS::SYSTEM_VIEW:
                SelectBottomView(VIEWS::PLANET_BOTTOM_VIEW);
                break;
            case VIEWS::RESEARCH_VIEW:
                SelectBottomView(VIEWS::RESEARCH_BOTTOM_VIEW);
                break;
            case VIEWS::INTEL_VIEW:
                SelectBottomView(VIEWS::INTEL_BOTTOM_VIEW);
                break;
            case VIEWS::DIPLOMACY_VIEW:
                SelectBottomView(VIEWS::DIPLOMACY_BOTTOM_VIEW);
                break;
            case VIEWS::TRADE_VIEW:
                SelectBottomView(VIEWS::TRADE_BOTTOM_VIEW);
                break;
            case VIEWS::SHIPDESIGN_VIEW:
                SelectBottomView(VIEWS::SHIPDESIGN_BOTTOM_VIEW);
                break;
            case VIEWS::FLEET_VIEW:
                SelectBottomView(VIEWS::SHIP_BOTTOM_VIEW);
                break;
            case VIEWS::TRANSPORT_VIEW:
                SelectBottomView(VIEWS::SHIP_BOTTOM_VIEW);
                break;
            default:
                SelectBottomView(VIEWS::PLANET_BOTTOM_VIEW);
                break;
            }

            // Wenn wir irgendwie in eine andere View, außer der Galaxieansicht gelangen, dann dürfen wir keine Handelsroute
            // oder Ressourcenroute mehr zeichnen
            if (whichView != VIEWS::GALAXY_VIEW)
            {
                CGalaxyMenuView::IsDrawResourceRoute(false);
                CGalaxyMenuView::IsDrawTradeRoute(false);
            }
        }
    }
}
/// Funktion lädt die rassenspezifischen Grafiken.
void CShipDesignMenuView::LoadRaceGraphics()
{
	CBotEDoc* pDoc = resources::pDoc;
	ASSERT(pDoc);

	CMajor* pMajor = m_pPlayersRace;
	ASSERT(pMajor);

	CreateButtons();

	CString sPrefix = pMajor->GetPrefix();
	bg_designmenu	= pDoc->GetGraphicPool()->GetGDIGraphic("Backgrounds\\" + sPrefix + "designmenu.boj");
}
Пример #6
0
LRESULT CMainFrame::InitViews(WPARAM /*wParam*/, LPARAM /*lParam*/)
{
    MYTRACE("general")(MT::LEVEL_INFO, "Getting Message to InitViews...");

    CBotEDoc* pDoc = resources::pDoc;
    AssertBotE(pDoc);

    // alle rassenabhängigen Grafiken in jeder View laden
    pDoc->LoadViewGraphics();

    MYTRACE("general")(MT::LEVEL_INFO, "Init all Views done\n");
    return TRUE;
}
Пример #7
0
LRESULT CMainFrame::UpdateViews(WPARAM /*wParam*/, LPARAM /*lParam*/)
{
    MYTRACE("general")(MT::LEVEL_INFO, "Getting Message to UpdateViews...");

    CBotEDoc* pDoc = resources::pDoc;
    AssertBotE(pDoc);

    // Views ihre Arbeiten zu jeder neuen Runde machen lassen
    pDoc->DoViewWorkOnNewRound();
    MYTRACE("general")(MT::LEVEL_INFO, "Updating all Views done\n");

    return TRUE;
}
Пример #8
0
bool CRandomEventCtrl::SystemEvent(const CPoint &ko, CMajor* pRace)
{
	CBotEDoc* pDoc = resources::pDoc;
	AssertBotE(pDoc);
	//ko= Systemkoordinate
	CString sMsgText;//Nachrichtentext
	int nEventNumber=rand()% (SYSTEMEVENTDEMOGRAPHIC + 1);

	if(nEventNumber==SYSTEMEVENTMORALBOOST)//If abfrage mit allen möglichen Randomevents; evtl. hier bedingungen einfügen
	{
		sMsgText=CLoc::GetString("SYSTEMEVENTMORALBOOST",false,pDoc->GetSystem(ko.x, ko.y).GetName());
		pDoc->GetSystem(ko.x, ko.y).SetMoral(10);
	}
	else if(nEventNumber==SYSTEMEVENTMORALMALUS)
	{
		sMsgText=CLoc::GetString("SYSTEMEVENTMORALMALUS",false,pDoc->GetSystem(ko.x, ko.y).GetName());
		pDoc->GetSystem(ko.x, ko.y).SetMoral(-10);
	}
	else if(nEventNumber==SYSTEMEVENTPLANETMOVEMENT)//Planetenveränderung
		pDoc->GetSystem(ko.x, ko.y).SystemEventPlanetMovement(sMsgText);
	else if(nEventNumber==SYSTEMEVENTDEMOGRAPHIC)
		pDoc->GetSystem(ko.x, ko.y).SystemEventDemographic(sMsgText, *pRace);
	if(!sMsgText.IsEmpty())
	{
		CEmpireNews message;
		message.CreateNews(sMsgText,EMPIRE_NEWS_TYPE::SOMETHING,"",ko);//Nachricht über Randomevent erstellen
		pRace->GetEmpire()->AddMsg(message);
		resources::pClientWorker->SetToEmpireViewFor(*pRace);
	}
	return !sMsgText.IsEmpty();
}
void CNewGameView::LoadGame(const CString& sPath)
{
	SetMode(MODE_LOAD);

	m_sFileName = sPath;
	if (CheckValues())
	{
		// Datei laden
		CBotEDoc* pDoc = resources::pDoc;
		ASSERT(pDoc);

		if (!pDoc->OnOpenDocument(m_sFileName))
		{
			MessageBox(CLoc::GetString("LOADERROR"), CLoc::GetString("ERROR"),	MB_ICONEXCLAMATION | MB_OK);
			m_sFileName = "";
			return;
		}

		pDoc->m_bGameLoaded = true;
		Sleep(250);
		StartServer(true);
	}
}
Пример #10
0
void CEventColonization::Draw(Graphics* g, CGraphicPool* graphicPool) const
{
	CEventScreen::Draw(g, graphicPool);

	CString fontName = "";
	Gdiplus::REAL fontSize = 0.0;
	StringFormat fontFormat;
	SolidBrush fontBrush(static_cast<Gdiplus::ARGB>(Color::White));

	CBotEDoc* pDoc = resources::pDoc;
	AssertBotE(pDoc);

	CMajor* pMajor = dynamic_cast<CMajor*>(pDoc->GetRaceCtrl()->GetRace(m_sRace));
	AssertBotE(pMajor);

	CFontLoader::CreateGDIFont(pMajor, 5, fontName, fontSize);
	fontFormat.SetAlignment(StringAlignmentCenter);
	fontFormat.SetLineAlignment(StringAlignmentCenter);
	fontFormat.SetFormatFlags(StringFormatFlagsNoWrap);
	Gdiplus::Color color;
	CFontLoader::GetGDIFontColor(pMajor, 3, color);
	fontBrush.SetColor(color);

	g->DrawString(CComBSTR(m_strHeadline), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(0,0,1280,96), &fontFormat, &fontBrush);

	CFontLoader::CreateGDIFont(pMajor, 3, fontName, fontSize);
	fontFormat.SetAlignment(StringAlignmentCenter);
	fontFormat.SetLineAlignment(StringAlignmentCenter);
	fontFormat.SetFormatFlags(!StringFormatFlagsNoWrap);
	g->DrawString(CComBSTR(m_strText), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(100,96,1080,128), &fontFormat, &fontBrush);

	// Buttons zeichnen
	CFontLoader::GetGDIFontColor(pMajor, 2, color);
	fontBrush.SetColor(color);
	for (int i = 0; i < m_Buttons.GetSize(); i++)
		m_Buttons.GetAt(i)->DrawButton(*g, graphicPool, Gdiplus::Font(CComBSTR(fontName), fontSize), fontBrush);
}
/// Funktion überprüft ob das in der Designansicht angeklickte Schiff in einem unserer Systeme gerade gebaut wird
/// Man benötigt diesen Check da man keine Schiffe ändern kann, welche gerade gebaut werden.
/// @param pShipInfo Zeiger des zu prüfenden Schiffes aus der Schiffsliste
/// @return CString mit dem Namen des Systems, wird das Schiff nirgends gebaut ist der String leer
CString CShipDesignMenuView::CheckIfShipIsBuilding(const CShipInfo* pShipInfo) const
{
	if (!pShipInfo)
		return "";

	CBotEDoc* pDoc = resources::pDoc;
	ASSERT(pDoc);

	CMajor* pMajor = m_pPlayersRace;
	ASSERT(pMajor);
	if (!pMajor)
		return "";

	USHORT ID = pShipInfo->GetID();
	// alle eigenen Systeme durchgehen und schauen, ob an erster Stelle in der Bauliste so ein Schiff steht
	for (int y = 0; y < STARMAP_SECTORS_VCOUNT; y++)
		for (int x = 0; x < STARMAP_SECTORS_HCOUNT; x++)
			if (pDoc->GetSystem(x,y).GetOwnerOfSystem() == pMajor->GetRaceID())
				for (int i = 0; i < ALE; i++)
					if (pDoc->GetSystem(x,y).GetAssemblyList()->GetAssemblyListEntry(i) == ID)
						return pDoc->GetSector(x,y).GetName();

	return "";
}
Пример #12
0
void CStartMenuView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();

	// TODO: Fügen Sie hier Ihren spezialisierten Code ein, und/oder rufen Sie die Basisklasse auf.
	CBotEDoc* pDoc = resources::pDoc;
	AssertBotE(pDoc);

	m_pBkgndImg = pDoc->GetGraphicPool()->GetGDIGraphic("Events\\Startmenu.boj");
	AssertBotE(m_pBkgndImg);

	m_pChooseRaceView = dynamic_cast<CChooseRaceView*>(resources::pMainFrame->GetView(RUNTIME_CLASS(CChooseRaceView)));
	AssertBotE(m_pChooseRaceView);

	m_pNewGameView = dynamic_cast<CNewGameView*>(resources::pMainFrame->GetView(RUNTIME_CLASS(CNewGameView)));
	AssertBotE(m_pNewGameView);

	// Immer im Vollbild anzeigen
	resources::pMainFrame->FullScreenMainView(true);

	// Menü zu Beginn nicht anzeigen
	GetTopLevelFrame()->SetMenuBarState(AFX_MBS_HIDDEN);

	m_TotalSize = CSize(1280, 1024);

	CRect clientRect;
	GetDesktopWindow()->GetClientRect(clientRect);

	double nButtonSizeX = 300.0;
	double nButtonSizeY = 40.0;

	double nXPos = clientRect.Width() / 2.0 - nButtonSizeX / 2.0;
	double nYPos = clientRect.Height() / 2.0 - 150.0;

	double nGab = 10.0;

	// Structure containing Style
	tButtonStyle tStyle;
	//////////////////////////////////////////////////////////////////////////

	// Get default Style
	m_tButtonStyle.GetButtonStyle(&tStyle);
	// Change Radius of Button
	tStyle.m_dRadius = 1.0;

	// Change Color Schema of Button
	tStyle.m_tColorFace.m_tEnabled		= RGB(100, 100, 100);
	tStyle.m_tColorBorder.m_tEnabled	= RGB(220, 220, 220);

	tStyle.m_tColorFace.m_tClicked		= RGB(75, 75, 75);
	tStyle.m_tColorBorder.m_tClicked	= RGB(25, 25, 25);

	tStyle.m_tColorFace.m_tPressed		= RGB(75, 75, 75);
	tStyle.m_tColorBorder.m_tPressed	= RGB(25, 25, 25);

	tStyle.m_tColorFace.m_tHot			= RGB(0x80, 0x80, 0xFF);
	tStyle.m_tColorBorder.m_tHot		= RGB(0x40, 0x40, 0xFF);

	// Set Style again
	m_tButtonStyle.SetButtonStyle(&tStyle);

	// Create a push button.
	m_btNewGame.Create(_T(CLoc::GetString("NEWGAME")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos, nXPos + nButtonSizeX, nYPos + nButtonSizeY), this, NEWGAME);
	m_btMultiplayer.Create(_T(CLoc::GetString("MULTIPLAYER")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 1, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 1 + nButtonSizeY), this, MULTIPLAYER);
	m_btLoadGame.Create(_T(CLoc::GetString("LOADGAME")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 2, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 2 + nButtonSizeY), this, LOADGAME);
	m_btTutorial.Create(_T(CLoc::GetString("TUTORIAL")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 3, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 3 + nButtonSizeY), this, TUTORIAL);
	m_btOptions.Create(_T(CLoc::GetString("SETTINGS")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 4, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 4 + nButtonSizeY), this, OPTIONS);
	m_btExit.Create(_T(CLoc::GetString("LEAVE")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 5, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 5 + nButtonSizeY), this, EXITGAME);

	m_btMPServer.Create(_T(CLoc::GetString("CREATEGAME")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 1, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 1 + nButtonSizeY), this, MP_CREATE);
	m_btMPClient.Create(_T(CLoc::GetString("JOINGAME")), WS_CHILD|BS_PUSHBUTTON|WS_DISABLED, CRect(nXPos, nYPos + (nGab + nButtonSizeY) * 2, nXPos + nButtonSizeX, nYPos + (nGab + nButtonSizeY) * 2 + nButtonSizeY), this, MP_JOIN);

	// Buttonstyle zuweisen
	for (int i = NEWGAME; i <= TUTORIAL; i++)
	{
		CRoundButton2* pBtn = dynamic_cast<CRoundButton2*>(GetDlgItem(i));
		if (!pBtn)
			continue;

		SetButtonStyle(pBtn);
	}

	// Für Tooltips registrieren
	CString sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("NEWGAMETT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(NEWGAME), sTooltip);
	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("MULTIPLAYERTT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(MULTIPLAYER), sTooltip);
	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("LOADGAMETT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(LOADGAME), sTooltip);
	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("SETTINGSTT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(OPTIONS), sTooltip);
	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("LEAVETT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(EXITGAME), sTooltip);
	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("TUTORIALTT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(TUTORIAL), sTooltip);

	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("CREATEGAMETT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(MP_CREATE), sTooltip);
	sTooltip = CHTMLStringBuilder::GetHTMLColor(CLoc::GetString("JOINGAMETT"), _T("silver"));
	resources::pMainFrame->AddToTooltip(GetDlgItem(MP_JOIN), sTooltip);

	this->SetTimer(1,1000,NULL);
}
Пример #13
0
void CIntelBottomView::OnDraw(CDC* dc)
{
	CBotEDoc* pDoc = resources::pDoc;
	AssertBotE(pDoc);

	if (!pDoc->m_bDataReceived)
		return;

	CMajor* pMajor = m_pPlayersRace;
	AssertBotE(pMajor);
	if (!pMajor)
		return;
	// TODO: add draw code here

	// Doublebuffering wird initialisiert
	CMyMemDC pDC(dc);
	CRect client;
	GetClientRect(&client);

	// Graphicsobjekt, in welches gezeichnet wird anlegen
	Graphics g(pDC->GetSafeHdc());

	g.Clear(static_cast<Gdiplus::ARGB>(Color::Black));
	g.SetSmoothingMode(SmoothingModeHighSpeed);
	g.SetInterpolationMode(InterpolationModeLowQuality);
	g.SetPixelOffsetMode(PixelOffsetModeHighSpeed);
	g.SetCompositingQuality(CompositingQualityHighSpeed);
	g.ScaleTransform((REAL)client.Width() / (REAL)m_TotalSize.cx, (REAL)client.Height() / (REAL)m_TotalSize.cy);

	CString fontName = "";
	Gdiplus::REAL fontSize = 0.0;
	StringFormat fontFormat;
	SolidBrush fontBrush(static_cast<Gdiplus::ARGB>(Color::White));

	Color color;
	color.SetFromCOLORREF(pMajor->GetDesign()->m_clrGalaxySectorText);

	fontBrush.SetColor(color);
	Bitmap* graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Backgrounds\\" + pMajor->GetPrefix() + "diplomacyV3.boj");

	// Grafik zeichnen
	if (graphic)
	{
		g.DrawImage(graphic, 0, 0, 1075, 249);
		graphic = NULL;
	}

	// Nur in bestimmten Submenüs werden in der View3 Berichte angezeigt
	BYTE curIntelSubMenu = resources::pMainFrame->GetSubMenu(RUNTIME_CLASS(CIntelMenuView));
	if (curIntelSubMenu == 4 || curIntelSubMenu == 5)
	{
		CRect r;
		r.SetRect(0,0,m_TotalSize.cx,m_TotalSize.cy);
		short n = pMajor->GetEmpire()->GetIntelligence()->GetIntelReports()->GetActiveReport();
		if (n != -1)
		{
			CFontLoader::CreateGDIFont(pMajor, 4, fontName, fontSize);
			fontFormat.SetAlignment(StringAlignmentNear);
			fontFormat.SetLineAlignment(StringAlignmentNear);
			fontFormat.SetFormatFlags(StringFormatFlagsNoWrap);
			CIntelObject* report = pMajor->GetEmpire()->GetIntelligence()->GetIntelReports()->GetReport(n);
			CString s;
			if (report->GetIsSpy())
				s = CLoc::GetString("SPY");
			else
				s = CLoc::GetString("SABOTAGE");
			g.DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 40, r.right-100, r.bottom-20), &fontFormat, &fontBrush);

			CFontLoader::CreateGDIFont(pMajor, 2, fontName, fontSize);
			fontBrush.SetColor(Color(200,200,250));
			fontFormat.SetFormatFlags(!StringFormatFlagsNoWrap);
			if (report->GetOwner() == pMajor->GetRaceID())
				s = *report->GetOwnerDesc();
			else
				s = *report->GetEnemyDesc();
			g.DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 100, r.right-250, r.bottom-20), &fontFormat, &fontBrush);
		}
	}
	g.ReleaseHDC(pDC->GetSafeHdc());
}
Пример #14
0
void CRandomEventCtrl::CalcShipEvents() const
{
	if (!IsActivated())
		return;

	CBotEDoc* pDoc = resources::pDoc;
	AssertBotE(pDoc);

	// Hüllenvirus
	for (int x = 0; x < STARMAP_SECTORS_HCOUNT; x++)
	{
		for (int y = 0; y < STARMAP_SECTORS_VCOUNT; y++)
		{
			// 0.1% Wahrscheinlichkeit für einen Hüllenvirus pro Sektor
			if (rand()%1000 != 0)
				continue;

			// gibt es keine Schiffe im Sektor, dann macht ein Hüllenvirus auch nichts
			CSector* pSector = &(pDoc->GetSystem(x, y));
			if (!pSector->GetIsShipInSector())
				continue;

			// allen Schiffe im Sektor die Hülle auf 1 reduzieren (außer Aliens)
			for (CShipMap::iterator i = pDoc->m_ShipMap.begin(); i != pDoc->m_ShipMap.end(); ++i)
			{
				if (i->second->IsAlien())
					continue;

				if (i->second->GetCo() != pSector->GetCo())
					continue;

				int nCurrentHull = i->second->GetHull()->GetCurrentHull();
				i->second->GetHull()->SetCurrentHull(-(nCurrentHull - 1), true);

				// allen Schiffen in der Flotte ebenfalls die Hülle auf 1 setzen
				for (CShips::iterator j = i->second->begin(); j != i->second->end(); ++j)
				{
					nCurrentHull = j->second->GetHull()->GetCurrentHull();
					j->second->GetHull()->SetCurrentHull(-(nCurrentHull - 1), true);
				}
			}

			// Nachrichten an alle Major welche Schiffe in diesem Sektor hatten
			const std::map<CString, CMajor*>* pmMajors = pDoc->GetRaceCtrl()->GetMajors();
			for (map<CString, CMajor*>::const_iterator it = pmMajors->begin(); it != pmMajors->end(); ++it)
			{
				if (!pSector->GetOwnerOfShip(it->first, true))
					continue;

				CMajor* pMajor = it->second;
				if (!pMajor)
					continue;

				const CString& sSectorName = pSector->CoordsName(true);

				CString sMessageText = CLoc::GetString("EVENTHULLVIRUS", false, sSectorName);
				CEmpireNews message;
				message.CreateNews(sMessageText,EMPIRE_NEWS_TYPE::MILITARY,pSector->GetName(),pSector->GetCo());
				pMajor->GetEmpire()->AddMsg(message);

				if (pMajor->IsHumanPlayer())
				{
					resources::pClientWorker->SetToEmpireViewFor(*pMajor);
					pMajor->GetEmpire()->PushEvent(boost::make_shared<CEventRandom>(pMajor->GetRaceID(), "HullVirus", sMessageText, ""));
				}
			}
		}
	}
}
Пример #15
0
void CResearchBottomView::OnDraw(CDC* dc)
{
	CBotEDoc* pDoc = resources::pDoc;
	AssertBotE(pDoc);

	if (!pDoc->m_bDataReceived)
		return;

	CMajor* pMajor = m_pPlayersRace;
	AssertBotE(pMajor);
	if (!pMajor)
		return;
	// TODO: add draw code here

	// Doublebuffering wird initialisiert
	CMyMemDC pDC(dc);
	CRect client;
	GetClientRect(&client);

	// Graphicsobjekt, in welches gezeichnet wird anlegen
	Graphics g(pDC->GetSafeHdc());

	g.Clear(static_cast<Gdiplus::ARGB>(Color::Black));
	g.SetSmoothingMode(SmoothingModeHighSpeed);
	g.SetInterpolationMode(InterpolationModeLowQuality);
	g.SetPixelOffsetMode(PixelOffsetModeHighSpeed);
	g.SetCompositingQuality(CompositingQualityHighSpeed);
	g.ScaleTransform((REAL)client.Width() / (REAL)m_TotalSize.cx, (REAL)client.Height() / (REAL)m_TotalSize.cy);

	CString fontName = "";
	Gdiplus::REAL fontSize = 0.0;
	StringFormat fontFormat;
	SolidBrush fontBrush(static_cast<Gdiplus::ARGB>(Color::White));
	CRect rect;
	rect.SetRect(0,0,m_TotalSize.cx,m_TotalSize.cy);

	CString sPrefix = pMajor->GetPrefix();
	Color color;
	color.SetFromCOLORREF(pMajor->GetDesign()->m_clrGalaxySectorText);
	fontBrush.SetColor(color);
	Bitmap* graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Backgrounds\\" + sPrefix + "researchV3.boj");

	// gibt es keine Spezialforschung zur Auswahl, so wird auf Standardanzeige umgestellt
	if (m_nCurrentTech == 6 && pMajor->GetEmpire()->GetResearch()->GetUniqueReady() == TRUE)
		m_nCurrentTech = 0;

	// Grafik zeichnen
	if (graphic)
	{
		g.DrawImage(graphic, 0, 0, 1075, 249);
		graphic = NULL;
	}
	switch(m_nCurrentTech)
	{
	case 0:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\biotech.bop"); break;
	case 1:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\energytech.bop"); break;
	case 2:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\computertech.bop"); break;
	case 3:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\propulsiontech.bop"); break;
	case 4:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\constructiontech.bop"); break;
	case 5:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\weapontech.bop"); break;
	case 6:	graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Research\\specialtech.bop"); break;
	}
	if (graphic)
	{
		g.DrawImage(graphic, 790, 25, 240, 200);
		graphic = NULL;
	}
	// Name und Beschreibung der Forschung anzeigen
	CFontLoader::CreateGDIFont(pMajor, 4, fontName, fontSize);
	fontFormat.SetAlignment(StringAlignmentNear);
	fontFormat.SetLineAlignment(StringAlignmentNear);
	fontFormat.SetFormatFlags(StringFormatFlagsNoWrap);

	CString s;
	if (m_nCurrentTech != 6)
		s = pMajor->GetEmpire()->GetResearch()->GetResearchInfo()->GetTechName(m_nCurrentTech);
	else
		s = pMajor->GetEmpire()->GetResearch()->GetResearchInfo()->GetCurrentResearchComplex()->GetComplexName();
	g.DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 30, rect.right-325, rect.bottom), &fontFormat, &fontBrush);

	CFontLoader::CreateGDIFont(pMajor, 2, fontName, fontSize);
	fontBrush.SetColor(Color(200,200,250));
	fontFormat.SetFormatFlags(!StringFormatFlagsNoWrap);
	if (m_nCurrentTech != 6)
		s = pMajor->GetEmpire()->GetResearch()->GetResearchInfo()->GetTechDescription(m_nCurrentTech);
	else
		s = pMajor->GetEmpire()->GetResearch()->GetResearchInfo()->GetCurrentResearchComplex()->GetComplexDescription();
	g.DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 100, rect.right-325, rect.bottom), &fontFormat, &fontBrush);

	g.ReleaseHDC(pDC->GetSafeHdc());
}
/////////////////////////////////////////////////////////////////////////////////////////
// Hier die Funktion zum Zeichnen des Schiffsdesignmenüs
/////////////////////////////////////////////////////////////////////////////////////////
void CShipDesignMenuView::DrawShipDesignMenue(Graphics* g)
{
	CBotEDoc* pDoc = resources::pDoc;
	ASSERT(pDoc);

	CMajor* pMajor = m_pPlayersRace;
	ASSERT(pDoc);
	if (!pMajor)
		return;

	CString fontName = "";
	Gdiplus::REAL fontSize = 0.0;

	// Rassenspezifische Schriftart auswählen
	CFontLoader::CreateGDIFont(pMajor, 2, fontName, fontSize);
	// Schriftfarbe wählen
	Gdiplus::Color normalColor;
	CFontLoader::GetGDIFontColor(pMajor, 3, normalColor);

	StringFormat fontFormat;
	fontFormat.SetAlignment(StringAlignmentNear);
	fontFormat.SetLineAlignment(StringAlignmentCenter);
	fontFormat.SetFormatFlags(StringFormatFlagsNoWrap);

	Color penColor;
	penColor.SetFromCOLORREF(pMajor->GetDesign()->m_clrListMarkPenColor);

	Color markColor;
	markColor.SetFromCOLORREF(pMajor->GetDesign()->m_clrListMarkTextColor);

	if (bg_designmenu)
		g->DrawImage(bg_designmenu, 0, 0, 1075, 750);

	SolidBrush fontBrush(normalColor);


	// Links im Bild die veränderbaren Schiffklassen zeichnen (bis jetzt darf man keine Stationen verändern,
	// weil deren Baukosten allein von den Industriekosten berechnet werden. Diese aber nicht steigen wenn
	// man die Hülle oder Schilde verbessert. Somit könnte man bessere Stationen für den gleichen Preis bauen.

	// Schiffsinfoarray durchgehen und nach zum Imperium gehörende baubare Schiffe suchen
	short j = 0;
	short counter = m_iClickedOnShip - 23 + m_iOldClickedOnShip;
	short oldClickedShip = m_iClickedOnShip;

	BYTE researchLevels[6] =
	{
		pMajor->GetEmpire()->GetResearch()->GetBioTech(),
		pMajor->GetEmpire()->GetResearch()->GetEnergyTech(),
		pMajor->GetEmpire()->GetResearch()->GetCompTech(),
		pMajor->GetEmpire()->GetResearch()->GetPropulsionTech(),
		pMajor->GetEmpire()->GetResearch()->GetConstructionTech(),
		pMajor->GetEmpire()->GetResearch()->GetWeaponTech()
	};

	m_pShownShip = NULL;
	m_nSizeOfShipDesignList = 0;
	// Es gehen nur 21 Einträge auf die Seite, deshalb muss abgebrochen werden
	for (int i = 0; i < pDoc->m_ShipInfoArray.GetSize(); i++)
		if (pDoc->m_ShipInfoArray.GetAt(i).GetRace() == pMajor->GetRaceShipNumber())
			if (!pDoc->m_ShipInfoArray.GetAt(i).IsStation())
				if (pDoc->m_ShipInfoArray.GetAt(i).IsThisShipBuildableNow(researchLevels))
				{
					// wurde dieses Schiff durch kein anderes jetzt baubares Schiff schon obsolet?
					BOOLEAN foundObsolet = FALSE;
					for (int m = 0; m < pDoc->m_ShipInfoArray.GetSize(); m++)
						if (pDoc->m_ShipInfoArray.GetAt(m).GetRace() == pMajor->GetRaceShipNumber())
							if (pDoc->m_ShipInfoArray.GetAt(m).GetObsoleteShipClass() == pDoc->m_ShipInfoArray.GetAt(i).GetShipClass())
								if (pDoc->m_ShipInfoArray.GetAt(m).IsThisShipBuildableNow(researchLevels))
								{
									foundObsolet = TRUE;
									break;
								}

					if (foundObsolet)
						continue;

					m_nSizeOfShipDesignList++;
					if (counter > 0)
					{
						m_iClickedOnShip--;
						counter--;
						continue;
					}

					if (j < 24)
					{
						fontBrush.SetColor(normalColor);
						// Wenn wir ein Schiff gefunden haben, dann zeichnen wir dieses in die Liste (max. 21)
						// Wenn wir das Schiff markiert haben, dann die Markierung zeichnen, haben wir kein spezielles Schiff
						// angeklickt, so wird das 1. Schiff in der Liste markiert
						if (j == m_iClickedOnShip || m_iClickedOnShip == -1)
						{
							fontBrush.SetColor(markColor);
							// Wenn wir nix angeklickt haben und nur das erste Schiff markiert war, dann automatisch
							m_iClickedOnShip = j;
							if (oldClickedShip == -1)
								oldClickedShip = j;

							m_pShownShip = &pDoc->m_ShipInfoArray.GetAt(i);

							// Markierung worauf wir geklickt haben
							g->FillRectangle(&SolidBrush(Color(50,200,200,200)), RectF(15,120+j*25,183,25));
							g->DrawLine(&Gdiplus::Pen(penColor), 15, 120+j*25, 198, 120+j*25);
							g->DrawLine(&Gdiplus::Pen(penColor), 15, 145+j*25, 198, 145+j*25);

							// Infos in unteren Schiffsdesignansicht aktualisieren
							if (CShipDesignBottomView* pView = dynamic_cast<CShipDesignBottomView*>(resources::pMainFrame->GetView(RUNTIME_CLASS(CShipDesignBottomView))))
							{
								if (pView->GetCurrentShipInfo() != i)
								{
									pView->SetCurrentShipInfo(i);
									pView->Invalidate(FALSE);
								}
							}
						}
						CString s = pDoc->m_ShipInfoArray.GetAt(i).GetShipClass();
						g->DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(25, 120 + j * 25, 175, 25), &fontFormat, &fontBrush);
						j++;
					}
				}
	m_iClickedOnShip = oldClickedShip;

	// Hier jetzt Informationen zum angeklickten Schiff anzeigen
	if (m_pShownShip)
	{
		// Bild des Schiffes zeichnen
		CString s;
		s.Format("Ships\\%s.bop",m_pShownShip->GetShipClass());
		Bitmap* graphic = pDoc->GetGraphicPool()->GetGDIGraphic(s);
		if (graphic == NULL)
			graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Ships\\ImageMissing.bop");
		if (graphic)
		{
			g->DrawImage(graphic, 388, 90, 200, 150);
			graphic = NULL;
		}
		// allgemeine Schiffsinformationen anzeigen
		m_pShownShip->DrawShipInformation(g, CRect(220,250,740,440), &Gdiplus::Font(CComBSTR(fontName), fontSize), normalColor, markColor, pMajor->GetEmpire()->GetResearch());
		// Baukosten des Schiffes anzeigen
		fontBrush.SetColor(markColor);
		fontFormat.SetAlignment(StringAlignmentCenter);
		fontFormat.SetLineAlignment(StringAlignmentNear);
		g->DrawString(CComBSTR(CLoc::GetString("BUILDCOSTS")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(190,440,580,25), &fontFormat, &fontBrush);

		fontBrush.SetColor(normalColor);
		s.Format("%s: %d  %s: %d  %s: %d",CLoc::GetString("INDUSTRY"),m_pShownShip->GetNeededIndustry(),
			CLoc::GetString("TITAN"),m_pShownShip->GetNeededTitan(),
			CLoc::GetString("DEUTERIUM"),m_pShownShip->GetNeededDeuterium());
		g->DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(190,465,580,25), &fontFormat, &fontBrush);

		s.Format("%s: %d  %s: %d  %s: %d  %s: %d",CLoc::GetString("DURANIUM"),m_pShownShip->GetNeededDuranium(),
			CLoc::GetString("CRYSTAL"),m_pShownShip->GetNeededCrystal(),
			CLoc::GetString("IRIDIUM"),m_pShownShip->GetNeededIridium(),
			CLoc::GetString("DERITIUM"),m_pShownShip->GetNeededDeritium());
			g->DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(190,490,580,25), &fontFormat, &fontBrush);

		// Die Buttons zur Eigenschaftsänderung in der Rechten Seite der Ansicht anzeigen
		// zuerst überprüfen wir die Beamwaffen, wir können den Typ der Beamwaffe verändern, wenn wir mindst. ein anderes
		// Schiff des Imperiums finden, welches DIESE Beamwaffe mit einem höheren Typ oder einem niedrigeren Typ besitzt

		graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Other\\" + pMajor->GetPrefix() + "button_small.bop");
		Color btnColor;
		CFontLoader::GetGDIFontColor(pMajor, 1, btnColor);
		SolidBrush btnBrush(btnColor);

		fontFormat.SetAlignment(StringAlignmentCenter);
		fontFormat.SetLineAlignment(StringAlignmentCenter);

		// Nach Beamwaffen suchen
		if (m_pShownShip->GetBeamWeapons()->GetSize() > m_iBeamWeaponNumber)
		{
			// gibt es schon von dieser Beamwaffe hier auf dem Schiff einen höheren Typ?
			USHORT maxTyp =	pMajor->GetWeaponObserver()->GetMaxBeamType(m_pShownShip->GetBeamWeapons()->GetAt(m_iBeamWeaponNumber).GetBeamName());
			if (maxTyp > m_pShownShip->GetBeamWeapons()->GetAt(m_iBeamWeaponNumber).GetBeamType())
			{
				// Dann können wir den Typ unserer Beamwaffe(n) verbessern
				if (graphic)
					g->DrawImage(graphic, 930, 120, 120, 30);
				g->DrawString(CComBSTR(CLoc::GetString("BTN_STRONGER")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(930,120,120,30), &fontFormat, &btnBrush);
				m_bFoundBetterBeam = TRUE;
			}
			// Wenn wir einen größeren Typ als Typ 1 haben, dann können wir diesen verringern
			if (m_pShownShip->GetBeamWeapons()->GetAt(m_iBeamWeaponNumber).GetBeamType() > 1)
			{
				// Dann können wir den Typ unserer Beamwaffe(n) verkleinern
				if (graphic)
					g->DrawImage(graphic, 800, 120, 120, 30);
				g->DrawString(CComBSTR(CLoc::GetString("BTN_WEAKER")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(800,120,120,30), &fontFormat, &btnBrush);
				m_bFoundWorseBeam = TRUE;
			}

			// Typ und Name der Beamwaffe zeichnen
			fontBrush.SetColor(normalColor);
			s.Format("%s %d %s",CLoc::GetString("TYPE"),m_pShownShip->GetBeamWeapons()->GetAt(m_iBeamWeaponNumber).GetBeamType(),m_pShownShip->GetBeamWeapons()->GetAt(m_iBeamWeaponNumber).GetBeamName());
			fontFormat.SetTrimming(StringTrimmingEllipsisCharacter);
			g->DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(845,80,160,25), &fontFormat, &fontBrush);
			fontFormat.SetTrimming(StringTrimmingNone);
		}

		// Nach anderer Torpedowaffe suchen
		if (m_pShownShip->GetTorpedoWeapons()->GetSize() > m_iTorpedoWeaponNumber)
		{
			// den aktuellen Torpedotyp holen
			BYTE currentTorpType = m_pShownShip->GetTorpedoWeapons()->GetAt(m_iTorpedoWeaponNumber).GetTorpedoType();
			// Torpedoname zeichnen
			fontBrush.SetColor(normalColor);
			s.Format("%s (%d°)",m_pShownShip->GetTorpedoWeapons()->GetAt(m_iTorpedoWeaponNumber).GetTupeName(), m_pShownShip->GetTorpedoWeapons()->GetAt(m_iTorpedoWeaponNumber).GetFirearc()->GetAngle());
			g->DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(775,170,300,25), &fontFormat, &fontBrush);

			s.Format("%s (%d)", CTorpedoInfo::GetName(currentTorpType), CTorpedoInfo::GetPower(currentTorpType));
			g->DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(775,195,300,25), &fontFormat, &fontBrush);

			if (graphic)
				g->DrawImage(graphic, 800, 230, 120, 30);
			g->DrawString(CComBSTR(CLoc::GetString("BTN_LAUNCHER")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(800,230,120,30), &fontFormat, &btnBrush);
			if (graphic)
				g->DrawImage(graphic, 930, 230, 120, 30);
			g->DrawString(CComBSTR(CLoc::GetString("BTN_TORPEDO")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(930,230,120,30), &fontFormat, &btnBrush);
		}

		// hier Möglichkeit anderes Hüllenmaterial anzubringen eingebaut
		CString material;
		switch (m_pShownShip->GetHull()->GetHullMaterial())
		{
			case TITAN:		material = CLoc::GetString("TITAN");; break;
			case DURANIUM:	material = CLoc::GetString("DURANIUM");; break;
			case IRIDIUM:	material = CLoc::GetString("IRIDIUM");; break;
			default: material = "";
		}

		BOOLEAN bDoubleHull = m_pShownShip->GetHull()->GetDoubleHull();
		if (bDoubleHull == TRUE)
			s.Format("%s%s",material, CLoc::GetString("DOUBLE_HULL_ARMOUR"));
		else
			s.Format("%s%s",material, CLoc::GetString("HULL_ARMOR"));
		g->DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(775,380,300,30), &fontFormat, &fontBrush);

		// Hier kann man den Schildtyp ändern
		// zuerst Anzeige der jetzt aktuellen Schilde. Beim Romulaner eine schwarze Schriftart wählen. Wenn dies
		// später auch bei der Föd heller unterlegt ist kann auch dort eine schwarze Schriftfarbe gewählt werden.
		s.Format("%s %d %s",CLoc::GetString("TYPE"),m_pShownShip->GetShield()->GetShieldType(),CLoc::GetString("SHIELDS"));
		g->DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(775,490,300,30), &fontFormat, &fontBrush);

		// Ab jetzt die Buttons zum Ändern der jeweiligen Komponenten
		if (graphic)
			g->DrawImage(graphic, 800, 420, 120, 30);
		g->DrawString(CComBSTR(CLoc::GetString("BTN_MATERIAL")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(800,420,120,30), &fontFormat, &btnBrush);

		// wenn eine Doppelhülle draus gemacht werden soll dann darf die Manövrierbarkeit nicht schon "keine" oder nur 1 sein
		// wenn eine Einzelhülle draus gemacht werden soll, dann darf die Manövrierbarkeit nicht schon phänomenal sein
		if ((bDoubleHull == FALSE && m_pShownShip->GetManeuverability() > 1) || (bDoubleHull == TRUE && m_pShownShip->GetManeuverability() < 9))
		{
			if (graphic)
				g->DrawImage(graphic, 930, 420, 120, 30);
			g->DrawString(CComBSTR(CLoc::GetString("BTN_HULLTYPE")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(930,420,120,30), &fontFormat, &btnBrush);
		}

		// Schildtyp schwächer Button einblenden
		if (m_pShownShip->GetShield()->GetShieldType() > 0)
		{
			if (graphic)
				g->DrawImage(graphic, 800, 540, 120, 30);
			g->DrawString(CComBSTR(CLoc::GetString("BTN_WEAKER")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(800,540,120,30), &fontFormat, &btnBrush);
		}
		// Schildtyp stärker Button einblenden
		if (m_pShownShip->GetShield()->GetShieldType() < pMajor->GetWeaponObserver()->GetMaxShieldType())
		{
			if (graphic)
				g->DrawImage(graphic, 930, 540, 120, 30);
			g->DrawString(CComBSTR(CLoc::GetString("BTN_STRONGER")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(930,540,120,30), &fontFormat, &btnBrush);
		}
	}
	// Wenn das Schiff in irgendeinem unserer Systeme gebaut wird, dann großen Text ausgeben, in welchem System das Schiff
	// gerade gebaut wird
	CString systemName = CheckIfShipIsBuilding(m_pShownShip);
	if (!systemName.IsEmpty())
	{
		COverlayBanner *banner = new COverlayBanner(CPoint(200,300), CSize(580, 200),
			CLoc::GetString("NO_CHANGE_POSSIBLE", FALSE, systemName), RGB(220,0,0));
		banner->Draw(g, &Gdiplus::Font(CComBSTR(fontName), fontSize));
		delete banner;
	}

	// draw Button DisplayAllShips
	Bitmap* btnDisplayAllShips = pDoc->GetGraphicPool()->GetGDIGraphic("Other\\" + pMajor->GetPrefix() + "button_small.bop");//All-Button zeichnen
	if(btnDisplayAllShips)
		g->DrawImage(btnDisplayAllShips,40,750,80,30);

	CString s;
	//AfxMessageBox("m_bDisplayAllShips"); 
	if (m_bDisplayAllShips)
		s=CLoc::GetString("BTN_ALL");
	else
		s=CLoc::GetString("BTN_CURRENTS");
	g->DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40,750,80,30), &fontFormat, &fontBrush);


	// "Schiffsdesign" in der Mitte zeichnen
	// Rassenspezifische Schriftart auswählen
	CFontLoader::CreateGDIFont(pMajor, 5, fontName, fontSize);
	// Schriftfarbe wählen
	CFontLoader::GetGDIFontColor(pMajor, 3, normalColor);
	fontBrush.SetColor(normalColor);
	g->DrawString(CComBSTR(CLoc::GetString("SHIPDESIGN")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(188,10,600,50), &fontFormat, &fontBrush);
}
void CNewGameView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();

	// TODO: Fügen Sie hier Ihren spezialisierten Code ein, und/oder rufen Sie die Basisklasse auf.
	CBotEDoc* pDoc = resources::pDoc;
	ASSERT(pDoc);

	m_pBkgndImg = pDoc->GetGraphicPool()->GetGDIGraphic("Events\\Startmenu.boj");
	m_TotalSize = CSize(1280, 1024);

	CRect clientRect;
	GetDesktopWindow()->GetClientRect(clientRect);

	//double nButtonSizeX = 300.0;
	//double nButtonSizeY = 40.0;

	//double nXPos = clientRect.Width() / 2.0 - nButtonSizeX / 2.0;
	double nYPos = clientRect.Height() / 2.0 - 175.0;

	//double nGab = 10.0;

	// Structure containing Style
	tButtonStyle tStyle;
	//////////////////////////////////////////////////////////////////////////

	// Get default Style
	m_tButtonStyle.GetButtonStyle(&tStyle);
	// Change Radius of Button
	tStyle.m_dRadius = 1.0;

	// Change Color Schema of Button
	tStyle.m_tColorFace.m_tEnabled		= RGB(100, 100, 100);
	tStyle.m_tColorBorder.m_tEnabled	= RGB(220, 220, 220);

	tStyle.m_tColorFace.m_tClicked		= RGB(75, 75, 75);
	tStyle.m_tColorBorder.m_tClicked	= RGB(25, 25, 25);

	tStyle.m_tColorFace.m_tPressed		= RGB(75, 75, 75);
	tStyle.m_tColorBorder.m_tPressed	= RGB(25, 25, 25);

	tStyle.m_tColorFace.m_tHot			= RGB(0x80, 0x80, 0xFF);
	tStyle.m_tColorBorder.m_tHot		= RGB(0x40, 0x40, 0xFF);

	// Set Style again
	m_tButtonStyle.SetButtonStyle(&tStyle);

	// auflösungsabhängige Font erstellen
	CFont fnt;
	fnt.CreateFont(17, 0, 0, 0, FW_BLACK, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, DEFAULT_PITCH, "Calibri");

	// Set control positions
	m_username.SetWindowPos(NULL, clientRect.Width() / 2.0 - 100, nYPos, 200, 25, SWP_FRAMECHANGED);
	m_username.SetFont(&fnt);

	// Controls nur für Server
	m_description.SetWindowPos(NULL, clientRect.Width() / 2.0 - 100, nYPos + 35, 200, 25, SWP_FRAMECHANGED);
	m_description.SetFont(&fnt);

	m_serverPort.SetWindowPos(NULL, clientRect.Width() / 2.0 - 100, nYPos + 70, 200, 25, SWP_FRAMECHANGED);
	m_serverPort.SetFont(&fnt);

	m_btPublish.SetWindowPos(NULL, clientRect.Width() / 2.0 - 100, nYPos + 105, 14, 14, SWP_FRAMECHANGED);
	m_btPublish.SetFont(&fnt);

	// Controls nur für Clients
	m_hostIP.SetWindowPos(NULL, clientRect.Width() / 2.0 - 100, nYPos + 35, 200, 25, SWP_FRAMECHANGED);
	m_hostIP.SetFont(&fnt);

	m_btSearchServers.SetWindowPos(NULL, clientRect.Width() / 2.0 + 110, nYPos + 35, 175, 25, SWP_FRAMECHANGED);
	SetButtonStyle(&m_btSearchServers);
	m_btSearchServers.SetWindowText(CLoc::GetString("SEARCHLANSERVER"));

	m_hostPort.SetWindowPos(NULL, clientRect.Width() / 2.0 - 100, nYPos + 70, 200, 25, SWP_FRAMECHANGED);
	m_hostPort.SetFont(&fnt);

	// Create push buttons
	m_btBack.Create(_T(CLoc::GetString("BTN_BACK")), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(), this, BTN_BACK);
	m_btBack.SetWindowPos(NULL, clientRect.Width() / 2.0 - 160, nYPos + 175, 150, 30, SWP_FRAMECHANGED);
	SetButtonStyle(&m_btBack);

	m_btNext.Create(_T(CLoc::GetString("BTN_FURTHER")), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(), this, BTN_NEXT);
	m_btNext.SetWindowPos(NULL, clientRect.Width() / 2.0 + 10, nYPos + 175, 150, 30, SWP_FRAMECHANGED);
	SetButtonStyle(&m_btNext);

	// Handle auf Font freigeben
	fnt.Detach();

	// Anfangswerte setzen
	m_btPublish.SetCheck(TRUE);

	CString userName = "";
	CIniLoader::GetInstance()->ReadValue("General", "USERNAME", userName);
	if (!userName.IsEmpty())
		SetDlgItemText(IDC_USERNAME, userName);
	else
	{
		TCHAR userName[UNLEN + 1];
		DWORD nLen = UNLEN + 1;
		VERIFY(GetUserName(userName, &nLen));
		SetDlgItemText(IDC_USERNAME, userName);
	}
	GetDlgItemText(IDC_USERNAME, userName);
	CIniLoader::GetInstance()->WriteValue("General", "USERNAME", userName);

	m_hostIP.SetAddress(INADDR_LOOPBACK);
	m_hostPort.SetWindowText("7777");
	m_serverPort.SetWindowText("7777");
	CString strDesc;
	strDesc.Format("%ss BotE-Server", userName);
	m_description.SetWindowText(strDesc);

	SetMode(MODE_SERVER);

	EnableNextButton();

	// TEST-OPTION (only for Debug)
// Automatisch bis zu einer gewissen Runde durchzuklicken falls per Startparamter aktiviert
// Eventscreen gleich wieder schließen
if (const CCommandLineParameters* const clp = resources::pClp)
{
    int nAutoTurns = clp->GetAutoTurns();
		CBotEDoc* pDoc = resources::pDoc;
	ASSERT(pDoc);
	if (!pDoc)
		return;
    //if (!pDoc->m_bRoundEndPressed && pDoc->GetCurrentRound() < nAutoTurns)
    //{
	using namespace network;

	// Wechsel zur nächsten Seite nur möglich, wenn der Server läuft
	//if (!m_bIsServer)
	//	return;


	StartServer(m_btPublish.GetCheck() == BST_CHECKED);
	client.RequestRace((network::RACE)(clp->GetAutoTurns()));

	//m_bStopDrawing = true;

	//SetCursor(::LoadCursor(NULL, IDC_WAIT));

	// evtl. laufende Veröffentlichung des Spiels stoppen
	//serverPublisher.StopPublishing();

	// die nicht ausgewählten Völker vom Server spielen lassen
	/*for (int i = 0; i < RACE_COUNT; i++)
	{
		RACE race = (RACE)(RACE_FIRST + i);
		if (!server.IsPlayedByClient(race))
			server.SetPlayByServer(race,TRUE,FALSE);
	}*/

	// Spiel starten; veranlasst die Clients, auf die nächste Seite zu wechseln
	pDoc->PrepareData();
	server.BeginGame(pDoc);

	SetCursor(::LoadCursor(NULL, IDC_ARROW));
}
}
Пример #18
0
void CDiplomacyBottomView::OnDraw(CDC* dc)
{
    CBotEDoc* pDoc = resources::pDoc;
    AssertBotE(pDoc);

    if (!pDoc->m_bDataReceived)
        return;

    CMajor* pMajor = m_pPlayersRace;
    AssertBotE(pMajor);
    if (!pMajor)
        return;
    // TODO: add draw code here

    // Doublebuffering wird initialisiert
    CMyMemDC pDC(dc);
    CRect client;
    GetClientRect(&client);

    // Graphicsobjekt, in welches gezeichnet wird anlegen
    Graphics g(pDC->GetSafeHdc());

    g.Clear(static_cast<Gdiplus::ARGB>(Color::Black));
    g.SetSmoothingMode(SmoothingModeHighSpeed);
    g.SetInterpolationMode(InterpolationModeLowQuality);
    g.SetPixelOffsetMode(PixelOffsetModeHighSpeed);
    g.SetCompositingQuality(CompositingQualityHighSpeed);
    g.ScaleTransform((REAL)client.Width() / (REAL)m_TotalSize.cx, (REAL)client.Height() / (REAL)m_TotalSize.cy);

    CString fontName = "";
    Gdiplus::REAL fontSize = 0.0;
    StringFormat fontFormat;
    SolidBrush fontBrush(static_cast<Gdiplus::ARGB>(Color::White));

    // Soll was über die Diplomatie angezeigt werden
    CRect rect;
    rect.SetRect(0,0,m_TotalSize.cx,m_TotalSize.cy);

    CString sPrefix = pMajor->GetPrefix();
    Color color;
    color.SetFromCOLORREF(pMajor->GetDesign()->m_clrGalaxySectorText);
    fontBrush.SetColor(color);
    Bitmap* graphic = pDoc->GetGraphicPool()->GetGDIGraphic("Backgrounds\\" + sPrefix + "diplomacyV3.boj");

    // Grafik zeichnen
    if (graphic)
    {
        g.DrawImage(graphic, 0, 0, 1075, 249);
        graphic = NULL;
    }

    CFontLoader::CreateGDIFont(pMajor, 4, fontName, fontSize);
    fontFormat.SetAlignment(StringAlignmentNear);
    fontFormat.SetLineAlignment(StringAlignmentNear);
    fontFormat.SetFormatFlags(StringFormatFlagsNoWrap);
    g.DrawString(CComBSTR(m_strHeadLine), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 30, rect.right, rect.bottom), &fontFormat, &fontBrush);

    if (m_strText.IsEmpty())
        g.DrawString(CComBSTR(CLoc::GetString("NO_DIPLOMATIC_NEWS")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 30, rect.right, rect.bottom), &fontFormat, &fontBrush);
    m_strHeadLine = "";

    CFontLoader::CreateGDIFont(pMajor, 2, fontName, fontSize);
    fontBrush.SetColor(Color(200,200,250));
    fontFormat.SetFormatFlags(!StringFormatFlagsNoWrap);
    g.DrawString(CComBSTR(m_strText), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(40, 100, rect.right-250, rect.bottom), &fontFormat, &fontBrush);

    g.ReleaseHDC(pDC->GetSafeHdc());
}