QtCraft API C++ classes QML types Handbook

QcUiScale Namespace

The size of the HUD and the screens (decisions E-725, E-875): the player's choice (a step from 75 % to 200 %) times the window's factor, which grows the UI with large windows, and how far that may go in a window before the UI would no longer fit. More...

Header: #include <clientcore/settings/QcUiScale.h>

Types

enum class Step { Auto, Percent75, Percent100, Percent125, Percent150, …, Percent200 }

Variables

const QcUiScale::Step defaultStep
const QSizeF hudDesignSize
const double maxWindowFactor
const QSizeF screenDesignSize
const QSizeF windowReferenceSize

Functions

double fittedFactor(double requested, QSizeF window, QSizeF designSize)
std::optional<double> fixedFactor(QcUiScale::Step step)
std::optional<QcUiScale::Step> fromName(const QString &text)
QString name(QcUiScale::Step step)
double requestedFactor(QcUiScale::Step step, QSizeF window)
double windowFactor(QSizeF window)

Detailed Description

Pure functions; QcUiScaling applies them for QML.

Type Documentation

enum class QcUiScale::Step

The choices of the settings screen, stored as "uiScale" ("auto", "75", …, "200").

Auto is the choice of older settings files and means 100 % (the window's factor applies to every step).

ConstantValueDescription
QcUiScale::Step::Auto0100 %, from older settings files
QcUiScale::Step::Percent75175 %
QcUiScale::Step::Percent1002100 %
QcUiScale::Step::Percent1253125 %
QcUiScale::Step::Percent1504150 %
QcUiScale::Step::Percent1755175 %
QcUiScale::Step::Percent2006200 %

Variable Documentation

const QcUiScale::Step QcUiScale::defaultStep

The step of new settings.

const QSizeF QcUiScale::hudDesignSize

The HUD needs less room (hotbar, status rows, one hint line), so it may grow further.

const double QcUiScale::maxWindowFactor

Largest window factor.

const QSizeF QcUiScale::screenDesignSize

The window the screens are laid out for at 100 % (Main.qml's minimum size): a larger factor needs a window that much larger.

const QSizeF QcUiScale::windowReferenceSize

The window whose UI the steps mean as they are (factor 1.0): about a MacBook's screen in logical pixels (1512 x 982), where the screens were designed. Window sizes are logical pixels: the system's display scaling (Retina, Windows and Linux scale settings) is already in them, so the factor adds nothing for density; it makes up for large monitors at 100 % display scaling (2560 x 1440: 1.5).

Function Documentation

double QcUiScale::fittedFactor(double requested, QSizeF window, QSizeF designSize)

Returns requested, at most as large as lets a UI laid out for designSize fit into window (rounded down to an eighth); 100 % and less always stay, so a window below the design size keeps today's layout rather than shrinking.

std::optional<double> QcUiScale::fixedFactor(QcUiScale::Step step)

Returns the factor of step relative to the window, 0.75 … 2.0; Auto has no factor of its own (std::nullopt, used as 1.0).

std::optional<QcUiScale::Step> QcUiScale::fromName(const QString &text)

Returns the step named text (name()); nothing for an unknown name.

QString QcUiScale::name(QcUiScale::Step step)

Returns the name of step in the settings: "auto", "75", …, "200".

double QcUiScale::requestedFactor(QcUiScale::Step step, QSizeF window)

Returns the factor of step in a window of this logical size: the step's factor times windowFactor.

double QcUiScale::windowFactor(QSizeF window)

Returns the factor of window: its logical size against windowReferenceSize (the smaller ratio), rounded to an eighth and kept within 1.0 … maxWindowFactor (a small window never shrinks the UI).