コード例 #1
0
void CShop::DisplayShop( idUserInterface *gui ) {
	const idStr &curStartingMap = gameLocal.m_MissionManager->GetCurrentStartingMap();
	idStr filename = va( "maps/%s", curStartingMap.c_str() );
	// Let the GUI know which map to load
	gui->SetStateString( "mapStartCmd", va( "exec 'map %s'", curStartingMap.c_str() ) );
	// Load the map from the missiondata class (provides cached loading)
	idMapFile *mapFile = gameLocal.m_MissionData->LoadMap( filename );
	if( mapFile == NULL ) {
		// Couldn't load map
		gui->HandleNamedEvent( "SkipShop" );
		gameLocal.Warning( "Couldn't load map %s, skipping shop.", filename.c_str() );
		return;
	}
	// Load the shop items from the map entity/entities
	LoadFromMap( mapFile );
	if( _skipShop ) {
		// Shop data says: skip da shoppe
		gui->HandleNamedEvent( "SkipShop" );
		return;
	}
	// grayman (#2376) add "inv_map_start" items to the shop's list of starting items,
	// then check for lockpick duplications.
	AddMapItems( mapFile );
	// Add items from previous missions (which are marked as persistent)
	AddPersistentStartingEquipment();
	if( _pickSetShop ) {
		CheckPicks( _itemsForSale );
	}
	if( _pickSetStarting ) {
		CheckPicks( _startingItems );
	}
	// greebo: Update the amount of gold to spend based on the loot the player found earlier
	AddGoldFromPreviousMission();
	UpdateGUI( gui );
}
コード例 #2
0
int	WINAPI WKPluginShowEventX(char szEvent[128],HWND pParent,COleDateTime dt,BOOL bAskMenu)
{
	static long l=0;
	if(l>0){
		return 0;
	}
	SimpleTracker lc(l);

	CString sEventName=_l2("Scheduled event");
	HINSTANCE hLLHookInst=GetModuleHandle("WP_KeyMaster.wkp");
	_WKIHOTKEYS_GetHotkeyDscByID fpHk=(_WKIHOTKEYS_GetHotkeyDscByID)GetProcAddress(hLLHookInst,"WKIHOTKEYS_GetHotkeyDscByID");
	BOOL bDef=(strcmp(szEvent,DEF_ID)==0);
	if(fpHk){
		char szTitle[256]={0};
		if((*fpHk)(szEvent,szTitle,sizeof(szTitle))){
			sEventName=szTitle;
		}else{
			sEventName=_l2("Attention! Time has come!");
		}
	}
	_GetReminder fp=(_GetReminder)GetProcAddress(hRemin,"GetReminder");
	_IsReminderFamilyPresent fpPr=(_IsReminderFamilyPresent)GetProcAddress(hRemin,"IsReminderFamilyPresent");
	CString sRMKey=szEvent;
	// Возможно нужен выбор?
	CStringArray aTitles;
	CStringArray aKeys;
	if(bDef){
		aTitles.SetAtGrow(0,_l2("Add new reminder"));
		aKeys.SetAtGrow(0,sRMKey);
	}else{
		aTitles.SetAtGrow(0,_l2("Add new schedule"));
		aKeys.SetAtGrow(0,sRMKey);
	}
	CString sSelectedKey="";
	if(bAskMenu){
		int iMaxIndex=0;
		if(fpPr && (*fpPr)(sRMKey,&iMaxIndex)){
			aKeys[0]="";
			for(int i=0;i<=iMaxIndex;i++){
				if(fp){
					CWPReminder rem;
					strcpy(rem.szKey,GetNextPrefixedId(sRMKey,i));
					if((*fp)(rem.szKey,rem)){
						AddMapItems(aKeys,aTitles, rem.szKey, GetRemDsc(rem,TRUE));
					}
				}
			}
		}
		if(aKeys.GetSize()==1){
			sRMKey=aKeys[0];
		}else{
			CMenu menu;
			menu.CreatePopupMenu();
			CPoint pt;
			GetCursorPos(&pt);
			for(int i=0;i<aKeys.GetSize();i++){
				AddMenuString(&menu,WM_USER+i,aTitles[i]);
			}
			AddMenuString(&menu,WM_USER+aKeys.GetSize()+1,_l2("Close menu"));
			int iNum=::TrackPopupMenu(menu.GetSafeHmenu(), TPM_RETURNCMD|TPM_NONOTIFY|TPM_RIGHTBUTTON, pt.x, pt.y, 0, pParent, NULL);
			if(iNum==0 || iNum<WM_USER || iNum>=WM_USER+aKeys.GetSize()){
				return 0;
			}
			sSelectedKey=aKeys[iNum-WM_USER];
			if(sSelectedKey==""){
				sSelectedKey=calcNextPrefixedId(sRMKey);
			}
			sRMKey=sSelectedKey;
		}
	}
	BOOL bNewReminder=0;
	CWPReminder rem;
	memset(&rem,0,sizeof(CWPReminder));
	if(fp && sRMKey!=""){
		strcpy(rem.szKey,sRMKey);
		if(!(*fp)(rem.szKey,rem)){
			// Создаем новый!
			bNewReminder=1;
			//COleDateTime dt=COleDateTime::GetCurrentTime();
			dt=dt+COleDateTimeSpan(0,0,1,0);
			dt.GetAsSystemTime(rem.EventTime);
			rem.bActPopup=bDef;
			rem.bActSound=bActSound;
			rem.bLoopSound=bLoopSound;
			strcpy(rem.szText,sEventName);
			strcpy(rem.szSoundPath,szWavFilePath);
			if(!bDef){
				// Здесь именно оригинальный Id-Event!!!
				strcpy(rem.szReserved,szEvent);
			}
			_PutReminder fp2=(_PutReminder)GetProcAddress(hRemin,"PutReminder");
			if(fp2){
				(*fp2)(rem.szKey,rem);
			}
		}
	}
#ifdef _DEBUG
	WKGetPluginContainer()->ShowAlert(rem.szKey,"opened reminder");
#endif
	_CallModifyReminder fp1=(_CallModifyReminder)GetProcAddress(hRemin,"CallModifyReminder");
	if(fp1){
		int iRes=(*fp1)(rem.szKey,pParent,0);
		if(iRes==IDCANCEL && bNewReminder){
			_RemoveReminder fp3=(_RemoveReminder)GetProcAddress(hRemin,"RemoveReminder");
			if(fp3){
				(*fp3)(rem.szKey);
			}
		}
	}
	return 1;
}