public static void Register() { Action <Func <bool> > register = (f) => { var attributes = f.Method.GetCustomAttributes(false); var uniquename = UniqueNameAttribute.GetUniqueName(attributes); if (uniquename != null) { Shortcuts.SetFunction(uniquename, f); } }; register(New); register(Open); register(Overwrite); register(SaveAs); register(Exit); register(Play); register(Stop); register(Step); register(BackStep); register(Undo); register(Redo); register(Copy); register(Paste); register(PasteInfo); register(AddNode); register(InsertNode); register(RemoveNode); }
public static void Terminate() { Core.SaveBackup(System.IO.Path.GetTempPath() + "/efk_quit.efkbac"); var entryDirectory = GetEntryDirectory(); System.IO.Directory.SetCurrentDirectory(entryDirectory); SaveWindowConfig(ConfigFilePath); foreach (var p in panels) { if (p != null) { p.DispatchDisposed(); } } if (effectViewer != null) { effectViewer.DispatchDisposed(); } Network.Save(); Shortcuts.SeveShortcuts(); RecentFiles.SaveRecentConfig(); Network.Dispose(); Network = null; Viewer.HideViewer(); Viewer.Dispose(); Viewer = null; if (MainViewImage != null) { MainViewImage.Dispose(); MainViewImage = null; } NativeManager.SetCallback(null); NativeManager.Terminate(); Images.Unload(); if (HardwareDevice != null) { HardwareDevice.Dispose(); HardwareDevice = null; } swig.MainWindow.Terminate(); MainWindow.Dispose(); MainWindow = null; ThumbnailManager.Terminate(); swig.IO.Terminate(); IO.Dispose(); IO = null; }
public static void Terminate() { System.IO.Directory.SetCurrentDirectory(GetEntryDirectory()); Manager.NativeManager.SaveDock("config.Dock.config"); SaveWindowConfig("config.Dock.xml"); foreach (var p in panels) { if (p != null) { p.DispatchDisposed(); } } if (effectViewer != null) { effectViewer.DispatchDisposed(); } Shortcuts.SeveShortcuts(); RecentFiles.SaveRecentConfig(); Viewer.HideViewer(); NativeManager.SetCallback(null); NativeManager.Terminate(); Images.Unload(); }
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { bool handle = false; Shortcuts.ProcessCmdKey(ref msg, keyData, ref handle); if (handle) { return(true); } return(base.ProcessCmdKey(ref msg, keyData)); }
public static void Initialize() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); configGuiPath = System.IO.Path.Combine(GetEntryDirectory(), ConfigGuiFileName); configGuiPanelPath = System.IO.Path.Combine(GetEntryDirectory(), ConfigGuiPanelFileName); configRecentPath = System.IO.Path.Combine(GetEntryDirectory(), ConfigRecentFileName); configNetworkPath = System.IO.Path.Combine(GetEntryDirectory(), ConfigNetworkFileName); Shortcuts.LoadShortcuts(); Commands.Regist(); LoadRecentConfig(); Network = new Network(); MainForm = new MainForm(); AboutForm = new AboutForm(); DockViewer = new DockViewer(); DockViewerController = new DockViewerController(); DockViewPoint = new DockViewPoint(); DockRecorder = new GUI.DockRecorder(); DockNodeTreeView = new DockNodeTreeView(); DockNodeCommonValues = new GUI.DockNodeCommonValues(); DockNodeLocationValues = new GUI.DockNodeLocationValues(); DockNodeRotationValues = new GUI.DockNodeRotationValues(); DockNodeScalingValues = new GUI.DockNodeScaleValues(); DockNodeLocationAbsValues = new GUI.DockNodeLocationAbsValues(); DockNodeGenerationLocationValues = new DockNodeGenerationLocationValues(); DockNodeDepthValues = new DockNodeDepthValues(); DockNodeRendererCommonValues = new GUI.DockNodeRendererCommonValues(); DockNodeRendererCommonValues2 = new GUI.DockNodeRendererCommonValues2(); DockNodeDrawingValues = new GUI.DockNodeRendererValues(); DockNodeSoundValues = new GUI.DockNodeSoundValues(); DockOption = new GUI.DockOption(); DockGlobal = new GUI.DockGlobal(); DockEffectBehavior = new GUI.DockEffectBehavior(); DockFCurves = new GUI.DockFCurves(); DockCulling = new GUI.DockCulling(); DockNetwork = new GUI.DockNetwork(); DockFileViewer = new GUI.DockFileViewer(); MainForm.Show(); LoadConfig(); DockViewer.ShowViewer(); Core.MainForm = MainForm; }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (Commands.SaveOnDisposing()) { } else { e.Cancel = true; return; } GUIManager.SaveConfig(); Shortcuts.SeveShortcuts(); }
public static void Terminate() { var entryDirectory = GetEntryDirectory(); System.IO.Directory.SetCurrentDirectory(entryDirectory); Manager.NativeManager.SaveDock(entryDirectory + "/config.Dock.config"); SaveWindowConfig(entryDirectory + "/config.Dock.xml"); foreach (var p in panels) { if (p != null) { p.DispatchDisposed(); } } if (effectViewer != null) { effectViewer.DispatchDisposed(); } Network.Save(); Shortcuts.SeveShortcuts(); RecentFiles.SaveRecentConfig(); Viewer.HideViewer(); NativeManager.SetCallback(null); NativeManager.Terminate(); Images.Unload(); swig.MainWindow.Terminate(); MainWindow.Dispose(); MainWindow = null; ThumbnailManager.Terminate(); swig.IO.Terminate(); IO.Dispose(); IO = null; }
private void DockNodeTreeView_Load(object sender, EventArgs e) { Func <Func <bool>, ToolStripMenuItem> create_menu_item_from_commands = (a) => { var item = new ToolStripMenuItem(); var attributes = a.Method.GetCustomAttributes(false); var uniquename = UniqueNameAttribute.GetUniqueName(attributes); item.Text = NameAttribute.GetName(attributes); item.ShowShortcutKeys = true; item.ShortcutKeyDisplayString = Shortcuts.GetShortcutText(uniquename); item.Click += (object _sender, EventArgs _e) => { a(); }; return(item); }; contextMenuStrip.SuspendLayout(); var items = contextMenuStrip.Items; items.Add(create_menu_item_from_commands(Commands.AddNode)); items.Add(create_menu_item_from_commands(Commands.InsertNode)); items.Add(create_menu_item_from_commands(Commands.RemoveNode)); items.Add(new ToolStripSeparator()); items.Add(create_menu_item_from_commands(Commands.Copy)); items.Add(create_menu_item_from_commands(Commands.Paste)); items.Add(create_menu_item_from_commands(Commands.PasteInfo)); items.Add(new ToolStripSeparator()); items.Add(create_menu_item_from_commands(Commands.Undo)); items.Add(create_menu_item_from_commands(Commands.Redo)); contextMenuStrip.ResumeLayout(); contextMenuStrip.PerformLayout(); }
public static void Update() { if (isFontSizeDirtied) { NativeManager.InvalidateFont(); var appDirectory = Manager.GetEntryDirectory(); var type = Core.Option.Font.Value; NativeManager.ClearAllFonts(); var characterTable = System.IO.Path.Combine(appDirectory, "resources/languages/characterTable.txt"); if (type == Data.FontType.Normal) { NativeManager.AddFontFromFileTTF(System.IO.Path.Combine(appDirectory, MultiLanguageTextProvider.GetText("Font_Normal")), characterTable, MultiLanguageTextProvider.GetText("CharacterTable"), Core.Option.FontSize.Value); } else if (type == Data.FontType.Bold) { NativeManager.AddFontFromFileTTF(System.IO.Path.Combine(appDirectory, MultiLanguageTextProvider.GetText("Font_Bold")), characterTable, MultiLanguageTextProvider.GetText("CharacterTable"), Core.Option.FontSize.Value); } NativeManager.AddFontFromAtlasImage(System.IO.Path.Combine(appDirectory, "resources/icons/MenuIcons.png"), 0xec00, 24, 24, 16, 16); isFontSizeDirtied = false; } // Reset IO.Update(); Shortcuts.Update(); Network.Update(); var handle = false; if (!handle) { if (!NativeManager.IsAnyItemActive()) { Shortcuts.ProcessCmdKey(ref handle); } } var mousePos = NativeManager.GetMousePosition(); if (isFirstUpdate) { mousePos_pre = mousePos; } if ((effectViewer == null && !NativeManager.IsAnyWindowHovered()) || (effectViewer != null && effectViewer.IsHovered)) { var result = ControllViewport(); if (result.Slide) { var dx = mousePos.X - mousePos_pre.X; var dy = mousePos.Y - mousePos_pre.Y; if (Core.Option.ViewerMode.Value == Data.OptionValues.ViewMode._3D) { Viewer.Slide(dx / 30.0f, dy / 30.0f); } else if (Core.Option.ViewerMode.Value == Data.OptionValues.ViewMode._2D) { Viewer.Slide(dx / 16.0f, dy / 16.0f); } } else if (NativeManager.GetMouseWheel() != 0) { Viewer.Zoom(NativeManager.GetMouseWheel()); } else if (result.Zoom) { var dx = mousePos.X - mousePos_pre.X; var dy = mousePos.Y - mousePos_pre.Y; Viewer.Zoom(-dy * 0.25f); } else if (result.Rotate) { var dx = mousePos.X - mousePos_pre.X; var dy = mousePos.Y - mousePos_pre.Y; if (Core.Option.ViewerMode.Value == Data.OptionValues.ViewMode._3D) { Viewer.Rotate(dx, dy); } else if (Core.Option.ViewerMode.Value == Data.OptionValues.ViewMode._2D) { Viewer.Slide(dx / 16.0f, dy / 16.0f); } } } mousePos_pre = mousePos; Viewer.UpdateViewer(); Native.UpdateWindow(); Native.ClearWindow(50, 50, 50, 0); //if(effectViewer == null) //{ // Native.RenderWindow(); //} NativeManager.ResetGUI(); if (resetCount < 0) { resetCount++; if (resetCount == 0) { Application.Current.OnResetWindowActually(); } } if (resizedCount > 0) { resizedCount--; } Controls.Lock(); foreach (var c in Controls.Internal) { c.Update(); } foreach (var _ in Controls.Internal) { if (!_.ShouldBeRemoved) { continue; } var dp = _ as Dock.DockPanel; if (dp != null) { dp.DispatchDisposed(); } } foreach (var _ in Controls.Internal) { if (!_.ShouldBeRemoved) { continue; } Controls.Remove(_); } Controls.Unlock(); for (int i = 0; i < dockTypes.Length; i++) { if (panels[i] != null && panels[i].ShouldBeRemoved) { panels[i] = null; } } NativeManager.RenderGUI(resizedCount == 0); Native.Present(); NativeManager.Present(); isFirstUpdate = false; // TODO more smart // When minimized, suppress CPU activity if (actualWidth == 0) { System.Threading.Thread.Sleep(16); } }
public static bool Initialize(int width, int height, swig.DeviceType deviceType, Type[] dockTypes_) { dockTypes = dockTypes_; var appDirectory = Manager.GetEntryDirectory(); swig.MainWindowState state = new swig.MainWindowState(); if (System.Environment.OSVersion.Platform == PlatformID.Win32NT) { IsWindowFrameless = true; } // TODO : refactor var windowConfig = new Configs.WindowConfig(); if (windowConfig.Load(ConfigFilePath)) { state.PosX = windowConfig.WindowPosX; state.PosY = windowConfig.WindowPosY; state.Width = windowConfig.WindowWidth; state.Height = windowConfig.WindowHeight; state.IsMaximumMode = windowConfig.WindowIsMaximumMode; } else { state.PosX = -10000; // nodata state.Width = 1280; state.Height = 720; windowConfig = null; } state.IsFrameless = IsWindowFrameless; if (!swig.MainWindow.Initialize("Effekseer", state, false, deviceType == swig.DeviceType.OpenGL)) { return(false); } MainWindow = swig.MainWindow.GetInstance(); swig.IO.Initialize(1000); IO = swig.IO.GetInstance(); ioCallback = new ManagerIOCallback(); IO.AddCallback(ioCallback); Core.OnFileLoaded += (string path) => { #if DEBUG Console.WriteLine("OnFileLoaded : " + path); #endif var f = IO.LoadIPCFile(path); if (f == null) { f = IO.LoadFile(path); } // TODO : refactor it // Permission error if (f != null && f.GetSize() == 0) { var message = MultiLanguageTextProvider.GetText("PermissionError_File"); if (swig.GUIManager.IsMacOSX()) { message += "\n"; message += MultiLanguageTextProvider.GetText("PermissionError_File_Mac"); } message = string.Format(message, System.IO.Path.GetFileName(path)); throw new FileLoadPermissionException(message); } if (f == null) { return(null); } byte[] ret = new byte[f.GetSize()]; System.Runtime.InteropServices.Marshal.Copy(f.GetData(), ret, 0, ret.Length); f.Dispose(); return(ret); }; ThumbnailManager.Initialize(); var mgr = new swig.GUIManager(); if (mgr.Initialize(MainWindow, deviceType)) { } else { mgr.Dispose(); mgr = null; return(false); } Native = new swig.Native(); Viewer = new Viewer(Native); if (!Viewer.ShowViewer(mgr.GetNativeHandle(), state.Width, state.Height, deviceType)) { mgr.Dispose(); mgr = null; return(false); } mgr.InitializeGUI(Native); NativeManager = mgr; Images.Load(GUI.Manager.Native); guiManagerCallback = new GUIManagerCallback(); NativeManager.SetCallback(guiManagerCallback); panels = new Dock.DockPanel[dockTypes.Length]; // Load font UpdateFont(); // Load window icon NativeManager.SetWindowIcon(System.IO.Path.Combine(appDirectory, "resources/icon.png")); // Load config RecentFiles.LoadRecentConfig(); Shortcuts.LoadShortcuts(); Commands.Register(); // Add controls Application.Current.OnCreateMainMenu(); dockManager = new GUI.Dock.DockManager(); GUI.Manager.AddControl(dockManager); // EffectViwer Application.Current.OnCreateEffectViwer(); if (LoadWindowConfig(ConfigFilePath)) { } else { ResetWindow(); } TextOffsetY = (NativeManager.GetTextLineHeightWithSpacing() - NativeManager.GetTextLineHeight()) / 2; Network = new Network(Native); Network.Load(); Command.CommandManager.Changed += OnChanged; Core.EffectBehavior.Location.X.OnChanged += OnChanged; Core.EffectBehavior.Location.Y.OnChanged += OnChanged; Core.EffectBehavior.Location.Z.OnChanged += OnChanged; Core.EffectBehavior.Rotation.X.OnChanged += OnChanged; Core.EffectBehavior.Rotation.Y.OnChanged += OnChanged; Core.EffectBehavior.Rotation.Z.OnChanged += OnChanged; Core.EffectBehavior.Scale.X.OnChanged += OnChanged; Core.EffectBehavior.Scale.Y.OnChanged += OnChanged; Core.EffectBehavior.Scale.Z.OnChanged += OnChanged; Core.EffectBehavior.LocationVelocity.X.OnChanged += OnChanged; Core.EffectBehavior.LocationVelocity.Y.OnChanged += OnChanged; Core.EffectBehavior.LocationVelocity.Z.OnChanged += OnChanged; Core.EffectBehavior.RotationVelocity.X.OnChanged += OnChanged; Core.EffectBehavior.RotationVelocity.Y.OnChanged += OnChanged; Core.EffectBehavior.RotationVelocity.Z.OnChanged += OnChanged; Core.EffectBehavior.ScaleVelocity.X.OnChanged += OnChanged; Core.EffectBehavior.ScaleVelocity.Y.OnChanged += OnChanged; Core.EffectBehavior.ScaleVelocity.Z.OnChanged += OnChanged; Core.EffectBehavior.RemovedTime.Infinite.OnChanged += OnChanged; Core.EffectBehavior.RemovedTime.Value.OnChanged += OnChanged; Core.EffectBehavior.TargetLocation.X.OnChanged += OnChanged; Core.EffectBehavior.TargetLocation.Y.OnChanged += OnChanged; Core.EffectBehavior.TargetLocation.Z.OnChanged += OnChanged; Core.EffectBehavior.CountX.OnChanged += OnChanged; Core.EffectBehavior.CountY.OnChanged += OnChanged; Core.EffectBehavior.CountZ.OnChanged += OnChanged; Core.EffectBehavior.Distance.OnChanged += OnChanged; Core.EffectBehavior.TimeSpan.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.R.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.G.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.B.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.A.OnChanged += OnChanged; Core.EffectBehavior.PlaybackSpeed.OnChanged += OnChanged; Core.Option.Magnification.OnChanged += OnChanged; Core.Option.IsGridShown.OnChanged += OnChanged; Core.Option.GridLength.OnChanged += OnChanged; Core.Option.GridColor.R.OnChanged += OnChanged; Core.Option.GridColor.G.OnChanged += OnChanged; Core.Option.GridColor.B.OnChanged += OnChanged; Core.Option.GridColor.A.OnChanged += OnChanged; Core.Option.FPS.OnChanged += OnChanged; Core.Option.DistortionType.OnChanged += OnChanged; Core.Option.Coordinate.OnChanged += OnChanged; Core.Environment.Background.BackgroundColor.R.OnChanged += OnChanged; Core.Environment.Background.BackgroundColor.G.OnChanged += OnChanged; Core.Environment.Background.BackgroundColor.B.OnChanged += OnChanged; Core.Environment.Background.BackgroundColor.A.OnChanged += OnChanged; Core.Environment.Background.BackgroundImage.OnChanged += OnChanged; Core.Environment.Ground.IsShown.OnChanged += OnChanged; Core.Environment.Ground.Height.OnChanged += OnChanged; Core.Environment.Ground.Extent.OnChanged += OnChanged; Core.Culling.IsShown.OnChanged += OnChanged; Core.Culling.Type.OnChanged += OnChanged; Core.Culling.Sphere.Location.X.OnChanged += OnChanged; Core.Culling.Sphere.Location.Y.OnChanged += OnChanged; Core.Culling.Sphere.Location.Z.OnChanged += OnChanged; Core.Culling.Sphere.Radius.OnChanged += OnChanged; Core.OnAfterLoad += new EventHandler(Core_OnAfterLoad); Core.OnAfterNew += new EventHandler(Core_OnAfterNew); Core.OnReload += new EventHandler(Core_OnReload); // Set imgui path var entryDirectory = GetEntryDirectory(); swig.GUIManager.SetIniFilename(ImGuiIniFilePath); // check files if (!System.IO.File.Exists(System.IO.Path.Combine(appDirectory, "resources/fonts/GenShinGothic-Monospace-Bold.ttf"))) { ErrorUtils.ThrowFileNotfound(); } if (!System.IO.File.Exists(System.IO.Path.Combine(appDirectory, "resources/icons/MenuIcons.png"))) { ErrorUtils.ThrowFileNotfound(); } return(true); }
public static void Update() { Shortcuts.Update(); var handle = false; if (!handle) { Shortcuts.ProcessCmdKey(ref handle); } var mousePos = NativeManager.GetMousePosition(); if (isFirstUpdate) { mousePos_pre = mousePos; } if ((effectViewer == null && !NativeManager.IsAnyWindowHovered()) || (effectViewer != null && effectViewer.IsHovered)) { if (NativeManager.GetMouseButton(2) > 0) { var dx = mousePos.X - mousePos_pre.X; var dy = mousePos.Y - mousePos_pre.Y; Viewer.Slide(dx / 30.0f, dy / 30.0f); } if (NativeManager.GetMouseButton(1) > 0) { var dx = mousePos.X - mousePos_pre.X; var dy = mousePos.Y - mousePos_pre.Y; Viewer.Rotate(dx, dy); } if (NativeManager.GetMouseWheel() != 0) { Viewer.Zoom(NativeManager.GetMouseWheel()); } } mousePos_pre = mousePos; Viewer.UpdateViewer(); Native.UpdateWindow(); Native.ClearWindow(50, 50, 50, 0); if (effectViewer == null) { Native.RenderWindow(); } NativeManager.ResetGUI(); if (resetCount < 0) { resetCount++; if (resetCount == 0) { ResetWindowActually(); } } Controls.Lock(); foreach (var c in Controls.Internal) { c.Update(); } foreach (var _ in Controls.Internal) { if (!_.ShouldBeRemoved) { continue; } var dp = _ as Dock.DockPanel; if (dp != null) { dp.DispatchDisposed(); } } foreach (var _ in Controls.Internal) { if (!_.ShouldBeRemoved) { continue; } Controls.Remove(_); } Controls.Unlock(); for (int i = 0; i < dockTypes.Length; i++) { if (panels[i] != null && panels[i].ShouldBeRemoved) { panels[i] = null; } } NativeManager.RenderGUI(); Native.Present(); NativeManager.Present(); isFirstUpdate = false; }
public static bool Initialize(int width, int height) { bool isOpenGLMode = true; var mgr = new swig.GUIManager(); if (mgr.Initialize("Effekseer", 1280, 720, isOpenGLMode, false)) { } else { mgr.Dispose(); mgr = null; return(false); } Native = new swig.Native(); Viewer = new Viewer(Native); if (!Viewer.ShowViewer(mgr.GetNativeHandle(), 1280, 720, isOpenGLMode)) { mgr.Dispose(); mgr = null; return(false); } mgr.InitializeGUI(Native); NativeManager = mgr; Images.Load(GUI.Manager.Native); guiManagerCallback = new GUIManagerCallback(); NativeManager.SetCallback(guiManagerCallback); panels = new Dock.DockPanel[dockTypes.Length]; // Load font NativeManager.AddFontFromFileTTF("resources/GenShinGothic-Monospace-Normal.ttf", 16); // Load config RecentFiles.LoadRecentConfig(); Shortcuts.LoadShortcuts(); Commands.Register(); // Add controls var mainMenu = new GUI.Menu.MainMenu(); GUI.Manager.AddControl(mainMenu); dockManager = new GUI.Dock.DockManager(); GUI.Manager.AddControl(dockManager); // Default effectViewer = new Dock.EffectViwer(); if (dockManager != null) { effectViewer.InitialDockSlot = swig.DockSlot.None; dockManager.Controls.Add(effectViewer); } else { AddControl(effectViewer); } if (LoadWindowConfig("config.Dock.xml")) { Manager.NativeManager.LoadDock("config.Dock.config"); } else { ResetWindowActually(); } Network = new Network(Native); Command.CommandManager.Changed += OnChanged; Core.EffectBehavior.Location.X.OnChanged += OnChanged; Core.EffectBehavior.Location.Y.OnChanged += OnChanged; Core.EffectBehavior.Location.Z.OnChanged += OnChanged; Core.EffectBehavior.Rotation.X.OnChanged += OnChanged; Core.EffectBehavior.Rotation.Y.OnChanged += OnChanged; Core.EffectBehavior.Rotation.Z.OnChanged += OnChanged; Core.EffectBehavior.Scale.X.OnChanged += OnChanged; Core.EffectBehavior.Scale.Y.OnChanged += OnChanged; Core.EffectBehavior.Scale.Z.OnChanged += OnChanged; Core.EffectBehavior.LocationVelocity.X.OnChanged += OnChanged; Core.EffectBehavior.LocationVelocity.Y.OnChanged += OnChanged; Core.EffectBehavior.LocationVelocity.Z.OnChanged += OnChanged; Core.EffectBehavior.RotationVelocity.X.OnChanged += OnChanged; Core.EffectBehavior.RotationVelocity.Y.OnChanged += OnChanged; Core.EffectBehavior.RotationVelocity.Z.OnChanged += OnChanged; Core.EffectBehavior.ScaleVelocity.X.OnChanged += OnChanged; Core.EffectBehavior.ScaleVelocity.Y.OnChanged += OnChanged; Core.EffectBehavior.ScaleVelocity.Z.OnChanged += OnChanged; Core.EffectBehavior.RemovedTime.Infinite.OnChanged += OnChanged; Core.EffectBehavior.RemovedTime.Value.OnChanged += OnChanged; Core.EffectBehavior.TargetLocation.X.OnChanged += OnChanged; Core.EffectBehavior.TargetLocation.Y.OnChanged += OnChanged; Core.EffectBehavior.TargetLocation.Z.OnChanged += OnChanged; Core.EffectBehavior.CountX.OnChanged += OnChanged; Core.EffectBehavior.CountY.OnChanged += OnChanged; Core.EffectBehavior.CountZ.OnChanged += OnChanged; Core.EffectBehavior.Distance.OnChanged += OnChanged; Core.EffectBehavior.TimeSpan.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.R.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.G.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.B.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.A.OnChanged += OnChanged; Core.Option.Magnification.OnChanged += OnChanged; Core.Option.IsGridShown.OnChanged += OnChanged; Core.Option.GridLength.OnChanged += OnChanged; Core.Option.BackgroundColor.R.OnChanged += OnChanged; Core.Option.BackgroundColor.G.OnChanged += OnChanged; Core.Option.BackgroundColor.B.OnChanged += OnChanged; Core.Option.BackgroundColor.A.OnChanged += OnChanged; Core.Option.GridColor.R.OnChanged += OnChanged; Core.Option.GridColor.G.OnChanged += OnChanged; Core.Option.GridColor.B.OnChanged += OnChanged; Core.Option.GridColor.A.OnChanged += OnChanged; Core.Option.FPS.OnChanged += OnChanged; Core.Option.DistortionType.OnChanged += OnChanged; Core.Option.Coordinate.OnChanged += OnChanged; Core.Option.BackgroundImage.OnChanged += OnChanged; Core.Culling.IsShown.OnChanged += OnChanged; Core.Culling.Type.OnChanged += OnChanged; Core.Culling.Sphere.Location.X.OnChanged += OnChanged; Core.Culling.Sphere.Location.Y.OnChanged += OnChanged; Core.Culling.Sphere.Location.Z.OnChanged += OnChanged; Core.Culling.Sphere.Radius.OnChanged += OnChanged; Core.OnAfterLoad += new EventHandler(Core_OnAfterLoad); Core.OnAfterNew += new EventHandler(Core_OnAfterNew); Core.OnReload += new EventHandler(Core_OnReload); return(true); }
void ReloadMenu() { Func <Func <bool>, ToolStripMenuItem> create_menu_item_from_commands = (a) => { var item = new ToolStripMenuItem(); var attributes = a.Method.GetCustomAttributes(false); var uniquename = UniqueNameAttribute.GetUniqueName(attributes); item.Text = NameAttribute.GetName(attributes); item.ShowShortcutKeys = true; item.ShortcutKeyDisplayString = Shortcuts.GetShortcutText(uniquename); item.Click += (object sender, EventArgs e) => { a(); }; return(item); }; this.menuStrip.SuspendLayout(); this.SuspendLayout(); { string file = string.Empty; string input = string.Empty; string output = string.Empty; file = Properties.Resources.Files; input = Properties.Resources.Import; output = Properties.Resources.Export; var menu = new ToolStripMenuItem(file); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.New)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Open)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Overwrite)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.SaveAs)); menu.DropDownItems.Add(new ToolStripSeparator()); { var import_menu = new ToolStripMenuItem(input); for (int c = 0; c < Core.ImportScripts.Count; c++) { var item = new ToolStripMenuItem(); var script = Core.ImportScripts[c]; item.Text = script.Title; item.Click += (object _sender, EventArgs _e) => { OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = System.IO.Directory.GetCurrentDirectory(); ofd.Filter = script.Filter; ofd.FilterIndex = 2; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { var filepath = ofd.FileName; script.Function(filepath); System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(filepath)); } else { return; } }; import_menu.DropDownItems.Add(item); } menu.DropDownItems.Add(import_menu); } { var export_menu = new ToolStripMenuItem(output); for (int c = 0; c < Core.ExportScripts.Count; c++) { var item = new ToolStripMenuItem(); var script = Core.ExportScripts[c]; item.Text = script.Title; item.Click += (object _sender, EventArgs _e) => { SaveFileDialog ofd = new SaveFileDialog(); ofd.InitialDirectory = System.IO.Directory.GetCurrentDirectory(); ofd.Filter = script.Filter; ofd.FilterIndex = 2; ofd.OverwritePrompt = true; if (ofd.ShowDialog() == DialogResult.OK) { var filepath = ofd.FileName; script.Function(filepath); System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(filepath)); } else { return; } }; export_menu.DropDownItems.Add(item); } menu.DropDownItems.Add(export_menu); } menu.DropDownItems.Add(new ToolStripSeparator()); { ReloadRecentFiles(); menu.DropDownItems.Add(recentFiles); } menu.DropDownItems.Add(new ToolStripSeparator()); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Exit)); menuStrip.Items.Add(menu); } { string edit = Properties.Resources.Edit; string view = Properties.Resources.View; var menu = new ToolStripMenuItem(edit); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.AddNode)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.InsertNode)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.RemoveNode)); menu.DropDownItems.Add(new ToolStripSeparator()); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Copy)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Paste)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.PasteInfo)); menu.DropDownItems.Add(new ToolStripSeparator()); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Undo)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Redo)); menuStrip.Items.Add(menu); } { string edit = Properties.Resources.Edit; string view = Properties.Resources.View; var menu = new ToolStripMenuItem(view); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Play)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Stop)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Step)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.BackStep)); menuStrip.Items.Add(menu); } /* * { * var menu = new ToolStripMenuItem("全体処理"); * * for (int c = 0; c < Core.CommandScripts.Count; c++) * { * var command_item = new ToolStripMenuItem(); * var command = Core.CommandScripts[c]; * command_item.Text = command.Title; * command_item.Click += (object _sender, EventArgs _e) => * { * command.Function(); * }; * menu.DropDownItems.Add(command_item); * } * * menuStrip.Items.Add(menu); * } * * { * var menu = new ToolStripMenuItem("選択部処理"); * for (int c = 0; c < Core.SelectedScripts.Count; c++) * { * var command_item = new ToolStripMenuItem(); * var command = Core.SelectedScripts[c]; * command_item.Text = command.Title; * command_item.Click += (object _sender, EventArgs _e) => * { * command.Function(Core.SelectedNode, null); * }; * menu.DropDownItems.Add(command_item); * } * * menuStrip.Items.Add(menu); * } */ { var menu = new ToolStripMenuItem(Properties.Resources.Window); { var item = new ToolStripMenuItem(); item.Text = Properties.Resources.ResetWindow; item.Click += (object sender, EventArgs e) => { GUIManager.CloseDockWindow(); GUIManager.AssignDockWindowIntoDefaultPosition(); }; menu.DropDownItems.Add(item); } Action <string, Type, Image> setDockWindow = (s, t, icon) => { var item = new ToolStripMenuItem(); item.Text = s; item.Click += (object sender, EventArgs e) => { GUIManager.SelectOrShowWindow(t); }; item.Image = icon; menu.DropDownItems.Add(item); }; setDockWindow(Properties.Resources.NodeTree, typeof(DockNodeTreeView), Properties.Resources.IconNodeTree); setDockWindow(Properties.Resources.BasicSettings, typeof(DockNodeCommonValues), Properties.Resources.IconCommon); setDockWindow(Properties.Resources.Position, typeof(DockNodeLocationValues), Properties.Resources.IconLocation); setDockWindow(Properties.Resources.AttractionForces, typeof(DockNodeLocationAbsValues), Properties.Resources.IconLocationAbs); setDockWindow(Properties.Resources.SpawningMethod, typeof(DockNodeGenerationLocationValues), Properties.Resources.IconGenerationLocation); setDockWindow(Properties.Resources.Rotation, typeof(DockNodeRotationValues), Properties.Resources.IconRotation); setDockWindow(Properties.Resources.Scale, typeof(DockNodeScaleValues), Properties.Resources.IconScale); setDockWindow(Properties.Resources.BasicRenderSettings, typeof(DockNodeRendererCommonValues), Properties.Resources.IconRendererCommon); setDockWindow(Properties.Resources.RenderSettings, typeof(DockNodeRendererValues), Properties.Resources.IconRenderer); setDockWindow(Properties.Resources.Sound, typeof(DockNodeSoundValues), Properties.Resources.IconSound); setDockWindow(Properties.Resources.FCurves, typeof(DockFCurves), Properties.Resources.IconFCurve); setDockWindow(Properties.Resources.ViewerControls, typeof(DockViewerController), Properties.Resources.IconViewer); setDockWindow(Properties.Resources.CameraSettings, typeof(DockViewPoint), Properties.Resources.IconViewPoint); setDockWindow(Properties.Resources.Recorder, typeof(DockRecorder), Properties.Resources.IconRecorder); setDockWindow(Properties.Resources.Options, typeof(DockOption), Properties.Resources.IconOption); setDockWindow(Properties.Resources.Behavior, typeof(DockEffectBehavior), Properties.Resources.IconBehavior); setDockWindow(Properties.Resources.Culling, typeof(DockCulling), Properties.Resources.IconCulling); setDockWindow(Properties.Resources.Network, typeof(DockNetwork), Properties.Resources.IconNetwork); setDockWindow(Properties.Resources.FileViewer, typeof(DockFileViewer), Properties.Resources.IconFileViewer); menuStrip.Items.Add(menu); } { var menu = new ToolStripMenuItem(Properties.Resources.Help); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.ViewHelp)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.OpenSample)); menu.DropDownItems.Add(new ToolStripSeparator()); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.About)); menuStrip.Items.Add(menu); } this.menuStrip.ResumeLayout(false); this.menuStrip.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); }
public static void Update() { // Reset NativeManager.SetNextDockRate(0.5f); NativeManager.SetNextDock(swig.DockSlot.Tab); NativeManager.ResetNextParentDock(); Shortcuts.Update(); var handle = false; if (!handle) { var cursor = Manager.NativeManager.GetMouseCursor(); if (cursor == swig.MouseCursor.None || cursor == swig.MouseCursor.Arrow) { Shortcuts.ProcessCmdKey(ref handle); } } var mousePos = NativeManager.GetMousePosition(); if (isFirstUpdate) { mousePos_pre = mousePos; } if ((effectViewer == null && !NativeManager.IsAnyWindowHovered()) || (effectViewer != null && effectViewer.IsHovered)) { if (NativeManager.GetMouseButton(2) > 0) { var dx = mousePos.X - mousePos_pre.X; var dy = mousePos.Y - mousePos_pre.Y; Viewer.Slide(dx / 30.0f, dy / 30.0f); } if (NativeManager.GetMouseButton(1) > 0) { var dx = mousePos.X - mousePos_pre.X; var dy = mousePos.Y - mousePos_pre.Y; Viewer.Rotate(dx, dy); } if (NativeManager.GetMouseWheel() != 0) { Viewer.Zoom(NativeManager.GetMouseWheel()); } } mousePos_pre = mousePos; Viewer.UpdateViewer(); Native.UpdateWindow(); Native.ClearWindow(50, 50, 50, 0); if (effectViewer == null) { Native.RenderWindow(); } NativeManager.ResetGUI(); if (resetCount < 0) { resetCount++; if (resetCount == 0) { ResetWindowActually(); } } if (resizedCount > 0) { resizedCount--; } Controls.Lock(); foreach (var c in Controls.Internal) { c.Update(); } foreach (var _ in Controls.Internal) { if (!_.ShouldBeRemoved) { continue; } var dp = _ as Dock.DockPanel; if (dp != null) { dp.DispatchDisposed(); } } foreach (var _ in Controls.Internal) { if (!_.ShouldBeRemoved) { continue; } Controls.Remove(_); } Controls.Unlock(); for (int i = 0; i < dockTypes.Length; i++) { if (panels[i] != null && panels[i].ShouldBeRemoved) { panels[i] = null; } } NativeManager.RenderGUI(resizedCount == 0); Native.Present(); NativeManager.Present(); isFirstUpdate = false; // TODO more smart // When minimized, suppress CPU activity if (actualWidth == 0) { System.Threading.Thread.Sleep(16); } }
public static bool Initialize(int width, int height, swig.DeviceType deviceType) { var mgr = new swig.GUIManager(); if (mgr.Initialize("Effekseer", 1280, 720, deviceType, false)) { } else { mgr.Dispose(); mgr = null; return(false); } Native = new swig.Native(); Viewer = new Viewer(Native); if (!Viewer.ShowViewer(mgr.GetNativeHandle(), 1280, 720, deviceType)) { mgr.Dispose(); mgr = null; return(false); } mgr.InitializeGUI(Native); NativeManager = mgr; Images.Load(GUI.Manager.Native); guiManagerCallback = new GUIManagerCallback(); NativeManager.SetCallback(guiManagerCallback); panels = new Dock.DockPanel[dockTypes.Length]; var appDirectory = Manager.GetEntryDirectory(); // Load font NativeManager.AddFontFromFileTTF(System.IO.Path.Combine(appDirectory, "resources/GenShinGothic-Monospace-Normal.ttf"), 16); // Load window icon NativeManager.SetWindowIcon(System.IO.Path.Combine(appDirectory, "resources/icon.png")); // Load config RecentFiles.LoadRecentConfig(); Shortcuts.LoadShortcuts(); Commands.Register(); // Add controls var mainMenu = new GUI.Menu.MainMenu(); GUI.Manager.AddControl(mainMenu); dockManager = new GUI.Dock.DockManager(); GUI.Manager.AddControl(dockManager); // Default effectViewer = new Dock.EffectViwer(); if (dockManager != null) { effectViewer.InitialDockSlot = swig.DockSlot.None; dockManager.Controls.Add(effectViewer); } else { AddControl(effectViewer); } if (LoadWindowConfig(System.IO.Path.Combine(appDirectory, "config.Dock.xml"))) { Manager.NativeManager.LoadDock(System.IO.Path.Combine(appDirectory, "config.Dock.config")); } else { ResetWindowActually(); } TextOffsetY = (NativeManager.GetTextLineHeightWithSpacing() - NativeManager.GetTextLineHeight()) / 2; Network = new Network(Native); Network.Load(); Command.CommandManager.Changed += OnChanged; Core.EffectBehavior.Location.X.OnChanged += OnChanged; Core.EffectBehavior.Location.Y.OnChanged += OnChanged; Core.EffectBehavior.Location.Z.OnChanged += OnChanged; Core.EffectBehavior.Rotation.X.OnChanged += OnChanged; Core.EffectBehavior.Rotation.Y.OnChanged += OnChanged; Core.EffectBehavior.Rotation.Z.OnChanged += OnChanged; Core.EffectBehavior.Scale.X.OnChanged += OnChanged; Core.EffectBehavior.Scale.Y.OnChanged += OnChanged; Core.EffectBehavior.Scale.Z.OnChanged += OnChanged; Core.EffectBehavior.LocationVelocity.X.OnChanged += OnChanged; Core.EffectBehavior.LocationVelocity.Y.OnChanged += OnChanged; Core.EffectBehavior.LocationVelocity.Z.OnChanged += OnChanged; Core.EffectBehavior.RotationVelocity.X.OnChanged += OnChanged; Core.EffectBehavior.RotationVelocity.Y.OnChanged += OnChanged; Core.EffectBehavior.RotationVelocity.Z.OnChanged += OnChanged; Core.EffectBehavior.ScaleVelocity.X.OnChanged += OnChanged; Core.EffectBehavior.ScaleVelocity.Y.OnChanged += OnChanged; Core.EffectBehavior.ScaleVelocity.Z.OnChanged += OnChanged; Core.EffectBehavior.RemovedTime.Infinite.OnChanged += OnChanged; Core.EffectBehavior.RemovedTime.Value.OnChanged += OnChanged; Core.EffectBehavior.TargetLocation.X.OnChanged += OnChanged; Core.EffectBehavior.TargetLocation.Y.OnChanged += OnChanged; Core.EffectBehavior.TargetLocation.Z.OnChanged += OnChanged; Core.EffectBehavior.CountX.OnChanged += OnChanged; Core.EffectBehavior.CountY.OnChanged += OnChanged; Core.EffectBehavior.CountZ.OnChanged += OnChanged; Core.EffectBehavior.Distance.OnChanged += OnChanged; Core.EffectBehavior.TimeSpan.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.R.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.G.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.B.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.A.OnChanged += OnChanged; Core.Option.Magnification.OnChanged += OnChanged; Core.Option.IsGridShown.OnChanged += OnChanged; Core.Option.GridLength.OnChanged += OnChanged; Core.Option.BackgroundColor.R.OnChanged += OnChanged; Core.Option.BackgroundColor.G.OnChanged += OnChanged; Core.Option.BackgroundColor.B.OnChanged += OnChanged; Core.Option.BackgroundColor.A.OnChanged += OnChanged; Core.Option.GridColor.R.OnChanged += OnChanged; Core.Option.GridColor.G.OnChanged += OnChanged; Core.Option.GridColor.B.OnChanged += OnChanged; Core.Option.GridColor.A.OnChanged += OnChanged; Core.Option.FPS.OnChanged += OnChanged; Core.Option.DistortionType.OnChanged += OnChanged; Core.Option.Coordinate.OnChanged += OnChanged; Core.Option.BackgroundImage.OnChanged += OnChanged; Core.Culling.IsShown.OnChanged += OnChanged; Core.Culling.Type.OnChanged += OnChanged; Core.Culling.Sphere.Location.X.OnChanged += OnChanged; Core.Culling.Sphere.Location.Y.OnChanged += OnChanged; Core.Culling.Sphere.Location.Z.OnChanged += OnChanged; Core.Culling.Sphere.Radius.OnChanged += OnChanged; Core.OnAfterLoad += new EventHandler(Core_OnAfterLoad); Core.OnAfterNew += new EventHandler(Core_OnAfterNew); Core.OnReload += new EventHandler(Core_OnReload); // Set imgui path var entryDirectory = GetEntryDirectory(); swig.GUIManager.SetIniFilename(entryDirectory + "/imgui.ini"); return(true); }
public static void Update() { if (isFontSizeDirtied) { NativeManager.InvalidateFont(); var appDirectory = Manager.GetEntryDirectory(); var type = Core.Option.Font.Value; if (type == Data.FontType.Normal) { NativeManager.AddFontFromFileTTF(System.IO.Path.Combine(appDirectory, "resources/GenShinGothic-Monospace-Normal.ttf"), Core.Option.FontSize.Value); } else if (type == Data.FontType.Bold) { NativeManager.AddFontFromFileTTF(System.IO.Path.Combine(appDirectory, "resources/fonts/GenShinGothic-Monospace-Bold.ttf"), Core.Option.FontSize.Value); } isFontSizeDirtied = false; } // Reset NativeManager.SetNextDockRate(0.5f); NativeManager.SetNextDock(swig.DockSlot.Tab); NativeManager.ResetNextParentDock(); IO.Update(); Shortcuts.Update(); Network.Update(); var handle = false; if (!handle) { if (!NativeManager.IsAnyItemActive()) { Shortcuts.ProcessCmdKey(ref handle); } } var mousePos = NativeManager.GetMousePosition(); if (isFirstUpdate) { mousePos_pre = mousePos; } if ((effectViewer == null && !NativeManager.IsAnyWindowHovered()) || (effectViewer != null && effectViewer.IsHovered)) { if (NativeManager.GetMouseButton(2) > 0) { var dx = mousePos.X - mousePos_pre.X; var dy = mousePos.Y - mousePos_pre.Y; Viewer.Slide(dx / 30.0f, dy / 30.0f); } if (NativeManager.GetMouseButton(1) > 0) { var dx = mousePos.X - mousePos_pre.X; var dy = mousePos.Y - mousePos_pre.Y; Viewer.Rotate(dx, dy); } if (NativeManager.GetMouseWheel() != 0) { Viewer.Zoom(NativeManager.GetMouseWheel()); } } mousePos_pre = mousePos; Viewer.UpdateViewer(); Native.UpdateWindow(); Native.ClearWindow(50, 50, 50, 0); if (effectViewer == null) { Native.RenderWindow(); } NativeManager.ResetGUI(); if (resetCount < 0) { resetCount++; if (resetCount == 0) { ResetWindowActually(); } } if (resizedCount > 0) { resizedCount--; } Controls.Lock(); foreach (var c in Controls.Internal) { c.Update(); } foreach (var _ in Controls.Internal) { if (!_.ShouldBeRemoved) { continue; } var dp = _ as Dock.DockPanel; if (dp != null) { dp.DispatchDisposed(); } } foreach (var _ in Controls.Internal) { if (!_.ShouldBeRemoved) { continue; } Controls.Remove(_); } Controls.Unlock(); for (int i = 0; i < dockTypes.Length; i++) { if (panels[i] != null && panels[i].ShouldBeRemoved) { panels[i] = null; } } NativeManager.RenderGUI(resizedCount == 0); Native.Present(); NativeManager.Present(); isFirstUpdate = false; // TODO more smart // When minimized, suppress CPU activity if (actualWidth == 0) { System.Threading.Thread.Sleep(16); } }
public static bool Initialize(int width, int height, swig.DeviceType deviceType) { var appDirectory = Manager.GetEntryDirectory(); swig.MainWindowState state = new swig.MainWindowState(); // TODO : refactor var windowConfig = new Configs.WindowConfig(); if (windowConfig.Load(System.IO.Path.Combine(appDirectory, "config.Dock.xml"))) { state.PosX = windowConfig.WindowPosX; state.PosY = windowConfig.WindowPosY; state.Width = windowConfig.WindowWidth; state.Height = windowConfig.WindowHeight; state.IsMaximumMode = windowConfig.WindowIsMaximumMode; } else { state.PosX = -10000; // nodata state.Width = 1280; state.Height = 720; windowConfig = null; } if (!swig.MainWindow.Initialize("Effekseer", state, false, deviceType == swig.DeviceType.OpenGL)) { return(false); } MainWindow = swig.MainWindow.GetInstance(); swig.IO.Initialize(1000); IO = swig.IO.GetInstance(); ioCallback = new ManagerIOCallback(); IO.AddCallback(ioCallback); ThumbnailManager.Initialize(); var mgr = new swig.GUIManager(); if (mgr.Initialize(MainWindow, deviceType)) { } else { mgr.Dispose(); mgr = null; return(false); } Native = new swig.Native(); Viewer = new Viewer(Native); if (!Viewer.ShowViewer(mgr.GetNativeHandle(), state.Width, state.Height, deviceType)) { mgr.Dispose(); mgr = null; return(false); } mgr.InitializeGUI(Native); NativeManager = mgr; Images.Load(GUI.Manager.Native); guiManagerCallback = new GUIManagerCallback(); NativeManager.SetCallback(guiManagerCallback); panels = new Dock.DockPanel[dockTypes.Length]; // Load font UpdateFontSize(); // Load window icon NativeManager.SetWindowIcon(System.IO.Path.Combine(appDirectory, "resources/icon.png")); // Load config RecentFiles.LoadRecentConfig(); Shortcuts.LoadShortcuts(); Commands.Register(); // Add controls var mainMenu = new GUI.Menu.MainMenu(); GUI.Manager.AddControl(mainMenu); dockManager = new GUI.Dock.DockManager(); GUI.Manager.AddControl(dockManager); // Default effectViewer = new Dock.EffectViwer(); if (dockManager != null) { effectViewer.InitialDockSlot = swig.DockSlot.None; dockManager.Controls.Add(effectViewer); } else { AddControl(effectViewer); } // TODO : refactor if (LoadWindowConfig(System.IO.Path.Combine(appDirectory, "config.Dock.xml"))) { Manager.NativeManager.LoadDock(System.IO.Path.Combine(appDirectory, "config.Dock.config")); } else { ResetWindowActually(); } TextOffsetY = (NativeManager.GetTextLineHeightWithSpacing() - NativeManager.GetTextLineHeight()) / 2; Network = new Network(Native); Network.Load(); Command.CommandManager.Changed += OnChanged; Core.EffectBehavior.Location.X.OnChanged += OnChanged; Core.EffectBehavior.Location.Y.OnChanged += OnChanged; Core.EffectBehavior.Location.Z.OnChanged += OnChanged; Core.EffectBehavior.Rotation.X.OnChanged += OnChanged; Core.EffectBehavior.Rotation.Y.OnChanged += OnChanged; Core.EffectBehavior.Rotation.Z.OnChanged += OnChanged; Core.EffectBehavior.Scale.X.OnChanged += OnChanged; Core.EffectBehavior.Scale.Y.OnChanged += OnChanged; Core.EffectBehavior.Scale.Z.OnChanged += OnChanged; Core.EffectBehavior.LocationVelocity.X.OnChanged += OnChanged; Core.EffectBehavior.LocationVelocity.Y.OnChanged += OnChanged; Core.EffectBehavior.LocationVelocity.Z.OnChanged += OnChanged; Core.EffectBehavior.RotationVelocity.X.OnChanged += OnChanged; Core.EffectBehavior.RotationVelocity.Y.OnChanged += OnChanged; Core.EffectBehavior.RotationVelocity.Z.OnChanged += OnChanged; Core.EffectBehavior.ScaleVelocity.X.OnChanged += OnChanged; Core.EffectBehavior.ScaleVelocity.Y.OnChanged += OnChanged; Core.EffectBehavior.ScaleVelocity.Z.OnChanged += OnChanged; Core.EffectBehavior.RemovedTime.Infinite.OnChanged += OnChanged; Core.EffectBehavior.RemovedTime.Value.OnChanged += OnChanged; Core.EffectBehavior.TargetLocation.X.OnChanged += OnChanged; Core.EffectBehavior.TargetLocation.Y.OnChanged += OnChanged; Core.EffectBehavior.TargetLocation.Z.OnChanged += OnChanged; Core.EffectBehavior.CountX.OnChanged += OnChanged; Core.EffectBehavior.CountY.OnChanged += OnChanged; Core.EffectBehavior.CountZ.OnChanged += OnChanged; Core.EffectBehavior.Distance.OnChanged += OnChanged; Core.EffectBehavior.TimeSpan.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.R.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.G.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.B.OnChanged += OnChanged; Core.EffectBehavior.ColorAll.A.OnChanged += OnChanged; Core.Option.Magnification.OnChanged += OnChanged; Core.Option.IsGridShown.OnChanged += OnChanged; Core.Option.GridLength.OnChanged += OnChanged; Core.Option.GridColor.R.OnChanged += OnChanged; Core.Option.GridColor.G.OnChanged += OnChanged; Core.Option.GridColor.B.OnChanged += OnChanged; Core.Option.GridColor.A.OnChanged += OnChanged; Core.Option.FPS.OnChanged += OnChanged; Core.Option.DistortionType.OnChanged += OnChanged; Core.Option.Coordinate.OnChanged += OnChanged; Core.Environment.Background.BackgroundColor.R.OnChanged += OnChanged; Core.Environment.Background.BackgroundColor.G.OnChanged += OnChanged; Core.Environment.Background.BackgroundColor.B.OnChanged += OnChanged; Core.Environment.Background.BackgroundColor.A.OnChanged += OnChanged; Core.Environment.Background.BackgroundImage.OnChanged += OnChanged; Core.Culling.IsShown.OnChanged += OnChanged; Core.Culling.Type.OnChanged += OnChanged; Core.Culling.Sphere.Location.X.OnChanged += OnChanged; Core.Culling.Sphere.Location.Y.OnChanged += OnChanged; Core.Culling.Sphere.Location.Z.OnChanged += OnChanged; Core.Culling.Sphere.Radius.OnChanged += OnChanged; Core.OnAfterLoad += new EventHandler(Core_OnAfterLoad); Core.OnAfterNew += new EventHandler(Core_OnAfterNew); Core.OnReload += new EventHandler(Core_OnReload); // Set imgui path var entryDirectory = GetEntryDirectory(); swig.GUIManager.SetIniFilename(entryDirectory + "/imgui.ini"); // check files if (!System.IO.File.Exists(System.IO.Path.Combine(appDirectory, "resources/fonts/GenShinGothic-Monospace-Bold.ttf"))) { ErrorUtils.ThrowFileNotfound(); } return(true); }
void ReloadMenu() { Func <Action, ToolStripMenuItem> create_menu_item_from_commands = (a) => { var item = new ToolStripMenuItem(); var attributes = a.Method.GetCustomAttributes(false); var uniquename = UniqueNameAttribute.GetUniqueName(attributes); item.Text = NameAttribute.GetName(attributes); item.ShowShortcutKeys = true; item.ShortcutKeyDisplayString = Shortcuts.GetShortcutText(uniquename); item.Click += (object sender, EventArgs e) => { a(); }; return(item); }; this.menuStrip.SuspendLayout(); this.SuspendLayout(); { string file = string.Empty; string input = string.Empty; string output = string.Empty; if (Core.Language == Language.Japanese) { file = "ファイル"; input = "入力"; output = "出力"; } else if (Core.Language == Language.English) { file = "Files"; input = "Import"; output = "Export"; } var menu = new ToolStripMenuItem(file); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.New)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Open)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Overwrite)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.SaveAs)); menu.DropDownItems.Add(new ToolStripSeparator()); { var import_menu = new ToolStripMenuItem(input); for (int c = 0; c < Core.ImportScripts.Count; c++) { var item = new ToolStripMenuItem(); var script = Core.ImportScripts[c]; item.Text = script.Title; item.Click += (object _sender, EventArgs _e) => { OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = System.IO.Directory.GetCurrentDirectory(); ofd.Filter = script.Filter; ofd.FilterIndex = 2; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { var filepath = ofd.FileName; script.Function(filepath); System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(filepath)); } else { return; } }; import_menu.DropDownItems.Add(item); } menu.DropDownItems.Add(import_menu); } { var export_menu = new ToolStripMenuItem(output); for (int c = 0; c < Core.ExportScripts.Count; c++) { var item = new ToolStripMenuItem(); var script = Core.ExportScripts[c]; item.Text = script.Title; item.Click += (object _sender, EventArgs _e) => { SaveFileDialog ofd = new SaveFileDialog(); ofd.InitialDirectory = System.IO.Directory.GetCurrentDirectory(); ofd.Filter = script.Filter; ofd.FilterIndex = 2; ofd.OverwritePrompt = true; if (ofd.ShowDialog() == DialogResult.OK) { var filepath = ofd.FileName; script.Function(filepath); System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(filepath)); } else { return; } }; export_menu.DropDownItems.Add(item); } menu.DropDownItems.Add(export_menu); } menu.DropDownItems.Add(new ToolStripSeparator()); { ReloadRecentFiles(); menu.DropDownItems.Add(recentFiles); } menu.DropDownItems.Add(new ToolStripSeparator()); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Exit)); menuStrip.Items.Add(menu); } { string edit = string.Empty; string view = string.Empty; if (Core.Language == Language.Japanese) { edit = "編集"; view = "表示"; } else if (Core.Language == Language.English) { edit = "Edit"; view = "View"; } var menu = new ToolStripMenuItem(edit); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.AddNode)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.InsertNode)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.RemoveNode)); menu.DropDownItems.Add(new ToolStripSeparator()); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Copy)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Paste)); menu.DropDownItems.Add(new ToolStripSeparator()); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Undo)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Redo)); menuStrip.Items.Add(menu); } { string edit = string.Empty; string view = string.Empty; if (Core.Language == Language.Japanese) { edit = "編集"; view = "表示"; } else if (Core.Language == Language.English) { edit = "Edit"; view = "View"; } var menu = new ToolStripMenuItem(view); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Play)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Stop)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.Step)); menuStrip.Items.Add(menu); } /* * { * var menu = new ToolStripMenuItem("全体処理"); * * for (int c = 0; c < Core.CommandScripts.Count; c++) * { * var command_item = new ToolStripMenuItem(); * var command = Core.CommandScripts[c]; * command_item.Text = command.Title; * command_item.Click += (object _sender, EventArgs _e) => * { * command.Function(); * }; * menu.DropDownItems.Add(command_item); * } * * menuStrip.Items.Add(menu); * } * * { * var menu = new ToolStripMenuItem("選択部処理"); * for (int c = 0; c < Core.SelectedScripts.Count; c++) * { * var command_item = new ToolStripMenuItem(); * var command = Core.SelectedScripts[c]; * command_item.Text = command.Title; * command_item.Click += (object _sender, EventArgs _e) => * { * command.Function(Core.SelectedNode, null); * }; * menu.DropDownItems.Add(command_item); * } * * menuStrip.Items.Add(menu); * } */ { string window = string.Empty; string resetWindow = string.Empty; if (Core.Language == Language.Japanese) { window = "ウインドウ"; resetWindow = "ウインドウ位置を初期化"; } else if (Core.Language == Language.English) { window = "Window"; resetWindow = "Reset Window Position"; } var menu = new ToolStripMenuItem(window); { var item = new ToolStripMenuItem(); item.Text = resetWindow; item.Click += (object sender, EventArgs e) => { GUIManager.CloseDockWindow(); GUIManager.AssignDockWindowIntoDefaultPosition(); }; menu.DropDownItems.Add(item); } Action <string, Type> setDockWindow = (s, t) => { var item = new ToolStripMenuItem(); item.Text = s; item.Click += (object sender, EventArgs e) => { GUIManager.SelectOrShowWindow(t); }; menu.DropDownItems.Add(item); }; if (Core.Language == Language.Japanese) { setDockWindow("ノードツリー", typeof(DockNodeTreeView)); setDockWindow("共通", typeof(DockNodeCommonValues)); setDockWindow("位置", typeof(DockNodeLocationValues)); setDockWindow("絶対位置", typeof(DockNodeLocationAbsValues)); setDockWindow("生成位置", typeof(DockNodeGenerationLocationValues)); setDockWindow("回転", typeof(DockNodeRotationValues)); setDockWindow("拡大", typeof(DockNodeScaleValues)); setDockWindow("描画共通", typeof(DockNodeRendererCommonValues)); setDockWindow("描画", typeof(DockNodeRendererValues)); setDockWindow("音", typeof(DockNodeSoundValues)); setDockWindow("Fカーブ", typeof(DockFCurves)); setDockWindow("ビュワー操作", typeof(DockViewerController)); setDockWindow("視点操作", typeof(DockViewPoint)); setDockWindow("録画", typeof(DockRecorder)); setDockWindow("オプション", typeof(DockOption)); setDockWindow("振る舞い", typeof(DockEffectBehavior)); setDockWindow("カリング", typeof(DockCulling)); setDockWindow("ネットワーク", typeof(DockNetwork)); } else if (Core.Language == Language.English) { setDockWindow("Node Tree", typeof(DockNodeTreeView)); setDockWindow("Basic Settings", typeof(DockNodeCommonValues)); setDockWindow("Position", typeof(DockNodeLocationValues)); setDockWindow("Attraction Forces", typeof(DockNodeLocationAbsValues)); setDockWindow("Spawning Method", typeof(DockNodeGenerationLocationValues)); setDockWindow("Rotation", typeof(DockNodeRotationValues)); setDockWindow("Scale", typeof(DockNodeScaleValues)); setDockWindow("Basic Render Settings", typeof(DockNodeRendererCommonValues)); setDockWindow("Render Settings", typeof(DockNodeRendererValues)); setDockWindow("Sound", typeof(DockNodeSoundValues)); setDockWindow("F-Curves", typeof(DockFCurves)); setDockWindow("Viewer Controls", typeof(DockViewerController)); setDockWindow("Camera Settings", typeof(DockViewPoint)); setDockWindow("Recorder", typeof(DockRecorder)); setDockWindow("Options", typeof(DockOption)); setDockWindow("Behavior", typeof(DockEffectBehavior)); setDockWindow("Culling", typeof(DockCulling)); setDockWindow("Network", typeof(DockNetwork)); } menuStrip.Items.Add(menu); } { string help = string.Empty; if (Core.Language == Language.Japanese) { help = "ヘルプ"; } else if (Core.Language == Language.English) { help = "Help"; } var menu = new ToolStripMenuItem(help); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.ViewHelp)); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.OpenSample)); menu.DropDownItems.Add(new ToolStripSeparator()); menu.DropDownItems.Add(create_menu_item_from_commands(Commands.About)); menuStrip.Items.Add(menu); } this.menuStrip.ResumeLayout(false); this.menuStrip.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); }