Constantly updating the window title can lead to issues on some systems and therefore is discouraged.
How often is "constantly"? What could be considered a safe minimum time between setTitle calls? (And what sort of issues emerge?)
My game changes its window title based on what area you're in. In some situations, the player (of their own volition) might be able to straddle between areas 2-3 times per second, which causes the window title to change each time. Would this generally cause issues?
Without vsync, i had a game freeze my OS due to setTitle being called hundreds of times per second... granted it was back on Win7, but still not a good thing.
That would be a potential issue; recommended minimum time i can only suggest something not faster than 1/4 seconds simply because that should be enough for the most dynamically updating windows title you might need. That said, with your explanation, your usecase should be fine.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
This sounds related to "event de-bouncing" (edit: "throttling" actually, not "de-bouncing") that people do in JavaScript, to not clog up the interpreter when you're flooded with events and each event is costly to process: https://www.inkoop.io/blog/debounce-and ... t-edition/
I think zorg's suggestion of a constant update rate (refreshing the window title at even timesteps, say, every 1 second), is probably the safest way.
I'm not a big fan of the proposal to use a constant update rate, as it wil cause a bit of lag in the display of the updated title. Instead, a cooldown timer will provide instant reaction time in all situations except those that are potential trouble makers.
local currentTitle = "\0"
local newTitle = currentTitle
local titleCoolDown = 0.25 -- Cool-down time
-- Initialize the timer to expired
local titleTimer = love.timer.getTime()
local function setTitle(title)
newTitle = title
if title == currentTitle then return end
local time = love.timer.getTime()
if time < titleTimer then return end
currentTitle = title
love.window.setTitle(title)
titleTimer = time + titleCoolDown
end
function love.update()
-- Add this somewhere within your actual love.update()
setTitle(newTitle)
end
ncrecc wrote: ↑Fri Aug 16, 2024 8:25 pm
My game changes its window title based on what area you're in.
In another direction, design-wise, I can't remember playing a game that did that kind of thing (having important info outside of the game screen).
Isn't there a way for the text to be on screen, in a way that fits with your game? This would make the text a graphic like any other, and extremely fast to draw. You can have it at the top of the screen like a notification banner, or a tooltip that follows the player, or something else.
Window titles are a bad idea to place information in because you never know what window management your users have and how it will be cut away.
Does the user even have a Title?
This also affects how changable it is, different OS and WMs and such, likely you can do framerate speed for 90% of users but also may end up crashing on the rest 10%.