Page 3 of 7

Re: [WIP]BeatFever Mania ~ osu! Engine reimplementation

Posted: Thu Mar 31, 2016 7:32 pm
by Nixola
Some guy on IRC wrote:don't give me credit

Re: [WIP]BeatFever Mania ~ osu! Engine reimplementation

Posted: Thu Mar 31, 2016 7:46 pm
by zorg
Sulunia wrote:Does love even have a IRC? Where? :o:
https://love2d.org/ wrote:Community: (...) There is also an IRC channel: #love@irc.oftc.net.

Re: [WIP]BeatFever Mania ~ osu! Engine reimplementation

Posted: Thu Mar 31, 2016 7:54 pm
by Davidobot
I'm not going to let down:

Code: Select all

local ffi = require('ffi')
ffi.cdef('int PHYSFS_mount(const char *newDir, const char *mountPoint, int appendToPath);')
local liblove = ffi.os == 'Windows' and ffi.load('love') or ffi.C

function love.filedropped(file)
  local path = file:getFilename()
  extractZip(true, path)
end

local lfs = love.filesystem

local function enu(folder, saveDir)
    local filesTable = lfs.getDirectoryItems(folder)
	if saveDir ~= "" and not lfs.isDirectory(saveDir) then lfs.createDirectory(saveDir) end
   
    for i,v in ipairs(filesTable) do
		local file = folder.."/"..v
		local saveFile = saveDir.."/"..v
		if saveDir == "" then saveFile = v end
      
        if lfs.isDirectory(file) then
			lfs.createDirectory(saveFile)
            enu(file, saveFile)
        else
			lfs.write(saveFile, tostring(lfs.read(file)))
		end
    end
end

function extractZIP(tech, file, dir, delete)
	local dir = dir or ""
	local temp = tostring(love.math.random(1000, 2000))
	if tech then
	success = liblove.PHYSFS_mount(path, temp, false)
	else
	success = lfs.mount(file, temp)
	end
	
        if success then enu(temp, dir) end
	lfs.unmount(file)
	if delete then lfs.remove(file) end
end
The tech variable checks if the complex lovelib call is needed or not, it is meant to be true only if the file is to be extracted from drop.

Re: [WIP]BeatFever Mania ~ osu! Engine reimplementation

Posted: Thu Mar 31, 2016 8:09 pm
by Sulunia
Davidobot wrote:I'm not going to let down:

Code: Select all

local ffi = require('ffi')
ffi.cdef('int PHYSFS_mount(const char *newDir, const char *mountPoint, int appendToPath);')
local liblove = ffi.os == 'Windows' and ffi.load('love') or ffi.C

function love.filedropped(file)
  local path = file:getFilename()
  extractZip(true, path)
end

local lfs = love.filesystem

local function enu(folder, saveDir)
    local filesTable = lfs.getDirectoryItems(folder)
	if saveDir ~= "" and not lfs.isDirectory(saveDir) then lfs.createDirectory(saveDir) end
   
    for i,v in ipairs(filesTable) do
		local file = folder.."/"..v
		local saveFile = saveDir.."/"..v
		if saveDir == "" then saveFile = v end
      
        if lfs.isDirectory(file) then
			lfs.createDirectory(saveFile)
            enu(file, saveFile)
        else
			lfs.write(saveFile, tostring(lfs.read(file)))
		end
    end
end

function extractZIP(tech, file, dir, delete)
	local dir = dir or ""
	local temp = tostring(math.random(1000, 2000))
	if tech then
	success = liblove.PHYSFS_mount(path, temp, false)
	else
	success = lfs.mount(file, temp)
	end
	
        if success then enu(temp, dir) end
	lfs.unmount(file)
	if delete then lfs.remove(file) end
end
The tech variable checks if the complex lovelib call is needed or not, it is meant to be true only if the file is to be extracted from drop.
Now that's handy. Allright, the next "release" here will have drag and drop to install and a revamped selection screen UI.
Thanks to everybody so far! I'll be back with news soon enough. :3

Re: [WIP]BeatFever Mania ~ osu! Engine reimplementation

Posted: Thu Mar 31, 2016 8:23 pm
by zorg
Davidobot wrote:I'm not going to let down:

Code: Select all

local temp = tostring(math.random(1000, 2000))
Not gonna run around, and will just say, use love.math.random instead, for various reasons, including the here important fact that it's actually seeded in love.run, unlike lua's math.random.

Re: [WIP]BeatFever Mania ~ osu! Engine reimplementation

Posted: Thu Mar 31, 2016 8:33 pm
by Davidobot
zorg wrote:
Davidobot wrote:I'm not going to let down:

Code: Select all

local temp = tostring(math.random(1000, 2000))
Not gonna run around, and will just say, use love.math.random instead, for various reasons, including the here important fact that it's actually seeded in love.run, unlike lua's math.random.
To be fair, that's just a stupid way to ensure that there are no folder overlaps? If that makes sense. Anyways, I switched it out. This code was written before love.math.random was introduced, so it was justifiable. :P

EDIT: No it was not, filesystem.mount and love.math.random were introduced at the same time. No excuse :|

Re: [WIP]BeatFever Mania ~ osu! Engine reimplementation

Posted: Thu Mar 31, 2016 9:29 pm
by Sulunia
A wip to you guys:
Image
Once the UI is in place, i'll cleanup the code and implement drag and drop install.

Shouldn't the code be cleaned up first? I guess, but since it'll get messy again, lemme finish EVERYTHING so i refactor just once xD

Re: [WIP]BeatFever Mania ~ osu! Engine reimplementation

Posted: Sat Apr 02, 2016 9:00 am
by Davidobot
Just want to let you know that https://github.com/danielpontello/beatfever is no longer a thing..

Re: [WIP]BeatFever Mania ~ osu! Engine reimplementation

Posted: Sat Apr 02, 2016 12:53 pm
by zorg
C&D?

Re: [WIP]BeatFever Mania ~ osu! Engine reimplementation

Posted: Sun Apr 03, 2016 5:47 pm
by Sulunia
Davidobot wrote:Just want to let you know that https://github.com/danielpontello/beatfever is no longer a thing..
Oops.

We forgot to unprivate the repo. I'll let him know.

@edit

Seens like github seriously has an issue with opening private repositories to the public. I guess i'll have to recreate it on my own profile :shock: