llviewermenu.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llviewermenu.h" 
00035 
00036 // system library includes
00037 #include <iostream>
00038 #include <fstream>
00039 #include <sstream>
00040 
00041 // linden library includes
00042 #include "audioengine.h"
00043 #include "indra_constants.h"
00044 #include "llassetstorage.h"
00045 #include "llchat.h"
00046 #include "llfeaturemanager.h"
00047 #include "llfocusmgr.h"
00048 #include "llfontgl.h"
00049 #include "llinstantmessage.h"
00050 #include "llpermissionsflags.h"
00051 #include "llrect.h"
00052 #include "llsecondlifeurls.h"
00053 #include "lltransactiontypes.h"
00054 #include "llui.h"
00055 #include "llview.h"
00056 #include "llxfermanager.h"
00057 #include "message.h"
00058 #include "raytrace.h"
00059 #include "llsdserialize.h"
00060 #include "lltimer.h"
00061 #include "llvfile.h"
00062 #include "llvolumemgr.h"
00063 
00064 // newview includes
00065 #include "llagent.h"
00066 
00067 #include "llagentpilot.h"
00068 #include "llbox.h"
00069 #include "llcallingcard.h"
00070 #include "llclipboard.h"
00071 #include "llcompilequeue.h"
00072 #include "llconsole.h"
00073 #include "llviewercontrol.h"
00074 #include "lldebugview.h"
00075 #include "lldir.h"
00076 #include "lldrawable.h"
00077 #include "lldrawpoolalpha.h"
00078 #include "lldrawpooltree.h"
00079 #include "llface.h"
00080 #include "llfirstuse.h"
00081 #include "llfloater.h"
00082 #include "llfloaterabout.h"
00083 #include "llfloaterbuycurrency.h"
00084 #include "llfloateractivespeakers.h"
00085 #include "llfloateranimpreview.h"
00086 #include "llfloateravatarinfo.h"
00087 #include "llfloateravatartextures.h"
00088 #include "llfloaterbuildoptions.h"
00089 #include "llfloaterbump.h"
00090 #include "llfloaterbuy.h"
00091 #include "llfloaterbuycontents.h"
00092 #include "llfloaterbuycurrency.h"
00093 #include "llfloaterbuyland.h"
00094 #include "llfloatercamera.h"
00095 #include "llfloaterchat.h"
00096 #include "llfloatercustomize.h"
00097 #include "llfloaterdaycycle.h"
00098 #include "llfloaterdirectory.h"
00099 #include "llfloatereditui.h"
00100 #include "llfloaterchatterbox.h"
00101 #include "llfloaterfriends.h"
00102 #include "llfloatergesture.h"
00103 #include "llfloatergodtools.h"
00104 #include "llfloatergroupinfo.h"
00105 #include "llfloatergroupinvite.h"
00106 #include "llfloatergroups.h"
00107 #include "llfloaterhtml.h"
00108 #include "llfloaterhtmlhelp.h"
00109 #include "llfloaterhud.h"
00110 #include "llfloaterinspect.h"
00111 #include "llfloaterlagmeter.h"
00112 #include "llfloaterland.h"
00113 #include "llfloaterlandholdings.h"
00114 #include "llfloatermap.h"
00115 #include "llfloatermute.h"
00116 #include "llfloateropenobject.h"
00117 #include "llfloaterpermissionsmgr.h"
00118 #include "llfloaterpostprocess.h"
00119 #include "llfloaterpreference.h"
00120 #include "llfloaterregioninfo.h"
00121 #include "llfloaterreporter.h"
00122 #include "llfloaterscriptdebug.h"
00123 #include "llfloatersettingsdebug.h"
00124 #include "llfloaterenvsettings.h"
00125 #include "llfloaterstats.h"
00126 #include "llfloatertest.h"
00127 #include "llfloatertools.h"
00128 #include "llfloaterwater.h"
00129 #include "llfloaterwindlight.h"
00130 #include "llfloaterworldmap.h"
00131 #include "llframestats.h"
00132 #include "llframestatview.h"
00133 #include "llfasttimerview.h"
00134 #include "llmemoryview.h"
00135 #include "llgivemoney.h"
00136 #include "llgroupmgr.h"
00137 #include "llhoverview.h"
00138 #include "llhudeffecttrail.h"
00139 #include "llhudmanager.h"
00140 #include "llimage.h"
00141 #include "llimagebmp.h"
00142 #include "llimagej2c.h"
00143 #include "llimagetga.h"
00144 #include "llinventorymodel.h"
00145 #include "llinventoryview.h"
00146 #include "llkeyboard.h"
00147 #include "llpanellogin.h"
00148 #include "llfloaterlandmark.h"
00149 #include "llmenucommands.h"
00150 #include "llmenugl.h"
00151 #include "llmorphview.h"
00152 #include "llmoveview.h"
00153 #include "llmutelist.h"
00154 #include "llnotify.h"
00155 #include "llpanelobject.h"
00156 #include "llparcel.h"
00157 #include "llprimitive.h"
00158 #include "llresmgr.h"
00159 #include "llselectmgr.h"
00160 #include "llsky.h"
00161 #include "llstatusbar.h"
00162 #include "llstatview.h"
00163 #include "llstring.h"
00164 #include "llsurfacepatch.h"
00165 #include "llimview.h"
00166 #include "lltextureview.h"
00167 #include "lltool.h"
00168 #include "lltoolbar.h"
00169 #include "lltoolcomp.h"
00170 #include "lltoolfocus.h"
00171 #include "lltoolgrab.h"
00172 #include "lltoolmgr.h"
00173 #include "lltoolpie.h"
00174 #include "lltoolplacer.h"
00175 #include "lltoolselectland.h"
00176 #include "lluictrlfactory.h"
00177 #include "lluploaddialog.h"
00178 #include "lluserauth.h"
00179 #include "lluuid.h"
00180 #include "llvelocitybar.h"
00181 #include "llviewercamera.h"
00182 #include "llviewergenericmessage.h"
00183 #include "llviewergesture.h"
00184 #include "llviewerinventory.h"
00185 #include "llviewermenufile.h"   // init_menu_file()
00186 #include "llviewermessage.h"
00187 #include "llviewernetwork.h"
00188 #include "llviewerobjectlist.h"
00189 #include "llviewerparcelmgr.h"
00190 #include "llviewerparceloverlay.h"
00191 #include "llviewerregion.h"
00192 #include "llviewerstats.h"
00193 #include "llviewerwindow.h"
00194 #include "llvoavatar.h"
00195 #include "llvolume.h"
00196 #include "llweb.h"
00197 #include "llworld.h"
00198 #include "llworldmap.h"
00199 #include "object_flags.h"
00200 #include "pipeline.h"
00201 #include "llappviewer.h"
00202 #include "roles_constants.h"
00203 #include "llviewerjoystick.h"
00204 #include "llwlanimator.h"
00205 #include "llwlparammanager.h"
00206 #include "llwaterparammanager.h"
00207 
00208 #include "lltexlayer.h"
00209 
00210 void init_landmark_menu(LLMenuGL* menu);
00211 void clear_landmark_menu(LLMenuGL* menu);
00212 
00213 void init_client_menu(LLMenuGL* menu);
00214 void init_server_menu(LLMenuGL* menu);
00215 
00216 void init_debug_world_menu(LLMenuGL* menu);
00217 void init_debug_rendering_menu(LLMenuGL* menu);
00218 void init_debug_ui_menu(LLMenuGL* menu);
00219 void init_debug_xui_menu(LLMenuGL* menu);
00220 void init_debug_avatar_menu(LLMenuGL* menu);
00221 void init_debug_baked_texture_menu(LLMenuGL* menu);
00222 
00223 BOOL enable_land_build(void*);
00224 BOOL enable_object_build(void*);
00225 
00226 LLVOAvatar* find_avatar_from_object( LLViewerObject* object );
00227 LLVOAvatar* find_avatar_from_object( const LLUUID& object_id );
00228 
00229 void handle_test_load_url(void*);
00230 
00231 //
00232 // Evil hackish imported globals
00233 //
00234 extern BOOL     gRenderLightGlows;
00235 extern BOOL gRenderAvatar;
00236 extern BOOL     gHideSelectedObjects;
00237 extern BOOL gShowOverlayTitle;
00238 extern BOOL gOcclusionCull;
00239 extern BOOL gAllowSelectAvatar;
00240 
00241 //
00242 // Globals
00243 //
00244 
00245 LLMenuBarGL             *gMenuBarView = NULL;
00246 LLViewerMenuHolderGL    *gMenuHolder = NULL;
00247 LLMenuGL                *gPopupMenuView = NULL;
00248 LLMenuBarGL             *gLoginMenuBarView = NULL;
00249 
00250 // Pie menus
00251 LLPieMenu       *gPieSelf       = NULL;
00252 LLPieMenu       *gPieAvatar = NULL;
00253 LLPieMenu       *gPieObject = NULL;
00254 LLPieMenu       *gPieAttachment = NULL;
00255 LLPieMenu       *gPieLand       = NULL;
00256 
00257 // local constants
00258 const LLString LANDMARK_MENU_NAME("Landmarks");
00259 const LLString CLIENT_MENU_NAME("Advanced");
00260 const LLString SERVER_MENU_NAME("Admin");
00261 
00262 const LLString SAVE_INTO_INVENTORY("Save Object Back to My Inventory");
00263 const LLString SAVE_INTO_TASK_INVENTORY("Save Object Back to Object Contents");
00264 
00265 #if LL_WINDOWS
00266 static const char* SOUND_EXTENSIONS = ".wav";
00267 static const char* IMAGE_EXTENSIONS = ".tga .bmp .jpg .jpeg .png";
00268 static const char* ANIM_EXTENSIONS =  ".bvh";
00269 #ifdef _CORY_TESTING
00270 static const char* GEOMETRY_EXTENSIONS = ".slg";
00271 #endif
00272 static const char* XML_EXTENSIONS = ".xml";
00273 static const char* SLOBJECT_EXTENSIONS = ".slobject";
00274 #endif
00275 static const char* ALL_FILE_EXTENSIONS = "*.*";
00276 
00277 LLMenuGL* gAttachSubMenu = NULL;
00278 LLMenuGL* gDetachSubMenu = NULL;
00279 LLMenuGL* gTakeOffClothes = NULL;
00280 LLPieMenu* gPieRate = NULL;
00281 LLPieMenu* gAttachScreenPieMenu = NULL;
00282 LLPieMenu* gAttachPieMenu = NULL;
00283 LLPieMenu* gAttachBodyPartPieMenus[8];
00284 LLPieMenu* gDetachPieMenu = NULL;
00285 LLPieMenu* gDetachScreenPieMenu = NULL;
00286 LLPieMenu* gDetachBodyPartPieMenus[8];
00287 
00288 LLMenuGL* gLandmarkMenu = NULL;
00289 LLMenuItemCallGL* gAFKMenu = NULL;
00290 LLMenuItemCallGL* gBusyMenu = NULL;
00291 
00292 typedef LLMemberListener<LLView> view_listener_t;
00293 
00294 //
00295 // Local prototypes
00296 //
00297 void handle_leave_group(void *);
00298 
00299 // File Menu
00300 const char* upload_pick(void* data);
00301 void handle_upload(void* data);
00302 //void handle_upload_object(void* data);
00303 void handle_compress_image(void*);
00304 BOOL enable_save_as(void *);
00305 
00306 // Edit menu
00307 void handle_dump_group_info(void *);
00308 void handle_dump_capabilities_info(void *);
00309 void handle_dump_focus(void*);
00310 
00311 void handle_region_dump_settings(void*);
00312 void handle_region_dump_temp_asset_data(void*);
00313 void handle_region_clear_temp_asset_data(void*);
00314 
00315 // Object pie menu
00316 BOOL sitting_on_selection();
00317 
00318 void near_sit_object();
00319 void label_sit_or_stand(LLString& label, void*);
00320 // buy and take alias into the same UI positions, so these
00321 // declarations handle this mess.
00322 BOOL is_selection_buy_not_take();
00323 S32 selection_price();
00324 BOOL enable_take();
00325 void handle_take();
00326 void confirm_take(S32 option, void* data);
00327 BOOL enable_buy(void*); 
00328 void handle_buy(void *);
00329 void handle_buy_object(LLSaleInfo sale_info);
00330 void handle_buy_contents(LLSaleInfo sale_info);
00331 void label_touch(LLString& label, void*);
00332 
00333 // Land pie menu
00334 void near_sit_down_point(BOOL success, void *);
00335 
00336 // Avatar pie menu
00337 void handle_follow(void *userdata);
00338 void handle_talk_to(void *userdata);
00339 
00340 // Debug menu
00341 void show_permissions_control(void*);
00342 void load_url_local_file(const char* file_name);
00343 void toggle_build_options(void* user_data);
00344 #if 0 // Unused
00345 void handle_audio_status_1(void*);
00346 void handle_audio_status_2(void*);
00347 void handle_audio_status_3(void*);
00348 void handle_audio_status_4(void*);
00349 #endif
00350 void manage_landmarks(void*);
00351 void create_new_landmark(void*);
00352 void landmark_menu_action(void*);
00353 void reload_ui(void*);
00354 void handle_agent_stop_moving(void*);
00355 void print_packets_lost(void*);
00356 void drop_packet(void*);
00357 void velocity_interpolate( void* data );
00358 void update_fov(S32 increments);
00359 void toggle_wind_audio(void);
00360 void toggle_water_audio(void);
00361 void handle_rebake_textures(void*);
00362 BOOL check_admin_override(void*);
00363 void handle_admin_override_toggle(void*);
00364 #ifdef TOGGLE_HACKED_GODLIKE_VIEWER
00365 void handle_toggle_hacked_godmode(void*);
00366 BOOL check_toggle_hacked_godmode(void*);
00367 #endif
00368 
00369 void toggle_glow(void *);
00370 BOOL check_glow(void *);
00371 
00372 void toggle_vertex_shaders(void *);
00373 BOOL check_vertex_shaders(void *);
00374 
00375 void toggle_cull_small(void *);
00376 
00377 void toggle_show_xui_names(void *);
00378 BOOL check_show_xui_names(void *);
00379 
00380 void run_vectorize_perf_test(void *)
00381 {
00382         gSavedSettings.setBOOL("VectorizePerfTest", TRUE);
00383 }
00384 
00385 // Debug UI
00386 void handle_web_search_demo(void*);
00387 void handle_slurl_test(void*);
00388 void handle_save_to_xml(void*);
00389 void handle_load_from_xml(void*);
00390 
00391 void handle_god_mode(void*);
00392 
00393 // God menu
00394 void handle_leave_god_mode(void*);
00395 
00396 BOOL is_inventory_visible( void* user_data );
00397 void handle_reset_view();
00398 
00399 void disabled_duplicate(void*);
00400 void handle_duplicate_in_place(void*);
00401 void handle_repeat_duplicate(void*);
00402 
00403 void handle_export(void*);
00404 // void handle_deed_object_to_group(void*);
00405 // BOOL enable_deed_object_to_group(void*);
00406 void handle_object_owner_self(void*);
00407 void handle_object_owner_permissive(void*);
00408 void handle_object_lock(void*);
00409 void handle_object_asset_ids(void*);
00410 void force_take_copy(void*);
00411 #ifdef _CORY_TESTING
00412 void force_export_copy(void*);
00413 void force_import_geometry(void*);
00414 #endif
00415 
00416 void handle_force_parcel_owner_to_me(void*);
00417 void handle_force_parcel_to_content(void*);
00418 void handle_claim_public_land(void*);
00419 
00420 void handle_god_request_havok(void *);
00421 void handle_god_request_avatar_geometry(void *);        // Hack for easy testing of new avatar geometry
00422 void reload_personal_settings_overrides(void *);
00423 void reload_vertex_shader(void *);
00424 void slow_mo_animations(void *);
00425 void handle_disconnect_viewer(void *);
00426 
00427 void force_error_breakpoint(void *);
00428 void force_error_llerror(void *);
00429 void force_error_bad_memory_access(void *);
00430 void force_error_infinite_loop(void *);
00431 void force_error_software_exception(void *);
00432 
00433 void handle_stopall(void*);
00434 //void handle_hinge(void*);
00435 //void handle_ptop(void*);
00436 //void handle_lptop(void*);
00437 //void handle_wheel(void*);
00438 //void handle_dehinge(void*);
00439 BOOL enable_dehinge(void*);
00440 void handle_force_delete(void*);
00441 void print_object_info(void*);
00442 void print_agent_nvpairs(void*);
00443 void toggle_debug_menus(void*);
00444 void toggle_map( void* user_data );
00445 void export_info_callback(LLAssetInfo *info, void **user_data, S32 result);
00446 void export_data_callback(LLVFS *vfs, const LLUUID& uuid, LLAssetType::EType type, void **user_data, S32 result);
00447 void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status);
00448 BOOL menu_check_build_tool( void* user_data );
00449 void handle_reload_settings(void*);
00450 void focus_here(void*);
00451 void dump_select_mgr(void*);
00452 void dump_volume_mgr(void*);
00453 void dump_inventory(void*);
00454 void edit_ui(void*);
00455 void toggle_visibility(void*);
00456 BOOL get_visibility(void*);
00457 
00458 // Avatar Pie menu
00459 void request_friendship(const LLUUID& agent_id);
00460 
00461 // Tools menu
00462 void handle_force_unlock(void*);
00463 void handle_selected_texture_info(void*);
00464 void handle_dump_image_list(void*);
00465 
00466 void handle_crash(void*);
00467 void handle_dump_followcam(void*);
00468 void handle_viewer_enable_message_log(void*);
00469 void handle_viewer_disable_message_log(void*);
00470 void handle_send_postcard(void*);
00471 void handle_gestures_old(void*);
00472 void handle_focus(void *);
00473 BOOL enable_buy_land(void*);
00474 void handle_move(void*);
00475 void handle_show_inventory(void*);
00476 void handle_activate(void*);
00477 BOOL enable_activate(void*);
00478 
00479 // Help menu
00480 void handle_buy_currency(void*);
00481 
00482 void handle_test_male(void *);
00483 void handle_test_female(void *);
00484 void handle_toggle_pg(void*);
00485 void handle_dump_attachments(void *);
00486 void handle_show_overlay_title(void*);
00487 void handle_dump_avatar_local_textures(void*);
00488 void handle_debug_avatar_textures(void*);
00489 void handle_grab_texture(void*);
00490 BOOL enable_grab_texture(void*);
00491 void handle_dump_region_object_cache(void*);
00492 
00493 BOOL menu_ui_enabled(void *user_data);
00494 void check_toggle_control( LLUICtrl *, void* user_data );
00495 BOOL menu_check_control( void* user_data);
00496 void menu_toggle_variable( void* user_data );
00497 BOOL menu_check_variable( void* user_data);
00498 BOOL enable_land_selected( void* );
00499 BOOL enable_more_than_one_selected(void* );
00500 BOOL enable_selection_you_own_all(void*);
00501 BOOL enable_selection_you_own_one(void*);
00502 BOOL enable_save_into_inventory(void*);
00503 BOOL enable_save_into_task_inventory(void*);
00504 BOOL enable_not_thirdperson(void*);
00505 BOOL enable_export_selected(void *);
00506 BOOL enable_have_card(void*);
00507 BOOL enable_detach(void*);
00508 BOOL enable_region_owner(void*);
00509 
00510 class LLLandmarkObserver : public LLInventoryObserver
00511 {
00512 public:
00513         LLLandmarkObserver();
00514         virtual ~LLLandmarkObserver();
00515 
00516         virtual void changed(U32 mask)
00517         {
00518                 // JC - Disabled for now - slows down client or causes crashes
00519                 // in inventory code.
00520                 //
00521                 // Also, this may not be faster than just rebuilding the menu each time.
00522                 // I believe gInventory.getObject() is not fast.
00523                 //
00524                 //const std::set<LLUUID>& changed_ids = gInventory.getChangedIDs();
00525                 //std::set<LLUUID>::const_iterator id_it;
00526                 //BOOL need_to_rebuild_menu = FALSE;
00527                 //for(id_it = changed_ids.begin(); id_it != changed_ids.end(); ++id_it)
00528                 //{
00529                 //      LLInventoryObject* objectp = gInventory.getObject(*id_it);
00530                 //      if (objectp && (objectp->getType() == LLAssetType::AT_LANDMARK || objectp->getType() == LLAssetType::AT_CATEGORY))
00531                 //      {
00532                 //              need_to_rebuild_menu = TRUE;
00533                 //      }
00534                 //}
00535                 //if (need_to_rebuild_menu)
00536                 //{
00537                 //      init_landmark_menu(gLandmarkMenu);
00538                 //}
00539         }
00540 };
00541 
00542 // For debugging only, I think the inventory observer doesn't get 
00543 // called if the inventory is loaded from cache.
00544 void build_landmark_menu(void*)
00545 {
00546         init_landmark_menu(gLandmarkMenu);
00547 }
00548 
00549 LLLandmarkObserver::LLLandmarkObserver()
00550 {
00551         gInventory.addObserver(this);
00552 }
00553 
00554 LLLandmarkObserver::~LLLandmarkObserver()
00555 {
00556         gInventory.removeObserver(this);
00557 }
00558 
00559 class LLMenuParcelObserver : public LLParcelObserver
00560 {
00561 public:
00562         LLMenuParcelObserver();
00563         ~LLMenuParcelObserver();
00564         virtual void changed();
00565 };
00566 
00567 static LLMenuParcelObserver* gMenuParcelObserver = NULL;
00568 static LLLandmarkObserver* gLandmarkObserver = NULL;
00569 
00570 LLMenuParcelObserver::LLMenuParcelObserver()
00571 {
00572         LLViewerParcelMgr::getInstance()->addObserver(this);
00573 }
00574 
00575 LLMenuParcelObserver::~LLMenuParcelObserver()
00576 {
00577         LLViewerParcelMgr::getInstance()->removeObserver(this);
00578 }
00579 
00580 void LLMenuParcelObserver::changed()
00581 {
00582         gMenuHolder->childSetEnabled("Land Buy Pass", LLPanelLandGeneral::enableBuyPass(NULL));
00583         
00584         BOOL buyable = enable_buy_land(NULL);
00585         gMenuHolder->childSetEnabled("Land Buy", buyable);
00586         gMenuHolder->childSetEnabled("Buy Land...", buyable);
00587 }
00588 
00589 
00590 //-----------------------------------------------------------------------------
00591 // Menu Construction
00592 //-----------------------------------------------------------------------------
00593 
00594 // code required to calculate anything about the menus
00595 void pre_init_menus()
00596 {
00597         // static information
00598         LLColor4 color;
00599         color = gColors.getColor( "MenuDefaultBgColor" );
00600         LLMenuGL::setDefaultBackgroundColor( color );
00601         color = gColors.getColor( "MenuItemEnabledColor" );
00602         LLMenuItemGL::setEnabledColor( color );
00603         color = gColors.getColor( "MenuItemDisabledColor" );
00604         LLMenuItemGL::setDisabledColor( color );
00605         color = gColors.getColor( "MenuItemHighlightBgColor" );
00606         LLMenuItemGL::setHighlightBGColor( color );
00607         color = gColors.getColor( "MenuItemHighlightFgColor" );
00608         LLMenuItemGL::setHighlightFGColor( color );
00609 }
00610 
00611 void initialize_menus();
00612 
00613 //-----------------------------------------------------------------------------
00614 // Initialize main menus
00615 //
00616 // HOW TO NAME MENUS:
00617 //
00618 // First Letter Of Each Word Is Capitalized, Even At Or And
00619 //
00620 // Items that lead to dialog boxes end in "..."
00621 //
00622 // Break up groups of more than 6 items with separators
00623 //-----------------------------------------------------------------------------
00624 
00625 void set_underclothes_menu_options()
00626 {
00627         if (gMenuHolder && gAgent.isTeen())
00628         {
00629                 gMenuHolder->getChild<LLView>("Self Underpants", TRUE)->setVisible(FALSE);
00630                 gMenuHolder->getChild<LLView>("Self Undershirt", TRUE)->setVisible(FALSE);
00631         }
00632         if (gMenuBarView && gAgent.isTeen())
00633         {
00634                 gMenuBarView->getChild<LLView>("Menu Underpants", TRUE)->setVisible(FALSE);
00635                 gMenuBarView->getChild<LLView>("Menu Undershirt", TRUE)->setVisible(FALSE);
00636         }
00637 }
00638 
00639 void init_menus()
00640 {
00641         S32 top = gViewerWindow->getRootView()->getRect().getHeight();
00642         S32 width = gViewerWindow->getRootView()->getRect().getWidth();
00643 
00644         //
00645         // Main menu bar
00646         //
00647         gMenuHolder = new LLViewerMenuHolderGL();
00648         gMenuHolder->setRect(LLRect(0, top, width, 0));
00649         gMenuHolder->setFollowsAll();
00650 
00651         LLMenuGL::sMenuContainer = gMenuHolder;
00652 
00653         // Initialize actions
00654         initialize_menus();
00655 
00661         
00662         gPopupMenuView = new LLMenuGL( "Popup" );
00663         gPopupMenuView->setVisible( FALSE );
00664         gMenuHolder->addChild( gPopupMenuView );
00665 
00669         gPieSelf = LLUICtrlFactory::getInstance()->buildPieMenu("menu_pie_self.xml", gMenuHolder);
00670 
00671         // TomY TODO: what shall we do about these?
00672         gDetachScreenPieMenu = gMenuHolder->getChild<LLPieMenu>("Object Detach HUD", true);
00673         gDetachPieMenu = gMenuHolder->getChild<LLPieMenu>("Object Detach", true);
00674 
00675         gPieAvatar = LLUICtrlFactory::getInstance()->buildPieMenu("menu_pie_avatar.xml", gMenuHolder);
00676 
00677         gPieObject = LLUICtrlFactory::getInstance()->buildPieMenu("menu_pie_object.xml", gMenuHolder);
00678 
00679         gAttachScreenPieMenu = gMenuHolder->getChild<LLPieMenu>("Object Attach HUD");
00680         gAttachPieMenu = gMenuHolder->getChild<LLPieMenu>("Object Attach");
00681         gPieRate = gMenuHolder->getChild<LLPieMenu>("Rate Menu");
00682 
00683         gPieAttachment = LLUICtrlFactory::getInstance()->buildPieMenu("menu_pie_attachment.xml", gMenuHolder);
00684 
00685         gPieLand = LLUICtrlFactory::getInstance()->buildPieMenu("menu_pie_land.xml", gMenuHolder);
00686 
00690         LLColor4 color;
00691 
00692         LLColor4 pie_color = gColors.getColor("PieMenuBgColor");
00693         gPieSelf->setBackgroundColor( pie_color );
00694         gPieAvatar->setBackgroundColor( pie_color );
00695         gPieObject->setBackgroundColor( pie_color );
00696         gPieAttachment->setBackgroundColor( pie_color );
00697         gPieLand->setBackgroundColor( pie_color );
00698 
00699         color = gColors.getColor( "MenuPopupBgColor" );
00700         gPopupMenuView->setBackgroundColor( color );
00701 
00702         // If we are not in production, use a different color to make it apparent.
00703         if (LLAppViewer::instance()->isInProductionGrid())
00704         {
00705                 color = gColors.getColor( "MenuBarBgColor" );
00706         }
00707         else
00708         {
00709                 color = gColors.getColor( "MenuNonProductionBgColor" );
00710         }
00711         gMenuBarView = (LLMenuBarGL*)LLUICtrlFactory::getInstance()->buildMenu("menu_viewer.xml", gMenuHolder);
00712         gMenuBarView->setRect(LLRect(0, top, 0, top - MENU_BAR_HEIGHT));
00713         gMenuBarView->setBackgroundColor( color );
00714 
00715     gMenuBarView->setItemVisible("Tools", FALSE);
00716         gMenuBarView->arrange();
00717         
00718         gMenuHolder->addChild(gMenuBarView);
00719         
00720         // menu holder appears on top of menu bar so you can see the menu title
00721         // flash when an item is triggered (the flash occurs in the holder)
00722         gViewerWindow->getRootView()->addChild(gMenuHolder);
00723    
00724     gViewerWindow->setMenuBackgroundColor(false, 
00725         LLAppViewer::instance()->isInProductionGrid());
00726 
00727         // *TODO:Get the cost info from the server
00728         const LLString upload_cost("10");
00729         gMenuHolder->childSetLabelArg("Upload Image", "[COST]", upload_cost);
00730         gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", upload_cost);
00731         gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", upload_cost);
00732         gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", upload_cost);
00733 
00734         gAFKMenu = gMenuBarView->getChild<LLMenuItemCallGL>("Set Away", TRUE);
00735         gBusyMenu = gMenuBarView->getChild<LLMenuItemCallGL>("Set Busy", TRUE);
00736         gAttachSubMenu = gMenuBarView->getChildMenuByName("Attach Object", TRUE);
00737         gDetachSubMenu = gMenuBarView->getChildMenuByName("Detach Object", TRUE);
00738 
00739         // TomY TODO convert these two
00740         LLMenuGL*menu;
00741 
00742         // JC - Maybe we don't want a global landmark menu
00743         /*
00744         menu = new LLMenuGL(LANDMARK_MENU_NAME);
00745         // Defer init_landmark_menu() until inventory observer reports that we actually
00746         // have inventory.  Otherwise findCategoryByUUID() will create an empty
00747         // Landmarks folder in inventory. JC
00748         gMenuBarView->appendMenu( menu );
00749         menu->updateParent(LLMenuGL::sMenuContainer);
00750         gLandmarkMenu = menu;
00751         */
00752 
00753         menu = new LLMenuGL(CLIENT_MENU_NAME);
00754         init_client_menu(menu);
00755         gMenuBarView->appendMenu( menu );
00756         menu->updateParent(LLMenuGL::sMenuContainer);
00757 
00758         menu = new LLMenuGL(SERVER_MENU_NAME);
00759         init_server_menu(menu);
00760         gMenuBarView->appendMenu( menu );
00761         menu->updateParent(LLMenuGL::sMenuContainer);
00762 
00763         gMenuBarView->createJumpKeys();
00764 
00765         // Let land based option enable when parcel changes
00766         gMenuParcelObserver = new LLMenuParcelObserver();
00767 
00768         // Let landmarks menu update when landmarks are added/removed
00769         gLandmarkObserver = new LLLandmarkObserver();
00770 
00771         //
00772         // Debug menu visiblity
00773         //
00774         show_debug_menus();
00775 
00776         gLoginMenuBarView = (LLMenuBarGL*)LLUICtrlFactory::getInstance()->buildMenu("menu_login.xml", gMenuHolder);
00777         LLRect menuBarRect = gLoginMenuBarView->getRect();
00778         gLoginMenuBarView->setRect(LLRect(menuBarRect.mLeft, menuBarRect.mTop, gViewerWindow->getRootView()->getRect().getWidth() - menuBarRect.mLeft,  menuBarRect.mBottom));
00779 
00780         gLoginMenuBarView->setBackgroundColor( color );
00781 
00782         gMenuHolder->addChild(gLoginMenuBarView);
00783         
00784 }
00785 
00786 
00787 
00788 void init_landmark_menu(LLMenuGL* menu)
00789 {
00790         if (!menu) return;
00791 
00792         // clear existing menu, as we might be rebuilding as result of inventory update
00793         clear_landmark_menu(menu);
00794 
00795         menu->append(new LLMenuItemCallGL("Organize Landmarks", 
00796                         &manage_landmarks, NULL));
00797         menu->append(new LLMenuItemCallGL("New Landmark...", 
00798                         &create_new_landmark, NULL));
00799         menu->appendSeparator();
00800         
00801         // now collect all landmarks in inventory and build menu...
00802         LLInventoryModel::cat_array_t* cats;
00803         LLInventoryModel::item_array_t* items;
00804         gInventory.getDirectDescendentsOf(gInventory.findCategoryUUIDForType(LLAssetType::AT_LANDMARK), cats, items);
00805         if(items)
00806         {
00807                 S32 count = items->count();
00808                 for(S32 i = 0; i < count; ++i)
00809                 {
00810                         LLInventoryItem* item = items->get(i);
00811                         LLString landmark_name = item->getName();
00812                         LLUUID* landmark_id_ptr = new LLUUID( item->getUUID() );
00813                         LLMenuItemCallGL* menu_item =
00814                                 new LLMenuItemCallGL(landmark_name, landmark_menu_action, 
00815                                         NULL, NULL,     landmark_id_ptr);
00816                         menu->append(menu_item);
00817                 }
00818         }
00819 }
00820 
00821 void clear_landmark_menu(LLMenuGL* menu)
00822 {
00823         if (!menu) return;
00824 
00825         // We store the UUIDs of the landmark inventory items in the userdata
00826         // field of the menus.  Therefore when we clean up the menu we need to
00827         // delete that data.
00828         const LLView::child_list_t* child_list = menu->getChildList();
00829         LLView::child_list_const_iter_t it = child_list->begin();
00830         for ( ; it != child_list->end(); ++it)
00831         {
00832                 LLView* view = *it;
00833                 LLMenuItemCallGL* menu_item = dynamic_cast<LLMenuItemCallGL*>(view);
00834                 
00835                 if (menu_item && menu_item->getMenuCallback() == landmark_menu_action)
00836                 {
00837                         void* user_data = menu_item->getUserData();
00838                         delete (LLUUID*)user_data;
00839                 }
00840         }
00841 
00842         menu->empty();
00843 }
00844 
00845 void init_client_menu(LLMenuGL* menu)
00846 {
00847         LLMenuGL* sub_menu = NULL;
00848 
00849         //menu->append(new LLMenuItemCallGL("Permissions Control", &show_permissions_control));
00850 
00851 // this is now in the view menu so we don't need it here!
00852         {
00853                 LLMenuGL* sub = new LLMenuGL("Consoles");
00854                 menu->appendMenu(sub);
00855                 sub->append(new LLMenuItemCheckGL("Frame Console", 
00856                                                                                 &toggle_visibility,
00857                                                                                 NULL,
00858                                                                                 &get_visibility,
00859                                                                                 (void*)gDebugView->mFrameStatView,
00860                                                                                 '2', MASK_CONTROL|MASK_SHIFT ) );
00861                 sub->append(new LLMenuItemCheckGL("Texture Console", 
00862                                                                                 &toggle_visibility,
00863                                                                                 NULL,
00864                                                                                 &get_visibility,
00865                                                                                 (void*)gTextureView,
00866                                                                                 '3', MASK_CONTROL|MASK_SHIFT ) );
00867                 LLView* debugview = gDebugView->mDebugConsolep;
00868                 sub->append(new LLMenuItemCheckGL("Debug Console", 
00869                                                                                 &toggle_visibility,
00870                                                                                 NULL,
00871                                                                                 &get_visibility,
00872                                                                                 debugview,
00873                                                                                 '4', MASK_CONTROL|MASK_SHIFT ) );
00874 #if 0 // Unused
00875         {
00876                 LLMenuGL* sub = new LLMenuGL("Audio");
00877                 menu->appendMenu(sub);
00878 
00879                 sub->append(new LLMenuItemCallGL("Global Pos", 
00880                                         &handle_audio_status_1, NULL, NULL ,'5', MASK_CONTROL|MASK_SHIFT) );
00881                 sub->append(new LLMenuItemCallGL("Cone", 
00882                                         &handle_audio_status_2, NULL, NULL ,'6', MASK_CONTROL|MASK_SHIFT) );
00883                 sub->append(new LLMenuItemCallGL("Local Pos", 
00884                                         &handle_audio_status_3, NULL, NULL ,'7', MASK_CONTROL|MASK_SHIFT) );
00885                 sub->append(new LLMenuItemCallGL("Duration", 
00886                                         &handle_audio_status_4, NULL, NULL ,'8', MASK_CONTROL|MASK_SHIFT) );
00887                 sub->createJumpKeys();
00888         }
00889 #endif
00890                 sub->append(new LLMenuItemCheckGL("Fast Timers", 
00891                                                                                 &toggle_visibility,
00892                                                                                 NULL,
00893                                                                                 &get_visibility,
00894                                                                                 (void*)gDebugView->mFastTimerView,
00895                                                                                   '9', MASK_CONTROL|MASK_SHIFT ) );
00896 #if MEM_TRACK_MEM
00897                 sub->append(new LLMenuItemCheckGL("Memory", 
00898                                                                                 &toggle_visibility,
00899                                                                                 NULL,
00900                                                                                 &get_visibility,
00901                                                                                 (void*)gDebugView->mMemoryView,
00902                                                                                   '0', MASK_CONTROL|MASK_SHIFT ) );
00903 #endif
00904                 sub->appendSeparator();
00905                 sub->append(new LLMenuItemCallGL("Region Info to Debug Console", 
00906                         &handle_region_dump_settings, NULL));
00907                 sub->append(new LLMenuItemCallGL("Group Info to Debug Console",
00908                         &handle_dump_group_info, NULL, NULL));
00909                 sub->append(new LLMenuItemCallGL("Capabilities Info to Debug Console",
00910                         &handle_dump_capabilities_info, NULL, NULL));
00911                 sub->createJumpKeys();
00912         }
00913         
00914         // neither of these works particularly well at the moment
00915         /*menu->append(new LLMenuItemCallGL(  "Reload UI XML",  &reload_ui,     
00916                                         NULL, NULL) );*/
00917         /*menu->append(new LLMenuItemCallGL("Reload settings/colors", 
00918                                         &handle_reload_settings, NULL, NULL));*/
00919         menu->append(new LLMenuItemCallGL("Reload personal setting overrides", 
00920                 &reload_personal_settings_overrides, NULL, NULL, KEY_F2, MASK_CONTROL|MASK_SHIFT));
00921 
00922         sub_menu = new LLMenuGL("HUD Info");
00923         {
00924                 sub_menu->append(new LLMenuItemCheckGL("Velocity", 
00925                                                                                                 &toggle_visibility,
00926                                                                                                 NULL,
00927                                                                                                 &get_visibility,
00928                                                                                                 (void*)gVelocityBar));
00929 
00930                 sub_menu->append(new LLMenuItemToggleGL("Camera",       &gDisplayCameraPos ) );
00931                 sub_menu->append(new LLMenuItemToggleGL("Wind",         &gDisplayWindInfo) );
00932                 sub_menu->append(new LLMenuItemToggleGL("FOV",          &gDisplayFOV ) );
00933                 sub_menu->createJumpKeys();
00934         }
00935         menu->appendMenu(sub_menu);
00936 
00937         menu->appendSeparator();
00938 
00939         menu->append(new LLMenuItemCheckGL( "High-res Snapshot",
00940                                                                                 &menu_toggle_control,
00941                                                                                 NULL,
00942                                                                                 &menu_check_control,
00943                                                                                 (void*)"HighResSnapshot"));
00944         
00945         menu->append(new LLMenuItemCheckGL( "Quiet Snapshots to Disk",
00946                                                                                 &menu_toggle_control,
00947                                                                                 NULL,
00948                                                                                 &menu_check_control,
00949                                                                                 (void*)"QuietSnapshotsToDisk"));
00950 
00951         menu->append(new LLMenuItemCheckGL( "Compress Snapshots to Disk",
00952                                                                                 &menu_toggle_control,
00953                                                                                 NULL,
00954                                                                                 &menu_check_control,
00955                                                                                 (void*)"CompressSnapshotsToDisk"));
00956 
00957         menu->append(new LLMenuItemCheckGL("Show Mouselook Crosshairs",
00958                                                                            &menu_toggle_control,
00959                                                                            NULL,
00960                                                                            &menu_check_control,
00961                                                                            (void*)"ShowCrosshairs"));
00962 
00963         menu->append(new LLMenuItemCheckGL("Debug Permissions",
00964                                                                            &menu_toggle_control,
00965                                                                            NULL,
00966                                                                            &menu_check_control,
00967                                                                            (void*)"DebugPermissions"));
00968         
00969 
00970 
00971 #ifdef TOGGLE_HACKED_GODLIKE_VIEWER
00972         if (!LLAppViewer::instance()->isInProductionGrid())
00973         {
00974                 menu->append(new LLMenuItemCheckGL("Hacked Godmode",
00975                                                                                    &handle_toggle_hacked_godmode,
00976                                                                                    NULL,
00977                                                                                    &check_toggle_hacked_godmode,
00978                                                                                    (void*)"HackedGodmode"));
00979         }
00980 #endif
00981 
00982         menu->append(new LLMenuItemCallGL("Clear Group Cache", 
00983                                                                           LLGroupMgr::debugClearAllGroups));
00984         menu->appendSeparator();
00985 
00986         sub_menu = new LLMenuGL("Rendering");
00987         init_debug_rendering_menu(sub_menu);
00988         menu->appendMenu(sub_menu);
00989 
00990         sub_menu = new LLMenuGL("World");
00991         init_debug_world_menu(sub_menu);
00992         menu->appendMenu(sub_menu);
00993 
00994         sub_menu = new LLMenuGL("UI");
00995         init_debug_ui_menu(sub_menu);
00996         menu->appendMenu(sub_menu);
00997 
00998         sub_menu = new LLMenuGL("XUI");
00999         init_debug_xui_menu(sub_menu);
01000         menu->appendMenu(sub_menu);
01001 
01002         sub_menu = new LLMenuGL("Character");
01003         init_debug_avatar_menu(sub_menu);
01004         menu->appendMenu(sub_menu);
01005 
01006 {
01007                 LLMenuGL* sub = NULL;
01008                 sub = new LLMenuGL("Network");
01009 
01010                 sub->append(new LLMenuItemCallGL("Enable Message Log",  
01011                         &handle_viewer_enable_message_log,  NULL));
01012                 sub->append(new LLMenuItemCallGL("Disable Message Log", 
01013                         &handle_viewer_disable_message_log, NULL));
01014 
01015                 sub->appendSeparator();
01016 
01017                 sub->append(new LLMenuItemCheckGL("Velocity Interpolate Objects", 
01018                                                                                   &velocity_interpolate,
01019                                                                                   NULL, 
01020                                                                                   &menu_check_control,
01021                                                                                   (void*)"VelocityInterpolate"));
01022                 sub->append(new LLMenuItemCheckGL("Ping Interpolate Object Positions", 
01023                                                                                   &menu_toggle_control,
01024                                                                                   NULL, 
01025                                                                                   &menu_check_control,
01026                                                                                   (void*)"PingInterpolate"));
01027 
01028                 sub->appendSeparator();
01029 
01030                 sub->append(new LLMenuItemCallGL("Drop a Packet", 
01031                         &drop_packet, NULL, NULL, 
01032                         'L', MASK_ALT | MASK_CONTROL));
01033 
01034                 menu->appendMenu( sub );
01035                 sub->createJumpKeys();
01036         }
01037         {
01038                 LLMenuGL* sub = NULL;
01039                 sub = new LLMenuGL("Recorder");
01040 
01041                 sub->append(new LLMenuItemCheckGL("Full Session Logging", &menu_toggle_control, NULL, &menu_check_control, (void*)"StatsSessionTrackFrameStats"));
01042 
01043                 sub->append(new LLMenuItemCallGL("Start Logging",       &LLFrameStats::startLogging, NULL));
01044                 sub->append(new LLMenuItemCallGL("Stop Logging",        &LLFrameStats::stopLogging, NULL));
01045                 sub->append(new LLMenuItemCallGL("Log 10 Seconds", &LLFrameStats::timedLogging10, NULL));
01046                 sub->append(new LLMenuItemCallGL("Log 30 Seconds", &LLFrameStats::timedLogging30, NULL));
01047                 sub->append(new LLMenuItemCallGL("Log 60 Seconds", &LLFrameStats::timedLogging60, NULL));
01048                 sub->appendSeparator();
01049                 sub->append(new LLMenuItemCallGL("Start Playback", &LLAgentPilot::startPlayback, NULL));
01050                 sub->append(new LLMenuItemCallGL("Stop Playback",       &LLAgentPilot::stopPlayback, NULL));
01051                 sub->append(new LLMenuItemToggleGL("Loop Playback", &LLAgentPilot::sLoop) );
01052                 sub->append(new LLMenuItemCallGL("Start Record",        &LLAgentPilot::startRecord, NULL));
01053                 sub->append(new LLMenuItemCallGL("Stop Record", &LLAgentPilot::saveRecord, NULL));
01054 
01055                 menu->appendMenu( sub );
01056                 sub->createJumpKeys();
01057         }
01058 
01059         menu->appendSeparator();
01060 
01061         menu->append(new LLMenuItemToggleGL("Show Updates", 
01062                 &gShowObjectUpdates,
01063                 'U', MASK_ALT | MASK_SHIFT | MASK_CONTROL));
01064         
01065         menu->appendSeparator(); 
01066         
01067         menu->append(new LLMenuItemCallGL("Compress Images...", 
01068                 &handle_compress_image, NULL, NULL));
01069 
01070         menu->append(new LLMenuItemCheckGL("Limit Select Distance", 
01071                                                                            &menu_toggle_control,
01072                                                                            NULL, 
01073                                                                            &menu_check_control,
01074                                                                            (void*)"LimitSelectDistance"));
01075 
01076         menu->append(new LLMenuItemCheckGL("Disable Camera Constraints", 
01077                                                                            &menu_toggle_control,
01078                                                                            NULL, 
01079                                                                            &menu_check_control,
01080                                                                            (void*)"DisableCameraConstraints"));
01081 
01082         menu->append(new LLMenuItemCheckGL("Mouse Smoothing",
01083                                                                                 &menu_toggle_control,
01084                                                                                 NULL,
01085                                                                                 &menu_check_control,
01086                                                                                 (void*) "MouseSmooth"));
01087         menu->appendSeparator();
01088 
01089         menu->append(new LLMenuItemCheckGL( "Console Window", 
01090                                                                                 &menu_toggle_control,
01091                                                                                 NULL, 
01092                                                                                 &menu_check_control,
01093                                                                                 (void*)"ShowConsoleWindow"));
01094 
01095         if(gSavedSettings.getBOOL("QAMode"))
01096         {
01097                 LLMenuGL* sub = NULL;
01098                 sub = new LLMenuGL("Debugging");
01099 #if LL_WINDOWS
01100         sub->append(new LLMenuItemCallGL("Force Breakpoint", &force_error_breakpoint, NULL, NULL, 'B', MASK_CONTROL | MASK_ALT));
01101 #endif
01102                 sub->append(new LLMenuItemCallGL("Force LLError And Crash", &force_error_llerror));
01103         sub->append(new LLMenuItemCallGL("Force Bad Memory Access", &force_error_bad_memory_access));
01104                 sub->append(new LLMenuItemCallGL("Force Infinite Loop", &force_error_infinite_loop));
01105                 // *NOTE:Mani this isn't handled yet... sub->append(new LLMenuItemCallGL("Force Software Exception", &force_error_unhandled_exception)); 
01106                 sub->createJumpKeys();
01107                 menu->appendMenu(sub);
01108         }
01109 
01110         menu->append(new LLMenuItemCheckGL( "Output Debug Minidump", 
01111                                                                                 &menu_toggle_control,
01112                                                                                 NULL, 
01113                                                                                 &menu_check_control,
01114                                                                                 (void*)"SaveMinidump"));
01115 
01116         // TomY Temporary menu item so we can test this floater
01117         menu->append(new LLMenuItemCheckGL("Clothing...", 
01118                                                                                                 &handle_clothing,
01119                                                                                                 NULL,
01120                                                                                                 NULL,
01121                                                                                                 NULL));
01122 
01123         menu->append(new LLMenuItemCallGL("Debug Settings...", LLFloaterSettingsDebug::show, NULL, NULL));
01124         menu->append(new LLMenuItemCheckGL("View Admin Options", &handle_admin_override_toggle, NULL, &check_admin_override, NULL, 'V', MASK_CONTROL | MASK_ALT));
01125 
01126         menu->append(new LLMenuItemCallGL("Request Admin Status", 
01127                 &handle_god_mode, NULL, NULL, 'G', MASK_ALT | MASK_CONTROL));
01128 
01129         menu->append(new LLMenuItemCallGL("Leave Admin Status", 
01130                 &handle_leave_god_mode, NULL, NULL, 'G', MASK_ALT | MASK_SHIFT | MASK_CONTROL));
01131 
01132         menu->createJumpKeys();
01133 }
01134 
01135 void init_debug_world_menu(LLMenuGL* menu)
01136 {
01137 /* REMOVE mouse move sun from menu options
01138         menu->append(new LLMenuItemCheckGL("Mouse Moves Sun", 
01139                                                                            &menu_toggle_control,
01140                                                                            NULL, 
01141                                                                            &menu_check_control,
01142                                                                            (void*)"MouseSun", 
01143                                                                            'M', MASK_CONTROL|MASK_ALT));
01144 */
01145         menu->append(new LLMenuItemCheckGL("Sim Sun Override", 
01146                                                                            &menu_toggle_control,
01147                                                                            NULL, 
01148                                                                            &menu_check_control,
01149                                                                            (void*)"SkyOverrideSimSunPosition"));
01150         menu->append(new LLMenuItemCallGL("Dump Scripted Camera",
01151                 &handle_dump_followcam, NULL, NULL));
01152         menu->append(new LLMenuItemCheckGL("Fixed Weather", 
01153                                                                            &menu_toggle_control,
01154                                                                            NULL, 
01155                                                                            &menu_check_control,
01156                                                                            (void*)"FixedWeather"));
01157         menu->append(new LLMenuItemCallGL("Dump Region Object Cache",
01158                 &handle_dump_region_object_cache, NULL, NULL));
01159         menu->createJumpKeys();
01160 }
01161 
01162 
01163 void handle_export_menus_to_xml(void*)
01164 {
01165         LLFilePicker& picker = LLFilePicker::instance();
01166         if(!picker.getSaveFile(LLFilePicker::FFSAVE_XML))
01167         {
01168                 llwarns << "No file" << llendl;
01169                 return;
01170         }
01171         const char* filename = picker.getFirstFile();
01172 
01173         llofstream out(filename);
01174         LLXMLNodePtr node = gMenuBarView->getXML();
01175         node->writeToOstream(out);
01176         out.close();
01177 }
01178 
01179 extern BOOL gDebugClicks;
01180 extern BOOL gDebugWindowProc;
01181 extern BOOL gDebugTextEditorTips;
01182 extern BOOL gDebugSelectMgr;
01183 
01184 void init_debug_ui_menu(LLMenuGL* menu)
01185 {
01186         menu->append(new LLMenuItemCallGL("SLURL Test", &handle_slurl_test));
01187         menu->append(new LLMenuItemCallGL("Editable UI", &edit_ui));
01188         menu->append(new LLMenuItemToggleGL("Async Keystrokes", &gHandleKeysAsync));
01189         menu->append(new LLMenuItemCallGL( "Dump SelectMgr", &dump_select_mgr));
01190         menu->append(new LLMenuItemCallGL( "Dump Inventory", &dump_inventory));
01191         menu->append(new LLMenuItemCallGL( "Dump Focus Holder", &handle_dump_focus, NULL, NULL, 'F', MASK_ALT | MASK_CONTROL));
01192         menu->append(new LLMenuItemCallGL( "Print Selected Object Info",        &print_object_info, NULL, NULL, 'P', MASK_CONTROL|MASK_SHIFT ));
01193         menu->append(new LLMenuItemCallGL( "Print Agent Info",                  &print_agent_nvpairs, NULL, NULL, 'P', MASK_SHIFT ));
01194         menu->append(new LLMenuItemCallGL( "Texture Memory Stats",  &output_statistics, NULL, NULL, 'M', MASK_SHIFT | MASK_ALT | MASK_CONTROL));
01195         menu->append(new LLMenuItemCheckGL("Double-Click Auto-Pilot", 
01196                 menu_toggle_control, NULL, menu_check_control, 
01197                 (void*)"DoubleClickAutoPilot"));
01198         menu->appendSeparator();
01199 //      menu->append(new LLMenuItemCallGL( "Print Packets Lost",                        &print_packets_lost, NULL, NULL, 'L', MASK_SHIFT ));
01200         menu->append(new LLMenuItemToggleGL("Debug SelectMgr", &gDebugSelectMgr));
01201         menu->append(new LLMenuItemToggleGL("Debug Clicks", &gDebugClicks));
01202         menu->append(new LLMenuItemToggleGL("Debug Views", &LLView::sDebugRects));
01203         menu->append(new LLMenuItemCheckGL("Show Name Tooltips", toggle_show_xui_names, NULL, check_show_xui_names, NULL));
01204         menu->append(new LLMenuItemToggleGL("Debug Mouse Events", &LLView::sDebugMouseHandling));
01205         menu->append(new LLMenuItemToggleGL("Debug Keys", &LLView::sDebugKeys));
01206         menu->append(new LLMenuItemToggleGL("Debug WindowProc", &gDebugWindowProc));
01207         menu->append(new LLMenuItemToggleGL("Debug Text Editor Tips", &gDebugTextEditorTips));
01208         menu->appendSeparator();
01209         menu->append(new LLMenuItemCheckGL("Show Time", menu_toggle_control, NULL, menu_check_control, (void*)"DebugShowTime"));
01210         menu->append(new LLMenuItemCheckGL("Show Render Info", menu_toggle_control, NULL, menu_check_control, (void*)"DebugShowRenderInfo"));
01211         menu->append(new LLMenuItemCheckGL("Show Color Under Cursor", menu_toggle_control, NULL, menu_check_control, (void*)"DebugShowColor"));
01212         
01213         menu->createJumpKeys();
01214 }
01215 
01216 void init_debug_xui_menu(LLMenuGL* menu)
01217 {
01218         menu->append(new LLMenuItemCallGL("Floater Test...", LLFloaterTest::show));
01219         menu->append(new LLMenuItemCallGL("Export Menus to XML...", handle_export_menus_to_xml));
01220         menu->append(new LLMenuItemCallGL("Edit UI...", LLFloaterEditUI::show));        
01221         menu->append(new LLMenuItemCallGL("Load from XML...", handle_load_from_xml));
01222         menu->append(new LLMenuItemCallGL("Save to XML...", handle_save_to_xml));
01223         menu->append(new LLMenuItemCheckGL("Show XUI Names", toggle_show_xui_names, NULL, check_show_xui_names, NULL));
01224 
01225         //menu->append(new LLMenuItemCallGL("Buy Currency...", handle_buy_currency));
01226         menu->createJumpKeys();
01227 }
01228 
01229 void init_debug_rendering_menu(LLMenuGL* menu)
01230 {
01231         LLMenuGL* sub_menu = NULL;
01232 
01234         //
01235         // Debug menu for types/pools
01236         //
01237         sub_menu = new LLMenuGL("Types");
01238         menu->appendMenu(sub_menu);
01239 
01240         sub_menu->append(new LLMenuItemCheckGL("Simple",
01241                                                                                         &LLPipeline::toggleRenderTypeControl, NULL,
01242                                                                                         &LLPipeline::hasRenderTypeControl,
01243                                                                                         (void*)LLPipeline::RENDER_TYPE_SIMPLE,  '1', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
01244         sub_menu->append(new LLMenuItemCheckGL("Alpha",
01245                                                                                         &LLPipeline::toggleRenderTypeControl, NULL,
01246                                                                                         &LLPipeline::hasRenderTypeControl,
01247                                                                                         (void*)LLPipeline::RENDER_TYPE_ALPHA, '2', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
01248         sub_menu->append(new LLMenuItemCheckGL("Tree",
01249                                                                                         &LLPipeline::toggleRenderTypeControl, NULL,
01250                                                                                         &LLPipeline::hasRenderTypeControl,
01251                                                                                         (void*)LLPipeline::RENDER_TYPE_TREE, '3', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
01252         sub_menu->append(new LLMenuItemCheckGL("Character",
01253                                                                                         &LLPipeline::toggleRenderTypeControl, NULL,
01254                                                                                         &LLPipeline::hasRenderTypeControl,
01255                                                                                         (void*)LLPipeline::RENDER_TYPE_AVATAR, '4', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
01256         sub_menu->append(new LLMenuItemCheckGL("SurfacePatch",
01257                                                                                         &LLPipeline::toggleRenderTypeControl, NULL,
01258                                                                                         &LLPipeline::hasRenderTypeControl,
01259                                                                                         (void*)LLPipeline::RENDER_TYPE_TERRAIN, '5', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
01260         sub_menu->append(new LLMenuItemCheckGL("Sky",
01261                                                                                         &LLPipeline::toggleRenderTypeControl, NULL,
01262                                                                                         &LLPipeline::hasRenderTypeControl,
01263                                                                                         (void*)LLPipeline::RENDER_TYPE_SKY, '6', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
01264         sub_menu->append(new LLMenuItemCheckGL("Water",
01265                                                                                         &LLPipeline::toggleRenderTypeControl, NULL,
01266                                                                                         &LLPipeline::hasRenderTypeControl,
01267                                                                                         (void*)LLPipeline::RENDER_TYPE_WATER, '7', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
01268         sub_menu->append(new LLMenuItemCheckGL("Ground",
01269                                                                                         &LLPipeline::toggleRenderTypeControl, NULL,
01270                                                                                         &LLPipeline::hasRenderTypeControl,
01271                                                                                         (void*)LLPipeline::RENDER_TYPE_GROUND, '8', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
01272         sub_menu->append(new LLMenuItemCheckGL("Volume",
01273                                                                                         &LLPipeline::toggleRenderTypeControl, NULL,
01274                                                                                         &LLPipeline::hasRenderTypeControl,
01275                                                                                         (void*)LLPipeline::RENDER_TYPE_VOLUME, '9', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
01276         sub_menu->append(new LLMenuItemCheckGL("Grass",
01277                                                                                         &LLPipeline::toggleRenderTypeControl, NULL,
01278                                                                                         &LLPipeline::hasRenderTypeControl,
01279                                                                                         (void*)LLPipeline::RENDER_TYPE_GRASS, '0', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
01280         sub_menu->append(new LLMenuItemCheckGL("Clouds",
01281                                                                                         &LLPipeline::toggleRenderTypeControl, NULL,
01282                                                                                         &LLPipeline::hasRenderTypeControl,
01283                                                                                         (void*)LLPipeline::RENDER_TYPE_CLOUDS, '-', MASK_CONTROL|MASK_ALT| MASK_SHIFT));
01284         sub_menu->append(new LLMenuItemCheckGL("Particles",
01285                                                                                         &LLPipeline::toggleRenderTypeControl, NULL,
01286                                                                                         &LLPipeline::hasRenderTypeControl,
01287                                                                                         (void*)LLPipeline::RENDER_TYPE_PARTICLES, '=', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
01288         sub_menu->append(new LLMenuItemCheckGL("Bump",
01289                                                                                         &LLPipeline::toggleRenderTypeControl, NULL,
01290                                                                                         &LLPipeline::hasRenderTypeControl,
01291                                                                                         (void*)LLPipeline::RENDER_TYPE_BUMP, '\\', MASK_CONTROL|MASK_ALT|MASK_SHIFT));
01292         sub_menu->createJumpKeys();
01293         sub_menu = new LLMenuGL("Features");
01294         menu->appendMenu(sub_menu);
01295         sub_menu->append(new LLMenuItemCheckGL("UI",
01296                                                                                         &LLPipeline::toggleRenderDebugFeature, NULL,
01297                                                                                         &LLPipeline::toggleRenderDebugFeatureControl,
01298                                                                                         (void*)LLPipeline::RENDER_DEBUG_FEATURE_UI, KEY_F1, MASK_ALT|MASK_CONTROL));
01299         sub_menu->append(new LLMenuItemCheckGL("Selected",
01300                                                                                         &LLPipeline::toggleRenderDebugFeature, NULL,
01301                                                                                         &LLPipeline::toggleRenderDebugFeatureControl,
01302                                                                                         (void*)LLPipeline::RENDER_DEBUG_FEATURE_SELECTED, KEY_F2, MASK_ALT|MASK_CONTROL));
01303         sub_menu->append(new LLMenuItemCheckGL("Highlighted",
01304                                                                                         &LLPipeline::toggleRenderDebugFeature, NULL,
01305                                                                                         &LLPipeline::toggleRenderDebugFeatureControl,
01306                                                                                         (void*)LLPipeline::RENDER_DEBUG_FEATURE_HIGHLIGHTED, KEY_F3, MASK_ALT|MASK_CONTROL));
01307         sub_menu->append(new LLMenuItemCheckGL("Dynamic Textures",
01308                                                                                         &LLPipeline::toggleRenderDebugFeature, NULL,
01309                                                                                         &LLPipeline::toggleRenderDebugFeatureControl,
01310                                                                                         (void*)LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES, KEY_F4, MASK_ALT|MASK_CONTROL));
01311         sub_menu->append(new LLMenuItemCheckGL( "Foot Shadows", 
01312                                                                                         &LLPipeline::toggleRenderDebugFeature, NULL,
01313                                                                                         &LLPipeline::toggleRenderDebugFeatureControl,
01314                                                                                         (void*)LLPipeline::RENDER_DEBUG_FEATURE_FOOT_SHADOWS, KEY_F5, MASK_ALT|MASK_CONTROL));
01315         sub_menu->append(new LLMenuItemCheckGL("Fog",
01316                                                                                         &LLPipeline::toggleRenderDebugFeature, NULL,
01317                                                                                         &LLPipeline::toggleRenderDebugFeatureControl,
01318                                                                                         (void*)LLPipeline::RENDER_DEBUG_FEATURE_FOG, KEY_F6, MASK_ALT|MASK_CONTROL));
01319         sub_menu->append(new LLMenuItemCheckGL("Palletized Textures",
01320                                                                                         &LLPipeline::toggleRenderDebugFeature, NULL,
01321                                                                                         &LLPipeline::toggleRenderDebugFeatureControl,
01322                                                                                         (void*)LLPipeline::RENDER_DEBUG_FEATURE_PALETTE, KEY_F7, MASK_ALT|MASK_CONTROL));
01323         sub_menu->append(new LLMenuItemCheckGL("Test FRInfo",
01324                                                                                         &LLPipeline::toggleRenderDebugFeature, NULL,
01325                                                                                         &LLPipeline::toggleRenderDebugFeatureControl,
01326                                                                                         (void*)LLPipeline::RENDER_DEBUG_FEATURE_FR_INFO, KEY_F8, MASK_ALT|MASK_CONTROL));
01327         sub_menu->append(new LLMenuItemCheckGL( "Flexible Objects", 
01328                                                                                         &LLPipeline::toggleRenderDebugFeature, NULL,
01329                                                                                         &LLPipeline::toggleRenderDebugFeatureControl,
01330                                                                                         (void*)LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE, KEY_F9, MASK_ALT|MASK_CONTROL));
01331         sub_menu->createJumpKeys();
01332 
01334         //
01335         // Debug menu for info displays
01336         //
01337         sub_menu = new LLMenuGL("Info Displays");
01338         menu->appendMenu(sub_menu);
01339 
01340         sub_menu->append(new LLMenuItemCheckGL("Verify",        &LLPipeline::toggleRenderDebug, NULL,
01341                                                                                                         &LLPipeline::toggleRenderDebugControl,
01342                                                                                                         (void*)LLPipeline::RENDER_DEBUG_VERIFY));
01343         sub_menu->append(new LLMenuItemCheckGL("BBoxes",        &LLPipeline::toggleRenderDebug, NULL,
01344                                                                                                         &LLPipeline::toggleRenderDebugControl,
01345                                                                                                         (void*)LLPipeline::RENDER_DEBUG_BBOXES));
01346         sub_menu->append(new LLMenuItemCheckGL("Points",        &LLPipeline::toggleRenderDebug, NULL,
01347                                                                                                         &LLPipeline::toggleRenderDebugControl,
01348                                                                                                         (void*)LLPipeline::RENDER_DEBUG_POINTS));
01349         sub_menu->append(new LLMenuItemCheckGL("Octree",        &LLPipeline::toggleRenderDebug, NULL,
01350                                                                                                         &LLPipeline::toggleRenderDebugControl,
01351                                                                                                         (void*)LLPipeline::RENDER_DEBUG_OCTREE));
01352         sub_menu->append(new LLMenuItemCheckGL("Occlusion",     &LLPipeline::toggleRenderDebug, NULL,
01353                                                                                                         &LLPipeline::toggleRenderDebugControl,
01354                                                                                                         (void*)LLPipeline::RENDER_DEBUG_OCCLUSION));
01355         sub_menu->append(new LLMenuItemCheckGL("Render Batches", &LLPipeline::toggleRenderDebug, NULL,
01356                                                                                                         &LLPipeline::toggleRenderDebugControl,
01357                                                                                                         (void*)LLPipeline::RENDER_DEBUG_BATCH_SIZE));
01358         sub_menu->append(new LLMenuItemCheckGL("Animated Textures",     &LLPipeline::toggleRenderDebug, NULL,
01359                                                                                                         &LLPipeline::toggleRenderDebugControl,
01360                                                                                                         (void*)LLPipeline::RENDER_DEBUG_TEXTURE_ANIM));
01361         sub_menu->append(new LLMenuItemCheckGL("Texture Priority",      &LLPipeline::toggleRenderDebug, NULL,
01362                                                                                                         &LLPipeline::toggleRenderDebugControl,
01363                                                                                                         (void*)LLPipeline::RENDER_DEBUG_TEXTURE_PRIORITY));
01364         sub_menu->append(new LLMenuItemCheckGL("Avatar Rendering Cost", &LLPipeline::toggleRenderDebug, NULL,
01365                                                                                                         &LLPipeline::toggleRenderDebugControl,
01366                                                                                                         (void*)LLPipeline::RENDER_DEBUG_SHAME));
01367         sub_menu->append(new LLMenuItemCheckGL("Texture Area (sqrt(A))",&LLPipeline::toggleRenderDebug, NULL,
01368                                                                                                         &LLPipeline::toggleRenderDebugControl,
01369                                                                                                         (void*)LLPipeline::RENDER_DEBUG_TEXTURE_AREA));
01370         sub_menu->append(new LLMenuItemCheckGL("Face Area (sqrt(A))",&LLPipeline::toggleRenderDebug, NULL,
01371                                                                                                         &LLPipeline::toggleRenderDebugControl,
01372                                                                                                         (void*)LLPipeline::RENDER_DEBUG_FACE_AREA));
01373         sub_menu->append(new LLMenuItemCheckGL("Pick Render",   &LLPipeline::toggleRenderDebug, NULL,
01374                                                                                                         &LLPipeline::toggleRenderDebugControl,
01375                                                                                                         (void*)LLPipeline::RENDER_DEBUG_PICKING));
01376         sub_menu->append(new LLMenuItemCheckGL("Lights",        &LLPipeline::toggleRenderDebug, NULL,
01377                                                                                                         &LLPipeline::toggleRenderDebugControl,
01378                                                                                                         (void*)LLPipeline::RENDER_DEBUG_LIGHTS));
01379         sub_menu->append(new LLMenuItemCheckGL("Particles",     &LLPipeline::toggleRenderDebug, NULL,
01380                                                                                                         &LLPipeline::toggleRenderDebugControl,
01381                                                                                                         (void*)LLPipeline::RENDER_DEBUG_PARTICLES));
01382         sub_menu->append(new LLMenuItemCheckGL("Composition", &LLPipeline::toggleRenderDebug, NULL,
01383                                                                                                         &LLPipeline::toggleRenderDebugControl,
01384                                                                                                         (void*)LLPipeline::RENDER_DEBUG_COMPOSITION));
01385         sub_menu->append(new LLMenuItemCheckGL("Glow",&LLPipeline::toggleRenderDebug, NULL,
01386                                                                                                         &LLPipeline::toggleRenderDebugControl,
01387                                                                                                         (void*)LLPipeline::RENDER_DEBUG_GLOW));
01388         
01389         sub_menu->append(new LLMenuItemCheckGL("Show Depth Buffer",
01390                                                                                    &menu_toggle_control,
01391                                                                                    NULL,
01392                                                                                    &menu_check_control,
01393                                                                                    (void*)"ShowDepthBuffer"));
01394         sub_menu->append(new LLMenuItemToggleGL("Show Select Buffer", &gDebugSelect));
01395 
01396         sub_menu->append(new LLMenuItemCallGL("Vectorize Perf Test", &run_vectorize_perf_test));
01397 
01398         sub_menu = new LLMenuGL("Render Tests");
01399 
01400         sub_menu->append(new LLMenuItemCheckGL("Camera Offset", 
01401                                                                                   &menu_toggle_control,
01402                                                                                   NULL, 
01403                                                                                   &menu_check_control,
01404                                                                                   (void*)"CameraOffset"));
01405 
01406         sub_menu->append(new LLMenuItemToggleGL("Randomize Framerate", &gRandomizeFramerate));
01407 
01408         sub_menu->append(new LLMenuItemToggleGL("Periodic Slow Frame", &gPeriodicSlowFrame));
01409 
01410         sub_menu->append(new LLMenuItemToggleGL("Frame Test", &LLPipeline::sRenderFrameTest));
01411 
01412         sub_menu->createJumpKeys();
01413 
01414         menu->appendMenu( sub_menu );
01415 
01416         menu->appendSeparator();
01417         menu->append(new LLMenuItemCheckGL("Axes", menu_toggle_control, NULL, menu_check_control, (void*)"ShowAxes"));
01418 //      menu->append(new LLMenuItemCheckGL("Cull Small Objects", toggle_cull_small, NULL, menu_check_control, (void*)"RenderCullBySize"));
01419 
01420         menu->appendSeparator();
01421         menu->append(new LLMenuItemToggleGL("Hide Selected", &gHideSelectedObjects));
01422         menu->appendSeparator();
01423         menu->append(new LLMenuItemCheckGL("Tangent Basis", menu_toggle_control, NULL, menu_check_control, (void*)"ShowTangentBasis"));
01424         menu->append(new LLMenuItemCallGL("Selected Texture Info", handle_selected_texture_info, NULL, NULL, 'T', MASK_CONTROL|MASK_SHIFT|MASK_ALT));
01425         //menu->append(new LLMenuItemCallGL("Dump Image List", handle_dump_image_list, NULL, NULL, 'I', MASK_CONTROL|MASK_SHIFT));
01426         
01427         menu->append(new LLMenuItemToggleGL("Wireframe", &gUseWireframe, 
01428                         'R', MASK_CONTROL|MASK_SHIFT));
01429 
01430         LLMenuItemCheckGL* item;
01431         item = new LLMenuItemCheckGL("Object-Object Occlusion", menu_toggle_control, NULL, menu_check_control, (void*)"UseOcclusion", 'O', MASK_CONTROL|MASK_SHIFT);
01432         item->setEnabled(gGLManager.mHasOcclusionQuery && LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion"));
01433         menu->append(item);
01434 
01435         item = new LLMenuItemCheckGL("Debug GL", menu_toggle_control, NULL, menu_check_control, (void*)"RenderDebugGL");
01436         menu->append(item);
01437         
01438         item = new LLMenuItemCheckGL("Debug Pipeline", menu_toggle_control, NULL, menu_check_control, (void*)"RenderDebugPipeline");
01439         menu->append(item);
01440         
01441         item = new LLMenuItemCheckGL("Fast Alpha", menu_toggle_control, NULL, menu_check_control, (void*)"RenderFastAlpha");
01442         menu->append(item);
01443         
01444         item = new LLMenuItemCheckGL("Animate Textures", menu_toggle_control, NULL, menu_check_control, (void*)"AnimateTextures");
01445         menu->append(item);
01446         
01447         item = new LLMenuItemCheckGL("Disable Textures", menu_toggle_variable, NULL, menu_check_variable, (void*)&LLViewerImage::sDontLoadVolumeTextures);
01448         menu->append(item);
01449         
01450 #ifndef LL_RELEASE_FOR_DOWNLOAD
01451         item = new LLMenuItemCheckGL("HTTP Get Textures", menu_toggle_control, NULL, menu_check_control, (void*)"ImagePipelineUseHTTP");
01452         menu->append(item);
01453 #endif
01454         
01455         item = new LLMenuItemCheckGL("Run Multiple Threads", menu_toggle_control, NULL, menu_check_control, (void*)"RunMultipleThreads");
01456         menu->append(item);
01457 
01458 #ifndef LL_RELEASE_FOR_DOWNLOAD
01459         item = new LLMenuItemCheckGL("Dynamic Reflections", menu_toggle_control, NULL, menu_check_control, (void*)"RenderDynamicReflections");
01460         menu->append(item);
01461 #endif
01462         
01463         item = new LLMenuItemCheckGL("Cheesy Beacon", menu_toggle_control, NULL, menu_check_control, (void*)"CheesyBeacon");
01464         menu->append(item);
01465         
01466         menu->createJumpKeys();
01467 }
01468 
01469 extern BOOL gDebugAvatarRotation;
01470 
01471 void init_debug_avatar_menu(LLMenuGL* menu)
01472 {
01473         LLMenuGL* sub_menu = new LLMenuGL("Grab Baked Texture");
01474         init_debug_baked_texture_menu(sub_menu);
01475         menu->appendMenu(sub_menu);
01476 
01477         sub_menu = new LLMenuGL("Character Tests");
01478         sub_menu->append(new LLMenuItemToggleGL("Go Away/AFK When Idle",
01479                 &gAllowIdleAFK));
01480 
01481         sub_menu->append(new LLMenuItemCallGL("Appearance To XML", 
01482                 &LLVOAvatar::dumpArchetypeXML));
01483 
01484         // HACK for easy testing of avatar geometry
01485         sub_menu->append(new LLMenuItemCallGL( "Toggle Character Geometry", 
01486                 &handle_god_request_avatar_geometry, &enable_god_customer_service, NULL));
01487 
01488         sub_menu->append(new LLMenuItemCallGL("Test Male", 
01489                 handle_test_male));
01490 
01491         sub_menu->append(new LLMenuItemCallGL("Test Female", 
01492                 handle_test_female));
01493 
01494         sub_menu->append(new LLMenuItemCallGL("Toggle PG", handle_toggle_pg));
01495 
01496         sub_menu->append(new LLMenuItemToggleGL("Allow Select Avatar", &gAllowSelectAvatar));
01497         sub_menu->createJumpKeys();
01498 
01499         menu->appendMenu(sub_menu);
01500 
01501         menu->append(new LLMenuItemToggleGL("Tap-Tap-Hold To Run", &gAllowTapTapHoldRun));
01502         menu->append(new LLMenuItemCallGL("Force Params to Default", &LLAgent::clearVisualParams, NULL));
01503         menu->append(new LLMenuItemCallGL("Reload Vertex Shader", &reload_vertex_shader, NULL));
01504         menu->append(new LLMenuItemToggleGL("Animation Info", &LLVOAvatar::sShowAnimationDebug));
01505         menu->append(new LLMenuItemCallGL("Slow Motion Animations", &slow_mo_animations, NULL));
01506         menu->append(new LLMenuItemToggleGL("Show Look At", &LLHUDEffectLookAt::sDebugLookAt));
01507         menu->append(new LLMenuItemToggleGL("Show Point At", &LLHUDEffectPointAt::sDebugPointAt));
01508         menu->append(new LLMenuItemToggleGL("Debug Joint Updates", &LLVOAvatar::sJointDebug));
01509         menu->append(new LLMenuItemToggleGL("Disable LOD", &LLViewerJoint::sDisableLOD));
01510         menu->append(new LLMenuItemToggleGL("Debug Character Vis", &LLVOAvatar::sDebugInvisible));
01511         //menu->append(new LLMenuItemToggleGL("Show Attachment Points", &LLVOAvatar::sShowAttachmentPoints));
01512         //diabling collision plane due to DEV-14477 -brad
01513         //menu->append(new LLMenuItemToggleGL("Show Collision Plane", &LLVOAvatar::sShowFootPlane));
01514         menu->append(new LLMenuItemToggleGL("Show Collision Skeleton", &LLVOAvatar::sShowCollisionVolumes));
01515         menu->append(new LLMenuItemToggleGL( "Display Agent Target", &LLAgent::sDebugDisplayTarget));
01516         menu->append(new LLMenuItemToggleGL( "Debug Rotation", &gDebugAvatarRotation));
01517         menu->append(new LLMenuItemCallGL("Dump Attachments", handle_dump_attachments));
01518         menu->append(new LLMenuItemCallGL("Rebake Textures", handle_rebake_textures, NULL, NULL, 'R', MASK_ALT | MASK_CONTROL ));
01519 #ifndef LL_RELEASE_FOR_DOWNLOAD
01520         menu->append(new LLMenuItemCallGL("Debug Avatar Textures", handle_debug_avatar_textures, NULL, NULL, 'A', MASK_SHIFT|MASK_CONTROL|MASK_ALT));
01521         menu->append(new LLMenuItemCallGL("Dump Local Textures", handle_dump_avatar_local_textures, NULL, NULL, 'M', MASK_SHIFT|MASK_ALT ));    
01522 #endif
01523         menu->createJumpKeys();
01524 }
01525 
01526 void init_debug_baked_texture_menu(LLMenuGL* menu)
01527 {
01528         menu->append(new LLMenuItemCallGL("Iris", handle_grab_texture, enable_grab_texture, (void*) LLVOAvatar::TEX_EYES_BAKED));
01529         menu->append(new LLMenuItemCallGL("Head", handle_grab_texture, enable_grab_texture, (void*) LLVOAvatar::TEX_HEAD_BAKED));
01530         menu->append(new LLMenuItemCallGL("Upper Body", handle_grab_texture, enable_grab_texture, (void*) LLVOAvatar::TEX_UPPER_BAKED));
01531         menu->append(new LLMenuItemCallGL("Lower Body", handle_grab_texture, enable_grab_texture, (void*) LLVOAvatar::TEX_LOWER_BAKED));
01532         menu->append(new LLMenuItemCallGL("Skirt", handle_grab_texture, enable_grab_texture, (void*) LLVOAvatar::TEX_SKIRT_BAKED));
01533         menu->createJumpKeys();
01534 }
01535 
01536 void init_server_menu(LLMenuGL* menu)
01537 {
01538         /*
01539         {
01540                 // These messages are now trusted. We can write scripts to do
01541                 // this, and the message is unchecked for source.
01542                 LLMenuGL* sub_menu = NULL;
01543                 sub_menu = new LLMenuGL("Sim Logging");
01544 
01545                 sub_menu->append(new LLMenuItemCallGL("Turn off llinfos Log", 
01546                         &handle_reduce_llinfo_log, &enable_god_customer_service));
01547 
01548                 sub_menu->append(new LLMenuItemCallGL("Normal Logging", 
01549                         &handle_normal_llinfo_log, &enable_god_customer_service));
01550 
01551                 sub_menu->appendSeparator();
01552                 sub_menu->append(new LLMenuItemCallGL("Enable Message Log",  
01553                         &handle_sim_enable_message_log,  &enable_god_customer_service));
01554                 sub_menu->append(new LLMenuItemCallGL("Disable Message Log", 
01555                         &handle_sim_disable_message_log, &enable_god_customer_service));
01556 
01557                 sub_menu->appendSeparator();
01558 
01559                 sub_menu->append(new LLMenuItemCallGL("Fetch Message Log",      
01560                         &handle_sim_fetch_message_log,  &enable_god_customer_service));
01561 
01562                 sub_menu->append(new LLMenuItemCallGL("Fetch Log",                      
01563                         &handle_sim_fetch_log, &enable_god_customer_service));
01564 
01565                 menu->appendMenu( sub_menu );
01566         }
01567         */
01568 
01569         {
01570                 LLMenuGL* sub = new LLMenuGL("Object");
01571                 menu->appendMenu(sub);
01572 
01573                 sub->append(new LLMenuItemCallGL( "Take Copy",
01574                                                                                   &force_take_copy, &enable_god_customer_service, NULL,
01575                                                                                   'O', MASK_SHIFT | MASK_ALT | MASK_CONTROL));
01576 #ifdef _CORY_TESTING
01577                 sub->append(new LLMenuItemCallGL( "Export Copy",
01578                                                                                    &force_export_copy, NULL, NULL));
01579                 sub->append(new LLMenuItemCallGL( "Import Geometry",
01580                                                                                    &force_import_geometry, NULL, NULL));
01581 #endif
01582                 //sub->append(new LLMenuItemCallGL( "Force Public", 
01583                 //                      &handle_object_owner_none, NULL, NULL));
01584                 //sub->append(new LLMenuItemCallGL( "Force Ownership/Permissive", 
01585                 //                      &handle_object_owner_self_and_permissive, NULL, NULL, 'K', MASK_SHIFT | MASK_ALT | MASK_CONTROL));
01586                 sub->append(new LLMenuItemCallGL( "Force Owner To Me", 
01587                                         &handle_object_owner_self, &enable_god_customer_service));
01588                 sub->append(new LLMenuItemCallGL( "Force Owner Permissive", 
01589                                         &handle_object_owner_permissive, &enable_god_customer_service));
01590                 //sub->append(new LLMenuItemCallGL( "Force Totally Permissive", 
01591                 //                      &handle_object_permissive));
01592                 sub->append(new LLMenuItemCallGL( "Delete", 
01593                                         &handle_force_delete, &enable_god_customer_service, NULL, KEY_DELETE, MASK_SHIFT | MASK_ALT | MASK_CONTROL));
01594                 sub->append(new LLMenuItemCallGL( "Lock", 
01595                                         &handle_object_lock, &enable_god_customer_service, NULL, 'L', MASK_SHIFT | MASK_ALT | MASK_CONTROL));
01596                 sub->append(new LLMenuItemCallGL( "Get Asset IDs", 
01597                                         &handle_object_asset_ids, &enable_god_customer_service, NULL, 'I', MASK_SHIFT | MASK_ALT | MASK_CONTROL));
01598                 sub->createJumpKeys();
01599         }
01600         {
01601                 LLMenuGL* sub = new LLMenuGL("Parcel");
01602                 menu->appendMenu(sub);
01603 
01604                 sub->append(new LLMenuItemCallGL("Owner To Me",
01605                                                                                  &handle_force_parcel_owner_to_me,
01606                                                                                  &enable_god_customer_service, NULL));
01607                 sub->append(new LLMenuItemCallGL("Set to Linden Content",
01608                                                                                  &handle_force_parcel_to_content,
01609                                                                                  &enable_god_customer_service, NULL,
01610                                                                                  'C', MASK_SHIFT | MASK_ALT | MASK_CONTROL));
01611                 sub->appendSeparator();
01612                 sub->append(new LLMenuItemCallGL("Claim Public Land",
01613                                                                                  &handle_claim_public_land, &enable_god_customer_service));
01614 
01615                 sub->createJumpKeys();
01616         }
01617         {
01618                 LLMenuGL* sub = new LLMenuGL("Region");
01619                 menu->appendMenu(sub);
01620                 sub->append(new LLMenuItemCallGL("Dump Temp Asset Data",
01621                         &handle_region_dump_temp_asset_data,
01622                         &enable_god_customer_service, NULL));
01623                 sub->createJumpKeys();
01624         }       
01625         menu->append(new LLMenuItemCallGL( "God Tools...", 
01626                 &LLFloaterGodTools::show, &enable_god_basic, NULL));
01627 
01628         menu->appendSeparator();
01629 
01630         menu->append(new LLMenuItemCallGL("Save Region State", 
01631                 &LLPanelRegionTools::onSaveState, &enable_god_customer_service, NULL));
01632 
01633 //      menu->append(new LLMenuItemCallGL("Force Join Group", handle_force_join_group));
01634 //
01635 //      menu->appendSeparator();
01636 //
01637 //      menu->append(new LLMenuItemCallGL( "OverlayTitle",
01638 //              &handle_show_overlay_title, &enable_god_customer_service, NULL));
01639         menu->createJumpKeys();
01640 }
01641 
01642 static std::vector<LLPointer<view_listener_t> > sMenus;
01643 
01644 //-----------------------------------------------------------------------------
01645 // cleanup_menus()
01646 //-----------------------------------------------------------------------------
01647 void cleanup_menus()
01648 {
01649         clear_landmark_menu(gLandmarkMenu);
01650 
01651         delete gMenuParcelObserver;
01652         gMenuParcelObserver = NULL;
01653 
01654         delete gLandmarkObserver;
01655         gLandmarkObserver = NULL;
01656 
01657         delete gPieSelf;
01658         gPieSelf = NULL;
01659 
01660         delete gPieAvatar;
01661         gPieAvatar = NULL;
01662 
01663         delete gPieObject;
01664         gPieObject = NULL;
01665 
01666         delete gPieAttachment;
01667         gPieAttachment = NULL;
01668 
01669         delete gPieLand;
01670         gPieLand = NULL;
01671 
01672         delete gMenuBarView;
01673         gMenuBarView = NULL;
01674 
01675         delete gPopupMenuView;
01676         gPopupMenuView = NULL;
01677 
01678         delete gMenuHolder;
01679         gMenuHolder = NULL;
01680 
01681         sMenus.clear();
01682 }
01683 
01684 //-----------------------------------------------------------------------------
01685 // Object pie menu
01686 //-----------------------------------------------------------------------------
01687 
01688 class LLObjectReportAbuse : public view_listener_t
01689 {
01690         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01691         {
01692                 LLFloaterReporter::showFromObject(gLastHitObjectID);
01693                 return true;
01694         }
01695 };
01696 
01697 // Enabled it you clicked an object
01698 class LLObjectEnableReportAbuse : public view_listener_t
01699 {
01700         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01701         {
01702                 bool new_value = !gLastHitObjectID.isNull();
01703                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
01704                 return true;
01705         }
01706 };
01707 
01708 class LLObjectTouch : public view_listener_t
01709 {
01710         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01711         {
01712                 LLViewerObject* object = gObjectList.findObject(gLastHitObjectID);
01713                 if (!object) return true;
01714 
01715                 LLMessageSystem *msg = gMessageSystem;
01716 
01717                 msg->newMessageFast(_PREHASH_ObjectGrab);
01718                 msg->nextBlockFast( _PREHASH_AgentData);
01719                 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
01720                 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
01721                 msg->nextBlockFast( _PREHASH_ObjectData);
01722                 msg->addU32Fast(    _PREHASH_LocalID, object->mLocalID);
01723                 msg->addVector3Fast(_PREHASH_GrabOffset, LLVector3::zero );
01724                 msg->sendMessage( object->getRegion()->getHost());
01725 
01726                 // *NOTE: Hope the packets arrive safely and in order or else
01727                 // there will be some problems.
01728                 // *TODO: Just fix this bad assumption.
01729                 msg->newMessageFast(_PREHASH_ObjectDeGrab);
01730                 msg->nextBlockFast(_PREHASH_AgentData);
01731                 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
01732                 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
01733                 msg->nextBlockFast(_PREHASH_ObjectData);
01734                 msg->addU32Fast(_PREHASH_LocalID, object->mLocalID);
01735                 msg->sendMessage(object->getRegion()->getHost());
01736 
01737                 return true;
01738         }
01739 };
01740 
01741 
01742 // One object must have touch sensor
01743 class LLObjectEnableTouch : public view_listener_t
01744 {
01745         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01746         {
01747                 LLViewerObject* obj = gObjectList.findObject(gLastHitObjectID);
01748                 bool new_value = obj && obj->flagHandleTouch();
01749                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
01750 
01751                 // Update label based on the node touch name if available.
01752                 LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
01753                 if (node && node->mValid && !node->mTouchName.empty())
01754                 {
01755                         gMenuHolder->childSetText("Object Touch", node->mTouchName);
01756                 }
01757                 else
01758                 {
01759                         gMenuHolder->childSetText("Object Touch", userdata["data"].asString());
01760                 }
01761 
01762                 return true;
01763         }
01764 };
01765 
01766 void label_touch(LLString& label, void*)
01767 {
01768         LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
01769         if (node && node->mValid && !node->mTouchName.empty())
01770         {
01771                 label.assign(node->mTouchName);
01772         }
01773         else
01774         {
01775                 label.assign("Touch");
01776         }
01777 }
01778 
01779 bool handle_object_open()
01780 {
01781         LLViewerObject* obj = gObjectList.findObject(gLastHitObjectID);
01782         if(!obj) return true;
01783 
01784         LLFloaterOpenObject::show();
01785         return true;
01786 }
01787 
01788 class LLObjectOpen : public view_listener_t
01789 {
01790         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01791         {
01792                 return handle_object_open();
01793         }
01794 };
01795 
01796 class LLObjectEnableOpen : public view_listener_t
01797 {
01798         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01799         {
01800                 // Look for contents in root object, which is all the LLFloaterOpenObject
01801                 // understands.
01802                 LLViewerObject* obj = gObjectList.findObject(gLastHitObjectID);
01803                 bool new_value = (obj != NULL);
01804                 if (new_value)
01805                 {
01806                         LLViewerObject* root = obj->getRootEdit();
01807                         if (!root) new_value = false;
01808                         else new_value = root->allowOpen();
01809                 }
01810                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
01811                 return true;
01812         }
01813 };
01814 
01815 
01816 class LLViewCheckBuildMode : public view_listener_t
01817 {
01818         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01819         {
01820                 bool new_value = LLToolMgr::getInstance()->inEdit();
01821                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
01822                 return true;
01823         }
01824 };
01825 
01826 bool toggle_build_mode()
01827 {
01828         if (LLToolMgr::getInstance()->inEdit())
01829         {
01830                 // just reset the view, will pull us out of edit mode
01831                 handle_reset_view();
01832 
01833                 // avoid spurious avatar movements pulling out of edit mode
01834                 LLViewerJoystick::getInstance()->moveAvatar(true);
01835         }
01836         else
01837         {
01838                 if (LLViewerJoystick::getInstance()->getOverrideCamera())
01839                 {
01840                         handle_toggle_flycam();
01841                 }
01842                         
01843                 if (gAgent.getFocusOnAvatar() && gSavedSettings.getBOOL("EditCameraMovement") )
01844                 {
01845                         // zoom in if we're looking at the avatar
01846                         gAgent.setFocusOnAvatar(FALSE, ANIMATE);
01847                         gAgent.setFocusGlobal(gAgent.getPositionGlobal() + 2.0 * LLVector3d(gAgent.getAtAxis()));
01848                         gAgent.cameraZoomIn(0.666f);
01849                         gAgent.cameraOrbitOver( 30.f * DEG_TO_RAD );
01850                 }
01851 
01852                 LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
01853                 LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolCompCreate::getInstance() );
01854 
01855                 // Could be first use
01856                 LLFirstUse::useBuild();
01857         }
01858         return true;
01859 }
01860 
01861 class LLViewBuildMode : public view_listener_t
01862 {
01863         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01864         {
01865                 return toggle_build_mode();
01866         }
01867 };
01868 
01869 
01870 class LLViewJoystickFlycam : public view_listener_t
01871 {
01872         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01873         {
01874                 handle_toggle_flycam();
01875                 return true;
01876         }
01877 };
01878 
01879 class LLViewCheckJoystickFlycam : public view_listener_t
01880 {
01881         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01882         {
01883                 bool new_val = LLViewerJoystick::getInstance()->getOverrideCamera();
01884                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_val);
01885                 return true;
01886         }
01887 };
01888 
01889 void handle_toggle_flycam()
01890 {
01891         LLViewerJoystick::getInstance()->toggleFlycam();
01892 }
01893 
01894 class LLObjectBuild : public view_listener_t
01895 {
01896         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01897         {
01898                 if (gAgent.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit() && gSavedSettings.getBOOL("EditCameraMovement") )
01899                 {
01900                         // zoom in if we're looking at the avatar
01901                         gAgent.setFocusOnAvatar(FALSE, ANIMATE);
01902                         gAgent.setFocusGlobal(gLastHitPosGlobal + gLastHitObjectOffset, gLastHitObjectID);
01903                         gAgent.cameraZoomIn(0.666f);
01904                         gAgent.cameraOrbitOver( 30.f * DEG_TO_RAD );
01905                         gViewerWindow->moveCursorToCenter();
01906                 }
01907                 else if ( gSavedSettings.getBOOL("EditCameraMovement") )
01908                 {
01909                         gAgent.setFocusGlobal(gLastHitPosGlobal + gLastHitObjectOffset, gLastHitObjectID);
01910                         gViewerWindow->moveCursorToCenter();
01911                 }
01912 
01913                 LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
01914                 LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolCompCreate::getInstance() );
01915 
01916                 // Could be first use
01917                 LLFirstUse::useBuild();
01918                 return true;
01919         }
01920 };
01921 
01922 class LLObjectEdit : public view_listener_t
01923 {
01924         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01925         {
01926                 LLViewerParcelMgr::getInstance()->deselectLand();
01927 
01928                 if (gAgent.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit())
01929                 {
01930                         LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
01931 
01932                         if (selection->getSelectType() == SELECT_TYPE_HUD || !gSavedSettings.getBOOL("EditCameraMovement"))
01933                         {
01934                                 // always freeze camera in space, even if camera doesn't move
01935                                 // so, for example, follow cam scripts can't affect you when in build mode
01936                                 gAgent.setFocusGlobal(gAgent.calcFocusPositionTargetGlobal(), LLUUID::null);
01937                                 gAgent.setFocusOnAvatar(FALSE, ANIMATE);
01938                         }
01939                         else
01940                         {
01941                                 gAgent.setFocusOnAvatar(FALSE, ANIMATE);
01942                                 // zoom in on object center instead of where we clicked, as we need to see the manipulator handles
01943                                 gAgent.setFocusGlobal(gLastHitPosGlobal /*+ gLastHitObjectOffset*/, gLastHitObjectID);
01944                                 gAgent.cameraZoomIn(0.666f);
01945                                 gAgent.cameraOrbitOver( 30.f * DEG_TO_RAD );
01946                                 gViewerWindow->moveCursorToCenter();
01947                         }
01948                 }
01949 
01950                 gFloaterTools->open();          /* Flawfinder: ignore */
01951         
01952                 LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
01953                 gFloaterTools->setEditTool( LLToolCompTranslate::getInstance() );
01954 
01955                 LLViewerJoystick::getInstance()->moveObjects(true);
01956                 LLViewerJoystick::getInstance()->setNeedsReset(true);
01957 
01958                 // Could be first use
01959                 LLFirstUse::useBuild();
01960                 return true;
01961         }
01962 };
01963 
01964 class LLObjectInspect : public view_listener_t
01965 {
01966         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01967         {
01968                 LLFloaterInspect::show();
01969                 return true;
01970         }
01971 };
01972 
01973 
01974 //---------------------------------------------------------------------------
01975 // Land pie menu
01976 //---------------------------------------------------------------------------
01977 class LLLandBuild : public view_listener_t
01978 {
01979         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
01980         {
01981                 LLViewerParcelMgr::getInstance()->deselectLand();
01982 
01983                 if (gAgent.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit() && gSavedSettings.getBOOL("EditCameraMovement") )
01984                 {
01985                         // zoom in if we're looking at the avatar
01986                         gAgent.setFocusOnAvatar(FALSE, ANIMATE);
01987                         gAgent.setFocusGlobal(gLastHitPosGlobal + gLastHitObjectOffset, gLastHitObjectID);
01988                         gAgent.cameraZoomIn(0.666f);
01989                         gAgent.cameraOrbitOver( 30.f * DEG_TO_RAD );
01990                         gViewerWindow->moveCursorToCenter();
01991                 }
01992                 else if ( gSavedSettings.getBOOL("EditCameraMovement")  )
01993                 {
01994                         // otherwise just move focus
01995                         gAgent.setFocusGlobal(gLastHitPosGlobal + gLastHitObjectOffset, gLastHitObjectID);
01996                         gViewerWindow->moveCursorToCenter();
01997                 }
01998 
01999 
02000                 LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
02001                 LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolCompCreate::getInstance() );
02002 
02003                 // Could be first use
02004                 LLFirstUse::useBuild();
02005                 return true;
02006         }
02007 };
02008 
02009 class LLLandBuyPass : public view_listener_t
02010 {
02011         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02012         {
02013                 LLPanelLandGeneral::onClickBuyPass((void *)FALSE);
02014                 return true;
02015         }
02016 };
02017 
02018 class LLLandEnableBuyPass : public view_listener_t
02019 {
02020         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02021         {
02022                 bool new_value = LLPanelLandGeneral::enableBuyPass(NULL);
02023                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
02024                 return true;
02025         }
02026 };
02027 
02028 // BUG: Should really check if CLICK POINT is in a parcel where you can build.
02029 BOOL enable_land_build(void*)
02030 {
02031         if (gAgent.isGodlike()) return TRUE;
02032         if (gAgent.inPrelude()) return FALSE;
02033 
02034         BOOL can_build = FALSE;
02035         LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
02036         if (agent_parcel)
02037         {
02038                 can_build = agent_parcel->getAllowModify();
02039         }
02040         return can_build;
02041 }
02042 
02043 // BUG: Should really check if OBJECT is in a parcel where you can build.
02044 BOOL enable_object_build(void*)
02045 {
02046         if (gAgent.isGodlike()) return TRUE;
02047         if (gAgent.inPrelude()) return FALSE;
02048 
02049         BOOL can_build = FALSE;
02050         LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
02051         if (agent_parcel)
02052         {
02053                 can_build = agent_parcel->getAllowModify();
02054         }
02055         return can_build;
02056 }
02057 
02058 class LLEnableEdit : public view_listener_t
02059 {
02060         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02061         {
02062                 bool new_value = gAgent.isGodlike() || !gAgent.inPrelude();
02063                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
02064                 return true;
02065         }
02066 };
02067 
02068 class LLSelfRemoveAllAttachments : public view_listener_t
02069 {
02070         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02071         {
02072                 LLAgent::userRemoveAllAttachments(NULL);
02073                 return true;
02074         }
02075 };
02076 
02077 class LLSelfEnableRemoveAllAttachments : public view_listener_t
02078 {
02079         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02080         {
02081                 bool new_value = false;
02082                 if (gAgent.getAvatarObject())
02083                 {
02084                         LLVOAvatar* avatarp = gAgent.getAvatarObject();
02085                         for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); 
02086                                  iter != avatarp->mAttachmentPoints.end(); )
02087                         {
02088                                 LLVOAvatar::attachment_map_t::iterator curiter = iter++;
02089                                 LLViewerJointAttachment* attachment = curiter->second;
02090                                 if (attachment->getObject())
02091                                 {
02092                                         new_value = true;
02093                                         break;
02094                                 }
02095                         }
02096                 }
02097                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
02098                 return true;
02099         }
02100 };
02101 
02102 BOOL enable_has_attachments(void*)
02103 {
02104 
02105         return FALSE;
02106 }
02107 
02108 //---------------------------------------------------------------------------
02109 // Avatar pie menu
02110 //---------------------------------------------------------------------------
02111 void handle_follow(void *userdata)
02112 {
02113         // follow a given avatar, ID in gLastHitObjectID
02114         gAgent.startFollowPilot(gLastHitObjectID);
02115 }
02116 
02117 class LLObjectEnableMute : public view_listener_t
02118 {
02119         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02120         {
02121                 LLViewerObject* object = gViewerWindow->lastObjectHit();
02122                 bool new_value = (object != NULL);
02123                 if (new_value)
02124                 {
02125                         LLVOAvatar* avatar = find_avatar_from_object(object); 
02126                         if (avatar)
02127                         {
02128                                 // It's an avatar
02129                                 LLNameValue *lastname = avatar->getNVPair("LastName");
02130                                 BOOL is_linden = lastname && !LLString::compareStrings(lastname->getString(), "Linden");
02131                                 BOOL is_self = avatar->isSelf();
02132                                 new_value = !is_linden && !is_self;
02133                         }
02134                 }
02135                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
02136                 return true;
02137         }
02138 };
02139 
02140 class LLObjectMute : public view_listener_t
02141 {
02142         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02143         {
02144                 LLViewerObject* object = gViewerWindow->lastObjectHit();
02145                 if (!object) return true;
02146                 
02147                 LLUUID id;
02148                 LLString name;
02149                 LLMute::EType type;
02150                 LLVOAvatar* avatar = find_avatar_from_object(object); 
02151                 if (avatar)
02152                 {
02153                         id = avatar->getID();
02154 
02155                         LLNameValue *firstname = avatar->getNVPair("FirstName");
02156                         LLNameValue *lastname = avatar->getNVPair("LastName");
02157                         if (firstname && lastname)
02158                         {
02159                                 name = firstname->getString();
02160                                 name += " ";
02161                                 name += lastname->getString();
02162                         }
02163                         
02164                         type = LLMute::AGENT;
02165                 }
02166                 else
02167                 {
02168                         // it's an object
02169                         id = object->getID();
02170 
02171                         LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
02172                         if (node)
02173                         {
02174                                 name = node->mName;
02175                         }
02176                         
02177                         type = LLMute::OBJECT;
02178                 }
02179                 
02180                 LLMute mute(id, name, type);
02181                 if (LLMuteList::getInstance()->isMuted(mute.mID, mute.mName))
02182                 {
02183                         LLMuteList::getInstance()->remove(mute);
02184                 }
02185                 else
02186                 {
02187                         LLMuteList::getInstance()->add(mute);
02188                         LLFloaterMute::showInstance();
02189                 }
02190                 
02191                 return true;
02192         }
02193 };
02194 
02195 bool handle_go_to()
02196 {
02197         // JAMESDEBUG try simulator autopilot
02198         std::vector<std::string> strings;
02199         std::string val;
02200         val = llformat("%g", gLastHitPosGlobal.mdV[VX]);
02201         strings.push_back(val);
02202         val = llformat("%g", gLastHitPosGlobal.mdV[VY]);
02203         strings.push_back(val);
02204         val = llformat("%g", gLastHitPosGlobal.mdV[VZ]);
02205         strings.push_back(val);
02206         send_generic_message("autopilot", strings);
02207 
02208         LLViewerParcelMgr::getInstance()->deselectLand();
02209 
02210         if (gAgent.getAvatarObject() && !gSavedSettings.getBOOL("AutoPilotLocksCamera"))
02211         {
02212                 gAgent.setFocusGlobal(gAgent.getFocusTargetGlobal(), gAgent.getAvatarObject()->getID());
02213         }
02214         else 
02215         {
02216                 // Snap camera back to behind avatar
02217                 gAgent.setFocusOnAvatar(TRUE, ANIMATE);
02218         }
02219 
02220         // Could be first use
02221         LLFirstUse::useGoTo();
02222         return true;
02223 }
02224 
02225 class LLGoToObject : public view_listener_t
02226 {
02227         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02228         {
02229                 return handle_go_to();
02230         }
02231 };
02232 
02233 //---------------------------------------------------------------------------
02234 // Parcel freeze, eject, etc.
02235 //---------------------------------------------------------------------------
02236 void callback_freeze(S32 option, void* data)
02237 {
02238         LLUUID* avatar_id = (LLUUID*) data;
02239 
02240         if (0 == option || 1 == option)
02241         {
02242                 U32 flags = 0x0;
02243                 if (1 == option)
02244                 {
02245                         // unfreeze
02246                         flags |= 0x1;
02247                 }
02248 
02249                 LLMessageSystem* msg = gMessageSystem;
02250                 LLViewerObject* avatar = gObjectList.findObject(*avatar_id);
02251 
02252                 if (avatar)
02253                 {
02254                         msg->newMessage("FreezeUser");
02255                         msg->nextBlock("AgentData");
02256                         msg->addUUID("AgentID", gAgent.getID());
02257                         msg->addUUID("SessionID", gAgent.getSessionID());
02258                         msg->nextBlock("Data");
02259                         msg->addUUID("TargetID", *avatar_id );
02260                         msg->addU32("Flags", flags );
02261                         msg->sendReliable( avatar->getRegion()->getHost() );
02262                 }
02263         }
02264 
02265         delete avatar_id;
02266         avatar_id = NULL;
02267 }
02268 
02269 class LLAvatarFreeze : public view_listener_t
02270 {
02271         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02272         {
02273                 LLVOAvatar* avatar = find_avatar_from_object( gViewerWindow->lastObjectHit() );
02274                 if( avatar )
02275                 {
02276                         LLUUID* avatar_id = new LLUUID( avatar->getID() );
02277                         LLString fullname = avatar->getFullname();
02278 
02279                         if (!fullname.empty())
02280                         {
02281                                 LLString::format_map_t args;
02282                                 args["[AVATAR_NAME]"] = fullname;
02283                                 gViewerWindow->alertXml("FreezeAvatarFullname",
02284                                                         args,
02285                                                         callback_freeze,
02286                                                         (void*)avatar_id);
02287                         }
02288                         else
02289                         {
02290                                 gViewerWindow->alertXml("FreezeAvatar",
02291                                                         callback_freeze,
02292                                                         (void*)avatar_id);
02293                         }
02294                 }
02295                 return true;
02296         }
02297 };
02298 
02299 class LLAvatarVisibleDebug : public view_listener_t
02300 {
02301         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02302         {
02303                 bool new_value = gAgent.isGodlike();
02304                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
02305                 return true;
02306         }
02307 };
02308 
02309 class LLAvatarEnableDebug : public view_listener_t
02310 {
02311         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02312         {
02313                 bool new_value = gAgent.isGodlike();
02314                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
02315                 return true;
02316         }
02317 };
02318 
02319 class LLAvatarDebug : public view_listener_t
02320 {
02321         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02322         {
02323                 LLVOAvatar* avatar = find_avatar_from_object( gViewerWindow->lastObjectHit() );
02324                 if( avatar )
02325                 {
02326                         avatar->dumpLocalTextures();
02327                         llinfos << "Dumping temporary asset data to simulator logs for avatar " << avatar->getID() << llendl;
02328                         std::vector<std::string> strings;
02329                         strings.push_back(avatar->getID().asString());
02330                         LLUUID invoice;
02331                         send_generic_message("dumptempassetdata", strings, invoice);
02332                         LLFloaterAvatarTextures::show( avatar->getID() );
02333                 }
02334                 return true;
02335         }
02336 };
02337 
02338 void callback_eject(S32 option, void* data)
02339 {
02340         LLUUID* avatar_id = (LLUUID*) data;
02341 
02342         if (0 == option || 1 == option)
02343         {
02344                 LLMessageSystem* msg = gMessageSystem;
02345                 LLViewerObject* avatar = gObjectList.findObject(*avatar_id);
02346 
02347                 if (avatar)
02348                 {
02349                         U32 flags = 0x0;
02350                         if (1 == option)
02351                         {
02352                                 // eject and add to ban list
02353                                 flags |= 0x1;
02354                         }
02355 
02356                         msg->newMessage("EjectUser");
02357                         msg->nextBlock("AgentData");
02358                         msg->addUUID("AgentID", gAgent.getID() );
02359                         msg->addUUID("SessionID", gAgent.getSessionID() );
02360                         msg->nextBlock("Data");
02361                         msg->addUUID("TargetID", *avatar_id );
02362                         msg->addU32("Flags", flags );
02363                         msg->sendReliable( avatar->getRegion()->getHost() );
02364                 }
02365         }
02366 
02367         delete avatar_id;
02368         avatar_id = NULL;
02369 }
02370 
02371 class LLAvatarEject : public view_listener_t
02372 {
02373         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02374         {
02375                 LLVOAvatar* avatar = find_avatar_from_object( gViewerWindow->lastObjectHit() );
02376                 if( avatar )
02377                 {
02378                         LLUUID* avatar_id = new LLUUID( avatar->getID() );
02379                         LLString fullname = avatar->getFullname();
02380 
02381                         if (!fullname.empty())
02382                         {
02383                                 LLString::format_map_t args;
02384                                 args["[AVATAR_NAME]"] = fullname;
02385                                 gViewerWindow->alertXml("EjectAvatarFullname",
02386                                                         args,
02387                                                         callback_eject,
02388                                                         (void*)avatar_id);
02389                         }
02390                         else
02391                         {
02392                                 gViewerWindow->alertXml("EjectAvatar",
02393                                                         callback_eject,
02394                                                         (void*)avatar_id);
02395                         }
02396                 }
02397                 return true;
02398         }
02399 };
02400 
02401 class LLAvatarEnableFreezeEject : public view_listener_t
02402 {
02403         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02404         {
02405                 LLVOAvatar* avatar = find_avatar_from_object( gViewerWindow->lastObjectHit() );
02406                 bool new_value = (avatar != NULL);
02407 
02408                 if (new_value)
02409                 {
02410                         const LLVector3& pos = avatar->getPositionRegion();
02411                         LLViewerRegion* region = avatar->getRegion();
02412                         new_value = (region != NULL);
02413 
02414                         if (new_value)
02415                         {
02416                                 new_value = (region->isOwnedSelf(pos) || region->isOwnedGroup(pos));
02417                         }
02418                 }
02419 
02420                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
02421                 return true;
02422         }
02423 };
02424 
02425 class LLAvatarGiveCard : public view_listener_t
02426 {
02427         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02428         {
02429                 llinfos << "handle_give_card()" << llendl;
02430                 LLViewerObject* dest = gViewerWindow->lastObjectHit();
02431                 if(dest && dest->isAvatar())
02432                 {
02433                         bool found_name = false;
02434                         LLString::format_map_t args;
02435                         LLNameValue* nvfirst = dest->getNVPair("FirstName");
02436                         LLNameValue* nvlast = dest->getNVPair("LastName");
02437                         if(nvfirst && nvlast)
02438                         {
02439                                 args["[FIRST]"] = nvfirst->getString();
02440                                 args["[LAST]"] = nvlast->getString();
02441                                 found_name = true;
02442                         }
02443                         LLViewerRegion* region = dest->getRegion();
02444                         LLHost dest_host;
02445                         if(region)
02446                         {
02447                                 dest_host = region->getHost();
02448                         }
02449                         if(found_name && dest_host.isOk())
02450                         {
02451                                 LLMessageSystem* msg = gMessageSystem;
02452                                 msg->newMessage("OfferCallingCard");
02453                                 msg->nextBlockFast(_PREHASH_AgentData);
02454                                 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
02455                                 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
02456                                 msg->nextBlockFast(_PREHASH_AgentBlock);
02457                                 msg->addUUIDFast(_PREHASH_DestID, dest->getID());
02458                                 LLUUID transaction_id;
02459                                 transaction_id.generate();
02460                                 msg->addUUIDFast(_PREHASH_TransactionID, transaction_id);
02461                                 msg->sendReliable(dest_host);
02462                                 LLNotifyBox::showXml("OfferedCard", args);
02463                         }
02464                         else
02465                         {
02466                                 gViewerWindow->alertXml("CantOfferCallingCard", args);
02467                         }
02468                 }
02469                 return true;
02470         }
02471 };
02472 
02473 
02474 
02475 void login_done(S32 which, void *user)
02476 {
02477         llinfos << "Login done " << which << llendl;
02478 
02479         LLPanelLogin::close();
02480 }
02481 
02482 
02483 void callback_leave_group(S32 option, void *userdata)
02484 {
02485         if (option == 0)
02486         {
02487                 LLMessageSystem *msg = gMessageSystem;
02488 
02489                 msg->newMessageFast(_PREHASH_LeaveGroupRequest);
02490                 msg->nextBlockFast(_PREHASH_AgentData);
02491                 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
02492                 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
02493                 msg->nextBlockFast(_PREHASH_GroupData);
02494                 msg->addUUIDFast(_PREHASH_GroupID, gAgent.mGroupID );
02495                 gAgent.sendReliableMessage();
02496         }
02497 }
02498 
02499 void handle_leave_group(void *)
02500 {
02501         if (gAgent.getGroupID() != LLUUID::null)
02502         {
02503                 LLString::format_map_t args;
02504                 args["[GROUP]"] = gAgent.mGroupName;
02505                 gViewerWindow->alertXml("GroupLeaveConfirmMember", args, callback_leave_group);
02506         }
02507 }
02508 
02509 void append_aggregate(LLString& string, const LLAggregatePermissions& ag_perm, PermissionBit bit, const char* txt)
02510 {
02511         LLAggregatePermissions::EValue val = ag_perm.getValue(bit);
02512         char buffer[MAX_STRING];                /* Flawfinder: ignore */
02513         buffer[0] = '\0';
02514         switch(val)
02515         {
02516         case LLAggregatePermissions::AP_NONE:
02517                 snprintf(buffer, MAX_STRING, "* %s None\n", txt);               /* Flawfinder: ignore */
02518                 break;
02519         case LLAggregatePermissions::AP_SOME:
02520                 snprintf(buffer, MAX_STRING, "* %s Some\n", txt);               /* Flawfinder: ignore */
02521                 break;
02522         case LLAggregatePermissions::AP_ALL:
02523                 snprintf(buffer, MAX_STRING, "* %s All\n", txt);                /* Flawfinder: ignore */
02524                 break;
02525         case LLAggregatePermissions::AP_EMPTY:
02526         default:
02527                 break;
02528         }
02529         string.append(buffer);
02530 }
02531 
02532 const char* build_extensions_string(LLFilePicker::ELoadFilter filter)
02533 {
02534         switch(filter)
02535         {
02536 #if LL_WINDOWS
02537         case LLFilePicker::FFLOAD_IMAGE:
02538                 return IMAGE_EXTENSIONS;
02539         case LLFilePicker::FFLOAD_WAV:
02540                 return SOUND_EXTENSIONS;
02541         case LLFilePicker::FFLOAD_ANIM:
02542                 return ANIM_EXTENSIONS;
02543         case LLFilePicker::FFLOAD_SLOBJECT:
02544                 return SLOBJECT_EXTENSIONS;
02545 #ifdef _CORY_TESTING
02546         case LLFilePicker::FFLOAD_GEOMETRY:
02547                 return GEOMETRY_EXTENSIONS;
02548 #endif
02549         case LLFilePicker::FFLOAD_XML:
02550             return XML_EXTENSIONS;
02551         case LLFilePicker::FFLOAD_ALL:
02552                 return ALL_FILE_EXTENSIONS;
02553 #endif
02554     default:
02555         return ALL_FILE_EXTENSIONS;
02556         }
02557 }
02558 
02559 
02560 BOOL enable_buy(void*)
02561 {
02562     // In order to buy, there must only be 1 purchaseable object in
02563     // the selection manger.
02564         if(LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() != 1) return FALSE;
02565     LLViewerObject* obj = NULL;
02566     LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
02567         if(node)
02568     {
02569         obj = node->getObject();
02570         if(!obj) return FALSE;
02571 
02572                 if(node->mSaleInfo.isForSale() && node->mPermissions->getMaskOwner() & PERM_TRANSFER &&
02573                         (node->mPermissions->getMaskOwner() & PERM_COPY || node->mSaleInfo.getSaleType() != LLSaleInfo::FS_COPY))
02574                 {
02575                         if(obj->permAnyOwner()) return TRUE;
02576                 }
02577     }
02578         return FALSE;
02579 }
02580 
02581 class LLObjectEnableBuy : public view_listener_t
02582 {
02583         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02584         {
02585                 bool new_value = enable_buy(NULL);
02586                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
02587                 return true;
02588         }
02589 };
02590 
02591 // Note: This will only work if the selected object's data has been
02592 // received by the viewer and cached in the selection manager.
02593 void handle_buy_object(LLSaleInfo sale_info)
02594 {
02595         if(!LLSelectMgr::getInstance()->selectGetAllRootsValid())
02596         {
02597                 LLNotifyBox::showXml("UnableToBuyWhileDownloading");
02598                 return;
02599         }
02600 
02601         LLUUID owner_id;
02602         LLString owner_name;
02603         BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name);
02604         if (!owners_identical)
02605         {
02606                 LLNotifyBox::showXml("CannotBuyObjectsFromDifferentOwners");
02607                 return;
02608         }
02609 
02610         LLPermissions perm;
02611         BOOL valid = LLSelectMgr::getInstance()->selectGetPermissions(perm);
02612         LLAggregatePermissions ag_perm;
02613         valid &= LLSelectMgr::getInstance()->selectGetAggregatePermissions(ag_perm);
02614         if(!valid || !sale_info.isForSale() || !perm.allowTransferTo(gAgent.getID()))
02615         {
02616                 LLNotifyBox::showXml("ObjectNotForSale");
02617                 return;
02618         }
02619 
02620         S32 price = sale_info.getSalePrice();
02621         
02622         if (price > 0 && price > gStatusBar->getBalance())
02623         {
02624                 LLFloaterBuyCurrency::buyCurrency("This object costs", price);
02625                 return;
02626         }
02627 
02628         LLFloaterBuy::show(sale_info);
02629 }
02630 
02631 
02632 void handle_buy_contents(LLSaleInfo sale_info)
02633 {
02634         LLFloaterBuyContents::show(sale_info);
02635 }
02636 
02637 void handle_region_dump_temp_asset_data(void*)
02638 {
02639         llinfos << "Dumping temporary asset data to simulator logs" << llendl;
02640         std::vector<std::string> strings;
02641         LLUUID invoice;
02642         send_generic_message("dumptempassetdata", strings, invoice);
02643 }
02644 
02645 void handle_region_clear_temp_asset_data(void*)
02646 {
02647         llinfos << "Clearing temporary asset data" << llendl;
02648         std::vector<std::string> strings;
02649         LLUUID invoice;
02650         send_generic_message("cleartempassetdata", strings, invoice);
02651 }
02652 
02653 void handle_region_dump_settings(void*)
02654 {
02655         LLViewerRegion* regionp = gAgent.getRegion();
02656         if (regionp)
02657         {
02658                 llinfos << "Damage:    " << (regionp->getAllowDamage() ? "on" : "off") << llendl;
02659                 llinfos << "Landmark:  " << (regionp->getAllowLandmark() ? "on" : "off") << llendl;
02660                 llinfos << "SetHome:   " << (regionp->getAllowSetHome() ? "on" : "off") << llendl;
02661                 llinfos << "ResetHome: " << (regionp->getResetHomeOnTeleport() ? "on" : "off") << llendl;
02662                 llinfos << "SunFixed:  " << (regionp->getSunFixed() ? "on" : "off") << llendl;
02663                 llinfos << "BlockFly:  " << (regionp->getBlockFly() ? "on" : "off") << llendl;
02664                 llinfos << "AllowP2P:  " << (regionp->getAllowDirectTeleport() ? "on" : "off") << llendl;
02665                 llinfos << "Water:     " << (regionp->getWaterHeight()) << llendl;
02666         }
02667 }
02668 
02669 void handle_dump_group_info(void *)
02670 {
02671         llinfos << "group   " << gAgent.mGroupName << llendl;
02672         llinfos << "ID      " << gAgent.mGroupID << llendl;
02673         llinfos << "powers " << gAgent.mGroupPowers << llendl;
02674         llinfos << "title   " << gAgent.mGroupTitle << llendl;
02675         //llinfos << "insig   " << gAgent.mGroupInsigniaID << llendl;
02676 }
02677 
02678 void handle_dump_capabilities_info(void *)
02679 {
02680         LLViewerRegion* regionp = gAgent.getRegion();
02681         if (regionp)
02682         {
02683                 regionp->logActiveCapabilities();
02684         }
02685 }
02686 
02687 void handle_dump_region_object_cache(void*)
02688 {
02689         LLViewerRegion* regionp = gAgent.getRegion();
02690         if (regionp)
02691         {
02692                 regionp->dumpCache();
02693         }
02694 }
02695 
02696 void handle_dump_focus(void *)
02697 {
02698         LLView *view = gFocusMgr.getKeyboardFocus();
02699 
02700         llinfos << "Keyboard focus " << (view ? view->getName() : "(none)") << llendl;
02701 }
02702 
02703 class LLSelfStandUp : public view_listener_t
02704 {
02705         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02706         {
02707                 gAgent.setControlFlags(AGENT_CONTROL_STAND_UP);
02708                 return true;
02709         }
02710 };
02711 
02712 class LLSelfEnableStandUp : public view_listener_t
02713 {
02714         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02715         {
02716                 bool new_value = gAgent.getAvatarObject() && gAgent.getAvatarObject()->mIsSitting;
02717                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
02718                 return true;
02719         }
02720 };
02721 
02722 BOOL check_admin_override(void*)
02723 {
02724         return gAgent.getAdminOverride();
02725 }
02726 
02727 void handle_admin_override_toggle(void*)
02728 {
02729         gAgent.setAdminOverride(!gAgent.getAdminOverride());
02730 
02731         // The above may have affected which debug menus are visible
02732         show_debug_menus();
02733 }
02734 
02735 void handle_god_mode(void*)
02736 {
02737         gAgent.requestEnterGodMode();
02738 }
02739 
02740 void handle_leave_god_mode(void*)
02741 {
02742         gAgent.requestLeaveGodMode();
02743 }
02744 
02745 void set_god_level(U8 god_level)
02746 {
02747         U8 old_god_level = gAgent.getGodLevel();
02748         gAgent.setGodLevel( god_level );
02749         gIMMgr->refresh();
02750         LLViewerParcelMgr::getInstance()->notifyObservers();
02751 
02752         // Some classifieds change visibility on god mode
02753         LLFloaterDirectory::requestClassifieds();
02754 
02755         // God mode changes sim visibility
02756         LLWorldMap::getInstance()->reset();
02757         LLWorldMap::getInstance()->setCurrentLayer(0);
02758 
02759         // inventory in items may change in god mode
02760         gObjectList.dirtyAllObjectInventory();
02761 
02762     if(gViewerWindow)
02763     {
02764         gViewerWindow->setMenuBackgroundColor(god_level > GOD_NOT,
02765             LLAppViewer::instance()->isInProductionGrid());
02766     }
02767 
02768     LLString::format_map_t args;
02769         if(god_level > GOD_NOT)
02770         {
02771                 args["[LEVEL]"] = llformat("%d",(S32)god_level);
02772                 LLNotifyBox::showXml("EnteringGodMode", args);
02773         }
02774         else
02775         {
02776                 args["[LEVEL]"] = llformat("%d",(S32)old_god_level);
02777                 LLNotifyBox::showXml("LeavingGodMode", args);
02778         }
02779 
02780 
02781         // changing god-level can affect which menus we see
02782         show_debug_menus();
02783 }
02784 
02785 #ifdef TOGGLE_HACKED_GODLIKE_VIEWER
02786 void handle_toggle_hacked_godmode(void*)
02787 {
02788         gHackGodmode = !gHackGodmode;
02789         set_god_level(gHackGodmode ? GOD_MAINTENANCE : GOD_NOT);
02790 }
02791 
02792 BOOL check_toggle_hacked_godmode(void*)
02793 {
02794         return gHackGodmode;
02795 }
02796 #endif
02797 
02798 void process_grant_godlike_powers(LLMessageSystem* msg, void**)
02799 {
02800         LLUUID agent_id;
02801         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
02802         LLUUID session_id;
02803         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_SessionID, session_id);
02804         if((agent_id == gAgent.getID()) && (session_id == gAgent.getSessionID()))
02805         {
02806                 U8 god_level;
02807                 msg->getU8Fast(_PREHASH_GrantData, _PREHASH_GodLevel, god_level);
02808                 set_god_level(god_level);
02809         }
02810         else
02811         {
02812                 llwarns << "Grant godlike for wrong agent " << agent_id << llendl;
02813         }
02814 }
02815 
02816 void load_url_local_file(const char* file_name)
02817 {
02818         if( gAgent.cameraMouselook() )
02819         {
02820                 gAgent.changeCameraToDefault();
02821         }
02822 
02823 #if LL_DARWIN || LL_LINUX || LL_SOLARIS
02824         // MBW -- If the Mac client is in fullscreen mode, it needs to go windowed so the browser will be visible.
02825         if(gViewerWindow->mWindow->getFullscreen())
02826         {
02827                 gViewerWindow->toggleFullscreen(TRUE);
02828         }
02829 #endif
02830 
02831         // JC - system() blocks until IE has launched.
02832         // spawn() runs asynchronously, but opens a command prompt.
02833         // ShellExecute() just opens the damn file with the default
02834         // web browser.
02835         std::string full_path = "file:///";
02836         full_path.append(gDirUtilp->getAppRODataDir());
02837         full_path.append(gDirUtilp->getDirDelimiter());
02838         full_path.append(file_name);
02839 
02840         LLWeb::loadURL(full_path.c_str());
02841 }
02842 
02843 /*
02844 class LLHaveCallingcard : public LLInventoryCollectFunctor
02845 {
02846 public:
02847         LLHaveCallingcard(const LLUUID& agent_id);
02848         virtual ~LLHaveCallingcard() {}
02849         virtual bool operator()(LLInventoryCategory* cat,
02850                                                         LLInventoryItem* item);
02851         BOOL isThere() const { return mIsThere;}
02852 protected:
02853         LLUUID mID;
02854         BOOL mIsThere;
02855 };
02856 
02857 LLHaveCallingcard::LLHaveCallingcard(const LLUUID& agent_id) :
02858         mID(agent_id),
02859         mIsThere(FALSE)
02860 {
02861 }
02862 
02863 bool LLHaveCallingcard::operator()(LLInventoryCategory* cat,
02864                                                                    LLInventoryItem* item)
02865 {
02866         if(item)
02867         {
02868                 if((item->getType() == LLAssetType::AT_CALLINGCARD)
02869                    && (item->getCreatorUUID() == mID))
02870                 {
02871                         mIsThere = TRUE;
02872                 }
02873         }
02874         return FALSE;
02875 }
02876 */
02877 
02878 BOOL is_agent_friend(const LLUUID& agent_id)
02879 {
02880         return (LLAvatarTracker::instance().getBuddyInfo(agent_id) != NULL);
02881 }
02882 
02883 BOOL is_agent_mappable(const LLUUID& agent_id)
02884 {
02885         return (is_agent_friend(agent_id) &&
02886                 LLAvatarTracker::instance().getBuddyInfo(agent_id)->isOnline() &&
02887                 LLAvatarTracker::instance().getBuddyInfo(agent_id)->isRightGrantedFrom(LLRelationship::GRANT_MAP_LOCATION)
02888                 );
02889 }
02890 
02891 // Enable a menu item when you have someone's card.
02892 /*
02893 BOOL enable_have_card(void *userdata)
02894 {
02895         LLUUID* avatar_id = (LLUUID *)userdata;
02896         if (gAgent.isGodlike())
02897         {
02898                 return TRUE;
02899         }
02900         else if(avatar_id)
02901         {
02902                 return is_agent_friend(*avatar_id);
02903         }
02904         else
02905         {
02906                 return FALSE;
02907         }
02908 }
02909 */
02910 
02911 // Enable a menu item when you don't have someone's card.
02912 class LLAvatarEnableAddFriend : public view_listener_t
02913 {
02914         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02915         {
02916                 LLVOAvatar* avatar = find_avatar_from_object(gViewerWindow->lastObjectHit());
02917                 bool new_value = avatar && !is_agent_friend(avatar->getID());
02918                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
02919                 return true;
02920         }
02921 };
02922 
02923 void request_friendship(const LLUUID& dest_id)
02924 {
02925         LLViewerObject* dest = gObjectList.findObject(dest_id);
02926         if(dest && dest->isAvatar())
02927         {
02928                 LLString fullname;
02929                 LLString::format_map_t args;
02930                 LLNameValue* nvfirst = dest->getNVPair("FirstName");
02931                 LLNameValue* nvlast = dest->getNVPair("LastName");
02932                 if(nvfirst && nvlast)
02933                 {
02934                         args["[FIRST]"] = nvfirst->getString();
02935                         args["[LAST]"] = nvlast->getString();
02936                         fullname = nvfirst->getString();
02937                         fullname += " ";
02938                         fullname += nvlast->getString();
02939                 }
02940                 if (!fullname.empty())
02941                 {
02942                         LLPanelFriends::requestFriendship(dest_id, fullname);
02943                         LLNotifyBox::showXml("OfferedFriendship", args);
02944                 }
02945                 else
02946                 {
02947                         gViewerWindow->alertXml("CantOfferFriendship");
02948                 }
02949         }
02950 }
02951 
02952 
02953 class LLEditEnableCustomizeAvatar : public view_listener_t
02954 {
02955         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
02956         {
02957                 bool new_value = gAgent.getWearablesLoaded();
02958                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
02959                 return true;
02960         }
02961 };
02962 
02963 bool handle_sit_or_stand()
02964 {
02965         LLViewerObject *object = gObjectList.findObject(gLastHitNonFloraObjectID);      
02966         if (!object)
02967         {
02968                 return true;
02969         }
02970 
02971         if (sitting_on_selection())
02972         {
02973                 gAgent.setControlFlags(AGENT_CONTROL_STAND_UP);
02974                 return true;
02975         }
02976 
02977         // get object selection offset 
02978 
02979         if (object && object->getPCode() == LL_PCODE_VOLUME)
02980         {
02981                 LLVector3d offset_double = gViewerWindow->lastNonFloraObjectHitOffset();
02982                 LLVector3 offset_single;
02983                 offset_single.setVec(offset_double);
02984                 
02985                 gMessageSystem->newMessageFast(_PREHASH_AgentRequestSit);
02986                 gMessageSystem->nextBlockFast(_PREHASH_AgentData);
02987                 gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
02988                 gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
02989                 gMessageSystem->nextBlockFast(_PREHASH_TargetObject);
02990                 gMessageSystem->addUUIDFast(_PREHASH_TargetID, object->mID);
02991                 gMessageSystem->addVector3Fast(_PREHASH_Offset, offset_single);
02992 
02993                 object->getRegion()->sendReliableMessage();
02994         }
02995         return true;
02996 }
02997 
02998 class LLObjectSitOrStand : public view_listener_t
02999 {
03000         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03001         {
03002                 return handle_sit_or_stand();
03003         }
03004 };
03005 
03006 void near_sit_down_point(BOOL success, void *)
03007 {
03008         if (success)
03009         {
03010                 gAgent.setFlying(FALSE);
03011                 gAgent.setControlFlags(AGENT_CONTROL_SIT_ON_GROUND);
03012 
03013                 // Might be first sit
03014                 LLFirstUse::useSit();
03015         }
03016 }
03017 
03018 class LLLandSit : public view_listener_t
03019 {
03020         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03021         {
03022                 gAgent.setControlFlags(AGENT_CONTROL_STAND_UP);
03023                 LLViewerParcelMgr::getInstance()->deselectLand();
03024 
03025                 LLVector3d posGlobal = gLastHitPosGlobal;
03026                 
03027                 LLQuaternion target_rot;
03028                 if (gAgent.getAvatarObject())
03029                 {
03030                         target_rot = gAgent.getAvatarObject()->getRotation();
03031                 }
03032                 else
03033                 {
03034                         target_rot = gAgent.getFrameAgent().getQuaternion();
03035                 }
03036                 gAgent.startAutoPilotGlobal(posGlobal, "Sit", &target_rot, near_sit_down_point, NULL, 0.7f);
03037                 return true;
03038         }
03039 };
03040 
03041 void show_permissions_control(void*)
03042 {
03043         LLFloaterPermissionsMgr* floaterp = LLFloaterPermissionsMgr::show();
03044         floaterp->mPermissions->addPermissionsData("foo1", LLUUID::null, 0);
03045         floaterp->mPermissions->addPermissionsData("foo2", LLUUID::null, 0);
03046         floaterp->mPermissions->addPermissionsData("foo3", LLUUID::null, 0);
03047 }
03048 
03049 #if 0 // Unused (these just modify AudioInfoPage which is not used anywhere in the code
03050 void handle_audio_status_1(void*)
03051 {
03052         S32 page = gSavedSettings.getS32("AudioInfoPage");
03053         if (1 == page)
03054         {
03055                 page = 0;
03056         }
03057         else
03058         {
03059                 page = 1;
03060         }
03061         gSavedSettings.setS32("AudioInfoPage", page);   
03062 }
03063 
03064 void handle_audio_status_2(void*)
03065 {
03066         S32 page = gSavedSettings.getS32("AudioInfoPage");
03067         if (2 == page)
03068         {
03069                 page = 0;
03070         }
03071         else
03072         {
03073                 page = 2;
03074         }
03075         gSavedSettings.setS32("AudioInfoPage", page);   
03076 }
03077 
03078 void handle_audio_status_3(void*)
03079 {
03080         S32 page = gSavedSettings.getS32("AudioInfoPage");
03081         if (3 == page)
03082         {
03083                 page = 0;
03084         }
03085         else
03086         {
03087                 page = 3;
03088         }
03089         gSavedSettings.setS32("AudioInfoPage", page);   
03090 }
03091 
03092 void handle_audio_status_4(void*)
03093 {
03094         S32 page = gSavedSettings.getS32("AudioInfoPage");
03095         if (4 == page)
03096         {
03097                 page = 0;
03098         }
03099         else
03100         {
03101                 page = 4;
03102         }
03103         gSavedSettings.setS32("AudioInfoPage", page);   
03104 }
03105 #endif
03106 
03107 void manage_landmarks(void*)
03108 {
03109         LLFloaterLandmark::showInstance(1);
03110 }
03111 
03112 void create_new_landmark(void*)
03113 {
03114         // Note this is temporary cut and paste of legacy functionality.
03115         // TODO: Make this spawn a floater allowing user customize before creating the inventory object
03116 
03117         LLViewerRegion* agent_region = gAgent.getRegion();
03118         if(!agent_region)
03119         {
03120                 llwarns << "No agent region" << llendl;
03121                 return;
03122         }
03123         LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
03124         if (!agent_parcel)
03125         {
03126                 llwarns << "No agent parcel" << llendl;
03127                 return;
03128         }
03129         if (!agent_parcel->getAllowLandmark()
03130                 && !LLViewerParcelMgr::isParcelOwnedByAgent(agent_parcel, GP_LAND_ALLOW_LANDMARK))
03131         {
03132                 gViewerWindow->alertXml("CannotCreateLandmarkNotOwner");
03133                 return;
03134         }
03135 
03136         LLUUID folder_id;
03137         folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_LANDMARK);
03138         std::string pos_string;
03139         gAgent.buildLocationString(pos_string);
03140 
03141         create_inventory_item(gAgent.getID(), gAgent.getSessionID(),
03142                 folder_id, LLTransactionID::tnull,
03143                 pos_string, pos_string, // name, desc
03144                 LLAssetType::AT_LANDMARK,
03145                 LLInventoryType::IT_LANDMARK,
03146                 NOT_WEARABLE, PERM_ALL, 
03147                 NULL);
03148 }
03149 
03150 void landmark_menu_action(void* userdata)
03151 {
03152         LLUUID item_id = *(LLUUID*)userdata;
03153 
03154         LLViewerInventoryItem* itemp = gInventory.getItem(item_id);
03155         if (itemp)
03156         {
03157                 open_landmark(itemp, itemp->getName(), FALSE);
03158         }
03159 }
03160 
03161 void reload_ui(void *)
03162 {
03163         LLUICtrlFactory::getInstance()->rebuild();
03164 }
03165 
03166 class LLWorldFly : public view_listener_t
03167 {
03168         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03169         {
03170                 gAgent.toggleFlying();
03171                 return true;
03172         }
03173 };
03174 
03175 class LLWorldEnableFly : public view_listener_t
03176 {
03177         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03178         {
03179                 BOOL sitting = FALSE;
03180                 if (gAgent.getAvatarObject())
03181                 {
03182                         sitting = gAgent.getAvatarObject()->mIsSitting;
03183                 }
03184                 gMenuHolder->findControl(userdata["control"].asString())->setValue(!sitting);
03185                 return true;
03186         }
03187 };
03188 
03189 
03190 void handle_agent_stop_moving(void*)
03191 {
03192         // stop agent
03193         gAgent.setControlFlags(AGENT_CONTROL_STOP);
03194 
03195         // cancel autopilot
03196         gAgent.stopAutoPilot();
03197 }
03198 
03199 void print_packets_lost(void*)
03200 {
03201         LLWorld::getInstance()->printPacketsLost();
03202 }
03203 
03204 
03205 void drop_packet(void*)
03206 {
03207         gMessageSystem->mPacketRing.dropPackets(1);
03208 }
03209 
03210 
03211 void velocity_interpolate( void* data )
03212 {
03213         BOOL toggle = gSavedSettings.getBOOL("VelocityInterpolate");
03214         LLMessageSystem* msg = gMessageSystem;
03215         if ( !toggle )
03216         {
03217                 msg->newMessageFast(_PREHASH_VelocityInterpolateOn);
03218                 msg->nextBlockFast(_PREHASH_AgentData);
03219                 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
03220                 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
03221                 gAgent.sendReliableMessage();
03222                 llinfos << "Velocity Interpolation On" << llendl;
03223         }
03224         else
03225         {
03226                 msg->newMessageFast(_PREHASH_VelocityInterpolateOff);
03227                 msg->nextBlockFast(_PREHASH_AgentData);
03228                 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
03229                 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
03230                 gAgent.sendReliableMessage();
03231                 llinfos << "Velocity Interpolation Off" << llendl;
03232         }
03233         // BUG this is a hack because of the change in menu behavior.  The
03234         // old menu system would automatically change a control's value,
03235         // but the new LLMenuGL system doesn't know what a control
03236         // is. However, it's easy to distinguish between the two callers
03237         // because LLMenuGL passes in the name of the user data (the
03238         // control name) to the callback function, and the user data goes
03239         // unused in the old menu code. Thus, if data is not null, then we
03240         // need to swap the value of the control.
03241         if( data )
03242         {
03243                 gSavedSettings.setBOOL( static_cast<char*>(data), !toggle );
03244         }
03245 }
03246 
03247 
03248 void update_fov(S32 increments)
03249 {
03250         F32 old_fov = LLViewerCamera::getInstance()->getDefaultFOV();
03251         // for each increment, FoV is 20% bigger
03252         F32 new_fov = old_fov * pow(1.2f, increments);
03253 
03254         // cap the FoV
03255         new_fov = llclamp(new_fov, MIN_FIELD_OF_VIEW, MAX_FIELD_OF_VIEW);
03256 
03257         if (new_fov != old_fov)
03258         {
03259                 LLMessageSystem* msg = gMessageSystem;
03260                 msg->newMessageFast(_PREHASH_AgentFOV);
03261                 msg->nextBlockFast(_PREHASH_AgentData);
03262                 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
03263                 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
03264                 msg->addU32Fast(_PREHASH_CircuitCode, gMessageSystem->mOurCircuitCode);
03265 
03266                 msg->nextBlockFast(_PREHASH_FOVBlock);
03267                 msg->addU32Fast(_PREHASH_GenCounter, 0);
03268                 msg->addF32Fast(_PREHASH_VerticalAngle, new_fov);
03269 
03270                 gAgent.sendReliableMessage();
03271 
03272                 // force agent to update dirty patches
03273                 LLViewerCamera::getInstance()->setDefaultFOV(new_fov);
03274                 LLViewerCamera::getInstance()->setView(new_fov);
03275         }
03276 }
03277 
03278 class LLViewZoomOut : public view_listener_t
03279 {
03280         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03281         {
03282                 update_fov(1);
03283                 return true;
03284         }
03285 };
03286 
03287 class LLViewZoomIn : public view_listener_t
03288 {
03289         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03290         {
03291                 update_fov(-1);
03292                 return true;
03293         }
03294 };
03295 
03296 class LLViewZoomDefault : public view_listener_t
03297 {
03298         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03299         {
03300                 F32 old_fov = LLViewerCamera::getInstance()->getView();
03301                 // for each increment, FoV is 20% bigger
03302                 F32 new_fov = DEFAULT_FIELD_OF_VIEW;
03303 
03304                 if (new_fov != old_fov)
03305                 {
03306                         LLMessageSystem* msg = gMessageSystem;
03307                         msg->newMessageFast(_PREHASH_AgentFOV);
03308                         msg->nextBlockFast(_PREHASH_AgentData);
03309                         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
03310                         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
03311                         msg->addU32Fast(_PREHASH_CircuitCode, gMessageSystem->mOurCircuitCode);
03312                         msg->nextBlockFast(_PREHASH_FOVBlock);
03313                         msg->addU32Fast(_PREHASH_GenCounter, 0);
03314                         msg->addF32Fast(_PREHASH_VerticalAngle, new_fov);
03315 
03316                         gAgent.sendReliableMessage();
03317 
03318                         // force agent to update dirty patches
03319                         LLViewerCamera::getInstance()->setDefaultFOV(new_fov);
03320                         LLViewerCamera::getInstance()->setView(new_fov);
03321                 }
03322                 return true;
03323         }
03324 };
03325 
03326 
03327 
03328 void toggle_wind_audio(void)
03329 {
03330         if (gAudiop)
03331         {
03332                 gAudiop->enableWind(!(gAudiop->isWindEnabled()));
03333         }
03334 }
03335 
03336 
03337 // Callback for enablement
03338 BOOL is_inventory_visible( void* user_data )
03339 {
03340         LLInventoryView* iv = reinterpret_cast<LLInventoryView*>(user_data);
03341         if( iv )
03342         {
03343                 return iv->getVisible();
03344         }
03345         return FALSE;
03346 }
03347 
03348 void handle_show_newest_map(void*)
03349 {
03350         LLFloaterWorldMap::show(NULL, FALSE);
03351 }
03352 
03353 //-------------------------------------------------------------------
03354 // Help menu functions
03355 //-------------------------------------------------------------------
03356 
03357 //
03358 // Major mode switching
03359 //
03360 void reset_view_final( BOOL proceed, void* );
03361 
03362 void handle_reset_view()
03363 {
03364         if( (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgent.getCameraMode()) && gFloaterCustomize )
03365         {
03366                 // Show dialog box if needed.
03367                 gFloaterCustomize->askToSaveAllIfDirty( reset_view_final, NULL );
03368         }
03369         else
03370         {
03371                 reset_view_final( TRUE, NULL );
03372         }
03373 }
03374 
03375 class LLViewResetView : public view_listener_t
03376 {
03377         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03378         {
03379                 handle_reset_view();
03380                 return true;
03381         }
03382 };
03383 
03384 // Note: extra parameters allow this function to be called from dialog.
03385 void reset_view_final( BOOL proceed, void* ) 
03386 {
03387         if( !proceed )
03388         {
03389                 return;
03390         }
03391 
03392         gAgent.changeCameraToDefault();
03393         
03394         if (LLViewerJoystick::getInstance()->getOverrideCamera())
03395         {
03396                 handle_toggle_flycam();
03397         }
03398 
03399         // reset avatar mode from eventual residual motion
03400         if (LLToolMgr::getInstance()->inBuildMode())
03401         {
03402                 LLViewerJoystick::getInstance()->moveAvatar(true);
03403         }
03404 
03405         gAgent.resetView(!gFloaterTools->getVisible());
03406         gFloaterTools->close();
03407         
03408         gViewerWindow->showCursor();
03409 
03410         // Switch back to basic toolset
03411         LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
03412 }
03413 
03414 class LLViewLookAtLastChatter : public view_listener_t
03415 {
03416         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03417         {
03418                 gAgent.lookAtLastChat();
03419                 return true;
03420         }
03421 };
03422 
03423 class LLViewMouselook : public view_listener_t
03424 {
03425         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03426         {
03427                 if (!gAgent.cameraMouselook())
03428                 {
03429                         gAgent.changeCameraToMouselook();
03430                 }
03431                 else
03432                 {
03433                         gAgent.changeCameraToDefault();
03434                 }
03435                 return true;
03436         }
03437 };
03438 
03439 class LLViewFullscreen : public view_listener_t
03440 {
03441         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03442         {
03443                 gViewerWindow->toggleFullscreen(TRUE);
03444                 return true;
03445         }
03446 };
03447 
03448 class LLViewDefaultUISize : public view_listener_t
03449 {
03450         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03451         {
03452                 gSavedSettings.setF32("UIScaleFactor", 1.0f);
03453                 gSavedSettings.setBOOL("UIAutoScale", FALSE);   
03454                 gViewerWindow->reshape(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight());
03455                 return true;
03456         }
03457 };
03458 
03459 class LLEditDuplicate : public view_listener_t
03460 {
03461         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03462         {
03463                 if(LLEditMenuHandler::gEditMenuHandler)
03464                 {
03465                         LLEditMenuHandler::gEditMenuHandler->duplicate();
03466                 }
03467                 return true;
03468         }
03469 };
03470 
03471 class LLEditEnableDuplicate : public view_listener_t
03472 {
03473         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03474         {
03475                 bool new_value = LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canDuplicate();
03476                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
03477                 return true;
03478         }
03479 };
03480 
03481 
03482 void disabled_duplicate(void*)
03483 {
03484         if (LLSelectMgr::getInstance()->getSelection()->getFirstObject())
03485         {
03486                 LLNotifyBox::showXml("CopyFailed");
03487         }
03488 }
03489 
03490 void handle_duplicate_in_place(void*)
03491 {
03492         llinfos << "handle_duplicate_in_place" << llendl;
03493 
03494         LLVector3 offset(0.f, 0.f, 0.f);
03495         LLSelectMgr::getInstance()->selectDuplicate(offset, TRUE);
03496 }
03497 
03498 void handle_repeat_duplicate(void*)
03499 {
03500         LLSelectMgr::getInstance()->repeatDuplicate();
03501 }
03502 
03503 /* dead code 30-apr-2008
03504 void handle_deed_object_to_group(void*)
03505 {
03506         LLUUID group_id;
03507         
03508         LLSelectMgr::getInstance()->selectGetGroup(group_id);
03509         LLSelectMgr::getInstance()->sendOwner(LLUUID::null, group_id, FALSE);
03510         LLViewerStats::getInstance()->incStat(LLViewerStats::ST_RELEASE_COUNT);
03511 }
03512 
03513 BOOL enable_deed_object_to_group(void*)
03514 {
03515         if(LLSelectMgr::getInstance()->getSelection()->isEmpty()) return FALSE;
03516         LLPermissions perm;
03517         LLUUID group_id;
03518 
03519         if (LLSelectMgr::getInstance()->selectGetGroup(group_id) &&
03520                 gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) &&
03521                 LLSelectMgr::getInstance()->selectGetPermissions(perm) &&
03522                 perm.deedToGroup(gAgent.getID(), group_id))
03523         {
03524                 return TRUE;
03525         }
03526         return FALSE;
03527 }
03528 
03529 */
03530 
03531 
03532 /*
03533  * No longer able to support viewer side manipulations in this way
03534  *
03535 void god_force_inv_owner_permissive(LLViewerObject* object,
03536                                                                         InventoryObjectList* inventory,
03537                                                                         S32 serial_num,
03538                                                                         void*)
03539 {
03540         typedef std::vector<LLPointer<LLViewerInventoryItem> > item_array_t;
03541         item_array_t items;
03542 
03543         InventoryObjectList::const_iterator inv_it = inventory->begin();
03544         InventoryObjectList::const_iterator inv_end = inventory->end();
03545         for ( ; inv_it != inv_end; ++inv_it)
03546         {
03547                 if(((*inv_it)->getType() != LLAssetType::AT_CATEGORY)
03548                    && ((*inv_it)->getType() != LLAssetType::AT_ROOT_CATEGORY))
03549                 {
03550                         LLInventoryObject* obj = *inv_it;
03551                         LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem((LLViewerInventoryItem*)obj);
03552                         LLPermissions perm(new_item->getPermissions());
03553                         perm.setMaskBase(PERM_ALL);
03554                         perm.setMaskOwner(PERM_ALL);
03555                         new_item->setPermissions(perm);
03556                         items.push_back(new_item);
03557                 }
03558         }
03559         item_array_t::iterator end = items.end();
03560         item_array_t::iterator it;
03561         for(it = items.begin(); it != end; ++it)
03562         {
03563                 // since we have the inventory item in the callback, it should not
03564                 // invalidate iteration through the selection manager.
03565                 object->updateInventory((*it), TASK_INVENTORY_ITEM_KEY, false);
03566         }
03567 }
03568 */
03569 
03570 void handle_object_owner_permissive(void*)
03571 {
03572         // only send this if they're a god.
03573         if(gAgent.isGodlike())
03574         {
03575                 // do the objects.
03576                 LLSelectMgr::getInstance()->selectionSetObjectPermissions(PERM_BASE, TRUE, PERM_ALL, TRUE);
03577                 LLSelectMgr::getInstance()->selectionSetObjectPermissions(PERM_OWNER, TRUE, PERM_ALL, TRUE);
03578         }
03579 }
03580 
03581 void handle_object_owner_self(void*)
03582 {
03583         // only send this if they're a god.
03584         if(gAgent.isGodlike())
03585         {
03586                 LLSelectMgr::getInstance()->sendOwner(gAgent.getID(), gAgent.getGroupID(), TRUE);
03587         }
03588 }
03589 
03590 // Shortcut to set owner permissions to not editable.
03591 void handle_object_lock(void*)
03592 {
03593         LLSelectMgr::getInstance()->selectionSetObjectPermissions(PERM_OWNER, FALSE, PERM_MODIFY);
03594 }
03595 
03596 void handle_object_asset_ids(void*)
03597 {
03598         // only send this if they're a god.
03599         if (gAgent.isGodlike())
03600         {
03601                 LLSelectMgr::getInstance()->sendGodlikeRequest("objectinfo", "assetids");
03602         }
03603 }
03604 
03605 void handle_force_parcel_owner_to_me(void*)
03606 {
03607         LLViewerParcelMgr::getInstance()->sendParcelGodForceOwner( gAgent.getID() );
03608 }
03609 
03610 void handle_force_parcel_to_content(void*)
03611 {
03612         LLViewerParcelMgr::getInstance()->sendParcelGodForceToContent();
03613 }
03614 
03615 void handle_claim_public_land(void*)
03616 {
03617         if (LLViewerParcelMgr::getInstance()->getSelectionRegion() != gAgent.getRegion())
03618         {
03619                 LLNotifyBox::showXml("ClaimPublicLand");
03620                 return;
03621         }
03622 
03623         LLVector3d west_south_global;
03624         LLVector3d east_north_global;
03625         LLViewerParcelMgr::getInstance()->getSelection(west_south_global, east_north_global);
03626         LLVector3 west_south = gAgent.getPosAgentFromGlobal(west_south_global);
03627         LLVector3 east_north = gAgent.getPosAgentFromGlobal(east_north_global);
03628 
03629         LLMessageSystem* msg = gMessageSystem;
03630         msg->newMessage("GodlikeMessage");
03631         msg->nextBlock("AgentData");
03632         msg->addUUID("AgentID", gAgent.getID());
03633         msg->addUUID("SessionID", gAgent.getSessionID());
03634         msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
03635         msg->nextBlock("MethodData");
03636         msg->addString("Method", "claimpublicland");
03637         msg->addUUID("Invoice", LLUUID::null);
03638         char buffer[32];                /* Flawfinder: ignore */
03639         snprintf(buffer, sizeof(buffer), "%f", west_south.mV[VX]);              /* Flawfinder: ignore */
03640         msg->nextBlock("ParamList");
03641         msg->addString("Parameter", buffer);
03642         snprintf(buffer, sizeof(buffer), "%f", west_south.mV[VY]);              /* Flawfinder: ignore */
03643         msg->nextBlock("ParamList");
03644         msg->addString("Parameter", buffer);
03645         snprintf(buffer, sizeof(buffer), "%f", east_north.mV[VX]);              /* Flawfinder: ignore */
03646         msg->nextBlock("ParamList");
03647         msg->addString("Parameter", buffer);
03648         snprintf(buffer, sizeof(buffer), "%f", east_north.mV[VY]);              /* Flawfinder: ignore */
03649         msg->nextBlock("ParamList");
03650         msg->addString("Parameter", buffer);
03651         gAgent.sendReliableMessage();
03652 }
03653 
03654 void handle_god_request_havok(void *)
03655 {
03656         if (gAgent.isGodlike())
03657         {
03658                 LLSelectMgr::getInstance()->sendGodlikeRequest("havok", "infoverbose");
03659         }
03660 }
03661 
03662 //void handle_god_request_foo(void *)
03663 //{
03664 //      if (gAgent.isGodlike())
03665 //      {
03666 //              LLSelectMgr::getInstance()->sendGodlikeRequest(GOD_WANTS_FOO);
03667 //      }
03668 //}
03669 
03670 //void handle_god_request_terrain_save(void *)
03671 //{
03672 //      if (gAgent.isGodlike())
03673 //      {
03674 //              LLSelectMgr::getInstance()->sendGodlikeRequest("terrain", "save");
03675 //      }
03676 //}
03677 
03678 //void handle_god_request_terrain_load(void *)
03679 //{
03680 //      if (gAgent.isGodlike())
03681 //      {
03682 //              LLSelectMgr::getInstance()->sendGodlikeRequest("terrain", "load");
03683 //      }
03684 //}
03685 
03686 
03687 // HACK for easily testing new avatar geometry
03688 void handle_god_request_avatar_geometry(void *)
03689 {
03690         if (gAgent.isGodlike())
03691         {
03692                 LLSelectMgr::getInstance()->sendGodlikeRequest("avatar toggle", NULL);
03693         }
03694 }
03695 
03696 
03697 void handle_show_overlay_title(void*)
03698 {
03699         gShowOverlayTitle = !gShowOverlayTitle;
03700         gSavedSettings.setBOOL("ShowOverlayTitle", gShowOverlayTitle);
03701 }
03702 
03703 void derez_objects(EDeRezDestination dest, const LLUUID& dest_id)
03704 {
03705         if(gAgent.cameraMouselook())
03706         {
03707                 gAgent.changeCameraToDefault();
03708         }
03709         //gInventoryView->setPanelOpen(TRUE);
03710 
03711         std::string error;
03712         LLDynamicArray<LLViewerObject*> derez_objects;
03713         
03714         // Check conditions that we can't deal with, building a list of
03715         // everything that we'll actually be derezzing.
03716         LLViewerRegion* first_region = NULL;
03717         for (LLObjectSelection::valid_root_iterator iter = LLSelectMgr::getInstance()->getSelection()->valid_root_begin();
03718                  iter != LLSelectMgr::getInstance()->getSelection()->valid_root_end(); iter++)
03719         {
03720                 LLSelectNode* node = *iter;
03721                 LLViewerObject* object = node->getObject();
03722                 LLViewerRegion* region = object->getRegion();
03723                 if (!first_region)
03724                 {
03725                         first_region = region;
03726                 }
03727                 else
03728                 {
03729                         if(region != first_region)
03730                         {
03731                                 // Derez doesn't work at all if the some of the objects
03732                                 // are in regions besides the first object selected.
03733                                 
03734                                 // ...crosses region boundaries
03735                                 error = "AcquireErrorObjectSpan";
03736                                 break;
03737                         }
03738                 }
03739                 if (object->isAvatar())
03740                 {
03741                         // ...don't acquire avatars
03742                         continue;
03743                 }
03744 
03745                 // If AssetContainers are being sent back, they will appear as 
03746                 // boxes in the owner's inventory.
03747                 if (object->getNVPair("AssetContainer")
03748                         && dest != DRD_RETURN_TO_OWNER)
03749                 {
03750                         // this object is an asset container, derez its contents, not it
03751                         llwarns << "Attempt to derez deprecated AssetContainer object type not supported." << llendl;
03752                         /*
03753                         object->requestInventory(container_inventory_arrived, 
03754                                 (void *)(BOOL)(DRD_TAKE_INTO_AGENT_INVENTORY == dest));
03755                         */
03756                         continue;
03757                 }
03758                 BOOL can_derez_current = FALSE;
03759                 switch(dest)
03760                 {
03761                 case DRD_TAKE_INTO_AGENT_INVENTORY:
03762                 case DRD_TRASH:
03763                         if( (node->mPermissions->allowTransferTo(gAgent.getID()) && object->permModify())
03764                                 || (node->allowOperationOnNode(PERM_OWNER, GP_OBJECT_MANIPULATE)) )
03765                         {
03766                                 can_derez_current = TRUE;
03767                         }
03768                         break;
03769 
03770                 case DRD_RETURN_TO_OWNER:
03771                         can_derez_current = TRUE;
03772                         break;
03773 
03774                 default:
03775                         if((node->mPermissions->allowTransferTo(gAgent.getID())
03776                                 && object->permCopy())
03777                            || gAgent.isGodlike())
03778                         {
03779                                 can_derez_current = TRUE;
03780                         }
03781                         break;
03782                 }
03783                 if(can_derez_current)
03784                 {
03785                         derez_objects.put(object);
03786                 }
03787         }
03788 
03789         // This constant is based on (1200 - HEADER_SIZE) / 4 bytes per
03790         // root.  I lopped off a few (33) to provide a bit
03791         // pad. HEADER_SIZE is currently 67 bytes, most of which is UUIDs.
03792         // This gives us a maximum of 63500 root objects - which should
03793         // satisfy anybody.
03794         const S32 MAX_ROOTS_PER_PACKET = 250;
03795         const S32 MAX_PACKET_COUNT = 254;
03796         F32 packets = ceil((F32)derez_objects.count() / (F32)MAX_ROOTS_PER_PACKET);
03797         if(packets > (F32)MAX_PACKET_COUNT)
03798         {
03799                 error = "AcquireErrorTooManyObjects";
03800         }
03801 
03802         if(error.empty() && derez_objects.count() > 0)
03803         {
03804                 U8 d = (U8)dest;
03805                 LLUUID tid;
03806                 tid.generate();
03807                 U8 packet_count = (U8)packets;
03808                 S32 object_index = 0;
03809                 S32 objects_in_packet = 0;
03810                 LLMessageSystem* msg = gMessageSystem;
03811                 for(U8 packet_number = 0;
03812                         packet_number < packet_count;
03813                         ++packet_number)
03814                 {
03815                         msg->newMessageFast(_PREHASH_DeRezObject);
03816                         msg->nextBlockFast(_PREHASH_AgentData);
03817                         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
03818                         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
03819                         msg->nextBlockFast(_PREHASH_AgentBlock);
03820                         msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID());
03821                         msg->addU8Fast(_PREHASH_Destination, d);        
03822                         msg->addUUIDFast(_PREHASH_DestinationID, dest_id);
03823                         msg->addUUIDFast(_PREHASH_TransactionID, tid);
03824                         msg->addU8Fast(_PREHASH_PacketCount, packet_count);
03825                         msg->addU8Fast(_PREHASH_PacketNumber, packet_number);
03826                         objects_in_packet = 0;
03827                         while((object_index < derez_objects.count())
03828                                   && (objects_in_packet++ < MAX_ROOTS_PER_PACKET))
03829 
03830                         {
03831                                 LLViewerObject* object = derez_objects.get(object_index++);
03832                                 msg->nextBlockFast(_PREHASH_ObjectData);
03833                                 msg->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
03834                                 // VEFFECT: DerezObject
03835                                 LLHUDEffectSpiral* effectp = (LLHUDEffectSpiral*)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINT, TRUE);
03836                                 effectp->setPositionGlobal(object->getPositionGlobal());
03837                                 effectp->setColor(LLColor4U(gAgent.getEffectColor()));
03838                         }
03839                         msg->sendReliable(first_region->getHost());
03840                 }
03841                 make_ui_sound("UISndObjectRezOut");
03842 
03843                 // Busy count decremented by inventory update, so only increment
03844                 // if will be causing an update.
03845                 if (dest != DRD_RETURN_TO_OWNER)
03846                 {
03847                         gViewerWindow->getWindow()->incBusyCount();
03848                 }
03849         }
03850         else if(!error.empty())
03851         {
03852                 gViewerWindow->alertXml(error);
03853         }
03854 }
03855 
03856 class LLToolsTakeCopy : public view_listener_t
03857 {
03858         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03859         {
03860                 if (LLSelectMgr::getInstance()->getSelection()->isEmpty()) return true;
03861 
03862                 const LLUUID& category_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_OBJECT);
03863                 derez_objects(DRD_ACQUIRE_TO_AGENT_INVENTORY, category_id);
03864 
03865                 return true;
03866         }
03867 };
03868 
03869 
03870 // You can return an object to its owner if it is on your land.
03871 class LLObjectReturn : public view_listener_t
03872 {
03873         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03874         {
03875                 if (LLSelectMgr::getInstance()->getSelection()->isEmpty()) return true;
03876                 
03877                 mObjectSelection = LLSelectMgr::getInstance()->getEditSelection();
03878 
03879                 gViewerWindow->alertXml("ReturnToOwner",
03880                         onReturnToOwner,
03881                         (void*)this);
03882                 return true;
03883         }
03884 
03885         static void onReturnToOwner(S32 option, void* data)
03886         {
03887                 LLObjectReturn* object_return = (LLObjectReturn*)data;
03888 
03889                 if (0 == option)
03890                 {
03891                         // Ignore category ID for this derez destination.
03892                         derez_objects(DRD_RETURN_TO_OWNER, LLUUID::null);
03893                 }
03894 
03895                 // drop reference to current selection
03896                 object_return->mObjectSelection = NULL;
03897         }
03898 
03899 protected:
03900         LLObjectSelectionHandle mObjectSelection;
03901 };
03902 
03903 
03904 // Allow return to owner if one or more of the selected items is
03905 // over land you own.
03906 class LLObjectEnableReturn : public view_listener_t
03907 {
03908         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
03909         {
03910 #ifdef HACKED_GODLIKE_VIEWER
03911                 bool new_value = true;
03912 #else
03913                 bool new_value = false;
03914                 if (gAgent.isGodlike())
03915                 {
03916                         new_value = true;
03917                 }
03918                 else
03919                 {
03920                         LLViewerRegion* region = gAgent.getRegion();
03921                         if (region)
03922                         {
03923                                 // Estate owners and managers can always return objects.
03924                                 if (region->canManageEstate())
03925                                 {
03926                                         new_value = true;
03927                                 }
03928                                 else
03929                                 {
03930                                         struct f : public LLSelectedObjectFunctor
03931                                         {
03932                                                 virtual bool apply(LLViewerObject* obj)
03933                                                 {
03934                                                         return (obj->isOverAgentOwnedLand() ||
03935                                                                         obj->isOverGroupOwnedLand() ||
03936                                                                         obj->permModify());
03937                                                 }
03938                                         } func;
03939                                         const bool firstonly = true;
03940                                         new_value = LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func, firstonly);
03941                                 }
03942                         }
03943                 }
03944 #endif
03945                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
03946                 return true;
03947         }
03948 };
03949 
03950 void force_take_copy(void*)
03951 {
03952         if (LLSelectMgr::getInstance()->getSelection()->isEmpty()) return;
03953         const LLUUID& category_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_OBJECT);
03954         derez_objects(DRD_FORCE_TO_GOD_INVENTORY, category_id);
03955 }
03956 
03957 void handle_take()
03958 {
03959         // we want to use the folder this was derezzed from if it's
03960         // available. Otherwise, derez to the normal place.
03961         if(LLSelectMgr::getInstance()->getSelection()->isEmpty())
03962         {
03963                 return;
03964         }
03965         
03966         BOOL you_own_everything = TRUE;
03967         BOOL locked_but_takeable_object = FALSE;
03968         LLUUID category_id;
03969         
03970         for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin();
03971                  iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++)
03972         {
03973                 LLSelectNode* node = *iter;
03974                 LLViewerObject* object = node->getObject();
03975                 if(object)
03976                 {
03977                         if(!object->permYouOwner())
03978                         {
03979                                 you_own_everything = FALSE;
03980                         }
03981 
03982                         if(!object->permMove())
03983                         {
03984                                 locked_but_takeable_object = TRUE;
03985                         }
03986                 }
03987                 if(node->mFolderID.notNull())
03988                 {
03989                         if(category_id.isNull())
03990                         {
03991                                 category_id = node->mFolderID;
03992                         }
03993                         else if(category_id != node->mFolderID)
03994                         {
03995                                 // we have found two potential destinations. break out
03996                                 // now and send to the default location.
03997                                 category_id.setNull();
03998                                 break;
03999                         }
04000                 }
04001         }
04002         if(category_id.notNull())
04003         {
04004                 // there is an unambiguous destination. See if this agent has
04005                 // such a location and it is not in the trash or library
04006                 if(!gInventory.getCategory(category_id))
04007                 {
04008                         // nope, set to NULL.
04009                         category_id.setNull();
04010                 }
04011                 if(category_id.notNull())
04012                 {
04013                         // check trash
04014                         LLUUID trash;
04015                         trash = gInventory.findCategoryUUIDForType(LLAssetType::AT_TRASH);
04016                         if(category_id == trash || gInventory.isObjectDescendentOf(category_id, trash))
04017                         {
04018                                 category_id.setNull();
04019                         }
04020 
04021                         // check library
04022                         if(gInventory.isObjectDescendentOf(category_id, gInventoryLibraryRoot))
04023                         {
04024                                 category_id.setNull();
04025                         }
04026 
04027                 }
04028         }
04029         if(category_id.isNull())
04030         {
04031                 category_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_OBJECT);
04032         }
04033         LLUUID* cat_id = new LLUUID(category_id);
04034         if(locked_but_takeable_object ||
04035            !you_own_everything)
04036         {
04037                 if(locked_but_takeable_object && you_own_everything)
04038                 {
04039                         gViewerWindow->alertXml("ConfirmObjectTakeLock",
04040                         confirm_take,
04041                         (void*)cat_id);
04042 
04043                 }
04044                 else if(!locked_but_takeable_object && !you_own_everything)
04045                 {
04046                         gViewerWindow->alertXml("ConfirmObjectTakeNoOwn",
04047                         confirm_take,
04048                         (void*)cat_id);
04049                 }
04050                 else
04051                 {
04052                         gViewerWindow->alertXml("ConfirmObjectTakeLockNoOwn",
04053                         confirm_take,
04054                         (void*)cat_id);
04055                 }
04056 
04057 
04058         }
04059 
04060         else
04061         {
04062                 confirm_take(0, (void*)cat_id);
04063         }
04064 }
04065 
04066 void confirm_take(S32 option, void* data)
04067 {
04068         LLUUID* cat_id = (LLUUID*)data;
04069         if(!cat_id) return;
04070         if(enable_take() && (option == 0))
04071         {
04072                 derez_objects(DRD_TAKE_INTO_AGENT_INVENTORY, *cat_id);
04073         }
04074         delete cat_id;
04075 }
04076 
04077 // You can take an item when it is public and transferrable, or when
04078 // you own it. We err on the side of enabling the item when at least
04079 // one item selected can be copied to inventory.
04080 BOOL enable_take()
04081 {
04082         if (sitting_on_selection())
04083         {
04084                 return FALSE;
04085         }
04086 
04087         for (LLObjectSelection::valid_root_iterator iter = LLSelectMgr::getInstance()->getSelection()->valid_root_begin();
04088                  iter != LLSelectMgr::getInstance()->getSelection()->valid_root_end(); iter++)
04089         {
04090                 LLSelectNode* node = *iter;
04091                 LLViewerObject* object = node->getObject();
04092                 if (object->isAvatar())
04093                 {
04094                         // ...don't acquire avatars
04095                         continue;
04096                 }
04097 
04098 #ifdef HACKED_GODLIKE_VIEWER
04099                 return TRUE;
04100 #else
04101 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
04102                 if (!LLAppViewer::instance()->isInProductionGrid() 
04103             && gAgent.isGodlike())
04104                 {
04105                         return TRUE;
04106                 }
04107 # endif
04108                 if((node->mPermissions->allowTransferTo(gAgent.getID())
04109                         && object->permModify())
04110                    || (node->mPermissions->getOwner() == gAgent.getID()))
04111                 {
04112                         return TRUE;
04113                 }
04114 #endif
04115         }
04116         return FALSE;
04117 }
04118 
04119 class LLToolsBuyOrTake : public view_listener_t
04120 {
04121         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04122         {
04123                 if (LLSelectMgr::getInstance()->getSelection()->isEmpty())
04124                 {
04125                         return true;
04126                 }
04127 
04128                 if (is_selection_buy_not_take())
04129                 {
04130                         S32 total_price = selection_price();
04131 
04132                         if (total_price <= gStatusBar->getBalance() || total_price == 0)
04133                         {
04134                                 handle_buy(NULL);
04135                         }
04136                         else
04137                         {
04138                                 LLFloaterBuyCurrency::buyCurrency(
04139                                         "Buying this costs", total_price);
04140                         }
04141                 }
04142                 else
04143                 {
04144                         handle_take();
04145                 }
04146                 return true;
04147         }
04148 };
04149 
04150 class LLToolsEnableBuyOrTake : public view_listener_t
04151 {
04152         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04153         {
04154                 bool is_buy = is_selection_buy_not_take();
04155                 bool new_value = is_buy ? enable_buy(NULL) : enable_take();
04156                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04157 
04158                 // Update label
04159                 LLString label;
04160                 LLString buy_text;
04161                 LLString take_text;
04162                 LLString param = userdata["data"].asString();
04163                 LLString::size_type offset = param.find(",");
04164                 if (offset != param.npos)
04165                 {
04166                         buy_text = param.substr(0, offset);
04167                         take_text = param.substr(offset+1);
04168                 }
04169                 if (is_buy)
04170                 {
04171                         label = buy_text;
04172                 }
04173                 else
04174                 {
04175                         label = take_text;
04176                 }
04177                 gMenuHolder->childSetText("Pie Object Take", label);
04178                 gMenuHolder->childSetText("Menu Object Take", label);
04179 
04180                 return true;
04181         }
04182 };
04183 
04184 // This is a small helper function to determine if we have a buy or a
04185 // take in the selection. This method is to help with the aliasing
04186 // problems of putting buy and take in the same pie menu space. After
04187 // a fair amont of discussion, it was determined to prefer buy over
04188 // take. The reasoning follows from the fact that when users walk up
04189 // to buy something, they will click on one or more items. Thus, if
04190 // anything is for sale, it becomes a buy operation, and the server
04191 // will group all of the buy items, and copyable/modifiable items into
04192 // one package and give the end user as much as the permissions will
04193 // allow. If the user wanted to take something, they will select fewer
04194 // and fewer items until only 'takeable' items are left. The one
04195 // exception is if you own everything in the selection that is for
04196 // sale, in this case, you can't buy stuff from yourself, so you can
04197 // take it.
04198 // return value = TRUE if selection is a 'buy'.
04199 //                FALSE if selection is a 'take'
04200 BOOL is_selection_buy_not_take()
04201 {
04202         for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin();
04203                  iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++)
04204         {
04205                 LLSelectNode* node = *iter;
04206                 LLViewerObject* obj = node->getObject();
04207                 if(obj && !(obj->permYouOwner()) && (node->mSaleInfo.isForSale()))
04208                 {
04209                         // you do not own the object and it is for sale, thus,
04210                         // it's a buy
04211                         return TRUE;
04212                 }
04213         }
04214         return FALSE;
04215 }
04216 
04217 S32 selection_price()
04218 {
04219         S32 total_price = 0;
04220         for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin();
04221                  iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++)
04222         {
04223                 LLSelectNode* node = *iter;
04224                 LLViewerObject* obj = node->getObject();
04225                 if(obj && !(obj->permYouOwner()) && (node->mSaleInfo.isForSale()))
04226                 {
04227                         // you do not own the object and it is for sale.
04228                         // Add its price.
04229                         total_price += node->mSaleInfo.getSalePrice();
04230                 }
04231         }
04232 
04233         return total_price;
04234 }
04235 
04236 void callback_show_buy_currency(S32 option, void*)
04237 {
04238         if (0 == option)
04239         {
04240                 llinfos << "Loading page " << BUY_CURRENCY_URL << llendl;
04241                 LLWeb::loadURL(BUY_CURRENCY_URL);
04242         }
04243 }
04244 
04245 
04246 void show_buy_currency(const char* extra)
04247 {
04248         // Don't show currency web page for branded clients.
04249 
04250         std::ostringstream mesg;
04251         if (extra != NULL)
04252         {       
04253                 mesg << extra << "\n \n";
04254         }
04255         mesg << "Go to " << BUY_CURRENCY_URL << "\nfor information on purchasing currency?";
04256 
04257         LLString::format_map_t args;
04258         if (extra != NULL)
04259         {
04260                 args["[EXTRA]"] = extra;
04261         }
04262         args["[URL]"] = BUY_CURRENCY_URL;
04263         gViewerWindow->alertXml("PromptGoToCurrencyPage", args, 
04264                 callback_show_buy_currency);
04265 }
04266 
04267 void handle_buy_currency(void*)
04268 {
04269 //      LLFloaterBuyCurrency::buyCurrency();
04270 }
04271 
04272 void handle_buy(void*)
04273 {
04274         if (LLSelectMgr::getInstance()->getSelection()->isEmpty()) return;
04275 
04276         LLSaleInfo sale_info;
04277         BOOL valid = LLSelectMgr::getInstance()->selectGetSaleInfo(sale_info);
04278         if (!valid) return;
04279 
04280         if (sale_info.getSaleType() == LLSaleInfo::FS_CONTENTS)
04281         {
04282                 handle_buy_contents(sale_info);
04283         }
04284         else
04285         {
04286                 handle_buy_object(sale_info);
04287         }
04288 }
04289 
04290 class LLObjectBuy : public view_listener_t
04291 {
04292         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04293         {
04294                 handle_buy(NULL);
04295                 return true;
04296         }
04297 };
04298 
04299 BOOL sitting_on_selection()
04300 {
04301         LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
04302         if (!node)
04303         {
04304                 return FALSE;
04305         }
04306 
04307         if (!node->mValid)
04308         {
04309                 return FALSE;
04310         }
04311 
04312         LLViewerObject* root_object = node->getObject();
04313         if (!root_object)
04314         {
04315                 return FALSE;
04316         }
04317 
04318         // Need to determine if avatar is sitting on this object
04319         LLVOAvatar* avatar = gAgent.getAvatarObject();
04320         if (!avatar)
04321         {
04322                 return FALSE;
04323         }
04324 
04325         return (avatar->mIsSitting && avatar->getRoot() == root_object);
04326 }
04327 
04328 class LLToolsSaveToInventory : public view_listener_t
04329 {
04330         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04331         {
04332                 if(enable_save_into_inventory(NULL))
04333                 {
04334                         derez_objects(DRD_SAVE_INTO_AGENT_INVENTORY, LLUUID::null);
04335                 }
04336                 return true;
04337         }
04338 };
04339 
04340 class LLToolsSaveToObjectInventory : public view_listener_t
04341 {
04342         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04343         {
04344                 LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
04345                 if(node && (node->mValid) && (!node->mFromTaskID.isNull()))
04346                 {
04347                         // *TODO: check to see if the fromtaskid object exists.
04348                         derez_objects(DRD_SAVE_INTO_TASK_INVENTORY, node->mFromTaskID);
04349                 }
04350                 return true;
04351         }
04352 };
04353 
04354 // Round the position of all root objects to the grid
04355 class LLToolsSnapObjectXY : public view_listener_t
04356 {
04357         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04358         {
04359                 F64 snap_size = (F64)gSavedSettings.getF32("GridResolution");
04360 
04361                 for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin();
04362                          iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++)
04363                 {
04364                         LLSelectNode* node = *iter;
04365                         LLViewerObject* obj = node->getObject();
04366                         if (obj->permModify())
04367                         {
04368                                 LLVector3d pos_global = obj->getPositionGlobal();
04369                                 F64 round_x = fmod(pos_global.mdV[VX], snap_size);
04370                                 if (round_x < snap_size * 0.5)
04371                                 {
04372                                         // closer to round down
04373                                         pos_global.mdV[VX] -= round_x;
04374                                 }
04375                                 else
04376                                 {
04377                                         // closer to round up
04378                                         pos_global.mdV[VX] -= round_x;
04379                                         pos_global.mdV[VX] += snap_size;
04380                                 }
04381 
04382                                 F64 round_y = fmod(pos_global.mdV[VY], snap_size);
04383                                 if (round_y < snap_size * 0.5)
04384                                 {
04385                                         pos_global.mdV[VY] -= round_y;
04386                                 }
04387                                 else
04388                                 {
04389                                         pos_global.mdV[VY] -= round_y;
04390                                         pos_global.mdV[VY] += snap_size;
04391                                 }
04392 
04393                                 obj->setPositionGlobal(pos_global, FALSE);
04394                         }
04395                 }
04396                 LLSelectMgr::getInstance()->sendMultipleUpdate(UPD_POSITION);
04397                 return true;
04398         }
04399 };
04400 
04401 // in order to link, all objects must have the same owner, and the
04402 // agent must have the ability to modify all of the objects. However,
04403 // we're not answering that question with this method. The question
04404 // we're answering is: does the user have a reasonable expectation
04405 // that a link operation should work? If so, return true, false
04406 // otherwise. this allows the handle_link method to more finely check
04407 // the selection and give an error message when the uer has a
04408 // reasonable expectation for the link to work, but it will fail.
04409 class LLToolsEnableLink : public view_listener_t
04410 {
04411         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04412         {
04413                 bool new_value = false;
04414                 // check if there are at least 2 objects selected, and that the
04415                 // user can modify at least one of the selected objects.
04416 
04417                 // in component mode, can't link
04418                 if (!gSavedSettings.getBOOL("EditLinkedParts"))
04419                 {
04420                         if(LLSelectMgr::getInstance()->selectGetAllRootsValid() && LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() >= 2)
04421                         {
04422                                 struct f : public LLSelectedObjectFunctor
04423                                 {
04424                                         virtual bool apply(LLViewerObject* object)
04425                                         {
04426                                                 return object->permModify();
04427                                         }
04428                                 } func;
04429                                 const bool firstonly = true;
04430                                 new_value = LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func, firstonly);
04431                         }
04432                 }
04433                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04434                 return true;
04435         }
04436 };
04437 
04438 class LLToolsLink : public view_listener_t
04439 {
04440         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04441         {
04442                 if(!LLSelectMgr::getInstance()->selectGetAllRootsValid())
04443                 {
04444                         LLNotifyBox::showXml("UnableToLinkWhileDownloading");
04445                         return true;
04446                 }
04447 
04448                 S32 object_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount();
04449                 if (object_count > MAX_CHILDREN_PER_TASK + 1)
04450                 {
04451                         LLStringBase<char>::format_map_t args;
04452                         args["[COUNT]"] = llformat("%d", object_count);
04453                         int max = MAX_CHILDREN_PER_TASK+1;
04454                         args["[MAX]"] = llformat("%d", max);
04455                         gViewerWindow->alertXml("UnableToLinkObjects", args);
04456                         return true;
04457                 }
04458 
04459                 if(LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() < 2)
04460                 {
04461                         gViewerWindow->alertXml("CannotLinkIncompleteSet");
04462                         return true;
04463                 }
04464                 if(!LLSelectMgr::getInstance()->selectGetRootsModify())
04465                 {
04466                         gViewerWindow->alertXml("CannotLinkModify");
04467                         return true;
04468                 }
04469                 LLUUID owner_id;
04470                 LLString owner_name;
04471                 if(!LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name))
04472                 {
04473                         // we don't actually care if you're the owner, but novices are
04474                         // the most likely to be stumped by this one, so offer the
04475                         // easiest and most likely solution.
04476                         gViewerWindow->alertXml("CannotLinkDifferentOwners");
04477                         return true;
04478                 }
04479                 LLSelectMgr::getInstance()->sendLink();
04480                 return true;
04481         }
04482 };
04483 
04484 class LLToolsEnableUnlink : public view_listener_t
04485 {
04486         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04487         {
04488                 bool new_value = LLSelectMgr::getInstance()->selectGetAllRootsValid() &&
04489                         LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject() &&
04490                         !LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject()->isAttachment();
04491                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04492                 return true;
04493         }
04494 };
04495 
04496 class LLToolsUnlink : public view_listener_t
04497 {
04498         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04499         {
04500                 LLSelectMgr::getInstance()->sendDelink();
04501                 return true;
04502         }
04503 };
04504 
04505 
04506 class LLToolsStopAllAnimations : public view_listener_t
04507 {
04508         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04509         {
04510                 LLVOAvatar* avatarp = gAgent.getAvatarObject();
04511                 
04512                 if (!avatarp) return true;
04513                 
04514                 avatarp->deactivateAllMotions();
04515         
04516                 avatarp->processAnimationStateChanges();
04517                 return true;
04518         }
04519 };
04520 
04521 //void handle_hinge(void*)
04522 //{
04523 //      LLSelectMgr::getInstance()->sendHinge(1);
04524 //}
04525 
04526 //void handle_ptop(void*)
04527 //{
04528 //      LLSelectMgr::getInstance()->sendHinge(2);
04529 //}
04530 
04531 //void handle_lptop(void*)
04532 //{
04533 //      LLSelectMgr::getInstance()->sendHinge(3);
04534 //}
04535 
04536 //void handle_wheel(void*)
04537 //{
04538 //      LLSelectMgr::getInstance()->sendHinge(4);
04539 //}
04540 
04541 //void handle_dehinge(void*)
04542 //{
04543 //      LLSelectMgr::getInstance()->sendDehinge();
04544 //}
04545 
04546 //BOOL enable_dehinge(void*)
04547 //{
04548 //      LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject();
04549 //      return obj && !obj->isAttachment();
04550 //}
04551 
04552 
04553 class LLEditEnableCut : public view_listener_t
04554 {
04555         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04556         {
04557                 bool new_value = LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canCut();
04558                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04559                 return true;
04560         }
04561 };
04562 
04563 class LLEditCut : public view_listener_t
04564 {
04565         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04566         {
04567                 if( LLEditMenuHandler::gEditMenuHandler )
04568                 {
04569                         LLEditMenuHandler::gEditMenuHandler->cut();
04570                 }
04571                 return true;
04572         }
04573 };
04574 
04575 class LLEditEnableCopy : public view_listener_t
04576 {
04577         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04578         {
04579                 bool new_value = LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canCopy();
04580                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04581                 return true;
04582         }
04583 };
04584 
04585 class LLEditCopy : public view_listener_t
04586 {
04587         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04588         {
04589                 if( LLEditMenuHandler::gEditMenuHandler )
04590                 {
04591                         LLEditMenuHandler::gEditMenuHandler->copy();
04592                 }
04593                 return true;
04594         }
04595 };
04596 
04597 class LLEditEnablePaste : public view_listener_t
04598 {
04599         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04600         {
04601                 bool new_value = LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canPaste();
04602                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04603                 return true;
04604         }
04605 };
04606 
04607 class LLEditPaste : public view_listener_t
04608 {
04609         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04610         {
04611                 if( LLEditMenuHandler::gEditMenuHandler )
04612                 {
04613                         LLEditMenuHandler::gEditMenuHandler->paste();
04614                 }
04615                 return true;
04616         }
04617 };
04618 
04619 class LLEditEnableDelete : public view_listener_t
04620 {
04621         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04622         {
04623                 bool new_value = LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canDoDelete();
04624                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04625                 return true;
04626         }
04627 };
04628 
04629 class LLEditDelete : public view_listener_t
04630 {
04631         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04632         {
04633                 // If a text field can do a deletion, it gets precedence over deleting
04634                 // an object in the world.
04635                 if( LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canDoDelete())
04636                 {
04637                         LLEditMenuHandler::gEditMenuHandler->doDelete();
04638                 }
04639 
04640                 // and close any pie/context menus when done
04641                 gMenuHolder->hideMenus();
04642 
04643                 // When deleting an object we may not actually be done
04644                 // Keep selection so we know what to delete when confirmation is needed about the delete
04645                 gPieObject->hide(TRUE);
04646                 return true;
04647         }
04648 };
04649 
04650 class LLObjectEnableDelete : public view_listener_t
04651 {
04652         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04653         {
04654                 bool new_value = 
04655 #ifdef HACKED_GODLIKE_VIEWER
04656                         TRUE;
04657 #else
04658 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
04659                         (!LLAppViewer::instance()->isInProductionGrid()
04660              && gAgent.isGodlike()) ||
04661 # endif
04662                         LLSelectMgr::getInstance()->canDoDelete();
04663 #endif
04664                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04665                 return true;
04666         }
04667 };
04668 
04669 class LLEditSearch : public view_listener_t
04670 {
04671         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04672         {
04673                 LLFloaterDirectory::toggleFind(NULL);
04674                 return true;
04675         }
04676 };
04677 
04678 class LLObjectDelete : public view_listener_t
04679 {
04680         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04681         {
04682                 if (LLSelectMgr::getInstance())
04683                 {
04684                         LLSelectMgr::getInstance()->doDelete();
04685                 }
04686 
04687                 // and close any pie/context menus when done
04688                 gMenuHolder->hideMenus();
04689 
04690                 // When deleting an object we may not actually be done
04691                 // Keep selection so we know what to delete when confirmation is needed about the delete
04692                 gPieObject->hide(TRUE);
04693                 return true;
04694         }
04695 };
04696 
04697 void handle_force_delete(void*)
04698 {
04699         LLSelectMgr::getInstance()->selectForceDelete();
04700 }
04701 
04702 class LLViewEnableLastChatter : public view_listener_t
04703 {
04704         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04705         {
04706                 // *TODO: add check that last chatter is in range
04707                 bool new_value = (gAgent.cameraThirdPerson() && gAgent.getLastChatter().notNull());
04708                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04709                 return true;
04710         }
04711 };
04712 
04713 class LLEditEnableDeselect : public view_listener_t
04714 {
04715         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04716         {
04717                 bool new_value = LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canDeselect();
04718                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04719                 return true;
04720         }
04721 };
04722 
04723 class LLEditDeselect : public view_listener_t
04724 {
04725         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04726         {
04727                 if( LLEditMenuHandler::gEditMenuHandler )
04728                 {
04729                         LLEditMenuHandler::gEditMenuHandler->deselect();
04730                 }
04731                 return true;
04732         }
04733 };
04734 
04735 class LLEditEnableSelectAll : public view_listener_t
04736 {
04737         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04738         {
04739                 bool new_value = LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canSelectAll();
04740                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04741                 return true;
04742         }
04743 };
04744 
04745 
04746 class LLEditSelectAll : public view_listener_t
04747 {
04748         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04749         {
04750                 if( LLEditMenuHandler::gEditMenuHandler )
04751                 {
04752                         LLEditMenuHandler::gEditMenuHandler->selectAll();
04753                 }
04754                 return true;
04755         }
04756 };
04757 
04758 
04759 class LLEditEnableUndo : public view_listener_t
04760 {
04761         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04762         {
04763                 bool new_value = LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canUndo();
04764                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04765                 return true;
04766         }
04767 };
04768 
04769 class LLEditUndo : public view_listener_t
04770 {
04771         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04772         {
04773                 if( LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canUndo() )
04774                 {
04775                         LLEditMenuHandler::gEditMenuHandler->undo();
04776                 }
04777                 return true;
04778         }
04779 };
04780 
04781 class LLEditEnableRedo : public view_listener_t
04782 {
04783         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04784         {
04785                 bool new_value = LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canRedo();
04786                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04787                 return true;
04788         }
04789 };
04790 
04791 class LLEditRedo : public view_listener_t
04792 {
04793         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04794         {
04795                 if( LLEditMenuHandler::gEditMenuHandler && LLEditMenuHandler::gEditMenuHandler->canRedo() )
04796                 {
04797                         LLEditMenuHandler::gEditMenuHandler->redo();
04798                 }
04799                 return true;
04800         }
04801 };
04802 
04803 
04804 
04805 void print_object_info(void*)
04806 {
04807         LLSelectMgr::getInstance()->selectionDump();
04808 }
04809 
04810 void print_agent_nvpairs(void*)
04811 {
04812         LLViewerObject *objectp;
04813 
04814         llinfos << "Agent Name Value Pairs" << llendl;
04815 
04816         objectp = gObjectList.findObject(gAgentID);
04817         if (objectp)
04818         {
04819                 objectp->printNameValuePairs();
04820         }
04821         else
04822         {
04823                 llinfos << "Can't find agent object" << llendl;
04824         }
04825 
04826         llinfos << "Camera at " << gAgent.getCameraPositionGlobal() << llendl;
04827 }
04828 
04829 void show_debug_menus()
04830 {
04831         // this can get called at login screen where there is no menu so only toggle it if one exists
04832         if ( gMenuBarView )
04833         {
04834                 BOOL debug = gSavedSettings.getBOOL("UseDebugMenus");
04835                 
04836                 if(debug)
04837                 {
04838                         LLFirstUse::useDebugMenus();
04839                 }
04840 
04841                 gMenuBarView->setItemVisible(CLIENT_MENU_NAME, debug);
04842                 gMenuBarView->setItemEnabled(CLIENT_MENU_NAME, debug);
04843 
04844                 // Server ('Admin') menu hidden when not in godmode.
04845                 const bool show_server_menu = debug && (gAgent.getGodLevel() > GOD_NOT);
04846                 gMenuBarView->setItemVisible(SERVER_MENU_NAME, show_server_menu);
04847                 gMenuBarView->setItemEnabled(SERVER_MENU_NAME, show_server_menu);
04848 
04849                 //gMenuBarView->setItemVisible(LLString("DebugOptions"),        visible);
04850                 //gMenuBarView->setItemVisible(LLString(AVI_TOOLS),     visible);
04851 
04852                 gMenuBarView->arrange(); // clean-up positioning 
04853         };
04854 }
04855 
04856 void toggle_debug_menus(void*)
04857 {
04858         BOOL visible = ! gSavedSettings.getBOOL("UseDebugMenus");
04859         gSavedSettings.setBOOL("UseDebugMenus", visible);
04860         show_debug_menus();
04861 }
04862 
04863 
04864 void toggle_map( void* user_data )
04865 {
04866         // Toggle the item
04867         BOOL checked = gSavedSettings.getBOOL( static_cast<char*>(user_data) );
04868         gSavedSettings.setBOOL( static_cast<char*>(user_data), !checked );
04869         if (checked)
04870         {
04871                 gFloaterMap->close();
04872         }
04873         else
04874         {
04875                 gFloaterMap->open();            /* Flawfinder: ignore */        
04876         }
04877 }
04878 
04879 
04880 LLUUID gExporterRequestID;
04881 LLString gExportDirectory;
04882 
04883 LLUploadDialog *gExportDialog = NULL;
04884 
04885 void handle_export_selected( void * )
04886 {
04887         LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
04888         if (selection->isEmpty())
04889         {
04890                 return;
04891         }
04892         llinfos << "Exporting selected objects:" << llendl;
04893 
04894         gExporterRequestID.generate();
04895         gExportDirectory = "";
04896 
04897         LLMessageSystem* msg = gMessageSystem;
04898         msg->newMessageFast(_PREHASH_ObjectExportSelected);
04899         msg->nextBlockFast(_PREHASH_AgentData);
04900         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
04901         msg->addUUIDFast(_PREHASH_RequestID, gExporterRequestID);
04902         msg->addS16Fast(_PREHASH_VolumeDetail, 4);
04903 
04904         for (LLObjectSelection::root_iterator iter = selection->root_begin();
04905                  iter != selection->root_end(); iter++)
04906         {
04907                 LLSelectNode* node = *iter;
04908                 LLViewerObject* object = node->getObject();
04909                 msg->nextBlockFast(_PREHASH_ObjectData);
04910                 msg->addUUIDFast(_PREHASH_ObjectID, object->getID());
04911                 llinfos << "Object: " << object->getID() << llendl;
04912         }
04913         msg->sendReliable(gAgent.getRegion()->getHost());
04914 
04915         gExportDialog = LLUploadDialog::modalUploadDialog("Exporting selected objects...");
04916 }
04917 
04918 BOOL menu_check_build_tool( void* user_data )
04919 {
04920         S32 index = (intptr_t) user_data;
04921         return LLToolMgr::getInstance()->getCurrentToolset()->isToolSelected( index );
04922 }
04923 
04924 void handle_reload_settings(void*)
04925 {
04926         gSavedSettings.resetToDefaults();
04927         gSavedSettings.loadFromFile(gSavedSettings.getString("ClientSettingsFile"));
04928 
04929         llinfos << "Loading colors from colors.xml" << llendl;
04930         std::string color_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"colors.xml");
04931         gColors.resetToDefaults();
04932         gColors.loadFromFileLegacy(color_file, FALSE, TYPE_COL4U);
04933 }
04934 
04935 class LLWorldSetHomeLocation : public view_listener_t
04936 {
04937         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04938         {
04939                 // we just send the message and let the server check for failure cases
04940                 // server will echo back a "Home position set." alert if it succeeds
04941                 // and the home location screencapture happens when that alert is recieved
04942                 gAgent.setStartPosition(START_LOCATION_ID_HOME);
04943                 return true;
04944         }
04945 };
04946 
04947 class LLWorldTeleportHome : public view_listener_t
04948 {
04949         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04950         {
04951                 gAgent.teleportHome();
04952                 return true;
04953         }
04954 };
04955 
04956 class LLWorldAlwaysRun : public view_listener_t
04957 {
04958         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04959         {
04960                 // as well as altering the default walk-vs-run state,
04961                 // we also change the *current* walk-vs-run state.
04962                 if (gAgent.getAlwaysRun())
04963                 {
04964                         gAgent.clearAlwaysRun();
04965                         gAgent.clearRunning();
04966                 }
04967                 else
04968                 {
04969                         gAgent.setAlwaysRun();
04970                         gAgent.setRunning();
04971                 }
04972 
04973                 // tell the simulator.
04974                 gAgent.sendWalkRun(gAgent.getAlwaysRun());
04975 
04976                 return true;
04977         }
04978 };
04979 
04980 class LLWorldCheckAlwaysRun : public view_listener_t
04981 {
04982         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04983         {
04984                 bool new_value = gAgent.getAlwaysRun();
04985                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
04986                 return true;
04987         }
04988 };
04989 
04990 class LLWorldSetAway : public view_listener_t
04991 {
04992         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
04993         {
04994                 if (gAgent.getAFK())
04995                 {
04996                         gAgent.clearAFK();
04997                 }
04998                 else
04999                 {
05000                         gAgent.setAFK();
05001                 }
05002                 return true;
05003         }
05004 };
05005 
05006 class LLWorldSetBusy : public view_listener_t
05007 {
05008         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05009         {
05010                 if (gAgent.getBusy())
05011                 {
05012                         gAgent.clearBusy();
05013                 }
05014                 else
05015                 {
05016                         gAgent.setBusy();
05017                         gViewerWindow->alertXml("BusyModeSet");
05018                 }
05019                 return true;
05020         }
05021 };
05022 
05023 
05024 class LLWorldCreateLandmark : public view_listener_t
05025 {
05026         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05027         {
05028                 LLViewerRegion* agent_region = gAgent.getRegion();
05029                 if(!agent_region)
05030                 {
05031                         llwarns << "No agent region" << llendl;
05032                         return true;
05033                 }
05034                 LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
05035                 if (!agent_parcel)
05036                 {
05037                         llwarns << "No agent parcel" << llendl;
05038                         return true;
05039                 }
05040                 if (!agent_parcel->getAllowLandmark()
05041                         && !LLViewerParcelMgr::isParcelOwnedByAgent(agent_parcel, GP_LAND_ALLOW_LANDMARK))
05042                 {
05043                         gViewerWindow->alertXml("CannotCreateLandmarkNotOwner");
05044                         return true;
05045                 }
05046 
05047                 LLUUID folder_id;
05048                 folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_LANDMARK);
05049                 std::string pos_string;
05050                 gAgent.buildLocationString(pos_string);
05051                 
05052                 create_inventory_item(gAgent.getID(), gAgent.getSessionID(),
05053                                                           folder_id, LLTransactionID::tnull,
05054                                                           pos_string, pos_string, // name, desc
05055                                                           LLAssetType::AT_LANDMARK,
05056                                                           LLInventoryType::IT_LANDMARK,
05057                                                           NOT_WEARABLE, PERM_ALL, 
05058                                                           NULL);
05059                 return true;
05060         }
05061 };
05062 
05063 class LLToolsLookAtSelection : public view_listener_t
05064 {
05065         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05066         {
05067                 const F32 PADDING_FACTOR = 2.f;
05068                 BOOL zoom = (userdata.asString() == "zoom");
05069                 if (!LLSelectMgr::getInstance()->getSelection()->isEmpty())
05070                 {
05071                         gAgent.setFocusOnAvatar(FALSE, ANIMATE);
05072 
05073                         LLBBox selection_bbox = LLSelectMgr::getInstance()->getBBoxOfSelection();
05074                         F32 angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getAspect() > 1.f ? LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect() : LLViewerCamera::getInstance()->getView());
05075                         F32 distance = selection_bbox.getExtentLocal().magVec() * PADDING_FACTOR / atan(angle_of_view);
05076 
05077                         LLVector3 obj_to_cam = LLViewerCamera::getInstance()->getOrigin() - selection_bbox.getCenterAgent();
05078                         obj_to_cam.normVec();
05079 
05080                         if (zoom)
05081                         {
05082                                 gAgent.setCameraPosAndFocusGlobal(LLSelectMgr::getInstance()->getSelectionCenterGlobal() + LLVector3d(obj_to_cam * distance), LLSelectMgr::getInstance()->getSelectionCenterGlobal(), LLSelectMgr::getInstance()->getSelection()->getFirstObject()->mID );
05083                         }
05084                         else
05085                         {
05086                                 gAgent.setFocusGlobal( LLSelectMgr::getInstance()->getSelectionCenterGlobal(), LLSelectMgr::getInstance()->getSelection()->getFirstObject()->mID );
05087                         }
05088                 }
05089                 return true;
05090         }
05091 };
05092 
05093 void callback_invite_to_group(LLUUID group_id, void *user_data)
05094 {
05095         std::vector<LLUUID> agent_ids;
05096         agent_ids.push_back(*(LLUUID *)user_data);
05097         
05098         LLFloaterGroupInvite::showForGroup(group_id, &agent_ids);
05099 }
05100 
05101 void invite_to_group(const LLUUID& dest_id)
05102 {
05103         LLViewerObject* dest = gObjectList.findObject(dest_id);
05104         if(dest && dest->isAvatar())
05105         {
05106                 LLFloaterGroupPicker* widget;
05107                 widget = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID()));
05108                 if (widget)
05109                 {
05110                         widget->center();
05111                         widget->setPowersMask(GP_MEMBER_INVITE);
05112                         widget->setSelectCallback(callback_invite_to_group, (void *)&dest_id);
05113                 }
05114         }
05115 }
05116 
05117 class LLAvatarInviteToGroup : public view_listener_t
05118 {
05119         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05120         {
05121                 LLVOAvatar* avatar = find_avatar_from_object( gViewerWindow->lastObjectHit() );
05122                 if(avatar)
05123                 {
05124                         invite_to_group(avatar->getID());
05125                 }
05126                 return true;
05127         }
05128 };
05129 
05130 class LLAvatarAddFriend : public view_listener_t
05131 {
05132         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05133         {
05134                 LLVOAvatar* avatar = find_avatar_from_object( gViewerWindow->lastObjectHit() );
05135                 if(avatar && !is_agent_friend(avatar->getID()))
05136                 {
05137                         request_friendship(avatar->getID());
05138                 }
05139                 return true;
05140         }
05141 };
05142 
05143 void complete_give_money(S32 option, void* user_data)
05144 {
05145         if (option == 0)
05146         {
05147                 gAgent.clearBusy();
05148         }
05149 
05150         LLObjectSelectionHandle handle(*(LLObjectSelectionHandle*)user_data);
05151         delete (LLObjectSelectionHandle*)user_data;
05152 
05153         LLViewerObject* objectp = handle->getPrimaryObject();
05154 
05155         // Show avatar's name if paying attachment
05156         if (objectp && objectp->isAttachment())
05157         {
05158                 while (objectp && !objectp->isAvatar())
05159                 {
05160                         objectp = (LLViewerObject*)objectp->getParent();
05161                 }
05162         }
05163 
05164         if (objectp)
05165         {
05166                 if (objectp->isAvatar())
05167                 {
05168                         const BOOL is_group = FALSE;
05169                         LLFloaterPay::payDirectly(&give_money,
05170                                                                           objectp->getID(),
05171                                                                           is_group);
05172                 }
05173                 else
05174                 {
05175                         LLFloaterPay::payViaObject(&give_money, objectp->getID());
05176                 }
05177         }
05178 }
05179 
05180 bool handle_give_money_dialog()
05181 {
05182         LLObjectSelectionHandle* handlep = new LLObjectSelectionHandle(LLSelectMgr::getInstance()->getSelection());
05183         if (gAgent.getBusy())
05184         {
05185                 // warn users of being in busy mode during a transaction
05186                 gViewerWindow->alertXml("BusyModePay", complete_give_money, handlep);
05187         }
05188         else
05189         {
05190                 complete_give_money(1, handlep);
05191         }
05192         return true;
05193 }
05194 
05195 class LLPayObject : public view_listener_t
05196 {
05197         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05198         {
05199                 return handle_give_money_dialog();
05200         }
05201 };
05202 
05203 class LLEnablePayObject : public view_listener_t
05204 {
05205         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05206         {
05207                 LLVOAvatar* avatar = find_avatar_from_object(gViewerWindow->lastObjectHit());
05208                 bool new_value = (avatar != NULL);
05209                 if (!new_value)
05210                 {
05211                         LLViewerObject* object = gViewerWindow->lastObjectHit();
05212                         if( object )
05213                         {
05214                                 LLViewerObject *parent = (LLViewerObject *)object->getParent();
05215                                 if((object->flagTakesMoney()) || (parent && parent->flagTakesMoney()))
05216                                 {
05217                                         new_value = true;
05218                                 }
05219                         }
05220                 }
05221                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
05222                 return true;
05223         }
05224 };
05225 
05226 class LLObjectEnableSitOrStand : public view_listener_t
05227 {
05228         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05229         {
05230                 bool new_value = false;
05231                 LLViewerObject* dest_object = NULL;
05232                 if((dest_object = gObjectList.findObject(gLastHitObjectID)))
05233                 {
05234                         if(dest_object->getPCode() == LL_PCODE_VOLUME)
05235                         {
05236                                 new_value = true;
05237                         }
05238                 }
05239                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
05240 
05241                 // Update label
05242                 LLString label;
05243                 LLString sit_text;
05244                 LLString stand_text;
05245                 LLString param = userdata["data"].asString();
05246                 LLString::size_type offset = param.find(",");
05247                 if (offset != param.npos)
05248                 {
05249                         sit_text = param.substr(0, offset);
05250                         stand_text = param.substr(offset+1);
05251                 }
05252                 if (sitting_on_selection())
05253                 {
05254                         label = stand_text;
05255                 }
05256                 else
05257                 {
05258                         LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
05259                         if (node && node->mValid && !node->mSitName.empty())
05260                         {
05261                                 label.assign(node->mSitName);
05262                         }
05263                         else
05264                         {
05265                                 label = sit_text;
05266                         }
05267                 }
05268                 gMenuHolder->childSetText("Object Sit", label);
05269 
05270                 return true;
05271         }
05272 };
05273 
05274 void edit_ui(void*)
05275 {
05276         LLFloater::setEditModeEnabled(!LLFloater::getEditModeEnabled());
05277 }
05278 
05279 void dump_select_mgr(void*)
05280 {
05281         LLSelectMgr::getInstance()->dump();
05282 }
05283 
05284 void dump_inventory(void*)
05285 {
05286         gInventory.dumpInventory();
05287 }
05288 
05289 // forcibly unlock an object
05290 void handle_force_unlock(void*)
05291 {
05292         // First, make it public.
05293         LLSelectMgr::getInstance()->sendOwner(LLUUID::null, LLUUID::null, TRUE);
05294 
05295         // Second, lie to the viewer and mark it editable and unowned
05296 
05297         struct f : public LLSelectedObjectFunctor
05298         {
05299                 virtual bool apply(LLViewerObject* object)
05300                 {
05301                         object->mFlags |= FLAGS_OBJECT_MOVE;
05302                         object->mFlags |= FLAGS_OBJECT_MODIFY;
05303                         object->mFlags |= FLAGS_OBJECT_COPY;
05304 
05305                         object->mFlags &= ~FLAGS_OBJECT_ANY_OWNER;
05306                         object->mFlags &= ~FLAGS_OBJECT_YOU_OWNER;
05307                         return true;
05308                 }
05309         } func;
05310         LLSelectMgr::getInstance()->getSelection()->applyToObjects(&func);
05311 }
05312 
05313 void handle_dump_followcam(void*)
05314 {
05315         LLFollowCamMgr::dump();
05316 }
05317 
05318 void handle_viewer_enable_message_log(void*)
05319 {
05320         gMessageSystem->startLogging();
05321 }
05322 
05323 void handle_viewer_disable_message_log(void*)
05324 {
05325         gMessageSystem->stopLogging();
05326 }
05327 
05328 // TomY TODO: Move!
05329 class LLShowFloater : public view_listener_t
05330 {
05331         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05332         {
05333                 LLString floater_name = userdata.asString();
05334                 if (floater_name == "gestures")
05335                 {
05336                         LLFloaterGesture::toggleVisibility();
05337                 }
05338                 else if (floater_name == "appearance")
05339                 {
05340                         if (gAgent.getWearablesLoaded())
05341                         {
05342                                 gAgent.changeCameraToCustomizeAvatar();
05343                         }
05344                 }
05345                 else if (floater_name == "friends")
05346                 {
05347                         LLFloaterMyFriends::toggleInstance(0);
05348                 }
05349                 else if (floater_name == "preferences")
05350                 {
05351                         LLFloaterPreference::show(NULL);
05352                 }
05353                 else if (floater_name == "toolbar")
05354                 {
05355                         LLToolBar::toggle(NULL);
05356                 }
05357                 else if (floater_name == "chat history")
05358                 {
05359                         LLFloaterChat::toggleInstance(LLSD());
05360                 }
05361                 else if (floater_name == "im")
05362                 {
05363                         LLFloaterChatterBox::toggleInstance(LLSD());
05364                 }
05365                 else if (floater_name == "inventory")
05366                 {
05367                         LLInventoryView::toggleVisibility(NULL);
05368                 }
05369                 else if (floater_name == "mute list")
05370                 {
05371                         LLFloaterMute::toggleInstance();
05372                 }
05373                 else if (floater_name == "camera controls")
05374                 {
05375                         LLFloaterCamera::toggleInstance();
05376                 }
05377                 else if (floater_name == "movement controls")
05378                 {
05379                         LLFloaterMove::toggleInstance();
05380                 }
05381                 else if (floater_name == "world map")
05382                 {
05383                         LLFloaterWorldMap::toggle(NULL);
05384                 }
05385                 else if (floater_name == "mini map")
05386                 {
05387                         LLFloaterMap::toggle(NULL);
05388                 }
05389                 else if (floater_name == "stat bar")
05390                 {
05391                         gDebugView->mFloaterStatsp->setVisible(!gDebugView->mFloaterStatsp->getVisible());
05392                 }
05393                 else if (floater_name == "my land")
05394                 {
05395                         LLFloaterLandHoldings::show(NULL);
05396                 }
05397                 else if (floater_name == "about land")
05398                 {
05399                         if (LLViewerParcelMgr::getInstance()->selectionEmpty())
05400                         {
05401                                 LLViewerParcelMgr::getInstance()->selectParcelAt(gAgent.getPositionGlobal());
05402                         }
05403 
05404                         LLFloaterLand::showInstance();
05405                 }
05406                 else if (floater_name == "buy land")
05407                 {
05408                         if (LLViewerParcelMgr::getInstance()->selectionEmpty())
05409                         {
05410                                 LLViewerParcelMgr::getInstance()->selectParcelAt(gAgent.getPositionGlobal());
05411                         }
05412                         
05413                         LLViewerParcelMgr::getInstance()->startBuyLand();
05414                 }
05415                 else if (floater_name == "about region")
05416                 {
05417                         LLFloaterRegionInfo::showInstance();
05418                 }
05419                 else if (floater_name == "grid options")
05420                 {
05421                         LLFloaterBuildOptions::show(NULL);
05422                 }
05423                 else if (floater_name == "script errors")
05424                 {
05425                         LLFloaterScriptDebug::show(LLUUID::null);
05426                 }
05427                 else if (floater_name == "help f1")
05428                 {
05429                         gViewerHtmlHelp.show();
05430                 }
05431                 else if (floater_name == "help tutorial")
05432                 {
05433                         LLFloaterHUD::show();
05434                 }
05435                 else if (floater_name == "complaint reporter")
05436                 {
05437                         // Prevent menu from appearing in screen shot.
05438                         gMenuHolder->hideMenus();
05439                         LLFloaterReporter::showFromMenu(COMPLAINT_REPORT);
05440                 }
05441                 else if (floater_name == "mean events")
05442                 {
05443                         if (!gNoRender)
05444                         {
05445                                 LLFloaterBump::show(NULL);
05446                         }
05447                 }
05448                 else if (floater_name == "lag meter")
05449                 {
05450                         LLFloaterLagMeter::showInstance();
05451                 }
05452                 else if (floater_name == "bug reporter")
05453                 {
05454                         // Prevent menu from appearing in screen shot.
05455                         gMenuHolder->hideMenus();
05456                         LLFloaterReporter::showFromMenu(BUG_REPORT);
05457                 }
05458                 else if (floater_name == "buy currency")
05459                 {
05460                         LLFloaterBuyCurrency::buyCurrency();
05461                 }
05462                 else if (floater_name == "about")
05463                 {
05464                         LLFloaterAbout::show(NULL);
05465                 }
05466                 else if (floater_name == "active speakers")
05467                 {
05468                         LLFloaterActiveSpeakers::toggleInstance(LLSD());
05469                 }
05470                 return true;
05471         }
05472 };
05473 
05474 class LLFloaterVisible : public view_listener_t
05475 {
05476         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05477         {
05478                 LLString control_name = userdata["control"].asString();
05479                 LLString floater_name = userdata["data"].asString();
05480                 bool new_value = false;
05481                 if (floater_name == "friends")
05482                 {
05483                         new_value = LLFloaterMyFriends::instanceVisible(0);
05484                 }
05485                 else if (floater_name == "toolbar")
05486                 {
05487                         new_value = LLToolBar::visible(NULL);
05488                 }
05489                 else if (floater_name == "chat history")
05490                 {
05491                         new_value = LLFloaterChat::instanceVisible();
05492                 }
05493                 else if (floater_name == "im")
05494                 {
05495                         new_value = LLFloaterMyFriends::instanceVisible(0);
05496                 }
05497                 else if (floater_name == "mute list")
05498                 {
05499                         new_value = LLFloaterMute::instanceVisible();
05500                 }
05501                 else if (floater_name == "camera controls")
05502                 {
05503                         new_value = LLFloaterCamera::instanceVisible();
05504                 }
05505                 else if (floater_name == "movement controls")
05506                 {
05507                         new_value = LLFloaterMove::instanceVisible();
05508                 }
05509                 else if (floater_name == "stat bar")
05510                 {
05511                         new_value = gDebugView->mFloaterStatsp->getVisible();
05512                 }
05513                 else if (floater_name == "active speakers")
05514                 {
05515                         new_value = LLFloaterActiveSpeakers::instanceVisible(LLSD());
05516                 }
05517                 gMenuHolder->findControl(control_name)->setValue(new_value);
05518                 return true;
05519         }
05520 };
05521 
05522 void callback_show_url(S32 option, void* url)
05523 {
05524         const char* urlp = (const char*)url;
05525         if (0 == option)
05526         {
05527                 LLWeb::loadURL(urlp);
05528         }
05529         delete urlp;
05530 }
05531 
05532 class LLPromptShowURL : public view_listener_t
05533 {
05534         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05535         {
05536                 LLString param = userdata.asString();
05537                 LLString::size_type offset = param.find(",");
05538                 if (offset != param.npos)
05539                 {
05540                         LLString alert = param.substr(0, offset);
05541                         LLString url = param.substr(offset+1);
05542                         char *url_copy = new char[url.size()+1];
05543                         if (url_copy != NULL)
05544                         {
05545                                 strcpy(url_copy, url.c_str());          /* Flawfinder: ignore */
05546                         }
05547                         else
05548                         {
05549                                 llerrs << "Memory Allocation Failed" << llendl;
05550                                 return false;
05551                         }
05552                         gViewerWindow->alertXml(alert, callback_show_url, url_copy);
05553                 }
05554                 else
05555                 {
05556                         llinfos << "PromptShowURL invalid parameters! Expecting \"ALERT,URL\"." << llendl;
05557                 }
05558                 return true;
05559         }
05560 };
05561 
05562 void callback_show_file(S32 option, void* filename)
05563 {
05564         const char* filenamep = (const char*)filename;
05565         if (0 == option)
05566         {
05567                 load_url_local_file(filenamep);
05568         }
05569         delete filenamep;
05570 }
05571 
05572 class LLPromptShowFile : public view_listener_t
05573 {
05574         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05575         {
05576                 LLString param = userdata.asString();
05577                 LLString::size_type offset = param.find(",");
05578                 if (offset != param.npos)
05579                 {
05580                         LLString alert = param.substr(0, offset);
05581                         LLString file = param.substr(offset+1);
05582                         char *file_copy = new char[file.size()+1];
05583                         if (file_copy != NULL)
05584                         {
05585                                 strcpy(file_copy, file.c_str());                /* Flawfinder: ignore */
05586                         }
05587                         else
05588                         {
05589                                 llerrs << "Memory Allocation Failed" << llendl;
05590                                 return false;
05591                         }
05592                         gViewerWindow->alertXml(alert, callback_show_file, file_copy);
05593                 }
05594                 else
05595                 {
05596                         llinfos << "PromptShowFile invalid parameters! Expecting \"ALERT,FILE\"." << llendl;
05597                 }
05598                 return true;
05599         }
05600 };
05601 
05602 class LLShowAgentProfile : public view_listener_t
05603 {
05604         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05605         {
05606                 LLUUID agent_id;
05607                 if (userdata.asString() == "agent")
05608                 {
05609                         agent_id = gAgent.getID();
05610                 }
05611                 else if (userdata.asString() == "hit object")
05612                 {
05613                         agent_id = gLastHitObjectID;
05614                 }
05615                 else
05616                 {
05617                         agent_id = userdata.asUUID();
05618                 }
05619 
05620                 LLVOAvatar* avatar = find_avatar_from_object(agent_id);
05621                 if (avatar)
05622                 {
05623                         LLFloaterAvatarInfo::show( avatar->getID() );
05624                 }
05625                 return true;
05626         }
05627 };
05628 
05629 class LLShowAgentGroups : public view_listener_t
05630 {
05631         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05632         {
05633                 LLFloaterMyFriends::toggleInstance(1);
05634                 return true;
05635         }
05636 };
05637 
05638 void handle_focus(void *)
05639 {
05640         if (gDisconnected)
05641         {
05642                 return;
05643         }
05644 
05645         if (gAgent.getFocusOnAvatar())
05646         {
05647                 // zoom in if we're looking at the avatar
05648                 gAgent.setFocusOnAvatar(FALSE, ANIMATE);
05649                 gAgent.setFocusGlobal(gLastHitPosGlobal + gLastHitObjectOffset, gLastHitObjectID);
05650                 gAgent.cameraZoomIn(0.666f);
05651         }
05652         else
05653         {
05654                 gAgent.setFocusGlobal(gLastHitPosGlobal + gLastHitObjectOffset, gLastHitObjectID);
05655         }
05656 
05657         gViewerWindow->moveCursorToCenter();
05658 
05659         // Switch to camera toolset
05660 //      LLToolMgr::getInstance()->setCurrentToolset(gCameraToolset);
05661         LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolCamera::getInstance() );
05662 }
05663 
05664 class LLLandEdit : public view_listener_t
05665 {
05666         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05667         {
05668                 if (gAgent.getFocusOnAvatar() && gSavedSettings.getBOOL("EditCameraMovement") )
05669                 {
05670                         // zoom in if we're looking at the avatar
05671                         gAgent.setFocusOnAvatar(FALSE, ANIMATE);
05672                         gAgent.setFocusGlobal(gLastHitPosGlobal + gLastHitObjectOffset, gLastHitObjectID);
05673 
05674                         gAgent.cameraOrbitOver( F_PI * 0.25f );
05675                         gViewerWindow->moveCursorToCenter();
05676                 }
05677                 else if ( gSavedSettings.getBOOL("EditCameraMovement") )
05678                 {
05679                         gAgent.setFocusGlobal(gLastHitPosGlobal + gLastHitObjectOffset, gLastHitObjectID);
05680                         gViewerWindow->moveCursorToCenter();
05681                 }
05682 
05683 
05684                 LLViewerParcelMgr::getInstance()->selectParcelAt( gLastHitPosGlobal );
05685 
05686                 gFloaterTools->showMore(TRUE);
05687                 gFloaterView->bringToFront( gFloaterTools );
05688 
05689                 // Switch to land edit toolset
05690                 LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolSelectLand::getInstance() );
05691                 return true;
05692         }
05693 };
05694 
05695 class LLWorldEnableBuyLand : public view_listener_t
05696 {
05697         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05698         {
05699                 bool new_value = LLViewerParcelMgr::getInstance()->canAgentBuyParcel(
05700                                                                 LLViewerParcelMgr::getInstance()->selectionEmpty()
05701                                                                         ? LLViewerParcelMgr::getInstance()->getAgentParcel()
05702                                                                         : LLViewerParcelMgr::getInstance()->getParcelSelection()->getParcel(),
05703                                                                 false);
05704                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
05705                 return true;
05706         }
05707 };
05708 
05709 BOOL enable_buy_land(void*)
05710 {
05711         return LLViewerParcelMgr::getInstance()->canAgentBuyParcel(
05712                                 LLViewerParcelMgr::getInstance()->getParcelSelection()->getParcel(), false);
05713 }
05714 
05715 
05716 void handle_move(void*)
05717 {
05718         if (gAgent.getFocusOnAvatar())
05719         {
05720                 // zoom in if we're looking at the avatar
05721                 gAgent.setFocusOnAvatar(FALSE, ANIMATE);
05722                 gAgent.setFocusGlobal(gLastHitPosGlobal + gLastHitObjectOffset, gLastHitObjectID);
05723 
05724                 gAgent.cameraZoomIn(0.666f);
05725         }
05726         else
05727         {
05728                 gAgent.setFocusGlobal(gLastHitPosGlobal + gLastHitObjectOffset, gLastHitObjectID);
05729         }
05730 
05731         gViewerWindow->moveCursorToCenter();
05732 
05733         LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
05734         LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolGrab::getInstance() );
05735 }
05736 
05737 class LLObjectAttachToAvatar : public view_listener_t
05738 {
05739 public:
05740         static void setObjectSelection(LLObjectSelectionHandle selection) { sObjectSelection = selection; }
05741 
05742 private:
05743         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05744         {
05745                 setObjectSelection(LLSelectMgr::getInstance()->getSelection());
05746                 LLViewerObject* selectedObject = sObjectSelection->getFirstRootObject();
05747                 if (selectedObject)
05748                 {
05749                         S32 index = userdata.asInteger();
05750                         LLViewerJointAttachment* attachment_point = NULL;
05751                         if (index > 0)
05752                                 attachment_point = get_if_there(gAgent.getAvatarObject()->mAttachmentPoints, index, (LLViewerJointAttachment*)NULL);
05753                         confirm_replace_attachment(0, attachment_point);
05754                 }
05755                 return true;
05756         }
05757 
05758 protected:
05759         static LLObjectSelectionHandle sObjectSelection;
05760 };
05761 
05762 LLObjectSelectionHandle LLObjectAttachToAvatar::sObjectSelection;
05763 
05764 void near_attach_object(BOOL success, void *user_data)
05765 {
05766         if (success)
05767         {
05768                 LLViewerJointAttachment *attachment = (LLViewerJointAttachment *)user_data;
05769                 
05770                 U8 attachment_id = 0;
05771                 if (attachment)
05772                 {
05773                         for (LLVOAvatar::attachment_map_t::iterator iter = gAgent.getAvatarObject()->mAttachmentPoints.begin();
05774                                  iter != gAgent.getAvatarObject()->mAttachmentPoints.end(); ++iter)
05775                         {
05776                                 if (iter->second == attachment)
05777                                 {
05778                                         attachment_id = iter->first;
05779                                         break;
05780                                 }
05781                         }
05782                 }
05783                 else
05784                 {
05785                         // interpret 0 as "default location"
05786                         attachment_id = 0;
05787                 }
05788                 LLSelectMgr::getInstance()->sendAttach(attachment_id);
05789         }               
05790         LLObjectAttachToAvatar::setObjectSelection(NULL);
05791 }
05792 
05793 void confirm_replace_attachment(S32 option, void* user_data)
05794 {
05795         if (option == 0/*YES*/)
05796         {
05797                 LLViewerObject* selectedObject = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject();
05798                 if (selectedObject)
05799                 {
05800                         const F32 MIN_STOP_DISTANCE = 1.f;      // meters
05801                         const F32 ARM_LENGTH = 0.5f;            // meters
05802                         const F32 SCALE_FUDGE = 1.5f;
05803 
05804                         F32 stop_distance = SCALE_FUDGE * selectedObject->getMaxScale() + ARM_LENGTH;
05805                         if (stop_distance < MIN_STOP_DISTANCE)
05806                         {
05807                                 stop_distance = MIN_STOP_DISTANCE;
05808                         }
05809 
05810                         LLVector3 walkToSpot = selectedObject->getPositionAgent();
05811                         
05812                         // make sure we stop in front of the object
05813                         LLVector3 delta = walkToSpot - gAgent.getPositionAgent();
05814                         delta.normVec();
05815                         delta = delta * 0.5f;
05816                         walkToSpot -= delta;
05817 
05818                         gAgent.startAutoPilotGlobal(gAgent.getPosGlobalFromAgent(walkToSpot), "Attach", NULL, near_attach_object, user_data, stop_distance);
05819                         gAgent.clearFocusObject();
05820                 }
05821         }
05822 }
05823 
05824 class LLAttachmentDrop : public view_listener_t
05825 {
05826         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05827         {
05828                 // Called when the user clicked on an object attached to them
05829                 // and selected "Drop".
05830                 LLViewerObject *object = gViewerWindow->lastObjectHit();
05831                 if (!object)
05832                 {
05833                         llwarns << "handle_drop_attachment() - no object to drop" << llendl;
05834                         return true;
05835                 }
05836 
05837                 LLViewerObject *parent = (LLViewerObject*)object->getParent();
05838                 while (parent)
05839                 {
05840                         if(parent->isAvatar())
05841                         {
05842                                 break;
05843                         }
05844                         object = parent;
05845                         parent = (LLViewerObject*)parent->getParent();
05846                 }
05847 
05848                 if (!object)
05849                 {
05850                         llwarns << "handle_detach() - no object to detach" << llendl;
05851                         return true;
05852                 }
05853 
05854                 if (object->isAvatar())
05855                 {
05856                         llwarns << "Trying to detach avatar from avatar." << llendl;
05857                         return true;
05858                 }
05859 
05860                 // The sendDropAttachment() method works on the list of selected
05861                 // objects.  Thus we need to clear the list, make sure it only
05862                 // contains the object the user clicked, send the message,
05863                 // then clear the list.
05864                 LLSelectMgr::getInstance()->sendDropAttachment();
05865                 return true;
05866         }
05867 };
05868 
05869 // called from avatar pie menu
05870 void handle_detach_from_avatar(void* user_data)
05871 {
05872         LLViewerJointAttachment *attachment = (LLViewerJointAttachment *)user_data;
05873         
05874         LLViewerObject* attached_object = attachment->getObject();
05875 
05876         if (attached_object)
05877         {
05878                 gMessageSystem->newMessage("ObjectDetach");
05879                 gMessageSystem->nextBlockFast(_PREHASH_AgentData);
05880                 gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
05881                 gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
05882 
05883                 gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
05884                 gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, attached_object->getLocalID());
05885                 gMessageSystem->sendReliable( gAgent.getRegionHost() );
05886         }
05887 }
05888 
05889 void attach_label(LLString& label, void* user_data)
05890 {
05891         LLViewerJointAttachment* attachmentp = (LLViewerJointAttachment*)user_data;
05892         if (attachmentp)
05893         {
05894                 label = attachmentp->getName();
05895                 if (attachmentp->getObject())
05896                 {
05897                         LLViewerInventoryItem* itemp = gInventory.getItem(attachmentp->getItemID());
05898                         if (itemp)
05899                         {
05900                                 label += LLString(" (") + itemp->getName() + LLString(")");
05901                         }
05902                 }
05903         }
05904 }
05905 
05906 void detach_label(LLString& label, void* user_data)
05907 {
05908         LLViewerJointAttachment* attachmentp = (LLViewerJointAttachment*)user_data;
05909         if (attachmentp)
05910         {
05911                 label = attachmentp->getName();
05912                 if (attachmentp->getObject())
05913                 {
05914                         LLViewerInventoryItem* itemp = gInventory.getItem(attachmentp->getItemID());
05915                         if (itemp)
05916                         {
05917                                 label += LLString(" (") + itemp->getName() + LLString(")");
05918                         }
05919                 }
05920         }
05921 }
05922 
05923 
05924 class LLAttachmentDetach : public view_listener_t
05925 {
05926         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05927         {
05928                 // Called when the user clicked on an object attached to them
05929                 // and selected "Detach".
05930                 LLViewerObject *object = gViewerWindow->lastObjectHit();
05931                 if (!object)
05932                 {
05933                         llwarns << "handle_detach() - no object to detach" << llendl;
05934                         return true;
05935                 }
05936 
05937                 LLViewerObject *parent = (LLViewerObject*)object->getParent();
05938                 while (parent)
05939                 {
05940                         if(parent->isAvatar())
05941                         {
05942                                 break;
05943                         }
05944                         object = parent;
05945                         parent = (LLViewerObject*)parent->getParent();
05946                 }
05947 
05948                 if (!object)
05949                 {
05950                         llwarns << "handle_detach() - no object to detach" << llendl;
05951                         return true;
05952                 }
05953 
05954                 if (object->isAvatar())
05955                 {
05956                         llwarns << "Trying to detach avatar from avatar." << llendl;
05957                         return true;
05958                 }
05959 
05960                 // The sendDetach() method works on the list of selected
05961                 // objects.  Thus we need to clear the list, make sure it only
05962                 // contains the object the user clicked, send the message,
05963                 // then clear the list.
05964                 // We use deselectAll to update the simulator's notion of what's
05965                 // selected, and removeAll just to change things locally.
05966                 //RN: I thought it was more useful to detach everything that was selected
05967                 if (LLSelectMgr::getInstance()->getSelection()->isAttachment())
05968                 {
05969                         LLSelectMgr::getInstance()->sendDetach();
05970                 }
05971                 return true;
05972         }
05973 };
05974 
05975 //Adding an observer for a Jira 2422 and needs to be a fetch observer
05976 //for Jira 3119
05977 class LLWornItemFetchedObserver : public LLInventoryFetchObserver
05978 {
05979 public:
05980         LLWornItemFetchedObserver() {}
05981         virtual ~LLWornItemFetchedObserver() {}
05982 
05983 protected:
05984         virtual void done()
05985         {
05986                 gPieAttachment->buildDrawLabels();
05987                 gInventory.removeObserver(this);
05988                 delete this;
05989         }
05990 };
05991 
05992 // You can only drop items on parcels where you can build.
05993 class LLAttachmentEnableDrop : public view_listener_t
05994 {
05995         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
05996         {
05997                 LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
05998                 BOOL can_build   = gAgent.isGodlike() || (parcel && parcel->getAllowModify());
05999 
06000                 //Add an inventory observer to only allow dropping the newly attached item
06001                 //once it exists in your inventory.  Look at Jira 2422.
06002                 //-jwolk
06003 
06004                 // A bug occurs when you wear/drop an item before it actively is added to your inventory
06005                 // if this is the case (you're on a slow sim, etc.) a copy of the object,
06006                 // well, a newly created object with the same properties, is placed
06007                 // in your inventory.  Therefore, we disable the drop option until the
06008                 // item is in your inventory
06009 
06010                 LLViewerObject*              object         = gViewerWindow->lastObjectHit();
06011                 LLViewerJointAttachment*     attachment_pt  = NULL;
06012                 LLInventoryItem*             item           = NULL;
06013 
06014                 if ( object )
06015                 {
06016                 S32 attachmentID  = ATTACHMENT_ID_FROM_STATE(object->getState());
06017                         attachment_pt = get_if_there(gAgent.getAvatarObject()->mAttachmentPoints, attachmentID, (LLViewerJointAttachment*)NULL);
06018 
06019                         if ( attachment_pt )
06020                         {
06021                                 // make sure item is in your inventory (it could be a delayed attach message being sent from the sim)
06022                                 // so check to see if the item is in the inventory already
06023                                 item = gInventory.getItem(attachment_pt->getItemID());
06024                                 
06025                                 if ( !item )
06026                                 {
06027                                         // Item does not exist, make an observer to enable the pie menu 
06028                                         // when the item finishes fetching worst case scenario 
06029                                         // if a fetch is already out there (being sent from a slow sim)
06030                                         // we refetch and there are 2 fetches
06031                                         LLWornItemFetchedObserver* wornItemFetched = new LLWornItemFetchedObserver();
06032                                         LLInventoryFetchObserver::item_ref_t items; //add item to the inventory item to be fetched
06033 
06034                                         items.push_back(attachment_pt->getItemID());
06035                                 
06036                                         wornItemFetched->fetchItems(items);
06037                                         gInventory.addObserver(wornItemFetched);
06038                                 }
06039                         }
06040                 }
06041                 
06042                 //now check to make sure that the item is actually in the inventory before we enable dropping it
06043                 bool new_value = enable_detach(NULL) && can_build && item;
06044 
06045                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
06046                 return true;
06047         }
06048 };
06049 
06050 BOOL enable_detach(void*)
06051 {
06052         LLViewerObject* object = gViewerWindow->lastObjectHit();
06053         if (!object) return FALSE;
06054         if (!object->isAttachment()) return FALSE;
06055 
06056         // Find the avatar who owns this attachment
06057         LLViewerObject* avatar = object;
06058         while (avatar)
06059         {
06060                 // ...if it's you, good to detach
06061                 if (avatar->getID() == gAgent.getID())
06062                 {
06063                         return TRUE;
06064                 }
06065 
06066                 avatar = (LLViewerObject*)avatar->getParent();
06067         }
06068 
06069         return FALSE;
06070 }
06071 
06072 class LLAttachmentEnableDetach : public view_listener_t
06073 {
06074         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06075         {
06076                 bool new_value = enable_detach(NULL);
06077                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
06078                 return true;
06079         }
06080 };
06081 
06082 // Used to tell if the selected object can be attached to your avatar.
06083 BOOL object_selected_and_point_valid(void *user_data)
06084 {
06085         //LLViewerJointAttachment *attachment = (LLViewerJointAttachment *)user_data;
06086         LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
06087         for (LLObjectSelection::root_iterator iter = selection->root_begin();
06088                  iter != selection->root_end(); iter++)
06089         {
06090                 LLSelectNode* node = *iter;
06091                 LLViewerObject* object = node->getObject();
06092                 for (U32 child_num = 0; child_num < object->mChildList.size(); child_num++ )
06093                 {
06094                         if (object->mChildList[child_num]->isAvatar())
06095                         {
06096                                 return FALSE;
06097                         }
06098                 }
06099         }
06100 
06101         return (selection->getRootObjectCount() == 1) && 
06102                 (selection->getFirstRootObject()->getPCode() == LL_PCODE_VOLUME) && 
06103                 selection->getFirstRootObject()->permYouOwner() &&
06104                 !((LLViewerObject*)selection->getFirstRootObject()->getRoot())->isAvatar() && 
06105                 (selection->getFirstRootObject()->getNVPair("AssetContainer") == NULL);
06106 }
06107 
06108 
06109 BOOL object_is_wearable()
06110 {
06111         if (!object_selected_and_point_valid(NULL))
06112         {
06113                 return FALSE;
06114         }
06115         if (sitting_on_selection())
06116         {
06117                 return FALSE;
06118         }
06119         LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
06120         for (LLObjectSelection::valid_root_iterator iter = LLSelectMgr::getInstance()->getSelection()->valid_root_begin();
06121                  iter != LLSelectMgr::getInstance()->getSelection()->valid_root_end(); iter++)
06122         {
06123                 LLSelectNode* node = *iter;             
06124                 if (node->mPermissions->getOwner() == gAgent.getID())
06125                 {
06126                         return TRUE;
06127                 }
06128         }
06129         return FALSE;
06130 }
06131 
06132 
06133 // Also for seeing if object can be attached.  See above.
06134 class LLObjectEnableWear : public view_listener_t
06135 {
06136         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06137         {
06138                 bool is_wearable = object_selected_and_point_valid(NULL);
06139                 gMenuHolder->findControl(userdata["control"].asString())->setValue(is_wearable);
06140                 return TRUE;
06141         }
06142 };
06143 
06144 
06145 BOOL object_attached(void *user_data)
06146 {
06147         LLViewerJointAttachment *attachment = (LLViewerJointAttachment *)user_data;
06148 
06149         return attachment->getObject() != NULL;
06150 }
06151 
06152 class LLAvatarSendIM : public view_listener_t
06153 {
06154         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06155         {
06156                 LLVOAvatar* avatar = find_avatar_from_object( gViewerWindow->lastObjectHit() );
06157                 if(avatar)
06158                 {
06159                         LLString name("IM");
06160                         LLNameValue *first = avatar->getNVPair("FirstName");
06161                         LLNameValue *last = avatar->getNVPair("LastName");
06162                         if (first && last)
06163                         {
06164                                 name.assign( first->getString() );
06165                                 name.append(" ");
06166                                 name.append( last->getString() );
06167                         }
06168 
06169                         gIMMgr->setFloaterOpen(TRUE);
06170                         //EInstantMessage type = have_agent_callingcard(gLastHitObjectID)
06171                         //      ? IM_SESSION_ADD : IM_SESSION_CARDLESS_START;
06172                         gIMMgr->addSession(name,
06173                                                                 IM_NOTHING_SPECIAL,
06174                                                                 avatar->getID());
06175                 }
06176                 return true;
06177         }
06178 };
06179 
06180 
06181 void handle_activate(void*)
06182 {
06183 }
06184 
06185 BOOL enable_activate(void*)
06186 {
06187         return FALSE;
06188 }
06189 
06190 namespace
06191 {
06192         struct QueueObjects : public LLSelectedObjectFunctor
06193         {
06194                 BOOL scripted;
06195                 BOOL modifiable;
06196                 LLFloaterScriptQueue* mQueue;
06197                 QueueObjects(LLFloaterScriptQueue* q) : mQueue(q), scripted(FALSE), modifiable(FALSE) {}
06198                 virtual bool apply(LLViewerObject* obj)
06199                 {
06200                         scripted = obj->flagScripted();
06201                         modifiable = obj->permModify();
06202 
06203                         if( scripted && modifiable )
06204                         {
06205                                 mQueue->addObject(obj->getID());
06206                                 return false;
06207                         }
06208                         else
06209                         {
06210                                 return true; // fail: stop applying
06211                         }
06212                 }
06213         };
06214 }
06215 
06216 void queue_actions(LLFloaterScriptQueue* q, const std::string& noscriptmsg, const std::string& nomodmsg)
06217 {
06218         // Apply until an object fails
06219         QueueObjects func(q);
06220         const bool firstonly = true;
06221         bool fail = LLSelectMgr::getInstance()->getSelection()->applyToObjects(&func, firstonly);
06222         if(fail)
06223         {
06224                 if ( !func.scripted )
06225                 {
06226                         gViewerWindow->alertXml(noscriptmsg);
06227                 }
06228                 else if ( !func.modifiable )
06229                 {
06230                         gViewerWindow->alertXml(nomodmsg);
06231                 }
06232                 else
06233                 {
06234                         llerrs << "Bad logic." << llendl;
06235                 }
06236         }
06237         else
06238         {
06239                 if (!q->start())
06240                 {
06241                         llwarns << "Unexpected script compile failure." << llendl;
06242                 }
06243         }
06244 }
06245 
06246 class LLToolsSelectedScriptAction : public view_listener_t
06247 {
06248         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06249         {
06250                 LLString action = userdata.asString();
06251                 LLFloaterScriptQueue* queue = NULL;
06252                 if (action == "compile")
06253                 {
06254                         queue = LLFloaterCompileQueue::create();
06255                 }
06256                 else if (action == "reset")
06257                 {
06258                         queue = LLFloaterResetQueue::create();
06259                 }
06260                 else if (action == "start")
06261                 {
06262                         queue = LLFloaterRunQueue::create();
06263                 }
06264                 else if (action == "stop")
06265                 {
06266                         queue = LLFloaterNotRunQueue::create();
06267                 }
06268                 if (!queue)
06269                 {
06270                         return true;
06271                 }
06272 
06273                 queue_actions(queue, "CannotRecompileSelectObjectsNoScripts", "CannotRecompileSelectObjectsNoPermission");
06274 
06275                 return true;
06276         }
06277 };
06278 
06279 void handle_reset_selection(void*)
06280 {
06281         LLFloaterResetQueue* queue = LLFloaterResetQueue::create();
06282         queue_actions(queue, "CannotResetSelectObjectsNoScripts", "CannotResetSelectObjectsNoPermission");
06283 }
06284 
06285 void handle_set_run_selection(void*)
06286 {
06287         LLFloaterRunQueue* queue = LLFloaterRunQueue::create();
06288         queue_actions(queue, "CannotSetRunningSelectObjectsNoScripts", "CannotSerRunningSelectObjectsNoPermission");
06289 }
06290 
06291 void handle_set_not_run_selection(void*)
06292 {
06293         LLFloaterNotRunQueue* queue = LLFloaterNotRunQueue::create();
06294         queue_actions(queue, "CannotSetRunningNotSelectObjectsNoScripts", "CannotSerRunningNotSelectObjectsNoPermission");
06295 }
06296 
06297 void handle_selected_texture_info(void*)
06298 {
06299         for (LLObjectSelection::valid_iterator iter = LLSelectMgr::getInstance()->getSelection()->valid_begin();
06300                  iter != LLSelectMgr::getInstance()->getSelection()->valid_end(); iter++)
06301         {
06302                 LLSelectNode* node = *iter;
06303                 
06304                 std::string msg;
06305                 msg.assign("Texture info for: ");
06306                 msg.append(node->mName);
06307                 LLChat chat(msg);
06308                 LLFloaterChat::addChat(chat);
06309 
06310                 U8 te_count = node->getObject()->getNumTEs();
06311                 // map from texture ID to list of faces using it
06312                 typedef std::map< LLUUID, std::vector<U8> > map_t;
06313                 map_t faces_per_texture;
06314                 for (U8 i = 0; i < te_count; i++)
06315                 {
06316                         if (!node->isTESelected(i)) continue;
06317 
06318                         LLViewerImage* img = node->getObject()->getTEImage(i);
06319                         LLUUID image_id = img->getID();
06320                         faces_per_texture[image_id].push_back(i);
06321                 }
06322                 // Per-texture, dump which faces are using it.
06323                 map_t::iterator it;
06324                 for (it = faces_per_texture.begin(); it != faces_per_texture.end(); ++it)
06325                 {
06326                         LLUUID image_id = it->first;
06327                         U8 te = it->second[0];
06328                         LLViewerImage* img = node->getObject()->getTEImage(te);
06329                         S32 height = img->getHeight();
06330                         S32 width = img->getWidth();
06331                         S32 components = img->getComponents();
06332                         msg = llformat("%dx%d %s on face ",
06333                                                                 width,
06334                                                                 height,
06335                                                                 (components == 4 ? "alpha" : "opaque"));
06336                         for (U8 i = 0; i < it->second.size(); ++i)
06337                         {
06338                                 msg.append( llformat("%d ", (S32)(it->second[i])));
06339                         }
06340                         LLChat chat(msg);
06341                         LLFloaterChat::addChat(chat);
06342                 }
06343         }
06344 }
06345 
06346 void handle_dump_image_list(void*)
06347 {
06348         gImageList.dump();
06349 }
06350 
06351 void handle_test_male(void*)
06352 {
06353         wear_outfit_by_name("Male Shape & Outfit");
06354         //gGestureList.requestResetFromServer( TRUE );
06355 }
06356 
06357 void handle_test_female(void*)
06358 {
06359         wear_outfit_by_name("Female Shape & Outfit");
06360         //gGestureList.requestResetFromServer( FALSE );
06361 }
06362 
06363 void handle_toggle_pg(void*)
06364 {
06365         gAgent.setTeen( !gAgent.isTeen() );
06366 
06367         LLFloaterWorldMap::reloadIcons(NULL);
06368 
06369         llinfos << "PG status set to " << (S32)gAgent.isTeen() << llendl;
06370 }
06371 
06372 void handle_dump_attachments(void*)
06373 {
06374         LLVOAvatar* avatar = gAgent.getAvatarObject();
06375         if( !avatar )
06376         {
06377                 llinfos << "NO AVATAR" << llendl;
06378                 return;
06379         }
06380 
06381         for (LLVOAvatar::attachment_map_t::iterator iter = avatar->mAttachmentPoints.begin(); 
06382                  iter != avatar->mAttachmentPoints.end(); )
06383         {
06384                 LLVOAvatar::attachment_map_t::iterator curiter = iter++;
06385                 LLViewerJointAttachment* attachment = curiter->second;
06386                 S32 key = curiter->first;
06387                 BOOL visible = (attachment->getObject() != NULL &&
06388                                                 attachment->getObject()->mDrawable.notNull() && 
06389                                                 !attachment->getObject()->mDrawable->isRenderType(0));
06390                 LLVector3 pos;
06391                 if (visible) pos = attachment->getObject()->mDrawable->getPosition();
06392                 llinfos << "ATTACHMENT " << key << ": item_id=" << attachment->getItemID()
06393                                 << (attachment->getObject() ? " present " : " absent ")
06394                                 << (visible ? "visible " : "invisible ")
06395                                 <<  " at " << pos
06396                                 << " and " << (visible ? attachment->getObject()->getPosition() : LLVector3::zero)
06397                                 << llendl;
06398         }
06399 }
06400 
06401 //---------------------------------------------------------------------
06402 // Callbacks for enabling/disabling items
06403 //---------------------------------------------------------------------
06404 
06405 BOOL menu_ui_enabled(void *user_data)
06406 {
06407         BOOL high_res = gSavedSettings.getBOOL( "HighResSnapshot" );
06408         return !high_res;
06409 }
06410 
06411 // TomY TODO DEPRECATE & REMOVE
06412 void menu_toggle_control( void* user_data )
06413 {
06414         BOOL checked = gSavedSettings.getBOOL( static_cast<char*>(user_data) );
06415         if (LLString(static_cast<char*>(user_data)) == "HighResSnapshot" && !checked)
06416         {
06417                 // High Res Snapshot active, must uncheck RenderUIInSnapshot
06418                 gSavedSettings.setBOOL( "RenderUIInSnapshot", FALSE );
06419         }
06420         gSavedSettings.setBOOL( static_cast<char*>(user_data), !checked );
06421 }
06422 
06423 
06424 // these are used in the gl menus to set control values.
06425 class LLToggleControl : public view_listener_t
06426 {
06427         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06428         {
06429                 LLString control_name = userdata.asString();
06430                 BOOL checked = gSavedSettings.getBOOL( control_name );
06431                 if (control_name == "HighResSnapshot" && !checked)
06432                 {
06433                         // High Res Snapshot active, must uncheck RenderUIInSnapshot
06434                         gSavedSettings.setBOOL( "RenderUIInSnapshot", FALSE );
06435                 }
06436                 gSavedSettings.setBOOL( control_name, !checked );
06437                 return true;
06438         }
06439 };
06440 
06441 // As above, but can be a callback from a LLCheckboxCtrl
06442 void check_toggle_control( LLUICtrl *, void* user_data )
06443 {
06444         BOOL checked = gSavedSettings.getBOOL( static_cast<char*>(user_data) );
06445         gSavedSettings.setBOOL( static_cast<char*>(user_data), !checked );
06446 }
06447 
06448 BOOL menu_check_control( void* user_data)
06449 {
06450         return gSavedSettings.getBOOL((char*)user_data);
06451 }
06452 
06453 // 
06454 void menu_toggle_variable( void* user_data )
06455 {
06456         BOOL checked = *(BOOL*)user_data;
06457         *(BOOL*)user_data = !checked;
06458 }
06459 
06460 BOOL menu_check_variable( void* user_data)
06461 {
06462         return *(BOOL*)user_data;
06463 }
06464 
06465 
06466 BOOL enable_land_selected( void* )
06467 {
06468         return !(LLViewerParcelMgr::getInstance()->selectionEmpty());
06469 }
06470 
06471 class LLSomethingSelected : public view_listener_t
06472 {
06473         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06474         {
06475                 bool new_value = !(LLSelectMgr::getInstance()->getSelection()->isEmpty());
06476                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
06477                 return true;
06478         }
06479 };
06480 
06481 class LLSomethingSelectedNoHUD : public view_listener_t
06482 {
06483         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06484         {
06485                 LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
06486                 bool new_value = !(selection->isEmpty()) && !(selection->getSelectType() == SELECT_TYPE_HUD);
06487                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
06488                 return true;
06489         }
06490 };
06491 
06492 BOOL enable_more_than_one_selected(void* )
06493 {
06494         return (LLSelectMgr::getInstance()->getSelection()->getObjectCount() > 1);
06495 }
06496 
06497 class LLEditableSelected : public view_listener_t
06498 {
06499         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06500         {
06501                 bool new_value = (LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject() != NULL);
06502                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
06503                 return true;
06504         }
06505 };
06506 
06507 class LLToolsEnableTakeCopy : public view_listener_t
06508 {
06509         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06510         {
06511                 bool all_valid = false;
06512                 if (LLSelectMgr::getInstance())
06513                 {
06514                         all_valid = true;
06515 #ifndef HACKED_GODLIKE_VIEWER
06516 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
06517                         if (LLAppViewer::instance()->isInProductionGrid()
06518                 || !gAgent.isGodlike())
06519 # endif
06520                         {
06521                                 struct f : public LLSelectedObjectFunctor
06522                                 {
06523                                         virtual bool apply(LLViewerObject* obj)
06524                                         {
06525                                                 return (!obj->permCopy() || obj->isAttachment());
06526                                         }
06527                                 } func;
06528                                 const bool firstonly = true;
06529                                 bool any_invalid = LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func, firstonly);
06530                                 all_valid = !any_invalid;
06531                         }
06532 #endif // HACKED_GODLIKE_VIEWER
06533                 }
06534 
06535                 gMenuHolder->findControl(userdata["control"].asString())->setValue(all_valid);
06536                 return true;
06537         }
06538 };
06539 
06540 BOOL enable_selection_you_own_all(void*)
06541 {
06542         if (LLSelectMgr::getInstance())
06543         {
06544                 struct f : public LLSelectedObjectFunctor
06545                 {
06546                         virtual bool apply(LLViewerObject* obj)
06547                         {
06548                                 return (!obj->permYouOwner());
06549                         }
06550                 } func;
06551                 const bool firstonly = true;
06552                 bool no_perms = LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func, firstonly);
06553                 if (no_perms)
06554                 {
06555                         return FALSE;
06556                 }
06557         }
06558         return TRUE;
06559 }
06560 
06561 BOOL enable_selection_you_own_one(void*)
06562 {
06563         if (LLSelectMgr::getInstance())
06564         {
06565                 struct f : public LLSelectedObjectFunctor
06566                 {
06567                         virtual bool apply(LLViewerObject* obj)
06568                         {
06569                                 return (obj->permYouOwner());
06570                         }
06571                 } func;
06572                 const bool firstonly = true;
06573                 bool any_perms = LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func, firstonly);
06574                 if (!any_perms)
06575                 {
06576                         return FALSE;
06577                 }
06578         }
06579         return TRUE;
06580 }
06581 
06582 class LLHasAsset : public LLInventoryCollectFunctor
06583 {
06584 public:
06585         LLHasAsset(const LLUUID& id) : mAssetID(id), mHasAsset(FALSE) {}
06586         virtual ~LLHasAsset() {}
06587         virtual bool operator()(LLInventoryCategory* cat,
06588                                                         LLInventoryItem* item);
06589         BOOL hasAsset() const { return mHasAsset; }
06590 
06591 protected:
06592         LLUUID mAssetID;
06593         BOOL mHasAsset;
06594 };
06595 
06596 bool LLHasAsset::operator()(LLInventoryCategory* cat,
06597                                                         LLInventoryItem* item)
06598 {
06599         if(item && item->getAssetUUID() == mAssetID)
06600         {
06601                 mHasAsset = TRUE;
06602         }
06603         return FALSE;
06604 }
06605 
06606 BOOL enable_save_into_inventory(void*)
06607 {
06608         // *TODO: clean this up
06609         // find the last root
06610         LLSelectNode* last_node = NULL;
06611         for (LLObjectSelection::root_iterator iter = LLSelectMgr::getInstance()->getSelection()->root_begin();
06612                  iter != LLSelectMgr::getInstance()->getSelection()->root_end(); iter++)
06613         {
06614                 last_node = *iter;
06615         }
06616 
06617 #ifdef HACKED_GODLIKE_VIEWER
06618         return TRUE;
06619 #else
06620 # ifdef TOGGLE_HACKED_GODLIKE_VIEWER
06621         if (!LLAppViewer::instance()->isInProductionGrid()
06622         && gAgent.isGodlike())
06623         {
06624                 return TRUE;
06625         }
06626 # endif
06627         // check all pre-req's for save into inventory.
06628         if(last_node && last_node->mValid && !last_node->mItemID.isNull()
06629            && (last_node->mPermissions->getOwner() == gAgent.getID())
06630            && (gInventory.getItem(last_node->mItemID) != NULL))
06631         {
06632                 LLViewerObject* obj = last_node->getObject();
06633                 if( obj && !obj->isAttachment() )
06634                 {
06635                         return TRUE;
06636                 }
06637         }
06638 #endif
06639         return FALSE;
06640 }
06641 
06642 class LLToolsEnableSaveToInventory : public view_listener_t
06643 {
06644         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06645         {
06646                 bool new_value = enable_save_into_inventory(NULL);
06647                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
06648                 return true;
06649         }
06650 };
06651 
06652 BOOL enable_save_into_task_inventory(void*)
06653 {
06654         LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
06655         if(node && (node->mValid) && (!node->mFromTaskID.isNull()))
06656         {
06657                 // *TODO: check to see if the fromtaskid object exists.
06658                 LLViewerObject* obj = node->getObject();
06659                 if( obj && !obj->isAttachment() )
06660                 {
06661                         return TRUE;
06662                 }
06663         }
06664         return FALSE;
06665 }
06666 
06667 class LLToolsEnableSaveToObjectInventory : public view_listener_t
06668 {
06669         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06670         {
06671                 bool new_value = enable_save_into_task_inventory(NULL);
06672                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
06673                 return true;
06674         }
06675 };
06676 
06677 BOOL enable_not_thirdperson(void*)
06678 {
06679         return !gAgent.cameraThirdPerson();
06680 }
06681 
06682 
06683 BOOL enable_export_selected(void *)
06684 {
06685         if (LLSelectMgr::getInstance()->getSelection()->isEmpty())
06686         {
06687                 return FALSE;
06688         }
06689         if (!gExporterRequestID.isNull())
06690         {
06691                 return FALSE;
06692         }
06693         if (!LLUploadDialog::modalUploadIsFinished())
06694         {
06695                 return FALSE;
06696         }
06697         return TRUE;
06698 }
06699 
06700 class LLViewEnableMouselook : public view_listener_t
06701 {
06702         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06703         {
06704                 // You can't go directly from customize avatar to mouselook.
06705                 // TODO: write code with appropriate dialogs to handle this transition.
06706                 bool new_value = (CAMERA_MODE_CUSTOMIZE_AVATAR != gAgent.getCameraMode() && !gSavedSettings.getBOOL("FreezeTime"));
06707                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
06708                 return true;
06709         }
06710 };
06711 
06712 class LLToolsEnableToolNotPie : public view_listener_t
06713 {
06714         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06715         {
06716                 bool new_value = ( LLToolMgr::getInstance()->getBaseTool() != LLToolPie::getInstance() );
06717                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
06718                 return true;
06719         }
06720 };
06721 
06722 class LLWorldEnableCreateLandmark : public view_listener_t
06723 {
06724         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06725         {
06726                 bool new_value = gAgent.isGodlike() || 
06727                         (gAgent.getRegion() && gAgent.getRegion()->getAllowLandmark());
06728                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
06729                 return true;
06730         }
06731 };
06732 
06733 class LLWorldEnableSetHomeLocation : public view_listener_t
06734 {
06735         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06736         {
06737                 bool new_value = gAgent.isGodlike() || 
06738                         (gAgent.getRegion() && gAgent.getRegion()->getAllowSetHome());
06739                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
06740                 return true;
06741         }
06742 };
06743 
06744 class LLWorldEnableTeleportHome : public view_listener_t
06745 {
06746         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06747         {
06748                 LLViewerRegion* regionp = gAgent.getRegion();
06749                 bool agent_on_prelude = (regionp && regionp->isPrelude());
06750                 bool enable_teleport_home = gAgent.isGodlike() || !agent_on_prelude;
06751                 gMenuHolder->findControl(userdata["control"].asString())->setValue(enable_teleport_home);
06752                 return true;
06753         }
06754 };
06755 
06756 BOOL enable_region_owner(void*)
06757 {
06758         if(gAgent.getRegion() && gAgent.getRegion()->getOwner() == gAgent.getID())
06759                 return TRUE;
06760         return enable_god_customer_service(NULL);
06761 }
06762 
06763 BOOL enable_god_full(void*)
06764 {
06765         return gAgent.getGodLevel() >= GOD_FULL;
06766 }
06767 
06768 BOOL enable_god_liaison(void*)
06769 {
06770         return gAgent.getGodLevel() >= GOD_LIAISON;
06771 }
06772 
06773 BOOL enable_god_customer_service(void*)
06774 {
06775         return gAgent.getGodLevel() >= GOD_CUSTOMER_SERVICE;
06776 }
06777 
06778 BOOL enable_god_basic(void*)
06779 {
06780         return gAgent.getGodLevel() > GOD_NOT;
06781 }
06782 
06783 #if 0 // 1.9.2
06784 void toggle_vertex_shaders(void *)
06785 {
06786         BOOL use_shaders = gPipeline.getUseVertexShaders();
06787         gPipeline.setUseVertexShaders(use_shaders);
06788 }
06789 
06790 BOOL check_vertex_shaders(void *)
06791 {
06792         return gPipeline.getUseVertexShaders();
06793 }
06794 #endif
06795 
06796 void toggle_show_xui_names(void *)
06797 {
06798         BOOL showXUINames = gSavedSettings.getBOOL("ShowXUINames");
06799         
06800         showXUINames = !showXUINames;
06801         gSavedSettings.setBOOL("ShowXUINames", showXUINames);
06802 }
06803 
06804 BOOL check_show_xui_names(void *)
06805 {
06806         return gSavedSettings.getBOOL("ShowXUINames");
06807 }
06808 
06809 
06810 
06811 void toggle_cull_small(void *)
06812 {
06813 //      gPipeline.mCullBySize = !gPipeline.mCullBySize;
06814 //
06815 //      gSavedSettings.setBOOL("RenderCullBySize", gPipeline.mCullBySize);
06816 }
06817 
06818 class LLToolsSelectOnlyMyObjects : public view_listener_t
06819 {
06820         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06821         {
06822                 BOOL cur_val = gSavedSettings.getBOOL("SelectOwnedOnly");
06823 
06824                 gSavedSettings.setBOOL("SelectOwnedOnly", ! cur_val );
06825 
06826                 return true;
06827         }
06828 };
06829 
06830 class LLToolsSelectOnlyMovableObjects : public view_listener_t
06831 {
06832         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06833         {
06834                 BOOL cur_val = gSavedSettings.getBOOL("SelectMovableOnly");
06835 
06836                 gSavedSettings.setBOOL("SelectMovableOnly", ! cur_val );
06837 
06838                 return true;
06839         }
06840 };
06841 
06842 class LLToolsSelectBySurrounding : public view_listener_t
06843 {
06844         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06845         {
06846                 LLSelectMgr::sRectSelectInclusive = !LLSelectMgr::sRectSelectInclusive;
06847 
06848                 gSavedSettings.setBOOL("RectangleSelectInclusive", LLSelectMgr::sRectSelectInclusive);
06849                 return true;
06850         }
06851 };
06852 
06853 class LLToolsShowHiddenSelection : public view_listener_t
06854 {
06855         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06856         {
06857                 // TomY TODO Merge these
06858                 LLSelectMgr::sRenderHiddenSelections = !LLSelectMgr::sRenderHiddenSelections;
06859 
06860                 gSavedSettings.setBOOL("RenderHiddenSelections", LLSelectMgr::sRenderHiddenSelections);
06861                 return true;
06862         }
06863 };
06864 
06865 class LLToolsShowSelectionLightRadius : public view_listener_t
06866 {
06867         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06868         {
06869                 // TomY TODO merge these
06870                 LLSelectMgr::sRenderLightRadius = !LLSelectMgr::sRenderLightRadius;
06871 
06872                 gSavedSettings.setBOOL("RenderLightRadius", LLSelectMgr::sRenderLightRadius);
06873                 return true;
06874         }
06875 };
06876 
06877 class LLToolsEditLinkedParts : public view_listener_t
06878 {
06879         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
06880         {
06881                 BOOL select_individuals = gSavedSettings.getBOOL("EditLinkedParts");
06882                 if (select_individuals)
06883                 {
06884                         LLSelectMgr::getInstance()->demoteSelectionToIndividuals();
06885                 }
06886                 else
06887                 {
06888                         LLSelectMgr::getInstance()->promoteSelectionToRoot();
06889                 }
06890                 return true;
06891         }
06892 };
06893 
06894 void reload_personal_settings_overrides(void *)
06895 {
06896         llinfos << "Loading overrides from " << gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT,"overrides.xml") << llendl;
06897         
06898         gSavedSettings.loadFromFile(gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT,"overrides.xml"));
06899 }
06900 
06901 void reload_vertex_shader(void *)
06902 {
06903         //THIS WOULD BE AN AWESOME PLACE TO RELOAD SHADERS... just a thought    - DaveP
06904 }
06905 
06906 void slow_mo_animations(void*)
06907 {
06908         static BOOL slow_mo = FALSE;
06909         if (slow_mo)
06910         {
06911                 gAgent.getAvatarObject()->setAnimTimeFactor(1.f);
06912                 slow_mo = FALSE;
06913         }
06914         else
06915         {
06916                 gAgent.getAvatarObject()->setAnimTimeFactor(0.2f);
06917                 slow_mo = TRUE;
06918         }
06919 }
06920 
06921 void handle_dump_avatar_local_textures(void*)
06922 {
06923         LLVOAvatar* avatar = gAgent.getAvatarObject();
06924         if( avatar )
06925         {
06926                 avatar->dumpLocalTextures();
06927         }
06928 }
06929 
06930 void handle_debug_avatar_textures(void*)
06931 {
06932         LLFloaterAvatarTextures::show(gLastHitObjectID);
06933 }
06934 
06935 void handle_grab_texture(void* data)
06936 {
06937         LLVOAvatar::ETextureIndex index = (LLVOAvatar::ETextureIndex)((intptr_t)data);
06938         LLVOAvatar* avatar = gAgent.getAvatarObject();
06939         if ( avatar )
06940         {
06941                 const LLUUID& asset_id = avatar->grabLocalTexture(index);
06942                 llinfos << "Adding baked texture " << asset_id << " to inventory." << llendl;
06943                 LLAssetType::EType asset_type = LLAssetType::AT_TEXTURE;
06944                 LLInventoryType::EType inv_type = LLInventoryType::IT_TEXTURE;
06945                 LLUUID folder_id(gInventory.findCategoryUUIDForType(asset_type));
06946                 if(folder_id.notNull())
06947                 {
06948                         LLString name = "Baked ";
06949                         switch (index)
06950                         {
06951                         case LLVOAvatar::TEX_EYES_BAKED:
06952                                 name.append("Iris");
06953                                 break;
06954                         case LLVOAvatar::TEX_HEAD_BAKED:
06955                                 name.append("Head");
06956                                 break;
06957                         case LLVOAvatar::TEX_UPPER_BAKED:
06958                                 name.append("Upper Body");
06959                                 break;
06960                         case LLVOAvatar::TEX_LOWER_BAKED:
06961                                 name.append("Lower Body");
06962                                 break;
06963                         case LLVOAvatar::TEX_SKIRT_BAKED:
06964                                 name.append("Skirt");
06965                                 break;
06966                         default:
06967                                 name.append("Unknown");
06968                                 break;
06969                         }
06970                         name.append(" Texture");
06971 
06972                         LLUUID item_id;
06973                         item_id.generate();
06974                         LLPermissions perm;
06975                         perm.init(gAgentID,
06976                                           gAgentID,
06977                                           LLUUID::null,
06978                                           LLUUID::null);
06979                         U32 next_owner_perm = PERM_MOVE | PERM_TRANSFER;
06980                         perm.initMasks(PERM_ALL,
06981                                                    PERM_ALL,
06982                                                    PERM_NONE,
06983                                                    PERM_NONE,
06984                                                    next_owner_perm);
06985                         S32 creation_date_now = time_corrected();
06986                         LLPointer<LLViewerInventoryItem> item
06987                                 = new LLViewerInventoryItem(item_id,
06988                                                                                         folder_id,
06989                                                                                         perm,
06990                                                                                         asset_id,
06991                                                                                         asset_type,
06992                                                                                         inv_type,
06993                                                                                         name,
06994                                                                                         "",
06995                                                                                         LLSaleInfo::DEFAULT,
06996                                                                                         LLInventoryItem::II_FLAGS_NONE,
06997                                                                                         creation_date_now);
06998 
06999                         item->updateServer(TRUE);
07000                         gInventory.updateItem(item);
07001                         gInventory.notifyObservers();
07002 
07003                         LLInventoryView* view = LLInventoryView::getActiveInventory();
07004 
07005                         // Show the preview panel for textures to let
07006                         // user know that the image is now in inventory.
07007                         if(view)
07008                         {
07009                                 LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus();
07010 
07011                                 view->getPanel()->setSelection(item_id, TAKE_FOCUS_NO);
07012                                 view->getPanel()->openSelected();
07013                                 //LLInventoryView::dumpSelectionInformation((void*)view);
07014                                 // restore keyboard focus
07015                                 gFocusMgr.setKeyboardFocus(focus_ctrl);
07016                         }
07017                 }
07018                 else
07019                 {
07020                         llwarns << "Can't find a folder to put it in" << llendl;
07021                 }
07022         }
07023 }
07024 
07025 BOOL enable_grab_texture(void* data)
07026 {
07027         LLVOAvatar::ETextureIndex index = (LLVOAvatar::ETextureIndex)((intptr_t)data);
07028         LLVOAvatar* avatar = gAgent.getAvatarObject();
07029         if ( avatar )
07030         {
07031                 return avatar->canGrabLocalTexture(index);
07032         }
07033         return FALSE;
07034 }
07035 
07036 // Returns a pointer to the avatar give the UUID of the avatar OR of an attachment the avatar is wearing.
07037 // Returns NULL on failure.
07038 LLVOAvatar* find_avatar_from_object( LLViewerObject* object )
07039 {
07040         if (object)
07041         {
07042                 if( object->isAttachment() )
07043                 {
07044                         do
07045                         {
07046                                 object = (LLViewerObject*) object->getParent();
07047                         }
07048                         while( object && !object->isAvatar() );
07049                 }
07050                 else
07051                 if( !object->isAvatar() )
07052                 {
07053                         object = NULL;
07054                 }
07055         }
07056 
07057         return (LLVOAvatar*) object;
07058 }
07059 
07060 
07061 // Returns a pointer to the avatar give the UUID of the avatar OR of an attachment the avatar is wearing.
07062 // Returns NULL on failure.
07063 LLVOAvatar* find_avatar_from_object( const LLUUID& object_id )
07064 {
07065         return find_avatar_from_object( gObjectList.findObject(object_id) );
07066 }
07067 
07068 
07069 void handle_disconnect_viewer(void *)
07070 {
07071         char message[2048];             /* Flawfinder: ignore */
07072         message[0] = '\0';
07073 
07074         snprintf(message, sizeof(message), "Testing viewer disconnect");                /* Flawfinder: ignore */
07075 
07076         LLAppViewer::instance()->forceDisconnect(message);
07077 }
07078 
07079 void force_error_breakpoint(void *)
07080 {
07081     LLAppViewer::instance()->forceErrorBreakpoint();
07082 }
07083 
07084 void force_error_llerror(void *)
07085 {
07086     LLAppViewer::instance()->forceErrorLLError();
07087 }
07088 
07089 void force_error_bad_memory_access(void *)
07090 {
07091     LLAppViewer::instance()->forceErrorBadMemoryAccess();
07092 }
07093 
07094 void force_error_infinite_loop(void *)
07095 {
07096     LLAppViewer::instance()->forceErrorInifiniteLoop();
07097 }
07098 
07099 void force_error_software_exception(void *)
07100 {
07101     LLAppViewer::instance()->forceErrorSoftwareException();
07102 }
07103 
07104 class LLToolsUseSelectionForGrid : public view_listener_t
07105 {
07106         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07107         {
07108                 LLSelectMgr::getInstance()->clearGridObjects();
07109                 struct f : public LLSelectedObjectFunctor
07110                 {
07111                         virtual bool apply(LLViewerObject* objectp)
07112                         {
07113                                 LLSelectMgr::getInstance()->addGridObject(objectp);
07114                                 return true;
07115                         }
07116                 } func;
07117                 LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func);
07118                 LLSelectMgr::getInstance()->setGridMode(GRID_MODE_REF_OBJECT);
07119                 if (gFloaterTools)
07120                 {
07121                         gFloaterTools->mComboGridMode->setCurrentByIndex((S32)GRID_MODE_REF_OBJECT);
07122                 }
07123                 return true;
07124         }
07125 };
07126 
07127 void handle_test_load_url(void*)
07128 {
07129         LLWeb::loadURL("");
07130         LLWeb::loadURL("hacker://www.google.com/");
07131         LLWeb::loadURL("http");
07132         LLWeb::loadURL("http://www.google.com/");
07133 }
07134 
07135 //
07136 // LLViewerMenuHolderGL
07137 //
07138 
07139 LLViewerMenuHolderGL::LLViewerMenuHolderGL() : LLMenuHolderGL()
07140 {
07141 }
07142 
07143 BOOL LLViewerMenuHolderGL::hideMenus()
07144 {
07145         BOOL handled = LLMenuHolderGL::hideMenus();
07146 
07147         // drop pie menu selection
07148         mParcelSelection = NULL;
07149         mObjectSelection = NULL;
07150 
07151         gMenuBarView->clearHoverItem();
07152         gMenuBarView->resetMenuTrigger();
07153 
07154         return handled;
07155 }
07156 
07157 void LLViewerMenuHolderGL::setParcelSelection(LLSafeHandle<LLParcelSelection> selection) 
07158 { 
07159         mParcelSelection = selection; 
07160 }
07161 
07162 void LLViewerMenuHolderGL::setObjectSelection(LLSafeHandle<LLObjectSelection> selection) 
07163 { 
07164         mObjectSelection = selection; 
07165 }
07166 
07167 
07168 const LLRect LLViewerMenuHolderGL::getMenuRect() const
07169 {
07170         return LLRect(0, getRect().getHeight() - MENU_BAR_HEIGHT, getRect().getWidth(), STATUS_BAR_HEIGHT);
07171 }
07172 
07173 void handle_save_to_xml(void*)
07174 {
07175         LLFloater* frontmost = gFloaterView->getFrontmost();
07176         if (!frontmost)
07177         {
07178         gViewerWindow->alertXml("NoFrontmostFloater");
07179                 return;
07180         }
07181 
07182         LLString default_name = "floater_";
07183         default_name += frontmost->getTitle();
07184         default_name += ".xml";
07185 
07186         LLString::toLower(default_name);
07187         LLString::replaceChar(default_name, ' ', '_');
07188         LLString::replaceChar(default_name, '/', '_');
07189         LLString::replaceChar(default_name, ':', '_');
07190         LLString::replaceChar(default_name, '"', '_');
07191 
07192         LLFilePicker& picker = LLFilePicker::instance();
07193         if (picker.getSaveFile(LLFilePicker::FFSAVE_XML, default_name.c_str()))
07194         {
07195                 LLString filename = picker.getFirstFile();
07196                 LLUICtrlFactory::getInstance()->saveToXML(frontmost, filename);
07197         }
07198 }
07199 
07200 void handle_load_from_xml(void*)
07201 {
07202         LLFilePicker& picker = LLFilePicker::instance();
07203         if (picker.getOpenFile(LLFilePicker::FFLOAD_XML))
07204         {
07205                 LLString filename = picker.getFirstFile();
07206                 LLFloater* floater = new LLFloater("sample_floater");
07207                 LLUICtrlFactory::getInstance()->buildFloater(floater, filename);
07208         }
07209 }
07210 
07211 void handle_slurl_test(void*)
07212 {
07213         const bool open_links_externally = false;
07214         const bool open_app_slurls = true;
07215         LLFloaterHtml::getInstance()->show(
07216                 "http://secondlife.com/app/search/slurls.html",
07217                 "SLURL Test", 
07218                 open_links_externally, 
07219                 open_app_slurls);
07220 }
07221 
07222 void handle_rebake_textures(void*)
07223 {
07224         LLVOAvatar* avatar = gAgent.getAvatarObject();
07225         if (!avatar) return;
07226 
07227         // Slam pending upload count to "unstick" things
07228         bool slam_for_debug = true;
07229         avatar->forceBakeAllTextures(slam_for_debug);
07230 }
07231 
07232 void toggle_visibility(void* user_data)
07233 {
07234         LLView* viewp = (LLView*)user_data;
07235         viewp->setVisible(!viewp->getVisible());
07236 }
07237 
07238 BOOL get_visibility(void* user_data)
07239 {
07240         LLView* viewp = (LLView*)user_data;
07241         return viewp->getVisible();
07242 }
07243 
07244 // TomY TODO: Get rid of these?
07245 class LLViewShowHoverTips : public view_listener_t
07246 {
07247         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07248         {
07249                 LLHoverView::sShowHoverTips = !LLHoverView::sShowHoverTips;
07250                 return true;
07251         }
07252 };
07253 
07254 class LLViewCheckShowHoverTips : public view_listener_t
07255 {
07256         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07257         {
07258                 bool new_value = LLHoverView::sShowHoverTips;
07259                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
07260                 return true;
07261         }
07262 };
07263 
07264 // TomY TODO: Get rid of these?
07265 class LLViewHighlightTransparent : public view_listener_t
07266 {
07267         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07268         {
07269                 LLDrawPoolAlpha::sShowDebugAlpha = !LLDrawPoolAlpha::sShowDebugAlpha;
07270                 return true;
07271         }
07272 };
07273 
07274 class LLViewCheckHighlightTransparent : public view_listener_t
07275 {
07276         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07277         {
07278                 bool new_value = LLDrawPoolAlpha::sShowDebugAlpha;
07279                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
07280                 return true;
07281         }
07282 };
07283 
07284 class LLViewBeaconWidth : public view_listener_t
07285 {
07286         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07287         {
07288                 LLString width = userdata.asString();
07289                 if(width == "1")
07290                 {
07291                         gSavedSettings.setS32("DebugBeaconLineWidth", 1);
07292                 }
07293                 else if(width == "4")
07294                 {
07295                         gSavedSettings.setS32("DebugBeaconLineWidth", 4);
07296                 }
07297                 else if(width == "16")
07298                 {
07299                         gSavedSettings.setS32("DebugBeaconLineWidth", 16);
07300                 }
07301                 else if(width == "32")
07302                 {
07303                         gSavedSettings.setS32("DebugBeaconLineWidth", 32);
07304                 }
07305 
07306                 return true;
07307         }
07308 };
07309 
07310 
07311 class LLViewToggleBeacon : public view_listener_t
07312 {
07313         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07314         {
07315                 LLString beacon = userdata.asString();
07316                 if (beacon == "scriptsbeacon")
07317                 {
07318                         LLPipeline::toggleRenderScriptedBeacons(NULL);
07319                         gSavedSettings.setBOOL( "scriptsbeacon", LLPipeline::getRenderScriptedBeacons(NULL) );
07320                         // toggle the other one off if it's on
07321                         if (LLPipeline::getRenderScriptedBeacons(NULL) && LLPipeline::getRenderScriptedTouchBeacons(NULL))
07322                         {
07323                                 LLPipeline::toggleRenderScriptedTouchBeacons(NULL);
07324                                 gSavedSettings.setBOOL( "scripttouchbeacon", LLPipeline::getRenderScriptedTouchBeacons(NULL) );
07325                         }
07326                 }
07327                 else if (beacon == "physicalbeacon")
07328                 {
07329                         LLPipeline::toggleRenderPhysicalBeacons(NULL);
07330                         gSavedSettings.setBOOL( "physicalbeacon", LLPipeline::getRenderPhysicalBeacons(NULL) );
07331                 }
07332                 else if (beacon == "soundsbeacon")
07333                 {
07334                         LLPipeline::toggleRenderSoundBeacons(NULL);
07335                         gSavedSettings.setBOOL( "soundsbeacon", LLPipeline::getRenderSoundBeacons(NULL) );
07336                 }
07337                 else if (beacon == "particlesbeacon")
07338                 {
07339                         LLPipeline::toggleRenderParticleBeacons(NULL);
07340                         gSavedSettings.setBOOL( "particlesbeacon", LLPipeline::getRenderParticleBeacons(NULL) );
07341                 }
07342                 else if (beacon == "scripttouchbeacon")
07343                 {
07344                         LLPipeline::toggleRenderScriptedTouchBeacons(NULL);
07345                         gSavedSettings.setBOOL( "scripttouchbeacon", LLPipeline::getRenderScriptedTouchBeacons(NULL) );
07346                         // toggle the other one off if it's on
07347                         if (LLPipeline::getRenderScriptedBeacons(NULL) && LLPipeline::getRenderScriptedTouchBeacons(NULL))
07348                         {
07349                                 LLPipeline::toggleRenderScriptedBeacons(NULL);
07350                                 gSavedSettings.setBOOL( "scriptsbeacon", LLPipeline::getRenderScriptedBeacons(NULL) );
07351                         }
07352                 }
07353                 else if (beacon == "renderbeacons")
07354                 {
07355                         LLPipeline::toggleRenderBeacons(NULL);
07356                         gSavedSettings.setBOOL( "renderbeacons", LLPipeline::getRenderBeacons(NULL) );
07357                         // toggle the other one on if it's not
07358                         if (!LLPipeline::getRenderBeacons(NULL) && !LLPipeline::getRenderHighlights(NULL))
07359                         {
07360                                 LLPipeline::toggleRenderHighlights(NULL);
07361                                 gSavedSettings.setBOOL( "renderhighlights", LLPipeline::getRenderHighlights(NULL) );
07362                         }
07363                 }
07364                 else if (beacon == "renderhighlights")
07365                 {
07366                         LLPipeline::toggleRenderHighlights(NULL);
07367                         gSavedSettings.setBOOL( "renderhighlights", LLPipeline::getRenderHighlights(NULL) );
07368                         // toggle the other one on if it's not
07369                         if (!LLPipeline::getRenderBeacons(NULL) && !LLPipeline::getRenderHighlights(NULL))
07370                         {
07371                                 LLPipeline::toggleRenderBeacons(NULL);
07372                                 gSavedSettings.setBOOL( "renderbeacons", LLPipeline::getRenderBeacons(NULL) );
07373                         }
07374                 }
07375                         
07376                 return true;
07377         }
07378 };
07379 
07380 class LLViewCheckBeaconEnabled : public view_listener_t
07381 {
07382         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07383         {
07384                 LLString beacon = userdata["data"].asString();
07385                 bool new_value = false;
07386                 if (beacon == "scriptsbeacon")
07387                 {
07388                         new_value = gSavedSettings.getBOOL( "scriptsbeacon");
07389                         LLPipeline::setRenderScriptedBeacons(new_value);
07390                 }
07391                 else if (beacon == "physicalbeacon")
07392                 {
07393                         new_value = gSavedSettings.getBOOL( "physicalbeacon");
07394                         LLPipeline::setRenderPhysicalBeacons(new_value);
07395                 }
07396                 else if (beacon == "soundsbeacon")
07397                 {
07398                         new_value = gSavedSettings.getBOOL( "soundsbeacon");
07399                         LLPipeline::setRenderSoundBeacons(new_value);
07400                 }
07401                 else if (beacon == "particlesbeacon")
07402                 {
07403                         new_value = gSavedSettings.getBOOL( "particlesbeacon");
07404                         LLPipeline::setRenderParticleBeacons(new_value);
07405                 }
07406                 else if (beacon == "scripttouchbeacon")
07407                 {
07408                         new_value = gSavedSettings.getBOOL( "scripttouchbeacon");
07409                         LLPipeline::setRenderScriptedTouchBeacons(new_value);
07410                 }
07411                 else if (beacon == "renderbeacons")
07412                 {
07413                         new_value = gSavedSettings.getBOOL( "renderbeacons");
07414                         LLPipeline::setRenderBeacons(new_value);
07415                 }
07416                 else if (beacon == "renderhighlights")
07417                 {
07418                         new_value = gSavedSettings.getBOOL( "renderhighlights");
07419                         LLPipeline::setRenderHighlights(new_value);
07420                 }
07421                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
07422                 return true;
07423         }
07424 };
07425 
07426 class LLViewToggleRenderType : public view_listener_t
07427 {
07428         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07429         {
07430                 LLString type = userdata.asString();
07431                 if (type == "hideparticles")
07432                 {
07433                         LLPipeline::toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES);
07434                 }
07435                 return true;
07436         }
07437 };
07438 
07439 class LLViewCheckRenderType : public view_listener_t
07440 {
07441         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07442         {
07443                 LLString type = userdata["data"].asString();
07444                 bool new_value = false;
07445                 if (type == "hideparticles")
07446                 {
07447                         new_value = LLPipeline::toggleRenderTypeControlNegated((void *)LLPipeline::RENDER_TYPE_PARTICLES);
07448                 }
07449                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
07450                 return true;
07451         }
07452 };
07453 
07454 class LLViewShowHUDAttachments : public view_listener_t
07455 {
07456         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07457         {
07458                 LLPipeline::sShowHUDAttachments = !LLPipeline::sShowHUDAttachments;
07459                 return true;
07460         }
07461 };
07462 
07463 class LLViewCheckHUDAttachments : public view_listener_t
07464 {
07465         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07466         {
07467                 bool new_value = LLPipeline::sShowHUDAttachments;
07468                 gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value);
07469                 return true;
07470         }
07471 };
07472 
07473 class LLEditEnableTakeOff : public view_listener_t
07474 {
07475         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07476         {
07477                 LLString control_name = userdata["control"].asString();
07478                 LLString clothing = userdata["data"].asString();
07479                 bool new_value = false;
07480                 if (clothing == "shirt")
07481                 {
07482                         new_value = LLAgent::selfHasWearable((void *)WT_SHIRT);
07483                 }
07484                 if (clothing == "pants")
07485                 {
07486                         new_value = LLAgent::selfHasWearable((void *)WT_PANTS);
07487                 }
07488                 if (clothing == "shoes")
07489                 {
07490                         new_value = LLAgent::selfHasWearable((void *)WT_SHOES);
07491                 }
07492                 if (clothing == "socks")
07493                 {
07494                         new_value = LLAgent::selfHasWearable((void *)WT_SOCKS);
07495                 }
07496                 if (clothing == "jacket")
07497                 {
07498                         new_value = LLAgent::selfHasWearable((void *)WT_JACKET);
07499                 }
07500                 if (clothing == "gloves")
07501                 {
07502                         new_value = LLAgent::selfHasWearable((void *)WT_GLOVES);
07503                 }
07504                 if (clothing == "undershirt")
07505                 {
07506                         new_value = LLAgent::selfHasWearable((void *)WT_UNDERSHIRT);
07507                 }
07508                 if (clothing == "underpants")
07509                 {
07510                         new_value = LLAgent::selfHasWearable((void *)WT_UNDERPANTS);
07511                 }
07512                 if (clothing == "skirt")
07513                 {
07514                         new_value = LLAgent::selfHasWearable((void *)WT_SKIRT);
07515                 }
07516                 gMenuHolder->findControl(control_name)->setValue(new_value);
07517                 return true;
07518         }
07519 };
07520 
07521 class LLEditTakeOff : public view_listener_t
07522 {
07523         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07524         {
07525                 LLString clothing = userdata.asString();
07526                 if (clothing == "shirt")
07527                 {
07528                         LLAgent::userRemoveWearable((void*)WT_SHIRT);
07529                 }
07530                 else if (clothing == "pants")
07531                 {
07532                         LLAgent::userRemoveWearable((void*)WT_PANTS);
07533                 }
07534                 else if (clothing == "shoes")
07535                 {
07536                         LLAgent::userRemoveWearable((void*)WT_SHOES);
07537                 }
07538                 else if (clothing == "socks")
07539                 {
07540                         LLAgent::userRemoveWearable((void*)WT_SOCKS);
07541                 }
07542                 else if (clothing == "jacket")
07543                 {
07544                         LLAgent::userRemoveWearable((void*)WT_JACKET);
07545                 }
07546                 else if (clothing == "gloves")
07547                 {
07548                         LLAgent::userRemoveWearable((void*)WT_GLOVES);
07549                 }
07550                 else if (clothing == "undershirt")
07551                 {
07552                         LLAgent::userRemoveWearable((void*)WT_UNDERSHIRT);
07553                 }
07554                 else if (clothing == "underpants")
07555                 {
07556                         LLAgent::userRemoveWearable((void*)WT_UNDERPANTS);
07557                 }
07558                 else if (clothing == "skirt")
07559                 {
07560                         LLAgent::userRemoveWearable((void*)WT_SKIRT);
07561                 }
07562                 else if (clothing == "all")
07563                 {
07564                         LLAgent::userRemoveAllClothes(NULL);
07565                 }
07566                 return true;
07567         }
07568 };
07569 
07570 class LLWorldChat : public view_listener_t
07571 {
07572         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07573         {
07574                 handle_chat(NULL);
07575                 return true;
07576         }
07577 };
07578 
07579 class LLToolsSelectTool : public view_listener_t
07580 {
07581         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07582         {
07583                 LLString tool_name = userdata.asString();
07584                 if (tool_name == "focus")
07585                 {
07586                         LLToolMgr::getInstance()->getCurrentToolset()->selectToolByIndex(1);
07587                 }
07588                 else if (tool_name == "move")
07589                 {
07590                         LLToolMgr::getInstance()->getCurrentToolset()->selectToolByIndex(2);
07591                 }
07592                 else if (tool_name == "edit")
07593                 {
07594                         LLToolMgr::getInstance()->getCurrentToolset()->selectToolByIndex(3);
07595                 }
07596                 else if (tool_name == "create")
07597                 {
07598                         LLToolMgr::getInstance()->getCurrentToolset()->selectToolByIndex(4);
07599                 }
07600                 else if (tool_name == "land")
07601                 {
07602                         LLToolMgr::getInstance()->getCurrentToolset()->selectToolByIndex(5);
07603                 }
07604                 return true;
07605         }
07606 };
07607 
07609 class LLWorldEnvSettings : public view_listener_t
07610 {       
07611         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07612         {
07613                 LLString tod = userdata.asString();
07614                 LLVector3 sun_direction;
07615                 
07616                 if (tod == "editor")
07617                 {
07618                         // if not there or is hidden, show it
07619                         if(     !LLFloaterEnvSettings::isOpen() || 
07620                                 !LLFloaterEnvSettings::instance()->getVisible()) {
07621                                 LLFloaterEnvSettings::show();
07622                                 
07623                         // otherwise, close it button acts like a toggle
07624                         } 
07625                         else 
07626                         {
07627                                 LLFloaterEnvSettings::instance()->close();
07628                         }
07629                         return true;
07630                 }
07631                 
07632                 if (tod == "sunrise")
07633                 {
07634                         // set the value, turn off animation
07635                         LLWLParamManager::instance()->mAnimator.setDayTime(0.25);
07636                         LLWLParamManager::instance()->mAnimator.mIsRunning = false;
07637                         LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;
07638 
07639                         // then call update once
07640                         LLWLParamManager::instance()->mAnimator.update(
07641                                 LLWLParamManager::instance()->mCurParams);
07642                 }
07643                 else if (tod == "noon")
07644                 {
07645                         // set the value, turn off animation
07646                         LLWLParamManager::instance()->mAnimator.setDayTime(0.567);
07647                         LLWLParamManager::instance()->mAnimator.mIsRunning = false;
07648                         LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;
07649 
07650                         // then call update once
07651                         LLWLParamManager::instance()->mAnimator.update(
07652                                 LLWLParamManager::instance()->mCurParams);
07653                 }
07654                 else if (tod == "sunset")
07655                 {
07656                         // set the value, turn off animation
07657                         LLWLParamManager::instance()->mAnimator.setDayTime(0.75);
07658                         LLWLParamManager::instance()->mAnimator.mIsRunning = false;
07659                         LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;
07660 
07661                         // then call update once
07662                         LLWLParamManager::instance()->mAnimator.update(
07663                                 LLWLParamManager::instance()->mCurParams);
07664                 }
07665                 else if (tod == "midnight")
07666                 {
07667                         // set the value, turn off animation
07668                         LLWLParamManager::instance()->mAnimator.setDayTime(0.0);
07669                         LLWLParamManager::instance()->mAnimator.mIsRunning = false;
07670                         LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;
07671 
07672                         // then call update once
07673                         LLWLParamManager::instance()->mAnimator.update(
07674                                 LLWLParamManager::instance()->mCurParams);
07675                 }
07676                 else
07677                 {
07678                         LLWLParamManager::instance()->mAnimator.mIsRunning = true;
07679                         LLWLParamManager::instance()->mAnimator.mUseLindenTime = true;  
07680                 }
07681                 return true;
07682         }
07683 };
07684 
07686 class LLWorldWaterSettings : public view_listener_t
07687 {       
07688         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07689         {
07690                 // if not there or is hidden, show it
07691                 if(     !LLFloaterWater::isOpen() || 
07692                         !LLFloaterWater::instance()->getVisible()) {
07693                         LLFloaterWater::show();
07694                                 
07695                 // otherwise, close it button acts like a toggle
07696                 } 
07697                 else 
07698                 {
07699                         LLFloaterWater::instance()->close();
07700                 }
07701                 return true;
07702         }
07703 };
07704 
07706 class LLWorldPostProcess : public view_listener_t
07707 {
07708         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07709         {
07710                 LLFloaterPostProcess::show();
07711                 return true;
07712         }
07713 };
07714 
07716 class LLWorldDayCycle : public view_listener_t
07717 {
07718         bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
07719         {
07720                 LLFloaterDayCycle::show();
07721                 return true;
07722         }
07723 };
07724 
07725 
07726 
07727 static void addMenu(view_listener_t *menu, const char *name)
07728 {
07729         sMenus.push_back(menu);
07730         menu->registerListener(gMenuHolder, name);
07731 }
07732 
07733 void initialize_menus()
07734 {
07735         // File menu
07736         init_menu_file();
07737 
07738         // Edit menu
07739         addMenu(new LLEditUndo(), "Edit.Undo");
07740         addMenu(new LLEditRedo(), "Edit.Redo");
07741         addMenu(new LLEditCut(), "Edit.Cut");
07742         addMenu(new LLEditCopy(), "Edit.Copy");
07743         addMenu(new LLEditPaste(), "Edit.Paste");
07744         addMenu(new LLEditDelete(), "Edit.Delete");
07745         addMenu(new LLEditSearch(), "Edit.Search");
07746         addMenu(new LLEditSelectAll(), "Edit.SelectAll");
07747         addMenu(new LLEditDeselect(), "Edit.Deselect");
07748         addMenu(new LLEditDuplicate(), "Edit.Duplicate");
07749         addMenu(new LLEditTakeOff(), "Edit.TakeOff");
07750 
07751         addMenu(new LLEditEnableUndo(), "Edit.EnableUndo");
07752         addMenu(new LLEditEnableRedo(), "Edit.EnableRedo");
07753         addMenu(new LLEditEnableCut(), "Edit.EnableCut");
07754         addMenu(new LLEditEnableCopy(), "Edit.EnableCopy");
07755         addMenu(new LLEditEnablePaste(), "Edit.EnablePaste");
07756         addMenu(new LLEditEnableDelete(), "Edit.EnableDelete");
07757         addMenu(new LLEditEnableSelectAll(), "Edit.EnableSelectAll");
07758         addMenu(new LLEditEnableDeselect(), "Edit.EnableDeselect");
07759         addMenu(new LLEditEnableDuplicate(), "Edit.EnableDuplicate");
07760         addMenu(new LLEditEnableTakeOff(), "Edit.EnableTakeOff");
07761         addMenu(new LLEditEnableCustomizeAvatar(), "Edit.EnableCustomizeAvatar");
07762 
07763         // View menu
07764         addMenu(new LLViewMouselook(), "View.Mouselook");
07765         addMenu(new LLViewBuildMode(), "View.BuildMode");
07766         addMenu(new LLViewJoystickFlycam(), "View.JoystickFlycam");
07767         addMenu(new LLViewResetView(), "View.ResetView");
07768         addMenu(new LLViewLookAtLastChatter(), "View.LookAtLastChatter");
07769         addMenu(new LLViewShowHoverTips(), "View.ShowHoverTips");
07770         addMenu(new LLViewHighlightTransparent(), "View.HighlightTransparent");
07771         addMenu(new LLViewToggleBeacon(), "View.ToggleBeacon");
07772         addMenu(new LLViewBeaconWidth(), "View.BeaconWidth");
07773         addMenu(new LLViewToggleRenderType(), "View.ToggleRenderType");
07774         addMenu(new LLViewShowHUDAttachments(), "View.ShowHUDAttachments");
07775         addMenu(new LLViewZoomOut(), "View.ZoomOut");
07776         addMenu(new LLViewZoomIn(), "View.ZoomIn");
07777         addMenu(new LLViewZoomDefault(), "View.ZoomDefault");
07778         addMenu(new LLViewFullscreen(), "View.Fullscreen");
07779         addMenu(new LLViewDefaultUISize(), "View.DefaultUISize");
07780 
07781         addMenu(new LLViewEnableMouselook(), "View.EnableMouselook");
07782         addMenu(new LLViewEnableLastChatter(), "View.EnableLastChatter");
07783 
07784         addMenu(new LLViewCheckBuildMode(), "View.CheckBuildMode");
07785         addMenu(new LLViewCheckJoystickFlycam(), "View.CheckJoystickFlycam");
07786         addMenu(new LLViewCheckShowHoverTips(), "View.CheckShowHoverTips");
07787         addMenu(new LLViewCheckHighlightTransparent(), "View.CheckHighlightTransparent");
07788         addMenu(new LLViewCheckBeaconEnabled(), "View.CheckBeaconEnabled");
07789         addMenu(new LLViewCheckRenderType(), "View.CheckRenderType");
07790         addMenu(new LLViewCheckHUDAttachments(), "View.CheckHUDAttachments");
07791 
07792         // World menu
07793         addMenu(new LLWorldChat(), "World.Chat");
07794         addMenu(new LLWorldAlwaysRun(), "World.AlwaysRun");
07795         addMenu(new LLWorldFly(), "World.Fly");
07796         addMenu(new LLWorldEnableFly(), "World.EnableFly");
07797         addMenu(new LLWorldCreateLandmark(), "World.CreateLandmark");
07798         addMenu(new LLWorldSetHomeLocation(), "World.SetHomeLocation");
07799         addMenu(new LLWorldTeleportHome(), "World.TeleportHome");
07800         addMenu(new LLWorldSetAway(), "World.SetAway");
07801         addMenu(new LLWorldSetBusy(), "World.SetBusy");
07802 
07803         addMenu(new LLWorldEnableCreateLandmark(), "World.EnableCreateLandmark");
07804         addMenu(new LLWorldEnableSetHomeLocation(), "World.EnableSetHomeLocation");
07805         addMenu(new LLWorldEnableTeleportHome(), "World.EnableTeleportHome");
07806         addMenu(new LLWorldEnableBuyLand(), "World.EnableBuyLand");
07807 
07808         addMenu(new LLWorldCheckAlwaysRun(), "World.CheckAlwaysRun");
07809         
07810         (new LLWorldEnvSettings())->registerListener(gMenuHolder, "World.EnvSettings");
07811         (new LLWorldWaterSettings())->registerListener(gMenuHolder, "World.WaterSettings");
07812         (new LLWorldPostProcess())->registerListener(gMenuHolder, "World.PostProcess");
07813         (new LLWorldDayCycle())->registerListener(gMenuHolder, "World.DayCycle");
07814 
07815         // Tools menu
07816         addMenu(new LLToolsSelectTool(), "Tools.SelectTool");
07817         addMenu(new LLToolsSelectOnlyMyObjects(), "Tools.SelectOnlyMyObjects");
07818         addMenu(new LLToolsSelectOnlyMovableObjects(), "Tools.SelectOnlyMovableObjects");
07819         addMenu(new LLToolsSelectBySurrounding(), "Tools.SelectBySurrounding");
07820         addMenu(new LLToolsShowHiddenSelection(), "Tools.ShowHiddenSelection");
07821         addMenu(new LLToolsShowSelectionLightRadius(), "Tools.ShowSelectionLightRadius");
07822         addMenu(new LLToolsEditLinkedParts(), "Tools.EditLinkedParts");
07823         addMenu(new LLToolsSnapObjectXY(), "Tools.SnapObjectXY");
07824         addMenu(new LLToolsUseSelectionForGrid(), "Tools.UseSelectionForGrid");
07825         addMenu(new LLToolsLink(), "Tools.Link");
07826         addMenu(new LLToolsUnlink(), "Tools.Unlink");
07827         addMenu(new LLToolsStopAllAnimations(), "Tools.StopAllAnimations");
07828         addMenu(new LLToolsLookAtSelection(), "Tools.LookAtSelection");
07829         addMenu(new LLToolsBuyOrTake(), "Tools.BuyOrTake");
07830         addMenu(new LLToolsTakeCopy(), "Tools.TakeCopy");
07831         addMenu(new LLToolsSaveToInventory(), "Tools.SaveToInventory");
07832         addMenu(new LLToolsSaveToObjectInventory(), "Tools.SaveToObjectInventory");
07833         addMenu(new LLToolsSelectedScriptAction(), "Tools.SelectedScriptAction");
07834 
07835         addMenu(new LLToolsEnableToolNotPie(), "Tools.EnableToolNotPie");
07836         addMenu(new LLToolsEnableLink(), "Tools.EnableLink");
07837         addMenu(new LLToolsEnableUnlink(), "Tools.EnableUnlink");
07838         addMenu(new LLToolsEnableBuyOrTake(), "Tools.EnableBuyOrTake");
07839         addMenu(new LLToolsEnableTakeCopy(), "Tools.EnableTakeCopy");
07840         addMenu(new LLToolsEnableSaveToInventory(), "Tools.SaveToInventory");
07841         addMenu(new LLToolsEnableSaveToObjectInventory(), "Tools.SaveToObjectInventory");
07842 
07843         /*addMenu(new LLToolsVisibleBuyObject(), "Tools.VisibleBuyObject");
07844         addMenu(new LLToolsVisibleTakeObject(), "Tools.VisibleTakeObject");*/
07845 
07846         // Help menu
07847         // most items use the ShowFloater method
07848 
07849         // Self pie menu
07850         addMenu(new LLSelfStandUp(), "Self.StandUp");
07851         addMenu(new LLSelfRemoveAllAttachments(), "Self.RemoveAllAttachments");
07852 
07853         addMenu(new LLSelfEnableStandUp(), "Self.EnableStandUp");
07854         addMenu(new LLSelfEnableRemoveAllAttachments(), "Self.EnableRemoveAllAttachments");
07855 
07856          // Avatar pie menu
07857         addMenu(new LLObjectMute(), "Avatar.Mute");
07858         addMenu(new LLAvatarAddFriend(), "Avatar.AddFriend");
07859         addMenu(new LLAvatarFreeze(), "Avatar.Freeze");
07860         addMenu(new LLAvatarDebug(), "Avatar.Debug");
07861         addMenu(new LLAvatarVisibleDebug(), "Avatar.VisibleDebug");
07862         addMenu(new LLAvatarEnableDebug(), "Avatar.EnableDebug");
07863         addMenu(new LLAvatarInviteToGroup(), "Avatar.InviteToGroup");
07864         addMenu(new LLAvatarGiveCard(), "Avatar.GiveCard");
07865         addMenu(new LLAvatarEject(), "Avatar.Eject");
07866         addMenu(new LLAvatarSendIM(), "Avatar.SendIM");
07867         
07868         addMenu(new LLObjectEnableMute(), "Avatar.EnableMute");
07869         addMenu(new LLAvatarEnableAddFriend(), "Avatar.EnableAddFriend");
07870         addMenu(new LLAvatarEnableFreezeEject(), "Avatar.EnableFreezeEject");
07871 
07872         // Object pie menu
07873         addMenu(new LLObjectOpen(), "Object.Open");
07874         addMenu(new LLObjectBuild(), "Object.Build");
07875         addMenu(new LLObjectTouch(), "Object.Touch");
07876         addMenu(new LLObjectSitOrStand(), "Object.SitOrStand");
07877         addMenu(new LLObjectDelete(), "Object.Delete");
07878         addMenu(new LLObjectAttachToAvatar(), "Object.AttachToAvatar");
07879         addMenu(new LLObjectReturn(), "Object.Return");
07880         addMenu(new LLObjectReportAbuse(), "Object.ReportAbuse");
07881         addMenu(new LLObjectMute(), "Object.Mute");
07882         addMenu(new LLObjectBuy(), "Object.Buy");
07883         addMenu(new LLObjectEdit(), "Object.Edit");
07884         addMenu(new LLObjectInspect(), "Object.Inspect");
07885 
07886         addMenu(new LLObjectEnableOpen(), "Object.EnableOpen");
07887         addMenu(new LLObjectEnableTouch(), "Object.EnableTouch");
07888         addMenu(new LLObjectEnableSitOrStand(), "Object.EnableSitOrStand");
07889         addMenu(new LLObjectEnableDelete(), "Object.EnableDelete");
07890         addMenu(new LLObjectEnableWear(), "Object.EnableWear");
07891         addMenu(new LLObjectEnableReturn(), "Object.EnableReturn");
07892         addMenu(new LLObjectEnableReportAbuse(), "Object.EnableReportAbuse");
07893         addMenu(new LLObjectEnableMute(), "Object.EnableMute");
07894         addMenu(new LLObjectEnableBuy(), "Object.EnableBuy");
07895 
07896         /*addMenu(new LLObjectVisibleTouch(), "Object.VisibleTouch");
07897         addMenu(new LLObjectVisibleCustomTouch(), "Object.VisibleCustomTouch");
07898         addMenu(new LLObjectVisibleStandUp(), "Object.VisibleStandUp");
07899         addMenu(new LLObjectVisibleSitHere(), "Object.VisibleSitHere");
07900         addMenu(new LLObjectVisibleCustomSit(), "Object.VisibleCustomSit");*/
07901 
07902         // Attachment pie menu
07903         addMenu(new LLAttachmentDrop(), "Attachment.Drop");
07904         addMenu(new LLAttachmentDetach(), "Attachment.Detach");
07905 
07906         addMenu(new LLAttachmentEnableDrop(), "Attachment.EnableDrop");
07907         addMenu(new LLAttachmentEnableDetach(), "Attachment.EnableDetach");
07908 
07909         // Land pie menu
07910         addMenu(new LLLandBuild(), "Land.Build");
07911         addMenu(new LLLandSit(), "Land.Sit");
07912         addMenu(new LLLandBuyPass(), "Land.BuyPass");
07913         addMenu(new LLLandEdit(), "Land.Edit");
07914 
07915         addMenu(new LLLandEnableBuyPass(), "Land.EnableBuyPass");
07916 
07917         // Generic actions
07918         addMenu(new LLShowFloater(), "ShowFloater");
07919         addMenu(new LLPromptShowURL(), "PromptShowURL");
07920         addMenu(new LLPromptShowFile(), "PromptShowFile");
07921         addMenu(new LLShowAgentProfile(), "ShowAgentProfile");
07922         addMenu(new LLShowAgentGroups(), "ShowAgentGroups");
07923         addMenu(new LLToggleControl(), "ToggleControl");
07924 
07925         addMenu(new LLGoToObject(), "GoToObject");
07926         addMenu(new LLPayObject(), "PayObject");
07927 
07928         addMenu(new LLEnablePayObject(), "EnablePayObject");
07929         addMenu(new LLEnableEdit(), "EnableEdit");
07930 
07931         addMenu(new LLFloaterVisible(), "FloaterVisible");
07932         addMenu(new LLSomethingSelected(), "SomethingSelected");
07933         addMenu(new LLSomethingSelectedNoHUD(), "SomethingSelectedNoHUD");
07934         addMenu(new LLEditableSelected(), "EditableSelected");
07935 }

Generated on Fri May 16 08:34:12 2008 for SecondLife by  doxygen 1.5.5