Record Class AppConfig
java.lang.Object
java.lang.Record
cit244.app.AppConfig
public record AppConfig(int viewportW, int viewportH, RenderMode renderMode, int paramsFontSize, int hudFontSize, WindowMode windowMode, int fullscreenDisplay, String title)
extends Record
Immutable configuration for the app framework.
This record captures window sizing, rendering mode selection, and UI font sizing.
Use defaults() as a baseline, then derive variants with the helper methods
like windowed(int, int) or withFontSizes(int, int).
Notes:
viewportW/viewportHdescribe the main drawing viewport (not including any extra HUD region)fullscreenDisplayis only meaningful whenwindowMode == FULLSCREEN_DISPLAYtitlemay be null or blank to indicate "use the framework default"
-
Constructor Summary
ConstructorsConstructorDescriptionAppConfig(int viewportW, int viewportH, RenderMode renderMode, int paramsFontSize, int hudFontSize, WindowMode windowMode, int fullscreenDisplay, String title) Canonical constructor with validation and null-defaulting forwindowMode. -
Method Summary
Modifier and TypeMethodDescriptionstatic AppConfigdefaults()Returns the framework default configuration.final booleanIndicates whether some other object is "equal to" this one.Returns a copy of this config set to fullscreen mode.fullscreen(int display1Based) Returns a copy of this config set to fullscreen on a specific display.intReturns the value of thefullscreenDisplayrecord component.Returns a copy of this config set to fullscreen spanning displays (if supported).final inthashCode()Returns a hash code value for this object.intReturns the value of thehudFontSizerecord component.booleanReturns true if this configuration uses a fullscreen window mode.static AppConfigof(int viewportW, int viewportH) Convenience factory that returns a WINDOWED config with the given viewport size, based ondefaults().intReturns the value of theparamsFontSizerecord component.Returns the value of therenderModerecord component.title()Returns the value of thetitlerecord component.final StringtoString()Returns a string representation of this record class.intReturns the value of theviewportHrecord component.intReturns the value of theviewportWrecord component.windowed(int viewportW, int viewportH) Returns a copy of this config set to WINDOWED with the given viewport size.Returns the value of thewindowModerecord component.withFontSizes(int paramsSize, int hudSize) Returns a copy with both parameter and HUD font sizes updated.withHudFontSize(int size) Returns a copy with the HUD font size updated.withParamsFontSize(int size) Returns a copy with the parameter UI font size updated.withRenderMode(RenderMode renderMode) Returns a copy with the render mode updated.Returns a copy with the window title updated.
-
Constructor Details
-
AppConfig
public AppConfig(int viewportW, int viewportH, RenderMode renderMode, int paramsFontSize, int hudFontSize, WindowMode windowMode, int fullscreenDisplay, String title) Canonical constructor with validation and null-defaulting forwindowMode.Not intended for direct use. Prefer
defaults()orof(int,int).- Throws:
IllegalArgumentException- if viewport dimensions or font sizes are non-positive, or iffullscreenDisplay < 1when using FULLSCREEN_DISPLAYNullPointerException- ifrenderModeis null
-
-
Method Details
-
of
Convenience factory that returns a WINDOWED config with the given viewport size, based ondefaults().- Parameters:
viewportW- viewport width in pixels (positive)viewportH- viewport height in pixels (positive)- Returns:
- a windowed AppConfig with the requested viewport dimensions
-
defaults
Returns the framework default configuration.- Returns:
- the default AppConfig
-
isFullscreen
public boolean isFullscreen()Returns true if this configuration uses a fullscreen window mode.- Returns:
- true for any fullscreen mode, false for WINDOWED
-
windowed
Returns a copy of this config set to WINDOWED with the given viewport size.- Parameters:
viewportW- viewport width in pixels (positive)viewportH- viewport height in pixels (positive)- Returns:
- a new AppConfig in WINDOWED mode
-
fullscreen
Returns a copy of this config set to fullscreen mode.- Returns:
- a new AppConfig in FULLSCREEN_PREF mode
-
fullscreen
Returns a copy of this config set to fullscreen on a specific display.- Parameters:
display1Based- 1-based display index- Returns:
- a new AppConfig in FULLSCREEN_DISPLAY mode
-
fullscreenSpan
Returns a copy of this config set to fullscreen spanning displays (if supported).You probably don't want this unless you have multiple monitors and a beefy computer.
- Returns:
- a new AppConfig in FULLSCREEN_SPAN mode
-
withFontSizes
Returns a copy with both parameter and HUD font sizes updated.- Parameters:
paramsSize- params UI font size (positive)hudSize- HUD font size (positive)- Returns:
- a new AppConfig with updated font sizes
-
withParamsFontSize
Returns a copy with the parameter UI font size updated.- Parameters:
size- params UI font size (positive)- Returns:
- a new AppConfig with updated params font size
-
withHudFontSize
Returns a copy with the HUD font size updated.- Parameters:
size- HUD font size (positive)- Returns:
- a new AppConfig with updated HUD font size
-
withRenderMode
Returns a copy with the render mode updated.- Parameters:
renderMode- the new render mode (non-null)- Returns:
- a new AppConfig with updated render mode
-
withTitle
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
viewportW
public int viewportW()Returns the value of theviewportWrecord component.- Returns:
- the value of the
viewportWrecord component
-
viewportH
public int viewportH()Returns the value of theviewportHrecord component.- Returns:
- the value of the
viewportHrecord component
-
renderMode
Returns the value of therenderModerecord component.- Returns:
- the value of the
renderModerecord component
-
paramsFontSize
public int paramsFontSize()Returns the value of theparamsFontSizerecord component.- Returns:
- the value of the
paramsFontSizerecord component
-
hudFontSize
public int hudFontSize()Returns the value of thehudFontSizerecord component.- Returns:
- the value of the
hudFontSizerecord component
-
windowMode
Returns the value of thewindowModerecord component.- Returns:
- the value of the
windowModerecord component
-
fullscreenDisplay
public int fullscreenDisplay()Returns the value of thefullscreenDisplayrecord component.- Returns:
- the value of the
fullscreenDisplayrecord component
-
title
Returns the value of thetitlerecord component.- Returns:
- the value of the
titlerecord component
-