static void loadCornerXml(TextureSlot slot, bloResourceFinder finder, xElement element, bloMirror defMirror) { slot.texture = finder.find <bloTexture>(element.Element("texture"), "timg"); slot.color = bloXml.loadColor(element.Element("color"), new bloColor(bloColor.cWhite)); if (!Enum.TryParse <bloMirror>(element.Element("mirror"), out slot.mirror)) { slot.mirror = 0; } }
protected override void loadXml(xElement element) { base.loadXml(element); var finder = bloResourceFinder.getFinder(); mTextureCount = 1; mTextures[0] = finder.find <bloTexture>(element.Element("texture"), "timg"); mPalette = finder.find <bloPalette>(element.Element("palette"), "tlut"); if (!Enum.TryParse <bloBinding>(element.Element("binding"), true, out mBinding)) { mBinding = (bloBinding.Left | bloBinding.Top | bloBinding.Right | bloBinding.Bottom); } if (!Enum.TryParse <bloMirror>(element.Element("mirror"), true, out mMirror)) { mMirror = 0; } mRotate90 = (element.Element("rotate-90") | false); if (!Enum.TryParse <bloWrapMode>(element.Element("wrap-s"), true, out mWrapS)) { mWrapS = bloWrapMode.None; } if (!Enum.TryParse <bloWrapMode>(element.Element("wrap-t"), true, out mWrapT)) { mWrapT = bloWrapMode.None; } bloXml.loadGradient(element.Element("gradient"), out mFromColor, out mToColor); var white = new bloColor(bloColor.cWhite); var colors = element.Element("colors"); mColors[(int)bloTextureBase.TopLeft] = bloXml.loadColor(colors.Element("top-left"), white); mColors[(int)bloTextureBase.TopRight] = bloXml.loadColor(colors.Element("top-right"), white); mColors[(int)bloTextureBase.BottomLeft] = bloXml.loadColor(colors.Element("bottom-left"), white); mColors[(int)bloTextureBase.BottomRight] = bloXml.loadColor(colors.Element("bottom-right"), white); setBlendKonstColor(); setBlendKonstAlpha(); }
protected override void loadXml(xElement element) { base.loadXml(element); var finder = bloResourceFinder.getFinder(); var content = element.Element("content"); mContentRect = bloXml.loadRectangle(content.Element("rectangle")); mContentTexture = finder.find <bloTexture>(content.Element("texture"), "timg"); mPalette = finder.find <bloPalette>(element.Element("palette"), "tlut"); var corners = element.Element("corners"); loadCornerXml(mTextures[cTopLeft], finder, corners.Element("top-left"), 0); loadCornerXml(mTextures[cTopRight], finder, corners.Element("top-right"), bloMirror.X); loadCornerXml(mTextures[cBottomLeft], finder, corners.Element("bottom-left"), bloMirror.Y); loadCornerXml(mTextures[cBottomRight], finder, corners.Element("bottom-right"), (bloMirror.X | bloMirror.Y)); bloXml.loadGradient(element.Element("gradient"), out mFromColor, out mToColor); initializeMinSize(); }
protected override void loadXml(xElement element) { base.loadXml(element); var finder = bloResourceFinder.getFinder(); mFont = finder.find <bloResFont>(element.Element("font"), "font"); mText = bloXml.loadTextBuffer(element.Element("text"), mFont); var white = new bloColor(bloColor.cWhite); var colors = element.Element("colors"); mTopColor = bloXml.loadColor(colors.Element("top"), white); mBottomColor = bloXml.loadColor(colors.Element("bottom"), white); var binding = element.Element("binding"); if (!Enum.TryParse <bloTextboxHBinding>(binding.Element("horizontal"), true, out mHBinding)) { mHBinding = bloTextboxHBinding.Left; } if (!Enum.TryParse <bloTextboxVBinding>(binding.Element("vertical"), true, out mVBinding)) { mVBinding = bloTextboxVBinding.Top; } var typesetting = element.Element("typesetting"); int leading = (mFont != null ? mFont.getLeading() : 20); int width = (mFont != null ? mFont.getWidth() : 20); int height = (mFont != null ? mFont.getHeight() : 20); mFontSpacing = (typesetting.Element("spacing") | 0); mFontLeading = (typesetting.Element("leading") | leading); mFontWidth = (typesetting.Element("width") | width); mFontHeight = (typesetting.Element("height") | height); bloXml.loadGradient(element.Element("gradient"), out mFromColor, out mToColor); }
protected virtual void loadXml(xElement element) { if (element == null) { throw new ArgumentNullException("element"); } mName = convertStringToName(element.Attribute("id") | ""); setConnectParent(element.Attribute("connect") | false); mVisible = (element.Attribute("visible") | true); mRect = bloXml.loadRectangle(element.Element("rectangle")); mAngle = ((element.Element("angle") | 0) % 360); if (!Enum.TryParse <bloAnchor>(element.Element("anchor"), true, out mAnchor)) { mAnchor = bloAnchor.TopLeft; } if (!Enum.TryParse <gxCullMode>(element.Element("cull-mode"), true, out mCullMode)) { mCullMode = gxCullMode.None; } mAlpha = (byte)bloMath.clamp((element.Element("alpha") | 255), 0, 255); mInheritAlpha = (element.Element("alpha").Attribute("inherit") | true); }
public static bloRectangle loadRectangle(xElement element, bloRectangle defRectangle = default(bloRectangle)) { if (element == null) { return(defRectangle); } var rectangle = new bloRectangle(); if (element.Element("x") != null && element.Element("y") != null && element.Element("width") != null && element.Element("height") != null) { rectangle.move(element.Element("x"), element.Element("y")); rectangle.resize(element.Element("width"), element.Element("height")); } else if (element.Element("left") != null && element.Element("top") != null && element.Element("right") != null && element.Element("bottom") != null) { rectangle.set(element.Element("left"), element.Element("top"), element.Element("right"), element.Element("bottom")); } else { rectangle = defRectangle; } return(rectangle); }
public static bloColor loadColor(xElement element, bloColor defColor = default(bloColor)) { if (element == null) { return(defColor); } uint rgba; var color = new bloColor(); if (element.Element("r") != null && element.Element("g") != null && element.Element("b") != null) { color.r = bloMath.clamp(element.Element("r"), 0, 255); color.g = bloMath.clamp(element.Element("g"), 0, 255); color.b = bloMath.clamp(element.Element("b"), 0, 255); color.a = bloMath.clamp(element.Element("a") | 255, 0, 255); } else { var match = Regex.Match(element.Value, @"\s*(?<value>[0-9a-f]{1,8})\s*", (RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)); if (match.Success) { var valueGrp = match.Groups["value"]; rgba = UInt32.Parse(valueGrp.Value, NumberStyles.AllowHexSpecifier); switch (valueGrp.Length) { case 1: color = new bloColor(255, 255, 255, (int)(rgba * 17)); break; case 2: color = new bloColor(255, 255, 255, (int)rgba); break; case 3: { color = new bloColor( (int)(((rgba >> 8) & 15) * 17), (int)(((rgba >> 4) & 15) * 17), (int)(((rgba >> 0) & 15) * 17), 255 ); break; } case 4: { color = new bloColor( (int)(((rgba >> 12) & 15) * 17), (int)(((rgba >> 8) & 15) * 17), (int)(((rgba >> 4) & 15) * 17), (int)(((rgba >> 0) & 15) * 17) ); break; } case 5: { color = new bloColor( (int)(((rgba >> 16) & 15) * 17), (int)(((rgba >> 12) & 15) * 17), (int)(((rgba >> 7) & 15) * 17), (int)((rgba >> 0) & 255) ); break; } case 6: { color = new bloColor( (int)((rgba >> 16) & 255), (int)((rgba >> 8) & 255), (int)((rgba >> 0) & 255), 255 ); break; } case 7: { color = new bloColor( (int)((rgba >> 20) & 255), (int)((rgba >> 12) & 255), (int)((rgba >> 4) & 255), (int)(((rgba >> 0) & 15) * 17) ); break; } case 8: color = new bloColor(rgba); break; } } } return(color); }
public static void loadGradient(xElement element, out bloColor fromColor, out bloColor toColor) { fromColor = loadColor(element.Element("from"), new bloColor(bloColor.cZero)); toColor = loadColor(element.Element("to"), new bloColor(bloColor.cOne)); }