mirror of
https://github.com/FellippeHeitor/InForm.git
synced 2025-01-15 03:49:56 +00:00
438 lines
11 KiB
QBasic
438 lines
11 KiB
QBasic
': This program was generated by
|
||
': InForm - GUI system for QB64 - Beta version 1
|
||
': Fellippe Heitor, 2016 - fellippe@qb64.org - @fellippeheitor
|
||
'-----------------------------------------------------------
|
||
|
||
$UNSTABLE:MIDI
|
||
$MIDISOUNDFONT:DEFAULT
|
||
|
||
': Controls' IDs: ------------------------------------------------------------------
|
||
DIM SHARED MasterMindGuessTheSequence AS LONG
|
||
DIM SHARED SecretSequenceLB AS LONG
|
||
DIM SHARED WriteSequenceToTestTB AS LONG
|
||
DIM SHARED ListBox1 AS LONG
|
||
DIM SHARED TestSequenceBT AS LONG
|
||
DIM SHARED HelpBT AS LONG
|
||
DIM SHARED StartBT AS LONG
|
||
DIM SHARED OptionsBT AS LONG
|
||
DIM SHARED QuitBT AS LONG
|
||
DIM SHARED HelpLB AS LONG
|
||
DIM SHARED TrackBar1 AS LONG
|
||
DIM SHARED RadioButton1 AS LONG
|
||
DIM SHARED TrackBar1LB AS LONG
|
||
DIM SHARED MusicCB AS LONG
|
||
DIM SHARED MaxSequence AS INTEGER ' it set how numbers make the sequence
|
||
DIM SHARED ResulT AS STRING
|
||
DIM SHARED ma&
|
||
|
||
|
||
'$INCLUDE:'../../InForm/InForm.bi'
|
||
'$INCLUDE:'MasterMindGuessTheSequence.frm'
|
||
|
||
': Event procedures: ---------------------------------------------------------------
|
||
SUB __UI_BeforeInit
|
||
|
||
END SUB
|
||
|
||
SUB __UI_OnLoad
|
||
RANDOMIZE TIMER
|
||
MaxSequence = 4
|
||
Caption(SecretSequenceLB) = STR$(MaxSequence) + " Digits"
|
||
Control(SecretSequenceLB).Disabled = True
|
||
Control(ListBox1).Disabled = True
|
||
Control(WriteSequenceToTestTB).Disabled = True
|
||
Control(TestSequenceBT).Disabled = True
|
||
Caption(HelpLB) = "Help:" + CHR$(10) + " Options: set difficult of game, Tutor, Music " + CHR$(10) + " Help: this info" + CHR$(10) + " Quit:exit program" + CHR$(10) + " Start: begin the game" + CHR$(10) + " Reset: restart the game" + CHR$(10) + " HOW TO PLAY: click Start, type sequence, press Enter/click Test sequence"
|
||
Control(HelpLB).Hidden = True
|
||
Control(HelpLB).Disabled = True
|
||
Control(HelpLB).WordWrap = True
|
||
Control(TrackBar1).Value = 4
|
||
Control(TrackBar1).HasBorder = True
|
||
Control(TrackBar1).BorderColor = _RGB32(0, 255, 127)
|
||
Caption(TrackBar1) = LTRIM$(STR$(MaxSequence))
|
||
Control(TrackBar1).ForeColor = _RGB32(0, 0, 255)
|
||
Control(TrackBar1).Disabled = True
|
||
Caption(RadioButton1) = "Tutor"
|
||
Control(RadioButton1).Disabled = True
|
||
Caption(TrackBar1LB) = LTRIM$(STR$(MaxSequence))
|
||
ma& = _SNDOPEN("mozart_-_Turkish_March_in_Bb.mid")
|
||
Control(MusicCB).Disabled = True
|
||
END SUB
|
||
|
||
SUB __UI_BeforeUpdateDisplay
|
||
|
||
END SUB
|
||
|
||
SUB __UI_BeforeUnload
|
||
|
||
END SUB
|
||
|
||
SUB VictorY
|
||
Caption(SecretSequenceLB) = "YOU GOT IT. YOU WIN!!"
|
||
BEEP
|
||
_DELAY 2
|
||
BEEP
|
||
Caption(StartBT) = "Start"
|
||
ResetList ListBox1
|
||
Control(SecretSequenceLB).Disabled = True
|
||
Control(ListBox1).Disabled = True
|
||
Control(WriteSequenceToTestTB).Disabled = True
|
||
Control(TestSequenceBT).Disabled = True
|
||
Caption(SecretSequenceLB) = ""
|
||
Text(SecretSequenceLB) = ""
|
||
Control(RadioButton1).Value = False
|
||
END SUB
|
||
|
||
SUB CheckInput (stringa AS STRING)
|
||
DIM Goal AS STRING, z AS STRING, x AS STRING, visto AS STRING
|
||
DIM a AS INTEGER, b AS INTEGER
|
||
|
||
Goal = Text(SecretSequenceLB) 'sequence made at random at each start pushing and put in Text(iD) array
|
||
ResulT = " ": a = 0: b = 0: z = "": x = ""
|
||
visto = ""
|
||
Goal = Text(SecretSequenceLB)
|
||
|
||
IF stringa = Goal THEN
|
||
VictorY
|
||
EXIT SUB
|
||
END IF
|
||
|
||
FOR a = 1 TO MaxSequence
|
||
z = MID$(stringa, a, 1)
|
||
b = INSTR(1, Goal, z) ' z is in SecretSequenceLB
|
||
' if it is in the secret sequence then if it is at right place we get a X otherwise we get an O
|
||
IF b > 0 THEN
|
||
' if position of z in stringa is the same in Text(secretSequenceLB) we get X otherwise we get O z is in Text(secretSequenceLB) but in different position
|
||
IF INSTR(1, visto, z) = 0 THEN IF b = a THEN ResulT = ResulT + "X" ELSE ResulT = ResulT + "O"
|
||
ELSE
|
||
IF Control(RadioButton1).Value = True THEN ResulT = ResulT + "-"
|
||
END IF
|
||
visto = visto + z
|
||
NEXT
|
||
IF Control(RadioButton1).Value = False THEN IF LEN(ResulT) < MaxSequence THEN ResulT = ResulT + STRING$(MaxSequence - LEN(ResulT) + 1, "_") ' or ,"?") or ,"<22>")
|
||
AddItem ListBox1, stringa + "--> " + ResulT
|
||
Text(WriteSequenceToTestTB) = ""
|
||
ResulT = " "
|
||
END SUB
|
||
|
||
SUB __UI_Click (id AS LONG)
|
||
SELECT CASE id
|
||
CASE RadioButton1
|
||
|
||
CASE TrackBar1LB
|
||
|
||
CASE MusicCB
|
||
|
||
CASE MasterMindGuessTheSequence
|
||
|
||
CASE SecretSequenceLB
|
||
|
||
CASE WriteSequenceToTestTB
|
||
|
||
CASE ListBox1
|
||
|
||
CASE TestSequenceBT
|
||
IF LEN(Text(WriteSequenceToTestTB)) >= MaxSequence THEN
|
||
Text(WriteSequenceToTestTB) = LEFT$(Text(WriteSequenceToTestTB), MaxSequence)
|
||
CheckInput Text(WriteSequenceToTestTB)
|
||
ELSE
|
||
BEEP
|
||
Caption(SecretSequenceLB) = "Add " + STR$(MaxSequence - LEN(Text(WriteSequenceToTestTB))) + " Digits"
|
||
_DELAY 3
|
||
BEEP
|
||
Caption(SecretSequenceLB) = LTRIM$(STR$(MaxSequence)) + " Digits"
|
||
END IF
|
||
CASE HelpBT
|
||
Control(HelpLB).Hidden = False
|
||
Control(HelpLB).Disabled = False
|
||
|
||
|
||
CASE StartBT
|
||
IF Caption(StartBT) = "Start" THEN
|
||
Caption(StartBT) = "Reset"
|
||
Control(SecretSequenceLB).Disabled = False
|
||
Control(ListBox1).Disabled = False
|
||
Text(WriteSequenceToTestTB) = ""
|
||
Control(WriteSequenceToTestTB).Disabled = False
|
||
Control(TestSequenceBT).Disabled = False
|
||
CreateListToCheck
|
||
Caption(SecretSequenceLB) = STR$(MaxSequence) + " Digits" 'Text(SecretSequenceLB) ' debug statement
|
||
|
||
ELSE
|
||
Caption(StartBT) = "Start"
|
||
ResetList ListBox1
|
||
Control(SecretSequenceLB).Disabled = True
|
||
Text(WriteSequenceToTestTB) = ""
|
||
Control(ListBox1).Disabled = True
|
||
Control(WriteSequenceToTestTB).Disabled = True
|
||
Control(TestSequenceBT).Disabled = True
|
||
Caption(SecretSequenceLB) = STR$(MaxSequence) + " Digits"
|
||
Text(SecretSequenceLB) = ""
|
||
Control(RadioButton1).Value = False
|
||
END IF
|
||
CASE OptionsBT
|
||
IF Control(TrackBar1).Disabled = True THEN
|
||
Control(TrackBar1).Disabled = False
|
||
Control(RadioButton1).Disabled = False
|
||
IF ma& = 0 THEN Control(MusicCB).Disabled = True ELSE Control(MusicCB).Disabled = False
|
||
ELSE
|
||
Control(TrackBar1).Disabled = True
|
||
Control(RadioButton1).Disabled = True
|
||
Control(MusicCB).Disabled = True
|
||
END IF
|
||
|
||
CASE QuitBT
|
||
SYSTEM
|
||
CASE HelpLB
|
||
Control(HelpLB).Hidden = True
|
||
Control(HelpLB).Disabled = True
|
||
CASE TrackBar1
|
||
END SELECT
|
||
__UI_Focus = WriteSequenceToTestTB
|
||
END SUB
|
||
|
||
SUB CreateListToCheck
|
||
Text(SecretSequenceLB) = ""
|
||
a = 0: n = -1
|
||
FOR a = 1 TO MaxSequence
|
||
DO
|
||
n = CINT(RND * 9) ' cint(rnd * (9-0)+ 0
|
||
LOOP WHILE (INSTR(Text(SecretSequenceLB), LTRIM$(STR$(n)))) ' while n is in string SecretSequenceLB it creates another sequence item
|
||
Text(SecretSequenceLB) = Text(SecretSequenceLB) + LTRIM$(STR$(n))
|
||
NEXT
|
||
END SUB
|
||
|
||
SUB __UI_MouseEnter (id AS LONG)
|
||
SELECT CASE id
|
||
CASE HelpLB
|
||
|
||
CASE TrackBar1
|
||
|
||
CASE RadioButton1
|
||
|
||
CASE TrackBar1LB
|
||
|
||
CASE MusicCB
|
||
|
||
CASE MasterMindGuessTheSequence
|
||
|
||
CASE SecretSequenceLB
|
||
|
||
CASE WriteSequenceToTestTB
|
||
|
||
CASE ListBox1
|
||
|
||
CASE TestSequenceBT
|
||
|
||
CASE HelpBT
|
||
|
||
CASE StartBT
|
||
|
||
CASE OptionsBT
|
||
|
||
CASE QuitBT
|
||
|
||
END SELECT
|
||
END SUB
|
||
|
||
SUB __UI_MouseLeave (id AS LONG)
|
||
SELECT CASE id
|
||
CASE HelpLB
|
||
|
||
CASE TrackBar1
|
||
|
||
CASE RadioButton1
|
||
|
||
CASE TrackBar1LB
|
||
|
||
CASE MusicCB
|
||
|
||
CASE MasterMindGuessTheSequence
|
||
|
||
CASE SecretSequenceLB
|
||
|
||
CASE WriteSequenceToTestTB
|
||
|
||
CASE ListBox1
|
||
|
||
CASE TestSequenceBT
|
||
|
||
CASE HelpBT
|
||
|
||
CASE StartBT
|
||
|
||
CASE OptionsBT
|
||
|
||
CASE QuitBT
|
||
|
||
END SELECT
|
||
END SUB
|
||
|
||
SUB __UI_FocusIn (id AS LONG)
|
||
SELECT CASE id
|
||
CASE TrackBar1
|
||
|
||
CASE RadioButton1
|
||
|
||
CASE MusicCB
|
||
|
||
CASE WriteSequenceToTestTB
|
||
|
||
CASE ListBox1
|
||
|
||
CASE TestSequenceBT
|
||
|
||
CASE HelpBT
|
||
|
||
CASE StartBT
|
||
|
||
CASE OptionsBT
|
||
|
||
CASE QuitBT
|
||
|
||
END SELECT
|
||
END SUB
|
||
|
||
SUB __UI_FocusOut (id AS LONG)
|
||
SELECT CASE id
|
||
CASE TrackBar1
|
||
|
||
CASE RadioButton1
|
||
|
||
CASE MusicCB
|
||
|
||
CASE WriteSequenceToTestTB
|
||
|
||
CASE ListBox1
|
||
|
||
CASE TestSequenceBT
|
||
|
||
CASE HelpBT
|
||
|
||
CASE StartBT
|
||
|
||
CASE OptionsBT
|
||
|
||
CASE QuitBT
|
||
|
||
END SELECT
|
||
END SUB
|
||
|
||
SUB __UI_MouseDown (id AS LONG)
|
||
SELECT CASE id
|
||
CASE HelpLB
|
||
|
||
CASE TrackBar1
|
||
|
||
CASE RadioButton1
|
||
|
||
CASE TrackBar1LB
|
||
|
||
CASE MusicCB
|
||
|
||
CASE MasterMindGuessTheSequence
|
||
|
||
CASE SecretSequenceLB
|
||
|
||
CASE WriteSequenceToTestTB
|
||
|
||
CASE ListBox1
|
||
|
||
CASE TestSequenceBT
|
||
|
||
CASE HelpBT
|
||
|
||
CASE StartBT
|
||
|
||
CASE OptionsBT
|
||
|
||
CASE QuitBT
|
||
|
||
END SELECT
|
||
END SUB
|
||
|
||
SUB __UI_MouseUp (id AS LONG)
|
||
SELECT CASE id
|
||
CASE HelpLB
|
||
|
||
CASE TrackBar1
|
||
|
||
CASE RadioButton1
|
||
|
||
CASE TrackBar1LB
|
||
|
||
CASE MusicCB
|
||
|
||
CASE MasterMindGuessTheSequence
|
||
|
||
CASE SecretSequenceLB
|
||
|
||
CASE WriteSequenceToTestTB
|
||
|
||
CASE ListBox1
|
||
|
||
CASE TestSequenceBT
|
||
|
||
CASE HelpBT
|
||
|
||
CASE StartBT
|
||
|
||
CASE OptionsBT
|
||
|
||
CASE QuitBT
|
||
|
||
END SELECT
|
||
END SUB
|
||
|
||
SUB __UI_KeyPress (id AS LONG)
|
||
SELECT CASE id
|
||
CASE TrackBar1
|
||
|
||
CASE RadioButton1
|
||
|
||
CASE MusicCB
|
||
|
||
CASE WriteSequenceToTestTB
|
||
IF __UI_KeyHit = 13 THEN __UI_Click TestSequenceBT
|
||
CASE ListBox1
|
||
|
||
CASE TestSequenceBT
|
||
|
||
CASE HelpBT
|
||
|
||
CASE StartBT
|
||
|
||
CASE OptionsBT
|
||
|
||
CASE QuitBT
|
||
|
||
END SELECT
|
||
END SUB
|
||
|
||
SUB __UI_TextChanged (id AS LONG)
|
||
SELECT CASE id
|
||
CASE WriteSequenceToTestTB
|
||
Text(WriteSequenceToTestTB) = LTRIM$(Text(WriteSequenceToTestTB))
|
||
END SELECT
|
||
END SUB
|
||
|
||
SUB __UI_ValueChanged (id AS LONG)
|
||
SELECT CASE id
|
||
CASE RadioButton1
|
||
|
||
CASE ListBox1
|
||
|
||
CASE TrackBar1
|
||
MaxSequence = Control(TrackBar1).Value
|
||
ToolTip(TrackBar1) = LTRIM$(STR$(MaxSequence))
|
||
Caption(TrackBar1LB) = LTRIM$(STR$(MaxSequence))
|
||
CASE MusicCB
|
||
IF Control(MusicCB).Value = True THEN _SNDLOOP ma& ELSE _SNDSTOP ma&
|
||
END SELECT
|
||
END SUB
|
||
|
||
SUB __UI_FormResized
|
||
END SUB
|
||
|
||
'$INCLUDE:'../../InForm/InForm.ui'
|
||
'$INCLUDE:'../../InForm/xp.uitheme'
|