Browse Source

Have the JSResource window listen for user preference change notification events

Shaddock Heath 9 years ago
parent
commit
2af71ef32f

+ 5 - 0
Source/Atomic/Resource/ResourceEvents.h

@@ -95,6 +95,11 @@ EVENT(E_PROJECTUNLOADEDNOTIFICATION, ProjecUnloadedNotification)
 {
 }
     
+/// User Preferences Changed
+EVENT(E_USERPREFERENCESCHANGEDNOTIFICAITON, UserPreferencesChangedNotification)
+{
+}
+    
 
 /// Language changed.
 EVENT(E_CHANGELANGUAGE, ChangeLanguage)

+ 12 - 0
Source/AtomicEditor/Editors/JSResourceEditor.cpp

@@ -90,6 +90,7 @@ JSResourceEditor ::JSResourceEditor(Context* context, const String &fullpath, UI
     SubscribeToEvent(E_RENAMERESOURCENOTIFICATION, HANDLER(JSResourceEditor, HandleRenameResourceNotification));
     SubscribeToEvent(E_DELETERESOURCENOTIFICATION, HANDLER(JSResourceEditor, HandleDeleteResourceNotification));
     SubscribeToEvent(E_PROJECTUNLOADEDNOTIFICATION, HANDLER(JSResourceEditor, HandleProjectUnloadedNotification));
+    SubscribeToEvent(E_USERPREFERENCESCHANGEDNOTIFICAITON, HANDLER(JSResourceEditor, HandleUserPreferencesChangedNotification));
 
     c->AddChild(webView_->GetInternalWidget());
 
@@ -137,6 +138,17 @@ void JSResourceEditor::HandleProjectUnloadedNotification(StringHash eventType, V
     webClient_->ExecuteJavaScript("HOST_projectUnloaded();");
 }
 
+void JSResourceEditor::HandleUserPreferencesChangedNotification(StringHash eventType, VariantMap& eventData)
+{
+    ToolSystem* tsys = GetSubsystem<ToolSystem>();
+    Project* proj = tsys->GetProject();
+    FileSystem* fileSystem = GetSubsystem<FileSystem>();
+    if (fileSystem->FileExists(proj->GetUserPrefsFullPath()))
+    {
+        webClient_->ExecuteJavaScript(ToString("HOST_loadPreferences(\"atomic://%s\");", proj->GetUserPrefsFullPath().CString()));
+    }
+}
+    
 void JSResourceEditor::HandleWebViewLoadEnd(StringHash eventType, VariantMap& eventData)
 {
     // need to wait until we get an editor load complete message since we could

+ 1 - 0
Source/AtomicEditor/Editors/JSResourceEditor.h

@@ -71,6 +71,7 @@ private:
     void HandleRenameResourceNotification(StringHash eventType, VariantMap& eventData);
     void HandleDeleteResourceNotification(StringHash eventType, VariantMap& eventData);
     void HandleProjectUnloadedNotification(StringHash eventType, VariantMap& eventData);
+    void HandleUserPreferencesChangedNotification(StringHash eventType, VariantMap& eventData);
     
     SharedPtr<UIWebView> webView_;
     WeakPtr<WebClient> webClient_;