more work

This commit is contained in:
Ryan Ward 2020-02-17 20:33:58 -05:00
parent f0f2f9b8c7
commit 7ac51cb6e5
12 changed files with 207 additions and 32 deletions

View File

@ -59,9 +59,9 @@ end
function gui:canPress() function gui:canPress()
local ref = self local ref = self
if self.ClipReference then ref = self.ClipReference end if self.ClipReference then ref = self.ClipReference end
if self.Visible==true and self:parentVisible() and not(self:isBeingCovering()) then if self:isVisible() and not(self:isBeingCovering()) then
local x,y = love.mouse.getX(),love.mouse.getY() local x,y = love.mouse.getX(),love.mouse.getY()
if (x > ref.x and x < ref.x+ref.width and y > ref.y and y < ref.y+ref.height) and (x > self.x and x < self.x+self.width and y > self.y and y < self.y+self.height and self:Clickable() and (self:eventable() or self:touchable())) then if (x > ref.x and x < ref.x+ref.width and y > ref.y and y < ref.y+ref.height) and (self:eventable() or self:touchable()) then
return true return true
else else
return false return false

View File

@ -34,6 +34,11 @@ end)
local cache = {} local cache = {}
function gui:SetImage(i,inthread,backup) function gui:SetImage(i,inthread,backup)
if not i then return end if not i then return end
if self.scale.size.x~=0 or self.scale.size.y~=0 then
gui.OnScreenSizeChanged(function()
multi:newAlarm(.01):OnRing(function() self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth) end)
end)
end
if type(i) == "userdata" and i:type() == "Image" then if type(i) == "userdata" and i:type() == "Image" then
self.Image=i self.Image=i
self.ImageHeigth=self.Image:getHeight() self.ImageHeigth=self.Image:getHeight()
@ -51,7 +56,6 @@ function gui:SetImage(i,inthread,backup)
end end
DownloadImage(i,hash).connect(function(img) DownloadImage(i,hash).connect(function(img)
if img == "noimage" then if img == "noimage" then
print("Need backup")
if backup then if backup then
return self:SetImage(backup) return self:SetImage(backup)
else else

View File

@ -0,0 +1,11 @@
function gui:isVisible()
if self.Visible == false then return false end
local parent = self.Parent
while parent~=_GuiPro do
if parent.Visible == false then
return false
end
parent = parent.Parent
end
return true
end

View File

@ -60,6 +60,13 @@ function gui:newScrollMenu(name)
self.ref = ref self.ref = ref
end end
temp.max = 40 temp.max = 40
function temp:reset()
temp.max = 40
for i,v in pairs(temp.list) do
v:Destroy()
end
temp.list = {}
end
function temp:addItem(text, height, padding, obj) function temp:addItem(text, height, padding, obj)
local padding = padding or 10 local padding = padding or 10
local height = height or 30 local height = height or 30

View File

@ -67,10 +67,16 @@ gui.LoadAll("GuiManager/Drawing")
-- End of Load -- End of Load
gui:respectHierarchy() gui:respectHierarchy()
_GuiPro.width,_GuiPro.height=love.graphics.getDimensions() _GuiPro.width,_GuiPro.height=love.graphics.getDimensions()
gui.OnScreenSizeChanged = multi:newConnection()
multi:newThread("GuiManager",function() multi:newThread("GuiManager",function()
local x,y
while true do while true do
x,y = love.graphics.getDimensions()
thread.sleep(.01) thread.sleep(.01)
_GuiPro.width,_GuiPro.height=love.graphics.getDimensions() _GuiPro.width,_GuiPro.height=love.graphics.getDimensions()
if x~=_GuiPro.width or y~=_GuiPro.height then
gui.OnScreenSizeChanged:Fire(x,y,_GuiPro.width,_GuiPro.height)
end
end end
end) end)
multi:onDraw(function() multi:onDraw(function()

27
app.lua
View File

@ -16,8 +16,16 @@ local spd = 7
-- keep at top -- keep at top
local head local head
function app.createPage(name,path) function app.createPage(name,path)
local page = require("pages/"..path).init(app.workspace:newFullFrame(name),app.workspace) local page = app.workspace:newFullFrame(name)
page.Color = theme.menu local bg = page:newImageLabel("images/bg.jpg",0,0,0,0,0,0,1,1)
multi:newThread(function()
thread.hold(function()
return bg.Image
end)
bg:repeatImage("repeat","repeat")
end)
bg.Color = theme.menu
require("pages/"..path).init(page,app.workspace)
table.insert(app.pages,page) table.insert(app.pages,page)
page.Visible = false page.Visible = false
function page:Goto() function page:Goto()
@ -28,27 +36,25 @@ function app.createPage(name,path)
end end
local button local button
if head == app.header then if head == app.header then
button = head:newTextButton(name,name,5,0,100,60) button = head:newTextLabel(name,name,5,0,100,60)
else else
button = head:newTextButton(name,name,5,0,100,60,1) button = head:newTextLabel(name,name,5,0,100,60,1)
end end
button:centerY() button:centerY()
head = button head = button
button:fitFont() button:fitFont()
button.Color = theme.menuitem button.Color = theme.menuitem
button:OnReleased(function() button:OnReleased(function()
page:Goto() page:Goto()
end) end)
print("done") return page, button
return page
end end
local function init(a) local function init(a)
love.filesystem.setIdentity("MangaPro") love.filesystem.setIdentity("MangaPro")
app.workspace = a:newFrame(0,headersize,0,-headersize,0,0,1,1)
app.header = a:newFrame(0,0,0,headersize,0,0,1) app.header = a:newFrame(0,0,0,headersize,0,0,1)
head = app.header head = app.header
app.header.Color = theme.header app.header.Color = theme.header
app.workspace = a:newFrame(0,headersize,0,-headersize,0,0,1,1)
app.menu = a:newFrame(0,headersize,menusize,-headersize,0,0,0,1) app.menu = a:newFrame(0,headersize,menusize,-headersize,0,0,0,1)
app.menu.Color = theme.menu app.menu.Color = theme.menu
app.menu:OnReleasedOuter(function(b,self) app.menu:OnReleasedOuter(function(b,self)
@ -59,8 +65,9 @@ local function init(a)
app.workspace.Color = Color.Black app.workspace.Color = Color.Black
app.menu.Visible = false app.menu.Visible = false
local search = app.createPage("Search","search") local search = app.createPage("Search","search")
app.createPage("Favorites","favs") local favs = app.createPage("Favorites","favs")
--search:Goto() search:Goto()
--app.createPage("Favorites","favs")
end end
return { return {
init = init init = init

BIN
images/bg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
images/star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
images/unstar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -35,6 +35,7 @@ m.getManga = queue:newFunction("queue",function(title)
local http = require("socket.http") local http = require("socket.http")
local manga = http.request(title.Link) local manga = http.request(title.Link)
local tab = {} local tab = {}
tab.Link = title.Link
tab.Cover = manga:match([[<div id="mangaimg"><img src="(.-)"]]) tab.Cover = manga:match([[<div id="mangaimg"><img src="(.-)"]])
tab.Title = manga:match([[Name:.-"aname">%s*([^<]*)]]) tab.Title = manga:match([[Name:.-"aname">%s*([^<]*)]])
tab.AltTitle = manga:match([[Alternate Name:.-<td>([^<]*)]]) tab.AltTitle = manga:match([[Alternate Name:.-<td>([^<]*)]])

View File

@ -135,14 +135,13 @@ function multi:newSystemThreadedJobQueue(n)
end end
end end
end) end)
print("Cores: ",c.cores)
for i=1,c.cores do for i=1,c.cores do
multi:newSystemThread("JobQueue_"..jqc.."_worker_"..i,function(jqc) multi:newSystemThread("JobQueue_"..jqc.."_worker_"..i,function(jqc)
local multi, thread = require("multi"):init() local multi, thread = require("multi"):init()
require("love.timer")
local function atomic(channel) local function atomic(channel)
return channel:pop() return channel:pop()
end end
require("love.timer")
local clock = os.clock local clock = os.clock
local funcs = THREAD.createStaticTable("__JobQueue_"..jqc.."_table") local funcs = THREAD.createStaticTable("__JobQueue_"..jqc.."_table")
local queue = love.thread.getChannel("__JobQueue_"..jqc.."_queue") local queue = love.thread.getChannel("__JobQueue_"..jqc.."_queue")

View File

@ -50,23 +50,140 @@ local chars = {"#"}
for i=65,90 do for i=65,90 do
table.insert(chars,string.char(i)) table.insert(chars,string.char(i))
end end
local onNav = false
function saveFavs(favs)
local f = bin.new()
f:addBlock(favs or {})
f:tofile("favs.dat")
end
function getFavs()
if bin.fileExists("favs.dat") then
return bin.load("favs.dat"):getBlock("t")
else
return {}
end
end
local function init(page,workspace) local function init(page,workspace)
local favs = getFavs()
local holder = page:newFrame("",15,80,-30,-95,0,0,1,1) local holder = page:newFrame("",15,80,-30,-95,0,0,1,1)
local nav = page:newFrame(10,10,-20,40,0,0,1)
local SBL = page:newFrame(0,55,0,40,0,0,1)
local mangaViewer = page:newFrame(0,0,0,0,.1,.1,.8,.8)
mangaViewer.Visible = false
local cover = mangaViewer:newImageLabel(nil,10,10,mangaSize.x,mangaSize.y)
local desc = mangaViewer:newTextLabel("","",15+mangaSize.x,10,-25-mangaSize.x,-13,0,0,1,.5)
local chaps = mangaViewer:newTextLabel("","",15+mangaSize.x,3,-25-mangaSize.x,-13,0,.5,1,.5)
local dets = mangaViewer:newTextLabel("","",10,15+mangaSize.y,mangaSize.x,-25-mangaSize.y,0,0,0,1)
local menu = chaps:newScrollMenu("Chapters")
local goback = mangaViewer:newTextLabel("Back","Back",0,5,80,40,0,1)
goback:fitFont()
goback:OnUpdate(function()
goback:centerX()
end)
goback:OnReleased(function()
multi:newThread(function()
thread.sleep(.1)
mangaViewer.Visible = false
end)
end)
goback.Color = theme.button
function setViewer(manga)
menu:reset()
mangaViewer.Visible = true
mangaViewer:setRoundness(10,10,60)
mangaViewer.BorderSize = 2
mangaViewer.Color = theme.menu
cover:SetImage(manga.Cover,nil,"images/notfound.png")
desc.text = manga.Desc
desc.TextFormat = "left"
desc.XTween = 2
dets.text = "Title: " .. manga.Title .. "\n" ..
"Author: " .. manga.Author .. "\n" ..
"Artist: " .. manga.Artist .. "\n" ..
"ReadingDir: " .. manga.ReadingDir .. "\n" ..
"Chapters: " .. #manga.Chapters .. "\n" ..
"Status: " .. manga.Status
dets.XTween = 2
dets.TextFormat = "left"
gui.massMutate({
Visibility = 0,
BorderSize = 0,
},desc,chaps,dets)
menu.BorderSize = 0
menu.scrollM = 4
menu.scroll.Color = theme.header
menu.scroll.Mover.Color = theme.menuitem
menu.first:SetDualDim(nil,13)
menu:SetDualDim(nil,0)
menu.header.Color = theme.header
menu.ref = {
[[setRoundness(5,5,30)]],
Color = theme.menuitem
}
for i,v in ipairs(manga.Chapters) do
menu:addItem(v.Lead, 20, 3)
end
end
function addManga(manga,v) function addManga(manga,v)
local temp = holder:newImageButton(nil,0,0,mangaSize.x,mangaSize.y) local temp = holder:newImageLabel(nil,0,0,mangaSize.x,mangaSize.y)
temp.Visible = false
local text = temp:newTextLabel(v.Title,v.Title,0,-30,0,30,0,1,1) local text = temp:newTextLabel(v.Title,v.Title,0,-30,0,30,0,1,1)
local onStar = false
local fav = false
local star
if favs[v.Title] then
star = temp:newImageLabel("images/star.png",-40,0,40,40,1)
else
star = temp:newImageLabel("images/unstar.png",-40,0,40,40,1)
end
star:OnMouseEnter(function()
onStar = true
end)
star:OnMouseMoved(function()
onStar = true
end)
star:OnReleasedOuter(function()
onStar = false
end)
star:OnReleased(function()
fav = not fav
if fav then
star:SetImage("images/star.png")
favs[v.Title] = v
saveFavs(favs)
else
star:SetImage("images/unstar.png")
favs[v.Title] = nil
saveFavs(favs)
end
end)
star.BorderSize = 0
text.Visibility = .6 text.Visibility = .6
text.Color = Color.Black text.Color = Color.Black
text.TextColor = Color.White text.TextColor = Color.White
text.TextFormat = "center" text.TextFormat = "center"
text:fitFont() text:fitFont()
temp.BorderSize = 2 temp.BorderSize = 2
temp:SetImage(manga.Cover,nil,"Images/notfound.png") temp:SetImage(manga.Cover,nil,"images/notfound.png")
multi:newThread(function()
thread.hold(function()
return temp.Image
end)
temp.Visible = true
end)
temp:OnReleased(function(b,self) temp:OnReleased(function(b,self)
print("Manga",v.Title) if onNav or onStar or mangaViewer:isVisible() then return end
setViewer(manga)
end) end)
end end
page:OnMouseWheelMoved(function(self,x,y) page:OnMouseWheelMoved(function(self,x,y)
if mangaViewer:isVisible() then return end
holder:Move(0,y*60) holder:Move(0,y*60)
if holder.offset.pos.y>85 then if holder.offset.pos.y>85 then
holder:SetDualDim(nil,85) holder:SetDualDim(nil,85)
@ -74,7 +191,6 @@ local function init(page,workspace)
end) end)
holder.Visibility = 0 holder.Visibility = 0
holder.BorderSize = 0 holder.BorderSize = 0
page.ClipDescendants = true
holder:OnUpdate(function() holder:OnUpdate(function()
local c = holder:getChildren() local c = holder:getChildren()
for i=1,#c do for i=1,#c do
@ -84,16 +200,33 @@ local function init(page,workspace)
local size = math.floor(holder.width/(mangaSize.x+5))*(mangaSize.x+5) local size = math.floor(holder.width/(mangaSize.x+5))*(mangaSize.x+5)
holder:SetDualDim((page.width-size)/2) holder:SetDualDim((page.width-size)/2)
end) end)
local nav = page:newFrame(10,10,-20,40,0,0,1)
local SBL = page:newFrame(0,55,0,40,0,0,1)
SBL.BorderSize = 0 SBL.BorderSize = 0
local FAV = SBL:newTextLabel("*","*",0,0,0,0,0/28,0,1/28,1)
FAV.Color = theme.button
FAV:OnReleased(thread:newFunction(function()
if mangaViewer:isVisible() then return end
holder:SetDualDim(nil,85)
local c = holder:getChildren()
for i=#c,1,-1 do
c[i]:Destroy()
end
for i,v in pairs(favs) do
thread.yield()
print(v.Title,v.Link)
mangaReader.getManga(v).connect(function(manga)
print(manga.Title)
addManga(manga,{Title=manga.Title,Link=manga.Link})
end)
end
end))
for i,v in pairs(chars) do for i,v in pairs(chars) do
local temp = SBL:newTextLabel(v,v,0,0,0,0,(i-1)/27,0,1/27,1) local temp = SBL:newTextLabel(v,v,0,0,0,0,(i)/28,0,1/28,1)
temp.Color = theme.button temp.Color = theme.button
multi.setTimeout(function() multi.setTimeout(function()
temp:fitFont() temp:fitFont()
end,.1) end,.1)
temp:OnReleased(thread:newFunction(function() temp:OnReleased(thread:newFunction(function()
if mangaViewer:isVisible() then return end
holder:SetDualDim(nil,85) holder:SetDualDim(nil,85)
thread.hold(function() return titles end) thread.hold(function() return titles end)
local list = searchBy(temp.text) local list = searchBy(temp.text)
@ -103,34 +236,41 @@ local function init(page,workspace)
end end
for i,v in pairs(list) do for i,v in pairs(list) do
thread.yield() thread.yield()
print(v)
mangaReader.getManga(v).connect(function(manga) mangaReader.getManga(v).connect(function(manga)
addManga(manga,v) addManga(manga,{Title=manga.Title,Link=manga.Link})
end) end)
end end
end)) end))
end end
--[[ nav:OnMouseEnter(function()
local temp = holder:newImageLabel("images/test.jpg",0,0,mangaSize.x,mangaSize.y) onNav = true
temp.BorderSize = 2 end)
]] local function exiter()
onNav = false
end
nav:OnMouseExit(exiter)
nav:OnReleasedOuter(exiter)
nav.Color = theme.header nav.Color = theme.header
nav:setRoundness(5,5,60) nav:setRoundness(5,5,60)
local search = nav:newTextButton("Search","Search",5,5,60,-10,0,0,0,1) local search = nav:newTextLabel("Search","Search",5,5,60,-10,0,0,0,1)
search.Color = theme.button search.Color = theme.button
search:fitFont() search:fitFont()
local bar = nav:newTextBox("","",70,5,-75,-10,0,0,1,1) local bar = nav:newTextBox("","",70,5,-75,-10,0,0,1,1)
search:OnReleased(thread:newFunction(function() search:OnReleased(thread:newFunction(function()
if mangaViewer:isVisible() then return end
local c = holder:getChildren()
for i=#c,1,-1 do
c[i]:Destroy()
end
holder:SetDualDim(nil,85) holder:SetDualDim(nil,85)
thread.hold(function() return titles end) thread.hold(function() return titles end)
local list = searchFor(bar.text) local list = searchFor(bar.text)
for i,v in pairs(list) do for i,v in pairs(list) do
mangaReader.getManga(v).connect(function(manga) mangaReader.getManga(v).connect(function(manga)
addManga(manga,v) addManga(manga,{Title=manga.Title,Link=manga.Link})
end) end)
-- local manga = mangaReader.getManga(title)
-- local page = mangaReader.getPages(manga,1)
end end
print(page)
end)) end))
bar:fitFont() bar:fitFont()
bar.Color = theme.input bar.Color = theme.input