void SBehaviorTreeBlackboardEditor::HandleDeleteEntry() { check(BlackboardData); if(!IsDebuggerActive()) { bool bIsInherited = false; FBlackboardEntry* BlackboardEntry = GetSelectedEntry(bIsInherited); if(BlackboardEntry != nullptr && !bIsInherited) { const FScopedTransaction Transaction(LOCTEXT("BlackboardEntryDeleteTransaction", "Delete Blackboard Entry")); BlackboardData->SetFlags(RF_Transactional); BlackboardData->Modify(); for(int32 ItemIndex = 0; ItemIndex < BlackboardData->Keys.Num(); ItemIndex++) { if(BlackboardEntry == &BlackboardData->Keys[ItemIndex]) { BlackboardData->Keys.RemoveAt(ItemIndex); break; } } GraphActionMenu->RefreshAllActions(true); OnBlackboardKeyChanged.ExecuteIfBound(BlackboardData, nullptr); // signal de-selection if(OnEntrySelected.IsBound()) { OnEntrySelected.Execute(nullptr, false); } } } }
SLISTITEM* CPlaylist::getSelectedItem() { CListItem<SLISTITEM*>* pListItem = (CListItem<SLISTITEM*>*)GetSelectedEntry(); if(pListItem != NULL) { SLISTITEM *pItem = pListItem->GetItemData(); return pItem; } return NULL; }
void ExploreFrame::OnReplaceClicked( wxCommandEvent& event ) { const WADArchiveEntry& entry = GetSelectedEntry(); wxFileName entryFN(entry.GetFileName()); wxFileDialog fileDlg(this, wxString::Format(_("Select file to replace %s"), entry.GetFileName()), wxString(), entryFN.GetFullName(), "*." + entryFN.GetExt(), wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST); if (fileDlg.ShowModal() == wxID_OK) { if (entryFN.GetExt().IsSameAs("png", false)) { wxString imgErrors; // Do some sanity checks on the replacement image wxImage replaceImage(fileDlg.GetPath()); if (replaceImage.IsOk()) { if (replaceImage.HasAlpha()) imgErrors += _("- Image may not have an alpha mask\n"); wxMemoryOutputStream oStr; m_archive->Extract(entry, oStr); wxStreamBuffer* buffer = oStr.GetOutputStreamBuffer(); wxMemoryInputStream iStr(buffer->GetBufferStart(), buffer->GetBufferSize()); wxImage orgImage(iStr); if (orgImage.GetSize() != replaceImage.GetSize()) imgErrors += wxString::Format(_("- Image has to be %dx%d in size\n"), orgImage.GetSize().x, orgImage.GetSize().y); if (orgImage.HasMask() != replaceImage.HasMask()) imgErrors += _("- Image must have transparency\n"); } else imgErrors = _("Image could not be loaded"); if (!imgErrors.empty()) { wxMessageDialog msgDlg(this, wxString::Format( _("Image Errors\n\nThe replacement image contains erros which might crash the game\n\n%s\n\nDo you want't to replace anyway?"), imgErrors), _("Warning"), wxICON_WARNING | wxYES_NO | wxNO_DEFAULT); msgDlg.SetYesNoLabels(_("Replace"), _("Don't Replace")); if (msgDlg.ShowModal() != wxID_YES) return; } } size_t index = (size_t) m_fileListCtrl->GetSelection().GetID() - 1; m_archive->ReplaceFiltered(index, fileDlg.GetPath()); static_cast<FileDataModel*>(m_fileListCtrl->GetModel())->RowChanged(index); wxDataViewEvent evt(wxEVT_DATAVIEW_SELECTION_CHANGED); OnFileListSelectionChanged(evt); UpdateTitle(); } }
void ExploreFrame::OnExtractClicked( wxCommandEvent& event ) { if (m_fileListCtrl->GetSelectedItemsCount() == 0) { wxLogError(_("Select file(s) to extract")); return; } wxString extractFolder = wxStandardPaths::Get().GetDocumentsDir(); if (m_fileListCtrl->GetSelectedItemsCount() > 1) { wxDirDialog dirDlg(this, _("Select folder to extract files to"), extractFolder, wxDD_DEFAULT_STYLE); if (dirDlg.ShowModal() == wxID_OK) { wxBusyInfo busyInfo(_("Extracting data...")); wxBusyCursor busyCursor; wxDataViewItemArray selectedItems; m_fileListCtrl->GetSelections(selectedItems); for (auto it = selectedItems.begin(); it != selectedItems.end(); ++it) { const WADArchiveEntry& entry = m_archive->GetFilteredEntry((size_t) it->GetID() - 1); wxFileName targetFileName(entry.GetFileName(), wxPATH_UNIX); targetFileName.Normalize(wxPATH_NORM_ALL, dirDlg.GetPath()); wxLogDebug("Extracting to: %s", targetFileName.GetFullPath()); if (!targetFileName.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL)) break; m_archive->Extract(entry, targetFileName.GetFullPath()); } } wxLogInfo(_("Files extracted to %s"), dirDlg.GetPath()); } else { const WADArchiveEntry& entry = GetSelectedEntry(); wxFileName fn(entry.GetFileName(), wxPATH_UNIX); wxString fileName = fn.GetFullName(); wxFileDialog fileDlg(this, _("Select target for file extraction"), extractFolder, fileName, wxFileSelectorDefaultWildcardStr, wxFD_OVERWRITE_PROMPT | wxFD_SAVE); if (fileDlg.ShowModal() == wxID_OK) { wxBusyInfo busyInfo(_("Extracting data...")); wxBusyCursor busyCursor; m_archive->Extract(entry, fileDlg.GetPath()); } wxLogInfo(_("File extracted to %s"), fileDlg.GetPath()); } }
void ExploreFrame::OnDeleteClicked( wxCommandEvent& event ) { const WADArchiveEntry& entry = GetSelectedEntry(); if (wxMessageBox(wxString::Format(_("Are you sure you want to delete %s?"), entry.GetFileName()), _("Warning"), wxICON_WARNING | wxYES_NO | wxNO_DEFAULT, this) == wxYES) { size_t index = (size_t) m_fileListCtrl->GetSelection().GetID() - 1; m_archive->Remove(index); static_cast<FileDataModel*>(m_fileListCtrl->GetModel())->RowDeleted(index); wxDataViewEvent evt(wxEVT_DATAVIEW_SELECTION_CHANGED); OnFileListSelectionChanged(evt); UpdateTitle(); } }
bool ListInterface::MoveSelectedEntry(const wxString &group, int direction) { const DataEntry *selected = GetSelectedEntry(group); if( !selected ) return false; List *list = FindListByName(group); int itemid = list->GetSelectedIndex(); //Move List Index if( !list->MoveIndex(itemid, direction) ) return false; int selectedEntryIndex = -1; for( unsigned int i = 0; i < GetEntryCount(); ++i ) { const DataEntry* entry = data[i]; if( entry ) { if( entry->CompareName(selected->GetName()) ) { selectedEntryIndex = i; break; } } } //Swap selection and its victim if( selectedEntryIndex != -1 ) { int swapIndex = selectedEntryIndex + (direction < 0 ? -1 : 1); if( swapIndex < 0 || swapIndex >= (int)data.size() ) { return false; } DataEntry *selectedEntry = data[selectedEntryIndex]; DataEntry *swapEntry = data[swapIndex]; data[selectedEntryIndex] = swapEntry; data[swapIndex] = selectedEntry; } return true; }
bool SBehaviorTreeBlackboardEditor::CanRenameEntry() const { const bool bModeActive = OnIsBlackboardModeActive.IsBound() && OnIsBlackboardModeActive.Execute(); if(!IsDebuggerActive() && bModeActive) { bool bIsInherited = false; FBlackboardEntry* BlackboardEntry = GetSelectedEntry(bIsInherited); if(BlackboardEntry != nullptr) { return !bIsInherited; } } return false; }
void EditCoursesMenu::Right() { if( m_bInSongMenu ) { m_SongMenu.Right(); return; } if( CanGoRight() ) { m_iSelection[m_SelectedRow]++; switch( m_SelectedRow ) { case ROW_ENTRY_TYPE: GetSelectedEntry()->type = GetSelectedEntryType(); break; } OnRowValueChanged( m_SelectedRow ); m_soundChangeValue.Play(); } }
void EditCoursesMenu::HandleScreenMessage( const ScreenMessage SM ) { Course* pCourse = GetSelectedCourse(); CourseEntry* pEntry = GetSelectedEntry(); switch( SM ) { case SM_BackFromCourseOptionsMenu: pCourse->m_bRepeat = !!ScreenMiniMenu::s_iLastAnswers[repeat]; pCourse->m_bRandomize = !!ScreenMiniMenu::s_iLastAnswers[randomize]; pCourse->m_iLives = ScreenMiniMenu::s_iLastAnswers[lives]; if( pCourse->m_iLives == 0 ) pCourse->m_iLives = -1; OnRowValueChanged( ROW_COURSE_OPTIONS ); break; case SM_BackFromPlayerOptions: case SM_BackFromSongOptions: // coming back from PlayerOptions or SongOptions pEntry->modifiers = GAMESTATE->m_PlayerOptions[PLAYER_1].GetString() + "," + GAMESTATE->m_SongOptions.GetString(); OnRowValueChanged( ROW_ENTRY_PLAYER_OPTIONS ); break; } }
void EditCoursesMenu::OnRowValueChanged( Row row ) { LOG->Trace( "EditCoursesMenu::OnRowValueChanged(%i)", row ); const bool bCanGoLeft = CanGoLeft(), bCanGoRight = CanGoRight(); m_sprArrows[0].SetDiffuse( bCanGoLeft?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); m_sprArrows[1].SetDiffuse( bCanGoRight?RageColor(1,1,1,1):RageColor(0.2f,0.2f,0.2f,1) ); m_sprArrows[0].EnableAnimation( bCanGoLeft ); m_sprArrows[1].EnableAnimation( bCanGoRight ); Course* pCourse = GetSelectedCourse(); CourseEntry* pEntry = GetSelectedEntry(); switch( row ) { case ROW_COURSE: CHECKPOINT; m_textValue[ROW_COURSE].SetText( pCourse->GetFullDisplayTitle() ); m_CourseBanner.LoadFromCourse( pCourse ); m_CourseBanner.ScaleToClipped( COURSE_BANNER_WIDTH, COURSE_BANNER_HEIGHT ); m_iSelection[ROW_ENTRY] = 0; pEntry = GetSelectedEntry(); if( pEntry == NULL ) { CourseEntry ce; const vector<Song*> &apSongs = SONGMAN->GetAllSongs(); ASSERT( !apSongs.empty() ); ce.pSong = apSongs[0]; pCourse->m_entries.push_back( ce ); pEntry = GetSelectedEntry(); } // fall through case ROW_COURSE_OPTIONS: CHECKPOINT; m_textValue[ROW_COURSE_OPTIONS].SetText( ssprintf( "(START) %s, %s, ", pCourse->m_bRepeat ? "repeat" : "no repeat", pCourse->m_bRandomize ? "randomize" : "no randomize" ) + ssprintf( (pCourse->m_iLives==-1) ? "use bar life" : "%d lives", pCourse->m_iLives ) ); // fall through case ROW_ACTION: CHECKPOINT; m_textValue[ROW_ACTION].SetText( "(START) " + ActionToString(GetSelectedAction()) ); // fall through case ROW_ENTRY: CHECKPOINT; m_textValue[ROW_ENTRY].SetText( ssprintf("%d of %d",m_iSelection[ROW_ENTRY]+1, (int)GetSelectedCourse()->m_entries.size()) ); m_iSelection[ROW_ENTRY_TYPE] = pEntry->type; // fall through case ROW_ENTRY_TYPE: CHECKPOINT; m_textValue[ROW_ENTRY_TYPE].SetText( pEntry ? CourseEntryTypeToString(pEntry->type) : CString("(none)") ); // fall through case ROW_ENTRY_OPTIONS: CHECKPOINT; { CStringArray as; const bool *bShow = g_bRowEnabledForType[GetSelectedEntry()->type]; if( bShow[song] ) as.push_back( pEntry->pSong ? pEntry->pSong->GetFullTranslitTitle() : CString("(missing song)") ); if( bShow[group] ) as.push_back( pEntry->group_name.empty() ? CString("(no group)") : pEntry->group_name ); if( bShow[difficulty] ) if( pEntry->difficulty != DIFFICULTY_INVALID ) as.push_back( DifficultyToString(pEntry->difficulty) ); if( bShow[low_meter] ) if( pEntry->low_meter > 0 ) as.push_back( ssprintf("low meter %d", pEntry->low_meter) ); if( bShow[high_meter] ) if( pEntry->high_meter > 0 ) as.push_back( ssprintf("high meter %d", pEntry->high_meter) ); if( bShow[best_worst_value] ) if( pEntry->players_index != -1 ) as.push_back( ssprintf("rank %d", pEntry->players_index+1) ); m_textValue[ROW_ENTRY_OPTIONS].SetText( "(START) " + join(", ",as) ); } // fall through case ROW_ENTRY_PLAYER_OPTIONS: CHECKPOINT; { CString s = "(START) "; PlayerOptions po; po.FromString( pEntry->modifiers ); if( po.GetString().empty() ) s += "(none)"; else s += po.GetString(); m_textValue[ROW_ENTRY_PLAYER_OPTIONS].SetText( s ); } // fall through case ROW_ENTRY_SONG_OPTIONS: CHECKPOINT; { CString s = "(START) "; SongOptions so; so.FromString( pEntry->modifiers ); if( so.GetString().empty() ) s += "(none)"; else s += so.GetString(); m_textValue[ROW_ENTRY_SONG_OPTIONS].SetText( s ); } break; default: ASSERT(0); // invalid row } }
void EditCoursesMenu::Start() { if( m_bInSongMenu ) { m_SongMenu.SaveToCourseEntry( GetSelectedEntry() ); m_bInSongMenu = false; OnRowValueChanged( ROW_ENTRY ); return; } Course* pCourse = GetSelectedCourse(); CourseEntry* pEntry = GetSelectedEntry(); switch( m_SelectedRow ) { case ROW_COURSE_OPTIONS: g_CourseOptionsMenu.rows[repeat].defaultChoice = pCourse->m_bRepeat ? 1 : 0; g_CourseOptionsMenu.rows[randomize].defaultChoice = pCourse->m_bRandomize ? 1 : 0; g_CourseOptionsMenu.rows[lives].defaultChoice = pCourse->m_iLives; if( g_CourseOptionsMenu.rows[lives].defaultChoice == -1 ) g_CourseOptionsMenu.rows[lives].defaultChoice = 0; SCREENMAN->MiniMenu( &g_CourseOptionsMenu, SM_BackFromCourseOptionsMenu ); break; case ROW_ACTION: switch( GetSelectedAction() ) { case save: m_soundSave.Play(); pCourse->Save(); SCREENMAN->SystemMessage( "Course saved." ); break; case add_entry: SCREENMAN->PlayStartSound(); pCourse->m_entries.insert( pCourse->m_entries.begin()+m_iSelection[ROW_ENTRY], pCourse->m_entries[m_iSelection[ROW_ENTRY]] ); OnRowValueChanged( ROW_ENTRY ); break; case delete_selected_entry: if( pCourse->m_entries.size() == 1 ) { SCREENMAN->PlayInvalidSound(); SCREENMAN->SystemMessage( "Cannot delete the last entry from a course" ); break; } SCREENMAN->PlayStartSound(); pCourse->m_entries.erase( pCourse->m_entries.begin()+m_iSelection[ROW_ENTRY] ); CLAMP( m_iSelection[ROW_ENTRY], 0, (int) pCourse->m_entries.size()-1 ); OnRowValueChanged( ROW_ENTRY ); break; default: ASSERT(0); } OnRowValueChanged( ROW_ENTRY ); break; case ROW_ENTRY_OPTIONS: m_SongMenu.LoadFromCourseEntry( GetSelectedEntry() ); m_bInSongMenu = true; break; case ROW_ENTRY_PLAYER_OPTIONS: SCREENMAN->PlayStartSound(); GAMESTATE->m_PlayerOptions[PLAYER_1] = PlayerOptions(); GAMESTATE->m_PlayerOptions[PLAYER_1].FromString( pEntry->modifiers ); SCREENMAN->AddNewScreenToTop( "ScreenPlayerOptions", SM_BackFromPlayerOptions ); break; case ROW_ENTRY_SONG_OPTIONS: SCREENMAN->PlayStartSound(); GAMESTATE->m_SongOptions = SongOptions(); GAMESTATE->m_SongOptions.FromString( pEntry->modifiers ); SCREENMAN->AddNewScreenToTop( "ScreenSongOptions", SM_BackFromSongOptions ); break; default: SCREENMAN->PlayInvalidSound(); return; } }