### Execute Shell Script for Linux Setup Source: https://docs.flatredball.com/gum/gum-tool/setup This snippet demonstrates how to make a downloaded shell script executable and then run it. This is used in the Linux setup process to automate the installation of WINE, Winetricks, fonts, and .NET 8. ```shell chmod +x ./setup_gum_linux.sh && ./setup_gum_linux.sh ``` -------------------------------- ### Install .NET Framework 8 with Winetricks Source: https://docs.flatredball.com/gum/gum-tool/setup Installs the .NET Framework 8 using Winetricks within the specified WINE prefix. This process may take several minutes and requires user interaction through two installer dialogs. ```shell WINEPREFIX=$GUM_WINE_PREFIX_PATH winetricks dotnetdesktop8 ``` -------------------------------- ### Install WINE and Winetricks on Fedora & Nobara Source: https://docs.flatredball.com/gum/gum-tool/setup Installs WINE and winetricks on Fedora and Nobara Linux distributions using the DNF package manager. ```shell sudo dnf install wine sudo dnf install winetricks ``` -------------------------------- ### Make and Execute macOS Setup Script Source: https://docs.flatredball.com/gum/gum-tool/setup Makes the downloaded Gum setup script for macOS executable and then runs it. This script automates the environment setup for running Gum on macOS using WINE. ```bash chmod +x ./setup_gum_mac.sh ./setup_gum.mac.sh ``` -------------------------------- ### Install Winetricks on Linux Mint 21 Source: https://docs.flatredball.com/gum/gum-tool/setup Installs winetricks on Linux Mint 21 (Jammy Jellyfish) by adding the i386 architecture, importing the WineHQ GPG key, configuring the WineHQ repository, and installing winetricks. ```shell 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/ jammy main | sudo tee /etc/apt/sources.list.d/winehq.list sudo apt-get install winetricks ``` -------------------------------- ### Install Winetricks on Linux Mint 22 Source: https://docs.flatredball.com/gum/gum-tool/setup Installs winetricks on Linux Mint 22 (Noble Numbat) by adding the i386 architecture, importing the WineHQ GPG key, configuring the WineHQ repository, and installing winetricks. ```shell 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/ noble main | sudo tee /etc/apt/sources.list.d/winehq.list sudo apt-get install winetricks ``` -------------------------------- ### Install Winetricks on Linux Mint 20 Source: https://docs.flatredball.com/gum/gum-tool/setup Installs winetricks on Linux Mint 20 (Focal Fossa) by adding the i386 architecture, importing the WineHQ GPG key, configuring the WineHQ repository, and installing winetricks. ```shell 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 ``` -------------------------------- ### Install WINE and Winetricks on macOS Source: https://docs.flatredball.com/gum/gum-tool/setup Installs WINE and Winetricks on macOS using the Homebrew package manager. These are prerequisites for running Gum on macOS. ```bash brew install --cask --no-quarantine wine-stable brew install winetricks ``` -------------------------------- ### Install WINE and Winetricks on Ubuntu 22.04 Source: https://docs.flatredball.com/gum/gum-tool/setup Installs WINE stable version and winetricks on Ubuntu 22.04 (Jammy Jellyfish) by adding the i386 architecture, configuring the WineHQ repository, and updating the package list. ```shell 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 ``` -------------------------------- ### Install WINE and Winetricks on Ubuntu 24.04 Source: https://docs.flatredball.com/gum/gum-tool/setup Installs WINE stable version and winetricks on Ubuntu 24.04 (Noble Numbat) by adding the i386 architecture, configuring the WineHQ repository, and updating the package list. ```shell 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 ``` -------------------------------- ### Create Gum Executable Script Source: https://docs.flatredball.com/gum/gum-tool/setup Finds the Gum.exe file within the WINE prefix, creates a 'bin' directory in the user's home if it doesn't exist, creates an executable script named 'gum' in the 'bin' directory, and makes it executable. ```bash GUM_EXE_PATH=$(find "$GUM_WINE_PREFIX_PATH" -name "Gum.exe" -type f) && \ mkdir -p $HOME/bin && \ touch $HOME/bin/gum chmod +x $HOME/bin/gum ``` -------------------------------- ### Component Runtime Namespace Example Source: https://docs.flatredball.com/gum/gum-tool/code-tab This example demonstrates how to add a using statement for component runtimes in your project. This is essential when creating Screens that utilize custom components, ensuring their respective runtime classes are accessible. ```csharp using {YourProjectNamespace}.Components; ``` -------------------------------- ### Instantiate DataUiGrid in Code Source: https://docs.flatredball.com/gum/code/gum-tool-code-contributing-and-plugins/datauigrid This code example shows how to create an instance of the DataUiGrid programmatically in C#. It demonstrates the basic instantiation and suggests adding it to a layout object. ```csharp var grid = new DataUiGrid(); // add the grid to some layout object like a Grid or StackLayout... ``` -------------------------------- ### Unzip and Install Gum Tool in WINE Source: https://docs.flatredball.com/gum/gum-tool/setup Removes any existing Gum installation, extracts the downloaded Gum.zip file to the specified WINE Program Files directory, and then cleans up the ZIP file. Ensure the GUM_WINE_PREFIX_PATH environment variable is correctly set. ```bash rm -rf $GUM_WINE_PREFIX_PATH/drive_c/Program\ Files/Gum && \ unzip Gum.zip -d $GUM_WINE_PREFIX_PATH/drive_c/Program\ Files/Gum && \ rm -f Gum.zip ``` -------------------------------- ### Download Gum Tool ZIP from GitHub Source: https://docs.flatredball.com/gum/gum-tool/setup Downloads the latest Gum Tool ZIP archive from the GitHub releases page using curl. This command saves the downloaded file as 'Gum.zip' in the current directory. ```bash curl -o Gum.zip https://github.com/vchelaru/gum/releases/latest/download/Gum.zip ``` -------------------------------- ### TaskScreen Binding and Event Setup (C#) Source: https://docs.flatredball.com/gum/code/binding-viewmodels/tutorial-task-screen This C# snippet shows the binding and event setup for a TaskScreen, intended to be used with the Gum UI tool's code generation. It focuses on connecting UI elements like ListBox and TextBox to ViewModel properties and handling button clicks by invoking ViewModel methods. This is a common pattern for integrating UI elements with application logic. ```csharp class TaskScreen { TaskScreenViewModel ViewModel => (TaskScreenViewModel)BindingContext; private void CustomInitialize() { TaskListBox.SetBinding( nameof(TaskListBox.Items), nameof(ViewModel.Tasks)); TaskListBox.SetBinding( nameof(TaskListBox.SelectedObject), nameof(ViewModel.SelectedTask)); TaskListBox.DisplayMemberPath = nameof(TaskItemViewModel.Name); TaskNameTextBox.SetBinding( nameof(TaskNameTextBox.Text), nameof(ViewModel.NewTaskName)); AddTaskButton.Click += (_,_) => ViewModel.HandleAddTask(); RemoveTaskButton.Click += (_,_) => ViewModel.HandleRemoveTask(); } } ``` -------------------------------- ### Initialize Gum and Add StackPanel in MonoGame Source: https://docs.flatredball.com/gum/code/getting-started/tutorials/code-only-gum-forms-tutorial/setup Initializes the Gum service with the game instance and a visual version, then creates and adds a StackPanel to the root. This is a one-time setup for Gum projects. The StackPanel acts as a container for other UI elements and receives drawing and input. ```csharp using Gum.Forms; using Gum.Forms.Controls; 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() { GumUI.Initialize(this, DefaultVisualsVersion.V3); var mainPanel = new StackPanel(); mainPanel.AddToRoot(); base.Initialize(); } protected override void Update(GameTime gameTime) { GumUI.Update(gameTime); base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); GumUI.Draw(); base.Draw(gameTime); } } ``` ```csharp GumUI.Initialize(this, DefaultVisualsVersion.V3); var mainPanel = new StackPanel(); mainPanel.AddToRoot(); ``` -------------------------------- ### Instantiate and Bind SettingsScreen to ViewModel (C#) Source: https://docs.flatredball.com/gum/code/binding-viewmodels/tutorial-settings-screen This snippet demonstrates how to create an instance of SettingsScreen, add it to the game's root, create a SettingsViewModel, and assign it as the BindingContext. Initial values are set on the ViewModel, which are then reflected in the UI. ```csharp var screen = new SettingsScreen(); screen.AddToRoot(); var viewModel = new SettingsViewModel(); screen.BindingContext = viewModel; viewModel.SfxVolume = 50; viewModel.MusicVolume = 75; viewModel.IsFullScreen = true; ``` -------------------------------- ### Create and Initialize ContainerRuntime (C#) Source: https://docs.flatredball.com/gum/code/standard-visuals/containerruntime Demonstrates how to instantiate a ContainerRuntime, set its dimensions, and add it to the system managers. Containers use absolute width and height by default. ```csharp var container = new ContainerRuntime(); container.Width = 150; // by default, containers use absolute width... container.Height = 150; // ...and height. container.AddToManagers(SystemManagers.Default, null); ``` -------------------------------- ### Tutorial: Settings Screen Binding in Gum Source: https://docs.flatredball.com/gum/code A tutorial demonstrating how to implement data binding for a settings screen using MVVM principles in Gum. It likely shows how to bind UI elements to ViewModel properties. ```C# // Code related to Tutorial - Settings Screen will be documented here. ``` -------------------------------- ### Loading Gum Project with Absolute Path (C#) Source: https://docs.flatredball.com/gum/code/gum-code-reference/gumservice-gumui This snippet shows how to initialize GumService by providing an absolute path to the Gum project (.gumx) file. Use this method with caution, as it can limit project portability across different machines. ```csharp GumUI.Initialize(this, "c:/Gum/GumProject.gumx"); ``` -------------------------------- ### Switch Screen 2 to Screen 1 (C#) Source: https://docs.flatredball.com/gum/code/getting-started/tutorials/gum-project-forms-tutorial/multiple-screens This C# code snippet shows how to switch back from Screen2 to Screen1. Similar to the previous example, it attaches a click handler to a button. When clicked, it clears the current screen and loads Screen1, facilitating navigation within the application. ```csharp using MonoGameGum; partial class Screen2 { partial void CustomInitialize() { ButtonStandardInstance.Click += (_, _) => { GumService.Default.Root.Children.Clear(); var screen = new Screen1(); screen.AddToRoot(); }; } } ``` ```diff using MonoGameGum; partial class Screen2 { partial void CustomInitialize() { + ButtonStandardInstance.Click += (_, _) => + { + GumService.Default.Root.Children.Clear(); + var screen = new Screen1(); + screen.AddToRoot(); + }; } } ``` -------------------------------- ### Configure WINE prefix and install fonts with Winetricks Source: https://docs.flatredball.com/gum/gum-tool/setup Sets the WINE prefix path for the GUM tool and installs essential Windows fonts (Arial, Tahoma, Courier, Calibri) using Winetricks. This ensures the GUM tool has the necessary font dependencies. ```shell GUM_WINE_PREFIX_PATH=$HOME/.wine_gum_prefix/ winetricks --version sudo winetricks --self-update WINEPREFIX=$GUM_WINE_PREFIX_PATH winetricks arial WINEPREFIX=$GUM_WINE_PREFIX_PATH winetricks tahoma WINEPREFIX=$GUM_WINE_PREFIX_PATH winetricks courier WINEPREFIX=$GUM_WINE_PREFIX_PATH winetricks calibri ``` -------------------------------- ### Run Gum Tool Source: https://docs.flatredball.com/gum/gum-tool/setup Executes the Gum Tool by simply typing 'gum' in the terminal. This command assumes the Gum script has been correctly installed and the PATH environment variable has been updated and reloaded. ```bash gum ``` -------------------------------- ### C# Custom Code Initialization Example Source: https://docs.flatredball.com/gum/code/getting-started/tutorials/gum-project-.gumx-tutorial/strongly-typed-components-using-code-generation Provides a C# code snippet demonstrating the `CustomInitialize` method, which is part of Gum's custom code functionality. This method allows for custom initialization logic when a component is first created. It is declared as a partial method, meaning it can be optionally implemented or even deleted if no custom initialization is needed. ```csharp partial void CustomInitialize() { } ``` -------------------------------- ### Reload Shell Configuration (Zsh) Source: https://docs.flatredball.com/gum/gum-tool/setup Reloads the '.zshrc' file to apply any recent changes to the shell's configuration, including PATH updates. This command is specific to the Zsh shell. ```bash source ~/.zshrc ``` -------------------------------- ### Reload Shell Configuration (Bash) Source: https://docs.flatredball.com/gum/gum-tool/setup Reloads the '.bashrc' file to apply any recent changes made to the shell's configuration, such as modifications to the PATH environment variable. This command is specific to the Bash shell. ```bash source ~/.bashrc ``` -------------------------------- ### Upgrade Gum Tool Source: https://docs.flatredball.com/gum/gum-tool/upgrading/migrating-to-2025-december Instructions to download and install the latest Gum tool from GitHub releases. This involves deleting the old tool and unzipping the new one to the same location. ```text 1. Download Gum.zip from the release on Github: https://github.com/vchelaru/Gum/releases/tag/Release_December_28_2025 2. Delete the old tool from your machine 3. Unzip the gum tool to the same location as to not break any file associations ``` -------------------------------- ### Initialize Game with Gum TitleScreen (C#) Source: https://docs.flatredball.com/gum/code/getting-started/tutorials/gum-project-forms-tutorial/gum-screens This snippet demonstrates how to initialize the Gum UI system and display a TitleScreen in a game. It requires the GumUI library and a Gum project file. The code instantiates a TitleScreen object and adds it to the root for rendering and event handling. ```csharp protected override void Initialize() { GumUI.Initialize(this, "GumProject/GumProject.gumx"); var screen = new TitleScreen(); screen.AddToRoot(); base.Initialize(); } ``` ```diff protected override void Initialize() { GumUI.Initialize(this, "GumProject/GumProject.gumx"); + var screen = new TitleScreen(); + screen.AddToRoot(); base.Initialize(); } ``` -------------------------------- ### Load and Play Gum Animations in C# Source: https://docs.flatredball.com/gum/code/animationruntime This C# code demonstrates loading all animations from a Gum project and playing them on UI elements. It shows how to initialize the GumService, load animations, create a screen, and trigger animations like 'SlideOnAndOff' and 'Spinning' based on keyboard input. It also includes stopping animations and toggling visibility. ```cs using Gum.Wireframe; public class Game1 : Game { private GraphicsDeviceManager _graphics; GumService GumUI => GumService.Default; public Game1() { _graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; } AnimatedScreen _animatedScreen; protected override void Initialize() { GumUI.Initialize(this, "GumProject/GumProject.gumx"); GumUI.LoadAnimations(); _animatedScreen = new AnimatedScreen(); _animatedScreen.AddToRoot(); base.Initialize(); } protected override void Update(GameTime gameTime) { GumUI.Update(gameTime); var keyboard = GumUI.Keyboard; if(keyboard.KeyPushed(Keys.Space)) { _animatedScreen.Visual.PlayAnimation("SlideOnAndOff"); } if(keyboard.KeyPushed(Keys.Escape)) { var popup = _animatedScreen .PleaseWaitPopupInstance.Visual; if(popup.Visible) { popup.StopAnimation(); popup.Visible = false; } else { popup.Visible = true; popup.PlayAnimation("Spinning"); } } base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); GumUI.Draw(); base.Draw(gameTime); } } ``` ```csharp using Gum.Wireframe; using MonoGameGum; // needed for ToGraphicalUiElement() extension method public class Game1 : Game { private GraphicsDeviceManager _graphics; GumService GumUI => GumService.Default; public Game1() { _graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; } 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(); } protected override void Update(GameTime gameTime) { GumUI.Update(gameTime); var keyboard = GumUI.Keyboard; if(keyboard.KeyPushed(Keys.Space)) { _animatedScreen.PlayAnimation("SlideOnAndOff"); } if(keyboard.KeyPushed(Keys.Escape)) ``` -------------------------------- ### Add Gum Script Directory to PATH (Zsh) Source: https://docs.flatredball.com/gum/gum-tool/setup Appends the '$HOME/bin' directory to the PATH environment variable in the user's '.zshrc' file if it's not already present. This ensures the 'gum' script is accessible globally. ```bash if ! grep -q 'export PATH="$HOME/bin:$PATH"' ~/.zshrc 2>/dev/null; then echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc fi ``` -------------------------------- ### Add Gum Script Directory to PATH (Bash) Source: https://docs.flatredball.com/gum/gum-tool/setup Appends the '$HOME/bin' directory to the PATH environment variable in the user's '.bashrc' file if it's not already present. This allows the 'gum' script to be executed from any directory. ```bash if ! grep -q 'export PATH="$HOME/bin:$PATH"' ~/.bashrc 2>/dev/null; then echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc fi ``` -------------------------------- ### Basic Nez Game Class Setup (C#) Source: https://docs.flatredball.com/gum/code/getting-started/setup/empty-project-before-adding-gum/nez This C# code snippet demonstrates the basic structure of a Nez game class. It inherits from Nez Core and overrides essential methods like Initialize, Update, and Draw. The Initialize method is used to set up the initial scene, typically a BasicScene. ```csharp public class Game1 : Core { protected override void Initialize() { base.Initialize(); Scene = new BasicScene(); } protected override void Update(GameTime gameTime) { base.Update(gameTime); } protected override void Draw(GameTime gameTime) { base.Draw(gameTime); } } ``` -------------------------------- ### Change Font Properties in Skia Source: https://docs.flatredball.com/gum/code/standard-visuals/textruntime/fonts This example illustrates how to change font properties for TextRuntime instances on the Skia platform. It involves directly assigning the Font, IsItalic, IsBold, and FontSize properties. The specified font must be installed on the system. ```csharp // Example for Skia (properties to be set directly) // textRuntimeInstance.Font = "Arial"; // textRuntimeInstance.IsItalic = false; // textRuntimeInstance.IsBold = false; // textRuntimeInstance.FontSize = 18; ``` -------------------------------- ### Get Absolute Position and Draw Sprite (C#) Source: https://docs.flatredball.com/gum/code/gum-code-reference/graphicaluielement/absolute-values This example demonstrates how to retrieve the absolute left and top coordinates of a container (a GraphicalUiElement) and use them to draw a sprite at that position using SpriteBatch. It assumes 'container' is a valid GraphicalUiElement and '_spriteBatch' is an initialized SpriteBatch object. ```csharp var absoluteLeft = container.AbsoluteLeft; var absoluteTop = container.AbsoluteTop; _spriteBatch.Begin(); _spriteBatch.Draw(texture, new Vector2(absoluteLeft, absoluteTop), Color.White); _spriteBatch.End(); ``` -------------------------------- ### Create SettingsScreen Layout and Bindings (Code-Only) Source: https://docs.flatredball.com/gum/code/binding-viewmodels/tutorial-settings-screen This C# code defines a `SettingsScreen` class from scratch, including creating UI elements like sliders, checkboxes, and buttons, and then establishing data bindings between these elements and a `SettingsViewModel`. It uses `SetBinding` with `nameof` for robust property association. ```csharp public class SettingsScreen : FrameworkElement { Slider SfxSlider; Slider MusicSlider; CheckBox FullScreenCheckbox; Button BackToMainMenuButton; public SettingsScreen() : base(new ContainerRuntime()) { CreateLayout(); CreateBinding(); } private void CreateLayout() { this.Dock(Gum.Wireframe.Dock.Fill); var panel = new StackPanel(); this.AddChild(panel); panel.Anchor(Gum.Wireframe.Anchor.Center); var label = new Label(); panel.AddChild(label); label.Text = "SFX Volume:"; SfxSlider = new Slider(); panel.AddChild(SfxSlider); SfxSlider.Width = 200; var musicLabel = new Label(); panel.AddChild(musicLabel); musicLabel.Text = "Music Volume:"; // add some padding: musicLabel.Y = 12; MusicSlider = new Slider(); panel.AddChild(MusicSlider); MusicSlider.Width = 200; FullScreenCheckbox = new CheckBox(); panel.AddChild(FullScreenCheckbox); FullScreenCheckbox.Text = "Full Screen"; // Add some padding: FullScreenCheckbox.Y = 12; BackToMainMenuButton = new Button(); panel.AddChild(BackToMainMenuButton); BackToMainMenuButton.Text = "Back to Main Menu"; // Add some padding: BackToMainMenuButton.Y = 12; } private void CreateBinding() { SfxSlider.SetBinding( nameof(SfxSlider.Value), nameof(SettingsViewModel.SfxVolume)); MusicSlider.SetBinding( nameof(MusicSlider.Value), nameof(SettingsViewModel.MusicVolume)); FullScreenCheckbox.SetBinding( nameof(FullScreenCheckbox.IsChecked), nameof(SettingsViewModel.IsFullScreen)); } } ``` -------------------------------- ### Set Focus and Handle Input for a Button Source: https://docs.flatredball.com/gum/code/getting-started/tutorials/code-only-gum-forms-tutorial/input-in-forms This example demonstrates how to enable keyboard and gamepad input, create a Button, attach a click event handler, and set the button's focus. When focused, the button will respond to clicks via the keyboard (Enter/Space) or gamepad (A button). ```csharp FrameworkElement.KeyboardsForUiControl.Add(GumService.Default.Keyboard); FrameworkElement.GamePadsForUiControl.AddRange(GumService.Default.Gamepads); var button = new Button(); int clickCount = 0; button.Text = "Click me"; button.Click += (s, e) => { clickCount++; button.Text = $"Clicked {clickCount} times"; }; button.IsFocused = true; mainPanel.AddChild(button); ``` -------------------------------- ### Basic MonoGame Game Class Structure (C#) Source: https://docs.flatredball.com/gum/code/getting-started/setup/empty-project-before-adding-gum/monogame-kni-fna This C# code snippet demonstrates the fundamental structure of a Game class in a MonoGame project. It includes initialization of the graphics device, sprite batch, and the core Update and Draw methods. This serves as a starting point before integrating Gum. ```csharp namespace MonoGameGum1; public class Game1 : Game { private GraphicsDeviceManager _graphics; private SpriteBatch _spriteBatch; public Game1() { _graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; IsMouseVisible = true; } protected override void Initialize() { base.Initialize(); } protected override void Update(GameTime gameTime) { base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); base.Draw(gameTime); } } ``` -------------------------------- ### Get Cursor Position Respecting Gum Zoom in C# Source: https://docs.flatredball.com/gum/code/gum-code-reference/cursor/position This C# code snippet demonstrates how to retrieve the cursor's X and Y coordinates, taking into account Gum's camera zoom and bounds. It's useful for placing UI elements accurately relative to the camera's view. This example adds a ColoredRectangleRuntime when the primary mouse button is pushed. ```csharp protected override void Initialize() { GumUI.Initialize(this); GumUI.Renderer.Camera.Zoom = 2; base.Initialize(); } protected override void Update(GameTime gameTime) { GumUI.Update(gameTime); var cursor = GumUI.Cursor; if(cursor.PrimaryPush) { var rectangle = new ColoredRectangleRuntime(); rectangle.X = cursor.XRespectingGumZoomAndBounds(); rectangle.Y = cursor.YRespectingGumZoomAndBounds(); rectangle.AddToRoot(); } base.Update(gameTime); } ``` -------------------------------- ### Gum Tool WINE Execution Script Source: https://docs.flatredball.com/gum/gum-tool/setup A bash script to launch the Gum Tool using WINE. It sets necessary environment variables, defines WINE prefix and Gum executable paths, attempts to add a registry key for WINE's X11 driver, and then executes Gum.exe via WINE. Users must update the path variables. ```bash #!/bin/bash # Setup Env vars (harmless if unsupported) export WINE_NO_WM_DECORATION=1 export PROTON_NO_WM_DECORATION=1 # Update these with the correct paths GUM_WINE_PREFIX_PATH="$HOME/.wine_gum_dotnet8/" GUM_EXE_PATH="$GUM_WINE_PREFIX_PATH/drive_c/Program Files/Gum/gum.exe" # Attempt to add registry keys WINEPREFIX="$GUM_WINE_PREFIX_PATH" wine reg add "HKCU\Software\Wine\X11 Driver" /v Decorated /t REG_SZ /d N /f # Launch gum through wine using the wineprefix WINEPREFIX="$GUM_WINE_PREFIX_PATH" wine "$GUM_EXE_PATH" ``` -------------------------------- ### Tutorial: Task Screen Binding in Gum Source: https://docs.flatredball.com/gum/code A tutorial illustrating data binding for a task management screen within the Gum framework, following MVVM patterns. It focuses on practical application of binding concepts. ```C# // Code related to Tutorial - Task Screen will be documented here. ```