diff --git a/src/drivers/win/taseditor/history.cpp b/src/drivers/win/taseditor/history.cpp index 248a5639..9342f06d 100644 --- a/src/drivers/win/taseditor/history.cpp +++ b/src/drivers/win/taseditor/history.cpp @@ -103,8 +103,8 @@ char modCaptions[MODTYPES_TOTAL][20] = {" Initialization", " LUA Marker Remove", " LUA Marker Rename", " LUA Change", - " AdjustUp", - " AdjustDown" }; + " AdjustLag", + " AdjustLag" }; char LuaCaptionPrefix[6] = " LUA "; 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: snap.mod_type = mod_type; strcat(snap.description, modCaptions[snap.mod_type]); + // set jump_frame switch (mod_type) { case MODTYPE_SET: @@ -499,21 +500,44 @@ int HISTORY::RegisterChanges(int mod_type, int start, int end, const char* comme break; } } - snap.start_frame = start; - snap.end_frame = end; - 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) + // set start_frame, end_frame, consecutive_tag + if (snap.mod_type == MODTYPE_ADJUST_UP || snap.mod_type == MODTYPE_ADJUST_DOWN) { - // combine 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 + // special operation: AdjustLag + snap.start_frame = snap.end_frame = start; + if (snap.mod_type == MODTYPE_ADJUST_UP) + snap.consecutive_tag = -1; + else + snap.consecutive_tag = 1; + // combine Adjustment with previous snapshot if needed + 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]; - 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); strcat(snap.description, framenum); 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, " "); strncat(snap.description, comment, SNAPSHOT_DESC_MAX_LENGTH - strlen(snap.description) - 1); } - // set hotchanges - if (taseditor_config.enable_hot_changes) + if (combine) { - 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 + { + 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 { - // 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) + // normal operations + snap.start_frame = start; + snap.end_frame = end; + 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 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, " "); - 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) + _itoa(snap.start_frame, framenum, 10); + strcat(snap.description, framenum); + if (snap.end_frame > snap.start_frame) { - 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_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; + 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) + { + 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(); } @@ -626,7 +688,7 @@ int HISTORY::RegisterInsertNum(int start, int frames) strcat(snap.description, framenum); // set hotchanges 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); branches.ChangesMadeSinceBranch(); } diff --git a/src/drivers/win/taseditor/piano_roll.h b/src/drivers/win/taseditor/piano_roll.h index eccff744..cea683d0 100644 --- a/src/drivers/win/taseditor/piano_roll.h +++ b/src/drivers/win/taseditor/piano_roll.h @@ -112,9 +112,9 @@ enum DRAG_MODES #define PALE_GREENZONE_INPUT_COLOR1 0xD3F9D2 #define PALE_GREENZONE_INPUT_COLOR2 0xBAEBBA -#define VERY_PALE_GREENZONE_FRAMENUM_COLOR 0xF2FFF2 -#define VERY_PALE_GREENZONE_INPUT_COLOR1 0xE9FCE9 -#define VERY_PALE_GREENZONE_INPUT_COLOR2 0xDDF5DD +#define VERY_PALE_GREENZONE_FRAMENUM_COLOR 0xF1FFF1 +#define VERY_PALE_GREENZONE_INPUT_COLOR1 0xE7FCE7 +#define VERY_PALE_GREENZONE_INPUT_COLOR2 0xD9F4D9 #define LAG_FRAMENUM_COLOR 0xDDDCFF #define LAG_INPUT_COLOR1 0xD2D0F0 @@ -124,9 +124,9 @@ enum DRAG_MODES #define PALE_LAG_INPUT_COLOR1 0xDADAF4 #define PALE_LAG_INPUT_COLOR2 0xCFCEEA -#define VERY_PALE_LAG_FRAMENUM_COLOR 0xF1F1FF -#define VERY_PALE_LAG_INPUT_COLOR1 0xEDEDFA -#define VERY_PALE_LAG_INPUT_COLOR2 0xE7E7F5 +#define VERY_PALE_LAG_FRAMENUM_COLOR 0xF0F0FF +#define VERY_PALE_LAG_INPUT_COLOR1 0xEBEBF9 +#define VERY_PALE_LAG_INPUT_COLOR2 0xE5E5F3 #define CUR_FRAMENUM_COLOR 0xFCF1CE #define CUR_INPUT_COLOR1 0xF8EBB6 diff --git a/src/drivers/win/taseditor/snapshot.cpp b/src/drivers/win/taseditor/snapshot.cpp index 0ae1aa79..e011eb95 100644 --- a/src/drivers/win/taseditor/snapshot.cpp +++ b/src/drivers/win/taseditor/snapshot.cpp @@ -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; // 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) bytes_to_copy = source_size - source_pos; 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; // 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) bytes_to_copy = source_size - source_pos; 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" memset(&hot_changes[bytes * start], 0xFF, bytes * frames); diff --git a/src/drivers/win/taseditor/snapshot.h b/src/drivers/win/taseditor/snapshot.h index e6548fb3..4b8ee042 100644 --- a/src/drivers/win/taseditor/snapshot.h +++ b/src/drivers/win/taseditor/snapshot.h @@ -49,8 +49,8 @@ public: void inheritHotChanges(SNAPSHOT* source_of_hotchanges); void inheritHotChanges_DeleteSelection(SNAPSHOT* source_of_hotchanges); void inheritHotChanges_InsertSelection(SNAPSHOT* source_of_hotchanges); - void inheritHotChanges_DeleteNum(SNAPSHOT* source_of_hotchanges, int start, int frames); - void inheritHotChanges_InsertNum(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, bool fade_old); void inheritHotChanges_PasteInsert(SNAPSHOT* source_of_hotchanges, SelectionFrames& inserted_set); void fillHotChanges(SNAPSHOT& snap, int start = 0, int end = -1);