/* BaseResourceArchivesPanel::onBtnAdd * Called when the 'Add Archive' button is clicked *******************************************************************/ void BaseResourceArchivesPanel::onBtnAdd(wxCommandEvent& e) { // Create extensions string string extensions = theArchiveManager->getArchiveExtensionsString(); // Open a file browser dialog that allows multiple selection wxFileDialog dialog_open(this, "Choose file(s) to open", dir_last, wxEmptyString, extensions, wxFD_OPEN|wxFD_MULTIPLE|wxFD_FILE_MUST_EXIST, wxDefaultPosition); // Run the dialog & check that the user didn't cancel if (dialog_open.ShowModal() == wxID_OK) { // Get an array of selected filenames wxArrayString files; dialog_open.GetPaths(files); // Add each to the paths list for (size_t a = 0; a < files.size(); a++) { if (theArchiveManager->addBaseResourcePath(files[a])) list_base_archive_paths->Append(files[a]); } // Save 'dir_last' dir_last = dialog_open.GetDirectory(); } }
void mouse_clickfunc(int button, int state, int x, int y) { if (is_dialog()) { dialog_click(button,state,x,y); return; } // test global ui elements if (button==GLUT_LEFT_BUTTON) { if (state==GLUT_DOWN) { if (main_ui[MAIN_PAGE1]) { console_post("Synthesizers"); cpage=1; return; } if (main_ui[MAIN_PAGE2]) { console_post("Patches"); cpage=2; return; } if (main_ui[MAIN_PAGE3]) { console_post("Patterns"); cpage=3; return; } if (main_ui[MAIN_PAGE4]) { console_post("Sequencer"); cpage=4; return; } if (main_ui[MAIN_ABOUT]) { dialog_open(&about_draw, &about_hover, &about_click); return; } if (main_ui[MAIN_VU]) { audio_peak=0.0f; console_post("VU meter peak reset"); return; } } } switch (cpage) { case MAIN_PAGE1: synth_mouse_click(button, state, x, y); break; case MAIN_PAGE2: patch_mouse_click(button, state, x, y); break; case MAIN_PAGE3: pattern_mouse_click(button, state, x, y); break; case MAIN_PAGE4: sequencer_mouse_click(button, state, x, y); break; default: break; } }
void palette_scenery_open(int x,int y) { ControlID ctrl_id; EventHandlerUPP tab_event_upp; EventTypeSpec tab_event_list[]={{kEventClassControl,kEventControlHit}, {kEventClassKeyboard,kEventRawKeyUp}}; // open the window dialog_open(&palette_scenery_wind,"SceneryPalette"); MoveWindow(palette_scenery_wind,x,y,FALSE); // setup the tabs dialog_set_tab(palette_scenery_wind,kSceneryTab,0,0,kSceneryTabCount); ctrl_id.signature=kSceneryTab; ctrl_id.id=0; GetControlByID(palette_scenery_wind,&ctrl_id,&palette_scenery_tab); tab_event_upp=NewEventHandlerUPP(palette_scenery_tab_proc); InstallControlEventHandler(palette_scenery_tab,tab_event_upp,GetEventTypeCount(tab_event_list),tab_event_list,palette_scenery_wind,NULL); // show palette ShowWindow(palette_scenery_wind); }
void dialog_preference_run(void) { EventHandlerUPP event_upp; EventTypeSpec event_list[]={{kEventClassCommand,kEventProcessCommand}}; // open the dialog dialog_open(&dialog_preference_wind,"Preferences"); // set controls dialog_set_text(dialog_preference_wind,kPrefEngineName,0,setup.engine_name); dialog_set_combo(dialog_preference_wind,kPrefMipMapMode,0,setup.mipmap_mode); dialog_set_boolean(dialog_preference_wind,kPrefAutoTexture,0,setup.auto_texture); dialog_set_int(dialog_preference_wind,kPrefDuplicateOffset,0,setup.duplicate_offset); dialog_set_color(dialog_preference_wind,kPrefBackgroundColor,0,&setup.col.background); dialog_set_color(dialog_preference_wind,kPrefLineColor,0,&setup.col.mesh_line); dialog_set_color(dialog_preference_wind,kPrefMeshSelColor,0,&setup.col.mesh_sel); dialog_set_color(dialog_preference_wind,kPrefPolySelColor,0,&setup.col.poly_sel); // show window ShowWindow(dialog_preference_wind); // install event handler event_upp=NewEventHandlerUPP(preference_event_proc); InstallWindowEventHandler(dialog_preference_wind,event_upp,GetEventTypeCount(event_list),event_list,NULL,NULL); // modal window dialog_preference_cancel=FALSE; RunAppModalLoopForWindow(dialog_preference_wind); // dialog to data if (!dialog_preference_cancel) { dialog_get_text(dialog_preference_wind,kPrefEngineName,0,setup.engine_name,256); setup.mipmap_mode=dialog_get_combo(dialog_preference_wind,kPrefMipMapMode,0); setup.auto_texture=dialog_get_boolean(dialog_preference_wind,kPrefAutoTexture,0); setup.duplicate_offset=dialog_get_int(dialog_preference_wind,kPrefDuplicateOffset,0); dialog_get_color(dialog_preference_wind,kPrefBackgroundColor,0,&setup.col.background); dialog_get_color(dialog_preference_wind,kPrefLineColor,0,&setup.col.mesh_line); dialog_get_color(dialog_preference_wind,kPrefMeshSelColor,0,&setup.col.mesh_sel); dialog_get_color(dialog_preference_wind,kPrefPolySelColor,0,&setup.col.poly_sel); setup_xml_write(); } // close window DisposeWindow(dialog_preference_wind); }
bool dialog_play_blend_animation_run(void) { EventHandlerUPP event_upp; EventTypeSpec event_list[]={{kEventClassCommand,kEventProcessCommand}}; // open the dialog dialog_open(&dialog_play_blend_animation_wind,"BlendAnimation"); // set controls dialog_set_animate_combo(dialog_play_blend_animation_wind,kBlendAnimate1,0,play_animate_blend_idx[0],FALSE); dialog_set_animate_combo(dialog_play_blend_animation_wind,kBlendAnimate2,0,play_animate_blend_idx[1],TRUE); dialog_set_animate_combo(dialog_play_blend_animation_wind,kBlendAnimate3,0,play_animate_blend_idx[2],TRUE); dialog_set_animate_combo(dialog_play_blend_animation_wind,kBlendAnimate4,0,play_animate_blend_idx[3],TRUE); // show window ShowWindow(dialog_play_blend_animation_wind); // install event handler event_upp=NewEventHandlerUPP(play_blend_animation_event_proc); InstallWindowEventHandler(dialog_play_blend_animation_wind,event_upp,GetEventTypeCount(event_list),event_list,NULL,NULL); // modal window dialog_play_blend_animation_cancel=FALSE; RunAppModalLoopForWindow(dialog_play_blend_animation_wind); // dialog to data if (!dialog_play_blend_animation_cancel) { // get play animations play_animate_blend_idx[0]=dialog_get_animate_combo(dialog_play_blend_animation_wind,kBlendAnimate1,0,FALSE); play_animate_blend_idx[1]=dialog_get_animate_combo(dialog_play_blend_animation_wind,kBlendAnimate2,0,TRUE); play_animate_blend_idx[2]=dialog_get_animate_combo(dialog_play_blend_animation_wind,kBlendAnimate3,0,TRUE); play_animate_blend_idx[3]=dialog_get_animate_combo(dialog_play_blend_animation_wind,kBlendAnimate4,0,TRUE); } // close window DisposeWindow(dialog_play_blend_animation_wind); return(!dialog_play_blend_animation_cancel); }
bool dialog_mesh_info_run(model_mesh_type *mesh) { EventHandlerUPP event_upp; EventTypeSpec event_list[]={{kEventClassCommand,kEventProcessCommand}}; // open the dialog dialog_open(&dialog_mesh_info_wind,"MeshInfo"); // setup the controls dialog_set_text(dialog_mesh_info_wind,kMeshInfoName,0,mesh->name); dialog_set_boolean(dialog_mesh_info_wind,kMeshNoLighting,0,mesh->no_lighting); dialog_set_boolean(dialog_mesh_info_wind,kMeshAdditive,0,mesh->blend_add); dialog_set_boolean(dialog_mesh_info_wind,kMeshTintable,0,mesh->tintable); // show window ShowWindow(dialog_mesh_info_wind); // install event handler event_upp=NewEventHandlerUPP(mesh_info_event_proc); InstallWindowEventHandler(dialog_mesh_info_wind,event_upp,GetEventTypeCount(event_list),event_list,NULL,NULL); // modal window dialog_cancel=FALSE; dialog_set_focus(dialog_mesh_info_wind,'name',0); RunAppModalLoopForWindow(dialog_mesh_info_wind); if (!dialog_cancel) { dialog_get_text(dialog_mesh_info_wind,kMeshInfoName,0,mesh->name,name_str_len); mesh->no_lighting=dialog_get_boolean(dialog_mesh_info_wind,kMeshNoLighting,0); mesh->blend_add=dialog_get_boolean(dialog_mesh_info_wind,kMeshAdditive,0); mesh->tintable=dialog_get_boolean(dialog_mesh_info_wind,kMeshTintable,0); } // close window DisposeWindow(dialog_mesh_info_wind); return(!dialog_cancel); }
bool dialog_create_grid_mesh_run(int *xdiv,int *ydiv,int *zdiv) { EventHandlerUPP event_upp; EventTypeSpec event_list[]={{kEventClassCommand,kEventProcessCommand}}; // open the dialog dialog_open(&dialog_create_grid_mesh_wind,"GridMesh"); // install event handler event_upp=NewEventHandlerUPP(create_grid_mesh_event_proc); InstallWindowEventHandler(dialog_create_grid_mesh_wind,event_upp,GetEventTypeCount(event_list),event_list,NULL,NULL); // setup controls dialog_set_int(dialog_create_grid_mesh_wind,kGridMeshXDivision,0,10); dialog_set_int(dialog_create_grid_mesh_wind,kGridMeshYDivision,0,10); dialog_set_int(dialog_create_grid_mesh_wind,kGridMeshZDivision,0,10); // show window ShowWindow(dialog_create_grid_mesh_wind); // modal window dialog_create_grid_mesh_cancel=FALSE; RunAppModalLoopForWindow(dialog_create_grid_mesh_wind); // get object name if (!dialog_create_grid_mesh_cancel) { *xdiv=dialog_get_int(dialog_create_grid_mesh_wind,kGridMeshXDivision,0); *ydiv=dialog_get_int(dialog_create_grid_mesh_wind,kGridMeshYDivision,0); *zdiv=dialog_get_int(dialog_create_grid_mesh_wind,kGridMeshZDivision,0); } // close window DisposeWindow(dialog_create_grid_mesh_wind); return(!dialog_create_grid_mesh_cancel); }
bool dialog_save_run(void) { bool dialog_save_ok; WindowRef dialog_save_wind; SetCursor(*GetCursor(watchCursor)); dialog_open(&dialog_save_wind,"Save"); ShowWindow(dialog_save_wind); node_path_rebuild(); dialog_save_ok=map_save(&map); DisposeWindow(dialog_save_wind); InitCursor(); return(dialog_save_ok); }
void palette_polygon_open(int x,int y) { EventHandlerUPP event_upp; EventTypeSpec event_list[]={{kEventClassControl,kEventControlHit}, {kEventClassKeyboard,kEventRawKeyUp}}; // open the window dialog_open(&palette_poly_wind,"PolyPalette"); MoveWindow(palette_poly_wind,x,y,FALSE); // show palette ShowWindow(palette_poly_wind); // install event handler event_upp=NewEventHandlerUPP(palette_poly_event_proc); InstallWindowEventHandler(palette_poly_wind,event_upp,GetEventTypeCount(event_list),event_list,NULL,NULL); }
bool dialog_group_settings_run(group_type *group) { EventHandlerUPP event_upp; EventTypeSpec event_list[]={{kEventClassCommand,kEventProcessCommand}}; // open the dialog dialog_open(&dialog_group_settings_wind,"GroupSettings"); // set controls dialog_set_text(dialog_group_settings_wind,kGroupName,0,group->name); // show window ShowWindow(dialog_group_settings_wind); // install event handler event_upp=NewEventHandlerUPP(group_setting_event_proc); InstallWindowEventHandler(dialog_group_settings_wind,event_upp,GetEventTypeCount(event_list),event_list,NULL,NULL); // modal window dialog_group_settings_cancel=FALSE; RunAppModalLoopForWindow(dialog_group_settings_wind); // dialog to data if (!dialog_group_settings_cancel) { dialog_get_text(dialog_group_settings_wind,kGroupName,0,group->name,name_str_len); } // close window DisposeWindow(dialog_group_settings_wind); return(!dialog_group_settings_cancel); }
/* TranslationEditorDialog::onBtnLoad * Called when the 'Load Translation' button is clicked *******************************************************************/ void TranslationEditorDialog::onBtnLoad(wxCommandEvent& e) { // Get user directory string dir = appPath("translations", DIR_USER); // Create open file dialog wxFileDialog dialog_open(this, "Load Translation from File", dir, wxEmptyString, "Text Files (*.txt)|*.txt", wxFD_OPEN|wxFD_FILE_MUST_EXIST, wxDefaultPosition); // Run the dialog & check that the user didn't cancel if (dialog_open.ShowModal() == wxID_OK) { // Get the selected filename string filename = dialog_open.GetPath(); // Load file in a tokenizer Tokenizer tz; tz.openFile(dialog_open.GetPath()); // Parse translation Translation trans; string token = tz.getToken(); while (!token.IsEmpty()) { // Parse translation range trans.parse(token); tz.getToken(); // Skip , token = tz.getToken(); } // Open it if parsed ok if (trans.nRanges() > 0) openTranslation(trans); else wxMessageBox("Not a valid translation file", "Error", wxICON_ERROR); } }
/* TextureXPanel::newTextureFromFile * Creates a new texture from an image file. The file will be * imported and added to the patch table if needed *******************************************************************/ void TextureXPanel::newTextureFromFile() { // Get all entry types vector<EntryType*> etypes = EntryType::allTypes(); // Go through types string ext_filter = "All files (*.*)|*.*|"; for (unsigned a = 0; a < etypes.size(); a++) { // If the type is a valid image type, add its extension filter if (etypes[a]->extraProps().propertyExists("image")) { ext_filter += etypes[a]->getFileFilterString(); ext_filter += "|"; } } // Create open file dialog wxFileDialog dialog_open(this, "Choose file(s) to open", dir_last, wxEmptyString, ext_filter, wxFD_OPEN|wxFD_MULTIPLE|wxFD_FILE_MUST_EXIST, wxDefaultPosition); // Run the dialog & check that the user didn't cancel if (dialog_open.ShowModal() == wxID_OK) { // Get file selection wxArrayString files; dialog_open.GetPaths(files); // Save 'dir_last' dir_last = dialog_open.GetDirectory(); // Go through file selection for (unsigned a = 0; a < files.size(); a++) { // Load the file into a temporary ArchiveEntry ArchiveEntry* entry = new ArchiveEntry(); entry->importFile(files[a]); // Determine type EntryType::detectEntryType(entry); // If it's not a valid image type, ignore this file if (!entry->getType()->extraProps().propertyExists("image")) { wxLogMessage("%s is not a valid image file", files[a]); continue; } // Ask for name for texture wxFileName fn(files[a]); string name = fn.GetName().Upper().Truncate(8); name = wxGetTextFromUser(S_FMT("Enter a texture name for %s:", fn.GetFullName()), "New Texture", name); name = name.Truncate(8); // Add patch to archive entry->setName(name); entry->setExtensionByType(); tx_entry->getParent()->addEntry(entry, "patches"); // Add patch to patch table if needed if (texturex.getFormat() != TXF_TEXTURES) tx_editor->patchTable().addPatch(name); // Create new texture from patch CTexture* tex = newTextureFromPatch(name, name); // Add texture after the last selected item int selected = list_textures->getLastSelected(); if (selected == -1) selected = texturex.nTextures() - 1; // Add to end of the list if nothing selected texturex.addTexture(tex, selected + 1); // Record undo level undo_manager->beginRecord("New Texture from File"); undo_manager->recordUndoStep(new TextureCreateDeleteUS(this, tex, true)); undo_manager->endRecord(true); // Update texture list list_textures->updateList(); // Select the new texture list_textures->clearSelection(); list_textures->selectItem(selected + 1); list_textures->EnsureVisible(selected + 1); // Update patch table counts tx_editor->patchTable().updatePatchUsage(tex); } } }
/* PatchTablePanel::onBtnPatchFromFile * Called when the 'New Patch from File' button is clicked *******************************************************************/ void PatchTablePanel::onBtnPatchFromFile(wxCommandEvent& e) { // Get all entry types vector<EntryType*> etypes = EntryType::allTypes(); // Go through types string ext_filter = "All files (*.*)|*.*|"; for (unsigned a = 0; a < etypes.size(); a++) { // If the type is a valid image type, add its extension filter if (etypes[a]->extraProps().propertyExists("image")) { ext_filter += etypes[a]->getFileFilterString(); ext_filter += "|"; } } // Create open file dialog wxFileDialog dialog_open(this, "Choose file(s) to open", dir_last, wxEmptyString, ext_filter, wxFD_OPEN|wxFD_MULTIPLE|wxFD_FILE_MUST_EXIST, wxDefaultPosition); // Run the dialog & check that the user didn't cancel if (dialog_open.ShowModal() == wxID_OK) { // Get file selection wxArrayString files; dialog_open.GetPaths(files); // Save 'dir_last' dir_last = dialog_open.GetDirectory(); // Go through file selection for (unsigned a = 0; a < files.size(); a++) { // Load the file into a temporary ArchiveEntry ArchiveEntry* entry = new ArchiveEntry(); entry->importFile(files[a]); // Determine type EntryType::detectEntryType(entry); // If it's not a valid image type, ignore this file if (!entry->getType()->extraProps().propertyExists("image")) { wxLogMessage("%s is not a valid image file", files[a]); continue; } // Ask for name for patch wxFileName fn(files[a]); string name = fn.GetName().Upper().Truncate(8); name = wxGetTextFromUser(S_FMT("Enter a patch name for %s:", fn.GetFullName()), "New Patch", name); name = name.Truncate(8); // Add patch to archive entry->setName(name); entry->setExtensionByType(); parent->getArchive()->addEntry(entry, "patches"); // Add patch to patch table patch_table->addPatch(name); } // Refresh patch list list_patches->updateList(); parent->pnamesModified(true); } }
int main(int argc, char **argv) { int err; #ifdef __APPLE__ char *cfrespath; CFBundleRef mainBundle; CFURLRef res; CFStringRef respathref; #endif // load config file from user's homedir dotfile_load(); // calculate tables for supersaw calc_supersaw_tables(); // init data on all pages to defaults synth_init(); patch_init(); pattern_init(); sequencer_init(); // init glut glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(DS_WIDTH,DS_HEIGHT); glutCreateWindow("komposter"); glutIgnoreKeyRepeat(1); #ifdef __APPLE__ // get application bundle base path mainBundle=CFBundleGetMainBundle(); res=CFBundleCopyBundleURL(mainBundle); respathref=CFURLCopyFileSystemPath(res, 0); cfrespath=(char*)CFStringGetCStringPtr(respathref, kCFStringEncodingISOLatin1); if (!cfrespath) { cfrespath=malloc(512); CFStringGetCString(respathref, cfrespath, 511, kCFStringEncodingISOLatin1); strncpy(respath, cfrespath, 511); free(cfrespath); } else { strncpy(respath, cfrespath, 511); } strncat(respath, "/Contents/Resources/", 511); // append the resource dir #else #ifdef RESOURCEPATH if(is_dir(RESOURCEPATH)) { strncpy(respath, RESOURCEPATH, 511); } else { fprintf(stderr, "'%s' not found, trying relative path\n", RESOURCEPATH); strncpy(respath, "resources/", 511); } #else strncpy(respath, "resources/", 512); #endif #endif printf("Resource path is %s\n", respath); // init freetype err=font_init(); if (!err) { printf("Error initializing Freetype!\n"); return 0; } // set glut callbacks glutKeyboardFunc(keyboardfunc); glutKeyboardUpFunc(keyboardupfunc); glutMouseFunc(mouse_clickfunc); glutMotionFunc(mouse_dragfunc); glutSpecialFunc(specialkeyfunc); glutPassiveMotionFunc(mouse_hoverfunc); // init memory manager kmm_init(); // set up screen and fire up the update timer cpage=MAIN_PAGE4; glutDisplayFunc(display); glutTimerFunc(20, update, 1); dialog_open(&about_draw, &about_hover, &about_click); // start audio and opengl mainloop atexit(cleanup); if (!audio_initialize()) { printf("Failed to initialize audio playback - sound is disabled.\n"); } else { err = pthread_create(&audiothread, NULL, audio_playback, (void *)NULL); } err = pthread_create(&renderthread, NULL, audio_renderer, (void *)NULL); glutMainLoop(); return 0; }
bool dialog_movement_move_settings_run(movement_move_type *move) { EventHandlerUPP event_upp; EventTypeSpec event_list[]={{kEventClassCommand,kEventProcessCommand}}; // open the dialog dialog_open(&dialog_movement_move_settings_wind,"MovementMoveSettings"); // set controls dialog_set_int(dialog_movement_move_settings_wind,kMoveMillisecond,0,move->msec); dialog_set_int(dialog_movement_move_settings_wind,kMoveUserID,0,move->user_id); dialog_special_combo_fill_sound(dialog_movement_move_settings_wind,kMoveSoundName,0,move->sound_name); dialog_set_float(dialog_movement_move_settings_wind,kMoveSoundPitch,0,move->sound_pitch); dialog_set_int(dialog_movement_move_settings_wind,kMoveMoveX,0,move->mov.x); dialog_set_int(dialog_movement_move_settings_wind,kMoveMoveY,0,move->mov.y); dialog_set_int(dialog_movement_move_settings_wind,kMoveMoveZ,0,move->mov.z); dialog_set_float(dialog_movement_move_settings_wind,kMoveRotX,0,move->rot.x); dialog_set_float(dialog_movement_move_settings_wind,kMoveRotY,0,move->rot.y); dialog_set_float(dialog_movement_move_settings_wind,kMoveRotZ,0,move->rot.z); // show window ShowWindow(dialog_movement_move_settings_wind); // install event handler event_upp=NewEventHandlerUPP(movement_move_settings_event_proc); InstallWindowEventHandler(dialog_movement_move_settings_wind,event_upp,GetEventTypeCount(event_list),event_list,NULL,NULL); // modal window dialog_movement_move_settings_cancel=FALSE; RunAppModalLoopForWindow(dialog_movement_move_settings_wind); // dialog to data if (!dialog_movement_move_settings_cancel) { move->msec=dialog_get_int(dialog_movement_move_settings_wind,kMoveMillisecond,0); move->user_id=dialog_get_int(dialog_movement_move_settings_wind,kMoveUserID,0); dialog_special_combo_get_sound(dialog_movement_move_settings_wind,kMoveSoundName,0,move->sound_name,name_str_len); move->sound_pitch=dialog_get_float(dialog_movement_move_settings_wind,kMoveSoundPitch,0); move->mov.x=dialog_get_int(dialog_movement_move_settings_wind,kMoveMoveX,0); move->mov.y=dialog_get_int(dialog_movement_move_settings_wind,kMoveMoveY,0); move->mov.z=dialog_get_int(dialog_movement_move_settings_wind,kMoveMoveZ,0); move->rot.x=dialog_get_float(dialog_movement_move_settings_wind,kMoveRotX,0); move->rot.y=dialog_get_float(dialog_movement_move_settings_wind,kMoveRotY,0); move->rot.z=dialog_get_float(dialog_movement_move_settings_wind,kMoveRotZ,0); } // close window DisposeWindow(dialog_movement_move_settings_wind); return(!dialog_movement_move_settings_cancel); }
bool dialog_animation_settings_run(int animate_idx) { int i,pose_move_idx; ControlRef ctrl; ControlID ctrl_id; DataBrowserItemID itemID; DataBrowserCallbacks dbcall; DataBrowserItemDataUPP pose_list_item_upp,particle_list_item_upp,ring_list_item_upp; DataBrowserItemNotificationUPP pose_list_notify_upp,particle_list_notify_upp,ring_list_notify_upp; EventHandlerUPP event_upp,tab_event_upp; EventLoopTimerRef timer_event; EventLoopTimerUPP timer_upp; EventTypeSpec event_list[]={{kEventClassCommand,kEventProcessCommand}}, tab_event_list[]={{kEventClassCommand,kEventProcessCommand}, {kEventClassControl,kEventControlHit}}; // backup animation for cancel memmove(&animate_backup,&model.animates[animate_idx],sizeof(model_animate_type)); // if there is no pose moves or new animation, // then we need to add a default pose pose_move_idx=0; if (model.animates[animate_idx].npose_move==0) { pose_move_idx=model_animate_pose_insert(&model,animate_idx,-1,0); } // open the dialog dialog_open(&dialog_animation_settings_wind,"AnimationSettings"); // tab dialog_set_tab(dialog_animation_settings_wind,kAnimationPoseTab,0,0,kAnimationPoseTabCount); ctrl_id.signature=kAnimationPoseTab; ctrl_id.id=0; GetControlByID(dialog_animation_settings_wind,&ctrl_id,&ctrl); tab_event_upp=NewEventHandlerUPP(pose_move_setting_tab_proc); InstallControlEventHandler(ctrl,tab_event_upp,GetEventTypeCount(tab_event_list),tab_event_list,dialog_animation_settings_wind,NULL); // set pose list dialog_animate_idx=animate_idx; dialog_pose_move_idx=pose_move_idx; ctrl_id.signature=kAnimationPoseList; ctrl_id.id=0; GetControlByID(dialog_animation_settings_wind,&ctrl_id,&dialog_pose_move_list); dbcall.version=kDataBrowserLatestCallbacks; InitDataBrowserCallbacks(&dbcall); pose_list_item_upp=NewDataBrowserItemDataUPP(&pose_list_item_proc); dbcall.u.v1.itemDataCallback=pose_list_item_upp; pose_list_notify_upp=NewDataBrowserItemNotificationUPP(&pose_list_notify_proc); dbcall.u.v1.itemNotificationCallback=pose_list_notify_upp; SetDataBrowserCallbacks(dialog_pose_move_list,&dbcall); AddDataBrowserItems(dialog_pose_move_list,kDataBrowserNoItem,model.animates[dialog_animate_idx].npose_move,NULL,kDataBrowserItemNoProperty); dialog_pose_move_change_ok=FALSE; itemID=pose_move_idx+1; SetDataBrowserSelectedItems(dialog_pose_move_list,1,&itemID,kDataBrowserItemsAssign); dialog_pose_move_change_ok=TRUE; // setup particle list ctrl_id.signature=kAnimationParticleList; ctrl_id.id=0; GetControlByID(dialog_animation_settings_wind,&ctrl_id,&dialog_particle_list); dbcall.version=kDataBrowserLatestCallbacks; InitDataBrowserCallbacks(&dbcall); particle_list_item_upp=NewDataBrowserItemDataUPP(&particle_list_item_proc); dbcall.u.v1.itemDataCallback=particle_list_item_upp; particle_list_notify_upp=NewDataBrowserItemNotificationUPP(&particle_list_notify_proc); dbcall.u.v1.itemNotificationCallback=particle_list_notify_upp; SetDataBrowserCallbacks(dialog_particle_list,&dbcall); // setup ring list ctrl_id.signature=kAnimationRingList; ctrl_id.id=0; GetControlByID(dialog_animation_settings_wind,&ctrl_id,&dialog_ring_list); dbcall.version=kDataBrowserLatestCallbacks; InitDataBrowserCallbacks(&dbcall); ring_list_item_upp=NewDataBrowserItemDataUPP(&ring_list_item_proc); dbcall.u.v1.itemDataCallback=ring_list_item_upp; ring_list_notify_upp=NewDataBrowserItemNotificationUPP(&ring_list_notify_proc); dbcall.u.v1.itemNotificationCallback=ring_list_notify_upp; SetDataBrowserCallbacks(dialog_ring_list,&dbcall); // fill pose combo dialog_clear_combo(dialog_animation_settings_wind,kAnimationPosePose,0); for (i=0;i!=model.npose;i++) { dialog_add_combo_item(dialog_animation_settings_wind,kAnimationPosePose,0,model.poses[i].name,FOUR_CHAR_CODE('\?\?\?\?')); } // fill mesh combo (leave none in list) for (i=0;i!=model.nmesh;i++) { dialog_add_combo_item(dialog_animation_settings_wind,kAnimationMeshName,0,model.meshes[i].name,FOUR_CHAR_CODE('\?\?\?\?')); } // load setting data dialog_set_text(dialog_animation_settings_wind,kAnimationName,0,model.animates[animate_idx].name); dialog_set_boolean(dialog_animation_settings_wind,kAnimationLoop,0,model.animates[animate_idx].loop); dialog_set_focus(dialog_animation_settings_wind,kAnimationName,0); // load pose move data dialog_pose_move_settings_load(); dialog_animation_settings_cancel=FALSE; // show window ShowWindow(dialog_animation_settings_wind); // install event handler event_upp=NewEventHandlerUPP(animation_settings_event_proc); InstallWindowEventHandler(dialog_animation_settings_wind,event_upp,GetEventTypeCount(event_list),event_list,NULL,NULL); // modal window and timer timer_upp=NewEventLoopTimerUPP(pose_move_timer); InstallEventLoopTimer(GetCurrentEventLoop(),0,0.01,timer_upp,NULL,&timer_event); RunAppModalLoopForWindow(dialog_animation_settings_wind); RemoveEventLoopTimer(timer_event); DisposeEventLoopTimerUPP(timer_upp); // dialog to data dialog_get_text(dialog_animation_settings_wind,kAnimationName,0,model.animates[animate_idx].name,name_str_len); model.animates[animate_idx].loop=dialog_get_boolean(dialog_animation_settings_wind,kAnimationLoop,0); dialog_pose_move_settings_save(); // close window DisposeDataBrowserItemDataUPP(pose_list_item_upp); DisposeDataBrowserItemNotificationUPP(pose_list_notify_upp); DisposeDataBrowserItemDataUPP(particle_list_item_upp); DisposeDataBrowserItemNotificationUPP(particle_list_notify_upp); DisposeDataBrowserItemDataUPP(ring_list_item_upp); DisposeDataBrowserItemNotificationUPP(ring_list_notify_upp); DisposeWindow(dialog_animation_settings_wind); // if cancel, reset animation if (dialog_animation_settings_cancel) { memmove(&model.animates[animate_idx],&animate_backup,sizeof(model_animate_type)); } reset_animate_list(); return(!dialog_animation_settings_cancel); }