void CEntKeyFindReplace::OnReplace() 
{
	// quick check, if no key value is specified then there's not much to do...
	//
	UpdateData(DIALOG_TO_DATA);
	if (m_strFindKey.IsEmpty())
	{
		ErrorBox("Empty FIND <key>!\n\n(This is only permitted for FIND, not replace, for safety reasons)");
	}
	else
	{
		if (!m_strFindValue.IsEmpty() || GetYesNo(va("Empty FIND <value> means replace any existing ( & non-blank ) <value> for <key> \"%s\"\n\nProceed?",(LPCSTR)m_strFindKey)))
		{
			// another check, if they're trying to do a replace with a missing replace key, it'll just delete found keys...
			//
			if ((!m_strReplaceKey.IsEmpty() && !m_strReplaceValue.IsEmpty()) || GetYesNo(va("Empty REPLACE <key> or <value> fields will just delete all occurence of <key> \"%s\"\n\nProceed?",m_strFindKey)))
			{
				if (GetYesNo("Sure?"))
				{
					CopyFields();
					EndDialog(ID_RET_REPLACE);
				}
			}
		}
	}
}
示例#2
0
文件: callback.c 项目: dervish77/adgf
void file_quit(Widget w, void *data)
{
   MyProgram *me=data;
   int okay;
   char *new_file_name;

   /* Do any cleanup that is necessary for your program here */

   if (me->project_saved == FALSE)
   {
      okay = GetYesNo("Model file not saved!!\n\nDo you want to save it now?");  
      if (okay)
      {
         printf("saving model ...\n");

         if (strlen(me->save_file_name) == 0)
         {
            new_file_name = GetString("Enter file name to save as (file.mdl)\n", "");

            if (strlen(new_file_name) < FILE_STRING_LEN)
               strcpy(me->save_file_name, new_file_name);
            else {
               strncpy(me->save_file_name, new_file_name, FILE_STRING_LEN);
               me->save_file_name[FILE_STRING_LEN - 1] = '\0';
            }
         }

         me->save_file = fopen(me->save_file_name, "w");
         if (me->save_file == (FILE *) NULL)
         {
            fprintf(stderr, "file_quit: can't open '%s' as model file", me->save_file_name);
            exit(1);
         }

/*
         SaveModel(me);
*/

         me->project_saved = TRUE;

         fclose(me->save_file);

         printf("done saving\n");
      }
   }

   okay = GetYesNo("Do you really want to quit?");  
   if (okay)
   {
      printf("We're out of here!!!\n");
      exit(0);
   }
}
示例#3
0
文件: mainfrm.cpp 项目: DT85/ModView
void CMainFrame::OnFileWriteideal() 
{
	if (GetYesNo(va("Write \"<modelname>.ideal\" file\n\nAre you sure?")))
	{
		AppVars_WriteIdeal();
	}
}
示例#4
0
// do a quick mem test to check for any potential future mem problems...
//
static void QuickMemTest(void)
{
//	if (!Sys_LowPhysicalMemory())
	{
		const int iMemTestMegs = 128;	// useful search label
		// special test, 
		void *pvData = malloc(iMemTestMegs * 1024 * 1024);
		if (pvData)
		{
			free(pvData);
		}
		else
		{
			// err...
			//
			LPCSTR psContinue = re.Language_IsAsian() ? 
								"Your machine failed to allocate %dMB in a memory test, which may mean you'll have problems running this game all the way through.\n\nContinue anyway?"
								: 
								SE_GetString("CON_TEXT_FAILED_MEMTEST");
								// ( since it's too much hassle doing MBCS code pages and decodings etc for MessageBox command )

			#define GetYesNo(psQuery)	(!!(MessageBox(NULL,psQuery,"Query",MB_YESNO|MB_ICONWARNING|MB_TASKMODAL)==IDYES))
			if (!GetYesNo(va(psContinue,iMemTestMegs)))
			{
				LPCSTR psNoMem = re.Language_IsAsian() ?
								"Insufficient memory to run this game!\n"
								:
								SE_GetString("CON_TEXT_INSUFFICIENT_MEMORY");
								// ( since it's too much hassle doing MBCS code pages and decodings etc for MessageBox command )

				Com_Error( ERR_FATAL, psNoMem );
			}
		}
	}
}
示例#5
0
int     DebugHalt       (void)
{
    if (GetYesNo ((char *) "Halt; y = continue, n = quit program") == 'n')
        exit (1);

    errors++;

    return 0;
}
示例#6
0
文件: callback.c 项目: dervish77/adgf
void file_close(Widget w, void *data)
{
   MyProgram *me=data;
   int okay;
   char *new_file_name;

   if (me->project_saved == FALSE)
   {
      okay = GetYesNo("Model file not saved!!\n\nDo you want to save it now?");  
      if (okay)
      {
         if (strlen(me->save_file_name) == 0)
         {
            new_file_name = GetString("Enter file name to save as (file.mdl)\n", NULL);

            if ( (new_file_name != (char *) NULL) 
			&& (strlen(new_file_name) > 0) )
            {
               if (strlen(new_file_name) < FILE_STRING_LEN)
                  strcpy(me->save_file_name, new_file_name);
               else {
                  strncpy(me->save_file_name, new_file_name, FILE_STRING_LEN);
                  me->save_file_name[FILE_STRING_LEN - 1] = '\0';
               }
            }
            else
            {
               printf("saving cancelled\n");
               okay = FALSE;
            }
         }

         if (okay)
         {
            me->save_file = fopen(me->save_file_name, "w");
            if (me->save_file == (FILE *) NULL)
            {
               fprintf(stderr, "file_close: can't open '%s' as model file\n", me->save_file_name);
               exit(1);
            }

/*
            SaveModel(me);
*/

            me->project_saved = TRUE;

            fclose(me->save_file);
         }
      }
   }

   InitDatabase(me);
   UpdateDisplay(me);
   
   printf("files closed\n");
}
示例#7
0
int     PerhapsQuit     (void)
{
    if (!forceable)
        exit (1);

    if (GetYesNo ((char *) "Serious error, quit program") != 'n')
        exit (1);

    errors++;

    return 0;
}
示例#8
0
文件: callback.c 项目: dervish77/adgf
void opt_dump_database(Widget w, void *data)
{
   MyProgram *me=data;
   int okay;

   okay = GetYesNo("Do you really want to\ndump the entire database?"); 

   if (okay == TRUE)
   {
      printf("dumping database ... ");
      DumpDatabase(me);
      printf("done dumping\n");
   }
}
示例#9
0
libusb_device_handle*   open_usb    (int bFailAllowed = 0)
{
    int n = 5;
    while (0 == (handle = libusb_open_device_with_vid_pid (NULL, 0x1f3a, 0xefe8)))
      {
        if (bFailAllowed)
            return 0;

        switch (errno)
          {
            case EACCES:
                fprintf (stderr, "ERROR: Allwinner USB FEL device access denied\n");
                break;
            default:
                fprintf (stderr, "ERROR: Allwinner USB FEL device not found\n");
                break;
          }

        if (n == 0)
          {
            if (GetYesNo ((char *) "Retry USB device access") != 'y')
                exit (1);
          }
        else
          {
            n--;
            usleep(500000);
          }
      }

    rc = libusb_claim_interface (handle, 0);            // claim interface

#if defined(__linux__)
    if (rc != LIBUSB_SUCCESS)                           // if claim rejected,
      {
        libusb_detach_kernel_driver (handle, 0);        // tell kernel to release
        detached_iface = 0;                             // > -1 = restore later
        rc = libusb_claim_interface (handle, 0);        // try to claim again
      }
#endif

    assert (rc == 0);                                   // die if error

    return handle;
}
示例#10
0
文件: callback.c 项目: dervish77/adgf
void opt_status(Widget w, void *data)
{
   MyProgram *me=data;
   int okay;
   char status[300], string[50];

   sprintf(status, "Current Status\n--------------\n");

   sprintf(string, "\nLoad File = %s\n", me->load_file_name);
   strcat(status, string);

   sprintf(string, "Save File = %s\n", me->save_file_name);
   strcat(status, string);

   sprintf(string, "\nNumber of Systems = %d out of %d\n", me->data.psys_count, MAX_PSYSTEMS);
   strcat(status, string);

   sprintf(string, "\nDatabase size = %d bytes\n", sizeof(*me));
   strcat(status, string);

   switch(me->view_screen_mode)
   {
      case ALL_VIEW:
         sprintf(string, "\nView Mode = All\n");
         break;
      case ORTH_XY_VIEW:
         sprintf(string, "\nView Mode = XY\n");
         break;
      case ORTH_ZY_VIEW:
         sprintf(string, "\nView Mode = ZY\n");
         break;
      case ORTH_XZ_VIEW:
         sprintf(string, "\nView Mode = XZ\n");
         break;
      case CAMERA_VIEW:
         sprintf(string, "\nView Mode = Camera\n");
         break;
   }
   strcat(status, string);

   okay = GetYesNo(status); 
}
示例#11
0
文件: Model.cpp 项目: DT85/Assimilate
void CModelPropPage::OnOK() 
{
	if (!m_bMakeSkel && !m_strSkelPath.IsEmpty())
	{
		// actually, this SHOULD just cancel the OnOK and stay in the dialog (according to the windoze docs,
		//	but of course being microsoft, it doesn't bloody work, and just cancels, so I adapted the message...
		//
		if (!GetYesNo("Warning, you have a make-skeleton path entered, but 'makeskel' is OFF, this will lose that path info when this dialog closes.\n\nProceed? ('NO' is the same as clicking 'CANCEL')"))
			return;
	}

	m_model->SetOriginX(m_iOriginX);
	m_model->SetOriginY(m_iOriginY);
	m_model->SetOriginZ(m_iOriginZ);

	m_model->SetSkew90(!!m_bSkew90);
	m_model->SetSmooth(!!m_bSmooth);
	m_model->SetLoseDupVerts(!!m_bLoseDupVerts);
	m_model->SetMakeSkin(!!m_bMakeSkin);
	m_model->SetMakeSkelPath(m_bMakeSkel?(LPCSTR)m_strSkelPath:"");

	m_model->SetScale(m_fScale);
	m_model->SetKeepMotion(!!m_bKeepMotion);
	m_model->SetPreQuat(!!m_bPreQuat);

	m_model->PCJList_Clear();
	for (int i=0; i<GetPCJEntries(); i++)
	{
		m_model->PCJList_AddEntry(GetPCJEntry(i));
	}

	m_model->SetRefGLAPath(m_strRefGLAPath);


	*m_soilFlag = true;

	CPropertyPage::OnOK();
}
示例#12
0
//
// this actually reads XSI or GLA headers...  historical mutation strikes again...
//
static void ReadASEHeader_Actual(LPCSTR psFilename, int &iStartFrame, int &iFrameCount, int &iFrameSpeed, bool bReadingGLA, bool bCanSkipXSIRead /* = false */)
{
	// since the XSI loader is so damn slow and flakey I'm going to have to cache the info to avoid re-reading...
	//

	// do we have it in the cache?...
	//
	if (strstr(psFilename,".xsi") || strstr(psFilename,".XSI"))
	{
		ASECachedInfo_t::iterator iter = ASECachedInfo.find(psFilename);
		if (iter != ASECachedInfo.end())
		{
			iStartFrame = 0;
			iFrameCount = (*iter).second.first;
			iFrameSpeed = (*iter).second.second;
			return;
		}
	}

	// is it a GLA file?...
	//
	if (bReadingGLA)
	{
		char sTemp[1024];
		strcpy(sTemp,psFilename);
		if (!(strstr(psFilename,".gla") || strstr(psFilename,".GLA")))
		{
			strcat(sTemp,".gla");
		}

		iStartFrame = 0;
		iFrameCount = GLA_ReadHeader(sTemp);
		iFrameSpeed = 20;	// any old value for GLA file
		return;
	}


	// it's not in the cache, but we may be able to avoid having to read it under some circumstances...
	//
	bool bXSIShouldBeRead = true;

	if (gbCarWash_DoingScan)
	{
		bCanSkipXSIRead = false;	// stop it asking the question
		bXSIShouldBeRead= gbCarWash_YesToXSIScan;
	}

	if ( (strstr(psFilename,".xsi") || strstr(psFilename,".XSI"))
		&& bCanSkipXSIRead
		)
	{
		if (!gbSkipXSIRead && !gbSkipXSIRead_QuestionAsked)
		{
			gbSkipXSIRead_QuestionAsked = true;
			gbSkipXSIRead = !GetYesNo(va("Model file: \"%s\"\n\n... is an XSI, and they can be damn slow to read in\n\nDo you want to scan all the XSIs?",psFilename));
		}
					
		bXSIShouldBeRead = !gbSkipXSIRead;
	}

	if (strstr(psFilename,".xsi") || strstr(psFilename,".XSI"))
	{
		if (bXSIShouldBeRead)
		{
			ReadXSIHeader(psFilename, iStartFrame, iFrameCount, iFrameSpeed);
	
			if (iFrameCount!=0)
			{
				// cache it for future...
				//
				ASECachedInfo[psFilename] = FrameCountAndSpeed_t(iFrameCount,iFrameSpeed);
			}
		}
		return;
	}

	// it must be an ASE file then instead....
	//
	CTokenizer* tokenizer = CTokenizer::Create();
	tokenizer->AddParseFile(psFilename, ((CAssimilateApp*)AfxGetApp())->GetBufferSize());
	tokenizer->SetSymbols(CSequence_s_Symbols);
	tokenizer->SetKeywords(CSequence_s_Keywords);

	CToken* curToken = tokenizer->GetToken();
	while(curToken != NULL)
	{
		switch (curToken->GetType())
		{
		case TK_EOF:
			curToken->Delete();
			curToken = NULL;
			break;
		case TK_ASTERISK:
			curToken->Delete();
			curToken = tokenizer->GetToken();
			switch(curToken->GetType())
			{
			case TK_ASE_FIRSTFRAME:
				curToken->Delete();
				curToken = tokenizer->GetToken();
				if (curToken->GetType() == TK_INTEGER)
				{
					iStartFrame = curToken->GetIntValue();
					curToken->Delete();
					curToken = tokenizer->GetToken();
				}
				break;
			case TK_ASE_LASTFRAME:
				curToken->Delete();
				curToken = tokenizer->GetToken();
				if (curToken->GetType() == TK_INTEGER)
				{
					iFrameCount = curToken->GetIntValue() + 1;
					curToken->Delete();
					curToken = NULL;	// tells outer loop to finish
				}
				break;
			case TK_ASE_FRAMESPEED:
				curToken->Delete();
				curToken = tokenizer->GetToken();
				if (curToken->GetType() == TK_INTEGER)
				{
					iFrameSpeed = curToken->GetIntValue();
					curToken->Delete();
					curToken = tokenizer->GetToken();
				}
				break;
			case TK_EOF:
				curToken->Delete();
				curToken = NULL;
				break;
			default:
				curToken->Delete();
				curToken = tokenizer->GetToken();
				break;
			}
			break;
		default:
			curToken->Delete();
			curToken = tokenizer->GetToken();
			break;
		}
	}
	tokenizer->Delete();

	iFrameCount -= iStartFrame;	
	iStartFrame  = 0;
}
示例#13
0
/*
============
Entity_Write
============
*/
void Entity_Write (entity_t *e, FILE *f, qboolean use_region)
{
	epair_t		*ep;
	brush_t		*b;
	vec3_t		origin;
	char		text[128];
	int			count;

	// if none of the entities brushes are in the region,
	// don't write the entity at all
	if (use_region)
	{
		// in region mode, save the camera position as playerstart
		if ( !strcmp(ValueForKey (e, "classname"), "info_player_start") )
		{
			// see if this ent is entirely within the region first...
			//
			bool bWithinRegion = true;
			for (b=e->brushes.onext ; b != &e->brushes ; b=b->onext)
				if (Map_IsBrushFiltered(b))
					bWithinRegion = false;

			// if the player_start is NOT within the region, then use the camera position instead, else keep it...
			//
			if (!bWithinRegion || !GetYesNo("\"player_info_start\" found within region, keep it?\n\n( 'NO' will generate a new one from the current camera position )"))
			{
				fprintf (f, "{\n");
				fprintf (f, "\"classname\" \"info_player_start\"\n");
				fprintf (f, "\"origin\" \"%i %i %i\"\n", (int)g_pParentWnd->GetCamera()->Camera().origin[0],
					(int)g_pParentWnd->GetCamera()->Camera().origin[1], (int)g_pParentWnd->GetCamera()->Camera().origin[2]);
				fprintf (f, "\"angle\" \"%i\"\n", (int)g_pParentWnd->GetCamera()->Camera().angles[YAW]);
				fprintf (f, "}\n");
				return;
			}
		}

		for (b=e->brushes.onext ; b != &e->brushes ; b=b->onext)
			if (!Map_IsBrushFiltered(b))
				break;	// got one

		if (b == &e->brushes)
			return;		// nothing visible
	}

	// if fixedsize, calculate a new origin based on the current
	// brush position
	if (e->eclass->fixedsize)
	{
#ifdef SOF
	// I know these 2 do the same thing, but if that VectorSubtract ever gets re-instated it'll break ours -slc
	if (strnicmp(e->eclass->name, "misc_",			5) == 0 ||
		strnicmp(e->eclass->name, "light_",			6) == 0 ||
		strnicmp(e->eclass->name, "m_",				2) == 0 ||
		strnicmp(e->eclass->name, "item_weapon_",	12)== 0 ||
		strnicmp(e->eclass->name, "item_ammo_",		10)== 0
		)
	{
		VectorCopy(e->origin, origin);
	}
#else
    if (strnicmp(e->eclass->name, "misc_model",10) == 0 && e->md3Class != NULL)
    {
      VectorCopy(e->origin, origin);
		  //VectorSubtract (e->brushes.onext->mins, e->md3Class->mins, origin);
    }
#endif
    else
    {
		  VectorSubtract (e->brushes.onext->mins, e->eclass->mins, origin);
    }
    sprintf (text, "%i %i %i", (int)origin[0], (int)origin[1], (int)origin[2]);
		SetKeyValue (e, "origin", text);
	}

	fprintf (f, "{\n");
	for (ep = e->epairs ; ep ; ep=ep->next)
		fprintf (f, "\"%s\" \"%s\"\n", ep->key, ep->value);

	if (!e->eclass->fixedsize)
	{
		count = 0;
		for (b=e->brushes.onext ; b != &e->brushes ; b=b->onext)
		{
			if (!use_region || !Map_IsBrushFiltered (b))
      {
				fprintf (f, "// brush %i\n", count);
				count++;
				Brush_Write (b, f);
			}
		}
	}
	fprintf (f, "}\n");
}
示例#14
0
文件: Model.cpp 项目: DT85/Assimilate
void CModel::Resequence(bool bReScanASEFiles /* = false */)
{
	CWaitCursor wait;
	CRect Rect;

	CProgressCtrl *pProgress = NULL;

	if (bReScanASEFiles && ((CAssimilateApp*)AfxGetApp())->m_pMainWnd)
	{
		pProgress = new CProgressCtrl;
		bool bOK = !!pProgress->Create(	WS_CHILD|WS_VISIBLE|PBS_SMOOTH,		// DWORD dwStyle, 
									CRect(100,100,200,200),				// const RECT& rect, 
									((CAssimilateApp*)AfxGetApp())->m_pMainWnd,	// CWnd* pParentWnd, 
									1									// UINT nID 
									);
		if (!bOK)
		{
			delete pProgress;
			pProgress = NULL;
		}
	}
	
	int iTotMasterSequences = GetTotMasterSequences();
	if (pProgress)
	{			
		pProgress->SetRange(0,iTotMasterSequences);
	}
	int iSequenceNumber=0;

	int curFrame = 0;
	CSequence* curSequence = m_sequences;
	while(curSequence != NULL)
	{
		if (pProgress)
		{
			pProgress->SetPos(iSequenceNumber++);
			wait.Restore();
		}
		
		// mark current enums as valid or not...

		curSequence->SetValidEnum(((CAssimilateApp*)AfxGetApp())->ValidEnum(curSequence->GetEnum()));
	
		for (int _i=0; _i<MAX_ADDITIONAL_SEQUENCES; _i++)
		{
			CSequence *additionalSeq = curSequence->AdditionalSeqs[_i];

			additionalSeq->SetValidEnum(((CAssimilateApp*)AfxGetApp())->ValidEnum(additionalSeq->GetEnum()));
		}

		if ( bReScanASEFiles )
		{
			// new code, first of all check for changed framecounts (ie updated ASE file), and update sequence if nec...

			CString nameASE = ((CAssimilateApp*)AfxGetApp())->GetQuakeDir();
					nameASE+= curSequence->GetPath();

			if (!FileExists(nameASE))
			{
				if (gbCarWash_DoingScan)
				{
					strCarWashErrors += va("Model file missing: \"%s\"\n",nameASE);
				}
				else
				{
					if ( gbReportMissingASEs )
					{	
						gbReportMissingASEs = GetYesNo(va("Model file missing: \"%s\"\n\nContinue recieving this message?",nameASE));
					}
				}
			}
			else
			{
				int iStartFrame, iFrameCount, iFrameSpeed;

				iFrameCount = curSequence->GetFrameCount();	// default it in case we skip an XSI read
				iFrameSpeed = curSequence->GetFrameSpeed();	// default it in case we cache this file

				curSequence->ReadASEHeader( nameASE, iStartFrame, iFrameCount, iFrameSpeed, true);	// true = can skip XSI read

				if ( iFrameCount != curSequence->GetFrameCount() )
				{
					if (gbCarWash_DoingScan)
					{
						strCarWashErrors += va("file: \"%s\" has a framecount of %d, but .CAR file says %d\n",nameASE,iFrameCount,curSequence->GetFrameCount());
					}
					else
					{
						// don't mention it if the current count is zero, it's probably a new anim we've just added...

						if ( curSequence->GetFrameCount() )
						{
							if (giFixUpdatedASEFrameCounts == YES || giFixUpdatedASEFrameCounts == NO)
							{
								CYesNoYesAllNoAll query(	va("Model file: \"%s\"",nameASE),
															"",
															va("... has a framecount of %d instead of %d as the QDT/CAR file says",iFrameCount, curSequence->GetFrameCount()),
															"",
															"",
															"Do you want me to fix this?"
															);
								giFixUpdatedASEFrameCounts = query.DoModal();
							}
						}

						// update the sequence?...

						if (giFixUpdatedASEFrameCounts == YES || giFixUpdatedASEFrameCounts == YES_ALL 
							|| !curSequence->GetFrameCount()	// update: I think this should be here?
							)
						{
							curSequence->SetFrameCount( iFrameCount );
						}
					}
				}
			}

			// findmeste:	this no longer seems to do anything under JK2, presumablt EF1-only?
#if 0
			// now try to do any auto-associate between the ASE filename base and the existing enums, 
			//	so if we find (eg) /...../...../CROUCH.ASE and we have BOTH_CROUCH then auto-set the enum to BOTH_CROUCH

			CString stringASEName = nameASE;
			Filename_BaseOnly(stringASEName);	// now = (eg) "falldeath" or "injured" etc 			

			for (int i=0; ; i++)
			{
				LPCSTR p = ((CAssimilateApp*)AfxGetApp())->GetEnumEntry(i);	

				if (!p)		// EOS?
					break;

				CString stringEnum = p;

				// note, I could check stuff like "IsEnumSeperator(LPCSTR lpString)" on <p>, but you'd never
				//	have one of those enums assigned to a sequence anyway.

				char *psEnumPosAfterUnderScore = strchr(stringEnum,'_');
				if (psEnumPosAfterUnderScore++)	// check it, and skip to next char 
				{
					// does this enum match the ASE name?

					if ( !stricmp( psEnumPosAfterUnderScore, stringASEName ) )
					{
						// ok, we've found a good candidate, so set it...  (no need for query-prev code, but I wanted to)

						if ( strcmp( curSequence->GetEnum(), stringEnum))
						{
							curSequence->SetEnum(stringEnum);
						}
					}
				}
				else
				{						
					// this should never happen...

					if (gbCarWash_DoingScan)
					{
						strCarWashErrors += va("found an anim enum with no underscore: \"%s\"\n",stringEnum);
					}
					else
					{
						ASSERT(0);
						ErrorBox(va("Error! Somehow I found an anim enum with no underscore: \"%s\"",stringEnum));
					}
				}
			}
#endif
		}

		// More bollox for Gummelt... :-)
		// now do the other freaky trick (you'd better be grateful for all this Mike!!! <g>), which is:

		// If you find the substring DEATH in this (master) sequence's enum, then ensure that the first *additional*
		//	sequence of it is set to be the corresponding DEAD enum, but using the last frame only (and non-looping)
		//
		// (... or something...)

		{	// keep scope local for neatness

			if ( strstr (curSequence->GetEnum(), "DEATH") )
			{
				// scan this sequence's additional sequences for a DEAD of the same basic type...

				CString stringEnumDEAD = curSequence->GetEnum();

				ASSERT(!IsEnumSeperator(stringEnumDEAD));

				stringEnumDEAD.Replace("DEATH","DEAD");

				// 1st, is there even a corresponding DEAD enum in the global enum table that we can look for...

				CString stringEnum;
				bool bEnumFound = false;
				for (int iEnumEntry=0; !bEnumFound; iEnumEntry++)
				{
					LPCSTR p = ((CAssimilateApp*)AfxGetApp())->GetEnumEntry(iEnumEntry);	

					if (!p)		// EOS?
						break;

					stringEnum = p;

					// note, I could check stuff like "IsEnumSeperator(LPCSTR lpString)" on <p>, but you'd never
					//	have one of those enums assigned to a sequence anyway.

					// does this enum match the one we've built?

					if ( !_stricmp( stringEnum, stringEnumDEAD ) )
					{
						bEnumFound = true;
					}
				}

				if ( bEnumFound )
				{
					// ok, there *is* one of these, so let's scan this sequence's additional sequences to see if we've
					//	got it...

					CSequence *additionalSeq;	// outside FOR scope
					for (int i=0; i<MAX_ADDITIONAL_SEQUENCES; i++)
					{
						additionalSeq = curSequence->AdditionalSeqs[i];

						if (additionalSeq->AdditionalSequenceIsValid())
						{
							if (!strcmp(additionalSeq->GetEnum(),stringEnum))
							{
								break;	// we've found one!
							}
						}
					}

					// if we didn't find one, NULL the ptr
					if (int i=MAX_ADDITIONAL_SEQUENCES)
					{
						additionalSeq = NULL;
					}

					// did we find one? (or did it have the wrong info in?)

					if ( additionalSeq == NULL // didn't find one
						|| additionalSeq->GetFrameCount()!=1
						|| additionalSeq->GetLoopFrame() !=-1
						|| additionalSeq->GetStartFrame()!= curSequence->GetFrameCount()-1
						|| additionalSeq->GetFrameSpeed()!= curSequence->GetFrameSpeed()
						)
					{
						// find a slot to add this new sequence to, or use the faulty one...

						if (additionalSeq == NULL)
						{
							for (int i=0; i<MAX_ADDITIONAL_SEQUENCES; i++)
							{
								additionalSeq = curSequence->AdditionalSeqs[i];

								if (!additionalSeq->AdditionalSequenceIsValid())
								{
									break;	// found an unused slot
								}
							}
						}

						// so have we got a slot to work with?

						if ( additionalSeq == NULL )
						{
							if (gbCarWash_DoingScan)
							{
								strCarWashErrors += va( "F**k!!!: I need an 'additional sequence' slot free in the entry: \"%s\" to generate a DEAD seq, but there isn't one spare. Edit this yourself later.\n",curSequence->GetPath());
							}
							else
							{
								ErrorBox( va( "F**k!!!\n\nI need an 'additional sequence' slot free in the ASE:\n\n\"%s\"\n\n... to generate a DEAD seq, but there isn't one spare. Edit this yourself later.",curSequence->GetPath()));
							}
						}
						else
						{
							additionalSeq->SetStartFrame( curSequence->GetFrameCount()-1 );
							additionalSeq->SetFrameCount( 1 );
							additionalSeq->SetLoopFrame (-1 );
							additionalSeq->SetFrameSpeed( curSequence->GetFrameSpeed() );
							additionalSeq->SetEnum ( stringEnumDEAD );
						}
					}
				}
			}
		}

		curSequence->SetTargetFrame(curFrame + curSequence->GetStartFrame());	// slightly more legal than just (curFrame)

		// update: now set any additional sequences within it...

		for (int i=0; i<MAX_ADDITIONAL_SEQUENCES; i++)
		{
			curSequence->AdditionalSeqs[i]->SetTargetFrame(curFrame + curSequence->AdditionalSeqs[i]->GetStartFrame());
		}

		curFrame += curSequence->GetFrameCount();
		curFrame += curSequence->GetGenLoopFrame()?1:0;	// findme:  is this right?  I hate this system
		curSequence = curSequence->GetNext();
	}
	m_totFrames = curFrame;

	ghAssimilateView->GetDocument()->SetModifiedFlag();

	if (pProgress)
	{
		delete pProgress;
		pProgress = 0;
	}
}
示例#15
0
文件: callback.c 项目: dervish77/adgf
void file_help(Widget w, void *data)
{
   int okay;

   okay = GetYesNo("HELP\n----\n\nFile->Open - to load model\nFile->Save - to save model\nFile->Save As - save to new file\nFile->Close - close current file");  
}
示例#16
0
文件: callback.c 项目: dervish77/adgf
void file_about(Widget w, void *data)
{
   int okay;

   okay = GetYesNo("Particle\n\n  by Brian Lingard\n\nversion 1.0");  
}
示例#17
0
// every case here must either do CommArea_CommandAck(...) or CommArea_CommandError(...),
//	failure to do this is amazingly bad!!!
// 
static void HandleCommands(LPCSTR psString, byte *pbCommandData, int iCommandDataSize)
{
/*
#define IF_ARG(string)	if (!strncmp(psArg,string,strlen(string)))
#define NEXT_ARG		SkipWhitespace(FindWhitespace(psArg))

	LPCSTR psArg = psString;
		
	IF_ARG("model_loadprimary")
	{
		psArg = NEXT_ARG;

		if (Document_ModelLoadPrimary( psArg ))
		{
			CommArea_CommandAck();
		}
		else
		{
			CommArea_CommandError(va("ModView: Failed command: \"model_loadprimary %s\"\"", psArg));
		}
	}
	else				
	IF_ARG("modeltree_getrootsurface")
	{
		// for this command, just send back whatever the answer is without validating...
		//
		HTREEITEM hTreeItem = ModelTree_GetRootSurface(Model_GetPrimaryHandle());
		
		CommArea_CommandAck(va("%d",hTreeItem));
	}
	else				
	IF_ARG("modeltree_getrootbone")
	{
		// for this command, just send back whatever the answer is without validating...
		//
		HTREEITEM hTreeItem = ModelTree_GetRootBone(Model_GetPrimaryHandle());

		CommArea_CommandAck(va("%d",hTreeItem));
	}
	else
	// this version MUST be the first of the two, or the shorter one will early-match even a long command
	IF_ARG("modeltree_getitemtextpure")	// "...pure" will skip stuff like "////" for disabled surfaces
	{
		psArg = NEXT_ARG;

		HTREEITEM	hTreeItem	= (HTREEITEM) atoi(psArg);
		LPCSTR		psText		= ModelTree_GetItemText(hTreeItem,true);

		CommArea_CommandAck(psText);
	}
	else
	IF_ARG("modeltree_getitemtext")
	{
		psArg = NEXT_ARG;

		HTREEITEM	hTreeItem	= (HTREEITEM) atoi(psArg);
		LPCSTR		psText		= ModelTree_GetItemText(hTreeItem);

		CommArea_CommandAck(psText);
	}
	else
	IF_ARG("modeltree_getchilditem")
	{
		psArg = NEXT_ARG;

		HTREEITEM	hTreeItem = (HTREEITEM) atoi(psArg);
					hTreeItem = ModelTree_GetChildItem(hTreeItem);

		CommArea_CommandAck(va("%d",hTreeItem));
	}
	else
	IF_ARG("modeltree_getnextsiblingitem")
	{
		psArg = NEXT_ARG;

		HTREEITEM	hTreeItem = (HTREEITEM) atoi(psArg);
					hTreeItem = ModelTree_GetNextSiblingItem(hTreeItem);

		CommArea_CommandAck(va("%d",hTreeItem));
	}
	else
	{
		// unknown command...
		//		
		CommArea_CommandError(va("ModView: Unknown command \"%s\"", psString));
	}
*/

	InfoBox(va("CommsTest: Command recieved: \"%s\"",psString));

	if (GetYesNo("CommsTest: Report as error? ('NO' will report success)"))
	{
		CommArea_CommandError(va("CommsTest: Failed to complete task '%s'", psString));
	}
	else
	{					
		CommArea_CommandAck();
	}
}
示例#18
0
bool Skins_Validate( ModelContainer_t *pContainer, int iSkinNumber )
{
	bool bReturn = true;	
	bool bPREV_bReportImageLoadErrors = g_bReportImageLoadErrors;
										g_bReportImageLoadErrors = false;

	bool bCheckMissingMaterials = true;//GetYesNo("Check for materials referenced by model but missing in skinfile(s)?\n\n( Note: This can give false alarms for skins which don't use (eg) \"scarf\" )");

	// first, build up a list of all model materials...
	//	
	StringSet_t MaterialsPresentInModel;
	for (int iSurface = 0; iSurface < pContainer->iNumSurfaces; iSurface++)
	{
		bool bOnOff = GLMModel_SurfaceIsON(pContainer->hModel, iSurface);

		if (bOnOff)
		{
			LPCSTR psMaterial = GLMModel_GetSurfaceShaderName( pContainer->hModel, iSurface);

			MaterialsPresentInModel.insert(MaterialsPresentInModel.end(),psMaterial);
		}
	}

	// build up a list of shaders used...
	//	
	StringSet_t UniqueSkinShaders;	
	SkinFileMaterialsMissing_t SkinFileMaterialsMissing;
	int iThisSkinIndex = 0;
	for (SkinSets_t::iterator itSkins = pContainer->SkinSets.begin(); itSkins != pContainer->SkinSets.end(); ++itSkins, iThisSkinIndex++)
	{
		if (iSkinNumber == iThisSkinIndex || iSkinNumber == -1)
		{
			SkinSet_Validate_BuildList(UniqueSkinShaders, itSkins, MaterialsPresentInModel, SkinFileMaterialsMissing);
		}
	}

	// now process the unique list we've just built...
	//
	CWaitCursor wait;
	string strFoundList;
	string strNotFoundList;
	int iUniqueIndex = 0;
	for (StringSet_t::iterator it = UniqueSkinShaders.begin(); it != UniqueSkinShaders.end(); ++it, iUniqueIndex++)
	{			
		string strShader(*it);

		StatusMessage(va("Processing shader %d/%d: \"%s\"\n",iUniqueIndex,UniqueSkinShaders.size(),strShader.c_str()));

		OutputDebugString(va("Unique: \"%s\"... ",strShader.c_str()));

		int iTextureHandle = Texture_Load(strShader.c_str(), true);	// bInhibitStatus

		GLuint uiGLBind = Texture_GetGLBind( iTextureHandle );

		if (uiGLBind == 0)
		{
			OutputDebugString("NOT FOUND\n");
			
			strNotFoundList += strShader;
			strNotFoundList += "\n";
		}
		else
		{
			OutputDebugString("found\n");

			strFoundList += strShader;
			strFoundList += "\n";
		}
	}

	StatusMessage(NULL);

	
	// see if we were missing any model materials in these skins...
	//
	CString strModelMaterialsMissing;
	if (SkinFileMaterialsMissing.size())
	{
		for (SkinFileMaterialsMissing_t::iterator itSkinFileMaterialsMissing = SkinFileMaterialsMissing.begin(); itSkinFileMaterialsMissing != SkinFileMaterialsMissing.end(); ++itSkinFileMaterialsMissing)
		{
			string strSkinFileName((*itSkinFileMaterialsMissing).first);

			if (iSkinNumber == -1)
			{
				strModelMaterialsMissing += va("\nSkin \"%s\":\n",strSkinFileName.c_str());
			}
																					 
			for (EthnicMaterials_t::iterator itSkinFile = (*itSkinFileMaterialsMissing).second.begin(); itSkinFile != (*itSkinFileMaterialsMissing).second.end(); ++itSkinFile)
			{
				string strEthnicFileName((*itSkinFile).first);

				strModelMaterialsMissing += va("Ethnic \"%s\":   ",strEthnicFileName.c_str());

				StringVector_t& MaterialStrings = (*itSkinFile).second;

				for (int iMaterial = 0; iMaterial != MaterialStrings.size(); ++iMaterial)
				{
					string strMaterial(MaterialStrings[iMaterial]);

					strModelMaterialsMissing += va("%s\"%s\"",(iMaterial==0)?"":", ",strMaterial.c_str());
				}
				strModelMaterialsMissing += "\n";
			}
		}
	}
	if (!strModelMaterialsMissing.IsEmpty())
	{
		if (iSkinNumber == -1)
		{
			strModelMaterialsMissing.Insert(0, "One or more skin files are missing some material definitions referenced by this model's currently-active surfaces.\nList follows...\n\n");
		}
		else
		{
			strModelMaterialsMissing.Insert(0, "This skin file is missing one or more material definitions referenced by this model's currently-active surfaces.\nList follows...\n\n");
		}
	}

	
	if (!strModelMaterialsMissing.IsEmpty())
	{
		if (bCheckMissingMaterials)
		{
			WarningBox(va("Summary Part 1: Missing materials\n\n%s",(LPCSTR)strModelMaterialsMissing));
		}
	}


	// Now output results...

	// If too many lines to fit on screen (which is now happening), send 'em to notepad instead...
	//
	// ( tacky way of counting lines...)
	CString strTackyCount(strNotFoundList.c_str());
			strTackyCount += strFoundList.c_str();

	int iLines = strTackyCount.Replace('\n','?');	// :-)

	#define MAX_BOX_LINES_HERE 50

	if (strNotFoundList.empty())
	{
		if (iLines > MAX_BOX_LINES_HERE)
		{
			if (GetYesNo(va("All shaders found...    :-)\n\nList has > %d entries, send to Notepad?",MAX_BOX_LINES_HERE)))
			{
				SendStringToNotepad(va("All shaders found...    :-)\n\nList follows:\n\n%s",strFoundList.c_str()),"found_shaders.txt");
			}
		}
		else
		{
			InfoBox(va("All shaders found...    :-)\n\nList follows:\n\n%s",strFoundList.c_str()));
		}
	}
	else
	{
		if (iLines > MAX_BOX_LINES_HERE)
		{
			if (GetYesNo(va("Some missing shader, some found, but list is > %d entries, send to Notepad?",MAX_BOX_LINES_HERE)))
			{
				SendStringToNotepad(va("Missing shaders:\n\n%s\n\nFound shaders:\n\n%s",strNotFoundList.c_str(),strFoundList.c_str()),"found_shaders.txt");
			}
		}
		else
		{
			WarningBox(va("Missing shaders:\n\n%s\n\nFound shaders:\n\n%s",strNotFoundList.c_str(),strFoundList.c_str()));
		}
		bReturn = false;
	}


	g_bReportImageLoadErrors = bPREV_bReportImageLoadErrors;
	return bReturn;
}
示例#19
0
void GetYesNoAsInt(char *message, int *num)
{
	char yn = (*num > 0) ? 'Y' : 'N';
	GetYesNo(message, &yn);
	*num = (yn == 'Y') ? 1 : 0;
}