Пример #1
0
        private static void LoadBooleanSettings()
        {
            using (Settings xmlReader = new SKSettings())
            {
                IDictionary <string, bool> allBooleanSettings = xmlReader.GetSection <bool>("booleansettings");

                if (allBooleanSettings == null)
                {
                    return;
                }

                lock (_skinBoolSettings)
                {
                    var enumerator = allBooleanSettings.GetEnumerator();
                    if (enumerator != null)
                    {
                        while (enumerator.MoveNext())
                        {
                            // Create the new boolean setting.
                            SkinBool newBool = new SkinBool();
                            newBool.Name  = enumerator.Current.Key;
                            newBool.Value = enumerator.Current.Value;
                            newBool.Kind  = Kind.PERSISTENT;

                            // Add the setting to the dictionary.
                            int key = _skinBoolSettings.Count;
                            _skinBoolSettings[key] = newBool;

                            // Create the setting as a property.  The boolean value is converted as a string representation.
                            GUIPropertyManager.SetProperty(newBool.Name, newBool.Value.ToString());
                        }
                    }
                }
            }
        }
Пример #2
0
        private static void LoadStringSettings()
        {
            using (Settings xmlReader = new SKSettings())
            {
                IDictionary <string, string> allStringSettings = xmlReader.GetSection <string>("stringsettings");

                if (allStringSettings == null)
                {
                    return;
                }

                lock (_skinStringSettings)
                {
                    var enumerator = allStringSettings.GetEnumerator();
                    if (enumerator != null)
                    {
                        while (enumerator.MoveNext())
                        {
                            // Create the new string setting.
                            SkinString newString = new SkinString();
                            newString.Name  = enumerator.Current.Key;
                            newString.Value = enumerator.Current.Value;
                            newString.Kind  = Kind.PERSISTENT;

                            // Add the setting to the dictionary.
                            int key = _skinStringSettings.Count;
                            _skinStringSettings[key] = newString;

                            // Create the setting as a property.
                            GUIPropertyManager.SetProperty(newString.Name, newString.Value);
                        }
                    }
                }
            }
        }
Пример #3
0
    ///////////////////////////////////////////

    static void Main(string[] args)
    {
        // Initialize the StereoKit application
        SKSettings settings = new SKSettings
        {
            appName      = "StereoKit_BingMaps",
            assetsFolder = "Assets",
        };

        if (!SK.Initialize(settings))
        {
            Environment.Exit(1);
        }

        Initialize();

        while (SK.Step(() =>
        {
            // If we're in AR, we don't initialize floorMesh, hence the '?'
            // operator! The real world should already have a floor :)
            floorMesh?.Draw(floorMat, Matrix.T(0, -1.5f, 0));

            // Draw the terrain widget!
            ShowTerrainWidget();
        }))
        {
            ;
        }

        SK.Shutdown();
    }
Пример #4
0
    public void Initialize()
    {
        /// :CodeDoc: Guides Using The Simulator
        SKSettings settings = new SKSettings {
            appName      = "Flatscreen Simulator",
            assetsFolder = "Assets",
            // This tells StereoKit to always start in a 2D flatscreen
            // window, instead of an immersive MR environment.
            displayPreference = DisplayMode.Flatscreen,
            // Setting this to true will disable all built-in MR simulator
            // controls.
            disableFlatscreenMRSim = false,
            // Setting this to true will prevent StereoKit from creating the
            // fallback simulator when OpenXR fails to initialize. This is
            // important when shipping a final application to users.
            noFlatscreenFallback = true,
        };

        ///
        /// ### Overriding Hands
        ///
        /// A number of functions are present that can make unit test and
        /// complex input simulation possible. For a full example of this,
        /// the [DebugToolWindow](https://github.com/maluoi/StereoKit/blob/master/Examples/StereoKitTest/DebugToolWindow.cs)
        /// in the Test project has a number of sample utilities for
        /// recording and playing back input.
        ///
        /// Overriding the hands is one important element that you may want
        /// to do! [`Input.HandOverride`]({{site.url}}/Pages/Reference/Input/HandOverride.html)
        /// will set the hand input to a very specific pose, and hold that
        /// pose until you call `Input.HandOverride` again with a new pose,
        /// or call [`Input.HandClearOverride`]({{site.url}}/Pages/Reference/Input/HandClearOverride.html)
        /// to restore control back to the user.
        ///
        /// ![An overriden hand]({{site.screen_url}}/HandOverride.jpg)
        /// _This screenshot is generated fresh every StereoKit release using Input.HandOverride, to ensure consistency!_
        // These 25 joints were printed using code from a session with a real
        // hand.
        HandJoint[] joints = new HandJoint[] { new HandJoint(new Vec3(0.132f, -0.221f, -0.168f), new Quat(-0.445f, -0.392f, 0.653f, -0.472f), 0.021f), new HandJoint(new Vec3(0.132f, -0.221f, -0.168f), new Quat(-0.445f, -0.392f, 0.653f, -0.472f), 0.021f), new HandJoint(new Vec3(0.141f, -0.181f, -0.181f), new Quat(-0.342f, -0.449f, 0.618f, -0.548f), 0.014f), new HandJoint(new Vec3(0.139f, -0.151f, -0.193f), new Quat(-0.409f, -0.437f, 0.626f, -0.499f), 0.010f), new HandJoint(new Vec3(0.141f, -0.133f, -0.198f), new Quat(-0.409f, -0.437f, 0.626f, -0.499f), 0.010f), new HandJoint(new Vec3(0.124f, -0.229f, -0.172f), new Quat(0.135f, -0.428f, 0.885f, -0.125f), 0.024f), new HandJoint(new Vec3(0.103f, -0.184f, -0.209f), new Quat(0.176f, -0.530f, 0.774f, -0.299f), 0.013f), new HandJoint(new Vec3(0.078f, -0.153f, -0.225f), new Quat(0.173f, -0.645f, 0.658f, -0.349f), 0.010f), new HandJoint(new Vec3(0.061f, -0.135f, -0.228f), new Quat(-0.277f, 0.674f, -0.623f, 0.283f), 0.010f), new HandJoint(new Vec3(0.050f, -0.125f, -0.227f), new Quat(-0.277f, 0.674f, -0.623f, 0.283f), 0.010f), new HandJoint(new Vec3(0.119f, -0.235f, -0.172f), new Quat(0.147f, -0.399f, 0.847f, -0.318f), 0.024f), new HandJoint(new Vec3(0.088f, -0.200f, -0.211f), new Quat(0.282f, -0.603f, 0.697f, -0.268f), 0.012f), new HandJoint(new Vec3(0.056f, -0.169f, -0.216f), new Quat(-0.370f, 0.871f, -0.308f, 0.099f), 0.010f), new HandJoint(new Vec3(0.045f, -0.156f, -0.195f), new Quat(-0.463f, 0.884f, -0.022f, -0.066f), 0.010f), new HandJoint(new Vec3(0.047f, -0.155f, -0.178f), new Quat(-0.463f, 0.884f, -0.022f, -0.066f), 0.010f), new HandJoint(new Vec3(0.111f, -0.244f, -0.173f), new Quat(0.182f, -0.436f, 0.778f, -0.414f), 0.022f), new HandJoint(new Vec3(0.074f, -0.213f, -0.205f), new Quat(-0.353f, 0.622f, -0.656f, 0.244f), 0.011f), new HandJoint(new Vec3(0.046f, -0.189f, -0.204f), new Quat(-0.436f, 0.891f, -0.073f, -0.108f), 0.010f), new HandJoint(new Vec3(0.048f, -0.184f, -0.182f), new Quat(-0.451f, 0.811f, 0.264f, -0.263f), 0.010f), new HandJoint(new Vec3(0.061f, -0.188f, -0.168f), new Quat(-0.451f, 0.811f, 0.264f, -0.263f), 0.010f), new HandJoint(new Vec3(0.105f, -0.250f, -0.170f), new Quat(0.219f, -0.470f, 0.678f, -0.521f), 0.020f), new HandJoint(new Vec3(0.062f, -0.228f, -0.196f), new Quat(-0.444f, 0.610f, -0.623f, 0.206f), 0.010f), new HandJoint(new Vec3(0.044f, -0.215f, -0.192f), new Quat(-0.501f, 0.841f, -0.094f, -0.183f), 0.010f), new HandJoint(new Vec3(0.048f, -0.209f, -0.176f), new Quat(-0.521f, 0.682f, 0.251f, -0.448f), 0.010f), new HandJoint(new Vec3(0.061f, -0.207f, -0.168f), new Quat(-0.521f, 0.682f, 0.251f, -0.448f), 0.010f), new HandJoint(new Vec3(0.098f, -0.222f, -0.191f), new Quat(0.308f, -0.906f, 0.288f, -0.042f), 0.000f), new HandJoint(new Vec3(0.131f, -0.251f, -0.164f), new Quat(0.188f, -0.436f, 0.844f, -0.248f), 0.000f) };

        Input.HandOverride(Handed.Right, joints);
        ///
        /// :End:

        if (Tests.IsTesting)
        {
            Input.HandVisible(Handed.Right, true);
        }
        Tests.RunForFrames(2);
    }
Пример #5
0
        void Run(IntPtr activityHandle)
        {
            if (running)
            {
                return;
            }
            running = true;

            Task.Run(() => {
                // If the app has a constructor that takes a string array, then
                // we'll use that, and pass the command line arguments into it on
                // creation
                Type appType = typeof(App);
                app          = appType.GetConstructor(new Type[] { typeof(string[]) }) != null
                                        ? (App)Activator.CreateInstance(appType, new object[] { new string[0] {
                                                                                                } })
                                        : (App)Activator.CreateInstance(appType);
                if (app == null)
                {
                    throw new System.Exception("StereoKit loader couldn't construct an instance of the App!");
                }

                // Initialize StereoKit, and the app
                SKSettings settings      = app.Settings;
                settings.androidActivity = activityHandle;
                settings.assetsFolder    = "";

                // For requesting permission to use the Microphone
                if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.RecordAudio) != Android.Content.PM.Permission.Granted)
                {
                    ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.RecordAudio }, 1);
                }

                if (!SK.Initialize(settings))
                {
                    return;
                }
                app.Init();

                // Now loop until finished, and then shut down
                while (SK.Step(app.Step))
                {
                }
                SK.Shutdown();

                Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
            });
        }
Пример #6
0
 private static void LoadDiscreteSettings()
 {
     using (Settings xmlReader = new SKSettings())
     {
         if (!_noTheme)
         {
             // Initialize the theme manager for the selected theme.
             GUIThemeManager.Init(xmlReader.GetValueAsString(THEME_SECTION_NAME, THEME_NAME_ENTRY, GUIThemeManager.THEME_SKIN_DEFAULT));
         }
         else
         {
             // Initialize the theme manager for the watchdog.
             GUIThemeManager.Init(GUIThemeManager.THEME_SKIN_DEFAULT);
         }
     }
 }
Пример #7
0
 /// <summary>
 /// Save all skin settings to disk.
 /// </summary>
 public static void _Save()
 {
     using (Settings xmlWriter = new SKSettings())
     {
         lock (_skinBoolSettings)
         {
             SaveBooleanSettings(xmlWriter);
         }
         lock (_skinStringSettings)
         {
             SaveStringSettings(xmlWriter);
         }
         SaveDiscreteSettings(xmlWriter);
     }
     Settings.SaveCache();
     Log.Debug("SkinSettings: Saved all settings.");
 }
Пример #8
0
        static void Main(string[] args)
        {
            // Initialize StereoKit
            SKSettings settings = new SKSettings
            {
                appName      = "SKTemplate_UWP_Name",
                assetsFolder = "Assets",
            };

            if (!SK.Initialize(settings))
            {
                Environment.Exit(1);
            }


            // Create assets used by the app
            Pose  cubePose = new Pose(0, 0, -0.5f, Quat.Identity);
            Model cube     = Model.FromMesh(
                Mesh.GenerateRoundedCube(Vec3.One * 0.1f, 0.02f),
                Default.MaterialUI);

            Matrix   floorTransform = Matrix.TS(0, -1.5f, 0, new Vec3(30, 0.1f, 30));
            Material floorMaterial  = new Material(Shader.FromFile("floor.hlsl"));

            floorMaterial.Transparency = Transparency.Blend;


            // Core application loop
            while (SK.Step(() =>
            {
                if (SK.System.displayType == Display.Opaque)
                {
                    Default.MeshCube.Draw(floorMaterial, floorTransform);
                }

                UI.Handle("Cube", ref cubePose, cube.Bounds);
                cube.Draw(cubePose.ToMatrix());
            }))
            {
                ;
            }
            SK.Shutdown();
        }
Пример #9
0
        void Run(IntPtr activityHandle)
        {
            if (running)
            {
                return;
            }
            running = true;

            Task.Run(() => {
                // If the app has a constructor that takes a string array, then
                // we'll use that, and pass the command line arguments into it on
                // creation
                Type appType = typeof(App);
                app          = appType.GetConstructor(new Type[] { typeof(string[]) }) != null
                                        ? (App)Activator.CreateInstance(appType, new object[] { new string[0] {
                                                                                                } })
                                        : (App)Activator.CreateInstance(appType);
                if (app == null)
                {
                    throw new System.Exception("StereoKit loader couldn't construct an instance of the App!");
                }

                // Initialize StereoKit, and the app
                SKSettings settings      = app.Settings;
                settings.androidActivity = activityHandle;
                settings.assetsFolder    = "";
                if (!SK.Initialize(settings))
                {
                    return;
                }
                app.Init();

                // Now loop until finished, and then shut down
                while (SK.Step(app.Step))
                {
                }
                SK.Shutdown();
            });
        }
Пример #10
0
 /// <summary>
 /// Save all skin settings to disk.
 /// </summary>
 public static void Save()
 {
   using (Settings xmlWriter = new SKSettings())
   {
     SaveBooleanSettings(xmlWriter);
     SaveStringSettings(xmlWriter);
     SaveDiscreteSettings(xmlWriter);
   }
   Settings.SaveCache();
 }
Пример #11
0
    public void LoadSettings(string selectedSkin)
    {
      // We must specify the hostname of the TV server since MP is not running and their is no active communication with the TV server.
      TvServerRemote.HostName = TVRadio.Hostname;

      // Get the MediaPortal genres from the TV server.
      _mpGenres = TvServerRemote.GetMpGenres();

      // Load tv guide colors.
      using (Settings xmlreader = new SKSettings())
      {
        string selectedTheme;
        selectedTheme = xmlreader.GetValueAsString("theme", "name", GUIThemeManager.THEME_SKIN_DEFAULT);

        if (!xmlreader.HasSection<string>("tvguidecolors"))
        {
          CreateDefaultGenreColors(xmlreader);
        }

        PopulateThemesList(selectedTheme);

        if (SettingsForm.UseTvServer)
        {
          if (!_guideColorsLoaded)
          {
            _guideColorsLoaded = LoadGuideColors(xmlreader);
          }

          PopulateGuideGenreList();

          // Need to read skin settings as string and parse to boolean to allow skin settings to have true/false values rather than yes/no values.
          cbColoredGuide.Checked =
            bool.Parse(xmlreader.GetValueAsString("booleansettings", "#skin.tvguide.usecolorsforbuttons", "False"));
          cbGenreColoring.Checked =
            bool.Parse(xmlreader.GetValueAsString("booleansettings", "#skin.tvguide.usecolorsforgenre", "False"));
          cbGenreColorKey.Checked =
            bool.Parse(xmlreader.GetValueAsString("booleansettings", "#skin.tvguide.showgenrekey", "False"));
          cbBorderHighlight.Checked =
            bool.Parse(xmlreader.GetValueAsString("booleansettings", "#skin.tvguide.useborderhighlight", "False"));

          cbGenreColoring.Enabled = cbColoredGuide.Checked;
          cbGenreColorKey.Enabled = cbGenreColoring.Checked;

          if (cbColoredGuide.Checked)
          {
            if (!tabControlTvGuideSettings.Controls.Contains(tabPageTvGuideColors))
            {
              tabControlTvGuideSettings.Controls.Add(tabPageTvGuideColors);
            }
          }
          else
          {
            tabControlTvGuideSettings.Controls.Remove(tabPageTvGuideColors);
          }
        }
      }
    }
Пример #12
0
    public void SaveSettings()
    {
      if (SettingsForm.UseTvServer)
      {
        using (Settings xmlwriter = new SKSettings())
        {
          xmlwriter.SetValue("theme", "name", listViewAvailableThemes.SelectedItems[0].Text);

          xmlwriter.SetValue("booleansettings", "#skin.tvguide.usecolorsforbuttons", cbColoredGuide.Checked);
          xmlwriter.SetValue("booleansettings", "#skin.tvguide.usecolorsforgenre", cbGenreColoring.Checked);
          xmlwriter.SetValue("booleansettings", "#skin.tvguide.useborderhighlight", cbBorderHighlight.Checked);
          xmlwriter.SetValue("booleansettings", "#skin.tvguide.showgenrekey", cbGenreColorKey.Checked);

          SaveGuideColors(xmlwriter);
        }
      }
    }
Пример #13
0
    static void Main(string[] args)
    {
        // Initialize StereoKit! During initialization, we can prepare a few
        // settings, like the assetsFolder and appName. assetsFolder the
        // folder that StereoKit will look for assets in when provided a
        // relative folder name. Settings can also be told to make a
        // flatscreen app, or how to behave if the preferred initialization
        // mode fails.
        SKSettings settings = new SKSettings
        {
            appName      = "StereoKitPaintTutorial",
            assetsFolder = "Assets",
        };

        if (!SK.Initialize(settings))
        {
            Environment.Exit(1);
        }

        // This is a simple radial hand menu where we'll store some quick
        // actions! It's activated by a grip motion, and is great for fast,
        // gesture-like activation of menu items. It also can be used with
        // multiple HandRadialLayers to nest commands in sub-menus.
        //
        // Steppers are classes that implement the IStepper interface, and
        // once added to StereoKit's stepper list, will have their Step
        // method called each frame! This is a great way to add fire-and-
        // forget objects or systems that need to update each frame.
        SK.AddStepper(new HandMenuRadial(
                          new HandRadialLayer("Root", -90,
                                              new HandMenuItem("Undo", null, () => activePainting?.Undo()),
                                              new HandMenuItem("Redo", null, () => activePainting?.Redo()))));

        // Initialize the palette menu, see PaletteMenu.cs! This class
        // manages the palette UI object for manipulating our brush stroke
        // size and color.
        paletteMenu = new PaletteMenu();

        // Step the application each frame, until StereoKit is told to exit!
        // The callback code here is called every frame after input and
        // system events, but before the draw events!
        while (SK.Step(() =>
        {
            // Send input information to the painting, it will handle this
            // info to create brush strokes. This will also draw the painting
            // too!
            activePainting.Step(Handed.Right, paletteMenu.PaintColor, paletteMenu.PaintSize);

            // Step our palette UI!
            paletteMenu.Step();

            // Step our application's menu! This includes Save/Load Clear and
            // Quit commands.
            StepMenuWindow();
        }))
        {
            ;
        }

        // We're done! Clean up StereoKit and all its resources :)
        SK.Shutdown();
    }
Пример #14
0
    private void LoadSettings()
    {
      using (Settings xmlreader = new MPSettings())
      {
        String channelName = xmlreader.GetValueAsString("radioguide", "channel", String.Empty);
        TvBusinessLayer layer = new TvBusinessLayer();
        IList<Channel> channels = layer.GetChannelsByName(channelName);
        if (channels != null && channels.Count > 0)
        {
          _currentChannel = channels[0];
        }
        _cursorX = xmlreader.GetValueAsInt("radioguide", "ypos", 0);
        ChannelOffset = xmlreader.GetValueAsInt("radioguide", "yoffset", 0);
        _byIndex = xmlreader.GetValueAsBool("myradio", "byindex", true);
        _showChannelNumber = xmlreader.GetValueAsBool("myradio", "showchannelnumber", false);
        _channelNumberMaxLength = xmlreader.GetValueAsInt("myradio", "channelnumbermaxlength", 3);
        _timePerBlock = xmlreader.GetValueAsInt("radioguide", "timeperblock", 30);
        _hdtvProgramText = xmlreader.GetValueAsString("myradio", "hdtvProgramText", "(HDTV)");
        _guideContinuousScroll = xmlreader.GetValueAsBool("myradio", "continuousScrollGuide", false);
        _loopDelay = xmlreader.GetValueAsInt("gui", "listLoopDelay", 0);
      }

      // Load settings defined by the skin.
      LoadSkinSettings();

      // Load genre colors.
      // If guide colors have not been loaded then attempt to load guide colors.

      // this is just for the border highlight in radio EPG

      if (!_guideColorsLoaded)
      {
        using (Settings xmlreader = new SKSettings())
        {
          _guideColorsLoaded = LoadGuideColors(xmlreader);
        }
      }

      _useNewRecordingButtonColor =
        Utils.FileExistsInCache(GUIGraphicsContext.GetThemedSkinFile(@"\media\tvguide_recButton_Focus_middle.png"));
      _useNewPartialRecordingButtonColor =
        Utils.FileExistsInCache(GUIGraphicsContext.GetThemedSkinFile(@"\media\tvguide_partRecButton_Focus_middle.png"));
      _useNewNotifyButtonColor =
        Utils.FileExistsInCache(GUIGraphicsContext.GetThemedSkinFile(@"\media\tvguide_notifyButton_Focus_middle.png"));
      _useHdProgramIcon =
        Utils.FileExistsInCache(GUIGraphicsContext.GetThemedSkinFile(@"\media\tvguide_hd_program.png"));
    }
Пример #15
0
    private void LoadSettings()
    {
      using (Settings xmlreader = new MPSettings())
      {
        String channelName = xmlreader.GetValueAsString("mytv", "channel", String.Empty);
        TvBusinessLayer layer = new TvBusinessLayer();
        IList<Channel> channels = layer.GetChannelsByName(channelName);
        if (channels != null && channels.Count > 0)
        {
          _currentChannel = channels[0];
        }
        PositionGuideCursorToCurrentChannel();

        _byIndex = xmlreader.GetValueAsBool("mytv", "byindex", true);
        _showChannelNumber = xmlreader.GetValueAsBool("mytv", "showchannelnumber", false);
        _channelNumberMaxLength = xmlreader.GetValueAsInt("mytv", "channelnumbermaxlength", 3);
        _timePerBlock = xmlreader.GetValueAsInt("tvguide", "timeperblock", 30);
        _hdtvProgramText = xmlreader.GetValueAsString("mytv", "hdtvProgramText", "(HDTV)");
        _guideContinuousScroll = xmlreader.GetValueAsBool("mytv", "continuousScrollGuide", false);
        _loopDelay = xmlreader.GetValueAsInt("gui", "listLoopDelay", 0);

        // Load the genre map.
        if (_genreMap.Count == 0)
        {
          LoadGenreMap(xmlreader);
        }

        // Special genre rules.
        _specifyMpaaRatedAsMovie = xmlreader.GetValueAsBool("genreoptions", "specifympaaratedasmovie", false);
      }

      // Load settings defined by the skin.
      LoadSkinSettings();

      // Load genre colors.
      // If guide colors have not been loaded then attempt to load guide colors.
      if (!_guideColorsLoaded)
      {
        using (Settings xmlreader = new SKSettings())
        {
          _guideColorsLoaded = LoadGuideColors(xmlreader);
        }
      }

      _useNewRecordingButtonColor =
        Utils.FileExistsInCache(GUIGraphicsContext.GetThemedSkinFile(@"\media\tvguide_recButton_Focus_middle.png"));
      _useNewPartialRecordingButtonColor =
        Utils.FileExistsInCache(GUIGraphicsContext.GetThemedSkinFile(@"\media\tvguide_partRecButton_Focus_middle.png"));
      _useNewNotifyButtonColor =
        Utils.FileExistsInCache(GUIGraphicsContext.GetThemedSkinFile(@"\media\tvguide_notifyButton_Focus_middle.png"));
      _useHdProgramIcon =
        Utils.FileExistsInCache(GUIGraphicsContext.GetThemedSkinFile(@"\media\tvguide_hd_program.png"));
    }
Пример #16
0
        static void Main(string[] args)
        {
            Sound song;

            Queue <Note>[] noteQueues      = null;
            int            positionInNotes = 0;
            double         songStartTime   = 0;
            DateTime       watcherStart    = DateTime.Now;

            // Initialize StereoKit
            SKSettings settings = new SKSettings
            {
                appName      = "DrumMR",
                assetsFolder = "Assets",
            };

            if (!SK.Initialize(settings))
            {
                Environment.Exit(1);
            }



            SerialPort port = new SerialPort();

            port.PortName = "COM3";
            port.BaudRate = 9600;
            //port.Open();
            port.DataReceived += (sender, dataArgs) =>
            {
                SerialPort sp     = (SerialPort)sender;
                string     result = sp.ReadExisting();
                Debug.WriteLine("Serial data received: " + result);
                //buffer[Int32.Parse(result)] = true;
            };

            Vec3[] unitVectors = createNewUnitVectors(); //x, y, and z
            Mesh   boardMesh   = Mesh.GenerateCube(new Vec3(1f, 2f, 0));
            Mesh   noteMesh    = Mesh.GenerateCube(new Vec3(.04f, .048f, 0));
            Model  boardModel  = Model.FromMesh(boardMesh, Default.Material);
            Model  noteModel   = Model.FromMesh(noteMesh, Default.Material);

            Debug.WriteLine(unitVectors[0]);



            Quat boardQuat = new Quat((float)0, (float).7, (float).7, (float)0);

            Vec3 boardLocation = new Vec3(drumLocations[1].orientation.x + .05f * (unitVectors[0].x + unitVectors[1].x + unitVectors[2].x), drumLocations[1].orientation.y + .05f * ((unitVectors[0].y + unitVectors[1].y + unitVectors[2].y)), drumLocations[1].orientation.z + (((unitVectors[0].z + unitVectors[1].z + unitVectors[2].z))));
            Pose boardPose     = new Pose(boardLocation, boardQuat);

            boardModel.Draw(boardPose.ToMatrix(), Color.Black);
            //TODO: SET THIS QUAT TO BE PARALLEL TO UNITVECTORS[0]
            //TODO: MAKE DIFFERENTLY COLORED NOTE MESHES FOR EACH LANE
            //TODO: ROTATION IS GOING TO NEED TO BE FIGURED OUT.  IT CAN'T TURN DYNAMICALLY BECAUSE THE NOTES WOULD NEED TO TURN AS WELL

            // Core application loop

            InitializeDrumLocations();
            while (SK.Step(() =>
            {
                if (!PoseIsInitialized(drumLocations[0]))
                {
                    getDrumLocation(0);
                }
                else if (!PoseIsInitialized(drumLocations[1]))
                {
                    getDrumLocation(1);
                }
                else if (!PoseIsInitialized(drumLocations[2]))
                {
                    getDrumLocation(2);
                }
                else if (!PoseIsInitialized(drumLocations[3]))
                {
                    getDrumLocation(3);
                }
                else if (notes is null)
                {
                    //TODO: CHANGE THIS TO MOVE WITH THE USER USING INPUT.HEAD.POSITION?
                    Pose windowPose = new Pose(-.4f, 0, 0, Quat.LookDir(1, 0, 1));
                    UI.WindowBegin("Window", ref windowPose, new Vec2(20, 0) * U.cm, UIWin.Normal);
                    for (int i = 0; i < songs.Length; i++)
                    {
                        if (UI.Button(songs[i]))
                        {
                            Debug.WriteLine(songs[i]);
                            string jsonString = getJSONStringOfSong(songs[i] + ".json");
                            notes = parseJSONSong(jsonString);
                            notes = sortNotes(notes);
                            song = Sound.FromFile(songs[i] + ".wav");
                            song.Play(Input.Head.position);
                            songStartTime = Time.Total;
                            noteQueues = new Queue <Note> [4];
                            for (int j = 0; j < 4; j++)
                            {
                                noteQueues[j] = new Queue <Note> {
                                };
                            }
                        }
                    }
                    UI.WindowEnd();
                }
                else
                {
                    //calculates x values for note lanes
                    float midpoint = (drumLocations[0].position.x + drumLocations[3].position.x) / 2;
                    float notePoint = midpoint / 8;

                    //draws the board
                    boardModel.Draw(boardPose.ToMatrix(), Color.Black);

                    while (positionInNotes < notes.Length && notes[positionInNotes].time - (Time.Total - songStartTime) < GAME_BOARD_TIME)
                    {
                        Note noteToPush = notes[positionInNotes];
                        Debug.WriteLine(noteToPush.pad);
                        Debug.WriteLine(noteQueues[noteToPush.pad].Count);
                        noteQueues[noteToPush.pad].Enqueue(noteToPush);
                        positionInNotes++;
                    }

                    for (int i = 0; i < noteQueues.Length; i++)
                    {
                        for (int j = 0; j < noteQueues[i].Count; j++)
                        {
                            Note noteToRender = noteQueues[i].Dequeue();
                            Pose notePose = new Pose(notePoint * i, (float)(noteToRender.time - songStartTime) * (float)(2 / 1.5), boardLocation.z + (float).1, boardQuat);
                            Debug.WriteLine("note " + i);
                            noteModel.Draw(notePose.ToMatrix(), Color.White);
                            //TODO: RENDER THE NOTE HERE
                            //unitVectors[3] contains vectors representing



                            if (j == 0 && buffer[i] && noteToRender.time - songStartTime < NOTE_HIT_TIME_MARGIN)
                            {
                                //TODO: ONLY DO THIS IF THE NOTE IS CLOSE TO THE BOTTOM
                                buffer[i] = false;
                            }
                            else
                            {
                                noteQueues[i].Enqueue(noteToRender);
                            }
                        }
                    }
                    if (positionInNotes == notes.Length)
                    {
                        notes = null;
                    }
                }
            }))
            {
                ;
            }
            SK.Shutdown();
        }
Пример #17
0
    private static void LoadBooleanSettings()
    {
      using (Settings xmlReader = new SKSettings())
      {
        IDictionary<string, bool> allBooleanSettings = xmlReader.GetSection<bool>("booleansettings");

        if (allBooleanSettings == null)
        {
          return;
        }

        lock (_skinBoolSettings)
        {
          var enumerator = allBooleanSettings.GetEnumerator();
          if (enumerator != null)
          {
            while (enumerator.MoveNext())
            {
              // Create the new boolean setting.
              SkinBool newBool = new SkinBool();
              newBool.Name = enumerator.Current.Key;
              newBool.Value = enumerator.Current.Value;
              newBool.Kind = Kind.PERSISTENT;

              // Add the setting to the dictionary.
              int key = _skinBoolSettings.Count;
              _skinBoolSettings[key] = newBool;

              // Create the setting as a property.  The boolean value is converted as a string representation.
              GUIPropertyManager.SetProperty(newBool.Name, newBool.Value.ToString());
            }
          }
        }
      }
    }
Пример #18
0
    private static void LoadStringSettings()
    {
      using (Settings xmlReader = new SKSettings())
      {
        IDictionary<string, string> allStringSettings = xmlReader.GetSection<string>("stringsettings");

        if (allStringSettings == null)
        {
          return;
        }

        lock (_skinStringSettings)
        {
          var enumerator = allStringSettings.GetEnumerator();
          if (enumerator != null)
          {
            while (enumerator.MoveNext())
            {
              // Create the new string setting.
              SkinString newString = new SkinString();
              newString.Name = enumerator.Current.Key;
              newString.Value = enumerator.Current.Value;
              newString.Kind = Kind.PERSISTENT;

              // Add the setting to the dictionary.
              int key = _skinStringSettings.Count;
              _skinStringSettings[key] = newString;

              // Create the setting as a property.
              GUIPropertyManager.SetProperty(newString.Name, newString.Value);
            }
          }
        }
      }
    }
Пример #19
0
    public void LoadSettings(string selectedSkin)
    {
      // Load the genre map from MP settings.
      // TODO: this needs to be loaded from tv server settings.
      using (Settings xmlreader = new MPSettings())
      {
        if (_genreList.Count == 0)
        {
          LoadGenreList(xmlreader);
        }
      }

      // Load tv guide colors.
      using (Settings xmlreader = new SKSettings())
      {
        string selectedTheme;
        selectedTheme = xmlreader.GetValueAsString("theme", "name", GUIThemeManager.THEME_SKIN_DEFAULT);

        if (!xmlreader.HasSection<string>("tvguidecolors"))
        {
          CreateDefaultGenreColors(xmlreader);
        }

        if (!_guideColorsLoaded)
        {
          _guideColorsLoaded = LoadGuideColors(xmlreader);
        }

        PopulateThemesList(selectedTheme);
        PopulateGuideGenreList();

        // Need to read skin settings as string and parse to boolean to allow skin settings to have true/false values rather than yes/no values.
        cbColoredGuide.Checked = bool.Parse(xmlreader.GetValueAsString("booleansettings", "#skin.tvguide.usecolorsforbuttons", "False"));
        cbGenreColoring.Checked = bool.Parse(xmlreader.GetValueAsString("booleansettings", "#skin.tvguide.usecolorsforgenre", "False"));
        cbGenreColorKey.Checked = bool.Parse(xmlreader.GetValueAsString("booleansettings", "#skin.tvguide.showgenrekey", "False"));
        cbBorderHighlight.Checked = bool.Parse(xmlreader.GetValueAsString("booleansettings", "#skin.tvguide.useborderhighlight", "False"));

        cbGenreColoring.Enabled = cbColoredGuide.Checked;
        cbGenreColorKey.Enabled = cbGenreColoring.Checked;

        if (cbColoredGuide.Checked)
        {
          if (!tabControlTvGuideSettings.Controls.Contains(tabPageTvGuideColors))
          {
            tabControlTvGuideSettings.Controls.Add(tabPageTvGuideColors);
          }
        }
        else
        {
          tabControlTvGuideSettings.Controls.Remove(tabPageTvGuideColors);
        }
      }
    }
Пример #20
0
 private static void LoadDiscreteSettings()
 {
   using (Settings xmlReader = new SKSettings())
   {
     if (!_noTheme)
     {
       // Initialize the theme manager for the selected theme.
       GUIThemeManager.Init(xmlReader.GetValueAsString(THEME_SECTION_NAME, THEME_NAME_ENTRY, GUIThemeManager.THEME_SKIN_DEFAULT));
     }
     else
     {
       // Initialize the theme manager for the watchdog.
       GUIThemeManager.Init(GUIThemeManager.THEME_SKIN_DEFAULT);
     }
   }
 }
Пример #21
0
 /// <summary>
 /// Save all skin settings to disk.
 /// </summary>
 public static void _Save()
 {
   using (Settings xmlWriter = new SKSettings())
   {
     lock (_skinBoolSettings)
     {
       SaveBooleanSettings(xmlWriter);
     }
     lock (_skinStringSettings)
     {
       SaveStringSettings(xmlWriter);
     }
     SaveDiscreteSettings(xmlWriter);
   }
   Settings.SaveCache();
   Log.Debug("SkinSettings: Saved all settings.");
 }