Example #1
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     if (!Program.LoadGlobalData())
     {
         return;
     }
     Program.Editor        = new EditorForm();
     Program.Start         = new StartForm();
     Program.Debug         = new DebugLog();
     Program.Preferences   = new PreferencesForm();
     Program.ImportScreens = new ImportScreensForm();
     Application.Run(Editor);
 }
Example #2
0
            public TilesetsTab(EditorForm parent)
            {
                form = parent;

                form.tileset_list.SelectedIndexChanged += delegate {
                    if (form.tileset_list.SelectedItems.Count > 0)
                    {
                        Bitmap b = Program.LoadBitmap(Program.OpenStory.Path + @"\Tilesets\" + form.tileset_list.SelectedItems[0].Text);
                        b.MakeTransparent(Color.Magenta);
                        form.tileset_view.Image = b;
                        form.tileset_view.Tag   = Program.OpenStory.Path + @"\Tilesets\" + form.tileset_list.SelectedItems[0].Text;
                        form.tileset_label.Text = form.tileset_list.SelectedItems[0].Text;
                    }
                };
            }
Example #3
0
            public GradientsTab(EditorForm parent)
            {
                form = parent;

                form.gradient_list.ListViewItemSorter    = lvItemComparer;
                form.gradient_list.SelectedIndexChanged += delegate {
                    if (form.gradient_list.SelectedItems.Count > 0)
                    {
                        form.gradient_view.BackgroundImage = Program.LoadBitmap(Program.OpenStory.Path + @"\Gradients\" + form.gradient_list.SelectedItems[0].Text);
                        form.gradient_view.Tag             = Program.OpenStory.Path + @"\Gradients\" + form.gradient_list.SelectedItems[0].Text;
                        form.gradient_label.Text           = form.gradient_list.SelectedItems[0].Text;
                    }
                };

                form.gradient_tileCheck.CheckedChanged += delegate {
                    form.gradient_view.BackgroundImageLayout = form.gradient_view.BackgroundImageLayout == ImageLayout.Tile ? ImageLayout.None : ImageLayout.Tile;
                };
            }
Example #4
0
            public MapTab(EditorForm parent)
            {
                form = parent;

                form.map_mainView.TheStory      = Program.OpenStory;
                form.map_mainView.UpdateScreen += delegate(int x, int y) {
                    parent.screen.ChangeScreen(x, y);
                };
                form.map_mainView.UpdateStatus += delegate(int x, int y) {
                    form.toolStripStatusLabel1.Text = "x" + x + ", y" + y;
                };
                form.map_showThumbs.CheckedChanged += map_showThumbs_CheckChanged;

                form.button7.Click += delegate {
                    Program.ImportScreens.Show();
                };
                form.button8.Click += delegate(object sender, EventArgs e) {
                    if (overwrite > 0)
                    {
                        if (MessageBox.Show("This action will overwrite " + overwrite + " screens. Do you wish to continue? This action cannot be undone.",
                                            "Paste Screens",
                                            MessageBoxButtons.OKCancel,
                                            MessageBoxIcon.Warning) == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                    int activeX = Program.ActiveScreen.X;
                    int activeY = Program.ActiveScreen.Y;
                    form.map_mainView.ConfirmPaste();
                    form.screen.ChangeScreen(activeX, activeY);
                    form.map_mainView.DrawMap(); // TODO remove redundant redraw
                    ((Control)sender).Enabled = false;
                    form.button9.Enabled      = false;
                };
                form.button9.Click += delegate(object sender, EventArgs e) {
                    form.map_mainView.CancelPaste();
                    ((Control)sender).Enabled = false;
                    form.button8.Enabled      = false;
                };
            }
Example #5
0
            public WorldIniTab(EditorForm parent)
            {
                form = parent;

                CreateMenuCollections();

                form.worldIni_goToWorld.Click           += delegate { scrollToLine("[world]"); };
                form.worldIni_goToCutsceneMusic.Click   += delegate { scrollToLine("[cutscene music]"); };
                form.worldIni_goToCurrentScreen.Click   += delegate { scrollToLine("[x" + Program.ActiveScreen.X + "y" + Program.ActiveScreen.Y + "]"); };
                form.worldIni_screenX.ValueChanged      += goToScreen;
                form.worldIni_screenY.ValueChanged      += goToScreen;
                form.worldIni_customObject.ValueChanged += delegate { scrollToLine("[custom object " + form.worldIni_customObject.Value + "]"); };

                form.contextMenuStrip4.Opening += contextMenuStrip4_Opening;

                //form.scintilla1.ConfigurationManager.Language = "props";
                //form.scintilla1.ConfigurationManager.Configure();
                //form.scintilla1.Lexing.LexerName = "props";

                //Font theFont = new Font("Courier New", 8);

                //form.scintilla1.Styles[0].ForeColor = Color.Black;
                //form.scintilla1.Styles[0].Font = theFont;

                //form.scintilla1.Styles[1].ForeColor = Color.Gray;
                //form.scintilla1.Styles[1].Font = theFont;

                //form.scintilla1.Styles[2].ForeColor = Color.Green;
                //form.scintilla1.Styles[2].Font = theFont;

                //form.scintilla1.Styles[3].ForeColor = Color.Gray;
                //form.scintilla1.Styles[3].Font = theFont;

                //form.scintilla1.Styles[5].ForeColor = Color.Blue;
                //form.scintilla1.Styles[5].Font = theFont;

                //form.scintilla1.Folding.IsEnabled = true;
            }
Example #6
0
            public OverviewTab(EditorForm parent)
            {
                form = parent;

                this.overlay = form.overview_info.Image;
                form.overview_overlayCheck.CheckedChanged += this.overlayCheck_CheckedChanged;
                form.overview_publish.MouseClick          += this.publish_MouseClick;

                form.overview_author.TextChanged += delegate(object sender, EventArgs e) { Program.OpenStory.Author = ((TextBox)sender).Text; };
                form.overview_title.TextChanged  += delegate(object sender, EventArgs e) {
                    Program.OpenStory.Title = ((TextBox)sender).Text;
                    form.Text = Program.OpenStory.Title + " - Story Crafter";
                };
                form.overview_description.TextChanged += delegate(object sender, EventArgs e) { Program.OpenStory.Description = ((TextBox)sender).Text; };

                form.overview_size.TextChanged += delegate(object sender, EventArgs e) { Program.OpenStory.Size = ((ComboBox)sender).Text; };

                form.overview_catA.TextChanged += delegate(object sender, EventArgs e) { Program.OpenStory.CategoryA = ((ComboBox)sender).Text; };
                form.overview_catB.TextChanged += delegate(object sender, EventArgs e) { Program.OpenStory.CategoryB = ((ComboBox)sender).Text; };

                form.overview_diffA.TextChanged += delegate(object sender, EventArgs e) { Program.OpenStory.DifficultyA = ((ComboBox)sender).Text; };
                form.overview_diffB.TextChanged += delegate(object sender, EventArgs e) { Program.OpenStory.DifficultyB = ((ComboBox)sender).Text; };
                form.overview_diffC.TextChanged += delegate(object sender, EventArgs e) { Program.OpenStory.DifficultyC = ((ComboBox)sender).Text; };
            }
Example #7
0
            public ScreenTab(EditorForm parent)
            {
                form = parent;

                // These timers are used to create a delay between changing the tileset/gradient and redrawing the screen.
                // Otherwise, the program would freeze up when a user scrolled through the tilesets/gradients.

                this.TimerA = new System.Timers.Timer()
                {
                    AutoReset = false, Interval = 75
                };
                this.TimerA.Elapsed += ChangeTilesetA;
                this.TimerB          = new System.Timers.Timer()
                {
                    AutoReset = false, Interval = 75
                };
                this.TimerB.Elapsed += ChangeTilesetB;
                this.TimerGrad       = new System.Timers.Timer()
                {
                    AutoReset = false, Interval = 75
                };
                this.TimerGrad.Elapsed += ChangeGradient;

                form.screen_tilesetA.ValueChanged += tilesetA_ValueChanged;
                form.screen_tilesetB.ValueChanged += tilesetB_ValueChanged;
                form.screen_gradient.ValueChanged += gradient_ValueChanged;

                form.screen_tilesetViewA.MouseUp += delegate(Object sender, MouseEventArgs e) {
                    this.activeTileset = 0;
                    this.selection     = form.screen_tilesetViewA.Selection;
                    form.screen_tilesetViewB.Active = false;
                };
                form.screen_tilesetViewB.MouseUp += delegate(Object sender, MouseEventArgs e) {
                    this.activeTileset = 1;
                    this.selection     = form.screen_tilesetViewB.Selection;
                    form.screen_tilesetViewA.Active = false;
                };
                form.screen_objectList.LargeImageList           = new ImageList();
                form.screen_objectList.LargeImageList.ImageSize = new Size(24, 24);
                Program.SendMessage(form.screen_objectList.Handle, 0x1000 + 53, IntPtr.Zero, (IntPtr)(((ushort)(30)) | (uint)((50) << 16))); // Sets margins and spacing.

                form.screen_bankList.SelectedIndexChanged += bankList_SelectedIndexChanged;
                foreach (ObjectBank b in Program.Banks)
                {
                    form.screen_bankList.Items.Add(b.Index + ". " + b.Name);
                }

                form.screen_mainView.GetCanvas += delegate() {
                    return(editingPattern == null ? (ICanvas)Program.ActiveScreen : (ICanvas)editingPattern);
                };
                form.screen_mainView.GetLayer += delegate() {
                    return(editingPattern == null ? Program.ActiveScreen.Layers[GetActiveLayer()] : editingPattern.Layers[GetActiveLayer()]);
                };
                form.screen_mainView.GetTool += delegate() {
                    return(currentTool);
                };
                form.screen_mainView.GetSelection += delegate() {
                    return(selection);
                };
                form.screen_mainView.GetBrushSize += delegate() {
                    return(new Size(this.brushSizeX, this.brushSizeY));
                };
                form.screen_mainView.GetTilesetIndex += delegate() {
                    return(activeTileset);
                };
                form.screen_mainView.GetObject += delegate() {
                    return(new Tuple <int, int>(Program.Banks.ByAbsoluteIndex(form.screen_bankList.SelectedIndex).Index,
                                                form.screen_objectList.SelectedIndices.Count > 0 ? form.screen_objectList.SelectedIndices[0] : 0)); // TODO make more robust?
                };
                form.screen_mainView.GetTilesetA += delegate() {
                    return(TilesetA);
                };
                form.screen_mainView.GetTilesetB += delegate() {
                    return(TilesetB);
                };
                form.screen_mainView.GetGradient += delegate() {
                    return(Gradient);
                };
                // TODO move to function
                form.screen_mainView.MouseUp += delegate(Object sender, MouseEventArgs e) {
                    if (e.Button == MouseButtons.Right)
                    {
                        int  layer = GetActiveLayer();
                        int  x     = (int)(e.X / 24f);
                        int  y     = (int)(e.Y / 24f);
                        Tile t     = editingPattern == null ? Program.ActiveScreen.Layers[layer].Tiles[y * Program.ScreenWidth + x] :
                                     editingPattern.Layers[layer].Tiles[y * Program.ScreenWidth + x];
                        if (layer < 4)
                        {
                            activeTileset = t.Tileset;
                            if (activeTileset == 0)
                            {
                                form.screen_tilesetViewA.Active = true;
                                form.screen_tilesetViewB.Active = false;
                                selection = form.screen_tilesetViewA.Selection;
                            }
                            else
                            {
                                form.screen_tilesetViewA.Active = false;
                                form.screen_tilesetViewB.Active = true;
                                selection = form.screen_tilesetViewB.Selection;
                            }
                            selection.Clear();
                            Point p = Program.TilesetIndexToPoint(t.Index);
                            selection.Add(new Rectangle(p.X, p.Y, 1, 1));
                            form.screen_tilesetViewA.Refresh();
                            form.screen_tilesetViewB.Refresh();
                        }
                        else
                        {
                            ObjectBank bank = Program.Banks[t.Bank];
                            int        idx  = bank.AbsoluteIndex;
                            int        obj  = bank.AbsoluteIndexOf(t.Index);
                            if (idx < form.screen_bankList.Items.Count && obj >= 0 && obj < bank.Count)
                            {
                                form.screen_bankList.SelectedIndex = idx;
                                form.screen_objectList.SelectedIndices.Clear();
                                form.screen_objectList.SelectedIndices.Add(obj);
                                form.screen_objectList.EnsureVisible(form.screen_objectList.SelectedIndices[0]);
                            }
                        }
                    }
                };

                TabPage pg = form.tabControl1.TabPages["tabPageScreen"];

                layerSelectors = new Tuple <RadioButton, Label> [8];
                for (int i = 0; i < 8; i++)
                {
                    layerSelectors[i] = new Tuple <RadioButton, Label>(
                        (RadioButton)pg.Controls["screen_layer" + i],
                        (Label)pg.Controls["screen_layer" + i + "Label"]
                        );
                    layerSelectors[i].Item1.Tag      = i;
                    layerSelectors[i].Item1.MouseUp += layerSelector_MouseUp;
                }

                // TODO fix hotkeys
                form.screen_mainView.Click += delegate {
                    form.tabControl1.Focus();
                };
                form.tabControl1.KeyUp += delegate(object sender, KeyEventArgs e) {
                    switch (e.KeyCode)
                    {
                    case Keys.W:
                        if (editingPattern == null && e.Shift)
                        {
                            this.ChangeScreen(Program.ActiveScreen.X, Program.ActiveScreen.Y - 1);
                        }
                        else
                        {
                            selection.Translate(0, -1);
                            form.screen_tilesetViewA.Refresh();
                            form.screen_tilesetViewB.Refresh();
                        }
                        break;

                    case Keys.A:
                        if (editingPattern == null && e.Shift)
                        {
                            this.ChangeScreen(Program.ActiveScreen.X - 1, Program.ActiveScreen.Y);
                        }
                        else
                        {
                            selection.Translate(-1, 0);
                            form.screen_tilesetViewA.Refresh();
                            form.screen_tilesetViewB.Refresh();
                        }
                        break;

                    case Keys.S:
                        if (editingPattern == null && e.Shift)
                        {
                            this.ChangeScreen(Program.ActiveScreen.X, Program.ActiveScreen.Y + 1);
                        }
                        else
                        {
                            selection.Translate(0, 1);
                            form.screen_tilesetViewA.Refresh();
                            form.screen_tilesetViewB.Refresh();
                        }
                        break;

                    case Keys.D:
                        if (editingPattern == null && e.Shift)
                        {
                            this.ChangeScreen(Program.ActiveScreen.X + 1, Program.ActiveScreen.Y);
                        }
                        else
                        {
                            selection.Translate(1, 0);
                            form.screen_tilesetViewA.Refresh();
                            form.screen_tilesetViewB.Refresh();
                        }
                        break;

                    case Keys.D0:
                        form.screen_layer0.Checked = true;
                        break;

                    case Keys.D1:
                        form.screen_layer1.Checked = true;
                        break;

                    case Keys.D2:
                        form.screen_layer2.Checked = true;
                        break;

                    case Keys.D3:
                        form.screen_layer3.Checked = true;
                        break;

                    case Keys.D4:
                        form.screen_layer4.Checked = true;
                        break;

                    case Keys.D5:
                        form.screen_layer5.Checked = true;
                        break;

                    case Keys.D6:
                        form.screen_layer6.Checked = true;
                        break;

                    case Keys.D7:
                        form.screen_layer7.Checked = true;
                        break;
                    }
                };

                form.screen_comboPatterns.Items.Add("");
                form.screen_comboPatterns.SelectedIndex = 0;
                // TODO move to function
                form.screen_buttonEditPattern.Click += delegate {
                    if (editingPattern == null)
                    {
                        form.screen_tilesetA.Enabled            = false;
                        form.screen_tilesetB.Enabled            = false;
                        form.screen_gradient.Enabled            = false;
                        form.screen_music.Enabled               = false;
                        form.screen_ambiA.Enabled               = false;
                        form.screen_ambiB.Enabled               = false;
                        form.screen_comboPatterns.DropDownStyle = ComboBoxStyle.Simple;
                        form.screen_buttonEditPattern.Text      = "Save";
                        form.screen_mainView.Resizable          = true;
                        if (form.screen_comboPatterns.SelectedIndex <= 0)
                        {
                            editingPattern = new Pattern(GetActiveLayer());
                            newPattern     = true;
                            for (int i = 0; i < 8; i++)
                            {
                                layerSelectors[i].Item2.Enabled = layerSelectors[i].Item1.Checked;
                            }
                        }
                        else
                        {
                            editingPattern            = Program.OpenStory.Patterns[form.screen_comboPatterns.SelectedIndex - 1];
                            form.screen_mainView.Size = new Size(editingPattern.Width * 24 + 2, editingPattern.Height * 24 + 2);
                            for (int i = 0; i < 8; i++)
                            {
                                layerSelectors[i].Item2.Enabled = editingPattern.Layers[i].Active;
                            }
                        }
                        form.screen_checkBoxOverwrite.Visible = true;
                        form.screen_checkBoxOverwrite.Checked = editingPattern.Overwrite;
                        form.screen_mainView.Draw();
                    }
                    else
                    {
                        if (form.screen_comboPatterns.Text == "" &&
                            MessageBox.Show("Please enter a name for your pattern, or press Cancel to discard.", "Enter Pattern Name", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                        {
                            return;
                        }
                        if (form.screen_comboPatterns.Text != "")
                        {
                            editingPattern.Name = form.screen_comboPatterns.Text;
                            if (newPattern)
                            {
                                Program.OpenStory.Patterns.Add(editingPattern);
                                form.screen_comboPatterns.Items.Add(editingPattern.Name);
                                form.screen_comboPatterns.SelectedIndex = form.screen_comboPatterns.Items.Count - 1;
                            }
                            else
                            {
                                form.screen_comboPatterns.Items[Program.OpenStory.Patterns.IndexOf(editingPattern) + 1] = editingPattern.Name;
                                form.screen_buttonEditPattern.Text = "Edit";
                            }
                            ((PatternTool)tools[4]).Source = editingPattern;
                        }
                        else
                        {
                            form.screen_comboPatterns.SelectedIndex = 0;
                        }
                        newPattern = false;
                        form.screen_tilesetA.Enabled            = true;
                        form.screen_tilesetB.Enabled            = true;
                        form.screen_gradient.Enabled            = true;
                        form.screen_music.Enabled               = true;
                        form.screen_ambiA.Enabled               = true;
                        form.screen_ambiB.Enabled               = true;
                        form.screen_comboPatterns.DropDownStyle = ComboBoxStyle.DropDown;
                        form.screen_mainView.Resizable          = false;
                        form.screen_mainView.Size               = new Size(Program.PxScreenWidth + 2, Program.PxScreenHeight + 2);
                        for (int i = 0; i < 8; i++)
                        {
                            layerSelectors[i].Item2.Enabled = Program.ActiveScreen.Layers[i].Active;
                        }
                        form.screen_checkBoxOverwrite.Visible = false;
                        editingPattern = null;
                        form.screen_mainView.Draw();
                    }
                };
                form.screen_comboPatterns.SelectedIndexChanged += delegate {
                    if (form.screen_comboPatterns.SelectedIndex == 0)
                    {
                        form.screen_buttonEditPattern.Text = "New";
                        ((PatternTool)tools[4]).Source     = null;
                    }
                    else if (editingPattern == null)
                    {
                        form.screen_buttonEditPattern.Text = "Edit";
                        ((PatternTool)tools[4]).Source     = Program.OpenStory.Patterns[form.screen_comboPatterns.SelectedIndex - 1];
                    }
                };
                form.screen_checkBoxOverwrite.CheckedChanged += delegate {
                    editingPattern.Overwrite = form.screen_checkBoxOverwrite.Checked;
                };

                this.selection = form.screen_tilesetViewA.Selection;
                form.screen_tilesetViewA.Active = true;

                tools = new List <EditingTool>(5);
                tools.Add(new PaintTool());
                tools.Add(new FillTool());
                tools.Add(new ReplaceTool());
                tools.Add(new RandomizeTool());
                tools.Add(new PatternTool());
                currentTool = tools[0];
            }
Example #8
0
 public MusicTab(EditorForm parent)
 {
     form = parent;
 }
Example #9
0
 public CutscenesTab(EditorForm parent)
 {
     form = parent;
 }
Example #10
0
 public AmbianceTab(EditorForm parent)
 {
     form = parent;
 }
Example #11
0
 public ObjectsTab(EditorForm parent)
 {
     form = parent;
 }