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/
|
2006-01-16 22:02:54 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @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"
|
|
|
|
|
2009-09-10 06:14:28 +02:00
|
|
|
#ifndef AGI_PRE
|
|
|
|
#include <fstream>
|
2010-08-03 00:14:11 +02:00
|
|
|
#include <list>
|
|
|
|
#include <vector>
|
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>
|
|
|
|
#endif
|
|
|
|
|
2007-01-08 22:11:06 +01:00
|
|
|
#include "ass_dialogue.h"
|
|
|
|
#include "ass_override.h"
|
|
|
|
#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
|
|
|
|
2010-05-19 02:44:44 +02:00
|
|
|
AssDialogue::AssDialogue()
|
2012-01-31 01:44:43 +01:00
|
|
|
: AssEntry(wxString(), "[Events]")
|
|
|
|
, 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-02-01 01:47:49 +01:00
|
|
|
: AssEntry(wxString(), that.group)
|
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-01-31 01:44:43 +01:00
|
|
|
: AssEntry(wxString(), "[Events]")
|
|
|
|
, 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))
|
2011-09-28 21:43:11 +02:00
|
|
|
throw "Failed parsing line.";
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
AssDialogue::~AssDialogue () {
|
2010-07-11 05:31:19 +02:00
|
|
|
delete_clear(Blocks);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2006-02-21 04:13:35 +01:00
|
|
|
void AssDialogue::ClearBlocks() {
|
2010-07-11 05:31:19 +02:00
|
|
|
delete_clear(Blocks);
|
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;
|
|
|
|
Style = tkn.GetNextToken();
|
|
|
|
Style.Trim(true);
|
|
|
|
Style.Trim(false);
|
|
|
|
|
|
|
|
// Get actor
|
|
|
|
if (!tkn.HasMoreTokens()) return false;
|
|
|
|
Actor = tkn.GetNextToken();
|
|
|
|
Actor.Trim(true);
|
|
|
|
Actor.Trim(false);
|
|
|
|
|
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;
|
|
|
|
Effect = tkn.GetNextToken();
|
2006-01-16 22:02:54 +01:00
|
|
|
Effect.Trim(true);
|
|
|
|
Effect.Trim(false);
|
|
|
|
|
|
|
|
// 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),
|
|
|
|
Start.GetASSFormated(),
|
|
|
|
End.GetASSFormated(),
|
|
|
|
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,
|
|
|
|
Text);
|
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
|
|
|
}
|
|
|
|
|
2010-07-08 09:14:55 +02: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-03-29 01:58:50 +02:00
|
|
|
std::vector<AssDialogueBlock*> AssDialogue::ParseTags() const {
|
|
|
|
std::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
|
|
|
|
if (Text.empty()) {
|
|
|
|
Blocks.push_back(new AssDialogueBlockPlain);
|
2012-03-29 01:58:50 +02:00
|
|
|
return Blocks;
|
2011-12-26 23:21:02 +01:00
|
|
|
}
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
int drawingLevel = 0;
|
|
|
|
|
2011-12-26 23:21:02 +01:00
|
|
|
for (size_t len = Text.size(), cur = 0; cur < len; ) {
|
2006-01-16 22:02:54 +01:00
|
|
|
// Overrides block
|
|
|
|
if (Text[cur] == '{') {
|
2011-12-26 23:21:02 +01:00
|
|
|
++cur;
|
2006-01-16 22:02:54 +01:00
|
|
|
// Get contents of block
|
|
|
|
wxString work;
|
2011-12-26 23:21:02 +01:00
|
|
|
size_t end = Text.find("}", cur);
|
2006-01-16 22:02:54 +01:00
|
|
|
if (end == wxString::npos) {
|
|
|
|
work = Text.substr(cur);
|
2011-12-26 23:21:02 +01:00
|
|
|
cur = len;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
work = Text.substr(cur, end - cur);
|
|
|
|
cur = end + 1;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
2012-03-25 06:05:06 +02:00
|
|
|
|
2011-12-26 23:21:02 +01:00
|
|
|
if (work.size() && work.Find("\\") == wxNOT_FOUND) {
|
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
|
|
|
|
std::vector<AssOverrideTag*>::iterator curTag;
|
2012-10-05 04:10:20 +02:00
|
|
|
for (curTag = block->Tags.begin(); curTag != block->Tags.end(); ++curTag) {
|
2011-09-28 21:43:11 +02:00
|
|
|
if ((*curTag)->Name == "\\p") {
|
2010-06-24 03:24:43 +02:00
|
|
|
drawingLevel = (*curTag)->Params[0]->Get<int>(0);
|
2007-06-03 03:54:39 +02:00
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Plain-text/drawing block
|
|
|
|
else {
|
|
|
|
wxString work;
|
2011-12-26 23:21:02 +01:00
|
|
|
size_t end = Text.find("{",cur);
|
2006-01-16 22:02:54 +01:00
|
|
|
if (end == wxString::npos) {
|
|
|
|
work = Text.substr(cur);
|
2011-12-26 23:21:02 +01:00
|
|
|
cur = len;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
work = Text.substr(cur, end - cur);
|
|
|
|
cur = end;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Plain-text
|
|
|
|
if (drawingLevel == 0) {
|
2011-12-26 23:21:08 +01:00
|
|
|
Blocks.push_back(new AssDialogueBlockPlain(work));
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
// Drawing
|
|
|
|
else {
|
2012-03-10 03:16:08 +01:00
|
|
|
Blocks.push_back(new AssDialogueBlockDrawing(work, drawingLevel));
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-29 01:58:50 +02:00
|
|
|
|
|
|
|
return Blocks;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AssDialogue::ParseASSTags() {
|
|
|
|
ClearBlocks();
|
|
|
|
Blocks = ParseTags();
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void AssDialogue::StripTags () {
|
2010-06-24 03:24:43 +02:00
|
|
|
Text = GetStrippedText();
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2007-01-13 23:33:02 +01:00
|
|
|
void AssDialogue::StripTag (wxString tagName) {
|
|
|
|
ParseASSTags();
|
|
|
|
wxString final;
|
|
|
|
|
|
|
|
// Look for blocks
|
2012-10-05 04:10:20 +02:00
|
|
|
for (std::vector<AssDialogueBlock*>::iterator cur = Blocks.begin(); cur != Blocks.end(); ++cur) {
|
|
|
|
if ((*cur)->GetType() != BLOCK_OVERRIDE) {
|
|
|
|
final += (*cur)->GetText();
|
|
|
|
continue;
|
|
|
|
}
|
2007-01-13 23:33:02 +01:00
|
|
|
|
2012-10-05 04:10:20 +02:00
|
|
|
AssDialogueBlockOverride *over = dynamic_cast<AssDialogueBlockOverride*>(*cur);
|
|
|
|
wxString temp;
|
|
|
|
for (size_t i = 0; i < over->Tags.size(); ++i) {
|
|
|
|
if (over->Tags[i]->Name != tagName)
|
|
|
|
temp += *over->Tags[i];
|
2007-01-13 23:33:02 +01:00
|
|
|
}
|
2012-10-05 04:10:20 +02:00
|
|
|
|
|
|
|
if (!temp.empty())
|
|
|
|
final += "{" + temp + "}";
|
2007-01-13 23:33:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ClearBlocks();
|
|
|
|
Text = final;
|
|
|
|
}
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
void AssDialogue::UpdateText () {
|
2010-06-24 03:24:43 +02:00
|
|
|
if (Blocks.empty()) return;
|
|
|
|
Text.clear();
|
2012-10-05 04:10:20 +02:00
|
|
|
for (std::vector<AssDialogueBlock*>::iterator cur = Blocks.begin(); cur != Blocks.end(); ++cur) {
|
2008-01-14 01:30:00 +01:00
|
|
|
if ((*cur)->GetType() == BLOCK_OVERRIDE) {
|
2011-09-28 21:43:11 +02:00
|
|
|
Text += "{";
|
2006-01-16 22:02:54 +01:00
|
|
|
Text += (*cur)->GetText();
|
2011-09-28 21:43:11 +02:00
|
|
|
Text += "}";
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
else Text += (*cur)->GetText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-05 04:10:20 +02:00
|
|
|
void AssDialogue::SetMarginString(wxString const& origvalue, int which) {
|
2012-10-10 16:04:44 +02:00
|
|
|
if (which < 0 || which > 2) throw Aegisub::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-10-10 16:04:44 +02:00
|
|
|
wxString AssDialogue::GetMarginString(int which, bool pad) const {
|
|
|
|
if (which < 0 || which > 2) throw Aegisub::InvalidMarginIdError();
|
2012-10-05 04:10:20 +02:00
|
|
|
return wxString::Format(pad ? "%04d" : "%d", Margin[which]);
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
2009-08-01 05:27:13 +02:00
|
|
|
void AssDialogue::ProcessParameters(AssDialogueBlockOverride::ProcessParametersCallback callback,void *userData) {
|
2006-01-16 22:02:54 +01:00
|
|
|
// Apply for all override blocks
|
2012-10-05 04:10:20 +02:00
|
|
|
for (std::vector<AssDialogueBlock*>::iterator cur = Blocks.begin(); cur != Blocks.end(); ++cur) {
|
2008-01-14 01:30:00 +01:00
|
|
|
if ((*cur)->GetType() == BLOCK_OVERRIDE) {
|
2012-10-05 04:10:20 +02:00
|
|
|
static_cast<AssDialogueBlockOverride*>(*cur)->ProcessParameters(callback, userData);
|
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
|
|
|
}
|
|
|
|
|
2009-06-06 21:32:17 +02:00
|
|
|
wxString AssDialogue::GetStrippedText() const {
|
2012-10-05 04:10:20 +02:00
|
|
|
static const wxRegEx reg("\\{[^\\{]*\\}", wxRE_ADVANCED);
|
2010-06-24 03:24:43 +02:00
|
|
|
wxString txt(Text);
|
2012-10-05 04:10:20 +02:00
|
|
|
reg.Replace(&txt, "");
|
2010-06-24 03:24:43 +02:00
|
|
|
return txt;
|
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;
|
|
|
|
}
|