Exemple #1
0
        //call on loading to set up the project
        //return a string message if there is a problem or null if everything is okay
        public string Setup()
        {
            //Game.ini
            Ini = new GameIni();
            if (File.Exists(System.IO.Path.Combine(Directory, "Game.ini")))
            {
                Ini.Deserialize(File.ReadAllText(System.IO.Path.Combine(Directory, "Game.ini")));
            }
            else
            {
                return("There was an error reading Game.ini");
            }

            //Load RTP(s)
            FindRTPs();

            //Ruby
            Ruby = new Ruby();

            //Scripts.rxdata
            Scripts = new ScriptHive();
            Ruby.PopulateScriptHive(Scripts);

            //MapInfos.rxdata
            Maps = new MapInfos();
            Ruby.PopulateMapInfos(Maps);
            Maps.FinishedLoading();

            return(null);
        }
Exemple #2
0
        //we need an actual value copy for temporary modification in the script editor
        public ScriptHive Clone()
        {
            ScriptHive clone = new ScriptHive();

            foreach (Script s in Scripts)
            {
                clone.AddScript(s.Clone());
            }
            return(clone);
        }
        public DialogScriptEditor()
        {
            InitializeComponent();
            //setup scintilla
            scintilla.Lexer = ScintillaNET.Lexer.Ruby;

            scintilla.StyleResetDefault();
            scintilla.Styles[Style.Default].Font = "Consolas";
            scintilla.Styles[Style.Default].Size = 10;
            scintilla.StyleClearAll();

            scintilla.Styles[ScintillaNET.Style.Ruby.Default].Font          = "Consolas";
            scintilla.Styles[ScintillaNET.Style.Ruby.CommentLine].Font      = "Consolas";
            scintilla.Styles[ScintillaNET.Style.Ruby.Default].Size          = 10;
            scintilla.Styles[ScintillaNET.Style.Ruby.CommentLine].ForeColor = Color.ForestGreen;
            scintilla.Styles[ScintillaNET.Style.Ruby.Pod].ForeColor         = Color.ForestGreen;
            scintilla.Styles[ScintillaNET.Style.Ruby.Number].ForeColor      = Color.DarkRed;
            scintilla.Styles[ScintillaNET.Style.Ruby.Word].ForeColor        = Color.Navy;
            scintilla.Styles[ScintillaNET.Style.Ruby.WordDemoted].ForeColor = Color.Violet;
            scintilla.Styles[ScintillaNET.Style.Ruby.String].ForeColor      = Color.Purple;
            scintilla.Styles[ScintillaNET.Style.Ruby.Character].ForeColor   = Color.Indigo;
            scintilla.Styles[ScintillaNET.Style.Ruby.Operator].ForeColor    = Color.SteelBlue;
            scintilla.Styles[ScintillaNET.Style.Ruby.Regex].ForeColor       = Color.OrangeRed;
            scintilla.Styles[ScintillaNET.Style.Ruby.Global].ForeColor      = Color.DarkSlateGray;
            scintilla.Styles[ScintillaNET.Style.Ruby.Symbol].ForeColor      = Color.Olive;
            scintilla.SetKeywords(0, @"BEGIN END __ENCODING__ __END__ __FILE__ __LINE__ alias and begin break case class def defined? do else elsif end ensure false for if in module next nil not or redo rescue return self super then true undef unless until when while yield");
            //scintilla.SetKeywords(1, @"Audio Graphics Input RPG Bitmap Color Font Plane Rect Sprite Table Tilemap Tone Viewport Window RGSSError");

            scintilla.EdgeColumn       = 80;
            scintilla.EdgeMode         = ScintillaNET.EdgeMode.Line;
            scintilla.EdgeColor        = Color.Gray;
            scintilla.Margins[0].Width = 16;
            scintilla.TextChanged     += scintilla_TextChanged;

            FormClosed += DialogScriptEditor_FormClosed;
            listBoxScripts.SelectedIndexChanged += ListBoxScripts_SelectedIndexChanged;
            Scripts = Editor.Project.CreateTemporaryScriptHive();
            //if the script hive is empty, let's add a blank script so that there is a starting point
            if (Scripts.Scripts.Count == 0)
            {
                Scripts.AddScript(new Script(0, "", ""));
            }

            //quickload first script
            textBoxScriptName.Text = Scripts.Scripts[0].Name;
            scintilla.Text         = Scripts.Scripts[0].Contents;
            scintilla.Focus();
            scintilla.CurrentPosition = Scripts.Scripts[0].lastPosition;

            RefreshScriptList();
            listBoxScripts.SelectedIndex = 0;

            textBoxScriptName.TextChanged += TextBoxScriptName_TextChanged;
        }
Exemple #4
0
 public void PopulateScriptHive(ScriptHive hive)
 {
     try
     {
         List <dynamic> scrArray = ToList(rbhelper.load_scripts());
         foreach (dynamic scr in scrArray)
         {
             hive.AddScript(new Script((int)scr[0], scr[1].ToString(), GameData.DataHelper.Inflate(((IronRuby.Builtins.MutableString)scr[2]).ConvertToBytes())));
         }
     }
     catch (Exception e)
     {
         System.Windows.Forms.MessageBox.Show(e.Message);
     }
 }
Exemple #5
0
        //call on loading to set up the project
        //return a string message if there is a problem or null if everything is okay
        public string Setup()
        {
            //Game.ini
            Ini = new GameIni();
            if (File.Exists(System.IO.Path.Combine(Directory, "Game.ini")))
            {
                Ini.Deserialize(File.ReadAllText(System.IO.Path.Combine(Directory, "Game.ini")));
            }
            else
            {
                return("There was an error reading Game.ini");
            }

            //Load RTP(s)
            FindRTPs();

            //Ruby
            Ruby = new Ruby();

            //Scripts.rxdata
            Scripts = new ScriptHive();
            Ruby.PopulateScriptHive(Scripts);

            //Database
            Database = new Database();
            Ruby.PopulateDatabase(Database);

            //MapInfos.rxdata
            Maps = new MapInfos();
            Ruby.PopulateMapInfos(Maps);
            Maps.FinishedLoading();

            //setup starting position
            MapHandler.startMapId = Database.System.start_map_id;
            MapHandler.startMapX  = Database.System.start_x;
            MapHandler.startMapY  = Database.System.start_y;

            return(null);
        }
Exemple #6
0
 public void WriteScriptHive(ScriptHive hive)
 {
     try
     {
         IronRuby.Builtins.RubyArray ra = new IronRuby.Builtins.RubyArray();
         foreach (Script s in hive.Scripts)
         {
             IronRuby.Builtins.RubyArray ra_entry = new IronRuby.Builtins.RubyArray();
             ra_entry.Add(s.MagicNumber);
             ra_entry.Add(s.Name);
             var ms = new IronRuby.Builtins.MutableString();
             ms = ms.ChangeEncoding(IronRuby.Builtins.RubyEncoding.Binary, true);
             ms.Append(GameData.DataHelper.Deflate(s.Contents));
             ra_entry.Add(ms);
             ra.Add(ra_entry);
         }
         rbhelper.save_scripts(ra);
     }
     catch (Exception e)
     {
         System.Windows.Forms.MessageBox.Show(e.Message);
     }
 }