Exemplo n.º 1
0
 public void SetEvent(Event Event)
 {
     this.EventData = Event;
     Sprites["gfx"].Bitmap?.Dispose();
     if (Event.Pages.Count > 0)
     {
         EventGraphic gfx = Event.Pages[0].Graphic;
         if (gfx.Type == ":file")
         {
             if (System.IO.File.Exists(Data.ProjectPath + "/" + gfx.Param.ToString() + ".png"))
             {
                 Sprites["gfx"].Bitmap         = new Bitmap(Data.ProjectPath + "/" + gfx.Param.ToString());
                 Sprites["gfx"].SrcRect.Width  = Sprites["gfx"].Bitmap.Width / gfx.NumFrames;
                 Sprites["gfx"].SrcRect.Height = Sprites["gfx"].Bitmap.Height / gfx.NumDirections;
                 int dir = 0;
                 if (gfx.NumDirections == 4)
                 {
                     dir = gfx.Direction / 2 - 1;
                 }
                 if (gfx.NumDirections == 8)
                 {
                     dir = gfx.Direction - 1;
                 }
                 Sprites["gfx"].SrcRect.Y = Sprites["gfx"].SrcRect.Height * dir;
             }
         }
     }
 }
        public EventGraphicSelector(
            EventGraphic editingGraphic,
            FrmEvent eventEditor,
            EventMoveRouteDesigner moveRouteDesigner = null,
            bool newMoveRouteAction = false
            )
        {
            InitializeComponent();
            mEditingGraphic = editingGraphic;
            mEventEditor    = eventEditor;
            mLoading        = true;
            UpdateGraphicList();
            if (cmbGraphic.Items.IndexOf(mEditingGraphic.Filename) > -1)
            {
                cmbGraphic.SelectedIndex = cmbGraphic.Items.IndexOf(mEditingGraphic.Filename);
            }

            mRouteDesigner  = moveRouteDesigner;
            mNewRouteAction = newMoveRouteAction;
            mLoading        = false;
            InitLocalization();
            cmbGraphicType.SelectedIndex = (int)mEditingGraphic.Type;
            mTmpGraphic.CopyFrom(mEditingGraphic);
            UpdatePreview();
        }
Exemplo n.º 3
0
        public override void Load(EntityPacket packet)
        {
            base.Load(packet);
            var pkt = (EventEntityPacket)packet;

            DirectionFix   = pkt.DirectionFix;
            WalkingAnim    = pkt.WalkingAnim;
            DisablePreview = pkt.DisablePreview;
            Desc           = pkt.Description;
            Graphic        = pkt.Graphic;
            RenderLevel    = pkt.RenderLayer;
        }
        public void SetEvent(Event Event)
        {
            this.EventData = Event;
            string text = $"{Utilities.Digits(Event.ID, 3)}: {Event.Name}";
            Font   f    = Font.Get("Fonts/Ubuntu-B", 14);
            Size   s    = f.TextSize(text);

            Sprites["text"].Bitmap?.Dispose();
            Sprites["text"].Bitmap = new Bitmap(s);
            Sprites["text"].Bitmap.Unlock();
            Sprites["text"].Bitmap.Font = f;
            Sprites["text"].Bitmap.DrawText(text, Color.WHITE);
            Sprites["text"].Bitmap.Lock();
            Sprites["graphic"].Bitmap?.Dispose();
            if (Event.Pages.Count > 0)
            {
                EventGraphic gfx = Event.Pages[0].Graphic;
                if (gfx.Type == ":file")
                {
                    if (System.IO.File.Exists(Data.ProjectPath + "/" + gfx.Param.ToString() + ".png"))
                    {
                        Sprites["graphic"].Bitmap = new Bitmap(Data.ProjectPath + "/" + gfx.Param.ToString());
                        int dir = 0;
                        if (gfx.NumDirections == 4)
                        {
                            dir = gfx.Direction / 2 - 1;
                        }
                        if (gfx.NumDirections == 8)
                        {
                            dir = gfx.Direction - 1;
                        }
                        Sprites["graphic"].SrcRect.Width  = Sprites["graphic"].Bitmap.Width / gfx.NumFrames;
                        Sprites["graphic"].SrcRect.Height = Sprites["graphic"].Bitmap.Height / gfx.NumDirections;
                        Sprites["graphic"].SrcRect.Y      = Sprites["graphic"].SrcRect.Height * dir;
                    }
                }
                Sprites["graphic"].X = 4;
                Sprites["graphic"].Y = 4;
                if (Sprites["graphic"].Bitmap != null)
                {
                    int    max  = Math.Max(Sprites["graphic"].SrcRect.Width, Sprites["graphic"].SrcRect.Height);
                    double perc = 24d / max;
                    Sprites["graphic"].ZoomX = perc;
                    Sprites["graphic"].ZoomY = perc;
                }
            }
        }
Exemplo n.º 5
0
        public ChooseGraphic(EventGraphic graphic)
        {
            this.OldGraphic  = graphic;
            this.GraphicData = graphic.Clone();
            SetTitle("Choose Graphic");
            MinimumSize = MaximumSize = new Size(735, 421);
            SetSize(MaximumSize);
            Center();

            Label GraphicLabel = new Label(this);

            GraphicLabel.SetFont(Font.Get("Fonts/Ubuntu-B", 16));
            GraphicLabel.SetText("Current Graphic");
            GraphicLabel.SetPosition(559, 35);

            Color outline = new Color(59, 91, 124);
            Color inline  = new Color(17, 27, 38);
            Color filler  = new Color(24, 38, 53);

            Sprites["gfxbox"]        = new Sprite(this.Viewport);
            Sprites["gfxbox"].X      = 542;
            Sprites["gfxbox"].Y      = 59;
            Sprites["gfxbox"].Bitmap = new Bitmap(177, 177);
            Sprites["gfxbox"].Bitmap.Unlock();
            Sprites["gfxbox"].Bitmap.DrawRect(0, 0, 177, 177, outline);
            Sprites["gfxbox"].Bitmap.DrawRect(1, 1, 175, 175, inline);
            Sprites["gfxbox"].Bitmap.FillRect(2, 2, 173, 173, filler);
            Sprites["gfxbox"].Bitmap.FillRect(163, 163, 13, 13, outline);
            Sprites["gfxbox"].Bitmap.DrawLine(162, 1, 162, 162, inline);
            Sprites["gfxbox"].Bitmap.DrawLine(163, 1, 163, 162, outline);
            Sprites["gfxbox"].Bitmap.DrawLine(164, 1, 164, 162, inline);
            Sprites["gfxbox"].Bitmap.DrawLine(165, 162, 174, 162, inline);
            Sprites["gfxbox"].Bitmap.DrawLine(1, 162, 162, 162, inline);
            Sprites["gfxbox"].Bitmap.DrawLine(1, 163, 162, 163, outline);
            Sprites["gfxbox"].Bitmap.DrawLine(1, 164, 162, 164, inline);
            Sprites["gfxbox"].Bitmap.DrawLine(162, 165, 162, 174, inline);
            Sprites["gfxbox"].Bitmap.Lock();

            Container GraphicContainer = new Container(this);

            GraphicContainer.SetPosition(544, 61);
            GraphicContainer.SetSize(160, 160);
            GraphicContainer.HAutoScroll = true;
            GraphicContainer.VAutoScroll = true;
            VScrollBar vs = new VScrollBar(this);

            vs.SetPosition(708, 62);
            vs.SetSize(10, 158);
            GraphicContainer.SetVScrollBar(vs);
            HScrollBar hs = new HScrollBar(this);

            hs.SetPosition(545, 225);
            hs.SetSize(158, 10);
            GraphicContainer.SetHScrollBar(hs);

            Graphic = new PictureBox(GraphicContainer);

            Cursor = new CursorWidget(GraphicContainer);
            Cursor.ConsiderInAutoScrollCalculation = false;

            Font f = Font.Get("Fonts/ProductSans-M", 12);

            TypeLabel = new Label(this);
            TypeLabel.SetPosition(547, 244);
            TypeLabel.SetFont(f);
            TypeLabel.SetText("Type: File");

            Label DirectionLabel = new Label(this);

            DirectionLabel.SetFont(f);
            DirectionLabel.SetText("Direction:");
            DirectionLabel.SetPosition(547, 269);
            DirectionBox = new DropdownBox(this);
            DirectionBox.SetPosition(609, 263);
            DirectionBox.SetSize(110, 25);
            DirectionBox.SetItems(new List <ListItem>()
            {
                new ListItem("Down"),
                new ListItem("Left"),
                new ListItem("Right"),
                new ListItem("Up")
            });
            DirectionBox.SetSelectedIndex(GraphicData.Direction / 2 - 1);
            DirectionBox.OnSelectionChanged += delegate(BaseEventArgs e)
            {
                GraphicData.Direction = (DirectionBox.SelectedIndex + 1) * 2;
                if (GraphicData.NumDirections == 1)
                {
                    GraphicData.NumDirections = 4;
                    NumDirectionsBox.SetSelectedIndex(1);
                }
                RedrawGraphic();
            };

            Label NumDirectionsLabel = new Label(this);

            NumDirectionsLabel.SetFont(f);
            NumDirectionsLabel.SetText("Number of Directions:");
            NumDirectionsLabel.SetPosition(547, 308);
            NumDirectionsBox = new DropdownBox(this);
            NumDirectionsBox.SetPosition(679, 304);
            NumDirectionsBox.SetSize(40, 25);
            NumDirectionsBox.SetItems(new List <ListItem>()
            {
                new ListItem("1"),
                new ListItem("4")
            });
            NumDirectionsBox.SetSelectedIndex(GraphicData.NumDirections == 1 ? 0 : 1);
            NumDirectionsBox.OnSelectionChanged += delegate(BaseEventArgs e)
            {
                GraphicData.NumDirections = NumDirectionsBox.SelectedIndex == 0 ? 1 : 4;
                RedrawGraphic();
            };

            Label NumFramesLabel = new Label(this);

            NumFramesLabel.SetFont(f);
            NumFramesLabel.SetText("Number of Frames:");
            NumFramesLabel.SetPosition(547, 348);
            NumFramesBox = new NumericBox(this);
            NumFramesBox.SetPosition(669, 343);
            NumFramesBox.SetSize(50, 27);
            NumFramesBox.MinValue = 1;
            NumFramesBox.MaxValue = 999;
            NumFramesBox.SetValue(GraphicData.NumFrames);
            NumFramesBox.OnValueChanged += delegate(BaseEventArgs e)
            {
                GraphicData.NumFrames = NumFramesBox.Value;
                RedrawGraphic();
            };

            FileExplorer = new FileExplorer(this);
            FileExplorer.SetPosition(1, 24);
            FileExplorer.SetSize(529, 396);
            FileExplorer.SetBaseDirectory(Data.ProjectPath);
            FileExplorer.SetFileExtensions("png");
            string dir = "";

            if (GraphicData.Param != null)
            {
                List <string> dirs = ((string)GraphicData.Param).Split('/').ToList();
                for (int i = 0; i < dirs.Count - 1; i++)
                {
                    dir += dirs[i];
                    if (i != dirs.Count - 2)
                    {
                        dir += "/";
                    }
                }
            }
            else
            {
                dir = "gfx/characters";
            }
            FileExplorer.SetDirectory(dir);
            FileExplorer.OnFileSelected += delegate(BaseEventArgs e)
            {
                string param = FileExplorer.SelectedFilename.Replace(Data.ProjectPath + "/", "").Replace(".png", "");
                if (param != (string)this.GraphicData.Param)
                {
                    this.GraphicData       = new EventGraphic();
                    this.GraphicData.Type  = ":file";
                    this.GraphicData.Param = param;
                    DirectionBox.SetSelectedIndex(0);
                    NumDirectionsBox.SetSelectedIndex(1);
                    NumFramesBox.SetValue(4);
                    RedrawGraphic();
                }
            };
            FileExplorer.SetSelectedFile((string)GraphicData.Param + ".png");

            CreateButton("Cancel", Cancel);
            Buttons[0].SetPosition(Size.Width - 99, Buttons[0].Position.Y);
            CreateButton("OK", OK);
            Buttons[1].SetPosition(Size.Width - 188, Buttons[1].Position.Y);

            RedrawGraphic();
        }
Exemplo n.º 6
0
 public void Cancel(BaseEventArgs e)
 {
     this.GraphicData = OldGraphic;
     Close();
 }