configurable
added the ability to use a config file.
This commit is contained in:
parent
662907254a
commit
321b0a3424
Notes:
visionmercer
2026-09-15 13:19:18 +02:00
This is not tested in windows or mac os.
1 changed files with 68 additions and 0 deletions
68
cimp.bas
68
cimp.bas
|
|
@ -133,6 +133,8 @@ dim shuffle as integer
|
|||
dim nooutput as integer
|
||||
dim timevis as integer
|
||||
dim nyan as integer
|
||||
dim server as integer
|
||||
|
||||
dim marqueeoffset as integer
|
||||
dim i as integer
|
||||
|
||||
|
|
@ -167,6 +169,40 @@ timevis=1
|
|||
nyan=0
|
||||
marqueeoffset=0
|
||||
|
||||
|
||||
dim config as string
|
||||
config = GetConfig("cimp.conf")
|
||||
if _fileexists(config) then
|
||||
dim li as string
|
||||
dim fh as integer
|
||||
fh = freefile
|
||||
open config for input as fh
|
||||
while not eof(fh)
|
||||
line input #fh, li
|
||||
if left$(li,1)="#" then _continue
|
||||
select case _trim$(left$(li,instr(li,"=")-1))
|
||||
case "volume"
|
||||
volume=val(_trim$(mid$(li,instr(li,"=")+1)))/100
|
||||
case "shuffle"
|
||||
if _trim$(mid$(li,instr(li,"=")+1))="true" then shuffle=-1 else shuffle=0
|
||||
case "repeat"
|
||||
if _trim$(mid$(li,instr(li,"=")+1))="true" then repeat=-1 else repeat=0
|
||||
if _trim$(mid$(li,instr(li,"=")+1))="1" then repeat=1
|
||||
case "server"
|
||||
if _trim$(mid$(li,instr(li,"=")+1))="true" then server=-1 else server=0
|
||||
case "nyan"
|
||||
if _trim$(mid$(li,instr(li,"=")+1))="true" then nyan=-1 else nyan=0
|
||||
case "nooutput"
|
||||
if _trim$(mid$(li,instr(li,"=")+1))="true" then nooutput=-1 else nooutput=0
|
||||
case ""
|
||||
case else
|
||||
print "Config not understood:"
|
||||
print li
|
||||
end select
|
||||
wend
|
||||
close fh
|
||||
end if
|
||||
|
||||
for i=1 to _commandcount
|
||||
select case command$(i)
|
||||
case "-v","--volume"
|
||||
|
|
@ -710,3 +746,35 @@ end function
|
|||
sub loadsoundbank (filename as string)
|
||||
_midisoundbank filename
|
||||
end sub
|
||||
|
||||
|
||||
FUNCTION GetConfig$ (FileName as string)
|
||||
SELECT CASE left$(_OS$,instr(_OS$,"]"))
|
||||
CASE "[WINDOWS]"
|
||||
dim appdata as string
|
||||
appdata = ENVIRON$("APPDATA")
|
||||
if appdata = "" then appdata = ENVIRON$("USERPROFILE") + "\AppData\Roaming"
|
||||
if right$(appdata, 1) <> "\" then appdata = appdata + "\"
|
||||
GetConfig = appdata + FileName
|
||||
|
||||
CASE "[MACOSX]"
|
||||
dim homemac as string
|
||||
homemac = ENVIRON$("HOME")
|
||||
if homemac = "" then homemac = "/tmp"
|
||||
if right$(homemac, 1) = "/" then homemac = left$(homemac, len(homemac) - 1)
|
||||
GetConfig = homemac + "/Library/Application Support/" + FileName
|
||||
|
||||
CASE ELSE ' Linux and other Unix-like systems
|
||||
dim xdg as string, baseDir as string, homelinux as string
|
||||
xdg = ENVIRON$("XDG_CONFIG_HOME")
|
||||
if xdg <> "" then
|
||||
baseDir = xdg
|
||||
else
|
||||
homelinux = ENVIRON$("HOME")
|
||||
if homelinux = "" then homelinux = "/tmp"
|
||||
baseDir = homelinux + "/.config"
|
||||
end if
|
||||
if right$(baseDir, 1) = "/" then baseDir = left$(baseDir, len(baseDir) - 1)
|
||||
GetConfig = baseDir + "/" + FileName
|
||||
END SELECT
|
||||
END FUNCTION
|
||||
|
|
|
|||
Loading…
Reference in a new issue