Files
itgmania212121/stepmania/src/ScreenEdit.h
T

514 lines
12 KiB
C++
Raw Normal View History

2004-06-08 05:22:33 +00:00
/* ScreenEdit - Edit, record, playback, and synchronize notes. */
2002-05-20 08:59:37 +00:00
2004-06-08 05:22:33 +00:00
#ifndef SCREEN_EDIT_H
#define SCREEN_EDIT_H
2002-05-20 08:59:37 +00:00
#include "ScreenWithMenuElements.h"
2002-05-20 08:59:37 +00:00
#include "BitmapText.h"
#include "Player.h"
#include "RageSound.h"
#include "SnapDisplay.h"
#include "Background.h"
#include "Foreground.h"
2005-01-25 18:29:42 +00:00
#include "NoteField.h"
2005-03-08 21:19:17 +00:00
#include "song.h"
#include "Steps.h"
2005-03-12 23:27:48 +00:00
#include "ThemeMetric.h"
#include "PlayerState.h"
2007-01-13 03:34:32 +00:00
#include "GameInput.h"
#include "GameplayAssist.h"
2007-04-24 05:42:44 +00:00
#include "AutoKeysounds.h"
2002-05-20 08:59:37 +00:00
#include <map>
const int NUM_EDIT_BUTTON_COLUMNS = 10;
2005-07-14 04:59:06 +00:00
struct MenuDef;
2006-03-11 21:32:29 +00:00
enum EditState
{
STATE_EDITING,
STATE_RECORDING,
STATE_RECORDING_PAUSED,
STATE_PLAYING,
2006-09-26 20:41:53 +00:00
NUM_EditState,
EditState_Invalid
};
enum EditButton
{
EDIT_BUTTON_COLUMN_0,
EDIT_BUTTON_COLUMN_1,
EDIT_BUTTON_COLUMN_2,
EDIT_BUTTON_COLUMN_3,
EDIT_BUTTON_COLUMN_4,
EDIT_BUTTON_COLUMN_5,
EDIT_BUTTON_COLUMN_6,
EDIT_BUTTON_COLUMN_7,
EDIT_BUTTON_COLUMN_8,
EDIT_BUTTON_COLUMN_9,
/* These are modifiers to EDIT_BUTTON_COLUMN_*. */
EDIT_BUTTON_RIGHT_SIDE,
2005-04-18 01:23:57 +00:00
EDIT_BUTTON_LAY_MINE_OR_ROLL,
2005-08-30 18:09:00 +00:00
EDIT_BUTTON_LAY_TAP_ATTACK,
2006-08-19 21:17:58 +00:00
EDIT_BUTTON_LAY_LIFT,
2005-07-30 07:07:11 +00:00
EDIT_BUTTON_REMOVE_NOTE,
EDIT_BUTTON_SCROLL_UP_LINE,
EDIT_BUTTON_SCROLL_UP_PAGE,
EDIT_BUTTON_SCROLL_DOWN_LINE,
EDIT_BUTTON_SCROLL_DOWN_PAGE,
EDIT_BUTTON_SCROLL_NEXT_MEASURE,
EDIT_BUTTON_SCROLL_PREV_MEASURE,
EDIT_BUTTON_SCROLL_HOME,
EDIT_BUTTON_SCROLL_END,
EDIT_BUTTON_SCROLL_NEXT,
EDIT_BUTTON_SCROLL_PREV,
/* These are modifiers to EDIT_BUTTON_SCROLL_*. */
EDIT_BUTTON_SCROLL_SELECT,
EDIT_BUTTON_LAY_SELECT,
EDIT_BUTTON_SCROLL_SPEED_UP,
EDIT_BUTTON_SCROLL_SPEED_DOWN,
EDIT_BUTTON_SNAP_NEXT,
EDIT_BUTTON_SNAP_PREV,
EDIT_BUTTON_OPEN_EDIT_MENU,
EDIT_BUTTON_OPEN_AREA_MENU,
EDIT_BUTTON_OPEN_BGCHANGE_LAYER1_MENU,
EDIT_BUTTON_OPEN_BGCHANGE_LAYER2_MENU,
EDIT_BUTTON_OPEN_COURSE_MENU,
2005-08-30 18:09:00 +00:00
EDIT_BUTTON_OPEN_COURSE_ATTACK_MENU,
EDIT_BUTTON_OPEN_INPUT_HELP,
2005-06-07 09:42:57 +00:00
EDIT_BUTTON_BAKE_RANDOM_FROM_SONG_GROUP,
EDIT_BUTTON_BAKE_RANDOM_FROM_SONG_GROUP_AND_GENRE,
EDIT_BUTTON_PLAY_FROM_START,
EDIT_BUTTON_PLAY_FROM_CURSOR,
EDIT_BUTTON_PLAY_SELECTION,
EDIT_BUTTON_RECORD_FROM_CURSOR,
EDIT_BUTTON_RECORD_SELECTION,
EDIT_BUTTON_RETURN_TO_EDIT,
EDIT_BUTTON_INSERT,
EDIT_BUTTON_DELETE,
EDIT_BUTTON_INSERT_SHIFT_PAUSES,
EDIT_BUTTON_DELETE_SHIFT_PAUSES,
EDIT_BUTTON_OPEN_NEXT_STEPS,
EDIT_BUTTON_OPEN_PREV_STEPS,
EDIT_BUTTON_PLAY_SAMPLE_MUSIC,
EDIT_BUTTON_BPM_UP,
EDIT_BUTTON_BPM_DOWN,
EDIT_BUTTON_STOP_UP,
EDIT_BUTTON_STOP_DOWN,
EDIT_BUTTON_OFFSET_UP,
EDIT_BUTTON_OFFSET_DOWN,
EDIT_BUTTON_SAMPLE_START_UP,
EDIT_BUTTON_SAMPLE_START_DOWN,
EDIT_BUTTON_SAMPLE_LENGTH_UP,
EDIT_BUTTON_SAMPLE_LENGTH_DOWN,
/* This modifies offset, BPM, and stop segment changes. */
EDIT_BUTTON_ADJUST_FINE,
2005-05-17 07:24:25 +00:00
EDIT_BUTTON_UNDO,
2006-03-14 08:41:16 +00:00
EDIT_BUTTON_ADD_COURSE_MODS,
2006-08-01 08:28:19 +00:00
EDIT_BUTTON_SWITCH_PLAYERS,
2005-05-17 07:24:25 +00:00
2006-09-27 04:37:01 +00:00
NUM_EditButton, // leave this at the end
EditButton_Invalid
};
2006-10-07 08:56:58 +00:00
#define FOREACH_EditButton( e ) FOREACH_ENUM( EditButton, e )
const int NUM_EDIT_TO_DEVICE_SLOTS = 2;
const int NUM_EDIT_TO_MENU_SLOTS = 2;
2005-01-15 13:14:36 +00:00
/*
* g_MapEditToDI is a simple mapping: edit functions map to DeviceInputs.
* If g_MapEditToDIHold for a given edit function is valid, then at least one
* input in g_MapEditToDIHold must be held when pressing any key in g_MapEditToDI
* for the input to occur.
*/
struct MapEditToDI
{
2006-09-27 04:37:01 +00:00
DeviceInput button[NUM_EditButton][NUM_EDIT_TO_DEVICE_SLOTS];
DeviceInput hold[NUM_EditButton][NUM_EDIT_TO_DEVICE_SLOTS];
2005-01-15 13:14:36 +00:00
void Clear()
{
FOREACH_EditButton(e)
for( int slot = 0; slot < NUM_EDIT_TO_DEVICE_SLOTS; ++slot )
{
button[e][slot].MakeInvalid();
hold[e][slot].MakeInvalid();
}
}
};
2002-08-17 06:44:04 +00:00
2007-01-13 03:44:16 +00:00
// Like MapEditToDI, but maps GameButton instead of DeviceInput.
struct MapEditButtonToMenuButton
{
2007-01-13 03:44:16 +00:00
GameButton button[NUM_EditButton][NUM_EDIT_TO_MENU_SLOTS];
void Clear()
{
FOREACH_EditButton(e)
for( int slot = 0; slot < NUM_EDIT_TO_MENU_SLOTS; ++slot )
2007-01-13 03:44:16 +00:00
button[e][slot] = GameButton_Invalid;
}
};
class ScreenEdit : public ScreenWithMenuElements
2002-05-20 08:59:37 +00:00
{
public:
virtual void Init();
2006-03-16 07:35:47 +00:00
virtual void BeginScreen();
virtual void EndScreen();
2002-05-20 08:59:37 +00:00
virtual ~ScreenEdit();
virtual void Update( float fDeltaTime );
virtual void DrawPrimitives();
virtual void Input( const InputEventPlus &input );
void InputEdit( const InputEventPlus &input, EditButton EditB );
void InputRecord( const InputEventPlus &input, EditButton EditB );
void InputRecordPaused( const InputEventPlus &input, EditButton EditB );
void InputPlay( const InputEventPlus &input, EditButton EditB );
2006-11-13 23:11:25 +00:00
virtual void HandleMessage( const Message &msg );
2002-05-20 08:59:37 +00:00
virtual void HandleScreenMessage( const ScreenMessage SM );
void SetDirty( bool bDirty ) { m_bDirty = bDirty; }
bool IsDirty() const { return m_bDirty; }
2002-05-20 08:59:37 +00:00
protected:
virtual ScreenType GetScreenType() const { return m_EditState==STATE_PLAYING ? gameplay : ScreenWithMenuElements::GetScreenType(); }
2005-05-19 23:29:39 +00:00
2005-04-14 06:34:17 +00:00
void TransitionEditState( EditState em );
2005-07-21 22:31:09 +00:00
void ScrollTo( float fDestinationBeat );
2004-01-12 09:36:01 +00:00
void PlayTicks();
2003-03-05 02:38:17 +00:00
void PlayPreviewMusic();
2005-03-23 10:43:57 +00:00
// Call this before modifying m_NoteDataEdit.
void SaveUndo();
// Revert m_NoteDataEdit using m_Undo.
void Undo();
void ClearUndo();
2005-03-23 10:43:57 +00:00
// Call this after modifying m_NoteDataEdit. It will Undo() if
// MAX_NOTES_PER_MEASURE was exceeded.
void CheckNumberOfNotesAndUndo();
2002-05-20 08:59:37 +00:00
void OnSnapModeChange();
float GetMaximumBeatForNewNote() const; // don't allow Down key to go past this beat.
float GetMaximumBeatForMoving() const; // don't allow Down key to go past this beat.
2006-03-16 20:59:15 +00:00
void DoHelp();
2005-04-14 06:34:17 +00:00
EditState m_EditState;
2002-05-20 08:59:37 +00:00
Song* m_pSong;
2004-05-24 03:41:39 +00:00
Steps* m_pSteps;
2002-05-20 08:59:37 +00:00
2006-07-30 23:45:55 +00:00
PlayerNumber m_InputPlayerNumber;
PlayerState m_PlayerStateEdit;
2002-10-08 00:39:31 +00:00
NoteField m_NoteFieldEdit;
NoteData m_NoteDataEdit;
2002-10-08 00:39:31 +00:00
SnapDisplay m_SnapDisplay;
2002-05-20 08:59:37 +00:00
2005-03-20 07:11:23 +00:00
BitmapText m_textInputTips;
2005-04-01 08:34:23 +00:00
void UpdateTextInfo();
2003-02-18 23:15:38 +00:00
BitmapText m_textInfo; // status information that changes
2005-04-01 08:34:23 +00:00
bool m_bTextInfoNeedsUpdate;
BitmapText m_textPlayRecordHelp;
2002-05-20 08:59:37 +00:00
// keep track of where we are and what we're doing
2006-01-30 02:53:18 +00:00
float m_fTrailingBeat; // this approaches GAMESTATE->m_fSongBeat, which is the actual beat
/* The location we were at when shift was pressed, or
* -1 when shift isn't pressed: */
2006-03-11 21:32:29 +00:00
int m_iShiftAnchor;
2002-05-20 08:59:37 +00:00
2006-01-30 02:53:18 +00:00
NoteData m_Clipboard;
bool m_bHasUndo;
2006-01-30 02:53:18 +00:00
NoteData m_Undo;
2002-05-20 08:59:37 +00:00
bool m_bDirty;
2006-01-30 02:53:18 +00:00
RageSound m_soundAddNote;
RageSound m_soundRemoveNote;
RageSound m_soundChangeLine;
RageSound m_soundChangeSnap;
RageSound m_soundMarker;
2006-02-04 18:35:29 +00:00
RageSound m_soundValueIncrease;
RageSound m_soundValueDecrease;
2006-02-03 19:24:39 +00:00
RageSound m_soundSwitchSteps;
2006-01-30 02:53:18 +00:00
RageSound m_soundSave;
2002-05-20 08:59:37 +00:00
2005-03-08 21:19:17 +00:00
// used for reverting
void CopyToLastSave();
void CopyFromLastSave();
2005-05-18 03:31:36 +00:00
void RevertFromDisk();
2005-03-08 21:19:17 +00:00
Song m_SongLastSave;
map< Difficulty, Steps > m_mStepsLastSave;
2006-11-12 03:26:25 +00:00
2002-05-20 08:59:37 +00:00
// for MODE_RECORD
2002-06-29 11:59:09 +00:00
NoteField m_NoteFieldRecord;
NoteData m_NoteDataRecord;
2005-07-30 07:07:11 +00:00
RageTimer m_RemoveNoteButtonLastChanged;
bool m_bRemoveNoteButtonDown;
2002-05-20 08:59:37 +00:00
// for MODE_PLAY
2004-01-26 20:56:58 +00:00
void SetupCourseAttacks();
PlayerPlus m_Player;
Background m_Background;
Foreground m_Foreground;
bool m_bReturnToRecordMenuAfterPlay;
2002-05-20 08:59:37 +00:00
// for MODE_RECORD and MODE_PLAY
2006-01-30 02:53:18 +00:00
int m_iStartPlayingAt, m_iStopPlayingAt;
float m_fBeatToReturnTo;
2002-05-20 08:59:37 +00:00
2007-04-24 05:42:44 +00:00
AutoKeysounds m_AutoKeysounds;
RageSound *m_pSoundMusic;
GameplayAssist m_GameplayAssist;
2006-09-26 03:19:37 +00:00
ThemeMetric<EditMode> EDIT_MODE;
2003-02-18 23:15:38 +00:00
public:
2006-03-11 21:32:29 +00:00
enum MainMenuChoice
{
2006-03-07 20:43:40 +00:00
play_selection,
set_selection_start,
set_selection_end,
2005-03-20 20:13:27 +00:00
edit_steps_information,
2003-02-18 23:15:38 +00:00
play_whole_song,
play_selection_start_to_end,
play_current_beat_to_end,
2003-02-18 23:15:38 +00:00
save,
2005-03-08 21:19:17 +00:00
revert_to_last_save,
2005-05-18 03:31:36 +00:00
revert_from_disk,
2005-07-20 00:30:19 +00:00
options,
2003-02-18 23:15:38 +00:00
edit_song_info,
edit_bpm,
edit_stop,
2003-02-18 23:15:38 +00:00
play_preview_music,
exit,
save_on_exit,
2005-03-14 05:42:07 +00:00
NUM_MAIN_MENU_CHOICES,
MAIN_MENU_CHOICE_INVALID
2003-02-18 23:15:38 +00:00
};
2005-03-20 06:41:56 +00:00
void HandleMainMenuChoice( MainMenuChoice c, const vector<int> &iAnswers );
void HandleMainMenuChoice( MainMenuChoice c ) { const vector<int> v; HandleMainMenuChoice( c, v ); }
2005-03-14 05:42:07 +00:00
MainMenuChoice m_CurrentAction;
2003-02-18 23:15:38 +00:00
2006-03-11 21:32:29 +00:00
enum AreaMenuChoice
{
2003-02-18 23:15:38 +00:00
cut,
copy,
2003-02-22 00:48:38 +00:00
paste_at_current_beat,
paste_at_begin_marker,
2003-02-18 23:15:38 +00:00
clear,
quantize,
2003-03-13 09:20:21 +00:00
turn,
2003-02-18 23:15:38 +00:00
transform,
alter,
2003-09-07 22:28:46 +00:00
tempo,
2003-02-18 23:15:38 +00:00
play,
record,
insert_and_shift,
delete_and_shift,
shift_pauses_forward,
shift_pauses_backward,
convert_to_pause,
2003-11-03 08:44:49 +00:00
convert_pause_to_beat,
2005-03-23 10:43:57 +00:00
undo,
2003-02-18 23:15:38 +00:00
NUM_AREA_MENU_CHOICES
};
2005-03-23 10:43:57 +00:00
void HandleAreaMenuChoice( AreaMenuChoice c, const vector<int> &iAnswers, bool bAllowUndo = true );
void HandleAreaMenuChoice( AreaMenuChoice c, bool bAllowUndo = true ) { const vector<int> v; HandleAreaMenuChoice( c, v, bAllowUndo ); }
2005-03-07 19:45:45 +00:00
enum TurnType
{
left,
right,
mirror,
shuffle,
super_shuffle,
NUM_TURN_TYPES
};
enum TransformType
{
noholds,
nomines,
little,
wide,
big,
quick,
skippy,
2005-03-20 20:13:27 +00:00
add_mines,
2005-03-07 19:45:45 +00:00
echo,
stomp,
planted,
floored,
twister,
nojumps,
nohands,
noquads,
nostretch,
2005-03-07 19:45:45 +00:00
NUM_TRANSFORM_TYPES
};
enum AlterType
2005-03-25 09:36:08 +00:00
{
autogen_to_fill_width,
2005-03-07 19:45:45 +00:00
backwards,
swap_sides,
copy_left_to_right,
copy_right_to_left,
clear_left,
clear_right,
collapse_to_one,
collapse_left,
shift_left,
shift_right,
NUM_ALTER_TYPES
};
enum TempoType
{
compress_2x,
compress_3_2,
compress_4_3,
expand_4_3,
expand_3_2,
expand_2x,
NUM_TEMPO_TYPES
};
2003-02-18 23:15:38 +00:00
2006-03-11 21:32:29 +00:00
enum StepsInformationChoice
{
2003-02-18 23:15:38 +00:00
difficulty,
meter,
description,
predict_meter,
2003-02-18 23:15:38 +00:00
tap_notes,
2005-03-20 20:13:27 +00:00
jumps,
hands,
quads,
holds,
mines,
2003-02-18 23:15:38 +00:00
stream,
voltage,
air,
freeze,
chaos,
2005-03-20 20:13:27 +00:00
NUM_STEPS_INFORMATION_CHOICES
2003-02-18 23:15:38 +00:00
};
2005-03-20 20:13:27 +00:00
void HandleStepsInformationChoice( StepsInformationChoice c, const vector<int> &iAnswers );
2003-02-18 23:15:38 +00:00
2006-03-11 21:32:29 +00:00
enum SongInformationChoice
{
2003-02-18 23:15:38 +00:00
main_title,
sub_title,
artist,
2003-06-23 02:24:13 +00:00
credit,
2003-02-18 23:15:38 +00:00
main_title_transliteration,
sub_title_transliteration,
artist_transliteration,
last_beat_hint,
2005-03-20 20:13:27 +00:00
NUM_SONG_INFORMATION_CHOICES
2003-02-18 23:15:38 +00:00
};
2005-03-20 20:13:27 +00:00
void HandleSongInformationChoice( SongInformationChoice c, const vector<int> &iAnswers );
2003-02-18 23:15:38 +00:00
2006-03-11 21:32:29 +00:00
enum BGChangeChoice
{
2005-05-26 09:35:57 +00:00
layer,
rate,
transition,
effect,
2005-06-05 22:21:55 +00:00
color1,
color2,
file1_type,
file1_song_bganimation,
file1_song_movie,
file1_song_still,
file1_global_bganimation,
file1_global_movie,
file1_global_movie_song_group,
file1_global_movie_song_group_and_genre,
file2_type,
file2_song_bganimation,
file2_song_movie,
file2_song_still,
file2_global_bganimation,
file2_global_movie,
file2_global_movie_song_group,
file2_global_movie_song_group_and_genre,
delete_change,
NUM_BGCHANGE_CHOICES
};
2005-03-20 06:41:56 +00:00
void HandleBGChangeChoice( BGChangeChoice c, const vector<int> &iAnswers );
2006-03-11 21:32:29 +00:00
enum CourseAttackChoice
{
2005-08-30 18:09:00 +00:00
duration,
set_mods,
remove,
NUM_CourseAttackChoice
};
2005-01-15 13:14:36 +00:00
void InitEditMappings();
2006-09-14 21:02:14 +00:00
EditButton DeviceToEdit( const DeviceInput &DeviceI ) const;
2007-01-13 03:44:16 +00:00
EditButton MenuButtonToEditButton( GameButton MenuI ) const;
2005-01-15 18:33:09 +00:00
bool EditToDevice( EditButton button, int iSlotNum, DeviceInput &DeviceI ) const;
2005-01-23 23:49:19 +00:00
bool EditPressed( EditButton button, const DeviceInput &DeviceI );
2005-01-15 18:33:09 +00:00
bool EditIsBeingPressed( EditButton button ) const;
const MapEditToDI *GetCurrentDeviceInputMap() const;
const MapEditButtonToMenuButton *GetCurrentMenuButtonMap() const;
2006-03-11 21:32:29 +00:00
MapEditToDI m_EditMappingsDeviceInput;
MapEditToDI m_PlayMappingsDeviceInput;
MapEditToDI m_RecordMappingsDeviceInput;
MapEditToDI m_RecordPausedMappingsDeviceInput;
MapEditButtonToMenuButton m_EditMappingsMenuButton;
MapEditButtonToMenuButton m_PlayMappingsMenuButton;
MapEditButtonToMenuButton m_RecordMappingsMenuButton;
MapEditButtonToMenuButton m_RecordPausedMappingsMenuButton;
2005-07-19 21:43:12 +00:00
void MakeFilteredMenuDef( const MenuDef* pDef, MenuDef &menu );
void EditMiniMenu( const MenuDef* pDef, ScreenMessage SM_SendOnOK = SM_None, ScreenMessage SM_SendOnCancel = SM_None );
2002-05-20 08:59:37 +00:00
};
2004-06-08 05:22:33 +00:00
#endif
2002-05-20 08:59:37 +00:00
2004-06-08 05:22:33 +00:00
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/