public ContentManager( FileSystem fileSystem, GraphicsDevice graphicsDevice, GraphicsDevice2D graphicsDevice2D, SageGame sageGame) { _fileSystem = fileSystem; GraphicsDevice = graphicsDevice; GraphicsDevice2D = graphicsDevice2D; SageGame = sageGame; IniDataContext = new IniDataContext(fileSystem); _contentLoaders = new Dictionary <Type, ContentLoader> { { typeof(Model), AddDisposable(new ModelLoader()) }, { typeof(Scene), AddDisposable(new MapLoader()) }, { typeof(Texture), AddDisposable(new TextureLoader(graphicsDevice)) }, { typeof(WndTopLevelWindow), AddDisposable(new WindowLoader(this)) }, { typeof(ShapeComponent), AddDisposable(new ShapeLoader(this)) } }; _cachedObjects = new Dictionary <string, object>(); EffectLibrary = AddDisposable(new EffectLibrary(graphicsDevice)); TranslationManager = new TranslationManager(fileSystem); _cachedTextFormats = new Dictionary <TextFormatKey, TextFormat>(); }
private WndWindowStateConfiguration( WndWindowDefinition wndWindow, ColorRgba textColor, ColorRgba textBorderColor, WndDrawData wndDrawData, StretchableImage image, GraphicsDevice graphicsDevice, GraphicsDevice2D graphicsDevice2D) { TextColor = textColor; TextBorderColor = textBorderColor; if (!wndWindow.Status.HasFlag(WndWindowStatusFlags.Image)) { BackgroundColor = ConversionExtensions.ToColorRgbaF(wndDrawData.Items[0].Color); } if (BackgroundColor != null || wndWindow.Status.HasFlag(WndWindowStatusFlags.Border)) { BorderColor = ConversionExtensions.ToColorRgbaF(wndDrawData.Items[0].BorderColor); } if (image != null) { ImageTexture = AddDisposable(image.RenderToTexture(graphicsDevice, graphicsDevice2D)); } }
public static void Stop() { GraphicsDevice2D.Dispose(); GraphicsDevice2D = null; GraphicsDevice.Dispose(); GraphicsDevice = null; }
internal Texture RenderToTexture(GraphicsDevice graphicsDevice, GraphicsDevice2D graphicsDevice2D) { var imageTexture = Texture.CreateTexture2D( graphicsDevice, PixelFormat.Rgba8UNorm, _totalWidth, _height, TextureBindFlags.ShaderResource | TextureBindFlags.RenderTarget); using (var drawingContext = new DrawingContext(graphicsDevice2D, imageTexture)) { drawingContext.Begin(); switch (_mode) { case StretchableImageMode.Normal: drawingContext.DrawImage( _croppedBitmapLeft.Bitmap, ToRawRectangleF(_croppedBitmapLeft.SourceRect), new RawRectangleF(0, 0, _totalWidth, _height), false); break; case StretchableImageMode.Stretchable: var leftWidth = _croppedBitmapLeft.SourceRect.Width; var rightWidth = _croppedBitmapRight.SourceRect.Width; var leftRect = new RawRectangleF(0, 0, leftWidth, _height); drawingContext.DrawImage( _croppedBitmapLeft.Bitmap, ToRawRectangleF(_croppedBitmapLeft.SourceRect), leftRect, false); var middleRect = new RawRectangleF(leftRect.Right, 0, _totalWidth - leftWidth - rightWidth, _height); drawingContext.DrawImage( _croppedBitmapMiddle.Bitmap, ToRawRectangleF(_croppedBitmapMiddle.SourceRect), middleRect, false); var rightRect = new RawRectangleF(middleRect.Right, 0, rightWidth, _height); drawingContext.DrawImage( _croppedBitmapRight.Bitmap, ToRawRectangleF(_croppedBitmapRight.SourceRect), rightRect, false); break; default: throw new InvalidOperationException(); } drawingContext.End(); } return(imageTexture); }
public static WndWindowStateConfiguration Create( WndWindowDefinition wndWindow, WndWindowState state, ContentManager contentManager, GraphicsDevice graphicsDevice, GraphicsDevice2D graphicsDevice2D) { WndDrawData wndDrawData; ColorRgba textColor, textColorBorder; switch (state) { case WndWindowState.Enabled: wndDrawData = wndWindow.EnabledDrawData; textColor = wndWindow.TextColor.Enabled; textColorBorder = wndWindow.TextColor.EnabledBorder; break; case WndWindowState.Highlighted: case WndWindowState.HighlightedPushed: wndDrawData = wndWindow.HiliteDrawData; textColor = wndWindow.TextColor.Hilite; textColorBorder = wndWindow.TextColor.HiliteBorder; break; case WndWindowState.Disabled: wndDrawData = wndWindow.DisabledDrawData; textColor = wndWindow.TextColor.Disabled; textColorBorder = wndWindow.TextColor.DisabledBorder; break; default: throw new ArgumentOutOfRangeException(nameof(state)); } StretchableImage createImage() { switch (wndWindow.WindowType) { case WndWindowType.PushButton: switch (state) { case WndWindowState.HighlightedPushed: return(StretchableImage.CreatePushButtonImage( wndWindow, wndDrawData, contentManager, 1, 3, 4)); default: return(StretchableImage.CreatePushButtonImage( wndWindow, wndDrawData, contentManager, 0, 5, 6)); } default: return(StretchableImage.CreateNormalImage( wndWindow, wndDrawData, contentManager)); } } var image = wndWindow.Status.HasFlag(WndWindowStatusFlags.Image) ? createImage() : null; return(new WndWindowStateConfiguration( wndWindow, textColor, textColorBorder, wndDrawData, image, graphicsDevice, graphicsDevice2D)); }
public TextFormat(GraphicsDevice2D graphicsDevice, string fontFamily, float fontSize, FontWeight fontWeight, TextAlignment alignment) { PlatformConstruct(graphicsDevice, fontFamily, fontSize, fontWeight, alignment); }
private void PlatformConstruct(GraphicsDevice2D graphicsDevice, string fontFamily, float fontSize, FontWeight fontWeight, TextAlignment alignment) { }
public static void Start() { GraphicsDevice = new GraphicsDevice(); GraphicsDevice2D = new GraphicsDevice2D(GraphicsDevice); }