Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Customizable Program Display
#1
Here's a little showcase of something which I'm working on for a personal little project of mine, which I thought folks might like to take a look at -- an user customizable-display program.

Code: (Select All)
'Set compiler and global progeam options
'All variables and arrays are dynamic by default
'$Dynamic
'Allow the use of color names for 32-bit screen mode
$Color:32
''$INCLUDE:'Keyboard Library.BI'
_Define A-Z As LONG  'default variable type is long
_Title "Title TBD"



'Types and global variables
Dim Shared As Long ScreenWidth, ScreenHeight, DisplayScreen, WorkScreen, ReDrawScreen
Dim Shared As Long Font(10), FontSize, Brightness
Dim Shared As Long True, False

'Defaut vaues for global variables
ScreenWidth = 1280
ScreenHeight = 720
DisplayScreen = _NewImage(ScreenWidth, ScreenHeight, 32)
WorkScreen = _NewImage(ScreenWidth, 32000, 32)
True = -1: False = 0
ReDrawScreen = 0
Font(0) = _LoadFont("courbd.ttf", 6, "monospace")
Font(1) = _LoadFont("courbd.ttf", 8, "monospace")
Font(2) = _LoadFont("courbd.ttf", 10, "monospace")
Font(3) = _LoadFont("courbd.ttf", 12, "monospace")
Font(4) = _LoadFont("courbd.ttf", 14, "monospace")
Font(5) = _LoadFont("courbd.ttf", 16, "monospace")
Font(6) = _LoadFont("courbd.ttf", 18, "monospace")
Font(7) = _LoadFont("courbd.ttf", 22, "monospace")
Font(8) = _LoadFont("courbd.ttf", 28, "monospace")
Font(9) = _LoadFont("courbd.ttf", 36, "monospace")
Font(10) = _LoadFont("courbd.ttf", 48, "monospace")
FontSize = 8 'starting font size
Brightness = 5

Screen DisplayScreen
_Delay .2
_Dest WorkScreen
_Font Font(FontSize)
Color _RGB32(255 \ Brightness), 0



Do
    ProcessInput
    Cls , 0
    Print _Width(DisplayScreen), _Height(DisplayScreen)

    _PutImage , WorkScreen, DisplayScreen, (0, 0)-Step(_Width(DisplayScreen), _Height(DisplayScreen))
    _Limit 60
    _Display
Loop

Sub ProcessInput
    While _MouseInput: MouseScroll = MouseScroll + _MouseWheel: Wend
    K = _KeyHit

    If _KeyDown(100306) Or _KeyDown(100305) Then CTRL = True Else CTRL = False
    If _KeyDown(100304) Or _KeyDown(100303) Then SHIFT = True Else SHIFT = False
    If _KeyDown(100308) Or _KeyDown(100307) Then ALT = True Else ALT = False
    Select Case K
        Case 19200 'left
            If CTRL Then
                If ScreenWidth >= 650 Then ScreenWidth = ScreenWidth - _FontWidth: AutoResize
            ElseIf ALT Then
                If FontSize > 0 Then FontSize = FontSize - 1: _Font Font(FontSize): AutoResize

            End If
        Case 18432 'up
            If CTRL Then
                If ScreenHeight >= 410 Then ScreenHeight = ScreenHeight - _FontHeight: AutoResize
            ElseIf ALT Then
                If Brightness > 1 Then Brightness = Brightness - 1: Color _RGB32(255 \ Brightness), 0

            End If
        Case 19712 'right
            If CTRL Then
                If ScreenWidth <= _DesktopWidth - 10 Then ScreenWidth = ScreenWidth + _FontWidth: AutoResize
            ElseIf ALT Then
                If FontSize < 10 Then FontSize = FontSize + 1: _Font Font(FontSize): AutoResize

            End If
        Case 20480 'down
            If CTRL Then
                If ScreenHeight <= _DesktopHeight - 10 Then ScreenHeight = ScreenHeight + _FontHeight: AutoResize
            ElseIf ALT Then
                If Brightness < 10 Then Brightness = Brightness + 1: Color _RGB32(255 \ Brightness), 0


            End If
        Case 27
            System
    End Select


End Sub

Sub AutoResize
    Static OldFontSize

    W = _Width(DisplayScreen): H = _Height(DisplayScreen)
    FW = _FontWidth: FH = _FontHeight
    RW = ScreenWidth: RH = ScreenHeight

    RW = _Round(RW / FW) * FW
    RH = _Round(RH / FH) * FH
    ScreenWidth = RW: ScreenHeight = RH

    tempscreen = _NewImage(RW, RH, 32)
    Screen tempscreen
    _FreeImage DisplayScreen
    DisplayScreen = tempscreen

    tempscreen = _NewImage(RW, 32000, 32) 'create the newly sized WorkScreen
    _Dest tempscreen 'can't freeimage a screen if it's in use?
    _FreeImage WorkScreen 'free the old WorkScreen
    WorkScreen = tempscreen
    _Dest WorkScreen
    _Font Font(FontSize)
    Color _RGB32(255 \ Brightness), 0


    OldFontSize = FontSize
    ReDrawScreen = -1
End Sub


''$INCLUDE:'Keyboard Library.BM'


Now, since I couldn't get $RESIZE:ON to work the way I was wanting, with a limit for size, I took it out of this program.  Instead, the user here now has several options, all of which are keyboard operated:

CTRL + Arrow Keys = Resize the screen.  You can make this program bigger or smaller, on the fly.

ALT + Left/Right Arrow = Increase or Decrease the size of the font on the screen.  Notice that this can also change the size of the screen slightly to suit the new fontwidth and fontheight.

ALT + Up/Down Arrow = Increase or Decrease the brightness of the text on the screen.  Late at night, I tend to do things with the lights off and while sitting in the dark a lot of the times, and a bright display ends up hurting my eyes.  This corrects that issue by allowing us to adjust the brightness of the text so that we can might it more intense in times of high surrounding light, or turn it waaay down, if we prefer, for use in the dark.

Now, we're not actually doing anything with this program as of yet, but it does use two distinct screens for us -- a WorkScreen and a DisplayScreen.  The WorkScreen is 32000 pixels in height, so we can print multiple pages of text upon it, and then display segments upon the DisplayScreen, for ease of scrolling up and down with screens which hold more than a single page of information.

I'll be adding word wrap along with the auto-resizing features, and then the basic interface will more-or-less be done for my needs.  If you guys want, I'll post a version of this with a nice long page of junk and word wrap to bring it all together, but I thought I'd go ahead and share it as it is, in case anyone else would ever be interested in making use of this type of user-interactive interface.  Personally, I think it'd make a nice little way to allow the user some display options for something like a text-adventure game, or any type of program which would be heavy on text usage.  

As I get older, I find it's always nice to be able to make text a little bigger/smaller and brighter/dimmer, depending on the state of my poor eyes.  What we have here is basically just a little plug-in routine which is ready built to handle most of that for us already.  With just a few minor enhancements, I imagine this will be something which I might end up making a lot of use of in the future.  Smile
Reply


Messages In This Thread
Customizable Program Display - by SMcNeill - 08-02-2022, 05:00 AM
RE: Customizable Program Display - by bplus - 08-02-2022, 03:40 PM
RE: Customizable Program Display - by SMcNeill - 08-03-2022, 01:20 AM
RE: Customizable Program Display - by Pete - 08-03-2022, 03:29 AM
RE: Customizable Program Display - by admin - 08-03-2022, 03:56 AM
RE: Customizable Program Display - by admin - 08-03-2022, 03:58 AM
RE: Customizable Program Display - by Pete - 08-03-2022, 04:22 AM
RE: Customizable Program Display - by SMcNeill - 08-03-2022, 05:13 AM
RE: Customizable Program Display - by Pete - 08-03-2022, 05:31 AM
RE: Customizable Program Display - by SMcNeill - 08-03-2022, 05:57 AM
RE: Customizable Program Display - by Pete - 08-03-2022, 06:46 AM
RE: Customizable Program Display - by SMcNeill - 08-03-2022, 07:17 AM
RE: Customizable Program Display - by Pete - 08-03-2022, 07:54 AM
RE: Customizable Program Display - by SMcNeill - 08-03-2022, 08:17 AM
RE: Customizable Program Display - by Pete - 08-03-2022, 04:30 PM



Users browsing this thread: 1 Guest(s)