Beispiel #1
0
void ATheHUD::Unselect( vector<AGameObject*> objects )
{
  // If none of the objects are in the selection, there's no change.
  if( !in<AGameObject*>( Selected, objects ) )
  {
    error( FS( "None of objects [%s] were in Selected [%s], nothing to unselect",
               *GetNames( objects ), *GetNames( Selected ) ) );
    return;
  }

  for( AGameObject* go : objects )
  {
    // Remove any selectors on there
    go->RemoveTagged( Game->flycam->SelectedTargetName );

    // If I'm the only selected unit with on follow target then remove follow target selection
    // If go is the only follower / attacker in Selected, then remove the marker.
    if( go->FollowTarget )
      if( Intersection<AGameObject>( Selected, go->FollowTarget->Followers ).size() <= 1 )
        go->RemoveTagged( Game->flycam->FollowTargetName );

    if( go->AttackTarget )
      if( Intersection( Selected, go->AttackTarget->Attackers ).size() <= 1 )
        go->RemoveTagged( Game->flycam->AttackTargetName );
  }

  operator-=<AGameObject*>( Selected, objects );

  //Reselect selected, to refresh the selectors on attack targets.
  Select( Selected );
}
Beispiel #2
0
int CmFile::GetNames(CStr& rootFolder, CStr &fileW, vecS &names)
{
	GetNames(rootFolder + fileW, names);
	vecS subFolders, tmpNames;
	int subNum = CmFile::GetSubFolders(rootFolder, subFolders);
	for (int i = 0; i < subNum; i++){
		subFolders[i] += "/";
		int subNum = GetNames(rootFolder + subFolders[i], fileW, tmpNames);
		for (int j = 0; j < subNum; j++)
			names.push_back(subFolders[i] + tmpNames[j]);
	}
	return (int)names.size();
}
Beispiel #3
0
// Function : Get all the 'fileW' type file's name in the rootFolder, 
// include the subFolder
// args: fileW: file type filter
// Eg : GetNames("D:\\", "*.jpg", names)
int IMVLFile::GetNames(const string& rootFolder, const string &fileW, vector<string> &names)
{
	GetNames(rootFolder + fileW, names);
	vector<string> subFolders, tmpNames;
	int subNum = IMVLFile::GetSubFolders(rootFolder, subFolders);
	for (int i = 0; i < subNum; i++){
		subFolders[i] += "/";
		int subNum = GetNames(rootFolder + subFolders[i], fileW, tmpNames);
		for (int j = 0; j < subNum; j++)
			names.push_back(subFolders[i] + tmpNames[j]);
	}
	return (int)names.size();
}
/**
 * Compares name to passed in one. Sort is alphabetical ascending.
 *
 * @param	Other	Name to compare this against
 * @return	< 0 is this < Other, 0 if this == Other, > 0 if this > Other
 */
int32 FName::Compare( const FName& Other ) const
{
    // Names match, check whether numbers match.
    if( GetComparisonIndexFast() == Other.GetComparisonIndexFast() )
    {
        return GetNumber() - Other.GetNumber();
    }
    // Names don't match. This means we don't even need to check numbers.
    else
    {
        TNameEntryArray& Names = GetNames();
        const FNameEntry* const ThisEntry = GetComparisonNameEntry();
        const FNameEntry* const OtherEntry = Other.GetComparisonNameEntry();

        // Ansi/Wide mismatch, convert to wide
        if( ThisEntry->IsWide() != OtherEntry->IsWide() )
        {
            return FCStringWide::Stricmp(	ThisEntry->IsWide() ? ThisEntry->GetWideName() : StringCast<WIDECHAR>(ThisEntry->GetAnsiName()).Get(),
                                            OtherEntry->IsWide() ? OtherEntry->GetWideName() : StringCast<WIDECHAR>(OtherEntry->GetAnsiName()).Get() );
        }
        // Both are wide.
        else if( ThisEntry->IsWide() )
        {
            return FCStringWide::Stricmp( ThisEntry->GetWideName(), OtherEntry->GetWideName() );
        }
        // Both are ansi.
        else
        {
            return FCStringAnsi::Stricmp( ThisEntry->GetAnsiName(), OtherEntry->GetAnsiName() );
        }
    }
}
Beispiel #5
0
void CFGAS_FontMgr::RegisterFace(FXFT_Face pFace,
                                 const CFX_WideString* pFaceName) {
  if ((pFace->face_flags & FT_FACE_FLAG_SCALABLE) == 0)
    return;

  std::unique_ptr<CFX_FontDescriptor> pFont(new CFX_FontDescriptor);
  pFont->m_dwFontStyles |= FXFT_Is_Face_Bold(pFace) ? FX_FONTSTYLE_Bold : 0;
  pFont->m_dwFontStyles |= FXFT_Is_Face_Italic(pFace) ? FX_FONTSTYLE_Italic : 0;
  pFont->m_dwFontStyles |= GetFlags(pFace);

  std::vector<uint16_t> charsets = GetCharsets(pFace);
  GetUSBCSB(pFace, pFont->m_dwUsb, pFont->m_dwCsb);

  FT_ULong dwTag;
  FT_ENC_TAG(dwTag, 'n', 'a', 'm', 'e');

  std::vector<uint8_t> table;
  unsigned long nLength = 0;
  unsigned int error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, nullptr, &nLength);
  if (error == 0 && nLength != 0) {
    table.resize(nLength);
    if (FXFT_Load_Sfnt_Table(pFace, dwTag, 0, table.data(), nullptr))
      table.clear();
  }
  GetNames(table.empty() ? nullptr : table.data(), pFont->m_wsFamilyNames);

  pFont->m_wsFamilyNames.Add(CFX_ByteString(pFace->family_name).UTF8Decode());
  pFont->m_wsFaceName =
      pFaceName ? *pFaceName
                : CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(pFace));
  pFont->m_nFaceIndex = pFace->face_index;

  m_InstalledFonts.Add(pFont.release());
}
bool FName::InitInternal_FindOrAdd(const TCharType* InName, const EFindName FindType, const int32 HardcodeIndex, int32& OutComparisonIndex, int32& OutDisplayIndex)
{
    const bool bWasFoundOrAdded = InitInternal_FindOrAddNameEntry<TCharType>(InName, FindType, ENameCase::IgnoreCase, OutComparisonIndex);

#if WITH_CASE_PRESERVING_NAME
    if(bWasFoundOrAdded && HardcodeIndex < 0)
    {
        TNameEntryArray& Names = GetNames();
        const FNameEntry* const NameEntry = Names[OutComparisonIndex];

        // If the string we got back doesn't match the case of the string we provided, also add a case variant version for display purposes
        if(TCString<TCharType>::Strcmp(InName, FNameInitHelper<TCharType>::GetNameString(NameEntry)) != 0)
        {
            if(!InitInternal_FindOrAddNameEntry<TCharType>(InName, FindType, ENameCase::CaseSensitive, OutDisplayIndex))
            {
                // We don't consider failing to find/add the case variant a full failure
                OutDisplayIndex = OutComparisonIndex;
            }
        }
        else
        {
            OutDisplayIndex = OutComparisonIndex;
        }
    }
    else
#endif
    {
        OutDisplayIndex = OutComparisonIndex;
    }

    return bWasFoundOrAdded;
}
int CmFile::GetNamesNE(const string& nameWC, vector<string> &names, string &dir)
{
	int fNum = GetNames(nameWC, names, dir);
	for (int i = 0; i < fNum; i++)
		names[i] = GetNameNE(names[i]);
	return fNum;
}
Beispiel #8
0
std::string IVolume::GetName() const
{
	auto names = GetNames();
	if (names.empty())
		return "";
	else
		return names[0];
}
Beispiel #9
0
int CmFile::GetNamesNE(CStr& rootFolder, CStr &fileW, vecS &names)
{
	int fNum = GetNames(rootFolder, fileW, names);
	int extS = (int)GetExtention(fileW).size();
	for (int i = 0; i < fNum; i++)
		names[i].resize(names[i].size() - extS);
	return fNum;
}
Beispiel #10
0
int CmFile::GetNamesNE(CStr& nameWC, vecS &names, string &dir, string &ext)
{
	int fNum = GetNames(nameWC, names, dir);
	ext = GetExtention(nameWC);
	for (int i = 0; i < fNum; i++)
		names[i] = GetNameNE(names[i]);
	return fNum;
}
Beispiel #11
0
int CmFile::GetNamesNE(CStr& nameWC, vecS &names)
{
	int fNum = GetNames(nameWC, names);
	//string ext = GetExtention(nameWC);
	for (int i = 0; i < fNum; i++)
		names[i] = GetNameNE(names[i]);
	return fNum;
}
Beispiel #12
0
void CPrinterInfo::UpdateFromDevNames(HGLOBAL hDevNames, HGLOBAL hDevMode, HDC hDC, int nOrientation, BOOL fUseWinIni /*=TRUE*/)
{
	Defaults();
	m_nOrientationType = nOrientation;
	GetNames(hDevNames, fUseWinIni);
	GetDeviceInfo(hDevMode, hDC);
	ReadSettings();
}
Beispiel #13
0
// NE for No extension
int IMVLFile::GetNamesNE(const string& rootFolder, const string &fileW, vector<string> &names)
{
	int fNum = GetNames(rootFolder, fileW, names);
	int extS = (int)GetExtention(fileW).size();
	for (int i = 0; i < fNum; i++)
		names[i].resize(names[i].size() - extS);
	return fNum;
}
Beispiel #14
0
// NE for No extension
int IMVLFile::GetNamesNE(const string& nameWC, vector<string> &names, string &dir, string &ext)
{
	int fNum = GetNames(nameWC, names, dir);
	ext = GetExtention(nameWC);
	for (int i = 0; i < fNum; i++)
		names[i] = GetNameNE(names[i]);
	return fNum;
}
Beispiel #15
0
status_t
ThemeManager::SaveTheme(int32 id, bool excl)
{
	FENTRY;
	status_t err;
	BString name, fname;
	BPath path;
	BDirectory dir;
	BDirectory tdir;
	BFile tfile;
	BMessage names;
	BString location;
	BMessage *theme;
	theme = ThemeAt(id);
	if (!theme)
		return EINVAL;
	err = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
	if (err)	return err;
	path.Append(Z_THEMES_FOLDER_NAME);
	err = dir.SetTo(path.Path());
	if (err)	return err;
	err = ThemeName(id, name);
	if (err)	return err;
	fname = name;
	NormalizeThemeFolderName(fname);

	err = ThemeLocation(id, location);
	if (!err) {
		if (location.FindFirst("/boot/beos") >= 0) {
			PRINT(("trying to save theme '%s' to system dir!\n", name.String()));
			return B_PERMISSION_DENIED;
		}
	}
	path.Append(fname.String());
	err = theme->ReplaceString(Z_THEME_LOCATION, path.Path());
	if (err)
		err = theme->AddString(Z_THEME_LOCATION, path.Path());
	
	if (dir.CreateDirectory(fname.String(), NULL) < B_OK) {
		if (excl)
			return B_FILE_EXISTS;
	}
	err = tdir.SetTo(&dir, fname.String());
	if (err)	return err;
	err = tdir.CreateFile(Z_THEME_FILE_NAME, &tfile);
	if (err)	return err;
	
	BMessage tosave(*theme);
	err = tosave.RemoveName(Z_THEME_LOCATION);
	err = GetNames(names);
	
	err = DumpMessageToStream(&tosave, tfile, 0, &names);
	if (err)	return err;
	return B_OK;
}
Beispiel #16
0
JNIEXPORT void JNICALL Java_xtramy_protocols_hybridcertification_oracles_XactAverageExecutionTimes_initiateCubist(JNIEnv *env, jobject thisobject, jstring js){
  FILE *F;
  FileStem = (*env)->GetStringUTFChars(env, js, 0); 

  if ( ! (F = GetFile(".names", "r")) )
    Error(0, Fn, "");

  GetNames(F);   

  CubistModel = GetCommittee(".model");
}
Beispiel #17
0
int CmFile::Rename(CStr& _srcNames, CStr& _dstDir, const char *nameCommon, const char *nameExt)
{
	vecS names;
	string inDir;
	int fNum = GetNames(_srcNames, names, inDir);
	for (int i = 0; i < fNum; i++) {
		string dstName = format("%s\\%.4d%s.%s", _S(_dstDir), i, nameCommon, nameExt);
		string srcName = inDir + names[i];
		::CopyFileA(srcName.c_str(), dstName.c_str(), FALSE);
	}
	return fNum;
}
Beispiel #18
0
/**\brief Returns true if a player already exists
 */
bool Players::PlayerExists(string playerName) {
	list<string>* names = GetNames();
	list<string>::iterator i;

	if( names->empty() ) return false;

	for(i = names->begin(); i != names->end(); ++i ) {
		if(*i == playerName) return true;
	}

	return false;
}
Beispiel #19
0
int CmFile::ChangeImgFormat(CStr &imgW, CStr dstW)
{
	vecS names;
	string inDir, ext = GetExtention(imgW);
	int iNum = GetNames(imgW, names, inDir);
#pragma omp parallel for
	for (int i = 0; i < iNum; i++) {
		Mat img = imread(inDir + names[i]);
		imwrite(format(_S(dstW), _S(GetNameNE(names[i]))), img);
	}
	return iNum;
}
Beispiel #20
0
BatchCommands::BatchCommands()
{
   ResetChain();

   wxArrayString names = GetNames();

   if (names.Index(MP3Conversion) == wxNOT_FOUND) {
      AddChain(MP3Conversion);
      RestoreChain(MP3Conversion);
      WriteChain(MP3Conversion);
   }
}
Beispiel #21
0
void CmFile::ChkImgs(CStr &imgW)
{
	vecS names;
	string inDir;
	int imgNum = GetNames(imgW, names, inDir);
	printf("Checking %d images: %s\n", imgNum, _S(imgW));
	for (int i = 0; i < imgNum; i++){
		Mat img = imread(inDir + names[i]);
		if (img.data == NULL)
			printf("Loading file %s failed\t\t\n", _S(names[i]));
		if (i % 200 == 0)
			printf("Processing %2.1f%%\r", (i*100.0)/imgNum);
	}
	printf("\t\t\t\t\r");
}
Beispiel #22
0
const wxArrayString &CVolumes::GetVolumeNames() const
{
  if(m_asVolumeNames.IsEmpty())
  {
    SetVolumeNames setNames;
    size_t n = GetNames(&setNames);
    m_asVolumeNames.Alloc(n);
    for(SetVolumeNames::iterator itr = setNames.begin();
      itr != setNames.end();
      ++itr)
    {
      m_asVolumeNames.Add(*itr);
    }
  }
  return m_asVolumeNames;
}
Beispiel #23
0
/**\brief Get the PlayerInfo for the most recent player
 */
PlayerInfo* Players::LastPlayer() {
	list<string>* names = GetNames();
	list<string>::iterator i;
	PlayerInfo* latest = NULL;

	if( names->empty() ){
		return NULL;
	}

	for(i = names->begin(); i != names->end(); ++i ) {
		if( (latest == NULL) || (latest->lastLoadTime < GetPlayerInfo(*i)->lastLoadTime ) ) {
			latest = GetPlayerInfo(*i);
		}
	}

	return latest;
}
Beispiel #24
0
BatchCommands::BatchCommands()
{
   ResetChain();

   wxArrayString names = GetNames();
#ifdef CLEANSPEECH   // possibly the rest of this fn
   if (names.Index(CleanSpeech) == wxNOT_FOUND) {
      AddChain(CleanSpeech);
      RestoreChain(CleanSpeech);
      WriteChain(CleanSpeech);
   }
#endif   // CLEANSPEECH

   if (names.Index(MP3Conversion) == wxNOT_FOUND) {
      AddChain(MP3Conversion);
      RestoreChain(MP3Conversion);
      WriteChain(MP3Conversion);
   }
}
Beispiel #25
0
inline const GLuint*
GetGLNames(const Sequence<ObjName>& sequence)
{
	return GetNames(sequence);
}
int CmFile::GetNames(const string &nameW, vecS &names, string &dir)
{
	dir = GetFolder(nameW);
	return GetNames(nameW, names);
}
void FName::StaticInit()
{
    check(IsInGameThread());
    /** Global instance used to initialize the GCRCTable. It used to be initialized in appInit() */
    //@todo: Massive workaround for static init order without needing to use a function call for every use of GCRCTable
    // This ASSUMES that fname::StaticINit is going to be called BEFORE ANY use of GCRCTable
    FCrc::Init();

    check(GetIsInitialized() == false);
    check((ARRAY_COUNT(NameHash)&(ARRAY_COUNT(NameHash)-1)) == 0);
    GetIsInitialized() = 1;


    // Init the name hash.
    for (int32 HashIndex = 0; HashIndex < ARRAY_COUNT(FName::NameHash); HashIndex++)
    {
        NameHash[HashIndex] = NULL;
    }

    {
        FScopeLock ScopeLock(GetCriticalSection());

        TNameEntryArray& Names = GetNames();
        Names.AddZeroed(NAME_MaxHardcodedNameIndex + 1);
    }

    {
        // Register all hardcoded names.
#define REGISTER_NAME(num,namestr) FName Temp_##namestr(EName(num), TEXT(#namestr));
#include "UObject/UnrealNames.h"
    }

#if DO_CHECK
    // Verify no duplicate names.
    for (int32 HashIndex = 0; HashIndex < ARRAY_COUNT(NameHash); HashIndex++)
    {
        for (FNameEntry* Hash = NameHash[HashIndex]; Hash; Hash = Hash->HashNext)
        {
            for (FNameEntry* Other = Hash->HashNext; Other; Other = Other->HashNext)
            {
                if (FCString::Stricmp(*Hash->GetPlainNameString(), *Other->GetPlainNameString()) == 0)
                {
                    // we can't print out here because there may be no log yet if this happens before main starts
                    if (FPlatformMisc::IsDebuggerPresent())
                    {
                        FPlatformMisc::DebugBreak();
                    }
                    else
                    {
                        FPlatformMisc::PromptForRemoteDebugging(false);
                        FMessageDialog::Open(EAppMsgType::Ok, FText::Format( NSLOCTEXT("UnrealEd", "DuplicatedHardcodedName", "Duplicate hardcoded name: {0}"), FText::FromString( Hash->GetPlainNameString() ) ) );
                        FPlatformMisc::RequestExit(false);
                    }
                }
            }
        }
    }
    // check that the MAX_NETWORKED_HARDCODED_NAME define is correctly set
    if (GetMaxNames() <= MAX_NETWORKED_HARDCODED_NAME)
    {
        if (FPlatformMisc::IsDebuggerPresent())
        {
            FPlatformMisc::DebugBreak();
        }
        else
        {
            FPlatformMisc::PromptForRemoteDebugging(false);
            // can't use normal check()/UE_LOG(LogUnrealNames, Fatal,) here
            FMessageDialog::Open( EAppMsgType::Ok, FText::Format( NSLOCTEXT("UnrealEd", "MAX_NETWORKED_HARDCODED_NAME Incorrect", "MAX_NETWORKED_HARDCODED_NAME is incorrectly set! (Currently {0}, must be no greater than {1}"), FText::AsNumber( MAX_NETWORKED_HARDCODED_NAME ), FText::AsNumber( GetMaxNames() - 1 ) ) );
            FPlatformMisc::RequestExit(false);
        }
    }
#endif
}
const FNameEntry* FName::GetDisplayNameEntry() const
{
    TNameEntryArray& Names = GetNames();
    const NAME_INDEX Index = GetDisplayIndex();
    return Names[Index];
}
const FNameEntry* FName::GetComparisonNameEntry() const
{
    TNameEntryArray& Names = GetNames();
    const NAME_INDEX Index = GetComparisonIndex();
    return Names[Index];
}
bool FName::InitInternal_FindOrAddNameEntry(const TCharType* InName, const EFindName FindType, const ENameCase ComparisonMode, int32& OutIndex)
{
    // Hash value of string
    const int32 iHash = ( (ComparisonMode == ENameCase::IgnoreCase) ? FCrc::Strihash_DEPRECATED( InName ) : FCrc::StrCrc32( InName ) ) & (ARRAY_COUNT(NameHash)-1);

    if (OutIndex < 0)
    {
        // Try to find the name in the hash.
        for( FNameEntry* Hash=NameHash[iHash]; Hash; Hash=Hash->HashNext )
        {
            FPlatformMisc::Prefetch( Hash->HashNext );
            // Compare the passed in string
            if( Hash->IsEqual( InName, ComparisonMode ) )
            {
                // Found it in the hash.
                OutIndex = Hash->GetIndex();

                // Check to see if the caller wants to replace the contents of the
                // FName with the specified value. This is useful for compiling
                // script classes where the file name is lower case but the class
                // was intended to be uppercase.
                if (FindType == FNAME_Replace_Not_Safe_For_Threading)
                {
                    check(IsInGameThread());

                    // This *must* be true, or we'll overwrite memory when the
                    // copy happens if it is longer
                    check(TCString<TCharType>::Strlen(InName) == Hash->GetNameLength());

                    FNameInitHelper<TCharType>::SetNameString(Hash, InName);
                }
                check(OutIndex >= 0);
                return true;
            }
        }

        // Didn't find name.
        if( FindType==FNAME_Find )
        {
            // Not found.
            return false;
        }
    }
    // acquire the lock
    FScopeLock ScopeLock(GetCriticalSection());
    if (OutIndex < 0)
    {
        // Try to find the name in the hash. AGAIN...we might have been adding from a different thread and we just missed it
        for( FNameEntry* Hash=NameHash[iHash]; Hash; Hash=Hash->HashNext )
        {
            // Compare the passed in string
            if( Hash->IsEqual( InName, ComparisonMode ) )
            {
                // Found it in the hash.
                OutIndex = Hash->GetIndex();
                check(FindType == FNAME_Add);  // if this was a replace, well it isn't safe for threading. Find should have already been handled
                return true;
            }
        }
    }
    FNameEntry* OldHash=NameHash[iHash];
    TNameEntryArray& Names = GetNames();
    if (OutIndex < 0)
    {
        OutIndex = Names.AddZeroed(1);
    }
    else
    {
        check(OutIndex < Names.Num());
    }
    FNameEntry* NewEntry = AllocateNameEntry( InName, OutIndex, OldHash, FNameInitHelper<TCharType>::IsAnsi );
    if (FPlatformAtomics::InterlockedCompareExchangePointer((void**)&Names[OutIndex], NewEntry, NULL) != NULL) // we use an atomic operation to check for unexpected concurrency, verify alignment, etc
    {
        UE_LOG(LogUnrealNames, Fatal, TEXT("Hardcoded name '%s' at index %i was duplicated (or unexpected concurrency). Existing entry is '%s'."), *NewEntry->GetPlainNameString(), NewEntry->GetIndex(), *Names[OutIndex]->GetPlainNameString() );
    }
    if (FPlatformAtomics::InterlockedCompareExchangePointer((void**)&NameHash[iHash], NewEntry, OldHash) != OldHash) // we use an atomic operation to check for unexpected concurrency, verify alignment, etc
    {
        check(0); // someone changed this while we were changing it
    }
    check(OutIndex >= 0);
    return true;
}