//============================================================================= // // le_select_edit.mel - handles all selection and field entry for level editor // //============================================================================= /////////////////////////////////////////////////////////////////////////////// // generic callbacks for dialog elements // callback for setting color global proc le_update_color (string $layout, int $run_colorEditor) { string $c, $controls[], $canvas; int $result, $i, $ncontrols = 0; float $rgba[]; $controls = `layout -query -childArray $layout`; for ($c in $controls) { if (get_trailing_string ($c, "float_") != "") $rgba[$ncontrols ++] = `floatField -query -value $c`; else if (get_trailing_string ($c, "canvas_") != "") $canvas = $c; } if ($run_colorEditor) { if ($ncontrols == 3) colorEditor -rgb $rgba[0] $rgba[1] $rgba[2] -result; else colorEditor -rgb $rgba[0] $rgba[1] $rgba[2] -alpha $rgba[3] -result; if (`colorEditor -query -result`) { $rgba = `colorEditor -query -rgb`; if ($ncontrols > 3) $rgba[3] = `colorEditor -query -alpha`; for ($i = 0; $i < $ncontrols; $i++) floatField -edit -value $rgba[$i] $controls[$i]; } } canvas -edit -bg $rgba[0] $rgba[1] $rgba[2] $canvas; // le_update_attr (""); } // callback for deleting an entry in a string table list global proc le_delete_list_entry (string $control) { int $s, $selected[] = `textScrollList -query -sii $control`; for ($s in $selected) textScrollList -edit -rii $s $control; // le_update_attr (""); } // callback for Maya noderef selection global proc le_noderef_select (string $layout, string $callback) { global string $le_current_selection[]; global int $le_selection_scriptjob; string $controls[] = `layout -query -childArray $layout`; string $label; $label = `button -query -label $controls[2]`; if ($label == "select") { $le_selection_scriptjob = 0; $label = `button -edit -label "choose" $controls[2]`; $le_current_selection = `ls -sl`; // copy current selection } else { string $s, $selection[] = `ls -selection`; string $tokens[]; tokenize $selection[0] "|" $tokens; $selection[0] = $tokens[`size($tokens)`-1]; // restore selection select $le_current_selection; $label = `button -edit -label "select" $controls[2]`; // copy current selection here if (get_trailing_string ($controls[1], "textField_") != "") { textField -edit -text $selection[0] $controls[1]; } else { int $selected[] = `textScrollList -query -sii $controls[1]`; for ($s in $selection) textScrollList -edit -append $s $controls[1]; textScrollList -edit -showIndexedItem `textScrollList -query -ni $controls[1]` $controls[1]; } eval ($callback + " (\"update\")"); // hack to disable the scriptjob one more time $le_selection_scriptjob = -1; } } /////////////////////////////////////////////////////////////////////////////// // scriptjob called when the selection changes global proc le_selection_changed () { global int $le_selection_scriptjob; global int $le_scriptjob; string $tokens[], $undotted_tokens[]; string $type = ""; string $attr = ""; string $all[], $sel; int $i; $all = `ls -selection -long`; select -clear; // see if we need to get the 'real' node for ($sel in $all) { // make it into a hierarchy tokenize $sel "|" $tokens; // find first parent that is a level-editor entity for ($i=(size($tokens)-1); $i>=0; $i--) { tokenize $tokens[$i] "." $undotted_tokens; $attr = le_get_attributes ($undotted_tokens[0]); if ($attr != "") { // now select actual level-editor entity select -add $tokens[$i]; break; } } // didn't find one, just select object if ($i == -1) select -add $sel; } if ($le_selection_scriptjob > 0) { if ($attr != "") { tokenize $attr ";" $tokens; $type = $tokens[0]; if ($type != "path") le_kill_all_path_script_jobs(); // update entity's menu eval ("le_handle_" + $type + " (\"select\")"); } else // just a regular object, clear le dialog { le_clear_layout(); } } else if ($le_selection_scriptjob < 0) { $le_selection_scriptjob = 1; le_kill_all_path_script_jobs(); } } /////////////////////////////////////////////////////////////////////////////// // dialog controls // builds a separator global proc le_build_separator () { separator -style "none" -horizontal true -height 8; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Name field changed, do relink and update global proc le_name_changed (string $thing, string $callback) { // get new name string $new_name = `nameField -query -object ("nameField_" + $callback)`; // check if this is a zone or object string $attr = le_get_attributes ($new_name); if ($attr != "") { string $pairs[] = le_pairs_from_attr ($attr); string $obj_type, $link_type; // we've just changed the name of a zone, find its object if ($pairs[0] == "zone") { $obj_type = "zone"; $link_type = "object"; } else // we've changed the name of an object { $obj_type = "object"; $link_type = "zone"; } // find what that zone/object is linked to string $values[] = le_values_from_pairs ($pairs, $link_type); // found it, now change the link object to the new name if ($values[0] != "" && `objExists $values[0]`) { string $attr2 = le_get_attributes ($values[0]); if ($attr2 != "") { string $pairs2[] = le_pairs_from_attr ($attr2); string $values2[] = le_values_from_pairs ($pairs2, $obj_type); if ($values2[0] == $thing) // the old name was there, so we can update it to the new one le_set_attr_from_param ($values[0], $obj_type, le_short_name ($new_name)); } } } eval ("le_handle_" + $callback + " (\"update\")"); } //***************************************************************************** // builds "type", plus name field global proc le_build_type (string $thing, string $name, string $callback) { string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/4; rowColumnLayout -numberOfColumns 2 -columnWidth 1 ($cwidth - 4) -columnSpacing 1 4 -columnWidth 2 ($cwidth*3 - 4) -columnSpacing 2 4 ("nameFieldLayout_" + $name); text -label ($name + ":") ("type_" + $name); // nameField -object $thing -cc ("le_handle_" + $callback + " (\"update\")") ("nameField_" + $name); nameField -object $thing -cc ("le_name_changed (\"" + $thing + "\", \"" + $callback + "\")") ("nameField_" + $callback); setParent ..; } //***************************************************************************** // 2 or 3 float fields corresponding to a vector attribute of thing global proc le_build_attr (string $thing, string $attr, int $extra) { string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/($extra+4); rowColumnLayout -numberOfColumns 8 -columnWidth 1 ($cwidth*4) -columnSpacing 1 4 -columnWidth 2 $cwidth -columnSpacing 2 4 -columnWidth 3 $cwidth -columnSpacing 3 4 -columnWidth 4 $cwidth -columnSpacing 4 4 -columnWidth 5 $cwidth -columnSpacing 5 1; attrFieldGrp -attribute ($thing + "." + $attr) -columnWidth 1 $cwidth -columnWidth 2 $cwidth -columnWidth 3 $cwidth -columnWidth 4 $cwidth ("attrFieldGrp_" + $attr); // caller must do this if it has extra fields if ($extra == 0) setParent ..; } //***************************************************************************** // a list of radio buttons, corresponding to a choice global proc le_build_choice (string $name, string $sel, string $choices[], string $callback) { string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/4 - 4; rowColumnLayout -numberOfColumns 4 -columnWidth 1 $cwidth -columnSpacing 1 4 -columnWidth 2 $cwidth -columnSpacing 2 4 -columnWidth 3 $cwidth -columnSpacing 3 4 ("radioButtonLayout_" + $name); radioCollection $name; text ($name + ":"); for ($choice in $choices) { if ($callback != "") { radioButton -label $choice -onCommand ($callback + " (\"update\")") ("radioButton_" + $choice); } else { radioButton -label $choice ("radioButton_" + $choice); } if ($sel == $choice) { radioButton -edit -select ("radioButton_" + $choice); } } setParent ..; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Set object parameters global proc le_set_object (string $param1, string $param2, string $param3, string $param4, string $object_name, string $object_path) { if ($param1 == "event") { // 1="event", 2=$field_name, 3=$callback, 4=$old_item textField -edit -text $object_name $param2; eval ($param3 + " (\"update\")"); return; } string $thing = $param2; string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); // since we use the same menu, branch here if world object if ($pairs[0] == "world_object") { le_set_world_object ($thing, $object_name, $object_path); return; } else if ($pairs[0] == "sound_object") { le_set_sound_object ($thing, $object_name, $object_path); return; } string $old_type[] = le_values_from_pairs ($pairs, "type"); string $old_ref_path[] = le_values_from_pairs ($pairs, "path"); string $events = le_find_param_in_pairs ($pairs, "events"); string $ref_path; string $object[], $temp_group; if ($old_type[0] != "") { if (le_check_namespace ($old_ref_path[0])) le_delete_namespace ($old_ref_path[0]); } string $ref = le_get_unique_namespace(); le_load_ref_object ($thing, $ref, $object_path); select -r $thing; $ref_path = $ref + "," + $object_path; // zone just changed $attr = le_get_attributes ($thing); $pairs = le_pairs_from_attr ($attr); $zone = le_find_param_in_pairs ($pairs, "zone"); le_update_object ($thing, $object_name, $ref_path, $zone, $events); le_handle_object ("touch"); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Select zone global proc le_select_zone (string $thing) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $zone[] = le_values_from_pairs ($pairs, "zone"); if ($zone[0] != "") { // make sure that it's there if (`objExists $zone[0]`) select -r $zone[0]; } } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Place zone at center of object global proc le_center_zone (string $thing) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $zone[] = le_values_from_pairs ($pairs, "zone"); if ($zone[0] != "") { // make sure that it's still there if (`objExists $zone[0]`) { select -r $zone[0]; float $pos[] = `getAttr ($thing + ".translate")`; move -a -ws $pos[0] $pos[1] $pos[2]; select -r $thing; } } } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Select zone and set the move tool global proc le_set_zone_to_move (string $thing) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $zone[] = le_values_from_pairs ($pairs, "zone"); if ($zone[0] != "") { // make sure that it's there if (`objExists $zone[0]`) { select -r $zone[0]; setToolTo "moveSuperContext"; } } } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_object_zone_options (string $thing) { string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/2 - 6; $layout = `rowColumnLayout -numberOfColumns 2 -columnWidth 1 $cwidth -columnSpacing 1 4 -columnWidth 2 $cwidth -columnSpacing 2 4`; button -l "Go to (select) zone" -c ("le_select_zone (\""+$thing+"\")"); button -l "Move zone to object center" -c ("le_center_zone (\""+$thing+"\")"); setParent ..; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Set world object parameters global proc le_set_world_object (string $thing, string $object_name, string $object_path) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $old_type[] = le_values_from_pairs ($pairs, "type"); string $old_ref_path[] = le_values_from_pairs ($pairs, "path"); string $world_obj = le_find_param_in_pairs ($pairs, "world_obj"); string $ref_path; string $object[], $temp_group; if ($old_type[0] != "") { if (le_check_namespace ($old_ref_path[0])) le_delete_namespace ($old_ref_path[0]); } string $ref = le_get_unique_namespace(); le_load_ref_object ($thing, $ref, $object_path); select -r $thing; $ref_path = $ref + "," + $object_path; le_update_world_object ($thing, $object_name, $ref_path, $world_obj); le_handle_world_object ("touch"); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Set hazard object parameters global proc le_set_hazard_object (string $thing, string $object_name, string $object_path) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $old_type[] = le_values_from_pairs ($pairs, "type"); string $old_ref_path[] = le_values_from_pairs ($pairs, "path"); string $world_obj = le_find_param_in_pairs ($pairs, "world_obj"); string $hazard_type = le_find_param_in_pairs ($pairs, "hazard_type"); string $death_type = le_find_param_in_pairs ($pairs, "death_type"); string $damage = le_find_param_in_pairs ($pairs, "damage"); string $ref_path; string $object[], $temp_group; if ($old_type[0] != "") { if (le_check_namespace ($old_ref_path[0])) le_delete_namespace ($old_ref_path[0]); } string $ref = le_get_unique_namespace(); le_load_ref_object ($thing, $ref, $object_path); select -r $thing; $ref_path = $ref + "," + $object_path; le_update_hazard_object ($thing, $object_name, $ref_path, $world_obj, $hazard_type, $death_type, $damage); le_handle_hazard_object ("touch"); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Set boss object parameters global proc le_set_boss_object (string $thing, string $object_name, string $object_path) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $old_type[] = le_values_from_pairs ($pairs, "type"); string $old_ref_path[] = le_values_from_pairs ($pairs, "path"); string $world_obj = le_find_param_in_pairs ($pairs, "world_obj"); string $boss_obj = le_find_param_in_pairs ($pairs, "boss_obj"); string $body_part = le_find_param_in_pairs ($pairs, "body_part"); string $ref_path; string $object[], $temp_group; if ($old_type[0] != "") { if (le_check_namespace ($old_ref_path[0])) le_delete_namespace ($old_ref_path[0]); } string $ref = le_get_unique_namespace(); le_load_ref_object ($thing, $ref, $object_path); select -r $thing; $ref_path = $ref + "," + $object_path; le_update_boss_object ($thing, $object_name, $ref_path, $world_obj, $boss_obj, $body_part); le_handle_boss_object ("touch"); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Set sound object parameters global proc le_set_sound_object (string $thing, string $object_name, string $object_path) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $old_type[] = le_values_from_pairs ($pairs, "type"); string $old_ref_path[] = le_values_from_pairs ($pairs, "path"); string $inner_vol = le_find_param_in_pairs ($pairs, "inner_vol"); string $outer_vol = le_find_param_in_pairs ($pairs, "outer_vol"); string $snd_name = le_find_param_in_pairs ($pairs, "snd_name"); string $snd_type = le_find_param_in_pairs ($pairs, "snd_type"); string $ref_path; string $object[], $temp_group; if ($old_type[0] != "") { if (le_check_namespace ($old_ref_path[0])) le_delete_namespace ($old_ref_path[0]); } string $ref = le_get_unique_namespace(); le_load_ref_object ($thing, $ref, $object_path); select -r $thing; $ref_path = $ref + "," + $object_path; le_update_sound_object ($thing, $object_name, $ref_path, $inner_vol, $outer_vol, $snd_name, $snd_type); le_handle_sound_object ("touch"); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Set vector field parameters global proc le_set_vector_field (string $thing, string $object_name, string $object_path) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $old_type = le_find_param_in_pairs ($pairs, "type"); string $old_ref_path[] = le_values_from_pairs ($pairs, "path"); string $magnitude = le_find_param_in_pairs ($pairs, "magnitude"); string $max_velocity = le_find_param_in_pairs ($pairs, "max_velocity"); string $priority = le_find_param_in_pairs ($pairs, "priority"); string $vf_path = le_find_param_in_pairs ($pairs, "vf_path"); string $force_dir = le_find_param_in_pairs ($pairs, "force_dir"); string $activate = le_find_param_in_pairs ($pairs, "activate"); string $height = le_find_param_in_pairs ($pairs, "height"); string $radius = le_find_param_in_pairs ($pairs, "radius"); string $inner_dist = le_find_param_in_pairs ($pairs, "inner_dist"); string $outer_dist = le_find_param_in_pairs ($pairs, "outer_dist"); string $inner_dist2 = le_find_param_in_pairs ($pairs, "inner_dist2"); string $outer_dist2 = le_find_param_in_pairs ($pairs, "outer_dist2"); string $inner_dist3 = le_find_param_in_pairs ($pairs, "inner_dist3"); string $outer_dist3 = le_find_param_in_pairs ($pairs, "outer_dist3"); string $ref_path; string $object[], $temp_group; if ($old_type != "") { if (le_check_namespace ($old_ref_path[0])) le_delete_namespace ($old_ref_path[0]); } if ((int)$force_dir < 0 || (int)$force_dir > 1) $force_dir = "0"; string $ref = le_get_unique_namespace(); le_load_ref_object ($thing, $ref, $object_path); select -r $thing; $ref_path = $ref + "," + $object_path; // zone just changed $attr = le_get_attributes ($thing); $pairs = le_pairs_from_attr ($attr); string $zone = le_find_param_in_pairs ($pairs, "zone"); le_update_vector_field ($thing, $object_name, $ref_path, $zone, $magnitude, $max_velocity, $priority, $activate, $force_dir, $vf_path, $height, $radius, $inner_dist, $outer_dist, $inner_dist2, $outer_dist2, $inner_dist3, $outer_dist3); le_handle_vector_field ("touch"); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Place object at center of zone global proc le_center_object (string $thing) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $object[] = le_values_from_pairs ($pairs, "object"); if ($object[0] != "") { // make sure that it's still there if (`objExists $object[0]`) { // see if zone is a child of the object string $long_name[] = `ls -long $thing`; string $children[] = `listRelatives -allDescendents -fullPath $object[0]`; string $child; int $flag = false; float $pos[3]; for ($child in $children) { if ($long_name[0] == $child) $flag = true; } if ($flag == true) // we are a child { // $thing is the zone, $object[0] is the object // get center of zone and apply to object $pos = `getAttr ($thing + ".translate")`; move -r -ws $pos[0] $pos[1] $pos[2] $object[0]; // recenter zone on object $pos = `getAttr ($object[0] + ".translate")`; move -a -ws $pos[0] $pos[1] $pos[2] $thing; } else // unrelated, just copy coords { select -r $object[0]; $pos = `getAttr ($thing + ".translate")`; move -a -ws $pos[0] $pos[1] $pos[2]; select -r $thing; } } } } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Select object and set the move tool global proc le_set_object_to_move (string $thing) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $object[] = le_values_from_pairs ($pairs, "object"); if ($object[0] != "") { // make sure that it's there if (`objExists $object[0]`) { select -r $object[0]; setToolTo "moveSuperContext"; } } } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Select object global proc le_select_object (string $thing) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $object[] = le_values_from_pairs ($pairs, "object"); if ($object[0] != "") { // make sure that it's there if (`objExists $object[0]`) select -r $object[0]; } } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_zone_object_options (string $thing) { string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/2 - 6; $layout = `rowColumnLayout -numberOfColumns 2 -columnWidth 1 $cwidth -columnSpacing 1 4 -columnWidth 2 $cwidth -columnSpacing 2 4`; button -l "Go to (select) object" -c ("le_select_object (\""+$thing+"\")"); // button -l "Move object" -c ("le_set_object_to_move (\""+$thing+"\")"); button -l "Move object to zone center" -c ("le_center_object (\""+$thing+"\")"); setParent ..; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // load object menu (it will call le_set_object from within it) //source ".../le_build_object_menu.mel"; // the above script builds a menu and has entries like this: // menuItem -label "switch_splizz" -c ("le_set_object (\"" + $param1 + "\", \"" + $param2 + "\", \"" + $param3 + "\", \"" + $param4 + "\", \"switch_splizz\", \"//Icarus/usr2/madsci/design/Editor/Switches/switch_splizz.mb\")"); //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_object_selector (string $thing, string $pairs[]) { string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/4 - 4; $layout = `rowColumnLayout -numberOfColumns 4 -columnWidth 1 $cwidth -columnSpacing 1 4 -columnWidth 2 $cwidth -columnSpacing 2 4`; button -l "Choose icon"; popupMenu -button 1; le_build_object_menu ("type", $thing, "", ""); string $values[] = le_values_from_pairs ($pairs, "type"); textField -ed false -tx $values[0]; setParent ..; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_object_type_selector (string $title, string $name, string $value, string $callback) { string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/2 - 4; // set layout so that it can be parsed by parse_layout later $layout = `rowColumnLayout -numberOfColumns 2 -columnWidth 1 $cwidth -columnSpacing 1 4 -columnWidth 2 $cwidth -columnSpacing 2 4 ("stringLayout_" + $name)`; string $item; // will be used by parse_layout and le_menu_selector string $field_name = ("textField_" + $name + "_0"); button -l $title; popupMenu -button 1; le_build_object_menu ("event", $field_name, $callback, $item); // save textField -editable false -text $value $field_name; setParent ..; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // set camera type global proc le_set_camera_type (string $thing, string $camera_type) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $zone = le_find_param_in_pairs ($pairs, "zone"); string $events = le_find_param_in_pairs ($pairs, "events"); le_update_camera ($thing, $camera_type, $zone, $events); le_handle_camera ("touch"); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_camera_selector (string $thing, string $pairs[]) { string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/2 - 4; $layout = `rowColumnLayout -numberOfColumns 2 -columnWidth 1 $cwidth -columnSpacing 1 4 -columnWidth 2 $cwidth -columnSpacing 2 4`; button -l "Choose camera type"; popupMenu -button 1; menuItem -label "none" -c ("le_set_camera_type (\"" + $thing + "\",\",\")"); menuItem -label "2dscroll" -c ("le_set_camera_type (\"" + $thing + "\", \"2dscroll_cam\")"); menuItem -label "al" -c ("le_set_camera_type (\"" + $thing + "\", \"al_cam\")"); menuItem -label "al_insta_fixed" -c ("le_set_camera_type (\"" + $thing + "\", \"al_insta_fixed\")"); menuItem -label "climb" -c ("le_set_camera_type (\"" + $thing + "\", \"climb_cam\")"); menuItem -label "cylinder" -c ("le_set_camera_type (\"" + $thing + "\", \"cylinder_cam\")"); menuItem -label "directional" -c ("le_set_camera_type (\"" + $thing + "\", \"directional_cam\")"); menuItem -label "directional_climb" -c ("le_set_camera_type (\"" + $thing + "\", \"directional_climb_cam\")"); menuItem -label "fixed" -c ("le_set_camera_type (\"" + $thing + "\", \"fixed_cam\")"); menuItem -label "follow" -c ("le_set_camera_type (\"" + $thing + "\", \"follow_cam\")"); menuItem -label "insta_fixed" -c ("le_set_camera_type (\"" + $thing + "\", \"insta_fixed_cam\")"); menuItem -label "insta_plant" -c ("le_set_camera_type (\"" + $thing + "\", \"insta_plant_cam\")"); menuItem -label "inv_cylinder" -c ("le_set_camera_type (\"" + $thing + "\", \"inv_cylinder_cam\")"); menuItem -label "parented_fixed" -c ("le_set_camera_type (\"" + $thing + "\", \"parented_fixed_cam\")"); menuItem -label "parented_planted" -c ("le_set_camera_type (\"" + $thing + "\", \"parented_planted_cam\")"); menuItem -label "planted" -c ("le_set_camera_type (\"" + $thing + "\", \"planted_cam\")"); menuItem -label "rope" -c ("le_set_camera_type (\"" + $thing + "\", \"rope_cam\")"); menuItem -label "track" -c ("le_set_camera_type (\"" + $thing + "\", \"track_cam\")"); string $values[] = le_values_from_pairs ($pairs, "type"); textField -editable false -text $values[0]; setParent ..; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // set camera trigger global proc le_set_camera_trigger (string $thing, string $new_trigger) { global int $le_trigger_index; global string $le_event_data[]; $le_event_data[3] = $new_trigger; le_rebuild_event_data ($thing); le_handle_camera ("touch"); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_camera_trigger (string $thing) { global string $le_trigger_tab[]; global string $le_event_data[]; global int $le_trigger_index; string $cur_trigger = $le_event_data[3]; string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/2 - 4; $layout = `rowColumnLayout -numberOfColumns 2 -columnWidth 1 $cwidth -columnSpacing 1 4 -columnWidth 2 $cwidth -columnSpacing 2 4`; button -l "Choose camera trigger"; popupMenu -button 1; int $tab_idx[] = le_find_dir_in_tab ($le_trigger_tab, "Zone tests"); int $i; if ($tab_idx[0] >= 0 && $tab_idx[1] >= 0) { for ($i=$tab_idx[0]; $i<$tab_idx[1]; $i+=2) { if ($le_trigger_tab[$i+1] == "") menuItem -label $le_trigger_tab[$i] -c ("le_set_camera_trigger (\"" + $thing + "\", \"" + $le_trigger_tab[$i] + "\")"); } } textField -editable false -text $cur_trigger; setParent ..; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // set sound type global proc le_set_sound_type (string $thing, string $snd_type) { string $attr = le_get_attributes ($thing); string $pairs[] = le_pairs_from_attr ($attr); string $type = le_find_param_in_pairs ($pairs, "type"); string $ref_path = le_find_param_in_pairs ($pairs, "path"); string $inner_vol= le_find_param_in_pairs ($pairs, "inner_vol"); string $outer_vol= le_find_param_in_pairs ($pairs, "outer_vol"); string $snd_name = le_find_param_in_pairs ($pairs, "snd_name"); le_update_sound_object ($thing, $type, $ref_path, $inner_vol, $outer_vol, $snd_name, $snd_type); le_handle_sound_object ("touch"); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_sound_type_selector (string $thing, string $pairs[]) { string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/4; int $cwidth2 = $cwidth * 3; $layout = `rowColumnLayout -numberOfColumns 2 -columnWidth 1 $cwidth -columnSpacing 1 4 -columnWidth 2 $cwidth2 -columnSpacing 2 4`; button -l "Choose sound type"; popupMenu -button 1; menuItem -label "snd_normal" -c ("le_set_sound_type (\"" + $thing + "\",\"snd_normal\")"); menuItem -label "snd_activate" -c ("le_set_sound_type (\"" + $thing + "\", \"snd_activate\")"); string $values[] = le_values_from_pairs ($pairs, "snd_type"); textField -ed false -tx $values[0]; setParent ..; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_update_float_edit_field (string $data_ptr, string $data_ref, string $edit_name) { global float $le_edit_data; $le_edit_data = `floatField -q -v $edit_name`; expression -ae true -s ($data_ref + "; " + $data_ptr + " = $le_edit_data;"); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // // Build a generic field editor for a globally defined float // Upon entry: $label -> text label to preceed float data // $data_ptr -> string that contains name of target float // $data_ref -> global definition of target float global proc le_build_float_edit (string $label, string $data_ptr, string $data_ref, string $item) { global float $le_edit_data; string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/3; $layout = `rowColumnLayout -numberOfColumns 2 -columnWidth 1 $cwidth -columnSpacing 1 4 -columnWidth 2 $cwidth -columnSpacing 2 4`; string $edit_name = "le_float_edit" + $item; text $label; // execute a string expression as if it were a script expression -ae true -s ($data_ref + "; $le_edit_data = " + $data_ptr + ";"); floatField -v $le_edit_data -cc ("le_update_float_edit_field (\""+$data_ptr+"\", \""+$data_ref+"\", \"" + $edit_name +"\")") ($edit_name); setParent ..; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_float (string $title, string $name, string $values[], string $callback, int $extra) { int $num = size ($values); if ($num == 0) $num = 1; string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/($num+1+$extra) - 5; int $i; float $value; rowColumnLayout -numberOfColumns 8 -columnWidth 1 $cwidth -columnSpacing 1 4 -columnWidth 2 $cwidth -columnSpacing 2 4 -columnWidth 3 $cwidth -columnSpacing 3 4 -columnWidth 4 $cwidth -columnSpacing 4 4 -columnWidth 5 $cwidth -columnSpacing 5 4 -columnWidth 6 $cwidth -columnSpacing 6 4 -columnWidth 7 $cwidth -columnSpacing 7 4 -columnWidth 8 $cwidth -columnSpacing 8 4 ("floatLayout_" + $name); text ($title + ":"); for ($i=0; $i<$num; $i++) { if ($values[$i] == "") $values[$i] = "0.0"; $value = $values[$i]; print ($title + " " + $value + "\n"); if ($callback != "") { floatField -value $value -changeCommand ($callback + " (\"update\")") ("float_" + $name + "_" + ($i)); } else { floatField -value $value ("float_" + $name + "_" + ($i)); } } // caller must do this if it has extra fields if ($extra == 0) setParent ..; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_update_float (string $title, string $name, string $values[], string $callback, int $extra) { int $num = size ($values); int $i; float $value; text ($title + ":"); for ($i=0; $i<$num; $i++) { if ($values[$i] == "") $values[$i] = "0.0"; $value = $values[$i]; if ($callback != "") { floatField -edit -value $value -changeCommand ($callback + " (\"update\")") ("float_" + $name + "_" + ($i)); } else { floatField -edit -value $value ("float_" + $name + "_" + ($i)); } } } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_int (string $title, string $name, string $values[], string $callback) { int $i; int $value; int $num = size ($values); if ($num == 0) $num = 1; string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/($num+1) - 5; rowColumnLayout -numberOfColumns 8 -columnWidth 1 $cwidth -columnSpacing 1 4 -columnWidth 2 $cwidth -columnSpacing 2 4 -columnWidth 3 $cwidth -columnSpacing 3 4 -columnWidth 4 $cwidth -columnSpacing 4 4 -columnWidth 5 $cwidth -columnSpacing 5 4 -columnWidth 6 $cwidth -columnSpacing 6 4 -columnWidth 7 $cwidth -columnSpacing 7 4 -columnWidth 8 $cwidth -columnSpacing 8 4 ("intLayout_" + $name); text ($title + ":"); for ($i=0; $i<$num; $i++) { if ($values[$i] == "") $values[$i] = "0"; $value = $values[$i]; if ($callback != "") { intField -value $value -changeCommand ($callback + " (\"update\")") ("int_" + $name + "_" + ($i)); } else { intField -value $value ("int_" + $name + "_" + ($i)); } } setParent ..; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_text (string $title, string $name, string $values[], string $callback) { int $num = size ($values); if ($num == 0) $num = 1; string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/($num+1) - 5; int $i; rowColumnLayout -numberOfColumns 8 -columnWidth 1 $cwidth -columnSpacing 1 4 -columnWidth 2 $cwidth -columnSpacing 2 4 -columnWidth 3 $cwidth -columnSpacing 3 4 -columnWidth 4 $cwidth -columnSpacing 4 4 -columnWidth 5 $cwidth -columnSpacing 5 4 -columnWidth 6 $cwidth -columnSpacing 6 4 -columnWidth 7 $cwidth -columnSpacing 7 4 -columnWidth 8 $cwidth -columnSpacing 8 4 ("stringLayout_" + $name); text ($title + ":"); for ($i=0; $i<$num; $i++) { if ($callback != "") { textField -text $values[$i] -changeCommand ($callback + " (\"update\")") ("textField_" + $name + "_" + ($i)); } else { textField -text $values[$i] ("textField_" + $name + "_" + ($i)); } } setParent ..; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_noderef (string $title, string $name, string $values[], string $callback) { string $parent = `setParent -query`; string $layout; int $cwidth1 = 2 * (`layout -query -width $parent`)/5 - 6; int $cwidth2 = (`layout -query -width $parent`)/5 - 6; int $i, $nentries; $layout = `rowColumnLayout -numberOfColumns 3 -columnWidth 1 $cwidth1 -columnSpacing 1 4 -columnWidth 2 $cwidth1 -columnSpacing 2 4 -columnWidth 3 $cwidth2 -columnSpacing 3 4 ("stringLayout_" + $name)`; text $title; $nentries = size ($values); if ($nentries < 2) { if ($callback != "") textField -text $values[0] -editable false -changeCommand ($callback + " (\"update\")") ("textField_" + $name); } else { string $control = `textScrollList -numberOfRows $nentries ("textScrollList_" + $name)`; for ($i = 0; $i < $nentries; $i++) textScrollList -edit -append $values[$i] $control; textScrollList -edit -editable false -deleteKeyCommand ("le_delete_list_entry (\"" + $control + "\")") $control; } button -command ("le_noderef_select (\"" + $layout + "\", \"" + $callback + "\")") -label "select" ("button_" + $name); setParent ..; } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_menu_selector (string $field_name, string $callback, string $item) { textField -edit -text $item $field_name; eval ($callback + " (\"update\")"); } //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& global proc le_build_menu_selector (string $title, string $name, string $value, string $menu[], string $callback) { string $parent = `setParent -query`; int $cwidth = (`layout -query -width $parent`)/2 - 4; // set layout so that it can be parsed by parse_layout later $layout = `rowColumnLayout -numberOfColumns 2 -columnWidth 1 $cwidth -columnSpacing 1 4 -columnWidth 2 $cwidth -columnSpacing 2 4 ("stringLayout_" + $name)`; string $item; int $i; // will be used by parse_layout and le_menu_selector string $field_name = ("textField_" + $name + "_0"); button -l $title; popupMenu -button 1; for ($i=0; $i