Ejemplo n.º 1
0
        public void OpenProject(string filePath)
        {
            filePath = Path.GetFullPath(filePath);
            if (!File.Exists(filePath))
            {
                return;
            }

            CloseProject();

            string json = File.ReadAllText(filePath);

            m_projectModel = JsonConvert.DeserializeObject <ProjectModel>(json);
            m_projectModel.WorkingDirectory = Path.GetDirectoryName(filePath);
            m_projectModel.UpdateFromCbp();

            MainForm mainForm = FindForm() as MainForm;

            if (mainForm != null)
            {
                m_projectModel.ApplyToCbp(mainForm.SettingsModel);

                mainForm.LoadSdkMetaFiles();
                mainForm.GenerateProjectMetaFiles();
                mainForm.InitializeGameEditorPages();
                mainForm.SelectTabPage(MainForm.TAB_NAME_BUILD);
                mainForm.AppTitleExtended            = m_projectModel.Name;
                mainForm.ProjectFilesViewer.RootPath = m_projectModel.WorkingDirectory;
            }
        }
Ejemplo n.º 2
0
 private void m_fileSystemWatcher_Deleted(object sender, FileSystemEventArgs e)
 {
     if (ProjectModel != null)
     {
         if ((Path.GetExtension(e.FullPath) == ".h" || Path.GetExtension(e.FullPath) == ".cpp") && ProjectModel.Files.Contains(e.FullPath))
         {
             string hfile   = Path.ChangeExtension(e.FullPath, ".h");
             string cppfile = Path.ChangeExtension(e.FullPath, ".cpp");
             RemoveMetaFile(hfile);
             ProjectModel.Files.Remove(hfile);
             ProjectModel.Files.Remove(cppfile);
             ProjectModel.ApplyToCbp(SettingsModel);
             if (File.Exists(hfile))
             {
                 File.Delete(hfile);
             }
             if (File.Exists(cppfile))
             {
                 File.Delete(cppfile);
             }
         }
         if (m_projectFilesPanel != null)
         {
             m_projectFilesPanel.DoOnUiThread(() => m_projectFilesPanel.RebuildList());
         }
     }
 }
Ejemplo n.º 3
0
        public void SaveProject()
        {
            MainForm mainForm = FindForm() as MainForm;

            if (mainForm != null && m_projectModel != null)
            {
                if (m_projectModel.ApplyToCbp(mainForm.SettingsModel))
                {
                    MetroMessageBox.Show(FindForm(), "Project \"" + m_projectModel.Name + "\" saved!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Ejemplo n.º 4
0
 private void m_fileSystemWatcher_Renamed(object sender, RenamedEventArgs e)
 {
     if (ProjectModel != null)
     {
         if (Path.GetExtension(e.OldFullPath) == ".h" && ProjectModel.Files.Contains(e.OldFullPath))
         {
             string cppPath = Path.ChangeExtension(e.OldFullPath, ".cpp");
             if (File.Exists(cppPath))
             {
                 File.Move(cppPath, Path.ChangeExtension(e.FullPath, ".cpp"));
             }
             ProjectModel.Files.Remove(e.OldFullPath);
             if (Path.GetExtension(e.FullPath) == ".h")
             {
                 ProjectModel.Files.Add(e.FullPath);
                 RenameMetaFile(e.OldFullPath, e.FullPath);
             }
             else
             {
                 RemoveMetaFile(e.OldFullPath);
             }
             ProjectModel.ApplyToCbp(SettingsModel);
         }
         else if (Path.GetExtension(e.OldFullPath) == ".cpp" && ProjectModel.Files.Contains(e.OldFullPath))
         {
             ProjectModel.Files.Remove(e.OldFullPath);
             if (Path.GetExtension(e.FullPath) == ".cpp")
             {
                 ProjectModel.Files.Add(e.FullPath);
                 string hPath = Path.ChangeExtension(e.OldFullPath, ".h");
                 if (File.Exists(hPath))
                 {
                     File.Move(hPath, Path.ChangeExtension(e.FullPath, ".h"));
                 }
             }
             ProjectModel.ApplyToCbp(SettingsModel);
         }
         if (m_projectFilesPanel != null)
         {
             m_projectFilesPanel.DoOnUiThread(() => m_projectFilesPanel.RebuildList());
         }
     }
 }
Ejemplo n.º 5
0
 private void m_fileSystemWatcher_Created(object sender, FileSystemEventArgs e)
 {
     if (ProjectModel != null)
     {
         if (e.FullPath == ProjectModel.WorkingDirectory + @"\" + ProjectModel.EditorCbpPath)
         {
             DoAction(new Action("EditorCbpChanged"));
         }
         else if (e.FullPath == ProjectModel.WorkingDirectory + @"\" + ProjectModel.EditorPluginPath)
         {
             DoAction(new Action("SceneViewPluginChanged"));
         }
         else if ((Path.GetExtension(e.FullPath) == ".h" || Path.GetExtension(e.FullPath) == ".cpp") && !e.FullPath.StartsWith(Path.GetDirectoryName(ProjectModel.WorkingDirectory + @"\" + ProjectModel.EditorCbpPath)))
         {
             string cppFile = Path.ChangeExtension(e.FullPath, ".cpp");
             string hFile   = Path.ChangeExtension(e.FullPath, ".h");
             if (File.Exists(cppFile) && !ProjectModel.Files.Contains(cppFile))
             {
                 ProjectModel.Files.Add(cppFile);
             }
             if (File.Exists(hFile) && !ProjectModel.Files.Contains(hFile))
             {
                 ProjectModel.Files.Add(hFile);
             }
             if (e.FullPath == hFile)
             {
                 GenerateMetaFile(hFile);
             }
             ProjectModel.ApplyToCbp(SettingsModel);
         }
         if (m_projectFilesPanel != null)
         {
             m_projectFilesPanel.DoOnUiThread(() => m_projectFilesPanel.RebuildList());
         }
     }
 }