Type=Activity
Version=4.3
ModulesStructureVersion=1
B4A=true
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: False
#End Region

Sub Process_Globals
Dim sStage,sTime,sState,sScore,sGameNumber As String
End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.

	Dim lblstage As Label
	Dim lbltime As Label
	Dim imgstar As ImageView
	Dim lbltitle As Label
	Dim btnnext As Button
	Dim lblstate As Label
	Dim lblscore As Label
	Dim btnrepeat As Button
	Dim imgbackground As ImageView
End Sub

Sub Activity_Create(FirstTime As Boolean)
If sStage = 11 Then
 Activity.Finish
 frmGame1_final.sGame = sGameNumber
 StartActivity(frmGame1_final)
End If
Activity.LoadLayout("game1_result")
common.changeTheme(imgbackground)
lblstage.Text = "مرحله " & sStage & " از بازی"
lbltime.Text = sTime
lbltime.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
lblstage.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
lbltitle.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
btnnext.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
btnrepeat.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
If sState = "win" Then
 common.playAudio("win.mp3")
 imgstar.Bitmap = LoadBitmap(File.DirAssets,"star.png")
 lbltitle.Text = lbltitle.Text & " : شما برنده اید"
Else
 lbltitle.Text = lbltitle.Text & " : شما باختید"
 imgstar.Bitmap = LoadBitmap(File.DirAssets,"sad_star.jpg")
 common.playAudio("unwin.mp3")
 btnnext.Enabled = False
End If

lblscore.Text = sScore
lblscore.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")

If sScore < -10 Then
 lblstate.Text = "خیلی بد"
 lblstate.TextColor = Colors.RGB(255,0,0)
Else If sScore < 0 Then
 lblstate.TextColor = Colors.RGB(155,0,0)
 lblstate.Text = "بد"
Else If sScore > 40 Then
 lblstate.TextColor = Colors.RGB(0,255,0)
 lblstate.Text = "خیلی خوب"
Else If sScore > 20 Then
 lblstate.TextColor = Colors.RGB(0,150,0)
 lblstate.Text = "خوب"
End If

lblstate.Typeface = Typeface.LoadFromAssets("BNazanin.ttf")
loadMenu
settings.saveData("gameReport" & sGameNumber & ".app","stage" & sStage,sStage & "<>" & sScore & "<>" & sTime)
End Sub
Sub loadMenu
Activity.AddMenuItem2("تنظیمات","btnsetting",LoadBitmap(File.DirAssets,"setting.png"))
Activity.AddMenuItem2("درباره ما","btnabout",LoadBitmap(File.DirAssets,"about.png"))
Activity.AddMenuItem2("خروج","exit1",LoadBitmap(File.DirAssets,"exit.png"))
End Sub
Sub btnsetting_Click
Activity.Finish
StartActivity(setting)
End Sub
Sub btnabout_Click
Activity.Finish
StartActivity(frmabout)
End Sub
Sub exit1_Click
Dim i As Int
i = Msgbox2("آیا مایل به خروج هستید؟","خروج","آری","خیر","",Null)
If i = DialogResponse.POSITIVE Then
 ExitApplication
End If
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub btnnext_Click
If sStage = "" Then
 sStage = "1"
End If
settings.saveData("settingGame" & sGameNumber & ".app","timeout",settings.getData("settingGame" & sGameNumber & ".app","timeout") - 3)
settings.saveData("settingGame" & sGameNumber & ".app","stage",sStage + 1)
Activity.Finish
 Select Case sGameNumber
  Case "1"
   StartActivity(frmGame1)
  Case "3"
   StartActivity(frmGame3)
  Case "4"
   StartActivity(frmGame4)
  Case "5"
   StartActivity(frmGame5)
  Case "8"
   StartActivity(frmGame8)
  Case "9"
   StartActivity(frmGame9)
 End Select
End Sub
Sub btnrepeat_Click
Activity.Finish
 Select Case sGameNumber
  Case "1"
   StartActivity(frmGame1)
  Case "3"
   StartActivity(frmGame3)
  Case "4"
   StartActivity(frmGame4)
  Case "5"
   StartActivity(frmGame5)
  Case "8"
   StartActivity(frmGame8)
  Case "9"
   StartActivity(frmGame9)
 End Select
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
  If KeyCode = KeyCodes.KEYCODE_BACK Then
   Activity.Finish
   StartActivity(Main)
  End If
  If KeyCode = KeyCodes.KEYCODE_MENU Then
   Activity.OpenMenu
  End If
End Sub