void drawNSFMeta() { char str[256]; setFont(font_gautami_10); setColor(genericTextColor); sprintf(str, "%s: ", l_title); bg_dispString(10, 50 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); bg_dispString(getLastX(), 50 + HEIGHT_ADJUST, getNSFMeta(0)); setColor(genericTextColor); sprintf(str, "%s: ", l_artist); bg_dispString(10, 65 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); bg_dispString(getLastX(), 65 + HEIGHT_ADJUST, getNSFMeta(1)); setColor(soundMetaTextColor); bg_dispString(10, 95 + HEIGHT_ADJUST, "© "); bg_dispString(getLastX(), 95 + HEIGHT_ADJUST, getNSFMeta(2)); setColor(genericTextColor); sprintf(str, "%s: ", l_track); bg_dispString(10, 125 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); sprintf(str, "%d/%d", getNSFTrack(), getNSFTotalTracks()); bg_dispString(getLastX(), 125 + HEIGHT_ADJUST, str); setColor(genericTextColor); sprintf(str, " (%c%c%c%c %s)", BUTTON_LEFT, POS_RIGHT, POS_RIGHT, BUTTON_RIGHT, l_tochange); bg_dispString(getLastX(), 125 + HEIGHT_ADJUST, str); }
int MaxDecSub(int* arr, int len){ int i, j, k, tmpLen, maxLen, ansLen, idx, ansIdx; int dp[len][len]; ansLen = 1; for(i = 0; i < len; i++){ for(j = 0; j < len; j++){ dp[i][j] = INT_MAX; } } dp[0][0] = arr[0]; for(i = 1; i < len; i++){ maxLen = 1; for(j = 0; j < i; j++){ int x = getLastX(dp[j], j); if(x > arr[i]){ tmpLen = getLen(dp[j], j)+1; if(maxLen < tmpLen){ maxLen = tmpLen; idx = j; } } } for(k = 0; k < maxLen -1; k++){ dp[i][k] = dp[idx][k]; } dp[i][k] = arr[i]; if(ansLen < maxLen){ ansLen = maxLen; ansIdx = i; } } return ansLen; }
void drawSNDHMeta() { api68_music_info_t sndhInfo; char str[256]; setFont(font_gautami_10); getSNDHMeta(&sndhInfo); setColor(genericTextColor); sprintf(str, "%s: ", l_title); bg_dispString(10, 50 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); bg_dispString(getLastX(), 50 + HEIGHT_ADJUST, sndhInfo.title); setColor(genericTextColor); sprintf(str, "%s: ", l_author); bg_dispString(10, 65 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); bg_dispString(getLastX(), 65 + HEIGHT_ADJUST, sndhInfo.author); setColor(genericTextColor); sprintf(str, "%s: ", l_composer); bg_dispString(10, 80 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); bg_dispString(getLastX(), 80 + HEIGHT_ADJUST, sndhInfo.composer); setColor(genericTextColor); sprintf(str, "%s: ", l_converter); bg_dispString(10, 95 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); bg_dispString(getLastX(), 95 + HEIGHT_ADJUST, sndhInfo.converter); setColor(genericTextColor); sprintf(str, "%s: ", l_ripper); bg_dispString(10, 110 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); bg_dispString(getLastX(), 110 + HEIGHT_ADJUST, sndhInfo.ripper); setColor(genericTextColor); sprintf(str, "%s: ", l_track); bg_dispString(10, 125 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); sprintf(str, "%d/%d", getSNDHTrack(), getSNDHTotalTracks()); bg_dispString(getLastX(), 125 + HEIGHT_ADJUST, str); setColor(genericTextColor); sprintf(str, " (%c%c%c%c %s)", BUTTON_LEFT, POS_RIGHT, POS_RIGHT, BUTTON_RIGHT, l_tochange); bg_dispString(getLastX(), 125 + HEIGHT_ADJUST, str); }
void drawSPCMeta() { char str[256]; setFont(font_gautami_10); setColor(genericTextColor); sprintf(str, "%s: ", l_title); bg_dispString(10, 50 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); bg_dispString(getLastX(), 50 + HEIGHT_ADJUST, getSPCMeta(0)); setColor(genericTextColor); sprintf(str, "%s: ", l_game); bg_dispString(10, 65 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); bg_dispString(getLastX(), 65 + HEIGHT_ADJUST, getSPCMeta(1)); setColor(genericTextColor); sprintf(str, "%s: ", l_artist); bg_dispString(10, 80 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); bg_dispString(getLastX(), 80 + HEIGHT_ADJUST, getSPCMeta(2)); setColor(genericTextColor); sprintf(str, "%s: ", l_year); bg_dispString(10, 95 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); bg_dispString(getLastX(), 95 + HEIGHT_ADJUST, getSPCMeta(3)); setColor(genericTextColor); sprintf(str, "%s: ", l_comment); bg_dispString(10, 110 + HEIGHT_ADJUST, str); setColor(soundMetaTextColor); bg_dispString(getLastX(), 110 + HEIGHT_ADJUST, getSPCMeta(4)); }
bool TrackballTransformManipulator::rotate() { if ( ( getCurrentX() != getLastX() ) || ( getCurrentY() != getLastY() ) ) { DP_ASSERT( getViewState()->getCamera().isPtrTo<FrustumCamera>() ); TransformSharedPtr transform = m_transformPath->getTail().staticCast<Transform>(); FrustumCameraSharedPtr const& camera = getViewState()->getCamera().staticCast<FrustumCamera>(); if ( camera && transform ) { unsigned int rtWidth = getRenderTarget()->getWidth(); unsigned int rtHeight = getRenderTarget()->getHeight(); Vec2f camWinSize = camera->getWindowSize(); if ( ( 0 < rtHeight ) && ( 0 < rtWidth ) && ( FLT_EPSILON < fabs( camWinSize[0] ) ) && ( FLT_EPSILON < fabs( camWinSize[1] ) ) ) { // get all the matrices needed here Mat44f m2w, w2m, w2v, v2w, v2s, m2v; m_transformPath->getModelToWorldMatrix( m2w, w2m ); // model->world and world->model w2v = camera->getWorldToViewMatrix(); // world->view v2w = camera->getViewToWorldMatrix(); // view->world v2s = camera->getProjection(); // view->screen (normalized) m2v = m2w * w2v; const Sphere3f& bs = transform->getBoundingSphere(); // center of the object in view coordinates Vec4f centerV = Vec4f( bs.getCenter(), 1.0f ) * m2v; DP_ASSERT( fabs( centerV[3] - 1.0f ) < FLT_EPSILON ); // center of the object in normalized screen coordinates Vec4f centerNS = centerV * v2s; DP_ASSERT( centerNS[3] != 0.0f ); centerNS /= centerNS[3]; // center of the object in screen space Vec2f centerS( rtWidth * ( 1 + centerNS[0] ) / 2, rtHeight * ( 1 - centerNS[1] ) / 2 ); // move the input points relative to the center // move the input points absolutely //Vec2f last( m_orbitCursor ); Vec2f last( getLastCursorPosition() ); Vec2f p0( last[0] - centerS[0], centerS[1] - last[1] ); Vec2f p1( getCurrentX() - centerS[0], centerS[1] - getCurrentY() ); DP_ASSERT( p0[0] != p1[0] || p0[1] != p1[1] ); // get the scaling (from model to view) Vec3f scaling, translation; Quatf orientation, scaleOrientation; decompose( m2v, translation, orientation, scaling, scaleOrientation ); float maxScale = std::max( scaling[0], std::max( scaling[1], scaling[2] ) ); DP_ASSERT( FLT_EPSILON < fabs( maxScale ) ); // determine the radius in screen space (in the centers depth) Vec2f centerWindowSize = - centerV[2] / getViewState()->getTargetDistance() * camWinSize; float radius = bs.getRadius() * maxScale * rtWidth / centerWindowSize[0]; // with p0, p1, and the radius determine the axis and angle of rotation via the Trackball utility // => axis is in view space then Vec3f axis; float angle; m_trackball.setSize( radius ); m_trackball.apply( p0, p1, axis, angle ); float dx = p1[0]-p0[0]; float dy = p1[1]-p0[1]; checkLockAxis(dx, dy); if ( m_activeLockAxis[static_cast<size_t>(Axis::X)] ) { if ( dx < 0 ) axis = Vec3f(0.f, -1.f, 0.f); else if ( dx > 0) axis = Vec3f(0.f, 1.f, 0.f); else return false; } else if ( m_activeLockAxis[static_cast<size_t>(Axis::Y)] ) { if ( dy < 0 ) axis = Vec3f(1.f, 0.f, 0.f); else if ( dy > 0) axis = Vec3f(-1.f, 0.f, 0.f); else return false; } // transform axis back into model space axis = Vec3f( Vec4f( axis, 0.0f ) * v2w * w2m ); axis.normalize(); // create the rotation around the center (in model space) Trafo trafo; trafo.setCenter( bs.getCenter() ); trafo.setOrientation( Quatf( axis, angle ) ); // concatenate this rotation with the current transformation trafo.setMatrix( transform->getTrafo().getMatrix() * trafo.getMatrix() ); // concatenate this rotation with the original transformation //trafo.setMatrix( m_matrix * trafo.getMatrix() ); // set the current transform transform->setTrafo( trafo ); return true; } } } return false; }
bool TrackballTransformManipulator::pan() { int dxScreen = getCurrentX() - getLastX(); int dyScreen = getLastY() - getCurrentY(); if ( dxScreen || dyScreen ) { DP_ASSERT( getViewState()->getCamera().isPtrTo<FrustumCamera>() ); TransformSharedPtr transform = m_transformPath->getTail().staticCast<Transform>(); FrustumCameraSharedPtr const& camera = getViewState()->getCamera().staticCast<FrustumCamera>(); if ( camera && transform ) { unsigned int rtWidth = getRenderTarget()->getWidth(); unsigned int rtHeight = getRenderTarget()->getHeight(); Vec2f camWinSize = camera->getWindowSize(); if ( ( 0 < rtHeight ) && ( 0 < rtWidth ) && ( FLT_EPSILON < fabs( camWinSize[0] ) ) && ( FLT_EPSILON < fabs( camWinSize[1] ) ) ) { // get all the matrices needed here Mat44f m2w, w2m; m_transformPath->getModelToWorldMatrix(m2w, w2m); // model->world and world->model Mat44f w2v = camera->getWorldToViewMatrix(); // world->view Mat44f v2w = camera->getViewToWorldMatrix(); // view->world // center of the object in view coordinates Vec4f center = Vec4f( transform->getBoundingSphere().getCenter(), 1.0f ) * m2w * w2v; // window size at distance of the center of the object Vec2f centerWindowSize = - center[2] / getViewState()->getTargetDistance() * camWinSize; checkLockAxis(dxScreen, dyScreen); if ( m_activeLockAxis[static_cast<size_t>(Axis::X)] ) { if ( dxScreen != 0 ) { dyScreen = 0; } else { return false; } } else if ( m_activeLockAxis[static_cast<size_t>(Axis::Y)] ) { if ( dyScreen != 0) { dxScreen = 0; } else { return false; } } // delta in model coordinates Vec4f viewCenter( centerWindowSize[0] * dxScreen / rtWidth , centerWindowSize[1] * dyScreen / rtHeight, 0.f, 0.f ); Vec4f modelDelta = viewCenter * v2w * w2m; // add the delta to the translation of the transform Trafo trafo = transform->getTrafo(); trafo.setTranslation( trafo.getTranslation() + Vec3f( modelDelta ) ); transform->setTrafo( trafo ); return true; } } } return false; }
void initializeIt() { char filename[512],*p; char directory[1024] = ""; char currentDir[MAX_PATH] = ""; memset(filename, '\000', sizeof(filename)); GetModuleFileName(NULL,filename,sizeof(filename)); strcpy(currentDir, filename); char *pend; pend = strrchr(currentDir, '\\'); if (pend) { *pend = '\000'; } p = filename+lstrlen(filename); while (p >= filename && *p != '\\') p--; p++; char logFile[1024] = ""; memset(logFile, '\000', sizeof(logFile)); strcpy(logFile, "edcast_foo"); char tmpfile[MAX_PATH] = ""; sprintf(tmpfile, "%s\\.tmp", currentDir); FILE *filep = fopen(tmpfile, "w"); if (filep == 0) { char path[MAX_PATH] = ""; SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path); strcpy(currentDir, path); } else { fclose(filep); } LoadConfigs(currentDir, logFile); /************ Bad string!!!!!*************/ //AfxWinInit(core_api::get_my_instance(), NULL, "", SW_HIDE); ::AfxSetResourceHandle(core_api::get_my_instance()); mainWindow = new CMainWindow(); mainWindow->InitializeWindow(); strcpy(mainWindow->m_currentDir, currentDir); //mainWindow->Create((UINT)IDD_EDCAST, mainApp.GetMainWnd()); //mainWindow->Create((UINT)IDD_EDCAST, CWnd::FromHandle(core_api::get_main_window())); //::AfxGetMainWnd(); mainWindow->Create((UINT)IDD_EDCAST, AfxGetMainWnd()); int x = getLastX(); int y = getLastY(); if (x < 0) { x = 0; } if (y < 0) { y = 0; } mainWindow->SetWindowPos(NULL, x, y, -1, -1, SWP_NOSIZE | SWP_SHOWWINDOW); modeless_dialog_manager::g_add(mainWindow->m_hWnd); modeless_dialog_manager::g_add(mainWindow->configDialog->m_hWnd); modeless_dialog_manager::g_add(mainWindow->editMetadata->m_hWnd); mainWindow->SetIcon(mainApp.LoadIcon(IDR_MAINFRAME), TRUE); mainWindow->ShowWindow(SW_HIDE); initializeedcast(); }
// Here is the entry point for the Plugin..this gets called first. int initaltacast(struct winampDSPModule *this_mod) { char filename[512],*p; char directory[1024] = ""; char currentDir[1024] = ""; memset(filename, '\000', sizeof(filename)); GetModuleFileName(this_mod->hDllInstance,filename,sizeof(filename)); strcpy(currentDir, filename); char *pend; pend = strrchr(currentDir, '\\'); if (pend) { *pend = '\000'; } p = filename+lstrlen(filename); while (p >= filename && *p != '\\') p--; p++; char logFile[1024] = ""; memset(logFile, '\000', sizeof(logFile)); char *p2 = strchr(p, '.'); if (p2) { strncpy(logFile, p, p2-p); } else { strcpy(logFile, p); } char tmpfile[MAX_PATH] = ""; sprintf(tmpfile, "%s\\.tmp", currentDir); FILE *filep = fopen(tmpfile, "w"); if (filep == 0) { char path[MAX_PATH] = ""; SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path); strcpy(currentDir, path); } else { fclose(filep); } LoadConfigs(currentDir, logFile); ghwnd_winamp = this_mod->hwndParent; AfxWinInit( this_mod->hDllInstance, NULL, "", SW_HIDE); mainWindow = new CMainWindow(); mainWindow->InitializeWindow(); strcpy(mainWindow->m_currentDir, currentDir); mainWindow->Create((UINT)IDD_ALTACAST, AfxGetMainWnd()); int x = getLastX(); int y = getLastY(); if (x < 0) { x = 0; } if (y < 0) { y = 0; } mainWindow->SetWindowPos(NULL, (int)x, (int)y, -1, -1, SWP_NOSIZE | SWP_SHOWWINDOW); mainWindow->SetIcon(mainApp.LoadIcon(IDR_MAINFRAME), TRUE); mainWindow->ShowWindow(SW_SHOW); initializealtacast(); timerId = SetTimer(NULL, 1, 1000, (TIMERPROC)getCurrentSongTitle); return 0; }