mirror of
https://github.com/love2d/love.git
synced 2026-08-13 17:10:54 +02:00
Display a warning if the game's version is incompatible.
This commit is contained in:
+28
-1
@@ -225,7 +225,7 @@ function love.init()
|
||||
local c = {
|
||||
title = "Untitled",
|
||||
author = "Unnamed",
|
||||
version = 0,
|
||||
version = love._version,
|
||||
screen = {
|
||||
width = 800,
|
||||
height = 600,
|
||||
@@ -315,6 +315,33 @@ function love.init()
|
||||
love._openConsole()
|
||||
end
|
||||
|
||||
-- Check the version
|
||||
local compat = false
|
||||
c.version = tostring(c.version)
|
||||
for i, v in ipairs(love._version_compat) do
|
||||
if c.version == v then
|
||||
compat = true
|
||||
end
|
||||
end
|
||||
if not compat then
|
||||
local major, minor, revision = c.version:match("^(%d+)%.(%d+)%.(%d+)$")
|
||||
if (not major or not minor or not revision) or (major ~= love._version_major and minor ~= love._version_minor) then
|
||||
local msg = "This game was made for a version that is probably incompatible.\n"..
|
||||
"The game might still work, but it is not guaranteed.\n" ..
|
||||
"Furthermore, this means one should not judge this game or the engine if not."
|
||||
print(msg)
|
||||
if love.graphics and love.timer and love.event then
|
||||
love.event.pump()
|
||||
love.graphics.setBackgroundColor(89, 157, 220)
|
||||
love.graphics.clear()
|
||||
love.graphics.print(msg, 70, 70)
|
||||
love.graphics.present()
|
||||
love.graphics.setBackgroundColor(0, 0, 0)
|
||||
love.timer.sleep(3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function love.run()
|
||||
|
||||
Reference in New Issue
Block a user