Skip to content

Commit

Permalink
Revert "bugs fixed?"
Browse files Browse the repository at this point in the history
This reverts commit 1e256fb.
  • Loading branch information
Fjara-h committed Apr 8, 2024
1 parent 1e256fb commit 83b7920
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 13 deletions.
Binary file added component/foo_skipcount-v2.0.4.fb2k-component
Binary file not shown.
Binary file removed component/foo_skipcount-v2.0.4b.fb2k-component
Binary file not shown.
Binary file modified component/foo_skipcount.dll
Binary file not shown.
Binary file modified component/x64/foo_skipcount.dll
Binary file not shown.
Binary file modified pdbs/foo_skipcount.pdb
Binary file not shown.
Binary file modified pdbs/x64/foo_skipcount.pdb
Binary file not shown.
4 changes: 2 additions & 2 deletions src/contextmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ namespace foo_skipcount {
}
}
if(writeMsg) {
pfc::stringLite skipTimes = getSkipTimesStr(recordWrite.skipTimes, false, true, false).c_str();
pfc::stringLite skipTimes = getSkipTimesStr(recordWrite.skipTimes, false, true, ", ", false).c_str();
if(skipTimes.get_length() > MAX_DISPLAY_LENGTH) {
skipTimes.truncate(MAX_DISPLAY_LENGTH);
skipTimes += "...";
Expand Down Expand Up @@ -655,7 +655,7 @@ namespace foo_skipcount {
info[i].meta_set(tagMetaFieldString.at("current").c_str(), std::to_string(getLocalTimestamp(filetimestamp_from_system_timer(), false)).c_str());
}
if(tagAllTimestampsRaw) {
info[i].meta_set(tagMetaFieldString.at("times").c_str(), getSkipTimesStr(record.skipTimes, false, false, false, tagTimestampDelimiters[tagDelimiter]).c_str());
info[i].meta_set(tagMetaFieldString.at("times").c_str(), getSkipTimesStr(record.skipTimes, false, false, tagTimestampDelimiters[tagDelimiter], false).c_str());
}
tmp += hash;
}
Expand Down
12 changes: 6 additions & 6 deletions src/fields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ namespace foo_skipcount {
case FIELD_LATEST_SKIP:
case FIELD_FIRST_SKIP:
case FIELD_OLDEST_SKIP: {
if(record.skipTimes.size() == 0) {
t_filetimestamp skip = (index == FIELD_LAST_SKIP || index == FIELD_LATEST_SKIP) ? getLatestSkip(record) : getOldestSkip(record);
if(skip == 0) {
out->write(titleformat_inputtypes::meta, "Never");
}
else {
t_filetimestamp skip = (index == FIELD_LAST_SKIP || index == FIELD_LATEST_SKIP) ? record.skipTimes.back() : record.skipTimes.front();
out->write(titleformat_inputtypes::meta, foobar2000_io::format_filetimestamp(skip));
}
break;
Expand All @@ -71,7 +71,7 @@ namespace foo_skipcount {
out->write(titleformat_inputtypes::meta, "[]");
}
else {
out->write(titleformat_inputtypes::meta, getSkipTimesStr(record.skipTimes, (index == FIELD_SKIP_TIMES_JS), (index == FIELD_SKIP_TIMES)).c_str());
out->write(titleformat_inputtypes::meta, getSkipTimesStr(record.skipTimes, (index == FIELD_SKIP_TIMES_JS), (index == FIELD_SKIP_TIMES), ", ", (index == FIELD_SKIP_TIMES_JS)).c_str());
}
break;
}
Expand Down Expand Up @@ -121,18 +121,18 @@ namespace foo_skipcount {
}

if(hashes.get_count() == 1 && !firstRecord.skipTimes.empty()) {
skipTimesStr = getSkipTimesStr(firstRecord.skipTimes, false, true).c_str();
skipTimesStr = getSkipTimesStr(firstRecord.skipTimes, false, true, ", ", true).c_str();
#define MAX_PROPERTY_LENGTH 500
if(skipTimesStr.get_length() > MAX_PROPERTY_LENGTH) {
skipTimesStr.truncate(MAX_PROPERTY_LENGTH);
skipTimesStr += "...";
}
skipTimesRawStr = getSkipTimesStr(firstRecord.skipTimes, false, false).c_str();
skipTimesRawStr = getSkipTimesStr(firstRecord.skipTimes, false, false, ", ", true).c_str();
if(skipTimesRawStr.get_length() > MAX_PROPERTY_LENGTH) {
skipTimesRawStr.truncate(MAX_PROPERTY_LENGTH);
skipTimesRawStr += "...";
}
skipTimesJSStr = getSkipTimesStr(firstRecord.skipTimes, true, false).c_str();
skipTimesJSStr = getSkipTimesStr(firstRecord.skipTimes, true, false, ", ", true).c_str();
if(skipTimesJSStr.get_length() > MAX_PROPERTY_LENGTH) {
skipTimesJSStr.truncate(MAX_PROPERTY_LENGTH);
skipTimesJSStr += "...";
Expand Down
20 changes: 15 additions & 5 deletions src/record.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,33 @@ namespace foo_skipcount {
}

inline static t_filetimestamp getLatestSkip(record_t record) {
return record.skipTimes.empty() ? 0 : record.skipTimes.back();
if((record.version > 1 && !record.skipTimes.empty())) {
return (record.skipTimes.size() == 1) ? record.skipTimes[0] : record.skipTimes.back();
}
else {
return 0;
}
}

inline static t_filetimestamp getOldestSkip(record_t record) {
return record.skipTimes.empty() ? 0 : record.skipTimes.front();
if((record.version > 1 && !record.skipTimes.empty())) {
return (record.skipTimes.size() == 1) ? record.skipTimes[0] : record.skipTimes.front();
}
else {
return 0;
}
}

static std::string getSkipTimesStr(std::vector<t_filetimestamp> skipTimes, bool JS, bool dateTime, bool useArrayChars = true, std::string delimiter = ", ") {
static std::string getSkipTimesStr(std::vector<t_filetimestamp> skipTimes, bool JS, bool dateTime, std::string delimiter = ", ", bool useArrayChars = false) {
if(skipTimes.empty()) {
return useArrayChars ? "[]" : "";
}
std::string str = useArrayChars ? "[" : "";
for(t_filetimestamp& time : skipTimes) {
if(dateTime) {
str.append(useArrayChars ? "\"" : "");
str.append(useArrayChars ? "" : "\"");
str.append(foobar2000_io::format_filetimestamp(time));
str.append(useArrayChars ? "\"" : "");
str.append(useArrayChars ? "" : "\"");
}
else {
str.append(std::to_string(getLocalTimestamp(time, JS)));
Expand Down

0 comments on commit 83b7920

Please sign in to comment.