Exemple #1
0
        private void BackButton_Click(object sender, EventArgs e)
        {
            Form runnerMenuForm = new MainForm.MainForm();

            Hide();
            runnerMenuForm.Show();
        }
        private void backButton_Click(object sender, EventArgs e)
        {
            Form mainForm = new MainForm.MainForm();

            Hide();
            mainForm.Show();
        }
        private void ApplyConfig(MainForm.MainForm mainForm)
        {
            if (CheckForUpdatesOnStartup && AutomaticUpdater.UpdateHeroesPowerPlant(out _))
            {
                mainForm.AfterUpdate();
            }
            else
            {
                if (AutomaticallyLoadLastConfig && File.Exists(LastProjectPath))
                {
                    var config = ProjectConfig.Open(LastProjectPath);
                    ProjectConfig.ApplyInstance(mainForm, config);
                    mainForm.currentSavePath = LastProjectPath;
                }

                if (VSync)
                {
                    mainForm.EnableVSync();
                }
                else
                {
                    mainForm.DisableVSync(); // In case the program default ever changes.
                }
                mainForm.SetCheckForUpdatesOnStartup(CheckForUpdatesOnStartup);
                mainForm.SetAutoLoadLastProject(AutomaticallyLoadLastConfig);
                mainForm.SetAutomaticallySaveConfig(AutomaticallySaveConfig);
            }
        }
Exemple #4
0
        /// <summary>
        /// Reads a specified Config editor config.
        /// </summary>
        /// <param name="fileName"></param>
        public void OpenFile(string fileName, MainForm.MainForm mainForm)
        {
            ProgramIsChangingStuff = true;

            if (Path.GetExtension(fileName).ToLower().Equals(".cc"))
            {
                ReadINIConfig(fileName);
            }
            else if (Path.GetExtension(fileName).ToLower().Equals(".json"))
            {
                ReadJSONConfig(fileName);
            }
            else
            {
                throw new Exception("Error: Unknown file type.");
            }

            OpenConfigFileName   = fileName;
            LabelFileLoaded.Text = "Loaded " + fileName;
            mainForm.EnableSplineEditor();
            SplineEditor.SplineEditorOpenConfig(fileName, mainForm.renderer);
            SplineEditor.buttonSave.Enabled = true;

            ProgramIsChangingStuff = false;
        }
        private void SendUserStatusToMainForm()
        {
            FormsController formsController = FormsControllerImpl.GetInstance();

            MainForm.MainForm mainForm = formsController.GetMainForm();
            mainForm.SetUserRole(GetUserRole());
        }
Exemple #6
0
 public void OpenFile(string fileName, MainForm.MainForm mainForm)
 {
     layoutSystem.SelectedIndexChanged(new int[] { -1 });
     ProgramIsChangingStuff = true;
     layoutSystem.OpenLayoutFile(fileName);
     UpdateObjectComboBox();
     UpdateFileLabel(mainForm);
 }
Exemple #7
0
 public void OpenFile(string fileName, MainForm.MainForm mainForm)
 {
     if (File.Exists(fileName))
     {
         collisionSystem.Open(fileName);
         initFile(mainForm);
     }
 }
 public MainForm.MainForm GetMainForm()
 {
     if (mainForm == null)
     {
         mainForm = new MainForm.MainForm();
     }
     return(mainForm);
 }
        public LoadingForm()
        {
            InitializeComponent();
            desingerService = DesingerServiceImpl.GetInstance();
            desingerService.AddFormToDesinger(this);
            desingerService.AddPanelToChangeColor(progressPanel);

            FormsController formsController = FormsControllerImpl.GetInstance();

            mainForm = formsController.GetMainForm();
        }
Exemple #10
0
        private void UpdateFileLabel(MainForm.MainForm mainForm)
        {
            if (string.IsNullOrEmpty(layoutSystem.CurrentlyOpenFileName))
            {
                openFileLabel.Text = "No file loaded";
            }
            else
            {
                openFileLabel.Text = layoutSystem.CurrentlyOpenFileName;
            }

            Text = "Layout Editor - " + Path.GetFileName(layoutSystem.CurrentlyOpenFileName);
            mainForm.SetLayoutEditorStripItemName(this, Path.GetFileName(layoutSystem.CurrentlyOpenFileName));
        }
Exemple #11
0
        public Crawler(MainForm.MainForm mainForm, string siteToCrawl)
        {
            MainForm = mainForm;

            LoadCrawlingOptions();

            BaseUrl           = new Uri(siteToCrawl);
            semaphore         = new SemaphoreSlim(MaxSemaphores);
            cts               = new CancellationTokenSource();
            crawledPages      = new HashSet <Uri>();
            inLinksData       = new Dictionary <string, InLinksCounter>();
            cancellationToken = default;

            visitedPages = 0;
            pagesTovisit = 1;
        }
Exemple #12
0
        /// <summary>
        /// Loads the current Power Plant Config. Note: Returns a new instance on successful load, throw the old instance away.
        /// </summary>
        public HPPConfig Load(MainForm.MainForm mainForm)
        {
            if (!File.Exists(ConfigPath))
            {
                Save();
                System.Windows.Forms.MessageBox.Show("It appears this is your first time using Heroes Power Plant.\nIf you haven't yet, please check out the Heroes Power Plant wiki on GitHub, as it features a complete guide on using the program and creating custom stages for Sonic Heroes and Shadow the Hedgehog.");
                mainForm.AboutBox.Show();
            }

            string fileText = File.ReadAllText(ConfigPath);

            Instance = JsonConvert.DeserializeObject <HPPConfig>(fileText);
            Instance.ApplyConfig(mainForm);

            return(Instance);
        }
Exemple #13
0
        /// <summary>
        /// Loads the current Power Plant Config. Note: Returns a new instance on successful load, throw the old instance away.
        /// </summary>
        public HPPConfig Load(MainForm.MainForm mainForm)
        {
            if (!File.Exists(ConfigPath))
            {
                Save();
                System.Windows.Forms.MessageBox.Show("It appears this is your first time using Heroes Power Plant.\nIf you haven't yet, please check out readme.md as that file has useful info regarding use of the program.\nThere are also tutorials available on YouTube and Sonic Retro.");
                mainForm.AboutBox.Show();
            }

            string fileText = File.ReadAllText(ConfigPath);

            Instance = JsonConvert.DeserializeObject <HPPConfig>(fileText);
            Instance.ApplyConfig(mainForm);

            return(Instance);
        }
Exemple #14
0
        public void initFile(MainForm.MainForm mainForm)
        {
            progressBarColEditor.Minimum = 0;
            progressBarColEditor.Value   = 0;
            progressBarColEditor.Step    = 1;

            collisionSystem.LoadCLFile(mainForm.renderer.Device, progressBarColEditor);

            Text = "Collision Editor - " + Path.GetFileName(collisionSystem.CurrentCLfileName);
            mainForm.SetCollisionEditorStripItemName(this, Path.GetFileName(collisionSystem.CurrentCLfileName));

            labelFileLoaded.Text = "Loaded " + collisionSystem.CurrentCLfileName;
            labelVertexNum.Text  = "Vertices: " + collisionSystem.NumVertices.ToString();
            labelTriangles.Text  = "Triangles: " + collisionSystem.NumTriangles.ToString();
            labelQuadnodes.Text  = "QuadNodes: " + collisionSystem.NumQuadNodes.ToString();
            if (collisionSystem.DepthLevel != 0)
            {
                numericDepthLevel.Value = collisionSystem.DepthLevel;
            }

            exportOBJToolStripMenuItem.Enabled = true;

            progressBarColEditor.Value = 0;
        }
Exemple #15
0
 /// <summary>
 /// Initialise an new copy item object
 /// </summary>
 public CopyItems(MainForm.MainForm mainForm)
 {
     this._mainForm = mainForm;
 }
Exemple #16
0
        /// <summary>
        /// Loads the appropriate paths stored in the <see cref="ProjectConfig"/> instance into each of the editors.
        /// </summary>
        public static void ApplyInstance(MainForm.MainForm mainForm, ProjectConfig config)
        {
            mainForm.ClearConfig();

            ExecuteIfFilePresent($"Config Editor error: file not found: {config.StageConfigPath}", "Error", config.StageConfigPath, path => mainForm.ConfigEditor.OpenFile(path, mainForm));

            if (config.IsShadow)
            {
                if (Directory.Exists(config.LevelEditorPath))
                {
                    mainForm.LevelEditor.OpenONEShadowFolder(config.LevelEditorPath, true);
                }
                else if (!string.IsNullOrEmpty(config.LevelEditorPath))
                {
                    MessageBox.Show($"Level Editor error: file not found: {config.LevelEditorPath}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                ExecuteIfFilePresent($"Level Editor error: file not found: {config.LevelEditorPath}", "Error", config.LevelEditorPath, path => mainForm.LevelEditor.OpenONEHeroesFile(path, mainForm.renderer));
                ExecuteIfFilePresent($"Visibility Editor error: file not found: {config.VisibilityPath}", "Error", config.VisibilityPath, path => mainForm.LevelEditor.initVisibilityEditor(false, path));
            }

            if (config.CollisionEditorPaths != null)
            {
                foreach (var v in config.CollisionEditorPaths)
                {
                    ExecuteIfFilePresent($"Collision Editor error: file not found: {v}", "Error", v, path => mainForm.AddCollisionEditor(path));
                }
            }
            if (config.LayoutEditorPaths != null)
            {
                foreach (var v in config.LayoutEditorPaths)
                {
                    ExecuteIfFilePresent($"Layout Editor error: file not found: {v}", "Error", v, path => mainForm.AddLayoutEditor(path));
                }
            }

            ExecuteIfFilePresent($"Camera Editor error: file not found: {config.CameraEditorPath}", "Error", config.CameraEditorPath, path => mainForm.CameraEditor.OpenFile(path));
            ExecuteIfFilePresent($"Particle Editor error: file not found: {config.ParticleEditorPath}", "Error", config.ParticleEditorPath, path => mainForm.ParticleEditor.OpenFile(path));
            ExecuteIfFilePresent($"Texture Pattern Editor error: file not found: {config.TexturePatternEditorPath}", "Error", config.TexturePatternEditorPath, path => mainForm.TexturePatternEditor.OpenFile(path));
            ExecuteIfFilePresent($"Light Editor error: file not found: {config.LightEditorPath}", "Error", config.LightEditorPath, path => mainForm.LightEditor.OpenFile(path, config.LightEditorIsShadow));
            ExecuteIfFilePresent($"SET ID Table Editor error: file not found: {config.SetIdTableEditorPath}", "Error", config.SetIdTableEditorPath, path => mainForm.SetIdTableEditor.OpenExternal(path, config.SetIdTableEditorIsShadow));

            if (config.CameraSettings != null)
            {
                mainForm.renderer.Camera.ApplyConfig(config.CameraSettings);
            }

            TextureManager.ClearTextures(mainForm.renderer, mainForm.LevelEditor.bspRenderer);
            if (config.TXDPaths != null)
            {
                foreach (string s in config.TXDPaths)
                {
                    ExecuteIfFilePresent($"Error: TXD file not found: {s}", "Error", s, path => TextureManager.LoadTexturesFromTXD(s, mainForm.renderer, mainForm.LevelEditor.bspRenderer));
                }
            }

            if (config.TextureFolderPaths != null)
            {
                foreach (string s in config.TextureFolderPaths)
                {
                    ExecuteIfFilePresent($"Error: Folder not found: {s}", "Error", s, path => TextureManager.LoadTexturesFromFolder(s, mainForm.renderer, mainForm.LevelEditor.bspRenderer));
                }
            }

            mainForm.renderer.dffRenderer.ClearObjectONEFiles();
            if (config.DFFONEPaths != null)
            {
                mainForm.renderer.dffRenderer.AddDFFFiles(config.DFFONEPaths);
            }

            if (config.RenderingOptions != null)
            {
                mainForm.ApplyConfig(config.RenderingOptions);
                mainForm.ViewConfig.NumericQuadHeight.Value = (decimal)config.RenderingOptions.QuadtreeHeight;
            }
        }
Exemple #17
0
        /// <summary>
        /// Creates a ProjectConfig based on the currently opened files in each of the editors.
        /// </summary>
        public static ProjectConfig FromCurrentInstance(MainForm.MainForm mainForm)
        {
            List <string> colEditorPaths = new List <string>();

            foreach (var v in mainForm.CollisionEditors)
            {
                colEditorPaths.Add(v.GetOpenFileName());
            }

            List <string> layoutEditorPaths = new List <string>();

            foreach (var v in mainForm.LayoutEditors)
            {
                layoutEditorPaths.Add(v.GetOpenFileName());
            }

            return(new ProjectConfig
            {
                // Get info from existing editors.
                IsShadow = mainForm.LevelEditor.isShadowMode,
                LevelEditorPath = mainForm.LevelEditor.GetOpenONEFilePath(),
                StageConfigPath = mainForm.ConfigEditor.GetOpenConfigFileName(),
                VisibilityPath = mainForm.LevelEditor.visibilityFunctions.OpenVisibilityFile,
                CollisionEditorPaths = colEditorPaths,
                LayoutEditorPaths = layoutEditorPaths,
                CameraEditorPath = mainForm.CameraEditor.CurrentCameraFile,
                ParticleEditorPath = mainForm.ParticleEditor.GetCurrentlyOpenParticleFile(),
                TexturePatternEditorPath = mainForm.TexturePatternEditor.GetCurrentlyOpenTXC(),
                LightEditorPath = mainForm.LightEditor.GetCurrentlyOpenLightFile(),
                SetIdTableEditorPath = mainForm.SetIdTableEditor.GetCurrentFileName(),
                LightEditorIsShadow = mainForm.LightEditor.GetIsShadow(),
                SetIdTableEditorIsShadow = mainForm.SetIdTableEditor.GetIsShadow(),
                TXDPaths = TextureManager.OpenTXDfiles,
                TextureFolderPaths = TextureManager.OpenTextureFolders,

                DFFONEPaths = mainForm.renderer.dffRenderer.filePaths,

                CameraSettings = new Camera()
                {
                    CameraPosition = mainForm.renderer.Camera.ViewMatrix.Position,
                    Pitch = mainForm.renderer.Camera.ViewMatrix.Pitch,
                    Speed = mainForm.renderer.Camera.Speed,
                    Yaw = mainForm.renderer.Camera.ViewMatrix.Yaw,
                    FieldOfView = mainForm.renderer.Camera.ProjectionMatrix.FieldOfView,
                    DrawDistance = mainForm.renderer.Camera.ProjectionMatrix.FarPlane
                },

                RenderingOptions = new RenderOptions()
                {
                    QuadtreeHeight = (float)mainForm.ViewConfig.NumericQuadHeight.Value,
                    NoCulling = mainForm.renderer.Device.GetCullMode() == SharpDX.Direct3D11.CullMode.None,
                    Wireframe = mainForm.renderer.Device.GetFillMode() == SharpDX.Direct3D11.FillMode.Wireframe,
                    ShowStartPos = mainForm.renderer.ShowStartPositions,
                    ShowSplines = mainForm.renderer.ShowSplines,
                    RenderByChunk = BSPRenderer.renderByChunk,
                    ShowChunkBoxes = mainForm.renderer.ShowChunkBoxes,
                    ShowCollision = mainForm.renderer.ShowCollision,
                    ShowQuadtree = mainForm.renderer.ShowQuadtree,
                    ShowObjects = mainForm.renderer.ShowObjects,
                    ShowCameras = mainForm.renderer.ShowCameras,
                    BackgroundColor = mainForm.renderer.backgroundColor,
                    SelectionColor = mainForm.renderer.selectedColor,
                }
            });
        }
Exemple #18
0
 //Override Form Close Button
 protected override void OnFormClosed(FormClosedEventArgs e)
 {
     MainForm.MainForm mainForm = new MainForm.MainForm();
     this.Hide();
     mainForm.Show();
 }