Similar but different:Gablea wrote:Now I just have to work out how to use your code badidea :D
Code: Select all
#include "fbgfx.bi"
#include "vbcompat.bi"
const as integer QUIT_SCREEN = 0
const as integer BACKGROUND_SCREEN = 1
const as integer SIGNED_ON_SCREEN = 2
const as integer SCRN_W = 800, SCRN_H = 600
'-------------------------------------------------------------------------------
type Background_type
dim as integer unusedVariable
declare sub Display()
declare sub HandleInput(key as string, byref state as integer)
end type
sub Background_type.Display()
line(60, 60)-(SCRN_W - 60, SCRN_H - 60), &h00440044, bf
draw string (70, 70), "BACKGROUND_SCREEN"
draw string (70, 90), format(now, "yyyy-mm-dd hh:mm:ss")
locate 2, 1: print "Press <ENTER> for SignedOnScreen";
locate 3, 1: print "Press <ESCAPE> to exit program ";
end sub
sub Background_type.HandleInput(key as string, byref state as integer)
select case key
case chr(13)
state = SIGNED_ON_SCREEN
case chr(27)
state = QUIT_SCREEN
case else
end select
end sub
'-------------------------------------------------------------------------------
type SignedOnScreen_type
dim as string userName
declare sub Display()
declare sub HandleInput(key as string, byref state as integer)
end type
sub SignedOnScreen_type.Display()
line(160, 160)-(SCRN_W - 160, SCRN_H - 160), &h00004444, bf
draw string (170, 170), "SIGNED_ON_SCREEN"
draw string (170, 190), "userName: " + userName
locate 2, 1: print "Press <ESCAPE> to go back ";
locate 3, 1: print "Try typing user name ... ";
end sub
sub SignedOnScreen_type.HandleInput(key as string, byref state as integer)
select case key
case chr(27)
state = BACKGROUND_SCREEN
case chr(33) to chr(126) 'somwhat normal characters
if len(userName) < 40 then
userName += key
end if
case chr(8) 'backspace
if len(userName) > 0 then
userName = left(userName, len(userName) - 1)
end if
case else
end select
end sub
'-------------------------------------------------------------------------------
screenres SCRN_W, SCRN_H, 32
width SCRN_W \ 8, SCRN_H \ 16
'Makes instances of the about classes
dim as Background_type Background
dim as SignedOnScreen_type SignedOnScreen
dim as string key
dim as integer state = BACKGROUND_SCREEN
do
key = inkey
select case state
case BACKGROUND_SCREEN
Background.HandleInput(key, state)
case SIGNED_ON_SCREEN
SignedOnScreen.HandleInput(key, state)
end select
screenlock
Background.Display() 'always
locate 1, 1: print "state: " + str(state);
if state = SIGNED_ON_SCREEN then SignedOnScreen.Display()
screenunlock
sleep 1, 1
loop until state = QUIT_SCREEN