Skip to content

Commit

Permalink
option to disable tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Dec 9, 2023
1 parent 70f5600 commit a2a5fa0
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions sources/include/cage-engine/guiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ namespace cage
AssetManager *assetManager = nullptr;
ProvisionalGraphics *provisionalGraphics = nullptr;
uint32 skinsCount = 4;
bool tooltipsEnabled = true;
};

CAGE_ENGINE_API Holder<GuiManager> newGuiManager(const GuiManagerCreateConfig &config);
Expand Down
1 change: 1 addition & 0 deletions sources/include/cage-simple/guiInWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace cage
Entity *cameraEntity = nullptr; // optional
Vec2i resolution = Vec2i(1920, 1080);
Real retinaScale = 4;
bool tooltipsEnabled = true;
};

Holder<GuiInWorld> newGuiInWorld(const GuiInWorldCreateConfig &config);
Expand Down
2 changes: 1 addition & 1 deletion sources/libengine/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace cage
{
GuiImpl::GuiImpl(const GuiManagerCreateConfig &config) : assetOnDemand(newAssetOnDemand(config.assetManager)), assetMgr(config.assetManager), provisionalGraphics(config.provisionalGraphics)
GuiImpl::GuiImpl(const GuiManagerCreateConfig &config) : assetOnDemand(newAssetOnDemand(config.assetManager)), assetMgr(config.assetManager), provisionalGraphics(config.provisionalGraphics), ttEnabled(config.tooltipsEnabled)
{
#define GCHL_GENERATE(T) entityMgr->defineComponent(CAGE_JOIN(Gui, CAGE_JOIN(T, Component))());
CAGE_EVAL_SMALL(CAGE_EXPAND_ARGS(GCHL_GENERATE, GCHL_GUI_COMMON_COMPONENTS, GCHL_GUI_WIDGET_COMPONENTS, GCHL_GUI_LAYOUT_COMPONENTS));
Expand Down
1 change: 1 addition & 0 deletions sources/libengine/gui/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ namespace cage

std::vector<SkinData> skins;

bool ttEnabled = false;
Vec2 ttLastMousePos; // points
Real ttMouseTraveledDistance; // points
uint64 ttTimestampMouseMove = 0; // last time when mouse moved too much
Expand Down
3 changes: 3 additions & 0 deletions sources/libengine/gui/tooltips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ namespace cage

void GuiImpl::updateTooltips()
{
if (!ttEnabled)
return;

auto candidate = findTopWidget(this);

const uint64 currentTime = applicationTime();
Expand Down
1 change: 1 addition & 0 deletions sources/libsimple/guiInWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace cage
GuiManagerCreateConfig cfg;
cfg.assetManager = engineAssets();
cfg.provisionalGraphics = +engineProvisonalGraphics();
cfg.tooltipsEnabled = config.tooltipsEnabled;
guiMan = newGuiManager(cfg);
guiMan->outputResolution(config.resolution);
guiMan->outputRetina(config.retinaScale);
Expand Down

0 comments on commit a2a5fa0

Please sign in to comment.