QScriptValue localizedStringToScriptValue(QScriptEngine *engine, const LocalizedString &s) { QScriptValue value = engine->newObject(); value.setProperty("context", QString::fromUtf8(s.context())); value.setProperty("text", QString::fromUtf8(s.original())); value.setProperty("toString", engine->newFunction(localizedStringToString)); return value; }
RString RageDisplay_D3D::Init( const VideoModeParams &p, bool /* bAllowUnacceleratedRenderer */ ) { GraphicsWindow::Initialize( true ); LOG->Trace( "RageDisplay_D3D::RageDisplay_D3D()" ); LOG->MapLog("renderer", "Current renderer: Direct3D"); g_pd3d = Direct3DCreate9(D3D_SDK_VERSION); if(!g_pd3d) { LOG->Trace( "Direct3DCreate9 failed" ); return D3D_NOT_INSTALLED.GetValue(); } if( FAILED( g_pd3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &g_DeviceCaps) ) ) return HARDWARE_ACCELERATION_NOT_AVAILABLE.GetValue(); D3DADAPTER_IDENTIFIER9 identifier; g_pd3d->GetAdapterIdentifier( D3DADAPTER_DEFAULT, 0, &identifier ); LOG->Trace( "Driver: %s\n" "Description: %s\n" "Max texture size: %d\n" "Alpha in palette: %s\n", identifier.Driver, identifier.Description, g_DeviceCaps.MaxTextureWidth, (g_DeviceCaps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE) ? "yes" : "no" ); LOG->Trace( "This display adaptor supports the following modes:" ); D3DDISPLAYMODE mode; UINT modeCount = g_pd3d->GetAdapterModeCount(D3DADAPTER_DEFAULT, g_DefaultAdapterFormat); for( UINT u=0; u < modeCount; u++ ) if( SUCCEEDED( g_pd3d->EnumAdapterModes( D3DADAPTER_DEFAULT, g_DefaultAdapterFormat, u, &mode ) ) ) LOG->Trace( " %ux%u %uHz, format %d", mode.Width, mode.Height, mode.RefreshRate, mode.Format ); g_PaletteIndex.clear(); for( int i = 0; i < 256; ++i ) g_PaletteIndex.push_back(i); // Save the original desktop format. g_pd3d->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &g_DesktopMode ); /* Up until now, all we've done is set up g_pd3d and do some queries. Now, * actually initialize the window. Do this after as many error conditions as * possible, because if we have to shut it down again we'll flash a window briefly. */ bool bIgnore = false; return SetVideoMode( p, bIgnore ); }
BOOL CSMPackageInstallDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here DialogUtil::LocalizeDialogAndContents( *this ); DialogUtil::SetHeaderFont( *this, IDC_STATIC_HEADER_TEXT ); // mount the zip RageFileOsAbsolute file; if( !file.Open(m_sPackagePath) ) { Dialog::OK( ssprintf(COULD_NOT_OPEN_FILE.GetValue(),m_sPackagePath.c_str()) ); exit(1); // better way to abort? } RageFileDriverZip zip; if( !zip.Load(&file) ) { Dialog::OK( ssprintf(IS_NOT_A_VALID_ZIP.GetValue(),m_sPackagePath.c_str()) ); exit(1); // better way to abort? } // // Set the text of the first Edit box // RString sMessage1 = "\t" + m_sPackagePath; CEdit* pEdit1 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE1); pEdit1->SetWindowText( sMessage1 ); // // Set the text of the second Edit box // { vector<RString> vs; GetSmzipFilesToExtract( zip, vs ); CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE2); RString sText = "\t" + join( "\r\n\t", vs ); pEdit2->SetWindowText( sText ); } RefreshInstallationList(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void ScreenGameplaySyncMachine::RefreshText() { float fNew = PREFSMAN->m_fGlobalOffsetSeconds; float fOld = AdjustSync::s_fGlobalOffsetSecondsOriginal; float fStdDev = AdjustSync::s_fStandardDeviation; RString s; s += OLD_OFFSET.GetValue() + ssprintf( ": %0.3f\n", fOld ); s += NEW_OFFSET.GetValue() + ssprintf( ": %0.3f\n", fNew ); s += STANDARD_DEVIATION.GetValue() + ssprintf( ": %0.3f\n", fStdDev ); s += COLLECTING_SAMPLE.GetValue() + ssprintf( ": %d / %d", AdjustSync::s_iAutosyncOffsetSample+1, AdjustSync::OFFSET_SAMPLE_COUNT ); m_textSyncInfo.SetText( s ); }
void ScreenNetworkOptions::Init() { ScreenOptions::Init(); vector<OptionRowHandler*> vHands; { OptionRowHandler *pHand = OptionRowHandlerUtil::MakeNull(); vHands.push_back( pHand ); pHand->m_Def.m_sName = "Connection"; pHand->m_Def.m_bOneChoiceForAllPlayers = true; pHand->m_Def.m_bAllowThemeItems = false; if ( NSMAN->useSMserver ) pHand->m_Def.m_vsChoices.push_back(CLIENT_DISCONNECT.GetValue()); else pHand->m_Def.m_vsChoices.push_back(CLIENT_CONNECT.GetValue()); } { OptionRowHandler *pHand = OptionRowHandlerUtil::MakeNull(); vHands.push_back( pHand ); pHand->m_Def.m_sName = "Scoreboard"; pHand->m_Def.m_vsChoices.clear(); pHand->m_Def.m_bOneChoiceForAllPlayers = true; pHand->m_Def.m_bAllowThemeItems = false; pHand->m_Def.m_vsChoices.push_back(SCORE_OFF.GetValue()); pHand->m_Def.m_vsChoices.push_back(SCORE_ON.GetValue()); } /* { // Get info on all received servers from NSMAN. AllServers.clear(); NSMAN->GetListOfLANServers( AllServers ); if( !AllServers.empty() ) { OptionRowHandler *pHand = OptionRowHandlerUtil::MakeNull(); pHand->m_Def.m_sName = "Servers"; pHand->m_Def.m_bAllowThemeItems = false; for (auto &server: AllServers) { pHand->m_Def.m_vsChoices.push_back( server.Name ); } vHands.push_back( pHand ); } } */ InitMenu( vHands ); m_pRows[PO_SCOREBOARD]->SetOneSharedSelection(PREFSMAN->m_bEnableScoreboard); }
void ScreenTitleMenu::Input( const InputEventPlus &input ) { #if defined(DEBUG) LOG->Trace( "ScreenTitleMenu::Input( %d-%d )", input.DeviceI.device, input.DeviceI.button ); // debugging gameport joystick problem #endif if( m_In.IsTransitioning() || m_Cancel.IsTransitioning() ) /* not m_Out */ return; if( input.type == IET_FIRST_PRESS ) { // detect codes if( CodeDetector::EnteredCode(input.GameI.controller,CODE_NEXT_THEME) || CodeDetector::EnteredCode(input.GameI.controller,CODE_NEXT_THEME2) ) { GameLoop::ChangeTheme( THEME->GetNextSelectableTheme(), m_sName ); } if( CodeDetector::EnteredCode(input.GameI.controller,CODE_NEXT_ANNOUNCER) || CodeDetector::EnteredCode(input.GameI.controller,CODE_NEXT_ANNOUNCER2) ) { ANNOUNCER->NextAnnouncer(); RString sName = ANNOUNCER->GetCurAnnouncerName(); if( sName=="" ) sName = "(none)"; SCREENMAN->SystemMessage( ANNOUNCER_.GetValue()+": "+sName ); SCREENMAN->SetNewScreen( m_sName ); } } ScreenSelectMaster::Input( input ); }
RString ClearMachineStats() { Profile* pProfile = PROFILEMAN->GetMachineProfile(); pProfile->ClearStats(); PROFILEMAN->SaveMachineProfile(); return MACHINE_STATS_CLEARED.GetValue(); }
LowLevelWindow_X11::LowLevelWindow_X11() { if( !OpenXConnection() ) RageException::Throw( "%s", FAILED_CONNECTION_XSERVER.GetValue().c_str() ); if( XRRQueryVersion( Dpy, &g_iRandRVerMajor, &g_iRandRVerMinor ) && g_iRandRVerMajor >= 1 && g_iRandRVerMinor >= 2) g_bUseXRandR12 = true; #ifdef HAVE_XINERAMA int xinerama_event_base = 0; int xinerama_error_base = 0; Atom fullscreen_monitors = XInternAtom( Dpy, "_NET_WM_FULLSCREEN_MONITORS", False ); if (XineramaQueryExtension( Dpy, &xinerama_event_base, &xinerama_error_base ) && NetWMSupported( Dpy, fullscreen_monitors )) { g_bUseXinerama = true; } #endif const int iScreen = DefaultScreen( Dpy ); int iXServerVersion = XVendorRelease( Dpy ); /* eg. 40201001 */ int iMajor = iXServerVersion / 10000000; iXServerVersion %= 10000000; int iMinor = iXServerVersion / 100000; iXServerVersion %= 100000; int iRevision = iXServerVersion / 1000; iXServerVersion %= 1000; int iPatch = iXServerVersion; LOG->Info( "Display: %s (screen %i)", DisplayString(Dpy), iScreen ); LOG->Info( "X server vendor: %s [%i.%i.%i.%i]", XServerVendor( Dpy ), iMajor, iMinor, iRevision, iPatch ); LOG->Info( "Server GLX vendor: %s [%s]", glXQueryServerString( Dpy, iScreen, GLX_VENDOR ), glXQueryServerString( Dpy, iScreen, GLX_VERSION ) ); LOG->Info( "Client GLX vendor: %s [%s]", glXGetClientString( Dpy, GLX_VENDOR ), glXGetClientString( Dpy, GLX_VERSION ) ); m_bWasWindowed = true; g_pScreenConfig = XRRGetScreenInfo( Dpy, RootWindow(Dpy, DefaultScreen(Dpy)) ); }
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable ) { #if defined(UNIX) /* Mount the root filesystem, so we can read files in /proc, /etc, and so on. * This is /rootfs, not /root, to avoid confusion with root's home directory. */ FILEMAN->Mount( "dir", "/", "/rootfs" ); /* Mount /proc, so Alsa9Buf::GetSoundCardDebugInfo() and others can access it. * (Deprecated; use rootfs.) */ FILEMAN->Mount( "dir", "/proc", "/proc" ); #endif RString Root; struct stat st; if( !stat(sDirOfExecutable + "/Packages", &st) && st.st_mode&S_IFDIR ) Root = sDirOfExecutable; else if( !stat(sDirOfExecutable + "/Songs", &st) && st.st_mode&S_IFDIR ) Root = sDirOfExecutable; else if( !stat(RageFileManagerUtil::sInitialWorkingDirectory + "/Songs", &st) && st.st_mode&S_IFDIR ) Root = RageFileManagerUtil::sInitialWorkingDirectory; else RageException::Throw( "%s", COULDNT_FIND_SONGS.GetValue().c_str() ); FILEMAN->Mount( "dir", Root, "/" ); }
bool ScreenTitleMenu::Input( const InputEventPlus &input ) { #if defined(DEBUG) LOG->Trace( "ScreenTitleMenu::Input( %d-%d )", input.DeviceI.device, input.DeviceI.button ); // debugging gameport joystick problem #endif if( m_In.IsTransitioning() || m_Cancel.IsTransitioning() ) /* not m_Out */ return false; bool bHandled = false; if( input.type == IET_FIRST_PRESS ) { // detect codes // Theme changing pad codes are marked as deprecated in _fallback's // metrics.ini, remove them after SM5? -Kyz if( CodeDetector::EnteredCode(input.GameI.controller,CODE_NEXT_THEME) || CodeDetector::EnteredCode(input.GameI.controller,CODE_NEXT_THEME2) ) { GameLoop::ChangeTheme(THEME->GetNextSelectableTheme()); bHandled = true; } if( CodeDetector::EnteredCode(input.GameI.controller,CODE_NEXT_ANNOUNCER) || CodeDetector::EnteredCode(input.GameI.controller,CODE_NEXT_ANNOUNCER2) ) { ANNOUNCER->NextAnnouncer(); RString sName = ANNOUNCER->GetCurAnnouncerName(); if( sName=="" ) sName = "(none)"; SCREENMAN->SystemMessage( ANNOUNCER_.GetValue()+": "+sName ); SCREENMAN->SetNewScreen( m_sName ); bHandled = true; } } return ScreenSelectMaster::Input( input ) || bHandled; }
void AdjustSync::AutosyncTempo() { float fSlope = 0.0f; float fIntercept = 0.0f; if( !CalcLeastSquares( s_vAutosyncTempoData, fSlope, fIntercept, s_fAverageError ) ) { s_vAutosyncTempoData.clear(); return; } if( s_fAverageError < ERROR_TOO_HIGH ) { // Here we filter out any steps that are too far off. // // If it turns out that we want to be even more selective, we can // keep only a fraction of the data, such as the 80% with the lowest // error. However, throwing away the ones with high error should // be enough in most cases. float fFilteredError = 0.0; s_iStepsFiltered = s_vAutosyncTempoData.size(); FilterHighErrorPoints( s_vAutosyncTempoData, fSlope, fIntercept, ERROR_TOO_HIGH ); s_iStepsFiltered -= s_vAutosyncTempoData.size(); if( !CalcLeastSquares( s_vAutosyncTempoData, fSlope, fIntercept, fFilteredError ) ) return; GAMESTATE->m_pCurSong->m_Timing.m_fBeat0OffsetInSeconds += fIntercept; const float fScaleBPM = 1.0f/(1.0f - fSlope); FOREACH( BPMSegment, GAMESTATE->m_pCurSong->m_Timing.m_BPMSegments, i ) i->SetBPM( i->GetBPM() * fScaleBPM ); // We assume that the stops were measured as a number of beats. // Therefore, if we change the bpms, we need to make a similar // change to the stops. FOREACH( StopSegment, GAMESTATE->m_pCurSong->m_Timing.m_StopSegments, i ) i->m_fStopSeconds *= 1.0f - fSlope; SCREENMAN->SystemMessage( AUTOSYNC_CORRECTION_APPLIED.GetValue() ); } else { // deviation... error... close enough for an error message SCREENMAN->SystemMessage( AUTOSYNC_CORRECTION_NOT_APPLIED.GetValue() ); } s_vAutosyncTempoData.clear(); }
bool ScreenTextEntry::FloatValidate( const RString &sAnswer, RString &sErrorOut ) { float f; if( StringToFloat(sAnswer, f) ) return true; sErrorOut = ssprintf( INVALID_FLOAT.GetValue(), sAnswer.c_str() ); return false; }
bool ScreenTextEntry::IntValidate( const RString &sAnswer, RString &sErrorOut ) { int f; if(sAnswer >> f) return true; sErrorOut = ssprintf( INVALID_INT.GetValue(), sAnswer.c_str() ); return false; }
bool ScreenNetworkOptions::MenuStart( const InputEventPlus &input ) { switch( GetCurrentRow() ) { case PO_CONNECTION: if ( !NSMAN->useSMserver ) { ScreenTextEntry::TextEntry( SM_DoneConnecting, ENTER_NETWORK_ADDRESS.GetValue()+"\n\n"+CONNECT_TO_YOURSELF.GetValue(), g_sLastServer.Get(), 128 ); } else { NSMAN->CloseConnection(); SCREENMAN->SystemMessage( DISCONNECTED.GetValue() ); UpdateConnectStatus( ); } return true; case PO_SCOREBOARD: if (m_pRows[PO_SCOREBOARD]->GetOneSharedSelection() == NO_SCOREBOARD_ON) PREFSMAN->m_bEnableScoreboard.Set(true); else PREFSMAN->m_bEnableScoreboard.Set(false); return true; /* case NetworkOptionRow::PO_SERVERS: if ( !AllServers.empty() ) { string sNewName = AllServers[m_pRows[GetCurrentRow()]->GetOneSharedSelection()].Address; NSMAN->PostStartUp(sNewName); NSMAN->DisplayStartupStatus(); UpdateConnectStatus( ); } else { //If the server list is empty, keep passing the message on so exit works ScreenOptions::MenuStart( input ); } return true; */ default: return ScreenOptions::MenuStart( input ); } }
void AdjustSync::AutosyncOffset() { const float mean = calc_mean( s_fAutosyncOffset, s_fAutosyncOffset+OFFSET_SAMPLE_COUNT ); const float stddev = calc_stddev( s_fAutosyncOffset, s_fAutosyncOffset+OFFSET_SAMPLE_COUNT ); RString sAutosyncType; switch( GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType ) { case SongOptions::AUTOSYNC_SONG: sAutosyncType = AUTOSYNC_SONG; break; case SongOptions::AUTOSYNC_MACHINE: sAutosyncType = AUTOSYNC_MACHINE; break; default: ASSERT(0); } if( stddev < .03f ) // If they stepped with less than .03 error { switch( GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType ) { case SongOptions::AUTOSYNC_SONG: GAMESTATE->m_pCurSong->m_Timing.m_fBeat0OffsetInSeconds += mean; break; case SongOptions::AUTOSYNC_MACHINE: PREFSMAN->m_fGlobalOffsetSeconds.Set( PREFSMAN->m_fGlobalOffsetSeconds + mean ); break; default: ASSERT(0); } SCREENMAN->SystemMessage( AUTOSYNC_CORRECTION_APPLIED.GetValue() ); } else { SCREENMAN->SystemMessage( AUTOSYNC_CORRECTION_NOT_APPLIED.GetValue() ); } s_iAutosyncOffsetSample = 0; s_fStandardDeviation = stddev; }
RString RageDisplay::SetVideoMode( VideoModeParams p, bool &bNeedReloadTextures ) { RString err; vector<RString> vs; if( (err = this->TryVideoMode(p,bNeedReloadTextures)) == "" ) return RString(); LOG->Trace( "TryVideoMode failed: %s", err.c_str() ); vs.push_back( err ); // fall back to settings that will most likely work p.bpp = 16; if( (err = this->TryVideoMode(p,bNeedReloadTextures)) == "" ) return RString(); vs.push_back( err ); // "Intel(R) 82810E Graphics Controller" won't accept a 16 bpp surface if // the desktop is 32 bpp, so try 32 bpp as well. p.bpp = 32; if( (err = this->TryVideoMode(p,bNeedReloadTextures)) == "" ) return RString(); vs.push_back( err ); // Fall back on a known resolution good rather than 640 x 480. DisplayResolutions dr; this->GetDisplayResolutions( dr ); if( dr.empty() ) { vs.push_back( "No display resolutions" ); return SETVIDEOMODE_FAILED.GetValue() + " " + join(";",vs); } const DisplayResolution &d = *dr.begin(); p.width = d.iWidth; p.height = d.iHeight; if( (err = this->TryVideoMode(p,bNeedReloadTextures)) == "" ) return RString(); vs.push_back( err ); return SETVIDEOMODE_FAILED.GetValue() + " " + join(";",vs); }
bool LocalizedString::operator==(const LocalizedString& other) const { if (m_Type!=other.getType()) return false; switch(m_Type) { case lsIndex: return (m_Index==other.m_Index); case lsString: return (m_String==other.m_String); default: //lsNone return true; }//swi }
static RString GetDebugButtonName( const IDebugLine *pLine ) { RString s = INPUTMAN->GetDeviceSpecificInputString(pLine->m_Button); IDebugLine::Type type = pLine->GetType(); switch( type ) { case IDebugLine::all_screens: return s; case IDebugLine::gameplay_only: return ssprintf( IN_GAMEPLAY.GetValue(), s.c_str() ); default: FAIL_M(ssprintf("Invalid debug line type: %i", type)); } }
void MakeInputHandlers( const RString &drivers, vector<InputHandler *> &Add ) { vector<RString> DriversToTry; split( drivers, ",", DriversToTry, true ); if( DriversToTry.empty() ) RageException::Throw( INPUT_HANDLERS_EMPTY.GetValue() ); RString Driver; FOREACH_CONST( RString, DriversToTry, s ) { InputHandler *ret = NULL; #ifdef USE_INPUT_HANDLER_DIRECTINPUT if( !s->CompareNoCase("DirectInput") ) ret = new InputHandler_DInput; #endif #ifdef USE_INPUT_HANDLER_PIUIO if( !s->CompareNoCase("PIUIO") ) ret = new InputHandler_Linux_PIUIO; #endif #ifdef USE_INPUT_HANDLER_LINUX_JOYSTICK if( !s->CompareNoCase("Joystick") ) ret = new InputHandler_Linux_Joystick; #endif #ifdef USE_INPUT_HANDLER_LINUX_TTY if( !s->CompareNoCase("tty") ) ret = new InputHandler_Linux_tty; #endif #ifdef USE_INPUT_HANDLER_SDL if( !s->CompareNoCase("SDL") ) ret = new InputHandler_SDL; #endif #ifdef USE_INPUT_HANDLER_WIN32_PARA if( !s->CompareNoCase("Para") ) ret = new InputHandler_Win32_Para; #endif #ifdef USE_INPUT_HANDLER_WIN32_PUMP if( !s->CompareNoCase("Pump") ) ret = new InputHandler_Win32_Pump; #endif #ifdef USE_INPUT_HANDLER_WIN32_MIDI if( !s->CompareNoCase("MIDI") ) ret = new InputHandler_Win32_MIDI; #endif #ifdef USE_INPUT_HANDLER_X11 if( !s->CompareNoCase("X11") ) ret = new InputHandler_X11; #endif #ifdef USE_INPUT_HANDLER_MACOSX_HID if( !s->CompareNoCase("MacOSX") ) ret = new InputHandler_MacOSX_HID; #endif if( ret == NULL ) LOG->Trace( "Unknown Input Handler name: %s", s->c_str() ); else Add.push_back( ret ); }
void ChangeGameSettings::OnOK() { // TODO: Add extra validation here IniFile ini; ini.ReadFile( SpecialFiles::PREFERENCES_INI_PATH ); if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_OPENGL) ) ini.SetValue( "Options", "VideoRenderers", (RString)"opengl" ); else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_DIRECT3D) ) ini.SetValue( "Options", "VideoRenderers", (RString)"d3d" ); else ini.SetValue( "Options", "VideoRenderers", RString() ); if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_DIRECTSOUND_HARDWARE) ) ini.SetValue( "Options", "SoundDrivers", (RString)"DirectSound" ); else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_DIRECTSOUND_SOFTWARE) ) ini.SetValue( "Options", "SoundDrivers", (RString)"DirectSound-sw" ); else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_WAVEOUT) ) ini.SetValue( "Options", "SoundDrivers", (RString)"WaveOut" ); else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_NULL) ) ini.SetValue( "Options", "SoundDrivers", (RString)"null" ); else ini.SetValue( "Options", "SoundDrivers", RString() ); if( BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_FORCE_60HZ) ) { ini.SetValue( "Options", "RefreshRate", 60 ); } else { int iRefresh = 0; ini.GetValue( "Options", "RefreshRate", iRefresh ); if( iRefresh == 60 ) ini.SetValue( "Options", "RefreshRate", 0 ); } ini.SetValue( "Options", "LogToDisk", BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_LOG_TO_DISK) ); ini.SetValue( "Options", "ShowLogOutput", BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_SHOW_LOG_WINDOW) ); if( !ini.WriteFile(SpecialFiles::PREFERENCES_INI_PATH) ) { RString sError = ssprintf( ERROR_WRITING_FILE.GetValue(), SpecialFiles::PREFERENCES_INI_PATH.c_str(), ini.GetError().c_str() ); Dialog::OK( sError ); } CDialog::OnOK(); }
void ToolTipEvent::addField(const LocalizedString &title, const LocalizedString &description, const QString &icon, IconPosition iconPosition, quint8 priority) { QString text; bool descriptionEmpty = description.toString().isEmpty(); if (iconPosition == IconBeforeTitle) d->addIcon(text, icon); if (!title.toString().isEmpty()) { text += QLatin1Literal("<b>") % title.toString(); if (!descriptionEmpty) text += ":"; text += "</b>"; } if (iconPosition == IconBeforeDescription) d->addIcon(text, icon); if (!descriptionEmpty) { if (!text.isEmpty()) text += " "; text += description.toString(); } if (!text.isEmpty()) text.prepend("<br/>"); d->fields.insert(priority, text); }
void AdjustSync::GetSyncChangeTextGlobal( vector<RString> &vsAddTo ) { { float fOld = Quantize( AdjustSync::s_fGlobalOffsetSecondsOriginal, 0.001f ); float fNew = Quantize( PREFSMAN->m_fGlobalOffsetSeconds, 0.001f ) ; float fDelta = fNew - fOld; if( fabsf(fDelta) > 0.0001f ) { vsAddTo.push_back( ssprintf( GLOBAL_OFFSET_FROM.GetValue(), fOld, fNew, (fDelta > 0 ? EARLIER:LATER).GetValue().c_str() ) ); } } }
RageMovieTexture *RageMovieTexture::Create( RageTextureID ID ) { DumpAVIDebugInfo( ID.filename ); RString sDrivers = g_sMovieDrivers; if( sDrivers.empty() ) sDrivers = DEFAULT_MOVIE_DRIVER_LIST; vector<RString> DriversToTry; split( sDrivers, ",", DriversToTry, true ); if( DriversToTry.empty() ) RageException::Throw( "%s", MOVIE_DRIVERS_EMPTY.GetValue().c_str() ); RageMovieTexture *ret = NULL; FOREACH_CONST( RString, DriversToTry, Driver ) { LOG->Trace( "Initializing driver: %s", Driver->c_str() ); RageDriver *pDriverBase = RageMovieTextureDriver::m_pDriverList.Create( *Driver ); if( pDriverBase == NULL ) { LOG->Trace( "Unknown movie driver name: %s", Driver->c_str() ); continue; } RageMovieTextureDriver *pDriver = dynamic_cast<RageMovieTextureDriver *>( pDriverBase ); ASSERT( pDriver != NULL ); RString sError; ret = pDriver->Create( ID, sError ); delete pDriver; if( ret == NULL ) { LOG->Trace( "Couldn't load driver %s: %s", Driver->c_str(), sError.c_str() ); SAFE_DELETE( ret ); continue; } LOG->Trace( "Created movie texture \"%s\" with driver \"%s\"", ID.filename.c_str(), Driver->c_str() ); break; }
void ScreenTestLights::Update( float fDeltaTime ) { Screen::Update( fDeltaTime ); if( m_timerBackToAutoCycle.Ago() > 20 ) { m_timerBackToAutoCycle.Touch(); LIGHTSMAN->SetLightsMode( LIGHTSMODE_TEST_AUTO_CYCLE ); } CabinetLight cl = LIGHTSMAN->GetFirstLitCabinetLight(); GameInput gi = LIGHTSMAN->GetFirstLitGameButtonLight(); RString s; switch( LIGHTSMAN->GetLightsMode() ) { case LIGHTSMODE_TEST_AUTO_CYCLE: s += AUTO_CYCLE.GetValue()+"\n"; break; case LIGHTSMODE_TEST_MANUAL_CYCLE: s += MANUAL_CYCLE.GetValue()+"\n"; break; default: break; } if( cl == CabinetLight_Invalid ) s += CABINET_LIGHT.GetValue()+": -----\n"; else s += ssprintf( "%s: %d %s\n", CABINET_LIGHT.GetValue().c_str(), cl, CabinetLightToString(cl).c_str() ); if( !gi.IsValid() ) { s += CONTROLLER_LIGHT.GetValue()+": -----\n"; } else { RString sGameButton = GameButtonToLocalizedString( INPUTMAPPER->GetInputScheme(), gi.button ); PlayerNumber pn = (PlayerNumber)(gi.controller); s += ssprintf( "%s: %s %d %s\n", CONTROLLER_LIGHT.GetValue().c_str(), PlayerNumberToString(pn).c_str(), gi.button, sGameButton.c_str() ); } m_textInputs.SetText( s ); }
void InputHandler::Create( const RString &drivers_, vector<InputHandler *> &Add ) { const RString drivers = drivers_.empty()? RString(DEFAULT_INPUT_DRIVER_LIST):drivers_; vector<RString> DriversToTry; split( drivers, ",", DriversToTry, true ); if( DriversToTry.empty() ) RageException::Throw( "%s", INPUT_HANDLERS_EMPTY.GetValue().c_str() ); FOREACH_CONST( RString, DriversToTry, s ) { RageDriver *pDriver = InputHandler::m_pDriverList.Create( *s ); if( pDriver == NULL ) { LOG->Trace( "Unknown Input Handler name: %s", s->c_str() ); continue; } InputHandler *ret = dynamic_cast<InputHandler *>( pDriver ); DEBUG_ASSERT( ret ); Add.push_back( ret ); }
void ScreenOptionsCourseOverview::ProcessMenuStart( const InputEventPlus &input ) { if( IsTransitioning() ) return; int iRow = m_iCurrentRow[GAMESTATE->GetMasterPlayerNumber()]; switch( iRow ) { case CourseOverviewRow_Play: case CourseOverviewRow_Edit: SCREENMAN->PlayStartSound(); this->BeginFadingOut(); return; // handled case CourseOverviewRow_Shuffle: { Course *pCourse = GAMESTATE->m_pCurCourse; random_shuffle( pCourse->m_vEntries.begin(), pCourse->m_vEntries.end() ); Trail *pTrail = pCourse->GetTrailForceRegenCache( GAMESTATE->GetCurrentStyle(input.pn)->m_StepsType ); GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail ); SCREENMAN->PlayStartSound(); MESSAGEMAN->Broadcast("CurrentCourseChanged"); } return; // handled case CourseOverviewRow_Rename: ScreenTextEntry::TextEntry( SM_BackFromRename, ENTER_COURSE_NAME.GetValue(), GAMESTATE->m_pCurCourse->GetDisplayFullTitle(), EditCourseUtil::MAX_NAME_LENGTH, EditCourseUtil::ValidateEditCourseName ); break; case CourseOverviewRow_Delete: ScreenPrompt::Prompt( SM_BackFromDelete, COURSE_WILL_BE_LOST.GetValue()+"\n\n"+CONTINUE_WITH_DELETE.GetValue(), PROMPT_YES_NO, ANSWER_NO ); break; case CourseOverviewRow_Save: { bool bPromptForName = EditCourseUtil::s_bNewCourseNeedsName; if( bPromptForName ) { ScreenTextEntry::TextEntry( SM_BackFromEnterName, ENTER_COURSE_NAME.GetValue(), GAMESTATE->m_pCurCourse->GetDisplayFullTitle(), EditCourseUtil::MAX_NAME_LENGTH, EditCourseUtil::ValidateEditCourseName ); } else { if( EditCourseUtil::Save( GAMESTATE->m_pCurCourse ) ) { m_soundSave.Play(true); SCREENMAN->SystemMessage( COURSE_SAVED.GetValue() ); } else { SCREENMAN->PlayInvalidSound(); SCREENMAN->SystemMessage( ERROR_SAVING_COURSE.GetValue() ); } } } return; // handled } ScreenOptions::ProcessMenuStart( input ); }
void ScreenOptionsCourseOverview::HandleScreenMessage( const ScreenMessage SM ) { if( SM == SM_GoToPrevScreen ) { // If we're pointing to an unsaved course, it will be inaccessible once we're back on ScreenOptionsManageCourses. GAMESTATE->m_pCurCourse.Set( nullptr ); } else if( SM == SM_GoToNextScreen ) { int iRow = m_iCurrentRow[GAMESTATE->GetMasterPlayerNumber()]; switch( iRow ) { case CourseOverviewRow_Play: EditCourseUtil::PrepareForPlay(); SCREENMAN->SetNewScreen( PLAY_SCREEN.GetValue() ); return; // handled case CourseOverviewRow_Edit: SCREENMAN->SetNewScreen( EDIT_SCREEN.GetValue() ); return; // handled } } else if( SM == SM_BackFromEnterName ) { if( !ScreenTextEntry::s_bCancelledLast ) { ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this if( EditCourseUtil::RenameAndSave( GAMESTATE->m_pCurCourse, ScreenTextEntry::s_sLastAnswer ) ) { m_soundSave.Play(true); SCREENMAN->SystemMessage( COURSE_SAVED.GetValue() ); } } } else if( SM == SM_BackFromRename ) { if( !ScreenTextEntry::s_bCancelledLast ) { ASSERT( ScreenTextEntry::s_sLastAnswer != "" ); // validate should have assured this if( !EditCourseUtil::RenameAndSave(GAMESTATE->m_pCurCourse, ScreenTextEntry::s_sLastAnswer) ) { ScreenPrompt::Prompt( SM_None, ERROR_RENAMING.GetValue() ); return; } SCREENMAN->SetNewScreen( this->m_sName ); // reload } } else if( SM == SM_BackFromDelete ) { if( ScreenPrompt::s_LastAnswer == ANSWER_YES ) { if( !EditCourseUtil::RemoveAndDeleteFile(GAMESTATE->m_pCurCourse) ) { ScreenPrompt::Prompt( SM_None, rage_fmt_wrapper(ERROR_DELETING_FILE, GAMESTATE->m_pCurCourse->m_sPath.c_str()) ); return; } GAMESTATE->m_pCurCourse.Set( nullptr ); GAMESTATE->m_pCurTrail[PLAYER_1].Set( nullptr ); /* Our course is gone, so back out. */ StartTransitioningScreen( SM_GoToPrevScreen ); } } ScreenOptions::HandleScreenMessage( SM ); }
virtual std::string GetDisplayValue() { return IsEnabled() ? ON.GetValue():OFF.GetValue(); }
bool ScreenDebugOverlay::Input( const InputEventPlus &input ) { if( input.DeviceI == g_Mappings.holdForDebug1 || input.DeviceI == g_Mappings.holdForDebug2 ) { bool bHoldingNeither = (!g_Mappings.holdForDebug1.IsValid() || !INPUTFILTER->IsBeingPressed(g_Mappings.holdForDebug1)) && (!g_Mappings.holdForDebug2.IsValid() || !INPUTFILTER->IsBeingPressed(g_Mappings.holdForDebug2)); bool bHoldingBoth = (!g_Mappings.holdForDebug1.IsValid() || INPUTFILTER->IsBeingPressed(g_Mappings.holdForDebug1)) && (!g_Mappings.holdForDebug2.IsValid() || INPUTFILTER->IsBeingPressed(g_Mappings.holdForDebug2)); if( bHoldingNeither ) m_bForcedHidden = false; if( bHoldingBoth ) g_bIsDisplayed = true; else g_bIsDisplayed = false; } if(input.DeviceI == g_Mappings.toggleMute) { PREFSMAN->m_MuteActions.Set(!PREFSMAN->m_MuteActions); SCREENMAN->SystemMessage(PREFSMAN->m_MuteActions ? MUTE_ACTIONS_ON.GetValue() : MUTE_ACTIONS_OFF.GetValue()); } int iPage = 0; if( g_bIsDisplayed && GetValueFromMap(g_Mappings.pageButton, input.DeviceI, iPage) ) { if( input.type != IET_FIRST_PRESS ) return true; // eat the input but do nothing m_iCurrentPage = iPage; m_iCurrentPage = Rage::clamp( m_iCurrentPage, 0, (int) m_asPages.size()-1 ); return true; } for (auto p = g_pvpSubscribers->begin(); p != g_pvpSubscribers->end(); ++p) { std::string sPageName = (*p)->GetPageName(); int i = p-g_pvpSubscribers->begin(); // Gameplay buttons are available only in gameplay. Non-gameplay buttons // are only available when the screen is displayed. IDebugLine::Type type = (*p)->GetType(); switch( type ) { case IDebugLine::all_screens: if( !g_bIsDisplayed ) continue; if( sPageName != GetCurrentPageName() ) continue; break; case IDebugLine::gameplay_only: if( !IsGameplay() ) continue; break; default: FAIL_M(fmt::sprintf("Invalid debug line type: %i", type)); } if( input.DeviceI == (*p)->m_Button ) { if( input.type != IET_FIRST_PRESS ) return true; // eat the input but do nothing // do the action std::string sMessage; (*p)->DoAndLog( sMessage ); if( !sMessage.empty() ) LOG->Trace("DEBUG: %s", sMessage.c_str() ); if( (*p)->ForceOffAfterUse() ) m_bForcedHidden = true; // update text to show the effect of what changed above UpdateText(); // show what changed BitmapText &bt = *m_vptextButton[i]; bt.FinishTweening(); bt.PlayCommand("Toggled"); return true; } } return Screen::Input(input); }
void ScreenDebugOverlay::Init() { Screen::Init(); // Init debug mappings // TODO: Arch-specific? { g_Mappings.Clear(); g_Mappings.holdForDebug1 = DeviceInput(DEVICE_KEYBOARD, KEY_F3); g_Mappings.holdForDebug2.MakeInvalid(); g_Mappings.holdForSlow = DeviceInput(DEVICE_KEYBOARD, KEY_ACCENT); g_Mappings.holdForFast = DeviceInput(DEVICE_KEYBOARD, KEY_TAB); g_Mappings.toggleMute = DeviceInput(DEVICE_KEYBOARD, KEY_PAUSE); /* TODO: Find a better way of indicating which option is which here. * Maybe we should take a page from ScreenEdit's menus and make * RowDefs()? */ int i=0; g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F8); g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F7); g_Mappings.gameplayButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_F6); i=0; g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C1); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C2); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C3); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C4); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C5); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C6); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C7); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C8); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C9); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_C0); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cq); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cw); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ce); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cr); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ct); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cy); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cu); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ci); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Co); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cp); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Ca); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cs); g_Mappings.debugButton[i++] = DeviceInput(DEVICE_KEYBOARD, KEY_Cd); g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F5)] = 0; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F6)] = 1; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F7)] = 2; g_Mappings.pageButton[DeviceInput(DEVICE_KEYBOARD, KEY_F8)] = 3; } std::map<std::string,int> iNextDebugButton; int iNextGameplayButton = 0; for (auto *p: *g_pvpSubscribers) { std::string sPageName = p->GetPageName(); DeviceInput di; switch( p->GetType() ) { case IDebugLine::all_screens: di = g_Mappings.debugButton[iNextDebugButton[sPageName]++]; break; case IDebugLine::gameplay_only: di = g_Mappings.gameplayButton[iNextGameplayButton++]; break; } p->m_Button = di; if( find(m_asPages.begin(), m_asPages.end(), sPageName) == m_asPages.end() ) m_asPages.push_back( sPageName ); } m_iCurrentPage = 0; m_bForcedHidden = false; m_Quad.StretchTo( Rage::RectF( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ) ); m_Quad.SetDiffuse( BACKGROUND_COLOR ); this->AddChild( &m_Quad ); // if you're going to add user commands, make sure to have the overrides // set after parsing the metrics. -aj m_textHeader.SetName( "HeaderText" ); m_textHeader.LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "header") ); LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_textHeader ); m_textHeader.SetText( DEBUG_MENU.GetValue() ); this->AddChild( &m_textHeader ); for (auto s = m_asPages.begin(); s != m_asPages.end(); ++s) { int iPage = s - m_asPages.begin(); DeviceInput di; bool b = GetKeyFromMap( g_Mappings.pageButton, iPage, di ); ASSERT( b ); std::string sButton = INPUTMAN->GetDeviceSpecificInputString( di ); BitmapText *p = new BitmapText; p->SetName( "PageText" ); p->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "page") ); LOAD_ALL_COMMANDS_AND_ON_COMMAND( p ); // todo: Y value is still hardcoded. -aj p->SetXY( PAGE_START_X+iPage*PAGE_SPACING_X, SCREEN_TOP+20 ); p->SetText( *s + " (" + sButton + ")" ); m_vptextPages.push_back( p ); this->AddChild( p ); } auto onEachLine = [this](IDebugLine *) { { BitmapText *bt = new BitmapText; bt->SetName( "ButtonText" ); bt->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "line") ); bt->SetHorizAlign( align_right ); bt->SetText( "blah" ); LOAD_ALL_COMMANDS_AND_ON_COMMAND( *bt ); m_vptextButton.push_back( bt ); this->AddChild( bt ); } { BitmapText *bt = new BitmapText; bt->SetName( "FunctionText" ); bt->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "line") ); bt->SetHorizAlign( align_left ); bt->SetText( "blah" ); LOAD_ALL_COMMANDS_AND_ON_COMMAND( *bt ); m_vptextFunction.push_back( bt ); this->AddChild( bt ); } }; std::for_each(g_pvpSubscribers->begin(), g_pvpSubscribers->end(), onEachLine); this->SetVisible( false ); }