CMainWindow::CMainWindow(CPsfVm& virtualMachine) : Framework::Win32::CDialog(MAKEINTRESOURCE(IDD_MAINWINDOW)) , m_virtualMachine(virtualMachine) , m_ready(false) , m_frames(0) , m_lastUpdateTime(~0) , m_selectedAudioPlugin(DEFAULT_SOUND_HANDLER_ID) , m_selectedCharEncoding(DEFAULT_CHAR_ENCODING_ID) , m_playlistPanel(NULL) , m_fileInformationPanel(NULL) , m_spu0RegViewPanel(NULL) , m_spu1RegViewPanel(NULL) , m_currentPlaylistItem(0) , m_repeatMode(DEFAULT_REPEAT_MODE) , m_trackLength(0) , m_accel(CreateAccelerators()) , m_reverbEnabled(true) , m_playListOnceIcon(NULL) , m_repeatListIcon(NULL) , m_shuffleListIcon(NULL) , m_repeatTrackIcon(NULL) , m_toolTip(NULL) , m_trayPopupMenu(NULL) , m_configPopupMenu(NULL) , m_useTrayIcon(false) , m_trayIconServer(NULL) , m_taskBarList(NULL) , m_randomSeed(0) { OSVERSIONINFO versionInfo; memset(&versionInfo, 0, sizeof(OSVERSIONINFO)); versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&versionInfo); if(versionInfo.dwMajorVersion > 6) { m_useTrayIcon = false; } else if(versionInfo.dwMajorVersion == 6) { m_useTrayIcon = versionInfo.dwMinorVersion < 1; } else { m_useTrayIcon = true; } #ifdef FORCE_ENABLE_TRAYICON m_useTrayIcon = true; #endif if(!m_useTrayIcon) { m_taskBarList = new Framework::Win32::CTaskBarList(); } { srand(static_cast<unsigned int>(time(NULL)) * 0x13579ACD); float delta = (static_cast<float>(rand()) / static_cast<float>(RAND_MAX)); m_randomSeed = delta * static_cast<float>(0xCAFECAFE) + 0xDAEBB042; } CAppConfig::GetInstance().RegisterPreferenceBoolean(PREF_REVERB_ENABLED, true); CAppConfig::GetInstance().RegisterPreferenceInteger(PREF_SOUNDHANDLER_ID, DEFAULT_SOUND_HANDLER_ID); CAppConfig::GetInstance().RegisterPreferenceInteger(PREF_CHAR_ENCODING_ID, DEFAULT_CHAR_ENCODING_ID); CAppConfig::GetInstance().RegisterPreferenceInteger(PREF_REPEAT_MODE, DEFAULT_REPEAT_MODE); m_reverbEnabled = CAppConfig::GetInstance().GetPreferenceBoolean(PREF_REVERB_ENABLED); m_repeatMode = static_cast<REPEAT_MODE>(CAppConfig::GetInstance().GetPreferenceInteger(PREF_REPEAT_MODE)); LoadAudioPluginPreferences(); LoadCharEncodingPreferences(); for(unsigned int i = 0; i < MAX_PANELS; i++) { m_panels[i] = NULL; } SetClassPtr(); SetTimer(m_hWnd, TIMER_UPDATE_CLOCK, 200, NULL); SetTimer(m_hWnd, TIMER_UPDATE_FADE, 50, NULL); SetTimer(m_hWnd, TIMER_UPDATE_DISCOVERIES, 100, NULL); { int smallIconSizeX = GetSystemMetrics(SM_CXSMICON); int smallIconSizeY = GetSystemMetrics(SM_CYSMICON); int bigIconSizeX = GetSystemMetrics(SM_CXICON); int bigIconSizeY = GetSystemMetrics(SM_CYICON); HICON smallIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAIN), IMAGE_ICON, smallIconSizeX, smallIconSizeY, 0)); HICON bigIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAIN), IMAGE_ICON, bigIconSizeX, bigIconSizeY, 0)); SetIcon(ICON_SMALL, smallIcon); SetIcon(ICON_BIG, bigIcon); } m_trayPopupMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_TRAY_POPUP)); m_configPopupMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_CONFIG_POPUP)); m_virtualMachine.OnNewFrame.connect(std::bind(&CMainWindow::OnNewFrame, this)); m_toolTip = new Framework::Win32::CToolTip(m_hWnd); m_toolTip->Activate(true); ChangeAudioPlugin(FindAudioPlugin(m_selectedAudioPlugin)); m_playListOnceIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PLAYONCE), IMAGE_ICON, 16, 16, 0)); m_repeatListIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_REPEAT_LIST), IMAGE_ICON, 16, 16, 0)); m_shuffleListIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_SHUFFLE_LIST), IMAGE_ICON, 16, 16, 0)); m_repeatTrackIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_REPEAT_TRACK), IMAGE_ICON, 16, 16, 0)); m_configIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_CONFIG), IMAGE_ICON, 16, 16, 0)); m_playIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PLAY), IMAGE_ICON, 16, 16, 0)); m_pauseIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PAUSE), IMAGE_ICON, 16, 16, 0)); m_prevTrackIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PREV_TRACK), IMAGE_ICON, 16, 16, 0)); m_nextTrackIcon = reinterpret_cast<HICON>(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NEXT_TRACK), IMAGE_ICON, 16, 16, 0)); m_timerLabel = Framework::Win32::CStatic(GetItem(IDC_TIMER_LABEL)); m_titleLabel = Framework::Win32::CStatic(GetItem(IDC_TITLE_LABEL)); m_placeHolder = Framework::Win32::CStatic(GetItem(IDC_PLACEHOLDER)); m_configButton = Framework::Win32::CButton(GetItem(IDC_CONFIG_BUTTON)); m_toolTip->AddTool(m_configButton.m_hWnd, _T("Configuration")); m_configButton.SetIcon(m_configIcon); m_repeatButton = Framework::Win32::CButton(GetItem(IDC_REPEAT_BUTTON)); m_toolTip->AddTool(m_repeatButton.m_hWnd, _T("")); UpdateRepeatButton(); m_pauseButton = Framework::Win32::CButton(GetItem(IDC_PAUSE_BUTTON)); //Initialize symbol fonts CreateSymbolFonts(); { m_pauseButton.SetFont(m_webdingsFont); SendMessage(GetItem(ID_FILE_PREVIOUSTRACK), WM_SETFONT, reinterpret_cast<WPARAM>(static_cast<HFONT>(m_webdingsFont)), 0); SendMessage(GetItem(ID_FILE_NEXTTRACK), WM_SETFONT, reinterpret_cast<WPARAM>(static_cast<HFONT>(m_webdingsFont)), 0); SendMessage(GetItem(IDC_PREVTAB_BUTTON), WM_SETFONT, reinterpret_cast<WPARAM>(static_cast<HFONT>(m_webdingsFont)), 0); SendMessage(GetItem(IDC_NEXTTAB_BUTTON), WM_SETFONT, reinterpret_cast<WPARAM>(static_cast<HFONT>(m_webdingsFont)), 0); } if(m_segoeUiSymbolFont.IsValid()) { SendMessage(GetItem(IDC_EJECT_BUTTON), WM_SETFONT, reinterpret_cast<WPARAM>(static_cast<HFONT>(m_segoeUiSymbolFont)), 0); SendMessage(GetItem(IDC_EJECT_BUTTON), WM_SETTEXT, NULL, reinterpret_cast<LPARAM>(_T("\u23CF"))); } //Create tray icon if(m_useTrayIcon) { m_trayIconServer = new Framework::Win32::CTrayIconServer(); Framework::Win32::CTrayIcon* trayIcon = m_trayIconServer->Insert(); trayIcon->SetIcon(LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAIN))); trayIcon->SetTip(_T("PsfPlayer")); m_trayIconServer->RegisterHandler(std::bind(&CMainWindow::OnTrayIconEvent, this, std::placeholders::_1, std::placeholders::_2)); } //Create play list panel m_playlistPanel = new CPlaylistPanel(m_hWnd, m_playlist); m_playlistPanel->OnItemDblClick.connect(std::bind(&CMainWindow::OnPlaylistItemDblClick, this, std::placeholders::_1)); m_playlistPanel->OnAddClick.connect(std::bind(&CMainWindow::OnPlaylistAddClick, this)); m_playlistPanel->OnRemoveClick.connect(std::bind(&CMainWindow::OnPlaylistRemoveClick, this, std::placeholders::_1)); m_playlistPanel->OnSaveClick.connect(std::bind(&CMainWindow::OnPlaylistSaveClick, this)); //Create file information panel m_fileInformationPanel = new CFileInformationPanel(m_hWnd); //Create RegView panels m_spu0RegViewPanel = new CSpuRegViewPanel(m_hWnd, _T("SPU0")); m_spu1RegViewPanel = new CSpuRegViewPanel(m_hWnd, _T("SPU1")); //Initialize panels m_panels[0] = m_playlistPanel; m_panels[1] = m_fileInformationPanel; m_panels[2] = m_spu0RegViewPanel; m_panels[3] = m_spu1RegViewPanel; CreateAudioPluginMenu(); UpdateAudioPluginMenu(); CreateCharEncodingMenu(); UpdateCharEncodingMenu(); UpdateClock(); UpdateTitle(); UpdatePlaybackButtons(); UpdateConfigMenu(); m_currentPanel = -1; ActivatePanel(0); }
/*! Handle the messages routed to the display queue */ static void DisplayQueueMessageHandler(tMessage* pMsg) { tMessage Msg; unsigned char i = 0; switch (pMsg->Type) { case WriteBufferMsg: WriteBufferHandler(pMsg); break; case SetWidgetListMsg: SetWidgetList(pMsg); break; case UpdateDisplayMsg: if ((!(pMsg->Options & MSG_OPT_UPD_INTERNAL) && (pMsg->Options & MODE_MASK) == NOTIF_MODE) && GetProperty(PROP_AUTO_BACKLIGHT)) SendMessage(&Msg, AutoBacklightMsg, MSG_OPT_NONE); UpdateDisplayHandler(pMsg); break; case UpdateClockMsg: UpdateClock(); break; case DrawClockWidgetMsg: DrawClockWidget(pMsg->Options); break; case MonitorBatteryMsg: MonitorBattery(); break; case BluetoothStateChangeMsg: BluetoothStateChangeHandler(pMsg); break; case IdleUpdateMsg: IdleUpdateHandler(); break; case ButtonStateMsg: ButtonStateHandler(); break; case CallerIdMsg: pMsg->pBuffer[pMsg->Length] = NUL; ShowCall((char *)pMsg->pBuffer, pMsg->Options); break; case CallerNameMsg: if (pMsg->Length) { pMsg->pBuffer[pMsg->Length] = NUL; ShowCall((char *)pMsg->pBuffer, SHOW_NOTIF_CALLER_NAME); if (GetProperty(PROP_AUTO_BACKLIGHT)) SendMessage(&Msg, AutoBacklightMsg, MSG_OPT_NONE); } else ShowCall("", pMsg->Options); break; case MusicPlayStateMsg: HandleMusicPlayStateChange(pMsg->Options); break; case ChangeModeMsg: ChangeModeHandler(pMsg->Options); break; case ControlFullScreenMsg: SetProperty(PROP_PHONE_DRAW_TOP, pMsg->Options || *pMsg->pBuffer ? PROP_PHONE_DRAW_TOP : 0); break; case ModifyTimeMsg: ModifyTimeHandler(pMsg); break; case MenuModeMsg: MenuModeHandler(pMsg->Options); break; case MenuButtonMsg: MenuButtonHandler(pMsg->Options); break; case EnableButtonMsg: EnableButtonMsgHandler(pMsg); break; case DevTypeMsg: SetupMessageWithBuffer(&Msg, DevTypeRespMsg, BOARD_TYPE); //default G2 if (Msg.pBuffer != NULL) { Msg.pBuffer[0] = BOARD_TYPE; // backward compatible Msg.Length = 1; if (GetMsp430HardwareRevision() < 'F') { Msg.Options = DIGITAL_WATCH_TYPE_G1; Msg.pBuffer[0] = DIGITAL_WATCH_TYPE_G1; // backward compatible } Msg.Options |= pMsg->Options & 0x80; // support ACK RouteMsg(&Msg); } PrintF("- DevTypeResp:%d", Msg.Options); // set ACK bit SendMessage(&Msg, ConnTypeMsg, pMsg->Options); break; case VerInfoMsg: SetupMessageWithBuffer(&Msg, VerInfoRespMsg, MSG_OPT_NONE); if (Msg.pBuffer != NULL) { /* exclude middle '.' */ strncpy((char *)Msg.pBuffer, BUILD, 3); strncpy((char *)Msg.pBuffer + 3, BUILD + 4, 3); Msg.Length += strlen(BUILD) - 1; *(Msg.pBuffer + Msg.Length++) = (unsigned char)atoi(VERSION); while (VERSION[i++] != '.'); *(Msg.pBuffer + Msg.Length++) = atoi(VERSION + i); *(Msg.pBuffer + Msg.Length++) = NULL; RouteMsg(&Msg); } PrintS("-Ver:"); for (i = 6; i < Msg.Length; ++i) PrintH(Msg.pBuffer[i]); break; case SetVibrateMode: SetVibrateModeHandler(pMsg); break; case SetRtcMsg: SetRtc((Rtc_t *)pMsg->pBuffer); #if COUNTDOWN_TIMER if (CurrentPage[PageType] == CountdownPage && CountdownMode() == COUNTING) SendMessage(&Msg, CountDownMsg, MSG_OPT_CNTDWN_TIME); #endif UpdateClock(); break; #if COUNTDOWN_TIMER case CountDownMsg: if (pMsg->Options == MSG_OPT_NONE) { PageType = PAGE_TYPE_INFO; CurrentPage[PageType] = CountdownPage; } DrawCountdownScreen(pMsg->Options); break; case SetCountdownDoneMsg: // for testing // Rtc_t Done; // Done.Month = 5; // Done.Day = 1; // Done.Hour = 0; // Done.Minute = 0; // SetDoneTime(&Done); // Valid only DoneTime is different if (SetDoneTime((Rtc_t *)pMsg->pBuffer)) SendMessage(&Msg, CountDownMsg, MSG_OPT_NONE); break; #endif case ServiceMenuMsg: ServiceMenuHandler(); break; case DisableButtonMsg: DisableButtonMsgHandler(pMsg); break; case ReadButtonConfigMsg: ReadButtonConfigHandler(pMsg); break; case SetBacklightMsg: SetBacklight(pMsg->Options); // testing // pMsg->Type = AccelMsg; // pMsg->Options = 1; //enable // HandleAccelerometer(pMsg); break; case AutoBacklightMsg: if (LightSenseCycle() < DARK_LEVEL) SetBacklight(LED_ON_OPTION); break; case BatteryConfigMsg: SetBatteryLevels(pMsg->pBuffer); break; case ReadBatteryVoltageMsg: ReadBatteryVoltageHandler(); break; case ResetMsg: SoftwareResetHandler(pMsg); break; case NvalOperationMsg: NvalOperationHandler(pMsg); break; case SecInvertMsg: HandleSecInvert(pMsg->Options); break; case LoadTemplateMsg: LoadTemplateHandler(pMsg); break; case LinkAlarmMsg: if (LinkAlarmEnable) { SetupMessageWithBuffer(&Msg, SetVibrateMode, MSG_OPT_NONE); if (Msg.pBuffer != NULL) { *(tSetVibrateModePayload *)Msg.pBuffer = LnkAlmTone; RouteMsg(&Msg); } } break; case ModeTimeoutMsg: ModeTimeoutHandler(); break; case WatchStatusMsg: PageType = PAGE_TYPE_INFO; CurrentPage[PageType] = StatusPage; DrawWatchStatusScreen(); break; // case ListPairedDevicesMsg: // ListPairedDevicesHandler(); // break; case WatchDrawnScreenTimeout: IdleUpdateHandler(); break; case TermModeMsg: TermModeHandler(); break; case LowBatteryWarningMsg: break; case LowBatteryBtOffMsg: UpdateClock(); break; #if __IAR_SYSTEMS_ICC__ case EraseTemplateMsg: EraseTemplateHandler(pMsg); break; case WriteToTemplateMsg: WriteToTemplateHandler(pMsg); break; #endif case AccelMsg: HandleAccelerometer(pMsg); break; case ReadLightSensorMsg: ReadLightSensorHandler(); break; case RateTestMsg: SetupMessageWithBuffer(&Msg, DiagnosticLoopback, MSG_OPT_NONE); if (Msg.pBuffer != NULL) { /* don't care what data is */ Msg.Length = 10; RouteMsg(&Msg); } break; default: PrintF("# Disp Msg: 0x%02x", pMsg->Type); break; } }
void OnTimer(wxTimerEvent& WXUNUSED(event)) { UpdateClock(); }
void CVideoSyncGLX::Run(std::atomic<bool>& stop) { unsigned int PrevVblankCount; unsigned int VblankCount; int ReturnV; bool IsReset = false; int64_t Now; //get the current vblank counter m_glXGetVideoSyncSGI(&VblankCount); PrevVblankCount = VblankCount; while(!stop && !m_displayLost && !m_displayReset) { //wait for the next vblank ReturnV = m_glXWaitVideoSyncSGI(2, (VblankCount + 1) % 2, &VblankCount); m_glXGetVideoSyncSGI(&VblankCount); //the vblank count returned by glXWaitVideoSyncSGI is not always correct Now = CurrentHostCounter(); //get the timestamp of this vblank if(ReturnV) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXWaitVideoSyncSGI returned %i", ReturnV); return; } if (VblankCount > PrevVblankCount) { UpdateClock((int)(VblankCount - PrevVblankCount), Now, m_refClock); IsReset = false; } else { CLog::Log(LOGDEBUG, "CVideoReferenceClock: Vblank counter has reset"); //only try reattaching once if (IsReset) return; //because of a bug in the nvidia driver, glXWaitVideoSyncSGI breaks when the vblank counter resets CLog::Log(LOGDEBUG, "CVideoReferenceClock: Detaching glX context"); ReturnV = glXMakeCurrent(m_Dpy, None, NULL); if (ReturnV != True) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXMakeCurrent returned %i", ReturnV); return; } //sleep here so we don't busy spin when this constantly happens, for example when the display went to sleep Sleep(1000); CLog::Log(LOGDEBUG, "CVideoReferenceClock: Attaching glX context"); ReturnV = glXMakeCurrent(m_Dpy, m_Window, m_Context); if (ReturnV != True) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXMakeCurrent returned %i", ReturnV); return; } m_glXGetVideoSyncSGI(&VblankCount); IsReset = true; } PrevVblankCount = VblankCount; } m_lostEvent.Set(); while(!stop && m_displayLost && !m_displayReset) { Sleep(10); } }
uint64_t RealClockTimeMicro() { UpdateClock(); return ClockTimeMicro(); }
uint64_t RealClockTimeNano() { UpdateClock(); return ClockTimeNano(); }
void CScreensaverOverlay::RenderControl() { UpdateClock(); SallyAPI::GUI::CApplicationWindow::RenderControl(); }
inline time_t Now() { UpdateClock(); return _ts.tv_sec; }
void ShowPictureWindows( int window ) { switch (window) { case 1: // Main Window. TAP_Osd_FillBox( rgn, SCREEN_X_MIN, SCREEN_Y_MIN, SCREEN_W_MAX, SCREEN_H_MAX, 0 ); // Clear the entire Main window area. TAP_Channel_Scale( CHANNEL_Main, SCREEN_X, SCREEN_Y, SCREEN_W, SCREEN_H, FALSE ); if (guideWindowDisplayed) DisplayGuideWindow( currentSvcType, currentSvcNum ); UpdateClock( rgn, CLOCK_X, CLOCK_Y ); // Draw the clock. TAP_Osd_DrawRectangle( rgn, PIP_SCRX, PIP_SCRY, PIP_SCRW, PIP_SCRH, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, BASE_X-10, BASE_Y-HEADER_H, LOGO_WINDOW_W-BASE_X+10, LOGO_WINDOW_H-BASE_Y+HEADER_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, GDE_X-1, GDE_Y, GDE_W, GDE_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, EVENT_X, EVENT_Y, EVENT_W, EVENT_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, CLOCK_X-CLOCK_W, CLOCK_Y, CLOCK_W, CLOCK_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, GDE_SCREEN_X, GDE_SCREEN_Y, GDE_SCREEN_W, GDE_SCREEN_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, SCREEN_X, SCREEN_Y, SCREEN_W, SCREEN_H, 2, COLOR_Red ); break; case 2: // PiP Window. TAP_Osd_FillBox( rgn, 0, PIP_SCRY-1, PIP_X_MAX, OSD_MAX_Y-(PIP_SCRY-1), 0 ); // Clear the entire PIP window area. TAP_Channel_Scale( CHANNEL_Sub, PIP_SCRX, PIP_SCRY, PIP_SCRW, PIP_SCRH, FALSE ); // define the PIP window UpdateClock( rgn, CLOCK_X, CLOCK_Y ); // Draw the clock. TAP_Osd_DrawRectangle( rgn, SCREEN_X, SCREEN_Y, SCREEN_W, SCREEN_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, PIP_SCRX, PIP_SCRY, PIP_SCRW, PIP_SCRH, 2, COLOR_Red ); TAP_Osd_DrawRectangle( rgn, BASE_X-10, BASE_Y-HEADER_H, LOGO_WINDOW_W-BASE_X+10, LOGO_WINDOW_H-BASE_Y+HEADER_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, GDE_X-1, GDE_Y, GDE_W, GDE_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, EVENT_X, EVENT_Y, EVENT_W, EVENT_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, CLOCK_X-CLOCK_W, CLOCK_Y, CLOCK_W, CLOCK_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, GDE_SCREEN_X, GDE_SCREEN_Y, GDE_SCREEN_W, GDE_SCREEN_H, 2, COLOR_Yellow ); break; case 3: // Logo Window. TAP_Osd_FillBox( rgn, SCREEN_X_MIN, SCREEN_Y_MIN, SCREEN_W_MAX, SCREEN_H_MAX, 0 ); // Clear the entire Main window area. ActivateLogos( currentSvcType, currentSvcNum ); // draw the logos if (guideWindowDisplayed) { CloseGuideWindow(); // Close current Guide window ActivateGuideWindow(); // Reactivate with new coordinates. DisplayGuideWindow( currentSvcType, currentSvcNum ); } UpdateClock( rgn, CLOCK_X, CLOCK_Y ); // Draw the clock. TAP_Osd_DrawRectangle( rgn, SCREEN_X, SCREEN_Y, SCREEN_W, SCREEN_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, PIP_SCRX, PIP_SCRY, PIP_SCRW, PIP_SCRH, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, BASE_X-10, BASE_Y-HEADER_H, LOGO_WINDOW_W-BASE_X+10, LOGO_WINDOW_H-BASE_Y+HEADER_H, 2, COLOR_Red ); TAP_Osd_DrawRectangle( rgn, BASE_X-10, LOGO_WINDOW_H, LOGO_WINDOW_W-BASE_X+10, 2, 1, COLOR_Black ); TAP_Osd_DrawRectangle( rgn, GDE_X-1, GDE_Y, GDE_W, GDE_H, 2, COLOR_Red ); TAP_Osd_DrawRectangle( rgn, EVENT_X, EVENT_Y, EVENT_W, EVENT_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, CLOCK_X-CLOCK_W, CLOCK_Y, CLOCK_W, CLOCK_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, GDE_SCREEN_X, GDE_SCREEN_Y, GDE_SCREEN_W, GDE_SCREEN_H, 2, COLOR_Yellow ); break; case 4: // Event Info Window DisplayScreenConfigWindow(window); // Redraw Event Window with new coordinates. UpdateClock( rgn, CLOCK_X, CLOCK_Y ); // Draw the clock. TAP_Osd_DrawRectangle( rgn, SCREEN_X, SCREEN_Y, SCREEN_W, SCREEN_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, PIP_SCRX, PIP_SCRY, PIP_SCRW, PIP_SCRH, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, BASE_X-10, BASE_Y-HEADER_H, LOGO_WINDOW_W-BASE_X+10, LOGO_WINDOW_H-BASE_Y+HEADER_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, GDE_X-1, GDE_Y, GDE_W, GDE_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, EVENT_X, EVENT_Y, EVENT_W, EVENT_H, 2, COLOR_Red ); TAP_Osd_DrawRectangle( rgn, CLOCK_X-CLOCK_W, CLOCK_Y, CLOCK_W, CLOCK_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, GDE_SCREEN_X, GDE_SCREEN_Y, GDE_SCREEN_W, GDE_SCREEN_H, 2, COLOR_Yellow ); break; case 5: // Clock Window UpdateClock( rgn, CLOCK_X, CLOCK_Y ); // Draw the clock. TAP_Osd_DrawRectangle( rgn, SCREEN_X, SCREEN_Y, SCREEN_W, SCREEN_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, PIP_SCRX, PIP_SCRY, PIP_SCRW, PIP_SCRH, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, BASE_X-10, BASE_Y-HEADER_H, LOGO_WINDOW_W-BASE_X+10, LOGO_WINDOW_H-BASE_Y+HEADER_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, GDE_X-1, GDE_Y, GDE_W, GDE_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, EVENT_X, EVENT_Y, EVENT_W, EVENT_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, CLOCK_X-CLOCK_W, CLOCK_Y, CLOCK_W, CLOCK_H, 2, COLOR_Red ); TAP_Osd_DrawRectangle( rgn, GDE_SCREEN_X, GDE_SCREEN_Y, GDE_SCREEN_W, GDE_SCREEN_H, 2, COLOR_Yellow ); break; case 6: // Main Window with Guide Window Active TAP_Osd_FillBox( rgn, LOGO_WINDOW_W+GDE_W, 0, OSD_MAX_X-(LOGO_WINDOW_W+GDE_W), EVENT_Y-1, 0 ); // Clear the entire Main window area. TAP_Channel_Scale( CHANNEL_Main, GDE_SCREEN_X, GDE_SCREEN_Y, GDE_SCREEN_W, GDE_SCREEN_H, FALSE ); if (guideWindowDisplayed) DisplayGuideWindow( currentSvcType, currentSvcNum ); UpdateClock( rgn, CLOCK_X, CLOCK_Y ); // Draw the clock. TAP_Osd_DrawRectangle( rgn, PIP_SCRX, PIP_SCRY, PIP_SCRW, PIP_SCRH, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, BASE_X-10, BASE_Y-HEADER_H, LOGO_WINDOW_W-BASE_X+10, LOGO_WINDOW_H-BASE_Y+HEADER_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, GDE_X-1, GDE_Y, GDE_W, GDE_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, EVENT_X, EVENT_Y, EVENT_W, EVENT_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, CLOCK_X-CLOCK_W, CLOCK_Y, CLOCK_W, CLOCK_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, SCREEN_X, SCREEN_Y, SCREEN_W, SCREEN_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, GDE_SCREEN_X, GDE_SCREEN_Y, GDE_SCREEN_W, GDE_SCREEN_H, 2, COLOR_Red ); break; case OVERSCAN_WINDOW: // Overscan window SetOverScanSizes(); TAP_Osd_FillBox( rgn, 0, 0, OSD_MAX_X, OSD_MAX_Y, 0 ); // Clear the entire window area. ActivateLogos( currentSvcType, currentSvcNum ); // draw the logos DisplayScreenConfigWindow(window); // Redraw Event Window with new coordinates. TAP_Channel_Scale( CHANNEL_Main, SCREEN_X, SCREEN_Y, SCREEN_W, SCREEN_H, FALSE ); TAP_Channel_Scale( CHANNEL_Sub, PIP_SCRX, PIP_SCRY, PIP_SCRW, PIP_SCRH, FALSE ); // define the PIP window if (guideWindowDisplayed) DisplayGuideWindow( currentSvcType, currentSvcNum ); UpdateClock( rgn, CLOCK_X, CLOCK_Y ); // Draw the clock. TAP_Osd_DrawRectangle( rgn, PIP_SCRX, PIP_SCRY, PIP_SCRW, PIP_SCRH, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, BASE_X-10, BASE_Y-HEADER_H, LOGO_WINDOW_W-BASE_X+10, LOGO_WINDOW_H-BASE_Y+HEADER_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, GDE_X-1, GDE_Y, GDE_W, GDE_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, EVENT_X, EVENT_Y, EVENT_W, EVENT_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, CLOCK_X-CLOCK_W, CLOCK_Y, CLOCK_W, CLOCK_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, SCREEN_X, SCREEN_Y, SCREEN_W, SCREEN_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, GDE_SCREEN_X, GDE_SCREEN_Y, GDE_SCREEN_W, GDE_SCREEN_H, 2, COLOR_Yellow ); TAP_Osd_DrawRectangle( rgn, OVERSCAN_X, OVERSCAN_Y, OVERSCAN_W, OVERSCAN_H, 2, COLOR_Red ); break; } }
void EditClock::saveAsData() { QString clockname=edit_name; QString sql; RDSqlQuery *q; QString str; if(!ValidateCode()) { return; } QString old_name=edit_name; if(edit_modified) { switch(QMessageBox::question(this,tr("Clock Modified"), tr("The clock has been modified.\nDo you want to save?"),QMessageBox::Yes,QMessageBox::No,QMessageBox::Cancel)) { case QMessageBox::Yes: Save(); break; case QMessageBox::Cancel: case QMessageBox::NoButton: return; break; } } if(edit_shortname_edit->text().isEmpty()) { QMessageBox::warning(this,tr("Missing Clock Code"), tr("You must specify a clock code!")); return; } sql= QString().sprintf("select SHORT_NAME from CLOCKS where SHORT_NAME=\"%s\"", (const char *) RDEscapeString(edit_shortname_edit->text())); q=new RDSqlQuery(sql); if(q->first()) { QMessageBox::warning(this,tr("Code Exists"), tr("The clock code is already in use!")); delete q; return; } delete q; AddClock *addclock=new AddClock(&clockname,this,"addclock"); if(addclock->exec()<0) { delete addclock; return; } delete addclock; edit_name=clockname; sql=QString().sprintf("select NAME from CLOCKS where NAME=\"%s\"", (const char *)clockname); q=new RDSqlQuery(sql); if(q->first()) { if(QMessageBox::question(this,tr("Clock Exists"), tr("Clock already exists! Overwrite?"),QMessageBox::Yes,QMessageBox::No)!=QMessageBox::Yes) { delete q; return; } } delete q; edit_clock->setName(clockname); sql=RDCreateClockTableSql(RDClock::tableName(clockname)); q=new RDSqlQuery(sql); delete q; Save(); edit_new_clocks->push_back(clockname); CopyClockPerms(old_name,clockname); if(edit_new_clock) { AbandonClock(old_name); } edit_clockname_label->setText(clockname); UpdateClock(); str=QString(tr("Edit Clock:")); setCaption(QString().sprintf("%s %s",(const char *)str, (const char *)edit_name)); }
/******************************************************************************* 関数名: void UpdateGame(void) 引数: なし 戻り値: なし 説明: ゲームの更新関数 *******************************************************************************/ void UpdateGame(void) { //初期値 g_fTimeSpeed = 0.01f; GAME_STEP stepNow = GetGameStep(); switch(stepNow) { case STEP_PLAY: UpdatePlayer(); UpdateCamera(); UpdateGun(); UpdatePlayerBullet(g_fTimeSpeed); UpdateEnemy( g_fTimeSpeed); UpdateEnemyBullet( g_fTimeSpeed); //UpdateBillBoard(); UpdateParticle( g_fTimeSpeed); UpdateStageManager( g_fTimeSpeed); //UpdateModel(); UpdateGunSight(); UpdateItemBullet(); UpdateClock( g_fTimeSpeed); UpdateTime( g_fTimeSpeed); if(GetKeyboardTrigger(DIK_P) ) { SetGameStep(STEP_PAUSE); SetMessage(MSG_PAUSE); } break; case STEP_SHOOT: ChangeTimeSpeed( 1.0f); UpdateEnemy( g_fTimeSpeed); //UpdatePlayer(); UpdatePlayerBullet( g_fTimeSpeed); //UpdateEnemyBullet( g_fTimeSpeed); UpdateClock( g_fTimeSpeed); UpdateTime( g_fTimeSpeed); g_nCounterShoot++; if( g_nCounterShoot > 15) { g_nCounterShoot = 0; SetGameStep(STEP_PLAY); } break; case STEP_PAUSE: StopSound(); if(GetKeyboardTrigger(DIK_P) ) { SetGameStep(STEP_PLAY); ClearMessage(MSG_PAUSE); } break; case STEP_DIE: ChangeTimeSpeed( 1.0f); UpdateEnemy( g_fTimeSpeed); UpdateEnemyBullet( g_fTimeSpeed); UpdatePlayerBullet( g_fTimeSpeed); UpdateParticle( g_fTimeSpeed); g_nCounterFrame++; if( g_nCounterFrame > 90) { g_nCounterFrame = 0; if( GetPlayer()->nLife <= 0) { FadeOutToNext(MODE_RESULT); } else { FadeOutToNext(STEP_RESET); SetGameStep(STEP_NOTHING); } } break; case STEP_RESET: InitStageManager( false, GetPlayer()->nLife); SetGameStep(STEP_PLAY); break; case STEP_CLEAR: StopSound(SOUND_LABEL_SE_RUN); SetMessage(MSG_STAGECLEAR); g_nCounterFrame++; if( g_nCounterFrame > 90) { g_nCounterFrame = 0; switch(GetStageMode()) { case STAGE0: FadeOutToNext(STAGE1); break; case STAGE1: FadeOutToNext(STAGE2); break; case STAGE2: FadeOutToNext(STAGE3); break; case STAGE3: FadeOutToNext(MODE_RESULT); g_bGameClear = true; break; } SetGameStep(STEP_NOTHING); } break; case STEP_NOTHING: //just let time go, and do nothing break; } //UI update UpdateNumBullet(); //Debug update UpdateMeshDome(); if(GetKeyboardTrigger(DIK_RETURN) ) { FadeOutToNext(MODE_RESULT); } if(GetKeyboardTrigger(DIK_F3)) { PlaySound( SOUND_LABEL_SE_CLEAR); SetGameStep(STEP_CLEAR); } if(GetKeyboardTrigger(DIK_F2)) { PlaySound(SOUND_LABEL_SE_SWITCH); SwitchDebug(); } }
void GameLoop(void) { InputAtom InputEvent; POINT MousePos; UINT32 uiOldScreen=guiCurrentScreen; GetCursorPos(&MousePos); // Hook into mouse stuff for MOVEMENT MESSAGES MouseSystemHook(MOUSE_POS, (UINT16)MousePos.x ,(UINT16)MousePos.y ,_LeftButtonDown, _RightButtonDown); MusicPoll( FALSE ); while (DequeueSpecificEvent(&InputEvent, LEFT_BUTTON_REPEAT|RIGHT_BUTTON_REPEAT|LEFT_BUTTON_DOWN|LEFT_BUTTON_UP|RIGHT_BUTTON_DOWN|RIGHT_BUTTON_UP ) == TRUE ) { // HOOK INTO MOUSE HOOKS switch(InputEvent.usEvent) { case LEFT_BUTTON_DOWN: MouseSystemHook(LEFT_BUTTON_DOWN, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown); break; case LEFT_BUTTON_UP: MouseSystemHook(LEFT_BUTTON_UP, (INT16)MousePos.x, (INT16)MousePos.y ,_LeftButtonDown, _RightButtonDown); break; case RIGHT_BUTTON_DOWN: MouseSystemHook(RIGHT_BUTTON_DOWN, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown); break; case RIGHT_BUTTON_UP: MouseSystemHook(RIGHT_BUTTON_UP, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown); break; case LEFT_BUTTON_REPEAT: MouseSystemHook(LEFT_BUTTON_REPEAT, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown); break; case RIGHT_BUTTON_REPEAT: MouseSystemHook(RIGHT_BUTTON_REPEAT, (INT16)MousePos.x, (INT16)MousePos.y,_LeftButtonDown, _RightButtonDown); break; } } if ( gfGlobalError ) { guiCurrentScreen = ERROR_SCREEN; } //if we are to check for free space on the hard drive if( gubCheckForFreeSpaceOnHardDriveCount < DONT_CHECK_FOR_FREE_SPACE ) { //only if we are in a screen that can get this check if( guiCurrentScreen == MAP_SCREEN || guiCurrentScreen == GAME_SCREEN || guiCurrentScreen == SAVE_LOAD_SCREEN ) { if( gubCheckForFreeSpaceOnHardDriveCount < 1 ) { gubCheckForFreeSpaceOnHardDriveCount++; } else { // Make sure the user has enough hard drive space if( !DoesUserHaveEnoughHardDriveSpace() ) { CHAR16 zText[512]; CHAR16 zSpaceOnDrive[512]; UINT32 uiSpaceOnDrive; CHAR16 zSizeNeeded[512]; swprintf( zSizeNeeded, L"%d", REQUIRED_FREE_SPACE / BYTESINMEGABYTE ); InsertCommasForDollarFigure( zSizeNeeded ); uiSpaceOnDrive = GetFreeSpaceOnHardDriveWhereGameIsRunningFrom( ); swprintf( zSpaceOnDrive, L"%.2f", uiSpaceOnDrive / (FLOAT)BYTESINMEGABYTE ); swprintf( zText, pMessageStrings[ MSG_LOWDISKSPACE_WARNING ], zSpaceOnDrive, zSizeNeeded ); if( guiPreviousOptionScreen == MAP_SCREEN ) DoMapMessageBox( MSG_BOX_BASIC_STYLE, zText, MAP_SCREEN, MSG_BOX_FLAG_OK, NULL ); else DoMessageBox( MSG_BOX_BASIC_STYLE, zText, GAME_SCREEN, MSG_BOX_FLAG_OK, NULL, NULL ); } gubCheckForFreeSpaceOnHardDriveCount = DONT_CHECK_FOR_FREE_SPACE; } } } // ATE: Force to be in message box screen! if ( gfInMsgBox ) { guiPendingScreen = MSG_BOX_SCREEN; } if ( guiPendingScreen != NO_PENDING_SCREEN ) { // Based on active screen, deinit! if( guiPendingScreen != guiCurrentScreen ) { switch( guiCurrentScreen ) { case MAP_SCREEN: if( guiPendingScreen != MSG_BOX_SCREEN ) { EndMapScreen( FALSE ); } break; case LAPTOP_SCREEN: ExitLaptop(); break; } } // if the screen has chnaged if( uiOldScreen != guiPendingScreen ) { // Set the fact that the screen has changed uiOldScreen = guiPendingScreen; HandleNewScreenChange( guiPendingScreen, guiCurrentScreen ); } guiCurrentScreen = guiPendingScreen; guiPendingScreen = NO_PENDING_SCREEN; } uiOldScreen = (*(GameScreens[guiCurrentScreen].HandleScreen))(); // if the screen has chnaged if( uiOldScreen != guiCurrentScreen ) { HandleNewScreenChange( uiOldScreen, guiCurrentScreen ); guiCurrentScreen = uiOldScreen; } RefreshScreen( NULL ); guiGameCycleCounter++; UpdateClock(); #ifdef JA2BETAVERSION if( gubReportMapscreenLock ) { ReportMapscreenErrorLock(); } #endif }
HRESULT CTSParserInputPin::Receive(IMediaSample * pSample) { // Lock this with the receiver lock CAutoLock lock(m_pReceiveLock); // Check all is well with the base class, if not, drop it. HRESULT hr = CBaseInputPin::Receive(pSample); if(hr != S_OK) { return hr; } // Send the sample to the table processor object for processing CHECK_BADPTR( TEXT("invalid sample"), pSample); BYTE* pData = NULL; hr = pSample->GetPointer(&pData); CHECK_ERROR( TEXT("pSample->GetPointer() failed"), hr); CHECK_BADPTR( TEXT("invalid data point"), pData); long lDataLen; lDataLen = pSample->GetActualDataLength(); //we need check TS format, to setup TSDemuxer if ( m_bIsSagePushSource && m_pFilter->m_dwDumpedBytes == 0 ) { int uInputStreamFormat = CheckFormat( pData, lDataLen ); if ( uInputStreamFormat && uInputStreamFormat != MPEG_TS ) { ChangeDemuxerTSStreamType( m_pTSRemuxer, uInputStreamFormat ); } } //use debug data file to replace input data for debug if ( m_pFilter->m_hDebugFileSource != NULL ) { int lReadBytes = (long)fread( pData, 1, lDataLen, m_pFilter->m_hDebugFileSource ); if ( feof( m_pFilter->m_hDebugFileSource ) ) fseek( m_pFilter->m_hDebugFileSource, 0, SEEK_SET ); //looping reading lDataLen = lReadBytes; } if ( !m_pFilter->m_bParserEnabled ) return hr; //pass thrus data pin DWORD Bytes, dwLength, UsedBytes; BYTE *pStart; DWORD dwAllocSize; pStart = pData; dwLength = lDataLen; if ( lDataLen > 0 && m_pFilter->m_dwDumpSize && m_pFilter->GetDumpSize( &dwAllocSize ) == S_OK && m_pFilter->m_dwDumpedBytes < m_pFilter->m_dwDumpSize ) { while ( dwLength > 0 ) { Bytes = dwAllocSize > dwLength ? dwLength : dwAllocSize; m_pFilter->DumpOut( pStart, Bytes, &UsedBytes ); dwLength -= UsedBytes; pStart += UsedBytes; } } m_pFilter->m_dwDumpedBytes += lDataLen; if ( m_pFilter->m_bPassThroughEnabled ) { pStart = pData; dwLength = lDataLen; if ( m_pFilter->GetPassThroughSize( &dwAllocSize ) == S_OK ) { while ( dwLength > 0 ) { Bytes = dwAllocSize > dwLength ? dwLength : dwAllocSize; m_pFilter->PassThrough( pStart, Bytes, &UsedBytes ); dwLength -= UsedBytes; pStart += UsedBytes; } } } //Remux data to push data out if ( !m_bScanChannel && m_pTSRemuxer && lDataLen ) { int nUsedBytes; pStart = pData; dwLength = lDataLen; if ( m_nExpectedBytes ) { int nExpectedBytes2; memcpy( m_cAlignBuffer+m_nAlignBytes, pStart, m_nExpectedBytes ); nUsedBytes = PushRemuxStreamData( m_pTSRemuxer, m_cAlignBuffer, m_nAlignBytes+m_nExpectedBytes, &nExpectedBytes2 ); if ( nExpectedBytes2 == 0 ) { pStart += m_nExpectedBytes; dwLength -= m_nExpectedBytes; } } nUsedBytes = PushRemuxStreamData( m_pTSRemuxer, pStart, dwLength, &m_nExpectedBytes ); m_nAlignBytes = dwLength - nUsedBytes; ASSERT( m_nExpectedBytes+m_nAlignBytes <= sizeof(m_cAlignBuffer) ); ASSERT( m_nAlignBytes >= 0 ); if ( m_nAlignBytes > 0 && m_nAlignBytes + m_nExpectedBytes <= sizeof(m_cAlignBuffer)) { memcpy( m_cAlignBuffer, pStart+nUsedBytes, m_nAlignBytes ); } else { //drop data, because of asking too many m_nExpectedBytes = 0; } } if ( m_bScanChannel && m_pCScan ) { m_pCScan->ProcessScan( pData, lDataLen ); } if ( !m_pFilter->m_bDisableClockTimeout ) { DWORD dwTickMs = clock( )*1000/CLOCKS_PER_SEC; UpdateClock( m_pTSRemuxer, dwTickMs ); } return hr; }