public Message(EndianBinaryReader reader) { m_textDataOffset = reader.ReadInt32(); m_messageId = reader.ReadInt16(); m_itemPrice = reader.ReadInt16(); m_nextMessageID = reader.ReadInt16(); m_unknownField3 = reader.ReadInt16(); m_textBoxType = (BoxTypes)reader.ReadByte(); m_initialDrawType = (DrawTypes)reader.ReadByte(); m_textBoxPosition = (BoxPositions)reader.ReadByte(); m_displayItemId = (ItemID)reader.ReadByte(); m_unknownBool1 = reader.ReadBoolean(); m_initialSound = reader.ReadByte(); m_initialCameraBehavior = reader.ReadByte(); m_initialSpeakerAnim = reader.ReadByte(); reader.SkipByte(); m_numLinesPerBox = reader.ReadInt16(); reader.SkipByte(); m_textData = ""; }
bool Draw_Real(Rect rect,DrawTypes d,string S) { if (ForceGUIChange==true){ ForceGUIChange = false; GUI.changed = true; } LastUsedRect = SU.AddRectVector(rect,ShaderUtil.GetGroupVector()); bool RetVal = false; Rect InitialRect = rect; Color oldCol = GUI.backgroundColor; ShaderColor OldVector = Vector; RetVal = UpdateToInput(false); if (d == DrawTypes.Type) { if (ImagePaths==null||ImagePaths.Length==0){ rect.height*=Mathf.Ceil((float)Names.Length/(float)TypeDispL); int oldType = Type; Type = GUI.SelectionGrid(rect,Type,Names,TypeDispL); if (Type!=oldType) RetVal = true; rect.y+=rect.height; rect.height+=20; SU.Label(rect,Descriptions[Type],12); } else { //GUI.backgroundColor = new Color(0,0,0,1); if (Type>=Names.Length) Type = 0; if (Type<0) Type = Names.Length-1; GUI.Box(rect,"",GUI.skin.button); if (Images==null)Images = new Texture2D[ImagePaths.Length]; if (Images[Type]==null)Images[Type] = EditorGUIUtility.Load("Shader Sandwich/"+ImagePaths[Type]) as Texture2D; if (ImagePaths[Type]!=""){ GUI.DrawTexture( rect ,Images[Type]); GUI.DrawTexture( rect ,Images[Type]); GUI.DrawTexture( rect ,Images[Type]); GUI.DrawTexture( rect ,Images[Type]); } rect.y+=rect.height-20; rect.height = 20; GUI.Box(rect,"",GUI.skin.button); GUI.skin.label.alignment = TextAnchor.UpperCenter; SU.Label(rect,Names[Type],12); GUI.skin.label.alignment = TextAnchor.UpperLeft; rect.y+=20;//rect.height; rect.height = 30; rect.width = 40; if(GUI.Button( rect ,ShaderSandwich.LeftArrow))Type-=1; rect.x+=InitialRect.width-40; if(GUI.Button( rect ,ShaderSandwich.RightArrow))Type+=1; if (Type>=Names.Length) Type = 0; if (Type<0) Type = Names.Length-1; } } else { if (S!="") { if (d != DrawTypes.Toggle) DrawGear(rect); GUI.backgroundColor = Color.white; SU.Label(rect,S,12); //UseInput = GUI.Toggle(new Rect(rect.x+120,rect.y+2,20,20),UseInput,""); rect.x+=LabelOffset; rect.width-=LabelOffset; } GUI.backgroundColor = Color.white; if (d == DrawTypes.Slider01){ GUI.backgroundColor = new Color(0.2f,0.2f,0.2f,1f); if (NoSlider==false){ //if (S!="") rect.width-=60-20; EditorGUI.BeginChangeCheck(); Float = GUI.HorizontalSlider (rect,Float, Range0, Range1); if (EditorGUI.EndChangeCheck()) EditorGUIUtility.editingTextField = false; //if (S!="") { //rect.width+=10; Float = EditorGUI.FloatField( new Rect(rect.x+rect.width+10,rect.y,30,20),Float,ShaderUtil.EditorFloatInput); } } else { rect.x-=5; rect.width+=6; EditorGUIUtility.labelWidth = 30; if (NoArrows) Float = EditorGUI.FloatField( rect,Float,ShaderUtil.EditorFloatInput); else Float = EditorGUI.FloatField( rect,"<>",Float,ShaderUtil.EditorFloatInput); EditorGUIUtility.labelWidth = 0; //GUI.Box(rect,""); } } if (d == DrawTypes.Color){ Vector = new ShaderColor(EditorGUI.ColorField (rect,Vector.ToColor())); if (!OldVector.Cmp(Vector)) RetVal = true; } if (d == DrawTypes.Texture){ if (Image==null) Image = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(ImageGUID),typeof(Texture2D)); Texture2D oldImage = Image; Image = (Texture2D) EditorGUI.ObjectField (rect,Image, typeof (Texture2D),false); ImageGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(Image)); if (oldImage!=Image) RetVal = true; } if (d == DrawTypes.Cubemap){ if (Cube==null) Cube = (Cubemap)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(CubeGUID),typeof(Cubemap)); Cubemap oldCube = Cube; Cube = (Cubemap) EditorGUI.ObjectField (rect,Cube, typeof (Cubemap),false); CubeGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(Cube)); if (oldCube!=Cube) RetVal = true; } if (d == DrawTypes.Toggle){ //Debug.Log("Toggle!"); rect.x-=30;//+=(rect.width-50); rect.width = 17; rect.height = 17; GUI.backgroundColor = new Color(0.2f,0.2f,0.2f,1f); GUIStyle ButtonStyle = new GUIStyle(GUI.skin.button); ButtonStyle.padding = new RectOffset(0,0,0,0); ButtonStyle.margin = new RectOffset(0,0,0,0); if (On) On = GUI.Toggle(rect,On,ShaderSandwich.Tick,ButtonStyle); else On = GUI.Toggle(rect,On,ShaderSandwich.Cross,ButtonStyle); //On = EditorGUI.Toggle (rect,On); } if (d == DrawTypes.ObjectArray){ if (Event.current.type == EventType.Repaint) GUI.skin.GetStyle("ObjectFieldThumb").Draw(rect, false, false, false,ObjFieldOn); if ((ObjField!=null)){ //GUIUtility.hotControl = 0; ObjFieldOn = true; } if (ShaderSandwich.GUIMouseDown&&(rect.Contains(Event.current.mousePosition))) ObjFieldOn = true; if (GUIUtility.hotControl != 0&&ObjField==null) ObjFieldOn = false; //GUI.skin.GetStyle("ObjectFieldThumb").Draw(rect, bool isHover, bool isActive, bool on, bool hasKeyboardFocus); Rect newRect = rect; newRect.width-=2; newRect.height-=2; newRect.y+=1; newRect.x+=1; if (Obj!=null) GUI.DrawTexture(newRect,ObjFieldImage[Selected]); rect.x+=rect.width-32; rect.width = 32; rect.y+=rect.height-8; rect.height = 8; if (GUI.Button(rect,"Select",GUI.skin.GetStyle("ObjectFieldThumbOverlay2"))){ if (RGBAMasks){ ObjField = ShaderObjectField.Show(this,"Select Mask (RGBA Masks Only!)",ObjFieldObject,ObjFieldImage,ObjFieldEnabled,Selected); ObjField.SomethingOtherThanAMask = true; } else ObjField = ShaderObjectField.Show(this,"Select Mask",ObjFieldObject,ObjFieldImage,ObjFieldEnabled,Selected); } } } UpdateToVar(); GUI.backgroundColor = oldCol; if (RetVal&&OnChange!=null) OnChange(); return RetVal; }
public bool Draw(Rect rect,string S,DrawTypes d) { return Draw_Real(rect,d,S); }
/// <summary> /// セットアップ /// </summary> private void _Settings() { // 画像の保存 newSave.Click += (s, e) => { using (var dlalog = new SaveFileDialog()) { // .jpg dlalog.Filter = "jpg files (*.jpg)|*.jpg"; if (DialogResult.OK == dlalog.ShowDialog()) { drawArea.BackgroundImage.Save(dlalog.FileName); } } }; // アプリの終了 closeApp.Click += (s, e) => { this.Dispose(); this.Close(); }; // 色指定 colorInfo.Click += (s, e) => { using (var dlalog = new ColorDialog()) { if (DialogResult.OK == dlalog.ShowDialog()) { _CurrentColor = dlalog.Color; } } }; // ツール設定 Action <DrawTypes> setTools = (types) => { _CurrentTool = types; status.Text = $"{_CurrentTool} を描画ツールとして設定しました。"; }; // 描画ツール指定:ペンモード pencil.Click += (s, e) => setTools(DrawTypes.Pencil); // 描画ツール指定:消しゴムモード eraser.Click += (s, e) => setTools(DrawTypes.Eraser); // 描画ツール指定:塗りつぶしモード fill.Click += (s, e) => setTools(DrawTypes.Fill); // 描画ツール指定:楕円モード circle.Click += (s, e) => setTools(DrawTypes.Circle); // 描画ツール指定:四角形モード rect.Click += (s, e) => setTools(DrawTypes.Rect); // 描画ツール指定:なし none.Click += (s, e) => setTools(DrawTypes.None); // 描画する線・図形:線の太さを指定 L1.Click += (s, e) => _SelectStroke = PencilStrokes.S1; L2.Click += (s, e) => _SelectStroke = PencilStrokes.S2; L3.Click += (s, e) => _SelectStroke = PencilStrokes.S3; L4.Click += (s, e) => _SelectStroke = PencilStrokes.S4; L5.Click += (s, e) => _SelectStroke = PencilStrokes.S5; L6.Click += (s, e) => _SelectStroke = PencilStrokes.S6; // 全消し allErase.Click += (s, e) => { using (var back = Graphics.FromImage(drawArea.BackgroundImage)) { back.Clear(Color.White); var front = drawArea.CreateGraphics(); front.CompositingMode = CompositingMode.SourceCopy; front.Clear(Color.White); } }; }
protected internal void Draw(PaintEventArgs paintEventArgs, DrawTypes drawType) { paintEventArgs.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; if (paintEventArgs != null) { // If the control is currently Disabled... Color borderColor; if (!this.Enabled) { // Let the user know borderColor = DisabledBorderColor; checkMarkColor = DisabledCheckmarkColor; checkBoxColor = DisabledCheckBoxBackgroundColor; backgroundColor = DisabledBackgroundColor; //separatorColor = DisabledSeparatorColor; } else { // either way... borderColor = BorderColor; } switch (drawType) { case DrawTypes.Border: if (confirmed) { if (buttonHasFocus) { using (Pen borderPen = new Pen(ConfirmedBorderColor, BorderThickness)) { borderPen.DashStyle = FocusedBorderStyle; paintEventArgs.Graphics.DrawRectangle( borderPen, 0, 0, this.Bounds.Width - BorderThickness, this.Bounds.Height - BorderThickness); } } else { using (Pen borderPen = new Pen(ConfirmedBorderColor, BorderThickness)) { borderPen.DashStyle = BorderStyle; paintEventArgs.Graphics.DrawRectangle( borderPen, 0, 0, this.Bounds.Width - BorderThickness, this.Bounds.Height - BorderThickness); } } } else { if (buttonHasFocus) { using (Pen borderPen = new Pen(borderColor, BorderThickness)) { borderPen.DashStyle = FocusedBorderStyle; paintEventArgs.Graphics.DrawRectangle( borderPen, 0, 0, this.Bounds.Width - BorderThickness, this.Bounds.Height - BorderThickness); } } else { using (Pen borderPen = new Pen(borderColor, BorderThickness)) { borderPen.DashStyle = BorderStyle; paintEventArgs.Graphics.DrawRectangle( borderPen, 0, 0, this.Bounds.Width - BorderThickness, this.Bounds.Height - BorderThickness); } } } break; case DrawTypes.Text: TextFormatFlags textFormatFlags = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis; if (RequiresConfirmation) { TextRenderer.DrawText( paintEventArgs.Graphics, this.Text, this.Font, new Rectangle( SeparatorDistance, 0, this.Bounds.Width - SeparatorDistance, this.Bounds.Height), this.ForeColor, textFormatFlags); } else { TextRenderer.DrawText( paintEventArgs.Graphics, this.Text, this.Font, new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height), this.ForeColor, textFormatFlags); } break; case DrawTypes.Checkmark: Color checkmarkColor; float thickness = 1.0f; if (this.SynchronizeCheckMarkWithBorderSettings) { checkmarkColor = this.BorderColor.IsEmpty ? this.ForeColor : this.BorderColor; thickness = this.BorderThickness; } else { checkmarkColor = this.CheckmarkColor.IsEmpty ? this.ForeColor : this.CheckmarkColor; thickness = CheckmarkThickness; } if (confirmed) { checkmarkColor = ConfirmedCheckmarkColor; thickness = CheckmarkThickness; } if (!this.Enabled) { checkmarkColor = DisabledCheckmarkColor; } paintEventArgs.Graphics.DrawLine( new Pen( checkmarkColor, thickness), 7, 15, 11, 18); paintEventArgs.Graphics.DrawLine( new Pen( checkmarkColor, thickness), 11, 18, 18, 10); checkmarkColor = Color.Empty; thickness = 1.0f; break; case DrawTypes.Image: break; case DrawTypes.Separator: if (confirmed) { paintEventArgs.Graphics.DrawLine( new Pen( ConfirmedBorderColor, BorderThickness ), SeparatorDistance, 0, SeparatorDistance, this.Bounds.Height ); } else { separatorColor = this.Enabled ? BorderColor : DisabledSeparatorColor; paintEventArgs.Graphics.DrawLine( new Pen( separatorColor, BorderThickness ), SeparatorDistance, 0, SeparatorDistance, this.Bounds.Height ); } break; case DrawTypes.CheckBoxFiller: Color color; if (StyleButtonSeparately) { if (mouseHasEntered) { color = CheckboxHighlightColor; } else if (mouseButtonIsDown) { color = CheckboxActiveColor; } else { color = CheckboxBackgroundColor; } if (!this.Enabled && !confirmed) { color = DisabledCheckBoxBackgroundColor; } using (SolidBrush brush = new SolidBrush(color)) { paintEventArgs.Graphics.FillRectangle( brush, 0, 0, SeparatorDistance, (this.Bounds.Height - 1) ); } } if (shouldFillCheckBoxArea) { color = this.Enabled ? ActiveColor : DisabledCheckBoxBackgroundColor; using (SolidBrush brush = new SolidBrush(color)) { paintEventArgs.Graphics.FillRectangle( brush, 0, 0, SeparatorDistance, this.Bounds.Height ); } shouldFillCheckBoxArea = false; } if (RequiresConfirmation && confirmed) { if (!ConfirmedCheckBoxBackgroundColor.IsEmpty) { using (SolidBrush brush = new SolidBrush(ConfirmedCheckBoxBackgroundColor)) { paintEventArgs.Graphics.FillRectangle( brush, 0, 0, SeparatorDistance, this.Bounds.Height ); } } } break; case DrawTypes.TexturedBackground: if (BackgroundTexture != null) { // Create a mapping of all image layout types to functions that generate rectangles for that type Dictionary <ImageLayout, Func <Rectangle> > LayoutMap = new Dictionary <ImageLayout, Func <Rectangle> >() { { ImageLayout.None, () => new Rectangle( new Point( (int)BorderThickness, (int)BorderThickness), new Size( BackgroundTexture.Width, BackgroundTexture.Height ) ) }, { ImageLayout.Stretch, () => new Rectangle( new Point( (int)BorderThickness, (int)BorderThickness), new Size( (Width - (int)BorderThickness), (Height - (int)BorderThickness) ) ) }, { ImageLayout.Tile, () => new Rectangle( new Point( (int)BorderThickness, (int)BorderThickness), new Size( (Width - (int)BorderThickness), (Height - (int)BorderThickness) ) ) }, { ImageLayout.Zoom, () => { throw new NotImplementedException("Zoom is not yet supported for the confirmation button."); } }, { ImageLayout.Center, () => { int xLocation = (Width / 2) - (BackgroundTexture.Width / 2) - ((int)BorderThickness * 2); int yLocation = (Height / 2) - (BackgroundTexture.Height / 2) - ((int)BorderThickness * 2); return(new Rectangle( new Point(xLocation, yLocation), new Size( BackgroundTexture.Width, BackgroundTexture.Height) )); } } }; // Attempt to get a rectangle generating function from the dictionary defined above. // Because the ImageLayout type is an enum, we don't need a default case (as the default case will be ImageLayout.None) Func <Rectangle> GenerateLayout; if (LayoutMap.TryGetValue(BackgroundTextureLayout, out GenerateLayout)) { // If the layout mode is anything other than tile, just draw the image: if (BackgroundTextureLayout != ImageLayout.Tile) { using (TextureBrush textureBrush = new TextureBrush(BackgroundTexture)) { paintEventArgs.Graphics.DrawImage(textureBrush.Image, GenerateLayout()); } } // Otherwise, use a tiling brush and fill the rectangle with the texture else { using (TextureBrush textureBrush = new TextureBrush(BackgroundTexture, WrapMode.Tile)) { paintEventArgs.Graphics.FillRectangle(textureBrush, GenerateLayout()); } } } } break; } } }