Skip to content

Commit

Permalink
Merge pull request #12 from veu/next
Browse files Browse the repository at this point in the history
Version 2.1.0
  • Loading branch information
veu authored Feb 4, 2023
2 parents 5bccf28 + a7f67f5 commit 2b43b9d
Show file tree
Hide file tree
Showing 16 changed files with 193 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/constants.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = "2.0.2"
VERSION = "2.1.0"

CELL = 16
TOP_NUMBER_HEIGHT = 14
Expand Down
Binary file added src/img/preview-table-400-240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/imports.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import "screen/about"
import "screen/create-avatar"
import "screen/create-puzzle"
import "screen/play-puzzle"
import "screen/select-creator"
import "screen/select-puzzle"
import "screen/sketch-tutorial"
import "screen/solved-puzzle"
Expand Down Expand Up @@ -73,6 +74,7 @@ import "ui/list"
import "ui/menu-border"
import "ui/modal"
import "ui/player-avatar"
import "ui/puzzle-preview"
import "ui/text-cursor"
import "ui/time"
import "ui/timer"
Expand Down Expand Up @@ -113,6 +115,8 @@ imgRdk = gfx.image.new("img/rdk")
assert(imgRdk, err)
imgAbout = gfx.image.new("img/about")
assert(imgAbout, err)
imgPreview = gfx.imagetable.new("img/preview")
assert(imgPreview, err)

snd1 = {}
snd2 = {}
Expand Down
20 changes: 15 additions & 5 deletions src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "imports"
local aboutScreen <const> = AboutScreen()
local createAvatarScreen <const> = CreateAvatarScreen()
local createPuzzleScreen <const> = CreatePuzzleScreen()
local selectCreatorScreen <const> = SelectCreatorScreen()
local selectPuzzleScreen <const> = SelectPuzzleScreen()
local sketchTutorialScreen <const> = SketchTutorialScreen()
local solvedPuzzleScreen <const> = SolvedPuzzleScreen()
Expand Down Expand Up @@ -193,9 +194,10 @@ function switch(newScreen, newSidebar, selected, out, onReady)
onReady()
end
end
local same <const> = context.sidebar == newSidebar
context.sidebar:leave(context)
context.sidebar = newSidebar
context.sidebar:enter(context, selected)
context.sidebar:enter(context, selected, same)
end

local idleCounter = 0
Expand Down Expand Up @@ -523,7 +525,7 @@ playPuzzleSidebar.onDeletePuzzle = function ()
if #context.creator.created > 0 then
switch(selectPuzzleScreen, selectPuzzleSidebar, nil, true)
else
switch(titleScreen, selectCreatorSidebar, nil, true)
switch(selectCreatorScreen, selectCreatorSidebar, nil, true)
end
end
showModal("Are you sure you want to delete the puzzle \"" .. context.puzzle.title .. "\"?", "Delete")
Expand Down Expand Up @@ -590,7 +592,11 @@ selectAvatarSidebar.onSelected = function(avatar)
end

selectCreatorSidebar.onAbort = function()
switch(nil, selectModeSidebar, MODE_PLAY, true)
switch(titleScreen, selectModeSidebar, MODE_PLAY, true)
end

selectCreatorSidebar.onNavigated = function (creator)
context.screen:setCreator(creator)
end

selectCreatorSidebar.onSelected = function(creator)
Expand All @@ -599,7 +605,11 @@ selectCreatorSidebar.onSelected = function(creator)
end

selectPuzzleSidebar.onAbort = function()
switch(titleScreen, selectCreatorSidebar, context.creator.id, true)
switch(selectCreatorScreen, selectCreatorSidebar, context.creator.id, true)
end

selectPuzzleSidebar.onNavigated = function (puzzle, preview)
context.screen:setPuzzle(puzzle, preview)
end

selectPuzzleSidebar.onSelected = function (puzzle)
Expand All @@ -614,7 +624,7 @@ end
selectModeSidebar.onSelected = function(selectedMode)
context.mode = selectedMode
if context.mode == MODE_PLAY then
switch(nil, selectCreatorSidebar)
switch(selectCreatorScreen, selectCreatorSidebar)
elseif context.mode == MODE_CREATE then
local puzzle = Puzzle.createEmpty()
if context.player.sketch then
Expand Down
4 changes: 2 additions & 2 deletions src/pdxinfo
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ author=RDK
description=Playdate’s #1 nonogram game
bundleID=net.monometric.sketch-share-solve
imagePath=launcherAssets/
version=2.0.2
buildNumber=200020
version=2.1.0
buildNumber=201000
23 changes: 23 additions & 0 deletions src/screen/select-creator.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class("SelectCreatorScreen").extends(Screen)

function SelectCreatorScreen:init()
SelectCreatorScreen.super.init(self)

self.collection = Collection()
end

function SelectCreatorScreen:enter(context)
self.collection:enter(context)
end

function SelectCreatorScreen:leave()
self.collection:leave()
end

function SelectCreatorScreen:setInvertedMode(active)
self.collection:setInvertedMode(active)
end

function SelectCreatorScreen:setCreator(creator)
self.collection:setCreator(creator)
end
10 changes: 7 additions & 3 deletions src/screen/select-puzzle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ class("SelectPuzzleScreen").extends(Screen)
function SelectPuzzleScreen:init()
SelectPuzzleScreen.super.init(self)

self.collection = Collection()
self.preview = PuzzlePreview()
end

function SelectPuzzleScreen:enter(context)
self.collection:enter(context)
self.preview:enter(context)
end

function SelectPuzzleScreen:leave()
self.collection:leave()
self.preview:leave()
end

function SelectPuzzleScreen:setPuzzle(puzzle, preview)
self.preview:setPuzzle(puzzle, preview)
end
4 changes: 2 additions & 2 deletions src/sidebar/create-puzzle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function CreatePuzzleSidebar:init()
CreatePuzzleSidebar.super.init(self)
end

function CreatePuzzleSidebar:enter(context, selected)
function CreatePuzzleSidebar:enter(context, selected, same)
local config = {
player = context.player.avatar,
menuTitle = "Create new puzzle",
Expand Down Expand Up @@ -61,5 +61,5 @@ function CreatePuzzleSidebar:enter(context, selected)
}
}

CreatePuzzleSidebar.super.enter(self, context, config)
CreatePuzzleSidebar.super.enter(self, context, config, nil, nil, same)
end
7 changes: 5 additions & 2 deletions src/sidebar/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function OptionsSidebar:init()
OptionsSidebar.super.init(self)
end

function OptionsSidebar:enter(context, selected)
function OptionsSidebar:enter(context, selected, same)
local hintsText = "Hints: " .. HINTS_TEXT[context.player.options.showHints]
local timerText = "Timer: " .. (
context.player.options.showTimer and "on" or "off"
Expand Down Expand Up @@ -93,6 +93,9 @@ function OptionsSidebar:enter(context, selected)
OptionsSidebar.super.enter(
self,
context,
config
config,
nil,
nil,
same
)
end
4 changes: 2 additions & 2 deletions src/sidebar/play-puzzle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function PlayPuzzleSidebar:init()
PlayPuzzleSidebar.super.init(self)
end

function PlayPuzzleSidebar:enter(context, selected)
function PlayPuzzleSidebar:enter(context, selected, same)
local player = context.player
local creator = context.creator
local puzzle = context.puzzle
Expand Down Expand Up @@ -104,7 +104,7 @@ function PlayPuzzleSidebar:enter(context, selected)
end
end

PlayPuzzleSidebar.super.enter(self, context, config)
PlayPuzzleSidebar.super.enter(self, context, config, nil, nil, same)
end

function PlayPuzzleSidebar:getTitle(player, creator, puzzle)
Expand Down
4 changes: 4 additions & 0 deletions src/sidebar/select-puzzle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ function SelectPuzzleSidebar:enter(context, selected)
local start = self.list.position
for i = start, math.min(numCreated, start + 5) do
self:addItem(i)
if i == self.list.cursor then
local menuItem <const> = self.menuItems[i]
self.onNavigated(menuItem.ref, menuItem.img)
end
end
self.list.needsRedraw = true

Expand Down
4 changes: 2 additions & 2 deletions src/sidebar/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function SettingsSidebar:init()
SettingsSidebar.super.init(self)
end

function SettingsSidebar:enter(context, selected)
function SettingsSidebar:enter(context, selected, same)
local config = {
menuTitle = "Settings",
menuItems = {
Expand Down Expand Up @@ -88,5 +88,5 @@ function SettingsSidebar:enter(context, selected)
end,
})

SettingsSidebar.super.enter(self, context, config)
SettingsSidebar.super.enter(self, context, config, nil, nil, same)
end
42 changes: 27 additions & 15 deletions src/sidebar/sidebar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Sidebar:init()
self.onSelected = function () end
end

function Sidebar:enter(context, config, player, creator)
function Sidebar:enter(context, config, player, creator, same)
self.config = config
self.menuItems = config.menuItems
self.menuTitle = config.menuTitle
Expand All @@ -44,7 +44,7 @@ function Sidebar:enter(context, config, player, creator)

self:add()

local isOpen = context.isSidebarOpen
local isOpen <const> = context.isSidebarOpen
self.isOpen = isOpen
self:moveTo(isOpen and 0 or -SIDEBAR_WIDTH + 24, 0)
self.playerAvatar:enter(config, config.player)
Expand All @@ -53,7 +53,7 @@ function Sidebar:enter(context, config, player, creator)
self.creatorAvatar:moveTo(isOpen and 0 or -SIDEBAR_WIDTH + 24, Sidebar.creatorAvatar.y)
self.list:moveTo()
self.menuBorder:moveTo(isOpen and 0 or -SIDEBAR_WIDTH + 24, 0)
self.list:enter(context, self.menuItems, self.menuTitle)
self.list:enter(context, self.menuItems, self.menuTitle, same)
self.list:select(self.cursor, true)
if not context.scrolling then
self.list.highlightUpdate = true
Expand All @@ -62,8 +62,9 @@ function Sidebar:enter(context, config, player, creator)
self:redraw()

if isOpen then
self:onNavigated_(self.menuItems[self.cursor].ref)
self.onNavigated(self.menuItems[self.cursor].ref)
local menuItem <const> = self.menuItems[self.cursor]
self:onNavigated_(menuItem.ref)
self.onNavigated(menuItem.ref, menuItem.img)
end
end

Expand All @@ -89,8 +90,9 @@ function Sidebar:cranked(change, acceleratedChange)
if self.cursor ~= newCursor then
self.cursor = newCursor
self.list:select(self.cursor)
self:onNavigated_(self.menuItems[self.cursor].ref)
self.onNavigated(self.menuItems[self.cursor].ref)
local menuItem <const> = self.menuItems[self.cursor]
self:onNavigated_(menuItem.ref)
self.onNavigated(menuItem.ref, menuItem.img)
end
self:onCranked()
end
Expand All @@ -101,8 +103,9 @@ function Sidebar:downButtonDown()
self.cursor = newCursor
self.cursorRaw = newCursor
self.list:select(self.cursor)
self:onNavigated_(self.menuItems[self.cursor].ref)
self.onNavigated(self.menuItems[self.cursor].ref)
local menuItem <const> = self.menuItems[self.cursor]
self:onNavigated_(menuItem.ref)
self.onNavigated(menuItem.ref, menuItem.img)
self:onMoved()
else
playEffect("scrollEnd")
Expand All @@ -121,8 +124,9 @@ function Sidebar:leftButtonDown()
self.cursor = newCursor
self.cursorRaw = newCursor
self.list:select(self.cursor)
self:onNavigated_(self.menuItems[self.cursor].ref)
self.onNavigated(self.menuItems[self.cursor].ref)
local menuItem <const> = self.menuItems[self.cursor]
self:onNavigated_(menuItem.ref)
self.onNavigated(menuItem.ref, menuItem.img)
self:onMoved()
else
playEffect("scrollEnd")
Expand All @@ -141,8 +145,9 @@ function Sidebar:rightButtonDown()
self.cursor = newCursor
self.cursorRaw = newCursor
self.list:select(self.cursor)
self:onNavigated_(self.menuItems[self.cursor].ref)
self.onNavigated(self.menuItems[self.cursor].ref)
local menuItem <const> = self.menuItems[self.cursor]
self:onNavigated_(menuItem.ref)
self.onNavigated(menuItem.ref, menuItem.img)
self:onMoved()
else
playEffect("scrollEnd")
Expand All @@ -155,15 +160,19 @@ function Sidebar:upButtonDown()
self.cursor = newCursor
self.cursorRaw = newCursor
self.list:select(self.cursor)
self:onNavigated_(self.menuItems[self.cursor].ref)
self.onNavigated(self.menuItems[self.cursor].ref)
local menuItem <const> = self.menuItems[self.cursor]
self:onNavigated_(menuItem.ref)
self.onNavigated(menuItem.ref, menuItem.img)
self:onMoved()
else
playEffect("scrollEnd")
end
end

function Sidebar:AButtonDown()
if self.animator then
return
end
local item = self.menuItems[self.cursor]
if item.disabled then
if item.disabledText then
Expand All @@ -182,6 +191,9 @@ function Sidebar:AButtonDown()
end

function Sidebar:BButtonDown()
if self.animator then
return
end
playEffect("back")
self.onAbort()
end
Expand Down
Loading

0 comments on commit 2b43b9d

Please sign in to comment.