@@ -590,7 +590,7 @@ private List<OnlineTemplateItem> ParseTemplatesFromJson(string json)
590590 // Parse individual fields
591591 var tarballUrl = ExtractNestedJsonString ( nodeJson , "\" tarball\" " , "\" url\" " ) ;
592592 var rawDescription = ExtractJsonString ( nodeJson , "\" description\" " ) ;
593- var splitDescription = SplitDescriptionIntoThree ( rawDescription ) ;
593+ var splitDescription = SplitTextToRows ( rawDescription , 3 ) ;
594594
595595 var template = new OnlineTemplateItem
596596 {
@@ -633,24 +633,6 @@ private List<OnlineTemplateItem> ParseTemplatesFromJson(string json)
633633 return templates ;
634634 }
635635
636- private string SplitDescriptionIntoThree ( string description )
637- {
638- if ( string . IsNullOrEmpty ( description ) ) return description ;
639-
640- int len = description . Length ;
641- if ( len <= 2 ) return description ; // too short to split meaningfully
642-
643- int firstCut = ( len / 3 ) ;
644- int secondCut = ( len * 2 ) / 3 ;
645-
646- // Raw split strictly by length/3 as requested
647- string part1 = description . Substring ( 0 , firstCut ) . Trim ( ) ;
648- string part2 = description . Substring ( firstCut , secondCut - firstCut ) . Trim ( ) ;
649- string part3 = description . Substring ( secondCut ) . Trim ( ) ;
650-
651- return part1 + Environment . NewLine + part2 + Environment . NewLine + part3 ;
652- }
653-
654636 private string ExtractJsonString ( string json , string key )
655637 {
656638 int keyIndex = json . IndexOf ( key + ":" ) ;
@@ -849,6 +831,25 @@ private async void btnDownloadTemplate_Click(object sender, RoutedEventArgs e)
849831 button . Content = "⬇" ;
850832 }
851833 }
834+ } // btnDownloadTemplate_Click
835+
836+ private string SplitTextToRows ( string description , int rows )
837+ {
838+ if ( rows < 2 ) return description ;
839+ if ( string . IsNullOrEmpty ( description ) ) return description ;
840+
841+ int len = description . Length ;
842+ if ( len <= rows ) return description ; // too short to split meaningfully
843+
844+ int firstCut = ( len / rows ) ;
845+ int secondCut = ( len * 2 ) / rows ;
846+
847+ string part1 = description . Substring ( 0 , firstCut ) . Trim ( ) ;
848+ string part2 = description . Substring ( firstCut , secondCut - firstCut ) . Trim ( ) ;
849+ string part3 = description . Substring ( secondCut ) . Trim ( ) ;
850+
851+ return part1 + Environment . NewLine + part2 + Environment . NewLine + part3 ;
852852 }
853+
853854 } // class NewProject
854855} // namespace UnityLauncherPro
0 commit comments