Display a warning if the game's version is incompatible.

This commit is contained in:
Bart van Strien
2011-10-03 00:52:44 +02:00
parent bd2172f826
commit 4f70742875
3 changed files with 102 additions and 2 deletions
+28 -1
View File
@@ -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()