November Engine Features (Part 4): CastleSettings.xml, DPI scaling, cleaner component palette

Posted on

Castle Game Engine Editor - design with checkboxes, labels, edit boxes
  1. You can create a file called CastleSettings.xml to define some UI properties, like UI scaling and default font. This file allows your game and CGE editor to use the same settings (e.g. same default font). In your game just call Window.Container.LoadSettings('castle-data:/CastleSettings.xml'); to load these settings.

  2. DPI scaling is now better.

    TCastleWindowCustom.Dpi and TUIContainer.Dpi (“dots per inch”, aka “pixels per inch”) is now correct in all situations, on all backends. This includes GTK, WinAPI, X11 and LCL backends (in addition to the previous Android and iOS). It is also now valid for TCastleControl.

    Note that in some cases (desktops), this property is configurable by user, and actually means “a user preference how should the user interface be scaled”. Only in some cases (on mobile devices) it actually reflects the physical dimensions of the screen (pixels per physical inch).

    Moreover, you have a new option to scale user interface: usDpiScale. This is great for desktop applications. It follows the auto-scaling of Lazarus LCL applications.

  3. The “Castle” component palette in Lazarus is now much cleaner.

    It now contains only visual components that make most sense to be dropped on a Lazarus form: TCastleControl, TCastle2DControl, TCastleControlCustom. Plus non-visual dialog components.

    Previously, it contained a lot of other CGE components, that were not visualized at design-time in Lazarus. Having them on a component palette was probably more confusing than useful — e.g. you could drop TCastleButton on a Lazarus form, but (surprisingly) it’s a non-visual component for Lazarus (as far as Lazarus LCL is concerned, because it’s actually rendered using OpenGL in CGE).

    The new CGE editor is a solution to visually edit CGE user interface components, like TCastleButton.

    If you need backward compatibility, simply add {$I CASTLE_REGISTER_ALL_COMPONENTS_IN_LAZARUS} to the src/ Reinstall the CGE packages, and the components will appear back. But please note that this is a temporary workaround: In the future, you should either instantiate them by code, or design them using CGE editor and load as `UserInterfaceLoad(‘xxx.castle-user-interface’)`.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.