@@ -13,13 +13,18 @@ public class ModManagerLogWindow : UIWindow
1313
1414 private string fileName = "mod_launcher.log" ;
1515
16+ private float calculatedMaxWindowHeight ;
17+
1618 public void setup ( string newFileName )
1719 {
1820 this . fileName = newFileName ;
1921
2022 // buildLog();
2123 logOutput . Clear ( ) ;
2224 logOutput . Append ( File . ReadAllText ( this . fileName ) ) ;
25+
26+ // count the number of newlines from the log and multiply it by the line height
27+ calculatedMaxWindowHeight = logOutput . ToString ( ) . Split ( '\n ' ) . Length * 16 ;
2328 }
2429
2530 public void Start ( )
@@ -29,64 +34,21 @@ public void Start()
2934 this . windowRect = new Rect ( 20 , 450 , 800 , 400 ) ;
3035 this . shown = true ;
3136
32- // buildLog();
33- logOutput . Clear ( ) ;
34- logOutput . Append ( File . ReadAllText ( this . fileName ) ) ;
37+ setup ( this . fileName ) ;
3538 }
3639
3740 public override void renderContent ( )
3841 {
3942
4043 // setup the scrollView dimensions based on the amount of loaded mods
4144 scrollViewRect . Set ( 1 , 20 , windowRect . width - 4 , windowRect . height - 2 ) ;
42- scrollContentMaxSize . Set ( 0 , 0 , windowRect . width , 9999 ) ;
45+ scrollContentMaxSize . Set ( 0 , 0 , windowRect . width , calculatedMaxWindowHeight ) ;
4346
44- GUI . Label ( new Rect ( 15 , 30 , windowRect . width - 10 , windowRect . height - 10 ) , logOutput . ToString ( ) ) ;
47+ GUI . Label ( new Rect ( 15 , 30 , windowRect . width - 10 , calculatedMaxWindowHeight ) , logOutput . ToString ( ) ) ;
4548
4649 // Make the windows be draggable.
4750 GUI . DragWindow ( new Rect ( 0 , 0 , 10000 , 10000 ) ) ;
4851 }
4952
50-
51- public void buildLog ( )
52- {
53- // clear the log
54- logOutput . Clear ( ) ;
55-
56- logOutput . AppendLine ( ) ;
57-
58- logOutput . Append ( "Game-Version: " ) ;
59- logOutput . Append ( Application . version ) ;
60- logOutput . AppendLine ( ) ;
61-
62- logOutput . Append ( "Unity-Version: " ) ;
63- logOutput . Append ( Application . unityVersion ) ;
64- logOutput . AppendLine ( ) ;
65-
66- logOutput . Append ( "Resolution: " ) ;
67- logOutput . Append ( Screen . width ) ;
68- logOutput . Append ( " x " ) ;
69- logOutput . Append ( Screen . height ) ;
70- logOutput . Append ( " @ " ) ;
71- logOutput . Append ( Screen . dpi ) ;
72- logOutput . Append ( " DPI" ) ;
73- logOutput . AppendLine ( ) ;
74-
75- logOutput . Append ( "Current level: " ) ;
76- logOutput . Append ( Application . loadedLevelName ) ;
77- logOutput . AppendLine ( ) ;
78-
79- logOutput . Append ( "Mouse-Position: " ) ;
80- logOutput . Append ( Input . mousePosition . ToString ( ) ) ;
81- logOutput . AppendLine ( ) ;
82-
83- logOutput . Append ( "Real time:" ) ;
84- logOutput . Append ( DateTime . Now . ToString ( "dd.MM.yyyy - HH:mm:ss" ) ) ;
85- logOutput . AppendLine ( ) ;
86-
87- logOutput . Append ( "Frames per second:" ) ;
88- logOutput . Append ( ( int ) ( 1.0f / Time . smoothDeltaTime ) ) ;
89- logOutput . AppendLine ( ) ;
90- }
9153 }
9254}
0 commit comments