Skip to content

Commit

Permalink
update v1.1 27/06/2023
Browse files Browse the repository at this point in the history
- improved crossfade fx no longer needs read > save > read
| or convert to png for alpha layer
- reworked localization, broader ui scope, utf support and more scalable
- implemented utilfile.bas generics for several apps
- implemented cpu syncfps thanks to fxm:
' via https://www.freebasic.net/forum/viewtopic.php?p=299305&sid=71b9b1edd5e91553b901d064a45ad12c#p299305 by fxm
  • Loading branch information
thrive4 committed Jun 28, 2023
1 parent 8d97901 commit f0820dd
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 33 deletions.
8 changes: 4 additions & 4 deletions app.rc
Expand Up @@ -10,8 +10,8 @@ FB_PROGRAM_ICON ICON "app.ico"

// add version and file info in exe windows only
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1, 0, 0, 000
PRODUCTVERSION 1, 0, 0, 0
FILEVERSION 1, 1, 0, 000
PRODUCTVERSION 1, 1, 0, 0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x9L
Expand All @@ -29,13 +29,13 @@ BEGIN
VALUE "Comments", "needs sdl, sdl_image and sdl_ttf libs"
VALUE "CompanyName", "thrive4"
VALUE "FileDescription", "slideshow with clock and date"
VALUE "FileVersion", "1, 0, 0, 000"
VALUE "FileVersion", "1, 1, 0, 000"
VALUE "InternalName", ""
VALUE "LegalCopyright", ""
VALUE "OriginalFilename", "slideshow"
VALUE "PrivateBuild", ""
VALUE "ProductName", "slideshow"
VALUE "ProductVersion", "1, 0, 0, 0"
VALUE "ProductVersion", "1, 1, 0, 0"
END
END
BLOCK "VarFileInfo"
Expand Down
18 changes: 12 additions & 6 deletions slideshow.bas
Expand Up @@ -626,6 +626,11 @@ SDL_RenderClear(renderer)
SDL_RenderPresent(renderer)
sdl_delay(400)

' surfaces needed for adding alpha
' sdl allocates memory per step SDL_SetSurfaceAlphaMod, SDL_ConvertSurfaceFormat
' using the same surface leads to a memeory leak....
Dim As SDL_Surface Ptr dsurf
Dim As SDL_Surface Ptr esurf

while running
datetime = Now()
Expand Down Expand Up @@ -681,14 +686,15 @@ while running
SDL_DestroyTexture(background_surface)

getimage(filename, mp3file, mp3chk, playtype)
SDL_DestroyTexture(background_surface)
background_surface = IMG_LoadTexture(renderer, filename)

temp_surface = IMG_Load(dummy)
IMG_SavePNG(temp_surface, exepath + "\dummy.png")
SDL_FreeSurface(temp_surface)
SDL_DestroyTexture(temp_surface)
temp_surface = IMG_LoadTexture(renderer, exepath + "\dummy.png")
' add alpha for crossfade
dsurf = IMG_Load(dummy)
SDL_SetSurfaceAlphaMod(dsurf, 0)
esurf = SDL_ConvertSurfaceFormat(dsurf, SDL_PIXELFORMAT_RGBA32, 0)
temp_surface = SDL_CreateTextureFromSurface(renderer, esurf)
SDL_FreeSurface(dsurf)
SDL_FreeSurface(esurf)

' scaling image
SDL_QueryTexture(background_surface, NULL, NULL, @iW, @iH)
Expand Down
8 changes: 8 additions & 0 deletions slideshow.nfo
@@ -1 +1,9 @@
update v1.1 27/06/2023
- improved crossfade fx no longer needs read > save > read
| or convert to png for alpha layer
- reworked localization, broader ui scope, utf support and more scalable
- implemented utilfile.bas generics for several apps
- implemented cpu syncfps thanks to fxm:
' via https://www.freebasic.net/forum/viewtopic.php?p=299305&sid=71b9b1edd5e91553b901d064a45ad12c#p299305 by fxm

public release v1.0 20/06/2023
Binary file modified slideshow.wfbe
Binary file not shown.
113 changes: 90 additions & 23 deletions utilfile.bas
Expand Up @@ -108,29 +108,6 @@ Function logentry(entrytype As String, logmsg As String) As Boolean
return true
End function

' localiztion can be applied by getting a locale or other method
dim locale as string = "en"
sub displayhelp(locale as string)
dim dummy as string
dim f as integer
f = freefile

' get text
if FileExists(exepath + "\conf\" + locale + "\help.ini") then
'nop
else
logentry("error", "open " + exepath + "\conf\" + locale + "\help.ini" + " file does not excist")
locale = "en"
end if
Open exepath + "\conf\" + locale + "\help.ini" For input As #f
Do Until EOF(f)
Line Input #f, dummy
print dummy
Loop
close f

end sub

' get fileversion executable or dll windows only
function getfileversion(versinfo() as string, versdesc() as string) as integer

Expand Down Expand Up @@ -299,6 +276,96 @@ Function checkpath(chkpath As String) As boolean

End Function

' localization file functions
' ______________________________________________________________________________'

' localization can be applied by getting a locale or other method
dim locale as string = "en"
sub displayhelp(locale as string)
dim dummy as string
dim f as integer
f = freefile

' get text
if FileExists(exepath + "\conf\" + locale + "\help.ini") then
'nop
else
logentry("error", "open " + exepath + "\conf\" + locale + "\help.ini" + " file does not excist")
locale = "en"
end if
Open exepath + "\conf\" + locale + "\help.ini" For input As #f
Do Until EOF(f)
Line Input #f, dummy
print wstr(dummy)
Loop
close f

end sub

' setup ui labels aka data spindel
type tbrec
as string fieldname(any)
as string fieldvalue(any)
end type
dim shared record as tbrec
common shared recnr as integer
recnr = 0

' get key value pair cheap localization via ini file
Function readuilabel(filename as string) as boolean
dim itm as string
dim inikey as string
dim inival as string
dim f as integer

if FileExists(filename) = false then
logentry("error", filename + " does not excist switching to default language")
filename = exepath + "\conf\en\menu.ini"
end if
f = readfromfile(filename)
Do Until EOF(f)
Line Input #f, itm
if instr(1, itm, "=") > 1 then
inikey = trim(mid(itm, 1, instr(1, itm, "=") - 2))
inival = trim(mid(itm, instr(1, itm, "=") + 2, len(itm)))
if inival = "" then
logentry("error", inikey + " has empty value in " + filename)
inival = "null"
end if
'print inikey + " - " + inival
recnr += 1
redim preserve record.fieldname(0 to recnr)
redim preserve record.fieldvalue(0 to recnr)
record.fieldname(recnr) = inikey
record.fieldvalue(recnr) = inival
end if
loop
close f
return true
end function

' display ui lable with unicode and semi automatic spacing via offset
function getuilabelvalue(needle as string, suffix as string = "", offset as integer = 10) as boolean
dim fieldname as string = ""
dim fieldvalue as string = ""

for i as integer = 0 to recnr
with record
if record.fieldname(i) = needle then
fieldname = record.fieldname(i)
fieldvalue = record.fieldvalue(i)
end if
end with
next i
if fieldname = "" or fieldvalue = "" then
print needle + " not found or empty " + suffix
return false
else
print wstr(fieldvalue + space(offset - Len(fieldvalue)) + suffix)
return true
end if
end function

' file type specific functions
' ______________________________________________________________________________'

Expand Down

0 comments on commit f0820dd

Please sign in to comment.