public void CopyPresentationFrom(Scriptable item, bool noOverwriteExisting) { // see Item if (HighlightStyle == null) { HighlightStyle = new HighlightStyleC(); } HighlightStyle.CopyFrom(item.HighlightStyle); if (!noOverwriteExisting || Sound == null) { Sound = item.Sound?.Clone(); } if (!noOverwriteExisting || string.IsNullOrEmpty(OutputText)) { OutputText = item.OutputText; } OutputAsDisplay = item.OutputAsDisplay; if (!noOverwriteExisting || string.IsNullOrEmpty(SpeechText)) { SpeechText = item.SpeechText; } SpeechAsDisplay = item.SpeechAsDisplay; if (!noOverwriteExisting || string.IsNullOrEmpty(PromptText)) { PromptText = item.PromptText; } }
public override bool IdenticalTo(StyleBase other) { HighlightStyleC highlight = (HighlightStyleC)other; return(LineColour.Equals(highlight.LineColour) && FillColour.Equals(highlight.FillColour) && TextColour.Equals(highlight.TextColour) && LineWidth == highlight.LineWidth); }
public override void CopyFrom(StyleBase other) { HighlightStyleC highlight = (HighlightStyleC)other; LineColour = highlight.LineColour; FillColour = highlight.FillColour; TextColour = highlight.TextColour; LineWidth = highlight.LineWidth; }
public static HighlightStyleC Read(DataReader reader) { HighlightStyleC newStyle = new HighlightStyleC(); newStyle.FillColour = reader.ReadColour(); newStyle.TextColour = reader.ReadColour(); newStyle.LineColour = reader.ReadColour(); newStyle.LineWidth = reader.ReadSingle(); if (newStyle.LineWidth < 0 || newStyle.LineWidth > 100) { throw new InvalidDataException("HighlightStyleC.Width out of bounds"); } return(newStyle); }
public override void Load(DataReader reader) { base.Load(reader); Element = (Shape)reader.ReadData(); if (Element != null) { Element.Parent = this; } SAWID = reader.ReadInt32(); Popup = reader.ReadBoolean(); Shown = reader.ReadBoolean(); AutoRepeat = reader.ReadBoolean(); NotVisited = reader.ReadBoolean(); if (reader.Version >= 123) { RepeatTimeout = reader.ReadInt32(); } for (int i = 0; i < Scripts.Length; i++) { if (reader.ReadBoolean()) { Scripts[i] = new Script(); Scripts[i].Read(reader); } } if (reader.Version < 129) { if (Element is Item item) { HighlightStyle = item.LoadedV7Data.HighlightStyle; Sound = item.LoadedV7Data.Sound; OutputText = item.LoadedV7Data.OutputText; OutputAsDisplay = item.LoadedV7Data.OutputAsDisplay; SpeechText = item.LoadedV7Data.SpeechText; SpeechAsDisplay = item.LoadedV7Data.SpeechAsDisplay; PromptText = item.LoadedV7Data.PromptText; } } else { HighlightStyle = HighlightStyleC.Read(reader); Sound = SharedReference <SharedResource> .FromGUID(reader.ReadGuid()); OutputText = reader.ReadBufferedString(); OutputAsDisplay = reader.ReadBoolean(); SpeechText = reader.ReadString(); SpeechAsDisplay = reader.ReadBoolean(); PromptText = reader.ReadString(); } }
internal override void Draw(Canvas gr, float scale, float coordScale, StaticView view, StaticView.InvalidationBuffer buffer, int fillAlpha = 255, int edgeAlpha = 255, bool reverseRenderOrder = false) { if (!Shown) { return; } HighlightStyleC actualStyles = null; if (State == ButtonShape.States.Highlight) { actualStyles = HighlightStyleC.FromShape(Element); HighlightStyle.ApplyToShape(Element); } Element.Draw(gr, scale, coordScale, view, buffer, fillAlpha, edgeAlpha, reverseRenderOrder); if (State == ButtonShape.States.Highlight) { actualStyles.ApplyToShape(Element); } }
/// <summary>Creates an instance initialised with the current (non-highlight) styles stored in a shape</summary> public static HighlightStyleC FromShape(Shape shape) { var highlight = new HighlightStyleC(); FillStyleC fill = (FillStyleC)shape.StyleObjectForParameter(Parameters.FillColour); if (fill != null) { highlight.FillColour = fill.Colour; } LineStyleC line = (LineStyleC)shape.StyleObjectForParameter(Parameters.LineColour); if (line != null) { highlight.LineColour = line.Colour; highlight.LineWidth = (line.Width + 1) / 2; } TextStyleC text = (TextStyleC)shape.StyleObjectForParameter(Parameters.TextColour); if (text != null) { highlight.TextColour = text.Colour; } return(highlight); }
public Scriptable() { HighlightStyle = new HighlightStyleC(); HighlightStyle.SetDefaults(); }