Exemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.Load"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (DesignMode)
                return;

            tssInfo.Text = string.Empty;
            UpdateCursorPos(Vector2.Zero, Vector2.Zero);

            Show();

            // Set the ToolBarVisibility values. Do it here instead of setting the properties to avoid messing up
            // the controls order.
            tbGlobal.ToolBarVisibility = ToolBarVisibility.Global;
            tbMap.ToolBarVisibility = ToolBarVisibility.Map;

            // Enable the update timer
            GlobalState.Instance.IsTickEnabled = true;

            // Create the child form instances
            _frmGrhTreeView = new GrhTreeViewForm();
            _frmGrhTreeView.VisibleChanged += _frmGrhTreeView_VisibleChanged;

            _frmSelectedMapObjs = new SelectedMapObjectsForm();
            _frmSelectedMapObjs.VisibleChanged += _frmSelectedMapObjs_VisibleChanged;

            _frmNPCChatEditor = new NPCChatEditorForm();
            _frmNPCChatEditor.VisibleChanged += _frmNPCChatEditor_VisibleChanged;

            _frmSkeletonEditor = new SkeletonEditorForm();
            _frmSkeletonEditor.VisibleChanged += _frmSkeletonEditor_VisibleChanged;

            _frmDbEditor = new DbEditorForm();
            _frmDbEditor.VisibleChanged += _frmDbEditor_VisibleChanged;

            _frmMusicEditor = new MusicEditorForm();
            _frmMusicEditor.VisibleChanged += _frmMusicEditor_VisibleChanged;

            _frmBodyEditor = new BodyEditorForm();
            _frmBodyEditor.VisibleChanged += _frmBodyEditor_VisibleChanged;

            _frmSoundEditor = new SoundEditorForm();
            _frmSoundEditor.VisibleChanged += _frmSoundEditor_VisibleChanged;

            // Set up some other stuff
            EditMapForm.FormLoaded += EditMapForm_FormLoaded;

            var mapPropertiesTool = ToolManager.Instance.TryGetTool<MapPropertiesTool>();
            if (mapPropertiesTool != null)
                mapPropertiesTool.DockPanel = dockPanel;
            else
            {
                const string errmsg = "Unable to set DockPanel on MapPropertiesTool - couldn't find tool instance.";
                Debug.Fail(errmsg);
            }

            // Load the settings
            LoadDockSettings("User");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.Load"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (DesignMode)
                return;

            tssInfo.Text = string.Empty;
            UpdateCursorPos(Vector2.Zero, Vector2.Zero);

            Show();

            // Set the ToolBarVisibility values. Do it here instead of setting the properties to avoid messing up
            // the controls order.
            tbGlobal.ToolBarVisibility = ToolBarVisibility.Global;
            tbMap.ToolBarVisibility = ToolBarVisibility.Map;

            // Auto-update GrhDatas
            SetStatusMessageLoading("Updating GrhData");
            GlobalState.Instance.AutoUpdateGrhDatas();
            GlobalState.Instance.AutoUpdateMusic();
            GlobalState.Instance.AutoUpdateSounds();
         

            SetStatusMessageLoading("Updating cached GrhData sizes");
            AutomaticGrhDataSizeUpdater.Instance.UpdateSizes();

            // Enable the update timer
            GlobalState.Instance.IsTickEnabled = true;

            // Create the child form instances
            SetStatusMessageLoading("Creating child forms");
            _frmGrhTreeView = new GrhTreeViewForm();
            _frmGrhTreeView.VisibleChanged += _frmGrhTreeView_VisibleChanged;

            _frmSelectedMapObjs = new SelectedMapObjectsForm();
            _frmSelectedMapObjs.VisibleChanged += _frmSelectedMapObjs_VisibleChanged;

            _frmNPCChatEditor = new NPCChatEditorForm();
            _frmNPCChatEditor.VisibleChanged += _frmNPCChatEditor_VisibleChanged;

            _frmSkeletonEditor = new SkeletonEditorForm();
            _frmSkeletonEditor.VisibleChanged += _frmSkeletonEditor_VisibleChanged;

            _frmDbEditor = new DbEditorForm();
            _frmDbEditor.VisibleChanged += _frmDbEditor_VisibleChanged;

            _frmMusicEditor = new MusicEditorForm();
            _frmMusicEditor.VisibleChanged += _frmMusicEditor_VisibleChanged;

            _frmBodyEditor = new BodyEditorForm();
            _frmBodyEditor.VisibleChanged += _frmBodyEditor_VisibleChanged;

            _frmSoundEditor = new SoundEditorForm();
            _frmSoundEditor.VisibleChanged += _frmSoundEditor_VisibleChanged;

            _frmGrhTilesetForm = new GrhTilesetForm();
            _frmGrhTilesetForm.VisibleChanged += new EventHandler(_frmGrhTilesetForm_VisibleChanged);

            // Set up some other stuff
            var mapPropertiesTool = ToolManager.Instance.TryGetTool<MapPropertiesTool>();
            if (mapPropertiesTool != null)
                mapPropertiesTool.DockPanel = dockPanel;
            else
            {
                const string errmsg = "Unable to set DockPanel on MapPropertiesTool - couldn't find tool instance.";
                Debug.Fail(errmsg);
            }

            // Load the settings
            SetStatusMessageLoading("Loading user settings");
            LoadDockSettings("User");

            // Set up map state control listeners & display initial values
            SetStatusMessageLoading("Hooking up map events");
            GlobalState.Instance.Map.LayerDepthChanged -= Map_LayerDepthChanged;
            GlobalState.Instance.Map.LayerDepthChanged += Map_LayerDepthChanged;

            GlobalState.Instance.Map.LayerChanged -= Map_LayerChanged;
            GlobalState.Instance.Map.LayerChanged += Map_LayerChanged;

            Map_LayerChanged(GlobalState.Instance, EventArgs.Empty);
            Map_LayerDepthChanged(GlobalState.Instance, EventArgs.Empty);

            // Clean up bad maps
            SetStatusMessageLoading("Validating map ids");
            MapHelper.DeleteMissingMapIds();

            // Load the initial map
            SetStatusMessageLoading("Loading the initial map");
            var validMaps = MapHelper.FindAllMaps().ToArray();
            if (validMaps.Length > 0)
            {
                MapID initialMapId = (MapID)EditorSettings.Default.InitialMapId;
                IMapTable initialMap = validMaps.FirstOrDefault(x => x.ID == initialMapId);

                if (initialMap == null)
                    initialMap = validMaps.MinElement(x => x.ID);

                CreateEditMapForm(initialMap);
            }

            // Global not currently used...
            tbGlobal.Visible = false;

            // Bind help
            SetStatusMessageLoading("Setting up F1 help");
            var helpManager = EditorHelpManager.Instance;
            helpManager.StatusLabel = tssInfo;
            helpManager.Add(cmbLayer, "Map Layers", "Map layers");
            helpManager.Add(trackBarDepth, "Layer Depth", "Layer depth");

            SetStatusMessage(string.Empty);
        }