Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
Fixes:
Browse files Browse the repository at this point in the history
 - Fix Visual Studio Compilation by using Unicode & WXDLL.
 - Made SRT Time to always round down.
   - Though I feel like someone will bring it up again, which I'd be like *Shrug*
  • Loading branch information
Ristellise committed Jan 30, 2021
1 parent 4988023 commit ac88b7f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ elseif(WIN32)
libaegisub/windows/path_win.cpp
libaegisub/windows/util_win.cpp
)
target_compile_definitions(libaegisub PRIVATE -D_UNICODE -DUNICODE)
endif()
set_target_properties(libaegisub PROPERTIES PREFIX "")
target_compile_definitions(libaegisub PRIVATE CMAKE_BUILD)
Expand Down Expand Up @@ -474,6 +475,7 @@ if(WIN32)
else()
target_include_directories(Aegisub PRIVATE "build")
endif()
target_compile_definitions(Aegisub PRIVATE -D_UNICODE -DUNICODE -DWXUSINGDLL)
else()
add_custom_target(git_version build/version.sh .
BYPRODUCTS "${PROJECT_SOURCE_DIR}/build/git_version.h" "${PROJECT_SOURCE_DIR}/build/git_version.xml"
Expand Down
6 changes: 6 additions & 0 deletions libaegisub/ass/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ std::string Time::GetSrtFormatted() const {
return ret;
}

void Time::RoundTime() {
float floatTime = (float)this->time / 10.0f;

time = floor(floatTime - 0.5) * 10;
}

SmpteFormatter::SmpteFormatter(vfr::Framerate fps, char sep)
: fps(std::move(fps))
, sep(sep)
Expand Down
3 changes: 3 additions & 0 deletions libaegisub/include/libaegisub/ass/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ class Time {

/// Return the time as a string
std::string GetSrtFormatted() const;

/// Rounds the time up to the nearest tenths, for compatibility with SRT.
void RoundTime();
};
}
8 changes: 6 additions & 2 deletions src/subtitle_format_srt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,12 @@ void SRTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename,

// create new subtitle
line = new AssDialogue;
line->Start = timestamp_match.str(1);
line->End = timestamp_match.str(2);
agi::Time startTime = agi::Time(timestamp_match.str(1));
startTime.RoundTime();
agi::Time endTime = agi::Time(timestamp_match.str(2));
endTime.RoundTime();
line->Start = startTime;
line->End = endTime;
// store pointer to subtitle, we'll continue working on it
target->Events.push_back(*line);
// next we're reading the text
Expand Down

0 comments on commit ac88b7f

Please sign in to comment.