Skip to content

Commit

Permalink
Add warning/notification for language options
Browse files Browse the repository at this point in the history
+ Add strings for language option dialog box
  • Loading branch information
sekodev committed May 23, 2023
1 parent a862927 commit a74071b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 7 deletions.
5 changes: 4 additions & 1 deletion main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ local function assignVariables()
composer.setVariable( "isQuestionResetNeeded", true ) -- Used to fix a consistency between versions

composer.setVariable( "isTermsPrivacyAccepted", false ) -- Privacy policy & terms of use information flag
composer.setVariable( "isLanguageOptionShown", false ) -- Language option notification flag

-- Statistics variables
composer.setVariable( "scoreHigh", 0 )
Expand Down Expand Up @@ -147,6 +148,7 @@ local function loadPreferences()
composer.setVariable( "savedIsRevived", preference.getValue("settings")[33] )
composer.setVariable( "isTermsPrivacyAccepted", preference.getValue("settings")[34] )
composer.setVariable( "fullScreen", preference.getValue("settings")[35] )
composer.setVariable( "isLanguageOptionShown", preference.getValue("settings")[36] )
end
end

Expand Down Expand Up @@ -187,7 +189,8 @@ function savePreferences()
composer.getVariable( "savedPlayerScore" ),
composer.getVariable( "savedIsRevived" ),
composer.getVariable( "isTermsPrivacyAccepted" ),
composer.getVariable( "fullScreen" ), } }
composer.getVariable( "fullScreen" ),
composer.getVariable( "isLanguageOptionShown" ), } }
end

-- Reset preferences file
Expand Down
45 changes: 39 additions & 6 deletions screens/menuScreen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -569,15 +569,15 @@ local function createMenuElements()
end
end

-- Close progress reset dialog box
local function closeDialogBox()
-- Close URL redirection warning box
local function closeURLWarningBox()
utils.clearDisplayGroup(URLGroup)
end

-- Open URL after user confirmation
local function openURL()
system.openURL( URLselected )
closeDialogBox()
closeURLWarningBox()
end

-- Handle touch events for permission dialog box
Expand All @@ -593,16 +593,16 @@ local function handlePermissionTouch(event)
local dialogTextBody = sozluk.getString("openURLQuestion") .. "\n\n" .. URLselected

-- Declare options for dialog box creation
local optionsDialogBox = {
local optionsURLDialogBox = {
fontDialog = fontLogo,
dialogText = dialogTextBody,
confirmText = sozluk.getString("openURLConfirm"),
confirmFunction = openURL,
denyText = sozluk.getString("openURLDeny"),
denyFunction = closeDialogBox,
denyFunction = closeURLWarningBox,
}

utils.showDialogBox(URLGroup, optionsDialogBox)
utils.showDialogBox(URLGroup, optionsURLDialogBox)
elseif (event.target.id == "acceptTerms") then
composer.setVariable( "isTermsPrivacyAccepted", true )

Expand Down Expand Up @@ -731,6 +731,23 @@ local function showPermissionRequest()
infoGroup.alpha = 1
end

-- Close language notification box
local function closeLanguageNotificationBox()
utils.clearDisplayGroup(infoGroup)

composer.setVariable( "isLanguageOptionShown", true )
savePreferences()
end

-- Switch scene to Settings
local function gotoSettings()
composer.setVariable( "isLanguageOptionShown", true )
savePreferences()

local optionsChangeScene = {effect = "tossLeft", time = timeTransitionScene, params = {callSource = "menuScreen"}}
composer.gotoScene( "screens.settingScreen", optionsChangeScene )
end

-- Handle system events such as resuming/suspending the game/application
function onSystemEvent(event)
if( event.type == "applicationResume" ) then
Expand Down Expand Up @@ -816,6 +833,22 @@ function scene:show( event )
local isTermsPrivacyAccepted = composer.getVariable( "isTermsPrivacyAccepted" )
if (not isTermsPrivacyAccepted) then
showPermissionRequest()
else
-- Show user dialog box informing them about language options in Settings
local isLanguageOptionShown = composer.getVariable( "isLanguageOptionShown" )

if (not isLanguageOptionShown) then
-- Declare options for dialog box creation
local optionsLanguageOptionBox = {
fontDialog = fontLogo,
dialogText = sozluk.getString("languageNotificationInformation"),
confirmText = sozluk.getString("languageNotificationConfirm"),
confirmFunction = gotoSettings,
denyText = sozluk.getString("languageNotificationDeny"),
denyFunction = closeLanguageNotificationBox,
}
utils.showDialogBox(infoGroup, optionsLanguageOptionBox)
end
end

audio.setVolume( composer.getVariable( "soundLevel" ), {channel = 3} )
Expand Down
3 changes: 3 additions & 0 deletions translations/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ function translationSetup.getData()
translationData["openURLQuestion"] = "This link will take you outside of the application to the following address:"
translationData["openURLConfirm"] = "Confirm"
translationData["openURLDeny"] = "Deny"
translationData["languageNotificationInformation"] = "You can change your language preferences through Settings and try the game in Turkish."
translationData["languageNotificationConfirm"] = "Go to Settings"
translationData["languageNotificationDeny"] = "OK"
translationData["score"] = "Score"
translationData["highScore"] = "High score!"
translationData["developedBy"] = "Developer"
Expand Down
3 changes: 3 additions & 0 deletions translations/tr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ function translationSetup.getData()
translationData["openURLQuestion"] = "Bu bağlantı sizi uygulama dışına, aşağıdaki adrese yönlendirecek."
translationData["openURLConfirm"] = "Onayla"
translationData["openURLDeny"] = "Vazgeç"
translationData["languageNotificationInformation"] = "Ayarlar ekranından dil tercihinizi değiştirebilir, oyunu İngilizce oynayabilirsiniz."
translationData["languageNotificationConfirm"] = "Ayarlar'a git"
translationData["languageNotificationDeny"] = "Tamam"
translationData["score"] = "Puan"
translationData["highScore"] = "Rekor!"
translationData["developedBy"] = "Geliştirici"
Expand Down

0 comments on commit a74071b

Please sign in to comment.