/// <summary> /// Наполение формы данными из карточки события /// </summary> /// <param name="c">Карточка события</param> public void Fill(Card c) { Text = c.Title; TitleLabel.Text = c.Title; HintTitle.SetToolTip(TitleLabel, c.Title); DescrLabel.Text = c.Description; CurrentImg.Load(c.Images[0]); //Если картинка только одна - отключаем кнопки вперед/назад if (c.Images.Count > 1) { PrevBtn.Enabled = true; NextBtn.Enabled = true; foreach (var im in c.Images) { Images.Add(Methods.GetBMP(im)); } } else { PrevBtn.Enabled = false; NextBtn.Enabled = false; } Body.Text = c.Body; if (String.IsNullOrEmpty(c.Age)) { c.Age = "0+"; } if (!c.Age.EndsWith("+")) { c.Age += "+"; } if (String.IsNullOrEmpty(c.Price)) { c.Price = "бесплатно"; } InfoLabel.Text = String.Format("Возраст: {0} Цена: {1}", c.Age, c.Price); }
public static void DrawLayerPanel(Rect window) { style.imagePosition = ImagePosition.ImageAbove; if (CurrentImg == null) { return; } for (int i = 0; i < CurrentImg.layers.Count; i++) { GUI.backgroundColor = Color.white; if (i == CurrentImg.selectedLayer) { GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f); } UPALayer tempLayer = CurrentImg.layers[i]; if (GUI.Button(new Rect(12, window.height - 60 - i * 36, 65, 33), "")) { CurrentImg.selectedLayer = i; } GUI.backgroundColor = Color.white; GUI.Label(new Rect(15, window.height - 52 - i * 36, 90, 30), tempLayer.name); bool layerEnabled = tempLayer.enabled; tempLayer.enabled = GUI.Toggle(new Rect(80, window.height - 61 - i * 36, 15, 15), tempLayer.enabled, ""); if (tempLayer.enabled != layerEnabled) { tempLayer.parentImg.dirty = true; } CurrentImg.layers[i] = tempLayer; } GUIStyle smallButon = new GUIStyle(); smallButon.fontSize = 8; smallButon.alignment = TextAnchor.MiddleCenter; smallButon.normal.background = Resources.Load("Background") as Texture2D; if (GUI.Button(new Rect(12, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/add") as Texture, "Add Layer"), smallButon)) { CurrentImg.AddLayer(); } if (CurrentImg.layerCount == 1) { GUI.contentColor = new Color(0.7f, 0.7f, 0.7f); } if (GUI.Button(new Rect(12 + 20, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/delete") as Texture, "Delete Layer"), smallButon)) { if (CurrentImg.layers.Count > 1) { bool delete = EditorUtility.DisplayDialog( "Delete Layer", "Do you want to remove " + CurrentImg.layers[CurrentImg.selectedLayer].name + "?", "Delete", "Cancel"); if (delete) { CurrentImg.RemoveLayerAt(CurrentImg.selectedLayer); } } } GUI.contentColor = Color.white; if (GUI.Button(new Rect(12 + 20 * 2, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/import") as Texture, "Import Image"), smallButon)) { string path = EditorUtility.OpenFilePanel( "Find an Image (.jpg | .png)", "/", "Image Files;*.jpg;*.png"); if (path.Length != 0) { // Load Texture from file Texture2D tex = null; byte[] fileData; if (File.Exists(path)) { fileData = File.ReadAllBytes(path); tex = new Texture2D(2, 2); tex.LoadImage(fileData); //..this will auto-resize the texture dimensions. } // Create a new Image with textures dimensions CurrentImg.AddLayer(); // Set pixel colors UPALayer layer = CurrentImg.layers[CurrentImg.layers.Count - 1]; for (int x = 0; x < CurrentImg.width; x++) { for (int y = 0; y < CurrentImg.height; y++) { layer.map[x + y * CurrentImg.width] = tex.GetPixel(x, CurrentImg.height - 1 - y); } } layer.LoadTexFromMap(); } } if (GUI.Button(new Rect(12 + 20 * 3, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/duplicate") as Texture, "Duplicate Layer"), smallButon)) { CurrentImg.layers.Add(new UPALayer(CurrentImg.layers[CurrentImg.selectedLayer])); } if (CurrentImg.selectedLayer == 0) { GUI.contentColor = new Color(0.7f, 0.7f, 0.7f); } if (GUI.Button(new Rect(12 + 20 * 4, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/merge") as Texture, "Merge Layer Down"), smallButon)) { if (CurrentImg.selectedLayer > 0) { UPALayer upper = CurrentImg.layers[CurrentImg.selectedLayer]; UPALayer lower = CurrentImg.layers[CurrentImg.selectedLayer - 1]; lower.tex = UPABlendModes.Blend(lower.tex, lower.opacity, upper.tex, upper.opacity, upper.mode); for (int x = 0; x < lower.tex.width; x++) { for (int y = 0; y < lower.tex.height; y++) { lower.map[x + y * lower.tex.width] = lower.tex.GetPixel(x, lower.tex.height - 1 - y); } } CurrentImg.RemoveLayerAt(CurrentImg.selectedLayer); } } GUI.contentColor = Color.white; //if (GUI.Button (new Rect (12 + 18 * 4, window.height - 18, 16, 16), Resources.Load("UI/up") as Texture2D, style)) { // CurrentImg.AddLayer (); //} //if (GUI.Button (new Rect (12 + 18 * 5, window.height - 18, 16, 16), Resources.Load("UI/down") as Texture2D, style)) { // CurrentImg.AddLayer (); //} if (GUI.Button(new Rect(12 + 20 * 5, window.height - 20, 18, 18), new GUIContent(Resources.Load("UI/edit") as Texture, "Layer Options"), smallButon)) { UPALayerSettings.Init(CurrentImg.layers[CurrentImg.selectedLayer]); } // Draw layer button tooltips if (GUI.tooltip != "") { GUI.Box(new Rect(12, window.height - 43, 120, 20), GUI.tooltip); } //CurrentImg.selectedLayer = GUI.Toolbar (new Rect (4, window.height - 200, 90, 30), CurrentImg.selectedLayer, layerNames); }
// Draw the settings toolbar public static void DrawToolbar(Rect window, Vector2 mousePos) { // Draw toolbar bg EditorGUI.DrawRect(new Rect(0, 0, window.width, 40), toolbarColor); if (GUI.Button(new Rect(5, 4, 50, 30), "New")) { UPAImageCreationWindow.Init(); } if (GUI.Button(new Rect(60, 4, 50, 30), "Open")) { //CurrentImg = UPASession.OpenFolder(false); CurrentImg = UPASession.OpenImage(); CurrentImg.initilizeAlphas(); if (CurrentImg == null) { return; } } if (GUI.Button(new Rect(115, 4, 50, 30), "Export")) { UPAExportWindow.Init(CurrentImg); } if (GUI.Button(new Rect(179, 6, 25, 25), "+")) { CurrentImg.gridSpacing *= 1.2f; } if (GUI.Button(new Rect(209, 6, 25, 25), "-")) { CurrentImg.gridSpacing *= 0.8f; CurrentImg.gridSpacing -= 2; } CurrentImg.selectedColor = EditorGUI.ColorField(new Rect(250, 7, 70, 25), CurrentImg.selectedColor); EditorGUI.DrawRect(new Rect(303, 7, 20, 25), toolbarColor); //bgColor = EditorGUI.ColorField (new Rect (400, 4, 70, 25), bgColor); GUI.backgroundColor = Color.white; if (UPAEditorWindow.selectedTool == UPATool.PaintBrush) { GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f); } if (GUI.Button(new Rect(320, 4, 60, 30), "Paint")) { UPAEditorWindow.selectedTool = UPATool.PaintBrush; } GUI.backgroundColor = Color.white; if (UPAEditorWindow.selectedTool == UPATool.Map) { GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f); } if (GUI.Button(new Rect(450, 4, 60, 30), "Map")) { UPAEditorWindow.selectedTool = UPATool.Map; } GUI.backgroundColor = Color.white; if (UPAEditorWindow.selectedTool == UPATool.Eraser) { GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f); } if (GUI.Button(new Rect(385, 4, 60, 30), "Erase")) { UPAEditorWindow.selectedTool = UPATool.Eraser; } GUI.backgroundColor = Color.white; style.normal.textColor = new Color(0.7f, 0.7f, 0.7f); style.fontSize = 12; style.fontStyle = FontStyle.Normal; GUI.Label(new Rect(525, 11, 150, 30), "Use WASD to navigate.", style); if (GUI.Button(new Rect(684, 4, 55, 30), "Center")) { CurrentImg.gridOffsetX = 0; CurrentImg.gridOffsetY = 0; } CurrentImg.gridBGIndex = GUI.Toolbar(new Rect(743, 4, 130, 30), CurrentImg.gridBGIndex, gridBGStrings); if (CurrentImg.gridBGIndex == 0) { gridBGColor = Color.black; } else if (CurrentImg.gridBGIndex == 1) { gridBGColor = Color.white; } else { gridBGColor = Color.clear; } if (GUI.Button(new Rect(930, 4, 75, 30), "Save Armor")) { Armor armor = new Armor("shoulder"); armor.AddArmorPiece(new ArmorPiece("topSide")); armorSavePath = DataController.SaveArmor(armor); Debug.Log(armorSavePath); } if (GUI.Button(new Rect(1010, 4, 75, 30), "Load Armor")) { Armor armor = DataController.LoadArmor(armorSavePath); Debug.Log("armor found"); Debug.Log(armor.name); for (int i = 0; i < armor.armorPieces.Count; i++) { Debug.Log(armor.armorPieces[i].name); } } if (GUI.Button(new Rect(1090, 4, 75, 30), "Load template")) { Debug.Log("load template pressed"); UPAImage img = UPASession.OpenFolder(true); img.initilizeAlphas(); img.loopThroughImage(); } if (GUI.Button(new Rect(1175, 4, 100, 30), "Load Animations")) { UPAEditorWindow.animation = UPASession.OpenAnimationsFromFolder(false); } if (GUI.Button(new Rect(1295, 4, 100, 30), "Preview")) { UPAEditorWindow.gettingPreviewArmor = true; } if (GUI.Button(new Rect(1410, 4, 100, 30), "Save Anim")) { UPAAnimator.MakeAnimationClip(UPAEditorWindow.animation); } //Vector2 pixelCoordinate = CurrentImg.GetReadablePixelCoordinate(mousePos); //CurrentImg.GetPixelByPos(pixelCoordinate, CurrentImg.selectedLayer); //GUI.Label(new Rect(1200, 11, 200, 30), "(" + CurrentImg.GetPixelByPos(mousePos, CurrentImg.selectedLayer, true) + ")", style); //GUI.Label(new Rect(880, 11, 100, 30), "(" + (int)pixelCoordinate.x + "," + (int)pixelCoordinate.y + ")", style); if (CurrentImg.tool == UPATool.ColorPicker) { style.fontStyle = FontStyle.Bold; style.fontSize = 15; GUI.Label(new Rect(window.width / 2f - 140, 60, 100, 30), "Click on a pixel to choose a color.", style); } }