public override void Initialize(EntityProperties properties, JsonObject attributes) { base.Initialize(properties, attributes); skintree = entity.WatchedAttributes.GetTreeAttribute("skinConfig"); if (skintree == null) { entity.WatchedAttributes["skinConfig"] = skintree = new TreeAttribute(); } entity.WatchedAttributes.RegisterModifiedListener("skinConfig", onSkinConfigChanged); entity.WatchedAttributes.RegisterModifiedListener("voicetype", onVoiceConfigChanged); entity.WatchedAttributes.RegisterModifiedListener("voicepitch", onVoiceConfigChanged); AvailableSkinParts = properties.Attributes["skinnableParts"].AsObject <SkinnablePart[]>(); foreach (var val in AvailableSkinParts) { string partCode = val.Code; val.VariantsByCode = new Dictionary <string, SkinnablePartVariant>(); AvailableSkinPartsByCode[val.Code] = val; if (val.Type == EnumSkinnableType.Texture && entity.Api.Side == EnumAppSide.Client) { ICoreClientAPI capi = entity.Api as ICoreClientAPI; LoadedTexture texture = new LoadedTexture(capi); foreach (var variant in val.Variants) { AssetLocation textureLoc; if (val.TextureTemplate != null) { textureLoc = val.TextureTemplate.Clone(); textureLoc.Path = textureLoc.Path.Replace("{code}", variant.Code); } else { textureLoc = variant.Texture; } IAsset asset = capi.Assets.TryGet(textureLoc.Clone().WithPathAppendixOnce(".png").WithPathPrefixOnce("textures/"), true); int r = 0, g = 0, b = 0; float c = 0; BitmapRef bmp = asset.ToBitmap(capi); for (int i = 0; i < 8; i++) { Vec2d vec = GameMath.R2Sequence2D(i); Color col2 = bmp.GetPixelRel((float)vec.X, (float)vec.Y); if (col2.A > 0.5) { r += col2.R; g += col2.G; b += col2.B; c++; } } bmp.Dispose(); c = Math.Max(1, c); variant.Color = ColorUtil.ColorFromRgba((int)(r / c), (int)(g / c), (int)(b / c), 255); val.VariantsByCode[variant.Code] = variant; } } else { foreach (var variant in val.Variants) { val.VariantsByCode[variant.Code] = variant; } } } if (entity.Api.Side == EnumAppSide.Server && AppliedSkinParts.Count == 0) { foreach (var val in AvailableSkinParts) { string partCode = val.Code; string variantCode = val.Variants[entity.World.Rand.Next(val.Variants.Length)].Code; selectSkinPart(partCode, variantCode, false); } } onVoiceConfigChanged(); }
/// <summary> /// 创建obj /// </summary> /// <param name="content"></param> /// <param name="data"></param> public void createEquipItem(Transform content, EquipInfoBean data) { GameObject equipObj = Instantiate(ResourcesManager.LoadData <GameObject>(s_ResTypeSelectItemPath)); //设置大小 RectTransform itemRect = equipObj.GetComponent <RectTransform>(); float itemWith = content.GetComponent <RectTransform>().rect.height * 0.52f; float itemHight = content.GetComponent <RectTransform>().rect.height * 0.8f; itemRect.sizeDelta = new Vector2(itemWith, itemHight); TabButton tabButton = equipObj.GetComponent <TabButton>(); equipObj.transform.SetParent(content); equipObj.transform.SetSiblingIndex((int)data.equipTypeId); equipObj.name = data.equipName; equipObj.transform.localScale = new Vector3(1, 1, 1); //背景 Image backgroundImage = CptUtil.getCptFormParentByName <Transform, Image>(equipObj.transform, "Background"); //设置名字 Text equipName = CptUtil.getCptFormParentByName <Transform, Text>(equipObj.transform, "EquipName"); equipName.text = data.equipName; //设置资源图片 Image equipImage = CptUtil.getCptFormParentByName <Transform, Image>(equipObj.transform, "EquipImage"); StartCoroutine(ResourcesManager.LoadAsyncDataImage(data.equipImageUrl, equipImage)); if (data.equipImageColor != null && data.equipImageColor.Length != 0) { if (data.equipTypeId == 0) { data.equipImageColor = "#EFEFEF"; } ColorUtil.setImageColor(equipImage, data.equipImageColor); } //获取是否锁定 ((EquipDSHandle)DataStorageManage.getEquipDSHandle()).getData(data); Image equipLock = CptUtil.getCptFormParentByName <Transform, Image>(equipObj.transform, "EquipLock"); Button equipButton = CptUtil.getCptFormParentByName <Transform, Button>(equipObj.transform, "EquipButton"); Image equipButtonImage = CptUtil.getCptFormParentByName <Transform, Image>(equipObj.transform, "EquipButton"); Text equipButtonText = CptUtil.getCptFormParentByName <Transform, Text>(equipObj.transform, "EquipButtonText"); if (data.equipTypeId != 0 && data.unlockType == 0) { //未解锁处理 equipLock.enabled = true; equipButtonText.text = CommonData.getText(13) + "(" + data.unlockPoint + "PP)"; equipButton.onClick.AddListener(delegate() { unlockEquip(content, data, equipObj); }); } else { //已解锁处理 equipLock.enabled = false; int equipId = 0; if (data.equipType == (int)EquipTypeEnum.PuzzlesShape) { equipId = (int)CommonConfigure.PuzzlesShape; } else if (data.equipType == (int)EquipTypeEnum.BorderShape) { equipId = (int)CommonConfigure.BorderShape; } else if (data.equipType == (int)EquipTypeEnum.BorderColor) { equipId = (int)CommonConfigure.BorderColor; } else if (data.equipType == (int)EquipTypeEnum.Background) { equipId = (int)CommonConfigure.Background; } if (equipId == data.equipTypeId) { equipButtonText.text = CommonData.getText(90); equipButton.onClick.RemoveAllListeners(); ColorUtil.setImageColor(backgroundImage, "#CCCCCC"); ColorUtil.setImageColor(equipButtonImage, "#CCCCCC"); } else { equipButtonText.text = CommonData.getText(89); equipButton.onClick.AddListener(delegate() { useEquip(content, data, equipObj); }); } } }
public override void Display(IVwEnv vwenv, int hvo, int frag) { TriggerDisplay(vwenv); // We use a table to display // encodings in column one and the strings in column two. // The table uses 100% of the available width. VwLength vlTable; vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; // The width of the writing system column is determined from the width of the // longest one which will be displayed. m_mDxmpLabelWidth = 0; for (int i = 0; i < m_rgws.Count; ++i) { int dxs; // Width of displayed string. int dys; // Height of displayed string (not used here). // Set qtss to a string representing the writing system. vwenv.get_StringWidth(NameOfWs(i), m_ttpLabel, out dxs, out dys); m_mDxmpLabelWidth = Math.Max(m_mDxmpLabelWidth, dxs); } VwLength vlColWs; // 5-pt space plus max label width. vlColWs.nVal = m_mDxmpLabelWidth + 5000; vlColWs.unit = VwUnit.kunPoint1000; // Enhance JohnT: possibly allow for right-to-left UI by reversing columns? // The Main column is relative and uses the rest of the space. VwLength vlColMain; vlColMain.nVal = 1; vlColMain.unit = VwUnit.kunRelative; vwenv.OpenTable(2, // Two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. VwRule.kvrlNone, // No rules between cells. 0, // No forced space between cells. 0, // No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. The writing system column only occurs at all if its // width is non-zero. vwenv.MakeColumns(1, vlColWs); vwenv.MakeColumns(1, vlColMain); vwenv.OpenTableBody(); var visibleWss = new Set <ILgWritingSystem>(); // if we passed in a view and have WritingSystemsToDisplay // then we'll load that list in order to filter our larger m_rgws list. AddViewWritingSystems(visibleWss); for (int i = 0; i < m_rgws.Count; ++i) { if (SkipEmptyWritingSystem(visibleWss, i, hvo)) { continue; } vwenv.OpenTableRow(); // First cell has writing system abbreviation displayed using m_ttpLabel. vwenv.Props = m_ttpLabel; vwenv.OpenTableCell(1, 1); vwenv.AddString(NameOfWs(i)); vwenv.CloseTableCell(); // Second cell has the string contents for the alternative. // DN version has some property setting, including trailing margin and // RTL. if (m_rgws[i].RightToLeftScript) { vwenv.set_IntProperty((int)FwTextPropType.ktptRightToLeft, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalTrailing); } if (!m_editable) { vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); } vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, (int)FwTextPropVar.ktpvMilliPoint, 2000); vwenv.OpenTableCell(1, 1); var wsdef = m_rgws[i] as WritingSystemDefinition; if (wsdef != null && wsdef.IsVoice) { // We embed it in a conc paragraph to ensure it never takes more than a line. // It will typically be covered up by a sound control. // Also set foreground color to match the window, so nothing shows even if the sound doesn't overlap it perfectly. // (transparent does not seem to work as a foreground color) vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Window))); // Must not spell-check a conc para, leads to layout failures when the paragraph tries to cast the source to // a conc text source, if it is overridden by a spelling text source. vwenv.set_IntProperty((int)FwTextPropType.ktptSpellCheck, (int)FwTextPropVar.ktpvEnum, (int)SpellingModes.ksmDoNotCheck); vwenv.OpenConcPara(0, 1, VwConcParaOpts.kcpoDefault, 0); vwenv.AddStringAltMember(m_flid, m_rgws[i].Handle, this); vwenv.CloseParagraph(); } else { if (!string.IsNullOrEmpty(TextStyle)) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, TextStyle); } vwenv.AddStringAltMember(m_flid, m_rgws[i].Handle, this); } vwenv.CloseTableCell(); vwenv.CloseTableRow(); } vwenv.CloseTableBody(); vwenv.CloseTable(); }
/// <summary> /// Sets the palette for rendering grayscale images. /// </summary> /// <param name="colors"></param> public void SetPalette(Color[] colors) { _gray2Palette = ColorUtil.GetPalette(colors, 4); _gray4Palette = ColorUtil.GetPalette(colors, 16); }
/// <summary> /// Draws an interval</summary> /// <param name="interval">Interval</param> /// <param name="bounds">Bounding rectangle, in screen space</param> /// <param name="drawMode">Drawing mode</param> /// <param name="c">Drawing context</param> protected override void Draw(IInterval interval, RectangleF bounds, DrawMode drawMode, Context c) { Color color = interval.Color; switch (drawMode & DrawMode.States) { case DrawMode.Normal: RectangleF realPart = new RectangleF( bounds.X, bounds.Y, GdiUtil.TransformVector(c.Transform, interval.Length), bounds.Height); bool hasTail = realPart.Width < MinimumDrawnIntervalLength; float h = color.GetHue(); float s = color.GetSaturation(); float b = color.GetBrightness(); Color endColor = ColorUtil.FromAhsb(color.A, h, s * 0.3f, b); c.Graphics.FillRectangle( realPart, new PointF(0, realPart.Top), new PointF(0, realPart.Bottom), color, endColor); if (hasTail) { endColor = ColorUtil.FromAhsb(64, h, s * 0.3f, b); RectangleF tailPart = new RectangleF( realPart.Right, bounds.Y, bounds.Width - realPart.Width, bounds.Height); c.Graphics.FillRectangle(tailPart, endColor); } if (color.R + color.G + color.B < 3 * 160) { TextBrush.Color = SystemColors.HighlightText; } else { TextBrush.Color = SystemColors.WindowText; } c.Graphics.DrawText(interval.Name + " " + interval.Start.ToString(), c.TextFormat, bounds.Location, TextBrush); if ((drawMode & DrawMode.Selected) != 0) { c.Graphics.DrawRectangle( new RectangleF(bounds.X + 1, bounds.Y + 1, bounds.Width - 2, bounds.Height - 2), SelectedBrush, 3.0f); } break; case DrawMode.Collapsed: c.Graphics.FillRectangle(bounds, CollapsedBrush); break; case DrawMode.Ghost: c.Graphics.FillRectangle(bounds, Color.FromArgb(128, color)); bool showRight = (drawMode & DrawMode.ResizeRight) != 0; float x = showRight ? bounds.Right : bounds.Left; c.Graphics.DrawText( GetXPositionString(x, c), c.TextFormat, new PointF(x, bounds.Bottom - c.FontHeight), TextBrush); break; case DrawMode.Invalid: c.Graphics.FillRectangle(bounds, InvalidBrush); break; } }
public override void DoRender3DOpaque(float dt, bool isShadowPass) { IRenderAPI rapi = capi.Render; // the value 22 is just trial&error, should probably be something proportial to the // 13ms game ticks (which is the physics frame rate) lerpedPos.X += (entity.Pos.X - lerpedPos.X) * 22 * dt; lerpedPos.Y += (entity.Pos.Y - lerpedPos.Y) * 22 * dt; lerpedPos.Z += (entity.Pos.Z - lerpedPos.Z) * 22 * dt; ItemRenderInfo renderInfo = rapi.GetItemStackRenderInfo(inslot, EnumItemRenderTarget.Ground); if (renderInfo.ModelRef == null) { return; } inslot.Itemstack.Collectible.OnBeforeRender(capi, inslot.Itemstack, EnumItemRenderTarget.Ground, ref renderInfo); IStandardShaderProgram prog = null; LoadModelMatrix(renderInfo, isShadowPass, dt); if (isShadowPass) { rapi.CurrentActiveShader.BindTexture2D("tex2d", renderInfo.TextureId, 0); float[] mvpMat = Mat4f.Mul(ModelMat, capi.Render.CurrentModelviewMatrix, ModelMat); Mat4f.Mul(mvpMat, capi.Render.CurrentProjectionMatrix, mvpMat); capi.Render.CurrentActiveShader.UniformMatrix("mvpMatrix", mvpMat); capi.Render.CurrentActiveShader.Uniform("origin", new Vec3f()); } else { prog = rapi.StandardShader; prog.Use(); prog.Tex2D = renderInfo.TextureId; prog.RgbaTint = ColorUtil.WhiteArgbVec; prog.DontWarpVertices = 0; prog.NormalShaded = 1; prog.AlphaTest = renderInfo.AlphaTest; if (entity.Swimming) { prog.AddRenderFlags = (entityitem.Itemstack.Collectible.MaterialDensity > 1000 ? 0 : 1) << 12; prog.WaterWaveCounter = capi.Render.ShaderUniforms.WaterWaveCounter; } else { prog.AddRenderFlags = 0; } prog.OverlayOpacity = renderInfo.OverlayOpacity; if (renderInfo.OverlayTexture != null && renderInfo.OverlayOpacity > 0) { prog.Tex2dOverlay2D = renderInfo.OverlayTexture.TextureId; prog.OverlayTextureSize = new Vec2f(renderInfo.OverlayTexture.Width, renderInfo.OverlayTexture.Height); prog.BaseTextureSize = new Vec2f(renderInfo.TextureSize.Width, renderInfo.TextureSize.Height); TextureAtlasPosition texPos = rapi.GetTextureAtlasPosition(entityitem.Itemstack); prog.BaseUvOrigin = new Vec2f(texPos.x1, texPos.y1); } BlockPos pos = entityitem.Pos.AsBlockPos; Vec4f lightrgbs = capi.World.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); int temp = (int)entityitem.Itemstack.Collectible.GetTemperature(capi.World, entityitem.Itemstack); float[] glowColor = ColorUtil.GetIncandescenceColorAsColor4f(temp); int extraGlow = GameMath.Clamp((temp - 550) / 2, 0, 255); glowRgb.R = glowColor[0]; glowRgb.G = glowColor[1]; glowRgb.B = glowColor[2]; glowRgb.A = extraGlow / 255f; prog.ExtraGlow = extraGlow; prog.RgbaAmbientIn = rapi.AmbientColor; prog.RgbaLightIn = lightrgbs; prog.RgbaGlowIn = glowRgb; prog.RgbaFogIn = rapi.FogColor; prog.FogMinIn = rapi.FogMin; prog.FogDensityIn = rapi.FogDensity; prog.ExtraGodray = 0; prog.NormalShaded = renderInfo.NormalShaded ? 1 : 0; prog.ProjectionMatrix = rapi.CurrentProjectionMatrix; prog.ViewMatrix = rapi.CameraMatrixOriginf; prog.ModelMatrix = ModelMat; ItemStack stack = entityitem.Itemstack; AdvancedParticleProperties[] ParticleProperties = stack.Block?.ParticleProperties; if (stack.Block != null && !capi.IsGamePaused) { Mat4f.MulWithVec4(ModelMat, new Vec4f(stack.Block.TopMiddlePos.X, stack.Block.TopMiddlePos.Y - 0.4f, stack.Block.TopMiddlePos.Z - 0.5f, 0), particleOutTransform); // No idea why the -0.5f and -0.4f accum += dt; if (ParticleProperties != null && ParticleProperties.Length > 0 && accum > 0.025f) { accum = accum % 0.025f; for (int i = 0; i < ParticleProperties.Length; i++) { AdvancedParticleProperties bps = ParticleProperties[i]; bps.basePos.X = particleOutTransform.X + entity.Pos.X; bps.basePos.Y = particleOutTransform.Y + entity.Pos.Y; bps.basePos.Z = particleOutTransform.Z + entity.Pos.Z; entityitem.World.SpawnParticles(bps); } } } } if (!renderInfo.CullFaces) { rapi.GlDisableCullFace(); } rapi.RenderMesh(renderInfo.ModelRef); if (!renderInfo.CullFaces) { rapi.GlEnableCullFace(); } if (!isShadowPass) { prog.Stop(); } }
private byte[] ColorizeGray4(int width, int height, byte[] frame) { return ColorUtil.ColorizeFrame(width, height, frame, _gray4Palette ?? _gray4Colors); }
public override void OnLoaded(ICoreAPI api) { base.OnLoaded(api); idleParticles = new SimpleParticleProperties( 0.5f, 1, ColorUtil.ToRgba(150, 34, 47, 44), new Vec3d(), new Vec3d(), new Vec3f(-0.1f, -0.1f, -0.1f), new Vec3f(0.1f, 0.1f, 0.1f), 1.5f, 0, 0.5f, 0.75f, EnumParticleModel.Quad ); idleParticles.SizeEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -0.6f); idleParticles.AddPos.Set(1, 2, 1); idleParticles.addLifeLength = 0.5f; idleParticles.RedEvolve = new EvolvingNatFloat(EnumTransformFunction.LINEAR, 80); insideParticles = new SimpleParticleProperties( 0.5f, 1, ColorUtil.ToRgba(150, 92, 111, 107), new Vec3d(), new Vec3d(), new Vec3f(-0.2f, -0.2f, -0.2f), new Vec3f(0.2f, 0.2f, 0.2f), 1.5f, 0, 0.5f, 0.75f, EnumParticleModel.Quad ); insideParticles.SizeEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -0.6f); insideParticles.AddPos.Set(1, 2, 1); insideParticles.addLifeLength = 0.5f; teleportParticles = new SimpleParticleProperties( 0.5f, 1, ColorUtil.ToRgba(150, 92, 111, 107), new Vec3d(), new Vec3d(), new Vec3f(-0.2f, -0.2f, -0.2f), new Vec3f(0.2f, 0.2f, 0.2f), 4.5f, 0, 0.5f, 0.75f, EnumParticleModel.Quad ); teleportParticles.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -1f); teleportParticles.AddPos.Set(1, 2, 1); teleportParticles.addLifeLength = 0.5f; }
public void UIFresh() { ItemItem itemItem = Global.gApp.gGameData.ItemData.Get(m_CampShopItem.propId); //武器需要根据当前情况处理 if (itemItem != null && GameItemFactory.GetInstance().GetItem(m_CampShopItem.propId) > 0) { Global.gApp.gSystemMgr.GetNpcMgr().CampShopTimesMap[m_CampShopItem.id.ToString()] = 1; Global.gApp.gSystemMgr.GetNpcMgr().SaveData(); } MatIcon.image.sprite = Resources.Load(itemItem.image_grow, typeof(Sprite)) as Sprite; double addNum = m_CampShopItem.propNum; if (m_CampShopItem.propId == SpecialItemIdConstVal.GOLD) { Gold_paramsItem gpiCfg = Global.gApp.gGameData.GoldParamsConfig.Get(Global.gApp.gSystemMgr.GetBaseAttrMgr().GetLevel()); addNum *= gpiCfg.coinParams; } m_ExchangeCount.text.text = "X " + UiTools.FormateMoneyUP(addNum); HeartCount.text.text = m_CampShopItem.heartNum.ToString(); HeartCount.text.color = ColorUtil.GetTextColor(GameItemFactory.GetInstance().GetItem(SpecialItemIdConstVal.RED_HEART) < m_CampShopItem.heartNum, "#FDE47EFF"); bool limit = Global.gApp.gSystemMgr.GetNpcMgr().CampShopTimesMap[m_CampShopItem.id.ToString()] >= m_CampShopItem.limitButTimes; ExchangeNode.gameObject.SetActive(!limit); SellOut.gameObject.SetActive(limit); MatIcon.image.color = limit ? ColorUtil.GetColor(ColorUtil.m_BlackColor) : ColorUtil.GetColor(ColorUtil.m_DeaultColor); MatName.text.text = itemItem.gamename; ExchangeCount.gameObject.SetActive(false); }
/// <summary> /// 普通单元格渲染时 /// </summary> /// <param name="groupIndex"></param> /// <param name="cellIndex"></param> /// <param name="cellData"></param> /// <param name="cellView"></param> /// <param name="selected"></param> protected override void OnCellRenderer(int groupIndex, int cellIndex, object cellData, RectTransform cellView, bool selected) { Animator animator = cellView.GetComponent <Animator>(); Image quality = cellView.Find("Content/Image_Quality").GetComponent <Image>(); Image icon1 = cellView.Find("Content/Image_Icon").GetComponent <Image>(); Image icon2 = cellView.Find("Content/Image_Icon2").GetComponent <Image>(); TMP_Text nameLabel = cellView.Find("Content/Mask/Label_Name").GetComponent <TMP_Text>(); TMP_Text typeLabel = cellView.Find("Content/Mask/Label_WeaponLabel").GetComponent <TMP_Text>(); Image currentUsedIcon = cellView.Find("Content/Image_Icon_E").GetComponent <Image>(); Image otherUsedIcon = cellView.Find("Content/Image_Icon_E1").GetComponent <Image>(); TMP_Text lv = cellView.Find("Content/Level/Label_Lv2").GetComponent <TMP_Text>(); ItemBase item = cellData as ItemBase; quality.color = ColorUtil.GetColorByItemQuality(item.ItemConfig.Quality); UIViewListLayout style = Parent.State.GetPageLayoutStyle(State.GetPageIndex()); if (style == UIViewListLayout.Grid) { UIUtil.SetIconImageSquare(icon1, item.ItemConfig.Icon); UIUtil.SetIconImageSquare(icon2, item.ItemConfig.Icon); } else { UIUtil.SetIconImage(icon1, item.ItemConfig.Icon); UIUtil.SetIconImage(icon2, item.ItemConfig.Icon); } sb.Clear(); nameLabel.text = TableUtil.GetItemName(item.TID); int zeroCount = 3 - item.Lv.ToString().Length; if (zeroCount > 0) { sb.Append("<color=#808080>"); do { sb.Append(0); } while (--zeroCount > 0); sb.Append("</color>"); } sb.Append(item.Lv); lv.text = sb.ToString(); switch (item) { case ItemWeaponVO val: typeLabel.text = TableUtil.GetLanguageString(val.WeaponType2); break; case ItemReformerVO val: typeLabel.text = TableUtil.GetLanguageString(val.MainType); break; case ItemEquipmentVO val: typeLabel.text = TableUtil.GetLanguageString(val.EquipmentType); break; case ItemModVO val: typeLabel.text = TableUtil.GetLanguageString(val.ModType1) + " " + TableUtil.GetLanguageString(val.ModType2); break; } currentUsedIcon.gameObject.SetActive(m_CurrentItemData?.GetReference() == item.UID); otherUsedIcon.gameObject.SetActive(false); if (!currentUsedIcon.gameObject.activeSelf) { if (item.Replicas.Count > 0) { for (int i = 0; i < item.Replicas.Count; i++) { if (Parent.Data.CurrentShip.GetItem(item.Replicas[i]) != null) { otherUsedIcon.gameObject.SetActive(true); break; } } } } animator?.SetBool("IsOn", selected); if (selected) { OnItemSelected(item); m_CurrentSelectedItemData = item; } }
public void ConnectStyles() { IStStyle normal = AddTestStyle("Normal", ContextValues.Internal, StructureValues.Undefined, FunctionValues.Prose, false); IStStyle normalParaStyle = AddTestStyle("Paragraph", ContextValues.Text, StructureValues.Body, FunctionValues.Prose, false); IStStyle sectionHead = AddTestStyle("Section Head", ContextValues.Text, StructureValues.Heading, FunctionValues.Prose, false); IStStyle verseNumberStyle = AddTestStyle("Verse Number", ContextValues.Text, StructureValues.Body, FunctionValues.Verse, true); IStStyle mainTitleStyle = AddTestStyle("Title Main", ContextValues.Title, StructureValues.Body, FunctionValues.Prose, false); IStStyle footnoteParaStyle = AddTestStyle("Note General Paragraph", ContextValues.Note, StructureValues.Undefined, FunctionValues.Prose, false); IStStyle footnoteMarkerStyle = AddTestStyle("Note Marker", ContextValues.Internal, StructureValues.Undefined, FunctionValues.Prose, true); StyleInfoTable table = new StyleInfoTable(string.Empty, Cache.ServiceLocator.WritingSystemManager); ITsPropsBldr props; props = normal.Rules.GetBldr(); props.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 20000); props.SetIntPropValues((int)FwTextPropType.ktptLineHeight, (int)FwTextPropVar.ktpvMilliPoint, 16000); props.SetIntPropValues((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, 10000); normal.Rules = props.GetTextProps(); table.Add("Normal", new DummyStyleInfo(normal)); props = normalParaStyle.Rules.GetBldr(); props.SetIntPropValues((int)FwTextPropType.ktptBorderLeading, (int)FwTextPropVar.ktpvMilliPoint, 1000); props.SetIntPropValues((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 2000); props.SetIntPropValues((int)FwTextPropType.ktptBorderTrailing, (int)FwTextPropVar.ktpvMilliPoint, 3000); props.SetIntPropValues((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 4000); props.SetIntPropValues((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Thistle))); normalParaStyle.Rules = props.GetTextProps(); normalParaStyle.BasedOnRA = normal; normalParaStyle.NextRA = normalParaStyle; table.Add("Paragraph", new DummyStyleInfo(normalParaStyle)); props = footnoteParaStyle.Rules.GetBldr(); footnoteParaStyle.BasedOnRA = normalParaStyle; footnoteParaStyle.NextRA = null; table.Add("Note General Paragraph", new DummyStyleInfo(footnoteParaStyle)); props = sectionHead.Rules.GetBldr(); props.SetIntPropValues((int)FwTextPropType.ktptItalic, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvOff); props.SetIntPropValues((int)FwTextPropType.ktptBackColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Aquamarine))); props.SetStrPropValue((int)FwTextPropType.ktptFontFamily, StyleServices.DefaultFont); sectionHead.Rules = props.GetTextProps(); sectionHead.BasedOnRA = normal; sectionHead.NextRA = normalParaStyle; DummyStyleInfo sectionInfo = new DummyStyleInfo(sectionHead); int wsEn = Cache.WritingSystemFactory.GetWsFromStr("en"); sectionInfo.FontInfoForWs(wsEn).m_fontName.ExplicitValue = "Arial"; table.Add("Section Head", sectionInfo); props = mainTitleStyle.Rules.GetBldr(); props.SetIntPropValues((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn); props.SetIntPropValues((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvDefault, (int)FwTextAlign.ktalCenter); props.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 16000); props.SetIntPropValues((int)FwTextPropType.ktptFirstIndent, (int)FwTextPropVar.ktpvMilliPoint, 0); mainTitleStyle.Rules = props.GetTextProps(); mainTitleStyle.BasedOnRA = sectionHead; mainTitleStyle.NextRA = mainTitleStyle; table.Add("Title Main", new DummyStyleInfo(mainTitleStyle)); props = verseNumberStyle.Rules.GetBldr(); props.SetIntPropValues((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvDefault, (int)FwTextToggleVal.kttvForceOn); props.SetIntPropValues((int)FwTextPropType.ktptItalic, (int)FwTextPropVar.ktpvDefault, (int)FwTextToggleVal.kttvForceOn); props.SetIntPropValues((int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, (int)FwSuperscriptVal.kssvSuper); props.SetIntPropValues((int)FwTextPropType.ktptUnderline, (int)FwTextPropVar.ktpvEnum, (int)FwUnderlineType.kuntDouble); props.SetIntPropValues((int)FwTextPropType.ktptUnderColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.SteelBlue))); props.SetIntPropValues((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Tomato))); props.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Courier"); verseNumberStyle.Rules = props.GetTextProps(); verseNumberStyle.BasedOnRA = null; verseNumberStyle.NextRA = null; table.Add("Verse Number", new DummyStyleInfo(verseNumberStyle)); footnoteMarkerStyle.BasedOnRA = verseNumberStyle; footnoteMarkerStyle.NextRA = null; table.Add("Note Marker", new DummyStyleInfo(footnoteMarkerStyle)); table.ConnectStyles(); // Check "Paragraph" style // Explicit properties DummyStyleInfo entry = (DummyStyleInfo)table["Paragraph"]; Assert.AreEqual("Paragraph", entry.Name); Assert.IsTrue(entry.IsParagraphStyle); Assert.AreEqual(table["Normal"].StyleNumber, entry.BasedOnStyleNumber); Assert.AreEqual(entry.StyleNumber, entry.NextStyleNumber); Assert.AreEqual(1000, entry.BorderLeading); Assert.AreEqual(2000, entry.BorderTop); Assert.AreEqual(3000, entry.BorderTrailing); Assert.AreEqual(4000, entry.BorderBottom); Assert.AreEqual((Color.FromKnownColor(KnownColor.Thistle)).ToArgb(), entry.BorderColor.ToArgb()); // Inherited properties FontInfo fontInfo = entry.FontInfoForWs(-1); Assert.IsNotNull(fontInfo); Assert.IsFalse(entry.ExplicitRightToLeftStyle); Assert.IsFalse(fontInfo.m_italic.Value); Assert.IsFalse(fontInfo.m_bold.Value); Assert.AreEqual(20000, fontInfo.m_fontSize.Value); Assert.AreEqual(10000, fontInfo.m_offset.Value); Assert.AreEqual(FwUnderlineType.kuntNone, fontInfo.m_underline.Value); Assert.IsTrue(fontInfo.m_underlineColor.IsInherited); Assert.AreEqual(Color.Black, fontInfo.m_underlineColor.Value); Assert.IsTrue(fontInfo.m_features.IsInherited); Assert.AreEqual(null, fontInfo.m_features.Value); Assert.IsTrue(fontInfo.m_backColor.IsInherited); Assert.AreEqual(Color.Empty, fontInfo.m_backColor.Value); Assert.IsTrue(fontInfo.m_fontColor.IsInherited); Assert.AreEqual(Color.Black, fontInfo.m_fontColor.Value); Assert.AreEqual("<default font>", fontInfo.m_fontName.Value); Assert.AreEqual(FwSuperscriptVal.kssvOff, fontInfo.m_superSub.Value); Assert.AreEqual(FwTextAlign.ktalLeading, entry.Alignment); Assert.AreEqual(0, entry.FirstLineIndent); Assert.AreEqual(16000, entry.LineSpacing.m_lineHeight); Assert.AreEqual(0, entry.LeadingIndent); Assert.AreEqual(0, entry.TrailingIndent); Assert.AreEqual(0, entry.SpaceAfter); Assert.AreEqual(0, entry.SpaceBefore); // Check Normal Footnote Paragraph style // Explicit properties entry = (DummyStyleInfo)table["Note General Paragraph"]; Assert.AreEqual("Note General Paragraph", entry.Name); Assert.IsTrue(entry.IsParagraphStyle); Assert.AreEqual(table["Paragraph"].StyleNumber, entry.BasedOnStyleNumber); Assert.AreEqual("Note General Paragraph", entry.NextStyle.Name); // Inherited properties fontInfo = entry.FontInfoForWs(-1); Assert.IsNotNull(fontInfo); Assert.IsFalse(entry.ExplicitRightToLeftStyle); Assert.IsFalse(fontInfo.m_italic.Value); Assert.IsFalse(fontInfo.m_bold.Value); Assert.AreEqual(20000, fontInfo.m_fontSize.Value); Assert.AreEqual(10000, fontInfo.m_offset.Value); Assert.AreEqual(FwUnderlineType.kuntNone, fontInfo.m_underline.Value); Assert.AreEqual(Color.Black, fontInfo.m_underlineColor.Value); Assert.IsNull(fontInfo.m_features.Value); Assert.AreEqual(Color.Empty, fontInfo.m_backColor.Value); Assert.AreEqual(Color.Black, fontInfo.m_fontColor.Value); Assert.AreEqual("<default font>", fontInfo.m_fontName.Value); Assert.AreEqual(FwSuperscriptVal.kssvOff, fontInfo.m_superSub.Value); Assert.AreEqual(FwTextAlign.ktalLeading, entry.Alignment); Assert.AreEqual(0, entry.FirstLineIndent); Assert.AreEqual(16000, entry.LineSpacing.m_lineHeight); Assert.AreEqual(0, entry.LeadingIndent); Assert.AreEqual(0, entry.TrailingIndent); Assert.AreEqual(0, entry.SpaceAfter); Assert.AreEqual(0, entry.SpaceBefore); Assert.AreEqual(1000, entry.BorderLeading); Assert.AreEqual(2000, entry.BorderTop); Assert.AreEqual(3000, entry.BorderTrailing); Assert.AreEqual(4000, entry.BorderBottom); Assert.AreEqual((Color.FromKnownColor(KnownColor.Thistle)).ToArgb(), entry.BorderColor.ToArgb()); // Check Title Main style // Explicit properties entry = (DummyStyleInfo)table["Title Main"]; Assert.AreEqual("Title Main", entry.Name); Assert.IsTrue(entry.IsParagraphStyle); Assert.AreEqual(FwTextAlign.ktalCenter, entry.Alignment); Assert.AreEqual(0, entry.FirstLineIndent); fontInfo = entry.FontInfoForWs(-1); Assert.IsNotNull(fontInfo); Assert.IsTrue(fontInfo.m_bold.Value); Assert.AreEqual(16000, fontInfo.m_fontSize.Value); Assert.AreEqual(table["Section Head"].StyleNumber, entry.BasedOnStyleNumber); Assert.AreEqual(entry.StyleNumber, entry.NextStyleNumber); // Inherited properties Assert.IsFalse(entry.ExplicitRightToLeftStyle); Assert.IsFalse(fontInfo.m_italic.Value); Assert.AreEqual(10000, fontInfo.m_offset.Value); Assert.AreEqual(FwUnderlineType.kuntNone, fontInfo.m_underline.Value); Assert.AreEqual(Color.Black, fontInfo.m_underlineColor.Value); Assert.IsNull(fontInfo.m_features.Value); Assert.AreEqual((Color.FromKnownColor(KnownColor.Aquamarine)).ToArgb(), fontInfo.m_backColor.Value.ToArgb()); Assert.AreEqual(Color.Black, fontInfo.m_fontColor.Value); Assert.AreEqual("<default font>", fontInfo.m_fontName.Value); Assert.AreEqual(16000, entry.LineSpacing.m_lineHeight); Assert.AreEqual(0, entry.LeadingIndent); Assert.AreEqual(0, entry.TrailingIndent); Assert.AreEqual(0, entry.SpaceAfter); Assert.AreEqual(0, entry.SpaceBefore); Assert.AreEqual(FwSuperscriptVal.kssvOff, fontInfo.m_superSub.Value); fontInfo = entry.FontInfoForWs(wsEn); Assert.AreEqual("Arial", fontInfo.m_fontName.Value); // Check Section Head style // Explicit properties entry = (DummyStyleInfo)table["Section Head"]; Assert.AreEqual("Section Head", entry.Name); Assert.IsTrue(entry.IsParagraphStyle); fontInfo = entry.FontInfoForWs(-1); Assert.IsNotNull(fontInfo); Assert.IsFalse(fontInfo.m_italic.Value); Assert.AreEqual(FwUnderlineType.kuntNone, fontInfo.m_underline.Value); Assert.AreEqual(Color.Black, fontInfo.m_underlineColor.Value); Assert.IsNull(fontInfo.m_features.Value); Assert.AreEqual((Color.FromKnownColor(KnownColor.Aquamarine)).ToArgb(), fontInfo.m_backColor.Value.ToArgb()); Assert.AreEqual("<default font>", fontInfo.m_fontName.Value); Assert.AreEqual(table["Normal"].StyleNumber, entry.BasedOnStyleNumber); Assert.AreEqual(table["Paragraph"].StyleNumber, entry.NextStyleNumber); // Inherited properties Assert.IsFalse(entry.ExplicitRightToLeftStyle); Assert.AreEqual(FwTextAlign.ktalLeading, entry.Alignment); Assert.AreEqual(0, entry.FirstLineIndent); Assert.IsFalse(fontInfo.m_bold.Value); Assert.AreEqual(20000, fontInfo.m_fontSize.Value); Assert.AreEqual(10000, fontInfo.m_offset.Value); Assert.AreEqual(Color.Black, fontInfo.m_fontColor.Value); Assert.AreEqual(16000, entry.LineSpacing.m_lineHeight); Assert.AreEqual(0, entry.LeadingIndent); Assert.AreEqual(0, entry.TrailingIndent); Assert.AreEqual(0, entry.SpaceAfter); Assert.AreEqual(0, entry.SpaceBefore); Assert.AreEqual(FwSuperscriptVal.kssvOff, fontInfo.m_superSub.Value); // Check Verse Number style // Explicit properties entry = (DummyStyleInfo)table["Verse Number"]; Assert.AreEqual("Verse Number", entry.Name); Assert.IsFalse(entry.IsParagraphStyle); fontInfo = entry.FontInfoForWs(-1); Assert.IsNotNull(fontInfo); Assert.IsTrue(fontInfo.m_bold.Value); Assert.IsTrue(fontInfo.m_italic.Value); Assert.AreEqual(FwSuperscriptVal.kssvSuper, fontInfo.m_superSub.Value); Assert.AreEqual(FwUnderlineType.kuntDouble, fontInfo.m_underline.Value); Assert.AreEqual((Color.FromKnownColor(KnownColor.SteelBlue)).ToArgb(), fontInfo.m_underlineColor.Value.ToArgb()); Assert.AreEqual((Color.FromKnownColor(KnownColor.Tomato)).ToArgb(), fontInfo.m_fontColor.Value.ToArgb()); Assert.AreEqual("Courier", fontInfo.m_fontName.Value); Assert.AreEqual(0, entry.BasedOnStyleNumber); // Inherited properties Assert.IsTrue(fontInfo.m_fontSize.IsInherited); Assert.IsTrue(fontInfo.m_offset.IsInherited); // Check Footnote Marker style // Explicit properties entry = (DummyStyleInfo)table["Note Marker"]; Assert.AreEqual("Note Marker", entry.Name); Assert.IsFalse(entry.IsParagraphStyle); Assert.AreEqual(table["Verse Number"].StyleNumber, entry.BasedOnStyleNumber); // Inherited properties fontInfo = entry.FontInfoForWs(-1); Assert.IsNotNull(fontInfo); Assert.IsTrue(fontInfo.m_bold.Value); Assert.IsTrue(fontInfo.m_italic.Value); Assert.AreEqual(FwSuperscriptVal.kssvSuper, fontInfo.m_superSub.Value); Assert.AreEqual(FwUnderlineType.kuntDouble, fontInfo.m_underline.Value); Assert.AreEqual((Color.FromKnownColor(KnownColor.SteelBlue)).ToArgb(), fontInfo.m_underlineColor.Value.ToArgb()); Assert.AreEqual((Color.FromKnownColor(KnownColor.Tomato)).ToArgb(), fontInfo.m_fontColor.Value.ToArgb()); Assert.AreEqual("Courier", fontInfo.m_fontName.Value); // Inherited properties Assert.IsTrue(fontInfo.m_fontSize.IsInherited); Assert.IsTrue(fontInfo.m_offset.IsInherited); }
void Group.Draw(Canvas c) { if (UIManager.ShowSecondaryMenu) { if (!UIManager.inMenuSession) { UIManager.initialX = UIManager.FirstHand.X; UIManager.initialY = UIManager.FirstHand.Y; UIManager.inMenuSession = true; } System.Windows.Media.Brush primaryColor = ProfileManager.ActiveProfile.PrimaryColor; System.Windows.Media.Brush secondaryColor = ProfileManager.ActiveProfile.SecondaryColor; System.Windows.Media.Brush fill = ColorUtil.FromHTML("#88FFFFFF"); double centerX = UIManager.initialX; double centerY = UIManager.initialY; double leftAreaX = UIManager.initialX - 1.25 * UIManager.SUBMENU_DIAMETER; double leftAreaY = UIManager.initialY; if (UIManager.FirstHandNumber == 2) { leftAreaX = UIManager.initialX + 1.25 * UIManager.SUBMENU_DIAMETER; } if (UIManager.FirstHand.X > leftAreaX - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.X < leftAreaX + UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.Y > leftAreaY - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.Y < leftAreaY + UIManager.SUBMENU_DIAMETER / 2) { leftSelected = true; } else if (UIManager.FirstHand.X > centerX - UIManager.MENU_DIAMETER / 2 && UIManager.FirstHand.X < centerX + UIManager.MENU_DIAMETER / 2 && UIManager.FirstHand.Y > centerY - UIManager.MENU_DIAMETER / 2 && UIManager.FirstHand.Y < centerY + UIManager.MENU_DIAMETER / 2) { if (leftSelected) { UIManager.SelectedGroup = parent; } leftSelected = false; } CanvasUtil.DrawEllipse(c, centerX, centerY, UIManager.MENU_DIAMETER, UIManager.MENU_DIAMETER, primaryColor, fill, null); if (leftSelected) { CanvasUtil.DrawEllipse(c, leftAreaX, leftAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, parent.IsActive ? secondaryColor : Brushes.LightGray, fill, System.Windows.Media.Brushes.White); } else { CanvasUtil.DrawEllipse(c, leftAreaX, leftAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, parent.IsActive ? secondaryColor : Brushes.LightGray, fill, null); } System.Windows.Controls.Image image0 = ImageUtil.GetResourceImage(((Group)this).Name); CanvasUtil.DrawImageInCircle(c, image0, UIManager.MENU_DIAMETER, centerX, centerY); System.Windows.Controls.Image image1 = ImageUtil.GetResourceImage(parent.Name); CanvasUtil.DrawImageInCircle(c, image1, UIManager.SUBMENU_DIAMETER, leftAreaX, leftAreaY); } else if (UIManager.FirstHandNumber != 0 && UIManager.FirstHand.IsSelected && !UIManager.inMenuSession) { if (!inSession) { UIManager.initialX = UIManager.FirstHand.X; UIManager.initialY = UIManager.FirstHand.Y; inSession = true; } System.Windows.Media.Brush primaryColor = ProfileManager.ActiveProfile.PrimaryColor; System.Windows.Media.Brush secondaryColor = ProfileManager.ActiveProfile.SecondaryColor; System.Windows.Media.Brush fill = ColorUtil.FromHTML("#88FFFFFF"); double centerX = UIManager.initialX; double centerY = UIManager.FirstHand.Y; double leftAreaX = UIManager.initialX - 1.25 * UIManager.SUBMENU_DIAMETER; double leftAreaY = UIManager.FirstHand.Y; double rightAreaX = UIManager.initialX + 1.25 * UIManager.SUBMENU_DIAMETER; double rightAreaY = UIManager.FirstHand.Y; if (UIManager.FirstHand.X > rightAreaX - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.X < rightAreaX + UIManager.SUBMENU_DIAMETER / 2 && selection == false) { rightSelected = true; selection = true; UIManager.ToNextPage(); } else if (UIManager.FirstHand.X > leftAreaX - UIManager.SUBMENU_DIAMETER / 2 && UIManager.FirstHand.X < leftAreaX + UIManager.SUBMENU_DIAMETER / 2 && selection == false) { leftSelected = true; selection = true; UIManager.ToPreviousPage(); } else if (UIManager.FirstHand.X > centerX - UIManager.MENU_DIAMETER / 2 && UIManager.FirstHand.X < centerX + UIManager.MENU_DIAMETER / 2) { selection = false; leftSelected = false; rightSelected = false; } CanvasUtil.DrawEllipse(c, centerX, centerY, UIManager.MENU_DIAMETER, UIManager.MENU_DIAMETER, primaryColor, fill, null); if (leftSelected) { CanvasUtil.DrawEllipse(c, leftAreaX, leftAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, secondaryColor, fill, Brushes.White); } else { CanvasUtil.DrawEllipse(c, leftAreaX, leftAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, secondaryColor, fill, null); } if (rightSelected) { CanvasUtil.DrawEllipse(c, rightAreaX, rightAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, secondaryColor, fill, Brushes.White); } else { CanvasUtil.DrawEllipse(c, rightAreaX, rightAreaY, UIManager.SUBMENU_DIAMETER, UIManager.SUBMENU_DIAMETER, secondaryColor, fill, null); } System.Windows.Controls.Image image0 = ImageUtil.GetResourceImage(((Group)this).Name); CanvasUtil.DrawImageInCircle(c, image0, UIManager.MENU_DIAMETER, centerX, centerY); System.Windows.Controls.Image image1 = ImageUtil.GetResourceImage("left"); CanvasUtil.DrawImageInCircle(c, image1, UIManager.SUBMENU_DIAMETER, leftAreaX, leftAreaY); System.Windows.Controls.Image image2 = ImageUtil.GetResourceImage("right"); CanvasUtil.DrawImageInCircle(c, image2, UIManager.SUBMENU_DIAMETER, rightAreaX, rightAreaY); } else { inSession = false; UIManager.inMenuSession = false; leftSelected = false; rightSelected = false; } }
public void DrawImage(Image image, RectangleF destRect, RectangleF srcRect, long transparentColor, int brightness, int contrast, int gamma, Color shadowColor, Stream imgData) { if (PointOutside.Check(ref srcRect)) { return; } if (PointOutside.Check(ref destRect)) { return; } if (image.Height <= 0 || image.Width <= 0) { return; } bool ChangedParams = brightness != FlxConsts.DefaultBrightness || contrast != FlxConsts.DefaultContrast || gamma != FlxConsts.DefaultGamma || shadowColor != Colors.Transparent; ImageAttributes imgAtt = null; try { if (transparentColor != FlxConsts.NoTransparentColor) { long cl = transparentColor; Color tcl = ColorUtil.FromArgb(0xFF, (byte)(cl & 0xFF), (byte)((cl & 0xFF00) >> 8), (byte)((cl & 0xFF0000) >> 16)); imgAtt = new ImageAttributes(); imgAtt.SetColorKey(tcl, tcl); } if (gamma != FlxConsts.DefaultGamma) { if (imgAtt == null) { imgAtt = new ImageAttributes(); } imgAtt.SetGamma((real)((UInt32)gamma) / 65536f); } if (!ChangedParams && srcRect.Top == 0 && srcRect.Left == 0 && srcRect.Width == image.Width && srcRect.Height == image.Height && imgAtt == null) { FCanvas.DrawImage(image, destRect); } else { Image FinalImage = image; try { if (image.RawFormat.Equals(ImageFormat.Wmf) || image.RawFormat.Equals(ImageFormat.Emf)) { FinalImage = FlgConsts.RasterizeWMF(image); //metafiles do not like cropping or changing attributes. } if (ChangedParams) { if (shadowColor != ColorUtil.Empty) { FlgConsts.MakeImageGray(ref imgAtt, shadowColor); } else { FlgConsts.AdjustImage(ref imgAtt, brightness, contrast); } } PointF[] ImageRect = new PointF[] { new PointF(destRect.Left, destRect.Top), new PointF(destRect.Right, destRect.Top), new PointF(destRect.Left, destRect.Bottom) }; FCanvas.DrawImage(FinalImage, ImageRect, srcRect, GraphicsUnit.Pixel, imgAtt); } finally { if (FinalImage != image) { FinalImage.Dispose(); } } } } finally { if (imgAtt != null) { imgAtt.Dispose(); } } }
private void blendColor(Color enemyColor) { Color blend = ColorUtil.getInstance().calculateBlend(spritesController.getColor(), enemyColor); spritesController.updateColor(blend); }
IEnumerator WaitScrollContent() { while (m_baseChara == null) { yield return(null); } yield return(null); IsViewScroll = true; while (LeaderSkillRect.sizeDelta.y == 0) { yield return(null); } ScrollBarViewHeight = ScrollViewRect.sizeDelta.y; float LeaderSkillHeight = LeaderSkillRect.sizeDelta.y; float LinkUnitInfoHeight = LinkUnitInfoRect.sizeDelta.y; while (LinkScrollRect.content.sizeDelta.y < (LeaderSkillHeight + LinkUnitInfoHeight)) { IsViewScroll = false; yield return(null); IsViewScroll = true; yield return(null); } if ((LeaderSkillHeight + LinkUnitInfoHeight) > ScrollBarViewHeight) { while (LinkScrollRect.verticalScrollbar.IsActive() == false) { yield return(null); } } /** * メインユニット情報 */ if (m_baseChara.m_CharaMasterDataParam != null) { baseUnitInfo.Name = m_baseChara.m_CharaMasterDataParam.name; baseUnitInfo.Rarity = (int)m_baseChara.m_CharaMasterDataParam.rare + 1; baseUnitInfo.MainRace = MainMenuUtil.GetTextKindSprite(m_baseChara.m_CharaMasterDataParam.kind, false); baseUnitInfo.IsViewSubRace = false; if (m_baseChara.m_CharaMasterDataParam.sub_kind != MasterDataDefineLabel.KindType.NONE) { baseUnitInfo.SubRace = MainMenuUtil.GetTextKindSprite(m_baseChara.m_CharaMasterDataParam.sub_kind, false); baseUnitInfo.IsViewSubRace = true; } baseUnitInfo.Element = MainMenuUtil.GetTextElementSprite(m_baseChara.m_CharaMasterDataParam.element); baseUnitInfo.ElementColor = ColorUtil.GetElementLabelColor(m_baseChara.m_CharaMasterDataParam.element); string levelFormat = GameTextUtil.GetText("unit_status17"); baseUnitInfo.Lv = string.Format(levelFormat, m_baseChara.m_CharaLevel, m_baseChara.m_CharaMasterDataParam.level_max); MasterDataSkillLimitBreak lb_skill = MasterFinder <MasterDataSkillLimitBreak> .Instance.Find((int)m_baseChara.m_CharaMasterDataParam.skill_limitbreak); baseUnitInfo.Slv = "-"; if (lb_skill != null) { baseUnitInfo.Slv = string.Format("{0}/{1}", m_baseChara.m_CharaLBSLv + 1, lb_skill.level_max + 1); } if (m_baseChara.m_CharaPlusHP != 0) { baseUnitInfo.Hp = string.Format(GameTextUtil.GetText("unit_status19"), m_baseChara.m_CharaHP, m_baseChara.m_CharaPlusHP); } else { baseUnitInfo.Hp = m_baseChara.m_CharaHP.ToString(); } if (m_baseChara.m_CharaPlusPow != 0) { baseUnitInfo.Atk = string.Format(GameTextUtil.GetText("unit_status19"), m_baseChara.m_CharaPow, m_baseChara.m_CharaPlusPow); } else { baseUnitInfo.Atk = m_baseChara.m_CharaPow.ToString(); } baseUnitInfo.Charm = string.Format(GameTextUtil.GetText("kyouka_text1"), m_baseChara.m_CharaCharm.ToString("F1")); } else { #if BUILD_TYPE_DEBUG baseUnitInfo.Name = "<color=#FF0000>No MasterDataParamChara fix_id:" + m_baseChara.m_CharaMasterDataParam.fix_id + "</color>"; #endif } ViewScrollAlpha = 1; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Saves the style information to the DB. /// </summary> /// <param name="style">The StStyle to save to.</param> /// <param name="existingStyle"><c>true</c> if the style exists; otherwise <c>false</c> /// </param> /// ------------------------------------------------------------------------------------ public void SaveToDB(IStStyle style, bool existingStyle) { Debug.Assert(IsValid); m_style = style; style.Name = m_name; style.Usage.UserDefaultWritingSystem = m_usage; style.Type = m_styleType; if (!IsBuiltIn) { // We need to update the context, structure, and function to be what the base // style is. We only want to do this for user styles so we don't override what // is set in the stylesheet. // Go down the inheritance chain until we find a value to be based on. BaseStyleInfo basedOn = RealBasedOnStyleInfo; if (!existingStyle) // Never change the context, etc. for an existing style { if (basedOn != null) { // If the based-on style cannot be inherited from, then this style must // be a copy of another style, from which it will have inherited its // context, structure, and function. if (basedOn.CanInheritFrom) { m_context = basedOn.Context; m_structure = basedOn.Structure; m_function = basedOn.Function; } } else if (IsParagraphStyle) { throw new ArgumentException("A user-defined paragraph style must have a real based-on style"); } } } style.Context = m_context; style.Structure = m_structure; style.Function = m_function; style.UserLevel = m_userLevel; style.IsModified = existingStyle; // Build the text props ITsPropsBldr styleProps = TsPropsBldrClass.Create(); if (m_defaultFontInfo.m_fontName.IsExplicit) { styleProps.SetStrPropValue((int)FwTextPropType.ktptFontFamily, m_defaultFontInfo.m_fontName.Value); } if (m_bulletInfo.IsExplicit) { m_bulletInfo.Value.ConvertAsTextProps(styleProps); } if (m_defaultFontInfo.m_bold.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, m_defaultFontInfo.m_bold.Value ? (int)FwTextToggleVal.kttvInvert : (int)FwTextToggleVal.kttvOff); } if (m_defaultFontInfo.m_italic.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptItalic, (int)FwTextPropVar.ktpvEnum, m_defaultFontInfo.m_italic.Value ? (int)FwTextToggleVal.kttvInvert : (int)FwTextToggleVal.kttvOff); } if (m_defaultFontInfo.m_superSub.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptSuperscript, 0, (int)m_defaultFontInfo.m_superSub.Value); } if (m_defaultFontInfo.m_fontSize.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptFontSize, 0, m_defaultFontInfo.m_fontSize.Value); } if (m_defaultFontInfo.m_fontColor.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptForeColor, 0, (int)ColorUtil.ConvertColorToBGR(m_defaultFontInfo.m_fontColor.Value)); } if (m_defaultFontInfo.m_backColor.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptBackColor, 0, (int)ColorUtil.ConvertColorToBGR(m_defaultFontInfo.m_backColor.Value)); } if (m_defaultFontInfo.m_offset.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptOffset, (int)FwTextPropVar.ktpvMilliPoint, m_defaultFontInfo.m_offset.Value); } if (m_defaultFontInfo.m_underline.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptUnderline, 0, (int)m_defaultFontInfo.m_underline.Value); } if (m_defaultFontInfo.m_underlineColor.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptUnderColor, 0, (int)ColorUtil.ConvertColorToBGR(m_defaultFontInfo.m_underlineColor.Value)); } if (m_defaultFontInfo.m_features.IsExplicit) { styleProps.SetStrPropValue((int)FwTextPropType.ktptFontVariations, m_defaultFontInfo.m_features.Value); } if (m_rtl.IsExplicit && m_rtl.Value != TriStateBool.triNotSet) { styleProps.SetIntPropValues((int)FwTextPropType.ktptRightToLeft, 0, (m_rtl.Value == TriStateBool.triTrue) ? 1 : 0); } if (m_alignment.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)m_alignment.Value); } if (m_spaceBefore.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptSpaceBefore, 0, m_spaceBefore.Value); } if (m_spaceAfter.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptSpaceAfter, 0, m_spaceAfter.Value); } if (m_firstLineIndent.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptFirstIndent, 0, m_firstLineIndent.Value); } if (m_leadingIndent.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptLeadingIndent, 0, m_leadingIndent.Value); } if (m_trailingIndent.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptTrailingIndent, 0, m_trailingIndent.Value); } if (m_lineSpacing.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptLineHeight, m_lineSpacing.Value.m_relative ? (int)FwTextPropVar.ktpvRelative : (int)FwTextPropVar.ktpvMilliPoint, m_lineSpacing.Value.m_lineHeight); } if (m_border.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptBorderTop, 0, m_border.Value.Top); styleProps.SetIntPropValues((int)FwTextPropType.ktptBorderBottom, 0, m_border.Value.Bottom); styleProps.SetIntPropValues((int)FwTextPropType.ktptBorderLeading, 0, m_border.Value.Leading); styleProps.SetIntPropValues((int)FwTextPropType.ktptBorderTrailing, 0, m_border.Value.Trailing); } if (m_borderColor.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptBorderColor, 0, (int)ColorUtil.ConvertColorToBGR(m_borderColor.Value)); } if (m_keepWithNext.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptKeepWithNext, 0, (m_keepWithNext.Value) ? 1 : 0); } if (m_keepTogether.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptKeepTogether, 0, (m_keepTogether.Value) ? 1 : 0); } if (m_widowOrphanControl.IsExplicit) { styleProps.SetIntPropValues((int)FwTextPropType.ktptWidowOrphanControl, 0, (m_widowOrphanControl.Value) ? 1 : 0); } SaveFontOverridesToDB(styleProps); style.Rules = styleProps.GetTextProps(); }
protected override void OnInitialized() { if (Day == MyChartType.Hourly) { _config = new LineConfig { Options = new LineOptions { Title = new OptionsTitle { Display = true, Text = Title + " Last Day" }, Responsive = true, Animation = new ArcAnimation { AnimateRotate = true, AnimateScale = true }, Scales = new Scales { xAxes = new List <CartesianAxis> { new TimeAxis { Distribution = TimeDistribution.Linear, Ticks = new TimeTicks { Source = TickSource.Auto, Reverse = true }, Time = new TimeOptions { Unit = TimeMeasurement.Hour, Round = TimeMeasurement.Second, TooltipFormat = "DD.MM.YYYY HH:mm:ss", DisplayFormats = TimeDisplayFormats.DE_CH }, ScaleLabel = new ScaleLabel { LabelString = "Time" } } } } } }; } else if (Day == MyChartType.Daily) { _config = new LineConfig { Options = new LineOptions { Title = new OptionsTitle { Display = true, Text = Title + " Last 2 Weeks" }, Responsive = true, Animation = new ArcAnimation { AnimateRotate = true, AnimateScale = true }, Scales = new Scales { xAxes = new List <CartesianAxis> { new TimeAxis { Distribution = TimeDistribution.Linear, Ticks = new TimeTicks { Source = TickSource.Auto, Reverse = true }, Time = new TimeOptions { Unit = TimeMeasurement.Day, Round = TimeMeasurement.Hour, TooltipFormat = "DD.MM.YYYY", DisplayFormats = TimeDisplayFormats.DE_CH }, ScaleLabel = new ScaleLabel { LabelString = "Date" } } } } } }; } else { _config = new LineConfig { Options = new LineOptions { Title = new OptionsTitle { Display = true, Text = Title + " Monthly" }, Responsive = true, Animation = new ArcAnimation { AnimateRotate = true, AnimateScale = true }, Scales = new Scales { xAxes = new List <CartesianAxis> { new TimeAxis { Distribution = TimeDistribution.Linear, Ticks = new TimeTicks { Source = TickSource.Auto, Reverse = true }, Time = new TimeOptions { Unit = TimeMeasurement.Month, Round = TimeMeasurement.Day, TooltipFormat = "DD.MM.YYYY", DisplayFormats = TimeDisplayFormats.DE_CH }, ScaleLabel = new ScaleLabel { LabelString = "Date" } } } } } }; } var Set = new LineDataset <TimeTuple <decimal> > { BackgroundColor = ColorUtil.FromDrawingColor(Color.Blue), BorderColor = ColorUtil.FromDrawingColor(Color.Blue), Fill = false, BorderWidth = 1, PointRadius = 5, PointBorderWidth = 1, SteppedLine = SteppedLine.False, ShowLine = true, Label = "Current" }; var PrevSet = new LineDataset <TimeTuple <decimal> > { BackgroundColor = ColorUtil.FromDrawingColor(Color.LightBlue), BorderDash = new int[] { 10, 5 }, BorderColor = ColorUtil.FromDrawingColor(Color.LightBlue), Fill = false, BorderWidth = 1, PointRadius = 3, PointBorderWidth = 1, SteppedLine = SteppedLine.False, ShowLine = true, Label = "Previous" }; for (int i = 0; i < Data.Count; i++) { var s = Labels[i]; var points = new TimeTuple <decimal>(new Moment(s), Convert.ToDecimal(Data[i])); Set.Add(points); } for (int i = 0; i < (Data.Count < PrevData.Count ? Data.Count : PrevData.Count); i++) { var s = Labels[i]; var points = new TimeTuple <decimal>(new Moment(s), Convert.ToDecimal(PrevData[i])); PrevSet.Add(points); } if (Labels.Count > 0) { DateTime dt = Labels.OrderByDescending(s => s.Date).FirstOrDefault(); Set.Label = dt.ToString("yyyy-MM-dd"); if (Day == MyChartType.Hourly) { PrevSet.Label = dt.AddDays(-1).ToString("yyyy-MM-dd"); } else if (Day == MyChartType.Daily) { PrevSet.Label = dt.AddDays(-14).ToString("yyyy-MM-dd"); } else { PrevSet.Label = "N/A"; PrevSet.Hidden = true; } } _config.Data.Datasets.Add(Set); _config.Data.Datasets.Add(PrevSet); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Saves the font overrides to the database. /// </summary> /// <param name="styleProps">The style props to write to</param> /// ------------------------------------------------------------------------------------ private void SaveFontOverridesToDB(ITsPropsBldr styleProps) { StringBuilder overridesString = new StringBuilder(); // JohnT: we MUST add writing system info to this string IN ORDER, sorted by // (unsigned) ws. List <int> wss = new List <int>(m_fontInfoOverrides.Keys); wss.Sort(CompareIntsAsUnsigned); foreach (int ws in wss) { FontInfo info = m_fontInfoOverrides[ws]; string fontName = null; List <IntPropInfo> intProps = new List <IntPropInfo>(); if (info.m_fontName.IsExplicit) { fontName = info.m_fontName.Value; } if (info.m_bold.IsExplicit) { intProps.Add(new IntPropInfo((int)FwTextPropType.ktptBold, info.m_bold.Value ? (int)FwTextToggleVal.kttvInvert : (int)FwTextToggleVal.kttvOff, (int)FwTextPropVar.ktpvEnum)); } if (info.m_italic.IsExplicit) { intProps.Add(new IntPropInfo((int)FwTextPropType.ktptItalic, info.m_italic.Value ? (int)FwTextToggleVal.kttvInvert : (int)FwTextToggleVal.kttvOff, (int)FwTextPropVar.ktpvEnum)); } if (info.m_superSub.IsExplicit) { intProps.Add(new IntPropInfo((int)FwTextPropType.ktptSuperscript, (int)info.m_superSub.Value, 0)); } if (info.m_fontSize.IsExplicit) { intProps.Add(new IntPropInfo((int)FwTextPropType.ktptFontSize, info.m_fontSize.Value, 0)); } if (info.m_fontColor.IsExplicit) { intProps.Add(new IntPropInfo((int)FwTextPropType.ktptForeColor, (int)ColorUtil.ConvertColorToBGR(info.m_fontColor.Value), 0)); } if (info.m_backColor.IsExplicit) { intProps.Add(new IntPropInfo((int)FwTextPropType.ktptBackColor, (int)ColorUtil.ConvertColorToBGR(info.m_backColor.Value), 0)); } if (info.m_offset.IsExplicit) { intProps.Add(new IntPropInfo((int)FwTextPropType.ktptOffset, info.m_offset.Value, (int)FwTextPropVar.ktpvMilliPoint)); } if (info.m_underline.IsExplicit) { intProps.Add(new IntPropInfo((int)FwTextPropType.ktptUnderline, (int)info.m_underline.Value, 0)); } if (info.m_underlineColor.IsExplicit) { intProps.Add(new IntPropInfo((int)FwTextPropType.ktptUnderColor, (int)ColorUtil.ConvertColorToBGR(info.m_underlineColor.Value), 0)); } // If anything was explicitly defined in this override, then save it if (fontName != null || intProps.Count != 0 || info.m_features.IsExplicit) { overridesString.Append(IntToString(ws)); if (fontName == null) { overridesString.Append(ShortToString((short)0)); } else { overridesString.Append(ShortToString((short)fontName.Length)); overridesString.Append(fontName); } if (info.m_features.IsExplicit) { overridesString.Append(ShortToString((short)-1)); // negative number indicates string property count overridesString.Append(ShortToString((short)FwTextPropType.ktptFontVariations)); string features = info.m_features.ValueIsSet && info.m_features.Value != null ? info.m_features.Value : ""; overridesString.Append(ShortToString((short)features.Length)); overridesString.Append(features); } overridesString.Append(ShortToString((short)intProps.Count)); foreach (IntPropInfo prop in intProps) { overridesString.Append(ShortToString((short)prop.m_textPropType)); overridesString.Append(ShortToString((short)prop.m_variant)); overridesString.Append(IntToString(prop.m_value)); } } } if (overridesString.Length != 0) { styleProps.SetStrPropValue((int)FwTextPropType.ktptWsStyle, overridesString.ToString()); } }
/// <summary> /// Connects a source with a destination and defines in which mode data is /// sent and received. /// </summary> /// <remarks> /// Note that render bitlength is enforced, i.e. even if the destination /// supports the "from" bitlength, it will be converted to the given "to" /// bitlength. /// </remarks> /// <param name="source">Source to subscribe to</param> /// <param name="dest">Destination to send the data to</param> /// <param name="from">Data format to read from source (incompatible source will throw exception)</param> /// <param name="to">Data forma to send to destination (incompatible destination will throw exception)</param> private void Connect(ISource source, IDestination dest, FrameFormat from, FrameFormat to) { var destFixedSize = dest as IFixedSizeDestination; var destGray2 = dest as IGray2Destination; var destGray4 = dest as IGray4Destination; var destRgb24 = dest as IRgb24Destination; var destBitmap = dest as IBitmapDestination; var destColoredGray2 = dest as IColoredGray2Destination; var destColoredGray4 = dest as IColoredGray4Destination; var scheduler = Scheduler.Default; Logger.Info("Connecting {0} to {1} ({2} => {3})", source.Name, dest.Name, from.ToString(), to.ToString()); switch (from) { // source is gray2: case FrameFormat.Gray2: var sourceGray2 = source as IGray2Source; switch (to) { // gray2 -> gray2 case FrameFormat.Gray2: AssertCompatibility(source, sourceGray2, dest, destGray2, from, to); _activeSources.Add(sourceGray2.GetGray2Frames() .Select(frame => TransformGray2(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destGray2.RenderGray2)); break; // gray2 -> gray4 case FrameFormat.Gray4: throw new NotImplementedException("Cannot convert from gray2 to gray4 (every gray4 destination should be able to do gray2 as well)."); // gray2 -> rgb24 case FrameFormat.Rgb24: AssertCompatibility(source, sourceGray2, dest, destRgb24, from, to); _activeSources.Add(sourceGray2.GetGray2Frames() .Select(frame => ColorizeGray2(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame)) .Select(frame => TransformRgb24(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destRgb24.RenderRgb24)); break; // gray2 -> bitmap case FrameFormat.Bitmap: AssertCompatibility(source, sourceGray2, dest, destBitmap, from, to); _activeSources.Add(sourceGray2.GetGray2Frames() .Select(frame => ImageUtil.ConvertFromRgb24( source.Dimensions.Value.Width, source.Dimensions.Value.Height, ColorizeGray2(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame) )) .Select(bmp => Transform(bmp, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destBitmap.RenderBitmap)); break; // gray2 -> colored gray2 case FrameFormat.ColoredGray2: throw new NotImplementedException("Cannot convert from gray2 to colored gray2 (doesn't make any sense, colored gray2 can also do gray2)."); // gray2 -> colored gray4 case FrameFormat.ColoredGray4: throw new NotImplementedException("Cannot convert from gray2 to colored gray2 (a colored gray4 destination should also be able to do gray2 directly)."); default: throw new ArgumentOutOfRangeException(nameof(to), to, null); } break; // source is gray4: case FrameFormat.Gray4: var sourceGray4 = source as IGray4Source; switch (to) { // gray4 -> gray2 case FrameFormat.Gray2: AssertCompatibility(source, sourceGray4, dest, destGray2, from, to); _activeSources.Add(sourceGray4.GetGray4Frames() .Select(frame => FrameUtil.ConvertGrayToGray(frame, new byte[] { 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x2, 0x2, 0x2, 0x2, 0x3, 0x3, 0x3, 0x3 })) .Select(frame => TransformGray2(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destGray2.RenderGray2)); break; // gray4 -> gray4 case FrameFormat.Gray4: AssertCompatibility(source, sourceGray4, dest, destGray4, from, to); _activeSources.Add(sourceGray4.GetGray4Frames() .Select(frame => TransformGray4(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destGray4.RenderGray4)); break; // gray4 -> rgb24 case FrameFormat.Rgb24: AssertCompatibility(source, sourceGray4, dest, destRgb24, from, to); _activeSources.Add(sourceGray4.GetGray4Frames() .Select(frame => ColorizeGray4(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame)) .Select(frame => TransformRgb24(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destRgb24.RenderRgb24)); break; // gray4 -> bitmap case FrameFormat.Bitmap: AssertCompatibility(source, sourceGray4, dest, destBitmap, from, to); _activeSources.Add(sourceGray4.GetGray4Frames() .Select(frame => ImageUtil.ConvertFromRgb24( source.Dimensions.Value.Width, source.Dimensions.Value.Height, ColorizeGray4(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame) )) .Select(bmp => Transform(bmp, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destBitmap.RenderBitmap)); break; // gray4 -> colored gray2 case FrameFormat.ColoredGray2: throw new NotImplementedException("Cannot convert from gray4 to colored gray2 (doesn't make any sense, colored gray2 can also do gray4)."); // gray4 -> colored gray4 case FrameFormat.ColoredGray4: throw new NotImplementedException("Cannot convert from gray2 to colored gray2 (doesn't make any sense, colored gray4 can also do gray4)."); default: throw new ArgumentOutOfRangeException(nameof(to), to, null); } break; // source is rgb24: case FrameFormat.Rgb24: var sourceRgb24 = source as IRgb24Source; switch (to) { // rgb24 -> gray2 case FrameFormat.Gray2: AssertCompatibility(source, sourceRgb24, dest, destGray2, from, to); _activeSources.Add(sourceRgb24.GetRgb24Frames() .Select(frame => ImageUtil.ConvertToGray(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, 4)) .Select(frame => TransformGray2(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destGray2.RenderGray2)); break; // rgb24 -> gray4 case FrameFormat.Gray4: AssertCompatibility(source, sourceRgb24, dest, destGray4, from, to); _activeSources.Add(sourceRgb24.GetRgb24Frames() .Select(frame => ImageUtil.ConvertToGray(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, 16)) .Select(frame => TransformGray4(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destGray4.RenderGray4)); break; // rgb24 -> rgb24 case FrameFormat.Rgb24: AssertCompatibility(source, sourceRgb24, dest, destRgb24, from, to); _activeSources.Add(sourceRgb24.GetRgb24Frames() .Select(frame => TransformRgb24(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destRgb24.RenderRgb24)); break; // rgb24 -> bitmap case FrameFormat.Bitmap: AssertCompatibility(source, sourceRgb24, dest, destBitmap, from, to); _activeSources.Add(sourceRgb24.GetRgb24Frames() .Select(frame => ImageUtil.ConvertFromRgb24(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame)) .Select(bmp => Transform(bmp, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destBitmap.RenderBitmap)); break; // rgb24 -> colored gray2 case FrameFormat.ColoredGray2: throw new NotImplementedException("Cannot convert from rgb24 to colored gray2 (colored gray2 only has 4 colors per frame)."); // rgb24 -> colored gray4 case FrameFormat.ColoredGray4: throw new NotImplementedException("Cannot convert from rgb24 to colored gray2 (colored gray4 only has 16 colors per frame)."); default: throw new ArgumentOutOfRangeException(nameof(to), to, null); } break; // source is bitmap: case FrameFormat.Bitmap: var sourceBitmap = source as IBitmapSource; switch (to) { // bitmap -> gray2 case FrameFormat.Gray2: AssertCompatibility(source, sourceBitmap, dest, destGray2, from, to); _activeSources.Add(sourceBitmap.GetBitmapFrames() .Select(bmp => ImageUtil.ConvertToGray2(bmp)) .Select(frame => TransformGray2(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destGray2.RenderGray2)); break; // bitmap -> gray4 case FrameFormat.Gray4: AssertCompatibility(source, sourceBitmap, dest, destGray4, from, to); _activeSources.Add(sourceBitmap.GetBitmapFrames() .Select(bmp => ImageUtil.ConvertToGray4(bmp)) .Select(frame => TransformGray4(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destGray4.RenderGray4)); break; // bitmap -> rgb24 case FrameFormat.Rgb24: AssertCompatibility(source, sourceBitmap, dest, destRgb24, from, to); _activeSources.Add(sourceBitmap.GetBitmapFrames() .Select(bmp => ImageUtil.ConvertToRgb24(bmp)) .Select(frame => TransformRgb24(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destRgb24.RenderRgb24)); break; // bitmap -> bitmap case FrameFormat.Bitmap: AssertCompatibility(Source, sourceBitmap, dest, destBitmap, from, to); _activeSources.Add(sourceBitmap.GetBitmapFrames() .Select(bmp => Transform(bmp, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destBitmap.RenderBitmap)); break; // bitmap -> colored gray2 case FrameFormat.ColoredGray2: throw new NotImplementedException("Cannot convert from bitmap to colored gray2 (colored gray2 only has 4 colors per frame)."); // bitmap -> colored gray4 case FrameFormat.ColoredGray4: throw new NotImplementedException("Cannot convert from bitmap to colored gray2 (colored gray4 only has 16 colors per frame)."); default: throw new ArgumentOutOfRangeException(nameof(to), to, null); } break; // source is colored gray2: case FrameFormat.ColoredGray2: var sourceColoredGray2 = source as IColoredGray2Source; switch (to) { // colored gray2 -> gray2 case FrameFormat.Gray2: AssertCompatibility(source, sourceColoredGray2, dest, destGray2, from, to); _activeSources.Add(sourceColoredGray2.GetColoredGray2Frames() .Select(x => FrameUtil.Join(source.Dimensions.Value.Width, source.Dimensions.Value.Height, x.Item1)) .Select(frame => TransformGray2(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destGray2.RenderGray2)); break; // colored gray2 -> gray4 case FrameFormat.Gray4: throw new NotImplementedException("Cannot convert from colored gray2 to gray4 (it's not like we can extract luminosity from the colors...)"); // colored gray2 -> rgb24 case FrameFormat.Rgb24: AssertCompatibility(source, sourceColoredGray2, dest, destRgb24, from, to); _activeSources.Add(sourceColoredGray2.GetColoredGray2Frames() .Select(x => ColorUtil.ColorizeFrame( source.Dimensions.Value.Width, source.Dimensions.Value.Height, FrameUtil.Join(source.Dimensions.Value.Width, source.Dimensions.Value.Height, x.Item1), x.Item2) ) .Select(frame => TransformRgb24(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destRgb24.RenderRgb24)); break; // colored gray2 -> bitmap case FrameFormat.Bitmap: AssertCompatibility(source, sourceColoredGray2, dest, destBitmap, from, to); _activeSources.Add(sourceColoredGray2.GetColoredGray2Frames() .Select(x => ColorUtil.ColorizeFrame( source.Dimensions.Value.Width, source.Dimensions.Value.Height, FrameUtil.Join(source.Dimensions.Value.Width, source.Dimensions.Value.Height, x.Item1), x.Item2) ) .Select(frame => ImageUtil.ConvertFromRgb24(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame)) .Select(bmp => Transform(bmp, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destBitmap.RenderBitmap)); break; // colored gray2 -> colored gray2 case FrameFormat.ColoredGray2: AssertCompatibility(source, sourceColoredGray2, dest, destColoredGray2, from, to); _activeSources.Add(sourceColoredGray2.GetColoredGray2Frames() .Select(x => TransformColoredGray2(source.Dimensions.Value.Width, source.Dimensions.Value.Height, x.Item1, x.Item2, destFixedSize)) .ObserveOn(scheduler) .Subscribe(x => destColoredGray2.RenderColoredGray2(x.Item1, x.Item2))); break; // colored gray2 -> colored gray4 case FrameFormat.ColoredGray4: throw new NotImplementedException("Cannot convert from colored gray2 to colored gray4 (if a destination can do colored gray4 it should be able to do colored gray2 directly)."); default: throw new ArgumentOutOfRangeException(nameof(to), to, null); } break; // source is colored gray4: case FrameFormat.ColoredGray4: var sourceColoredGray4 = source as IColoredGray4Source; switch (to) { // colored gray4 -> gray2 case FrameFormat.Gray2: AssertCompatibility(source, sourceColoredGray4, dest, destGray2, from, to); _activeSources.Add(sourceColoredGray4.GetColoredGray4Frames() .Select(x => FrameUtil.Join(source.Dimensions.Value.Width, source.Dimensions.Value.Height, x.Item1)) .Select(frame => FrameUtil.ConvertGrayToGray(frame, new byte[] { 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x2, 0x2, 0x2, 0x2, 0x3, 0x3, 0x3, 0x3 })) .Select(frame => TransformGray2(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destGray2.RenderGray2)); break; // colored gray4 -> gray4 case FrameFormat.Gray4: AssertCompatibility(source, sourceColoredGray4, dest, destGray4, from, to); _activeSources.Add(sourceColoredGray4.GetColoredGray4Frames() .Select(x => FrameUtil.Join(source.Dimensions.Value.Width, source.Dimensions.Value.Height, x.Item1)) .Select(frame => TransformGray2(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destGray4.RenderGray4)); break; // colored gray4 -> rgb24 case FrameFormat.Rgb24: AssertCompatibility(source, sourceColoredGray4, dest, destRgb24, from, to); _activeSources.Add(sourceColoredGray4.GetColoredGray4Frames() .Select(x => ColorUtil.ColorizeFrame( source.Dimensions.Value.Width, source.Dimensions.Value.Height, FrameUtil.Join(source.Dimensions.Value.Width, source.Dimensions.Value.Height, x.Item1), x.Item2) ) .Select(frame => TransformRgb24(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destRgb24.RenderRgb24)); break; // colored gray4 -> bitmap case FrameFormat.Bitmap: AssertCompatibility(source, sourceColoredGray4, dest, destBitmap, from, to); _activeSources.Add(sourceColoredGray4.GetColoredGray4Frames() .Select(x => ColorUtil.ColorizeFrame( source.Dimensions.Value.Width, source.Dimensions.Value.Height, FrameUtil.Join(source.Dimensions.Value.Width, source.Dimensions.Value.Height, x.Item1), x.Item2) ) .Select(frame => ImageUtil.ConvertFromRgb24(source.Dimensions.Value.Width, source.Dimensions.Value.Height, frame)) .Select(bmp => Transform(bmp, destFixedSize)) .ObserveOn(scheduler) .Subscribe(destBitmap.RenderBitmap)); break; // colored gray4 -> colored gray2 case FrameFormat.ColoredGray2: throw new NotImplementedException("Cannot convert from colored gray4 to colored gray2 (use rgb24 instead of down-coloring)."); // colored gray4 -> colored gray4 case FrameFormat.ColoredGray4: AssertCompatibility(source, sourceColoredGray4, dest, destColoredGray4, from, to); _activeSources.Add(sourceColoredGray4.GetColoredGray4Frames() .Select(x => TransformColoredGray4(source.Dimensions.Value.Width, source.Dimensions.Value.Height, x.Item1, x.Item2, destFixedSize)) .ObserveOn(scheduler) .Subscribe(x => destColoredGray4.RenderColoredGray4(x.Item1, x.Item2))); break; default: throw new ArgumentOutOfRangeException(nameof(to), to, null); } break; default: throw new ArgumentOutOfRangeException(); } }
protected List <IDestination> GetRenderers(BaseOptions options) { var renderers = new List <IDestination>(); switch (options.Destination) { case Auto: renderers = GetAvailableRenderers(options); break; case PinDMDv1: var pinDmd1 = PinDmd1.GetInstance(); if (pinDmd1.IsAvailable) { renderers.Add(pinDmd1); Logger.Info("Added PinDMDv1 renderer."); } else { throw new DeviceNotAvailableException(PinDMDv1.ToString()); } break; case PinDMDv2: var pinDmd2 = PinDmd2.GetInstance(); if (pinDmd2.IsAvailable) { renderers.Add(pinDmd2); Logger.Info("Added PinDMDv2 renderer."); } else { throw new DeviceNotAvailableException(PinDMDv2.ToString()); } break; case PinDMDv3: var pinDmd3 = PinDmd3.GetInstance(options.Port); if (pinDmd3.IsAvailable) { renderers.Add(pinDmd3); Logger.Info("Added PinDMDv3 renderer."); } else { throw new DeviceNotAvailableException(PinDMDv3.ToString()); } break; case PIN2DMD: var pin2Dmd = Pin2Dmd.GetInstance(); if (pin2Dmd.IsAvailable) { renderers.Add(pin2Dmd); Logger.Info("Added PIN2DMD renderer."); } else { throw new DeviceNotAvailableException(PIN2DMD.ToString()); } break; case Virtual: renderers.Add(ShowVirtualDmd(options)); Logger.Info("Added VirtualDMD renderer."); break; default: throw new ArgumentOutOfRangeException(); } if (renderers.Count == 0) { throw new NoRenderersAvailableException(); } if (!ColorUtil.IsColor(options.RenderColor)) { throw new InvalidOptionException("Argument --color must be a valid RGB color. Example: \"ff0000\"."); } foreach (var renderer in renderers) { var rgb24 = renderer as IRgb24Destination; rgb24?.SetColor(ColorUtil.ParseColor(options.RenderColor)); } _options = options; return(renderers); }
/// <summary> /// Sets the color with which a grayscale source is rendered on the RGB display. /// </summary> /// <param name="color">Rendered color</param> public void SetColor(Color color) { _gray2Colors = ColorUtil.GetPalette(new []{Colors.Black, color}, 4); _gray4Colors = ColorUtil.GetPalette(new []{Colors.Black, color}, 16); }
public override void StartClientSide(ICoreClientAPI api) { renderer = new PlacementRenderer(api); api.Event.RegisterRenderer(renderer, EnumRenderStage.Opaque); api.Input.RegisterHotKey("placementpreviewtoggle", "Toggle Placement Preview", GlKeys.Quote); api.Input.SetHotKeyHandler("placementpreviewtoggle", (a) => { VSHUDConfig config = api.ModLoader.GetModSystem <WaypointUtils>().Config; config.PRShow = !config.PRShow; api.ModLoader.GetModSystem <ConfigLoader>().SaveConfig(); return(true); }); api.RegisterCommand("pconfig", "Config Placement Preview System", "[enabled|tinted|tintcolorhex|tintcolorrgb|tintdefault|opacity]", (id, args) => { VSHUDConfig config = api.ModLoader.GetModSystem <WaypointUtils>().Config; string arg = args.PopWord(); bool?enabled; switch (arg) { case "enabled": enabled = args.PopBool(); config.PRShow = enabled ?? !config.PRShow; api.ShowChatMessage("Block preview set to " + config.PRShow); break; case "tinted": enabled = args.PopBool(); config.PRTint = enabled ?? !config.PRTint; api.ShowChatMessage("Block preview tinting set to " + config.PRTint); break; case "tintcolorhex": string col = args.PopWord(); if (col?[0] == '#') { var color = ColorUtil.Hex2Doubles(col); config.PRTintColor = new float[] { (float)(color[0]) * 10.0f, (float)(color[1]) * 10.0f, (float)(color[2]) * 10.0f, }; } break; case "opacity": config.PROpacity = args.PopFloat() ?? config.PROpacity; break; case "opacitydefault": config.PROpacity = new VSHUDConfig().PROpacity; break; case "tintcolorrgb": config.PRTintColor[0] = args.PopFloat() ?? config.PRTintColor[0]; config.PRTintColor[1] = args.PopFloat() ?? config.PRTintColor[1]; config.PRTintColor[2] = args.PopFloat() ?? config.PRTintColor[2]; break; case "tintdefault": config.PRTintColor = new VSHUDConfig().PRTintColor; break; default: break; } api.ModLoader.GetModSystem <ConfigLoader>().SaveConfig(); }); api.Event.LevelFinalize += () => api.Shader.ReloadShaders(); }
internal void DrawFocusCues() { if (!IsInATreeListView) { return; } if (TreeListView._Updating) { return; } if (TreeListView.HideSelection && !TreeListView.Focused) { return; } Graphics g = Graphics.FromHwnd(TreeListView.Handle); if (Visible) { Rectangle entireitemrect = GetBounds(ItemBoundsPortion.Entire); if (entireitemrect.Bottom > entireitemrect.Height * 1.5f) { Rectangle labelItemRect = GetBounds(ItemBoundsPortion.Label); Rectangle itemOnlyRect = GetBounds(ItemBoundsPortion.ItemOnly); Rectangle selectedItemRect = new Rectangle( labelItemRect.Left, labelItemRect.Top, TreeListView.FullRowSelect ? entireitemrect.Width - labelItemRect.Left - 1 : itemOnlyRect.Width - SystemInformation.SmallIconSize.Width - 1, labelItemRect.Height - 1); Pen pen = new Pen(TreeListView.Focused && Selected ? Color.Blue : ColorUtil.CalculateColor(System.Drawing.SystemColors.Highlight, System.Drawing.SystemColors.Window, 130)); for (int i = 1; i < TreeListView.Columns.Count; i++) { Rectangle rect = TreeListView.GetSubItemRect(Index, i); if (rect.X < selectedItemRect.X) { selectedItemRect = new Rectangle( rect.X, selectedItemRect.Y, selectedItemRect.Width + (selectedItemRect.X - rect.X), selectedItemRect.Height); } } g.DrawRectangle(new Pen(ColorUtil.VSNetSelectionColor), selectedItemRect); // Fill the item (in CommCtl V6, the selection area is not always the same : // label only or first column). I decided to always draw the entire column... if (!TreeListView.FullRowSelect) { g.FillRectangle(new SolidBrush(BackColor), itemOnlyRect.Right - 1, itemOnlyRect.Top, labelItemRect.Width - itemOnlyRect.Width + SystemInformation.SmallIconSize.Width + 1, selectedItemRect.Height + 1); } bool draw = true; if (PrevVisibleItem != null) { if (PrevVisibleItem.Selected) { draw = false; } } // Draw upper line if previous item is not selected if (draw) { g.DrawLine(pen, selectedItemRect.Left, selectedItemRect.Top, selectedItemRect.Right, selectedItemRect.Top); } g.DrawLine(pen, selectedItemRect.Left, selectedItemRect.Top, selectedItemRect.Left, selectedItemRect.Bottom); draw = true; if (NextVisibleItem != null) { if (NextVisibleItem.Selected) { draw = false; } } // Draw lower line if net item is not selected if (draw) { g.DrawLine(pen, selectedItemRect.Left, selectedItemRect.Bottom, selectedItemRect.Right, selectedItemRect.Bottom); } g.DrawLine(pen, selectedItemRect.Right, selectedItemRect.Top, selectedItemRect.Right, selectedItemRect.Bottom); // If FullRowSelect is false and multiselect is enabled, the items don't have the same width if (!TreeListView.FullRowSelect && NextVisibleItem != null) { if (NextVisibleItem.Selected) { int nextItemWidth = NextVisibleItem.GetBounds(TreeListViewItemBoundsPortion.ItemOnly).Width; if (nextItemWidth != itemOnlyRect.Width) { g.DrawLine( pen, selectedItemRect.Right, selectedItemRect.Bottom, selectedItemRect.Right - (itemOnlyRect.Width - nextItemWidth), selectedItemRect.Bottom); } } } pen.Dispose(); } } g.Dispose(); }
private void FilterTexture( Dictionary <string, List <Material> > slotMaterials, List <Texture2D> textures, Maid maid, string slotName, int materialIndex, string propName ) { Material material = null; Texture2D texture = null; { List <Material> materials; if (slotMaterials.TryGetValue(slotName, out materials) && materials != null) { material = materials.ElementAtOrDefault(materialIndex); if (material != null) { texture = material.GetTexture(propName) as Texture2D; } } } if (material == null || texture == null) { return; } FilterParam filterParam = Get(maid, slotName, material, propName); if (!filterParam.Dirty.Value) { return; } originalTextureCache.SetDirty(texture); filterParam.ClearDirtyFlag(); float outputBase = filterParam.OutputMin * 0.01f; float outputScale = (filterParam.OutputMax - filterParam.OutputMin) * 0.01f; float inputExp = Mathf.Log(filterParam.InputMid * 0.01f) / Mathf.Log(0.5f); float inputBase = (-filterParam.InputMin / (filterParam.InputMax - filterParam.InputMin)); float inputScale = 1f / ((filterParam.InputMax - filterParam.InputMin) * 0.01f); float hue = filterParam.Hue / 360f; float saturation = filterParam.Saturation / 100f; float lightness = filterParam.Lightness / 100f; Filter(texture, originalTextureCache.GetOriginalTexture(texture), (color) => { Color c = color; c.r = Mathf.Clamp01(c.r * inputScale + inputBase); c.g = Mathf.Clamp01(c.g * inputScale + inputBase); c.b = Mathf.Clamp01(c.b * inputScale + inputBase); c.r = Mathf.Pow(c.r, inputExp); c.g = Mathf.Pow(c.g, inputExp); c.b = Mathf.Pow(c.b, inputExp); Vector4 hsl = ColorUtil.ColorToHsl(c); hsl.x = (hsl.x + hue) % 1f; hsl.y *= saturation; hsl.z *= lightness; c = ColorUtil.HslToColor(hsl); c.r = c.r * outputScale + outputBase; c.g = c.g * outputScale + outputBase; c.b = c.b * outputScale + outputBase; return(c); }); }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); SetTheme(AppSettings.SetTabDarkTheme ? Resource.Style.MyTheme_Dark_Base : Resource.Style.MyTheme_Base); Methods.App.FullScreenApp(this, true); // Create your application here SetContentView(Resource.Layout.EditColorLayout); MAutoResizeEditText = (AutofitEdittext)FindViewById(Resource.Id.rEdittext); var mEmojiTypeFace = Typeface.CreateFromAsset(Assets, "emojione-android.ttf"); NewColorView = FindViewById <NiceArtEditorView>(Resource.Id.imgColorView); NewColorEditor = new NiceArtEditor.Builder(this, NewColorView, ContentResolver) .SetPinchTextScalable(true) // set false to disable pinch to zoom on text insertion.By default its true .SetDefaultEmojiTypeface(mEmojiTypeFace) // set default font TypeFace to add emojis .Build(); // build NiceArt Editor sdk NewColorEditor.SetOnNiceArtEditorListener(this); //Setup the color picker for text color AddTextColorPickerRecyclerView = FindViewById <RecyclerView>(Resource.Id.add_text_color_picker_recycler_view); FontTypeFaceRecyclerView = FindViewById <RecyclerView>(Resource.Id.fontTypeFace_recycler_view); //Color MColorFragment = new ColorFragment(NewColorEditor, this); LayoutManager = new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false); AddTextColorPickerRecyclerView.SetLayoutManager(LayoutManager); AddTextColorPickerRecyclerView.HasFixedSize = true; LayoutManagerTypeFace = new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false); FontTypeFaceRecyclerView.SetLayoutManager(LayoutManagerTypeFace); FontTypeFaceRecyclerView.HasFixedSize = true; ColorPickerAdapter = new ColorPickerAdapter(this, ColorType.ColorGradient, false); ColorPickerAdapter.ItemClick += ColorPickerAdapterOnItemClick; AddTextColorPickerRecyclerView.SetAdapter(ColorPickerAdapter); TypeFaceAdapter = new FontTypeFaceAdapter(this); TypeFaceAdapter.ItemClick += TypeFaceAdapterOnItemClick; FontTypeFaceRecyclerView.SetAdapter(TypeFaceAdapter); CloseImageView = FindViewById <ImageView>(Resource.Id.imgClose); SaveTextView = FindViewById <TextView>(Resource.Id.imgSave); ColorTextView = FindViewById <TextView>(Resource.Id.txtColor); SaveTextView.Tag = "Add"; SaveTextView.Text = GetText(Resource.String.Lbl_Add); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, ColorTextView, "\uf37b"); CloseImageView.Click += CloseImageViewOnClick; SaveTextView.Click += SaveTextViewOnClick; ColorTextView.Click += ColorTextViewOnClick; var point = Methods.App.OverrideGetSize(this); if (point != null) { Width = point.X; Height = point.Y; } int[] color = { Color.ParseColor("#6ec052"), Color.ParseColor("#28c4f3") }; var(gradient, bitmap) = ColorUtil.GetGradientDrawable(this, color, Width, Height); if (bitmap != null) { NewColorEditor.ClearAllViews(); NewColorView.GetSource().ClearColorFilter(); NewColorView.GetSource()?.SetImageBitmap(bitmap); } if ((int)Build.VERSION.SdkInt < 23) { if (!Directory.Exists(Methods.Path.FolderDiskNiceArt)) { Directory.CreateDirectory(Methods.Path.FolderDiskNiceArt); } } else { RequestPermissions(new[] { Manifest.Permission.ReadExternalStorage, Manifest.Permission.WriteExternalStorage }, 10); } AdsGoogle.Ad_RewardedVideo(this); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
protected override byte[] CaptureDMD() { // Initialize a new writeable bitmap to receive DMD pixels. var frame = new byte[DMDWidth * DMDHeight]; // Init DMD hack for Stern tables. InitSternDMD(_hProcess, false); // Check if a table is loaded.. var tableLoaded = new byte[1]; ReadProcessMemory(_hProcess, _gameStateAddr, tableLoaded, 1, IntPtr.Zero); // ..if not, return an empty frame (blank DMD). if (tableLoaded[0] == 0) { sternInit = false; // Reset Stern DMD hack state. return(frame); } // Table is loaded, reset Stern DMD hack. InitSternDMD(_hProcess, true); // Retrieve the DMD entrypoint from EAX registry (returned by our codecave). var eax = new byte[4]; ReadProcessMemory(_hProcess, _codeCave, eax, 4, IntPtr.Zero); // Now we have our DMD location in memory + little hack to re-align the DMD block. var dmdOffset = B4ToPointer(eax) - 0x1F406; // Grab the whole raw DMD block from game's memory. ReadProcessMemory(_hProcess, dmdOffset, RawDMD, MemBlockSize + 2, IntPtr.Zero); // Check the DMD CRC flag, skip the frame if the value is incorrect. if (RawDMD[0] != 0x02) { return(null); } // Used to parse pixel bytes of the DMD memory block, starting at 2 to skip the flag bytes. var rawPixelIndex = 2; var identical = true; // For each pixel on Y axis. for (var dmdY = 0; dmdY < DMDHeight; dmdY++) { // For each pixel on X axis. for (var dmdX = 0; dmdX < DMDWidth; dmdX++) { // RGB to BGR double hue, sat, lum; ColorUtil.RgbToHsl(RawDMD[rawPixelIndex], RawDMD[rawPixelIndex + 1], RawDMD[rawPixelIndex + 2], out hue, out sat, out lum); var pos = dmdY * DMDWidth + dmdX; byte pixel; // NoEx: how to check if it's stern? if (hasSpecialDMD(_hProcess)) { // from STERN, we get: [ 0, 0.0666666666666667, 0.135294117647059, 0.203921568627451, 0.272549019607843, 0.341176470588235, 0.409803921568627, 0.47843137254902 ] pixel = (byte)(lum * 15 * 2); } else { // from others, we get: [ 0, 0.366666666666667, 0.509803921568627, 0.605882352941176 ] pixel = (byte)(lum * 15 * 1.6); } if (pixel > 0 && pixel < 15) { pixel++; } if (!lums.Contains(lum)) { lums.Add(lum); Logger.Trace(String.Join(" ", lums.ToArray().OrderBy(l => l))); } // drop garbage frames if (pixel > 15) { return(null); } if (identical && (_lastFrame == null || _lastFrame[pos] == pixel)) { identical = false; } frame[pos] = pixel; // Each pixel takes 4 bytes of data in memory, advance 2 pixels. rawPixelIndex += 8; } // Jump to the next DMD line. rawPixelIndex += LineJump * 2 + DMDWidth * 8; } _lastFrame = frame; // Return the DMD bitmap we've created or null if frame was identical to previous. return(identical ? null : frame); }
/// <summary> /// This is the basic method needed for the view constructor. /// </summary> public override void Display(IVwEnv vwenv, int hvo, int frag) { switch (frag) { case VectorReferenceView.kfragTargetVector: // Check for an empty vector. if (hvo == 0 || m_cache.DomainDataByFlid.get_VecSize(hvo, m_flid) == 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault, (int)ColorUtil.ConvertColorToBGR(Color.Gray)); vwenv.set_IntProperty((int)FwTextPropType.ktptLeadingIndent, (int)FwTextPropVar.ktpvMilliPoint, 18000); vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvDefault, (int)TptEditable.ktptNotEditable); vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalRight); //vwenv.AddString(m_cache.MakeUserTss("Click to select -->")); if (hvo != 0) { vwenv.NoteDependency(new[] { hvo }, new[] { m_flid }, 1); } } else { if (!string.IsNullOrEmpty(TextStyle)) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, TextStyle); } vwenv.OpenParagraph(); vwenv.AddObjVec(m_flid, this, frag); vwenv.CloseParagraph(); } break; case VectorReferenceView.kfragTargetObj: // Display one object from the vector. { ILgWritingSystemFactory wsf = m_cache.WritingSystemFactory; vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvDefault, (int)TptEditable.ktptNotEditable); ITsString tss; ITsStrFactory tsf = m_cache.TsStrFactory; Debug.Assert(hvo != 0); #if USEBESTWS if (m_displayWs != null && m_displayWs.StartsWith("best")) { // The flid can be a variety of types, so deal with those. Debug.WriteLine("Using 'best ws': " + m_displayWs); int magicWsId = LgWritingSystem.GetMagicWsIdFromName(m_displayWs); int actualWS = m_cache.LanguageProject.ActualWs(magicWsId, hvo, m_flid); Debug.WriteLine("Actual ws: " + actualWS.ToString()); } else { #endif // Use reflection to get a prebuilt name if we can. Otherwise // settle for piecing together a string. Debug.Assert(m_cache != null); var obj = m_cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(hvo); Debug.Assert(obj != null); Type type = obj.GetType(); System.Reflection.PropertyInfo pi = type.GetProperty("TsName", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.FlattenHierarchy); if (pi != null) { tss = (ITsString)pi.GetValue(obj, null); } else { if (!string.IsNullOrEmpty(m_displayNameProperty)) { pi = type.GetProperty(m_displayNameProperty, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.FlattenHierarchy); } int ws = wsf.GetWsFromStr(obj.SortKeyWs); if (ws == 0) { ws = m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle; } if (pi != null) { object s = pi.GetValue(obj, null); if (s is ITsString) { tss = (ITsString)s; } else { tss = tsf.MakeString((string)s, ws); } } else { // ShortNameTss sometimes gets PropChanged, so worth letting the view know that's // what we're inserting. var flid = Cache.MetaDataCacheAccessor.GetFieldId2(obj.ClassID, "ShortNameTSS", true); vwenv.AddStringProp(flid, this); break; } #if USEBESTWS } #endif } if (!string.IsNullOrEmpty(TextStyle)) { vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle, TextStyle); } vwenv.AddString(tss); } break; default: throw new ArgumentException( "Don't know what to do with the given frag.", "frag"); } }
private REBARBANDINFO GetBandInfo(int index, Control currentBand) { bool placeHolder = false; Control band; if (currentBand != null) { placeHolder = true; band = currentBand; } else { band = bands[index]; } REBARBANDINFO rbbi = new REBARBANDINFO(); rbbi.cbSize = Marshal.SizeOf(typeof(REBARBANDINFO)); if (!IsCommonCtrl6()) { rbbi.fMask = (int)RebarInfoMask.RBBIM_COLORS; rbbi.clrBack = (int)ColorUtil.RGB(ColorUtil.VSNetControlColor); rbbi.clrFore = (int)ColorUtil.RGB(255, 0, 255); } rbbi.iImage = 0; rbbi.hbmBack = IntPtr.Zero; rbbi.lParam = 0; rbbi.cxHeader = 0; rbbi.fMask |= (int)RebarInfoMask.RBBIM_ID; rbbi.wID = index; if ((band.Text != null) && (band.Text != string.Empty)) { rbbi.fMask |= (int)RebarInfoMask.RBBIM_TEXT; rbbi.lpText = Marshal.StringToHGlobalAnsi(band.Text); rbbi.cch = (band.Text == null) ? 0 : band.Text.Length; } rbbi.fMask |= (int)RebarInfoMask.RBBIM_STYLE; rbbi.fStyle = (int)(RebarStylesEx.RBBS_CHILDEDGE | RebarStylesEx.RBBS_FIXEDBMP); if (placeHolder == false) { rbbi.fStyle |= (int)RebarStylesEx.RBBS_GRIPPERALWAYS; } ToolBarEx tb = (ToolBarEx)band; if (tb.UseNewRow == true) { rbbi.fStyle |= (int)(RebarStylesEx.RBBS_BREAK); } rbbi.fStyle |= (band is IChevron) ? (int)RebarStylesEx.RBBS_USECHEVRON : 0; rbbi.fMask |= (int)(RebarInfoMask.RBBIM_CHILD); rbbi.hwndChild = band.Handle; rbbi.fMask |= (int)(RebarInfoMask.RBBIM_CHILDSIZE); rbbi.cyMinChild = band.Height; rbbi.cxMinChild = 0; rbbi.cyChild = 0; rbbi.cyMaxChild = 0; rbbi.cyIntegral = 0; rbbi.fMask |= (int)(RebarInfoMask.RBBIM_SIZE); rbbi.cx = band.Width; rbbi.fMask |= (int)(RebarInfoMask.RBBIM_IDEALSIZE); rbbi.cxIdeal = band.Width; return(rbbi); }
/// <summary> /// 更新当前获取的颜色 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void colortimer_Tick(object sender, EventArgs e) { if (!stopDrawPreview && previewForm.MouseOnMe) { // 如果没有停止预览,并且鼠标在预览窗口上 // 就不取色,这是为了防止因循环取色导致过高的资源占用 return; } if (!settingLoaded) { // 不晓得为啥,在启动时加载Visible会被覆盖,所在放到这里来了 SwitchDisplayMode(Settings.Main.Display); settingLoaded = true; } // 如果光标位置不变,就不绘制了 if (MousePosition.Equals(lastPosition)) { return; } var color = ColorUtil.GetColor(MousePosition); // 如果颜色不变,就不绘制了 if (color.Equals(lastColor)) { return; } lastPosition = MousePosition; lastColor = color; colorBuffer.Clear(); var val = colorBuffer.AppendFormat("{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B).ToString(); lbHex.Tag = val; colorBuffer.Clear(); lbHex.Text = colorBuffer.AppendFormat("#{0}", lbHex.Tag).ToString(); colorBuffer.Clear(); val = colorBuffer.AppendFormat("{0},{1},{2}", color.R, color.G, color.B).ToString(); lbRgb.Tag = val; colorBuffer.Clear(); lbRgb.Text = colorBuffer.AppendFormat("RGB({0})", lbRgb.Tag).ToString(); colorBuffer.Clear(); if (trayMenuShowPreview.Checked && !stopDrawPreview) { DrawPreview(MousePosition); } if (FormatMode.Mini == currentFormatMode) { if (!lbColorPreview.Visible) { lbColorPreview.Show(); } lbColorPreview.BackColor = color; return; } if (lbColorPreview.Visible) { lbColorPreview.Hide(); } var contrastColor = ColorUtil.GetContrastColor(color); if (FormatMode.Standard == currentFormatMode) { lbRgb.BackColor = color; lbRgb.ForeColor = contrastColor; return; } if (lbRgb.BackColor != BackColor) { lbRgb.BackColor = BackColor; lbRgb.ForeColor = ForeColor; } // var hsl = HSL.Parse(color); var hsl = new HSL(color.GetHue(), color.GetSaturation(), color.GetBrightness()); lbHsl.Text = colorBuffer.AppendFormat("HSL({0},{1},{2})", Math.Round(hsl.H), Util.Round(hsl.S * 100), Util.Round(hsl.L * 100)).ToString(); colorBuffer.Clear(); var hsb = HSB.Parse(color); lbHsb.Text = colorBuffer.AppendFormat("HSB({0},{1},{2})", Math.Round(hsb.H), Util.Round(hsb.S * 100), Util.Round(hsb.B * 100)).ToString(); colorBuffer.Clear(); var hsi = HSI.Parse(color, currentHsiAlgorithm); lbHsi.Text = colorBuffer.AppendFormat("HSI({0},{1},{2})", Math.Round(hsi.H), Util.Round(hsi.S * 100), Util.Round(hsi.I * 100)).ToString(); colorBuffer.Clear(); pnExt.BackColor = color; pnExt.ForeColor = contrastColor; }
void initSoundsAndEffects() { capi = entity.Api as ICoreClientAPI; isSelf = capi.World.Player.Entity.EntityId == entity.EntityId; if (!isSelf) { return; } // Effects fogNoise = NormalizedSimplexNoise.FromDefaultOctaves(4, 1, 0.9, 123); rustParticles = new SimpleParticleProperties() { Color = ColorUtil.ToRgba(150, 50, 25, 15), ParticleModel = EnumParticleModel.Quad, MinSize = 0.1f, MaxSize = 0.5f, GravityEffect = 0, LifeLength = 2f, WithTerrainCollision = false, ShouldDieInLiquid = false, RandomVelocityChange = true, MinVelocity = new Vec3f(-1f, -1f, -1f), AddVelocity = new Vec3f(2f, 2f, 2f), MinQuantity = 1, AddQuantity = 0, }; rustParticles.AddVelocity = new Vec3f(0f, 30f, 0); rustParticles.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.QUADRATIC, -8); float b = 0.25f; capi.Ambient.CurrentModifiers["brownrainandfog"] = rainfogAmbient = new AmbientModifier() { AmbientColor = new WeightedFloatArray(new float[] { 0.5f * 132 / 255f, 0.5f * 115 / 255f, 0.5f * 112f / 255f, 1 }, 0), FogColor = new WeightedFloatArray(new float[] { b * 132 / 255f, b * 115 / 255f, b * 112f / 255f, 1 }, 0), FogDensity = new WeightedFloat(0.05f, 0), }.EnsurePopulated(); // Sounds tempStabSoundDrain = capi.World.LoadSound(new SoundParams() { Location = new AssetLocation("sounds/effect/tempstab-drain.ogg"), ShouldLoop = true, RelativePosition = true, DisposeOnFinish = false, SoundType = EnumSoundType.SoundGlitchunaffected, Volume = 0f }); tempStabSoundLow = capi.World.LoadSound(new SoundParams() { Location = new AssetLocation("sounds/effect/tempstab-low.ogg"), ShouldLoop = true, RelativePosition = true, DisposeOnFinish = false, SoundType = EnumSoundType.SoundGlitchunaffected, Volume = 0f }); tempStabSoundVeryLow = capi.World.LoadSound(new SoundParams() { Location = new AssetLocation("sounds/effect/tempstab-verylow.ogg"), ShouldLoop = true, RelativePosition = true, DisposeOnFinish = false, SoundType = EnumSoundType.SoundGlitchunaffected, Volume = 0f }); }