BOOL ChooseBuildingDlg::OnInitDialog()
{
	m_pComboBox = (CComboBox *)GetDlgItem(IDC_CHOOSE_BUILDING_COMBO);
	assert( m_pComboBox );

	m_pUsingPointerButton = (CButton *)GetDlgItem(IDC_CHOOSE_BUILDING_USING_POINTER_BUTTON);
	assert( m_pUsingPointerButton );

	m_pCancelButton = (CButton *)GetDlgItem(IDCANCEL);
	assert( m_pCancelButton );

	m_pOKButton = (CButton *)GetDlgItem(IDOK);
	assert( m_pOKButton );

	if (EditorInterface::instance()->ObjectSelectOnlyMode()) {
		m_pModifiedBuildingPtr = (building_ptr_type *)EditorInterface::instance()->objectivesEditState.pModifiedBuildingPtr;
	} else {
		m_pModifiedBuildingPtr = new building_ptr_type;
		(*m_pModifiedBuildingPtr) = (*m_pBuildingPtr);
	}

	m_buildingList.Clear();
	EditorObjectMgr::BUILDING_LIST completeBuildingList = EditorObjectMgr::instance()->getBuildings();
	EditorObjectMgr::BUILDING_LIST::EConstIterator it2 = completeBuildingList.Begin();
	while (!it2.IsDone()) {
		//if ((BUILDING == typeNum) || (TREEBUILDING == typeNum)) {
		if (true) {
			m_buildingList.Append(*it2);
		}
		it2++;
	}

	EditorObjectMgr::BUILDING_LIST::EConstIterator it = m_buildingList.Begin();
	while (!it.IsDone()) {
		EString tmpEStr;
		Stuff::Vector3D pos = (*it)->getPosition();
		const char *szDisplayName = (*it)->getDisplayName(); // nb: localization
		assert(szDisplayName);
		tmpEStr.Format("(pos: %.3f, %.3f) %s", pos.x, pos.y, szDisplayName);
		m_pComboBox->AddString(tmpEStr.Data());
		it++;
	}

	if (1 <= m_buildingList.Count()) {
		m_pComboBox->SetCurSel(0);
	} else {
		AfxMessageBox(IDS_NO_STRUCTURES);
		OnCancel();
	}

	if (EditorInterface::instance()->ObjectSelectOnlyMode()) {
		// post a message that the USEPOINTER button was pressed
		PostMessage(WM_COMMAND, (WPARAM)BN_CLICKED, (LPARAM)m_pUsingPointerButton->m_hWnd);
	}
	return 1;
}
Esempio n. 2
0
bool EString::Remove( EString& Sub_String )
{
	int Index = Find( Sub_String );

	if ( Index != -1 )
	{
		return Remove( Index, Index + Sub_String.StrSize( Sub_String.Data() ) - 1 );
	}

	return false;
}
Esempio n. 3
0
void MPDirectTcpip::init(FitIniFile* file)
{
	LogisticsScreen::init( *file, "Static", "Text", "Rect", "Button" );

	if ( buttonCount )
	{
		for ( int i = 0; i < buttonCount; i++ )
		{
			if (buttons[i].getID() == 0)
			{
				buttons[i].setID(FIRST_BUTTON_ID + i);
			}
		}
	}


	{
		char path[256];
		strcpy( path, artPath );
		strcat( path, "mcl_mp_tcpip_combobox0.fit" );
		
		FitIniFile PNfile;
		if ( NO_ERR != PNfile.open( path ) )
		{
			char error[256];
			sprintf( error, "couldn't open file %s", path );
			Assert( 0, 0, error );
			return;
		}
		ipAddressComboBox.init(&PNfile, "TCIPNumberComboBox");

		aStyle7TextListItem *pTmp2;
		int i;
		for (i = 0; i < 15; i += 1)
		{
			pTmp2 = new aStyle7TextListItem;
			EString tmpStr;
			tmpStr.Format("Text0");
			pTmp2->init(&PNfile, tmpStr.Data());
			ipAddressComboBox.AddItem(pTmp2);
		}
		ipAddressComboBox.SelectItem(0);
	}
}
Esempio n. 4
0
long aGameListItem::init( FitIniFile* file, const char* blockName )
{
	file->seekBlock( blockName );

	long width = 0;
	long height = 0;
	file->readIdLong( "Width", width );
	file->readIdLong( "Height", height );

	EString graphicBlockName;
	graphicBlockName += "Static0";
	allTechGraphic.init(file, graphicBlockName.Data());
	if (allTechGraphic.height() + 5 > height)
	{
		height = allTechGraphic.height() + 5;
	}
	if (allTechGraphic.globalRight() - globalX() > width)
	{
		width = allTechGraphic.globalRight() - globalX();
	}

	EString textBlockName;
	textBlockName = "Text0";
	gameName.init(file, textBlockName.Data());
	if (gameName.height() > height)
	{
		height = gameName.height();
	}
	if (gameName.globalRight() - globalX() > width)
	{
		//width = gameName.globalRight() - globalX();
	}

	textBlockName = "Text1";
	numPlayers.init(file, textBlockName.Data());
	if (numPlayers.height() > height)
	{
		height = numPlayers.height();
	}
	if (numPlayers.globalRight() - globalX() > width)
	{
		//width = numPlayers.globalRight() - globalX();
	}

	textBlockName = "Text2";
	mapName.init(file, textBlockName.Data());
	if (mapName.height() > height)
	{
		height = mapName.height();
	}
	if (mapName.globalRight() - globalX() > width)
	{
		//width = mapName.globalRight() - globalX();
	}

	textBlockName = "Text3";
	latency.init(*file, textBlockName.Data());
	if (latency.height() > height)
	{
		height = latency.height();
	}
	if (latency.globalRight() - globalX() > width)
	{
		//width = latency.globalRight() - globalX();
	}

	EString rectBlockName;
	rectBlockName = "Rect0";
	allTechRect.init(file, rectBlockName.Data());
	if (allTechRect.height() > height)
	{
		height = allTechRect.height();
	}
	if (allTechRect.globalRight() - globalX() > width)
	{
		width = allTechRect.globalRight() - globalX();
	}

	rectBlockName = "Rect1";
	gameNameRect.init(file, rectBlockName.Data());
	if (gameNameRect.height() > height)
	{
		height = gameNameRect.height();
	}
	if (gameNameRect.globalRight() - globalX() > width)
	{
		width = gameNameRect.globalRight() - globalX();
	}

	rectBlockName = "Rect2";
	numPlayersRect.init(file, rectBlockName.Data());
	if (numPlayersRect.height() > height)
	{
		height = numPlayersRect.height();
	}
	if (numPlayersRect.globalRight() - globalX() > width)
	{
		width = numPlayersRect.globalRight() - globalX();
	}

	rectBlockName = "Rect3";
	mapNameRect.init(file, rectBlockName.Data());
	if (mapNameRect.height() > height)
	{
		height = mapNameRect.height();
	}
	if (mapNameRect.globalRight() - globalX() > width)
	{
		width = mapNameRect.globalRight() - globalX();
	}

	rectBlockName = "Rect4";
	latencyRect.init(file, rectBlockName.Data());
	if (latencyRect.height() > height)
	{
		height = latencyRect.height();
	}
	if (latencyRect.globalRight() - globalX() > width)
	{
		width = latencyRect.globalRight() - globalX();
	}

	pingIcon.init( file, "Static1" );

	aObject::init(0, 0, width, height);
	
	addChild(&allTechGraphic);
	addChild(&gameName);
	addChild(&numPlayers);
	addChild(&mapName);
	addChild(&latency);
	addChild(&allTechRect);
	addChild(&gameNameRect);
	addChild(&numPlayersRect);
	addChild(&mapNameRect);
	addChild(&latencyRect);
	addChild( &pingIcon );

	return 0;
}