public void OnEnable() { #region Initialization if (data == null) { data = Resources.Load <ProceduralDataObject>("data"); } // Each editor window contains a root VisualElement object VisualElement root = rootVisualElement; // Import UXML var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Procedural++/Editor/MapCreatorWindow.uxml"); VisualElement uxml = visualTree.CloneTree(); //Import Stylesheet var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/Procedural++/Editor/MapCreatorWindow.uss"); uxml.styleSheets.Add(styleSheet); root.Add(uxml); #endregion #region Buttons Button createButton = root.Query <Button>("createMap"); createButton.clickable.clicked += () => { switch ((MapType)enumFieldMap.value) { case MapType.RandomNoise: previousArea = Procedural2DHelper.CreateRandomNoiseArea((int)sliderX.value, (int)sliderY.value, 0, 0); break; case MapType.Drunkard: previousArea = Procedural2DHelper.CreateDrunkardWalkArea((int)sliderX.value, (int)sliderY.value, 0, 0, iterationsDrunkard); break; case MapType.BSPDungeon: previousArea = Procedural2DHelper.CreateBSPDungeonArea((int)sliderX.value, (int)sliderY.value, 0, 0, minRooms, maxRooms, minWidth, minHeight); break; case MapType.SimpleDungeon: previousArea = Procedural2DHelper.CreateSimpleDungeonArea((int)sliderX.value, (int)sliderY.value, 0, 0, tryRooms, extraCorridors, minWidthS, maxWidth, minHeightS, maxHeight); break; case MapType.CellularAutomata: previousArea = Procedural2DHelper.CreateCellularAutomataArea((int)sliderX.value, (int)sliderY.value, cellularConfiguration.probabilities.ToArray(), 0, 0, cellularConfiguration.iterations, cellularConfiguration.numberOfTIles); break; } MapDrawer.DrawMapWithTileMap(previousArea); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); }; Button clearButton = root.Query <Button>("clearMap"); clearButton.clickable.clicked += () => { MapDrawer.ClearTileMap(); }; Button saveButton = root.Query <Button>("saveMap"); saveButton.clickable.clicked += () => { if (previousArea.tileInfo != null) { string name = EditorUtility.SaveFilePanel("Save map", "./Assets", "DataMap", "bin"); if (name != null) { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(name, FileMode.Create, FileAccess.Write, FileShare.None); formatter.Serialize(stream, previousArea); stream.Close(); } } else { Debug.Log("Generate an Area before saving!"); } }; Button loadButton = root.Query <Button>("loadMap"); loadButton.clickable.clicked += () => { string name = EditorUtility.OpenFilePanel("Load Map", "./Assets", "bin"); if (name != null) { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(name, FileMode.Open, FileAccess.Read, FileShare.Read); previousArea = (Area)formatter.Deserialize(stream); MapDrawer.DrawMapWithTileMap(previousArea); stream.Close(); } }; #endregion #region SizeSliders sliderX = root.Query <Slider>("sizeX"); sizeXText = root.Query <Label>("sizeXText"); sizeXText.text = ((int)sliderX.value).ToString() + " size X"; sliderX.RegisterValueChangedCallback((t) => { sizeXText.text = ((int)t.newValue).ToString() + " size X"; }); sliderY = root.Query <Slider>("sizeY"); sizeYText = root.Query <Label>("sizeYText"); sizeYText.text = ((int)sliderY.value).ToString() + " size Y"; sliderY.RegisterValueChangedCallback((t) => { sizeYText.text = ((int)t.newValue).ToString() + " size Y"; }); #endregion #region Default General Data ObjectField field = root.Query <ObjectField>("tileColision"); field.objectType = typeof(Tile); field.value = data.defaultCollisionTile; ObjectField fieldFloor = root.Query <ObjectField>("tileFloor"); fieldFloor.objectType = typeof(Tile); fieldFloor.value = data.defaultFreeTile; field.RegisterValueChangedCallback((t) => { data.defaultCollisionTile = (Tile)t.newValue; }); fieldFloor.RegisterValueChangedCallback((t) => { data.defaultFreeTile = (Tile)t.newValue; }); Toggle toggle = root.Query <Toggle>("autoClear"); toggle.value = data.autoClearTileMap; toggle.RegisterValueChangedCallback((t) => { data.autoClearTileMap = t.newValue; }); #endregion #region Map Specific Data parentMapSpecificData = root.Query <Box>("rootMapSpecific"); Slider iterations = new Slider(5000, 1000000); iterations.label = "Iterations (5000)"; iterations.value = iterationsDrunkard; iterations.RegisterValueChangedCallback((t) => { iterations.label = "Iterations (" + (int)t.newValue + ")"; iterationsDrunkard = (int)t.newValue; }); parentMapSpecificData.Add(iterations); enumFieldMap = root.Query <EnumField>("mapSelector"); enumFieldMap.Init(MapType.Drunkard); enumFieldMap.RegisterValueChangedCallback((t) => { var newValue = (MapType)t.newValue; switch (newValue) { case MapType.RandomNoise: RemoveChildsFromMapSpecificParent(); break; case MapType.Drunkard: DrunkardEnumSwitch(); break; case MapType.BSPDungeon: BSPDungeonSwitch(); break; case MapType.SimpleDungeon: SimpleDungeonSwitch(); break; case MapType.CellularAutomata: CellularAutomataSwitch(); break; } }); #endregion }
private SettingsWindow(MainWindow parent, Builder builder, VirtualFileSystem virtualFileSystem, HLE.FileSystem.Content.ContentManager contentManager) : base(builder.GetObject("_settingsWin").Handle) { Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.Resources.Logo_Ryujinx.png"); _parent = parent; builder.Autoconnect(this); _timeZoneContentManager = new TimeZoneContentManager(); _timeZoneContentManager.InitializeInstance(virtualFileSystem, contentManager, IntegrityCheckLevel.None); _validTzRegions = new HashSet <string>(_timeZoneContentManager.LocationNameCache.Length, StringComparer.Ordinal); // Zone regions are identifiers. Must match exactly. // Bind Events. _configureController1.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player1); _configureController2.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player2); _configureController3.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player3); _configureController4.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player4); _configureController5.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player5); _configureController6.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player6); _configureController7.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player7); _configureController8.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player8); _configureControllerH.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Handheld); _systemTimeZoneEntry.FocusOutEvent += TimeZoneEntry_FocusOut; _resScaleCombo.Changed += (sender, args) => _resScaleText.Visible = _resScaleCombo.ActiveId == "-1"; _galThreading.Changed += (sender, args) => { if (_galThreading.ActiveId != ConfigurationState.Instance.Graphics.BackendThreading.Value.ToString()) { GtkDialog.CreateInfoDialog("Warning - Backend Threading", "Ryujinx must be restarted after changing this option for it to apply fully. Depending on your platform, you may need to manually disable your driver's own multithreading when using Ryujinx's."); } }; // Setup Currents. if (ConfigurationState.Instance.Logger.EnableTrace) { _traceLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableFileLog) { _fileLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableError) { _errorLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableWarn) { _warningLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableInfo) { _infoLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableStub) { _stubLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableDebug) { _debugLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableGuest) { _guestLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableFsAccessLog) { _fsAccessLogToggle.Click(); } foreach (GraphicsDebugLevel level in Enum.GetValues <GraphicsDebugLevel>()) { _graphicsDebugLevel.Append(level.ToString(), level.ToString()); } _graphicsDebugLevel.SetActiveId(ConfigurationState.Instance.Logger.GraphicsDebugLevel.Value.ToString()); if (ConfigurationState.Instance.System.EnableDockedMode) { _dockedModeToggle.Click(); } if (ConfigurationState.Instance.EnableDiscordIntegration) { _discordToggle.Click(); } if (ConfigurationState.Instance.CheckUpdatesOnStart) { _checkUpdatesToggle.Click(); } if (ConfigurationState.Instance.ShowConfirmExit) { _showConfirmExitToggle.Click(); } if (ConfigurationState.Instance.HideCursorOnIdle) { _hideCursorOnIdleToggle.Click(); } if (ConfigurationState.Instance.Graphics.EnableVsync) { _vSyncToggle.Click(); } if (ConfigurationState.Instance.Graphics.EnableShaderCache) { _shaderCacheToggle.Click(); } if (ConfigurationState.Instance.System.EnablePtc) { _ptcToggle.Click(); } if (ConfigurationState.Instance.System.EnableInternetAccess) { _internetToggle.Click(); } if (ConfigurationState.Instance.System.EnableFsIntegrityChecks) { _fsicToggle.Click(); } switch (ConfigurationState.Instance.System.MemoryManagerMode.Value) { case MemoryManagerMode.SoftwarePageTable: _mmSoftware.Click(); break; case MemoryManagerMode.HostMapped: _mmHost.Click(); break; case MemoryManagerMode.HostMappedUnsafe: _mmHostUnsafe.Click(); break; } if (ConfigurationState.Instance.System.ExpandRam) { _expandRamToggle.Click(); } if (ConfigurationState.Instance.System.IgnoreMissingServices) { _ignoreToggle.Click(); } if (ConfigurationState.Instance.Hid.EnableKeyboard) { _directKeyboardAccess.Click(); } if (ConfigurationState.Instance.Hid.EnableMouse) { _directMouseAccess.Click(); } if (ConfigurationState.Instance.Ui.EnableCustomTheme) { _custThemeToggle.Click(); } // Custom EntryCompletion Columns. If added to glade, need to override more signals ListStore tzList = new ListStore(typeof(string), typeof(string), typeof(string)); _systemTimeZoneCompletion.Model = tzList; CellRendererText offsetCol = new CellRendererText(); CellRendererText abbrevCol = new CellRendererText(); _systemTimeZoneCompletion.PackStart(offsetCol, false); _systemTimeZoneCompletion.AddAttribute(offsetCol, "text", 0); _systemTimeZoneCompletion.TextColumn = 1; // Regions Column _systemTimeZoneCompletion.PackStart(abbrevCol, false); _systemTimeZoneCompletion.AddAttribute(abbrevCol, "text", 2); int maxLocationLength = 0; foreach (var(offset, location, abbr) in _timeZoneContentManager.ParseTzOffsets()) { var hours = Math.DivRem(offset, 3600, out int seconds); var minutes = Math.Abs(seconds) / 60; var abbr2 = (abbr.StartsWith('+') || abbr.StartsWith('-')) ? string.Empty : abbr; tzList.AppendValues($"UTC{hours:+0#;-0#;+00}:{minutes:D2} ", location, abbr2); _validTzRegions.Add(location); maxLocationLength = Math.Max(maxLocationLength, location.Length); } _systemTimeZoneEntry.WidthChars = Math.Max(20, maxLocationLength + 1); // Ensure minimum Entry width _systemTimeZoneEntry.Text = _timeZoneContentManager.SanityCheckDeviceLocationName(ConfigurationState.Instance.System.TimeZone); _systemTimeZoneCompletion.MatchFunc = TimeZoneMatchFunc; _systemLanguageSelect.SetActiveId(ConfigurationState.Instance.System.Language.Value.ToString()); _systemRegionSelect.SetActiveId(ConfigurationState.Instance.System.Region.Value.ToString()); _galThreading.SetActiveId(ConfigurationState.Instance.Graphics.BackendThreading.Value.ToString()); _resScaleCombo.SetActiveId(ConfigurationState.Instance.Graphics.ResScale.Value.ToString()); _anisotropy.SetActiveId(ConfigurationState.Instance.Graphics.MaxAnisotropy.Value.ToString()); _aspectRatio.SetActiveId(((int)ConfigurationState.Instance.Graphics.AspectRatio.Value).ToString()); _custThemePath.Buffer.Text = ConfigurationState.Instance.Ui.CustomThemePath; _resScaleText.Buffer.Text = ConfigurationState.Instance.Graphics.ResScaleCustom.Value.ToString(); _resScaleText.Visible = _resScaleCombo.ActiveId == "-1"; _graphicsShadersDumpPath.Buffer.Text = ConfigurationState.Instance.Graphics.ShadersDumpPath; _fsLogSpinAdjustment.Value = ConfigurationState.Instance.System.FsGlobalAccessLogMode; _systemTimeOffset = ConfigurationState.Instance.System.SystemTimeOffset; _gameDirsBox.AppendColumn("", new CellRendererText(), "text", 0); _gameDirsBoxStore = new ListStore(typeof(string)); _gameDirsBox.Model = _gameDirsBoxStore; foreach (string gameDir in ConfigurationState.Instance.Ui.GameDirs.Value) { _gameDirsBoxStore.AppendValues(gameDir); } if (_custThemeToggle.Active == false) { _custThemePath.Sensitive = false; _custThemePathLabel.Sensitive = false; _browseThemePath.Sensitive = false; } //Setup system time spinners UpdateSystemTimeSpinners(); _audioBackendStore = new ListStore(typeof(string), typeof(AudioBackend)); TreeIter openAlIter = _audioBackendStore.AppendValues("OpenAL", AudioBackend.OpenAl); TreeIter soundIoIter = _audioBackendStore.AppendValues("SoundIO", AudioBackend.SoundIo); TreeIter sdl2Iter = _audioBackendStore.AppendValues("SDL2", AudioBackend.SDL2); TreeIter dummyIter = _audioBackendStore.AppendValues("Dummy", AudioBackend.Dummy); _audioBackendSelect = ComboBox.NewWithModelAndEntry(_audioBackendStore); _audioBackendSelect.EntryTextColumn = 0; _audioBackendSelect.Entry.IsEditable = false; switch (ConfigurationState.Instance.System.AudioBackend.Value) { case AudioBackend.OpenAl: _audioBackendSelect.SetActiveIter(openAlIter); break; case AudioBackend.SoundIo: _audioBackendSelect.SetActiveIter(soundIoIter); break; case AudioBackend.SDL2: _audioBackendSelect.SetActiveIter(sdl2Iter); break; case AudioBackend.Dummy: _audioBackendSelect.SetActiveIter(dummyIter); break; default: throw new ArgumentOutOfRangeException(); } _audioBackendBox.Add(_audioBackendSelect); _audioBackendSelect.Show(); _previousVolumeLevel = ConfigurationState.Instance.System.AudioVolume; _audioVolumeLabel = new Label("Volume: "); _audioVolumeSlider = new Scale(Orientation.Horizontal, 0, 100, 1); _audioVolumeLabel.MarginStart = 10; _audioVolumeSlider.ValuePos = PositionType.Right; _audioVolumeSlider.WidthRequest = 200; _audioVolumeSlider.Value = _previousVolumeLevel * 100; _audioVolumeSlider.ValueChanged += VolumeSlider_OnChange; _audioBackendBox.Add(_audioVolumeLabel); _audioBackendBox.Add(_audioVolumeSlider); _audioVolumeLabel.Show(); _audioVolumeSlider.Show(); bool openAlIsSupported = false; bool soundIoIsSupported = false; bool sdl2IsSupported = false; Task.Run(() => { openAlIsSupported = OpenALHardwareDeviceDriver.IsSupported; soundIoIsSupported = SoundIoHardwareDeviceDriver.IsSupported; sdl2IsSupported = SDL2HardwareDeviceDriver.IsSupported; }); // This function runs whenever the dropdown is opened _audioBackendSelect.SetCellDataFunc(_audioBackendSelect.Cells[0], (layout, cell, model, iter) => { cell.Sensitive = ((AudioBackend)_audioBackendStore.GetValue(iter, 1)) switch { AudioBackend.OpenAl => openAlIsSupported, AudioBackend.SoundIo => soundIoIsSupported, AudioBackend.SDL2 => sdl2IsSupported, AudioBackend.Dummy => true, _ => throw new ArgumentOutOfRangeException() }; });
public override void OnActivate(string searchContext, VisualElement root) { var padRect = new VisualElement(); int padding = 10; padRect.style.paddingBottom = padding; padRect.style.paddingLeft = padding; padRect.style.paddingRight = padding; padRect.style.paddingTop = padding - 5; root.Add(padRect); var title = new Label("Notch Solution"); title.style.fontSize = 15; title.style.unityFontStyleAndWeight = FontStyle.Bold; padRect.Add(title); var repo = new Label("https://github.com/5argon/NotchSolution"); repo.style.paddingBottom = 15; repo.style.unityFontStyleAndWeight = FontStyle.Bold; repo.RegisterCallback((MouseDownEvent ev) => { System.Diagnostics.Process.Start("https://github.com/5argon/NotchSolution"); }); padRect.Add(repo); var colorField = new ColorField("Prefab mode overlay color"); colorField.value = NotchSolutionUtility.PrefabModeOverlayColor; colorField.RegisterValueChangedCallback(ev => { NotchSolutionUtility.PrefabModeOverlayColor = ev.newValue; NotchSimulator.UpdateAllMockups(); NotchSimulator.UpdateSimulatorTargets(); }); padRect.Add(colorField); string shortcutString = ShortcutManager.instance.GetShortcutBinding(NotchSolutionShortcuts.switchNarrowestWidestShortcut).ToString(); string text = $"This feature allows you to press {shortcutString} to quick switch between 2 aspect ratio choices. Commonly I would often switch between the longest phone like LG G7 and widest device like an iPad as I design. The index is counted from the top choice where 0 equals Free Aspect."; var box = new Box(); var helpBox = new Label(text); helpBox.style.whiteSpace = WhiteSpace.Normal; box.style.paddingTop = 5; box.style.paddingLeft = 5; box.style.paddingRight = 5; box.style.paddingBottom = 2; box.style.marginTop = 10; box.style.marginBottom = 10; box.Add(helpBox); padRect.Add(box); //TODO : Reflect to `GameViewSizes.instance` and request all sizes to draw a nicer drop down menu instead of index number. var narrowest = new IntegerField("Narrowest aspect index"); narrowest.value = NotchSolutionUtility.NarrowestAspectIndex; narrowest.RegisterValueChangedCallback(ev => { narrowest.value = Mathf.Max(0, ev.newValue); //go to -1 and the game view crashes.. NotchSolutionUtility.NarrowestAspectIndex = ev.newValue; NotchSimulator.UpdateAllMockups(); NotchSimulator.UpdateSimulatorTargets(); }); padRect.Add(narrowest); var widest = new IntegerField("Widest aspect index"); widest.value = NotchSolutionUtility.WidestAspectIndex; widest.RegisterValueChangedCallback(ev => { widest.value = Mathf.Max(0, ev.newValue); NotchSolutionUtility.WidestAspectIndex = ev.newValue; NotchSimulator.UpdateAllMockups(); NotchSimulator.UpdateSimulatorTargets(); }); padRect.Add(widest); }
public override VisualElement CreateInspectorGUI() { var root = new VisualElement { name = "HierarchyHeaderRoot" }; scrollView = new ScrollView(); #if UNITY_2020_2_OR_NEWER var boxContainer = new Box(); boxContainer.AddToClassList("mainBoxContainer"); boxContainer.Add(scrollView); #endif serializedObject.Update(); var property = serializedObject.GetIterator(); if (property.NextVisible(true)) { do { var propPath = property.propertyPath; var propertyField = new PropertyField(property) { name = "PropertyField:" + propPath }; switch (propPath) { case "m_Script" when serializedObject.targetObject != null: propertyField.visible = true; propertyField.SetEnabled(true); break; default: if (property.IsReallyArray() && serializedObject.targetObject != null) { var copiedProperty = property.Copy(); // @formatter:off #if UNITY_2020_2_OR_NEWER var imDefaultProperty = new IMGUIContainer(() => { DoDrawDefaultIMGUIProperty(serializedObject, copiedProperty); }) { name = propPath }; #else reorderableList = new ReorderableList(serializedObject, copiedProperty) { drawHeaderCallback = DrawHeaderCallback, drawElementCallback = DrawElementCallback, elementHeightCallback = ElementHeightCallback, onAddCallback = OnAddCallback }; // @formatter:on reorderableList.elementHeightCallback = ElementHeightCallback; var imDefaultProperty = new IMGUIContainer(() => { serializedObject.Update(); reorderableList.DoLayoutList(); serializedObject.ApplyModifiedProperties(); }) { name = propPath }; #endif imDefaultProperty.RegisterCallback <ChangeEvent <bool> >(evt => RecomputeSize(imDefaultProperty)); scrollView.Add(imDefaultProperty); } break; // @formatter:on } } while (property.NextVisible(false)); } foreach (var foldoutList in scrollView.Query <Foldout>().ToList()) { foldoutList.RegisterValueChangedCallback(e => { if (!(e.target is Foldout fd)) { return; } var path = fd.bindingPath; var container = scrollView.Q <IMGUIContainer>(path); RecomputeSize(container); }); } serializedObject.ApplyModifiedProperties(); #if UNITY_2020_2_OR_NEWER root.Add(boxContainer); #else root.Add(scrollView); #endif return(root); }
private SettingsWindow(MainWindow parent, Builder builder, VirtualFileSystem virtualFileSystem, HLE.FileSystem.Content.ContentManager contentManager) : base(builder.GetObject("_settingsWin").Handle) { _parent = parent; builder.Autoconnect(this); _timeZoneContentManager = new TimeZoneContentManager(); _timeZoneContentManager.InitializeInstance(virtualFileSystem, contentManager, LibHac.FsSystem.IntegrityCheckLevel.None); _validTzRegions = new HashSet <string>(_timeZoneContentManager.LocationNameCache.Length, StringComparer.Ordinal); // Zone regions are identifiers. Must match exactly. // Bind Events. _configureController1.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player1); _configureController2.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player2); _configureController3.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player3); _configureController4.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player4); _configureController5.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player5); _configureController6.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player6); _configureController7.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player7); _configureController8.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Player8); _configureControllerH.Pressed += (sender, args) => ConfigureController_Pressed(sender, PlayerIndex.Handheld); _systemTimeZoneEntry.FocusOutEvent += TimeZoneEntry_FocusOut; _resScaleCombo.Changed += (sender, args) => _resScaleText.Visible = _resScaleCombo.ActiveId == "-1"; // Setup Currents. if (ConfigurationState.Instance.Logger.EnableFileLog) { _fileLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableError) { _errorLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableWarn) { _warningLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableInfo) { _infoLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableStub) { _stubLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableDebug) { _debugLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableGuest) { _guestLogToggle.Click(); } if (ConfigurationState.Instance.Logger.EnableFsAccessLog) { _fsAccessLogToggle.Click(); } foreach (GraphicsDebugLevel level in Enum.GetValues(typeof(GraphicsDebugLevel))) { _graphicsDebugLevel.Append(level.ToString(), level.ToString()); } _graphicsDebugLevel.SetActiveId(ConfigurationState.Instance.Logger.GraphicsDebugLevel.Value.ToString()); if (ConfigurationState.Instance.System.EnableDockedMode) { _dockedModeToggle.Click(); } if (ConfigurationState.Instance.EnableDiscordIntegration) { _discordToggle.Click(); } if (ConfigurationState.Instance.CheckUpdatesOnStart) { _checkUpdatesToggle.Click(); } if (ConfigurationState.Instance.Graphics.EnableVsync) { _vSyncToggle.Click(); } if (ConfigurationState.Instance.Graphics.EnableShaderCache) { _shaderCacheToggle.Click(); } if (ConfigurationState.Instance.System.EnablePtc) { _ptcToggle.Click(); } if (ConfigurationState.Instance.System.EnableFsIntegrityChecks) { _fsicToggle.Click(); } if (ConfigurationState.Instance.System.IgnoreMissingServices) { _ignoreToggle.Click(); } if (ConfigurationState.Instance.Hid.EnableKeyboard) { _directKeyboardAccess.Click(); } if (ConfigurationState.Instance.Ui.EnableCustomTheme) { _custThemeToggle.Click(); } // Custom EntryCompletion Columns. If added to glade, need to override more signals ListStore tzList = new ListStore(typeof(string), typeof(string), typeof(string)); _systemTimeZoneCompletion.Model = tzList; CellRendererText offsetCol = new CellRendererText(); CellRendererText abbrevCol = new CellRendererText(); _systemTimeZoneCompletion.PackStart(offsetCol, false); _systemTimeZoneCompletion.AddAttribute(offsetCol, "text", 0); _systemTimeZoneCompletion.TextColumn = 1; // Regions Column _systemTimeZoneCompletion.PackStart(abbrevCol, false); _systemTimeZoneCompletion.AddAttribute(abbrevCol, "text", 2); int maxLocationLength = 0; foreach (var(offset, location, abbr) in _timeZoneContentManager.ParseTzOffsets()) { var hours = Math.DivRem(offset, 3600, out int seconds); var minutes = Math.Abs(seconds) / 60; var abbr2 = (abbr.StartsWith('+') || abbr.StartsWith('-')) ? string.Empty : abbr; tzList.AppendValues($"UTC{hours:+0#;-0#;+00}:{minutes:D2} ", location, abbr2); _validTzRegions.Add(location); maxLocationLength = Math.Max(maxLocationLength, location.Length); } _systemTimeZoneEntry.WidthChars = Math.Max(20, maxLocationLength + 1); // Ensure minimum Entry width _systemTimeZoneEntry.Text = _timeZoneContentManager.SanityCheckDeviceLocationName(); _systemTimeZoneCompletion.MatchFunc = TimeZoneMatchFunc; _systemLanguageSelect.SetActiveId(ConfigurationState.Instance.System.Language.Value.ToString()); _systemRegionSelect.SetActiveId(ConfigurationState.Instance.System.Region.Value.ToString()); _resScaleCombo.SetActiveId(ConfigurationState.Instance.Graphics.ResScale.Value.ToString()); _anisotropy.SetActiveId(ConfigurationState.Instance.Graphics.MaxAnisotropy.Value.ToString()); _aspectRatio.SetActiveId(((int)ConfigurationState.Instance.Graphics.AspectRatio.Value).ToString()); _custThemePath.Buffer.Text = ConfigurationState.Instance.Ui.CustomThemePath; _resScaleText.Buffer.Text = ConfigurationState.Instance.Graphics.ResScaleCustom.Value.ToString(); _resScaleText.Visible = _resScaleCombo.ActiveId == "-1"; _graphicsShadersDumpPath.Buffer.Text = ConfigurationState.Instance.Graphics.ShadersDumpPath; _fsLogSpinAdjustment.Value = ConfigurationState.Instance.System.FsGlobalAccessLogMode; _systemTimeOffset = ConfigurationState.Instance.System.SystemTimeOffset; _gameDirsBox.AppendColumn("", new CellRendererText(), "text", 0); _gameDirsBoxStore = new ListStore(typeof(string)); _gameDirsBox.Model = _gameDirsBoxStore; foreach (string gameDir in ConfigurationState.Instance.Ui.GameDirs.Value) { _gameDirsBoxStore.AppendValues(gameDir); } if (_custThemeToggle.Active == false) { _custThemePath.Sensitive = false; _custThemePathLabel.Sensitive = false; _browseThemePath.Sensitive = false; } //Setup system time spinners UpdateSystemTimeSpinners(); _audioBackendStore = new ListStore(typeof(string), typeof(AudioBackend)); TreeIter openAlIter = _audioBackendStore.AppendValues("OpenAL", AudioBackend.OpenAl); TreeIter soundIoIter = _audioBackendStore.AppendValues("SoundIO", AudioBackend.SoundIo); TreeIter dummyIter = _audioBackendStore.AppendValues("Dummy", AudioBackend.Dummy); _audioBackendSelect = ComboBox.NewWithModelAndEntry(_audioBackendStore); _audioBackendSelect.EntryTextColumn = 0; _audioBackendSelect.Entry.IsEditable = false; switch (ConfigurationState.Instance.System.AudioBackend.Value) { case AudioBackend.OpenAl: _audioBackendSelect.SetActiveIter(openAlIter); break; case AudioBackend.SoundIo: _audioBackendSelect.SetActiveIter(soundIoIter); break; case AudioBackend.Dummy: _audioBackendSelect.SetActiveIter(dummyIter); break; default: throw new ArgumentOutOfRangeException(); } _audioBackendBox.Add(_audioBackendSelect); _audioBackendSelect.Show(); bool openAlIsSupported = false; bool soundIoIsSupported = false; Task.Run(() => { openAlIsSupported = OpenALAudioOut.IsSupported; soundIoIsSupported = SoundIoAudioOut.IsSupported; }); // This function runs whenever the dropdown is opened _audioBackendSelect.SetCellDataFunc(_audioBackendSelect.Cells[0], (layout, cell, model, iter) => { cell.Sensitive = ((AudioBackend)_audioBackendStore.GetValue(iter, 1)) switch { AudioBackend.OpenAl => openAlIsSupported, AudioBackend.SoundIo => soundIoIsSupported, AudioBackend.Dummy => true, _ => throw new ArgumentOutOfRangeException() }; });
private void InitUI() { var start = new Button(); start.name = "btn_start_cmd"; start.text = "启动cmd"; start.clicked += () => { StartCMD(); StartButton.SetEnabled(false); CloseButton.SetEnabled(true); OutputBox.SetEnabled(true); SetInputEnable(true); }; rootVisualElement.Add(start); // 关闭cmd进程 var close = new Button(); close.name = "btn_close_cmd"; close.text = "关闭cmd"; close.clicked += () => { CloseProxy(); StartButton.SetEnabled(true); CloseButton.SetEnabled(false); OutputBox.SetEnabled(false); SetInputEnable(false); }; close.SetEnabled(false); rootVisualElement.Add(close); var output = new Box(); output.name = "box_output"; { // 滚动视图 var scrollView = new ScrollView(); scrollView.name = "sv_output"; { // 结果输出 var label = new Label(); label.name = "lab_output"; label.text = ""; scrollView.Add(label); } output.Add(scrollView); } output.SetEnabled(false); rootVisualElement.Add(output); // cmd命令输入框 var inputText = new TextField(); inputText.name = "ipt_text"; inputText.SetEnabled(false); rootVisualElement.Add(inputText); // 确定输入命令 var input = new Button(); input.name = "btn_input"; input.text = "确定"; input.clicked += () => { returnMsgs.Clear(); RunCmd(inputText.value, (msgs) => { returnMsgs = msgs; _cmdReturnFlag = true; // returnMsgs.Enqueue(msg); // if (msg.Equals(ProcessProxy.CommandReturnFlag)) // { // _cmdReturnFlag = true; // } }); SetInputEnable(false); }; input.SetEnabled(false); rootVisualElement.Add(input); }
private void CreateGameWindow(HLE.Switch device) { ControllerType type = (Ryujinx.Configuration.Hid.ControllerType)ConfigurationState.Instance.Hid.ControllerType switch { Ryujinx.Configuration.Hid.ControllerType.ProController => ControllerType.ProController, Ryujinx.Configuration.Hid.ControllerType.Handheld => ControllerType.Handheld, Ryujinx.Configuration.Hid.ControllerType.NpadPair => ControllerType.JoyconPair, Ryujinx.Configuration.Hid.ControllerType.NpadLeft => ControllerType.JoyconLeft, Ryujinx.Configuration.Hid.ControllerType.NpadRight => ControllerType.JoyconRight, _ => ControllerType.Handheld }; device.Hid.Npads.AddControllers(new ControllerConfig { PlayerId = HidControllerID.Player1, Type = type }); _gLWidget = new GLRenderer(_emulationContext); Application.Invoke(delegate { _viewBox.Remove(_gameTableWindow); _gLWidget.Expand = true; _viewBox.Child = _gLWidget; _gLWidget.ShowAll(); EditFooterForGameRender(); }); _gLWidget.WaitEvent.WaitOne(); _gLWidget.Start(); device.Dispose(); _deviceExitStatus.Set(); // NOTE: Everything that is here will not be executed when you close the UI. Application.Invoke(delegate { _viewBox.Remove(_gLWidget); _gLWidget.Exit(); if (_gLWidget.Window != this.Window && _gLWidget.Window != null) { _gLWidget.Window.Dispose(); } _gLWidget.Dispose(); _viewBox.Add(_gameTableWindow); _gameTableWindow.Expand = true; this.Window.Title = $"Ryujinx {Program.Version}"; _emulationContext = null; _gameLoaded = false; _gLWidget = null; DiscordIntegrationModule.SwitchToMainMenu(); RecreateFooterForMenu(); UpdateColumns(); UpdateGameTable(); Task.Run(RefreshFirmwareLabel); _stopEmulation.Sensitive = false; _firmwareInstallFile.Sensitive = true; _firmwareInstallDirectory.Sensitive = true; }); }
/// <summary> /// Creates rows, columns, and boxes in data to be used later. /// </summary> private void applySetRelationships() { #region Load Rows for (int index = 1; index <= 9; index++) { Row currentRow = new Row(index); currentRow.UnsolvedValues.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); for (int node = 1; node <= 9; node++) { // // SNode sNode = Sudoku[node - 1, index - 1]; currentRow.Add(sNode); sNode.Row = currentRow; if (sNode.Value != 0) { currentRow.ValueSolved(sNode.Value); } // // } Rows.Add(currentRow); } #endregion #region Load Columns for (int index = 1; index <= 9; index++) { Column currentColumn = new Column(index); currentColumn.UnsolvedValues.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); for (int node = 1; node <= 9; node++) { // // SNode sNode = Sudoku[index - 1, node - 1]; currentColumn.Add(sNode); sNode.Column = currentColumn; if (sNode.Value != 0) { currentColumn.ValueSolved(sNode.Value); } // // } Columns.Add(currentColumn); } #endregion #region Load Boxes int startRow = 0; int startColumn = 0; for (int index = 1; index <= 9; index++) { Box currentBox = new Box(index); currentBox.UnsolvedValues.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); for (int down = 0; down < 3; down++) { for (int right = 0; right < 3; right++) { // // SNode sNode = Sudoku[startColumn + right, startRow + down]; currentBox.Add(sNode); sNode.Box = currentBox; if (sNode.Value != 0) { currentBox.ValueSolved(sNode.Value); } // // } } Boxes.Add(currentBox); currentBox.AddColumn(currentBox[0].Column); currentBox.AddRow(currentBox[0].Row); currentBox.AddColumn(currentBox[4].Column); currentBox.AddRow(currentBox[4].Row); currentBox.AddColumn(currentBox[8].Column); currentBox.AddRow(currentBox[8].Row); // Sets up the starter indices for each box if (startColumn == 6) { startColumn = 0; startRow += 3; } else { startColumn += 3; } } #endregion }
void CreateVisualTree() { string[] guids = AssetDatabase.FindAssets("t:GameAssets"); //foreach (string guid in guids) //{ // //Debug.Log("ScriptObj: " + AssetDatabase.GUIDToAssetPath(guid)); //} if (guids != null && guids.Length > 0) { //allGameAssets = ScriptableObject.CreateInstance<GameAssets>(); allGameAssets = (GameAssets)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guids[0]), typeof(GameAssets)); } else { if (AssetDatabase.IsValidFolder("Assets/Export")) { //Debug.Log("Exists"); } else { string ret; ret = AssetDatabase.CreateFolder("Assets", "Export"); if (AssetDatabase.GUIDToAssetPath(ret) != "") { Debug.Log("Folder asset created"); } else { Debug.Log("Couldn't find the GUID for the path"); } } AssetDatabase.Refresh(); if (AssetDatabase.IsValidFolder("Assets/Export/Assets")) { //Debug.Log("Exists"); } else { string ret; ret = AssetDatabase.CreateFolder("Assets/Export", "Assets"); if (AssetDatabase.GUIDToAssetPath(ret) != "") { Debug.Log("Folder asset created"); } else { Debug.Log("Couldn't find the GUID for the path"); } } if (AssetDatabase.IsValidFolder("Assets/Export/Assets/Data")) { //Debug.Log("Exists"); } else { string ret; ret = AssetDatabase.CreateFolder("Assets/Export/Assets", "Data"); if (AssetDatabase.GUIDToAssetPath(ret) != "") { Debug.Log("Folder asset created"); } else { Debug.Log("Couldn't find the GUID for the path"); } } AssetDatabase.Refresh(); allGameAssets = ScriptableObject.CreateInstance <GameAssets>(); AssetDatabase.CreateAsset(allGameAssets, "Assets/Export/Data/allGameAssets.asset"); } var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/EditorComponents/AssetManager.uxml"); var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/Editor/LevelEditorWindow.uss"); assetManager = visualTree.CloneTree(); addAssetContainer = assetManager.Q <Box>("addAssetContainer"); //search field var popupSearchField = new ToolbarSearchField(); popupSearchField.AddToClassList("asset-manager-searchfield"); popupSearchField.RegisterValueChangedCallback(OnSearchTextChanged); assetTypeSelection = new EnumField(AssetType.Texture); assetTypeSelection.RegisterValueChangedCallback(AssetTypeChange); assetSelectionField = new ObjectField { objectType = typeof(UnityEngine.Texture) }; addAssetButton = new Button(); addAssetButton.text = "Add Asset"; addAssetButton.RegisterCallback <MouseUpEvent>(AddAsset); saveAssetsButton = new Button(); saveAssetsButton.text = "Export All Assets"; saveAssetsButton.RegisterCallback <MouseUpEvent>(SaveAssets); assetListBox = new Box(); assetListBox.style.height = 777; assetListBoxContainer = new ScrollView(); assetListBoxContainer.showHorizontal = false; assetListBox.Add(assetListBoxContainer); addAssetContainer.Add(popupSearchField); addAssetContainer.Add(assetTypeSelection); addAssetContainer.Add(assetSelectionField); addAssetContainer.Add(addAssetButton); addAssetContainer.Add(assetListBox); addAssetContainer.Add(saveAssetsButton); #region LoadAssetsFromAssetData foreach (Texture t in allGameAssets.gameTextures) { assetListBoxContainer.Add(CreateAsset(t.name)); } foreach (AudioClip ac in allGameAssets.gameAudioClips) { assetListBoxContainer.Add(CreateAsset(ac.name)); } foreach (Font f in allGameAssets.gameFonts) { assetListBoxContainer.Add(CreateAsset(f.name)); } #endregion }
private void RecreateFooterForMenu() { _footerBox.Add(_listStatusBox); }
void CreateVisualTree() { var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/EditorComponents/LevelEditor.uxml"); var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/Editor/LevelEditorWindow.uss"); levelEditor = visualTree.CloneTree(); addLevelContainer = levelEditor.Q <Box>("addLevelContainer"); levelListContainer = new IMGUIContainer(DrawAnimationList); levelListContainer.onGUIHandler = DrawAnimationList; levelList = new ReorderableList(allLevels, typeof(Level)); levelList.drawElementCallback = DrawList; levelList.drawHeaderCallback = WriteHeader; levelList.onReorderCallback = ChangeListOrder; levelList.onSelectCallback = SelectListItem; levelList.onAddCallback = AddToList; levelList.onRemoveCallback = RemoveFromList; addLevelContainer.Add(levelListContainer); MapLayer map = new MapLayer(); map.name = "Environment"; map.drawRects = new Dictionary <Vector2Int, Drawable>(); MapLayer objects = new MapLayer(); objects.name = "StaticObjects"; objects.drawRects = new Dictionary <Vector2Int, Drawable>(); MapLayer enemies = new MapLayer(); enemies.name = "Enemies"; enemies.drawRects = new Dictionary <Vector2Int, Drawable>(); MapLayer player = new MapLayer(); player.name = "Players"; player.drawRects = new Dictionary <Vector2Int, Drawable>(); layersToDraw.Add(map); layersToDraw.Add(objects); layersToDraw.Add(enemies); layersToDraw.Add(player); VisualElement stampToolLayout = levelEditor.Q <Box>("levelManagerContainer"); levelEditor.Add(stampToolLayout); VisualElement levelPropertyContainer = levelEditor.Q <Box>("PropertiesBarRow1"); // Create a new field and assign it its value. layersPopupField = new PopupField <string>("Select Layer to Paint", layers, 0); layersPopupField.value = "Environment"; layersPopupField.AddToClassList("height-width-slider"); levelPropertyContainer.Add(layersPopupField); //Label selectTileMapLabel = new Label("Choose TileMap(64x64)"); //levelPropertyContainer.Add(selectTileMapLabel); //textureObjectField = new ObjectField { objectType = typeof(UnityEngine.Texture) }; ////textureObjectField.StretchToParentSize(); //textureObjectField.AddToClassList("height-width-slider"); //levelPropertyContainer.Add(textureObjectField); //// Mirror value of uxml field into the C# field. //layersPopupField.RegisterCallback<ChangeEvent<string>>((evt) => //{ // styledField.value = evt.newValue; //}); VisualElement levelMapContainer = levelEditor.Q <Box>("LevelMapContainer"); mapElement = new IMGUIContainer(mapOnGUI); mapElement.AddToClassList("level-map-sub-container"); mapElement.RegisterCallback <MouseMoveEvent>(OnMapMouseMove); mapElement.RegisterCallback <MouseDownEvent>(OnMapMouseDown); mapElement.RegisterCallback <MouseUpEvent>(OnMapMouseUp); mapElement.RegisterCallback <MouseOutEvent>(OnMapMouseExit); levelMapContainer.Add(mapElement); VisualElement levelTileContainer = levelEditor.Q <Box>("TileMapContainer"); tileElement = new IMGUIContainer(tileOnGUI); tileElement.AddToClassList("tile-map-container"); tileElement.RegisterCallback <MouseUpEvent>(OnTileMouseup); levelTileContainer.Add(tileElement); InitializeLists(); }
public void SetAsmdef(Assembly[] assemblies, IToggleCheckDelegate toggleDelegate_) { var sortedAssemblies = assemblies.OrderBy(x => x.name).ToArray(); var scrollView = rootVisualElement.Q <ScrollView>(className: "ScrollView"); toggleDict.Clear(); for (var i = 0; i < toggleCount; i++) { var toggle = rootVisualElement.Q <Toggle>(className: $"toggle{i}"); if (i < sortedAssemblies.Length) { var assemblyName = sortedAssemblies[i].name; toggle.text = assemblyName; toggle.value = true; toggleDict.Add(assemblyName, new UiElementToggle(toggle)); } else { scrollView.Remove(toggle); } } // グループに分ける var group = new DomainGroup(); group.Create(sortedAssemblies.Select(x => x.name)); var tops = group.GetTopDomainsWithSomeSubDomains().ToArray(); foreach (var top in tops) { var topToggle = new Toggle { text = top, value = true }; var slaveToggles = new List <IToggle>(); Toggle firstToggle = null; var domains = group.GetSubDomains(top); foreach (var domain in domains) { var isLast = domains.Last() == domain; if (toggleDict.TryGetToggle(domain.FullName, out var toggle)) { var keisen = isLast ? "└" : "├"; toggle.Name = domain.HasSubDomain() ? $"{keisen} {domain.SubDomain}" : toggle.Name; slaveToggles.Add(toggle); if (firstToggle == null && toggle is UiElementToggle y) { firstToggle = y.Toggle; } } } var toggleGroup = new ToggleGroup(new UiElementToggle(topToggle), slaveToggles); if (firstToggle != null) { var index = scrollView.IndexOf(firstToggle); // グループに属する toggle は box に入れる var box = new Box(); scrollView.Insert(index, topToggle); scrollView.Insert(index + 1, box); foreach (var slaveToggle in slaveToggles) { if (slaveToggle is UiElementToggle x) { box.Add(x.Toggle); } } } groupMasterToggleDict.Add(top, toggleGroup); } toggleDelegate = toggleDelegate_; }
void AddRadioButton(Box parent, RadioButton button, uint padding) { Gtk.Box.BoxChild child; HBox hbox = new HBox (false, 0); parent.Add (hbox); hbox.Add (button); child = (Gtk.Box.BoxChild) (hbox [button]); child.Padding = padding; hbox.ShowAll (); }
private void UpdateOnTypeSelection(ChangeEvent <string> evt) { ObjectNameTextField.value = null; objectSelectionField.value = null; objectEditSelectionContainer.Clear(); if (ve != null) { ve.Clear(); } switch (evt.newValue) { case "SpriteObject": #region objectSelectionField.objectType = typeof(SpriteObject); var spriteVisualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/ObjectTypeEditors/SpriteDrawer.uxml"); ve = spriteVisualTree.CloneTree(); ve.style.height = 500; ve.style.alignContent = Align.Center; ve.style.paddingTop = 50; ObjectField SpriteSpriteSelection = ve.Q <ObjectField>("SpriteImageObjectSelectionField"); SpriteSpriteSelection.objectType = typeof(Sprite); objectEditSelectionContainer.Add(ve); //ve.Bind() break; #endregion case "EnvironmentObject": #region objectSelectionField.objectType = typeof(EnvironmentObject); var environementVisualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/ObjectTypeEditors/EnvironmentDrawer.uxml"); ve = environementVisualTree.CloneTree(); ve.style.height = 500; ve.style.alignContent = Align.Center; ve.style.paddingTop = 50; ObjectField EnvironementSpriteSelection = ve.Q <ObjectField>("SpriteImageObjectSelectionField"); EnvironementSpriteSelection.objectType = typeof(SpriteObject); ObjectField ColliderSelection = ve.Q <ObjectField>("SpriteColliderObjectSelectionField"); ColliderSelection.objectType = typeof(ColliderObject); objectEditSelectionContainer.Add(ve); break; #endregion case "StaticObject": #region objectSelectionField.objectType = typeof(StaticObject); var staticObjectVisualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/ObjectTypeEditors/StaticObjectDrawer.uxml"); ve = staticObjectVisualTree.CloneTree(); ve.style.height = 500; ve.style.alignContent = Align.Center; ve.style.paddingTop = 50; ObjectField StaticObjectSpriteSelection = ve.Q <ObjectField>("SpriteImageObjectSelectionField"); StaticObjectSpriteSelection.objectType = typeof(SpriteObject); ObjectField StaticObjectColliderSelection = ve.Q <ObjectField>("SpriteColliderObjectSelectionField"); StaticObjectColliderSelection.objectType = typeof(ColliderObject); objectEditSelectionContainer.Add(ve); break; #endregion case "AnimationObject": #region objectSelectionField.objectType = typeof(AnimationObject); var animationVisualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/ObjectTypeEditors/AnimationObjectDrawer.uxml"); ve = animationVisualTree.CloneTree(); ve.style.height = 500; ve.style.alignContent = Align.Center; ve.style.paddingTop = 50; ListView AnimationSpriteObjectsList = ve.Q <ListView>("AnimationSpriteObjectSelectionField"); //AnimationSpriteObjectsList.bindItem //AnimationSpriteObjectsList.objectType = typeof(Sprite); objectEditSelectionContainer.Add(ve); break; #endregion case "EnemyObject": #region objectSelectionField.objectType = typeof(EnemyObject); var enemyObjectVisualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/ObjectTypeEditors/EnemyDrawer.uxml"); ve = enemyObjectVisualTree.CloneTree(); ve.style.height = 500; ve.style.alignContent = Align.Center; ve.style.paddingTop = 50; ObjectField EnemyObjectSpriteSelection = ve.Q <ObjectField>("EnemySpriteObjectSelectionField"); EnemyObjectSpriteSelection.objectType = typeof(SpriteObject); FloatField EnemyHealthField = ve.Q <FloatField>("EnemyObjectHealthField"); FloatField EnemyAttackField = ve.Q <FloatField>("EnemyObjectAttackField"); ObjectField EnemyObjectColliderSelection = ve.Q <ObjectField>("EnemyColliderObjectSelectionField"); EnemyObjectColliderSelection.objectType = typeof(CircleColliderObject); objectEditSelectionContainer.Add(ve); break; #endregion case "EnemySpawner": #region objectSelectionField.objectType = typeof(EnemySpawnerObject); var enemySpawnerObjectVisualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/ObjectTypeEditors/EnemySpawnerDrawer.uxml"); ve = enemySpawnerObjectVisualTree.CloneTree(); ve.style.height = 500; ve.style.alignContent = Align.Center; ve.style.paddingTop = 50; ObjectField EnemySpawnerObjectSpriteSelection = ve.Q <ObjectField>("EnemySpawnerSpriteObjectSelectionField"); EnemySpawnerObjectSpriteSelection.objectType = typeof(SpriteObject); FloatField EnemySpawnerTimeField = ve.Q <FloatField>("EnemySpawnTimeField"); ObjectField EnemySpawnerenemySelection = ve.Q <ObjectField>("EnemyObjectSelectionField"); EnemySpawnerenemySelection.objectType = typeof(EnemyObject); ObjectField EnemySpawnerObjectColliderSelection = ve.Q <ObjectField>("SpawnerColliderObjectSelectionField"); EnemySpawnerObjectColliderSelection.objectType = typeof(CircleColliderObject); objectEditSelectionContainer.Add(ve); break; #endregion //case "Player": // objectSelectionField.objectType = typeof(PlayerObject); // break; case "PolygonCollider": #region objectSelectionField.objectType = typeof(PolygonColliderObject); var polyColliderObjectVisualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/ObjectTypeEditors/PolygonColliderDrawer.uxml"); ve = polyColliderObjectVisualTree.CloneTree(); ve.style.height = 500; ve.style.alignContent = Align.Center; ve.style.paddingTop = 50; FloatField PolyColliderHeightField = ve.Q <FloatField>("PolygonColliderHeightField"); FloatField PolyColliderWidthField = ve.Q <FloatField>("PolygonColliderWidthField"); Toggle PolyColliderIsTriggerToggle = ve.Q <Toggle>("PolygonColliderSetTrigger"); objectEditSelectionContainer.Add(ve); break; #endregion case "CircleCollider": #region objectSelectionField.objectType = typeof(CircleColliderObject); var cirColliderObjectVisualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/ObjectTypeEditors/CircleColliderDrawer.uxml"); ve = cirColliderObjectVisualTree.CloneTree(); ve.style.height = 500; ve.style.alignContent = Align.Center; ve.style.paddingTop = 50; FloatField CircleColliderHeightField = ve.Q <FloatField>("CircleColliderRadiusField"); Toggle CircleColliderIsTriggerToggle = ve.Q <Toggle>("CircleColliderSetTrigger"); objectEditSelectionContainer.Add(ve); break; #endregion case "ProjectileObject": #region //ProjectileObjectDrawer objectSelectionField.objectType = typeof(ProjectileObject); var projectileObjectVisualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/ObjectTypeEditors/ProjectileObjectDrawer.uxml"); ve = projectileObjectVisualTree.CloneTree(); ve.style.height = 500; ve.style.alignContent = Align.Center; ve.style.paddingTop = 50; ObjectField ProjectileObjectSpriteSelection = ve.Q <ObjectField>("ProjectileSpriteObjectSelectionField"); ProjectileObjectSpriteSelection.objectType = typeof(SpriteObject); FloatField ProjectileSpeedField = ve.Q <FloatField>("ProjectileSpeedField"); ObjectField ProjectileObjectColliderSelection = ve.Q <ObjectField>("ProjectileColliderObjectSelectionField"); ProjectileObjectColliderSelection.objectType = typeof(CircleColliderObject); objectEditSelectionContainer.Add(ve); break; #endregion case "PlayerObject": #region objectSelectionField.objectType = typeof(PlayerObject); var playerObjectVisualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/ObjectTypeEditors/PlayerDrawer.uxml"); ve = playerObjectVisualTree.CloneTree(); ve.style.height = 500; ve.style.alignContent = Align.Center; ve.style.paddingTop = 50; ObjectField PlayerObjectSpriteSelection = ve.Q <ObjectField>("PlayerSpriteObjectSelectionField"); PlayerObjectSpriteSelection.objectType = typeof(SpriteObject); FloatField PlayerHealthField = ve.Q <FloatField>("PlayerObjectHealthField"); FloatField PlayerAttackField = ve.Q <FloatField>("PlayerObjectAttackField"); FloatField PlayerSpeedField = ve.Q <FloatField>("PlayerObjectSpeedField"); ObjectField PlayerObjectProjectileSelection = ve.Q <ObjectField>("PlayerProjectileObjectSelectionField"); PlayerObjectProjectileSelection.objectType = typeof(ProjectileObject); ObjectField PlayerObjectColliderSelection = ve.Q <ObjectField>("PlayerColliderObjectSelectionField"); PlayerObjectColliderSelection.objectType = typeof(CircleColliderObject); objectEditSelectionContainer.Add(ve); break; #endregion } }
private void CreateGameWindow(HLE.Switch device) { device.Hid.InitializePrimaryController(ConfigurationState.Instance.Hid.ControllerType); _gLWidget?.Exit(); _gLWidget?.Dispose(); _gLWidget = new GLRenderer(_emulationContext); Application.Invoke(delegate { _viewBox.Remove(_gameTableWindow); _gLWidget.Expand = true; _viewBox.Child = _gLWidget; _gLWidget.ShowAll(); _listStatusBox.Hide(); }); _gLWidget.WaitEvent.WaitOne(); _gLWidget.Start(); Application.Invoke(delegate { _viewBox.Remove(_gLWidget); _gLWidget.Exit(); if (_gLWidget.Window != this.Window && _gLWidget.Window != null) { _gLWidget.Window.Dispose(); } _viewBox.Add(_gameTableWindow); _gameTableWindow.Expand = true; this.Window.Title = "Ryujinx"; _listStatusBox.ShowAll(); UpdateColumns(); UpdateGameTable(); Task.Run(RefreshFirmwareLabel); }); device.Dispose(); _emulationContext = null; _gameLoaded = false; _gLWidget = null; DiscordIntegrationModule.SwitchToMainMenu(); Application.Invoke(delegate { _stopEmulation.Sensitive = false; _firmwareInstallFile.Sensitive = true; _firmwareInstallDirectory.Sensitive = true; }); _screenExitStatus.Set(); }
/// <summary> /// Adds the listbox to a parent. It can only be added to a box at the current time. /// </summary> /// <param name="parent">Parent.</param> public void AddTo(Box parent) { parent.Add(Gadget); }
public override VisualElement CreatePropertyGUI(SerializedProperty property) { container = new VisualElement(); if (styleSheet is null) { styleSheet = typeof(SerializedDictionary <object, object>).GetStyleSheet($"InstanceId{nameof(SerializedDictionary<object, object>)}"); if (!(styleSheet is null)) { container.styleSheets.Add(styleSheet); } } propertyKeyField = property.FindPropertyRelative(SerializedDictionary <object, object> .KeyProperty); propertyValueField = property.FindPropertyRelative(SerializedDictionary <object, object> .ValueProperty); propertyKeyField.serializedObject.ApplyModifiedProperties(); propertyValueField.serializedObject.ApplyModifiedProperties(); var serializedDictionaryFoldout = new Foldout { text = property.displayName, value = false }; serializedDictionaryFoldout.NameAsUSS(nameof(serializedDictionaryFoldout)); var box = new Box(); var scroller = new ScrollView { name = "serialDictScroller" }; for (int i = 0; i < propertyKeyField.arraySize; i++) { var keyTypeString = propertyKeyField.GetArrayElementAtIndex(i).type; var keyType = propertyKeyField.GetArrayElementAtIndex(i).GetType(); var valueTypeString = propertyValueField.GetArrayElementAtIndex(i).type; var valueType = propertyValueField.GetArrayElementAtIndex(i).GetType(); // ----------------------------------------------------------- Dictionary Container // -- Dictionary Container -------------------------------------------------------- var layerEntry = new VisualElement { focusable = true, name = $"Entry: {i}" }; layerEntry.AddToClassList("serialDictionaryContainer"); // ----------------------------------------------------------------- Dictionary Key // -- Dictionary Key -------------------------------------------------------------- VisualElement listKey; listKey = new PropertyField(propertyKeyField.GetArrayElementAtIndex(i)) { name = "keyTextField" }; var keyTextField = new TextField { bindingPath = propertyKeyField.propertyPath, label = null, name = "keyTextField" }; keyTextField.tooltip = keyTextField.text; switch (valueTypeString) { case { } a when a.Contains("GuidReference"): case { } b when b.Contains("GuidComponent"): keyTextField.AddToClassList("serialDictionaryKeyGuid"); keyTextField.AddToClassList("unity-base-field--no-label"); break; default: keyTextField.AddToClassList("serialDictionaryKey"); keyTextField.AddToClassList("unity-base-field--no-label"); break; } keyTextField.SetValueWithoutNotify(propertyKeyField.GetArrayElementAtIndex(i).stringValue); keyTextField.SetEnabled(false); // keyTextField.Q(null, "unity-base-text-field__input").RemoveFromClassList("unity-base-text-field__input"); keyTextField.Q(null, "unity-disabled") .RemoveFromClassList("unity-disabled"); keyTextField.AddToClassList("serialDictionaryKeyLocator"); keyTextField.SetEnabled(false); listKey = keyTextField; layerEntry.Add(listKey); // --------------------------------------------------------------- Dictionary Value // -- Dictionary Value ------------------------------------------------------------ VisualElement listValue; listValue = new PropertyField(propertyValueField.GetArrayElementAtIndex(i)) { name = "valueObjectField" }; listValue.SetEnabled(true); switch (valueType) { case { } a when objectTypes.Contains(a.Name): case { } t1 when t1 == typeof(Object): case { } t2 when typeof(Object).IsSubclassOf(t2): case { } t3 when typeof(Object).IsAssignableFrom(t3): case { } t4 when Convert.GetTypeCode(t4) == TypeCode.Object: case { } t5 when typeof(Object).IsSubclassOf(t5): case { } t6 when typeof(Object).IsAssignableFrom(t6): var objectField = new ObjectField { bindingPath = propertyValueField.propertyPath, label = null, name = "valueObjectField" }; objectField.SetValueWithoutNotify(propertyValueField.GetArrayElementAtIndex(i).objectReferenceValue); objectField.AddToClassList("serialDictionaryValue"); objectField.AddToClassList("unity-base-field--no-label"); objectField.Q(null, "unity-object-field__selector") .RemoveFromClassList("unity-object-field__selector"); // objectField.Q(null, "unity-object-field__input").RemoveFromClassList("unity-object-field__input"); listValue = objectField; break; case { } b when guidTypes.Contains(b.Name): var guidObjectField = new ObjectField { bindingPath = propertyValueField.propertyPath, label = null, name = "valueObjectField" }; guidObjectField.SetValueWithoutNotify(propertyValueField.GetArrayElementAtIndex(i).objectReferenceValue); guidObjectField.AddToClassList("serialDictionaryGuidValue"); guidObjectField.AddToClassList("unity-base-field--no-label"); guidObjectField.Q(null, "unity-object-field__selector") .RemoveFromClassList("unity-object-field__selector"); // objectField.Q(null, "unity-object-field__input").RemoveFromClassList("unity-object-field__input"); listValue = guidObjectField; break; case { } d when d == (typeof(int)): var valueTextField = new TextField { bindingPath = propertyValueField.propertyPath, label = null }; valueTextField.SetValueWithoutNotify(propertyValueField.GetArrayElementAtIndex(i).intValue.ToString()); valueTextField.SetEnabled(false); listValue = valueTextField; listValue.AddToClassList("serialDictionaryValue"); listValue.RemoveFromClassList("unity-base-text-field__input"); break; case { } d when d == typeof(Type): var valueTypeTextField = new TextField { bindingPath = propertyValueField.propertyPath, label = null }; valueTypeTextField.SetValueWithoutNotify(propertyValueField.GetArrayElementAtIndex(i).stringValue); valueTypeTextField.SetEnabled(false); listValue = valueTypeTextField; listValue.AddToClassList("serialDictionaryValue"); listValue.RemoveFromClassList("unity-base-text-field__input"); break; default: if (property.IsReallyArray()) { listValue = new PropertyField(propertyValueField); } listValue.AddToClassList("serialDictionaryValue"); listValue.AddToClassList("unity-base-field--no-label"); break; } listValue.AddToClassList("serialDictionaryValueLocator"); layerEntry.Add(listValue); scroller.Add(layerEntry); } box.Add(scroller); serializedDictionaryFoldout.Add(box); container.Add(serializedDictionaryFoldout); return(container); }
public ToDoListItem(ListBox lb, ToDoItem item) { var box = new Box(Orientation.Horizontal, 0); tdItem = item; var label = new Label(item.name); label.Halign = Align.Start; box.PackStart(label, true, true, 0); deleteBtn = new Button(new Label("Delete")); deleteBtn.StyleContext.AddClass("danger"); var doneLabel = new Label(); var completeBtn = new Button(new Label("Complete")); completeBtn.Clicked += delegate { item.done = true; item.doneOn = DateTime.Now; if (item.done && item.doneOn.Value.Day != DateTime.Now.Day && item.days.IndexOf(DateTime.Now.DayOfWeek) != -1) { item.done = false; Util.SaveToDos(); } completeBtn.Hide(); if ((item.done && item.doneOn.Value.Day == DateTime.Now.Day) && item.days.IndexOf(DateTime.Now.DayOfWeek) != -1) { doneLabel.StyleContext.AddClass("done-label"); doneLabel.Text = "Done"; doneLabel.StyleContext.RemoveClass("notdone"); doneLabel.StyleContext.AddClass("done"); } else if (item.done) { doneLabel.Text = ""; doneLabel.StyleContext.RemoveClass("done-label"); } else if (!item.done) { doneLabel.StyleContext.AddClass("done-label"); doneLabel.StyleContext.RemoveClass("done"); doneLabel.StyleContext.AddClass("notdone"); doneLabel.Text = "Not done"; completeBtn.Show(); } }; box.PackStart(doneLabel, false, false, 3); foreach (var day in item.days) { var lbl = new Label(day.ToString()); lbl.StyleContext.AddClass("day"); if (DateTime.Now.DayOfWeek == day) { // Do it now! lbl.StyleContext.AddClass("doitnow"); } box.Add(lbl); } if (item.days.Count != 0) { box.Add(completeBtn); } box.Add(deleteBtn); Add(box); ShowAll(); completeBtn.Hide(); if (item.done && item.doneOn.Value.Day != DateTime.Now.Day && item.days.IndexOf(DateTime.Now.DayOfWeek) != -1) { item.done = false; Util.SaveToDos(); } if ((item.done && item.doneOn.Value.Day == DateTime.Now.Day) && item.days.IndexOf(DateTime.Now.DayOfWeek) != -1) { doneLabel.StyleContext.AddClass("done-label"); doneLabel.Text = "Done"; doneLabel.StyleContext.RemoveClass("notdone"); doneLabel.StyleContext.AddClass("done"); } else if (item.done) { doneLabel.Text = ""; doneLabel.StyleContext.RemoveClass("done-label"); } else if (!item.done) { doneLabel.StyleContext.AddClass("done-label"); doneLabel.StyleContext.RemoveClass("done"); doneLabel.StyleContext.AddClass("notdone"); doneLabel.Text = "Not done"; completeBtn.Show(); } }
private void CreateGameWindow(HLE.Switch device) { device.Hid.Npads.AddControllers(ConfigurationState.Instance.Hid.InputConfig.Value.Select(inputConfig => new HLE.HOS.Services.Hid.ControllerConfig { Player = (PlayerIndex)inputConfig.PlayerIndex, Type = (ControllerType)inputConfig.ControllerType } ).ToArray()); _glWidget = new GlRenderer(_emulationContext, ConfigurationState.Instance.Logger.GraphicsDebugLevel); Application.Invoke(delegate { _viewBox.Remove(_gameTableWindow); _glWidget.Expand = true; _viewBox.Child = _glWidget; _glWidget.ShowAll(); EditFooterForGameRender(); if (this.Window.State.HasFlag(Gdk.WindowState.Fullscreen)) { ToggleExtraWidgets(false); } }); _glWidget.WaitEvent.WaitOne(); _glWidget.Start(); Ptc.Close(); PtcProfiler.Stop(); device.Dispose(); _deviceExitStatus.Set(); // NOTE: Everything that is here will not be executed when you close the UI. Application.Invoke(delegate { if (this.Window.State.HasFlag(Gdk.WindowState.Fullscreen)) { ToggleExtraWidgets(true); } _viewBox.Remove(_glWidget); _glWidget.Exit(); if (_glWidget.Window != this.Window && _glWidget.Window != null) { _glWidget.Window.Dispose(); } _glWidget.Dispose(); _viewBox.Add(_gameTableWindow); _gameTableWindow.Expand = true; this.Window.Title = $"Ryujinx {Program.Version}"; _emulationContext = null; _gameLoaded = false; _glWidget = null; DiscordIntegrationModule.SwitchToMainMenu(); RecreateFooterForMenu(); UpdateColumns(); UpdateGameTable(); Task.Run(RefreshFirmwareLabel); _stopEmulation.Sensitive = false; _firmwareInstallFile.Sensitive = true; _firmwareInstallDirectory.Sensitive = true; }); }
public ItemDisplay(Builder builder, ToDoItem item) : base(builder.GetObject("ItemDisplay").Handle) { this.item = item; builder.Autoconnect(this); toDoName.Text = item.name; description.Buffer.Text = item.description; completeBtn.Hide(); if (item.done && item.doneOn.Value.Day != DateTime.Now.Day && item.days.IndexOf(DateTime.Now.DayOfWeek) != -1) { item.done = false; Util.SaveToDos(); } if ((item.done && item.doneOn.Value.Day == DateTime.Now.Day) && item.days.IndexOf(DateTime.Now.DayOfWeek) != -1) { doneLabel.StyleContext.AddClass("done-label"); doneLabel.Text = "Done"; doneLabel.StyleContext.RemoveClass("notdone"); doneLabel.StyleContext.AddClass("done"); } else if (!item.done) { doneLabel.StyleContext.AddClass("done-label"); doneLabel.StyleContext.RemoveClass("done"); doneLabel.StyleContext.AddClass("notdone"); doneLabel.Text = "Not done"; completeBtn.Show(); } foreach (var day in item.days) { var lbl = new Label(day.ToString()); lbl.StyleContext.AddClass("day"); if (DateTime.Now.DayOfWeek == day) { // Do it now! lbl.StyleContext.AddClass("doitnow"); } daysBox.Add(lbl); } daysBox.ShowAll(); Util.RefreshList(subtasks, ToDoList.fromArray(item.subtasks), subtaskRemoved); subtasks.ShowAll(); if (item.days.Count == 0) { completeBtn.Hide(); } addSubtaskBtn.Clicked += delegate { var res = Util.AddTask(); if (res == null) { return; // Cancelled } if (res.inheritDays) { res.days = item.days; } item.subtasks.Add(new ToDoItem { name = res.dlg.name.Text, description = res.dlg.desc.Buffer.Text, days = res.days }); Util.SaveToDos(); Util.RefreshList(subtasks, ToDoList.fromArray(item.subtasks), subtaskRemoved); }; subtasks.ListRowActivated += (o, args) => { var row = (ToDoListItem)args.Row; ToDoListItem.ShowDetails(this, row); }; saveDetailsBtn.Clicked += delegate { item.description = description.Buffer.Text; Util.SaveToDos(); }; completeBtn.Clicked += delegate { item.done = true; item.doneOn = DateTime.Now; if (item.done && item.doneOn.Value.Day != DateTime.Now.Day && item.days.IndexOf(DateTime.Now.DayOfWeek) != -1) { item.done = false; Util.SaveToDos(); completeBtn.Hide(); } if ((item.done && item.doneOn.Value.Day == DateTime.Now.Day) && item.days.IndexOf(DateTime.Now.DayOfWeek) != -1) { doneLabel.StyleContext.AddClass("done-label"); doneLabel.Text = "Done"; doneLabel.StyleContext.RemoveClass("notdone"); doneLabel.StyleContext.AddClass("done"); } else if (item.done) { doneLabel.Text = ""; doneLabel.StyleContext.RemoveClass("done-label"); } else if (!item.done) { doneLabel.StyleContext.AddClass("done-label"); doneLabel.StyleContext.RemoveClass("done"); doneLabel.StyleContext.AddClass("notdone"); doneLabel.Text = "Not done"; completeBtn.Show(); } }; refreshSubtasksBtn.Clicked += delegate { Util.RefreshList(subtasks, ToDoList.fromArray(item.subtasks), subtaskRemoved); }; }
public MainWindow() : base(WindowType.Toplevel) { GardenData.LoadedData = GardenData.LoadedData = new GardenData("new project"); Title = "Garden project '" + GardenData.LoadedData.Name + "'"; //GardenData.LoadedData = GardenPlanner.MainClass.TestData(); PlantSideVPaned.Add1(FamilyPlantVarietySelector); PlantAreaInfoVPaned.Add1(PlantBox); PlantAreaInfoVPaned.Add2(AreaInfo); PlantSideVPaned.Add2(PlantAreaInfoVPaned); TopPanedToolboxVPaned.Add1(GraphicsSidebarHPaned); TopPanedToolboxVPaned.Add2(ToolBox); Frame frame; PlantBox.Add(PlantAddButton); PlantBox.Add(PlantInfoButton); PlantBox.Add(PlantEditButton); ToolBox.Add(AreaNewButton); ToolBox.Add(AreaCancelButton); ToolBox.Add(AreaTypeComboBox); ToolBox.Add(AreaEditButton); ToolBox.Add(AreaDeleteButton); frame = new Frame("Zoom"); frame.Add(ZoomButton); ToolBox.Add(frame); frame = new Frame("Date"); VButtonBox buttonBox = new VButtonBox(); //yearButton = new SpinButton(GardenData.GetFirstYear(), GardenData.GetLastYear(), 1); yearButton = new SpinButton(settings.MinYear, settings.MaxYear, 1); buttonBox.Add(yearButton); buttonBox.Add(monthButton); frame.Add(buttonBox); ToolBox.Add(frame); foreach (Widget w in TopVBox.Children) { TopVBox.Remove(w); } TopVBox.Add(MenuBar); TopVBox.Add(TopPanedToolboxVPaned); if (this.Child == null) { this.Add(TopVBox); } ResetForNewData(); FamilyPlantVarietySelector.SetSizeRequest(100, 400); AreaInfo.WrapMode = WrapMode.Word; AreaInfo.Editable = false; PlantAddButton.Sensitive = false; PlantAddButton.Clicked += (sender, e) => { GardenDrawingArea area = GardenDrawingArea.ActiveInstance; if (area.SelectedArea is Planting planting && SelectedEntry is PlantVariety variety) { EditPlantingInfoWindow.ShowPlantingInfoWindow((PlantingInfo plantingInfo) => { planting.AddVariety(variety, plantingInfo); GardenDrawingArea.ActiveInstance.Draw(); ShowAreaSelectionInfo(area.SelectedArea); }, planting, variety.Name); } ; }; PlantInfoButton.Clicked += (object sender, System.EventArgs e) => { if (SelectedEntry is PlantFamily family) { InfoPlantFamilyWindow.ShowWindow(family, false); } else if (SelectedEntry is Plant plant) { InfoPlantWindow.ShowWindow(plant, false); } else if (SelectedEntry is PlantVariety variety) { InfoPlantVarietyWindow.ShowWindow(variety, false); } }; PlantEditButton.Clicked += (object sender, System.EventArgs e) => { if (SelectedEntry is PlantFamily family) { EditPlantFamilyWindow.ShowWindow(family); } else if (SelectedEntry is Plant plant) { EditPlantWindow.ShowWindow(plant); } else if (SelectedEntry is PlantVariety variety) { EditPlantVarietyWindow.ShowWindow(variety); } }; ZoomButton.Value = GardenDrawingArea.Zoom; ZoomButton.Events = Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.KeyPressMask | Gdk.EventMask.KeyReleaseMask; ZoomButton.TooltipText = "Zoom"; AreaNewButton.Clicked += (object sender, System.EventArgs e) => { if (AreaCancelButtonClicked) { AreaCancelButtonClicked = false; AreaCancelButton.Sensitive = false; if (GardenDrawingArea.ActiveInstance != null) { GardenDrawingArea.ActiveInstance.UndoSelection(); GardenDrawingArea.ActiveInstance.NewPoints.Clear(); GardenDrawingArea.ActiveInstance.Draw(); } } else if (!AreaNewButton.Active)//deactivated { AreaCancelButton.Sensitive = false; if (GardenDrawingArea.ActiveInstance != null) { List <GardenPoint> points = GardenDrawingArea.ActiveInstance.NewPoints; switch (AreaTypeComboBox.Active) { case 0: //garden if (GardenDrawingArea.ActiveInstance.Garden.Shape.GetPoints().Count == 0) { GardenDrawingArea.ActiveInstance.Garden.Shape.AddPoints(points); GardenDrawingArea.ActiveInstance.Garden.Shape.FinishPoints(); GardenDrawingArea.ActiveInstance.NewPoints.Clear(); GardenDrawingArea.ActiveInstance.Draw(); } break; case 1: //planting PlantingCreationDialog.ShowPlantingCreationDialog(new List <GardenPoint>(points), (Planting planting) => { GardenDrawingArea.ActiveInstance.NewPoints.Clear(); GardenDrawingArea.ActiveInstance.Draw(); GardenDrawingArea.ActiveInstance.Garden.AddPlanting(GardenData.GenID(planting.Name), planting); }); break; case 2: //method area GardenAreaCreationDialog.ShowGardenAreaCreationDialog(new List <GardenPoint>(points), (GardenArea area) => { GardenDrawingArea.ActiveInstance.NewPoints.Clear(); GardenDrawingArea.ActiveInstance.Draw(); GardenDrawingArea.ActiveInstance.Garden.AddMethodArea(GardenData.GenID(area.Name), area); }); break; } } } else //activated { if (AreaTypeComboBox.Active == 0) //garden { if (GardenDrawingArea.ActiveInstance == null || GardenDrawingArea.ActiveInstance.Garden.Shape.GetPoints().Count > 0) { AreaNewButton.Active = false; GardenCreationDialog.ShowGardenCreationDialog(new List <GardenPoint>(), ((Garden garden) => { GardenData.LoadedData.AddGarden(GardenData.GenID(garden.Name), garden); this.ResetForNewData(); GardenBedBook.Page = GardenBedBook.NPages - 1; AreaNewButton.Active = true; })); } } AreaCancelButton.Sensitive = true; } }; AreaCancelButton.Sensitive = false; AreaCancelButton.Clicked += (object sender, System.EventArgs e) => { AreaCancelButtonClicked = true; AreaCancelButton.Sensitive = false; AreaNewButton.Active = false; }; AreaTypeComboBox.Active = 0; AreaTypeComboBox.Changed += (object sender, System.EventArgs e) => { switch (AreaTypeComboBox.Active) { case 0: AreaNewButton.Label = "New Garden"; break; case 1: AreaNewButton.Label = "New Planting"; break; case 2: AreaNewButton.Label = "New Method Area"; break; } }; AreaEditButton.Clicked += (object sender, System.EventArgs e) => { GardenDrawingArea gardenDrawingArea = GardenDrawingArea.ActiveInstance; if (gardenDrawingArea == null || gardenDrawingArea.Garden == null || gardenDrawingArea.SelectedArea == null) { return; } if (gardenDrawingArea.SelectedArea is Planting planting) { PlantingCreationDialog.ShowPlantingEditDialog(planting); } else if (gardenDrawingArea.SelectedArea is Garden) { GardenAreaCreationDialog.ShowGardenAreaEditDialog(gardenDrawingArea.SelectedArea); } else { GardenAreaCreationDialog.ShowGardenAreaEditDialog(gardenDrawingArea.SelectedArea); } }; AreaDeleteButton.Clicked += (object sender, System.EventArgs e) => { GardenDrawingArea gardenDrawingArea = GardenDrawingArea.ActiveInstance; if (gardenDrawingArea == null || gardenDrawingArea.Garden == null) { return; } string name = gardenDrawingArea.SelectedArea != null ? gardenDrawingArea.SelectedArea.Name : gardenDrawingArea.Garden.Name; Dialog dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.OkCancel, "Do you want to delete '" + name + "'?", new { }); int response = dialog.Run(); //System.Console.WriteLine("response " + result); if (response == (int)ResponseType.Cancel) { } else if (response == (int)ResponseType.Ok) { if (gardenDrawingArea.Garden != null && (gardenDrawingArea.SelectedArea == null || gardenDrawingArea.SelectedArea is Garden)) { var garden = gardenDrawingArea.Garden; GardenData.LoadedData.Gardens.Remove(garden.ID); GardenBedBook.Remove(GardenBedBook.GetNthPage(GardenBedBook.CurrentPage)); //System.Console.WriteLine("delete garden"); GardenDrawingArea.ActiveInstance = null; gardenDrawingArea.UndoSelection(); SelectGardenEntry(null); if (GardenBedBook.Page >= 0 && GardenBedBook.GetNthPage(GardenBedBook.Page) is GardenDrawingArea drawingArea) { GardenDrawingArea.ActiveInstance = drawingArea; drawingArea.Draw(); } GardenData.unsaved = true; } else if (gardenDrawingArea.SelectedArea is Planting planting) { gardenDrawingArea.Garden.RemovePlanting(planting); gardenDrawingArea.UndoSelection(); SelectGardenEntry(null); gardenDrawingArea.Draw(); GardenData.unsaved = true; } else if (gardenDrawingArea.SelectedArea is GardenArea area) { gardenDrawingArea.Garden.RemoveMethodArea(area); gardenDrawingArea.UndoSelection(); SelectGardenEntry(null); gardenDrawingArea.Draw(); GardenData.unsaved = true; } } dialog.Destroy(); }; int yearValue = yearButton.ValueAsInt; yearButton.ValueChanged += (sender, e) => { if (yearButton.ValueAsInt > yearValue) { monthButton.Value = 1; } else { monthButton.Value = 12; } yearValue = yearButton.ValueAsInt; DateChanged(); }; monthButton.Changed += (sender, e) => { DateChanged(); }; void DateChanged() { GardenDrawingArea gardenDrawingArea = GardenDrawingArea.ActiveInstance; if (gardenDrawingArea == null) { return; } if (gardenDrawingArea.SelectedArea != null && (!gardenDrawingArea.SelectedArea.CheckDate(GetYear(), GetMonth()) || !gardenDrawingArea.Garden.CheckDate(GetYear(), GetMonth()))) { gardenDrawingArea.UndoSelection(); } gardenDrawingArea.Draw(); ShowAreaSelectionInfo(gardenDrawingArea.SelectedArea); } //FamilyPlantVarietySelector.Add1(PopulateFamilies(GardenData.LoadedData)); //RepopulateGrowables(); //Build(); this.DeleteEvent += (object o, DeleteEventArgs args) => { TryToClose(); args.RetVal = true; }; this.Destroyed += (sender, e) => { GardenPlannerSettings.Save(); Application.Quit(); }; }
public override VisualElement CreateInspectorGUI() { _currentEditSpawnZone = -1; VisualElement customInspector = new VisualElement(); _targetSurfaceBind = new ObjectField("Target Surface"); _targetSurfaceBind.RegisterValueChangedCallback(targetSurfaceChanged); _targetSurfaceBind.objectType = typeof(GameObject); _targetSurfaceBind.bindingPath = "targetSurface"; customInspector.Add(_targetSurfaceBind); _preDataBind = new ObjectField("PreData"); _preDataBind.RegisterValueChangedCallback(preDataChanged); _preDataBind.objectType = typeof(PreDataSO); _preDataBind.bindingPath = "preData"; customInspector.Add(_preDataBind); _spawnSObind = new ObjectField("Spawn Data"); _spawnSObind.RegisterValueChangedCallback(spawnDataChanged); _spawnSObind.objectType = typeof(SpawnSO); _spawnSObind.bindingPath = "spawnData"; customInspector.Add(_spawnSObind); _spawnBox = new Box(); customInspector.Add(_spawnBox); List <string> items = new List <string>(); Func <VisualElement> makeItem = () => new Label(); Action <VisualElement, int> bindItem = (e, i) => (e as Label).text = items[i]; const int itemHeight = ITEM_HEIGHT; _spawnZoneList = new ListView(items, itemHeight, makeItem, bindItem); _spawnZoneList.selectionType = SelectionType.Single; _spawnZoneList.onSelectionChange += onItemChosenHandler; //_spawnZoneList.onSelectionChanged += objects => Debug.Log(objects); _spawnBox.Add(_spawnZoneList); Box arBtnBox = new Box(); _spawnBox.Add(arBtnBox); arBtnBox.style.flexDirection = FlexDirection.Row; arBtnBox.style.alignContent = Align.Center; _addSpawZoneBtn = new Button(addSpawnZoneClickListener); _addSpawZoneBtn.text = "Add Spawn Zone"; arBtnBox.Add(_addSpawZoneBtn); _removeSpawZoneBtn = new Button(removeSpawnZoneClickListener); _removeSpawZoneBtn.text = "Remove Current Spawn Zone"; arBtnBox.Add(_removeSpawZoneBtn); _spawnSetNameTf = new TextField("Spawn Set Name"); _spawnBox.Add(_spawnSetNameTf); Button saveBtn = new Button(saveClickListener); saveBtn.text = "Save Spawns"; _spawnBox.Add(saveBtn); SpawnCreation sc = target as SpawnCreation; _targetObject = sc.targetSurface; _preData = sc.preData; _spawnSO = sc.spawnData; checkSRCdata(); return(customInspector); }
protected void DrawChartWithSeriesInfoBox() { Steema.TeeChart.Axis axis = null; Steema.TeeChart.Styles.Box s; DataTable dt = null; List <double> lstValue; this.AnalysisChart.Chart.Series.Clear(); this.AnalysisChart.SetXAxisRegularInterval(true); for (int i = 0; i < _llstSortingKey.Count; i++) { string strSortingValue = _llstSortingKey.GetKey(i).ToString(); string strSortingKey = _llstSortingKey.GetValue(i).ToString(); Color c = GetSeriesColor(i); s = new Box(); s.Color = c; s.Title = strSortingValue; s.XValues.Name = strSortingValue; this.AnalysisChart.Chart.Series.Add(s); lstValue = new List <double>(); dt = DataUtil.DataTableImportRow(this.dtDataSource.Select(string.Format("{0} = '{1}'", strSortingKey, strSortingValue))); foreach (DataRow dr in dt.Rows) { if (string.IsNullOrEmpty(dr[Definition.CHART_COLUMN.VALUE].ToString())) { continue; } lstValue.Add((double)dr[Definition.CHART_COLUMN.VALUE]); // s.Add(i, (double)dr[Definition.CHART_COLUMN.VALUE], c); } s.Add(lstValue.ToArray()); s.ReconstructFromData(); if (i == 0) { axis = this.AnalysisChart.Chart.Axes.Bottom; axis.Horizontal = true; axis.StartPosition = 0; axis.EndPosition = 100 / _llstSortingKey.Count; axis.AxisPen.Color = c; axis.Title.Font.Color = c; axis.Title.Font.Bold = true; axis.Title.Text = strSortingValue; axis.LogarithmicBase = 2; axis.Grid.Visible = false; axis.AxisPen.Visible = false; } else { axis = new Axis(true, false, this.AnalysisChart.Chart.Chart); this.AnalysisChart.Chart.Axes.Custom.Add(axis); s.CustomHorizAxis = axis; axis.StartPosition = 100 / _llstSortingKey.Count * i; axis.EndPosition = 100 / _llstSortingKey.Count * (i + 1); axis.AxisPen.Color = c; axis.Title.Font.Color = c; axis.Title.Font.Bold = true; axis.Title.Text = strSortingValue; axis.LogarithmicBase = 2; axis.Grid.Visible = false; axis.AxisPen.Visible = false; } axis.Labels.Angle = 90; axis.Title.Angle = 90; } this.AnalysisChart.Chart.Axes.Bottom.Labels.Angle = 90; this.AnalysisChart.Chart.Axes.Left.MinorTickCount = 0; //this.AnalysisChart.Chart.Axes.Left.MinAxisIncrement = .25; //this.AnalysisChart.Chart.Axes.Left.SetMinMax(0,5); }
private SequenceNode CreateNodeFrom(SerializedProperty property, string overrideName = "", bool hasInput = true) { var copy = property.Copy(); copy.Next(true); var rect = copy.rectValue; var name = overrideName; if (overrideName == string.Empty) { name = property.managedReferenceFullTypename.Split(' ').Last(); if (name.Contains('.')) { name = name.Split('.').Last(); } } var node = new SequenceNode() { title = name }; node.styleSheets.Add(Resources.Load <StyleSheet>("Node")); if (hasInput) { var inPort = node.InstantiatePort(Orientation.Horizontal, Direction.Input, Port.Capacity.Multi, typeof(float)); inPort.portName = "In"; node.inputContainer.Add(inPort); } var outPort = node.InstantiatePort(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi, typeof(float)); outPort.portName = "Out"; node.outputContainer.Add(outPort); node.RefreshExpandedState(); node.RefreshPorts(); var box = new Box(); var shouldAddPropertyBox = false; box.styleSheets.Add(Resources.Load <StyleSheet>("Box")); var propertyName = property.GetName(); var propertyStyle = Resources.Load <StyleSheet>("Label"); while (copy.NextVisible(false)) { var parentName = copy.GetParentName(); if (propertyName != parentName) { break; } var propertyField = new PropertyField(copy); propertyField.styleSheets.Add(propertyStyle); propertyField.Bind(property.serializedObject); box.Add(propertyField); shouldAddPropertyBox = true; } if (shouldAddPropertyBox) { node.mainContainer.Add(box); } node.SetPosition(rect); return(node); }
private void CreateGameWindow() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { _windowsMultimediaTimerResolution = new WindowsMultimediaTimerResolution(1); } GlRendererWidget = new GlRenderer(_emulationContext, ConfigurationState.Instance.Logger.GraphicsDebugLevel); Application.Invoke(delegate { _viewBox.Remove(_gameTableWindow); GlRendererWidget.Expand = true; _viewBox.Child = GlRendererWidget; GlRendererWidget.ShowAll(); EditFooterForGameRenderer(); if (Window.State.HasFlag(Gdk.WindowState.Fullscreen)) { ToggleExtraWidgets(false); } else if (ConfigurationState.Instance.Ui.StartFullscreen.Value) { FullScreen_Toggled(null, null); } }); GlRendererWidget.WaitEvent.WaitOne(); GlRendererWidget.Start(); Ptc.Close(); PtcProfiler.Stop(); _emulationContext.Dispose(); _deviceExitStatus.Set(); // NOTE: Everything that is here will not be executed when you close the UI. Application.Invoke(delegate { if (Window.State.HasFlag(Gdk.WindowState.Fullscreen)) { ToggleExtraWidgets(true); } _viewBox.Remove(GlRendererWidget); GlRendererWidget.Exit(); if (GlRendererWidget.Window != Window && GlRendererWidget.Window != null) { GlRendererWidget.Window.Dispose(); } GlRendererWidget.Dispose(); _windowsMultimediaTimerResolution?.Dispose(); _windowsMultimediaTimerResolution = null; _viewBox.Add(_gameTableWindow); _gameTableWindow.Expand = true; Window.Title = $"Ryujinx {Program.Version}"; _emulationContext = null; _gameLoaded = false; GlRendererWidget = null; DiscordIntegrationModule.SwitchToMainMenu(); RecreateFooterForMenu(); UpdateColumns(); UpdateGameTable(); Task.Run(RefreshFirmwareLabel); Task.Run(HandleRelaunch); _stopEmulation.Sensitive = false; _simulateWakeUpMessage.Sensitive = false; _firmwareInstallFile.Sensitive = true; _firmwareInstallDirectory.Sensitive = true; }); }
private void CreateButtons(string category_name, Gtk.Action[] actions, Box box) { foreach (var action in actions) { box.Add (new CommandMapButton (category_name, action)); } }
public void OnEnable() { var root = this.rootVisualElement; root.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/Examples/Editor/todolist.uss")); var toolbar = new Toolbar(); root.Add(toolbar); var btn1 = new ToolbarButton { text = "Button" }; toolbar.Add(btn1); var spc = new ToolbarSpacer(); toolbar.Add(spc); var tgl = new ToolbarToggle { text = "Toggle" }; toolbar.Add(tgl); var spc2 = new ToolbarSpacer() { name = "flexSpacer1", flex = true }; toolbar.Add(spc2); var menu = new ToolbarMenu { text = "Menu" }; menu.menu.AppendAction("Default is never shown", a => {}, a => DropdownMenuAction.Status.None); menu.menu.AppendAction("Normal menu", a => {}, a => DropdownMenuAction.Status.Normal); menu.menu.AppendAction("Hidden is never shown", a => {}, a => DropdownMenuAction.Status.Hidden); menu.menu.AppendAction("Checked menu", a => {}, a => DropdownMenuAction.Status.Checked); menu.menu.AppendAction("Disabled menu", a => {}, a => DropdownMenuAction.Status.Disabled); menu.menu.AppendAction("Disabled and checked menu", a => {}, a => DropdownMenuAction.Status.Disabled | DropdownMenuAction.Status.Checked); toolbar.Add(menu); var spc3 = new ToolbarSpacer() { name = "flexSpacer2", flex = true }; toolbar.Add(spc3); var popup = new ToolbarMenu { text = "Popup", variant = ToolbarMenu.Variant.Popup }; popup.menu.AppendAction("Popup", a => {}, a => DropdownMenuAction.Status.Normal); toolbar.Add(popup); var popupSearchField = new ToolbarPopupSearchField(); popupSearchField.RegisterValueChangedCallback(OnSearchTextChanged); popupSearchField.menu.AppendAction( "Popup Search Field", a => m_popupSearchFieldOn = !m_popupSearchFieldOn, a => m_popupSearchFieldOn ? DropdownMenuAction.Status.Checked : DropdownMenuAction.Status.Normal); toolbar.Add(popupSearchField); var searchField = new ToolbarSearchField(); searchField.RegisterValueChangedCallback(OnSearchTextChanged); toolbar.Add(searchField); var popupWindow = new PopupWindow(); popupWindow.text = "New Task"; root.Add(popupWindow); m_TextInput = new TextField() { name = "input", viewDataKey = "input", isDelayed = true }; popupWindow.Add(m_TextInput); m_TextInput.RegisterCallback <ChangeEvent <string> >(AddTask); var button = new Button(AddTask) { text = "Save task" }; popupWindow.Add(button); var box = new Box(); m_TasksContainer = new ScrollView(); m_TasksContainer.showHorizontal = false; box.Add(m_TasksContainer); root.Add(box); if (m_Tasks != null) { foreach (string task in m_Tasks) { m_TasksContainer.Add(CreateTask(task)); } } }
public EditPopover(Widget relative_to) : base(relative_to) { var vbox = new Box(Orientation.Vertical, 6); vbox.Margin = 6; // Justify Bar var justifyGrid = new Grid(); justifyGrid.Orientation = Orientation.Horizontal; justifyGrid.StyleContext.AddClass("linked"); // justifyGrid.Margin = 6; var JustifytLeftButton = new Button(); JustifytLeftButton.Image = Image.NewFromIconName("format-justify-left", IconSize.LargeToolbar); var JustifyRightButton = new Button(); JustifyRightButton.Image = Image.NewFromIconName("format-justify-right", IconSize.LargeToolbar); var JustifyCenterButton = new Button(); JustifyCenterButton.Image = Image.NewFromIconName("format-justify-center", IconSize.LargeToolbar); var JustifyFillButton = new Button(); JustifyFillButton.Image = Image.NewFromIconName("format-justify-fill", IconSize.LargeToolbar); justifyGrid.Attach(JustifytLeftButton, 0, 0, 1, 1); justifyGrid.Attach(JustifyCenterButton, 1, 0, 1, 1); justifyGrid.Attach(JustifyRightButton, 2, 0, 1, 1); justifyGrid.Attach(JustifyFillButton, 3, 0, 1, 1); // Format Bar var formatGrid = new Grid(); formatGrid.Orientation = Orientation.Horizontal; formatGrid.StyleContext.AddClass("linked"); // formatGrid.Margin = 6; var BoldButton = new Button(); BoldButton.Image = Image.NewFromIconName("format-text-bold", IconSize.LargeToolbar); var ItalicButton = new Button(); ItalicButton.Image = Image.NewFromIconName("format-text-italic", IconSize.LargeToolbar); var UnderlineButton = new Button(); UnderlineButton.Image = Image.NewFromIconName("format-text-underline", IconSize.LargeToolbar); var StrikeButton = new Button(); StrikeButton.Image = Image.NewFromIconName("format-text-strikethrough", IconSize.LargeToolbar); formatGrid.Attach(BoldButton, 0, 0, 1, 1); formatGrid.Attach(ItalicButton, 1, 0, 1, 1); formatGrid.Attach(UnderlineButton, 2, 0, 1, 1); formatGrid.Attach(StrikeButton, 3, 0, 1, 1); // Compose Popover grid vbox.Add(justifyGrid); vbox.Add(formatGrid); vbox.ShowAll(); Add(vbox); }
private void CellularAutomataSwitch() { RemoveChildsFromMapSpecificParent(); Slider iterations = new Slider(1, 64); Slider tilesNumber = new Slider(2, 10); ObjectField dataScriptable = new ObjectField(); iterations.value = 2; tilesNumber.value = 2; dataScriptable.objectType = typeof(CellularConfigurationObject); dataScriptable.allowSceneObjects = false; iterations.label = "Iterations(2)"; tilesNumber.label = "Number of tiles (2)"; dataScriptable.label = "Cellular Data"; iterations.RegisterValueChangedCallback((t) => { cellularIterations = (int)t.newValue; iterations.label = "Iterations(" + cellularIterations + ")"; }); tilesNumber.RegisterValueChangedCallback((t) => { this.tilesNumber = (int)t.newValue; tilesNumber.label = "Number of tiles (" + this.tilesNumber + ")"; }); dataScriptable.RegisterValueChangedCallback((t) => { this.cellularConfiguration = (CellularConfigurationObject)t.newValue; }); parentMapSpecificData.Add(iterations); parentMapSpecificData.Add(tilesNumber); parentMapSpecificData.Add(dataScriptable); }
public ResponseCurveEditor(UtilityAIConsiderationEditor utilityAIConsiderationEditor, ResponseCurve responseCurve) { this.utilityAIConsiderationEditor = utilityAIConsiderationEditor; this.responseCurve = responseCurve; VisualTreeAsset visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/UtilityAI/Scripts/Editor/Response Curve Editor/ResponseCurveEditor.uxml"); visualTree.CloneTree(this); StyleSheet stylesheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/UtilityAI/Scripts/Editor/Response Curve Editor/ResponseCurveEditor.uss"); this.styleSheets.Add(stylesheet); this.AddToClassList("responseCurveEditor"); EnumField curveTypeField = this.Query <EnumField>("curveType").First(); curveTypeField.Init(CurveType.Linear); curveTypeField.value = responseCurve.curveType; curveTypeField.RegisterCallback <ChangeEvent <Enum> >( e => { responseCurve.curveType = (CurveType)e.newValue; utilityAIConsiderationEditor.UpdateResponseCurve(); } ); FloatField xShiftField = this.Query <FloatField>("xShift").First(); xShiftField.value = responseCurve.xShift; xShiftField.RegisterCallback <ChangeEvent <float> >( e => { responseCurve.xShift = (float)e.newValue; utilityAIConsiderationEditor.UpdateResponseCurve(); } ); FloatField yShiftField = this.Query <FloatField>("yShift").First(); yShiftField.value = responseCurve.yShift; yShiftField.RegisterCallback <ChangeEvent <float> >( e => { responseCurve.yShift = (float)e.newValue; utilityAIConsiderationEditor.UpdateResponseCurve(); } ); FloatField slopeField = this.Query <FloatField>("slope").First(); slopeField.value = responseCurve.slope; slopeField.RegisterCallback <ChangeEvent <float> >( e => { responseCurve.slope = (float)e.newValue; utilityAIConsiderationEditor.UpdateResponseCurve(); } ); FloatField exponentialField = this.Query <FloatField>("exponential").First(); exponentialField.value = responseCurve.exponential; exponentialField.RegisterCallback <ChangeEvent <float> >( e => { responseCurve.exponential = (float)e.newValue; utilityAIConsiderationEditor.UpdateResponseCurve(); } ); Box box = new Box() { style = { flexGrow = 1, marginTop = 5, marginBottom = 5, marginLeft = 5, marginRight = 5, height = 300, } }; this.Add(box); VisualElement meshContainer = new VisualElement() { style = { flexGrow = 1, } }; box.Add(meshContainer); meshContainer.generateVisualContent += DrawGraph; }
void BuildUI() { bool show_toolbar; Builder builder = new Builder("gbrainy.ui"); builder.Autoconnect(this); show_toolbar = Preferences.Get <bool> (Preferences.ToolbarShowKey) == true; // Toolbar creation toolbar = new Widgets.Toolbar(main_hbox, framework_vbox); toolbar.Attach((Gtk.Orientation)Preferences.Get <int> (Preferences.ToolbarOrientationKey)); toolbar.AllButton.Clicked += OnAllGames; toolbar.LogicButton.Clicked += OnLogicOnly; toolbar.CalculationButton.Clicked += OnMathOnly; toolbar.MemoryButton.Clicked += OnMemoryOnly; toolbar.VerbalButton.Clicked += OnVerbalOnly; toolbar.PauseButton.Clicked += OnPauseGame; toolbar.FinishButton.Clicked += OnEndGame; drawing_area = new GameDrawingArea(); drawing_area.Drawable = session; drawing_area.Vexpand = true; drawing_area.SetSizeRequest(drawing_vbox.WidthRequest, drawing_vbox.HeightRequest); GameSensitiveUI(); EventBox eb = new EventBox(); // Provides a window for drawing area windowless widget eb.Events = Gdk.EventMask.PointerMotionMask; drawing_vbox.Add(eb); eb.Add(drawing_area); eb.MotionNotifyEvent += OnMouseMotionEvent; eb.ButtonPressEvent += OnHandleButtonPress; show_toolbar = Preferences.Get <bool> (Preferences.ToolbarShowKey) == true; // We only disable the Arrow if we are going to show the toolbar. // It has an impact on the total window width size even if we do not show it if (show_toolbar) { toolbar.ShowArrow = false; } app_window.IconName = "gbrainy"; app_window.ShowAll(); toolbar_orientation_menuitem.Sensitive = toolbar.Visible; // Check default radio button switch (toolbar.Orientation) { case Gtk.Orientation.Vertical: vertical_radiomenuitem.Active = true; break; case Gtk.Orientation.Horizontal: horizontal_radiomenuitem.Active = true; break; default: throw new InvalidOperationException(); } // The toolbar by default is enabled. By setting this menu entry to false // triggers the OnActivateToolbar event that hides the toolbar if (show_toolbar == false) { showtoolbar_menuitem.Active = false; } extensions_menuitem.Visible = false; ActiveInputControls(false); }
// // ─── LOGGING ──────────────────────────────────────────────────────────────────── // #region LOGGING private void DrawLoggingButtons(VisualElement root) { var label = new Label() { text = "Logging" }; var box = new Box(); box.style.height = StyleKeyword.Auto; box.style.overflow = Overflow.Visible; root.Add(label); root.Add(box); IntegerField loggingDepthField = new IntegerField("Logging Depth"); loggingDepthField.value = 30; box.Add(loggingDepthField); var logOverridesButton = new Button(() => { var msb = new MultilineStringBuilder("Log nested prefabs with overrides"); foreach (var item in _nestedPrefabs) { bool loggedOverride = false; foreach (var nested in item.Value) { bool hasOverrides = PrefabUtility.HasPrefabInstanceAnyOverrides(nested, false); if (hasOverrides && loggedOverride == false) { loggedOverride = true; msb.AddLine($"{item.Key.gameObject.name} has overrides at:"); } if (hasOverrides) { msb.AddLine($"---> {nested.name}"); } } loggedOverride = false; } DisplayInBox(GetTextElement(msb.ToString())); }) { text = "Log overrides" }; box.Add(logOverridesButton); var logCrossReferences = new Button(() => { var msb = new MultilineStringBuilder("Log Cross References"); LogCrossReferences(msb, loggingDepthField.value); DisplayInBox(GetTextElement(msb.ToString())); }) { text = "Log Cross References" }; box.Add(logCrossReferences); var logScriptReferencesButton = new Button(() => { var msb = new MultilineStringBuilder("Log Script References"); LogScriptReferences(msb, loggingDepthField.value); DisplayInBox(GetTextElement(msb.ToString())); }) { text = "Log Script References" }; box.Add(logScriptReferencesButton); // TODO this is dead var logUnhandledReferences = new Button(() => { var msb = new MultilineStringBuilder("Unhandled script references"); foreach (var kvp in _textFieldsByMonobehaviour) { msb.AddLine(new string[] { kvp.Key.GetType().ToString(), " from ", _customMonobehavioursByPrefab.First(slot => slot.Value.Contains(kvp.Key)).Key.ToString() }); foreach (var unhandledField in kvp.Value) { msb.AddLine($"---> {unhandledField.Name}"); } } DisplayInBox(GetTextElement(msb.ToString())); }) { text = "Unhandled script references" }; box.Add(logUnhandledReferences); }