diff --git a/stepmania/src/CodeDetector.cpp b/stepmania/src/CodeDetector.cpp new file mode 100644 index 0000000000..6b80c191ec --- /dev/null +++ b/stepmania/src/CodeDetector.cpp @@ -0,0 +1,192 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + Class: Course + + Desc: See header. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "CodeDetector.h" +#include "GameState.h" +#include "InputQueue.h" +#include "ThemeManager.h" +#include "RageLog.h" +#include "GameDef.h" +#include "StyleDef.h" + +enum Code { + CODE_EASIER1, + CODE_EASIER2, + CODE_HARDER1, + CODE_HARDER2, + CODE_NEXT_SORT1, + CODE_NEXT_SORT2, + CODE_MIRROR, + CODE_LEFT, + CODE_RIGHT, + CODE_SHUFFLE, + CODE_SUPER_SHUFFLE, + CODE_LITTLE, + CODE_NEXT_SCROLL_SPEED, + CODE_BOOST, + CODE_NEXT_EFFECT, + CODE_NEXT_APPEARANCE, + CODE_NEXT_TURN, + CODE_REVERSE, + CODE_NEXT_COLOR, + CODE_HOLDS, + CODE_DARK, + CODE_CANCEL_ALL, + NUM_CODES // leave this at the end +}; + +const CString g_sCodeNames[NUM_CODES] = { + "Easier1", + "Easier2", + "Harder1", + "Harder2", + "NextSort1", + "NextSort2", + "Mirror", + "Left", + "Right", + "Shuffle", + "SuperShuffle", + "Little", + "NextScrollSpeed", + "Boost", + "NextEffect", + "NextAppearance", + "NextTurn", + "Reverse", + "NextColor", + "HoldNotes", + "Dark", + "CancelAll" +}; + +struct CodeCacheItem { + int iNumButtons; + GameButton buttons[10]; +}; +CodeCacheItem g_CodeCacheItems[NUM_CODES]; + + +bool MatchesCacheItem( GameController controller, Code code ) +{ + if( g_CodeCacheItems[code].iNumButtons > 0 ) + if( INPUTQUEUE->MatchesPattern(controller, g_CodeCacheItems[code].buttons, g_CodeCacheItems[code].iNumButtons) ) + return true; + + return false; +} + +void RefreshCacheItem( int iIndex ) +{ + CodeCacheItem& item = g_CodeCacheItems[iIndex]; + const GameDef* pGameDef = GAMESTATE->GetCurrentGameDef(); + CString sCodeName = g_sCodeNames[iIndex]; + CString sButtonsNames = THEME->GetMetric("CodeDetector",sCodeName); + CStringArray asButtonNames; + split( sButtonsNames, ",", asButtonNames, false ); + + if( asButtonNames.GetSize() < 2 ) + { + LOG->Trace( "The code '%s' is less than 2 buttons, so it will be ignored.", sCodeName ); + item.iNumButtons = 0; + return; + } + + for( int i=0; im_iButtonsPerController; j++ ) + { + if( 0==stricmp(sButtonName,pGameDef->m_szButtonNames[j]) ) + { + gb = j; + item.iNumButtons = i+1; + break; // found it. Don't keep searching + } + } + if( gb == -1 ) // didn't find it + { + LOG->Trace( "The code '%s' contains an unrecognized button '%s'.", sCodeName, sButtonName ); + item.iNumButtons = 0; + return; + } + } + + // if we make it here, we found all the buttons in the code +} + +void CodeDetector::RefreshCacheItems() +{ + for( int i=0; iGetCurrentStyleDef(); + PlayerNumber pn = pStyleDef->ControllerToPlayerNumber( controller ); + + for( int c=CODE_MIRROR; cm_PlayerOptions[pn].m_TurnType, PlayerOptions::TURN_MIRROR, PlayerOptions::TURN_NONE ); break; + case CODE_LEFT: TOGGLE( GAMESTATE->m_PlayerOptions[pn].m_TurnType, PlayerOptions::TURN_LEFT, PlayerOptions::TURN_NONE ); break; + case CODE_RIGHT: TOGGLE( GAMESTATE->m_PlayerOptions[pn].m_TurnType, PlayerOptions::TURN_RIGHT, PlayerOptions::TURN_NONE ); break; + case CODE_SHUFFLE: TOGGLE( GAMESTATE->m_PlayerOptions[pn].m_TurnType, PlayerOptions::TURN_SHUFFLE, PlayerOptions::TURN_NONE ); break; + case CODE_SUPER_SHUFFLE: TOGGLE( GAMESTATE->m_PlayerOptions[pn].m_TurnType, PlayerOptions::TURN_SUPER_SHUFFLE, PlayerOptions::TURN_NONE ); break; + case CODE_LITTLE: TOGGLE( GAMESTATE->m_PlayerOptions[pn].m_bLittle, true, false ); break; + case CODE_NEXT_SCROLL_SPEED:INCREMENT_SCROLL_SPEED( GAMESTATE->m_PlayerOptions[pn].m_fArrowScrollSpeed ); break; + case CODE_BOOST: /* what goes here? */ break; + case CODE_NEXT_EFFECT: GAMESTATE->m_PlayerOptions[pn].m_EffectType = PlayerOptions::EffectType( (GAMESTATE->m_PlayerOptions[pn].m_EffectType+1) %NUM_EFFECT_TYPES ); break; + case CODE_NEXT_APPEARANCE: GAMESTATE->m_PlayerOptions[pn].m_AppearanceType = PlayerOptions::AppearanceType((GAMESTATE->m_PlayerOptions[pn].m_AppearanceType+1) %PlayerOptions::NUM_APPEARANCE_TYPES ); break; + case CODE_NEXT_TURN: GAMESTATE->m_PlayerOptions[pn].m_TurnType = PlayerOptions::TurnType( (GAMESTATE->m_PlayerOptions[pn].m_TurnType+1) %PlayerOptions::NUM_TURN_TYPES ); break; + case CODE_REVERSE: TOGGLE( GAMESTATE->m_PlayerOptions[pn].m_bReverseScroll, true, false ); break; + case CODE_NEXT_COLOR: GAMESTATE->m_PlayerOptions[pn].m_ColorType = PlayerOptions::ColorType( (GAMESTATE->m_PlayerOptions[pn].m_ColorType+1) %PlayerOptions::NUM_COLOR_TYPES ); break; + case CODE_HOLDS: TOGGLE( GAMESTATE->m_PlayerOptions[pn].m_bHoldNotes, true, false ); break; + case CODE_DARK: TOGGLE( GAMESTATE->m_PlayerOptions[pn].m_bDark, true, false ); break; + case CODE_CANCEL_ALL: GAMESTATE->m_PlayerOptions[pn] = PlayerOptions(); break; + default: + ASSERT(0); // unhandled code + } + return true; // don't check any more + } + } + + return false; +} diff --git a/stepmania/src/CodeDetector.h b/stepmania/src/CodeDetector.h new file mode 100644 index 0000000000..4f9289b707 --- /dev/null +++ b/stepmania/src/CodeDetector.h @@ -0,0 +1,26 @@ +#pragma once +/* +----------------------------------------------------------------------------- + Class: CodeDetector + + Desc: Uses InputQueue to detect input of codes that would affect player and song options. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "GameInput.h" + +class CodeDetector +{ +public: + static void RefreshCacheItems(); // call this before checking codes, but call infrequently + static bool EnteredEasierDifficulty( GameController controller ); + static bool EnteredHarderDifficulty( GameController controller ); + static bool EnteredNextSort( GameController controller ); + static bool DetectAndAdjustOptions( GameController controller ); +}; + + + diff --git a/stepmania/src/OptionIcon.cpp b/stepmania/src/OptionIcon.cpp new file mode 100644 index 0000000000..35fc3b410c --- /dev/null +++ b/stepmania/src/OptionIcon.cpp @@ -0,0 +1,43 @@ +#include "stdafx.h" +/* +----------------------------------------------------------------------------- + Class: OptionIcon + + Desc: A graphic displayed in the OptionIcon during Dancing. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "OptionIcon.h" +#include "ThemeManager.h" +#include "PlayerOptions.h" + +#define TEXT_X THEME->GetMetricF("OptionIcon","TextX") +#define TEXT_Y THEME->GetMetricF("OptionIcon","TextY") +#define TEXT_H_ALIGN THEME->GetMetricI("OptionIcon","TextHAlign") +#define TEXT_V_ALIGN THEME->GetMetricI("OptionIcon","TextVAlign") +#define TEXT_WIDTH THEME->GetMetricI("OptionIcon","TextWidth") + + +OptionIcon::OptionIcon() +{ + m_spr.Load( THEME->GetPathTo("Graphics","select music option icons 3x2") ); + this->AddChild( &m_spr ); + + m_text.LoadFromFont( THEME->GetPathTo("Fonts","option icons") ); + this->AddChild( &m_text ); +} + +void OptionIcon::Load( PlayerNumber pn, CString sText, bool bHeader ) +{ + bool bVacant = (sText==""); + m_spr.SetState( pn*3 + bVacant?1:2 ); + + m_text.SetText( sText ); + m_text.CropToWidth( TEXT_WIDTH ); + m_text.SetXY( TEXT_X, TEXT_Y ); + m_text.SetHorizAlign( (Actor::HorizAlign)TEXT_H_ALIGN ); + m_text.SetVertAlign( (Actor::VertAlign)TEXT_V_ALIGN ); +} diff --git a/stepmania/src/OptionIcon.h b/stepmania/src/OptionIcon.h new file mode 100644 index 0000000000..356a6b3d07 --- /dev/null +++ b/stepmania/src/OptionIcon.h @@ -0,0 +1,32 @@ +#ifndef OptionIcon_H +#define OptionIcon_H +/* +----------------------------------------------------------------------------- + Class: OptionIcon + + Desc: Shows PlayerOptions and SongOptions in icon form. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "ActorFrame.h" +#include "Sprite.h" +#include "BitmapText.h" +#include "GameConstantsAndTypes.h" + + +class OptionIcon : public ActorFrame +{ +public: + OptionIcon(); + + void Load( PlayerNumber pn, CString sText, bool bHeader = false ); + +protected: + BitmapText m_text; + Sprite m_spr; +}; + +#endif \ No newline at end of file