REM MIT: original project code. See !Xmas26.License and Licences.Project.Scope.
REM Native Wimp table: permanent icon buffers and fixed click destinations.
DEF PROClicensewindow
LOCAL w%,h%,i%,dummy%
DIM licbuf% 24575,licextent% 15,lichead% 31,licurlbuf% 255
DIM liccomp%(14),licterm%(14,1),licweb%(14)
DIM liclinkid%(63),liclinkkind%(63),liclinktarget$(63)
licused%=0:liclinks%=0:w%=1740:h%=820
$lichead%="C453321/F4EADC"
IF screenw%-80<w% THEN w%=screenw%-80
IF screenh%-160<h% THEN h%=screenh%-160
IF w%<600 THEN w%=600
IF h%<320 THEN h%=320
licences%=FNwindow(w%,h%,&FF000012,"Licences",1)
!licextent%=0:licextent%!4=-1980:licextent%!8=1760:licextent%!12=0
SYS "Wimp_SetExtent",licences%,licextent%
dummy%=FNlicicon("Sources and Licences",20,-54,1720,36,&17000111,-1)
dummy%=FNlicicon("Original project contributions: MIT. Third-party terms are listed below.",20,-94,1720,32,&17000111,-1)
dummy%=FNlicicon("Click a component or licence to read its file; click a web address to open your browser.",20,-130,1720,32,&17000111,-1)
licmusic%=FNlicicon("Music sources",20,-188,260,44,&1700313D,action%)
licapp%=FNlicicon("App sources",296,-188,240,44,&1700313D,action%)
licnotes%=FNlicicon("Licence notes",552,-188,352,44,&1700313D,action%)
licprogram%=FNlicicon("Read the Program",920,-188,320,44,&1700313D,action%)
licfolder%=FNlicicon("Open Licences folder",1256,-188,400,44,&1700313D,action%)
licwarranty%=FNlicicon("Warranty and safe use",20,-244,400,44,&1700313D,action%)
licchanges%=FNlicicon("Version changes",436,-244,352,44,&1700313D,action%)
dummy%=FNlicicon("Components / files",20,-328,620,48,&F700013D,lichead%)
dummy%=FNlicicon("Licence",640,-328,480,48,&F700013D,lichead%)
dummy%=FNlicicon("Status",1120,-328,620,48,&F700013D,lichead%)
PROClicrow(1,"Application and build code","!RunImage; Docs/build","MIT","Scope of the grant","Original project contributions","Editable source included")
PROClicbind(liccomp%(1),"!Xmas26.!RunImage",0)
PROClicbind(licterm%(1,0),"!Xmas26.License",0)
PROClicbind(licterm%(1,1),"Licences.Project.Scope",0)
PROClicrow(2,"Scene artwork and game","Sprites, !Sprites; Maze","MIT","Scope of the grant","Original procedural artwork","Third-party marks remain separate")
PROClicbind(liccomp%(2),"build.AppSources",0)
PROClicbind(licterm%(2,0),"!Xmas26.License",0)
PROClicbind(licterm%(2,1),"Licences.Project.Scope",0)
PROClicrow(3,"New arrangements and samples","Carols, MODs, samples and lyrics","MIT","Song-by-song sources","Project contributions licensed","Underlying works keep their rights")
PROClicbind(liccomp%(3),"Licences.Songs",0)
PROClicbind(licterm%(3,0),"!Xmas26.License",0)
PROClicbind(licterm%(3,1),"Licences.Songs",0)
PROClicrow(4,"Historical carols and words","Score and lyric source material","Source rights / grants","Catalogue declaration","Historical tunes and words","Individual sources recorded")
PROClicbind(liccomp%(4),"Licences.Songs",0)
PROClicbind(licterm%(4,0),"Licences.Songs",0)
PROClicbind(licterm%(4,1),"Licences.CarolScores.License",0)
PROClicwebsite(4,"acollectionofchristmascarols.com","https://acollectionofchristmascarols.com/")
PROClicrow(5,"VSCO 2 CE instrument samples","SampleBank; Classical MODs","CC0 1.0","Supplied credits","Nine recordings converted","Other instruments are synthesised")
PROClicbind(liccomp%(5),"Licences.VSCO2CE.ReadMe",0)
PROClicbind(licterm%(5,0),"Licences.VSCO2CE.License",0)
PROClicbind(licterm%(5,1),"Licences.VSCO2CE.Upstream",0)
PROClicwebsite(5,"versilian-studios.com/vsco-community","https://versilian-studios.com/vsco-community/")
PROClicrow(6,"QTM 1.49 player","Tracker.QTMModule","Custom freeware terms","Supplied licence","Unmodified replay module","Steve Harrison; Jeffrey Lee")
PROClicbind(liccomp%(6),"Licences.QTM.ReadMe",0)
PROClicbind(licterm%(6,0),"Licences.QTM.License",0)
PROClicbind(licterm%(6,1),"Licences.QTM.License",0)
PROClicwebsite(6,"www.pi-star.co.uk/qtm","https://www.pi-star.co.uk/qtm")
PROClicrow(7,"Generated speech","FXBank; spoken phrases","MIT: project output","Engine licence / sources","eSpeak NG used at build time","Engine and voice data not bundled")
PROClicbind(liccomp%(7),"Licences.eSpeakNG.ReadMe",0)
PROClicbind(licterm%(7,0),"!Xmas26.License",0)
PROClicbind(licterm%(7,1),"Licences.eSpeakNG.ReadMe",0)
PROClicwebsite(7,"github.com/espeak-ng/espeak-ng","https://github.com/espeak-ng/espeak-ng")
PROClicrow(8,"Original sound effects","FXBank; BuildEffects","MIT","Synthesis record","Train, chimes and character cues","Original synthesis; no sample pack")
PROClicbind(liccomp%(8),"build.EffectsData",0)
PROClicbind(licterm%(8,0),"!Xmas26.License",0)
PROClicbind(licterm%(8,1),"build.EffectsData",0)
PROClicrow(9,"Maestro score exports","Maestros; MaestrosPluck","MIT: new arrangements","Song source rights","92 editable score exports","Maestro is not used for playback")
PROClicbind(liccomp%(9),"Licences.Maestro.ReadMe",0)
PROClicbind(licterm%(9,0),"!Xmas26.License",0)
PROClicbind(licterm%(9,1),"Licences.Songs",0)
PROClicrow(10,"Shchedryk source engraving","Shchedryk.SourcePDF","Public-domain dedication","Supplied grant record","A1 engraving; original transcription","New backing and English words: MIT")
PROClicbind(liccomp%(10),"Licences.Shchedryk.ReadMe",0)
PROClicbind(licterm%(10,0),"Licences.Shchedryk.Grant",0)
PROClicbind(licterm%(10,1),"Licences.Shchedryk.Grant",0)
PROClicwebsite(10,"commons.wikimedia.org","https://commons.wikimedia.org/wiki/File:%D0%A9%D0%B5%D0%B4%D1%80%D0%B8%D0%BA.pdf")
PROClicrow(11,"Auld Lang Syne source","Historical score transcription","Source permission","Source and rights record","Historical tune and words","Project arrangement: MIT")
PROClicbind(liccomp%(11),"Licences.AuldLangSyne.ReadMe",0)
PROClicbind(licterm%(11,0),"Licences.AuldLangSyne.ReadMe",0)
PROClicbind(licterm%(11,1),"Licences.Songs",0)
PROClicrow(12,"Build and verification tools","Python and external host tools","Upstream licence links","Tool-by-tool record","Tools are not bundled in the app","No runtime Python dependency")
PROClicbind(liccomp%(12),"Licences.Tools",0)
PROClicbind(licterm%(12,0),"Licences.Tools",0)
PROClicbind(licterm%(12,1),"Licences.Tools",0)
PROClicrow(13,"Fonts and reference manuals","Installed fonts; API references","Respective owners terms","Reference and licence links","Fonts and manuals not bundled","Native Font Manager is used")
PROClicbind(liccomp%(13),"Licences.References",0)
PROClicbind(licterm%(13,0),"Licences.References",0)
PROClicbind(licterm%(13,1),"Licences.References",0)
PROClicrow(14,"Project documentation","Help, source and asset records","MIT: original text","Scope and exclusions","Original explanatory material","Quoted third-party notices retained")
PROClicbind(liccomp%(14),"Licences.FileIndex",0)
PROClicbind(licterm%(14,0),"!Xmas26.License",0)
PROClicbind(licterm%(14,1),"Licences.Project.Scope",0)
ENDPROC
:
DEF PROClicrow(row%,a$,b$,c$,d$,e$,f$)
LOCAL y%,dummy%
y%=-328-row%*116
PROCliccell(20,y%,620):PROCliccell(640,y%,480):PROCliccell(1120,y%,620)
liccomp%(row%)=FNlicicon(a$,28,y%+78,604,32,&18003111,-1)
dummy%=FNlicicon(b$,28,y%+42,604,32,&17000111,-1)
licterm%(row%,0)=FNlicicon(c$,648,y%+70,464,32,&18003111,-1)
licterm%(row%,1)=FNlicicon(d$,648,y%+30,464,32,&18003111,-1)
dummy%=FNlicicon(e$,1128,y%+70,604,32,&17000111,-1)
dummy%=FNlicicon(f$,1128,y%+30,604,32,&17000111,-1)
ENDPROC
:
DEF PROClicwebsite(row%,label$,url$)
licweb%(row%)=FNlicicon(label$,28,-328-row%*116+6,604,32,&18003111,-1)
PROClicbind(licweb%(row%),url$,1)
ENDPROC
:
DEF PROCliccell(x%,y%,w%)
LOCAL dummy%
dummy%=FNlicicon("",x%,y%,w%,116,&1700013D,inset%)
ENDPROC
:
DEF FNlicicon(s$,x%,y%,w%,h%,flags%,valid%)
LOCAL ptr%,id%
IF LEN(s$)>126 OR licused%+128>24576 THEN ERROR 1,"Licence table exceeds buffer"
ptr%=licbuf%+licused%:licused%+=128:$ptr%=s$
!icon%=licences%:icon%!4=x%:icon%!8=y%:icon%!12=x%+w%:icon%!16=y%+h%
icon%!20=flags%:icon%!24=ptr%:icon%!28=valid%:icon%!32=128
SYS "Wimp_CreateIcon",,icon% TO id%
=id%
:
DEF PROClicbind(id%,target$,kind%)
IF liclinks%>=64 THEN ERROR 1,"Too many licence links"
liclinkid%(liclinks%)=id%:liclinktarget$(liclinks%)=target$:liclinkkind%(liclinks%)=kind%
liclinks%+=1
ENDPROC
:
DEF PROClicenseclick
LOCAL i%
IF (poll%!8 AND 4)=0 THEN ENDPROC
CASE poll%!16 OF
  WHEN licmusic%:PROCsourceopen(0):ENDPROC
  WHEN licapp%:PROCsourceopen(1):ENDPROC
  WHEN licnotes%:PROCsourceopen(3):ENDPROC
  WHEN licprogram%:PROCsourceopen(2):ENDPROC
  WHEN licfolder%:PROClicensefolder:ENDPROC
  WHEN licwarranty%:PROClictext("Warranty"):ENDPROC
  WHEN licchanges%:PROClictext("VersionChanges"):ENDPROC
ENDCASE
FOR i%=0 TO liclinks%-1
  IF poll%!16=liclinkid%(i%) THEN
    IF liclinkkind%(i%)=1 THEN PROClicurl(liclinktarget$(i%)) ELSE PROClictext(liclinktarget$(i%))
    ENDPROC
  ENDIF
NEXT
ENDPROC
:
DEF FNlicpathok(file$)
LOCAL i%,c%
IF LEN(file$)<1 OR LEN(file$)>120 THEN =FALSE
FOR i%=1 TO LEN(file$)
  c%=ASC(MID$(file$,i%,1))
  IF (c%<65 OR c%>90) AND (c%<97 OR c%>122) AND (c%<48 OR c%>57) AND c%<>33 AND c%<>46 THEN =FALSE
NEXT
=TRUE
:
DEF PROClictext(file$)
IF FNlicpathok(file$)=FALSE THEN ENDPROC
IF LEFT$(file$,8)="!Xmas26." THEN
  PROCopenplain("<Xmas26$Dir>."+MID$(file$,9))
ELSE
  PROCopenplain("<Xmas26$Dir>.Docs."+file$)
ENDIF
ENDPROC
:
DEF PROCopenplain(path$)
LOCAL err%,flags%,kind%
SYS "XOS_File",5,path$ TO kind%;flags%
IF (flags% AND 1)<>0 OR kind%<>1 THEN
  PROClicerror("This text file is missing. Keep the supplied package folders together."):ENDPROC
ENDIF
REM Use the text-editor alias even if a file has an executable native type.
SYS "XWimp_StartTask","@RunType_FFF "+CHR$34+path$+CHR$34 TO err%;flags%
IF (flags% AND 1)<>0 THEN PROClicerror("The text editor could not open this file. Check your text-file association.")
ENDPROC
:
DEF PROClicurl(url$)
LOCAL i%,allowed%,result%,flags%
REM Only the exact published HTTPS destinations in this table can be opened.
allowed%=FALSE
FOR i%=0 TO liclinks%-1
  IF liclinkkind%(i%)=1 AND liclinktarget$(i%)=url$ THEN allowed%=TRUE
NEXT
IF allowed%=FALSE OR LEFT$(url$,8)<>"https://" OR LEN(url$)>254 THEN ENDPROC
$licurlbuf%=url$+CHR$0
REM XURI_Dispatch (&4E381 + X bit), with no command-line interpolation.
SYS &6E381,0,licurlbuf%,0 TO result%;flags%
IF (flags% AND 1)<>0 OR (result% AND 1)<>0 THEN PROClicerror("No browser accepted this address. Open your browser and try the web address shown.")
ENDPROC
:
DEF PROClicerror(message$)
!errorblock%=0:$(errorblock%+4)=LEFT$(message$,240)+CHR$0
SYS "XWimp_ReportError",errorblock%,1,"Xmas26"
ENDPROC
:
DEF PROClicensefolder
LOCAL folder$,kind%,err%,flags%
folder$="<Xmas26$Dir>.Docs.Licences"
SYS "OS_File",5,folder$ TO kind%
IF kind%<>2 THEN
  !errorblock%=0:$(errorblock%+4)="The Docs.Licences folder is missing from !Xmas26."
  SYS "Wimp_ReportError",errorblock%,1,"Xmas26":ENDPROC
ENDIF
SYS "XWimp_StartTask","Filer_OpenDir "+CHR$34+folder$+CHR$34 TO err%;flags%
IF (flags% AND 1)<>0 THEN SYS "Wimp_ReportError",err%,1,"Xmas26"
ENDPROC
