QB64-PE Sample Showcase
#4
Update to showcase the author's name as well. The screen is a little more cramped now, but I can't believe I forgot and left that off.

Work in progress; what can I say?

Code: (Select All)
'QB64-PE Sample Showcase
'code by SMcNeill (c) 2022
'code is under standard MIT License -- https://en.wikipedia.org/wiki/MIT_License
'inspired by code sample archive from QB64.com which is also MIT Licensed


Type Sample_Index_Type
    title As String
    author As String
    tag As String
    description As String
End Type
'format for data files is:
'Start line                                                   [START ENTRY]
'Title                                                        This is the same as the directory name
'Author(s)
'Tag(s)
'Description
'Continue Description as needed.
'Finish Line                                                   [END ENTRY]
'All sample information is kept in the above format and organized for ease of reference and editing in any text editor.

$Color:32
Screen _NewImage(1280, 720, 32)
ReDim Shared SI(1000) As Sample_Index_Type, count
_Title "QB64-PE Sample Showcase"

Load_Sample_Index
count = count - 1
_Delay .5
_ScreenMove _Middle



screenchanged = -1
Do
    If screenchanged Then
        DisplayScreen start, selected, limit
        screenchanged = 0
    End If
    k = _KeyHit
    Select Case k
        Case 27: System
        Case 18432
            selected = selected - 1: If selected < 0 Then selected = 40
            screenchanged = -1
        Case 20480:
            selected = selected + 1: If selected > limit Then selected = 0
            screenchanged = -1
        Case Asc("N"), Asc("n")
            start = start + 40: If start > count Then start = 0
            screenchanged = -1
        Case Asc("P"), Asc("p"):
            If start = 0 Then
                start = count - 40
            Else
                start = start - 40: If start < 0 Then start = 0
            End If
            screenchanged = -1
    End Select
    _Limit 30
    _Display
Loop



Sub DisplayScreen (start, selected, limit)
    Static screenshot, blankscreen
    If blankscreen = 0 Then blankscreen = _NewImage(460, 340, 32)

    finish = start + 40: If finish > count Then finish = count
    limit = finish - start
    If selected < 0 Then selected = 0
    If selected > limit Then selected = limit

    Cls , SkyBlue
    Color Black, transparent
    Print " ###"; Tab(10); "Title"; Tab(40); "Author"; Tab(60); "Tags"; Tab(120); "Details"
    For i = start To finish
        If i = start + selected Then
            Line (0, selected * 16 + 16)-Step(770, 16), Red, BF
            If screenshot <> 0 And screenshot <> -1 Then _FreeImage screenshot
            temp$ = "./" + SI(i).title + "/screenshot.png"
            screenshot = _LoadImage(temp$, 32)
            If screenshot <> -1 Then _PutImage (800, 20)-(1260, 359), screenshot
            _Dest blankscreen
            Cls , Black
            Color White, Black
            Print SI(i).description
            _Dest 0
            _PutImage (800, 360)-(1260, 699), blankscreen
        End If
        Print i; Tab(6); Left$(SI(i).title, 25); Tab(33); Left$(SI(i).author, 25); Tab(60); SI(i).tag
    Next
    Color Red, Black
    _PrintString (20, 680), "<P>revious Page      <N>ext Page      <UP/DOWN> change selection"
End Sub


Sub Load_Sample_Index
    Open ".\index.txt" For Input As #1 'The only file we should ever have open, in all honesty.

    Do Until EOF(1)
        Line Input #1, start$
        'If start$ <> "[START ENTRY]" Then Print "ERROR Reading file.  Invalid Start Entry Point.": End
        Line Input #1, title$
        Line Input #1, author$
        Line Input #1, tag$
        description$ = "": finish$ = ""
        Do Until finish$ = "[END ENTRY]"
            Line Input #1, finish$
            finish$ = _Trim$(finish$)
            If finish$ <> "[END ENTRY]" Then description$ = description$ + finish$ + Chr$(13)
        Loop
        SI(count).title = _Trim$(title$)
        SI(count).author = _Trim$(author$)
        SI(count).tag = _Trim$(tag$)
        SI(count).description = _Trim$(description$)
        count = count + 1
    Loop

    Close
End Sub

Save the replace the other QB64 Sample Showcase.bas file in the archive and then you can compile and see the authors names now. Wink
Reply


Messages In This Thread
QB64-PE Sample Showcase - by SMcNeill - 08-14-2022, 04:00 PM
RE: QB64-PE Sample Showcase - by Pete - 08-14-2022, 04:29 PM
RE: QB64-PE Sample Showcase - by SMcNeill - 08-14-2022, 04:42 PM
RE: QB64-PE Sample Showcase - by Pete - 08-14-2022, 05:39 PM
RE: QB64-PE Sample Showcase - by SMcNeill - 08-14-2022, 05:08 PM
RE: QB64-PE Sample Showcase - by SMcNeill - 08-14-2022, 05:42 PM
RE: QB64-PE Sample Showcase - by vince - 08-14-2022, 07:50 PM
RE: QB64-PE Sample Showcase - by SMcNeill - 08-14-2022, 08:53 PM
RE: QB64-PE Sample Showcase - by SMcNeill - 08-14-2022, 10:10 PM
RE: QB64-PE Sample Showcase - by dbox - 08-14-2022, 11:48 PM
RE: QB64-PE Sample Showcase - by SMcNeill - 08-15-2022, 12:04 AM
RE: QB64-PE Sample Showcase - by bplus - 08-14-2022, 11:51 PM
RE: QB64-PE Sample Showcase - by SMcNeill - 08-15-2022, 12:06 AM
RE: QB64-PE Sample Showcase - by bplus - 08-15-2022, 12:07 AM
RE: QB64-PE Sample Showcase - by mnrvovrfc - 08-16-2022, 09:16 AM
RE: QB64-PE Sample Showcase - by SMcNeill - 08-16-2022, 01:39 PM
RE: QB64-PE Sample Showcase - by SMcNeill - 08-21-2022, 07:00 PM
RE: QB64-PE Sample Showcase - by SMcNeill - 08-21-2022, 07:07 PM
RE: QB64-PE Sample Showcase - by justsomeguy - 09-02-2022, 09:33 PM
RE: QB64-PE Sample Showcase - by SMcNeill - 09-02-2022, 09:36 PM



Users browsing this thread: 6 Guest(s)