@@ -18,9 +18,6 @@ function MSync.AdminPanel.InitMySQL( sheet )
1818 mysqlip :SetPos ( 25 , 50 )
1919 mysqlip :SetSize ( 150 , 20 )
2020 mysqlip :SetText ( " 127.0.0.1" )
21- mysqlip .OnEnter = function ( self )
22- chat .AddText ( self :GetValue () )
23- end
2421
2522 local mysqlport_text = vgui .Create ( " DLabel" , pnl )
2623 mysqlport_text :SetPos ( 25 , 75 )
@@ -31,9 +28,6 @@ function MSync.AdminPanel.InitMySQL( sheet )
3128 mysqlport :SetPos ( 25 , 95 )
3229 mysqlport :SetSize ( 150 , 20 )
3330 mysqlport :SetText ( " 3306" )
34- mysqlport .OnEnter = function ( self )
35- chat .AddText ( self :GetValue () )
36- end
3731
3832 local mysqldb_text = vgui .Create ( " DLabel" , pnl )
3933 mysqldb_text :SetPos ( 25 , 120 )
@@ -44,9 +38,6 @@ function MSync.AdminPanel.InitMySQL( sheet )
4438 mysqldb :SetPos ( 25 , 140 )
4539 mysqldb :SetSize ( 150 , 20 )
4640 mysqldb :SetText ( " MSync" )
47- mysqldb .OnEnter = function ( self )
48- chat .AddText ( self :GetValue () )
49- end
5041
5142 local mysqluser_text = vgui .Create ( " DLabel" , pnl )
5243 mysqluser_text :SetPos ( 25 , 165 )
@@ -57,9 +48,6 @@ function MSync.AdminPanel.InitMySQL( sheet )
5748 mysqluser :SetPos ( 25 , 185 )
5849 mysqluser :SetSize ( 150 , 20 )
5950 mysqluser :SetText ( " root" )
60- mysqluser .OnEnter = function ( self )
61- chat .AddText ( self :GetValue () )
62- end
6351
6452 local mysqlpassword_text = vgui .Create ( " DLabel" , pnl )
6553 mysqlpassword_text :SetPos ( 25 , 210 )
@@ -70,48 +58,101 @@ function MSync.AdminPanel.InitMySQL( sheet )
7058 mysqlpassword :SetPos ( 25 , 230 )
7159 mysqlpassword :SetSize ( 150 , 20 )
7260 mysqlpassword :SetText ( " *****" )
73- mysqlpassword .OnEnter = function ( self )
74- chat .AddText ( self :GetValue () )
75- end
61+
62+ local title_info = vgui .Create ( " DLabel" , pnl )
63+ title_info :SetPos ( 200 , 25 )
64+ title_info :SetColor ( Color ( 0 , 0 , 0 ) )
65+ title_info :SetSize (400 , 15 )
66+ title_info :SetText ( " --Information--" )
67+
68+ local info = vgui .Create ( " DLabel" , pnl )
69+ info :SetPos ( 200 , 30 )
70+ info :SetColor ( Color ( 0 , 0 , 0 ) )
71+ info :SetSize (400 , 200 )
72+ info :SetText ( [[
73+ Support: https://www.Aperture-Development.de
74+ GitHub: https://github.com/Aperture-Development/MSync-2
75+ LICENCE: To know what you are allowed to do and what not,
76+ read the LICENCE file in the root directory of the addon.
77+ If there is no file, the Licence by-nc-sa 4.0 International applies.
78+
79+ Developer: This Addon was created by Aperture Development.
80+ Copyright 2018 - Aperture Development
81+ ]] )
82+
83+ local dbstatus = vgui .Create ( " DLabel" , pnl )
84+ dbstatus :SetPos ( 200 , 210 )
85+ dbstatus :SetColor ( Color ( 0 , 0 , 0 ) )
86+ dbstatus :SetSize (400 , 15 )
87+ dbstatus :SetText ( " DB Connection status: -Not Implemented-" )
7688
7789 local save_button = vgui .Create ( " DButton" , pnl )
7890 save_button :SetText ( " Save Settings" )
7991 save_button :SetPos ( 25 , 290 )
8092 save_button :SetSize ( 130 , 30 )
81- save_button .DoClick = function () end
93+ save_button .DoClick = function ()
94+ MSync .settings .mysql .host = mysqlip :GetValue ()
95+ MSync .settings .mysql .port = mysqlport :GetValue ()
96+ MSync .settings .mysql .database = mysqldb :GetValue ()
97+ MSync .settings .mysql .username = mysqluser :GetValue ()
98+ MSync .settings .mysql .password = mysqlpassword :GetValue ()
99+ MSync .net .sendSettings (MSync .settings )
100+ end
82101
83102 local saveconnect_button = vgui .Create ( " DButton" , pnl )
84103 saveconnect_button :SetText ( " Save and Connect" )
85104 saveconnect_button :SetPos ( 155 , 290 )
86105 saveconnect_button :SetSize ( 130 , 30 )
87- saveconnect_button .DoClick = function () end
106+ saveconnect_button .DoClick = function ()
107+ MSync .settings .mysql .host = mysqlip :GetValue ()
108+ MSync .settings .mysql .port = mysqlport :GetValue ()
109+ MSync .settings .mysql .database = mysqldb :GetValue ()
110+ MSync .settings .mysql .username = mysqluser :GetValue ()
111+ MSync .settings .mysql .password = mysqlpassword :GetValue ()
112+ MSync .net .sendSettings (MSync .settings )
113+ MSync .net .connectDB ()
114+ end
88115
89116 local connect_button = vgui .Create ( " DButton" , pnl )
90117 connect_button :SetText ( " Connect" )
91118 connect_button :SetPos ( 285 , 290 )
92119 connect_button :SetSize ( 130 , 30 )
93- connect_button .DoClick = function () end
120+ connect_button .DoClick = function ()
121+ MSync .net .connectDB ()
122+ end
94123
95124 local reset_button = vgui .Create ( " DButton" , pnl )
96125 reset_button :SetText ( " Reset Settings" )
97126 reset_button :SetPos ( 415 , 290 )
98127 reset_button :SetSize ( 130 , 30 )
99- reset_button .DoClick = function () end
128+ reset_button .DoClick = function ()
129+ mysqlip :SetText (" 127.0.0.1" )
130+ mysqlport :SetText (" 3306" )
131+ mysqldb :SetText (" msync" )
132+ mysqluser :SetText (" root" )
133+ mysqlpassword :SetText (" ****" )
134+ MSync .settings .mysql .host = mysqlip :GetValue ()
135+ MSync .settings .mysql .port = mysqlport :GetValue ()
136+ MSync .settings .mysql .database = mysqldb :GetValue ()
137+ MSync .settings .mysql .username = mysqluser :GetValue ()
138+ MSync .settings .mysql .password = " "
139+ MSync .net .sendSettings (MSync .settings )
140+ end
100141
101142 if not MSync .settings == nil then
102143 mysqlip :SetText (MSync .settings .mysql .host )
103144 mysqlport :SetText (MSync .settings .mysql .port )
104145 mysqldb :SetText (MSync .settings .mysql .database )
105146 mysqluser :SetText (MSync .settings .mysql .username )
106147 else
107- timer .Create (" msync.t.checkForSettings" , 1 , 0 , function ()
148+ timer .Create (" msync.t.checkForSettings" , 0.5 , 0 , function ()
108149 if not MSync .settings or not MSync .settings .mysql then return end ;
109150
110- timer .Remove (" msync.t.checkForSettings" )
111151 mysqlip :SetText (MSync .settings .mysql .host )
112152 mysqlport :SetText (MSync .settings .mysql .port )
113153 mysqldb :SetText (MSync .settings .mysql .database )
114154 mysqluser :SetText (MSync .settings .mysql .username )
155+ timer .Remove (" msync.t.checkForSettings" )
115156 end )
116157 end
117158
@@ -134,16 +175,26 @@ function MSync.AdminPanel.InitModules( sheet )
134175 ModuleList :AddColumn ( " Enabled" )
135176
136177 timer .Create (" msync.t.checkForServerModules" , 1 , 0 , function ()
137-
138178 if not MSync .serverModules then return end ;
139179
140- timer .Remove (" msync.t.checkForServerModules" )
141-
142180 for k ,v in pairs (MSync .serverModules ) do
143- ModuleList :AddItem (v [" Name" ], v [" ModuleIdentifier" ], v [" state" ])
181+ ModuleList :AddLine (v [" Name" ], v [" ModuleIdentifier" ], v [" state" ])
144182 end
183+ timer .Remove (" msync.t.checkForServerModules" )
145184 end )
146-
185+ ModuleList .OnRowRightClick = function (panel , lineID , line )
186+ local ident = line :GetValue (2 )
187+ local cursor_x , cursor_y = ModuleList :CursorPos ()
188+ local DMenu = vgui .Create (" DMenu" , ModuleList )
189+ DMenu :SetPos (cursor_x , cursor_y )
190+ DMenu :AddOption (MSync .serverModules [ident ].Description )
191+ DMenu :AddSpacer ()
192+ DMenu :AddOption (" Enable" )
193+ DMenu :AddOption (" Disable" )
194+ DMenu .OptionSelected = function (menu ,optPnl ,optStr )
195+ MSync .net .toggleModule (ident , optStr )
196+ end
197+ end
147198 return pnl
148199end
149200
@@ -178,6 +229,7 @@ function MSync.AdminPanel.InitPanel()
178229
179230 local panel = vgui .Create ( " DFrame" )
180231 panel :SetSize ( 600 , 400 )
232+ panel :SetTitle ( " MSync Admin Menu" )
181233 panel :Center ()
182234 panel :MakePopup ()
183235
0 commit comments