Add your privacy policy in the settings charm to a DirectX game

1 out of 2 rated this helpful - Rate this topic

[This documentation is preliminary and is subject to change.]

In this topic, you will learn about adding a settings charm to a DirectX 11.1 game for the Windows Store using C++. This topic describes the charms, the settings charm, related store requirements, and how to add the settings charm by using C++.

The example code in this topic is already included in the Direct3DGame_XAML template. See the Use DirectX with a XAML overlay topic for more information.

What is the Settings charm?

The charms are a specific and consistent set of buttons for users in every app: search, share, connect, settings, and start. The Settings charm displays a set of settings specific to the current app. You add items to the settings menu and set the actions triggered when the user clicks on each item.

Here is an illustration of the charms.

Dn166858.charms(en-us,WIN.10).png

Windows draws the charms and triggers the charms events.

Adding a privacy policy settings charm

The Windows Store requires that you have a privacy statement if your game uses any of these capabilities: internetClient, internetClientServer and privateNetworkClientServer. Examples of app features that require those capabilities include saving to the cloud and multi-player gaming.

The example code here adds a privacy policy settings charm to your app. Place this code in the constructor or an initialization method.


     // Add a Settings charm for the privacy policy
    SettingsPane::GetForCurrentView()->CommandsRequested += 
    ref new TypedEventHandler<SettingsPane^, SettingsPaneCommandsRequestedEventArgs^>(
        [this](SettingsPane^ sender, SettingsPaneCommandsRequestedEventArgs^ args) 
        {
            // Add the command labeled "Privacy Policy".
            args->Request->ApplicationCommands->Append(
                ref new SettingsCommand(
                    "privacyPolicy",  // settings command name.
                    "Privacy Policy", // Settings command label.
     
                    // Add a handler for when the user clicks the command.
                    ref new Windows::UI::Popups::UICommandInvokedHandler([=](Windows::UI::Popups::IUICommand^ command)
                    {
                        // This is a link to your privacy policy on you're website.
                        // Be sure to replace this string with the URL to your privacy policy.
                        auto uri = ref new Windows::Foundation::Uri("<insert web url to your privacy policy here>");

                        // Launch the URI.
                        concurrency::task<bool> launchUriOperation(Windows::System::Launcher::LaunchUriAsync(uri));
                        launchUriOperation.then([](bool success){});
                    })));
        });

The UICommandInvokedHandler delegate is where you place your event handler code.

Note  An invalid URL causes an exception at runtime.

Detecting when the charms appear

Many games need to pause when the charms appear. The example code here detects when the charms appear so that you can pause the game or perform other commands.


    // Add an event handler to pause when charms are activated.
    Window::Current->Activated += ref new WindowActivatedEventHandler(
            [this] (Platform::Object^ sender, Windows::UI::Core::WindowActivatedEventArgs^ args)
            {
                switch (args->WindowActivationState)
                {
                case Windows::UI::Core::CoreWindowActivationState::Deactivated:
                    m_paused = true;  // Set the game state to "paused".
                    break;
                    
                case Windows::UI::Core::CoreWindowActivationState::CodeActivated:
                case Windows::UI::Core::CoreWindowActivationState::PointerActivated:
                    m_paused = false; // Set the game state to "unpaused".
                    break;
                }
            }
        
        );

Note  The preceding example does not detect when the app bar appears. The app bar triggers event handlers when it opens and closes. For more information, see Add an app bar.

By following the example, you can add more settings. You can also add settings flyouts with multiple settings.

Adding entry points to settings flyouts

Entry points are text strings that appear at the top of the Settings pane and generally open settings flyouts, where you can display one or more settings options.

If you are creating a game with DirectX and XAML, you can use the XAML Popup element to a flyout container to display a custom settings pane. This pane can contain a variety of XAML controls, such as the Slider control. For example code, see the XAML Popup sample.

Note  If your app does not use XAML, you must display flyouts manually by using a technology such as Direct2D. The Guidelines for app settings describe best practices for using the settings charm to display app settings.

 

 

Build date: 3/22/2013

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.