more work
This commit is contained in:
parent
f0f2f9b8c7
commit
7ac51cb6e5
@ -59,9 +59,9 @@ end
|
||||
function gui:canPress()
|
||||
local ref = self
|
||||
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()
|
||||
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
|
||||
else
|
||||
return false
|
||||
|
||||
@ -34,6 +34,11 @@ end)
|
||||
local cache = {}
|
||||
function gui:SetImage(i,inthread,backup)
|
||||
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
|
||||
self.Image=i
|
||||
self.ImageHeigth=self.Image:getHeight()
|
||||
@ -51,7 +56,6 @@ function gui:SetImage(i,inthread,backup)
|
||||
end
|
||||
DownloadImage(i,hash).connect(function(img)
|
||||
if img == "noimage" then
|
||||
print("Need backup")
|
||||
if backup then
|
||||
return self:SetImage(backup)
|
||||
else
|
||||
|
||||
11
GuiManager/Misc/isVisible.int
Normal file
11
GuiManager/Misc/isVisible.int
Normal 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
|
||||
@ -60,6 +60,13 @@ function gui:newScrollMenu(name)
|
||||
self.ref = ref
|
||||
end
|
||||
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)
|
||||
local padding = padding or 10
|
||||
local height = height or 30
|
||||
|
||||
@ -67,10 +67,16 @@ gui.LoadAll("GuiManager/Drawing")
|
||||
-- End of Load
|
||||
gui:respectHierarchy()
|
||||
_GuiPro.width,_GuiPro.height=love.graphics.getDimensions()
|
||||
gui.OnScreenSizeChanged = multi:newConnection()
|
||||
multi:newThread("GuiManager",function()
|
||||
local x,y
|
||||
while true do
|
||||
x,y = love.graphics.getDimensions()
|
||||
thread.sleep(.01)
|
||||
_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)
|
||||
multi:onDraw(function()
|
||||
|
||||
27
app.lua
27
app.lua
@ -16,8 +16,16 @@ local spd = 7
|
||||
-- keep at top
|
||||
local head
|
||||
function app.createPage(name,path)
|
||||
local page = require("pages/"..path).init(app.workspace:newFullFrame(name),app.workspace)
|
||||
page.Color = theme.menu
|
||||
local page = app.workspace:newFullFrame(name)
|
||||
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)
|
||||
page.Visible = false
|
||||
function page:Goto()
|
||||
@ -28,27 +36,25 @@ function app.createPage(name,path)
|
||||
end
|
||||
local button
|
||||
if head == app.header then
|
||||
button = head:newTextButton(name,name,5,0,100,60)
|
||||
button = head:newTextLabel(name,name,5,0,100,60)
|
||||
else
|
||||
button = head:newTextButton(name,name,5,0,100,60,1)
|
||||
button = head:newTextLabel(name,name,5,0,100,60,1)
|
||||
end
|
||||
button:centerY()
|
||||
head = button
|
||||
button:fitFont()
|
||||
button.Color = theme.menuitem
|
||||
button:OnReleased(function()
|
||||
|
||||
page:Goto()
|
||||
end)
|
||||
print("done")
|
||||
return page
|
||||
return page, button
|
||||
end
|
||||
local function init(a)
|
||||
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)
|
||||
head = app.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.Color = theme.menu
|
||||
app.menu:OnReleasedOuter(function(b,self)
|
||||
@ -59,8 +65,9 @@ local function init(a)
|
||||
app.workspace.Color = Color.Black
|
||||
app.menu.Visible = false
|
||||
local search = app.createPage("Search","search")
|
||||
app.createPage("Favorites","favs")
|
||||
--search:Goto()
|
||||
local favs = app.createPage("Favorites","favs")
|
||||
search:Goto()
|
||||
--app.createPage("Favorites","favs")
|
||||
end
|
||||
return {
|
||||
init = init
|
||||
|
||||
BIN
images/bg.jpg
Normal file
BIN
images/bg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
BIN
images/star.png
Normal file
BIN
images/star.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
images/unstar.png
Normal file
BIN
images/unstar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@ -35,6 +35,7 @@ m.getManga = queue:newFunction("queue",function(title)
|
||||
local http = require("socket.http")
|
||||
local manga = http.request(title.Link)
|
||||
local tab = {}
|
||||
tab.Link = title.Link
|
||||
tab.Cover = manga:match([[<div id="mangaimg"><img src="(.-)"]])
|
||||
tab.Title = manga:match([[Name:.-"aname">%s*([^<]*)]])
|
||||
tab.AltTitle = manga:match([[Alternate Name:.-<td>([^<]*)]])
|
||||
|
||||
@ -135,14 +135,13 @@ function multi:newSystemThreadedJobQueue(n)
|
||||
end
|
||||
end
|
||||
end)
|
||||
print("Cores: ",c.cores)
|
||||
for i=1,c.cores do
|
||||
multi:newSystemThread("JobQueue_"..jqc.."_worker_"..i,function(jqc)
|
||||
local multi, thread = require("multi"):init()
|
||||
require("love.timer")
|
||||
local function atomic(channel)
|
||||
return channel:pop()
|
||||
end
|
||||
require("love.timer")
|
||||
local clock = os.clock
|
||||
local funcs = THREAD.createStaticTable("__JobQueue_"..jqc.."_table")
|
||||
local queue = love.thread.getChannel("__JobQueue_"..jqc.."_queue")
|
||||
|
||||
174
pages/search.lua
174
pages/search.lua
@ -50,23 +50,140 @@ local chars = {"#"}
|
||||
for i=65,90 do
|
||||
table.insert(chars,string.char(i))
|
||||
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 favs = getFavs()
|
||||
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)
|
||||
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 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.Color = Color.Black
|
||||
text.TextColor = Color.White
|
||||
text.TextFormat = "center"
|
||||
text:fitFont()
|
||||
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)
|
||||
print("Manga",v.Title)
|
||||
if onNav or onStar or mangaViewer:isVisible() then return end
|
||||
setViewer(manga)
|
||||
end)
|
||||
end
|
||||
page:OnMouseWheelMoved(function(self,x,y)
|
||||
if mangaViewer:isVisible() then return end
|
||||
holder:Move(0,y*60)
|
||||
if holder.offset.pos.y>85 then
|
||||
holder:SetDualDim(nil,85)
|
||||
@ -74,7 +191,6 @@ local function init(page,workspace)
|
||||
end)
|
||||
holder.Visibility = 0
|
||||
holder.BorderSize = 0
|
||||
page.ClipDescendants = true
|
||||
holder:OnUpdate(function()
|
||||
local c = holder:getChildren()
|
||||
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)
|
||||
holder:SetDualDim((page.width-size)/2)
|
||||
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
|
||||
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
|
||||
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
|
||||
multi.setTimeout(function()
|
||||
temp:fitFont()
|
||||
end,.1)
|
||||
temp:OnReleased(thread:newFunction(function()
|
||||
if mangaViewer:isVisible() then return end
|
||||
holder:SetDualDim(nil,85)
|
||||
thread.hold(function() return titles end)
|
||||
local list = searchBy(temp.text)
|
||||
@ -103,34 +236,41 @@ local function init(page,workspace)
|
||||
end
|
||||
for i,v in pairs(list) do
|
||||
thread.yield()
|
||||
print(v)
|
||||
mangaReader.getManga(v).connect(function(manga)
|
||||
addManga(manga,v)
|
||||
addManga(manga,{Title=manga.Title,Link=manga.Link})
|
||||
end)
|
||||
end
|
||||
end))
|
||||
end
|
||||
--[[
|
||||
local temp = holder:newImageLabel("images/test.jpg",0,0,mangaSize.x,mangaSize.y)
|
||||
temp.BorderSize = 2
|
||||
]]
|
||||
nav:OnMouseEnter(function()
|
||||
onNav = true
|
||||
end)
|
||||
local function exiter()
|
||||
onNav = false
|
||||
end
|
||||
nav:OnMouseExit(exiter)
|
||||
nav:OnReleasedOuter(exiter)
|
||||
nav.Color = theme.header
|
||||
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:fitFont()
|
||||
local bar = nav:newTextBox("","",70,5,-75,-10,0,0,1,1)
|
||||
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)
|
||||
thread.hold(function() return titles end)
|
||||
local list = searchFor(bar.text)
|
||||
for i,v in pairs(list) do
|
||||
mangaReader.getManga(v).connect(function(manga)
|
||||
addManga(manga,v)
|
||||
addManga(manga,{Title=manga.Title,Link=manga.Link})
|
||||
end)
|
||||
-- local manga = mangaReader.getManga(title)
|
||||
-- local page = mangaReader.getPages(manga,1)
|
||||
end
|
||||
print(page)
|
||||
end))
|
||||
bar:fitFont()
|
||||
bar.Color = theme.input
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user