mirror of
https://github.com/TangentFoxy/love-pe.git
synced 2025-07-28 02:02:16 +00:00
Wrote icon changer GUI
This commit is contained in:
4
conf.lua
4
conf.lua
@@ -9,7 +9,7 @@ function love.conf(t)
|
||||
|
||||
t.audio.mixwithsystem = true -- Keep background music playing when opening LOVE (boolean, iOS and Android only)
|
||||
|
||||
t.window.title = "LÖVE-Icon-Changer" -- The window title (string)
|
||||
t.window.title = "LÖVE Icon-Changer" -- The window title (string)
|
||||
t.window.icon = nil -- Filepath to an image to use as the window's icon (string)
|
||||
t.window.width = 300 -- The window width (number)
|
||||
t.window.height = 200 -- The window height (number)
|
||||
@@ -26,7 +26,7 @@ function love.conf(t)
|
||||
t.window.x = nil -- The x-coordinate of the window's position in the specified display (number)
|
||||
t.window.y = nil -- The y-coordinate of the window's position in the specified display (number)
|
||||
|
||||
t.window = nil
|
||||
--t.window = nil
|
||||
|
||||
t.modules.audio = false -- Enable the audio module (boolean)
|
||||
t.modules.data = true -- Enable the data module (boolean)
|
||||
|
64
main.lua
64
main.lua
@@ -2,6 +2,8 @@ io.stdout:setvbuf("no")
|
||||
|
||||
local lovePE = require("love-pe")
|
||||
|
||||
local message = "Replaced Icon Successfully"
|
||||
|
||||
function love.load(args)
|
||||
love.graphics.setBackgroundColor(1,1,1,1)
|
||||
|
||||
@@ -20,11 +22,65 @@ function love.load(args)
|
||||
love.event.quit(0)
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
love.graphics.setColor(0,0,0,1)
|
||||
love.graphics.printf("Replaced Icon Successfully",0,200/2-5,300,"center")
|
||||
local exeFile, icoFile
|
||||
|
||||
--Override the testing function
|
||||
function love.load()
|
||||
love.graphics.setBackgroundColor(1,1,1,1)
|
||||
|
||||
message = "\nPlease drop the .exe and .ico files"
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
function love.filedropped(file)
|
||||
if file:getFilename():sub(-4,-1) == ".exe" then
|
||||
local ok, err = file:open("r")
|
||||
if not ok then
|
||||
message = "Failed to open the .exe file in read mode: "..(err or "unkown reason")
|
||||
return
|
||||
end
|
||||
message = exeFile and ".exe file updated successfully" or ""
|
||||
exeFile = file
|
||||
elseif file:getFilename():sub(-4,-1) == ".ico" then
|
||||
local ok, err = file:open("r")
|
||||
if not ok then
|
||||
message = "Failed to open the .ico file in read mode: "..(err or "unkown reason")
|
||||
return
|
||||
end
|
||||
message = icoFile and ".ico file updated successfully" or ""
|
||||
icoFile = file
|
||||
else return end
|
||||
|
||||
if exeFile and icoFile then
|
||||
local filename = exeFile:getFilename():sub(1,-5):gsub("\\","/") print(filename)
|
||||
local lastSlash = string.find(filename:reverse(),"/") print(lastSlash)
|
||||
if lastSlash then filename = filename:sub(#filename-lastSlash+2,-1) end print(filename)
|
||||
|
||||
local newFile = assert(love.filesystem.newFile(os.time().."_"..filename..".exe","w"))
|
||||
|
||||
lovePE.replaceIcon(exeFile,icoFile,newFile)
|
||||
|
||||
newFile:flush() newFile:close()
|
||||
exeFile:close() icoFile:close()
|
||||
exeFile, icoFile = false,false
|
||||
|
||||
message = "Replaced icon successfully\nDrop new .exe and .ico files"
|
||||
|
||||
love.system.openURL("file://"..love.filesystem.getSaveDirectory())
|
||||
elseif icoFile then
|
||||
message = message.."\nPlease drop the .exe file"
|
||||
elseif exeFile then
|
||||
message = message.."\nPlease drop the .ico file"
|
||||
else
|
||||
message = message.."\nPlease drop the .exe and .ico files"
|
||||
end
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
love.graphics.setColor(0,0,0,1)
|
||||
love.graphics.printf(message,0,200/2-20,300,"center")
|
||||
end
|
||||
|
||||
function love.quit()
|
||||
if exeFile then exeFile:close() end
|
||||
if icoFile then icoFile:close() end
|
||||
end
|
Reference in New Issue
Block a user