// SpaceBall_Event(): double SpaceBall_Event( LWInstance _inst, const LWMasterAccess *access ) { if( access->eventCode == LWEVNT_COMMAND ) { if( strncmp( (const char *)access->eventData, "RenderFrame", 11 ) == 0 ) is_safe = false; else if( strncmp( (const char *)access->eventData, "RenderScene", 11 ) == 0 ) is_safe = false; else if( strncmp( (const char *)access->eventData, "RenderObject", 12 ) == 0 ) is_safe = false; if( sb_int != NULL ) { if( sb_int->IsOpen() ) { int do_capture; GET_INT( sb_int->capture, do_capture ); if( do_capture ) { if( (sb_int->current_function >= 0) && (sb_int->current_function < num_functions) ) { StringTools::strdup2( function_map[ sb_int->current_function ], (const char *)access->eventData ); REDRAW_CON( sb_int->list ); HandleList( sb_int->list, NULL ); } } } } } else if ( access->eventCode == LWEVNT_RENDER_DONE ) { is_safe = true; } return 0.0; }
// HandleClearAll(): void HandleClearAll( LWControl *con, void *data ) { if( (*rint->message->yesNo)( "Clear Swap List?", "Do you really want to clear the swap list?", NULL ) == 0 ) return; rint->swaps.Flush(); REDRAW_CON( rint->list ); HandleList( rint->list, NULL ); }
// HandleAdd(): void HandleAdd( LWControl *con, void *data ) { ReplaceObjects_SwapObject *new_swap = new ReplaceObjects_SwapObject; rint->swaps.Add( new_swap ); SET_IVEC( rint->list, (rint->swaps.NumElements() - 1), 1, 0 ); HandleSortBy( rint->sort_by_popup, NULL ); HandleList( rint->list, NULL ); }
CmdResult HandleLocal(LocalUser* user, const Params& parameters) override { if (parameters.empty()) { HandleList(user, false); return CMD_SUCCESS; } bool watch_l_done = false; bool watch_s_done = false; for (std::vector<std::string>::const_iterator i = parameters.begin(); i != parameters.end(); ++i) { const std::string& token = *i; char subcmd = toupper(token[0]); if (subcmd == '+') { HandlePlus(user, token.substr(1)); } else if (subcmd == '-') { HandleMinus(user, token.substr(1)); } else if (subcmd == 'C') { manager.UnwatchAll(user); } else if ((subcmd == 'L') && (!watch_l_done)) { watch_l_done = true; // WATCH L requests a full list with online and offline nicks // WATCH l requests a list with only online nicks HandleList(user, (token[0] == 'L')); } else if ((subcmd == 'S') && (!watch_s_done)) { watch_s_done = true; HandleStats(user); } } return CMD_SUCCESS; }
// HandleClone(): void HandleClone( LWControl *con, void *data ) { int index; GET_INT( rint->list, index ); if( index == -1 ) return; assert( index < (int)rint->swaps.NumElements() ); ReplaceObjects_SwapObject *new_swap = new ReplaceObjects_SwapObject; *new_swap = rint->swaps[ index ]; rint->swaps.Add( new_swap ); SET_IVEC( rint->list, (rint->swaps.NumElements() - 1), 1, 0 ); HandleSortBy( rint->sort_by_popup, NULL ); HandleList( rint->list, NULL ); }
// HandleRemove(): void HandleRemove( LWControl *con, void *data ) { int index; GET_INT( rint->list, index ); if( index == -1 ) return; assert( index < (int)rint->swaps.NumElements() ); delete rint->swaps[ index ]; rint->swaps.Remove( index ); if( index == (int)rint->swaps.NumElements() ) index--; SET_IVEC( rint->list, index, 1, 0 ); REDRAW_CON( rint->list ); HandleList( rint->list, NULL ); }
void HandleClear(LocalUser* user, std::string& result) { HandleList(result, user, false, false, true); capext.unset(user); }
// Returns a handle for positioning and rendering this face at the given size. Rocket::Core::FontFaceHandle* FontFace::GetHandle(const String& _raw_charset, int size) { UnicodeRangeList charset; HandleMap::iterator iterator = handles.find(size); if (iterator != handles.end()) { const HandleList& handles = (*iterator).second; // Check all the handles if their charsets match the requested one exactly (ie, were specified by the same // string). String raw_charset(_raw_charset); for (size_t i = 0; i < handles.size(); ++i) { if (handles[i]->GetRawCharset() == _raw_charset) { handles[i]->AddReference(); return (Rocket::Core::FreeType::FontFaceHandle*)handles[i]; } } // Check all the handles if their charsets contain the requested charset. if (!UnicodeRange::BuildList(charset, raw_charset)) { Log::Message(Log::LT_ERROR, "Invalid font charset '%s'.", _raw_charset.CString()); return NULL; } for (size_t i = 0; i < handles.size(); ++i) { bool range_contained = true; const UnicodeRangeList& handle_charset = handles[i]->GetCharset(); for (size_t j = 0; j < charset.size() && range_contained; ++j) { if (!charset[j].IsContained(handle_charset)) range_contained = false; } if (range_contained) { handles[i]->AddReference(); return (Rocket::Core::FreeType::FontFaceHandle*)handles[i]; } } } // See if this face has been released. if (face == NULL) { Log::Message(Log::LT_WARNING, "Font face has been released, unable to generate new handle."); return NULL; } // Construct and initialise the new handle. FontFaceHandle* handle = new FontFaceHandle(); if (!handle->Initialise(face, _raw_charset, size)) { handle->RemoveReference(); return NULL; } // Save the handle, and add a reference for the callee. The initial reference will be removed when the font face // releases it. if (iterator != handles.end()) (*iterator).second.push_back(handle); else handles[size] = HandleList(1, handle); handle->AddReference(); return handle; }
// OpenUI(): // Opens the user interface. Returns after the panel has been closed. bool ReplaceObjects_Interface::OpenUI() { // Destroy the panel if it hasn't been destroyed yet if( panel != NULL ) { (*panel_funcs->destroy)( panel ); panel = NULL; } char title_string[256]; sprintf( title_string, "ReplaceObjects -- %c2001 Joe Angell, TM Productions", 169 ); panel = (*panel_funcs->create)( title_string, panel_funcs ); if( !panel ) { // Make sure the panel was created (*message->error)("Error creating main panel, aborting", NULL ); return false; } // Limit To Pop-Up limit_to_popup = WPOPUP_CTL( panel_funcs, panel, "Limit To", limit_to_popup_strings, 110 ); // Sort By Pop-Up sort_by_popup = WPOPUP_CTL( panel_funcs, panel, "Sort By", sort_by_popup_strings, 110 ); PanelTools::PutOnLineWith( limit_to_popup, sort_by_popup, 10 ); // Match match_toggle = BOOL_CTL( panel_funcs, panel, "Match Name" ); match_string = STR_CTL( panel_funcs, panel, "Name Contains", 41 ); PanelTools::PutOnLineWith( match_toggle, match_string, 10 ); // List list = MULTILIST_CTL( panel_funcs, panel, "Swap Objects", 300, 20, ListNames, ListCount, ListColumnWidths ); PanelTools::PutUnder( match_toggle, list, 20 ); // Add add = WBUTTON_CTL( panel_funcs, panel, "Add", 60 ); PanelTools::PutOnLineWith( list, add, 3); // Clone clone = WBUTTON_CTL( panel_funcs, panel, "Clone", 60 ); PanelTools::AlignLabels( add, clone ); // Remove remove = WBUTTON_CTL( panel_funcs, panel, "Remove", 60 ); PanelTools::AlignLabels( clone, remove ); // Clear All clear_all = WBUTTON_CTL( panel_funcs, panel, "Clear All", 60 ); PanelTools::AlignLabels( remove, clear_all ); PanelTools::PutUnder( clear_all, clear_all ); // About about = WBUTTON_CTL( panel_funcs, panel, "About", 60 ); PanelTools::PutOnLineWith( sort_by_popup, about ); // Load load = LOADBUTTON_CTL( panel_funcs, panel, "Load", 60 ); PanelTools::PutOnLineWith( sort_by_popup, about ); // Save save = SAVEBUTTON_CTL( panel_funcs, panel, "Save", 60 ); PanelTools::PutOnLineWith( sort_by_popup, about ); // Path path = FILE_CTL( panel_funcs, panel, "Object Path", 59 ); PanelTools::PutUnder( list, path, 18 ); // Weight weight = FLOAT_CTL( panel_funcs, panel, "Weight" ); PanelTools::AlignLabels( path, weight ); // Enable enable = BOOL_CTL( panel_funcs, panel, "Enable" ); PanelTools::PutOnLineWith( weight, enable ); // Store Original Names store_original_name = BOOL_CTL( panel_funcs, panel, "Store Original Object Name As Tag" ); SET_INT( store_original_name, store_original_name_value ); PanelTools::AlignLabels( weight, store_original_name, 18 ); int x = CON_X( add ); int y = CON_Y( list ); int h = CON_H( list ); int h2 = CON_H( about ); MOVE_CON( about, x, (y + h) - h2 ); MOVE_CON( save, x, (y + h) - (h2 * 3) + 10 ); MOVE_CON( load, x, (y + h) - (h2 * 4) + 15 ); // Default Values SET_INT( list, -1 ); HandleList( list, NULL ); // Event Handlers CON_SETEVENT( list, HandleList, NULL ); CON_SETEVENT( about, HandleAbout, NULL ); CON_SETEVENT( sort_by_popup, HandleSortBy, NULL ); CON_SETEVENT( match_toggle, HandleMatchToggle, NULL ); CON_SETEVENT( add, HandleAdd, NULL ); CON_SETEVENT( clone, HandleClone, NULL ); CON_SETEVENT( remove, HandleRemove, NULL ); CON_SETEVENT( clear_all, HandleClearAll, NULL ); CON_SETEVENT( load, HandleLoad, NULL ); CON_SETEVENT( save, HandleSave, NULL ); CON_SETEVENT( path, HandlePath, NULL ); CON_SETEVENT( weight, HandleWeight, NULL ); CON_SETEVENT( enable, HandleEnable, NULL ); // Panel-Level Callbacks (*panel_funcs->set)( panel, PAN_USERDRAW, DrawPanel ); // Get a copy of the swaps swaps.Flush(); ReplaceObjects_SwapObject *new_swap; for( unsigned long i=0; i < old_swaps.NumElements(); i++ ) { new_swap = new ReplaceObjects_SwapObject; *new_swap = *old_swaps[i]; swaps.Add( new_swap ); } HandleMatchToggle( match_toggle, NULL ); // Open the Panel int retval = (*panel_funcs->open)( panel, PANF_BLOCKING | PANF_CANCEL | PANF_PASSALLKEYS ); if( retval > 0 ) { do_process = true; GET_INT( store_original_name, store_original_name_value ); old_swaps.Flush(); ReplaceObjects_SwapObject *new_swap; for( unsigned long i=0; i < swaps.NumElements(); i++ ) { new_swap = new ReplaceObjects_SwapObject; *new_swap = *swaps[i]; old_swaps.Add( new_swap ); } } return do_process; }