Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 0.9.2 #7

Merged
merged 4 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 140 additions & 1 deletion libs/commonMethods.lua
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function commonMethods.useLock(infoGroup, tableTimers, locksAvailable, textNumLo
end

-- Show number of locks available to use
function commonMethods.showLocksAvailable(targetGroup, yTopInfoBox, locksAvailable)
local function showLocksAvailable(targetGroup, yTopInfoBox, locksAvailable)
local fontLogo = composer.getVariable( "fontLogo" )

local colorTextDefault = themeData.colorTextDefault
Expand All @@ -306,6 +306,145 @@ function commonMethods.showLocksAvailable(targetGroup, yTopInfoBox, locksAvailab
targetGroup:insert(imageLock.textNumAvailable)
end

-- Change lock state and show information based on taps/clicks
function commonMethods.switchLock(buttonLock, infoGroup, locksAvailable, soundLock, fontLockUsed)
local lockInfoAvailable = composer.getVariable( "lockInfoAvailable" )
local colorPadlock = themeData.colorPadlock

-- Only change the flag as activated
-- This change will be used later on button press("Play") and scene change
if (buttonLock.isActivated) then
buttonLock.isActivated = false
buttonLock.alpha = buttonLock.alphaInactive
buttonLock:setFillColor( unpack(colorPadlock) )
else
audio.play( soundLock, {channel = 2} )

-- Check to see if information about lock system will be shown
-- If player discarded the message and chose "Don't show again", don't show info box
if (lockInfoAvailable) then
if (locksAvailable > 0) then
buttonLock.isActivated = true
buttonLock.alpha = 1
end

local infoText
local isPromptAvailable = true
if (locksAvailable > 0) then
infoText = sozluk.getString("lockInformation")
else
infoText = sozluk.getString("lockInformationNA")
isPromptAvailable = false
end

-- Declare options for information box creation
local optionsInfoBox = {
infoFont = fontLockUsed,
infoText = infoText,
isPromptAvailable = isPromptAvailable,
stringPromptPreference = "lockInfoAvailable",
}
yTopFrame = utils.showInformationBox(infoGroup, optionsInfoBox)
showLocksAvailable(infoGroup, yTopFrame, locksAvailable)
else
if (locksAvailable > 0) then
buttonLock.isActivated = true
buttonLock.alpha = 1
else
local infoText
local isPromptAvailable = true
if (locksAvailable <= 0) then
infoText = sozluk.getString("lockInformationNA")
isPromptAvailable = false
end

-- Declare options for information box creation
local optionsInfoBox = {
infoFont = fontLockUsed,
infoText = infoText,
isPromptAvailable = isPromptAvailable,
stringPromptPreference = "lockInfoAvailable",
}
yTopFrame = utils.showInformationBox(infoGroup, optionsInfoBox)
showLocksAvailable(infoGroup, yTopFrame, locksAvailable)
end
end
end
end

-- Handle touch events for navigation buttons
-- Calls assigned function when corresponding option is selected
local function handleNavigationTouch(event)
if (event.phase == "ended") then
event.target.methodAssigned()
end
return true
end

-- Creates navigation menu with back button
function commonMethods.createNavigationMenu(targetGroup, optionsNavigationMenu)
local position = optionsNavigationMenu["position"]
local fontName = optionsNavigationMenu["fontName"]
local backFunction = optionsNavigationMenu["backFunction"]

local colorBackground = themeData.colorBackground
local colorButtonFillDefault = themeData.colorButtonFillDefault
local colorButtonDefault = themeData.colorButtonDefault
local colorButtonOver = themeData.colorButtonOver
local colorTextDefault = themeData.colorTextDefault
local colorSeparator = themeData.colorSeparator

local background = display.newRect( targetGroup, display.contentCenterX, display.contentCenterY, contentWidth, contentHeight )
background:setFillColor( unpack(colorBackground) )
background:addEventListener( "touch", function () return true end )

local optionsButtonBack =
{
shape = "rect",
fillColor = { default = colorButtonFillDefault, over = colorButtonFillDefault },
width = contentWidthSafe / 6,
height = contentHeightSafe / 10,
label = "<",
labelColor = { default = colorButtonDefault, over = colorButtonOver },
font = fontName,
fontSize = contentHeightSafe / 15,
id = "buttonBack",
onEvent = handleNavigationTouch,
}
local buttonBack = widget.newButton( optionsButtonBack )
buttonBack.x = buttonBack.width / 2
if (position == "top") then
buttonBack.y = display.safeScreenOriginY + buttonBack.height / 2
elseif (position == "bottom") then
buttonBack.y = contentHeightSafe - buttonBack.height / 2
end
buttonBack.methodAssigned = backFunction
targetGroup:insert( buttonBack )


local yStartingPlacement

local menuSeparator = display.newRect( targetGroup, background.x, 0, background.width, 10 )

menuSeparator:setFillColor( unpack(colorSeparator) )

if (position == "top") then
menuSeparator.y = buttonBack.y + buttonBack.height / 2 + menuSeparator.height
yStartingPlacement = menuSeparator.y + menuSeparator.height / 2

background.height = (menuSeparator.y + menuSeparator.height / 2) - display.safeScreenOriginY
background.y = display.safeScreenOriginY + background.height / 2
elseif (position == "bottom") then
menuSeparator.y = buttonBack.y - buttonBack.height / 2 - menuSeparator.height
yStartingPlacement = menuSeparator.y - menuSeparator.height / 2

background.height = contentHeight - yStartingPlacement
background.y = contentHeight - background.height / 2
end

return yStartingPlacement
end

-- Handles touch events when in-game share UI is shown
local function handleShareTouch(event)
if (event.phase == "ended") then
Expand Down
75 changes: 75 additions & 0 deletions libs/infoCredits.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
local infoCredits = {}

function infoCredits.getData()
local creditsData = {}
creditsData.entries = {}

----------------------------
-- START OF EDITABLE AREA

creditsData.entries[1] = {
imagePath = { dark = "assets/other/logoSleepyBug.png", light = "assets/other/logoSleepyBug.png", width = 650, height = 155 }
}

creditsData.entries[2] = {
title = sozluk.getString("developedBy"),
people = { { fullName = "Serkan Aksit" } }
}

creditsData.entries[3] = {
title = sozluk.getString("testedBy"),
people = { { fullName = "Bilge Kol" } }
}

creditsData.entries[4] = {
title = sozluk.getString("serverSideBy") .. "\n" .. sozluk.getString("prev04"),
people = { { fullName = "Can Ertong" } }
}

creditsData.entries[5] = {
title = sozluk.getString("music"),
people = {
{ fullName = "Automation", author = "Eric Matyas", hyperlink = "https://soundimage.org/looping-music/" },
{ fullName = "Safe Cracking", author = "Eric Matyas", hyperlink = "https://soundimage.org/city-urban-2/" },
}
}

creditsData.entries[6] = {
title = sozluk.getString("soundFX"),
people = {
{ fullName = "freesound.org/404151/", author = "Mattias 'MATTIX' Lahoud", hyperlink = "https://freesound.org/people/MATTIX/sounds/404151/" },
{ fullName = "freesound.org/216090/", author = "RICHERlandTV", hyperlink = "https://freesound.org/people/RICHERlandTV/sounds/216090/" },
{ fullName = "freesound.org/264981/", author = "renatalmar", hyperlink = "https://freesound.org/people/renatalmar/sounds/264981/" },
{ fullName = "freesound.org/387713/", author = "Jagadamba", hyperlink = "https://freesound.org/people/Jagadamba/sounds/387713/" },
{ fullName = "freesound.org/80600/", author = "severaltimes", hyperlink = "https://freesound.org/people/severaltimes/sounds/80600/" },
{ fullName = "freesound.org/392465/\n" .. sozluk.getString("shortenedUse"), author = "ModulationStation", hyperlink = "https://freesound.org/people/ModulationStation/sounds/392465/" },
{ fullName = ".", author = sozluk.getString("disclaimerSoundLicense") },
}
}

creditsData.entries[7] = {
title = sozluk.getString("font"),
people = {
{ fullName = "Russo One", author = "Jovanny Lemonad", hyperlink = "https://www.dafont.com/russo-one.font" },
{ fullName = ".", author = sozluk.getString("disclaimerFont"), hyperlink = "https://scripts.sil.org/OFL" },
}
}

creditsData.entries[8] = {
title = sozluk.getString("poweredBy"),
imagePath = { dark = "assets/other/logoSolar2D.png", light = "assets/other/logoSolar2D-light.png",
width = 572, height = 200, hyperlink = "https://solar2d.com/", }
}

creditsData.entries[9] = {
people = { { fullName = "***", author = sozluk.getString("disclaimerCopyright") } }
}

-- END OF EDITABLE AREA
----------------------------

return creditsData
end


return infoCredits
12 changes: 10 additions & 2 deletions libs/themeSettings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ function themeSettings.getData(themeSelected)
-- themes: dark - light

if (themeSelected == "dark") then
themeData.themeSelected = "dark"
themeData.nameSelected = "dark"

themeData.colorBackground = { 0, 0, 0 }
themeData.colorBackgroundPopup = { .917, .917, .843 }

themeData.colorSeparator = { .99, .82, .009 }

themeData.colorButtonFillDefault = themeData.colorBackground
themeData.colorButtonFillOver = { .917, .917, .843 }
themeData.colorButtonDefault = { .917, .917, .843 }
Expand All @@ -39,6 +41,8 @@ function themeSettings.getData(themeSelected)

themeData.colorPadlock = { .878, 0, 0 }

themeData.colorTitle = { 1, 0, 0 }

themeData.colorTextDefault = { .917, .917, .843 }
themeData.colorTextOver = { 0, 0, 0 }
themeData.colorTextSelected = { .917, .917, .843 }
Expand All @@ -54,11 +58,13 @@ function themeSettings.getData(themeSelected)
themeData.colorHyperlinkPopup = { 0, 0, 1 }
themeData.colorHyperlinkPopupVisited = { .56, .85, .85 }
elseif (themeSelected == "light") then
themeData.themeSelected = "light"
themeData.nameSelected = "light"

themeData.colorBackground = { 1, 1, .922 }
themeData.colorBackgroundPopup = { 0, 0, 0 }

themeData.colorSeparator = { .99, .82, .009 }

themeData.colorButtonFillDefault = themeData.colorBackground
themeData.colorButtonFillOver = { 0, 0, 0 }
themeData.colorButtonDefault = { 0, 0, 0 }
Expand All @@ -75,6 +81,8 @@ function themeSettings.getData(themeSelected)

themeData.colorPadlock = { .878, 0, 0 }

themeData.colorTitle = { 1, 0, 0 }

themeData.colorTextDefault = { 0, 0, 0 }
themeData.colorTextOver = { 0, 0, 0 }
themeData.colorTextSelected = { .917, .917, .843 }
Expand Down
52 changes: 42 additions & 10 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ local function assignVariables()
composer.setVariable( "userToken", "" )

composer.setVariable( "emailSupport", "[email protected]" ) -- Used to show player a way to get in contact
composer.setVariable( "currentVersion" , "OpenBilgi, v0.9.1 (67)" ) -- Visible in Settings screen
composer.setVariable( "currentVersion" , "bilgi, v0.9.2 (72)" ) -- Visible in Settings screen
composer.setVariable( "idAppStore" , "123456789" ) -- Required to show rating pop-ups
composer.setVariable( "urlLandingPage" , "https://sekodev.github.io/bilgiWeb/" ) -- Required for sharing landing page on social media
composer.setVariable( "pathIconFile" , "assets/menu/iconQuiz.png" ) -- Required for share UI
Expand All @@ -51,7 +51,22 @@ local function assignVariables()
composer.setVariable( "languageSelected" , "") -- Default: ""
composer.setVariable( "fullScreen" , true) -- Full screen support - Default: true
composer.setVariable( "currentAppScene" , "menuScreen") -- Required for back button on Android
composer.setVariable( "timeTransitionScene", 250 ) -- Used in every scene change

composer.setVariable( "isMotionReduced", false )
-- Activate "reduce motion" based on device settings on iOS, tvOS and macOS
if (system.getInfo( "platform" ) == "ios" or
system.getInfo( "platform" ) == "tvos" or
system.getInfo( "platform" ) == "macos") then

if (system.getInfo( "reduceMotion" )) then
composer.setVariable( "isMotionReduced", true )
end
end

composer.setVariable( "sceneTransitionTime", 250 ) -- Used in every scene change
composer.setVariable( "sceneTransitionEffect", "tossLeft" ) -- Used in every scene change
composer.setVariable( "sceneTransitionEffectDefault", "tossLeft" ) -- Not saved but used as variable in settings
composer.setVariable( "sceneTransitionEffectReduceMotion", "crossFade" ) -- Not saved but used as variable in settings

composer.setVariable( "fontIngame", "Arial" )
composer.setVariable( "fontLogo", "Russo_One.ttf" )
Expand Down Expand Up @@ -151,6 +166,7 @@ local function loadPreferences()
composer.setVariable( "fullScreen", preference.getValue("settings")[35] )
composer.setVariable( "isLanguageOptionShown", preference.getValue("settings")[36] )
composer.setVariable( "languageSelected", preference.getValue("settings")[37] )
composer.setVariable( "isMotionReduced", preference.getValue("settings")[38] )
end
end

Expand Down Expand Up @@ -193,7 +209,8 @@ function savePreferences()
composer.getVariable( "isTermsPrivacyAccepted" ),
composer.getVariable( "fullScreen" ),
composer.getVariable( "isLanguageOptionShown" ),
composer.getVariable( "languageSelected" ), } }
composer.getVariable( "languageSelected" ),
composer.getVariable( "isMotionReduced" ), } }
end

-- Reset preferences file
Expand Down Expand Up @@ -285,6 +302,20 @@ function adjustScreenDimensions(fullScreen)
end
end

-- Set transition effect based on "Reduce motion" option
local function setSceneTransitionEffect()
local isMotionReduced = composer.getVariable( "isMotionReduced" )
local sceneTransitionEffect = composer.getVariable( "sceneTransitionEffect" )

if (isMotionReduced) then
sceneTransitionEffect = composer.getVariable( "sceneTransitionEffectReduceMotion" )
end

composer.setVariable( "sceneTransitionEffect", sceneTransitionEffect )

return sceneTransitionEffect
end


assignVariables()

Expand All @@ -294,6 +325,9 @@ loadPreferences()
-- Adjust screen dimensions depending on full screen option
adjustScreenDimensions(composer.getVariable( "fullScreen" ))

local sceneTransitionTime = composer.getVariable( "sceneTransitionTime" )
local sceneTransitionEffect = setSceneTransitionEffect()

-- Import sozluk library for localization
-- https://github.com/sekodev/sozluk
sozluk = require ( "libs.sozluk" )
Expand Down Expand Up @@ -346,8 +380,6 @@ for i = 2, audio.totalChannels do
end


local timeTransitionScene = composer.getVariable( "timeTransitionScene" )

-- Back button behavior for Android
local function onKeyEvent( event )
if ( event.keyName == "back" and event.phase == "up" ) then
Expand All @@ -358,16 +390,16 @@ local function onKeyEvent( event )
elseif ( currentAppScene == "gameScreen" ) then
composer.setVariable( "currentAppScene", "menuScreen" )

audio.fade( {channel = channelMusicBackground, time = timeTransitionScene, volume = 0} )
audio.fade( {channel = channelMusicBackground, time = sceneTransitionTime, volume = 0} )

local optionsChangeScene = {effect = "tossLeft", time = timeTransitionScene, params = {callSource = currentAppScene}}
local optionsChangeScene = {effect = sceneTransitionEffect, time = sceneTransitionTime, params = {callSource = currentAppScene}}
composer.gotoScene( "screens.menuScreen", optionsChangeScene )
else
composer.setVariable( "currentAppScene", "menuScreen" )

--audio.fade( {channel = channelMusicBackground, time = timeTransitionScene, volume = 0} )
--audio.fade( {channel = channelMusicBackground, time = sceneTransitionTime, volume = 0} )

local optionsChangeScene = {effect = "tossLeft", time = timeTransitionScene, params = {callSource = currentAppScene}}
local optionsChangeScene = {effect = sceneTransitionEffect, time = sceneTransitionTime, params = {callSource = currentAppScene}}
composer.gotoScene( "screens.menuScreen", optionsChangeScene )
end
return true
Expand All @@ -378,6 +410,6 @@ Runtime:addEventListener( "key", onKeyEvent )


-- After everything is done, switch to logo screen to start the game
local optionsChangeScene = {effect = "tossLeft", time = timeTransitionScene,
local optionsChangeScene = {effect = sceneTransitionEffect, time = sceneTransitionTime,
params = {callSource = "main"}}
composer.gotoScene( "screens.logoScreen", optionsChangeScene )
Loading