Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Updating the tTilemap Tool.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessefreeman committed Jul 28, 2020
1 parent 4c81deb commit 9383a42
Show file tree
Hide file tree
Showing 712 changed files with 7,025 additions and 14,379 deletions.
Binary file added Disks/PixelVisionOS/System/Fonts/input.font.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Disks/PixelVisionOS/System/Fonts/large.font.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Disks/PixelVisionOS/System/Fonts/medium.font.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Disks/PixelVisionOS/System/Fonts/small.font.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
896 changes: 896 additions & 0 deletions Disks/PixelVisionOS/System/Libs/pixel-vision-os-canvas-v2.lua

Large diffs are not rendered by default.

Empty file.
524 changes: 524 additions & 0 deletions Disks/PixelVisionOS/System/Libs/pixel-vision-os-color-picker-v4.lua

Large diffs are not rendered by default.

710 changes: 710 additions & 0 deletions Disks/PixelVisionOS/System/Libs/pixel-vision-os-item-picker-v1.lua

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions Disks/PixelVisionOS/System/Libs/pixel-vision-os-item-picker-v3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function PixelVisionOS:CreateItemPicker(rect, itemSize, columns, rows, colorOffs
data.displaySize = Display()

data.maxScale = 4
data.zoom = 1

-- Scroll values
data.scrollScale = NewPoint(math.ceil((data.columns - data.visibleColumns) / data.maxScale), math.ceil((data.rows - data.visibleRows) / data.maxScale))
Expand Down Expand Up @@ -156,7 +157,8 @@ function PixelVisionOS:CreateItemPicker(rect, itemSize, columns, rows, colorOffs

end

if(_G["vsliderhandle"] ~= nil and data.viewport.height < data.realHeight) then
--print(data.name, "scroller", data.viewport.height < data.realHeight, _G["vsliderhandle"])
if(_G["vsliderhandleup"] ~= nil and data.viewport.height < data.realHeight) then

data.vSlider = editorUI:CreateSlider(
{ x = rect.x + rect.w + 1, y = rect.y, w = 16, h = rect.h},
Expand Down Expand Up @@ -369,9 +371,12 @@ function PixelVisionOS:UpdateItemPicker(data)
self:UpdateItemPickerSelection(data)

-- Calculate the bg color
local bgColor = data.showBGColor and gameEditor:BackgroundColor() or (self.emptyColorID - data.colorOffset)

data.canvas:DrawPixels( data.visibleRect.x, data.visibleRect.y, DrawMode.TilemapCache, 1, -1, bgColor, data.colorOffset, NewRect(data.viewport.x + data.lastStartX, data.viewport.y + data.lastStartY, data.visibleRect.w, data.visibleRect.h), data.isolateSpriteColors)
local bgColor = data.showBGColor and gameEditor:BackgroundColor() or self.emptyColorID

-- TODO need to optimize this, the bg color isn't rendering correctly because of the color offset
DrawRect(data.visibleRect.x, data.visibleRect.y, data.visibleRect.w, data.visibleRect.h, bgColor, DrawMode.TilemapCache);

data.canvas:DrawPixels( data.visibleRect.x, data.visibleRect.y, DrawMode.TilemapCache, data.zoom, -1, -1, data.colorOffset, NewRect(data.viewport.x + data.lastStartX, data.viewport.y + data.lastStartY, data.visibleRect.w, data.visibleRect.h), data.isolateSpriteColors)

-- Reset the display invalidation
data.invalidateDisplay = false
Expand Down Expand Up @@ -615,7 +620,7 @@ function PixelVisionOS:ChangeItemPickerScale(data, scale, selection)

data.scale = selection--{x = scale, y = scale}

local tmpItemSize = scale * data.itemSize.x
--local tmpItemSize = scale * data.itemSize

-- Resize picker
data.picker.itemWidth = selection.x * data.itemSize.x
Expand Down
151 changes: 151 additions & 0 deletions Disks/PixelVisionOS/System/Libs/pixel-vision-os-sprite-picker-v3.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
function PixelVisionOS:CreateSpritePicker(rect, itemSize, columns, rows, colorOffset, spriteName, toolTip, enableDragging, draggingLabel)

local data = self:CreateItemPicker(rect, itemSize, columns, rows, colorOffset, spriteName, toolTip, enableDragging, draggingLabel)

data.name = "SpritePicker" .. data.name

-- Create pagination
data.totalPerPage = 256
data.pageSize = 128
data.totalPages = math.floor(data.totalItems / data.totalPerPage)
data.maxPages = Clamp(data.totalPages, 1, 8)
data.pageOverTime = 0
data.pageOverDelay = .5
data.pageOverLast = -1

data.pagePosition = NewPoint(
rect.x + rect.w,
rect.y + rect.h
)

data.realHeight = 128

-- Recalculate scrollScale so the hight is based on the real page height
data.scrollScale.y = math.ceil((((data.realHeight / 8) - data.visibleRows) / data.maxScale))

-- Shift the pagination down if there is a horizontal scroll bar
if(data.hSlider ~= nil) then
data.pagePosition.y = data.pagePosition.y + 16
end

-- Shift the pagination down if there is a horizontal scroll bar
if(data.vSlider ~= nil) then
data.pagePosition.x = data.pagePosition.x + 16
end

data.pages = editorUI:CreateToggleGroup()

data.pages.onAction = function(value)
self:OnSpritePickerPage(data, value)
end

data.pageToolTipTemplate = "Select sprite page "

self:RebuildPickerPages(data, data.totalPages)

self:RebuildSpritePickerCache(data)

self:OnSpritePickerPage(data, 1)

return data

end

function PixelVisionOS:RebuildSpritePickerCache(data)
-- Get all the sprite pixel data
local pixelData = gameEditor:ReadGameSpriteData(0, data.columns, data.rows)

self:SetItemPickerPixelData(data, pixelData)

self:InvalidateItemPickerDisplay(data)
end

function PixelVisionOS:UpdateSpritePicker(data)

editorUI:UpdateToggleGroup(data.pages)

self:UpdateItemPicker(data)

-- Check for dragging over a page
if(data.dragging == true) then

local pageButtons = data.pages.buttons

for i = 1, #pageButtons do
local tmpButton = pageButtons[i]

local hitRect = tmpButton.rect

-- TODO need to offset for size?

if(self.editorUI.collisionManager:MouseInRect(hitRect) == true and tmpButton.enabled == true) then

-- Test if over a new page
if(data.pageOverLast ~= i) then

data.pageOverLast = i
data.pageOverTime = 0

end

data.pageOverTime = data.pageOverTime + self.editorUI.timeDelta

if(data.pageOverTime > data.pageOverDelay)then
data.pageOverTime = 0
self:OnSpritePickerPage(data, i)

data.pageOverLast = i
data.pageOverTime = 0
end

end

end

else
-- Reset page over flag
data.pageOverLast = -1
data.pageOverTime = 0
end

end

function PixelVisionOS:OnSpritePickerPage(data, value)

-- Calculate the lastStartY position
data.lastStartY = (value - 1) * data.pageSize

data.scrollShift.y = data.lastStartY

-- Select the correct toggle button
editorUI:SelectToggleButton(data.pages, value)

if(data.vSlider ~= nil) then

-- Reset the scroll bar
editorUI:ChangeSlider(data.vSlider, 0, false)

end

-- Invalidate the display
self:InvalidateItemPickerDisplay(data)

end

function PixelVisionOS:SelectSpritePickerIndex(data, value)


-- Recalculate the position
local pos = CalculatePosition(value, data.columns)

-- Calculate the correct page from the position y value
local tmpPage = math.floor((pos.y * 8) / data.pageSize)

self:OnSpritePickerPage(data, tmpPage + 1)

self:SelectItemPickerIndex(data, value, false, true)

-- Invalidate the display
self:InvalidateItemPickerDisplay(data)

end

0 comments on commit 9383a42

Please sign in to comment.