[Player] CheckpointsFlashOnHold metric added (bool). also cleanup/comment/etc.

This commit is contained in:
AJ Kelly
2010-02-24 02:40:36 -06:00
parent 01137a22f5
commit 60b86919ba
28 changed files with 413 additions and 397 deletions
+161
View File
@@ -0,0 +1,161 @@
-- sm-ssc fallback theme | script ring 03 | Gameplay.lua
-- [en] This file is used to store settings that should be different in each
-- game mode.
-- GameCompatibleModes:
-- [en] returns possible modes for ScreenSelectPlayMode
function GameCompatibleModes()
sGame = GAMESTATE:GetCurrentGame():GetName();
local Modes = {
dance = "Single,Double,Solo,Versus,Couple",
pump = "Single,Double,HalfDouble,Versus,Couple",
beat = "5Keys,7Keys,10Keys,14Keys",
kb7 = "KB7",
para = "Single",
lights = "Single", -- lights shouldn't be playable
};
return Modes[sGame];
end
-- ComboContinue:
-- [en]
function ComboContinue()
sGame = GAMESTATE:GetCurrentGame():GetName();
local Continue = {
dance = GAMESTATE:GetPlayMode() == "PlayMode_Oni" and "TapNoteScore_W2" or "TapNoteScore_W3",
pump = "TapNoteScore_W4",
beat = "TapNoteScore_W3",
kb7 = "TapNoteScore_W3",
para = "TapNoteScore_W4",
};
return Continue[sGame]
end;
function ComboMaintain()
sGame = GAMESTATE:GetCurrentGame():GetName();
local Maintain = {
dance = "TapNoteScore_W3",
pump = "TapNoteScore_W4",
beat = "TapNoteScore_W3",
kb7 = "TapNoteScore_W3",
para = "TapNoteScore_W4",
};
return Maintain[sGame]
end;
function ComboPerRow()
sGame = GAMESTATE:GetCurrentGame():GetName();
if sGame == "pump" then
return true;
elseif GAMESTATE:GetPlayMode() == "PlayMode_Oni" then
return true;
else return false;
end;
end;
function HitCombo()
sGame = GAMESTATE:GetCurrentGame():GetName();
local Combo = {
dance = 2,
pump = 4,
beat = 2,
kb7 = 2,
para = 2,
};
return Combo[sGame]
end;
function MissCombo()
sGame = GAMESTATE:GetCurrentGame():GetName();
local Combo = {
dance = 2,
pump = 4,
beat = 0,
kb7 = 0,
para = 0,
};
return Combo[sGame]
end;
function FailCombo() -- The combo that causes game failure.
sGame = GAMESTATE:GetCurrentGame():GetName();
local Combo = {
dance = 30, -- ITG/Pump Pro does it this way.
pump = 51,
beat = -1,
kb7 = -1,
para = -1,
};
return Combo[sGame]
end;
-- todo: use tables for some of these -aj
function HoldTiming()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return 0;
else return PREFSMAN:GetPreference("TimingWindowSecondsHold");
end;
end;
function HoldJudgmentFail()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return cmd();
else return cmd(finishtweening;shadowlength,0;diffusealpha,1;zoom,1;y,-10;linear,0.8;y,10;sleep,0.5;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0);
end;
end;
function HoldJudgmentPass()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return cmd();
else return cmd(finishtweening;shadowlength,0;diffusealpha,1;zoom,1.25;linear,0.3;zoomx,1;zoomy,1;sleep,0.5;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0);
end;
end;
function HoldHeadStep()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return false;
else return true;
end;
end;
function InitialHoldLife()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return 0.05;
else return 1;
end;
end;
function MaxHoldLife()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return 0.05;
else return 1;
end;
end;
function ImmediateHoldLetGo()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return false;
else return true;
end;
end;
function RollBodyIncrementsCombo()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return false;
else return true;
end;
end;
function CheckpointsTapsSeparateJudgment()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return false;
else return true;
end;
end;
function ScoreMissedHoldsAndRolls()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return false;
else return true;
end;
end;
@@ -127,159 +127,4 @@ function round(what, precision)
end
--[[ end helper functions ]]
-- this code is in the public domain.
--[[ these should probably be moved into another file: ]]
function GameCompatibleModes()
sGame = GAMESTATE:GetCurrentGame():GetName();
local Modes = {
dance = "Single,Double,Solo,Versus,Couple",
pump = "Single,Double,HalfDouble,Versus,Couple",
beat = "5Keys,7Keys,10Keys,14Keys",
kb7 = "KB7",
para = "Single",
lights = "Single", -- lights shouldn't be playable
};
return Modes[sGame];
end
function ComboContinue()
sGame = GAMESTATE:GetCurrentGame():GetName();
local Continue = {
dance = GAMESTATE:GetPlayMode() == "PlayMode_Oni" and "TapNoteScore_W2" or "TapNoteScore_W3",
pump = "TapNoteScore_W4",
beat = "TapNoteScore_W3",
kb7 = "TapNoteScore_W3",
para = "TapNoteScore_W4",
};
return Continue[sGame]
end;
function ComboMaintain()
sGame = GAMESTATE:GetCurrentGame():GetName();
local Maintain = {
dance = "TapNoteScore_W3",
pump = "TapNoteScore_W4",
beat = "TapNoteScore_W3",
kb7 = "TapNoteScore_W3",
para = "TapNoteScore_W4",
};
return Maintain[sGame]
end;
function ComboPerRow()
sGame = GAMESTATE:GetCurrentGame():GetName();
if sGame == "pump" then
return true;
elseif GAMESTATE:GetPlayMode() == "PlayMode_Oni" then
return true;
else return false;
end;
end;
function HitCombo()
sGame = GAMESTATE:GetCurrentGame():GetName();
local Combo = {
dance = 2,
pump = 4,
beat = 2,
kb7 = 2,
para = 2,
};
return Combo[sGame]
end;
function MissCombo()
sGame = GAMESTATE:GetCurrentGame():GetName();
local Combo = {
dance = 2,
pump = 4,
beat = 0,
kb7 = 0,
para = 0,
};
return Combo[sGame]
end;
function FailCombo() -- The combo that causes game failure.
sGame = GAMESTATE:GetCurrentGame():GetName();
local Combo = {
dance = 30, -- ITG/Pump Pro does it this way.
pump = 51,
beat = -1,
kb7 = -1,
para = -1,
};
return Combo[sGame]
end;
-- todo: use tables for some of these -aj
function HoldTiming()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return 0;
else return PREFSMAN:GetPreference("TimingWindowSecondsHold");
end;
end;
function HoldJudgmentFail()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return cmd();
else return cmd(finishtweening;shadowlength,0;diffusealpha,1;zoom,1;y,-10;linear,0.8;y,10;sleep,0.5;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0);
end;
end;
function HoldJudgmentPass()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return cmd();
else return cmd(finishtweening;shadowlength,0;diffusealpha,1;zoom,1.25;linear,0.3;zoomx,1;zoomy,1;sleep,0.5;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0);
end;
end;
function HoldHeadStep()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return false;
else return true;
end;
end;
function InitialHoldLife()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return 0.05;
else return 1;
end;
end;
function MaxHoldLife()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return 0.05;
else return 1;
end;
end;
function ImmediateHoldLetGo()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return false;
else return true;
end;
end;
function RollBodyIncrementsCombo()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return false;
else return true;
end;
end;
function CheckpointsTapsSeparateJudgment()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return false;
else return true;
end;
end;
function ScoreMissedHoldsAndRolls()
if GAMESTATE:GetCurrentGame():GetName() == "pump" then
return false;
else return true;
end;
end;
-- this code is in the public domain.
+24 -1
View File
@@ -1,5 +1,28 @@
todo: edit this document to reflect sm-ssc's structure
sm-ssc Scripts Directory: Introduction
--------------------------------------------------------------------------------
Hello, and welcome to the sm-ssc Scripts directory. You'll notice that our Lua
scripts have numbers at the beginning of them. This is to control the order of
execution.
In sm-ssc, scripts in subdirectories of Scripts/
(e.g. Scripts/01/somescript.lua) are loaded before scripts in the root of
Scripts/ (e.g. Scripts/01 base.lua). This is important to know when making a
theme for sm-ssc.
In sm-ssc, there are five rings of script execution:
00 - Initialization
01 - Base
02 - Defaults
03 - Extensions
04 - ?
================================================================================
previously:
SMOKE WEED '98 Scripts Directory Organization,
or "An applied case of application of prefixes to control order of execution".
+5 -4
View File
@@ -1,5 +1,5 @@
# This probably is hard to understand from the way it was made in the first
# place, so instead just pay attention to each group, which has tons of
# place, so instead just pay attention to each group, which has tons of
# notes
# 01 # Global
@@ -33,7 +33,7 @@ DefaultNoteSkinName="default"
DifficultiesToShow="beginner,easy,medium,hard,challenge"
# Same as above, but for courses.
CourseDifficultiesToShow="easy,medium,hard"
# Things to hide. You couldn't play cabinet nayways.
# Things to hide. You couldn't play cabinet anyways.
StepsTypesToHide="lights-cabinet"
#~ StepsTypesToHide="dance-couple,dance-solo,pump-halfdouble,lights-cabinet"
# Useless?
@@ -831,13 +831,14 @@ ComboUnderField=true
PenalizeTapScoreNone=false
JudgeHoldNotesOnSameRowTogether=(GAMESTATE:GetCurrentGame():GetName() == "pump")
HoldCheckpoints=(GAMESTATE:GetCurrentGame():GetName() == "pump")
CheckpointsUseTimeSignatures=(GAMESTATE:GetCurrentGame():GetName() == "pump")
CheckpointsTapsSeparateJudgment=CheckpointsTapsSeparateJudgment()
CheckpointsFlashOnHold=false
ImmediateHoldLetGo=ImmediateHoldLetGo()
RequireStepOnHoldHeads=HoldHeadStep()
CheckpointsUseTimeSignatures=(GAMESTATE:GetCurrentGame():GetName() == "pump")
InitialHoldLife=InitialHoldLife()
MaxHoldLife=MaxHoldLife()
RollBodyIncrementsCombo=RollBodyIncrementsCombo()
CheckpointsTapsSeparateJudgment=CheckpointsTapsSeparateJudgment()
ScoreMissedHoldsAndRolls=ScoreMissedHoldsAndRolls()
[Profile]
+5 -3
View File
@@ -764,6 +764,8 @@ void GameState::FinishStage()
if( m_bDemonstrationOrJukebox )
return;
// todo: simplify. profile saving is accomplished in ScreenProfileSave
// now; all this code does differently is save machine profile as well. -aj
if( IsEventMode() )
{
const int iSaveProfileEvery = 3;
@@ -1413,7 +1415,7 @@ void GameState::GetAllUsedNoteSkins( vector<RString> &out ) const
{
out.push_back( m_pPlayerState[pn]->m_PlayerOptions.GetCurrent().m_sNoteSkin );
/* Add note skins that are used in courses. */
// Add note skins that are used in courses.
if( IsCourseMode() )
{
const Trail *pTrail = m_pCurTrail[pn];
@@ -1429,7 +1431,7 @@ void GameState::GetAllUsedNoteSkins( vector<RString> &out ) const
}
}
/* Remove duplicates. */
// Remove duplicates.
sort( out.begin(), out.end() );
out.erase( unique( out.begin(), out.end() ), out.end() );
}
@@ -1457,7 +1459,7 @@ PlayerOptions::FailType GameState::GetPlayerFailType( const PlayerState *pPlayer
PlayerNumber pn = pPlayerState->m_PlayerNumber;
PlayerOptions::FailType ft = pPlayerState->m_PlayerOptions.GetCurrent().m_FailType;
/* If the player changed the fail mode explicitly, leave it alone. */
// If the player changed the fail mode explicitly, leave it alone.
if( m_bChangedFailTypeOnScreenSongOptions )
return ft;
-2
View File
@@ -376,8 +376,6 @@ void MusicWheel::GetSongList( vector<Song*> &arraySongs, SortOrder so )
if( pSong->HasStepsType(GAMESTATE->GetCurrentStyle()->m_StepsType) )
arraySongs.push_back( pSong );
}
}
/* Hack: Add extra stage item if it was eliminated for any reason
+2 -2
View File
@@ -752,8 +752,8 @@ void NetworkSyncManager::SendSMOnline( )
SMOStepType NetworkSyncManager::TranslateStepType(int score)
{
/* Translate from Stepmania's constantly changing TapNoteScore to SMO's
note scores */
/* Translate from Stepmania's constantly changing TapNoteScore
* to SMO's note scores */
switch(score)
{
case TNS_HitMine:
+4 -3
View File
@@ -55,6 +55,7 @@ enum SMOStepType
const NSCommand NSServerOffset = (NSCommand)128;
// TODO: Provide a Lua binding that gives access to this data. -aj
struct EndOfGame_PlayerData
{
int name;
@@ -139,10 +140,10 @@ public:
bool isSMOnline;
bool isSMOLoggedIn[NUM_PLAYERS];
vector <int> m_PlayerStatus;
vector<int> m_PlayerStatus;
int m_ActivePlayers;
vector <int> m_ActivePlayer;
vector <RString> m_PlayerNames;
vector<int> m_ActivePlayer;
vector<RString> m_PlayerNames;
// Used for ScreenNetEvaluation
vector<EndOfGame_PlayerData> m_EvalPlayerData;
+9 -13
View File
@@ -126,8 +126,8 @@ void NoteField::CacheAllUsedNoteSkins()
for( unsigned i=0; i < asSkins.size(); ++i )
CacheNoteSkin( asSkins[i] );
/* If we're changing note skins in the editor, we can have old note skins lying
* around. Remove them so they don't accumulate. */
/* If we're changing note skins in the editor, we can have old note skins
* lying around. Remove them so they don't accumulate. */
set<RString> setNoteSkinsToUnload;
FOREACHM( RString, NoteDisplayCols *, m_NoteDisplays, d )
{
@@ -208,7 +208,7 @@ void NoteField::Update( float fDeltaTime )
const float fYOffsetLast = ArrowEffects::GetYOffset( m_pPlayerState, 0, m_fCurrentBeatLastUpdate );
const float fYPosLast = ArrowEffects::GetYPos( m_pPlayerState, 0, fYOffsetLast, m_fYReverseOffsetPixels );
const float fPixelDifference = fYPosLast - m_fYPosCurrentBeatLastUpdate;
//LOG->Trace( "speed = %f, %f, %f, %f, %f, %f", fSpeed, fYOffsetAtCurrent, fYOffsetAtNext, fSecondsAtCurrent, fSecondsAtNext, fPixelDifference, fSecondsDifference );
m_fBoardOffsetPixels += fPixelDifference;
@@ -218,7 +218,6 @@ void NoteField::Update( float fDeltaTime )
const float fYOffsetCurrent = ArrowEffects::GetYOffset( m_pPlayerState, 0, m_fCurrentBeatLastUpdate );
m_fYPosCurrentBeatLastUpdate = ArrowEffects::GetYPos( m_pPlayerState, 0, fYOffsetCurrent, m_fYReverseOffsetPixels );
m_rectMarkerBar.Update( fDeltaTime );
NoteDisplayCols *cur = m_pCurDisplay;
@@ -226,19 +225,16 @@ void NoteField::Update( float fDeltaTime )
cur->m_ReceptorArrowRow.Update( fDeltaTime );
cur->m_GhostArrowRow.Update( fDeltaTime );
// TODO: make fade time of 1.5 seconds metricable instead? -aj
if( m_fPercentFadeToFail >= 0 )
m_fPercentFadeToFail = min( m_fPercentFadeToFail + fDeltaTime/1.5f, 1 ); // take 1.5 seconds to totally fade
// Update fade to failed
m_pCurDisplay->m_ReceptorArrowRow.SetFadeToFailPercent( m_fPercentFadeToFail );
NoteDisplay::Update( fDeltaTime );
/*
* Update all NoteDisplays. Hack: We need to call this once per frame, not
* once per player.
*/
/* Update all NoteDisplays. Hack: We need to call this once per frame, not
* once per player. */
// TODO: Remove use of PlayerNumber.
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
@@ -315,16 +311,15 @@ void NoteField::DrawBeatBar( const float fBeat, BeatBarType type, int iMeasureIn
void NoteField::DrawBoard( int iDrawDistanceAfterTargetsPixels, int iDrawDistanceBeforeTargetsPixels )
{
// Draw the board centered on fYPosAt0 so that the board doesn't slide as
// the draw distance changes with modifiers.
const float fYPosAt0 = ArrowEffects::GetYPos( m_pPlayerState, 0, 0, m_fYReverseOffsetPixels );
// Draw the board centered on fYPosAt0 so that the board doesn't slide as the draw distance changes with modifiers.
// todo: make this an AutoActor instead? -aj
Sprite *pSprite = dynamic_cast<Sprite *>( (Actor*)m_sprBoard );
if( pSprite == NULL )
RageException::Throw( "Board must be a Sprite" );
RectF rect = *pSprite->GetCurrentTextureCoordRect();
const float fBoardGraphicHeightPixels = pSprite->GetUnzoomedHeight();
float fTexCoordOffset = m_fBoardOffsetPixels / fBoardGraphicHeightPixels;
@@ -336,6 +331,7 @@ void NoteField::DrawBoard( int iDrawDistanceAfterTargetsPixels, int iDrawDistanc
pSprite->ZoomToHeight( fHeight );
pSprite->SetY( fY );
// handle tex coord offset and fade
rect.top = -fTexCoordOffset-(iDrawDistanceBeforeTargetsPixels/fBoardGraphicHeightPixels);
rect.bottom = -fTexCoordOffset+(-iDrawDistanceAfterTargetsPixels/fBoardGraphicHeightPixels);
pSprite->SetCustomTextureRect( rect );
+4 -5
View File
@@ -16,14 +16,13 @@
#include <map>
#include "SpecialFiles.h"
NoteSkinManager* NOTESKIN = NULL; // global object accessable from anywhere in the program
const RString GAME_COMMON_NOTESKIN_NAME = "common";
const RString GAME_BASE_NOTESKIN_NAME = "default";
// this isn't a global because of nondeterministic global actor ordering might init this before SpecialFiles::NOTESKINS_DIR
// this isn't a global because of nondeterministic global actor ordering
// might init this before SpecialFiles::NOTESKINS_DIR
#define GLOBAL_BASE_DIR (SpecialFiles::NOTESKINS_DIR + GAME_COMMON_NOTESKIN_NAME + "/")
static map<RString,RString> g_PathCache;
@@ -96,7 +95,7 @@ void NoteSkinManager::LoadNoteSkinData( const RString &sNoteSkinName, NoteSkinDa
data_out.metrics.Clear();
data_out.vsDirSearchOrder.clear();
/* Read the current NoteSkin and all of its fallbacks */
// Read the current NoteSkin and all of its fallbacks
LoadNoteSkinDataRecursive( sNoteSkinName, data_out );
}
@@ -413,7 +412,7 @@ Actor *NoteSkinManager::LoadActor( const RString &sButton, const RString &sEleme
if( bSpriteOnly )
{
/* Make sure pActor is a Sprite (or something derived from Sprite). */
// Make sure pActor is a Sprite (or something derived from Sprite).
Sprite *pSprite = dynamic_cast<Sprite *>( pRet );
if( pSprite == NULL )
LOG->Warn( "%s: %s %s must be a Sprite", m_sCurrentNoteSkin.c_str(), sButton.c_str(), sElement.c_str() );
+1 -3
View File
@@ -23,7 +23,7 @@ private:
RString m_sMetricsGroup;
BitmapText m_textItem;
OptionsCursor m_Underline[NUM_PLAYERS];
OptionsCursor m_Underline[NUM_PLAYERS];
AutoActor m_sprFrame;
BitmapText m_textTitle;
ModIcon m_ModIcon;
@@ -110,9 +110,7 @@ public:
void Reload();
//
// Messages
//
virtual void HandleMessage( const Message &msg );
protected:
+44 -52
View File
@@ -113,6 +113,7 @@ int OptionRowHandlerUtil::GetOneSelection( const vector<bool> &vbSelected )
static LocalizedString OFF ( "OptionRowHandler", "Off" );
// begin OptionRow handlers
class OptionRowHandlerList : public OptionRowHandler
{
public:
@@ -145,7 +146,7 @@ public:
m_Default.Load( -1, ParseCommands(ENTRY_DEFAULT(sParam)) );
{
/* Parse the basic configuration metric. */
// Parse the basic configuration metric.
Commands cmds = ParseCommands( ENTRY(sParam) );
if( cmds.v.size() < 1 )
RageException::Throw( "Parse error in \"ScreenOptionsMaster::%s\".", sParam.c_str() );
@@ -466,8 +467,8 @@ class OptionRowHandlerListSteps : public OptionRowHandlerList
}
else
{
/* We have neither a song nor a course. We may be preloading the screen
* for future use. */
/* We have neither a song nor a course. We may be preloading the
* screen for future use. */
m_Def.m_vsChoices.push_back( "n/a" );
m_aListEntries.push_back( GameCommand() );
}
@@ -804,10 +805,10 @@ public:
}
m_EnabledForPlayersFunc.PushSelf( L );
/* Argument 1 (self): */
// Argument 1 (self):
m_pLuaTable->PushSelf( L );
lua_call( L, 1, 1 ); // call function with 1 argument and 1 result
if( !lua_istable(L, -1) )
RageException::Throw( "\"EnabledForPlayers\" did not return a table." );
@@ -817,12 +818,12 @@ public:
lua_pushnil( L );
while( lua_next(L, -2) != 0 )
{
/* `key' is at index -2 and `value' at index -1 */
// `key' is at index -2 and `value' at index -1
PlayerNumber pn = (PlayerNumber)luaL_checkint( L, -1 );
m_Def.m_vEnabledForPlayers.insert( pn );
lua_pop( L, 1 ); /* removes `value'; keeps `key' for next iteration */
lua_pop( L, 1 ); // removes `value'; keeps `key' for next iteration
}
lua_pop( L, 1 );
@@ -841,7 +842,7 @@ public:
Lua *L = LUA->Get();
/* Run the Lua expression. It should return a table. */
// Run the Lua expression. It should return a table.
m_pLuaTable->SetFromExpression( sLuaFunction );
if( m_pLuaTable->GetLuaType() != LUA_TTABLE )
@@ -857,19 +858,16 @@ public:
m_Def.m_sName = pStr;
lua_pop( L, 1 );
lua_pushstring( L, "OneChoiceForAllPlayers" );
lua_gettable( L, -2 );
m_Def.m_bOneChoiceForAllPlayers = !!lua_toboolean( L, -1 );
lua_pop( L, 1 );
lua_pushstring( L, "ExportOnChange" );
lua_gettable( L, -2 );
m_Def.m_bExportOnChange = !!lua_toboolean( L, -1 );
lua_pop( L, 1 );
lua_pushstring( L, "LayoutType" );
lua_gettable( L, -2 );
pStr = lua_tostring( L, -1 );
@@ -879,7 +877,6 @@ public:
ASSERT( m_Def.m_layoutType != LayoutType_Invalid );
lua_pop( L, 1 );
lua_pushstring( L, "SelectType" );
lua_gettable( L, -2 );
pStr = lua_tostring( L, -1 );
@@ -889,8 +886,7 @@ public:
ASSERT( m_Def.m_selectType != SelectType_Invalid );
lua_pop( L, 1 );
/* Iterate over the "Choices" table. */
// Iterate over the "Choices" table.
lua_pushstring( L, "Choices" );
lua_gettable( L, -2 );
if( !lua_istable( L, -1 ) )
@@ -899,7 +895,7 @@ public:
lua_pushnil( L );
while( lua_next(L, -2) != 0 )
{
/* `key' is at index -2 and `value' at index -1 */
// `key' is at index -2 and `value' at index -1
const char *pValue = lua_tostring( L, -1 );
if( pValue == NULL )
RageException::Throw( "\"%s\" Column entry is not a string.", sLuaFunction.c_str() );
@@ -907,21 +903,20 @@ public:
m_Def.m_vsChoices.push_back( pValue );
lua_pop( L, 1 ); /* removes `value'; keeps `key' for next iteration */
lua_pop( L, 1 ); // removes `value'; keeps `key' for next iteration
}
lua_pop( L, 1 ); /* pop choices table */
lua_pop( L, 1 ); // pop choices table
/* Set the EnabledForPlayers function. */
// Set the EnabledForPlayers function.
lua_pushstring( L, "EnabledForPlayers" );
lua_gettable( L, -2 );
if( !lua_isfunction( L, -1 ) && !lua_isnil( L, -1 ) )
RageException::Throw( "\"%s\" \"EnabledForPlayers\" is not a table.", sLuaFunction.c_str() );
m_EnabledForPlayersFunc.SetFromStack( L );
SetEnabledForPlayers();
/* Iterate over the "ReloadRowMessages" table. */
// Iterate over the "ReloadRowMessages" table.
lua_pushstring( L, "ReloadRowMessages" );
lua_gettable( L, -2 );
if( !lua_isnil( L, -1 ) )
@@ -932,7 +927,7 @@ public:
lua_pushnil( L );
while( lua_next(L, -2) != 0 )
{
/* `key' is at index -2 and `value' at index -1 */
// `key' is at index -2 and `value' at index -1
const char *pValue = lua_tostring( L, -1 );
if( pValue == NULL )
RageException::Throw( "\"%s\" Column entry is not a string.", sLuaFunction.c_str() );
@@ -940,23 +935,21 @@ public:
m_vsReloadRowMessages.push_back( pValue );
lua_pop( L, 1 ); /* removes `value'; keeps `key' for next iteration */
lua_pop( L, 1 ); // removes `value'; keeps `key' for next iteration
}
}
lua_pop( L, 1 ); /* pop ReloadRowMessages table */
lua_pop( L, 1 ); // pop ReloadRowMessages table
/* Look for "ExportOnChange" value. */
// Look for "ExportOnChange" value.
lua_pushstring( L, "ExportOnChange" );
lua_gettable( L, -2 );
if( !lua_isnil( L, -1 ) )
{
m_Def.m_bExportOnChange = !!MyLua_checkboolean( L, -1 );
}
lua_pop( L, 1 ); /* pop ExportOnChange value */
lua_pop( L, 1 ); // pop ExportOnChange value
lua_pop( L, 1 ); /* pop main table */
lua_pop( L, 1 ); // pop main table
ASSERT( lua_gettop(L) == 0 );
LUA->Release(L);
@@ -979,18 +972,18 @@ public:
PlayerNumber p = *pn;
vector<bool> &vbSelOut = vbSelectedOut[p];
/* Evaluate the LoadSelections(self,array,pn) function, where array is a table
* representing vbSelectedOut. */
/* Evaluate the LoadSelections(self,array,pn) function, where
* array is a table representing vbSelectedOut. */
/* All selections default to false. */
// All selections default to false.
for( unsigned i = 0; i < vbSelOut.size(); ++i )
vbSelOut[i] = false;
/* Create the vbSelectedOut table. */
// Create the vbSelectedOut table
LuaHelpers::CreateTableFromArrayB( L, vbSelOut );
ASSERT( lua_gettop(L) == 1 ); /* vbSelectedOut table */
ASSERT( lua_gettop(L) == 1 ); // vbSelectedOut table
/* Get the function to call from m_LuaTable. */
// Get the function to call from m_LuaTable.
m_pLuaTable->PushSelf( L );
ASSERT( lua_istable( L, -1 ) );
@@ -999,25 +992,25 @@ public:
if( !lua_isfunction( L, -1 ) )
RageException::Throw( "\"%s\" \"LoadSelections\" entry is not a function.", m_Def.m_sName.c_str() );
/* Argument 1 (self): */
// Argument 1 (self):
m_pLuaTable->PushSelf( L );
/* Argument 2 (vbSelectedOut): */
// Argument 2 (vbSelectedOut):
lua_pushvalue( L, 1 );
/* Argument 3 (pn): */
// Argument 3 (pn):
LuaHelpers::Push( L, p );
ASSERT( lua_gettop(L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */
ASSERT( lua_gettop(L) == 6 ); // vbSelectedOut, m_iLuaTable, function, self, arg, arg
lua_call( L, 3, 0 ); // call function with 3 arguments and 0 results
ASSERT( lua_gettop(L) == 2 );
lua_pop( L, 1 ); /* pop option table */
lua_pop( L, 1 ); // pop option table
LuaHelpers::ReadArrayFromTableB( L, vbSelOut );
lua_pop( L, 1 ); /* pop vbSelectedOut table */
lua_pop( L, 1 ); // pop vbSelectedOut table
ASSERT( lua_gettop(L) == 0 );
}
@@ -1040,11 +1033,11 @@ public:
vector<bool> vbSelectedCopy = vbSel;
/* Create the vbSelectedOut table. */
// Create the vbSelectedOut table.
LuaHelpers::CreateTableFromArrayB( L, vbSelectedCopy );
ASSERT( lua_gettop(L) == 1 ); /* vbSelectedOut table */
ASSERT( lua_gettop(L) == 1 ); // vbSelectedOut table
/* Get the function to call. */
// Get the function to call.
m_pLuaTable->PushSelf( L );
ASSERT( lua_istable( L, -1 ) );
@@ -1053,22 +1046,22 @@ public:
if( !lua_isfunction( L, -1 ) )
RageException::Throw( "\"%s\" \"SaveSelections\" entry is not a function.", m_Def.m_sName.c_str() );
/* Argument 1 (self): */
// Argument 1 (self):
m_pLuaTable->PushSelf( L );
/* Argument 2 (vbSelectedOut): */
// Argument 2 (vbSelectedOut):
lua_pushvalue( L, 1 );
/* Argument 3 (pn): */
// Argument 3 (pn):
LuaHelpers::Push( L, p );
ASSERT( lua_gettop(L) == 6 ); /* vbSelectedOut, m_iLuaTable, function, self, arg, arg */
ASSERT( lua_gettop(L) == 6 ); // vbSelectedOut, m_iLuaTable, function, self, arg, arg
lua_call( L, 3, 0 ); // call function with 3 arguments and 0 results
ASSERT( lua_gettop(L) == 2 );
lua_pop( L, 1 ); /* pop option table */
lua_pop( L, 1 ); /* pop vbSelected table */
lua_pop( L, 1 ); // pop option table
lua_pop( L, 1 ); // pop vbSelected table
ASSERT( lua_gettop(L) == 0 );
}
@@ -1309,7 +1302,6 @@ public:
OptionRowHandlerNull() { Init(); }
};
///////////////////////////////////////////////////////////////////////////////////
OptionRowHandler* OptionRowHandlerUtil::Make( const Commands &cmds )
+2 -2
View File
@@ -89,7 +89,7 @@ class OptionRowHandler
public:
OptionRowDefinition m_Def;
vector<RString> m_vsReloadRowMessages; // refresh this row on on these messages
OptionRowHandler() { Init(); }
virtual ~OptionRowHandler() { }
virtual void Init()
@@ -124,7 +124,7 @@ public:
virtual int GetDefaultOption() const { return -1; }
virtual void ImportOption( OptionRow *pRow, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const { }
/* Returns an OPT mask. */
// Returns an OPT mask.
virtual int ExportOption( const vector<PlayerNumber> &vpns, const vector<bool> vbSelected[NUM_PLAYERS] ) const { return 0; }
virtual void GetIconTextAndGameCommand( int iFirstSelection, RString &sIconTextOut, GameCommand &gcOut ) const;
virtual RString GetScreen( int iChoice ) const { return RString(); }
+4 -4
View File
@@ -51,16 +51,16 @@ public:
void Link( OptionsList *pLink ) { m_pLinked = pLink; }
/* Show the top-level menu. */
// Show the top-level menu.
void Open();
/* Close all menus (for menu timer). */
// Close all menus (for menu timer).
void Close();
void Input( const InputEventPlus &input );
bool IsOpened() const { return m_asMenuStack.size() > 0; }
bool Start(); /* return true if the last menu was popped in response to this press */
bool Start(); // return true if the last menu was popped in response to this press
private:
ThemeMetric<RString> TOP_MENU;
@@ -94,7 +94,7 @@ private:
map<RString, OptionRowHandler *> m_Rows;
map<RString, vector<bool> > m_bSelections;
set<RString> m_setDirectRows;
set<RString> m_setTopMenus; /* list of top-level menus, pointing to submenus */
set<RString> m_setTopMenus; // list of top-level menus, pointing to submenus
PlayerNumber m_pn;
AutoActor m_Cursor;
+12 -7
View File
@@ -51,7 +51,7 @@ class JudgedRows
vector<bool> m_vRows;
int m_iStart;
int m_iOffset;
void Resize( size_t iMin )
{
size_t iNewSize = max( 2*m_vRows.size(), iMin );
@@ -132,6 +132,7 @@ ThemeMetric<bool> PENALIZE_TAP_SCORE_NONE ( "Player", "PenalizeTapScoreNone" );
ThemeMetric<bool> JUDGE_HOLD_NOTES_ON_SAME_ROW_TOGETHER ( "Player", "JudgeHoldNotesOnSameRowTogether" );
ThemeMetric<bool> HOLD_CHECKPOINTS ( "Player", "HoldCheckpoints" );
ThemeMetric<bool> CHECKPOINTS_USE_TIME_SIGNATURES ( "Player", "CheckpointsUseTimeSignatures" );
ThemeMetric<bool> CHECKPOINTS_FLASH_ON_HOLD ( "Player", "CheckpointsFlashOnHold" ); // sm-ssc addition
ThemeMetric<bool> IMMEDIATE_HOLD_LET_GO ( "Player", "ImmediateHoldLetGo" );
ThemeMetric<bool> REQUIRE_STEP_ON_HOLD_HEADS ( "Player", "RequireStepOnHoldHeads" );
//ThemeMetric<bool> REQUIRE_STEP_ON_TAP_NOTES ( "Player", "RequireStepOnTapNotes" ); // parastar stuff; leave in though
@@ -2064,7 +2065,7 @@ void Player::StepStrumHopo( int col, int row, const RageTimer &tm, bool bHeld, b
goto done_checking_hopo;
}
// can't hopo on the same note 2x in a row
// con't hopo on the same note 2x in a row
if( col == m_pPlayerState->m_iLastHopoNoteCol )
{
bDidHopo = false;
@@ -2425,7 +2426,7 @@ void Player::UpdateJudgedRows()
switch( tn.result.tns )
{
DEFAULT_FAIL( tn.result.tns );
case TNS_None:
case TNS_None:
bAllJudged = false;
continue;
case TNS_AvoidMine:
@@ -2834,11 +2835,15 @@ void Player::HandleHoldCheckpoint( int iRow, int iNumHoldsHeldThisRow, int iNumH
if( iNumHoldsMissedThisRow == 0 )
{
FOREACH_CONST( int, viColsWithHold, i )
// added for http://ssc.ajworld.net/sm-ssc/bugtracker/view.php?id=16 -aj
if( CHECKPOINTS_FLASH_ON_HOLD )
{
bool bBright = m_pPlayerStageStats && m_pPlayerStageStats->m_iCurCombo>(int)BRIGHT_GHOST_COMBO_THRESHOLD;
if( m_pNoteField )
m_pNoteField->DidHoldNote( *i, HNS_Held, bBright );
FOREACH_CONST( int, viColsWithHold, i )
{
bool bBright = m_pPlayerStageStats && m_pPlayerStageStats->m_iCurCombo>(int)BRIGHT_GHOST_COMBO_THRESHOLD;
if( m_pNoteField )
m_pNoteField->DidHoldNote( *i, HNS_Held, bBright );
}
}
}
+4 -4
View File
@@ -156,7 +156,7 @@ void Screen::Update( float fDeltaTime )
CHECKPOINT_M( ssprintf("ScreenMessage(%s)", ScreenMessageHelpers::ScreenMessageToString(SM).c_str()) );
this->HandleScreenMessage( SM );
/* If the size changed, start over. */
// If the size changed, start over.
if( iSize != m_QueuedMessages.size() )
i = 0;
}
@@ -177,12 +177,12 @@ void Screen::Input( const InputEventPlus &input )
if( m_Codes.InputMessage(input, msg) )
this->HandleMessage( msg );
/* Don't send release messages with the default handler. */
// Don't send release messages with the default handler.
switch( input.type )
{
case IET_FIRST_PRESS:
case IET_REPEAT:
break; /* OK */
break; // OK
default:
return; // don't care
}
@@ -195,7 +195,7 @@ void Screen::Input( const InputEventPlus &input )
case GAME_BUTTON_MENULEFT: this->MenuLeft ( input ); return;
case GAME_BUTTON_MENURIGHT: this->MenuRight ( input ); return;
case GAME_BUTTON_BACK:
/* Don't make the user hold the back button if they're pressing escape and escape is the back button. */
// Don't make the user hold the back button if they're pressing escape and escape is the back button.
if( !PREFSMAN->m_bDelayedBack || input.type==IET_REPEAT || (input.DeviceI.device == DEVICE_KEYBOARD && input.DeviceI.button == KEY_ESC) )
this->MenuBack( input );
return;
+4 -4
View File
@@ -40,10 +40,10 @@ public:
* derived classes exist. (Don't call it directly; use InitScreen.) */
virtual void Init();
/* This is called immediately before the screen is used. */
// This is called immediately before the screen is used.
virtual void BeginScreen();
/* This is called when the screen is popped. */
// This is called when the screen is popped.
virtual void EndScreen();
virtual void Update( float fDeltaTime );
@@ -83,9 +83,9 @@ protected:
RString m_sNextScreen;
ScreenMessage m_smSendOnPop;
float m_fLockInputSecs;
float m_fLockInputSecs;
/* If currently between BeginScreen/EndScreen calls: */
// If currently between BeginScreen/EndScreen calls:
bool m_bRunning;
public:
+1
View File
@@ -474,6 +474,7 @@ void ScreenGameplay::Init()
pi->m_pPlayer->SetX( fPlayerX );
pi->m_pPlayer->RunCommands( PLAYER_INIT_COMMAND );
//ActorUtil::LoadAllCommands(pi->m_pPlayer, m_sName);
this->AddChild( pi->m_pPlayer );
pi->m_pPlayer->PlayCommand( "On" );
}
+8 -6
View File
@@ -61,7 +61,7 @@ void ScreenNetEvaluation::RedoUserTexts()
{
m_iActivePlayers = NSMAN->m_ActivePlayers;
//If unnecessary, just don't do this function.
// If unnecessary, just don't do this function.
if ( m_iActivePlayers == (int)m_textUsers.size() )
return;
@@ -78,7 +78,7 @@ void ScreenNetEvaluation::RedoUserTexts()
for( int i=0; i<m_iActivePlayers; ++i )
{
m_textUsers[i].LoadFromFont( THEME->GetPathF(m_sName,"names") );
m_textUsers[i].SetName( "User" );
m_textUsers[i].SetName( ssprintf("User") );
m_textUsers[i].SetShadowLength( 1 );
m_textUsers[i].SetXY( cx, cy );
@@ -150,10 +150,12 @@ void ScreenNetEvaluation::HandleScreenMessage( const ScreenMessage SM )
break;
m_textUsers[i].SetText( NSMAN->m_PlayerNames[NSMAN->m_EvalPlayerData[i].name] );
if ( NSMAN->m_EvalPlayerData[i].grade < Grade_Tier03 ) //Yes, hardcoded (I'd like to leave it that way)
m_textUsers[i].SetRainbowScroll( true );
else
m_textUsers[i].SetRainbowScroll( false );
// Yes, hardcoded (I'd like to leave it that way) -CNLohr (in reference to Grade_Tier03)
// Themes can read this differently. The correct solution depends...
// TODO: make this a server-side variable, or just find out
// the data from the theme? If we find out from the theme, people
// will be using different themes so it means nothing. -aj
m_textUsers[i].SetRainbowScroll( NSMAN->m_EvalPlayerData[i].grade < Grade_Tier03 );
ON_COMMAND( m_textUsers[i] );
LOG->Trace( "SMNETCheckpoint%d", i );
}
+1 -1
View File
@@ -19,7 +19,7 @@ static const char *PromptAnswerNames[] = {
};
XToString( PromptAnswer );
/* Settings: */
// Settings:
namespace
{
RString g_sText;
+2 -4
View File
@@ -26,10 +26,10 @@ public:
void UpdateAnimationState(); // take m_fSecondsIntoState, and move to a new state
/* Adjust texture properties for song backgrounds. */
// Adjust texture properties for song backgrounds.
static RageTextureID SongBGTexture( RageTextureID ID );
/* Adjust texture properties for song banners. */
// Adjust texture properties for song banners.
static RageTextureID SongBannerTexture( RageTextureID ID );
virtual void Load( RageTextureID ID );
@@ -67,9 +67,7 @@ public:
void CropTo( float fWidth, float fHeight );
static bool IsDiagonalBanner( int iWidth, int iHeight );
//
// Commands
//
virtual void PushSelf( lua_State *L );
void SetAllStateDelays(float fDelay);
+1 -2
View File
@@ -36,9 +36,8 @@ private:
StageStats m_AccumPlayedStageStats;
};
extern StatsManager* STATSMAN; // global and accessable from anywhere in our program
#endif
/*
@@ -761,7 +761,7 @@ void CTextureFontGeneratorDlg::UpdateFontViewAndCloseUp()
m_SpinTop.EnableWindow( true );
m_SpinBaseline.EnableWindow( true );
GetMenu()->EnableMenuItem( ID_FILE_SAVE, MF_ENABLED );
if( g_pTextureFont->m_sError != "" )
{
m_SpinTop.EnableWindow(false);
@@ -67,12 +67,11 @@ static void CheckForDirectInputDebugMode()
if( RegistryAccess::GetRegValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\DirectInput", "emulation", iVal) )
{
if( iVal & 0x8 )
LOG->Warn("DirectInput keyboard debug mode appears to be enabled. This reduces\n"
"input timing accuracy significantly. Disabling this is strongly recommended." );
LOG->Warn("DirectInput keyboard debug mode appears to be enabled. This reduces\n"
"input timing accuracy significantly. Disabling this is strongly recommended." );
}
}
static BOOL CALLBACK CountDevicesCallback( const DIDEVICEINSTANCE *pdidInstance, void *pContext )
{
(*(int*)pContext)++;
@@ -81,7 +80,7 @@ static BOOL CALLBACK CountDevicesCallback( const DIDEVICEINSTANCE *pdidInstance,
static int GetNumHidDevices()
{
int i = 0;
int i = 0;
RegistryAccess::GetRegValue( "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\HidUsb\\Enum", "Count", i, false ); // don't warn on error
return i;
}
@@ -194,7 +193,7 @@ InputHandler_DInput::~InputHandler_DInput()
void InputHandler_DInput::WindowReset()
{
/* We need to reopen keyboards. */
// We need to reopen keyboards.
ShutdownThread();
for( unsigned i = 0; i < Devices.size(); ++i )
@@ -204,12 +203,12 @@ void InputHandler_DInput::WindowReset()
Devices[i].Close();
/* We lose buffered inputs here, so we need to clear all pressed keys. */
// We lose buffered inputs here, so we need to clear all pressed keys.
INPUTFILTER->ResetDevice( Devices[i].dev );
bool ret = Devices[i].Open();
/* Reopening it should succeed. */
// Reopening it should succeed.
ASSERT( ret );
}
@@ -409,7 +408,7 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
if( GetForegroundWindow() != GraphicsWindow::GetHwnd() )
{
/* Discard input when not focused, and release all keys. */
// Discard input when not focused, and release all keys.
INPUTFILTER->ResetDevice( device.dev );
return;
}
@@ -423,77 +422,77 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
if( evtbuf[i].dwOfs != in.ofs )
continue;
switch( in.type )
{
case in.KEY:
/*
switch( in.num )
{
// "Joystick with Keyboard" hack
case 115: //s
ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_UP, !!(evtbuf[i].dwData & 0x80), tm) );
break;
case 120: //x
ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_DOWN, !!(evtbuf[i].dwData & 0x80), tm) );
break;
case 122: //z
ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_LEFT, !!(evtbuf[i].dwData & 0x80), tm) );
break;
case 99: //c
ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_RIGHT, !!(evtbuf[i].dwData & 0x80), tm) );
break;
case 100: //d
ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_BUTTON_1, !!(evtbuf[i].dwData & 0x80), tm) );
break;
case 101: //e
ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_BUTTON_2, !!(evtbuf[i].dwData & 0x80), tm) );
break;
default:
*/
ButtonPressed( DeviceInput(dev, (DeviceButton) in.num, !!(evtbuf[i].dwData & 0x80), tm) );
case in.KEY:
/*
switch( in.num )
{
// "Joystick with Keyboard" hack
case 115: //s
ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_UP, !!(evtbuf[i].dwData & 0x80), tm) );
break;
case 120: //x
ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_DOWN, !!(evtbuf[i].dwData & 0x80), tm) );
break;
case 122: //z
ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_LEFT, !!(evtbuf[i].dwData & 0x80), tm) );
break;
case 99: //c
ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_RIGHT, !!(evtbuf[i].dwData & 0x80), tm) );
break;
case 100: //d
ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_BUTTON_1, !!(evtbuf[i].dwData & 0x80), tm) );
break;
case 101: //e
ButtonPressed( DeviceInput(DEVICE_JOY1, JOY_BUTTON_2, !!(evtbuf[i].dwData & 0x80), tm) );
break;
default:
*/
ButtonPressed( DeviceInput(dev, (DeviceButton) in.num, !!(evtbuf[i].dwData & 0x80), tm) );
/*
break;
}
*/
break;
case in.BUTTON:
ButtonPressed( DeviceInput(dev, enum_add2(JOY_BUTTON_1, in.num), !!evtbuf[i].dwData, tm) );
break;
case in.AXIS:
{
DeviceButton up = DeviceButton_Invalid, down = DeviceButton_Invalid;
switch(in.ofs)
{
case DIJOFS_X: up = JOY_LEFT; down = JOY_RIGHT; break;
case DIJOFS_Y: up = JOY_UP; down = JOY_DOWN; break;
case DIJOFS_Z: up = JOY_Z_UP; down = JOY_Z_DOWN; break;
case DIJOFS_RX: up = JOY_ROT_UP; down = JOY_ROT_DOWN; break;
case DIJOFS_RY: up = JOY_ROT_LEFT; down = JOY_ROT_RIGHT; break;
case DIJOFS_RZ: up = JOY_ROT_Z_UP; down = JOY_ROT_Z_DOWN; break;
case DIJOFS_SLIDER(0): up = JOY_AUX_1; down = JOY_AUX_2; break;
case DIJOFS_SLIDER(1): up = JOY_AUX_3; down = JOY_AUX_4; break;
default: LOG->MapLog( "unknown input",
"Controller '%s' is returning an unknown joystick offset, %i",
device.m_sName.c_str(), in.ofs );
continue;
}
float l = SCALE( int(evtbuf[i].dwData), 0.0f, 100.0f, 0.0f, 1.0f );
ButtonPressed( DeviceInput(dev, up, max(-l,0), tm) );
ButtonPressed( DeviceInput(dev, down, max(+l,0), tm) );
break;
}
*/
break;
case in.BUTTON:
ButtonPressed( DeviceInput(dev, enum_add2(JOY_BUTTON_1, in.num), !!evtbuf[i].dwData, tm) );
break;
case in.AXIS:
{
DeviceButton up = DeviceButton_Invalid, down = DeviceButton_Invalid;
switch(in.ofs)
case in.HAT:
{
case DIJOFS_X: up = JOY_LEFT; down = JOY_RIGHT; break;
case DIJOFS_Y: up = JOY_UP; down = JOY_DOWN; break;
case DIJOFS_Z: up = JOY_Z_UP; down = JOY_Z_DOWN; break;
case DIJOFS_RX: up = JOY_ROT_UP; down = JOY_ROT_DOWN; break;
case DIJOFS_RY: up = JOY_ROT_LEFT; down = JOY_ROT_RIGHT; break;
case DIJOFS_RZ: up = JOY_ROT_Z_UP; down = JOY_ROT_Z_DOWN; break;
case DIJOFS_SLIDER(0): up = JOY_AUX_1; down = JOY_AUX_2; break;
case DIJOFS_SLIDER(1): up = JOY_AUX_3; down = JOY_AUX_4; break;
default: LOG->MapLog( "unknown input",
"Controller '%s' is returning an unknown joystick offset, %i",
device.m_sName.c_str(), in.ofs );
continue;
const int pos = TranslatePOV( evtbuf[i].dwData );
ButtonPressed( DeviceInput(dev, JOY_HAT_UP, !!(pos & HAT_UP_MASK), tm) );
ButtonPressed( DeviceInput(dev, JOY_HAT_DOWN, !!(pos & HAT_DOWN_MASK), tm) );
ButtonPressed( DeviceInput(dev, JOY_HAT_LEFT, !!(pos & HAT_LEFT_MASK), tm) );
ButtonPressed( DeviceInput(dev, JOY_HAT_RIGHT, !!(pos & HAT_RIGHT_MASK), tm) );
}
float l = SCALE( int(evtbuf[i].dwData), 0.0f, 100.0f, 0.0f, 1.0f );
ButtonPressed( DeviceInput(dev, up, max(-l,0), tm) );
ButtonPressed( DeviceInput(dev, down, max(+l,0), tm) );
break;
}
case in.HAT:
{
const int pos = TranslatePOV( evtbuf[i].dwData );
ButtonPressed( DeviceInput(dev, JOY_HAT_UP, !!(pos & HAT_UP_MASK), tm) );
ButtonPressed( DeviceInput(dev, JOY_HAT_DOWN, !!(pos & HAT_DOWN_MASK), tm) );
ButtonPressed( DeviceInput(dev, JOY_HAT_LEFT, !!(pos & HAT_LEFT_MASK), tm) );
ButtonPressed( DeviceInput(dev, JOY_HAT_RIGHT, !!(pos & HAT_RIGHT_MASK), tm) );
}
}
}
}
@@ -525,7 +524,7 @@ void InputHandler_DInput::PollAndAcquireDevices( bool bBuffered )
void InputHandler_DInput::Update()
{
/* Handle polled devices. Handle buffered, too, if there's no input thread to do it. */
/* Handle polled devices. Handle buffered, too, if there's no input thread to do it. */
PollAndAcquireDevices( false );
if( !m_InputThread.IsCreated() )
PollAndAcquireDevices( true );
@@ -538,7 +537,7 @@ void InputHandler_DInput::Update()
}
else if( !m_InputThread.IsCreated() )
{
/* If we have an input thread, it'll handle buffered devices. */
// If we have an input thread, it'll handle buffered devices.
UpdateBuffered( Devices[i], RageZeroTimer );
}
}
@@ -551,7 +550,6 @@ const float POLL_FOR_JOYSTICK_CHANGES_EVERY_SECONDS = 0.25f;
bool InputHandler_DInput::DevicesChanged()
{
//
// GetNumJoysticksSlow() blocks DirectInput for a while even if called from a
// different thread, so we can't poll with it.
// GetNumHidDevices() is fast, but sometimes the DirectInput joysticks haven't updated by
@@ -564,7 +562,6 @@ bool InputHandler_DInput::DevicesChanged()
// Note that this "poll for N seconds" method will not work if the Add New Hardware wizard
// halts device installation to wait for a driver. Most of the joysticks people would
// want to use don't prompt for a driver though and the wizard adds them pretty quickly.
//
int iOldNumHidDevices = m_iLastSeenNumHidDevices;
m_iLastSeenNumHidDevices = GetNumHidDevices();
@@ -602,7 +599,7 @@ void InputHandler_DInput::InputThreadMain()
if(!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST))
LOG->Warn(werr_ssprintf(GetLastError(), "Failed to set DirectInput thread priority"));
/* Enable priority boosting. */
// Enable priority boosting.
SetThreadPriorityBoost( GetCurrentThread(), FALSE );
vector<DIDevice*> BufferedDevices;
@@ -611,7 +608,7 @@ void InputHandler_DInput::InputThreadMain()
{
if( !Devices[i].buffered )
continue;
BufferedDevices.push_back( &Devices[i] );
Devices[i].Device->Unacquire();
@@ -626,7 +623,7 @@ void InputHandler_DInput::InputThreadMain()
CHECKPOINT;
if( BufferedDevices.size() )
{
/* Update buffered devices. */
// Update buffered devices.
PollAndAcquireDevices( true );
int ret = WaitForSingleObjectEx( Handle, 50, true );
@@ -636,15 +633,15 @@ void InputHandler_DInput::InputThreadMain()
continue;
}
/* Update devices even if no event was triggered, since this also checks for focus
* loss. */
/* Update devices even if no event was triggered, since this also
* checks for focus loss. */
RageTimer now;
for( unsigned i = 0; i < BufferedDevices.size(); ++i )
UpdateBuffered( *BufferedDevices[i], now );
}
CHECKPOINT;
/* If we have no buffered devices, we didn't delay at WaitForMultipleObjectsEx. */
// If we have no buffered devices, we didn't delay at WaitForMultipleObjectsEx.
if( BufferedDevices.size() == 0 )
usleep( 50000 );
CHECKPOINT;
@@ -671,7 +668,7 @@ void InputHandler_DInput::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vD
static wchar_t ScancodeAndKeysToChar( DWORD scancode, unsigned char keys[256] )
{
static HKL layout = GetKeyboardLayout(0); // 0 == current thread
static HKL layout = GetKeyboardLayout(0); // 0 == current thread
UINT vk = MapVirtualKeyEx( scancode, 1, layout );
static bool bInitialized = false;
@@ -687,7 +684,7 @@ static wchar_t ScancodeAndKeysToChar( DWORD scancode, unsigned char keys[256] )
}
unsigned short result[2]; // ToAscii writes a max of 2 chars
unsigned short result[2]; // ToAscii writes a max of 2 chars
ZERO( result );
if( pToUnicodeEx != NULL )
@@ -699,7 +696,7 @@ static wchar_t ScancodeAndKeysToChar( DWORD scancode, unsigned char keys[256] )
else
{
int iNum = ToAsciiEx( vk, scancode, keys, result, 0, layout );
// iNum == 2 will happen only for dead keys. See MSDN for ToAsciiEx.
// iNum == 2 will happen only for dead keys. See MSDN for ToAsciiEx.
if( iNum == 1 )
{
RString s = RString()+(char)result[0];
@@ -712,7 +709,7 @@ static wchar_t ScancodeAndKeysToChar( DWORD scancode, unsigned char keys[256] )
wchar_t InputHandler_DInput::DeviceButtonToChar( DeviceButton button, bool bUseCurrentKeyModifiers )
{
// ToAsciiEx maps these keys to a character. They shouldn't be mapped to any character.
// ToAsciiEx maps these keys to a character. They shouldn't be mapped to any character.
switch( button )
{
case KEY_ESC:
@@ -60,7 +60,6 @@ bool DIDevice::Open()
return false;
}
hr = Device->SetDataFormat( type == JOYSTICK? &c_dfDIJoystick: &c_dfDIKeyboard );
if ( hr != DI_OK )
{
@@ -119,7 +118,7 @@ bool DIDevice::Open()
void DIDevice::Close()
{
/* Don't try to close a device that isn't open. */
// Don't try to close a device that isn't open.
ASSERT( Device != NULL );
Device->Unacquire();
@@ -138,13 +137,13 @@ static BOOL CALLBACK DIJoystick_EnumDevObjectsProc(LPCDIDEVICEOBJECTINSTANCE dev
input_t in;
const int SupportedMask = DIDFT_BUTTON | DIDFT_POV | DIDFT_AXIS;
if(!(dev->dwType & SupportedMask))
return DIENUM_CONTINUE; /* unsupported */
return DIENUM_CONTINUE; // unsupported
in.ofs = dev->dwOfs;
if(dev->dwType & DIDFT_BUTTON) {
if( device->buttons == 24 )
return DIENUM_CONTINUE; /* too many buttons */
return DIENUM_CONTINUE; // too many buttons
in.type = in.BUTTON;
in.num = device->buttons;
@@ -153,13 +152,13 @@ static BOOL CALLBACK DIJoystick_EnumDevObjectsProc(LPCDIDEVICEOBJECTINSTANCE dev
in.type = in.HAT;
in.num = device->hats;
device->hats++;
} else { /* dev->dwType & DIDFT_AXIS */
} else { // dev->dwType & DIDFT_AXIS
DIPROPRANGE diprg;
DIPROPDWORD dilong;
in.type = in.AXIS;
in.num = device->axes;
diprg.diph.dwSize = sizeof(diprg);
diprg.diph.dwHeaderSize = sizeof(diprg.diph);
diprg.diph.dwObj = dev->dwOfs;
@@ -169,9 +168,9 @@ static BOOL CALLBACK DIJoystick_EnumDevObjectsProc(LPCDIDEVICEOBJECTINSTANCE dev
hr = device->Device->SetProperty( DIPROP_RANGE, &diprg.diph );
if ( hr != DI_OK )
return DIENUM_CONTINUE; /* don't use this axis */
/* Set dead zone to 0. */
return DIENUM_CONTINUE; // don't use this axis
// Set dead zone to 0.
dilong.diph.dwSize = sizeof(dilong);
dilong.diph.dwHeaderSize = sizeof(dilong.diph);
dilong.diph.dwObj = dev->dwOfs;
+1 -1
View File
@@ -62,7 +62,7 @@ public:
virtual bool TryWait() = 0;
};
/* These functions must be implemented by the thread implementation. */
// These functions must be implemented by the thread implementation.
ThreadImpl *MakeThread( int (*fn)(void *), void *data, uint64_t *piThreadID );
ThreadImpl *MakeThisThread();
MutexImpl *MakeMutex( RageMutex *pParent );
+19 -20
View File
@@ -62,15 +62,15 @@ int ThreadImpl_Win32::Wait()
return ret;
}
/* SetThreadName magic comes from VirtualDub. */
// SetThreadName magic comes from VirtualDub.
#define MS_VC_EXCEPTION 0x406d1388
typedef struct tagTHREADNAME_INFO
{
DWORD dwType; // must be 0x1000
LPCSTR szName; // pointer to name (in same addr space)
DWORD dwThreadID; // thread ID (-1 caller thread)
DWORD dwFlags; // reserved for future use, most be zero
DWORD dwType; // must be 0x1000
LPCSTR szName; // pointer to name (in same addr space)
DWORD dwThreadID; // thread ID (-1 caller thread)
DWORD dwFlags; // reserved for future use, must be zero
} THREADNAME_INFO;
static void SetThreadName( DWORD dwThreadID, LPCTSTR szThreadName )
@@ -114,7 +114,7 @@ static int GetOpenSlot( uint64_t iID )
g_pThreadIdMutex->Lock();
/* Find an open slot in g_ThreadIds. */
// Find an open slot in g_ThreadIds.
int slot = 0;
while( slot < MAX_THREADS && g_ThreadIds[slot] != 0 )
++slot;
@@ -173,7 +173,6 @@ ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThre
}
MutexImpl_Win32::MutexImpl_Win32( RageMutex *pParent ):
MutexImpl( pParent )
{
@@ -200,7 +199,7 @@ static bool SimpleWaitForSingleObject( HANDLE h, DWORD ms )
return false;
case WAIT_ABANDONED:
/* The docs aren't particular about what this does, but it should never happen. */
// The docs aren't particular about what this does, but it should never happen.
FAIL_M( "WAIT_ABANDONED" );
case WAIT_FAILED:
@@ -218,7 +217,7 @@ bool MutexImpl_Win32::Lock()
while( tries-- )
{
/* Wait for fifteen seconds. If it takes longer than that, we're probably deadlocked. */
// Wait for fifteen seconds. If it takes longer than that, we're probably deadlocked.
if( SimpleWaitForSingleObject( mutex, len ) )
return true;
@@ -275,7 +274,7 @@ EventImpl_Win32::~EventImpl_Win32()
{
ASSERT_M( m_iNumWaiting == 0, ssprintf("event destroyed while still in use (%i)", m_iNumWaiting) );
/* We don't own m_pParent; don't free it. */
// We don't own m_pParent; don't free it.
CloseHandle( m_WakeupSema );
DeleteCriticalSection( &m_iNumWaitingLock );
CloseHandle( m_WaitersDone );
@@ -288,7 +287,7 @@ EventImpl_Win32::~EventImpl_Win32()
static bool PortableSignalObjectAndWait( HANDLE hObjectToSignal, HANDLE hObjectToWaitOn, bool bFirstParamIsMutex, unsigned iMilliseconds = INFINITE )
{
static bool bSignalObjectAndWaitUnavailable = false;
/* Watch out: SignalObjectAndWait doesn't work when iMilliseconds is zero. */
// Watch out: SignalObjectAndWait doesn't work when iMilliseconds is zero.
if( !bSignalObjectAndWaitUnavailable && iMilliseconds != 0 )
{
DWORD ret = SignalObjectAndWait( hObjectToSignal, hObjectToWaitOn, iMilliseconds, false );
@@ -298,14 +297,14 @@ static bool PortableSignalObjectAndWait( HANDLE hObjectToSignal, HANDLE hObjectT
return true;
case WAIT_ABANDONED:
/* The docs aren't particular about what this does, but it should never happen. */
// The docs aren't particular about what this does, but it should never happen.
FAIL_M( "WAIT_ABANDONED" );
case 1: /* bogus Win98 return value */
case 1: // bogus Win98 return value
case WAIT_FAILED:
if( GetLastError() == ERROR_CALL_NOT_IMPLEMENTED )
{
/* We're probably on 9x. */
// We're probably on 9x.
bSignalObjectAndWaitUnavailable = true;
break;
}
@@ -336,7 +335,7 @@ static bool PortableSignalObjectAndWait( HANDLE hObjectToSignal, HANDLE hObjectT
return true;
case WAIT_ABANDONED:
/* The docs aren't particular about what this does, but it should never happen. */
// The docs aren't particular about what this does, but it should never happen.
FAIL_M( "WAIT_ABANDONED" );
case WAIT_TIMEOUT:
@@ -347,7 +346,7 @@ static bool PortableSignalObjectAndWait( HANDLE hObjectToSignal, HANDLE hObjectT
}
}
/* Event logic from http://www.cs.wustl.edu/~schmidt/win32-cv-1.html. */
// Event logic from http://www.cs.wustl.edu/~schmidt/win32-cv-1.html.
bool EventImpl_Win32::Wait( RageTimer *pTimeout )
{
EnterCriticalSection( &m_iNumWaitingLock );
@@ -361,7 +360,7 @@ bool EventImpl_Win32::Wait( RageTimer *pTimeout )
iMilliseconds = (unsigned) max( 0, int( fSecondsInFuture * 1000 ) );
}
/* Unlock the mutex and wait for a signal. */
// Unlock the mutex and wait for a signal.
bool bSuccess = PortableSignalObjectAndWait( m_pParent->mutex, m_WakeupSema, true, iMilliseconds );
EnterCriticalSection( &m_iNumWaitingLock );
@@ -401,7 +400,7 @@ void EventImpl_Win32::Signal()
LeaveCriticalSection( &m_iNumWaitingLock );
/* The waiter will touch m_WaitersDone. */
// The waiter will touch m_WaitersDone.
WaitForSingleObject( m_WaitersDone, INFINITE );
}
@@ -419,8 +418,8 @@ void EventImpl_Win32::Broadcast()
LeaveCriticalSection( &m_iNumWaitingLock );
/* The last waiter will touch m_WaitersDone, so we wait for all waiters to wake up and
* start waiting for the mutex before returning. */
/* The last waiter will touch m_WaitersDone, so we wait for all waiters to
* wake up and start waiting for the mutex before returning. */
WaitForSingleObject( m_WaitersDone, INFINITE );
}
+1 -1
View File
@@ -73,7 +73,7 @@ public:
private:
HANDLE sem;
/* We have to track the count ourself, since Windows gives no way to query it. */
// We have to track the count ourself, since Windows gives no way to query it.
int m_iCounter;
};