From 8a1618c034a70971f6b8890e74d5b3f5f6a12ea8 Mon Sep 17 00:00:00 2001 From: RamiLego4Game Date: Thu, 10 May 2018 11:22:57 +0300 Subject: [PATCH] Start the work on the icon changer --- conf.lua | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ icon-changer.lua | 42 +++++++++++++++++++++++++++++++++++++++++ main.lua | 26 +++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 conf.lua create mode 100644 icon-changer.lua create mode 100644 main.lua diff --git a/conf.lua b/conf.lua new file mode 100644 index 0000000..01b43ea --- /dev/null +++ b/conf.lua @@ -0,0 +1,49 @@ +function love.conf(t) + t.identity = "love-exe-icon-changer"-- The name of the save directory (string) + t.appendidentity = false -- Search files in source directory before save directory (boolean) + t.version = "11.1" -- The LÖVE version this game was made for (string) + t.console = false -- Attach a console (boolean, Windows only) + t.accelerometerjoystick = false -- Enable the accelerometer on iOS and Android by exposing it as a Joystick (boolean) + t.externalstorage = true -- True to save files (and read from the save directory) in external storage on Android (boolean) + t.gammacorrect = false -- Enable gamma-correct rendering, when supported by the system (boolean) + + 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.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) + t.window.borderless = false -- Remove all border visuals from the window (boolean) + t.window.resizable = false -- Let the window be user-resizable (boolean) + t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) + t.window.minheight = 1 -- Minimum window height if the window is resizable (number) + t.window.fullscreen = false -- Enable fullscreen (boolean) + t.window.fullscreentype = "desktop" -- Choose between "desktop" fullscreen or "exclusive" fullscreen mode (string) + t.window.vsync = 1 -- Vertical sync mode (number) + t.window.msaa = 0 -- The number of samples to use with multi-sampled antialiasing (number) + t.window.display = 1 -- Index of the monitor to show the window in (number) + t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean) + 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.modules.audio = false -- Enable the audio module (boolean) + t.modules.data = true -- Enable the data module (boolean) + t.modules.event = true -- Enable the event module (boolean) + t.modules.font = true -- Enable the font module (boolean) + t.modules.graphics = true -- Enable the graphics module (boolean) + t.modules.image = true -- Enable the image module (boolean) + t.modules.joystick = false -- Enable the joystick module (boolean) + t.modules.keyboard = true -- Enable the keyboard module (boolean) + t.modules.math = true -- Enable the math module (boolean) + t.modules.mouse = true -- Enable the mouse module (boolean) + t.modules.physics = false -- Enable the physics module (boolean) + t.modules.sound = false -- Enable the sound module (boolean) + t.modules.system = true -- Enable the system module (boolean) + t.modules.thread = true -- Enable the thread module (boolean) + t.modules.timer = true -- Enable the timer module (boolean), Disabling it will result 0 delta time in love.update + t.modules.touch = true -- Enable the touch module (boolean) + t.modules.video = false -- Enable the video module (boolean) + t.modules.window = true -- Enable the window module (boolean) +end \ No newline at end of file diff --git a/icon-changer.lua b/icon-changer.lua new file mode 100644 index 0000000..d2ce057 --- /dev/null +++ b/icon-changer.lua @@ -0,0 +1,42 @@ +--love-icon-changer library by RamiLego4Game (Rami Sabbagh) +--[[ +- Usage: +local iconChanger = require("icon-changer") + +local icodata = iconChanger.extractIcon(exeFile) +]] + +local bit = require("bit") + +local bor,band,lshift,rshift = bit.bor,bit.band,bit.lshift,bit.rshift + +--==Internal Functions==-- + +local function readNumber(str,bigEndian) + local num = 0 + + if bigEndian then str = str:reverse() end + + for char in string.gmatch(str,".") do + local byte = string.byte(char) + + num = lshift(num,8) + num = bor(num, byte) + end + + return num +end + +--==User API==-- + +local icapi = {} + +function icapi.extractIcon(exeFile) + + --DOS Header + if exeFile:read(2) ~= "MZ" then return error("This is not an executable file !") end + + +end + +return icapi \ No newline at end of file diff --git a/main.lua b/main.lua new file mode 100644 index 0000000..1733969 --- /dev/null +++ b/main.lua @@ -0,0 +1,26 @@ + +local iconChanger = require("icon-changer") + +function love.load(args) + love.graphics.setBackgroundColor(1,1,1,1) + + local exeFile = assert(love.filesystem.newFile("love.exe","r")) + + local iconData = iconChanger.extractIcon(exeFile) + + if iconData then + love.filesystem.write("Extracted Icon.ico",iconData) + love.system.openURL("file://"..love.filesystem.getSaveDirectory()) + end + + love.event.quit(0) +end + +function love.draw() + love.graphics.setColor(0,0,0,1) + love.graphics.printf("Icon extracted",0,200/2-5,300,"center") +end + +function love.update(dt) + +end \ No newline at end of file