Taseditor: combining consecutive AdjustLag operations

This commit is contained in:
ansstuff 2012-06-14 11:57:31 +00:00
parent 4474dc875d
commit 5a67cb3474
4 changed files with 149 additions and 85 deletions

View File

@ -103,8 +103,8 @@ char modCaptions[MODTYPES_TOTAL][20] = {" Initialization",
" LUA Marker Remove", " LUA Marker Remove",
" LUA Marker Rename", " LUA Marker Rename",
" LUA Change", " LUA Change",
" AdjustUp", " AdjustLag",
" AdjustDown" }; " AdjustLag" };
char LuaCaptionPrefix[6] = " LUA "; char LuaCaptionPrefix[6] = " LUA ";
char joypadCaptions[4][5] = {"(1P)", "(2P)", "(3P)", "(4P)"}; char joypadCaptions[4][5] = {"(1P)", "(2P)", "(3P)", "(4P)"};
@ -475,6 +475,7 @@ int HISTORY::RegisterChanges(int mod_type, int start, int end, const char* comme
// fill description: // fill description:
snap.mod_type = mod_type; snap.mod_type = mod_type;
strcat(snap.description, modCaptions[snap.mod_type]); strcat(snap.description, modCaptions[snap.mod_type]);
// set jump_frame
switch (mod_type) switch (mod_type)
{ {
case MODTYPE_SET: case MODTYPE_SET:
@ -499,21 +500,44 @@ int HISTORY::RegisterChanges(int mod_type, int start, int end, const char* comme
break; break;
} }
} }
snap.start_frame = start; // set start_frame, end_frame, consecutive_tag
snap.end_frame = end; if (snap.mod_type == MODTYPE_ADJUST_UP || snap.mod_type == MODTYPE_ADJUST_DOWN)
snap.consecutive_tag = consecutive_tag;
if (consecutive_tag && taseditor_config.combine_consecutive && snapshots[real_pos].mod_type == snap.mod_type && snapshots[real_pos].consecutive_tag == snap.consecutive_tag)
{ {
// combine with previous snapshot // special operation: AdjustLag
if (snap.jump_frame > snapshots[real_pos].jump_frame) snap.start_frame = snap.end_frame = start;
snap.jump_frame = snapshots[real_pos].jump_frame; if (snap.mod_type == MODTYPE_ADJUST_UP)
if (snap.start_frame > snapshots[real_pos].start_frame) snap.consecutive_tag = -1;
snap.start_frame = snapshots[real_pos].start_frame; else
if (snap.end_frame < snapshots[real_pos].end_frame) snap.consecutive_tag = 1;
snap.end_frame = snapshots[real_pos].end_frame; // combine Adjustment with previous snapshot if needed
// add upper and lower frame to description bool combine = false;
if (snapshots[real_pos].mod_type == MODTYPE_ADJUST_UP || snapshots[real_pos].mod_type == MODTYPE_ADJUST_DOWN)
combine = true;
if (combine)
{
if (snap.jump_frame > snapshots[real_pos].jump_frame)
snap.jump_frame = snapshots[real_pos].jump_frame;
if (snap.start_frame > snapshots[real_pos].start_frame)
snap.start_frame = snapshots[real_pos].start_frame;
if (snap.end_frame < snapshots[real_pos].end_frame)
snap.end_frame = snapshots[real_pos].end_frame;
snap.consecutive_tag += snapshots[real_pos].consecutive_tag;
}
// set hotchanges
if (taseditor_config.enable_hot_changes)
{
if (snap.mod_type == MODTYPE_ADJUST_UP)
snap.inheritHotChanges_DeleteNum(&snapshots[real_pos], start, 1, !combine);
else
snap.inheritHotChanges_InsertNum(&snapshots[real_pos], start, 1, !combine);
}
// add "consecutive_tag" to description
char framenum[11]; char framenum[11];
strcat(snap.description, " "); strcat(snap.description, " [");
_itoa(snap.consecutive_tag, framenum, 10);
strcat(snap.description, framenum);
strcat(snap.description, "] ");
// add upper and lower frame to description
_itoa(snap.start_frame, framenum, 10); _itoa(snap.start_frame, framenum, 10);
strcat(snap.description, framenum); strcat(snap.description, framenum);
if (snap.end_frame > snap.start_frame) if (snap.end_frame > snap.start_frame)
@ -528,72 +552,110 @@ int HISTORY::RegisterChanges(int mod_type, int start, int end, const char* comme
strcat(snap.description, " "); strcat(snap.description, " ");
strncat(snap.description, comment, SNAPSHOT_DESC_MAX_LENGTH - strlen(snap.description) - 1); strncat(snap.description, comment, SNAPSHOT_DESC_MAX_LENGTH - strlen(snap.description) - 1);
} }
// set hotchanges if (combine)
if (taseditor_config.enable_hot_changes)
{ {
snap.copyHotChanges(&snapshots[real_pos]); // replace current snapshot with this cloned snapshot and truncate history here
snap.fillHotChanges(snapshots[real_pos], first_changes, end); snapshots[real_pos] = snap;
history_total_items = history_cursor_pos+1;
UpdateHistoryList();
RedrawHistoryList();
} else
{
AddItemToHistory(snap);
} }
// replace current snapshot with this cloned snapshot and truncate history here
snapshots[real_pos] = snap;
history_total_items = history_cursor_pos+1;
UpdateHistoryList();
RedrawHistoryList();
} else } else
{ {
// don't combine // normal operations
// add upper and lower frame to description snap.start_frame = start;
char framenum[11]; snap.end_frame = end;
strcat(snap.description, " "); snap.consecutive_tag = consecutive_tag;
_itoa(snap.start_frame, framenum, 10); if (consecutive_tag && taseditor_config.combine_consecutive && snapshots[real_pos].mod_type == snap.mod_type && snapshots[real_pos].consecutive_tag == snap.consecutive_tag)
strcat(snap.description, framenum);
if (snap.end_frame > snap.start_frame)
{
strcat(snap.description, "-");
_itoa(snap.end_frame, framenum, 10);
strcat(snap.description, framenum);
}
// add comment if there is one specified
if (comment)
{ {
// combine Drawing with previous snapshot
if (snap.jump_frame > snapshots[real_pos].jump_frame)
snap.jump_frame = snapshots[real_pos].jump_frame;
if (snap.start_frame > snapshots[real_pos].start_frame)
snap.start_frame = snapshots[real_pos].start_frame;
if (snap.end_frame < snapshots[real_pos].end_frame)
snap.end_frame = snapshots[real_pos].end_frame;
// add upper and lower frame to description
char framenum[11];
strcat(snap.description, " "); strcat(snap.description, " ");
strncat(snap.description, comment, SNAPSHOT_DESC_MAX_LENGTH - strlen(snap.description) - 1); _itoa(snap.start_frame, framenum, 10);
} strcat(snap.description, framenum);
// set hotchanges if (snap.end_frame > snap.start_frame)
if (taseditor_config.enable_hot_changes)
{
// inherit previous hotchanges and set new changes
switch (mod_type)
{ {
case MODTYPE_DELETE: strcat(snap.description, "-");
snap.inheritHotChanges_DeleteSelection(&snapshots[real_pos]); _itoa(snap.end_frame, framenum, 10);
break; strcat(snap.description, framenum);
case MODTYPE_INSERT:
case MODTYPE_CLONE:
snap.inheritHotChanges_InsertSelection(&snapshots[real_pos]);
break;
case MODTYPE_ADJUST_UP:
snap.inheritHotChanges_DeleteNum(&snapshots[real_pos], start, 1);
break;
case MODTYPE_ADJUST_DOWN:
snap.inheritHotChanges_InsertNum(&snapshots[real_pos], start, 1);
break;
case MODTYPE_SET:
case MODTYPE_UNSET:
case MODTYPE_CLEAR:
case MODTYPE_CUT:
case MODTYPE_PASTE:
case MODTYPE_PATTERN:
snap.inheritHotChanges(&snapshots[real_pos]);
snap.fillHotChanges(snapshots[real_pos], first_changes, end);
break;
case MODTYPE_TRUNCATE:
snap.copyHotChanges(&snapshots[real_pos]);
// do not add new hotchanges and do not fade old hotchanges, because there was nothing added
break;
} }
// add comment if there is one specified
if (comment)
{
strcat(snap.description, " ");
strncat(snap.description, comment, SNAPSHOT_DESC_MAX_LENGTH - strlen(snap.description) - 1);
}
// set hotchanges
if (taseditor_config.enable_hot_changes)
{
snap.copyHotChanges(&snapshots[real_pos]);
snap.fillHotChanges(snapshots[real_pos], first_changes, end);
}
// replace current snapshot with this cloned snapshot and truncate history here
snapshots[real_pos] = snap;
history_total_items = history_cursor_pos+1;
UpdateHistoryList();
RedrawHistoryList();
} else
{
// don't combine
// add upper and lower frame to description
char framenum[11];
strcat(snap.description, " ");
_itoa(snap.start_frame, framenum, 10);
strcat(snap.description, framenum);
if (snap.end_frame > snap.start_frame)
{
strcat(snap.description, "-");
_itoa(snap.end_frame, framenum, 10);
strcat(snap.description, framenum);
}
// add comment if there is one specified
if (comment)
{
strcat(snap.description, " ");
strncat(snap.description, comment, SNAPSHOT_DESC_MAX_LENGTH - strlen(snap.description) - 1);
}
// set hotchanges
if (taseditor_config.enable_hot_changes)
{
// inherit previous hotchanges and set new changes
switch (mod_type)
{
case MODTYPE_DELETE:
snap.inheritHotChanges_DeleteSelection(&snapshots[real_pos]);
break;
case MODTYPE_INSERT:
case MODTYPE_CLONE:
snap.inheritHotChanges_InsertSelection(&snapshots[real_pos]);
break;
case MODTYPE_SET:
case MODTYPE_UNSET:
case MODTYPE_CLEAR:
case MODTYPE_CUT:
case MODTYPE_PASTE:
case MODTYPE_PATTERN:
snap.inheritHotChanges(&snapshots[real_pos]);
snap.fillHotChanges(snapshots[real_pos], first_changes, end);
break;
case MODTYPE_TRUNCATE:
snap.copyHotChanges(&snapshots[real_pos]);
// do not add new hotchanges and do not fade old hotchanges, because there was nothing added
break;
}
}
AddItemToHistory(snap);
} }
AddItemToHistory(snap);
} }
branches.ChangesMadeSinceBranch(); branches.ChangesMadeSinceBranch();
} }
@ -626,7 +688,7 @@ int HISTORY::RegisterInsertNum(int start, int frames)
strcat(snap.description, framenum); strcat(snap.description, framenum);
// set hotchanges // set hotchanges
if (taseditor_config.enable_hot_changes) if (taseditor_config.enable_hot_changes)
snap.inheritHotChanges_InsertNum(&snapshots[real_pos], start, frames); snap.inheritHotChanges_InsertNum(&snapshots[real_pos], start, frames, true);
AddItemToHistory(snap); AddItemToHistory(snap);
branches.ChangesMadeSinceBranch(); branches.ChangesMadeSinceBranch();
} }

View File

@ -112,9 +112,9 @@ enum DRAG_MODES
#define PALE_GREENZONE_INPUT_COLOR1 0xD3F9D2 #define PALE_GREENZONE_INPUT_COLOR1 0xD3F9D2
#define PALE_GREENZONE_INPUT_COLOR2 0xBAEBBA #define PALE_GREENZONE_INPUT_COLOR2 0xBAEBBA
#define VERY_PALE_GREENZONE_FRAMENUM_COLOR 0xF2FFF2 #define VERY_PALE_GREENZONE_FRAMENUM_COLOR 0xF1FFF1
#define VERY_PALE_GREENZONE_INPUT_COLOR1 0xE9FCE9 #define VERY_PALE_GREENZONE_INPUT_COLOR1 0xE7FCE7
#define VERY_PALE_GREENZONE_INPUT_COLOR2 0xDDF5DD #define VERY_PALE_GREENZONE_INPUT_COLOR2 0xD9F4D9
#define LAG_FRAMENUM_COLOR 0xDDDCFF #define LAG_FRAMENUM_COLOR 0xDDDCFF
#define LAG_INPUT_COLOR1 0xD2D0F0 #define LAG_INPUT_COLOR1 0xD2D0F0
@ -124,9 +124,9 @@ enum DRAG_MODES
#define PALE_LAG_INPUT_COLOR1 0xDADAF4 #define PALE_LAG_INPUT_COLOR1 0xDADAF4
#define PALE_LAG_INPUT_COLOR2 0xCFCEEA #define PALE_LAG_INPUT_COLOR2 0xCFCEEA
#define VERY_PALE_LAG_FRAMENUM_COLOR 0xF1F1FF #define VERY_PALE_LAG_FRAMENUM_COLOR 0xF0F0FF
#define VERY_PALE_LAG_INPUT_COLOR1 0xEDEDFA #define VERY_PALE_LAG_INPUT_COLOR1 0xEBEBF9
#define VERY_PALE_LAG_INPUT_COLOR2 0xE7E7F5 #define VERY_PALE_LAG_INPUT_COLOR2 0xE5E5F3
#define CUR_FRAMENUM_COLOR 0xFCF1CE #define CUR_FRAMENUM_COLOR 0xFCF1CE
#define CUR_INPUT_COLOR1 0xF8EBB6 #define CUR_INPUT_COLOR1 0xF8EBB6

View File

@ -690,7 +690,7 @@ void SNAPSHOT::inheritHotChanges_InsertSelection(SNAPSHOT* source_of_hotchanges)
} }
} }
} }
void SNAPSHOT::inheritHotChanges_DeleteNum(SNAPSHOT* source_of_hotchanges, int start, int frames) void SNAPSHOT::inheritHotChanges_DeleteNum(SNAPSHOT* source_of_hotchanges, int start, int frames, bool fade_old)
{ {
int bytes = joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY; int bytes = joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
// copy hot changes from source snapshot up to "start" and from "start+frames" to end // copy hot changes from source snapshot up to "start" and from "start+frames" to end
@ -708,10 +708,11 @@ void SNAPSHOT::inheritHotChanges_DeleteNum(SNAPSHOT* source_of_hotchanges, int s
if (bytes_to_copy > source_size - source_pos) if (bytes_to_copy > source_size - source_pos)
bytes_to_copy = source_size - source_pos; bytes_to_copy = source_size - source_pos;
memcpy(&hot_changes[dest_pos], &source_of_hotchanges->hot_changes[source_pos], bytes_to_copy); memcpy(&hot_changes[dest_pos], &source_of_hotchanges->hot_changes[source_pos], bytes_to_copy);
FadeHotChanges(); if (fade_old)
FadeHotChanges();
} }
} }
void SNAPSHOT::inheritHotChanges_InsertNum(SNAPSHOT* source_of_hotchanges, int start, int frames) void SNAPSHOT::inheritHotChanges_InsertNum(SNAPSHOT* source_of_hotchanges, int start, int frames, bool fade_old)
{ {
int bytes = joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY; int bytes = joysticks_per_frame[input_type] * HOTCHANGE_BYTES_PER_JOY;
// copy hot changes from source snapshot up to "start", then make a gap, then copy from "start+frames" to end // copy hot changes from source snapshot up to "start", then make a gap, then copy from "start+frames" to end
@ -729,7 +730,8 @@ void SNAPSHOT::inheritHotChanges_InsertNum(SNAPSHOT* source_of_hotchanges, int s
if (bytes_to_copy > source_size - source_pos) if (bytes_to_copy > source_size - source_pos)
bytes_to_copy = source_size - source_pos; bytes_to_copy = source_size - source_pos;
memcpy(&hot_changes[dest_pos], &source_of_hotchanges->hot_changes[source_pos], bytes_to_copy); memcpy(&hot_changes[dest_pos], &source_of_hotchanges->hot_changes[source_pos], bytes_to_copy);
FadeHotChanges(); if (fade_old)
FadeHotChanges();
} }
// fill the gap with max_hot lines on frames from "start" to "start+frames" // fill the gap with max_hot lines on frames from "start" to "start+frames"
memset(&hot_changes[bytes * start], 0xFF, bytes * frames); memset(&hot_changes[bytes * start], 0xFF, bytes * frames);

View File

@ -49,8 +49,8 @@ public:
void inheritHotChanges(SNAPSHOT* source_of_hotchanges); void inheritHotChanges(SNAPSHOT* source_of_hotchanges);
void inheritHotChanges_DeleteSelection(SNAPSHOT* source_of_hotchanges); void inheritHotChanges_DeleteSelection(SNAPSHOT* source_of_hotchanges);
void inheritHotChanges_InsertSelection(SNAPSHOT* source_of_hotchanges); void inheritHotChanges_InsertSelection(SNAPSHOT* source_of_hotchanges);
void inheritHotChanges_DeleteNum(SNAPSHOT* source_of_hotchanges, int start, int frames); void inheritHotChanges_DeleteNum(SNAPSHOT* source_of_hotchanges, int start, int frames, bool fade_old);
void inheritHotChanges_InsertNum(SNAPSHOT* source_of_hotchanges, int start, int frames); void inheritHotChanges_InsertNum(SNAPSHOT* source_of_hotchanges, int start, int frames, bool fade_old);
void inheritHotChanges_PasteInsert(SNAPSHOT* source_of_hotchanges, SelectionFrames& inserted_set); void inheritHotChanges_PasteInsert(SNAPSHOT* source_of_hotchanges, SelectionFrames& inserted_set);
void fillHotChanges(SNAPSHOT& snap, int start = 0, int end = -1); void fillHotChanges(SNAPSHOT& snap, int start = 0, int end = -1);