Bazaar developer reference

CvNotifications::Activate(Notification &)

Defined in
CvNotifications.cpp, line 878
Class
CvNotifications
Hook name
CivHooks::CvNotifications_Activate_with_Notification

Hooks

static bool BeforeCvNotifications_Activate_with_Notification(CvNotifications* self, CvNotifications::Notification & notification);static void AfterCvNotifications_Activate_with_Notification(CvNotifications* self, CvNotifications::Notification & notification);static void ReplaceCvNotifications_Activate_with_Notification(void (*original)(CvNotifications*, CvNotifications::Notification &), CvNotifications* self, CvNotifications::Notification & notification);CivRegisterBefore<CivHooks::CvNotifications_Activate_with_Notification>(host, &BeforeCvNotifications_Activate_with_Notification);CivRegisterAfter<CivHooks::CvNotifications_Activate_with_Notification>(host, &AfterCvNotifications_Activate_with_Notification);CivRegisterReplace<CivHooks::CvNotifications_Activate_with_Notification>(host, &ReplaceCvNotifications_Activate_with_Notification);

Code

878void CvNotifications::Activate(Notification& notification)879{880	GC.GetEngineUserInterface()->ActivateNotification(notification.m_iLookupIndex, notification.m_eNotificationType, notification.m_strMessage, notification.m_iX, notification.m_iY, notification.m_iGameDataIndex, notification.m_iExtraGameData, m_ePlayer);881882	gDLL->GameplayMinimapNotification(notification.m_iX, notification.m_iY, notification.m_iLookupIndex+1);	// The index is used to uniquely identify each flashing dot on the minimap. We're adding 1 since the selected unit is always 0. It ain't pretty, but it'll work883884	switch(notification.m_eNotificationType)885	{886	case NOTIFICATION_WONDER_COMPLETED_ACTIVE_PLAYER:887	{888		CvPopupInfo kPopup(BUTTONPOPUP_WONDER_COMPLETED_ACTIVE_PLAYER, notification.m_iGameDataIndex, notification.m_iExtraGameData, notification.m_iX, notification.m_iY);889		GC.GetEngineUserInterface()->AddPopup(kPopup);890	}891	break;892	case NOTIFICATION_GREAT_WORK_COMPLETED_ACTIVE_PLAYER:893		{894			CvPopupInfo kPopup(BUTTONPOPUP_GREAT_WORK_COMPLETED_ACTIVE_PLAYER, notification.m_iGameDataIndex, notification.m_iExtraGameData, notification.m_iX, notification.m_iY);895			GC.GetEngineUserInterface()->AddPopup(kPopup);896		}897		break;898	case NOTIFICATION_BUY_TILE:899	{900		// Jon say - do like Sid would!901		CvCity* pCity = GET_PLAYER(m_ePlayer).getCapitalCity();902		if(pCity)903		{904			auto_ptr<ICvPlot1> pDllPlot = GC.WrapPlotPointer(pCity->plot());905			GC.GetEngineUserInterface()->lookAt(pDllPlot.get(), CAMERALOOKAT_NORMAL);906		}907	}908	break;909	case NOTIFICATION_TECH:910	case NOTIFICATION_FREE_TECH:911	{912		CvPopupInfo kPopup(BUTTONPOPUP_CHOOSETECH, m_ePlayer, notification.m_iGameDataIndex, notification.m_iExtraGameData);913		strcpy_s(kPopup.szText, notification.m_strMessage);914		GC.GetEngineUserInterface()->AddPopup(kPopup);915	}916	break;917	case NOTIFICATION_TECH_AWARD:918	{919		if(notification.m_iExtraGameData != -1)920		{921			CvPopupInfo kPopup(BUTTONPOPUP_TECH_AWARD, m_ePlayer, notification.m_iGameDataIndex, notification.m_iExtraGameData);922			strcpy_s(kPopup.szText, notification.m_strMessage);923			GC.GetEngineUserInterface()->AddPopup(kPopup);924		}925	}926	break;927	case NOTIFICATION_POLICY:928	case NOTIFICATION_FREE_POLICY:929	{930		CvPopupInfo kPopup(BUTTONPOPUP_CHOOSEPOLICY, m_ePlayer);931		GC.GetEngineUserInterface()->AddPopup(kPopup);932	}933	break;934	case NOTIFICATION_DIPLO_VOTE:935	{936		CvPopupInfo kPopup(BUTTONPOPUP_DIPLO_VOTE, m_ePlayer);937		GC.GetEngineUserInterface()->AddPopup(kPopup);938	}939	break;940	case NOTIFICATION_MINOR_QUEST:941	{942		int iQuestFlags = notification.m_iExtraGameData;943		CvPlot* pPlot = GC.getMap().plot(notification.m_iX, notification.m_iY);944		if(pPlot)945		{946			auto_ptr<ICvPlot1> pDllPlot = GC.WrapPlotPointer(pPlot);947			GC.GetEngineUserInterface()->lookAt(pDllPlot.get(), CAMERALOOKAT_NORMAL);948			gDLL->GameplayDoFX(pDllPlot.get());949		}950951		PlayerTypes ePlayer = (PlayerTypes)notification.m_iGameDataIndex;952		if (GET_PLAYER(ePlayer).isAlive())953		{954			GC.GetEngineUserInterface()->SetTempString(notification.m_strMessage);955			CvPopupInfo kPopup(BUTTONPOPUP_CITY_STATE_MESSAGE, notification.m_iGameDataIndex, iQuestFlags);956			GC.GetEngineUserInterface()->AddPopup(kPopup);957		}958	}959	break;960	case NOTIFICATION_PRODUCTION:961	{962		CvCity* pCity = GC.getMap().plot(notification.m_iX, notification.m_iY)->getPlotCity();//GET_PLAYER(m_ePlayer).getCity(notification.m_iGameDataIndex);963		if(!pCity)964		{965			return;966		}967968		CvPopupInfo kPopupInfo(BUTTONPOPUP_CHOOSEPRODUCTION);969970		kPopupInfo.iData1 = pCity->GetID();971972		kPopupInfo.bOption2 = false;	// Not in purchase mode973974		// slewis - do we need the stuff below?975		//kPopupInfo.setOption1(false);976977		OrderTypes eOrder = (OrderTypes) notification.m_iGameDataIndex;978		int iItemID = notification.m_iExtraGameData;979		kPopupInfo.iData2 = eOrder;980		kPopupInfo.iData3 = iItemID;981982		GC.GetEngineUserInterface()->AddPopup(kPopupInfo);983	}984	break;985#if defined(MOD_UI_CITY_EXPANSION)986	case NOTIFICATION_CITY_TILE:987	{988		if (MOD_UI_CITY_EXPANSION) {989			CvCity* pCity = GC.getMap().plot(notification.m_iX, notification.m_iY)->getPlotCity();990			if (!pCity) {991				return;992			}993994			// CUSTOMLOG("Activate NOTIFICATION_CITY_TILE for city %s at (%i, %i)", pCity->getName().c_str(), notification.m_iX, notification.m_iY)995			// We want the C++ equivalent of UI.SetInterfaceMode(INTERFACEMODE_PURCHASE_PLOT) followed by996			// UI.DoSelectCityAtPlot(pPlot) (which itself happens to be bugged!)997			// The following is identical to the "Select Next City" then "Open City View" keyboard short-cuts code,998			// but it always opens the capital's city view screen!999			// DLLUI->selectCity(GC.WrapCityPointer(pCity).get());1000			// DLLUI->setInterfaceMode(INTERFACEMODE_PURCHASE_PLOT);1001			// DLLUI->selectLookAtCity();1002			// DLLUI->lookAtSelectionPlot();1003		1004			// As the City View screen isn't a pop-up, we'll have to call a pop-up to open that screen and then immediately dismiss itself1005			int iModderOffset = gCustomMods.getOption("UI_CITY_EXPANSION_BUTTONPOPUP_MODDER_OFFSET", 0);1006			CvPopupInfo kPopupInfoOpen((ButtonPopupTypes) (BUTTONPOPUP_MODDER_0 + iModderOffset));1007			kPopupInfoOpen.iData1 = pCity->GetID();1008			kPopupInfoOpen.iData2 = notification.m_iLookupIndex;1009			GC.GetEngineUserInterface()->AddPopup(kPopupInfoOpen);1010		} else {1011			// Default behavior is to move the camera to the X,Y passed in1012			CvPlot* pPlot = GC.getMap().plot(notification.m_iX, notification.m_iY);1013			if (pPlot) {1014				auto_ptr<ICvPlot1> pDllPlot = GC.WrapPlotPointer(pPlot);10151016				GC.GetEngineUserInterface()->lookAt(pDllPlot.get(), CAMERALOOKAT_NORMAL);1017				gDLL->GameplayDoFX(pDllPlot.get());1018			}1019		}1020	}1021	break;1022#endif1023	case NOTIFICATION_UNIT_PROMOTION:1024	{1025		UnitHandle pUnit = GET_PLAYER(m_ePlayer).getUnit(notification.m_iExtraGameData);1026		if(pUnit)1027		{1028			CvPlot* pPlot = pUnit->plot();1029			if(pPlot)1030			{1031				auto_ptr<ICvPlot1> pDllPlot = GC.WrapPlotPointer(pPlot);1032				auto_ptr<ICvUnit1> pDllUnit = GC.WrapUnitPointer(pUnit.pointer());10331034				GC.GetEngineUserInterface()->lookAt(pDllPlot.get(), CAMERALOOKAT_NORMAL);1035				GC.GetEngineUserInterface()->selectUnit(pDllUnit.get(), false);1036				gDLL->GameplayDoFX(pDllPlot.get());1037			}1038		}1039	}1040	break;1041	case NOTIFICATION_PLAYER_DEAL:1042	{1043		GC.GetEngineUserInterface()->OpenPlayerDealScreen((PlayerTypes) notification.m_iX);1044	}1045	break;1046	case NOTIFICATION_PLAYER_DEAL_RECEIVED:1047	{1048#if defined(MOD_AI_MP_DIPLOMACY)1049		if (MOD_AI_MP_DIPLOMACY) {1050			PlayerTypes eFrom = static_cast<PlayerTypes>(notification.m_iX);1051			CvPlayer& kFrom = GET_PLAYER(eFrom);1052			if (kFrom.isHuman() && notification.m_iY != -2 /* request hack */)1053			{1054				// Keep old PvP notification behaviour1055				GC.GetEngineUserInterface()->OpenPlayerDealScreen(eFrom);1056			}1057			else1058			{1059				// This request was sent by an AI.1060				PlayerTypes eTo = notification.m_ePlayerID;1061				CvPlayer& kTo = GET_PLAYER(eTo);1062				kTo.GetDiplomacyRequests()->ActivateAllFrom(eFrom);1063			}1064		} else {1065#endif1066		GC.GetEngineUserInterface()->OpenPlayerDealScreen((PlayerTypes) notification.m_iX);1067#if defined(MOD_AI_MP_DIPLOMACY)1068		}1069#endif1070	}1071	break;1072	case NOTIFICATION_FREE_GREAT_PERSON:1073	{1074		if(GET_PLAYER(m_ePlayer).GetNumFreeGreatPeople() > 0)1075		{1076			CvPopupInfo kPopup(BUTTONPOPUP_CHOOSE_FREE_GREAT_PERSON, m_ePlayer, notification.m_iGameDataIndex, notification.m_iExtraGameData);1077			GC.GetEngineUserInterface()->AddPopup(kPopup);1078		}1079	}1080	break;1081	case NOTIFICATION_FOUND_PANTHEON:1082	{1083		CvPopupInfo kPopup(BUTTONPOPUP_FOUND_PANTHEON, m_ePlayer, true /*bPantheonBelief*/);1084		GC.GetEngineUserInterface()->AddPopup(kPopup);1085	}1086	break;10871088	case NOTIFICATION_ADD_REFORMATION_BELIEF:1089	{1090		CvPopupInfo kPopup(BUTTONPOPUP_FOUND_PANTHEON, m_ePlayer, false /*bPantheonBelief*/);1091		GC.GetEngineUserInterface()->AddPopup(kPopup);1092	}1093	break;10941095	case NOTIFICATION_FOUND_RELIGION:1096	case NOTIFICATION_ENHANCE_RELIGION:1097	{1098		CvPopupInfo kPopup(BUTTONPOPUP_FOUND_RELIGION, m_ePlayer);1099		kPopup.iData1 = notification.m_iX;1100		kPopup.iData2 = notification.m_iY;11011102		if(notification.m_eNotificationType == NOTIFICATION_FOUND_RELIGION)1103		{1104			kPopup.bOption1 = true;1105		}1106		else1107		{1108			kPopup.bOption1 = false;1109		}1110		GC.GetEngineUserInterface()->AddPopup(kPopup);1111	}1112	break;11131114	case NOTIFICATION_SPY_CREATED_ACTIVE_PLAYER:1115	case NOTIFICATION_SPY_EVICTED:1116	case NOTIFICATION_SPY_PROMOTION:1117	{1118		CvPopupInfo kPopup(BUTTONPOPUP_ESPIONAGE_OVERVIEW, m_ePlayer);1119		GC.GetEngineUserInterface()->AddPopup(kPopup);1120	}1121	break;11221123	case NOTIFICATION_SPY_STOLE_TECH:1124	{1125		CvPopupInfo kPopup(BUTTONPOPUP_CHOOSE_TECH_TO_STEAL, m_ePlayer, notification.m_iGameDataIndex, notification.m_iExtraGameData);1126		strcpy(kPopup.szText, notification.m_strMessage);1127		GC.GetEngineUserInterface()->AddPopup(kPopup);1128	}1129	break;11301131	case NOTIFICATION_MAYA_LONG_COUNT:1132	{1133		if(GET_PLAYER(m_ePlayer).GetNumMayaBoosts() > 0)1134		{1135			CvPopupInfo kPopup(BUTTONPOPUP_CHOOSE_MAYA_BONUS, m_ePlayer, notification.m_iGameDataIndex, notification.m_iExtraGameData);1136			GC.GetEngineUserInterface()->AddPopup(kPopup);1137		}1138	}1139	break;11401141	case NOTIFICATION_FAITH_GREAT_PERSON:1142	{1143		if(GET_PLAYER(m_ePlayer).GetNumFaithGreatPeople() > 0)1144		{1145			CvPopupInfo kPopup(BUTTONPOPUP_CHOOSE_FAITH_GREAT_PERSON, m_ePlayer, notification.m_iGameDataIndex, notification.m_iExtraGameData);1146			GC.GetEngineUserInterface()->AddPopup(kPopup);1147		}1148	}1149	break;11501151	case NOTIFICATION_TECH_STOLEN_SPY_IDENTIFIED:1152	case NOTIFICATION_SPY_KILLED_A_SPY:1153	{1154		CvAssertMsg(notification.m_iGameDataIndex >= 0, "notification.m_iGameDataIndex is out of bounds");1155		if(notification.m_iGameDataIndex >= 0 && notification.m_iExtraGameData == -1)1156		{1157			PlayerTypes eTargetPlayer = (PlayerTypes)notification.m_iGameDataIndex;1158			if (!GET_PLAYER(eTargetPlayer).isHuman())1159			{1160				GET_PLAYER((PlayerTypes)notification.m_iGameDataIndex).GetDiplomacyAI()->DoBeginDiploWithHumanEspionageResult();1161			}11621163			GC.GetEngineUserInterface()->RemoveNotification(notification.m_iLookupIndex, m_ePlayer);1164			notification.m_iExtraGameData = 1; // slewis hack to mark notification as seen so we don't re-enter diplomacy1165		}1166	}1167	break;11681169	case NOTIFICATION_INTRIGUE_DECEPTION:1170	case NOTIFICATION_INTRIGUE_SNEAK_ATTACK_ARMY_AGAINST_KNOWN_CITY_KNOWN:1171	case NOTIFICATION_INTRIGUE_SNEAK_ATTACK_ARMY_AGAINST_KNOWN_CITY_UNKNOWN:1172	case NOTIFICATION_INTRIGUE_SNEAK_ATTACK_AMPHIB_AGAINST_KNOWN_CITY_UNKNOWN:1173	case NOTIFICATION_INTRIGUE_SNEAK_ATTACK_AMPHIB_AGAINST_KNOWN_CITY_KNOWN:1174		CvAssertMsg(notification.m_iGameDataIndex >= 0, "notification.m_iGameDataIndex is out of bounds");1175		if(notification.m_iGameDataIndex >= 0)1176		{1177			PlayerTypes ePlayerToContact = (PlayerTypes)notification.m_iGameDataIndex;1178			if (!GET_PLAYER(ePlayerToContact).isHuman() && ePlayerToContact != m_ePlayer && GET_PLAYER(m_ePlayer).GetEspionage()->HasRecentIntrigueAbout(ePlayerToContact) && !GET_TEAM(GET_PLAYER(m_ePlayer).getTeam()).isAtWar(GET_PLAYER(ePlayerToContact).getTeam()))1179			{1180				GET_PLAYER(ePlayerToContact).GetDiplomacyAI()->DoBeginDiploWithHumanInDiscuss();1181			}1182		}1183		break;11841185	case NOTIFICATION_LEAGUE_CALL_FOR_PROPOSALS:1186	case NOTIFICATION_LEAGUE_CALL_FOR_VOTES:1187	case NOTIFICATION_LEAGUE_VOTING_DONE:1188	case NOTIFICATION_LEAGUE_VOTING_SOON:1189		CvAssertMsg(notification.m_iGameDataIndex >= 0, "notification.m_iGameDataIndex is out of bounds");1190		if (notification.m_iGameDataIndex >= 0)1191		{1192			LeagueTypes eLeague = (LeagueTypes) notification.m_iGameDataIndex;1193			CvPopupInfo kPopup(BUTTONPOPUP_LEAGUE_OVERVIEW, eLeague);1194			GC.GetEngineUserInterface()->AddPopup(kPopup);1195		}1196		break;11971198	case NOTIFICATION_IDEOLOGY_CHOSEN:1199	case NOTIFICATION_CULTURE_VICTORY_SOMEONE_INFLUENTIAL:1200	case NOTIFICATION_CULTURE_VICTORY_WITHIN_TWO:1201	case NOTIFICATION_CULTURE_VICTORY_WITHIN_TWO_ACTIVE_PLAYER:1202	case NOTIFICATION_CULTURE_VICTORY_WITHIN_ONE:1203	case NOTIFICATION_CULTURE_VICTORY_WITHIN_ONE_ACTIVE_PLAYER:1204	case NOTIFICATION_CULTURE_VICTORY_NO_LONGER_INFLUENTIAL:1205		CvAssertMsg(notification.m_iGameDataIndex >= 0, "notification.m_iGameDataIndex is out of bounds");1206		if (notification.m_iGameDataIndex >= 0)1207		{1208			CvPopupInfo kPopup(BUTTONPOPUP_CULTURE_OVERVIEW);1209			kPopup.iData2 = 3; // Tab to select1210			GC.GetEngineUserInterface()->AddPopup(kPopup);1211		}1212		break;12131214	case NOTIFICATION_CHOOSE_ARCHAEOLOGY:1215		CvAssertMsg(notification.m_iGameDataIndex >= 0, "notification.m_iGameDataIndex is out of bounds");1216		if (notification.m_iGameDataIndex >= 0)1217		{1218			CvPopupInfo kPopup(BUTTONPOPUP_CHOOSE_ARCHAEOLOGY, m_ePlayer);1219			GC.GetEngineUserInterface()->AddPopup(kPopup);1220		}1221		break;12221223	case NOTIFICATION_CHOOSE_IDEOLOGY:1224		CvAssertMsg(notification.m_iGameDataIndex >= 0, "notification.m_iGameDataIndex is out of bounds");1225		if (notification.m_iGameDataIndex >= 0)1226		{1227			CvPopupInfo kPopup(BUTTONPOPUP_CHOOSE_IDEOLOGY, m_ePlayer);1228			GC.GetEngineUserInterface()->AddPopup(kPopup);1229		}1230		break;12311232	case NOTIFICATION_LEAGUE_PROJECT_COMPLETE:1233		CvAssertMsg(notification.m_iGameDataIndex >= 0, "notification.m_iGameDataIndex is out of bounds");1234		if (notification.m_iGameDataIndex >= 0)1235		{1236			LeagueTypes eLeague = (LeagueTypes) notification.m_iGameDataIndex;1237			LeagueProjectTypes eProject = (LeagueProjectTypes) notification.m_iExtraGameData;1238			CvPopupInfo kPopup(BUTTONPOPUP_LEAGUE_PROJECT_COMPLETED, eLeague, eProject);1239			GC.GetEngineUserInterface()->AddPopup(kPopup);1240		}1241		break;12421243	default:	// Default behavior is to move the camera to the X,Y passed in1244	{1245		CvPlot* pPlot = GC.getMap().plot(notification.m_iX, notification.m_iY);1246		if(pPlot)1247		{1248			auto_ptr<ICvPlot1> pDllPlot = GC.WrapPlotPointer(pPlot);12491250			GC.GetEngineUserInterface()->lookAt(pDllPlot.get(), CAMERALOOKAT_NORMAL);1251			gDLL->GameplayDoFX(pDllPlot.get());1252		}1253	}1254	break;1255	}1256}

Calls

Called by