Example #1
0
        private void AddPath(string name, string value, string[] allowed_extensions)
        {
            Grid panel = new Grid();

            panel.ColumnDefinitions.Add(new ColumnDefinition());
            panel.ColumnDefinitions.Add(new ColumnDefinition());

            panel.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Star);
            panel.ColumnDefinitions[1].Width = GridLength.Auto;

            TextBox input = new TextBox();

            input.Name   = name;
            input.Text   = value;
            input.Margin = new Thickness(0, 0, 10, 0);
            Grid.SetColumn(input, 0);
            panel.Children.Add(input);

            Button browse = new Button();

            browse.Margin  = new Thickness(0, 0, 10, 0);
            browse.Padding = new Thickness(0, 0, 0, 0);
            browse.Content = I18N.__("Browse");

            Grid.SetColumn(browse, 1);
            panel.Children.Add(browse);

            Grid.SetColumnSpan(panel, 2);
            Grid.SetColumn(panel, 1);
            Grid.SetRow(panel, row);

            this.container.Children.Add(panel);
        }
Example #2
0
        public void AddEntry(string name, string text, Type type, object value)
        {
            this.container.RowDefinitions.Add(new RowDefinition());

            // Label
            Label label = new Label();

            label.Foreground = new SolidColorBrush(Colors.White);
            label.Content    = text + ":";
            label.Margin     = new Thickness(10, 0, 10, 10);
            label.Padding    = new Thickness(2, 5, 2, 5);
            Grid.SetColumn(label, 0);
            Grid.SetRow(label, row);
            this.container.Children.Add(label);

            switch (type)
            {
            case Type.STRING:
                this.AddInput(name, (string)value);
                break;

            case Type.BOOLEAN:
                this.AddBoolean(name, (Boolean)value, I18N.__("True"), I18N.__("False"));
                break;

            case Type.TEXT:
                this.AddText(name, (string)value);
                break;

            case Type.ATLAS:
                this.AddAtlas(name, (string)value);
                break;

            case Type.KTEX:
                this.AddTexture(name, (string)value);
                break;

            case Type.NUMBER:
                this.AddNumber(name, (object)value);
                break;

            case Type.URL:
                this.AddLink(name, (string)value);
                break;

            case Type.STRINGLIST:
                this.AddList(name, (List <string>)value);
                break;

            case Type.YESNO:
                this.AddBoolean(name, (Boolean)value, I18N.__("Yes"), I18N.__("No"));
                break;

            case Type.SELECTION:
                this.AddSelection(name, (Selection)value);
                break;
            }

            ++row;
        }
Example #3
0
        public DSTM() : base()
        {
            this.id   = 245850;
            this.name = I18N.__("Mod Tools");

            this.AddTool("DST_TOOLS", null);
            this.AddSubTool("DST_TOOLS", "FMOD_DESIGNER", "mod_tools/FMOD_Designer/fmod_designer.exe");
            this.AddSubTool("DST_TOOLS", "SPRITER", "mod_tools/Spriter/Spriter.exe");
            this.AddSubTool("DST_TOOLS", "TILED", "mod_tools/Tiled/tiled.exe");
            this.AddSubTool("DST_TOOLS", "TEXTURE_VIEWER", "mod_tools/tools/bin/TextureViewer.exe");

            /*
             * @ToDo add scripts with specific arguments/parameters (see these secripts, check their help files & arguments)
             * compiler_scripts/image_build.py
             * compiler_scripts/properties.py
             * compiler_scripts/properties.pyc
             * compiler_scripts/zipanim.py
             *
             * mod_tools/export.py
             * mod_tools/ExportOptions.py
             * mod_tools/ResizeInfo.py
             * mod_tools/validate.py
             *
             * scripts/ds_to_spriter.py
             * scripts/resize.py
             *
             * tools/bin/ShaderCompiler.exe
             * tools/bin/TextureConverter.exe
             */
        }
Example #4
0
        private void AddSubDebugv2(string node, string name, string header, RoutedEventHandler function)
        {
            void add()
            {
                var menuItem = new MenuItem
                {
                    Name   = name,
                    Header = I18N.__(header),
                };

                menuItem.Click += function;
                var dbg = Boot.Core.IDE.GetDebug();

                foreach (MenuItem item in dbg.Items)
                {
                    if (item.Name == node)
                    {
                        item.Items.Add(menuItem);
                        break;
                    }
                }
            }

            Boot.Core.IDE.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(add));
        }
        private void Tab_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            switch (this.tab.SelectedIndex)
            {
            case 0:
                this.btn_Previous.IsEnabled = false;
                this.tip.Text = I18N.__("Select the specified values of the individual properties to change the configuration of the mod.");
                break;

            case 1:
                this.btn_Previous.IsEnabled = true;
                this.btn_Finish.IsEnabled   = false;
                this.btn_Next.IsEnabled     = true;
                this.tip.Text = I18N.__("Add or delete your mod options.");
                break;

            case 2:
                this.tip.Text             = I18N.__("Chose one or more mod type for your mod type.");
                this.btn_Finish.IsEnabled = true;
                this.btn_Next.IsEnabled   = false;
                break;

            default:
                break;
            }
        }
Example #6
0
        private void dockManager_DocumentClosing(object sender, DocumentClosingEventArgs e)
        {
            bool savedialogfunc(Dialog.Result r)
            {
                switch (r)
                {
                case Dialog.Result.Cancel:
                    e.Cancel = true;
                    break;

                case Dialog.Result.No:
                    //not call SaveActiveDocument() and close
                    break;

                case Dialog.Result.Yes:
                    SaveActiveDocument();
                    //Boot.Core.Workspace.RemoveDocument(GetActiveDocument());
                    break;

                default:
                    e.Cancel = true;
                    break;
                }
                return(true);
            }

            Dialog.Open(I18N.__("Save And close?"), "DSTEd", Dialog.Buttons.YesNoCancel, Dialog.Icon.Warning, savedialogfunc);
        }
Example #7
0
        private void CreateSourceEditor()
        {
            TabItem item = new TabItem();

            item.Header  = I18N.__("Source");
            item.Content = new Code(this.document);
            this.AddChild(item);
        }
Example #8
0
 public DSTS(ARG arg) : base()
 {
     Argument        = arg;
     this.id         = 343050;
     this.name       = I18N.__("Server");
     this.executable = "bin/dontstarve_dedicated_server_nullrenderer.exe";
     AddDebug("Server", null);
     setarg();
 }
Example #9
0
        public DSTC() : base()
        {
            this.id         = 322330;
            this.name       = I18N.__("Client");
            this.executable = "bin/dontstarve_steam.exe";
            this.SetMainGame();

            //this.AddDebug("RUN_DST", this.executable);
            //not supported so far. [Akarinnnnn]:try using another process to run?
        }
Example #10
0
 public DSTS() : base()
 {
     this.id         = 343050;
     this.name       = I18N.__("Server");
     this.executable = "bin/dontstarve_dedicated_server_nullrenderer.exe";
     AddDebug("Server", null);
     AddSubDebug("Server", "Run_debug_server", executable);
     AddSubDebugv2("Server", "KILL", "ShutDown Debug Server", (object sender, RoutedEventArgs arg) => { Shutdown(); });
     AddSubDebugv2("Server", "SPAWN", "Spawn an item",
                   (object a, RoutedEventArgs b) =>
     {
         //TODO: open a dialog, and ask user for item name.
     });
 }
Example #11
0
        private MenuItem AddDebugMenu(string name, string executable)
        {
            MenuItem item = new MenuItem();

            item.Name   = name;
            item.Header = I18N.__(name);

            if (executable != null)
            {
                item.Click += new RoutedEventHandler(delegate(object sender, RoutedEventArgs e) {
                    this.GetDebugger().Attach(this.path + "\\" + this.executable);
                });
            }

            return(item);
        }
Example #12
0
        public void SetSteamProfile(Core.Steam.Workshop profile)
        {
            string picture = @"";
            string name    = @"";

            if (profile == null)
            {
                picture = @"/DSTEd;component/Assets/Icons/warning.png";
                name    = I18N.__("Guest");
            }
            else
            {
                picture = profile.GetPicture();
                name    = profile.GetUsername();
            }

            Logger.Info("PICTURE: " + picture);
            BitmapImage image;

            // base64
            if (picture.StartsWith("data:image"))
            {
                String base64 = picture.Substring(picture.IndexOf(",") + 1);
                byte[] arr    = Convert.FromBase64String(base64);
                image = new BitmapImage();
                using (MemoryStream ms = new MemoryStream(arr))
                {
                    image.BeginInit();
                    image.CacheOption  = BitmapCacheOption.OnLoad;
                    image.StreamSource = ms;
                    image.EndInit();
                    image.Freeze();
                }
            }
            else
            {
                image = new BitmapImage(new Uri(picture, UriKind.RelativeOrAbsolute));
            }
            Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() => {
                PICTURE.Source = image;
                STEAM.Header   = name;
            }));
        }
Example #13
0
        private MenuItem AddToolMenu(string name, string executable)
        {
            MenuItem item = new MenuItem();

            item.Name   = name;
            item.Header = I18N.__(name);

            if (executable != null)
            {
                item.Click += new RoutedEventHandler(delegate(object sender, RoutedEventArgs e) {
                    try {
                        Process.Start(this.GetPath() + "/" + executable);
                    } catch {
                        Logger.Error("Can't open executable: " + this.GetPath() + "/" + executable);
                    }
                });
            }

            return(item);
        }
Example #14
0
        public void Load()
        {
            try {
                KTEX texture = new KTEX(File.OpenRead(this.document.GetFile()));
                if (!texture.IsValid())
                {
                    this.CreateLabel(I18N.__("Texture is Invalid."));
                }
                else
                {
                    Bitmap img = texture.GenerateBitMap();
                    System.Windows.Controls.Image image = new System.Windows.Controls.Image();
                    image.Source = this.ToBitmapImage(img);
                    this.Children.Add(image);
                    //var mipmap = CurrentFile.GetMainMipmap();

                    // EArgs.Size = mipmap.Width + "x" + mipmap.Height;
                }
            } catch (Exception e) {
                this.CreateLabel(I18N.__("Texture can't load: ") + e.Message);
            }
        }
Example #15
0
        public DSTC() : base()
        {
            this.id         = 322330;
            this.name       = I18N.__("Client");
            this.executable = "bin/dontstarve_steam.exe";
            this.SetMainGame();

            //this.AddDebug("RUN_DST", this.executable);
            //not supported so far. [Akarinnnnn]:try using another process to run?

            /*
             *  comment by Bizarrus:
             *
             *  The problem is in the execution.
             *  Here's what we want to do with the client:
             *      - the client should be started by DSTEd
             *      - All output and error streams should run through DSTEd
             *      - The execution must not be started in a separate, encapsulated process,
             *        but must be managed by the main application DSTEd. Otherwise, you cannot
             *        attach yourself to the process.
             */
        }
Example #16
0
        public DebugEntry(string content)
        {
            this.Text        = content;
            this.Padding     = new Thickness(5, 2, 5, 2);
            this.ContextMenu = context;


            context.Add(I18N.__("Copy"), delegate() {
                Clipboard.SetText(this.Text);
            });

            this.IsMouseDirectlyOverChanged += new DependencyPropertyChangedEventHandler(delegate(object sender, DependencyPropertyChangedEventArgs e) {
                if (this.IsMouseOver)
                {
                    this.Background = new SolidColorBrush(Color.FromArgb(100, 237, 92, 45));
                }
                else
                {
                    this.Background = new SolidColorBrush(Colors.Transparent);
                }
            });
        }
Example #17
0
        private void dockManager_DocumentClosing(object sender, DocumentClosingEventArgs e)
        {
            bool savedialogfunc(Dialog.Result r)
            {
                switch (r)
                {
                case Dialog.Result.Cancel:
                    e.Cancel = true;
                    break;

                case Dialog.Result.No:
                    //not call SaveActiveDocument() and close
                    break;

                case Dialog.Result.Yes:
                    SaveActiveDocument();
                    //Boot.Core.Workspace.RemoveDocument(GetActiveDocument());
                    break;

                default:
                    e.Cancel = true;
                    break;
                }

                return(true);
            }

            // Check if the document has changed.
            if ((e.Document.Title).Contains(CHANGED_CHARACTER))
            {
                Dialog.Open(I18N.__("Save And close?"), "DSTEd", Dialog.Buttons.YesNoCancel, Dialog.Icon.Warning, savedialogfunc);
            }
            else
            {
                e.Cancel = true;
            }
        }
        public void InitializeModInfo()
        {
            Core.Contents.Editors.Properties properties = new Core.Contents.Editors.Properties();

            // load defaut modinfo
            string modinfo;

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DSTEd.Project_Templates.BaseMod.modinfo.lua"))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    modinfo = reader.ReadToEnd();
                }
            }
            Core.Klei.Data.ModInfo info = Boot.Core.LUA.GetModInfo(modinfo, null, delegate(ParserException e) {
                Logger.Info("[ProjectWizard ModInfo] " + e);
            });

            if (info.IsBroken())
            {
                return;
            }

            // Build Properties-Editor
            properties.AddCategory(I18N.__("Informations"));
            properties.AddEntry("name", I18N.__("Name"), Core.Contents.Editors.Properties.Type.STRING, info.GetName());
            properties.AddEntry("version", I18N.__("Version"), Core.Contents.Editors.Properties.Type.STRING, info.GetVersion());
            properties.AddEntry("description", I18N.__("Description"), Core.Contents.Editors.Properties.Type.TEXT, info.GetDescription());
            properties.AddEntry("author", I18N.__("Author"), Core.Contents.Editors.Properties.Type.STRING, info.GetAuthor());
            properties.AddEntry("forumthread", I18N.__("Forum-Thread"), Core.Contents.Editors.Properties.Type.URL, info.GetForumThread());
            properties.AddEntry("server_filter_tags", I18N.__("Tags"), Core.Contents.Editors.Properties.Type.STRINGLIST, info.GetTags());

            properties.AddCategory(I18N.__("Assets"));
            properties.AddEntry("icon_atlas", I18N.__("Icon (Atlas)"), Core.Contents.Editors.Properties.Type.ATLAS, info.GetIconAtlas());
            properties.AddEntry("icon", I18N.__("Icon (Texture)"), Core.Contents.Editors.Properties.Type.KTEX, info.GetIcon());

            properties.AddCategory(I18N.__("System"));
            properties.AddEntry("priority", I18N.__("Priority"), Core.Contents.Editors.Properties.Type.NUMBER, info.GetPriority());
            properties.AddEntry("api_version", I18N.__("API Version"), Core.Contents.Editors.Properties.Type.SELECTION, new Core.Contents.Editors.Selection(new Dictionary <object, string> {
                { 6, "Don't Starve" },
                { 10, "Don't Starve Together" }
            }, info.GetAPIVersion()));

            // Only add outdated dst_api_version if it's exists on the modinfo.
            if (info.GetDSTAPIVersion() > 0)
            {
                properties.AddEntry("dst_api_version", I18N.__("API Version (DST)"), Core.Contents.Editors.Properties.Type.SELECTION, new Core.Contents.Editors.Selection(new Dictionary <object, string> {
                    { 6, "6" },
                    { 10, "10" }
                }, info.GetDSTAPIVersion()));
            }

            properties.AddCategory(I18N.__("Compatiblity"));
            properties.AddEntry("dont_starve_compatible", I18N.__("Don't Starve"), Core.Contents.Editors.Properties.Type.YESNO, info.IsDS());
            properties.AddEntry("dst_compatible", I18N.__("Don't Starve Together"), Core.Contents.Editors.Properties.Type.YESNO, info.IsDST());
            properties.AddEntry("reign_of_giants_compatible", I18N.__("Reign of Giants"), Core.Contents.Editors.Properties.Type.YESNO, info.IsROG());
            properties.AddEntry("shipwrecked_compatible", I18N.__("Shipwrecked"), Core.Contents.Editors.Properties.Type.YESNO, info.IsSW());

            properties.AddCategory(I18N.__("Requirements"));
            properties.AddEntry("standalone", I18N.__("Standalone"), Core.Contents.Editors.Properties.Type.YESNO, info.ModsAllowed());
            properties.AddEntry("client_only_mod", I18N.__("Only Client"), Core.Contents.Editors.Properties.Type.YESNO, info.IsOnlyClient());
            properties.AddEntry("all_clients_require_mod", I18N.__("All Clients Required"), Core.Contents.Editors.Properties.Type.YESNO, info.IsRequired());
            properties.AddEntry("restart_require", I18N.__("Restart Required"), Core.Contents.Editors.Properties.Type.YESNO, info.MustRestart());

            this.modinfo.Content = properties;
        }
        public void InitializeModOption()
        {
            Core.Contents.Editors.Properties properties = new Core.Contents.Editors.Properties();

            // load defaut modinfo
            string modinfo;

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DSTEd.Project_Templates.BaseMod.modinfo.lua"))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    modinfo = reader.ReadToEnd();
                }
            }

            Core.Klei.Data.ModInfo info = Boot.Core.LUA.GetModInfo(modinfo, null, delegate(ParserException e) {
                Logger.Info("[ProjectWizard ModInfo] " + e);
            });

            if (info.IsBroken())
            {
                return;
            }

            if (info.GetOptions() != null)
            {
                foreach (Core.Klei.Data.Options entry in info.GetOptions())
                {
                    properties.AddCategory("");
                    properties.AddEntry("name", I18N.__("Name"), Core.Contents.Editors.Properties.Type.STRING, entry.GetName());
                    properties.AddEntry("label", I18N.__("Label"), Core.Contents.Editors.Properties.Type.STRING, entry.GetLabel());
                    if (!(entry.GetHover() == null))
                    {
                        properties.AddEntry("hover", I18N.__("Hover"), Core.Contents.Editors.Properties.Type.STRING, entry.GetHover());
                    }
                    if (!(entry.GetLongLabel() == null))
                    {
                        properties.AddEntry("longlabel", I18N.__("LongLabel"), Core.Contents.Editors.Properties.Type.STRING, entry.GetLongLabel());
                    }

                    if (entry.GetDefaults() == null)
                    {
                        properties.AddEntry("default", I18N.__("Default"), Core.Contents.Editors.Properties.Type.STRING, "NULL");
                    }
                    else if (entry.GetDefaults().GetType() == typeof(string))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Core.Contents.Editors.Properties.Type.STRING, (string)entry.GetDefaults());
                    }
                    else if (entry.GetDefaults().GetType() == typeof(String))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Core.Contents.Editors.Properties.Type.STRING, (String)entry.GetDefaults());
                    }
                    else if (entry.GetDefaults().GetType() == typeof(bool))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Core.Contents.Editors.Properties.Type.YESNO, (bool)entry.GetDefaults());
                    }
                    else if (entry.GetDefaults().GetType() == typeof(Boolean))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Core.Contents.Editors.Properties.Type.YESNO, (Boolean)entry.GetDefaults());
                    }
                    else if (entry.GetDefaults().GetType() == typeof(int))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Core.Contents.Editors.Properties.Type.NUMBER, (int)entry.GetDefaults());
                    }
                    else if (entry.GetDefaults().GetType() == typeof(double))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Core.Contents.Editors.Properties.Type.NUMBER, (double)entry.GetDefaults());
                    }
                    else if (entry.GetDefaults().GetType() == typeof(float))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Core.Contents.Editors.Properties.Type.NUMBER, (float)entry.GetDefaults());
                    }
                    else
                    {
                        properties.AddEntry("default", I18N.__("Default"), Core.Contents.Editors.Properties.Type.STRING, entry.GetDefaults());
                    }

                    this.modoptions.Children.Add(properties);
                }
            }
        }
Example #20
0
        public void Open(string message, string title, Dialog.Buttons buttons, Dialog.Icon icon, Func <Dialog.Result, Boolean> result)
        {
            this.callback_result = result;

            if (title != null)
            {
                this.title.Content = title;
            }

            if (message != null)
            {
                this.message.Text = message;
            }

            switch (icon)
            {
            case Dialog.Icon.Asterisk:
                this.icon.Source = new BitmapImage(new Uri("/DSTEd;component/Assets/Dialog/Asterisk.png", UriKind.Relative));
                break;

            case Dialog.Icon.Error:
                this.icon.Source = new BitmapImage(new Uri("/DSTEd;component/Assets/Dialog/Error.png", UriKind.Relative));
                break;

            case Dialog.Icon.Exclamation:
                this.icon.Source = new BitmapImage(new Uri("/DSTEd;component/Assets/Dialog/Exclamation.png", UriKind.Relative));
                break;

            case Dialog.Icon.Hand:
                this.icon.Source = new BitmapImage(new Uri("/DSTEd;component/Assets/Dialog/Hand.png", UriKind.Relative));
                break;

            case Dialog.Icon.Information:
                this.icon.Source = new BitmapImage(new Uri("/DSTEd;component/Assets/Dialog/Information.png", UriKind.Relative));
                break;

            case Dialog.Icon.None:
                this.icon.Source = null;
                break;

            case Dialog.Icon.Question:
                this.icon.Source = new BitmapImage(new Uri("/DSTEd;component/Assets/Dialog/Question.png", UriKind.Relative));
                break;

            case Dialog.Icon.Stop:
                this.icon.Source = new BitmapImage(new Uri("/DSTEd;component/Assets/Dialog/Stop.png", UriKind.Relative));
                break;

            case Dialog.Icon.Warning:
                this.icon.Source = new BitmapImage(new Uri("/DSTEd;component/Assets/Dialog/Warning.png", UriKind.Relative));
                break;
            }

            if (icon != Dialog.Icon.None)
            {
                this.icon.Width  = 48;
                this.icon.Height = 48;
            }

            switch (buttons)
            {
            case Dialog.Buttons.None:
                this.UpdateButton(this.button_left, I18N.__("OK"), true, this.OnOK);
                this.UpdateButton(this.button_middle, null, false, null);
                this.UpdateButton(this.button_right, null, false, null);
                break;

            case Dialog.Buttons.AbortRetryIgnore:
                this.UpdateButton(this.button_left, I18N.__("Abort"), true, this.OnOK);
                this.UpdateButton(this.button_middle, I18N.__("Retry"), true, this.OnRetry);
                this.UpdateButton(this.button_right, I18N.__("Ignore"), true, this.OnIgnore);
                break;

            case Dialog.Buttons.OK:
                this.UpdateButton(this.button_left, I18N.__("OK"), true, this.OnOK);
                this.UpdateButton(this.button_middle, null, false, null);
                this.UpdateButton(this.button_right, null, false, null);
                break;

            case Dialog.Buttons.OKCancel:
                this.UpdateButton(this.button_left, I18N.__("OK"), true, this.OnOK);
                this.UpdateButton(this.button_middle, I18N.__("Cancel"), true, this.OnCancel);
                this.UpdateButton(this.button_right, null, false, null);
                break;

            case Dialog.Buttons.RetryCancel:
                this.UpdateButton(this.button_left, I18N.__("Retry"), true, this.OnRetry);
                this.UpdateButton(this.button_middle, I18N.__("Cancel"), true, this.OnCancel);
                this.UpdateButton(this.button_right, null, false, null);
                break;

            case Dialog.Buttons.YesNo:
                this.UpdateButton(this.button_left, I18N.__("Yes"), true, this.OnYes);
                this.UpdateButton(this.button_middle, I18N.__("No"), true, this.OnNo);
                this.UpdateButton(this.button_right, null, false, null);
                break;

            case Dialog.Buttons.YesNoCancel:
                this.UpdateButton(this.button_left, I18N.__("Yes"), true, this.OnYes);
                this.UpdateButton(this.button_middle, I18N.__("No"), true, this.OnNo);
                this.UpdateButton(this.button_right, I18N.__("Cancel"), true, this.OnCancel);
                break;
            }

            this.Closing += this.DialogFactory_Closing;

            Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle, new Action(delegate() {
                this.ShowDialog();
            }));
        }
Example #21
0
        private void CreateOptionsEditor()
        {
            Properties properties = new Properties(I18N.__("Options Editor"), "ModOptions", I18N.__("Make settings for the mod in the Options Editor."));

            //try {
            Klei.Data.ModInfo info = Boot.Core.LUA.GetModInfo(this.document.GetFileContent(), null, delegate(ParserException e) {
                Logger.Info("[ModInfo Editor] " + e);
            });

            if (info.IsBroken())
            {
                return;
            }

            if (info.GetOptions() != null)
            {
                foreach (Options entry in info.GetOptions())
                {
                    properties.AddCategory("");
                    properties.AddEntry("name", I18N.__("Name"), Properties.Type.STRING, entry.GetName());
                    properties.AddEntry("label", I18N.__("Label"), Properties.Type.STRING, entry.GetLabel());

                    if (entry.GetDefaults() == null)
                    {
                        properties.AddEntry("default", I18N.__("Default"), Properties.Type.STRING, "NULL");
                    }
                    else if (entry.GetDefaults().GetType() == typeof(string))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Properties.Type.STRING, (string)entry.GetDefaults());
                    }
                    else if (entry.GetDefaults().GetType() == typeof(String))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Properties.Type.STRING, (String)entry.GetDefaults());
                    }
                    else if (entry.GetDefaults().GetType() == typeof(bool))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Properties.Type.YESNO, (bool)entry.GetDefaults());
                    }
                    else if (entry.GetDefaults().GetType() == typeof(Boolean))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Properties.Type.YESNO, (Boolean)entry.GetDefaults());
                    }
                    else if (entry.GetDefaults().GetType() == typeof(int))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Properties.Type.NUMBER, (int)entry.GetDefaults());
                    }
                    else if (entry.GetDefaults().GetType() == typeof(double))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Properties.Type.NUMBER, (double)entry.GetDefaults());
                    }
                    else if (entry.GetDefaults().GetType() == typeof(float))
                    {
                        properties.AddEntry("default", I18N.__("Default"), Properties.Type.NUMBER, (float)entry.GetDefaults());
                    }
                    else
                    {
                        properties.AddEntry("default", I18N.__("Default"), Properties.Type.STRING, entry.GetDefaults());
                    }

                    properties.AddButton("data", I18N.__("Manage Data"), entry);

                    /*
                     * int index = 0;
                     *
                     * foreach (OptionsEntry values in entry.GetOptions()) {
                     *  properties.AddCategory("Value #" + (++index));
                     *  properties.AddEntry("description", I18N.__("Description"), Properties.Type.STRING, (string) values.GetDescription());
                     *  properties.AddEntry("hover", I18N.__("Hover"), Properties.Type.STRING, (string) values.GetHover());
                     *  properties.AddEntry("data", I18N.__("Data"), Properties.Type.STRING, (string) values.GetData());
                     * }*/
                }
            }

            /* } catch (SyntaxErrorException e) {
             *   string message = e.DecoratedMessage;
             *
             *   try {
             *       Match result = new Regex("^chunk_([0-9]+):\\(([0-9]+),([0-9\\-]+)\\): (.*)$").Match(e.DecoratedMessage);
             *
             *       if (result.Success) {
             *           message = string.Format("Line {0} with Position {1}:\n{2}", result.Groups[2].Value, result.Groups[3].Value, result.Groups[4].Value);
             *       }
             *   } catch (Exception) {
             *       /* Do Nothing /
             *   }
             *
             * Dialog.Open("The file is broken:\nmodinfo.lua on " + message + "\n\nPlease fix the problem. The ModInfo editor is deactivated and the view is changed to Code Editor.", I18N.__("Problem - Broken file"), Dialog.Buttons.OK, Dialog.Icon.Error, delegate (Dialog.Result result) {
             *  return true;
             * });
             *
             * properties.Disabled(string.Format(I18N.__("The ModInfo editor is deactivated due to an error.\n\n\n{0}"), message));
             * this.SelectedIndex = 2;
             * }*/

            TabItem item = new TabItem();

            item.Header  = I18N.__("Options");
            item.Content = properties;

            this.AddChild(item);
        }
Example #22
0
        private void CreatePropertiesEditor()
        {
            Properties properties = new Properties(I18N.__("ModInfo Editor"), "ModInfo", I18N.__("With the ModInfo Editor of DSTEd you can easily edit the modinfo.lua of your mods. To do this, select the specified values of the individual properties to change the configuration of the mod."));

            // try {
            Klei.Data.ModInfo info = Boot.Core.LUA.GetModInfo(this.document.GetFileContent(), null, delegate(ParserException e) {
                Logger.Info("[ModInfo Editor] " + e);
            });

            if (info.IsBroken())
            {
                return;
            }

            // Build Properties-Editor
            properties.AddCategory(I18N.__("Informations"));
            properties.AddEntry("name", I18N.__("Name"), Properties.Type.STRING, info.GetName());
            properties.AddEntry("version", I18N.__("Version"), Properties.Type.STRING, info.GetVersion());
            properties.AddEntry("description", I18N.__("Description"), Properties.Type.TEXT, info.GetDescription());
            properties.AddEntry("author", I18N.__("Author"), Properties.Type.STRING, info.GetAuthor());
            properties.AddEntry("forumthread", I18N.__("Forum-Thread"), Properties.Type.URL, info.GetForumThread());
            properties.AddEntry("server_filter_tags", I18N.__("Tags"), Properties.Type.STRINGLIST, info.GetTags());

            properties.AddCategory(I18N.__("Assets"));
            properties.AddEntry("icon_atlas", I18N.__("Icon (Atlas)"), Properties.Type.ATLAS, info.GetIconAtlas());
            properties.AddEntry("icon", I18N.__("Icon (Texture)"), Properties.Type.KTEX, info.GetIcon());

            properties.AddCategory(I18N.__("System"));
            properties.AddEntry("priority", I18N.__("Priority"), Properties.Type.NUMBER, info.GetPriority());
            properties.AddEntry("api_version", I18N.__("API Version"), Properties.Type.SELECTION, new Selection(new Dictionary <object, string> {
                { 6, "Don't Starve" },
                { 10, "Don't Starve Together" }
            }, info.GetAPIVersion()));

            // Only add outdated dst_api_version if it's exists on the modinfo.
            if (info.GetDSTAPIVersion() > 0)
            {
                properties.AddEntry("dst_api_version", I18N.__("API Version (DST)"), Properties.Type.SELECTION, new Selection(new Dictionary <object, string> {
                    { 6, "6" },
                    { 10, "10" }
                }, info.GetDSTAPIVersion()));
            }

            properties.AddCategory(I18N.__("Compatiblity"));
            properties.AddEntry("dont_starve_compatible", I18N.__("Don't Starve"), Properties.Type.YESNO, info.IsDS());
            properties.AddEntry("dst_compatible", I18N.__("Don't Starve Together"), Properties.Type.YESNO, info.IsDST());
            properties.AddEntry("reign_of_giants_compatible", I18N.__("Reign of Giants"), Properties.Type.YESNO, info.IsROG());
            properties.AddEntry("shipwrecked_compatible", I18N.__("Shipwrecked"), Properties.Type.YESNO, info.IsSW());

            properties.AddCategory(I18N.__("Requirements"));
            properties.AddEntry("standalone", I18N.__("Standalone"), Properties.Type.YESNO, info.ModsAllowed());
            properties.AddEntry("client_only_mod", I18N.__("Only Client"), Properties.Type.YESNO, info.IsOnlyClient());
            properties.AddEntry("all_clients_require_mod", I18N.__("All Clients Required"), Properties.Type.YESNO, info.IsRequired());
            properties.AddEntry("restart_require", I18N.__("Restart Required"), Properties.Type.YESNO, info.MustRestart());

            /*} catch(SyntaxErrorException e) {
             *  string message = e.DecoratedMessage;
             *  Dialog.Open("The file is broken:\nmodinfo.lua on " + message + "\n\nPlease fix the problem. The ModInfo editor is deactivated and the view is changed to Code Editor.", I18N.__("Problem - Broken file"), Dialog.Buttons.OK, Dialog.Icon.Error, delegate (Dialog.Result result) {
             *      return true;
             *  });
             *
             *  properties.Disabled(string.Format(I18N.__("The ModInfo editor is deactivated due to an error.\n\n\n{0}"), message));
             *  this.SelectedIndex = 2;
             * }*/

            TabItem item = new TabItem();

            item.Header  = I18N.__("Editor");
            item.Content = properties;

            this.AddChild(item);
        }