Anonymous avatar Anonymous committed bdd8c56

Fixed various more loading issues

Comments (0)

Files changed (3)

     AttributeDic::reload_all()
     puts "RELOADED ALL DICS"
     SU2LUX.reset_editor("settings")
+    #@settings_editor = SU2LUX.get_editor("settings")
+    #@settings_editor.updateAllSettings()
+    #@settings_editor.updatePresets()
     puts "RESET SETTINGS EDITOR"
 		#model.active_view.add_observer(SU2LUX_view_observer.new)
 		

su2lux/LuxrenderAttributeDictionaries.rb

     @attribute_dictionary.each {|key, val| yield key, val}
   end
   def include_key?(find_key)
-    puts "FIND KEY: #{find_key}"
+    #puts "FIND KEY: #{find_key}"
     
     self.each do |key, val|
       if find_key == key
         puts "remapping: #{key}"
         @sustrdic[key] = value
       else
-        puts "FOUND"
-        puts key
+        #puts "FOUND"
+        #puts key
       end
       
     end

su2lux/LuxrenderSettingsEditor.rb

 
 def updatePresets() #should be renamed or stuff changed to show_presets
   self.show_presets() #lshows presets already loaded from files
-  puts "UPDTING: " + @lrad["preset"].value
+  puts "UPDTING: " + self.get_current_preset()
   puts "updating"
-  self.js_select_preset(@lrad["preset"].value) #set the current preset
+  self.js_select_preset(self.get_current_preset()) #set the current preset
 end
 
 #set parameters in inputs of settings.html
   end
 end
 
-def load_preset_file(name)
-end
-
-def each_preset_file
-  return []
-end
-
 def su_select_preset(name)
    if @presets.include?(name)
     @lrad["preset"].value = name
   end
 end
 
-
-def find_presets()
+def find_preset_files()
   ret_arr = []
   preset_dir = SU2LUX.plugin_dir + "su2lux/presets"
   Dir.foreach(preset_dir) {|f| ret_arr.push(f) if f != "." and f != ".." and f.include?(".txt")}
   js_select_preset(name)
 end
 
+def set_current_preset(name)
+  #self.su_select_preset(name)
+  @lrad["preset"].value = name
+end
+
+def get_current_preset()
+  return @lrad["preset"].value
+end
+
+
 def remove_preset(name)
 end
 
+def load_preset_dic()
+  preset_names = find_preset_files() 
+  @presets = {} #setup a new hash to store preset objects in.
+  for name in preset_names
+    puts "found: " + name
+    name = name.gsub(/[.]txt/, "") #remove .txt from the end
+    puts "PRESET NAME: " + name
+    pres = Preset.new(name)
+    @presets[name] = pres
+  end
+end
+
+
+def load_current_preset()
+  #preset = @lrad["preset"]
+  #find presets in the preset folder
+  #puts "Loading Current Preset: " + @lrad["preset"].value
+  @presets[@lrad["preset"].value].load
+end
+
 def init_presets()
   preset = Attribute.new("preset")
   @lrad.add_root("preset", preset)
-  @presets = {} #setup a new hash to store preset objects in.
-  new_preset("default")#can be disabled for releases if too slow?
-  @lrad["preset"].value = "default"
-  #if preset.value == "" 
-    #only change preset to default if no other one has been previously selected and saved
-    preset.value = "default"
-  #end
-  self.load_presets()
+  self.load_preset_dic()
+  if @lrad["preset"].value != "" #ensure that the selected preset is reloaded properly
+    puts "FOUND PRESET SETTING: "
+    puts @lrad["preset"].value
+    if not @presets.include?(@lrad["preset"].value)
+      puts "Preset: #{@lrad["preset"].value} not found in file"
+      self.set_current_preset("default")
+    end
+  else
+    self.set_current_preset("default")
+    self.load_current_preset()
+  end
 end
 
+
 def show_presets()
   #puts presets loaded from files into the ui
   @presets.each_key do |name|
   end
 end
 
-def load_presets()
-  #preset = @lrad["preset"]
-  preset_names = find_presets() #find presets in the preset folder
-  @presets = {} #setup a new hash to store preset objects in.
-  for name in preset_names
-    puts "found: " + name
-    name = name.gsub(/[.]txt/, "") #remove .txt from the end
-    puts "PRESET NAME: " + name
-    pres = Preset.new(name)
-    @presets[name] = pres
-  end
-  puts "PRESET.VALUE: " + @lrad["preset"].value
-  @presets[@lrad["preset"].value].load
+def load_default_preset()
 end
 
 
   def initialize(name)
     @file_name = SU2LUX.plugin_dir + "su2lux/presets/" + name.to_s + ".txt"
     @lrsd = AttributeDic.spawn($lrsd_name)
+    @loaded = false
   end
   def save
     File.open(@file_name, "w") do |file|
     puts "SAVED!"
   end
   def load
+    @loaded = true
+    puts "LOADING PRESET: #{@file_name}"
     File.open(@file_name, "r") do |file|
       puts "IMPORTING"
       file.each_line do |line|
       end
     end
   end
+  def loaded?
+    return @loaded
+  end
 end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.