private void createUI() { Panel panel = AddControl <Panel>(); { panel.Style = new VisualStyle(EditorStyle.HelpBox); HorizontalLayout layout = panel.AddControl <HorizontalLayout>(); { // Label Label label = layout.AddControl <Label>(); { label.Content.Text = "AStar 2D"; } // Push to the right layout.AddControl <FlexibleSpacer>(); Button userGuideButton = layout.AddControl <Button>(); { userGuideButton.Content.Text = "User Guide"; userGuideButton.Content.Tooltip = "Open the user guide for AStar 2D"; userGuideButton.Style = new VisualStyle(EditorStyle.ToolbarButton); userGuideButton.OnClicked += (object sender) => { // Open the user guide Application.OpenURL(Application.dataPath + "/" + userGuideUrl); }; } // Help button Button helpButton = layout.AddControl <Button>(); { helpButton.Content.Text = "Get Help"; helpButton.Content.Tooltip = string.Format("Open help page '{0}'", helpUrl); helpButton.Style = new VisualStyle(EditorStyle.ToolbarButton); helpButton.OnClicked += (object sender) => { // Create the topic url string file = string.Format("{0}::{1}", helpUrl, helpTopic); // Launch the process Process.Start("hh.exe", file); }; } } } }
private void CreateGeneralTab(IDesignerControl parent) { int labelWidth = 200; // Space parent.AddControl <Spacer>(); // Case Sensitive Names setting HorizontalLayout a = parent.AddControl <HorizontalLayout>(); { // Create the label Label label = a.AddControl <Label>(); { label.Content.Text = "Case Sensitive Names"; label.Content.Tooltip = "Should type and member name searches be case sensitive"; label.Layout.Size = new Vector2(labelWidth, 0); } // Create the toggle box ToggleBox box = a.AddControl <ToggleBox>(); { box.Checked = DynamicCSharp.Settings.caseSensitiveNames; box.OnToggled += (object sender, bool value) => { DynamicCSharp.Settings.caseSensitiveNames = value; }; } } // Discover Non-Public Types setting HorizontalLayout b = parent.AddControl <HorizontalLayout>(); { // Create the label Label label = b.AddControl <Label>(); { label.Content.Text = "Discover non-public types"; label.Content.Tooltip = "Should types that are not marked 'public' be discovered"; label.Layout.Size = new Vector2(labelWidth, 0); } // Create the toggle box ToggleBox box = b.AddControl <ToggleBox>(); { box.Checked = DynamicCSharp.Settings.discoverNonPublicTypes; box.OnToggled += (object sender, bool value) => { DynamicCSharp.Settings.discoverNonPublicTypes = value; }; } } // Discover Non-Public Members HorizontalLayout c = parent.AddControl <HorizontalLayout>(); { // Create the label Label label = c.AddControl <Label>(); { label.Content.Text = "Discover non-public members"; label.Content.Tooltip = "Should class members that are not parked 'public' be discovered"; label.Layout.Size = new Vector2(labelWidth, 0); } // Create the toggle box ToggleBox box = c.AddControl <ToggleBox>(); { box.Checked = DynamicCSharp.Settings.discoverNonPublicMembers; box.OnToggled += (object sender, bool value) => { DynamicCSharp.Settings.discoverNonPublicMembers = value; }; } } // Debug mode HorizontalLayout d = parent.AddControl <HorizontalLayout>(); { // Create the label Label label = d.AddControl <Label>(); { label.Content.Text = "Debug Mode"; label.Content.Tooltip = "When enabled the compile will generate and load debug symbols"; label.Layout.Size = new Vector2(labelWidth, 0); } // Create the toggle box ToggleBox box = d.AddControl <ToggleBox>(); { box.Checked = DynamicCSharp.Settings.debugMode; box.OnToggled += (object sender, bool value) => { DynamicCSharp.Settings.debugMode = value; }; } } // Spacer parent.AddControl <Spacer>(); EditListBox listbox = parent.AddControl <EditListBox>(); { listbox.Content.Text = "Assembly References"; listbox.ItemStyle = new VisualStyle(EditorStyle.ToolbarButton); foreach (string value in DynamicCSharp.Settings.assemblyReferences) { listbox.AddItem(value); } // On add clicked listbox.OnAddClicked += (object sender) => { // Show an input dialog InputDialog dialog = InputDialog.ShowDialog <InputDialog>(new Vector2(0, 0)); dialog.WindowTitle = "Add Assembly Reference"; dialog.Content = "Enter the name of the assembly you want to add including the '.dll' file extension"; dialog.CenterAt(UiEvent.mouseScreenPosition); dialog.OnClosed += (object s, DialogResult result) => { // Check for dialog accepted if (result == DialogResult.OK) { InputDialog window = s as InputDialog; // Make sure the input is not empty if (string.IsNullOrEmpty(window.Text) == false) { // Add to listbox listbox.AddItem(window.Text); // Add to settings DynamicCSharp.Settings.AddAssemblyReference(window.Text); } } }; }; // On remove clicked listbox.OnRemoveClicked += (object sender) => { // Catch exceptions when the list is empty try { // Remove selection listbox.RemoveItem(listbox.SelectedItemName); // Remove from settings DynamicCSharp.Settings.RemoveAssemblyReference(listbox.SelectedIndex); } catch { } }; } }
private void CreateSecurityTab(IDesignerControl parent) { // Security check code HorizontalLayout a = parent.AddControl <HorizontalLayout>(); { // Create the label Label label = a.AddControl <Label>(); { label.Content.Text = "Security Check Code"; label.Content.Tooltip = "When enabled, all code will be security checked before it can be loaded"; } // Create the toggle box ToggleBox box = a.AddControl <ToggleBox>(); { box.Checked = DynamicCSharp.Settings.securityCheckCode; box.OnToggled += (object sender, bool value) => { DynamicCSharp.Settings.securityCheckCode = value; }; } } parent.AddControl <Spacer>(); EditListBox referenceListbox = parent.AddControl <EditListBox>(); { referenceListbox.Content.Text = "Assembly Reference Restrictions"; referenceListbox.ItemStyle = new VisualStyle(EditorStyle.ToolbarButton); foreach (ReferenceRestriction value in DynamicCSharp.Settings.referenceRestrictions) { referenceListbox.AddItem(value.RestrictedName); } // On add clicked referenceListbox.OnAddClicked += (object sender) => { // Show an input dialog InputDialog dialog = InputDialog.ShowDialog <InputDialog>(new Vector2(0, 0)); dialog.WindowTitle = "Add Assembly Reference Restriction"; dialog.Content = "Enter the name of the assembly you want to restrict including the '.dll' file extension"; dialog.CenterAt(UiEvent.mouseScreenPosition); dialog.OnClosed += (object s, DialogResult result) => { if (result == DialogResult.OK) { InputDialog window = s as InputDialog; if (string.IsNullOrEmpty(window.Text) == false) { // Add to listbox referenceListbox.AddItem(window.Text); // Add to settings DynamicCSharp.Settings.AddReferenceRestriction(window.Text); } } }; }; // On remove clicked referenceListbox.OnRemoveClicked += (object sender) => { // Catch exceptions cause by empty list try { // Remove selection referenceListbox.RemoveItem(referenceListbox.SelectedItemName); // Remove from settings DynamicCSharp.Settings.RemoveReferenceRestriction(referenceListbox.SelectedIndex); } catch { } }; } parent.AddControl <Spacer>(); EditListBox namespaceListbox = parent.AddControl <EditListBox>(); { namespaceListbox.Content.Text = "Namespace Restrictions"; namespaceListbox.ItemStyle = new VisualStyle(EditorStyle.ToolbarButton); foreach (NamespaceRestriction value in DynamicCSharp.Settings.namespaceRestrictions) { namespaceListbox.AddItem(value.RestrictedNamespace); } // On add clicked namespaceListbox.OnAddClicked += (object sender) => { // Show an input dialog InputDialog dialog = InputDialog.ShowDialog <InputDialog>(new Vector2(0, 0)); dialog.WindowTitle = "Add Namespace Restriction"; dialog.Content = "Enter the namespace you want to restrict. For example, 'System.IO'"; dialog.CenterAt(UiEvent.mouseScreenPosition); dialog.OnClosed += (object s, DialogResult result) => { if (result == DialogResult.OK) { InputDialog window = s as InputDialog; if (string.IsNullOrEmpty(window.Text) == false) { // Add to listbox namespaceListbox.AddItem(window.Text); // Add to settings DynamicCSharp.Settings.AddNamespaceRestriction(window.Text); } } }; }; // On remove clicked namespaceListbox.OnRemoveClicked += (object sender) => { // Catch exceptions cause by empty list try { // Remove selection namespaceListbox.RemoveItem(namespaceListbox.SelectedItemName); // Remove from settings DynamicCSharp.Settings.RemoveNamespaceRestriction(namespaceListbox.SelectedIndex); } catch { } }; } }
private void CreateUI() { Label label = AddControl <Label>(); { label.Content.Text = "Dynamic C# Installer"; label.Style = new VisualStyle(EditorStyle.BoldLabel); } AddControl <Spacer>(); HelpBox help = AddControl <HelpBox>(); { help.Content.Text = "This installer is only required if you need support for runtime script compilation. If you are using managed assemblies only then you can skip this install process. You can always come back to this installer at a later date from 'Tools -> Dynamic C# -> Installer'"; help.HelpType = HelpBoxType.Info; } AddControl <Spacer>(); Label helpLabel = AddControl <Label>(); { helpLabel.Content.Text = "The following actions need to be performed:"; helpLabel.Style = new VisualStyle(EditorStyle.BoldLabel); helpLabel.Layout.Size = new Vector2(0, 0); } HorizontalLayout compatibilityLayout = AddControl <HorizontalLayout>(); { // Tab spacer compatibilityLayout.AddControl <Spacer>().Spacing = 20; // Image Image img = compatibilityLayout.AddControl <Image>(); { img.Content.Texture = (IsCompatibilitySet() == true) ? tick : cross; img.Layout.Size = new Vector2(12, 12); } Label text = compatibilityLayout.AddControl <Label>(); { text.Content.Text = "-Change API compatibility level to '.NET 2.0'"; text.Layout.Size = new Vector2(0, 0); } } HorizontalLayout compilerLayout = AddControl <HorizontalLayout>(); { // Tab spacer compilerLayout.AddControl <Spacer>().Spacing = 20; // Image Image img = compilerLayout.AddControl <Image>(); { img.Content.Texture = (IsCompilerInstalled() == true) ? tick : cross; img.Layout.Size = new Vector2(12, 12); } Label text = compilerLayout.AddControl <Label>(); { text.Content.Text = "-Import the compiler package"; text.Layout.Size = new Vector2(0, 0); } } AddControl <FlexibleSpacer>(); CenterLayout center = AddControl <CenterLayout>(); { Button button = center.AddControl <Button>(); { button.Content.Text = "Install"; button.Layout.Size = new Vector2(100, 30); button.Enabled = !(IsCompatibilitySet() && IsCompilerInstalled()); button.OnClicked += InstallCompiler; } } }
private void createUI() { Toolbar toolbar = AddControl <Toolbar>(); { Label label = toolbar.AddControl <Label>(); { label.Content.Text = "Update Rate: "; label.Layout.Size = new Vector2(0, 0); } ToggleButton slow = toolbar.AddControl <ToggleButton>("0"); { slow.Style = new VisualStyle(EditorStyle.ToolbarButton); slow.Content.Text = "Slow Update"; slow.Content.Tooltip = "Set the refresh mode to slow. Less updates per frame"; slow.OnClicked += (object sender) => { setUpdateRate(0); }; } ToggleButton medium = toolbar.AddControl <ToggleButton>("1"); { medium.Style = new VisualStyle(EditorStyle.ToolbarButton); medium.Content.Text = "Medium Update"; medium.Content.Tooltip = "Set the refresh mode to medium. The default settings"; medium.OnClicked += (object sender) => { setUpdateRate(1); }; } ToggleButton fast = toolbar.AddControl <ToggleButton>("2"); { fast.Style = new VisualStyle(EditorStyle.ToolbarButton); fast.Content.Text = "Fast Update"; fast.Content.Tooltip = "Set the refresh mode to fast. More updates per frames for more accurate data"; fast.OnClicked += (object sender) => { setUpdateRate(2); }; } toolbar.AddControl <FlexibleSpacer>(); // Set the mode setUpdateRate(-1); } parent = AddControl <VerticalLayout>(); { HelpBox timingHelp = parent.AddControl <HelpBox>(); { timingHelp.Content.Text = "Shows the average and peek time taken to complete the algorithm"; } Chart timingChart = parent.AddControl <Chart>(); { timingChart.Layout.MinSize = new Vector2(0, 0); timingChart.SetChartAxis(ChartAxis.Horizontal, 0, 1, "Update (Frame Step)"); timingChart.SetChartAxis(ChartAxis.Vertical, 0, 1, "Time (ms)"); timingChart.SetDatasetCount(2); timingChart.SetDataset(0, timingData); timingChart.SetDataset(1, timingPeekData); timingData.Name = "Average Time (Per sample)"; timingPeekData.Name = "Highest Time (Per sample)"; } HelpBox usageHelp = parent.AddControl <HelpBox>(); { usageHelp.Content.Text = "Shows the current usages value for all worker threads (When active)"; } HorizontalLayout usageLayout = parent.AddControl <HorizontalLayout>(); { Chart usageChart = usageLayout.AddControl <Chart>(); { usageChart.Layout.MinSize = new Vector2(0, 0); usageChart.SetChartAxis(ChartAxis.Horizontal, 0, 1, "Update (Frame Step)"); usageChart.SetChartAxis(ChartAxis.Vertical, 0, 1, "Usage (%)"); // Set data usageChart.SetDatasetCount(3); for (int i = 0; i < ThreadManager.maxAllowedWorkerThreads; i++) { usageData[i] = new ChartDynamicDataset(); usageData[i].Name = string.Format("Thread {0}", i + 1); usageChart.SetDataset(i, usageData[i]); } } usageView = usageLayout.AddControl <ThreadViewCollectionControl>(); { usageView.Layout.Size = new Vector2(230, 0); } } } hint = AddControl <HelpBox>(); { hint.HelpType = HelpBoxType.Info; hint.Content.Text = "Waiting for game to launch. Timing and usage statistics can only be gathered in play mode"; } }