/// <summary> /// Initializes a new instance of the GUIManager class. /// </summary> /// <param name="system">The MiyagiSystem.</param> protected internal GUIManager(MiyagiSystem system) { this.MiyagiSystem = system; this.GUIs = new MiyagiCollection <GUI>(); this.modalDialogs = new ExtendedStack <IModalDialog>(); this.CheckCursorVisibility = true; }
public static void Read(Stream stream, MiyagiSystem system) { using (var xtr = new XmlTextReader(stream)) { new Reader(xtr, system); } }
/// <summary> /// Initializes a new instance of the ValueControllerChain class. /// </summary> /// <param name="system">The MiyagiSystem.</param> /// <param name="autoUpdate">Indicates whether the ValueControllerChain should update itself.</param> /// <param name="commonSetterDelegate">The common setter delegate.</param> public ValueControllerChain(MiyagiSystem system, bool autoUpdate, SetterDelegate <T> commonSetterDelegate) { this.miyagiSystem = system; this.autoUpdate = autoUpdate; this.commonSetterDelegate = commonSetterDelegate; this.chainLinkLists = new Dictionary <int, List <ChainLink <T> > >(); }
/// <summary> /// Initializes a new instance of the RenderManager class. /// </summary> internal MogreRenderManager(MiyagiSystem miyagiSystem) : base(miyagiSystem) { renderManagerCount++; // get SceneManager using (SceneManagerEnumerator.SceneManagerIterator sci = Root.Singleton.GetSceneManagerIterator()) { sci.MoveNext(); this.SceneManager = sci.Current; } // get Camera if (this.SceneManager != null) { using (SceneManager.CameraIterator ci = this.SceneManager.GetCameraIterator()) { ci.MoveNext(); if (ci.Current != null) { this.MainViewport = new MogreViewport(ci.Current, miyagiSystem.Backend.Width, miyagiSystem.Backend.Height); } } } this.DefaultRenderQueue = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY; this.MainRenderer = new MogreSpriteRenderer2D(this); ((IMogreSpriteRenderer)this.MainRenderer).RenderOnRenderQueueEnded = true; this.materialPtr = MaterialManager.Singleton.CreateOrRetrieve( "Miyagi_Material" + renderManagerCount, this.MiyagiSystem.Backend.ResourceGroupName).first; this.PreparePass(); }
/// <summary> /// Create a GpuProgram. /// </summary> /// <param name="system">The MiyagiSystem.</param> /// <param name="name">The name of the GpuProgam.</param> /// <param name="language">The shader language of GpuProgram.</param> /// <param name="sourceFile">The path to the source file.</param> /// <param name="type">The type of the GpuProgram.</param> /// <param name="parameters">The parameters of the GpuProgram.</param> /// <returns>The newly created GpuProgram.</returns> public static GpuProgram Create(MiyagiSystem system, string name, string language, string sourceFile, GpuProgramType type, IDictionary <string, string> parameters) { GpuProgram retValue = new GpuProgram(name, language, type, parameters, sourceFile); system.Backend.CreateGpuProgram(retValue); return(retValue); }
private DialogBox(DialogBoxSettings dialogBoxSettings, MiyagiSystem system) { this.GUIManager = system.GUIManager; this.SpriteRenderer = system.RenderManager.Create2DRenderer(); system.LocaleManager.CurrentCultureChanged += this.LocaleManagerCultureChanged; if (dialogBoxSettings == null) { Size screenRes = system.RenderManager.MainViewport.Size; this.location = new Point(screenRes.Width / 3, screenRes.Height / 4); this.labelTextOffset = new Point(3, 5); this.buttonTextOffset = Point.Empty; this.size = new Size(screenRes.Width / 3, screenRes.Height / 4); this.buttonSize = new Size(this.size.Width / 5, this.size.Height / 8); } else { this.location = dialogBoxSettings.Location; this.labelTextOffset = dialogBoxSettings.LabelTextOffset; this.buttonTextOffset = dialogBoxSettings.ButtonTextOffset; this.size = dialogBoxSettings.Size; this.buttonSize = dialogBoxSettings.ButtonSize; } system.GUIManager.ReleaseFocusedAndGrabbedControl(); // reset result this.dialogResult = DialogResult.None; // set this to the top of the ModalDialogs stack system.GUIManager.PushModalDialog(this); this.Visible = true; }
private void SetElementsSizes() { MiyagiSystem system = this.Owner.MiyagiSystem; var newSize = Size; this.TextureElement2.Size = new Common.Data.Size(newSize.Width, this.TextureElement2.Size.Height); this.TextureElement4.Size = new Common.Data.Size(this.TextureElement4.Size.Width, newSize.Height); this.TextureElement5.Size = newSize; if (IsBitmapTooltip) { InnerTextureElement.Size = this.TextureElement5.Size; } this.TextureElement6.Size = new Common.Data.Size(this.TextureElement6.Size.Width, newSize.Height); this.TextureElement8.Size = new Common.Data.Size(newSize.Width, this.TextureElement8.Size.Height); this.TextureElement3.Offset = new Point(this.TextureElement1.Size.Width + this.TextureElement2.Size.Width, 0); this.TextureElement6.Offset = new Point(this.TextureElement4.Size.Width + this.TextureElement5.Size.Width, this.TextureElement3.Size.Height); this.TextureElement7.Offset = new Point(0, this.TextureElement1.Size.Height + this.TextureElement4.Size.Height); this.TextureElement8.Offset = new Point(this.TextureElement7.Size.Width, this.TextureElement2.Size.Height + this.TextureElement5.Size.Height); this.TextureElement9.Offset = new Point(this.TextureElement7.Size.Width + this.TextureElement8.Size.Width, this.TextureElement3.Size.Height + this.TextureElement6.Size.Height); // set the skin this.TextureElement1.Texture = DefaultTexture1 ?? (DefaultTexture1 = Skin.CreateForToolTip(system)); this.TextureElement2.Texture = DefaultTexture2 ?? (DefaultTexture2 = Skin.CreateForToolTip(system)); this.TextureElement3.Texture = DefaultTexture3 ?? (DefaultTexture3 = Skin.CreateForToolTip(system)); this.TextureElement4.Texture = DefaultTexture4 ?? (DefaultTexture4 = Skin.CreateForToolTip(system)); this.TextureElement5.Texture = DefaultTexture5 ?? (DefaultTexture5 = Skin.CreateForToolTip(system)); this.TextureElement6.Texture = DefaultTexture6 ?? (DefaultTexture6 = Skin.CreateForToolTip(system)); this.TextureElement7.Texture = DefaultTexture7 ?? (DefaultTexture7 = Skin.CreateForToolTip(system)); this.TextureElement8.Texture = DefaultTexture8 ?? (DefaultTexture8 = Skin.CreateForToolTip(system)); this.TextureElement9.Texture = DefaultTexture9 ?? (DefaultTexture9 = Skin.CreateForToolTip(system)); }
/// <summary> /// Initializes a new instance of the Backend class. /// </summary> /// <param name="system">The MiyagiSystem.</param> protected Backend(MiyagiSystem system, int width, int height) { this.MiyagiSystem = system; this.ResourceGroupName = "General"; Width = width; Height = height; }
public Reader(XDocument element, MiyagiSystem system) { this.system = system; this.currentDoc = element; this.redirectDict = new Dictionary <string, object>(); this.ReadManagers(); }
internal static Texture CreateForToolTip(MiyagiSystem system) { const string TexName = "Miyagi_Tooltip"; LoadDefaultTexture(TexName, system.Backend, Assembly.GetExecutingAssembly().GetManifestResourceStream("Miyagi.Internals.Resources.Gfx.ToolTip.png")); return(new Texture(TexName)); }
/// <summary> /// Initializes a new instance of the TwoDManager class. /// </summary> /// <param name="system">The MiyagiSystem.</param> public TwoDManager(MiyagiSystem system) { this.Layers = new MiyagiCollection <Layer>(); this.Layers.ItemAdded += this.LayerAdded; this.Layers.ItemInserted += this.LayerAdded; this.Layers.ItemRemoved += LayerRemoved; this.MiyagiSystem = system; }
/// <summary> /// Creates a texture from Xml. /// </summary> /// <param name="xElement">An XElement that contains the XML representation of the Texture.</param> /// <param name="system">The MiyagiSystem.</param> /// <returns>The newly created Texture.</returns> public static Texture CreateFromXml(XElement xElement, MiyagiSystem system) { return(new Texture( ReadFrameAnimationMode(xElement.Element("FrameAnimationMode")), ReadFrames(xElement.Descendants("Frame")), ReadScrollVector(xElement.Element("ScrollVector")), ReadGpuPrograms(system, xElement.Descendants("GpuProgram")))); }
/// <summary> /// Creates a TrueTypeFont from XML. /// </summary> /// <param name="xElement">An XElement that contains the XML representation of the TrueTypeFont.</param> /// <param name="system">The MiyagiSystem.</param> /// <returns> /// The newly created TrueTypeFont or null if the XML file is invalid. /// </returns> public static TrueTypeFont CreateFromXml(XElement xElement, MiyagiSystem system) { TrueTypeFont retValue; var xv = new XmlValidator(); if (xv.ValidateAgainstInternalSchema(xElement, "TrueTypeFont")) { // create the TrueTypeFont using the Name attribute retValue = new TrueTypeFont(xElement.Attribute("Name").Value) { FileName = (string)xElement.Element("FileName"), FontStyle = xElement.Element("FontStyle").Value.ParseEnum <SD.FontStyle>(), Resolution = (int)xElement.Element("Resolution"), Size = (int)xElement.Element("Size"), TabSize = xElement.Element("TabSize") != null ? (int)xElement.Element("TabSize") : 3, Tracking = xElement.Element("Tracking") != null ? (int)xElement.Element("Tracking") : 0, }; var leading = xElement.Element("Leading"); if (leading != null) { retValue.Leading = (int)leading; } var spaceWidth = xElement.Element("SpaceWidth"); if (spaceWidth != null) { retValue.SpaceWidth = (int)spaceWidth; } // get CodePoints IList <Range> codePoints; if (xElement.Element("CodePoints") == null) { codePoints = DefaultCodePoints; } else { codePoints = new List <Range>( from codePointNode in xElement.Descendants("CodePoint") let codePoint = new Range( (int)codePointNode.Element("First"), (int)codePointNode.Element("Last")) select codePoint); } retValue.codePoints = codePoints; CreateFont(system, retValue); } else { throw new XmlException("Invalid font XElement"); } return(retValue); }
/************************************************************************/ /* constructor */ /************************************************************************/ public StateManager(OgreManager _engine) { mEngine = _engine; mInput = new MoisManager(); mGuiSystem = new MiyagiSystem("Mogre"); mCurrentState = null; mNewState = null; mShutdown = false; }
/// <summary> /// Creates the sprite renderer. /// </summary> /// <param name="system">The system.</param> protected internal virtual void CreateSpriteRenderer(MiyagiSystem system) { if (this.SpriteRenderer != null) { this.DestroySpriteRenderer(); } this.SpriteRenderer = system.RenderManager.Create2DRenderer(); this.SpriteRenderer.ZOrder = this.ZOrder; }
/// <summary> /// Starts the ValueController. /// </summary> /// <param name="system">The MiyagiSystem.</param> /// <param name="autoUpdate">Indicates whether the ValueController should update itself.</param> /// <param name="propertyName">The name of the property which value should be changed.</param> /// <param name="obj">The object which property should be changed.</param> /// <exception cref="ArgumentException">propertyName</exception> public void Start(MiyagiSystem system, bool autoUpdate, string propertyName, object obj) { PropertyInfo prop = obj.GetType().GetProperty(propertyName); if (prop.PropertyType != typeof(T)) { throw new ArgumentException("Property type mismatch. Expected: " + typeof(T).Name + ". Was: " + prop.PropertyType.Name, "propertyName"); } this.Start(system, autoUpdate, val => prop.SetValue(obj, val, null)); }
/// <summary> /// Creates a new Font for an image font. /// </summary> /// <param name="system">The MiyagiSystem.</param> /// <param name="name">The name of the ImageFont.</param> /// <param name="fontFileName">The filename of the ImageFont.</param> /// <param name="glyphCoordinates">The glyph coordinates of the ImageFont.</param> /// <returns>The newly created ImageFont.</returns> public static ImageFont Create(MiyagiSystem system, string name, string fontFileName, IDictionary <char, RectangleF> glyphCoordinates) { ImageFont retValue = new ImageFont(name) { FileName = fontFileName, GlyphCoordinates = glyphCoordinates }; retValue.CreateFont(system); return(retValue); }
/// <summary> /// Creates the sprite renderer. /// </summary> /// <param name="system">The system.</param> protected internal override void CreateSpriteRenderer(MiyagiSystem system) { if (this.SpriteRenderer != null) { this.DestroySpriteRenderer(); } this.SpriteRenderer = system.RenderManager.Create3DRenderer(); ((ISpriteRenderer3D)this.SpriteRenderer).SetRenderable(this); this.SpriteRenderer.ZOrder = this.ZOrder; }
internal static Skin CreateForDialogBox(MiyagiSystem system) { const string TexName = "Miyagi_DialogBox"; LoadDefaultTexture(TexName, system.Backend, Assembly.GetExecutingAssembly().GetManifestResourceStream("Miyagi.Internals.Resources.Gfx.DialogBox.png")); var retValue = new Skin("DialogBox"); retValue.SubSkins["DialogBox"] = new Texture(TexName, GetUV(DialogBoxSkin.UV_Panel)); return(retValue); }
/// <summary> /// Creates TrueTypeFonts from XML. /// </summary> /// <param name="fileName">The location of the XML file.</param> /// <param name="system">The system.</param> /// <returns>The newly created TrueTypeFonts.</returns> public static IList <TrueTypeFont> CreateFromXml(string fileName, MiyagiSystem system) { var xDoc = XDocument.Load(fileName, LoadOptions.SetBaseUri); var elements = xDoc.Descendants("TrueTypeFont"); var retValue = new List <TrueTypeFont>(elements.Count()); retValue.AddRange(elements.Select(ele => CreateFromXml(ele, system))); return(retValue); }
public void Show() { if (this.Owner.MiyagiSystem == null) { return; } if (!this.Visible) { if (IsBitmapTooltip && Bitmap == null) { Bitmap = Style.BitmapCreatorFunction(this.Owner.ToolTipText, Style.MaximumWidth); } MiyagiSystem system = this.Owner.MiyagiSystem; system.GUIManager.SetToolTip(this); this.SetVisible(true); // set the new size //var newSize = this.size = this.Style.TextStyle.Font.MeasureString(this.Owner.ToolTipText, Size.Empty, this.Owner.ToolTipText.Contains(Environment.NewLine)); var newSize = Size.Empty; if (IsBitmapTooltip) { newSize = new Common.Data.Size(Bitmap.Size.Width, Bitmap.Size.Height); } else { newSize = this.Style.TextStyle.Font.MeasureString(this.Owner.ToolTipText, Size.Empty, true) + new Size(0, 2); } this.size = newSize; SetLocation(); SetElementsSizes(); // start the fadecontroller this.opacity = 1; if (this.fadeController != null) { this.fadeController.Stop(); } if (this.Style.FadeInDuration > TimeSpan.Zero) { this.fadeController = new LinearFunctionValueController <float>(0, 1, this.Style.FadeInDuration); this.fadeController.Start(system, true, this.SetOpacity); } this.showStartTime = this.MiyagiSystem.LastUpdate; } }
private static void CreateFont(MiyagiSystem system, TrueTypeFont font) { if (!system.Backend.TextureExists(font.TextureName)) { font.CreateFont(system); } else { font.Leading = GlobalLeadings[font.TextureName]; font.GlyphCoordinates = GlobalGlyphCoordinates[font.TextureName]; font.TextureSize = system.Backend.GetTextureSize(font.TextureName); } }
internal static Skin CreateForDialogBoxButton(MiyagiSystem system) { const string TexName = "Miyagi_DialogBox"; LoadDefaultTexture(TexName, system.Backend, Assembly.GetExecutingAssembly().GetManifestResourceStream("Miyagi.Internals.Resources.Gfx.DialogBox.png")); var retValue = new Skin("DialogBox.Button"); retValue.SubSkins["DialogBox.Button"] = retValue.SubSkins["DialogBox.Button.MouseUp"] = retValue.SubSkins["DialogBox.Button.MouseLeave"] = new Texture(TexName, GetUV(DialogBoxSkin.UV_Button)); retValue.SubSkins["DialogBox.Button.MouseDown"] = new Texture(TexName, GetUV(DialogBoxSkin.UV_Button_MouseDown)); retValue.SubSkins["DialogBox.Button.MouseEnter"] = new Texture(TexName, GetUV(DialogBoxSkin.UV_Button_MouseEnter)); return(retValue); }
/// <summary> /// Creates all the fonts /// </summary> private static void CreateFonts(MiyagiSystem system) { var files = Directory.EnumerateFiles(_resourcesFileLocation + "Fonts", "*" + _miyagiXMLExtension, SearchOption.AllDirectories); var fonts = new List<Font>(); foreach (string file in files) { fonts.AddRange(ImageFont.CreateFromXml(file, system)); } Fonts = fonts.ToDictionary(f => f.Name); // set BlueHighway as default font Font.Default = Fonts["BlueHighway"]; }
/// <summary> /// Creates the fonts and the skins we will use /// </summary> public static void CreateResources(MiyagiSystem system) { CreateFonts(system); CreateSkins(); // then fix the fonts so they work correctly MiyagiHelper.SetupFonts( #if DEBUG true, #else false, #endif system, Fonts, Skins); CreateCursor(system.GUIManager); }
private void CreateFontTexture(MiyagiSystem system, SD.FontStyle fontStyle) { using (var pfc = new PrivateFontCollection()) { pfc.AddFontFile(this.FileName); int leading = this.Leading; using (SD.Bitmap fontBitmap = CreateFontBitmap(pfc.Families[0], fontStyle, this.Size, this.Resolution, ref leading, this.codePoints, this.GlyphCoordinates)) { this.Leading = leading; GlobalGlyphCoordinates[this.TextureName] = this.GlyphCoordinates; GlobalLeadings[this.TextureName] = this.Leading; this.TextureHandle = system.Backend.CreateTexture(this.TextureName, new Size(fontBitmap.Size.Width, fontBitmap.Size.Height)); system.Backend.WriteToTexture(fontBitmap.ToByteArray(), this.TextureHandle); } } }
/// <summary> /// Disposes the scripting manager. /// </summary> public void Dispose() { if (this.IsDisposed) { return; } if (this.Disposing != null) { this.Disposing(this, EventArgs.Empty); } this.Dispose(true); GC.SuppressFinalize(this); this.IsDisposed = true; this.MiyagiSystem.UnregisterManager(this); this.MiyagiSystem = null; }
/// <summary> /// Starts the ValueController. /// </summary> /// <param name="system">The MiyagiSystem.</param> /// <param name="autoUpdate">Indicates whether the ValueController should update itself.</param> /// <param name="setter">The setter delegate for the value.</param> /// <exception cref="ArgumentNullException"><paramref name="setter" /> is <c>null</c>.</exception> public void Start(MiyagiSystem system, bool autoUpdate, SetterDelegate <T> setter) { this.MiyagiSystem = system; if (this.isRunning) { this.Stop(); } if (setter == null) { throw new ArgumentNullException("setter"); } this.setterDelegate = setter; this.AutoUpdate = autoUpdate; this.OnStart(EventArgs.Empty); }
private static IEnumerable <GpuProgram> ReadGpuPrograms(MiyagiSystem system, IEnumerable <XElement> elements) { return (elements.Select(gpuNode => GpuProgram.Create( system, gpuNode.Attribute("Name").Value, gpuNode.Element("Language").Value, gpuNode.Element("SourceFile").Value, gpuNode.Attribute("Type").Value.ParseEnum <GpuProgramType>(), gpuNode.Descendants("Parameter").Select(paramNode => new { paramNode, parameter = new { Key = paramNode.Element("Key").Value, paramNode.Element("Value").Value } }).Select(t => t.parameter).ToDictionary(kvp => kvp.Key, kvp => kvp.Value)))); }
private static void CreateFonts(MiyagiSystem system) { const string FontPath = @"../Media/Fonts/"; var fonts = new[] { // load ttf definitions from xml file TrueTypeFont.CreateFromXml(Path.Combine(FontPath, "TrueTypeFonts.xml"), system) .Cast <Font>().ToDictionary(f => f.Name), // load image font definitions from xml file ImageFont.CreateFromXml(Path.Combine(FontPath, "ImageFonts.xml"), system) .Cast <Font>().ToDictionary(f => f.Name) }; Fonts = fonts.SelectMany(dict => dict) .ToDictionary(pair => pair.Key, pair => pair.Value); // set BlueHighway as default font Font.Default = Fonts["Expressway"]; }
public void CreateDefaultGui(MiyagiSystem GuiSystem) { gConsole = new GameConsole(); ctrlPanel = new ControlPanel(); cityPanel = new CityInfoPanel(); DebugPanel = new DebugPanel(); ContextMenu = new ContextMenu(); bcWindow = new BuildingCreationWindow(); topContainer = new TopContainer(); bldgPlacePanel = new BuildingPlacementPanel(); weatherInfo = new WeatherInfoWindow(); bldgSelectWindow = new BuildingSelectionWindow(); GuiComponents.AddRange(new IGuiComponent[] { gConsole, topContainer, ctrlPanel, cityPanel, debugPanel, contextMenu, bcWindow, bldgPlacePanel, weatherInfo, bldgSelectWindow }); Gui = new GUI(); GuiSystem.GUIManager.GUIs.Add(Gui); this.InitGui(Gui); }
/// <summary> /// Creates a new TrueTypeFont. /// </summary> /// <param name="system">The MiyagiSystem.</param> /// <param name="name">The name of the TrueTypeFont.</param> /// <param name="fontFileName">The filename of the font.</param> /// <param name="size">The desired size in points.</param> /// <param name="resolution">The resolution in dpi.</param> /// <param name="fontStyle">The style of the font.</param> /// <param name="codePoints">A list codepoint ranges.</param> /// <returns>The created TrueType font.</returns> public static TrueTypeFont Create(MiyagiSystem system, string name, string fontFileName, int size, int resolution, SD.FontStyle fontStyle, IList <Range> codePoints) { if (codePoints == null) { codePoints = DefaultCodePoints; } var retValue = new TrueTypeFont(name) { FileName = fontFileName, Size = size, Resolution = resolution, FontStyle = fontStyle, codePoints = codePoints, }; CreateFont(system, retValue); return(retValue); }
/// <summary> /// Loads up our GUI from an xml file /// </summary> private static void CreateFromSerialized(MiyagiSystem system) { system.SerializationManager.ImportFromFile(_resourcesFileLocation + "cerealized" + _miyagiXMLExtension); // the XML only gives us SkinNames and FontNames, so now we have to get them to all use the correct skins/fonts foreach (var control in system.GUIManager.AllControls) { SkinnedControl sc = control as SkinnedControl; if (sc != null) { sc.Skin = Skins[sc.SkinName]; } Label l = control as Label; if (l != null) { l.TextStyle.Font = Fonts[l.TextStyle.FontName]; } } }