@@ -306,13 +306,13 @@ func adjustTheme() {
306306 if optFallbackOnly {
307307 return
308308 }
309- err = adjustThemeNormal ()
309+ err = adjustThemeNormalV25 ()
310310 if err != nil {
311311 logger .Fatal (err )
312312 }
313313}
314314
315- func adjustThemeNormal () error {
315+ func adjustThemeNormalV20 () error {
316316 themeInputDir := filepath .Join (optThemeInputDir , themeNameNormal )
317317 themeOutputDir := filepath .Join (optThemeOutputDir , themeNameNormal )
318318
@@ -342,8 +342,6 @@ func adjustThemeNormal() error {
342342
343343 for _ , comp := range theme .Components {
344344 if comp .Type == tt .ComponentTypeBootMenu {
345- adjustBootMenu (themeOutputDir , comp , vars )
346-
347345 iconWidth , _ := comp .GetPropInt ("icon_width" )
348346 iconHeight , _ := comp .GetPropInt ("icon_height" )
349347 err = adjustResourcesOsLogos (themeInputDir , themeOutputDir , iconWidth , iconHeight )
@@ -409,6 +407,100 @@ func adjustThemeNormal() error {
409407 return err
410408}
411409
410+ func adjustThemeNormalV25 () error {
411+ themeInputDir := filepath .Join (optThemeInputDir , themeNameNormal )
412+ themeOutputDir := filepath .Join (optThemeOutputDir , themeNameNormal )
413+
414+ cleanupThemeOutputDir (themeOutputDir )
415+ err := os .MkdirAll (themeOutputDir , 0755 )
416+ if err != nil {
417+ return err
418+ }
419+ copyThemeFiles (themeInputDir , themeOutputDir )
420+
421+ bgImg , themeBgImg , err := loadV25BackgroundImage ()
422+ if err != nil {
423+ return err
424+ }
425+
426+ err = saveJpeg (bgImg , filepath .Join (themeOutputDir , "background.jpg" ))
427+ if err != nil {
428+ return err
429+ }
430+ if themeBgImg != nil {
431+ err = saveJpeg (themeBgImg , filepath .Join (themeOutputDir , "background_in_theme.jpg" ))
432+ if err != nil {
433+ return err
434+ }
435+ } else {
436+ _ , err = copyFile (filepath .Join (themeOutputDir , "background.jpg" ),
437+ filepath .Join (themeOutputDir , "background_in_theme.jpg" ))
438+ if err != nil {
439+ return err
440+ }
441+ }
442+
443+ themeFile := filepath .Join (themeInputDir , "theme.txt.tpl" )
444+ theme , err := tt .ParseThemeFile (themeFile )
445+ if err != nil {
446+ return err
447+ }
448+
449+ bootMenu := theme .FindComponentByType (tt .ComponentTypeBootMenu )
450+ if bootMenu != nil {
451+ adjustBootMenu (bootMenu , optScreenWidth , optScreenHeight )
452+ }
453+
454+ for _ , comp := range theme .Components {
455+ if comp .Type == tt .ComponentTypeLabel {
456+ adjustLabelText (comp )
457+ }
458+ }
459+
460+ themeOutput := filepath .Join (themeOutputDir , "theme.txt" )
461+ themeOutputFh , err := os .Create (themeOutput )
462+ if err != nil {
463+ return err
464+ }
465+ defer func () {
466+ _ = themeOutputFh .Close ()
467+ }()
468+ bw := bufio .NewWriter (themeOutputFh )
469+ // write head
470+ _ , err = fmt .Fprintf (bw , "#version:%d\n " , VERSION )
471+ if err != nil {
472+ return err
473+ }
474+ _ , err = fmt .Fprintf (bw , "#lang:%s\n " , optLang )
475+ if err != nil {
476+ return err
477+ }
478+
479+ var inputDir string
480+ inputDir , err = filepath .Abs (themeInputDir )
481+ if err != nil {
482+ logger .Warning (err )
483+ inputDir = themeInputDir
484+ }
485+
486+ _ , err = fmt .Fprintf (bw , "#themeInputDir:%s\n " , inputDir )
487+ if err != nil {
488+ return err
489+ }
490+
491+ _ , err = fmt .Fprintln (bw , "#head end" )
492+ if err != nil {
493+ return err
494+ }
495+
496+ _ , err = theme .WriteTo (bw )
497+ if err != nil {
498+ return err
499+ }
500+ err = bw .Flush ()
501+ return err
502+ }
503+
412504func adjustThemeFallback () error {
413505 themeInputDir := filepath .Join (optThemeInputDir , themeNameFallback )
414506 themeOutputDir := filepath .Join (optThemeOutputDir , themeNameFallback )
@@ -936,52 +1028,13 @@ func adjustBootMenuPixmapStyle(themeOutputDir string, comp *tt.Component, bgImg
9361028 cropSaveStyleBox (img3 , prefix , x + menuR )
9371029}
9381030
939- func adjustBootMenu (themeOutputDir string , comp * tt.Component , vars map [string ]float64 ) {
940- vars = copyVars (vars )
941- face , err := adjustFont (themeOutputDir , comp , "item_font" , vars )
942- if err != nil {
943- logger .Fatal (err )
944- }
945-
946- fontHeight := face .Height ()
947- vars ["font_height" ] = float64 (fontHeight )
948-
949- itemHeight := adjustProp (comp , "item_height" , vars )
950- itemR := getItemR (itemHeight )
951- vars ["item_r" ] = float64 (itemR )
952- menuR := getBootMenuR (itemHeight )
953- vars ["menu_r" ] = float64 (menuR )
954-
955- for _ , propName := range []string {
956- "item_spacing" ,
957- "item_padding" , "icon_width" ,
958- "icon_height" , "item_icon_space" ,
959- "height" , "width" ,
960- "left" , "top" ,
961- } {
962- adjustProp (comp , propName , vars )
963- }
964-
965- scrollbarThumbR := getScrollbarThumbR (menuR )
966- comp .SetProp ("scrollbar_width" , scrollbarThumbR * 2 )
967-
968- bgImg , err := loadBackgroundImage ()
969- if err != nil {
970- logger .Fatal (err )
971- }
972-
973- bgImg , err = adjustBackground (themeOutputDir , bgImg )
974- if err != nil {
975- logger .Fatal (err )
1031+ func adjustBootMenu (comp * tt.Component , width , height int ) {
1032+ // bootMenuBasePercent 是 boot menu 宽度计算的基础百分比
1033+ if width == 1024 && height == 768 {
1034+ const bootMenuBasePercent = 18
1035+ comp .SetProp ("width" , tt .RelNum (bootMenuBasePercent * 2 ))
1036+ comp .SetProp ("left" , tt .RelNum (50 - bootMenuBasePercent ))
9761037 }
977- adjustBootMenuPixmapStyle (themeOutputDir , comp , bgImg )
978-
979- convertPropAbs2Rel (comp , "left" , orientationHorizontal )
980- convertPropAbs2Rel (comp , "top" , orientationVertical )
981-
982- adjustSelectedItemPixmapStyle (itemR )
983- adjustItemPixmapStyle (itemR )
984- adjustScrollbarThumbPixmapStyle (scrollbarThumbR )
9851038}
9861039
9871040const (
0 commit comments