33
44namespace ModLoader
55{
6-
6+
77 public class ConsoleGUI : MonoBehaviour
88 {
9- private const string WINDOW_NAME = "Mod loader console" ;
10- private const float MENU_HEIGHT = 0.6f ;
11- private const float MENU_WIDTH = 0.4f ;
12-
139 // show console initial position and size
10+ private Rect _windowRect ;
1411 private Rect _consoleRect ;
12+ private Rect _consoleHeightRect ;
13+ //private Rect _sceneRect;
14+ //private Rect _sceneHeightRect;
15+ //private Rect _toolbarRect;
16+
1517
1618 //draw windows Gui items
1719 private WindowFunction _windosDraw ;
1820
1921 /// show in what position is the scroll of console
2022 private Vector2 _scrollConsole = Vector2 . zero ;
21- private Vector2 _scrollScene = Vector2 . zero ;
22- private Vector2 _scrollMods = Vector2 . zero ;
23+ // private Vector2 _scrollScene = Vector2.zero;
24+ // private Vector2 _scrollMods = Vector2.zero;
2325
2426 private bool _isVisible ;
2527 // show if the console is visible for user
@@ -33,24 +35,25 @@ public bool IsVisible
3335 private int _activeTab ;
3436
3537 // tab list
36- public string [ ] tabs = new string [ ] { "Console" , "Scene" } ;
38+ // public string[] tabs = new string[] { "Console System ", "Scene Information " };
3739
3840 // store all logs in game
3941 private GUIContent _logs ;
4042 public string Logs
4143 {
4244 set
4345 {
46+
4447 this . _logs . text += value ;
45- if ( this . _activeTab == 0 && this . _scrollConsole . y > this . _consoleheight * 0.2 )
48+ this . _consoleHeightRect . height = this . _consoleStyle . CalcHeight ( this . _logs , this . _consoleRect . width ) ;
49+ if ( this . _activeTab == 0 && this . _scrollConsole . y > this . _consoleRect . height * 0.6 )
4650 {
47- this . _scrollConsole . y = this . _consoleheight ;
51+
52+ this . _scrollConsole . y = this . _consoleHeightRect . height ;
4853 }
49-
50-
5154 }
5255 }
53-
56+ /*
5457 private GUIContent _sceneGameObjects;
5558 public GameObject[] SceneGameObjects
5659 {
@@ -60,13 +63,15 @@ public GameObject[] SceneGameObjects
6063 Component[] components;
6164 foreach (GameObject sceneObject in value)
6265 {
63- this . _sceneGameObjects . text += sceneObject . name + "\n " ;
66+ this._sceneGameObjects.text += "Object Name: " + sceneObject.name + "\nComponents: \n";
6467 components = sceneObject.GetComponents(typeof(Component));
6568 foreach (Component component in components)
6669 {
6770 this._sceneGameObjects.text += "\t" + component.ToString() + "\n";
6871 }
72+ this._sceneGameObjects.text += "\n";
6973 }
74+ this._sceneHeightRect.height = this._consoleStyle.CalcHeight(this._sceneGameObjects, this._sceneHeightRect.width);
7075 }
7176 }
7277
@@ -85,29 +90,55 @@ public SFSMod[] Mods
8590 this._mods.text += mod.Description + "\n\n";
8691 }
8792 }
88- }
93+ }*/
8994
9095 // console styles like background and text color
9196 private GUIStyle _consoleStyle ;
9297
93- // this make resize console
94- private float _consoleheight ;
98+ private GUIStyle _windowsStyle ;
99+
100+ //private GUIStyle _toolbarStyle;
95101
96102 void Awake ( )
97103 {
98- this . _isVisible = true ;
104+ this . _isVisible = false ;
105+ this . _windowsStyle = new GUIStyle ( ) ;
99106 this . _consoleStyle = new GUIStyle ( ) ;
107+ //this._toolbarStyle = new GUIStyle();
108+
100109 this . _logs = new GUIContent ( ) ;
101- this . _sceneGameObjects = new GUIContent ( ) ;
102- this . _mods = new GUIContent ( ) ;
103- this . _consoleRect = new Rect ( Screen . width * 0.1f , Screen . height * 0.1f , Screen . width * MENU_WIDTH , Screen . height * MENU_HEIGHT ) ;
110+ //this._mods = new GUIContent();
111+ //this._sceneGameObjects = new GUIContent();
112+
113+ this . _windowRect = new Rect ( 0 , 0 , Screen . width , Screen . height * 0.7f ) ;
114+ //this._toolbarRect = new Rect(0, 0, this._windowRect.width, 30);
115+
116+ this . _consoleRect = new Rect ( 0 , 0 , this . _windowRect . width , this . _windowRect . height ) ;
117+ this . _consoleHeightRect = new Rect ( 0 , 0 , this . _windowRect . width - 20 , this . _windowRect . height ) ;
118+
119+
120+ //this._sceneRect = new Rect(0, 30, this._windowRect.width, this._windowRect.height - 30);
121+ //this._sceneHeightRect = new Rect(0, 0, this._windowRect.width - 20, this._windowRect.height);
122+
104123 this . _windosDraw = new GUI . WindowFunction ( this . windowFunction ) ;
105124 }
106125
107126 void Start ( )
108127 {
109128 this . _consoleStyle . normal . textColor = Color . white ;
110- this . _consoleStyle . normal . background = this . makeTexture ( Color . black ) ;
129+ this . _consoleStyle . fontSize = 14 ;
130+ this . _consoleStyle . padding . left = 10 ;
131+ this . _consoleStyle . normal . background = this . makeTexture ( new Color32 ( 0 , 0 , 0 , 160 ) ) ;
132+
133+ this . _windowsStyle . normal . textColor = Color . white ;
134+ this . _windowsStyle . normal . background = this . makeTexture ( new Color32 ( 36 , 42 , 49 , 160 ) ) ;
135+
136+ //this._toolbarStyle.normal.textColor = Color.white;
137+ //this._toolbarStyle.alignment = TextAnchor.MiddleCenter;
138+ //this._toolbarStyle.fontSize = 16;
139+ //this._toolbarStyle.margin.right = 10;
140+ //this._toolbarStyle.normal.background = this.makeTexture(new Color32(27, 117, 222, 200));
141+
111142 }
112143
113144 /// <sumary>
@@ -128,7 +159,8 @@ private Texture2D makeTexture(Color col)
128159
129160 private void Update ( )
130161 {
131- if ( Input . GetKeyDown ( KeyCode . F1 ) ) {
162+ if ( Input . GetKeyDown ( KeyCode . F1 ) )
163+ {
132164 this . _isVisible = ! this . _isVisible ;
133165 }
134166 }
@@ -138,13 +170,13 @@ async void OnGUI()
138170
139171 if ( this . _isVisible )
140172 {
141- this . _consoleRect = GUI . Window ( GUIUtility . GetControlID ( FocusType . Passive ) , this . _consoleRect , this . _windosDraw , WINDOW_NAME ) ;
173+ GUI . Window ( GUIUtility . GetControlID ( FocusType . Passive ) , this . _windowRect , this . _windosDraw , "" , this . _windowsStyle ) ;
142174 }
143175 }
144176
145177 private void windowFunction ( int windowID )
146178 {
147- this . _activeTab = GUI . Toolbar ( new Rect ( 10 , 20 , this . _consoleRect . width - 20f , 30 ) , this . _activeTab , this . tabs ) ;
179+ /* this._activeTab = GUI.Toolbar(this._toolbarRect, this._activeTab, this.tabs, this._toolbarStyle );
148180 switch (this._activeTab)
149181 {
150182 case 0:
@@ -153,24 +185,19 @@ private void windowFunction(int windowID)
153185 case 1:
154186 this.sceneTab();
155187 break;
156- /*case 2:
157- this.modsTab();
158- break;*/
159- }
160- GUI . DragWindow ( ) ;
188+ case 2:
189+ this.modsTab();
190+ break;
191+ }*/
192+ this . consoleTab ( ) ;
193+ GUI . DragWindow ( ) ;
161194 }
162195
163196 private void consoleTab ( )
164197 {
165- this . _consoleheight = this . _consoleStyle . CalcHeight ( this . _logs , this . _consoleRect . width - 20f ) ;
166- if ( this . _consoleheight < this . _consoleRect . height - 60f )
167- {
168- this . _scrollConsole . y = this . _consoleheight = this . _consoleRect . height - 60f ;
169- }
170-
171- this . _scrollConsole = GUI . BeginScrollView ( new Rect ( 0 , 55 , this . _consoleRect . width , this . _consoleRect . height - 60f ) , this . _scrollConsole , new Rect ( 0 , 0 , this . _consoleRect . width - 20f , this . _consoleheight ) ) ;
198+ this . _scrollConsole = GUI . BeginScrollView ( this . _consoleRect , this . _scrollConsole , this . _consoleHeightRect ) ;
172199
173- GUI . Box ( new Rect ( 10 , 0 , this . _consoleRect . width - 30f , this . _consoleheight ) , this . _logs , this . _consoleStyle ) ;
200+ GUI . Box ( this . _consoleHeightRect , this . _logs , this . _consoleStyle ) ;
174201
175202 GUI . EndScrollView ( ) ;
176203 }
@@ -188,22 +215,16 @@ private void consoleTab()
188215 GUI.Box(new Rect(10, 0, this._consoleRect.width - 30f, this._consoleheight), this._mods, this._consoleStyle);
189216
190217 GUI.EndScrollView();
191- }*/
218+ }
192219
193220 private void sceneTab()
194221 {
195- this . _consoleheight = this . _consoleStyle . CalcHeight ( this . _sceneGameObjects , this . _consoleRect . width - 20f ) ;
196- if ( this . _consoleheight < this . _consoleRect . height - 60f )
197- {
198- this . _scrollScene . y = this . _consoleheight = this . _consoleRect . height - 60f ;
199- }
200-
201- this . _scrollScene = GUI . BeginScrollView ( new Rect ( 0 , 55 , this . _consoleRect . width , this . _consoleRect . height - 60f ) , this . _scrollScene , new Rect ( 0 , 0 , this . _consoleRect . width - 20f , this . _consoleheight ) ) ;
222+ this._scrollScene = GUI.BeginScrollView(this._sceneRect, this._scrollScene, this._sceneHeightRect);
202223
203- GUI . Box ( new Rect ( 10 , 0 , this . _consoleRect . width - 30f , this . _consoleheight ) , this . _sceneGameObjects , this . _consoleStyle ) ;
224+ GUI.Box(this._sceneHeightRect , this._sceneGameObjects, this._consoleStyle);
204225
205226 GUI.EndScrollView();
206- }
207- }
227+ }*/
208228
229+ }
209230}
0 commit comments