Skip to content

Commit f03565a

Browse files
committed
Final update logic fixes
1 parent 7e0ab3b commit f03565a

File tree

5 files changed

+37
-22
lines changed

5 files changed

+37
-22
lines changed

launcher/main.lua

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local downloader = require("downloader")
22

33
function love.load(args, unfilteredArgs)
44
if love.filesystem.mount("application.love", "") then
5+
_LAUNCHER = true
56
package.loaded.ssl = nil
67
package.loaded.https = nil
78
package.loaded.downloader = nil

release.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ copy /b %LOVE_DIR%\love.exe+,, %BUILD_DIR%
9494

9595
echo Customizing love.exe
9696
rcedit-x64 "%BUILD_DIR%\love.exe" --set-icon "%INSTALLER_DIR%\icon.ico"
97-
rcedit-x64 "%BUILD_DIR%\love.exe" --set-version-string "FileDescription" "M'Overlay"
9897
rcedit-x64 "%BUILD_DIR%\love.exe" --set-file-version "%VERSION%"
98+
rcedit-x64 "%BUILD_DIR%\love.exe" --set-version-string "FileDescription" "M'Overlay"
9999
rcedit-x64 "%BUILD_DIR%\love.exe" --set-version-string "InternalName" "%NAME%-%BIT%"
100100
rcedit-x64 "%BUILD_DIR%\love.exe" --set-version-string "OriginalFilename" "%EXE_NAME%"
101101

release.iss

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
;#define AppBuild
1515
;#define AppVersion GetVersionComponents("build/x64/m-overlay-x64.exe", AppMajor, AppMinor, AppRevision, AppBuild)
1616
;#define AppVersion Str(AppMajor) + "." + Str(AppMinor) + "." + Str(AppRevision)
17-
#define AppVersion 2.1.0
17+
#define AppVersion "2.1.0"
1818
PrivilegesRequired=lowest
1919
DisableWelcomePage=no
2020
AppName={#AppName}

source/modules/gui/panels/settings.lua

+18-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local json = require("serializer.json")
55
local notification = require("notification")
66
local music = require("music")
77
local overlay = require("overlay")
8+
local updater = require("updater")
89

910
require("extensions.math")
1011

@@ -340,15 +341,20 @@ This is also the same directory you use to place all your music for Melee.]])
340341
self.ABOUT = self.MAIN:AddTab("About", "textures/icon.png")
341342
self.ABOUT:SetBackgroundColor(color_purple)
342343

343-
local updater = require("updater")
344-
345344
self.ABOUT.LEFT = self.ABOUT:Add("Panel")
346345
self.ABOUT.LEFT:SetDrawPanel(false)
347346
self.ABOUT.LEFT:Dock(DOCK_LEFT)
348347
self.ABOUT.LEFT:SetWidth(160)
349348

350-
self.ABOUT.LEFT.Paint = function(this, w, h)
351-
updater.draw(w,h)
349+
if _LAUNCHER then
350+
self.ABOUT.LEFT.Paint = function(this, w, h)
351+
updater.draw(w,h)
352+
end
353+
else
354+
local ICON = self.ABOUT.LEFT:Add("Image")
355+
ICON:Dock(DOCK_FILL)
356+
ICON:DockMargin(32, 32, 32, 32)
357+
ICON:SetImage("textures/icon.png")
352358
end
353359

354360
self.ABOUT.RIGHT = self.ABOUT:Add("Panel")
@@ -365,13 +371,15 @@ This is also the same directory you use to place all your music for Melee.]])
365371
love.system.openURL(("https://github.com/bkacjios/m-overlay/releases/tag/v%s"):format(love.getMOverlayVersion()))
366372
end
367373

368-
local UPDATE = self.ABOUT.RIGHT:Add("ButtonIcon")
369-
UPDATE:SetImage("textures/gui/wrench.png")
370-
UPDATE:SetText("Check for update")
371-
UPDATE:Dock(DOCK_TOP)
374+
if _LAUNCHER then
375+
local UPDATE = self.ABOUT.RIGHT:Add("ButtonIcon")
376+
UPDATE:SetImage("textures/gui/wrench.png")
377+
UPDATE:SetText("Check for update")
378+
UPDATE:Dock(DOCK_TOP)
372379

373-
function UPDATE:OnClick()
374-
updater.check()
380+
function UPDATE:OnClick()
381+
updater.check()
382+
end
375383
end
376384

377385
self.ABOUT.SOCIALS = self.ABOUT.RIGHT:Add("Panel")

source/modules/updater.lua

+16-10
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@ local DOWNLOADED = 0
1212

1313
local STATUS = ""
1414

15-
local function splitVersion(tag)
15+
local function versionNumber(tag)
1616
-- Split into: major, minor, revision, hotfix
1717
if not tag then
18-
return 0, 0, 0, 0, ""
18+
return -1
1919
end
20-
local maj, min, rev, hot = tag:match("v?(%d+)%.(%d+)%.(%d+)(%a?)")
21-
return tonumber(maj), tonumber(min), tonumber(rev), hot
20+
local maj, min, rev, hot = tag:lower():match("v?(%d+)%.(%d+)%.(%d+)(%a?)")
21+
if not maj then
22+
return -1
23+
end
24+
local hotfix = 0
25+
if hot and #hot > 0 then
26+
-- 97 = a
27+
hotfix = string.byte(hot) - 96
28+
end
29+
return (tonumber(maj) * 10000) + (tonumber(min) * 1000) + (tonumber(rev) * 100) + hotfix
2230
end
2331

2432
do
@@ -54,20 +62,18 @@ do
5462
end
5563

5664
function updater.check()
57-
local version = love.getMOverlayVersion()
58-
59-
if version == "0.0.0" then return end
65+
local version = versionNumber(love.getMOverlayVersion())
6066

61-
local maj, min, rev, hot = splitVersion(version)
67+
if version <= 0 then return end
6268

6369
STATUS = "Checking for update.."
6470

6571
web.get("https://api.github.com/repos/bkacjios/m-overlay/releases/latest", function(event)
6672
if event.success and event.code == 200 then
6773
local response = json.decode(event.response)
6874
if (response.tag_name) then
69-
local rmaj, rmin, rrev, rhot = splitVersion(response.tag_name)
70-
if rmaj > maj or rmin > min or rev > rrev or rhot > hot then
75+
local updateVersion = versionNumber(response.tag_name)
76+
if updateVersion > 0 and updateVersion > version then
7177
log.warn("[UPDATER] Application update available")
7278
for id, asset in pairs(response.assets) do
7379
if asset.name == "application.love" then

0 commit comments

Comments
 (0)