@@ -30,169 +30,169 @@ var user_avatar : ImageTexture = ImageTexture.new()
30
30
var user_img = Image .new ()
31
31
32
32
var connection_status : Array = [
33
- IconLoaderGithub .load_icon_from_name ("searchconnection" ),
34
- IconLoaderGithub .load_icon_from_name ("noconnection" ),
35
- IconLoaderGithub .load_icon_from_name ("connection" )
33
+ IconLoaderGithub .load_icon_from_name ("searchconnection" ),
34
+ IconLoaderGithub .load_icon_from_name ("noconnection" ),
35
+ IconLoaderGithub .load_icon_from_name ("connection" )
36
36
]
37
37
38
38
var plugin_version : String
39
39
var plugin_name : String
40
40
41
41
# Load the configuration file for this plugin to fetch some info
42
42
func load_config () -> void :
43
- var config = ConfigFile .new ()
44
- var err = config .load ("res://addons/github-integration/plugin.cfg" )
45
- if err == OK :
46
- plugin_version = config .get_value ("plugin" ,"version" )
47
- plugin_name = "[%s ] >> " % config .get_value ("plugin" ,"name" )
43
+ var config = ConfigFile .new ()
44
+ var err = config .load ("res://addons/github-integration/plugin.cfg" )
45
+ if err == OK :
46
+ plugin_version = config .get_value ("plugin" ,"version" )
47
+ plugin_name = "[%s ] >> " % config .get_value ("plugin" ,"name" )
48
48
49
49
func connect_signals () -> void :
50
- Menu .connect ("index_pressed" , self , "menu_item_pressed" )
51
- RestartConnection .connect ("pressed" ,self ,"check_connection" )
52
- VersionCheck .connect ("request_completed" ,self ,"_on_version_check" )
53
- SignIn .connect ("signed" ,self ,"signed" )
54
- UserPanel .connect ("completed_loading" , SignIn , "_on_completed_loading" )
55
- UserPanel .connect ("loaded_gists" , Gist , "_on_loaded_repositories" )
56
- Header .connect ("load_invitations" , Notifications , "_on_load_invitations_list" )
57
- Header .notifications_btn .connect ("pressed" , Notifications , "_open_notifications" )
58
- Notifications .connect ("add_notifications" , Header , "_on_add_notifications" )
50
+ Menu .connect ("index_pressed" , self , "menu_item_pressed" )
51
+ RestartConnection .connect ("pressed" ,self ,"check_connection" )
52
+ VersionCheck .connect ("request_completed" ,self ,"_on_version_check" )
53
+ SignIn .connect ("signed" ,self ,"signed" )
54
+ UserPanel .connect ("completed_loading" , SignIn , "_on_completed_loading" )
55
+ UserPanel .connect ("loaded_gists" , Gist , "_on_loaded_repositories" )
56
+ Header .connect ("load_invitations" , Notifications , "_on_load_invitations_list" )
57
+ Header .notifications_btn .connect ("pressed" , Notifications , "_open_notifications" )
58
+ Notifications .connect ("add_notifications" , Header , "_on_add_notifications" )
59
59
60
60
func hide_nodes () -> void :
61
- Repo .hide ()
62
- SignIn .show ()
63
- UserPanel .hide ()
64
- Commit .hide ()
65
- LoadNode .hide ()
61
+ Repo .hide ()
62
+ SignIn .show ()
63
+ UserPanel .hide ()
64
+ Commit .hide ()
65
+ LoadNode .hide ()
66
66
67
67
func _ready ():
68
- connect_signals ()
69
- hide_nodes ()
70
- # Load Config file
71
- load_config ()
72
- Version .text = "v " + plugin_version
73
-
74
- ConnectionIcon .set_texture (connection_status [0 ])
75
- ConnectionIcon .use_parent_material = false
76
- ConnectionIcon .material .set ("shader_param/speed" , 3 )
77
-
78
- # Check the connection with the API
79
- RestHandler .check_connection ()
80
- # Yield until the "_check_connection" function returns a value
81
- var connection = yield (RestHandler , "_check_connection" )
82
- match connection :
83
- true :
84
- ConnectionIcon .set_texture (connection_status [2 ])
85
- ConnectionIcon .set_tooltip ("Connected to GitHub API" )
86
- RestartConnection .hide ()
87
- false :
88
- ConnectionIcon .set_texture (connection_status [1 ])
89
- ConnectionIcon .set_tooltip ("Can't connect to GitHub API, check your internet connection or API status" )
90
- RestartConnection .show ()
91
- ConnectionIcon .use_parent_material = true
92
- ConnectionIcon .material .set ("shader_param/speed" , 0 )
93
-
94
- Menu .set_item_checked (0 , PluginSettings .debug )
95
- Menu .set_item_checked (1 , PluginSettings .auto_log )
96
- # Check the plugin verison
97
- VersionCheck .request ("https://api.github.com/repos/fenix-hub/godot-engine.github-integration/tags" ,[],false ,HTTPClient .METHOD_GET ,"" )
98
-
99
- if PluginSettings .auto_log :
100
- SignIn .sign_in ()
101
-
102
- set_darkmode (PluginSettings .darkmode )
68
+ connect_signals ()
69
+ hide_nodes ()
70
+ # Load Config file
71
+ load_config ()
72
+ Version .text = "v " + plugin_version
73
+
74
+ ConnectionIcon .set_texture (connection_status [0 ])
75
+ ConnectionIcon .use_parent_material = false
76
+ ConnectionIcon .material .set ("shader_param/speed" , 3 )
77
+
78
+ # Check the connection with the API
79
+ RestHandler .check_connection ()
80
+ # Yield until the "_check_connection" function returns a value
81
+ var connection = yield (RestHandler , "_check_connection" )
82
+ match connection :
83
+ true :
84
+ ConnectionIcon .set_texture (connection_status [2 ])
85
+ ConnectionIcon .set_tooltip ("Connected to GitHub API" )
86
+ RestartConnection .hide ()
87
+ false :
88
+ ConnectionIcon .set_texture (connection_status [1 ])
89
+ ConnectionIcon .set_tooltip ("Can't connect to GitHub API, check your internet connection or API status" )
90
+ RestartConnection .show ()
91
+ ConnectionIcon .use_parent_material = true
92
+ ConnectionIcon .material .set ("shader_param/speed" , 0 )
93
+
94
+ Menu .set_item_checked (0 , PluginSettings .debug )
95
+ Menu .set_item_checked (1 , PluginSettings .auto_log )
96
+ # Check the plugin verison
97
+ VersionCheck .request ("https://api.github.com/repos/fenix-hub/godot-engine.github-integration/tags" ,[],false ,HTTPClient .METHOD_GET ,"" )
98
+
99
+ if PluginSettings .auto_log :
100
+ SignIn .sign_in ()
101
+
102
+ set_darkmode (PluginSettings .darkmode )
103
103
104
104
# Show or hide the loading screen
105
105
func loading (value : bool ) -> void :
106
- LoadNode .visible = value
106
+ LoadNode .visible = value
107
107
108
108
# Show the loading process, giving the current value and a maximum value
109
109
func show_loading_progress (value : float , max_value : float ) -> void :
110
- LoadNode .show_progress (value ,max_value )
110
+ LoadNode .show_progress (value ,max_value )
111
111
112
112
func hide_loading_progress ():
113
- LoadNode .hide_progress ()
113
+ LoadNode .hide_progress ()
114
114
115
115
func show_number (value : float , type : String ) -> void :
116
- LoadNode .show_number (value ,type )
116
+ LoadNode .show_number (value ,type )
117
117
118
118
func hide_number () -> void :
119
- LoadNode .hide_number ()
119
+ LoadNode .hide_number ()
120
120
121
121
# If User Signed
122
122
func signed () -> void :
123
- UserPanel .load_panel ()
124
- set_avatar (UserData .AVATAR )
125
- set_username (UserData .USER .login )
126
- yield (UserPanel , "completed_loading" )
127
- Notifications .request_notifications ()
123
+ UserPanel .load_panel ()
124
+ set_avatar (UserData .AVATAR )
125
+ set_username (UserData .USER .login )
126
+ yield (UserPanel , "completed_loading" )
127
+ Notifications .request_notifications ()
128
128
129
129
# Print a debug message if the debug setting is set to "true", with a debug type from 0 to 2
130
130
func print_debug_message (message : String = "" , type : int = 0 ) -> void :
131
- if PluginSettings .debug == true :
132
- match type :
133
- 0 :
134
- print (plugin_name ,message )
135
- 1 :
136
- printerr (plugin_name ,message )
137
- 2 :
138
- push_warning (plugin_name + message )
139
- if type != 1 : set_loading_message (message )
131
+ if PluginSettings .debug == true :
132
+ match type :
133
+ 0 :
134
+ print (plugin_name ,message )
135
+ 1 :
136
+ printerr (plugin_name ,message )
137
+ 2 :
138
+ push_warning (plugin_name + message )
139
+ if type != 1 : set_loading_message (message )
140
140
141
141
func set_loading_message (message : String ):
142
- LoadNode .message .set_text (message )
142
+ LoadNode .message .set_text (message )
143
143
144
144
# Control logic for each item in the plugin menu
145
145
func menu_item_pressed (id : int ) -> void :
146
- match id :
146
+ match id :
147
147
# 0:
148
148
# _on_debug_toggled(!Menu.is_item_checked(id))
149
149
# 1:
150
150
# _on_autologin_toggled(!Menu.is_item_checked(id))
151
- 0 :
152
- OS .shell_open ("https://github.com/fenix-hub/godot-engine.github-integration/wiki" )
153
- 1 :
154
- logout ()
155
- 2 :
156
- set_darkmode (! Menu .is_item_checked (id ))
151
+ 0 :
152
+ OS .shell_open ("https://github.com/fenix-hub/godot-engine.github-integration/wiki" )
153
+ 1 :
154
+ logout ()
155
+ 2 :
156
+ set_darkmode (! Menu .is_item_checked (id ))
157
157
158
158
# Logout function
159
159
func logout ():
160
- set_avatar (IconLoaderGithub .load_icon_from_name ("circle" ))
161
- set_username ("user" )
162
- SignIn .show ()
163
- UserPanel ._clear ()
164
- UserPanel .hide ()
165
- Repo .hide ()
166
- Commit .hide ()
167
- Gist .hide ()
168
- Notifications ._clear ()
169
- Notifications .hide ()
170
- SignIn .Mail .text = ""
171
- SignIn .Token .text = ""
172
- UserData .logout_user ()
160
+ set_avatar (IconLoaderGithub .load_icon_from_name ("circle" ))
161
+ set_username ("user" )
162
+ SignIn .show ()
163
+ UserPanel ._clear ()
164
+ UserPanel .hide ()
165
+ Repo .hide ()
166
+ Commit .hide ()
167
+ Gist .hide ()
168
+ Notifications ._clear ()
169
+ Notifications .hide ()
170
+ SignIn .Mail .text = ""
171
+ SignIn .Token .text = ""
172
+ UserData .logout_user ()
173
173
174
174
# Set to darkmode each single Control
175
175
func set_darkmode (darkmode : bool ) -> void :
176
- PluginSettings .set_darkmode (darkmode )
177
- SignIn .set_darkmode (darkmode )
178
- UserPanel .set_darkmode (darkmode )
179
- Repo .set_darkmode (darkmode )
180
- Commit .set_darkmode (darkmode )
181
- Gist .set_darkmode (darkmode )
182
- Header .set_darkmode (darkmode )
183
- Notifications .set_darkmode (darkmode )
176
+ PluginSettings .set_darkmode (darkmode )
177
+ SignIn .set_darkmode (darkmode )
178
+ UserPanel .set_darkmode (darkmode )
179
+ Repo .set_darkmode (darkmode )
180
+ Commit .set_darkmode (darkmode )
181
+ Gist .set_darkmode (darkmode )
182
+ Header .set_darkmode (darkmode )
183
+ Notifications .set_darkmode (darkmode )
184
184
185
185
func set_avatar (avatar : ImageTexture ) -> void :
186
- $ Header/datas/avatar .texture = avatar
186
+ $ Header/datas/avatar .texture = avatar
187
187
188
188
func set_username (username : String ) -> void :
189
- $ Header/datas/user .text = username
189
+ $ Header/datas/user .text = username
190
190
191
191
# If the plugin version has been checked
192
192
func _on_version_check (result , response_code , headers , body ) -> void :
193
- if result == 0 :
194
- if response_code == 200 :
195
- var tags : Array = JSON .parse (body .get_string_from_utf8 ()).result
196
- var first_tag : Dictionary = tags [0 ] as Dictionary
197
- if first_tag .name != ("v" + plugin_version ):
198
- print_debug_message ("a new plugin version has been found, current version is %s and new version is %s " % [("v" + plugin_version ), first_tag .name ],1 )
193
+ if result == 0 :
194
+ if response_code == 200 :
195
+ var tags : Array = JSON .parse (body .get_string_from_utf8 ()).result
196
+ var first_tag : Dictionary = tags [0 ] as Dictionary
197
+ if first_tag .name != ("v" + plugin_version ):
198
+ print_debug_message ("a new plugin version has been found, current version is %s and new version is %s " % [("v" + plugin_version ), first_tag .name ],1 )
0 commit comments