Esempio n. 1
0
static INT
TUILoggedOutSAS(
    IN OUT PGINA_CONTEXT pgContext)
{
    WCHAR UserName[256];
    WCHAR Password[256];
    NTSTATUS Status;
    NTSTATUS SubStatus = STATUS_SUCCESS;

    TRACE("TUILoggedOutSAS()\n");

    /* Ask the user for credentials */
    if (!ReadString(IDS_ASKFORUSER, UserName, _countof(UserName), TRUE))
        return WLX_SAS_ACTION_NONE;
    if (!ReadString(IDS_ASKFORPASSWORD, Password, _countof(Password), FALSE))
        return WLX_SAS_ACTION_NONE;

    Status = DoLoginTasks(pgContext, UserName, NULL, Password, &SubStatus);
    if (Status == STATUS_SUCCESS)
    {
        if (CreateProfile(pgContext, UserName, NULL, Password))
            return WLX_SAS_ACTION_LOGON;
    }

    return WLX_SAS_ACTION_NONE;
}
Esempio n. 2
0
void ProfileDlg::OnCreateProfile() 
{
	CString name;
	m_txtName.GetWindowText(name);
	name.TrimLeft(_T(" "));
	name.TrimRight(_T(" "));
	if(name == _T("")) 
		return;
	CreateProfile(name, m_settings);
	UpdateProfilesCombo();
}
UDeviceProfile& UDeviceProfileManager::FindProfile( const FString& ProfileName )
{
	UDeviceProfile* FoundProfile = nullptr;

	for( int32 Idx = 0; Idx < Profiles.Num(); Idx++ )
	{
		UDeviceProfile* CurrentDevice = CastChecked<UDeviceProfile>( Profiles[Idx] );
		if( CurrentDevice->GetName() == ProfileName )
		{
			FoundProfile = CurrentDevice;
			break;
		}
	}

	return FoundProfile != nullptr ? *FoundProfile : CreateProfile(ProfileName, FPlatformProperties::PlatformName());
}
Esempio n. 4
0
// Returns a profile with all system default values
Profile* ProfileManager::GetDefaultProfile(HmdTypeEnum device)
{
    // In the absence of any data, set some reasonable profile defaults.
    // However, this is not future proof and developers should still
    // provide reasonable default values for queried fields.
    
    // Biometric data
    Profile* profile = CreateProfile();
    profile->SetValue(OVR_KEY_USER,               "default");
    profile->SetValue(OVR_KEY_NAME,               "Default");
    profile->SetValue(OVR_KEY_GENDER,             OVR_DEFAULT_GENDER);
    profile->SetFloatValue(OVR_KEY_PLAYER_HEIGHT, OVR_DEFAULT_PLAYER_HEIGHT);
    profile->SetFloatValue(OVR_KEY_EYE_HEIGHT,    OVR_DEFAULT_EYE_HEIGHT);
    profile->SetFloatValue(OVR_KEY_IPD,           OVR_DEFAULT_IPD);
    float half_ipd[2] = { OVR_DEFAULT_IPD / 2, OVR_DEFAULT_IPD / 2 };
    profile->SetFloatValues(OVR_KEY_EYE_TO_NOSE_DISTANCE, half_ipd, 2);
    float dist[2] = {OVR_DEFAULT_NECK_TO_EYE_HORIZONTAL, OVR_DEFAULT_NECK_TO_EYE_VERTICAL};
    profile->SetFloatValues(OVR_KEY_NECK_TO_EYE_DISTANCE, dist, 2);
    
    // Device specific data
    if (device != HmdType_None)
    {
        if (device == HmdType_CrystalCoveProto || device == HmdType_DK2)
        {
            profile->SetValue("EyeCup", "A");
            profile->SetIntValue(OVR_KEY_EYE_RELIEF_DIAL, OVR_DEFAULT_EYE_RELIEF_DIAL);

            // TODO: These defaults are a little bogus and designed for continuity with 0.3
            // eye-relief values.  We need better measurement-based numbers in future releases
            float max_eye_plate[2] = { 0.01965f + 0.017f, 0.01965f + 0.017f };
            profile->SetFloatValues(OVR_KEY_MAX_EYE_TO_PLATE_DISTANCE, max_eye_plate, 2);
        }
        else
        {   // DK1 and DKHD variants
            profile->SetValue("EyeCup", "A");
            profile->SetIntValue(OVR_KEY_EYE_RELIEF_DIAL, OVR_DEFAULT_EYE_RELIEF_DIAL);

            // TODO: These defaults are a little bogus and designed for continuity with 0.3
            // DK1 distortion.  We need better measurement-based numbers in future releases
            float max_eye_plate[2] = { 0.02357f + 0.017f, 0.02357f + 0.017f };
            profile->SetFloatValues(OVR_KEY_MAX_EYE_TO_PLATE_DISTANCE, max_eye_plate, 2);
        }
    }

    return profile;
}
UDeviceProfile* UDeviceProfileManager::CreateProfile( const FString& ProfileName, const FString& ProfileType, const FString& ParentName )
{
	UDeviceProfile* DeviceProfile = FindObject<UDeviceProfile>( GetTransientPackage(), *ProfileName );
	if( DeviceProfile == NULL )
	{
		DeviceProfile = ConstructObject<UDeviceProfile>( UDeviceProfile::StaticClass(), GetTransientPackage(), *ProfileName, RF_Transient|RF_Public);
		DeviceProfile->LoadConfig( UDeviceProfile::StaticClass(), *DeviceProfileFileName );
		DeviceProfile->BaseProfileName = ParentName != TEXT("") ? ParentName : DeviceProfile->BaseProfileName;
		DeviceProfile->DeviceType = ProfileType;

		UDeviceProfile* ObjectTemplate = NULL;

		// Recursively build the parent tree
		if( DeviceProfile->BaseProfileName != TEXT("") )
		{
			DeviceProfile->Parent = FindObject<UDeviceProfile>( GetTransientPackage(), *DeviceProfile->BaseProfileName );
			if( DeviceProfile->Parent == NULL )
			{
				DeviceProfile->Parent = CreateProfile( DeviceProfile->BaseProfileName, ProfileType );
			}
			ObjectTemplate = CastChecked<UDeviceProfile>(DeviceProfile->Parent);
		}

		if( ObjectTemplate )
		{
			DeviceProfile->ClearFlags( RF_AllFlags );
			DeviceProfile->Rename( *FString::Printf(TEXT("RedundantDeviceProfile_%d"), RenameIndex++), GetTransientPackage());
			DeviceProfile->SetFlags( RF_PendingKill );

			DeviceProfile = ConstructObject<UDeviceProfile>( UDeviceProfile::StaticClass(), GetTransientPackage(), *ProfileName, RF_Transient|RF_Public, ObjectTemplate);
			DeviceProfile->BaseProfileName = ObjectTemplate->GetName();
			DeviceProfile->DeviceType = ProfileType;
		}

		Profiles.Add( DeviceProfile );

		// Inform the UI that the device list has changed
		ManagerUpdatedDelegate.Broadcast(); 
	}

	return DeviceProfile;
}
void UDeviceProfileManager::InternalLoadProfiles()
{
	TArray< FString > DeviceProfileMapArray;
	GConfig->GetArray( TEXT( "DeviceProfiles" ), TEXT( "DeviceProfileNameAndTypes" ), DeviceProfileMapArray, DeviceProfileFileName );

	for( int32 DeviceProfileIndex = 0; DeviceProfileIndex < DeviceProfileMapArray.Num(); ++DeviceProfileIndex)
	{
		FString NewDeviceProfileSelectorPlatformName;
		FString NewDeviceProfileSelectorPlatformType;
		DeviceProfileMapArray[DeviceProfileIndex].Split( TEXT(","), &NewDeviceProfileSelectorPlatformName, &NewDeviceProfileSelectorPlatformType);

		if( FindObject<UDeviceProfile>( GetTransientPackage(), *NewDeviceProfileSelectorPlatformName ) == NULL )
		{
			CreateProfile(NewDeviceProfileSelectorPlatformName, NewDeviceProfileSelectorPlatformType);
		}
	}


	ManagerUpdatedDelegate.Broadcast();
}
Esempio n. 7
0
//-----------------------------------------------------------------------------
bool ProfileManager::SetDefaultUser(const ProfileDeviceKey& deviceKey, const char* user)
{
    const char* tag_names[2] = {"Product", "Serial"};
    const char* tags[2];

	const char* product_str = deviceKey.ProductName.IsEmpty() ? NULL : deviceKey.ProductName.ToCStr();
	const char* serial_str = deviceKey.PrintedSerial.IsEmpty() ? NULL : deviceKey.PrintedSerial.ToCStr();

    if (product_str && serial_str)
    {
        tags[0] = product_str;
        tags[1] = serial_str;

        Ptr<Profile> p = *CreateProfile();
        p->SetValue("DefaultUser", user);
        return SetTaggedProfile(tag_names, tags, 2, p);
    }

    return false;
}
Esempio n. 8
0
	virtual void OnApply()
	{
		LRESULT curSel = m_driverList.GetCurSel();
		if (curSel == -1)
			return; // should never happen

		ptrT szName(m_profileName.GetText());
		if (szName == 0)
			return;

		// profile placed in "profile_name" subfolder
		mir_sntprintf(m_pd->ptszProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), m_pd->ptszProfileDir, szName, szName);
		m_pd->newProfile = 1;
		m_pd->dblink = (DATABASELINK *)m_driverList.GetItemData(curSel);

		if (CreateProfile(m_pd->ptszProfile, m_pd->dblink) == 0)
			SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
		else
			m_pd->bRun = true;
	}
Esempio n. 9
0
void CProfileSelectState::LoadProfiles()
{
	profiles.clear();
	CGameplayState* loader = CGameplayState::GetInstance();
	for (unsigned int i = 1; i < 4; i++)
	{
		loader->SetProfile(i);
		profiles.push_back(loader->LoadProfile());
	}
	for (unsigned int i = 0; i < 3; i++)
	{
		if (profiles[i].profile == 0)
		{
			currentProfile = i;
			profiles[i] = CreateProfile();
			//profiles[i].profile = i + 1;
		}
	}
	currentProfile = 0;
}
void UDeviceProfileManager::LoadProfiles()
{
	if( !HasAnyFlags( RF_ClassDefaultObject ) )
	{
		TArray< FString > DeviceProfileMapArray;
		GConfig->GetArray(TEXT("DeviceProfiles"), TEXT("DeviceProfileNameAndTypes"), DeviceProfileMapArray, DeviceProfileFileName);

		for (int32 DeviceProfileIndex = 0; DeviceProfileIndex < DeviceProfileMapArray.Num(); ++DeviceProfileIndex)
		{
			FString NewDeviceProfileSelectorPlatformName;
			FString NewDeviceProfileSelectorPlatformType;
			DeviceProfileMapArray[DeviceProfileIndex].Split(TEXT(","), &NewDeviceProfileSelectorPlatformName, &NewDeviceProfileSelectorPlatformType);

			if (FindObject<UDeviceProfile>(GetTransientPackage(), *NewDeviceProfileSelectorPlatformName) == NULL)
			{
				CreateProfile(NewDeviceProfileSelectorPlatformName, NewDeviceProfileSelectorPlatformType);
			}
		}

#if WITH_EDITOR
		if (!FPlatformProperties::RequiresCookedData())
		{
			// Register Texture LOD settings with each Target Platform
			ITargetPlatformManagerModule& TargetPlatformManager = GetTargetPlatformManagerRef();
			const TArray<ITargetPlatform*>& TargetPlatforms = TargetPlatformManager.GetTargetPlatforms();
			for (int32 PlatformIndex = 0; PlatformIndex < TargetPlatforms.Num(); ++PlatformIndex)
			{
				ITargetPlatform* Platform = TargetPlatforms[PlatformIndex];
				if (const UTextureLODSettings* TextureLODSettingsObj = (UTextureLODSettings*)&FindProfile(*Platform->GetPlatformInfo().VanillaPlatformName.ToString()))
				{
					// Set TextureLODSettings
					Platform->RegisterTextureLODSettings(TextureLODSettingsObj);
				}
			}
		}
#endif

		ManagerUpdatedDelegate.Broadcast();
	}
}
UDeviceProfile& UDeviceProfileManager::CreateProfile( const FString& ProfileName, const FString& ProfileType, const FString& InSpecifyParentName )
{
	UDeviceProfile* DeviceProfile = FindObject<UDeviceProfile>( GetTransientPackage(), *ProfileName );
	if( DeviceProfile == NULL )
	{
		// Build Parent objects first. Important for setup
		FString ParentName = InSpecifyParentName;
		if (ParentName.Len() == 0)
		{
			const FString SectionName = FString::Printf(TEXT("%s %s"), *ProfileName, *UDeviceProfile::StaticClass()->GetName());
			GConfig->GetString(*SectionName, TEXT("BaseProfileName"), ParentName, GetDeviceProfileIniName());
		}

		UObject* ParentObject = nullptr;
		// Recursively build the parent tree
		if (ParentName.Len() > 0)
		{
			ParentObject = FindObject<UDeviceProfile>(GetTransientPackage(), *ParentName);
			if (ParentObject == nullptr)
			{
				ParentObject = &CreateProfile(ParentName, ProfileType);
			}
		}

		// Create the profile after it's parents have been created.
		DeviceProfile = NewObject<UDeviceProfile>(GetTransientPackage(), *ProfileName);
		DeviceProfile->DeviceType = DeviceProfile->DeviceType.Len() > 0 ? DeviceProfile->DeviceType : ProfileType;
		DeviceProfile->BaseProfileName = DeviceProfile->BaseProfileName.Len() > 0 ? DeviceProfile->BaseProfileName : ParentName;
		DeviceProfile->Parent = ParentObject;

		// Add the new profile to the accessible device profile list
		Profiles.Add( DeviceProfile );

		// Inform any listeners that the device list has changed
		ManagerUpdatedDelegate.Broadcast(); 
	}

	return *DeviceProfile;
}
Esempio n. 12
0
void Matchmaker::CreateWONAccount(const char* theUserName, const char* thePassword)
{
#ifdef DLLSAMPLE
	WONError aError;
	if (mAuthH) { WONAuthCloseHandle(mAuthH); mAuthH = NULL; }
	mAuthH = WONAuthLoginNewAccountA(&aError, mAuthServers, mNumAuthServers, theUserName, COMMUNITY_SAMPLE, thePassword, "", gRequestTimeout);
#else
	mIdentity = Identity(theUserName, COMMUNITY_SAMPLE, thePassword, "", mAuthServers, mNumAuthServers);
	Error aError = mIdentity.AuthenticateNewAccount(gRequestTimeout);
#endif // DLLSAMPLE

	switch (aError)
	{
		case StatusCommon_Success:
			OutputError("Successfully created new account and logged in");

#ifdef DLLSAMPLE
			WONProfileCreate(mAuthH, mProfileServers, mNumProfileServers, "*****@*****.**", gRequestTimeout);
#else
			CreateProfile(&mIdentity, mProfileServers, mNumProfileServers, "*****@*****.**", gRequestTimeout);
#endif

			ListRooms();
			break;
		case StatusAuth_CDKeyInUse:
			OutputError("CD key is already in use");
			break;
		case StatusAuth_CRCFailed:
			OutputError("Invalid version of game");
			break;
		case StatusAuth_UserExists:
			OutputError("User already exists");
			break;
		default:
			OutputError("Account creation failed!", aError);
			break;
	}
}
Esempio n. 13
0
bool MapiProfiles::add(const QString &profile, const QString &username, const QString &password, const QString &domain, const QString &server)
{
    if (!init()) {
        return false;
    }

    // It seams that the QByteArray returned by QString::toUtf8() are not backed up.
    // calling toUtf8() several times will destroy the data. Therefore I copy them
    // all to temporary objects in order to preserve them throughout the whole method
    QByteArray baProfile(profile.toUtf8());
    QByteArray baUser(username.toUtf8());
    QByteArray baPass(password.toUtf8());
    QByteArray baDomain(domain.toUtf8());
    QByteArray baServer(server.toUtf8());

    const char *profile8 = baProfile.constData();
    qDebug() << "New profile is:"<<profile8;

    if (MAPI_E_SUCCESS != CreateProfile(m_context, profile8, baUser.constData(), baPass.constData(), 0)) {
        error() << "cannot create profile:" << mapiError();
        return false;
    }

    // TODO get workstation as parameter (was is it needed for anyway?)
    char hostname[256] = {};
    gethostname(&hostname[0], sizeof(hostname) - 1);
    hostname[sizeof(hostname) - 1] = 0;
    QString workstation = QString::fromLatin1(hostname);

    if (!attributeAdd(profile8, "binding", server)) {
        return false;
    }
    if (!attributeAdd(profile8, "workstation", workstation)) {
        return false;
    }
    if (!attributeAdd(profile8, "domain", domain)) {
        return false;
    }
// What is seal for? Seams to have something to do with Exchange 2010
// 	mapi_profile_add_string_attr(m_context, profile.toUtf8().constData(), "seal", (seal == true) ? "true" : "false");

// TODO Get langage from parameter if needed
// 	const char* locale = (const char *) (language) ? mapi_get_locale_from_language(language) : mapi_get_system_locale();
    const char *locale = mapi_get_system_locale();
    if (!locale) {
        error() << "cannot find system locale:" << mapiError();
        return false;
    }

    uint32_t cpid = mapi_get_cpid_from_locale(locale);
    uint32_t lcid = mapi_get_lcid_from_locale(locale);
    if (!cpid || !lcid) {
        error() << "invalid Locale supplied or unknown system locale" << locale << ", deleting profile..." << mapiError();
        if (!remove(profile)) {
            return false;
        }
        return false;
    }

    if (!attributeAdd(profile8, "codepage", QString::number(cpid))) {
        return false;
    }
    if (!attributeAdd(profile8, "language", QString::number(lcid))) {
        return false;
    }
    if (!attributeAdd(profile8, "method", QString::number(lcid))) {
        return false;
    }

    struct mapi_session *session = NULL;
    if (MAPI_E_SUCCESS != MapiLogonProvider(m_context, &session, profile8, password.toUtf8(), PROVIDER_ID_NSPI)) {
        error() << "cannot get logon provider, deleting profile..." << mapiError();
        if (!remove(profile)) {
            return false;
        }
        return false;
    }

    int retval = ProcessNetworkProfile(session, username.toUtf8().constData(), profileSelectCallback, NULL);
    if (retval != MAPI_E_SUCCESS && retval != 0x1) {
        error() << "cannot process network profile, deleting profile..." << mapiError();
        if (!remove(profile)) {
            return false;
        }
        return false;
    }
    return true;
}
Esempio n. 14
0
static
BOOL
DoLogon(
    IN HWND hwndDlg,
    IN OUT PGINA_CONTEXT pgContext)
{
    LPWSTR UserName = NULL;
    LPWSTR Password = NULL;
    LPWSTR Domain = NULL;
    BOOL result = FALSE;
    NTSTATUS Status, SubStatus = STATUS_SUCCESS;

    if (GetTextboxText(hwndDlg, IDC_USERNAME, &UserName) && *UserName == '\0')
        goto done;

    if (GetTextboxText(hwndDlg, IDC_LOGON_TO, &Domain) && *Domain == '\0')
        goto done;

    if (!GetTextboxText(hwndDlg, IDC_PASSWORD, &Password))
        goto done;

    Status = DoLoginTasks(pgContext, UserName, Domain, Password, &SubStatus);
    if (Status == STATUS_LOGON_FAILURE)
    {
        ResourceMessageBox(pgContext,
                           hwndDlg,
                           MB_OK | MB_ICONEXCLAMATION,
                           IDS_LOGONTITLE,
                           IDS_LOGONWRONGUSERORPWD);
        goto done;
    }
    else if (Status == STATUS_ACCOUNT_RESTRICTION)
    {
        TRACE("DoLoginTasks failed! Status 0x%08lx  SubStatus 0x%08lx\n", Status, SubStatus);

        if (SubStatus == STATUS_ACCOUNT_DISABLED)
        {
            ResourceMessageBox(pgContext,
                               hwndDlg,
                               MB_OK | MB_ICONEXCLAMATION,
                               IDS_LOGONTITLE,
                               IDS_LOGONUSERDISABLED);
            goto done;
        }
        else if (SubStatus == STATUS_ACCOUNT_LOCKED_OUT)
        {
            TRACE("Account locked!\n");
            pgContext->pWlxFuncs->WlxMessageBox(pgContext->hWlx,
                                                hwndDlg,
                                                L"Account locked!",
                                                L"Logon error",
                                                MB_OK | MB_ICONERROR);
            goto done;
        }
        else if ((SubStatus == STATUS_PASSWORD_MUST_CHANGE) ||
                 (SubStatus == STATUS_PASSWORD_EXPIRED))
        {
            if (SubStatus == STATUS_PASSWORD_MUST_CHANGE)
                ResourceMessageBox(pgContext,
                                   hwndDlg,
                                   MB_OK | MB_ICONSTOP,
                                   IDS_LOGONTITLE,
                                   IDS_PASSWORDMUSTCHANGE);
            else
                ResourceMessageBox(pgContext,
                                   hwndDlg,
                                   MB_OK | MB_ICONSTOP,
                                   IDS_LOGONTITLE,
                                   IDS_PASSWORDEXPIRED);

            if (!OnChangePassword(hwndDlg,
                                  pgContext))
                goto done;

            Status = DoLoginTasks(pgContext,
                                  pgContext->UserName,
                                  pgContext->Domain,
                                  pgContext->Password,
                                  &SubStatus);
            if (!NT_SUCCESS(Status))
            {
                TRACE("Login after password change failed! (Status 0x%08lx)\n", Status);

                goto done;
            }
        }
        else
        {
            TRACE("Other error!\n");
            pgContext->pWlxFuncs->WlxMessageBox(pgContext->hWlx,
                                                hwndDlg,
                                                L"Other error!",
                                                L"Logon error",
                                                MB_OK | MB_ICONERROR);
            goto done;
        }
    }
    else if (!NT_SUCCESS(Status))
    {
        TRACE("DoLoginTasks failed! Status 0x%08lx\n", Status);

        goto done;
    }


    if (!CreateProfile(pgContext, UserName, Domain, Password))
    {
        ERR("Failed to create the profile!\n");
        goto done;
    }

    ZeroMemory(pgContext->Password, 256 * sizeof(WCHAR));
    wcscpy(pgContext->Password, Password);

    result = TRUE;

done:
    if (UserName != NULL)
        HeapFree(GetProcessHeap(), 0, UserName);

    if (Password != NULL)
        HeapFree(GetProcessHeap(), 0, Password);

    if (Domain != NULL)
        HeapFree(GetProcessHeap(), 0, Domain);

    return result;
}
Esempio n. 15
0
void ProfileManager::LoadV1Profiles(JSON* v1)
{
    JSON* item0 = v1->GetFirstItem();
    JSON* item1 = v1->GetNextItem(item0);
    JSON* item2 = v1->GetNextItem(item1);

    // Create the new profile database
    Ptr<JSON> root = *JSON::CreateObject();
    root->AddNumberItem("Oculus Profile Version", 2.0);
    root->AddItem("Users", JSON::CreateArray());
    root->AddItem("TaggedData", JSON::CreateArray());
    ProfileCache = root;

    const char* default_dk1_user = item1->Value;
    
    // Read the number of profiles
    int   profileCount = (int)item2->dValue;
    JSON* profileItem  = item2;

    for (int p=0; p<profileCount; p++)
    {
        profileItem = root->GetNextItem(profileItem);
        if (profileItem == NULL)
            break;

        if (profileItem->Name == "Profile")
        {
            // Read the required Name field
            const char* profileName;
            JSON* item = profileItem->GetFirstItem();
        
            if (item && (item->Name == "Name"))
            {   
                profileName = item->Value;
            }
            else
            {
                return;   // invalid field
            }
            
            // Read the user profile fields
            if (CreateUser(profileName, profileName))
            {
                const char* tag_names[2] = {"User", "Product"};
                const char* tags[2];
                tags[0] = profileName;

                Ptr<Profile> user_profile = *CreateProfile();
                user_profile->SetValue(OVR_KEY_NAME, profileName);

                float neckeye[2] = { 0, 0 };

                item = profileItem->GetNextItem(item);
                while (item)
                {
                    if (item->Type != JSON_Object)
                    {
                        if (item->Name == OVR_KEY_PLAYER_HEIGHT)
                        {   // Add an explicit eye height

                        }
                        if (item->Name == "NeckEyeHori")
                            neckeye[0] = (float)item->dValue;
                        else if (item->Name == "NeckEyeVert")
                            neckeye[1] = (float)item->dValue;
                        else 
                            user_profile->SetValue(item);
                    }
                    else
                    {   
                        // Add the user/device tag values
                        const char* device_name = item->Name.ToCStr();
                        Ptr<Profile> device_profile = *CreateProfile();

                        JSON* device_item = item->GetFirstItem();
                        while (device_item)
                        {
                            device_profile->SetValue(device_item);
                            device_item = item->GetNextItem(device_item);
                        }

                        tags[1] = device_name;
                        SetTaggedProfile(tag_names, tags, 2, device_profile);
                    }

                    item = profileItem->GetNextItem(item);
                }

                // Add an explicit eye-height field
                float player_height = user_profile->GetFloatValue(OVR_KEY_PLAYER_HEIGHT,
                                                                  OVR_DEFAULT_PLAYER_HEIGHT);
                if (player_height > 0)
                {
                    char gender[16];
                    user_profile->GetValue(OVR_KEY_GENDER, gender, 16);
        
                    const float EYE_TO_HEADTOP_RATIO =   0.44538f;
                    const float MALE_AVG_HEAD_HEIGHT =   0.232f;
                    const float FEMALE_AVG_HEAD_HEIGHT = 0.218f;
     
                    // compute distance from top of skull to the eye
                    float head_height;
                    if (OVR_strcmp(gender, "Female") == 0)
                        head_height = FEMALE_AVG_HEAD_HEIGHT;
                    else
                        head_height = MALE_AVG_HEAD_HEIGHT;

                    float skull = EYE_TO_HEADTOP_RATIO * head_height;
                    float eye_height = player_height - skull;

                    user_profile->SetFloatValue(OVR_KEY_EYE_HEIGHT, eye_height);
                }

                // Convert NeckEye values to an array
                if (neckeye[0] > 0 && neckeye[1] > 0)
                    user_profile->SetFloatValues(OVR_KEY_NECK_TO_EYE_DISTANCE, neckeye, 2);

                // Add the user tag values
                SetTaggedProfile(tag_names, tags, 1, user_profile);
            }
        }
    }

    // since V1 profiles were only for DK1, the assign the user to all DK1's
    const char* tag_names[1] = { "Product" };
    const char* tags[1] = { "RiftDK1" };
    Ptr<Profile> product_profile = *CreateProfile();
    product_profile->SetValue("DefaultUser", default_dk1_user);
    SetTaggedProfile(tag_names, tags, 1, product_profile);
}
Esempio n. 16
0
void ProfileDlg::OnImportProfile() 
{
	CString name;
	CString tmp;
	tmp.LoadString(IDS_PROFILE_FILEDIALOG);
	CFileDialog fd( TRUE, _T("prf"), NULL, OFN_ENABLESIZING|OFN_FILEMUSTEXIST, tmp + _T(" (*.xpas)|*.xpas||"), this);
	tmp.LoadString(IDS_PROFILE_LOAD);
	fd.m_ofn.lpstrTitle = tmp;
	if(fd.DoModal() == IDOK)
	{
		StringVec profiles = GetExistingProfiles();
		for(int i = 0; i < profiles.size(); ++i)
		{
			profiles[i].MakeLower();
			fd.GetFileName().MakeLower();
			if(profiles[i] == fd.GetFileTitle())
			{
				CString tmp;
				tmp.LoadString(IDS_PROFILE_EXISTS);
				if(MessageBox(tmp, NULL, MB_YESNO) == IDNO)
				{
					return;
				}
				else
				{
					DeleteProfile(fd.GetFileTitle());
				}
			}
		}

		CFile file(fd.GetPathName(), CFile::modeRead);
		SettingVec vec;
		
		CArchive* ar=new CArchive(&file,CArchive::load);
		try
		{
			while(1)
			{
				SETTING set;
				*ar>>set.settingID;
				*ar>>set.checked;
				if((set.settingID <= ITEMCOUNT && set.settingID >= 0)
					|| (set.checked >= 0 && set.checked <= 1))
				{
					vec.push_back(set);
				}
			}
		}
		catch(CArchiveException* e)
		{
			e->Delete();
			if(vec.size() > 0)
				CreateProfile(fd.GetFileTitle(),vec);
			else
			{
				CString tmp;
				tmp.LoadString(IDS_PROFILE_ERROR);
				AfxMessageBox(tmp);
			}
		}
		ar->Close();
		if(ar) delete ar;
		file.Close();
	}
Esempio n. 17
0
void CProfileSelectState::MenuInput()
{
	SGD::InputManager* input = SGD::InputManager::GetInstance();

	if (state == MyState::ConfirmOverwrite)
	{
#if ARCADE
		if (input->IsButtonPressed(0, 1) || input->IsButtonPressed(1, 1))
#else
		if (input->IsKeyPressed(SGD::Key::Escape) || input->IsButtonPressed(0, 1))
#endif
		{
			delete confirm;
			confirm = nullptr;
			state = MyState::Menu;
			return;
		}
		switch (confirm->Input())
		{
		case 0:
		{
			delete confirm;
			confirm = nullptr;
			CGameplayState::GetInstance()->DeleteProfile(currentProfile+1);
			profiles[currentProfile] = CreateProfile();
			TutorialConfirmation();
			break;
		}
		case 1:
		{
			delete confirm;
			confirm = nullptr;
			state = MyState::Menu;
		}
		case -1:
		default:
			break;
		}
		return;
	}

	if (state == MyState::ConfirmDelete)
	{
#if ARCADE
		if (input->IsButtonPressed(0, 1) || input->IsButtonPressed(1, 1))
#else
		if (input->IsKeyPressed(SGD::Key::Escape) || input->IsButtonPressed(0, 1))
#endif
		{
			delete confirm;
			confirm = nullptr;
			state = MyState::Menu;
			return;
		}
		switch (confirm->Input())
		{
		case 0:
			CGameplayState::GetInstance()->DeleteProfile(currentProfile+1);
			profiles[currentProfile] = CreateProfile();
			//profiles[currentProfile].profile = currentProfile + 1;
			//Don't break! They both delete confirm and change state beck to menu
		case 1:
			delete confirm;
			confirm = nullptr;
			state = MyState::Menu;
			break;
		case -1:
		default:
			break;
		}
		return;
	}

	if (state == MyState::ConfirmTutorial)
	{
#if ARCADE
		if (input->IsButtonPressed(0, 1) || input->IsButtonPressed(1, 1))
#else
		if (input->IsKeyPressed(SGD::Key::Escape) || input->IsButtonPressed(0, 1))
#endif
		{
			delete confirm;
			confirm = nullptr;
			state = MyState::Menu;
			return;
		}
		switch (confirm->Input())
		{
		case 0:
			profiles[currentProfile].currLevel = Level::Gen1;
		case 1:
			CGameplayState::GetInstance()->SetSaveData(profiles[currentProfile]);
			Game::GetInstance()->PopState();
			Game::GetInstance()->PopState();
			Game::GetInstance()->PushState(CGameplayState::GetInstance());
			break;
		case 2:
			delete confirm;
			confirm = nullptr;
			state = MyState::Menu;
			break;
		case -1:
		default:
			break;
		}
		return;
	}

#if ARCADE
	if (input->IsButtonPressed(0, 1) || input->IsButtonPressed(1, 1))
#else
	if (input->IsKeyPressed(SGD::Key::Escape) || input->IsButtonPressed(0, 1))
#endif
	{
		state = MyState::Idle;
		return;
	}

	switch (menu->Input())
	{
	case 0:
		if (profiles[currentProfile].currLevel == Level::Tutorial)
		{
			TutorialConfirmation();
			break;
		}
		CGameplayState::GetInstance()->SetSaveData(profiles[currentProfile]);
		Game::GetInstance()->PopState();
		Game::GetInstance()->PopState();
		Game::GetInstance()->PushState(CGameplayState::GetInstance());
		break;
	case 1:
	{
		std::vector<std::string> yesno;
		yesno.push_back("Yes");
		yesno.push_back("No");
		confirm = new CMenu(&Game::GetInstance()->FontPoiret, yesno, "Overwrite?", { Game::GetInstance()->GetScreenWidth() * .55f, Game::GetInstance()->GetScreenHeight() * .6f }, false);
		state = MyState::ConfirmOverwrite;
		break;
	}
	case 2:
	{
		std::vector<std::string> yesno;
		yesno.push_back("Yes");
		yesno.push_back("No");
		confirm = new CMenu(&Game::GetInstance()->FontPoiret, yesno, "Delete?", { Game::GetInstance()->GetScreenWidth() * .55f, Game::GetInstance()->GetScreenHeight() * .6f }, false);
		state = MyState::ConfirmDelete;
		break;
	}
	case 3:
	{
		state = MyState::Idle;
		break;
	}
	case 4:
	{
		Game::GetInstance()->PopState();
		//Game::GetInstance()->PushState(CMainMenuState::GetInstance());
		break;
	}
	case -1:
	default:
		break;
	}
}
Esempio n. 18
0
GameInfo*   CGame::LoadProfile( int _slot )
{

	TiXmlDocument x_loadslot;


	//assert( x_loadslot.LoadFile("config/save_slots.xml") != false && "XML save slot file could not be loaded");
	//x_loadslot.LoadFile("config/save_slots.xml");

	ifstream ifs( m_szFilepath.c_str() );
	if(ifs)
		x_loadslot.LoadFile(m_szFilepath.c_str());
	else
		x_loadslot.LoadFile("config/save_slots.xml");
	ifs.close();


	TiXmlElement* x_pRoot = x_loadslot.RootElement();


	//assert( x_pRoot != nullptr && "XML root is NULL");

	int nSlot = 0;
	TiXmlElement* x_save = x_pRoot->FirstChildElement("Save");
	x_save->Attribute("slot", &nSlot);

	while(nSlot != _slot)
	{
		x_save = x_save->NextSiblingElement("Save");
		x_save->Attribute("slot", &nSlot);
	}

	int isFilled = 0;
	x_save->Attribute("empty", &isFilled);

	if(isFilled == false && _slot > 0)
		return nullptr;	
	else
	{
		
		int stg, exp, hp, sp, life, fire, wind, ice, earth, fsc, lang, bgm, sfx;

		TiXmlElement* x_player = x_save->FirstChildElement("Player");
		x_player->Attribute("stage", &stg);
		x_player->Attribute("Exp", &exp);

		TiXmlElement* x_upgrades = x_player->NextSiblingElement("Upgrades");

		TiXmlElement* x_HP = x_upgrades->FirstChildElement("Health");
		x_HP->Attribute("level", &hp);

		TiXmlElement* x_Spl = x_HP->NextSiblingElement("Special");
		x_Spl->Attribute("level", &sp);

		TiXmlElement* x_lives = x_Spl->NextSiblingElement("Lives");
		x_lives->Attribute("level", &life);

		TiXmlElement* x_fire = x_lives->NextSiblingElement("Fire");
		x_fire->Attribute("level", &fire);

		TiXmlElement* x_wind = x_fire->NextSiblingElement("Wind");
		x_wind->Attribute("level", &wind);

		TiXmlElement* x_ice = x_wind->NextSiblingElement("Ice");
		x_ice->Attribute("level", &ice);

		TiXmlElement* x_earth = x_ice->NextSiblingElement("Earth");
		x_earth->Attribute("level", &earth);


		TiXmlElement* x_Options = x_upgrades->NextSiblingElement("Options");

		TiXmlElement* x_setting = x_Options->FirstChildElement("fullscreen");


		//Set the pointer to it's own child
		x_setting->Attribute("value", &fsc);
		
		x_setting = x_setting->NextSiblingElement("language");
		x_setting->Attribute("value", &lang);

		x_setting = x_setting->NextSiblingElement("BGM");
		x_setting->Attribute("value", &bgm);

		x_setting = x_setting->NextSiblingElement("SFX");
		x_setting->Attribute("value", &sfx);

		return CreateProfile(stg, exp, hp, sp, life, fire, wind, ice,
										earth, fsc, lang, bgm, sfx);
	}

}
Esempio n. 19
0
void CGame::SaveProfile( GameInfo* pInfo, int _slot )
{
	TiXmlDocument x_saveSlot;

	//assert( x_saveSlot.LoadFile("config/save_slots.xml") != false && "XML save slot file could not be loaded");
//	if(m_szFilepath.c_str() == NULL)
	//	x_saveSlot.LoadFile("config/save_slots.xml");
	//else

	ifstream ifs( m_szFilepath.c_str() );
	if(ifs)
		x_saveSlot.LoadFile(m_szFilepath.c_str());
	else
		x_saveSlot.LoadFile("config/save_slots.xml");

	ifs.close();

	TiXmlElement* x_pRoot = x_saveSlot.RootElement();
	//assert( x_pRoot != nullptr && "XML root is NULL");

	int nSlot = 0;
	bool bClear = false;
	TiXmlElement* x_pSave = x_pRoot->FirstChildElement("Save");
	x_pSave->Attribute("slot", &nSlot);

	while(nSlot != _slot)
	{
		x_pSave = x_pSave->NextSiblingElement("Save");
		x_pSave->Attribute("slot", &nSlot);
	}

	if( pInfo == nullptr)
	{
		pInfo = CreateProfile();
		x_pSave->SetAttribute("empty", 0);
		bClear = true;
	}
	else
		x_pSave->SetAttribute("empty", 1);

	TiXmlElement* x_pPlayer = x_pSave->FirstChildElement("Player");
	x_pPlayer->SetAttribute("stage", pInfo->Stage());
	x_pPlayer->SetAttribute("Exp", pInfo->EXP());

	TiXmlElement* x_pUpgrades = x_pPlayer->NextSiblingElement("Upgrades");

	TiXmlElement* x_pItem = x_pUpgrades->FirstChildElement("Health");
	x_pItem->SetAttribute("level", pInfo->Health());

	x_pItem = x_pItem->NextSiblingElement("Special");
	x_pItem->SetAttribute("level", pInfo->Special());

	x_pItem = x_pItem->NextSiblingElement("Lives");
	x_pItem->SetAttribute("level", pInfo->Lives());

	x_pItem = x_pItem->NextSiblingElement("Fire");
	x_pItem->SetAttribute("level", pInfo->Fire());

	x_pItem = x_pItem->NextSiblingElement("Wind");
	x_pItem->SetAttribute("level", pInfo->Wind());

	x_pItem = x_pItem->NextSiblingElement("Ice");
	x_pItem->SetAttribute("level", pInfo->Ice());

	x_pItem = x_pItem->NextSiblingElement("Earth");
	x_pItem->SetAttribute("level", pInfo->Earth());


	TiXmlElement* x_pOptions = x_pUpgrades->NextSiblingElement("Options");

	TiXmlElement* x_pSetting = x_pOptions->FirstChildElement("fullscreen");
	x_pSetting->SetAttribute("value", pInfo->Fullscreen());

	x_pSetting = x_pSetting->NextSiblingElement("language");
	x_pSetting->SetAttribute("value", pInfo->Language());

	x_pSetting = x_pSetting->NextSiblingElement("BGM");
	x_pSetting->SetAttribute("value", pInfo->BGM());

	x_pSetting = x_pSetting->NextSiblingElement("SFX");
	x_pSetting->SetAttribute("value", pInfo->SFX() );

	
	x_saveSlot.SaveFile(m_szFilepath.c_str());
	//x_saveSlot.SaveFile("config/save_slots.xml");


	if(bClear)
		delete pInfo;
}
Esempio n. 20
0
// Initialize
//	- setup the SGD wrappers
//	- load resources
void CGame::Initialize( HWND hWnd, HINSTANCE hInstance,
					int nWidth, int nHeight,
					bool bIsWindowed )
{
	GameInstance	= hInstance;
	GamehWnd		= hWnd;
	// Store the SGD Wrapper singletons
	m_pD3D			= CSGD_Direct3D::GetInstance();
	m_pDI			= CSGD_DirectInput::GetInstance();
	m_pTM			= CSGD_TextureManager::GetInstance();
	m_pXA			= CSGD_XAudio2::GetInstance();
	m_pAM			= AnimationManager::GetInstance();	
	
	// Store the parameters
	m_nScreenWidth	= nWidth;
	m_nScreenHeight	= nHeight;
	m_bIsWindowed	= bIsWindowed;


	// Initialize the wrappers
	m_pD3D->Initialize( hWnd, 
						m_nScreenWidth, m_nScreenHeight, 
						m_bIsWindowed );

	m_pDI->Initialize( hWnd, hInstance, 
						DI_KEYBOARD | DI_JOYSTICKS /*| DI_MOUSE | DI_JOYSTICKS*/ );

	m_pTM->Initialize( m_pD3D->GetDirect3DDevice(),
						m_pD3D->GetSprite() );

	m_pXA->Initialize();

	m_pMS = CSGD_MessageSystem::GetInstance();
	m_pMS->InitMessageSystem(MessageProc);

	m_pAUM = CAudioManager::GetInstance();
	m_pAUM->Initialize("config/audio.xml");

	m_pFont = new FontManager;
	m_pFont->Initialize("config/fonts.xml");

	m_pEM = new CEntityManager;

	// Starts in the Main Menu state
	m_pGameState = new StateManager;
	m_pGameState->Initialize();

	m_pCtrl = CController::GetInstance();

	Create_Save_Load_Directory();
	m_pProfile = CreateProfile(1,1,1);

	COptionState::GetInstance()->Import(m_pProfile);


	m_pPUM   = CPopUpManager::GetInstance(); 
	m_pPUM->Initialize("config/popups.xml");

	FirstRun(true);
	Tutorial(false);
}
Esempio n. 21
0
static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	struct DlgProfData *dat = (struct DlgProfData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
		dat = (struct DlgProfData *)lParam;
		{
			HWND hwndCombo = GetDlgItem(hwndDlg, IDC_PROFILEDRIVERS);

			// what, no plugins?!
			if (arDbPlugins.getCount() == 0) {
				EnableWindow(hwndCombo, FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILENAME), FALSE);
				ShowWindow(GetDlgItem(hwndDlg, IDC_NODBDRIVERS), TRUE);
			}
			else {
				for (int i = 0; i < arDbPlugins.getCount(); i++) {
					DATABASELINK *p = arDbPlugins[i];
					LRESULT index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)TranslateTS(p->szFullName));
					SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)p);
				}
			}

			// default item
			SendMessage(hwndCombo, CB_SETCURSEL, 0, 0);

			// subclass the profile name box
			mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PROFILENAME), ProfileNameValidate);
		}

		// decide if there is a default profile name given in the INI and if it should be used
		if (dat->pd->noProfiles || (shouldAutoCreate(dat->pd->szProfile) && _taccess(dat->pd->szProfile, 0))) {
			TCHAR *profile = _tcsrchr(dat->pd->szProfile, '\\');
			if (profile) ++profile;
			else profile = dat->pd->szProfile;

			TCHAR *p = _tcsrchr(profile, '.');
			TCHAR c = 0;
			if (p) { c = *p; *p = 0; }

			SetDlgItemText(hwndDlg, IDC_PROFILENAME, profile);
			if (c) *p = c;
		}

		// focus on the textbox
		PostMessage(hwndDlg, WM_FOCUSTEXTBOX, 0, 0);
		return TRUE;

	case WM_FOCUSTEXTBOX:
		SetFocus(GetDlgItem(hwndDlg, IDC_PROFILENAME));
		break;

	case WM_INPUTCHANGED: // when input in the edit box changes
		SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
		EnableWindow(dat->hwndOK, GetWindowTextLength(GetDlgItem(hwndDlg, IDC_PROFILENAME)) > 0);
		break;

	case WM_SHOWWINDOW:
		if (wParam) {
			EnableWindow(dat->hwndSM, FALSE);
			SetWindowText(dat->hwndOK, TranslateT("&Create"));
			SendMessage(hwndDlg, WM_INPUTCHANGED, 0, 0);
		}
		break;

	case WM_NOTIFY:
		NMHDR *hdr = (NMHDR*)lParam;
		if (hdr && hdr->code == PSN_APPLY && dat && IsWindowVisible(hwndDlg)) {
			TCHAR szName[MAX_PATH];
			LRESULT curSel = SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETCURSEL, 0, 0);
			if (curSel == CB_ERR)
				break; // should never happen

			GetDlgItemText(hwndDlg, IDC_PROFILENAME, szName, SIZEOF(szName));
			if (szName[0] == 0)
				break;

			// profile placed in "profile_name" subfolder
			mir_sntprintf(dat->pd->szProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), dat->pd->szProfileDir, szName, szName);
			dat->pd->newProfile = 1;
			dat->pd->dblink = (DATABASELINK *)SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETITEMDATA, (WPARAM)curSel, 0);

			if (CreateProfile(dat->pd->szProfile, dat->pd->dblink, hwndDlg) == 0)
				SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
		}
		break;
	}

	return FALSE;
}