示例#1
0
        /// <summary>
        /// Add a mapping for a falagard based window.
        ///
        /// This function creates maps a target window type and target 'look' name onto a registered window type, thus allowing
        /// the ususal window creation interface to be used to create windows that require extra information to full initialise
        /// themselves.
        /// </summary>
        /// <remarks>
        /// These mappings support 'late binding' to the target window type, as such the type indicated by \a targetType need not
        /// exist in the system until attempting to create a Window using the type.
        /// <para>
        /// Also note that creating a mapping for an existing type will replace any previous mapping for that same type.
        /// </para>
        /// </remarks>
        /// <param name="newType">
        /// The type name that will be used to create windows using the target type and look.
        /// </param>
        /// <param name="targetType">
        /// The base window type.
        /// </param>
        /// <param name="lookName">
        /// The name of the 'look' that will be used by windows of this type.
        /// </param>
        /// <param name="renderer">
        /// The type of window renderer to assign for windows of this type.
        /// </param>
        /// <param name="effectName">
        /// The identifier of the RenderEffect to attempt to set up for windows of this type.
        /// </param>
        public void AddFalagardWindowMapping(string newType,
                                             string targetType,
                                             string lookName,
                                             string renderer,
                                             string effectName = "")
        {
            var mapping = new FalagardWindowMapping
            {
                d_windowType   = newType,
                d_baseType     = targetType,
                d_lookName     = lookName,
                d_rendererType = renderer,
                d_effectName   = effectName
            };

            // see if the type we're creating already exists
            if (d_falagardRegistry.ContainsKey(newType))
            {
                // type already exists, log the fact that it's going to be replaced.
                System.GetSingleton().Logger
                .LogEvent("Falagard mapping for type '" + newType +
                          "' already exists - current mapping will be replaced.");
            }

            System.GetSingleton().Logger.
            LogEvent("Creating falagard mapping for type '" +
                     newType + "' using base type '" + targetType + "', window renderer '" +
                     renderer + "' Look'N'Feel '" + lookName + "' and RenderEffect '" +
                     effectName + "'. " + mapping.GetHashCode().ToString("X8"));

            d_falagardRegistry[newType] = mapping;
        }
示例#2
0
        /*!
         * \see WidgetLookManager::parseLookNFeelSpecificationFromContainer
         */

        public void ParseLookNFeelSpecificationFromFile(string filename, string resourceGroup = "")
        {
            // valid filenames are required!
            if (String.IsNullOrEmpty(filename))
            {
                throw new InvalidRequestException("Filename supplied for look & feel file must be valid");
            }

            // create handler object
            var handler = new Falagard_xmlHandler(this);

            // perform parse of XML data
            try
            {
                System.GetSingleton().GetXMLParser()
                .ParseXmlFile(handler, filename, FalagardSchemaName, String.IsNullOrEmpty(resourceGroup)
                                                                               ? d_defaultResourceGroup
                                                                               : resourceGroup);
            }
            catch
            {
                System.GetSingleton().Logger
                .LogEvent(
                    String.Format(
                        "WidgetLookManager::parseLookNFeelSpecification - loading of look and feel data from file '{0}' has failed.",
                        filename),
                    LoggingLevel.Errors);
                throw;
            }
        }
示例#3
0
        private void LoadFntFile(Stream stream)
        {
            var fnt = XElement.Load(stream);

            var info   = fnt.Element("info");
            var common = fnt.Element("common");
            var pages  = fnt.Element("pages");

            var face = info.Attribute("face").Value;

            d_ascender  = XmlConvert.ToSingle(common.Attribute("base").Value);
            d_height    = XmlConvert.ToSingle(common.Attribute("lineHeight").Value);
            d_descender = d_ascender - d_height;

            foreach (var page in pages.Elements("page"))
            {
                var pageId   = page.Attribute("id").Value;
                var pageFile = page.Attribute("file").Value;
                System.GetSingleton().GetRenderer()
                .CreateTexture(d_name + "_glyph_images_page_id_" + pageId, pageFile,
                               String.IsNullOrEmpty(d_resourceGroup)
                                         ? GetDefaultResourceGroup()
                                         : d_resourceGroup);
            }

            var chars = fnt.Element("chars");

            foreach (var @char in chars.Elements("char"))
            {
                var pageId = d_name + "_glyph_images_page_id_" + @char.Attribute("page").Value;
                var charId = (char)XmlConvert.ToUInt32(@char.Attribute("id").Value);
                var area   = new Rectf(new Lunatics.Mathematics.Vector2(XmlConvert.ToSingle(@char.Attribute("x").Value),
                                                                        XmlConvert.ToSingle(@char.Attribute("y").Value)),
                                       new Sizef(XmlConvert.ToSingle(@char.Attribute("width").Value),
                                                 XmlConvert.ToSingle(@char.Attribute("height").Value)));
                var offset = new Lunatics.Mathematics.Vector2(XmlConvert.ToSingle(@char.Attribute("xoffset").Value),
                                                              XmlConvert.ToSingle(@char.Attribute("yoffset").Value) - d_ascender);
                d_cp_map[charId] = new FntGlyph(XmlConvert.ToSingle(@char.Attribute("xadvance").Value),
                                                new BitmapImage(charId.ToString(global::System.Globalization.CultureInfo.InvariantCulture),
                                                                System.GetSingleton().GetRenderer().GetTexture(pageId),
                                                                area, offset,
                                                                d_autoScaled,
                                                                d_nativeResolution),
                                                true);
                if (d_maxCodepoint < charId)
                {
                    d_maxCodepoint = charId;
                }
            }

            //foreach (var kerning in chars.Elements("kerning"))
            //{
            //    var first = XmlConvert.ToChar(kerning.Attribute("first").Value);
            //    var second = XmlConvert.ToChar(kerning.Attribute("second").Value);
            //    var amount = XmlConvert.ToSingle(kerning.Attribute("amount").Value);
            //    if (!_kerningPairs.ContainsKey(first))
            //        _kerningPairs.Add(first, new Dictionary<char, float>());
            //    _kerningPairs[first].Add(second, amount);
            //}
        }
示例#4
0
        /// <summary>
        /// Creates a set of windows (a GUI layout) from the information in the specified XML.
        /// </summary>
        /// <param name="source">
        /// String holding the XML source
        /// </param>
        /// <param name="callback">
        /// PropertyCallback function to be called for each Property element loaded from the layout.  This is
        /// called prior to the property value being applied to the window enabling client code manipulation of
        /// properties.
        /// </param>
        /// <param name="userdata">
        /// Client code data pointer passed to the PropertyCallback function.
        /// </param>
        /// <returns>
        /// Pointer to the root Window object defined in the layout.
        /// </returns>
        public Window LoadLayoutFromString(string source, PropertyCallback callback = null, object userdata = null)
        {
            // log the fact we are about to load a layout
            System.GetSingleton()
            .Logger.LogEvent("---- Beginning loading of GUI layout from string ----", LoggingLevel.Informative);

            // create handler object
            var handler = new GuiLayoutXmlHandler(callback, userdata);

            // do parse (which uses handler to create actual data)
            try
            {
                System.GetSingleton()
                .GetXMLParser()
                .ParseXmlString(handler, source, GuiLayoutSchemaName);
            }
            catch
            {
                System.GetSingleton()
                .Logger.LogEvent("WindowManager::loadLayoutFromString - loading of layout from string failed.",
                                 LoggingLevel.Errors);
                throw;
            }

            // log the completion of loading
            System.GetSingleton()
            .Logger.LogEvent("---- Successfully completed loading of GUI layout from string ----");

            return(handler.GetLayoutRootWindow());
        }
        //------------------------------------------------------------------------//
        protected override T GetNativeImpl(PropertyReceiver receiver)
        {
            var wnd = (Window)receiver;

            // the try/catch is used instead of querying the existence of the user
            // string in order that for the 'usual' case - where the user string
            // exists - there is basically no additional overhead, and that any
            // overhead is incurred only for the initial creation of the user
            // string.
            // Maybe the only negative here is that an error gets logged, though
            // this can be treated as a 'soft' error.
            try
            {
                return(PropertyHelper.FromString <T>(wnd.GetUserString(d_userStringName)));
            }
            catch (UnknownObjectException)
            {
                System.GetSingleton().Logger
                .LogEvent("PropertyDefiniton::get: Defining new user string: " + d_userStringName);

                // HACK: FIXME: TODO: This const_cast is basically to allow the
                // above mentioned performance measure; the alternative would be
                // to just return d_default, and while technically correct, it
                // would be very slow.
                wnd.SetUserString(d_userStringName, d_default);

                return(PropertyHelper.FromString <T>(d_default));
            }
        }
示例#6
0
        /// <summary>
        /// Creates a WindowFactory of the type \a T and adds it to the system for
        /// use. The created WindowFactory will automatically be deleted when the
        /// factory is removed from the system (either directly or at system
        /// deletion time).
        /// </summary>
        /// <typeparam name="TFactory">
        /// Specifies the type of WindowFactory subclass to add a factory for.
        /// </typeparam>
        public static void AddFactory <TFactory>() where TFactory : WindowFactory, new()
        {
            // create the factory object
            var factory = new TFactory();

            // only do the actual add now if our singleton has already been created
            if (Instance.IsValueCreated)
            {
                System.GetSingleton().Logger
                .LogEvent("Created WindowFactory for '" + factory.GetTypeName() + "' windows.");

                // add the factory we just created
                try
                {
                    GetSingleton().AddFactory(factory);
                }
                catch
                {
                    System.GetSingleton().Logger
                    .LogEvent("Deleted WindowFactory for '" + factory.GetTypeName() + "' windows.");
                    // delete the factory object
                    //CEGUI_DELETE_AO factory;

                    throw;
                }
            }

            d_ownedFactories.Add(factory);
        }
示例#7
0
        /// <summary>
        /// Parses an XML file containing animation specifications to create
        /// and initialise Animation objects.
        /// </summary>
        /// <param name="filename">
        /// String object holding the filename of the XML file to be processed.
        /// </param>
        /// <param name="resourceGroup">
        /// Resource group identifier to be passed to the resource provider when
        /// loading the XML file.
        /// </param>
        public void LoadAnimationsFromXml(string filename, string resourceGroup = "")
        {
            if (String.IsNullOrEmpty(filename))
            {
                throw new InvalidRequestException("filename supplied for file loading must be valid.");
            }

            var handler = new AnimationXmlHandler();

            // do parse (which uses handler to create actual data)
            try
            {
                System.GetSingleton().GetXMLParser()
                .ParseXmlFile(handler, filename, XMLSchemaName,
                              String.IsNullOrEmpty(resourceGroup)
                                        ? s_defaultResourceGroup
                                        : resourceGroup);
            }
            catch
            {
                System.GetSingleton().Logger
                .LogEvent(
                    "AnimationManager::loadAnimationsFromXML: loading of animations from file '" + filename +
                    "' has failed.",
                    LoggingLevel.Errors);

                throw;
            }
        }
示例#8
0
        /// <summary>
        /// Removes a WindowFactory from the list of registered factories.
        /// <para>
        /// The WindowFactory object is not destroyed (since it was created externally),
        /// instead it is just removed from the list.
        /// </para>
        /// </summary>
        /// <param name="name">
        /// String which holds the name (technically, Window type name) of the WindowFactory to be removed.
        /// If \a name is not in the list, no error occurs (nothing happens).
        /// </param>
        public void RemoveFactory(string name)
        {
            // exit if no factory exists for this type
            if (!d_factoryRegistry.ContainsKey(name))
            {
                return;
            }

            // see if we own this factory
            var j = d_ownedFactories.SingleOrDefault(x => x == d_factoryRegistry[name]);

            var addr_buff = d_factoryRegistry[name].GetHashCode().ToString("X8");

            d_factoryRegistry.Remove(name);

            System.GetSingleton().Logger
            .LogEvent("WindowFactory for '" + name + "' windows removed. " + addr_buff);

            // delete factory object if we created it
            if (j != null)
            {
                System.GetSingleton().Logger
                .LogEvent("Deleted WindowFactory for '" + j.GetTypeName() + "' windows.");

                //CEGUI_DELETE_AO (*j);
                d_ownedFactories.Remove(j);
            }
        }
示例#9
0
        /// <summary>
        /// updates the cached geometry.
        /// </summary>
        private void CacheGeometry()
        {
            d_cachedGeometryValid = true;
            DestroyGeometryBuffers();

            // if no image, nothing more to do.
            if (d_indicatorImage == null)
            {
                return;
            }

            if (Math.Abs(d_customSize.Width - 0.0f) > float.Epsilon ||
                Math.Abs(d_customSize.Height - 0.0f) > float.Epsilon)
            {
                CalculateCustomOffset();
                var imgRenderSettings = new ImageRenderSettings(new Rectf(d_customOffset, d_customSize));
                d_geometryBuffers.AddRange(d_indicatorImage.CreateRenderGeometry(imgRenderSettings));
            }
            else
            {
                var imgRenderSettings = new ImageRenderSettings(new Rectf(Lunatics.Mathematics.Vector2.Zero, d_indicatorImage.GetRenderedSize()));
                d_geometryBuffers.AddRange(d_indicatorImage.CreateRenderGeometry(imgRenderSettings));
            }

            // TODO: const Rectf clipping_area(glm::vec2(0, 0), System::getSingleton().getRenderer()->getDisplaySize());
            var clipping_area = new Rectf(Lunatics.Mathematics.Vector2.Zero,
                                          System.GetSingleton().GetRenderer().GetDisplaySize());

            UpdateGeometryBuffersClipping(clipping_area);
            UpdateGeometryBuffersTranslation();
        }
示例#10
0
        /// <summary>
        /// Return the current mouse cursor position as display resolution independant values.
        /// </summary>
        /// <returns>
        /// Point object describing the current mouse cursor position as resolution independant values that
        /// range from 0.0f to 1.0f, where 0.0f represents the left-most and top-most positions, and 1.0f
        /// represents the right-most and bottom-most positions.
        /// </returns>
        public Lunatics.Mathematics.Vector2 GetDisplayIndependantPosition()
        {
            var dsz = System.GetSingleton().GetRenderer().GetDisplaySize();

            return(new Lunatics.Mathematics.Vector2(d_position.X / (dsz.Width - 1.0f),
                                                    d_position.Y / (dsz.Height - 1.0f)));
        }
示例#11
0
        /// <summary>
        /// Free all allocated font data.
        /// </summary>
        private void Free()
        {
            if (d_fontFace == null)
            {
                return;
            }

            d_cp_map.Clear();

            _glyphImages.Clear();

            foreach (var glyphTexture in _glyphTextures)
            {
                System.GetSingleton().GetRenderer().DestroyTexture(glyphTexture);
            }

            _glyphTextures.Clear();

            if (_fontDataPtr != IntPtr.Zero)
            {
                Marshal.FreeHGlobal(_fontDataPtr);
                _fontDataPtr = IntPtr.Zero;
            }

            d_fontFace.Dispose();
            d_fontFace = null;

            System.GetSingleton().GetResourceProvider().UnloadRawDataContainer(d_fontData);
        }
示例#12
0
        /// <summary>
        /// convenience method which initiates parsing of an XML file.
        /// </summary>
        /// <param name="handler">
        /// XMLHandler based object which will process the XML elements.
        /// </param>
        /// <param name="filename">
        /// String object holding the filename of the XML file to be parsed.
        /// </param>
        /// <param name="schemaName">
        /// String object holding the name of the XML schema file to use for validating the XML.
        /// Note that whether this is used or not is dependant upon the XMLParser in use.
        /// </param>
        /// <param name="resourceGroup">
        /// String object holding the resource group identifier which will be passed to the
        /// ResourceProvider when loading the XML and schema files.
        /// </param>
        /// <param name="allowXmlValidation">
        /// A boolean object used for disallowing xml validation for a single call,
        /// defaulting to "true" to allow validation.
        /// Only needed if xml validation should be disallowed once.
        /// </param>
        public virtual void ParseXmlFile(XmlHandler handler, string filename, string schemaName, string resourceGroup, bool allowXmlValidation = true)
        {
            // Acquire resource using CEGUI ResourceProvider
            var rawXmlData = new RawDataContainer();

            System.GetSingleton().GetResourceProvider()
            .LoadRawDataContainer(filename, rawXmlData, resourceGroup);

            try
            {
                // The actual parsing action (this is overridden and depends on the specific parser)
                ParseXml(handler, rawXmlData, schemaName);
            }
            catch (Exception)
            {
                // hint the related file name in the log
                System.GetSingleton().Logger
                .LogEvent("The last thrown exception was related to XML file '" +
                          filename + "' from resource group '" + resourceGroup + "'.", LoggingLevel.Errors);

                throw;
            }
            finally
            {
                // Release resource
                System.GetSingleton().GetResourceProvider()
                .UnloadRawDataContainer(rawXmlData);
            }
        }
示例#13
0
        /// <summary>
        /// Set the native resolution for this Font
        /// </summary>
        /// <param name="size">
        /// Size object describing the new native screen resolution for this Font.
        /// </param>
        public void SetNativeResolution(Sizef size)
        {
            d_nativeResolution = size;

            // re-calculate scaling factors & notify images as required
            NotifyDisplaySizeChanged(System.GetSingleton().GetRenderer().GetDisplaySize());
        }
示例#14
0
        /// <summary>
        /// Constructor for FreeTypeFont based fonts.
        /// </summary>
        /// <param name="fontName">The name that the font will use within the CEGUI system.</param>
        /// <param name="pointSize">
        /// Specifies the point size that the font is to be rendered at.
        /// </param>
        /// <param name="antiAliased">
        /// Specifies whether the font should be rendered using anti aliasing.
        /// </param>
        /// <param name="fontFilename">
        /// The filename of an font file that will be used as the source for
        /// glyph images for this font.
        /// </param>
        /// <param name="resourceGroup">
        /// The resource group identifier to use when loading the font file
        /// specified by \a font_filename.
        /// </param>
        /// <param name="autoScaled">
        /// Specifies whether the font imagery should be automatically scaled to
        /// maintain the same physical size (which is calculated by using the
        /// native resolution setting).
        /// </param>
        /// <param name="nativeRes">
        /// The native resolution value. This is only significant when  auto scaling is enabled.
        /// </param>
        /// <param name="specificLineSpacing">
        /// If specified (non-zero), this will be the line spacing that we will
        /// report for this font, regardless of what is mentioned in the font file
        /// itself.
        /// </param>
        public FreeTypeFont(string fontName, float pointSize,
                            bool antiAliased, string fontFilename,
                            string resourceGroup,
                            AutoScaledMode autoScaled,
                            Sizef nativeRes,
                            float specificLineSpacing)
            : base(fontName, Font_xmlHandler.FontTypeFreeType, fontFilename,
                   resourceGroup, autoScaled, nativeRes)
        {
            d_specificLineSpacing = specificLineSpacing;
            d_ptSize      = pointSize;
            d_antiAliased = antiAliased;
            d_fontFace    = null;
            d_kerningMode = KerningMode.Default;

            if (ft_usage_count == 0)
            {
                _library = new Library();
            }

            AddFreeTypeFontProperties();
            UpdateFont();

            System.GetSingleton().Logger
            .LogEvent(String.Format("Successfully loaded {0} glyphs", d_cp_map.Count), LoggingLevel.Informative);

            ft_usage_count++;
        }
示例#15
0
        /// <summary>
        /// Destroy the specified Window object.
        /// </summary>
        /// <param name="window">
        /// Pointer to the Window object to be destroyed.
        /// </param>
        /// <exception cref="InvalidRequestException">
        /// Can be thrown if the WindowFactory for \a window's object type was removed.
        /// </exception>
        public void DestroyWindow(Window window)
        {
            var addrBuff = window.GetHashCode().ToString("X8");

            if (!d_windowRegistry.Contains(window))
            {
                System.GetSingleton()
                .Logger.LogEvent(
                    "[WindowManager] Attempt to delete Window that does not exist!  Address was: " +
                    addrBuff +
                    ". WARNING: This could indicate a double-deletion issue!!",
                    LoggingLevel.Errors);
                return;
            }

            d_windowRegistry.Remove(window);

            System.GetSingleton().Logger
            .LogEvent("Window at '" + window.GetNamePath() + "' will be added to dead pool. " + addrBuff, LoggingLevel.Informative);

            // do 'safe' part of cleanup
            window.Destroy();

            // add window to dead pool
            d_deathrow.Add(window);

            // fire event to notify interested parites about window destruction.
            // TODO: Perhaps this should fire first, so window is still usable?
            var handler = WindowDestroyed;

            if (handler != null)
            {
                handler(this, new WindowEventArgs(window));
            }
        }
示例#16
0
        /// <summary>
        /// Return the current mouse cursor position as display resolution independant values.
        /// </summary>
        /// <returns>
        /// Point object describing the current mouse cursor position as resolution independant values that
        /// range from 0.0f to 1.0f, where 0.0f represents the left-most and top-most positions, and 1.0f
        /// represents the right-most and bottom-most positions.
        /// </returns>
        public Vector2f GetDisplayIndependantPosition()
        {
            var dsz = System.GetSingleton().GetRenderer().GetDisplaySize();

            return(new Vector2f(d_position.d_x / (dsz.d_width - 1.0f),
                                d_position.d_y / (dsz.d_height - 1.0f)));
        }
示例#17
0
 /// <summary>
 /// Takes given file containing XML and handles it
 ///
 /// This is basically a convenience function used by NamedXMLResourceManager
 /// <internal>No need for this to be virtual</internal>
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="resourceGroup"></param>
 public void HandleFile(string fileName, string resourceGroup)
 {
     System.GetSingleton().GetXMLParser()
     .ParseXmlFile(this, fileName, GetSchemaName(), String.IsNullOrEmpty(resourceGroup)
                                                              ? GetDefaultResourceGroup()
                                                              : resourceGroup);
 }
示例#18
0
 public void LoadImageset(string filename, string resourceGroup = "")
 {
     System.GetSingleton().GetXMLParser()
     .ParseXmlFile(this, filename, ImagesetSchemaName, String.IsNullOrEmpty(resourceGroup)
                                                                 ? d_imagesetDefaultResourceGroup
                                                                 : resourceGroup);
 }
 protected override void ElementStartLocal(string element, XMLAttributes attributes)
 {
     System.GetSingleton().Logger
     .LogEvent(
         "AnimationAffectorHandler::elementStart: " + "</" + element + "> is invalid at this location.",
         LoggingLevel.Errors);
 }
示例#20
0
 /// <summary>
 /// handles the closing Font XML element.
 /// </summary>
 private void ElementFontEnd()
 {
     System.GetSingleton().Logger
     .LogEvent(String.Format("Finished creation of Font '{0}' via XML file. (0x{1:X8})",
                             _font.GetName(), _font.GetHashCode()),
               LoggingLevel.Informative);
 }
        /// <summary>
        /// Creates a WindowRendererFactory of the type \a T and adds it to the
        /// system for use.
        /// The created WindowRendererFactory will automatically be deleted when the
        /// factory is removed from the system (either directly or at system
        /// deletion time).
        /// </summary>
        /// <typeparam name="T">
        /// Specifies the type of WindowRendererFactory subclass to add a factory for.
        /// </typeparam>
        public static void AddFactory <T>() where T : WindowRendererFactory, new()
        {
            // create the factory object
            WindowRendererFactory factory = new T();

            // only do the actual add now if our singleton has already been created
            if (_instance != null)
            {
                System.GetSingleton().Logger
                .LogEvent("Created WindowRendererFactory for '" + factory.GetName() + "' WindowRenderers.");

                // add the factory we just created
                try
                {
                    Instance.AddFactory(factory);
                }
                catch (Exception)
                {
                    System.GetSingleton().Logger
                    .LogEvent("Deleted WindowRendererFactory for '" + factory.GetName() + "' WindowRenderers.");

                    // delete the factory object
                    //CEGUI_DELETE_AO factory;

                    throw;
                }
            }

            OwnedFactories.Add(factory);
        }
示例#22
0
        /// <summary>
        /// Renames the element.
        /// </summary>
        /// <param name="name">
        /// String object holding the new name for the element.
        /// </param>
        /// <exception cref="AlreadyExistsException">
        /// thrown if an element named \a name already exists in the parent of this element.
        /// </exception>
        public virtual void SetName(String name)
        {
            ThrowIfDisposed();

            if (d_name == name)
            {
                return;
            }

            if (GetParentElement() != null)
            {
                var parent = GetParentElement() as NamedElement;
                if (parent != null && parent.IsChild(name))
                {
                    throw new AlreadyExistsException("Failed to rename " +
                                                     "NamedElement at: " + GetNamePath() + " as: " + name +
                                                     ". A Window " +
                                                     "with that name is already attached as a sibling.");
                }
            }

            // log this under informative level
            System.GetSingleton().Logger.LogEvent("Renamed element at: " + GetNamePath() + " as: " + name,
                                                  LoggingLevel.Informative);

            d_name = name;

            OnNameChanged(new NamedElementEventArgs(this));
        }
示例#23
0
        /// <summary>
        /// Constructor.
        /// </summary>
        private SchemeManager()
            : base("Scheme")
        {
            d_autoLoadResources = true;

            System.GetSingleton().Logger
            .LogEvent("SharpCEGui.SchemeManager singleton created. " + GetHashCode().ToString("X8"));
        }
示例#24
0
        protected void RecomputeMultiClickAbsoluteTolerance()
        {
            var displaySize = System.GetSingleton().GetRenderer().GetDisplaySize();

            d_mouseButtonMultiClickAbsoluteTolerance = new Sizef(
                d_mouseButtonMultiClickTolerance.Width * displaySize.Width,
                d_mouseButtonMultiClickTolerance.Height * displaySize.Height);
        }
示例#25
0
        /// <summary>
        /// Constructs a new WindowManager object.
        ///
        /// NB: Client code should not create WindowManager objects - they are of limited use to you!  The
        /// intended pattern of access is to get a pointer to the GUI system's WindowManager via the System
        /// object, and use that.
        /// </summary>
        public WindowManager()
        {
            d_uid_counter = 0;
            d_lockCount   = 0;

            System.GetSingleton().Logger
            .LogEvent("CEGUI::WindowManager singleton created " + GetHashCode().ToString("X8"));
        }
示例#26
0
        /// <summary>
        /// Register all window renderer factories required by the scheme.
        /// </summary>
        public void LoadWindowRendererFactories()
        {
            // check factories
            foreach (var cmod in d_windowRendererModules)
            {
                if (cmod.factoryModule == null)
                {
                    //#if !defined(CEGUI_STATIC)
                    // load dynamic module as required
                    if (cmod.dynamicModule == null)
                    {
                        var filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                    (cmod.name == "CEGUICoreWindowRendererSet"
                                                         ? "SharpCEGui.CoreWindowRendererSet"
                                                         : cmod.name) + ".dll");

                        cmod.dynamicModule = Assembly.LoadFile(filename);
                    }

                    cmod.factoryModule =
                        (FactoryModule)Activator.CreateInstance(
                            cmod.dynamicModule.GetTypes().Single(x => typeof(FactoryModule).IsAssignableFrom(x)));

                    //            FactoryModule& (*getWRFactoryModuleFunc)() =
                    //                reinterpret_cast<FactoryModule&(*)()>((*cmod).dynamicModule->
                    //                    getSymbolAddress("getWindowRendererFactoryModule"));

                    //            if (!getWRFactoryModuleFunc)
                    //                CEGUI_THROW(InvalidRequestException(
                    //                    "Required function export "
                    //                    "'FactoryModule& getWindowRendererFactoryModule()' "
                    //                    "was not found in module '" + (*cmod).name + "'."));

                    //            // get the WindowRendererModule object for this module.
                    //            (*cmod).factoryModule = &getWRFactoryModuleFunc();
                    //#else
                    //cmod.factoryModule = GetWindowRendererFactoryModule();
                    //#endif
                }

                // see if we should just register all factories available in the module
                // (i.e. No factories explicitly specified)
                if (cmod.types.Count == 0)
                {
                    System.GetSingleton().Logger.LogEvent("No window renderer factories specified for module '" + cmod.name + "' - adding all available factories...");
                    cmod.factoryModule.RegisterAllFactories();
                }
                // some names were explicitly given, so only register those.
                else
                {
                    foreach (var elem in cmod.types)
                    {
                        cmod.factoryModule.RegisterFactory(elem);
                    }
                }
            }
        }
示例#27
0
        /// <summary>
        /// Sets the autoscale native resolution of this Image.
        /// </summary>
        /// <param name="nativeResolution">
        /// The  autoscale native resolution of this Image.
        /// </param>
        public void SetNativeResolution(Sizef nativeResolution)
        {
            d_nativeResolution = nativeResolution;

            if (d_autoScaled != AutoScaledMode.Disabled)
            {
                UpdateScaledSizeAndOffset(System.GetSingleton().GetRenderer().GetDisplaySize());
            }
        }
示例#28
0
        // TODO: ...
        //! container type used to hold the registered Image types.
        //typedef std::map<String, ImageFactory*, StringFastLessCompare
        //    CEGUI_MAP_ALLOC(String, ImageFactory*)> ImageFactoryRegistry;

        /// <summary>
        /// helper to delete an image given an map iterator.
        /// </summary>
        /// <param name="iter"></param>
        private void Destroy(ref KeyValuePair <string, Tuple <Image, ImageFactory> > iter)
        {
            System.GetSingleton().Logger.LogEvent("[ImageManager] Deleted image: " + iter.Key);

            // use the stored factory to destroy the image it created.
            iter.Value.Item2.Destroy(iter.Value.Item1);

            d_images.Remove(iter.Key);
        }
示例#29
0
        private void Reinit()
        {
            var fontData = new RawDataContainer();

            System.GetSingleton().GetResourceProvider()
            .LoadRawDataContainer(d_filename, fontData, String.IsNullOrEmpty(d_resourceGroup)
                                                                  ? GetDefaultResourceGroup()
                                                                  : d_resourceGroup);
            LoadFntFile(fontData.Stream());
        }
示例#30
0
        private ImageManager()
        {
            System.GetSingleton().Logger
            .LogEvent(String.Format("[SharpCEGui.Base.ImageManager] Singleton created (0x{0:X8})", GetHashCode()));

            // self-register the built in 'BitmapImage' type.
            AddImageType(BitmapImage.TypeName, new TplImageFactory <BitmapImage>(x => new BitmapImage(x), x => new BitmapImage(x)));
            // self-register the built in 'SVGImage' type.
            AddImageType(SvgImage.TypeName, new TplImageFactory <SvgImage>(x => new SvgImage(x), x => new SvgImage(x)));
        }