Esempio n. 1
0
        public MapViewerBase(IContainer Parent) : base(Parent)
        {
            this.SetBackgroundColor(28, 50, 73);
            this.OnWidgetSelected += WidgetSelected;

            GridLayout = new Grid(this);
            GridLayout.SetColumns(
                new GridSize(1),
                new GridSize(11, Unit.Pixels)
                );
            GridLayout.SetRows(
                new GridSize(1),
                new GridSize(11, Unit.Pixels)
                );
            MainContainer             = new Container(GridLayout);
            MainContainer.HAutoScroll = MainContainer.VAutoScroll = true;
            DummyWidget        = new Widget(MainContainer);
            Sprites["hslider"] = new Sprite(this.Viewport, new SolidBitmap(Size.Width - 13, 11, new Color(10, 23, 37)));
            Sprites["vslider"] = new Sprite(this.Viewport, new SolidBitmap(11, Size.Height - 13, new Color(10, 23, 37)));
            Sprites["block"]   = new Sprite(this.Viewport, new SolidBitmap(12, 12, new Color(64, 104, 146)));
            HScrollContainer   = new Container(GridLayout);
            HScrollContainer.SetGridRow(1);
            HScrollBar HScrollBar = new HScrollBar(HScrollContainer);

            HScrollBar.SetPosition(1, 2);
            HScrollBar.SetZIndex(1);
            HScrollBar.SetValue(0.5);
            HScrollBar.OnValueChanged += delegate(BaseEventArgs e)
            {
                if (Editor.MainWindow.MapWidget != null)
                {
                    Editor.MainWindow.MapWidget.SetHorizontalScroll(HScrollBar.Value);
                }
                MouseMoving(Graphics.LastMouseEvent);
            };
            VScrollContainer = new Container(GridLayout);
            VScrollContainer.SetGridColumn(1);
            VScrollBar VScrollBar = new VScrollBar(VScrollContainer);

            VScrollBar.SetPosition(2, 1);
            VScrollBar.SetZIndex(1);
            VScrollBar.SetValue(0.5);
            VScrollBar.OnValueChanged += delegate(BaseEventArgs e)
            {
                if (Editor.MainWindow.MapWidget != null)
                {
                    Editor.MainWindow.MapWidget.SetVerticalScroll(VScrollBar.Value);
                }
                MouseMoving(Graphics.LastMouseEvent);
            };

            MainContainer.SetHScrollBar(HScrollBar);
            MainContainer.SetVScrollBar(VScrollBar);

            Fade = new VignetteFade(MainContainer);
            Fade.ConsiderInAutoScrollCalculation = Fade.ConsiderInAutoScrollPositioning = false;
            Fade.SetZIndex(7);
        }
Esempio n. 2
0
        public HomeScreen(IContainer Parent) : base(Parent)
        {
            SetBackgroundColor(28, 50, 73);
            Sprites["map"] = new Sprite(this.Viewport);
            if (System.IO.File.Exists("home_map.png"))
            {
                Sprites["map"].Bitmap = new Bitmap("home_map.png");
            }
            Sprites["sidebar"]          = new Sprite(this.Viewport, "home_side.png");
            Sprites["logo"]             = new Sprite(this.Viewport, "home_logo.png");
            Sprites["logo"].X           = 33;
            Sprites["logo"].Y           = 4;
            Sprites["text"]             = new Sprite(this.Viewport, new Bitmap(360, 160));
            Sprites["text"].Bitmap.Font = Font.Get("Fonts/Ubuntu-B", 18);
            Sprites["text"].Bitmap.Unlock();
            Sprites["text"].Bitmap.DrawText(Editor.GetVersionString(), 348, 88, Color.WHITE, DrawOptions.RightAlign);
            Sprites["text"].Bitmap.Font = Font.Get("Fonts/Ubuntu-B", 22);
            Sprites["text"].Bitmap.DrawText("Recent Projects:", 38, 126, Color.WHITE, DrawOptions.Underlined);
            Sprites["text"].Bitmap.Lock();
            Sprites["filesel"]         = new Sprite(this.Viewport, new SolidBitmap(2, 38, new Color(0, 205, 255)));
            Sprites["filesel"].X       = 30;
            Sprites["filesel"].Visible = false;
            Sprites["files"]           = new Sprite(this.Viewport);
            Sprites["files"].X         = 42;
            Sprites["files"].Y         = 168;

            NewProjectButton = new HomeScreenButton(this);
            NewProjectButton.SetPosition(445, 108);
            NewProjectButton.SetText("New Project");
            NewProjectButton.SetIcon("home_icon_new");
            NewProjectButton.SetHelpText("Create a new project.");
            NewProjectButton.OnLeftClick += delegate(MouseEventArgs e)
            {
                NewProject();
            };

            OpenProjectButton = new HomeScreenButton(this);
            OpenProjectButton.SetPosition(690, 108);
            OpenProjectButton.SetText("Open Project");
            OpenProjectButton.SetIcon("home_icon_openfile");
            OpenProjectButton.SetHelpText("Open an existing project by selecting its project file.");
            OpenProjectButton.OnLeftClick += delegate(MouseEventArgs e)
            {
                OpenProject();
            };

            TutorialsButton = new HomeScreenButton(this);
            TutorialsButton.SetPosition(935, 108);
            TutorialsButton.SetText("Tutorials");
            TutorialsButton.SetHelpText("Click this button to be directed to various tutorials and documentation for RPG Studio MK.");
            TutorialsButton.SetIcon("home_icon_tutorials");
            TutorialsButton.OnLeftClick += delegate(MouseEventArgs e)
            {
                ShowTutorials();
            };

            YoutubeButton = new PictureBox(this);
            YoutubeButton.Sprite.Bitmap = new Bitmap("home_icon_youtube.png");
            YoutubeButton.SetHelpText("Visit MK's YouTube account.");
            YoutubeButton.OnLeftClick += delegate(MouseEventArgs e)
            {
                new MessageBox("Oops!", "MK does not have a YouTube channel yet!", IconType.Error);
            };

            TwitterButton = new PictureBox(this);
            TwitterButton.Sprite.Bitmap = new Bitmap("home_icon_twitter.png");
            TwitterButton.SetHelpText("Visit MK's Twitter account.");
            TwitterButton.OnLeftClick += delegate(MouseEventArgs e)
            {
                Utilities.OpenLink("http://twitter.com/MKStarterKit");
            };

            NoProjects = new MultilineLabel(this);
            NoProjects.SetSize(320, 100);
            NoProjects.SetPosition(40, 170);
            NoProjects.SetText("You haven't opened any projects recently.\nGet started by creating or opening a project!");
            NoProjects.SetFont(Font.Get("Fonts/Ubuntu-R", 15));

            VignetteFade = new VignetteFade(this);
        }
Esempio n. 3
0
        public TilesetEditor(IContainer Parent) : base(Parent)
        {
            Submodes = new SubmodeView(this);
            Submodes.SetHeaderHeight(31);
            Submodes.SetHeaderWidth(96);
            Submodes.SetHeaderSelHeight(1);
            Submodes.SetTextY(6);

            PassageContainer = Submodes.CreateTab("Passage");
            VignetteFade PassageFade = new VignetteFade(PassageContainer);

            PassageContainer.OnSizeChanged += delegate(BaseEventArgs e) { PassageFade.SetSize(PassageContainer.Size); };

            FourDirContainer = Submodes.CreateTab("4-Dir");
            VignetteFade FourDirFade = new VignetteFade(FourDirContainer);

            FourDirContainer.OnSizeChanged += delegate(BaseEventArgs e) { FourDirFade.SetSize(FourDirContainer.Size); };

            //PriorityContainer = Submodes.CreateTab("Priority");
            //VignetteFade PriorityFade = new VignetteFade(PriorityContainer);
            //PriorityContainer.OnSizeChanged += delegate (BaseEventArgs e) { PriorityFade.SetSize(PriorityContainer.Size); };

            //Submodes.CreateTab("Terrain Tag");
            //Submodes.CreateTab("Bush Flag");
            //Submodes.CreateTab("Counter Flag");

            Container PassageSubContainer = new Container(PassageContainer);

            PassageList = new TilesetDisplay(PassageSubContainer);
            PassageList.OnTilesetLoaded += delegate(BaseEventArgs e) { PassageDrawAll(); };
            PassageList.OnTileClicked   += delegate(MouseEventArgs e) { PassageInput(e); };

            Container FourDirSubContainer = new Container(FourDirContainer);

            FourDirList = new TilesetDisplay(FourDirSubContainer);
            FourDirList.OnTilesetLoaded += delegate(BaseEventArgs e) { FourDirDrawAll(); };
            FourDirList.OnTileClicked   += delegate(MouseEventArgs e) { FourDirInput(e); };

            PassageContainer.SetBackgroundColor(28, 50, 73);
            FourDirContainer.SetBackgroundColor(28, 50, 73);
            //PriorityContainer.SetBackgroundColor(28, 50, 73);

            SharedContainer = new Container(this);
            SharedContainer.SetPosition(22, 41);
            SharedContainer.Sprites["bg"] = new Sprite(SharedContainer.Viewport);
            SimpleFade fade = new SimpleFade(SharedContainer);

            fade.SetPosition(4, 4);
            NameLabel = new Label(SharedContainer);
            NameLabel.SetText("Name");
            NameLabel.SetFont(Font.Get("Fonts/Ubuntu-B", 14));
            NameLabel.SetPosition(19, 16);
            NameBox = new TextBox(SharedContainer);
            NameBox.SetPosition(19, 40);
            NameBox.SetSize(156, 21);
            NameBox.SetSkin(1);
            // Updates tileset list
            NameBox.OnTextChanged += delegate(BaseEventArgs e)
            {
                if (this.Tileset == null)
                {
                    return;
                }
                this.Tileset.Name = NameBox.Text;
                ListItem item = DBDataList.DataList.Items[TilesetID - 1];
                item.Name = item.Name.Split(':')[0] + ": " + this.Tileset.Name;
                DBDataList.DataList.Redraw();
            };

            GraphicLabel = new Label(SharedContainer);
            GraphicLabel.SetFont(Font.Get("Fonts/Ubuntu-B", 14));
            GraphicLabel.SetPosition(19, 79);
            GraphicLabel.SetText("Tileset Graphic");

            GraphicBox = new BrowserBox(SharedContainer);
            GraphicBox.SetPosition(19, 103);
            GraphicBox.SetSize(156, 21);
            GraphicBox.OnDropDownClicked += delegate(BaseEventArgs e)
            {
                OpenFileDialog of = new OpenFileDialog();
                of.SetFilter(new FileFilter("PNG Image", "png"));
                of.SetInitialDirectory(Game.Data.ProjectPath + "/gfx/tilesets");
                of.SetTitle("Pick a tileset...");
                object result = of.Show();
                if (result != null)
                {
                    // Converts path (C:/.../.../tileset_image.png) to filename (tileset_image)
                    string path = result as string;
                    while (path.Contains('\\'))
                    {
                        path = path.Replace('\\', '/');
                    }
                    string[] folders  = path.Split('/');
                    string   file_ext = folders[folders.Length - 1];
                    string[] dots     = file_ext.Split('.');
                    string   file     = "";
                    for (int i = 0; i < dots.Length - 1; i++)
                    {
                        file += dots[i];
                        if (i != dots.Length - 2)
                        {
                            file += '.';
                        }
                    }
                    string tilesetsfolder = Game.Data.ProjectPath + "/gfx/tilesets";
                    // Selected file not in the tilesets folder
                    // Copies source to tilesets folder
                    string chosenparent = System.IO.Directory.GetParent(path).FullName;
                    while (chosenparent.Contains('\\'))
                    {
                        chosenparent = chosenparent.Replace('\\', '/');
                    }
                    if (chosenparent != tilesetsfolder)
                    {
                        MessageBox box = new MessageBox("Error",
                                                        "The selected file doesn't exist in the gfx/tilesets folder. Would you like to copy it in?", ButtonType.YesNo);
                        box.OnButtonPressed += delegate(BaseEventArgs e)
                        {
                            if (box.Result == 0) // Yes
                            {
                                string newfilename = null;
                                if (System.IO.File.Exists(tilesetsfolder + "/" + file_ext))
                                {
                                    int iterator = 1;
                                    while (string.IsNullOrEmpty(newfilename))
                                    {
                                        if (!System.IO.File.Exists(tilesetsfolder + "/" + file + " (" + iterator.ToString() + ")." + dots[dots.Length - 1]))
                                        {
                                            newfilename = tilesetsfolder + "/" + file + " (" + iterator.ToString() + ")." + dots[dots.Length - 1];
                                            file        = file + " (" + iterator.ToString() + ")";
                                        }
                                        iterator++;
                                    }
                                }
                                else
                                {
                                    newfilename = tilesetsfolder + "/" + file_ext;
                                }
                                System.IO.File.Copy(path, newfilename);
                                SetTilesetGraphic(file);
                            }
                        };
                    }
                    // File is in tilesets folder
                    else
                    {
                        SetTilesetGraphic(file);
                    }
                }
            };
            // Updates graphic if typed
            GraphicBox.TextArea.OnWidgetDeselected += delegate(BaseEventArgs e)
            {
                string file = GraphicBox.Text;
                if (!System.IO.File.Exists(Game.Data.ProjectPath + "/gfx/tilesets/" + file + ".png"))
                {
                    new MessageBox("Error", "No tileset with the name '" + file + "' exists in gfx/tilesets.", IconType.Error);
                }
                else
                {
                    SetTilesetGraphic(file);
                }
            };

            ClearTilesetButton = new Button(SharedContainer);
            ClearTilesetButton.SetPosition(25, 150);
            ClearTilesetButton.SetSize(140, 44);
            ClearTilesetButton.SetFont(Font.Get("Fonts/Ubuntu-B", 16));
            ClearTilesetButton.SetText("Clear Tileset");
            ClearTilesetButton.OnClicked += delegate(BaseEventArgs e)
            {
                ConfirmClearTileset();
            };

            Submodes.SelectTab(1);
        }