### Initialize and Run a Game with RaylibGum Source: https://github.com/vchelaru/gum/blob/main/docs_projects/07_RaylibGum.md This example demonstrates the basic setup for initializing Gum with Raylib, updating game logic, and rendering the UI within the main game loop. Ensure Raylib-cs and Gum.raylib NuGet packages are installed. ```csharp using Raylib_cs; using Gum.Raylib; public class MyGame { public void Run() { Raylib.InitWindow(800, 600, "My Game"); GumService.Initialize(); while (!Raylib.WindowShouldClose()) { Raylib.BeginDrawing(); Raylib.ClearBackground(Color.RAYWHITE); GumService.Update(); GumService.Draw(); Raylib.EndDrawing(); } Raylib.CloseWindow(); } } ``` -------------------------------- ### Install GumCli Source: https://github.com/vchelaru/gum/blob/main/docs/ai/gumcli-for-agents.md Installs the GumCli as a .NET global tool. This is the initial setup step for using GumCli. ```bash dotnet tool install -g GumCli ``` -------------------------------- ### Run Gum Quick Setup Example Source: https://github.com/vchelaru/gum/blob/main/Runtimes/Python/gumui/README.md Execute the quick_setup_example.py script to test the Gum module. This script demonstrates basic functionality and visual output. ```bash python .\examples\quick_setup_example.py ``` -------------------------------- ### Make Linux Setup Script Executable and Run Source: https://github.com/vchelaru/gum/blob/main/docs/gum-tool/setup/README.md This command makes the Gum Linux setup script executable and then runs it. It automates the installation of WINE, Winetricks, fonts, and .NET 8. ```shellscript chmod +x ./setup_gum_linux.sh && ./setup_gum_linux.sh ``` -------------------------------- ### Install .NET Framework 8 using Winetricks Source: https://github.com/vchelaru/gum/blob/main/docs/gum-tool/setup/README.md Installs the .NET Framework 8 using winetricks. This process involves user interaction through two installer dialogs and may take several minutes. ```bash WINEPREFIX=$GUM_WINE_PREFIX_PATH winetricks dotnetdesktop8 ``` -------------------------------- ### Install Gum CLI from Source Source: https://github.com/vchelaru/gum/blob/main/docs_projects/18_Gum_Cli.md Instructions for installing the Gum CLI by building and running it directly from the source code. ```bash cd Gum_new/Tools/Gum.Cli dotnet run -- check ../../MyProject.gumx ``` -------------------------------- ### Initialize Gum UI Tree for Export Source: https://github.com/vchelaru/gum/blob/main/docs/code/layout/layout-export.md Example setup of a Gum UI tree structure before calling the export method. ```csharp // Initialize ContainerRuntime root = new ContainerRuntime(); root.Name = "Root"; root.Width = 800; root.Height = 600; root.WidthUnits = DimensionUnitType.Absolute; root.HeightUnits = DimensionUnitType.Absolute; TextRuntime title = new TextRuntime(); title.Name = "TitleLabel"; title.X = 100; title.Y = 50; title.Width = 600; title.Height = 40; title.WidthUnits = DimensionUnitType.Absolute; title.HeightUnits = DimensionUnitType.Absolute; title.Text = "Game Over"; root.AddChild(title); ContainerRuntime panel = new ContainerRuntime(); panel.Name = "ScorePanel"; panel.X = 150; panel.Y = 120; panel.Width = 500; panel.Height = 300; panel.WidthUnits = DimensionUnitType.Absolute; panel.HeightUnits = DimensionUnitType.Absolute; root.AddChild(panel); string json = root.ToLayoutJson(); ``` -------------------------------- ### Make Setup Script Executable on macOS Source: https://github.com/vchelaru/gum/blob/main/docs/gum-tool/setup/README.md Grant execute permissions to the Gum setup script before running it on macOS. ```sh chmod +x ./setup_gum_mac.sh ``` -------------------------------- ### Install Gum CLI as Local .NET Tool Source: https://github.com/vchelaru/gum/blob/main/docs_projects/18_Gum_Cli.md Steps to install the Gum CLI as a local .NET tool, including creating a tool manifest and using the CLI. ```bash # Crear manifiesto dotnet new tool-manifest # Instalar local dotnet tool install Gum.Cli # Usar dotnet gumcli check MyProject.gumx ``` -------------------------------- ### Initialize PyGame environment Source: https://github.com/vchelaru/gum/blob/main/Runtimes/Python/gumui/README_PACKAGED.md Standard PyGame setup including screen dimensions and display initialization. ```python pygame.init() BLACK = (0, 0, 0) SCREEN_WIDTH = 680 SCREEN_HEIGHT = 480 screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) ``` -------------------------------- ### Example: Basic reference check Source: https://github.com/vchelaru/gum/blob/main/docs/cli/check-references.md Run a standard check for unpropagated references in a project. ```bash gumcli check-references MyProject/MyProject.gumx ``` -------------------------------- ### Install Gum Module Locally Source: https://github.com/vchelaru/gum/blob/main/Runtimes/Python/gumui/README.md Install the Gum module directly from the local distribution file. Use --force-reinstall to ensure the latest version is used, overriding any existing installation. ```bash pip install --force-reinstall dist/gumui-0.1.0-py3-none-any.whl ``` -------------------------------- ### Install Gum Theme Packages Source: https://github.com/vchelaru/gum/blob/main/Themes/Gum.Themes.Template.MonoGame/README.md Install the Gum theme package that matches your runtime environment using the .NET CLI. ```bash dotnet add package Gum.Themes.Template.MonoGame dotnet add package Gum.Themes.Template.Kni dotnet add package Gum.Themes.Template.Raylib ``` -------------------------------- ### Example: Generating Fonts for a Project Source: https://github.com/vchelaru/gum/blob/main/docs/cli/fonts.md An example demonstrating how to run the gumcli fonts command with a specific project file. This will generate any missing font files in the 'FontCache/' directory. ```bash gumcli fonts MyProject/MyProject.gumx ``` -------------------------------- ### Install Neon Theme for Raylib Source: https://github.com/vchelaru/gum/blob/main/docs/code/styling/themes/README.md Installs the Neon theme package for Raylib projects, including pre-release versions. Run this in your project folder. ```bash dotnet add package Gum.Themes.Neon.Raylib --prerelease ``` -------------------------------- ### Install Forest Glade Theme for Raylib Source: https://github.com/vchelaru/gum/blob/main/docs/code/styling/themes/README.md Installs the Forest Glade theme package for Raylib projects. Apply the theme using ForestGladeTheme.Apply(). ```bash dotnet add package Gum.Themes.ForestGlade.Raylib --prerelease ``` ```csharp // Initialize using Gum.Themes.ForestGlade; ForestGladeTheme.Apply(); ``` -------------------------------- ### Add KernSmith.KniGum Package Source: https://github.com/vchelaru/gum/blob/main/Integrations/KernSmith/KernSmith.KniGum/README.md Install the KernSmith.KniGum NuGet package using the .NET CLI. ```bash dotnet add package KernSmith.KniGum ``` -------------------------------- ### Initialize Gum with V3 Default Visuals (New) Source: https://github.com/vchelaru/gum/blob/main/docs/gum-tool/upgrading/migrating-to-2026-july.md Demonstrates the recommended way to initialize Gum using V3 default visuals, which is the supported path forward. ```csharp // Initialize GumService.Default.Initialize( this, defaultVisualsVersion: DefaultVisualsVersion.V3); ``` -------------------------------- ### Install WINE and Winetricks on Ubuntu 24.04 Source: https://github.com/vchelaru/gum/blob/main/docs/gum-tool/setup/README.md Installs WINE stable and Winetricks on Ubuntu 24.04 using the official WineHQ repository. This is part of the manual setup for running Gum on Linux. ```shellscript sudo dpkg --add-architecture i386 sudo mkdir -pm755 /etc/apt/keyrings wget -O - https://dl.winehq.org/wine-builds/winehq.key | sudo gpg --dearmor -o /etc/apt/keyrings/winehq-archive.key - sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/noble/winehq-noble.sources sudo apt update && sudo apt install --install-recommends winehq-stable sudo apt-get -y install winetricks ``` -------------------------------- ### Install WINE and Winetricks on Ubuntu 22.04 Source: https://github.com/vchelaru/gum/blob/main/docs/gum-tool/setup/README.md Installs WINE stable and Winetricks on Ubuntu 22.04 using the official WineHQ repository. This is part of the manual setup for running Gum on Linux. ```shellscript sudo dpkg --add-architecture i386 sudo mkdir -pm755 /etc/apt/keyrings wget -O - https://dl.winehq.org/wine-builds/winehq.key | sudo gpg --dearmor -o /etc/apt/keyrings/winehq-archive.key - sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources sudo apt update && sudo apt install --install-recommends winehq-stable sudo apt-get -y install winetricks ``` -------------------------------- ### Initializing GumService with a Project File Source: https://github.com/vchelaru/gum/blob/main/docs/code/gum-code-reference/gumservice-gumui/README.md Initialize the Gum system by specifying the game instance and the path to the .gumx project file. ```csharp // Initialize GumUI.Initialize(this, "GumProject/GumProject.gumx"); ``` ```csharp // Initialize GumUI.Initialize(this, "../resources/GumProject/GumProject.gumx"); ``` ```csharp // Initialize FileManager.RelativeDirectory = "resources/"; GumUI.Initialize(this, "GumProject/GumProject.gumx"); ``` ```csharp // Initialize GumUI.Initialize(this, "c:/Gum/GumProject.gumx"); ``` -------------------------------- ### Install WINE and Winetricks on Linux Mint 20 Source: https://github.com/vchelaru/gum/blob/main/docs/gum-tool/setup/README.md Installs WINE and Winetricks on Linux Mint 20 (focal) using the official WineHQ repository. This is part of the manual setup for running Gum on Linux. ```shellscript sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https curl -y sudo dpkg --add-architecture i386 curl -s https://dl.winehq.org/wine-builds/winehq.key | sudo gpg --dearmor | sudo tee /usr/share/keyrings/winehq.gpg > /dev/null echo deb [signed-by=/usr/share/keyrings/winehq.gpg] http://dl.winehq.org/wine-builds/ubuntu/ focal main | sudo tee /etc/apt/sources.list.d/winehq.list sudo apt-get install winetricks ``` -------------------------------- ### Initialize Pygame and Screen Source: https://github.com/vchelaru/gum/blob/main/docs/code/getting-started/setup/adding-initializing-gum/pygame.md Initialize Pygame, define colors, and set up the display screen. This should be done before creating GumUI instances. ```python pygame.init() BLACK = (0, 0, 0) SCREEN_WIDTH = 640 SCREEN_HEIGHT = 480 screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) ``` -------------------------------- ### Get a Button by Qualified Name Source: https://github.com/vchelaru/gum/blob/main/docs/code/gum-code-reference/graphicaluielement/getframeworkelementbyname.md This example shows how to retrieve a Button element using a qualified name, which includes the names of its parent containers. This is useful when multiple elements share the same name. ```csharp var button = screenRuntime.GetFrameworkElementByName("MenuContainer.PlayButton"); button.Click += (_, _) => System.Diagnostics.Debug.WriteLine("Play was clicked"); ``` -------------------------------- ### Gum Fixed and Percentage Width Examples Source: https://github.com/vchelaru/gum/blob/main/docs/code/about/for-wpf-users.md Demonstrates setting a fixed width in Gum, similar to WPF. Also shows how to set a width as a percentage of the parent using WidthUnits and Width properties, offering more flexibility. ```csharp // Gum - fixed size (same): myButton.Width = 100; // Gum - percentage of parent (no direct WPF equivalent without a Grid Star column): myButton.Visual.WidthUnits = DimensionUnitType.PercentageOfParent; myButton.Visual.Width = 50; // 50% of parent ``` -------------------------------- ### Install DarkPro Theme Packages Source: https://github.com/vchelaru/gum/blob/main/Themes/Gum.Themes.DarkPro.MonoGame/README.md Add the appropriate NuGet package for your runtime (MonoGame, Kni, or Raylib) to your project. ```bash dotnet add package Gum.Themes.DarkPro.MonoGame dotnet add package Gum.Themes.DarkPro.Kni dotnet add package Gum.Themes.DarkPro.Raylib ``` -------------------------------- ### Install WINE and Winetricks on macOS Source: https://github.com/vchelaru/gum/blob/main/docs/gum-tool/setup/README.md Use Homebrew to install the necessary WINE and Winetricks packages on your macOS system. ```sh brew install --cask --no-quarantine wine-stable brew install winetricks ``` -------------------------------- ### Demonstrate StackPanel Layout Behavior Source: https://github.com/vchelaru/gum/blob/main/docs/code/performance-and-optimization/measuring-layout-calls.md This example initializes a StackPanel, adds it to the root, and then iteratively adds labels to it. It measures and logs the StackPanel's absolute height before and after each label is added, illustrating that the layout is recalculated after each child is added. ```csharp StackPanel stackPanel = new(); stackPanel.AddToRoot(); stackPanel.Anchor(Anchor.Center); for(int i = 0; i < 10; i++) { float heightBefore = stackPanel.Visual.GetAbsoluteHeight(); Label label = new(); stackPanel.AddChild(label); float heightAfter = stackPanel.Visual.GetAbsoluteHeight(); label.Text = $"Label {i + 1} (StackPanel Height: {heightBefore} -> {heightAfter})"; } ``` -------------------------------- ### Run SokolGumFromFile Sample Application Source: https://github.com/vchelaru/gum/blob/main/Runtimes/SokolGum/README.md Execute the sample application for SokolGum that loads .gumx files from the repository root. ```shell dotnet run --project Samples/SokolGumFromFile/SokolGumFromFile.csproj # loads .gumx ``` -------------------------------- ### Install Retro95 Theme for KNI Source: https://github.com/vchelaru/gum/blob/main/docs/code/styling/themes/README.md Installs the Retro95 theme package for KNI projects. Run this command in your project folder. ```bash dotnet add package Gum.Themes.Retro95.Kni ``` -------------------------------- ### Run SokolGum Sample Application Source: https://github.com/vchelaru/gum/blob/main/Runtimes/SokolGum/README.md Execute the code-only UI sample for SokolGum from the repository root. ```shell dotnet run --project Samples/SokolGum/SokolGumSample.csproj # code-only UI ``` -------------------------------- ### Install Neon Theme for MonoGame Source: https://github.com/vchelaru/gum/blob/main/docs/code/styling/themes/README.md Installs the Neon theme package for MonoGame projects. Use this command in your project directory. ```bash dotnet add package Gum.Themes.Neon.MonoGame ``` -------------------------------- ### Install Bubblegum Theme for Raylib Source: https://github.com/vchelaru/gum/blob/main/docs/code/styling/themes/README.md Installs the Bubblegum theme package for Raylib projects. Apply the theme using BubblegumTheme.Apply(). ```bash dotnet add package Gum.Themes.Bubblegum.Raylib --prerelease ``` ```csharp // Initialize using Gum.Themes.Bubblegum; BubblegumTheme.Apply(); ``` -------------------------------- ### Copy Plugin DLL and PDB Post-Build Event Source: https://github.com/vchelaru/gum/blob/main/docs/gum-tool/plugins/setting-up-post-build-events.md Use this command line script in your project's post-build event to create the necessary plugin directory and copy the DLL and PDB files. Remember to replace 'PluginProject' with your actual project name. ```text if not exist $(SolutionDir)Gum\bin\Debug\Data\Plugins\ md $(SolutionDir)Gum\bin\Debug\Data\Plugins\ if not exist $(SolutionDir)Gum\bin\Debug\Data\Plugins\PluginProject\ md $(SolutionDir)Gum\bin\Debug\Data\Plugins\PluginProject\ copy $(TargetDir)PluginProject.dll $(SolutionDir)Gum\bin\Debug\Data\Plugins\PluginProject\PluginProject.dll copy $(TargetDir)PluginProject.pdb $(SolutionDir)Gum\bin\Debug\Data\Plugins\PluginProject\PluginProject.pdb ``` -------------------------------- ### Install Bubblegum Theme for KNI Source: https://github.com/vchelaru/gum/blob/main/docs/code/styling/themes/README.md Installs the Bubblegum theme package for KNI projects. Apply the theme using BubblegumTheme.Apply(). ```bash dotnet add package Gum.Themes.Bubblegum.Kni ``` ```csharp // Initialize using Gum.Themes.Bubblegum; BubblegumTheme.Apply(); ``` -------------------------------- ### Install Bubblegum Theme for MonoGame Source: https://github.com/vchelaru/gum/blob/main/docs/code/styling/themes/README.md Installs the Bubblegum theme package for MonoGame projects. Apply the theme using BubblegumTheme.Apply(). ```bash dotnet add package Gum.Themes.Bubblegum.MonoGame ``` ```csharp // Initialize using Gum.Themes.Bubblegum; BubblegumTheme.Apply(); ``` -------------------------------- ### Create a 2x2 Grid with Sizing Source: https://github.com/vchelaru/gum/blob/main/docs/code/controls/grid.md Initializes a Grid, defines row and column proportions, and populates cells with colored rectangles and labels. ```csharp // Initialize var grid = new Grid(); // Grid fills its parent by default grid.AddToRoot(); // Three columns showing the three main sizing types grid.ColumnDefinitions.Add(new ColumnDefinition(new GridLength(1, GridUnitType.Star))); grid.ColumnDefinitions.Add(new ColumnDefinition(new GridLength(2, GridUnitType.Star))); grid.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Auto)); // Two rows with different proportions grid.RowDefinitions.Add(new RowDefinition(new GridLength(2, GridUnitType.Star))); grid.RowDefinitions.Add(new RowDefinition(new GridLength(1, GridUnitType.Star))); // Colors for each column — makes proportions immediately visible Color[] columnColors = [ new Color(180, 100, 100), // red-ish new Color(100, 150, 180), // blue-ish new Color(100, 170, 120), // green-ish ]; string[] columnLabels = ["1*", "2*", "Auto"]; string[] rowLabels = ["2*", "1*"]; for (int row = 0; row < 2; row++) { for (int col = 0; col < 3; col++) { var background = new ColoredRectangleRuntime(); float brightness = row == 0 ? 1.0f : 0.6f; var cellColor = new Color( (int)(columnColors[col].R * brightness), (int)(columnColors[col].G * brightness), (int)(columnColors[col].B * brightness) ); background.Color = cellColor; background.Dock(Dock.Fill); grid.AddChild(background, row: row, column: col); var label = new Label(); label.Text = $"Col {columnLabels[col]}\nRow {rowLabels[row]}"; label.XUnits = Gum.Converters.GeneralUnitType.PixelsFromMiddle; label.YUnits = Gum.Converters.GeneralUnitType.PixelsFromMiddle; label.X = 0; label.Y = 0; label.XOrigin = RenderingLibrary.Graphics.HorizontalAlignment.Center; label.YOrigin = RenderingLibrary.Graphics.VerticalAlignment.Center; grid.AddChild(label, row: row, column: col); } } ``` -------------------------------- ### Blazor Start Configuration Source: https://github.com/vchelaru/gum/blob/main/Samples/GumShapesGallery/KniGumShapesGallery.BlazorGL/wwwroot/index.html Configures the Blazor start process, including a custom loadBootResource function to handle Brotli decompression. ```javascript Blazor.start({ loadBootResource: function (type, name, defaultUri, integrity) { if (enableBrotliDecompression === true && type !== 'dotnetjs' && location.hostname !== 'localhost') { return (async function () { const response = await fetch(defaultUri + '.br', { cache: 'no-cache' }); if (!response.ok) throw new Error(response.statusText); const originalResponseBuffer = await response.arrayBuffer(); const originalResponseArray = new Int8Array(originalResponseBuffer); const contentType = (type === 'dotnetwasm') ? 'application/wasm' : 'application/octet-stream'; const decompressedResponseArray = BrotliDecode(originalResponseArray); return new Response(decompressedResponseArray, { headers: { 'content-type': contentType } }); })(); } } }); ``` -------------------------------- ### Create MenuItems Source: https://github.com/vchelaru/gum/blob/main/docs/code/controls/menuitem.md Demonstrates how to instantiate MenuItems and nest them within a Menu or other MenuItems. ```csharp // Initialize var menu = new Menu(); menu.AddToRoot(); var fileMenuItem = new MenuItem(); fileMenuItem.Header = "File"; menu.Items.Add(fileMenuItem); var newItem = new MenuItem(); newItem.Header = "New"; fileMenuItem.Items.Add(newItem); var loadRecent = new MenuItem(); loadRecent.Header = "Load Recent"; fileMenuItem.Items.Add(loadRecent); for(int i = 0; i < 10; i++) { var item = new MenuItem(); item.Header = "File " + i; loadRecent.Items.Add(item); } var editMenuItem = new MenuItem(); editMenuItem.Header = "Edit"; menu.Items.Add(editMenuItem); ``` -------------------------------- ### Install Gum CLI as Global .NET Tool Source: https://github.com/vchelaru/gum/blob/main/docs_projects/18_Gum_Cli.md Use these commands to install, update, or uninstall the Gum CLI as a global .NET tool. ```bash # Instalar dotnet tool install -g Gum.Cli # Actualizar dotnet tool update -g Gum.Cli # Desinstalar dotnet tool uninstall -g Gum.Cli ``` -------------------------------- ### Raylib Setup for Gum Source: https://github.com/vchelaru/gum/blob/main/docs/code/getting-started/tutorials/code-only-gum-forms-tutorial/setup.md Initializes Gum and sets up the game loop for Raylib projects. This includes initializing the window, GumService, and adding a root StackPanel. Ensure STAThread attribute is present for NativeAOT deployment on Windows. ```csharp using Gum; using Gum.Forms; using Gum.Forms.Controls; using Raylib_cs; namespace MyGumProject; public class Program { static GumService GumUI => GumService.Default; // STAThread is required if you deploy using NativeAOT on Windows - See https://github.com/raylib-cs/raylib-cs/issues/301 [STAThread] public static void Main() { const int screenWidth = 800; const int screenHeight = 450; Raylib.InitWindow(screenWidth, screenHeight, "Gum Sample"); Raylib.SetTargetFPS(60); // This tells Gum to use the entire screen GumUI.CanvasWidth = screenWidth; GumUI.CanvasHeight = screenHeight; GumUI.Initialize(); var mainPanel = new StackPanel(); mainPanel.AddToRoot(); while (!Raylib.WindowShouldClose()) { // Update game/UI state first, then render it. GumUI.Update(Raylib.GetTime()); Raylib.BeginDrawing(); Raylib.ClearBackground(Raylib_cs.Color.SkyBlue); GumUI.Draw(); Raylib.EndDrawing(); } Raylib.CloseWindow(); } } ``` -------------------------------- ### Install Retro95 Theme for Raylib Source: https://github.com/vchelaru/gum/blob/main/docs/code/styling/themes/README.md Installs the Retro95 theme package for Raylib projects, including pre-release versions. Use this in your project directory. ```bash dotnet add package Gum.Themes.Retro95.Raylib --prerelease ``` -------------------------------- ### Instantiate and Use TaskScreen Source: https://github.com/vchelaru/gum/blob/main/docs/code/binding-viewmodels/tutorial-task-screen.md Demonstrates how to create an instance of the TaskScreen, add it to the root of the game, and assign its BindingContext to a ViewModel. ```csharp // Initialize var screen = new TaskScreen(); screen.AddToRoot(); var viewModel = new TaskScreenViewModel(); screen.BindingContext = viewModel; ``` -------------------------------- ### Initialize Gum Project and Load Screen1 Source: https://github.com/vchelaru/gum/blob/main/docs/code/getting-started/tutorials/gum-project-.gumx-tutorial/multiple-screens.md Initializes the Gum project and loads 'Screen1' to be displayed. Ensure your Gum project path is correct and that 'Screen1' exists within your Gum project. ```csharp public class Game1 : Game { private GraphicsDeviceManager _graphics; GumService GumUI => GumService.Default; public Game1() { _graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; IsMouseVisible = true; } protected override void Initialize() { var gumProject = GumUI.Initialize( this, // This is relative to Content: "GumProject/GumProject.gumx"); // Start of new code var screen = gumProject.Screens.Find(item => item.Name == "Screen1"); // End of new code var screenRuntime = screen.ToGraphicalUiElement(); screenRuntime.AddToRoot(); base.Initialize(); } ... ``` -------------------------------- ### Install Neon Theme for KNI Source: https://github.com/vchelaru/gum/blob/main/docs/code/styling/themes/README.md Installs the Neon theme package for KNI projects. Execute this command in your project's root directory. ```bash dotnet add package Gum.Themes.Neon.Kni ``` -------------------------------- ### Initialize Gum Project and Display Screen Source: https://github.com/vchelaru/gum/blob/main/docs/code/getting-started/tutorials/gum-project-.gumx-tutorial/gum-screens.md Modify the Initialize method to load the Gum project, find a specific screen by name, convert it to a visual element, and add it to the game's root. This ensures the screen is rendered and updated. ```csharp protected override void Initialize() { var gumProject = GumUI.Initialize( this, // This is relative to Content: "GumProject/GumProject.gumx"); // the Screens list contains all screens. Find the screen you want var screen = gumProject.Screens.Find(item => item.Name == "TitleScreen"); // Calling GraphicalUiElement creates the visuals for the screen var screenRuntime = screen.ToGraphicalUiElement(); screenRuntime.AddToRoot(); base.Initialize(); } ``` -------------------------------- ### Install Forest Glade Theme for KNI Source: https://github.com/vchelaru/gum/blob/main/docs/code/styling/themes/README.md Installs the Forest Glade theme package for KNI projects. Apply the theme using ForestGladeTheme.Apply(). ```bash dotnet add package Gum.Themes.ForestGlade.Kni ``` ```csharp // Initialize using Gum.Themes.ForestGlade; ForestGladeTheme.Apply(); ``` -------------------------------- ### Install Forest Glade Theme for MonoGame Source: https://github.com/vchelaru/gum/blob/main/docs/code/styling/themes/README.md Installs the Forest Glade theme package for MonoGame projects. Apply the theme using ForestGladeTheme.Apply(). ```bash dotnet add package Gum.Themes.ForestGlade.MonoGame ``` ```csharp // Initialize using Gum.Themes.ForestGlade; ForestGladeTheme.Apply(); ``` -------------------------------- ### Build Gum Tool Solution Source: https://github.com/vchelaru/gum/blob/main/CLAUDE.md Use this command to build the entire Gum tool solution, including plugins. This is required for any work under `Tool/` or `Gum/`. ```bash dotnet build GumFull.sln ``` -------------------------------- ### AddNextClickAction Example Source: https://github.com/vchelaru/gum/blob/main/docs/code/gum-code-reference/interactivegue/addnextclickaction.md This example demonstrates creating a popup panel that closes on any click, while still allowing clicks on buttons within the panel to register. ```csharp // Initialize var popupPanel = new StackPanel(); popupPanel.IsVisible = false; popupPanel.Anchor(Anchor.Center); Gum.ModalRoot.AddChild(popupPanel); for(int i = 0; i < 5; i++) { var innerButton = new Button(); popupPanel.AddChild(innerButton); innerButton.Text = "Button " + i; innerButton.Click += (_,_) => { System.Diagnostics.Debug.WriteLine("Clicked " + innerButton.Text); }; } var button = new Button(); button.AddToRoot(); button.Anchor(Anchor.Center); button.Text = "Click me to show popup"; button.Y = -200; button.Click += (not, used) => { popupPanel.IsVisible = true; InteractiveGue.AddNextClickAction(() => { popupPanel.IsVisible = false; }); }; ``` -------------------------------- ### Create and Configure a Button Source: https://github.com/vchelaru/gum/blob/main/ai-reference/gum-code-forms.md Instantiate a Button, add it to a StackPanel, set its text, and attach a click event handler. Ensure the parent container is correctly set up. ```csharp var button = new Button(); stackPanel.AddChild(button); button.Text = "Click Me"; button.Click += (_, _) => { /* handle */ }; ``` -------------------------------- ### Install Powershell Package Manager Source: https://github.com/vchelaru/gum/blob/main/Runtimes/Python/gumui/README.md Install the Microsoft Powershell package manager using winget. This is necessary for managing packages and dependencies within Powershell. ```powershell winget install --id Microsoft.Powershell --source winget ``` -------------------------------- ### Initialize GumUI and Load Animations Source: https://github.com/vchelaru/gum/blob/main/docs/code/animationruntime.md Initializes the GumUI system and loads all animations from the specified Gum project file. It then finds and adds a specific screen to the root. ```csharp GraphicalUiElement _animatedScreen; protected override void Initialize() { GumUI.Initialize(this, "GumProject/GumProject.gumx"); GumUI.LoadAnimations(); _animatedScreen = Gum.Managers.ObjectFinder.Self .GetScreen("AnimatedScreen") .ToGraphicalUiElement(); _animatedScreen.AddToRoot(); base.Initialize(); } ``` -------------------------------- ### Install Twine for Building Python Packages Source: https://github.com/vchelaru/gum/blob/main/Runtimes/Python/gumui/README.md Install Twine, a tool for uploading Python packages to PyPI. This is a prerequisite for building and distributing the Gum Python module. ```bash pip install build twine ``` -------------------------------- ### After: Using Gum.GueDeriving Source: https://github.com/vchelaru/gum/blob/main/docs/gum-tool/upgrading/syntax-version-1.md Shows the same functionality after migrating to syntax version 1, using the unified Gum.GueDeriving namespace. ```csharp using Gum.GueDeriving; public class MyScreen { public void Setup() { SpriteRuntime sprite = new SpriteRuntime(); sprite.Width = 100; } } ``` -------------------------------- ### Create and Draw Buttons in Order Source: https://github.com/vchelaru/gum/blob/main/docs/code/ordering-layers-and-popups/object-order.md Initializes multiple Button instances and adds them to the root. Buttons added later are drawn on top and have higher click priority. ```csharp // Initialize for(int i = 0; i < 10; i++) { Button button = new(); button.AddToRoot(); button.X = i * 30; button.Y = i * 5; } ``` -------------------------------- ### Execute Gum Setup Script on macOS Source: https://github.com/vchelaru/gum/blob/main/docs/gum-tool/setup/README.md Run the automated script to set up the Gum tool environment on macOS. Note that Gum may crash after this setup. ```sh ./setup_gum.mac.sh ``` -------------------------------- ### Before: Using MonoGameGum.GueDeriving Source: https://github.com/vchelaru/gum/blob/main/docs/gum-tool/upgrading/syntax-version-1.md Illustrates the usage of runtime classes with the older MonoGameGum.GueDeriving namespace before syntax version 1. ```csharp using MonoGameGum.GueDeriving; public class MyScreen { public void Setup() { SpriteRuntime sprite = new SpriteRuntime(); sprite.Width = 100; } } ```