Пример #1
0
        private void ButtonOpen_MouseClick(object sender, MouseEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = false;
            DialogResult rep = ofd.ShowDialog();

            if (rep == DialogResult.OK)
            {
                string filepath = ofd.FileName;
                oMap   newm     = new oMap(filepath);
                this.Editer.SetMap(newm);

                //compute a position in the middle of the factory. it's to make sure that the user won't has to search for the factory / don't have to try to stay close to the pos (0;0)
                float mx    = 0f;
                float my    = 0f;
                int   count = 0;
                foreach (MapObject mo in newm.listMO)
                {
                    mx += mo.vpos.X;
                    my += mo.vpos.Y;
                    count++;
                }
                this.Editer.vpos.X = mx / (float)count;
                this.Editer.vpos.Y = my / (float)count;
                this.Editer.RefreshImage();
            }
        }
Пример #2
0
        public Form1()
        {
            InitializeComponent();
            this.KeyDown += new KeyEventHandler(this.Form1_KeyDown);
            this.KeyUp   += new KeyEventHandler(this.Form1_KeyUp);

            this.Map = new oMap();

            this.Editer              = new uiMapEditer(this.Map);
            this.Editer.Parent       = this;
            this.Editer.VirtualWidth = 20f;             // 10f

            this.TB        = new uiToolBox(this.Editer);
            this.TB.Parent = this;
        }
Пример #3
0
        public float VirtualWidth = 5f;                 //represents the width the the virtual area shown in the picture box



        public uiMapEditer(oMap StartMap)
        {
            this.Map = StartMap;

            this.ImageBox              = new PictureBox();
            this.ImageBox.BorderStyle  = BorderStyle.FixedSingle;
            this.ImageBox.SizeChanged += new EventHandler(this.ImageBox_SizeChanged);
            this.ImageBox.MouseDown   += new MouseEventHandler(this.ImageBox_MouseDown);
            this.ImageBox.MouseUp     += new MouseEventHandler(this.ImageBox_MouseUp);
            this.ImageBox.MouseWheel  += new MouseEventHandler(this.ImageBox_MouseWheel);
            this.ImageBox.MouseMove   += new MouseEventHandler(this.ImageBox_MouseMove);

            this.CreateTimerDragAndDrop();

            this.RefreshImage();
        }
Пример #4
0
        private void ButtonNew_MouseClick(object sender, MouseEventArgs e)
        {
            bool canceled = this.AutoAskUserToSaveCurrent();

            if (!canceled)
            {
                //create a new map
                oMap newmap = new oMap();
                //define the map
                this.Editer.SetMap(newmap);
                this.Map = newmap;
                this.ClearActualFile();

                //we reset the edits variable
                this.EditsWereMade = false;
            }
        }
Пример #5
0
        public Form1()
        {
            InitializeComponent();
            this.KeyDown += new KeyEventHandler(this.Form1_KeyDown);
            this.KeyUp   += new KeyEventHandler(this.Form1_KeyUp);
            this.TabContainer.DrawItem += new DrawItemEventHandler(this.TabContainer_DrawItem);
            this.FormClosing           += new FormClosingEventHandler(this.Form1_FormClosing);


            this.Map = new oMap();

            this.Editer                    = new uiMapEditer(this.Map);
            this.Editer.Parent             = this;
            this.Editer.VirtualWidth       = 20f;       // 20f
            this.Editer.UserDidSomeChange += new EventHandler(this.Editer_UserDidSomeChange);


            //load every currently loaded mod
            this.LoadEveryMod();



            this.CreateCraftsEvents();
        }
Пример #6
0
 public void SetMap(oMap newmap)
 {
     this.Map = newmap;
     this.RefreshImage();
     GC.Collect();
 }
Пример #7
0
        private void ButtonOpen_MouseClick(object sender, MouseEventArgs e)
        {
            bool canceled = this.AutoAskUserToSaveCurrent();

            if (!canceled)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Multiselect = false;
                DialogResult rep = ofd.ShowDialog();
                if (rep == DialogResult.OK)
                {
                    //save the actual map. if an error occurre while opening the file, we re-put this object into the map editer.
                    oMap OldMap = this.Editer.Map;


                    string filepath = ofd.FileName;
                    //oMap newm = null; // new oMap(filepath);
                    try
                    {
                        oMap newm = new oMap(filepath);

                        //if some items where not found when opening the map (most likely example: mods needed but not loaded), this variable will be false.
                        if (!newm.EveryItemWhereLoadedCorrectly)
                        {
                            string msg = "Some items may not have been loaded properly.\nThe following mods were loaded when saving this file :";

                            //generate the text to show to the user
                            foreach (string modname in newm.listModNames)
                            {
                                msg += "\n-" + modname;
                            }
                            //show the message
                            MessageBox.Show(msg);
                        }



                        //if an error occurred when opening the map, when creating the oMap object with the filepath, the following part will not execute and the map editer will not be affected a null map object.

                        //define the map.
                        this.Editer.SetMap(newm);
                        this.Map = newm;


                        //compute a position in the middle of the factory. it's to make sure that the user won't has to search for the factory / don't have to try to stay close to the pos (0;0)
                        float mx    = 0f;
                        float my    = 0f;
                        int   count = 0;
                        foreach (MapObject mo in newm.listMO)
                        {
                            mx += mo.vpos.X;
                            my += mo.vpos.Y;
                            count++;
                        }
                        this.Editer.vpos.X = mx / (float)count;
                        this.Editer.vpos.Y = my / (float)count;
                        this.Editer.RefreshImage();


                        //string filename = System.IO.Path.GetFileName(filepath);

                        //set this to the new file opened
                        this.DefineActualFile(filepath);
                        this.EditsWereMade = false;
                    }
                    catch
                    {
                        MessageBox.Show("An error occurred");
                    }
                }
            }
        }