public static Point SetFirstPoint(Point point, Bitmap currentBitmap, PaintTool paintTool) { Point startPoint = point; currentBitmap.SetPixel(startPoint.X, startPoint.Y, paintTool.Color); return(point); }
private void Awake() { _mainCam = Camera.main; _activeTool = PaintTool.Cube; _invoker = FindObjectOfType <CommandInvoker>(); _invoker.CountChanged += UpdateUICounters; }
public PaintPresenter(IPaintForm paintForm, PaintTool paintTool, CanvasFactory canvasFactory, SaveControler saveControler, BitmapLoader bitmapLoader, Caretaker caretaker, OriginatorFactory originatorFactory) { _paintForm = paintForm; _paintCommand = PaintCommandFactory.GetPaintCommand(PaintToolType.Pencil); _paintForm.StartPaintAction += ExecuteStartPaintAction; _paintForm.StopPaintAction += ExecuteStopPaintAction; _paintForm.ToolAction += ExecuteToolAction; _paintForm.MovePaintAction += ExecuteMovePaintAction; _paintForm.ColorAction += ExecuteColorAction; _paintForm.SizePenAction += ExecuteSizePenAction; _paintForm.SizeChangeAction += ExecuteSizeChangeAction; _paintForm.SaveAction += ExecuteSaveAction; _paintForm.LoadAction += ExecuteLoadAction; _paintForm.RotateAction += ExecuteRotateAction; _paintForm.FlipAction += ExecuteFlipAction; _paintForm.UndoAction += ExecuteUndoAction; _paintForm.BrushAction += ExecuteBrushAction; _paintTool = paintTool; _saveControler = saveControler; _bitmapLoader = bitmapLoader; _currentCanvas = canvasFactory(400, 400); _temporaryCanvas = canvasFactory(400, 400); _caretaker = caretaker; _originator = originatorFactory(_currentCanvas.Bitmap, _currentCanvas.Width, _currentCanvas.Height); _originatorFactory = originatorFactory; }
void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = _mainCam.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hitInfo, Mathf.Infinity)) { PaintAt(hitInfo.point); } } else if (Input.GetKeyDown(KeyCode.Z)) { _invoker.Undo(); } else if (Input.GetKeyDown(KeyCode.R)) { _invoker.Redo(); } else if (Input.GetKeyDown(KeyCode.C)) { _activeTool = PaintTool.Cube; UpdateUIActiveTool(); } else if (Input.GetKeyDown(KeyCode.S)) { _activeTool = PaintTool.Sphere; UpdateUIActiveTool(); } else if (Input.GetKeyDown(KeyCode.Q)) { // CommandInvoker.AddCommand(new ResetCommand()); } }
public void Execute(ref Canvas canvas, PaintTool paintTool) { using (var graphics = Graphics.FromImage(canvas.Bitmap)) { graphics.DrawLine(paintTool.Pen, paintTool.StartPoint, paintTool.EndPoint); } }
private void SelectOtherTexture(SupportedTexture newTextureToBuildWith) { BuildTool buildTool = tools[0] as BuildTool; PaintTool paintTool = tools[2] as PaintTool; Texture newTexture; switch (newTextureToBuildWith) { case SupportedTexture.DIRT: newTexture = textures[0]; break; case SupportedTexture.SAND: newTexture = textures[1]; break; case SupportedTexture.STONE: newTexture = textures[2]; break; case SupportedTexture.COBBLESTONE: newTexture = textures[3]; break; case SupportedTexture.PLANKS_OAK: default: newTexture = textures[4]; break; } buildTool.currentTexture = newTexture; paintTool.texture = newTexture; Debug.Log("Selecting new texture: " + newTexture); }
private Color GetLineInfo(string info, out TextDanceTypes type) { Color color = fcolor; type = TextDanceTypes.Normal; if (info != "") { if (info.Contains(".")) { var infos = info.Split('.'); if (infos[0] == "") { color = fcolor; } else { color = PaintTool.GetTalkColor(infos[0]); } type = GetTextDance(infos[1]); } else //没有.必然是颜色 { color = PaintTool.GetTalkColor(info); } } return(color); }
private void UpdatePaintbrushToggles(bool playFX = true) { PaintLargeBrush.Toggle(false, playFX); PaintMediumBrush.Toggle(false, playFX); PaintSmallBrush.Toggle(false, playFX); // Large size paintbrush. if (PaintSize == 1) { PaintLargeBrush.Toggle(true, playFX); } // Medium size paintbrush. else if (PaintSize == 2) { PaintMediumBrush.Toggle(true, playFX); } // Otherwise small size paintbrush. else { PaintSmallBrush.Toggle(true, playFX); } if (ToolMgr.Instance.activeTool.tool == ToolTypes.Paint) { PaintTool paintTool = (PaintTool)ToolMgr.Instance.activeTool; paintTool.SelectedRadius = PaintSize; } }
public void Execute(ref Canvas canvas, PaintTool paintTool) { using (var graphics = Graphics.FromImage(canvas.Bitmap)) { _points.Insert(0, paintTool.StartPoint); _points.Add(paintTool.EndPoint); graphics.DrawLines(paintTool.Pen, _points.ToArray()); } }
public void Execute(ref Canvas canvas, PaintTool paintTool) { using (var graphics = Graphics.FromImage(canvas.Bitmap)) { _rectangle.Location = RectangleUtil.GetLocation(paintTool.StartPoint, paintTool.EndPoint); _rectangle.Size = RectangleUtil.GetSize(paintTool.StartPoint, paintTool.EndPoint); graphics.DrawRectangle(paintTool.Pen, _rectangle); } }
private void Start() { SelectedPaintTool = (PaintTool)PlayerPrefs.GetInt("TerrainEditor.SelectedPaintTool", (int)PaintTool.Raise_Or_Lower_Terrain); UpdatePaintToolVisibility(); if (m_paintToolSelector != null) { m_paintToolSelector.Init(this, this, Strong.PropertyInfo((TerrainEditor x) => x.SelectedPaintTool), null, m_localization.GetString("ID_RTTerrain_TerrainEditor_Tool", "Tool:"), null, null, null, false); } }
public override void OnEnable() { base.OnEnable(); _lastSave = DateTime.Now; DrawTool = new PaintTool(this, null); UnityInternal.AddGlobalEventHandler(GlobalInputHack); EditorApplication.hierarchyWindowChanged += OnHierachyChange; _drawTileSetWindow = new DrawTileSetWindow(this); _brushWindow = new BrushWindow(this); RefreshMaps(); var cameraGo = GameObject.Find("TilerCamera"); if (cameraGo == null) { cameraGo = EditorUtility.CreateGameObjectWithHideFlags("TilerCamera", (HideFlags)13, new[] { typeof(Camera) }); cameraGo.AddComponent<GUILayer>(); cameraGo.AddComponent<FlareLayer>(); UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(cameraGo, "Assets/Tiler/Editor/Windows/Main/Draw/DrawWindow.cs (78,13)", "HaloLayer"); } _camera = cameraGo.GetComponent<Camera>(); _camera.enabled = false; _height = Mathf.Log(16); _camera.transform.eulerAngles = new Vector3(90, 0, 0); SetCameraHeight(); var lightGo = GameObject.Find("TilerLight"); // ReSharper disable ConvertIfStatementToNullCoalescingExpression if (lightGo == null) // ReSharper restore ConvertIfStatementToNullCoalescingExpression lightGo = EditorUtility.CreateGameObjectWithHideFlags("TilerLight", (HideFlags) 13, new[] {typeof (Light)}); _light = lightGo.GetComponent<Light>(); _light.type = LightType.Directional; _light.intensity = 0.5f; _light.enabled = false; var textGo = GameObject.Find("TilerText"); if (textGo == null) { textGo = EditorUtility.CreateGameObjectWithHideFlags("TilerText", (HideFlags) 13, new[] {typeof (GUIText)}); textGo.transform.position = new Vector3(0.5f, 1, 0); } _text = textGo.GetComponent<GUIText>(); _text.anchor = TextAnchor.UpperCenter; _text.alignment = TextAlignment.Center; //_text.font.material.color = Color.white; //_text.text = "Remember to save. Last save more than 10 minutes ago."; _text.enabled = false; }
public void Execute(ref Canvas canvas, PaintTool paintTool) { using (var graphics = Graphics.FromImage(canvas.Bitmap)) { var pen = new Pen(Color.White, paintTool.Pen.Width); _points.Add(paintTool.EndPoint); _points.Add(paintTool.EndPoint); graphics.DrawLines(pen, _points.ToArray()); } }
// Use this for initialization void Awake() { if(mInstance != null) { Destroy(this); } else { mInstance = this; } }
public void Execute(ref Canvas canvas, PaintTool paintTool) { using (var graphics = Graphics.FromImage(canvas.Bitmap)) { _rec.Add(paintTool.EndPoint); foreach (var point in _rec) { Rectangle rectangle = new Rectangle(point.X, point.Y, 10, 10); graphics.FillEllipse(paintTool.Brush, rectangle); } } }
private void ToolsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if ((sender as ComboBox).SelectedIndex == 0) { paintTool = PaintTool.Pen; PaintCanvas.EditingMode = InkCanvasEditingMode.Ink; } if ((sender as ComboBox).SelectedIndex == 1) { paintTool = PaintTool.Eraser; PaintCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint; } }
private void GlobalInputHack() { Event e = Event.current; if (e.type == EventType.KeyDown) { if (e.keyCode == KeyCode.D) { DrawTool.GetBrush().Rotate(); Parent.Repaint(); Repaint(); } if (e.keyCode == KeyCode.Alpha1) { DrawTool = new PaintTool(this, DrawTool.GetBrush()); Repaint(); } if (e.keyCode == KeyCode.Alpha2) { DrawTool = new FillTool(this, DrawTool.GetBrush() as NormalBrush); Repaint(); } if (e.keyCode == KeyCode.Alpha3) { DrawTool = new ReplaceTool(this, DrawTool.GetBrush() as NormalBrush); Repaint(); } var brush = DrawTool.GetBrush(); if (DrawTool is PaintTool && brush is NormalBrush) { if (e.keyCode == KeyCode.A) { //_brushWindow.BrushSizeAdd(-1); } if (e.keyCode == KeyCode.S) { //_brushWindow.BrushSizeAdd(1); } } if (e.keyCode == KeyCode.Alpha3) { _drawTileSetWindow.SetBrush(-1); } } }
public PictionaryForm(ClientManager client) { InitializeComponent(); ColorComboBox.SelectedIndex = 7; linePointsX = new List <double>(); linePointsY = new List <double>(); clientManager = client; newLine = true; paintTool = PaintTool.Pen; penColor = Colors.Black; ColorComboBox.ItemsSource = typeof(Colors).GetProperties(); ChatBox.Foreground = new SolidColorBrush(Colors.Gray); PaintCanvas.DefaultDrawingAttributes.Width = 2; ChatBox.AppendText("Welcome to Pictionary!"); }
public static void DrawBase(Graphics g, int cid, int x, int y, int width, int height) { int xDiff = width / 15; int yDiff = height / 15; Image img = GetCardImage(cid, width, height); var cardData = CardConfigManager.GetCardConfig(cid); int attr = cardData.Attr;//属性决定包边颜色 g.FillRectangle(PaintTool.GetBrushByAttribute(attr), x + 1, y + 1, width - 2, height - 2); g.DrawImage(img, x + 2 + xDiff, y + 2 + yDiff, width - 4 - xDiff * 2, height - 4 - yDiff * 2); string cardBorder = GetCardBorder(cardData); var imgBack = PicLoader.Read("Border", cardBorder); g.DrawImage(imgBack, x + 2, y + 2, width - 4, height - 4); imgBack.Dispose(); }
internal override void Draw(Graphics g) { int xOff = position.X - 10; if (damage.Dtype == DamageTypes.Magic) { xOff -= 16; g.DrawImage(HSIcons.GetIconsByEName("atr" + damage.Element), xOff, position.Y + 8, 18, 18); xOff += 16; color = PaintTool.GetColorByAttribute(damage.Element); } Brush brush = new SolidBrush(color); g.DrawString(word, font, brush, xOff, position.Y); brush.Dispose(); }
public override void OnGotFocus() { base.OnGotFocus(); CustomizationController.instance.cameraController.navigationEnabled = false; isActive = true; if (dontReload) { dontReload = false; return; } RagdollCustomization activeCustomization = CustomizationController.instance.activeCustomization; cameraController = CustomizationController.instance.cameraController; paint = GetComponent <PaintTool>(); paint.Initialize(activeCustomization); cursor.Initialize(); picker.Initialize(); cursor.color = (paint.color = (colorPalette.color = color)); cursor.cursorKernel = (paint.cursorKernel = cursorKernel); cursor.cursorFalloff = (paint.cursorFalloff = cursorFalloff); maskVisible = false; maskPanel.gameObject.SetActive(maskVisible); ShowMask(show: true); }
private void MouseEvents() { var e = Event.current; var rect = Parent.position; rect.x += 2; rect.y += ToolbarHeight + 2; rect.width -= RightWidth + 4; rect.height -= ToolbarHeight + 4; var mousePos = GUIUtility.GUIToScreenPoint(e.mousePosition); if (!rect.Contains(mousePos)) { return; } // Left mouse button events if (Event.current.button == 0 && !NoRightMouseAltInput()) { if (e.type == EventType.MouseDown) { TilerMapEditFunctions.Undo.NewUndo(); Paint(); _lastPlaced = _currentPoint; _isPainting = true; } if (e.type == EventType.MouseDrag) { if (_isPainting && _lastPlaced != _currentPoint) { Paint(); _lastPlaced = _currentPoint; } } } // Right mouse button events if (Event.current.button == 1 || NoRightMouseAltInput()) { if (e.type == EventType.MouseDown) { _isDraggingCopy = true; _startCopyPoint = _currentPoint; } if (e.type == EventType.MouseUp) { if (_isDraggingCopy) { var properties = new List<Brush>(); var start = new Point { X = Math.Min(_currentPoint.X, _startCopyPoint.X), Y = Math.Min(_currentPoint.Y, _startCopyPoint.Y) }; var count = new Point { X = Math.Abs(_currentPoint.X - _startCopyPoint.X) + 1, Y = Math.Abs(_currentPoint.Y - _startCopyPoint.Y) + 1 }; for (var y = start.Y; y < start.Y + count.Y; y++) { for (var x = start.X; x < start.X + count.X; x++) { var p = new Point(x, y); properties.Add(TilerMap.GetTileBrush(p)); } } var copy = new CopyBrush(properties.ToArray(), new Point(count.X, count.Y)); if (DrawTool is PaintTool) { DrawTool.SetBrush(copy); } else { DrawTool = new PaintTool(this, copy); } Repaint(); _isDraggingCopy = false; } } } if (e.type == EventType.MouseDrag) { if (Event.current.button == 2) { PanWindow(); Repaint(); } } else if (e.type == EventType.scrollWheel) { _height += Event.current.delta.y / 10f; _height = Mathf.Clamp(_height, -1, 5); SetCameraHeight(); Repaint(); } if (e.type == EventType.MouseDrag || e.type == EventType.MouseMove || e.type == EventType.scrollWheel) GetGridPoint(); }
public override void ToolBar() { base.ToolBar(); GUILayout.Box("Misc", EditorStyles.toolbarDropDown); Rect miscRect = GUILayoutUtility.GetLastRect(); if (MyGUI.ButtonMouseDown(miscRect)) { var misc = PopupWindow.ShowAtPosition<MiscPopup>(new Rect(miscRect.x, miscRect.y + miscRect.height, 120f, 60)); misc.Setup(TilerMap); } EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); GUI.enabled = TilerMapEditFunctions.Undo.IsUndo(); if (GUILayout.Button("<", EditorStyles.toolbarButton)) { TilerMapEditFunctions.Undo.PerformUndo(); Repaint(); } GUI.enabled = TilerMapEditFunctions.Undo.IsRedo(); if (GUILayout.Button(">", EditorStyles.toolbarButton)) { TilerMapEditFunctions.Undo.PerformRedo(); Repaint(); } GUI.enabled = true; EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); if (MyGUI.HasToggledPositive(DrawTool is PaintTool, "P", EditorStyles.toolbarButton)) { DrawTool = new PaintTool(this, DrawTool.GetBrush() as NormalBrush); Repaint(); } if (MyGUI.HasToggledPositive(DrawTool is FillTool, "F", EditorStyles.toolbarButton)) { DrawTool = new FillTool(this, DrawTool.GetBrush() as NormalBrush); Repaint(); } if (MyGUI.HasToggledPositive(DrawTool is ReplaceTool, "R", EditorStyles.toolbarButton)) { DrawTool = new ReplaceTool(this, DrawTool.GetBrush() as NormalBrush); Repaint(); } EditorGUILayout.Space(); if (GUILayout.Button("O", EditorStyles.toolbarButton)) { var p = _camera.transform.position; p.x = 0; p.z = 0; _camera.transform.position = p; } EditorGUILayout.Space(); //var currentIndex = _mapIndex; //_mapIndex = EditorGUILayout.Popup(_mapIndex, _mapNames, EditorStyles.toolbarPopup); //options = new[] { "CanJump", "CanShoot", "CanSwim" }; //flags = EditorGUILayout.MaskField("Layers", 1, options, EditorStyles.toolbarPopup); GUILayout.Box("Layers", EditorStyles.toolbarDropDown); Rect last = GUILayoutUtility.GetLastRect(); if (MyGUI.ButtonMouseDown(last)) { var height = 20*_tilerMaps.Count + 20;// +25; var lp = PopupWindow.ShowAtPosition<LayerPopup>(new Rect(last.x, last.y + last.height, 150f, height)); lp.Setup(_mapIndex, _mapMask, _tilerMaps, SetMapChange, SetMapMask, Save); GUIUtility.ExitGUI(); } /*if (currentIndex != _mapIndex) { Save(); SetMap(_mapIndex); }*/ }
private void ChangeMouseCursor(PaintTool Brush) { Stream cursor_stream; switch (Brush) { case PaintTool.Eraser: cursor_stream = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.EraserCursor.cur")); this.Cursor = new Cursor(cursor_stream); break; case PaintTool.Walk: cursor_stream = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.WalkCursor.cur")); this.Cursor = new Cursor(cursor_stream); break; case PaintTool.Fill: cursor_stream = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.BucketCursor.cur")); this.Cursor = new Cursor(cursor_stream); break; case PaintTool.Brush: this.Cursor = Cursors.Cross; break; case PaintTool.MarqueeBrush: cursor_stream = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.MarqueeCursor.cur")); this.Cursor = new Cursor(cursor_stream); break; case PaintTool.MarqueeEraser: cursor_stream = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.MarqueeEraser.cur")); this.Cursor = new Cursor(cursor_stream); break; case PaintTool.MarqueeWalk: cursor_stream = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.curMarqueeWalk.cur")); this.Cursor = new Cursor(cursor_stream); break; case PaintTool.MarqueeTerrain: cursor_stream = (assembly.GetManifestResourceStream("XNA_Map_Editor.Resources.MarqueeTerrain.cur")); this.Cursor = new Cursor(cursor_stream); break; default: this.Cursor = Cursors.Arrow; break; } }
void OnDestroy() { if(mInstance == this) { mInstance = null; } }
public void DrawPaintTools() { // Tools GUI.Label(new Rect(10, 35, 50, 20), "Tools", EditorStyles.miniLabel); if (GUI.Toggle(new Rect(10, 50, 32, 32), currentTool == PaintTool.Free, new GUIContent(moveToolTex, "Free Move (A)"), EditorStyles.miniButtonLeft) && currentTool != PaintTool.Free) { currentTool = PaintTool.Free; SelectLayer(SortingLayer.All); } // Draw-Switch tool if (GUI.Button(new Rect(44, 38, 28, 14), "v")) { SelectTool(PaintTool.Draw); fillRectMode = !fillRectMode; } if (GUI.Toggle(new Rect(42, 50, 32, 32), currentTool == PaintTool.Draw, new GUIContent(fillRectMode ? rectFillTex : penToolTex, "Draw (D) / Rectangle (R)"), EditorStyles.miniButtonMid) && currentTool != PaintTool.Draw) { SelectTool(PaintTool.Draw); } if (GUI.Toggle(new Rect(72, 50, 32, 32), currentTool == PaintTool.Flood, new GUIContent(floodToolTex, "Flood (F)"), EditorStyles.miniButtonMid) && currentTool != PaintTool.Flood) { SelectTool(PaintTool.Flood); } // Draw-Switch tool if (GUI.Button(new Rect(106, 38, 28, 14), "v")) { SelectTool(PaintTool.Erase); eraseAllLayersMode = !eraseAllLayersMode; } if (GUI.Toggle(new Rect(104, 50, 32, 32), currentTool == PaintTool.Erase, new GUIContent(eraseAllLayersMode ? superEraseToolTex : eraseToolTex, "Erase (E)/Super (S)"), EditorStyles.miniButtonMid) && currentTool != PaintTool.Erase) { SelectTool(PaintTool.Erase); } if (GUI.Toggle(new Rect(136, 50, 32, 32), currentTool == PaintTool.Collision, new GUIContent(collisionToolTex, "Collision (C)"), EditorStyles.miniButtonRight) && currentTool != PaintTool.Collision) { SelectTool(PaintTool.Collision); } // Layers if (currentTool == PaintTool.Draw || currentTool == PaintTool.Erase || currentTool == PaintTool.Flood) { GUI.Label(new Rect(172, 35, 50, 20), "Layer", EditorStyles.miniLabel); if (GUI.Toggle(new Rect(172, 50, 26, 32), currentLayer == 1, "1", EditorStyles.miniButtonLeft) && currentLayer != 1) { currentLayer = 1; SelectLayer(SortingLayer.Background); } if (GUI.Toggle(new Rect(198, 50, 26, 32), currentLayer == 2, "2", EditorStyles.miniButtonMid) && currentLayer != 2) { currentLayer = 2; SelectLayer(SortingLayer.Midground); } if (GUI.Toggle(new Rect(224, 50, 26, 32), currentLayer == 3, "3", EditorStyles.miniButtonRight) && currentLayer != 3) { currentLayer = 3; SelectLayer(SortingLayer.Foreground); } } else if(currentTool == PaintTool.Collision) { // Collision Tools GUI.Label(new Rect(172, 35, 50, 20), "Collision", EditorStyles.miniLabel); if (GUI.Button(new Rect(172, 50, 30, 32), "L" + currentCollisionLayer.ToString(), EditorStyles.miniButtonLeft) ) { ++currentCollisionLayer; if (currentCollisionLayer > maxCollisionLayers) currentCollisionLayer = 0; } if (GUI.Button(new Rect(202, 50, 36, 32), "x" + colliderSizeMultiplier.ToString(), EditorStyles.miniButtonRight)) { colliderSizeMultiplier += colliderScaleSteps; if (colliderSizeMultiplier > maxScaleColliders) colliderSizeMultiplier = 0.5f; SceneView.RepaintAll(); } } }
private void LifeClock_Paint(object sender, PaintEventArgs e) { if (back == null)//在editor模式下就不绘制了 { return; } e.Graphics.DrawImage(back, 0, 0, Width, Height); if (head != null) { if (IsLeft) { e.Graphics.DrawImage(head, 4, 3, 63, 64); } else { e.Graphics.DrawImage(head, Width - 67, 3, 63, 64); } } PlayerManaTypes nextAimMana = PlayerManaTypes.None; List <PlayerManaTypes> manaQueue = null; float roundRate = 0; if (player != null) { nextAimMana = player.EnergyGenerator.NextAimMana; manaQueue = player.EnergyGenerator.QueuedMana; roundRate = player.GetRoundRate(); } Brush b1 = new LinearGradientBrush(new Rectangle(0, 18, 500, 10), Color.FromArgb(255, 120, 120), Color.FromArgb(255, 0, 0), LinearGradientMode.Vertical); Brush b2 = new LinearGradientBrush(new Rectangle(0, 30, 500, 10), Color.FromArgb(120, 120, 255), Color.FromArgb(0, 0, 255), LinearGradientMode.Vertical); Pen pen = new Pen(Brushes.Black, 2); if (IsLeft) { if (manaQueue != null) { for (int i = 0; i < manaQueue.Count; i++) { e.Graphics.FillRectangle(PaintTool.GetBrushByManaType((int)manaQueue[i]), 78 - 7, 12 + i * 7, 17, 6); } } if (nextAimMana != PlayerManaTypes.None) { e.Graphics.DrawImage(HSIcons.GetIconsByEName("mix" + (int)nextAimMana), 78, 10, 30, 30); } var destRegion = new Rectangle(78, 10, 30, (int)(30 * (1 - roundRate))); e.Graphics.DrawImage(HSIcons.GetIconsByEName("mix0"), destRegion, 0, 0, 32, 32 * (1 - roundRate), GraphicsUnit.Pixel); if (player != null) { for (int i = 0; i < player.EnergyGenerator.LimitMp; i++) { if (i < player.Mp) { e.Graphics.FillRectangle(PaintTool.GetBrushByManaType((int)PlayerManaTypes.Mp), 112 + 24 * i, 10, 22, 8); } e.Graphics.DrawRectangle(Pens.Gray, 112 + 24 * i, 10, 22, 8); } for (int i = 0; i < player.EnergyGenerator.LimitPp; i++) { if (i < player.Pp) { e.Graphics.FillRectangle(PaintTool.GetBrushByManaType((int)PlayerManaTypes.Pp), 112 + 24 * i, 20, 22, 8); } e.Graphics.DrawRectangle(Pens.Gray, 112 + 24 * i, 20, 22, 8); } for (int i = 0; i < player.EnergyGenerator.LimitLp; i++) { if (i < player.Lp) { e.Graphics.FillRectangle(PaintTool.GetBrushByManaType((int)PlayerManaTypes.Lp), 112 + 24 * i, 30, 22, 8); } e.Graphics.DrawRectangle(Pens.Gray, 112 + 24 * i, 30, 22, 8); } } } else { if (manaQueue != null) { for (int i = 0; i < manaQueue.Count; i++) { e.Graphics.FillRectangle(PaintTool.GetBrushByManaType((int)manaQueue[i]), Width - 108 + 20, 12 + i * 7, 17, 6); } } if (nextAimMana != PlayerManaTypes.None) { e.Graphics.DrawImage(HSIcons.GetIconsByEName("mix" + (int)nextAimMana), Width - 108, 10, 30, 30); } var destRegion = new Rectangle(Width - 108, 10, 30, (int)(30 * (1 - roundRate))); e.Graphics.DrawImage(HSIcons.GetIconsByEName("mix0"), destRegion, 0, 0, 32, 32 * (1 - roundRate), GraphicsUnit.Pixel); if (player != null) { for (int i = 0; i < player.EnergyGenerator.LimitMp; i++) { if (i < player.Mp) { e.Graphics.FillRectangle(PaintTool.GetBrushByManaType((int)PlayerManaTypes.Mp), Width - 134 - 24 * i, 10, 22, 8); } e.Graphics.DrawRectangle(Pens.Gray, Width - 134 - 24 * i, 10, 22, 8); } for (int i = 0; i < player.EnergyGenerator.LimitPp; i++) { if (i < player.Pp) { e.Graphics.FillRectangle(PaintTool.GetBrushByManaType((int)PlayerManaTypes.Pp), Width - 134 - 24 * i, 20, 22, 8); } e.Graphics.DrawRectangle(Pens.Gray, Width - 134 - 24 * i, 20, 22, 8); } for (int i = 0; i < player.EnergyGenerator.LimitLp; i++) { if (i < player.Lp) { e.Graphics.FillRectangle(PaintTool.GetBrushByManaType((int)PlayerManaTypes.Lp), Width - 134 - 24 * i, 30, 22, 8); } e.Graphics.DrawRectangle(Pens.Gray, Width - 134 - 24 * i, 30, 22, 8); } } } pen.Dispose(); b1.Dispose(); b2.Dispose(); Font font = new Font("幼圆", 12 * 1.33f, FontStyle.Bold, GraphicsUnit.Pixel); int lenth = (int)e.Graphics.MeasureString(nameStr, font).Width; e.Graphics.DrawString(nameStr, font, Brushes.White, IsLeft ? 72 : Width - 72 - lenth, 44); e.Graphics.DrawImage(HSIcons.GetIconsByEName("tsk7"), IsLeft ? Width - 75 : 30, 44, 18, 18);//画剩余卡牌数 if (player != null) { e.Graphics.DrawString(player.Cards.LeftCount.ToString(), font, Brushes.White, IsLeft ? Width - 52 : 53, 44); if (player.TrapHolder.Count > 0) { var icon = HSIcons.GetIconsByEName("tsk6"); for (int i = 0; i < player.TrapHolder.Count; i++) { e.Graphics.DrawImage(icon, (IsLeft ? Width - 120 : 80) + i * 8, 44, 18, 18); } } } font.Dispose(); }
private void button4_Click(object sender, EventArgs e) { tool = PaintTool.STAR; }
private void button7_Click(object sender, EventArgs e) { tool = PaintTool.FILL; }
private void MergeWeaponForm_Paint(object sender, PaintEventArgs e) { BorderPainter.Draw(e.Graphics, "", Width, Height); Font font = new Font("黑体", 12 * 1.33f, FontStyle.Bold, GraphicsUnit.Pixel); e.Graphics.DrawString(" 试炼 ", font, Brushes.White, Width / 2 - 40, 8); font.Dispose(); if (currentInfo == null) { return; } font = new Font("宋体", 9 * 1.33f, FontStyle.Regular, GraphicsUnit.Pixel); e.Graphics.DrawString(timeText, font, Brushes.YellowGreen, 165, 412); font.Dispose(); int targetid = selectPanel.SelectInfo; EquipConfig equipConfig = ConfigData.GetEquipConfig(targetid); font = new Font("微软雅黑", 14 * 1.33f, FontStyle.Bold, GraphicsUnit.Pixel); e.Graphics.DrawString((GameResourceBook.OutStoneMerge(equipConfig.Quality + 1, equipConfig.Level)).ToString().PadLeft(5, ' '), font, PaintTool.GetBrushByResource((int)GameResourceType.Mercury), 273, 368); e.Graphics.DrawImage(HSIcons.GetIconsByEName("res3"), 333, 370, 24, 24); font.Dispose(); font = new Font("微软雅黑", 10 * 1.33f, FontStyle.Bold, GraphicsUnit.Pixel); int[] imgOff = { 200, 410, 270, 340 }; int index = 1; foreach (var pair in currentInfo.Methods) { var imgOffX = imgOff[index - 1]; Brush brush = new SolidBrush(Color.FromName(HSTypes.I2RareColor(ConfigData.GetHItemConfig(pair.Type).Rare))); e.Graphics.DrawString(ConfigData.GetHItemConfig(pair.Type).Name, font, brush, imgOffX, 305); brush.Dispose(); var itemCount = itemCounts[index]; bool isEnough = itemCount >= pair.Value; e.Graphics.DrawString(string.Format("{0}/{1}", itemCount, pair.Value), font, isEnough ? Brushes.Lime : Brushes.Red, imgOffX, 325); e.Graphics.DrawLine(isEnough ? Pens.Lime : Pens.Gray, 325, 160, imgOffX + 20, 295); index++; } font.Dispose(); Image border = PicLoader.Read("Border", "itemb1.PNG"); e.Graphics.DrawImage(border, 295 - 10, 100 - 15, 80, 90); border.Dispose(); virtualRegion.Draw(e.Graphics); }
private void button8_Click(object sender, EventArgs e) { tool = PaintTool.MOVE; }
private void SetBrush(PaintTool BrushType) { switch (BrushType) { case PaintTool.Brush: toolbar_brush.CheckState = CheckState.Checked; toolbar_eraser.CheckState = CheckState.Unchecked; toolbar_walkability.CheckState = CheckState.Unchecked; toolbar_bucket.CheckState = CheckState.Unchecked; toolbar_marquee.CheckState = CheckState.Unchecked; toolbar_marquee_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_terrain_brush.CheckState = CheckState.Unchecked; toolbar_portal.CheckState = CheckState.Unchecked; toolbar_chest.CheckState = CheckState.Unchecked; toolbar_NPC.CheckState = CheckState.Unchecked; toolbar_fixedCombat.CheckState = CheckState.Unchecked; toolbar_block.CheckState = CheckState.Unchecked; toolbar_switch.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; case PaintTool.Eraser: toolbar_eraser.CheckState = CheckState.Checked; toolbar_brush.CheckState = CheckState.Unchecked; toolbar_walkability.CheckState = CheckState.Unchecked; toolbar_bucket.CheckState = CheckState.Unchecked; toolbar_marquee.CheckState = CheckState.Unchecked; toolbar_marquee_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_terrain_brush.CheckState = CheckState.Unchecked; toolbar_portal.CheckState = CheckState.Unchecked; toolbar_chest.CheckState = CheckState.Unchecked; toolbar_NPC.CheckState = CheckState.Unchecked; toolbar_fixedCombat.CheckState = CheckState.Unchecked; toolbar_block.CheckState = CheckState.Unchecked; toolbar_switch.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; case PaintTool.Walk: toolbar_walkability.CheckState = CheckState.Checked; toolbar_brush.CheckState = CheckState.Unchecked; toolbar_eraser.CheckState = CheckState.Unchecked; toolbar_bucket.CheckState = CheckState.Unchecked; toolbar_marquee.CheckState = CheckState.Unchecked; toolbar_marquee_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_terrain_brush.CheckState = CheckState.Unchecked; toolbar_portal.CheckState = CheckState.Unchecked; toolbar_chest.CheckState = CheckState.Unchecked; toolbar_NPC.CheckState = CheckState.Unchecked; toolbar_fixedCombat.CheckState = CheckState.Unchecked; toolbar_block.CheckState = CheckState.Unchecked; toolbar_switch.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; case PaintTool.Fill: toolbar_bucket.CheckState = CheckState.Checked; toolbar_walkability.CheckState = CheckState.Unchecked; toolbar_brush.CheckState = CheckState.Unchecked; toolbar_eraser.CheckState = CheckState.Unchecked; toolbar_marquee.CheckState = CheckState.Unchecked; toolbar_marquee_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_terrain_brush.CheckState = CheckState.Unchecked; toolbar_portal.CheckState = CheckState.Unchecked; toolbar_chest.CheckState = CheckState.Unchecked; toolbar_NPC.CheckState = CheckState.Unchecked; toolbar_fixedCombat.CheckState = CheckState.Unchecked; toolbar_block.CheckState = CheckState.Unchecked; toolbar_switch.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; case PaintTool.MarqueeBrush: toolbar_marquee.CheckState = CheckState.Checked; toolbar_bucket.CheckState = CheckState.Unchecked; toolbar_walkability.CheckState = CheckState.Unchecked; toolbar_brush.CheckState = CheckState.Unchecked; toolbar_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_terrain_brush.CheckState = CheckState.Unchecked; toolbar_portal.CheckState = CheckState.Unchecked; toolbar_chest.CheckState = CheckState.Unchecked; toolbar_NPC.CheckState = CheckState.Unchecked; toolbar_fixedCombat.CheckState = CheckState.Unchecked; toolbar_block.CheckState = CheckState.Unchecked; toolbar_switch.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; case PaintTool.MarqueeEraser: toolbar_marquee_eraser.CheckState = CheckState.Checked; toolbar_marquee.CheckState = CheckState.Unchecked; toolbar_bucket.CheckState = CheckState.Unchecked; toolbar_walkability.CheckState = CheckState.Unchecked; toolbar_brush.CheckState = CheckState.Unchecked; toolbar_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_terrain_brush.CheckState = CheckState.Unchecked; toolbar_portal.CheckState = CheckState.Unchecked; toolbar_chest.CheckState = CheckState.Unchecked; toolbar_NPC.CheckState = CheckState.Unchecked; toolbar_fixedCombat.CheckState = CheckState.Unchecked; toolbar_block.CheckState = CheckState.Unchecked; toolbar_switch.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; case PaintTool.MarqueeWalk: toolbar_marquee_walk.CheckState = CheckState.Checked; toolbar_marquee_eraser.CheckState = CheckState.Unchecked; toolbar_marquee.CheckState = CheckState.Unchecked; toolbar_bucket.CheckState = CheckState.Unchecked; toolbar_walkability.CheckState = CheckState.Unchecked; toolbar_brush.CheckState = CheckState.Unchecked; toolbar_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_terrain_brush.CheckState = CheckState.Unchecked; toolbar_portal.CheckState = CheckState.Unchecked; toolbar_chest.CheckState = CheckState.Unchecked; toolbar_NPC.CheckState = CheckState.Unchecked; toolbar_fixedCombat.CheckState = CheckState.Unchecked; toolbar_block.CheckState = CheckState.Unchecked; toolbar_switch.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; case PaintTool.MarqueeTerrain: toolbar_terrain_brush.CheckState = CheckState.Checked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_marquee_eraser.CheckState = CheckState.Unchecked; toolbar_marquee.CheckState = CheckState.Unchecked; toolbar_bucket.CheckState = CheckState.Unchecked; toolbar_walkability.CheckState = CheckState.Unchecked; toolbar_brush.CheckState = CheckState.Unchecked; toolbar_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_portal.CheckState = CheckState.Unchecked; toolbar_chest.CheckState = CheckState.Unchecked; toolbar_NPC.CheckState = CheckState.Unchecked; toolbar_fixedCombat.CheckState = CheckState.Unchecked; toolbar_block.CheckState = CheckState.Unchecked; toolbar_switch.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; case PaintTool.Portal: toolbar_portal.CheckState = CheckState.Checked; toolbar_terrain_brush.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_marquee_eraser.CheckState = CheckState.Unchecked; toolbar_marquee.CheckState = CheckState.Unchecked; toolbar_bucket.CheckState = CheckState.Unchecked; toolbar_walkability.CheckState = CheckState.Unchecked; toolbar_brush.CheckState = CheckState.Unchecked; toolbar_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_chest.CheckState = CheckState.Unchecked; toolbar_NPC.CheckState = CheckState.Unchecked; toolbar_fixedCombat.CheckState = CheckState.Unchecked; toolbar_block.CheckState = CheckState.Unchecked; toolbar_switch.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; case PaintTool.Chest: toolbar_chest.CheckState = CheckState.Checked; toolbar_portal.CheckState = CheckState.Unchecked; toolbar_terrain_brush.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_marquee_eraser.CheckState = CheckState.Unchecked; toolbar_marquee.CheckState = CheckState.Unchecked; toolbar_bucket.CheckState = CheckState.Unchecked; toolbar_walkability.CheckState = CheckState.Unchecked; toolbar_brush.CheckState = CheckState.Unchecked; toolbar_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_NPC.CheckState = CheckState.Unchecked; toolbar_fixedCombat.CheckState = CheckState.Unchecked; toolbar_block.CheckState = CheckState.Unchecked; toolbar_switch.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; case PaintTool.NPC: toolbar_NPC.CheckState = CheckState.Checked; toolbar_portal.CheckState = CheckState.Unchecked; toolbar_terrain_brush.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_marquee_eraser.CheckState = CheckState.Unchecked; toolbar_marquee.CheckState = CheckState.Unchecked; toolbar_bucket.CheckState = CheckState.Unchecked; toolbar_walkability.CheckState = CheckState.Unchecked; toolbar_brush.CheckState = CheckState.Unchecked; toolbar_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_chest.CheckState = CheckState.Unchecked; toolbar_fixedCombat.CheckState = CheckState.Unchecked; toolbar_block.CheckState = CheckState.Unchecked; toolbar_switch.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; case PaintTool.FixedCombat: toolbar_fixedCombat.CheckState = CheckState.Checked; toolbar_portal.CheckState = CheckState.Unchecked; toolbar_terrain_brush.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_marquee_eraser.CheckState = CheckState.Unchecked; toolbar_marquee.CheckState = CheckState.Unchecked; toolbar_bucket.CheckState = CheckState.Unchecked; toolbar_walkability.CheckState = CheckState.Unchecked; toolbar_brush.CheckState = CheckState.Unchecked; toolbar_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_chest.CheckState = CheckState.Unchecked; toolbar_NPC.CheckState = CheckState.Unchecked; toolbar_block.CheckState = CheckState.Unchecked; toolbar_switch.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; case PaintTool.Block: toolbar_block.CheckState = CheckState.Checked; toolbar_fixedCombat.CheckState = CheckState.Unchecked; toolbar_portal.CheckState = CheckState.Unchecked; toolbar_terrain_brush.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_marquee_eraser.CheckState = CheckState.Unchecked; toolbar_marquee.CheckState = CheckState.Unchecked; toolbar_bucket.CheckState = CheckState.Unchecked; toolbar_walkability.CheckState = CheckState.Unchecked; toolbar_brush.CheckState = CheckState.Unchecked; toolbar_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_chest.CheckState = CheckState.Unchecked; toolbar_NPC.CheckState = CheckState.Unchecked; toolbar_switch.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; case PaintTool.Switch: toolbar_switch.CheckState = CheckState.Checked; toolbar_fixedCombat.CheckState = CheckState.Unchecked; toolbar_portal.CheckState = CheckState.Unchecked; toolbar_terrain_brush.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_marquee_eraser.CheckState = CheckState.Unchecked; toolbar_marquee.CheckState = CheckState.Unchecked; toolbar_bucket.CheckState = CheckState.Unchecked; toolbar_walkability.CheckState = CheckState.Unchecked; toolbar_brush.CheckState = CheckState.Unchecked; toolbar_eraser.CheckState = CheckState.Unchecked; toolbar_marquee_walk.CheckState = CheckState.Unchecked; toolbar_chest.CheckState = CheckState.Unchecked; toolbar_NPC.CheckState = CheckState.Unchecked; toolbar_block.CheckState = CheckState.Unchecked; ShowTerrainTypes = false; break; default: // should never get here break; } // set the brush type in glb_data GLB_Data.Brush = BrushType; }
public override void DrawOnCardDetail(Graphics g, int offX, int offY) { SpellConfig spellConfig = spell.SpellConfig; CardAssistant.DrawBase(g, spell.Id, offX + 10, offY + 10, 180, 200); int basel = 210; Font font = new Font("宋体", 10 * 1.33f, FontStyle.Regular, GraphicsUnit.Pixel); g.DrawString(("★★★★★★★★★★").Substring(10 - spellConfig.Star), font, Brushes.Yellow, offX + 30, offY + 30); font.Dispose(); basel += offY; Brush headerBack = new SolidBrush(Color.FromArgb(190, 175, 160)); Brush lineBack = new SolidBrush(Color.FromArgb(215, 210, 200)); g.FillRectangle(headerBack, offX + 10, basel, 180, 20); for (int i = 0; i < 1; i++) { g.FillRectangle(lineBack, offX + 10, basel + 20 + i * 30, 180, 15); } g.FillRectangle(headerBack, offX + 10, basel + 40, 180, 20); for (int i = 0; i < 3; i++) { g.FillRectangle(lineBack, offX + 10, basel + 75 + i * 30, 180, 15); } g.FillRectangle(headerBack, offX + 10, basel + 150, 180, 20); g.FillRectangle(lineBack, offX + 10, basel + 170, 180, 45); headerBack.Dispose(); lineBack.Dispose(); Font fontblack = new Font("黑体", 12 * 1.33f, FontStyle.Bold, GraphicsUnit.Pixel); Font fontsong = new Font("宋体", 10 * 1.33f, FontStyle.Regular, GraphicsUnit.Pixel); SolidBrush sb = new SolidBrush(Color.FromArgb(100, 50, 0)); g.DrawString(spellConfig.Name, fontblack, Brushes.White, offX + 10, basel + 2); g.DrawImage(HSIcons.GetIconsByEName("spl" + (spellConfig.Type - 200 + 1)), 60 + offX, basel - 40, 24, 24); g.DrawImage(HSIcons.GetIconsByEName("atr" + spellConfig.Attr), 88 + offX, basel - 40, 24, 24); g.DrawString(string.Format("Lv{0:00}", card.Level), fontsong, Brushes.Indigo, 13 + offX, basel + 22); g.DrawImage(HSIcons.GetIconsByEName("oth10"), 56 + offX, basel + 22, 14, 14); g.DrawString(string.Format("({0}/{1})", card.Exp, ExpTree.GetNextRequiredCard(card.Level)), fontsong, Brushes.RoyalBlue, 70 + offX, basel + 22); g.DrawString("数据", fontblack, Brushes.White, offX + 10, basel + 42); Adder add = new Adder(basel + 61, 15); g.DrawString(string.Format("伤害 {0,3:D}", spell.Damage), fontsong, sb, offX + 10, add.Next); PaintTool.DrawValueLine(g, spell.Damage / 5, 70 + offX, add.Now + 1, 115, 10); g.DrawString(string.Format("治疗 {0,3:D}", spell.Cure), fontsong, sb, offX + 10, add.Next); PaintTool.DrawValueLine(g, spell.Cure / 5, 70 + offX, add.Now + 1, 115, 10); g.DrawString(string.Format("持续 {0,3:D}", (int)spell.Time), fontsong, sb, 10 + offX, add.Next); PaintTool.DrawValueLine(g, (int)(spell.Time * 10), 70 + offX, add.Now + 1, 115, 10); g.DrawString(string.Format("辅助 {0,3:D}", (int)spell.Help), fontsong, sb, 10 + offX, add.Next); PaintTool.DrawValueLine(g, (int)(spell.Help * 10), 70 + offX, add.Now + 1, 115, 10); g.DrawString(string.Format("几率 {0,3:D}", (int)spell.Rate), fontsong, sb, 10 + offX, add.Next); PaintTool.DrawValueLine(g, (int)spell.Rate, 70 + offX, add.Now + 1, 115, 10); g.DrawString(string.Format("加成 {0,3:D}", spell.Atk), fontsong, sb, offX + 10, add.Next); PaintTool.DrawValueLine(g, spell.Atk / 2, 70 + offX, add.Now + 1, 115, 10); g.DrawString("效果", fontblack, Brushes.White, offX + 10, basel + 152); string des = spell.Descript; PaintTool.DrawStringMultiLine(g, fontsong, sb, offX + 10, basel + 61 + 110, 15, 13, des); fontblack.Dispose(); fontsong.Dispose(); sb.Dispose(); }
public void AssignImage() { if (GameMgr.Instance.CurrentLevel.Tool == ToolTypes.Segment) { Hide(); return; } transform.parent.localScale = GetOneScale(); // Scale parent instead to autoscale everything else Texture2D basePhoto = GameMgr.CurrentTex2D(); int cp = basePhoto.width * basePhoto.height; Color32[] cc = new Color32[cp]; for (int i = 0; i < cp; i++) { cc[i] = UIMgr.Instance.canvasClearColor; } if (GameMgr.Instance.CurrentLevel.Tool == ToolTypes.Paint) { Texture2D groundTruthPhoto = GameMgr.CurrentGroundTruthTex2D(); if (groundTruthPhoto == null) { Hide(); return; } if (GameMgr.Instance.CurrentLevel.TutorialMode == TutorialMode.Full) { Color[] pixels = groundTruthPhoto.GetPixels(); for (int i = 0; i < pixels.Length; i++) { if (pixels[i] != Color.black) { cc[i] = PaintHighlightColor; } } } else if (GameMgr.Instance.CurrentLevel.TutorialMode == TutorialMode.Simple) { PaintTool paintTool = ToolMgr.Instance.activeTool as PaintTool; // Check to make sure the ground truths have been assigned yet. if (paintTool == null || paintTool.groundTruthBlobs == null) { return; } foreach (var blob in paintTool.groundTruthBlobs) { int cx = (int)blob.Value.center.x; int cy = (int)blob.Value.center.y; //Debug.LogFormat("Checking blob at ({0}, {1}) with center at {2}", blob.Value.center.x, blob.Value.center.y, (cx + groundTruthPhoto.width * cy)); DrawCenter(cc, cx, cy, basePhoto.width, basePhoto.height, PaintRadius, PaintCenterColor); } } else { Hide(); return; } } else if (GameMgr.Instance.CurrentLevel.Tool == ToolTypes.Neuron) { NeuronTool neuronTool = ToolMgr.Instance.activeTool as NeuronTool; // Check to make sure the ground truths have been assigned yet. if (neuronTool == null || neuronTool.groundTruthGraph == null) { return; } if (GameMgr.Instance.CurrentLevel.TutorialMode == TutorialMode.Full) { foreach (Node n in neuronTool.groundTruthGraph.nodes) { //Debug.LogFormat("Checking node at ({0}, {1})", n.center.x, n.center.y); int nx = Mathf.RoundToInt(basePhoto.width * n.center.x); int ny = Mathf.RoundToInt(basePhoto.height * n.center.y); if (n.neighbors.Count >= MinNeigbors) { DrawCenter(cc, nx, ny, basePhoto.width, basePhoto.height, NeuronRadius, NeuronHighlightColor); } else { DrawCenter(cc, nx, ny, basePhoto.width, basePhoto.height, NeuronSecondaryRadius, NeuronSecondaryColor); } } } else if (GameMgr.Instance.CurrentLevel.TutorialMode == TutorialMode.Simple) { foreach (Node n in neuronTool.groundTruthGraph.nodes) { if (n.neighbors.Count < MinNeigbors) { continue; } //Debug.LogFormat("Checking node at ({0}, {1})", n.center.x, n.center.y); int nx = Mathf.RoundToInt(basePhoto.width * n.center.x); int ny = Mathf.RoundToInt(basePhoto.height * n.center.y); DrawCenter(cc, nx, ny, basePhoto.width, basePhoto.height, NeuronRadius, NeuronHighlightColor); } } else { Hide(); return; } } else { Hide(); return; } Texture2D tex = new Texture2D(basePhoto.width, basePhoto.height); tex.SetPixels32(0, 0, tex.width, tex.height, cc); tex.Apply(); MeshRenderer renderer = GetComponent <MeshRenderer>(); renderer.material = material; renderer.material.SetTexture("_MainTex", tex); _assigned = true; }
private void MouseEvents() { var e = Event.current; var rect = Parent.position; rect.x += 2; rect.y += ToolbarHeight + 2; rect.width -= RightWidth + 4; rect.height -= ToolbarHeight + 4; var mousePos = GUIUtility.GUIToScreenPoint(e.mousePosition); if (!rect.Contains(mousePos)) { return; } // Left mouse button events if (Event.current.button == 0 && !NoRightMouseAltInput()) { if (e.type == EventType.MouseDown) { TilerMapEditFunctions.Undo.NewUndo(); Paint(); _lastPlaced = _currentPoint; _isPainting = true; } if (e.type == EventType.MouseDrag) { if (_isPainting && _lastPlaced != _currentPoint) { Paint(); _lastPlaced = _currentPoint; } } } // Right mouse button events if (Event.current.button == 1 || NoRightMouseAltInput()) { if (e.type == EventType.MouseDown) { _isDraggingCopy = true; _startCopyPoint = _currentPoint; } if (e.type == EventType.MouseUp) { if (_isDraggingCopy) { var properties = new List <Brush>(); var start = new Point { X = Math.Min(_currentPoint.X, _startCopyPoint.X), Y = Math.Min(_currentPoint.Y, _startCopyPoint.Y) }; var count = new Point { X = Math.Abs(_currentPoint.X - _startCopyPoint.X) + 1, Y = Math.Abs(_currentPoint.Y - _startCopyPoint.Y) + 1 }; for (var y = start.Y; y < start.Y + count.Y; y++) { for (var x = start.X; x < start.X + count.X; x++) { var p = new Point(x, y); properties.Add(TilerMap.GetTileBrush(p)); } } var copy = new CopyBrush(properties.ToArray(), new Point(count.X, count.Y)); if (DrawTool is PaintTool) { DrawTool.SetBrush(copy); } else { DrawTool = new PaintTool(this, copy); } Repaint(); _isDraggingCopy = false; } } } if (e.type == EventType.MouseDrag) { if (Event.current.button == 2) { PanWindow(); Repaint(); } } else if (e.type == EventType.ScrollWheel) { _height += Event.current.delta.y / 10f; _height = Mathf.Clamp(_height, -1, 5); SetCameraHeight(); Repaint(); } if (e.type == EventType.MouseDrag || e.type == EventType.MouseMove || e.type == EventType.ScrollWheel) { GetGridPoint(); } }
private void SelectTool(PaintTool newTool) { currentTool = newTool; if(currentTool == PaintTool.Draw || currentTool == PaintTool.Erase || currentTool == PaintTool.Flood || currentTool == PaintTool.Collision) { Selection.activeGameObject = null; } // When using flood tool make sure that only one tile is selected an shut off multi-select if(currentTool == PaintTool.Flood && selectedTiles.Values.Count > 1) { GUITileSprite first = selectedTiles.Values[0]; selectedTiles.Clear(); selectedTiles.Add(first.Index, first); } else if(selectedTiles.Count == 0 && (currentTool == PaintTool.Draw || currentTool == PaintTool.Flood)) { // If we select draw or flood, select at least one tile so the user can click right away selectedTiles.Add(0, tiles[0]); } if (currentTool == PaintTool.Free || currentTool == PaintTool.Collision || (currentTool == PaintTool.Erase && eraseAllLayersMode)) SelectLayer(SortingLayer.All); else SelectLayer((SortingLayer)currentLayer); }
public override void OnEnable() { base.OnEnable(); _lastSave = DateTime.Now; DrawTool = new PaintTool(this, null); UnityInternal.AddGlobalEventHandler(GlobalInputHack); EditorApplication.hierarchyWindowChanged += OnHierachyChange; _drawTileSetWindow = new DrawTileSetWindow(this); _brushWindow = new BrushWindow(this); RefreshMaps(); var cameraGo = GameObject.Find("TilerCamera"); if (cameraGo == null) { cameraGo = EditorUtility.CreateGameObjectWithHideFlags("TilerCamera", (HideFlags)13, new[] { typeof(Camera) }); cameraGo.AddComponent <GUILayer>(); cameraGo.AddComponent <FlareLayer>(); UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(cameraGo, "Assets/Tiler/Editor/Windows/Main/Draw/DrawWindow.cs (78,13)", "HaloLayer"); } _camera = cameraGo.GetComponent <Camera>(); _camera.enabled = false; _height = Mathf.Log(16); _camera.transform.eulerAngles = new Vector3(90, 0, 0); SetCameraHeight(); var lightGo = GameObject.Find("TilerLight"); // ReSharper disable ConvertIfStatementToNullCoalescingExpression if (lightGo == null) { // ReSharper restore ConvertIfStatementToNullCoalescingExpression lightGo = EditorUtility.CreateGameObjectWithHideFlags("TilerLight", (HideFlags)13, new[] { typeof(Light) }); } _light = lightGo.GetComponent <Light>(); _light.type = LightType.Directional; _light.intensity = 0.5f; _light.enabled = false; var textGo = GameObject.Find("TilerText"); if (textGo == null) { textGo = EditorUtility.CreateGameObjectWithHideFlags("TilerText", (HideFlags)13, new[] { typeof(GUIText) }); textGo.transform.position = new Vector3(0.5f, 1, 0); } _text = textGo.GetComponent <GUIText>(); _text.anchor = TextAnchor.UpperCenter; _text.alignment = TextAlignment.Center; //_text.font.material.color = Color.white; //_text.text = "Remember to save. Last save more than 10 minutes ago."; _text.enabled = false; }
void OnGUI() { int nbByLine = editedTilemap.spriteSheet.width / editedTilemap.tileSize; Rect textRect = new Rect(0, 0, editedTilemap.spriteSheet.width, editedTilemap.spriteSheet.height); GUI.DrawTexture(textRect, editedTilemap.spriteSheet); Event e = Event.current; if (e.type == EventType.MouseDown) { if (e.button == 0) { _clickPos = e.mousePosition; if (_clickPos.y <= editedTilemap.spriteSheet.height) { _currentSelection = new TileSelection(); _inDrag = true; } } } else if (Event.current.type == EventType.mouseUp) { if (e.button == 0) { _inDrag = false; } } if (_inDrag) { Vector2 pos = e.mousePosition; Vector2 min = Vector2.Min(pos, _clickPos); Vector2 max = Vector2.Max(pos, _clickPos); int startX = (int)(min.x / editedTilemap.tileSize); int startY = (int)((textRect.height - max.y) / editedTilemap.tileSize); int endX = (int)(max.x / editedTilemap.tileSize); int endY = (int)((textRect.height - min.y) / editedTilemap.tileSize); _currentSelection.width = (endX - startX) + 1; _currentSelection.height = (endY - startY) + 1; _currentSelection.startX = startX; _currentSelection.startY = startY; _currentSelection.array = new int[_currentSelection.width, _currentSelection.height]; for (int i = 0; i < _currentSelection.width; ++i) { for (int j = 0; j < _currentSelection.height; ++j) { _currentSelection.array[i, j] = (startX + i) + (startY + j) * nbByLine; } } } DrawQuad(new Rect(_currentSelection.startX * editedTilemap.tileSize, (editedTilemap.spriteSheet.height) - (_currentSelection.startY + _currentSelection.height) * editedTilemap.tileSize, _currentSelection.width * editedTilemap.tileSize, _currentSelection.height * editedTilemap.tileSize), Color.red); Repaint(); //--------------------------------- _currentPaintTool = (PaintTool)GUI.SelectionGrid(new Rect(0, editedTilemap.spriteSheet.height, position.width, 50), (int)_currentPaintTool, paintToolNames, (int)PaintTool.MAX_PAINTTOOL); if (_currentSelection.array != null) { GUI.Label(new Rect(0, editedTilemap.spriteSheet.height + 50, position.width, 20), "Current Tile selected : " + _currentSelection.array[0, 0] + " to " + _currentSelection.array[_currentSelection.width - 1, _currentSelection.height - 1]); } }
public override void ToolBar() { base.ToolBar(); GUILayout.Box("Misc", EditorStyles.toolbarDropDown); Rect miscRect = GUILayoutUtility.GetLastRect(); if (MyGUI.ButtonMouseDown(miscRect)) { var misc = PopupWindow.ShowAtPosition <MiscPopup>(new Rect(miscRect.x, miscRect.y + miscRect.height, 120f, 60)); misc.Setup(TilerMap); } EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); GUI.enabled = TilerMapEditFunctions.Undo.IsUndo(); if (GUILayout.Button("<", EditorStyles.toolbarButton)) { TilerMapEditFunctions.Undo.PerformUndo(); Repaint(); } GUI.enabled = TilerMapEditFunctions.Undo.IsRedo(); if (GUILayout.Button(">", EditorStyles.toolbarButton)) { TilerMapEditFunctions.Undo.PerformRedo(); Repaint(); } GUI.enabled = true; EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); if (MyGUI.HasToggledPositive(DrawTool is PaintTool, "P", EditorStyles.toolbarButton)) { DrawTool = new PaintTool(this, DrawTool.GetBrush() as NormalBrush); Repaint(); } if (MyGUI.HasToggledPositive(DrawTool is FillTool, "F", EditorStyles.toolbarButton)) { DrawTool = new FillTool(this, DrawTool.GetBrush() as NormalBrush); Repaint(); } if (MyGUI.HasToggledPositive(DrawTool is ReplaceTool, "R", EditorStyles.toolbarButton)) { DrawTool = new ReplaceTool(this, DrawTool.GetBrush() as NormalBrush); Repaint(); } EditorGUILayout.Space(); if (GUILayout.Button("O", EditorStyles.toolbarButton)) { var p = _camera.transform.position; p.x = 0; p.z = 0; _camera.transform.position = p; } EditorGUILayout.Space(); //var currentIndex = _mapIndex; //_mapIndex = EditorGUILayout.Popup(_mapIndex, _mapNames, EditorStyles.toolbarPopup); //options = new[] { "CanJump", "CanShoot", "CanSwim" }; //flags = EditorGUILayout.MaskField("Layers", 1, options, EditorStyles.toolbarPopup); GUILayout.Box("Layers", EditorStyles.toolbarDropDown); Rect last = GUILayoutUtility.GetLastRect(); if (MyGUI.ButtonMouseDown(last)) { var height = 20 * _tilerMaps.Count + 20;// +25; var lp = PopupWindow.ShowAtPosition <LayerPopup>(new Rect(last.x, last.y + last.height, 150f, height)); lp.Setup(_mapIndex, _mapMask, _tilerMaps, SetMapChange, SetMapMask, Save); GUIUtility.ExitGUI(); } /*if (currentIndex != _mapIndex) * { * Save(); * SetMap(_mapIndex); * }*/ }