Example #1
0
 protected override void Initialize()
 {
     Content.RootDirectory = "Content";
     Service.Add(this);
     Service.Add(new SpriteBatch3D(this));
     Service.Add(new SpriteBatchUI(this));
     Service.Add <INetworkClient>(new NetworkClient());
     Service.Add <IInputService>(new InputService(Window.Handle));
     Service.Add(new AudioService());
     m_UserInterface = Service.Add(new UserInterfaceService());
     m_Plugins       = new PluginManager(AppDomain.CurrentDomain.BaseDirectory);
     m_Models        = new ModelManager();
     // Make sure we have a UO installation before loading IO.
     if (FileManager.IsUODataPresent)
     {
         // Initialize and load data
         IResourceProvider provider = new ResourceProvider(this);
         provider.RegisterResource(new EffectDataResource());
         Service.Add(provider);
         HueData.Initialize(GraphicsDevice);
         SkillsData.Initialize();
         GraphicsDevice.Textures[1] = HueData.HueTexture0;
         GraphicsDevice.Textures[2] = HueData.HueTexture1;
         m_IsRunning          = true;
         WorldModel.IsInWorld = false;
         Models.Current       = new LoginModel();
     }
     else
     {
         Tracer.Critical("Did not find a compatible UO Installation. JuicyUO is compatible with any version of UO through Mondian's Legacy.");
     }
 }
Example #2
0
 protected void CloseChildPicker()
 {
     if (m_ChildColorPicker != null)
     {
         m_ChildColorPicker.Dispose();
         m_ChildColorPicker = null;
         m_huesTexture      = HueData.CreateHueSwatch(1, 1, new int[1] {
             m_hues[Index]
         });
     }
 }
Example #3
0
 protected override void OnInitialize()
 {
     if (m_huesTexture == null)
     {
         if (IsChild) // is a child
         {
             m_huesTexture = HueData.CreateHueSwatch(m_hueWidth, m_hueHeight, m_hues);
             IResourceProvider provider = ServiceRegistry.GetService <IResourceProvider>();
             m_selectedIndicator = provider.GetUITexture(6000);
         }
         else
         {
             m_huesTexture = HueData.CreateHueSwatch(1, 1, new int[1] {
                 m_hues[Index]
             });
         }
     }
 }
Example #4
0
 protected override void OnInitialize()
 {
     if (_huesTexture == null)
     {
         if (IsChild) // is a child
         {
             var provider = Service.Get <IResourceProvider>();
             _huesTexture       = HueData.CreateHueSwatch(_hueWidth, _hueHeight, _hues);
             _selectedIndicator = provider.GetUITexture(6000);
         }
         else
         {
             _huesTexture = HueData.CreateHueSwatch(1, 1, new int[1] {
                 _hues[Index]
             });
         }
     }
 }
Example #5
0
        protected override void Initialize()
        {
            Content.RootDirectory = "Content";

            // register this instance as a service
            ServiceRegistry.Register <UltimaGame>(this);

            // Create all the services we need.
            ServiceRegistry.Register <SpriteBatch3D>(new SpriteBatch3D(this));
            ServiceRegistry.Register <SpriteBatchUI>(new SpriteBatchUI(this));
            ServiceRegistry.Register <AudioService>(new AudioService());
            Network       = ServiceRegistry.Register <INetworkClient>(new NetworkClient());
            Input         = ServiceRegistry.Register <InputManager>(new InputManager(Window.Handle));
            UserInterface = ServiceRegistry.Register <UserInterfaceService>(new UserInterfaceService());
            Plugins       = new PluginManager(AppDomain.CurrentDomain.BaseDirectory);

            // Make sure we have a UO installation before loading IO.
            if (FileManager.IsUODataPresent)
            {
                // Initialize and load data
                IResourceProvider provider = new ResourceProvider(this);
                provider.RegisterResource <EffectData>(new EffectDataResource());
                ServiceRegistry.Register <IResourceProvider>(provider);

                HueData.Initialize(GraphicsDevice);
                SkillsData.Initialize();
                GraphicsDevice.Textures[1] = HueData.HueTexture0;
                GraphicsDevice.Textures[2] = HueData.HueTexture1;

                IsRunning            = true;
                WorldModel.IsInWorld = false;

                ActiveModel = new LoginModel();
            }
            else
            {
                Tracer.Critical("Did not find a compatible UO Installation. UltimaXNA is compatible with any version of UO through Mondian's Legacy.");
            }
        }
        public static void CreateHues()
        {
            uint[] hues = HueData.GetAllHues();

            uint[] toMatches = new uint[216];
            for (int b = 0; b < 6; b++)
            {
                for (int g = 0; g < 6; g++)
                {
                    for (int r = 0; r < 6; r++)
                    {
                        toMatches[r + g * 6 + b * 36] = (uint)(0x000033 * r + 0x003300 * g + 0x330000 * b);
                    }
                }
            }

            Tuple <int, double>[] matches = new Tuple <int, double> [216];

            for (int i = 0; i < 216; i++)
            {
                int    nearestHue      = -1;
                double distance        = double.MaxValue;
                uint   dbl_input_red   = toMatches[i] & 0x0000ff;
                uint   dbl_input_green = (toMatches[i] & 0x00ff00) >> 8;
                uint   dbl_input_blue  = (toMatches[i] & 0xff0000) >> 16;
                for (int j = 0; j < HueData.HueCount; j++)
                {
                    // compute the Euclidean distance between the two colors
                    // note, that the alpha-component is not used in this example
                    double dbl_test_red   = Math.Pow(Convert.ToDouble(hues[j] & 0x0000ff) - dbl_input_red, 2.0);
                    double dbl_test_green = Math.Pow(Convert.ToDouble((hues[j] & 0x00ff00) >> 8) - dbl_input_green, 2.0);
                    double dbl_test_blue  = Math.Pow(Convert.ToDouble((hues[j] & 0xff0000) >> 16) - dbl_input_blue, 2.0);

                    double temp = Math.Sqrt(dbl_test_blue + dbl_test_green + dbl_test_red);
                    // explore the result and store the nearest color
                    if (temp == 0.0)
                    {
                        nearestHue = j;
                        distance   = 0;
                        break;
                    }
                    else if (temp < distance)
                    {
                        distance   = temp;
                        nearestHue = j;
                    }
                }
                matches[i] = new Tuple <int, double>(nearestHue, distance);
            }
            string m_kWebSafeHues = "static int[] m_kWebSafeHues = new int[216] {";

            for (int i = 0; i < 36; i++)
            {
                m_kWebSafeHues += "\n            ";
                for (int j = 0; j < 6; j++)
                {
                    m_kWebSafeHues += string.Format("{0:0000}, ", matches[i * 6 + j].Item1);
                }
            }
            m_kWebSafeHues += "};";
        }
Example #7
0
 /// <summary>
 /// Returns a Ultima Online Hue index that approximates the passed color.
 /// </summary>
 /// <param name="color"></param>
 /// <returns></returns>
 public ushort GetWebSafeHue(Color color)
 {
     return((ushort)HueData.GetWebSafeHue(color));
 }