DynamicHUD Dev Guide
DownloadNeed Support?
  • Dynamic HUD
  • Import using Gradle
  • Integrating DynamicHUD
    • Integrating DynamicHUD
    • Adding Widgets
    • Adding your own WidgetRenderer
    • Passing AbstractMoveableScreen instance
    • Changing default key bind
    • Changing save and load file
    • Registering Custom Widgets
  • Widget
    • Widget class
    • How to create a custom widget
    • Widget Renderer
    • WidgetData
    • DynamicValueRegistry
    • Scaling
  • Screens
    • AbstractMoveableScreen
  • ContextMenu
    • ContextMenu class
    • Using context menu
    • Option<T> class
      • Color Option
      • Boolean Option
      • Double Option
      • Runnable Option
      • Enum Option
      • List Option
      • SubMenu Option
Powered by GitBook
On this page

Was this helpful?

  1. Integrating DynamicHUD

Changing save and load file

The getWidgetsFile() method retrieves a File where widgets should be saved and loaded. It can be overridden to specify the file instance from which DynamicHUD will load and save your mod's widgets.

The default file returned is:

String FILENAME = "widgets.nbt";

//Fabric "config" directory.
File FILE_DIRECTORY = FabricLoader.getInstance().getConfigDir().toFile();

// This becomes same for all mods integrating dynamic hud
File WIDGETS_FILE = new File(FILE_DIRECTORY, FILENAME);

//Here is where we return the file.
default File getWidgetsFile() {
    return WIDGETS_FILE;
}
MyIntegration.java
    @Override
    public File getWidgetsFile() {
        return new File(FILE_DIRECTORY, "mymod_widgets.nbt");
    }
PreviousChanging default key bindNextRegistering Custom Widgets

Last updated 7 months ago

Was this helpful?