void CAdvancedSettingsPage::AddSettings() { m_wndList.DeleteAllItems(); for ( POSITION pos = Settings.GetHeadPosition() ; pos ; ) { CSettings::Item* pItem = Settings.GetNext( pos ); if ( ! pItem->m_bHidden && ( pItem->m_pBool || ( pItem->m_pDword && pItem->m_nScale ) || ( pItem->m_pString && pItem->m_nType != CSettings::setNull ) ) ) { EditItem* pEdit = new EditItem( pItem ); ASSERT( pEdit != NULL ); if ( pEdit == NULL ) return; LV_ITEM pList = {}; pList.mask = LVIF_PARAM|LVIF_TEXT|LVIF_IMAGE; pList.iItem = m_wndList.GetItemCount(); pList.lParam = (LPARAM)pEdit; pList.iImage = 0; pList.pszText = (LPTSTR)(LPCTSTR)pEdit->m_sName; pList.iItem = m_wndList.InsertItem( &pList ); UpdateListItem( pList.iItem ); } } }
void CAdvancedSettingsPage::UpdateAll() { for ( int nItem = 0 ; nItem < m_wndList.GetItemCount() ; nItem++ ) { EditItem* pItem = (EditItem*)m_wndList.GetItemData( nItem ); pItem->Update(); UpdateListItem( nItem ); } UpdateInputArea(); }
void CAdvancedSettingsPage::OnBnClickedDefaultValue() { int nItem = m_wndList.GetNextItem( -1, LVNI_SELECTED ); if ( nItem >= 0 ) { EditItem* pItem = (EditItem*)m_wndList.GetItemData( nItem ); pItem->Default(); UpdateListItem( nItem ); UpdateInputArea(); } }
void ShortcutList::ApplyShortcut(FXHotKey acckey, MenuSpec*spec) { FXAccelTable*table=win->getAccelTable(); FXString accel=unparseAccel(acckey); if (spec->accel[0]) { FXHotKey old=parseAccel(spec->accel); if (table->hasAccel(old)) table->removeAccel(old); } mnumgr->SetAccelerator(spec,accel); if (spec->ms_mc) { spec->ms_mc->setAccelText(spec->accel); table->addAccel(acckey,spec->ms_mc->getTarget(),FXSEL(SEL_COMMAND,spec->sel)); } else { table->addAccel(acckey,win,FXSEL(SEL_COMMAND,spec->sel)); } UpdateListItem(spec); }
bool ShortcutList::DeleteShortcut(MenuSpec*spec) { FXHotKey acckey=parseAccel(spec->accel); FXAccelTable*table=win->getAccelTable(); if (!table->hasAccel(acckey)) { return true; } else { if (FXMessageBox::question(getShell(), MBOX_YES_NO, _("Confirm delete"), _("Are you sure you want to remove this keybinding?") )==MBOX_CLICKED_YES) { table->removeAccel(acckey); memset(spec->accel,0,sizeof(spec->accel)); UpdateListItem(spec); return true; } else { return false; } } }
void CAdvancedSettingsPage::OnChangeValue() { if ( m_wndList.m_hWnd == NULL || m_bUpdating ) return; int nItem = m_wndList.GetNextItem( -1, LVNI_SELECTED ); if ( nItem >= 0 ) { EditItem* pItem = (EditItem*)m_wndList.GetItemData( nItem ); if ( pItem->m_pItem->m_pDword ) { CString strValue; m_wndValue.GetWindowText( strValue ); DWORD nValue; if ( _stscanf( strValue, _T("%lu"), &nValue ) != 1 ) return; pItem->m_nValue = max( pItem->m_pItem->m_nMin, min( pItem->m_pItem->m_nMax, nValue ) ) * pItem->m_pItem->m_nScale; } else if ( pItem->m_pItem->m_pBool ) { pItem->m_bValue = ( m_wndBool.GetCheck() == BST_CHECKED ); } else if ( pItem->m_pItem->m_pString && pItem->m_pItem->m_nType == CSettings::setString ) { m_wndValue.GetWindowText( pItem->m_sValue ); } else if ( pItem->m_pItem->m_pString && pItem->m_pItem->m_nType == CSettings::setFont ) { pItem->m_sValue = m_wndFonts.GetSelectedFont(); } else return; UpdateListItem( nItem ); m_wndDefaultBtn.EnableWindow( ! pItem->IsDefault() ); } }
void MainWindow::ImMessage(BMessage* msg) { int32 im_what = msg->FindInt32("im_what"); switch (im_what) { case IM_OWN_CONTACT_INFO: fStatusView->SetName(msg->FindString("name")); break; case IM_OWN_AVATAR_SET: { entry_ref ref; if (msg->FindRef("ref", &ref) == B_OK) { BBitmap* bitmap = BTranslationUtils::GetBitmap(&ref); fStatusView->SetAvatarIcon(bitmap); } break; } case IM_STATUS_SET: { int32 status; if (msg->FindInt32("status", &status) != B_OK) return; RosterItem* rosterItem = fServer->RosterItemForId(msg->FindString("id")); if (rosterItem) { UpdateListItem(rosterItem); // Add or remove item switch (status) { /*case CAYA_OFFLINE: // By default offline contacts are hidden if (!CayaPreferences::Item()->HideOffline) break; if (HasItem(rosterItem)) RemoveItem(rosterItem); return;*/ default: // Add item because it has a non-offline status if (!HasItem(rosterItem)) AddItem(rosterItem); break; } UpdateListItem(rosterItem); // Sort list view again fListView->Sort(); // Check if the user want the notification if (!CayaPreferences::Item()->NotifyContactStatus) break; switch (status) { case CAYA_ONLINE: case CAYA_OFFLINE: // Notify when contact is online or offline if (status == CAYA_ONLINE) { BString message; message << rosterItem->GetContactLinker()->GetName(); if (status == CAYA_ONLINE) message << " is available!"; else message << " is offline!"; BNotification notification(B_INFORMATION_NOTIFICATION); notification.SetGroup(BString("Caya")); notification.SetTitle(BString("Presence")); notification.SetIcon(rosterItem->Bitmap()); notification.SetContent(message); notification.Send(); } break; default: break; } } break; } case IM_AVATAR_SET: case IM_CONTACT_INFO: case IM_EXTENDED_CONTACT_INFO: { RosterItem* rosterItem = fServer->RosterItemForId(msg->FindString("id")); if (rosterItem) UpdateListItem(rosterItem); break; } } }
void MainWindow::MessageReceived(BMessage* message) { switch (message->what) { case kSearchContact: { void* control = NULL; if (message->FindPointer("source", &control) != B_OK) return; SearchBarTextControl* searchBox = static_cast<SearchBarTextControl*>(control); if (searchBox == NULL) return; RosterMap map = fServer->RosterItems(); for (uint32 i = 0; i < map.CountItems(); i++) { ContactLinker* linker = map.ValueAt(i); RosterItem* item = linker->GetRosterItem(); // If the search filter has been deleted show all the items, // otherwise remove the item in order to show only items // that matches the search criteria if (strcmp(searchBox->Text(), "") == 0) AddItem(item); else if (linker->GetName().IFindFirst(searchBox->Text()) == B_ERROR) RemoveItem(item); else AddItem(item); UpdateListItem(item); } break; } case CAYA_SHOW_SETTINGS: { PreferencesDialog* dialog = new PreferencesDialog(); dialog->Show(); break; } case CAYA_OPEN_CHAT_WINDOW: { int index = message->FindInt32("index"); RosterItem* ritem = ItemAt(index); if (ritem != NULL) ritem->GetContactLinker()->ShowWindow(false, true); break; } case CAYA_REPLICANT_STATUS_SET: { int32 status; message->FindInt32("status", &status); AccountManager* accountManager = AccountManager::Get(); accountManager->SetStatus((CayaStatus)status); break; } case CAYA_REPLICANT_SHOW_WINDOW: { if (LockLooper()) { SetWorkspaces(B_CURRENT_WORKSPACE); if ((IsMinimized() || IsHidden()) || fWorkspaceChanged) { Minimize(false); Show(); fWorkspaceChanged = false; } else if ((!IsMinimized() || !IsHidden()) || (!fWorkspaceChanged)) { Minimize(true); } UnlockLooper(); } break; } case IM_MESSAGE: ImMessage(message); break; case IM_ERROR: ImError(message); break; case B_ABOUT_REQUESTED: be_app->PostMessage(message); break; default: BWindow::MessageReceived(message); } }
INT_PTR ACheatInfoDlg::OnCommand(int codeNotify,int ctrlID,HWND hWndCtrl) { if(hWndCtrl){ if(ctrlID == IDC_CHEAT_EXECLUA){ int isel = m_CheatsList->GetNextItem(-1,LVNI_SELECTED); if(isel==-1){ this->MessageBox("选中一个值先~"); return 0; } extern FCEUGI *GameInfo; if(!GameInfo){ MessageBox("请先打开游戏~","",MB_ICONINFORMATION); return 0; } std::string& str = m_pEntry->item.values[isel]->script; int error = luaL_loadbuffer((lua_State*)luastate,str.c_str(),str.size(),"") || lua_pcall((lua_State*)luastate,0,0,0); if(error != 0){ //fprintf(stderr,"lua_pcall() error:%s\n",lua_tostring(L,-1)); this->MessageBox(lua_tostring((lua_State*)luastate,-1),"lua脚本错误",MB_ICONERROR); lua_pop((lua_State*)luastate,1); } return 0; }else if(ctrlID == IDC_CHEAT_CHEATINFO){ ACheatCheatInfoDlg dlg(this,m_pEntry); if(dlg.GetDlgCode() == IDOK){ m_editName->SetWindowText(m_pEntry->item.name.c_str()); ControlMessage cm = {0}; cm.self = this; cm.uMsg = WM_SETTEXT; cm.wParam = (WPARAM)m_pEntry->item.name.c_str(); NotifyParent(&cm); m_pFile->bNeedSaving = true; return SetDlgResult(TRUE); } return 0; }else if(ctrlID == IDC_CHEAT_EDITSCRIPT){ int isel = m_CheatsList->GetNextItem(-1,LVNI_SELECTED); if(isel==-1){ this->MessageBox("选中一个值先~"); return 0; } ACheatEntry::VALUE* v = m_pEntry->item.values[isel]; AEditCheatDlg dlg(this,(char*)v->name.c_str(),(char*)v->script.c_str()); int code = dlg.GetDlgCode(); if(code == AEditCheatDlg::RET_CLOSE || code==AEditCheatDlg::RET_CANCEL){ }else if(code == AEditCheatDlg::RET_OK){ std::string& name = dlg.GetName(); std::string& script = dlg.GetScript(); v->name = name; v->script = script; UpdateListItem(isel,v->name.c_str(),0); m_pFile->bNeedSaving = true; return 0; } return 0; }else if(ctrlID == IDC_CHEAT_ADDLUA){ AEditCheatDlg dlg(this); int code = dlg.GetDlgCode(); if(code == AEditCheatDlg::RET_CLOSE || code==AEditCheatDlg::RET_CANCEL){ }else if(code == AEditCheatDlg::RET_OK){ std::string& name = dlg.GetName(); std::string& script = dlg.GetScript(); ACheatEntry::VALUE* pValue = new ACheatEntry::VALUE; pValue->name = name; pValue->script = script; m_pEntry->item.values.push_back(pValue); AddListItem(pValue->name.c_str(),0); m_pFile->bNeedSaving = true; return 0; } return 0; }else if(ctrlID == IDC_CHEAT_DELETELUA){ int count_selected = 0; int i; for(i=-1;(i=m_CheatsList->GetNextItem(i,LVNI_SELECTED))!=-1;){ count_selected++; } if(count_selected == 0){ MessageBox("选择至少一个要删除的值~","",MB_ICONINFORMATION); return SetDlgResult(FALSE); }else{ stringstream ss; ss<<"删除选中的 "<<count_selected<<" 项?"; string str = ss.str(); if(MessageBox(str.c_str(),"确认",MB_OKCANCEL|MB_ICONQUESTION) == IDCANCEL){ return SetDlgResult(FALSE); } } for(i=-1;(i=m_CheatsList->GetNextItem(i,LVNI_SELECTED))!=-1;){ m_CheatsList->DeleteItem(i); auto& vs = m_pEntry->item.values; auto v = vs[i]; delete v; auto s=vs.begin(); for(; *s != v; ++s) ; vs.erase(s); i--; } m_pFile->bNeedSaving = true; return SetDlgResult(TRUE); }else if(ctrlID == IDC_CHEAT_CUSTOM){ lua_State* L = (lua_State*)luastate; bool need=false; for(string::size_type i=0;i<m_pEntry->item.custom.size(); i++){ if(isalnum(m_pEntry->item.custom[i])){ need = true; break; } } if(!need){ MessageBox( "当前金手指未提供可自定义的脚本~" "\n\n" "你可以点击 '信息', 查看并修改自定义金手指脚本!", "金手指自定义", MB_ICONINFORMATION); return 0; } extern FCEUGI *GameInfo; if(!GameInfo){ MessageBox("请先打开游戏~","",MB_ICONINFORMATION); return 0; } int ret=luaL_loadbuffer(L,m_pEntry->item.custom.c_str(),m_pEntry->item.custom.size(),"") ||lua_pcall(L,0,0,0); if(ret != 0){ this->MessageBox(lua_tostring(L,-1),"脚本错误",MB_ICONERROR); lua_pop(L,1); } return SetDlgResult(0); } } return 0; }