mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 02:59:20 +01:00
Properly handle no publications in overview
This commit is contained in:
parent
a5d99c0fae
commit
91c0f86595
@ -808,138 +808,138 @@ local function overview()
|
|||||||
category_id = 1,
|
category_id = 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
if publications then
|
contentContainer:removeChildren()
|
||||||
contentContainer:removeChildren()
|
|
||||||
|
|
||||||
local iconsContainer = contentContainer:addChild(GUI.container(1, 1, contentContainer.width, contentContainer.height))
|
local iconsContainer = contentContainer:addChild(GUI.container(1, 1, contentContainer.width, contentContainer.height))
|
||||||
iconsContainer.blockScreenEvents = true
|
iconsContainer.blockScreenEvents = true
|
||||||
|
|
||||||
local width = appWidth + 4
|
local width = appWidth + 4
|
||||||
local container = contentContainer:addChild(GUI.container(math.floor(contentContainer.width / 2 - width / 2), 1, width, contentContainer.height))
|
local container = contentContainer:addChild(GUI.container(math.floor(contentContainer.width / 2 - width / 2), 1, width, contentContainer.height))
|
||||||
container:addChild(GUI.panel(1, 1, container.width, container.height, 0xFFFFFF))
|
container:addChild(GUI.panel(1, 1, container.width, container.height, 0xFFFFFF))
|
||||||
|
|
||||||
local statisticsLayout = container:addChild(GUI.layout(1, 1, container.width, container.height, 1, 1))
|
local statisticsLayout = container:addChild(GUI.layout(1, 1, container.width, container.height, 1, 1))
|
||||||
|
|
||||||
statisticsLayout:addChild(GUI.image(1, 1, image.load(currentScriptDirectory .. "Icon.pic"))).height = 5
|
statisticsLayout:addChild(GUI.image(1, 1, image.load(currentScriptDirectory .. "Icon.pic"))).height = 5
|
||||||
|
|
||||||
local textLayout = statisticsLayout:addChild(GUI.layout(1, 1, container.width - 4, 1, 1, 1))
|
local textLayout = statisticsLayout:addChild(GUI.layout(1, 1, container.width - 4, 1, 1, 1))
|
||||||
textLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_LEFT, GUI.ALIGNMENT_VERTICAL_TOP)
|
textLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_LEFT, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||||
|
|
||||||
local function add(key, value)
|
local function add(key, value)
|
||||||
textLayout:addChild(GUI.keyAndValue(1, 1, 0x4B4B4B, 0xA5A5A5, key, ": " .. value))
|
textLayout:addChild(GUI.keyAndValue(1, 1, 0x4B4B4B, 0xA5A5A5, key, ": " .. value))
|
||||||
end
|
end
|
||||||
|
|
||||||
add(localization.statisticsUsersCount, statistics.users_count)
|
add(localization.statisticsUsersCount, statistics.users_count)
|
||||||
add(localization.statisticsNewUser, statistics.last_registered_user)
|
add(localization.statisticsNewUser, statistics.last_registered_user)
|
||||||
add(localization.statisticsMostPopularUser, statistics.most_popular_user)
|
add(localization.statisticsMostPopularUser, statistics.most_popular_user)
|
||||||
add(localization.statisticsPublicationsCount, statistics.publications_count)
|
add(localization.statisticsPublicationsCount, statistics.publications_count)
|
||||||
add(localization.statisticsReviewsCount, statistics.reviews_count)
|
add(localization.statisticsReviewsCount, statistics.reviews_count)
|
||||||
add(localization.statisticsMessagesCount, statistics.messages_count)
|
add(localization.statisticsMessagesCount, statistics.messages_count)
|
||||||
|
|
||||||
textLayout.height = #textLayout.children * 2
|
textLayout.height = #textLayout.children * 2
|
||||||
|
|
||||||
|
if #publications > 0 then
|
||||||
local applicationPreview = statisticsLayout:addChild(newApplicationPreview(1, 1, publications[1]))
|
local applicationPreview = statisticsLayout:addChild(newApplicationPreview(1, 1, publications[1]))
|
||||||
applicationPreview.panel.colors.background = 0xF0F0F0
|
applicationPreview.panel.colors.background = 0xF0F0F0
|
||||||
statisticsLayout:addChild(GUI.label(1, 1, statisticsLayout.width, 1, 0xA5A5A5, localization.statisticsPopularPublication)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_CENTER)
|
statisticsLayout:addChild(GUI.label(1, 1, statisticsLayout.width, 1, 0xA5A5A5, localization.statisticsPopularPublication)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_CENTER)
|
||||||
|
end
|
||||||
|
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
|
|
||||||
local uptime, newUptime = computer.uptime()
|
local uptime, newUptime = computer.uptime()
|
||||||
local function tick()
|
local function tick()
|
||||||
newUptime = computer.uptime()
|
newUptime = computer.uptime()
|
||||||
if newUptime - uptime > overviewAnimationDelay then
|
if newUptime - uptime > overviewAnimationDelay then
|
||||||
uptime = newUptime
|
uptime = newUptime
|
||||||
|
|
||||||
local child
|
local child
|
||||||
for i = 1, #iconsContainer.children do
|
for i = 1, #iconsContainer.children do
|
||||||
child = iconsContainer.children[i]
|
child = iconsContainer.children[i]
|
||||||
|
|
||||||
|
child.moveX, child.moveY = child.moveX + child.forceX, child.moveY + child.forceY
|
||||||
|
|
||||||
child.moveX, child.moveY = child.moveX + child.forceX, child.moveY + child.forceY
|
if child.forceX > 0 then
|
||||||
|
if child.forceX > overviewForceLimit then
|
||||||
if child.forceX > 0 then
|
child.forceX = child.forceX - overviewForceDecay
|
||||||
if child.forceX > overviewForceLimit then
|
|
||||||
child.forceX = child.forceX - overviewForceDecay
|
|
||||||
else
|
|
||||||
child.forceX = overviewForceLimit
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if child.forceX < -overviewForceLimit then
|
child.forceX = overviewForceLimit
|
||||||
child.forceX = child.forceX + overviewForceDecay
|
|
||||||
else
|
|
||||||
child.forceX = -overviewForceLimit
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
if child.forceY > 0 then
|
if child.forceX < -overviewForceLimit then
|
||||||
if child.forceY > overviewForceLimit then
|
child.forceX = child.forceX + overviewForceDecay
|
||||||
child.forceY = child.forceY - overviewForceDecay
|
|
||||||
else
|
|
||||||
child.forceY = overviewForceLimit
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if child.forceY < -overviewForceLimit then
|
child.forceX = -overviewForceLimit
|
||||||
child.forceY = child.forceY + overviewForceDecay
|
|
||||||
else
|
|
||||||
child.forceY = -overviewForceLimit
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if child.moveX <= 1 then
|
|
||||||
child.forceX, child.moveX = -child.forceX, 1
|
|
||||||
elseif child.moveX + child.width - 1 >= iconsContainer.width then
|
|
||||||
child.forceX, child.moveX = -child.forceX, iconsContainer.width - child.width + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if child.moveY <= 1 then
|
|
||||||
child.forceY, child.moveY = -child.forceY, 1
|
|
||||||
elseif child.moveY + child.height - 1 >= iconsContainer.height then
|
|
||||||
child.forceY, child.moveY = -child.forceY, iconsContainer.height - child.height + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
child.localX, child.localY = math.floor(child.moveX), math.floor(child.moveY)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
workspace:draw()
|
if child.forceY > 0 then
|
||||||
|
if child.forceY > overviewForceLimit then
|
||||||
return true
|
child.forceY = child.forceY - overviewForceDecay
|
||||||
end
|
else
|
||||||
end
|
child.forceY = overviewForceLimit
|
||||||
|
end
|
||||||
iconsContainer.eventHandler = function(workspace, object, e1, e2, e3, e4)
|
else
|
||||||
if e1 == "touch" or e1 == "drag" then
|
if child.forceY < -overviewForceLimit then
|
||||||
local child, deltaX, deltaY, vectorLength
|
child.forceY = child.forceY + overviewForceDecay
|
||||||
for i = 1, #iconsContainer.children do
|
else
|
||||||
child = iconsContainer.children[i]
|
child.forceY = -overviewForceLimit
|
||||||
|
|
||||||
deltaX, deltaY = e3 - child.x, e4 - child.y
|
|
||||||
vectorLength = math.sqrt(deltaX ^ 2 + deltaY ^ 2)
|
|
||||||
if vectorLength > 0 then
|
|
||||||
child.forceX = deltaX / vectorLength * math.random(overviewMaximumTouchAcceleration)
|
|
||||||
child.forceY = deltaY / vectorLength * math.random(overviewMaximumTouchAcceleration)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if child.moveX <= 1 then
|
||||||
|
child.forceX, child.moveX = -child.forceX, 1
|
||||||
|
elseif child.moveX + child.width - 1 >= iconsContainer.width then
|
||||||
|
child.forceX, child.moveX = -child.forceX, iconsContainer.width - child.width + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if child.moveY <= 1 then
|
||||||
|
child.forceY, child.moveY = -child.forceY, 1
|
||||||
|
elseif child.moveY + child.height - 1 >= iconsContainer.height then
|
||||||
|
child.forceY, child.moveY = -child.forceY, iconsContainer.height - child.height + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
child.localX, child.localY = math.floor(child.moveX), math.floor(child.moveY)
|
||||||
end
|
end
|
||||||
|
|
||||||
tick()
|
workspace:draw()
|
||||||
end
|
|
||||||
|
|
||||||
local function makeBlyad(object)
|
return true
|
||||||
object.localX = math.random(1, iconsContainer.width - object.width + 1)
|
end
|
||||||
object.localY = math.random(1, iconsContainer.height - object.width + 1)
|
end
|
||||||
object.moveX = object.localX
|
|
||||||
object.moveY = object.localY
|
iconsContainer.eventHandler = function(workspace, object, e1, e2, e3, e4)
|
||||||
object.forceX = math.random(-100, 100) / 100 * overviewForceLimit
|
if e1 == "touch" or e1 == "drag" then
|
||||||
object.forceY = math.random(-100, 100) / 100 * overviewForceLimit
|
local child, deltaX, deltaY, vectorLength
|
||||||
|
for i = 1, #iconsContainer.children do
|
||||||
if not tick() then
|
child = iconsContainer.children[i]
|
||||||
workspace:draw()
|
|
||||||
|
deltaX, deltaY = e3 - child.x, e4 - child.y
|
||||||
|
vectorLength = math.sqrt(deltaX ^ 2 + deltaY ^ 2)
|
||||||
|
if vectorLength > 0 then
|
||||||
|
child.forceX = deltaX / vectorLength * math.random(overviewMaximumTouchAcceleration)
|
||||||
|
child.forceY = deltaY / vectorLength * math.random(overviewMaximumTouchAcceleration)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 2, #publications do
|
tick()
|
||||||
makeBlyad(iconsContainer:addChild(GUI.image(1, 1, getPublicationIcon(publications[i])), 1))
|
end
|
||||||
|
|
||||||
|
local function makeBlyad(object)
|
||||||
|
object.localX = math.random(1, iconsContainer.width - object.width + 1)
|
||||||
|
object.localY = math.random(1, iconsContainer.height - object.width + 1)
|
||||||
|
object.moveX = object.localX
|
||||||
|
object.moveY = object.localY
|
||||||
|
object.forceX = math.random(-100, 100) / 100 * overviewForceLimit
|
||||||
|
object.forceY = math.random(-100, 100) / 100 * overviewForceLimit
|
||||||
|
|
||||||
|
if not tick() then
|
||||||
|
workspace:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for i = 2, #publications do
|
||||||
|
makeBlyad(iconsContainer:addChild(GUI.image(1, 1, getPublicationIcon(publications[i])), 1))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2293,4 +2293,4 @@ end
|
|||||||
window:resize(window.width, window.height)
|
window:resize(window.width, window.height)
|
||||||
|
|
||||||
-- Рисуем синюю писечку если надо
|
-- Рисуем синюю писечку если надо
|
||||||
checkForUnreadMessages()
|
checkForUnreadMessages()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user