// 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; }
// HandleSortBy(): void HandleSortBy( LWControl *con, void *data ) { int state, index; GET_INT( rint->sort_by_popup, state ); GET_INT( rint->list, index ); // Store the item ReplaceObjects_SwapObject *swap = NULL; if( index != -1 ) { swap = rint->swaps[ index ]; assert( swap != NULL ); } // Sort the list if( state == 0 ) rint->swaps.QSort( SortSwapObjects_Alpha ); else rint->swaps.QSort( SortSwapObjects_Weight ); // Reselect the item if( swap != NULL ) { unsigned long new_index = rint->swaps.FindIndexOf( swap ); SET_IVEC( rint->list, new_index, 1, 0 ); } REDRAW_CON( rint->list ); }
// 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 ); }
// ShowGroupTab(): bool FreeKeyInterface::ShowGroupTab() { UNGHOST_CON( group_name ); UNGHOST_CON( group_delete ); UNGHOST_CON( group_edit_mode ); UNGHOST_CON( group_edit_apply ); REDRAW_CON( group_name ); return true; }
// SetStatusText(): // Sets the status text and mode. If the text is NULL, only the mode is changed. // the default mode is Info if none is provided. This function can optionally // redraw the status line after settings it's contents. void FreeKeyInterface::SetStatusText( const char *text, enum fk_status_mode mode, bool draw_now ) { if( text != NULL ) strcpy( status_text, text ); status_mode = mode; if( draw_now ) REDRAW_CON( fk_int->status_line ); }
// OnItemMultiScroll(): // Called to handle the custom scroll bar under the lister void OnItemMultiScroll( LWControl *ctl, int mx, fk_mousestate mouse_state ) { static last_clicked = CLICKED_NONE; static down_pos = 0; static item_pos = 0; // Mouse Released; Reset if( mouse_state == MSTATE_UP ) { SET_STR( fk_int->select_item_name, "MS: Mouse Released", strlen( "MS: Mouse Released" ) ); last_clicked = CLICKED_NONE; REDRAW_CON( fk_int->item_multiscroll ); return; } // Mouse was just clicked; see what was clicked if( mouse_state == MSTATE_DOWN ) { down_pos = mx; mx -= CON_HOTX( ctl ); // Test the Divider int div_near = mx > fk_int->ms_divider ? mx-fk_int->ms_divider: fk_int->ms_divider-mx; if( div_near < 6 ) { last_clicked = CLICKED_DIVIDER; item_pos = fk_int->ms_divider; SET_STR( fk_int->select_item_name, "MS: Clicked Divider", strlen( "MS: Clicked Divider" ) ); } return; } // Mouse Moved: Change some value if( mouse_state == MSTATE_MOVING ) { if( last_clicked == CLICKED_DIVIDER ) fk_int->ms_divider = mx; // fk_int->ms_divider = down_pos - item_pos + mx - item_pos; char buffer[ 64 ]; sprintf( buffer, "MS: Moved Divider to %d", fk_int->ms_divider ); SET_STR( fk_int->select_item_name, buffer, strlen( buffer ) ); REDRAW_CON( ctl ); } }
// 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 ); }
// ShowItemSelectionTab(): bool FreeKeyInterface::ShowItemSelectionTab() { UNGHOST_CON( select_item_name ); UNGHOST_CON( select_name_mode ); UNGHOST_CON( apply_select_item_name ); UNGHOST_CON( select_toggle ); UNGHOST_CON( select_item_mode ); UNGHOST_CON( select_info_area ); UNGHOST_CON( fk_int->select_children_toggle ); REDRAW_CON( select_item_name ); // Decide if the And Children toggle should be ghosted int sel_opt, sel_mode; GET_INT( fk_int->select_item_mode, sel_mode ); GET_INT( fk_int->select_toggle, sel_opt ); if( (sel_opt == 2) && (sel_mode > 0) ) GHOST_CON( fk_int->select_children_toggle ); return true; }
// UpdateProgress(): // Updates the progress bar. If the user aborted the process (closed // the Processing panel), then this returns false so FreeKey::Process() // knows to stop working. bool __cdecl UpdateProgress( char *name, int current, int total ) { if( !processing_open ) return true; // Free any existing progress bar item name if( fk_int->progress_name != NULL ) { free( fk_int->progress_name ); fk_int->progress_name = NULL; } // Fill in some progress info fk_int->progress_name = strdup( name ); fk_int->progress_cur = current; fk_int->progress_total = total; // Update the progress bar REDRAW_CON( fk_int->progress_bar ); // Return a continue/abort value return fk_continue_processing; }
// OnFreeKey(): // This actually processes the scene file. To make the process // interuptable, the process task is spawned as another thread. void OnFreeKey(LWControl *ctl, FreeKeyInterface *panel) { if( !fk_int->fkd->TestKey( fk_int->fkd->ReadKey(), fk_int->fkd->GetDongleID() ) ) { fk_int->message->Error( "FreeKey Error: Licence key not found; Processing disabled", "Registering FreeKey will make it fully functional." ); return; } if( fk_int->processing ) { fk_int->stop_processing = true; return; } fk_int->stop_processing = false; fk_int->processing = true; fk_int->progress_total = 1; fk_int->progress_cur = 0; // See if there's anything to Freekey if( !AnyAssignedToGroups( &fk->GetScene().GetBaseItem() ) ) { fk_int->SetStatusText( "ERROR: No items assigned to any groups", STATUSMODE_ERROR, true ); fk_int->message->Error( "Freekey Error: No items have", "been assigned to any groups! Aborting" ); fk_int->processing = false; fk_int->stop_processing = true; return; } // Change the FreeKey-ify control's text to Abort SET_STR( fk_int->freekey, "Abort Process", strlen( "Abort Process" ) ); REDRAW_CON( fk_int->freekey ); // Count the number of item for total fk_int->progress_total = fk->GetScene().GetBaseItem().CountItems(false, true); int error; try { // Begin Processing error = fk->Process( UpdateProgress ); if( error != FREEKEY_OK ) { if( error == FREEKEY_USER_ABORT ) { /// Check for an abort fk_int->message->Info( "FreeKey Info: User Abort", "Any partially written output file has been removed" ); } else throw false; } sprintf( fk_int->status_text, "Complete! Processed %d items sucessfully.", fk->GetNumObjectsProcessed() + fk->GetNumLightsProcessed() + fk->GetNumBonesProcessed() ); fk_int->SetStatusText( NULL, STATUSMODE_INFO, true ); fk_int->message->Info( "FreeKey Info: Processing comlete!" ); } catch( bool ) { // Handle Errors // fk->CloseFiles(); sprintf( fk_int->status_text, "ERROR: %s", FreeKey::GetErrorString( error ) ); fk_int->SetStatusText( NULL, STATUSMODE_ERROR, true ); fk_int->message->Error( "FreeKey Error, aborting:", FreeKey::GetErrorString( error ) ); } // Restore the FreeKey-ify control's text SET_STR( fk_int->freekey, "FreeKey-ify!", strlen( "FreeKey-ify!" ) ); REDRAW_CON( fk_int->freekey ); fk_int->processing = false; fk_int->stop_processing = false; }