@@ -162,11 +162,8 @@ func getFontSize(screenWidth int, screenHeight int) int {
162162 return round (y )
163163}
164164
165- func getScreenSizeFromGrubParams (grubParamsFilePath string ) (w , h int , err error ) {
166- params , err := loadGrubParams (grubParamsFilePath )
167- if err != nil {
168- return
169- }
165+ func getScreenSizeFromGrubParams (grubParamsFilePaths []string ) (w , h int , err error ) {
166+ params := loadGrubParams (grubParamsFilePaths )
170167
171168 w , h , err = parseResolution (getGfxMode (params ))
172169 if err != nil {
@@ -306,13 +303,13 @@ func adjustTheme() {
306303 if optFallbackOnly {
307304 return
308305 }
309- err = adjustThemeNormal ()
306+ err = adjustThemeNormalV25 ()
310307 if err != nil {
311308 logger .Fatal (err )
312309 }
313310}
314311
315- func adjustThemeNormal () error {
312+ func adjustThemeNormalV20 () error {
316313 themeInputDir := filepath .Join (optThemeInputDir , themeNameNormal )
317314 themeOutputDir := filepath .Join (optThemeOutputDir , themeNameNormal )
318315
@@ -409,6 +406,100 @@ func adjustThemeNormal() error {
409406 return err
410407}
411408
409+ func adjustThemeNormalV25 () error {
410+ themeInputDir := filepath .Join (optThemeInputDir , themeNameNormal )
411+ themeOutputDir := filepath .Join (optThemeOutputDir , themeNameNormal )
412+
413+ cleanupThemeOutputDir (themeOutputDir )
414+ err := os .MkdirAll (themeOutputDir , 0755 )
415+ if err != nil {
416+ return err
417+ }
418+ copyThemeFiles (themeInputDir , themeOutputDir )
419+
420+ bgImg , themeBgImg , err := loadV25BackgroundImage ()
421+ if err != nil {
422+ return err
423+ }
424+
425+ err = saveJpeg (bgImg , filepath .Join (themeOutputDir , "background.jpg" ))
426+ if err != nil {
427+ return err
428+ }
429+ if themeBgImg != nil {
430+ err = saveJpeg (themeBgImg , filepath .Join (themeOutputDir , "background_in_theme.jpg" ))
431+ if err != nil {
432+ return err
433+ }
434+ } else {
435+ _ , err = copyFile (filepath .Join (themeOutputDir , "background.jpg" ),
436+ filepath .Join (themeOutputDir , "background_in_theme.jpg" ))
437+ if err != nil {
438+ return err
439+ }
440+ }
441+
442+ themeFile := filepath .Join (themeInputDir , "theme.txt.tpl" )
443+ theme , err := tt .ParseThemeFile (themeFile )
444+ if err != nil {
445+ return err
446+ }
447+
448+ bootMenu := theme .FindComponentByType (tt .ComponentTypeBootMenu )
449+ if bootMenu != nil {
450+ adjustBootMenuV25 (bootMenu , optScreenWidth , optScreenHeight )
451+ }
452+
453+ for _ , comp := range theme .Components {
454+ if comp .Type == tt .ComponentTypeLabel {
455+ adjustLabelText (comp )
456+ }
457+ }
458+
459+ themeOutput := filepath .Join (themeOutputDir , "theme.txt" )
460+ themeOutputFh , err := os .Create (themeOutput )
461+ if err != nil {
462+ return err
463+ }
464+ defer func () {
465+ _ = themeOutputFh .Close ()
466+ }()
467+ bw := bufio .NewWriter (themeOutputFh )
468+ // write head
469+ _ , err = fmt .Fprintf (bw , "#version:%d\n " , VERSION )
470+ if err != nil {
471+ return err
472+ }
473+ _ , err = fmt .Fprintf (bw , "#lang:%s\n " , optLang )
474+ if err != nil {
475+ return err
476+ }
477+
478+ var inputDir string
479+ inputDir , err = filepath .Abs (themeInputDir )
480+ if err != nil {
481+ logger .Warning (err )
482+ inputDir = themeInputDir
483+ }
484+
485+ _ , err = fmt .Fprintf (bw , "#themeInputDir:%s\n " , inputDir )
486+ if err != nil {
487+ return err
488+ }
489+
490+ _ , err = fmt .Fprintln (bw , "#head end" )
491+ if err != nil {
492+ return err
493+ }
494+
495+ _ , err = theme .WriteTo (bw )
496+ if err != nil {
497+ return err
498+ }
499+ err = bw .Flush ()
500+ return err
501+ }
502+
412503func adjustThemeFallback () error {
413504 themeInputDir := filepath .Join (optThemeInputDir , themeNameFallback )
414505 themeOutputDir := filepath .Join (optThemeOutputDir , themeNameFallback )
@@ -585,7 +676,10 @@ func main() {
585676
586677 if optScreenWidth == 0 || optScreenHeight == 0 {
587678 var err error
588- optScreenWidth , optScreenHeight , err = getScreenSizeFromGrubParams (grubParamsFile )
679+ optScreenWidth , optScreenHeight , err = getScreenSizeFromGrubParams ([]string {
680+ grubParamsFile ,
681+ ddeGrubParamsFile ,
682+ })
589683 if err != nil {
590684 logger .Debug (err )
591685 optScreenWidth = 1024
@@ -984,6 +1078,16 @@ func adjustBootMenu(themeOutputDir string, comp *tt.Component, vars map[string]f
9841078 adjustScrollbarThumbPixmapStyle (scrollbarThumbR )
9851079}
9861080
1081+ func adjustBootMenuV25 (comp * tt.Component , width , height int ) {
1082+ if width == 1024 && height == 768 {
1083+ // halfWidthPercent represents half of the boot menu width percentage.
1084+ // The boot menu is centered, so width = halfWidthPercent * 2, left = 50% - halfWidthPercent,
1085+ halfWidthPercent := 22
1086+ comp .SetProp ("width" , tt .RelNum (halfWidthPercent * 2 ))
1087+ comp .SetProp ("left" , tt .RelNum (50 - halfWidthPercent ))
1088+ }
1089+ }
1090+
9871091const (
9881092 orientationHorizontal = 0
9891093 orientationVertical = 1
0 commit comments