bombomby / optick

C++ Profiler For Games
https://optick.dev
MIT License
2.95k stars 296 forks source link

Rework PlatformSelector Control #57

Closed bombomby closed 5 years ago

bombomby commented 5 years ago

image

This control is responsible for selecting the target which we would like to connect to. Model is desribed here - Profiler.Platform.Connection:

            public class Connection
        {
            public Platform.Type Target { get; set; }
            public String Name { get; set; }
            public IPAddress Address { get; set; }
            public int Port { get; set; }
        }

Behaviour: By default the listbox should contain two items: 1) Current Host Name + IP Address + Default Port (31313) 2) An element with name "Add Connection" + IP 127.0.0.1 + Default Port (31313)

To get current host name use function Environment.MachineName. To get IP-address - please use the following function: List listIP = Platform.GetPCAddresses(); This function might return multiple IP-addresses in case we have more than one network card (including virtual network cards). We need to have an individual entry for each returned ip-address.

After selecting "Add Connection", selecting IP-address, Port and pressing start: if connection is succesful - you'll receive a routed message about the new connection.

        private void TimeLine_NewConnection(object sender, RoutedEventArgs e)
        {
            TimeLine.NewConnectionEventArgs args = e as TimeLine.NewConnectionEventArgs;
            // TODO: Implement new connection processing
            Debug.Print("New Connection: [{0}] {1}:{2} {3}", args.Connection.Target, args.Connection.Address, args.Connection.Port, args.Connection.Name);
        }

Example output: New Connection: [Windows] 127.0.0.1:31313 CopmuterName

Key features: 1) Once a message with the information regarding the new connection is arrived - we need to create a new entry in the combobox and select it (if we already have an instance with the same "IPAddress+Port" - just update the entry). 2) For each combobox item template we need to add a button with cross icon - alightment to the right ("appbar_close" icon name). When we hover this button - cross should become dark red. Pressing this button should remove the entry from the combobox. 3) We should not be able to remove any of the 'core' items (Current Host Addresses, "Add Connection") 4) Use the following icons for each platform: windows - "appbar_os_windows_8", linux - "appbar_os_ubuntu", macos - "appbar_social_apple", xbox - "appbar_controller_xbox", playstation - "appbar_social_playstation". 5) Extra textboxes for IP and Port are visible only if we selected "Add Connection" item. 6) Any modification to the list of connections or information update should be saved into local settings - "Profiler.Controls.Settings.LocalSettings.Connections". These settings has a special type which synchronizes values between multiple instances of the application. Any modification to the the data in this list should be confirmed with Save() call. This call might be expensive, so we need to run it as a Task. 7) Subscribe on Profiler.Controls.Settings.LocalSettings.OnChanged event and update the combo-box when this event is triggered. Test that combobox list of items is synchronized between multiple instances of the BrofilerApp.