Commits

Brent Tubbs  committed 348df2c

check-in before restyling

  • Participants
  • Parent commits a11b226

Comments (0)

Files changed (4)

   font-size: 10px;
 }
 label { font-size: 12px; }
-#header { background: #000075 url(/img/header_gradient.png) repeat-x; }
+#header { background: #000075 url('../img/header_gradient.png') repeat-x; }
 #header h1 {
   font-size: 50px;
   color: white;
   position: relative;
   width: 18px;
   height: 18px;
-  cursor: move;
   background-color: white;
   background-position: -190px -20px;
   background-repeat: no-repeat;
   font-size: 12px;
   padding: 8px;
 }
-#errors { color: red; }
+#errors {
+  color: red;
+  margin: 10px 0;
+}
+#reset {
+  width: 50%;
+  height: 30px;
+  font-size: 17px;
+  margin-bottom: 15px;
+}
 }
 
 #header {
-    background: #000075 url(/img/header_gradient.png) repeat-x;
+    background: #000075 url('../img/header_gradient.png') repeat-x;
     h1 {
         font-size: 50px;
         color: white;
     position: relative;
     width: 18px;
     height: 18px;
-    cursor: move;
+    /*cursor: move;*/
     background-color: white;
     background-position: -190px -20px ;
     background-repeat: no-repeat;
 }
 #errors {
     color: red;
+    margin: 10px 0;
 }
+
+#reset {
+    width: 50%;
+    height: 30px;
+    font-size: 17px;
+    margin-bottom: 15px;
+}
     <div class="clear"></div>
 </div>
 <div class="container_12" id="bottom">
+    <div class="grid_12">
+    <h2>Oh Noes</h2>
+    <p>So like two weeks after releasing this I learned that it only works in
+    Google Chrome, my browser of choice. Sad news!  I wonder how many IE and
+    Firefox users came here and wondered what all the fuss was about.  Anyway,
+    the controls below should do two things when you fiddle with them: 
+    <ol>
+        <li>Update the 'Code' box to show you the LSL code to make the
+        particles you've configured.</li>
+        <li>Send the settings to the prim inworld so you can see what your
+        particle settings actually look like.</li>
+    </ol>
+    If you'd like to try the magic of Schmarticles for yourself, why not
+    download Google Chrome?  You can get it at <a
+    href="http://www.google.com/chrome">http://www.google.com/chrome</a>.
+    </p>
+    <hr />
+    </div>
+    <div class="clear"></div>
     <div id="left_column" class="grid_4">
-        <h2>Object Info</h2>
+        <h2>Info</h2>
         <div class="gridbox">
             <p id="priminfo"></p>
             <div id="errors"></div>
             <div id="result"></div>
         </div>
-
+        <button type="button" id="reset">Reset Particles</button>
         <h2>Creation and Flow</h2>
         <p>
         Pattern: <select id="PSYS_SRC_PATTERN">
     <!--<div class="clear"></div>-->
     <div class="grid_8">
         <h2>Code</h2>
-        <pre id="code"></pre>
+        <pre id="code" class="brush: lsl;"></pre>
     </div>
     <div class="clear"></div>
 </div>

File js/schmarticles.js

 //TODO: Add a 'clear' button that removes all particles from the prim and
 //resets the page.
 //
-//TODO: figure out a good UI for the ACCEL var.  99% of people will just want
-//to set an upward or downward force, but some people may want to add x or y
-//forces (why?).  Perhaps for simplicity's sake I should just call it "gravity"
-//Yes, I think I should do that.  Usability > completeness/correctness for this
-//project.
-//
+//TODO: on sliders/resizers, make ajax call only on mouseup, instead of flooding the
+//pipe for every single change while dragging
+
 //TODO: find a way to stick tooltips on things.  Inner and Outer angle, for
 //example, need some explanation
 //
 //can land on nice round numbers instead of the .49-like values it settles on
 //right now
 //
-//TODO: on sliders/resizers, make ajax call only on mouseup, instead of flooding the
-//pipe for every single change while dragging
 
 //var working = '<img src="/img/ajax-loader.gif" />';
-var working = '<img src="/img/loading-squares.gif" />';
-var success = '<img src="/img/thumbs_up.png" />';
-var failure = '<img src="/img/thumbs_down.png" />';
+var working = '<img src="img/loading-squares.gif" />';
+var success = '<img src="img/thumbs_up.png" />';
+var failure = '<img src="img/thumbs_down.png" />';
+var schmarticleVersion = 0.7;
+var slurl = 'http://slurl.com/secondlife/Mormo/80/54/32';
 
 function error(errstring) {
     $('#errors').text(errstring);
 function jsonPrim(primurl) {
     this.url = primurl;
     function sendParticleString(particle_string) {
-        var fullurl = this.url + "particles/?particles=" + particle_string + "&callback=?";
+        var fullurl = this.url + "p/?p=" + particle_string + "&callback=?";
         $.getJSON(fullurl, 
             function(data) {
                 if (data.message == 'success') {
                 out = out + '|' + partRules[rule] + '|' + this.particles[rule];
             }
         }
+        out = out.replace(/</g, '').replace(/>/g, '').replace(/ /g,'');
+        console.debug(this);
         return out;
     }
 
-    function updateParticles() {
-        $('#result').html(working);
+    function setFlags() {
         //if there's a target set, then OR in PSYS_PART_TARGET_POS_MASK
         //if not, then negate and AND it out
         if (isKey(this.particles.PSYS_SRC_TARGET_KEY)) {
         } else {
             this.particles.PSYS_PART_FLAGS = this.particles.PSYS_PART_FLAGS & ~partMasks.PSYS_PART_INTERP_SCALE_MASK; 
         }
+    }
 
-        //loop over all of the attributes of the 'particles' sub-object
-        //for any that start with PSYS, look up their integer values in 
-        //partRules and mash them onto the output string
-        var particle_string = '';
-        for (var rule in this.particles) {
-            if (particle_string.length == 0) {
-                particle_string = partRules[rule] + '|' + this.particles[rule];
-            } else {
-                particle_string = particle_string + '|' + partRules[rule] + '|' + this.particles[rule];
-            }
-        }
-        //remove any <, >, and space characters in the string.  they really eat up our
-        //255 when vectors are used
-        particle_string = particle_string.replace(/</g, '').replace(/>/g, '').replace(/ /g,'');
-        //alert(particle_string);
-
-
+    function getLSL() {
         //update the LSL in #code
         var indent = '    ';
         var lsl = 'llParticleSystem([ \n';
             }
         //remove the last comma and newline, and close the list and function
         lsl = lsl.substring(0, lsl.length - 2) + '\n]);';
-        $('#code').text(lsl);
+        return lsl;
+    }
 
-        var fullurl = this.url + "p/?p=" + particle_string + "&callback=?";
-        $.getJSON(fullurl, 
-            function(data) {
-                if (data.message == 'success') {
-                    $('#result').html(success);
-                } else {
-                    $('#result').html(failure + '(' + data.message + ')');
-                }
-            }
-        );
+    function updateObj() {
+        this.setFlags();
+        $('#code').text(this.getLSL());
+    }
+
+    function updateParticles() {
+        this.updateObj();
+        $('#result').html(working);
+        this.sendParticleString(this.getParticleString());
     }
 
     this.sendParticleString = sendParticleString;
     this.getParticleString = getParticleString;
     this.updateParticles = updateParticles;
-    
+    this.setFlags = setFlags;
+    this.getLSL = getLSL;
+    this.updateObj = updateObj;
     this.particles = new Object;
 
     //set some defaults
     this.particles.PSYS_PART_FLAGS = 0;
     this.particles.PSYS_SRC_PATTERN = partPatterns.PSYS_SRC_PATTERN_DROP;
-    this.particles.PSYS_SRC_BURST_RADIUS = 1.0;
-    this.particles.PSYS_SRC_ANGLE_BEGIN = 0;
-    this.particles.PSYS_SRC_ANGLE_END = Math.PI.toString().substring(0, 5);
+    //this.particles.PSYS_SRC_BURST_RADIUS = 0.5;
 }
 
 $(document).ready(function () {
             for (key in data) {
                 info += key + ': ' + data[key] + '<br />';
             }
+
+            if (data.scriptversion == undefined || parseFloat(data.scriptversion) < schmarticleVersion) {
+                $('#errors').html('You have an old version of Schmarticles.  It might not work!.  You can get version ' + schmarticleVersion + ' at <a href="' + slurl + '">' + slurl + '</a>.');
+            }
             $("#priminfo").html(info);
             prim.updateParticles();
         }
     );
 
+    $('#debug').click(function () {
+        //alert(prim.getParticleString());
+        prim.updateParticles();
+    });
+
     //do a sensor
     $.getJSON(prim.url + "sensor/?callback=?", 
         function(sensed) {
             var shortened = scaled.toString().substring(0,4);
             $('#PSYS_SRC_BURST_RADIUS').text(shortened + 'm');
             prim.particles.PSYS_SRC_BURST_RADIUS = shortened;
+            prim.updateObj();
+        },
+        stop: function(event, ui) {
             prim.updateParticles();
         }
     });
             var val = $('#lifetime_slider').slider('value');
             $('#particle_lifetime').text(val + ' sec');
             prim.particles.PSYS_PART_MAX_AGE = val;
+            prim.updateObj();
+        },
+        stop: function(event, ui) {
             prim.updateParticles();
         }
     });
                 $('#burst_interval').text(val + ' sec');
             }
             prim.particles.PSYS_SRC_BURST_RATE = val;
+            prim.updateObj();
+        },
+        stop: function(event, ui) {
             prim.updateParticles();
         }
     });
             var val = $('#count_slider').slider('value');
             $('#count').text(val);
             prim.particles.PSYS_SRC_BURST_PART_COUNT = val;
+            prim.updateObj();
+        },
+        stop: function(event, ui) {
             prim.updateParticles();
         }
     });
             $('#start_alpha_span').text(alpha);
             $('#start_alpha_over').css('backgroundColor', 'rgba(255, 255, 255, ' + alpha + ')');
             prim.particles.PSYS_PART_START_ALPHA = alpha;
+            prim.updateObj();
+        },
+        stop: function(event, ui) {
             prim.updateParticles();
         }
     });
             $('#end_alpha_span').text(alpha);
             $('#end_alpha_over').css('backgroundColor', 'rgba(255, 255, 255, ' + alpha + ')');
             prim.particles.PSYS_PART_END_ALPHA = alpha;
+            prim.updateObj();
+        },
+        stop: function(event, ui) {
             prim.updateParticles();
         }
     });
             //now convert degrees to radians and save on the prim
             var rads = parseFloat(val) / 180.0 * Math.PI;
             prim.particles.PSYS_SRC_ANGLE_BEGIN = rads.toString().substring(0, 5);
+            prim.updateObj();
+        },
+        stop: function(event, ui) {
             prim.updateParticles();
         }
     });
             //now convert degrees to radians and save on the prim
             var rads = parseFloat(val) / 180.0 * Math.PI;
             prim.particles.PSYS_SRC_ANGLE_END = rads.toString().substring(0, 5);
+            prim.updateObj();
+        },
+        stop: function(event, ui) {
             prim.updateParticles();
         }
     });
             $('#gravity').text(val);
             val *= -1;
             prim.particles.PSYS_SRC_ACCEL = '<0, 0, ' + val.toString() + '>';
+            prim.updateObj();
+        },
+        stop: function(event, ui) {
             prim.updateParticles();
         }
     });
             $('#spin').text(val);
             val *= -1;
             prim.particles.PSYS_SRC_OMEGA = '<0, 0, ' + val.toString() + '>';
+            prim.updateObj();
+        },
+        stop: function(event, ui) {
             prim.updateParticles();
         }
     });
             var val = $('#min_speed_slider').slider('value');
             $('#min_speed').text(val + ' mps');
             prim.particles.PSYS_SRC_BURST_SPEED_MIN = val;
+            prim.updateObj();
+        },
+        stop: function(event, ui) {
             prim.updateParticles();
         }
     });
             var val = $('#max_speed_slider').slider('value');
             $('#max_speed').text(val + ' mps');
             prim.particles.PSYS_SRC_BURST_SPEED_MAX = val;
+            prim.updateObj();
+        },
+        stop: function(event, ui) {
             prim.updateParticles();
         }
     });
             $('#start_size_span').text(width + 'm x' + height + 'm');
             var vector = '<' + width + ', ' + height + ', 0>';
             prim.particles.PSYS_PART_START_SCALE = vector;
+            prim.updateObj();
+        },
+        onStop: function(size, position) {
             prim.updateParticles();
-        }        
+        }
     });
 
     $('#end_resizeMe').Resizable({
             $('#end_size_span').text(width + 'm x' + height + 'm');
             var vector = '<' + width + ', ' + height + ', 0>';
             prim.particles.PSYS_PART_END_SCALE = vector;
+            prim.updateObj();
+        },        
+        onStop: function(size, position) {
             prim.updateParticles();
-        }        
+        }
+    });
+
+    $('#reset').click(function() {
+        //delete all the particle settings
+        for (property in prim.particles) {
+            delete prim.particles.property;
+        }
+        //update
+        prim.updateParticles();
+        //refresh
+        location.reload();
     });
 });