コード例 #1
0
        public void LoadLabels(Surface surface)
        {
            for (int c = 0; c < surface.Width; ++c)
            {
                for (int r = 0; r < surface.Height; ++r)
                {
                    string label = surface.GetSpecialInfo(c, r);

                    if (label.Length > 0 && !listBox2.Items.Contains(label))
                    {
                        listBox2.Items.Add(label);
                    }
                }
            }
        }
コード例 #2
0
 private void ShiftControl_Load(object sender, EventArgs e)
 {
     surfacePanel = (Parent as EditorForm).SurfacePanel;
     surface = surfacePanel.Surface;
 }
コード例 #3
0
ファイル: Surface.cs プロジェクト: Natman64/SurfaceEditor
        public static Surface FromFile(string path)
        {
            Surface surface = new Surface();

            surface.FilePath = path;

            StreamReader reader = new StreamReader(path);
            string line = "";

            //COLORS
            line = reader.ReadLine();
            line = reader.ReadLine();

            Dictionary<char, Color> colors = new Dictionary<char, Color>();

            do
            {
                string[] split = line.Split(' ');

                char key = split[0][0];

                string r = split[1];
                string g = split[2];
                string b = split[3];

                colors[key] = Color.FromArgb(int.Parse(r), int.Parse(g), int.Parse(b));
            } while ((line = reader.ReadLine()) != "INFO CODES"); //Do-while loop used because COLORS will never be an empty section

            Dictionary<char, string> infoCodes = new Dictionary<char, string>();

            //INFO CODES
            while ((line = reader.ReadLine()) != "SIZE") //While loop used here because INFO CODES may be an empty section
            {
                string[] split = line.Split(' ');

                char key = split[0][0];
                string code = split[1];

                if (code == ".") code = "";

                infoCodes[key] = code;
            }

            //SIZE
            line = reader.ReadLine();

            string[] dimensions = line.Split(' ');

            int width = int.Parse(dimensions[0]);
            int height = int.Parse(dimensions[1]);

            surface.SetWidth(width);
            surface.SetHeight(height);

            //CHARACTERS
            line = reader.ReadLine();

            for (int r = 0; r < height; ++r) //for loop used because this section will have fixed size
            {
                line = reader.ReadLine();

                for (int c = 0; c < width; ++c)
                {
                    char character = line[c];

                    surface.SetCharacter(c, r, character);
                }
            }

            //BACKGROUND COLORS
            line = reader.ReadLine();

            for (int r = 0; r < height; ++r) //for loop used because this section will have fixed size
            {
                line = reader.ReadLine();

                for (int c = 0; c < width; ++c)
                {
                    char key = line[c];

                    surface.SetBackgroundColor(c, r, colors[key]);
                }
            }

            //CHARACTER COLORS
            line = reader.ReadLine();

            for (int r = 0; r < height; ++r) //for loop used because this section will have fixed size
            {
                line = reader.ReadLine();

                for (int c = 0; c < width; ++c)
                {
                    char key = line[c];

                    surface.SetCharacterColor(c, r, colors[key]);
                }
            }

            //OPACITY
            line = reader.ReadLine();

            for (int r = 0; r < height; ++r) //for loop used because this section will have fixed size
            {
                line = reader.ReadLine();

                for (int c = 0; c < width; ++c)
                {
                    char opacity = line[c];

                    surface.SetCellOpacity(c, r, opacity == '1');
                }
            }

            //SPECIAL INFO
            line = reader.ReadLine();

            for (int r = 0; r < height; ++r) //for loop used because this section will have fixed size
            {
                line = reader.ReadLine();

                for (int c = 0; c < width; ++c)
                {
                    char key = line[c];

                    if (key != ' ')
                    {
                        surface.SetSpecialInfo(c, r, infoCodes[key]);
                    }
                }
            }

            reader.Close();

            return surface;
        }
コード例 #4
0
ファイル: EditorForm.cs プロジェクト: Natman64/SurfaceEditor
        private void SetSurface(Surface surface)
        {
            surfacePanel1.Surface = surface;
            surfacePanel1.UpdateScrollBars();
            surfacePanel1.Refresh();

            //prepare the editor now that a new surface has been loaded.

            cellInfo1.Surface = surfacePanel1.Surface;
            cellInfo1.Enabled = true;

            toolbox1.Enabled = true;

            SpecialInfoControl.ClearLabels();
            SpecialInfoControl.LoadLabels(surface);
        }