2006-01-16 22:02:54 +01:00
|
|
|
// Copyright (c) 2005, Rodrigo Braz Monteiro
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
/// @file ass_dialogue.cpp
|
|
|
|
/// @brief Class for dialogue lines in subtitles
|
|
|
|
/// @ingroup subs_storage
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2012-12-04 23:35:59 +01:00
|
|
|
#include <boost/algorithm/string/join.hpp>
|
2009-09-10 06:14:28 +02:00
|
|
|
#include <fstream>
|
2010-08-03 00:14:11 +02:00
|
|
|
#include <list>
|
2009-09-10 15:06:40 +02:00
|
|
|
|
2007-06-19 05:34:53 +02:00
|
|
|
#include <wx/regex.h>
|
2009-09-10 04:23:43 +02:00
|
|
|
#include <wx/tokenzr.h>
|
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
#include "ass_dialogue.h"
|
|
|
|
#include "ass_override.h"
|
2012-10-25 15:45:06 +02:00
|
|
|
#include "compat.h"
|
|
|
|
#include "subtitle_format.h"
|
2007-01-08 22:11:06 +01:00
|
|
|
#include "utils.h"
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2012-12-02 19:24:49 +01:00
|
|
|
#include <libaegisub/of_type_adaptor.h>
|
|
|
|
|
2012-12-07 17:06:03 +01:00
|
|
|
using namespace boost::adaptors;
|
|
|
|
|
2012-12-04 23:35:59 +01:00
|
|
|
std::size_t hash_value(wxString const& s) {
|
|
|
|
return wxStringHash()(s);
|
|
|
|
}
|
|
|
|
|
2010-05-19 02:44:44 +02:00
|
|
|
AssDialogue::AssDialogue()
|
2012-11-25 01:08:29 +01:00
|
|
|
: AssEntry(wxString())
|
2012-01-31 01:44:43 +01:00
|
|
|
, Comment(false)
|
2010-05-19 02:44:44 +02:00
|
|
|
, Layer(0)
|
|
|
|
, Start(0)
|
|
|
|
, End(5000)
|
2011-09-28 21:43:11 +02:00
|
|
|
, Style("Default")
|
2010-05-19 02:44:44 +02:00
|
|
|
{
|
2012-10-05 04:10:20 +02:00
|
|
|
memset(Margin, 0, sizeof Margin);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2010-06-22 02:03:11 +02:00
|
|
|
AssDialogue::AssDialogue(AssDialogue const& that)
|
2012-11-25 01:08:29 +01:00
|
|
|
: AssEntry(wxString())
|
2010-06-22 02:03:33 +02:00
|
|
|
, Comment(that.Comment)
|
2010-06-22 02:03:11 +02:00
|
|
|
, Layer(that.Layer)
|
|
|
|
, Start(that.Start)
|
|
|
|
, End(that.End)
|
|
|
|
, Style(that.Style)
|
|
|
|
, Actor(that.Actor)
|
|
|
|
, Effect(that.Effect)
|
|
|
|
, Text(that.Text)
|
|
|
|
{
|
2012-10-10 16:04:44 +02:00
|
|
|
memmove(Margin, that.Margin, sizeof Margin);
|
2010-06-22 02:03:11 +02:00
|
|
|
}
|
|
|
|
|
2012-10-10 16:04:44 +02:00
|
|
|
AssDialogue::AssDialogue(wxString const& data)
|
2012-11-25 01:08:29 +01:00
|
|
|
: AssEntry(wxString())
|
2012-01-31 01:44:43 +01:00
|
|
|
, Comment(false)
|
2010-05-19 02:44:44 +02:00
|
|
|
, Layer(0)
|
|
|
|
, Start(0)
|
|
|
|
, End(5000)
|
2011-09-28 21:43:11 +02:00
|
|
|
, Style("Default")
|
2010-05-19 02:44:44 +02:00
|
|
|
{
|
2012-10-10 16:04:44 +02:00
|
|
|
if (!Parse(data))
|
2012-10-25 15:45:06 +02:00
|
|
|
throw SubtitleFormatParseError(STD_STR("Failed parsing line: " + data), 0);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
AssDialogue::~AssDialogue () {
|
2006-02-21 04:13:35 +01:00
|
|
|
}
|
|
|
|
|
2012-10-10 16:04:44 +02:00
|
|
|
bool AssDialogue::Parse(wxString const& rawData) {
|
2006-01-16 22:02:54 +01:00
|
|
|
size_t pos = 0;
|
|
|
|
wxString temp;
|
|
|
|
|
|
|
|
// Get type
|
2011-09-28 21:43:11 +02:00
|
|
|
if (rawData.StartsWith("Dialogue:")) {
|
2006-01-16 22:02:54 +01:00
|
|
|
Comment = false;
|
|
|
|
pos = 10;
|
|
|
|
}
|
2011-09-28 21:43:11 +02:00
|
|
|
else if (rawData.StartsWith("Comment:")) {
|
2006-01-16 22:02:54 +01:00
|
|
|
Comment = true;
|
|
|
|
pos = 9;
|
|
|
|
}
|
|
|
|
else return false;
|
2007-06-03 03:54:39 +02:00
|
|
|
|
2011-09-28 21:43:11 +02:00
|
|
|
wxStringTokenizer tkn(rawData.Mid(pos),",",wxTOKEN_RET_EMPTY_ALL);
|
2007-06-03 03:54:39 +02:00
|
|
|
if (!tkn.HasMoreTokens()) return false;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2007-01-08 02:54:02 +01:00
|
|
|
// Get first token and see if it has "Marked=" in it
|
2006-01-16 22:02:54 +01:00
|
|
|
temp = tkn.GetNextToken().Trim(false).Trim(true);
|
2012-10-10 16:04:44 +02:00
|
|
|
bool ssa = temp.Lower().StartsWith("marked=");
|
2007-01-08 02:54:02 +01:00
|
|
|
|
|
|
|
// Get layer number
|
2012-10-10 16:04:44 +02:00
|
|
|
if (ssa)
|
|
|
|
Layer = 0;
|
2006-01-16 22:02:54 +01:00
|
|
|
else {
|
|
|
|
long templ;
|
|
|
|
temp.ToLong(&templ);
|
|
|
|
Layer = templ;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get start time
|
|
|
|
if (!tkn.HasMoreTokens()) return false;
|
2012-02-14 01:35:06 +01:00
|
|
|
Start = tkn.GetNextToken();
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Get end time
|
|
|
|
if (!tkn.HasMoreTokens()) return false;
|
2012-02-14 01:35:06 +01:00
|
|
|
End = tkn.GetNextToken();
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Get style
|
|
|
|
if (!tkn.HasMoreTokens()) return false;
|
2012-12-04 23:35:59 +01:00
|
|
|
Style = tkn.GetNextToken().Trim(true).Trim(false);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Get actor
|
|
|
|
if (!tkn.HasMoreTokens()) return false;
|
2012-12-04 23:35:59 +01:00
|
|
|
Actor = tkn.GetNextToken().Trim(true).Trim(false);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2012-10-10 16:04:44 +02:00
|
|
|
// Get margins
|
|
|
|
for (int i = 0; i < 3; ++i) {
|
2007-01-08 02:54:02 +01:00
|
|
|
if (!tkn.HasMoreTokens()) return false;
|
2012-10-10 16:04:44 +02:00
|
|
|
SetMarginString(tkn.GetNextToken().Trim(false).Trim(true), i);
|
2007-01-08 02:54:02 +01:00
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2012-10-10 16:04:44 +02:00
|
|
|
if (!tkn.HasMoreTokens()) return false;
|
2012-12-04 23:35:59 +01:00
|
|
|
Effect = tkn.GetNextToken().Trim(true).Trim(false);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Get text
|
2012-10-10 16:04:44 +02:00
|
|
|
Text = rawData.Mid(pos + tkn.GetPosition());
|
2007-06-03 03:54:39 +02:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-08 09:14:55 +02:00
|
|
|
wxString AssDialogue::GetData(bool ssa) const {
|
|
|
|
wxString s = Style;
|
|
|
|
wxString a = Actor;
|
|
|
|
wxString e = Effect;
|
2011-09-28 21:43:11 +02:00
|
|
|
s.Replace(",",";");
|
|
|
|
a.Replace(",",";");
|
|
|
|
e.Replace(",",";");
|
2010-07-08 09:15:04 +02:00
|
|
|
|
|
|
|
wxString str = wxString::Format(
|
2011-09-28 21:43:11 +02:00
|
|
|
"%s: %s,%s,%s,%s,%s,%d,%d,%d,%s,%s",
|
|
|
|
Comment ? "Comment" : "Dialogue",
|
2011-09-28 21:43:48 +02:00
|
|
|
ssa ? "Marked=0" : wxString::Format("%01d", Layer),
|
2012-10-12 03:52:36 +02:00
|
|
|
Start.GetAssFormated(),
|
|
|
|
End.GetAssFormated(),
|
2011-09-28 21:43:48 +02:00
|
|
|
s, a,
|
2010-07-08 09:15:04 +02:00
|
|
|
Margin[0], Margin[1], Margin[2],
|
2011-09-28 21:43:48 +02:00
|
|
|
e,
|
2012-12-04 23:35:59 +01:00
|
|
|
Text.get());
|
2007-04-19 17:22:47 +02:00
|
|
|
|
|
|
|
// Make sure that final has no line breaks
|
2011-09-28 21:43:11 +02:00
|
|
|
str.Replace("\n", "");
|
|
|
|
str.Replace("\r", "");
|
2007-04-19 17:22:47 +02:00
|
|
|
|
2010-07-08 09:15:04 +02:00
|
|
|
return str;
|
2006-02-27 05:18:00 +01:00
|
|
|
}
|
|
|
|
|
2010-07-08 09:14:55 +02:00
|
|
|
const wxString AssDialogue::GetEntryData() const {
|
2010-06-24 03:24:43 +02:00
|
|
|
return GetData(false);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2012-12-02 19:24:49 +01:00
|
|
|
wxString AssDialogue::GetSSAText() const {
|
2010-06-24 03:24:43 +02:00
|
|
|
return GetData(true);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2012-12-02 19:24:49 +01:00
|
|
|
std::auto_ptr<boost::ptr_vector<AssDialogueBlock>> AssDialogue::ParseTags() const {
|
|
|
|
boost::ptr_vector<AssDialogueBlock> Blocks;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2011-12-26 23:21:02 +01:00
|
|
|
// Empty line, make an empty block
|
2012-12-04 23:35:59 +01:00
|
|
|
if (Text.get().empty()) {
|
2011-12-26 23:21:02 +01:00
|
|
|
Blocks.push_back(new AssDialogueBlockPlain);
|
2012-12-02 19:24:49 +01:00
|
|
|
return Blocks.release();
|
2011-12-26 23:21:02 +01:00
|
|
|
}
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
int drawingLevel = 0;
|
|
|
|
|
2012-12-04 23:35:59 +01:00
|
|
|
for (size_t len = Text.get().size(), cur = 0; cur < len; ) {
|
2006-01-16 22:02:54 +01:00
|
|
|
// Overrides block
|
2012-12-04 23:35:59 +01:00
|
|
|
if (Text.get()[cur] == '{') {
|
|
|
|
size_t end = Text.get().find('}', cur);
|
2012-11-22 17:54:17 +01:00
|
|
|
|
|
|
|
// VSFilter requires that override blocks be closed, while libass
|
|
|
|
// does not. We match VSFilter here.
|
|
|
|
if (end == wxString::npos)
|
|
|
|
goto plain;
|
|
|
|
|
2011-12-26 23:21:02 +01:00
|
|
|
++cur;
|
2006-01-16 22:02:54 +01:00
|
|
|
// Get contents of block
|
2012-12-04 23:35:59 +01:00
|
|
|
wxString work = Text.get().substr(cur, end - cur);
|
2012-11-22 17:54:17 +01:00
|
|
|
cur = end + 1;
|
2012-03-25 06:05:06 +02:00
|
|
|
|
2012-11-22 17:54:17 +01:00
|
|
|
if (work.size() && work.find('\\') == wxString::npos) {
|
2007-06-03 03:54:39 +02:00
|
|
|
//We've found an override block with no backslashes
|
|
|
|
//We're going to assume it's a comment and not consider it an override block
|
|
|
|
//Currently we'll treat this as a plain text block, but feel free to create a new class
|
2011-12-26 23:21:08 +01:00
|
|
|
Blocks.push_back(new AssDialogueBlockPlain("{" + work + "}"));
|
2007-06-03 03:54:39 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Create block
|
2011-12-26 23:21:08 +01:00
|
|
|
AssDialogueBlockOverride *block = new AssDialogueBlockOverride(work);
|
2007-06-03 03:54:39 +02:00
|
|
|
block->ParseTags();
|
|
|
|
Blocks.push_back(block);
|
|
|
|
|
|
|
|
// Look for \p in block
|
2012-11-04 04:53:03 +01:00
|
|
|
for (auto tag : block->Tags) {
|
2012-11-22 17:54:17 +01:00
|
|
|
if (tag->Name == "\\p")
|
2012-11-04 04:53:03 +01:00
|
|
|
drawingLevel = tag->Params[0]->Get<int>(0);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
}
|
2012-11-22 17:54:17 +01:00
|
|
|
|
|
|
|
continue;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
2012-11-22 17:54:17 +01:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Plain-text/drawing block
|
2012-11-22 17:54:17 +01:00
|
|
|
plain:
|
|
|
|
wxString work;
|
2012-12-04 23:35:59 +01:00
|
|
|
size_t end = Text.get().find('{', cur + 1);
|
2012-11-22 17:54:17 +01:00
|
|
|
if (end == wxString::npos) {
|
2012-12-04 23:35:59 +01:00
|
|
|
work = Text.get().substr(cur);
|
2012-11-22 17:54:17 +01:00
|
|
|
cur = len;
|
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
else {
|
2012-12-04 23:35:59 +01:00
|
|
|
work = Text.get().substr(cur, end - cur);
|
2012-11-22 17:54:17 +01:00
|
|
|
cur = end;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
2012-11-22 17:54:17 +01:00
|
|
|
|
|
|
|
if (drawingLevel == 0)
|
|
|
|
Blocks.push_back(new AssDialogueBlockPlain(work));
|
|
|
|
else
|
|
|
|
Blocks.push_back(new AssDialogueBlockDrawing(work, drawingLevel));
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
2012-03-29 01:58:50 +02:00
|
|
|
|
2012-12-02 19:24:49 +01:00
|
|
|
return Blocks.release();
|
2012-03-29 01:58:50 +02:00
|
|
|
}
|
|
|
|
|
2012-12-02 19:24:49 +01:00
|
|
|
void AssDialogue::StripTags() {
|
2010-06-24 03:24:43 +02:00
|
|
|
Text = GetStrippedText();
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2012-12-02 19:24:49 +01:00
|
|
|
void AssDialogue::StripTag(wxString const& tag_name) {
|
|
|
|
boost::ptr_vector<AssDialogueBlock> blocks(ParseTags());
|
2012-12-04 23:35:59 +01:00
|
|
|
wxString new_text;
|
2007-01-13 23:33:02 +01:00
|
|
|
|
|
|
|
// Look for blocks
|
2012-12-02 19:24:49 +01:00
|
|
|
for (auto& block : blocks) {
|
|
|
|
if (block.GetType() != BLOCK_OVERRIDE) {
|
2012-12-04 23:35:59 +01:00
|
|
|
new_text += block.GetText();
|
2012-10-05 04:10:20 +02:00
|
|
|
continue;
|
|
|
|
}
|
2007-01-13 23:33:02 +01:00
|
|
|
|
2012-12-02 19:24:49 +01:00
|
|
|
AssDialogueBlockOverride *over = static_cast<AssDialogueBlockOverride*>(&block);
|
2012-10-05 04:10:20 +02:00
|
|
|
wxString temp;
|
2012-11-04 04:53:03 +01:00
|
|
|
for (auto tag : over->Tags) {
|
2012-12-02 19:24:49 +01:00
|
|
|
if (tag->Name != tag_name)
|
2012-11-04 04:53:03 +01:00
|
|
|
temp += *tag;
|
2007-01-13 23:33:02 +01:00
|
|
|
}
|
2012-10-05 04:10:20 +02:00
|
|
|
|
|
|
|
if (!temp.empty())
|
2012-12-04 23:35:59 +01:00
|
|
|
new_text += "{" + temp + "}";
|
2007-01-13 23:33:02 +01:00
|
|
|
}
|
2012-12-04 23:35:59 +01:00
|
|
|
|
|
|
|
Text = new_text;
|
2007-01-13 23:33:02 +01:00
|
|
|
}
|
|
|
|
|
2012-12-04 23:35:59 +01:00
|
|
|
static wxString get_text(AssDialogueBlock &d) { return d.GetText(); }
|
2012-12-02 19:24:49 +01:00
|
|
|
void AssDialogue::UpdateText(boost::ptr_vector<AssDialogueBlock>& blocks) {
|
|
|
|
if (blocks.empty()) return;
|
2012-12-07 17:06:03 +01:00
|
|
|
Text = join(blocks | transformed(get_text), wxS(""));
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2012-10-05 04:10:20 +02:00
|
|
|
void AssDialogue::SetMarginString(wxString const& origvalue, int which) {
|
2012-10-26 16:33:50 +02:00
|
|
|
if (which < 0 || which > 2) throw InvalidMarginIdError();
|
2010-06-24 03:24:43 +02:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
// Make it numeric
|
|
|
|
wxString strvalue = origvalue;
|
|
|
|
if (!strvalue.IsNumber()) {
|
2012-01-31 01:44:43 +01:00
|
|
|
strvalue.clear();
|
2012-10-05 04:10:20 +02:00
|
|
|
for (size_t i = 0; i < origvalue.Length(); ++i) {
|
|
|
|
if (origvalue.Mid(i, 1).IsNumber()) {
|
|
|
|
strvalue += origvalue.Mid(i, 1);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get value
|
2012-01-20 06:14:56 +01:00
|
|
|
long value = 0;
|
2006-01-16 22:02:54 +01:00
|
|
|
strvalue.ToLong(&value);
|
2012-01-20 06:14:56 +01:00
|
|
|
Margin[which] = mid<int>(0, value, 9999);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2012-12-02 16:55:38 +01:00
|
|
|
wxString AssDialogue::GetMarginString(int which) const {
|
2012-10-26 16:33:50 +02:00
|
|
|
if (which < 0 || which > 2) throw InvalidMarginIdError();
|
2012-12-02 16:55:38 +01:00
|
|
|
return wxString::Format("%d", Margin[which]);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2012-03-20 01:39:10 +01:00
|
|
|
bool AssDialogue::CollidesWith(const AssDialogue *target) const {
|
2006-01-16 22:02:54 +01:00
|
|
|
if (!target) return false;
|
2011-12-22 22:28:51 +01:00
|
|
|
return ((Start < target->Start) ? (target->Start < End) : (Start < target->End));
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2012-12-07 17:06:03 +01:00
|
|
|
static wxString get_text_p(AssDialogueBlock *d) { return d->GetText(); }
|
2009-06-06 21:32:17 +02:00
|
|
|
wxString AssDialogue::GetStrippedText() const {
|
2012-12-02 19:24:49 +01:00
|
|
|
wxString ret;
|
|
|
|
boost::ptr_vector<AssDialogueBlock> blocks(ParseTags());
|
2012-12-07 17:06:03 +01:00
|
|
|
return join(blocks | agi::of_type<AssDialogueBlockPlain>() | transformed(get_text_p), wxS(""));
|
2007-01-13 03:22:28 +01:00
|
|
|
}
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2009-06-07 02:22:36 +02:00
|
|
|
AssEntry *AssDialogue::Clone() const {
|
2010-06-22 02:03:11 +02:00
|
|
|
return new AssDialogue(*this);
|
2006-02-27 10:07:08 +01:00
|
|
|
}
|
|
|
|
|
2007-10-18 04:47:13 +02:00
|
|
|
void AssDialogueBlockDrawing::TransformCoords(int mx,int my,double x,double y) {
|
2006-01-16 22:02:54 +01:00
|
|
|
// HACK: Implement a proper parser ffs!!
|
2010-06-24 03:24:43 +02:00
|
|
|
// Could use Spline but it'd be slower and this seems to work fine
|
2011-09-28 21:43:11 +02:00
|
|
|
wxStringTokenizer tkn(GetText()," ",wxTOKEN_DEFAULT);
|
2006-01-16 22:02:54 +01:00
|
|
|
wxString cur;
|
|
|
|
wxString final;
|
|
|
|
bool isX = true;
|
|
|
|
long temp;
|
|
|
|
|
|
|
|
// Process tokens
|
|
|
|
while (tkn.HasMoreTokens()) {
|
|
|
|
cur = tkn.GetNextToken().Lower();
|
|
|
|
|
|
|
|
// Number, process it
|
|
|
|
if (cur.IsNumber()) {
|
2007-10-18 04:47:13 +02:00
|
|
|
// Transform it
|
2006-01-16 22:02:54 +01:00
|
|
|
cur.ToLong(&temp);
|
2007-10-18 04:47:13 +02:00
|
|
|
if (isX) temp = (long int)((temp+mx)*x + 0.5);
|
|
|
|
else temp = (long int)((temp+my)*y + 0.5);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Write back to list
|
2011-09-28 21:43:11 +02:00
|
|
|
final += wxString::Format("%i ",temp);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Toggle X/Y
|
|
|
|
isX = !isX;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Text
|
|
|
|
else {
|
2011-09-28 21:43:11 +02:00
|
|
|
if (cur == "m" || cur == "n" || cur == "l" || cur == "b" || cur == "s" || cur == "p" || cur == "c") isX = true;
|
|
|
|
final += cur + " ";
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write back final
|
|
|
|
final = final.Left(final.Length()-1);
|
|
|
|
text = final;
|
|
|
|
}
|