mirror of https://github.com/odrling/Aegisub
More fixes and optimizations.
Originally committed to SVN as r2367.
This commit is contained in:
parent
bf9f2b50b7
commit
1397871e45
|
@ -96,7 +96,7 @@
|
|||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
|
@ -119,6 +119,7 @@
|
|||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/MP"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="false"
|
||||
|
@ -146,15 +147,11 @@
|
|||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../bin/aegilib.dll"
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
|
@ -164,9 +161,6 @@
|
|||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
|
@ -279,10 +273,6 @@
|
|||
RelativePath=".\include\aegilib\range.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\aegilib\selection.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\aegilib\serialize.h"
|
||||
>
|
||||
|
@ -396,7 +386,7 @@
|
|||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\aegilib\action.h"
|
||||
RelativePath=".\src\action.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
@ -415,26 +405,34 @@
|
|||
RelativePath=".\src\section.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\section.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\section_entry.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\aegilib\section_entry.h"
|
||||
RelativePath=".\src\section_entry.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\aegilib\section_entry_dialogue.h"
|
||||
RelativePath=".\src\section_entry_dialogue.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\aegilib\section_entry_style.h"
|
||||
RelativePath=".\src\section_entry_style.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\selection.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\selection.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\stdint.h"
|
||||
>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
// Contact: mailto:amz@aegisub.net
|
||||
//
|
||||
|
||||
#define ATHENA_DLL
|
||||
//#define ATHENA_DLL
|
||||
#ifdef ATHENA_DLL
|
||||
#ifdef ATHENA_EXPORTS
|
||||
#define ATHENA_API __declspec(dllexport)
|
||||
|
|
|
@ -253,15 +253,6 @@ namespace Athenasub {
|
|||
virtual String GetDefaultGroup() const = 0;
|
||||
|
||||
virtual Entry Clone() const = 0;
|
||||
|
||||
/*
|
||||
static PlainText GetAsPlain(Entry ptr);
|
||||
static Dialogue GetAsDialogue(Entry ptr);
|
||||
static DialogueConst GetAsDialogue(EntryConst ptr);
|
||||
static Style GetAsStyle(Entry ptr);
|
||||
static Attachment GetAsFile(Entry ptr);
|
||||
static RawEntry GetAsRaw(Entry ptr);
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
|
@ -298,8 +289,8 @@ namespace Athenasub {
|
|||
|
||||
// Write accessors
|
||||
virtual void SetText(const String& text) = 0;
|
||||
virtual void SetStartTime(Time start) = 0;
|
||||
virtual void SetEndTime(Time end) = 0;
|
||||
virtual void SetStartTime(const ITime& start) = 0;
|
||||
virtual void SetEndTime(const ITime& end) = 0;
|
||||
virtual void SetStartFrame(int start) = 0;
|
||||
virtual void SetEndFrame(int end) = 0;
|
||||
virtual void SetComment(bool isComment) = 0;
|
||||
|
|
|
@ -49,7 +49,6 @@ namespace Athenasub {
|
|||
|
||||
public:
|
||||
ActionInsert(Entry entry,int line,const String §ion);
|
||||
~ActionInsert() {}
|
||||
|
||||
Action GetAntiAction(const IModel& model) const;
|
||||
void Execute(IModel& model);
|
||||
|
@ -63,7 +62,6 @@ namespace Athenasub {
|
|||
|
||||
public:
|
||||
ActionRemove(int line,const String §ion);
|
||||
~ActionRemove() {}
|
||||
|
||||
Action GetAntiAction(const IModel& model) const;
|
||||
void Execute(IModel& model);
|
||||
|
@ -81,7 +79,6 @@ namespace Athenasub {
|
|||
public:
|
||||
ActionModify(Entry entry,int line,const String §ion,bool noTextFields);
|
||||
ActionModify(shared_ptr<void> delta,int line,const String §ion);
|
||||
~ActionModify() {}
|
||||
|
||||
Action GetAntiAction(const IModel& model) const;
|
||||
void Execute(IModel& model);
|
||||
|
@ -98,7 +95,6 @@ namespace Athenasub {
|
|||
|
||||
public:
|
||||
ActionModifyBatch(std::vector<Entry> entries,std::vector<VoidPtr> deltas,Selection selection,const String §ion,bool noTextFields);
|
||||
~ActionModifyBatch() {}
|
||||
|
||||
Action GetAntiAction(const IModel& model) const;
|
||||
void Execute(IModel& model);
|
||||
|
|
|
@ -40,7 +40,7 @@ using namespace Athenasub;
|
|||
|
||||
///////////////
|
||||
// Constructor
|
||||
CActionList::CActionList(Model _model,String _actionName,const String _owner,bool _undoAble)
|
||||
CActionList::CActionList(weak_ptr<IModel> _model,String _actionName,const String _owner,bool _undoAble)
|
||||
: model(_model), owner(_owner), undoAble(_undoAble)
|
||||
{
|
||||
valid = false;
|
||||
|
@ -96,7 +96,7 @@ void CActionList::Start(const String name)
|
|||
void CActionList::Finish()
|
||||
{
|
||||
if (valid) {
|
||||
model->ProcessActionList(*this);
|
||||
Model(model)->ProcessActionList(*this);
|
||||
actions.clear();
|
||||
valid = false;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ void CActionList::RemoveLine(int position,const String section)
|
|||
// Insert a "modify line" action
|
||||
Entry CActionList::ModifyLine(int position,const String section)
|
||||
{
|
||||
Section sect = model->GetSection(section);
|
||||
Section sect = Model(model)->GetSection(section);
|
||||
Entry entry = sect->GetEntry(position)->Clone();
|
||||
Action action = Action (new ActionModify(entry,position,section,false));
|
||||
AddAction(action);
|
||||
|
@ -138,7 +138,7 @@ Entry CActionList::ModifyLine(int position,const String section)
|
|||
std::vector<Entry> CActionList::ModifyLines(Selection selection,const String section)
|
||||
{
|
||||
// Get section
|
||||
Section sect = model->GetSection(section);
|
||||
Section sect = Model(model)->GetSection(section);
|
||||
|
||||
// Generate entries
|
||||
std::vector<Entry> entries(selection->GetCount());
|
||||
|
|
|
@ -56,12 +56,12 @@ namespace Athenasub {
|
|||
private:
|
||||
String actionName;
|
||||
String owner;
|
||||
Model model;
|
||||
weak_ptr<IModel> model;
|
||||
std::list<Action> actions;
|
||||
bool valid;
|
||||
bool undoAble;
|
||||
|
||||
CActionList(Model model,const String actionName,const String owner,bool undoAble);
|
||||
CActionList(weak_ptr<IModel>,const String actionName,const String owner,bool undoAble);
|
||||
void Start(const String actionName);
|
||||
void AddActionStart(const Action action);
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ namespace Athenasub {
|
|||
CTime() { ms = 0; }
|
||||
CTime(int _ms) { ms = _ms; }
|
||||
|
||||
void SetMS(int milliseconds) { ms = milliseconds; }
|
||||
int GetMS() const { return ms; }
|
||||
inline void SetMS(int milliseconds) { ms = milliseconds; }
|
||||
inline int GetMS() const { return ms; }
|
||||
|
||||
String GetString(int ms_precision,int h_precision) const;
|
||||
void ParseString(const String &data);
|
||||
|
|
|
@ -109,11 +109,15 @@ bool CController::CanRedo(const String owner) const
|
|||
}
|
||||
void CController::Undo(const String owner)
|
||||
{
|
||||
model->Undo(owner);
|
||||
if (CanUndo(owner)) {
|
||||
model->Undo(owner);
|
||||
}
|
||||
}
|
||||
void CController::Redo(const String owner)
|
||||
{
|
||||
model->Redo(owner);
|
||||
if (CanRedo(owner)) {
|
||||
model->Redo(owner);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -142,91 +142,61 @@ bool DialogueASS::Parse(wxString rawData, int version)
|
|||
// Serialize
|
||||
String DialogueASS::ToText(int version) const
|
||||
{
|
||||
// Old, slow code
|
||||
if (false) {
|
||||
// Prepare
|
||||
wxString final;
|
||||
// Calculate size
|
||||
size_t size = 9+9+20+12+12; // 9 for "comment: " (+1 for dialogue below), 9 for commas,
|
||||
// 20 for times, 12 for margins, 12 just to be sure that layer fits
|
||||
if (!isComment) size++; // Comment->Dialogue
|
||||
if (version == 0) size += 8; // "Marked=0"
|
||||
else if (version == 2) size += 5; // Fourth margin
|
||||
for (size_t i=0;i<4;i++) size += text[i].Length();
|
||||
|
||||
// Write comment or dialogue
|
||||
if (isComment) final = _T("Comment: ");
|
||||
else final = _T("Dialogue: ");
|
||||
// Allocate string
|
||||
wxString final;
|
||||
wxChar *buffer = final.GetWriteBuf(size);
|
||||
wxChar temp[16];
|
||||
|
||||
// Write layer or marked
|
||||
if (version >= 1) final += wxString::Format(_T("%01i,"),layer);
|
||||
else final += _T("Marked=0,");
|
||||
// Write comment/dialogue
|
||||
size_t pos = 0;
|
||||
if (isComment) WriteText(buffer,_T("Comment: "),9,pos);
|
||||
else WriteText(buffer,_T("Dialogue: "),10,pos);
|
||||
|
||||
// Write times, style and actor
|
||||
final += time[0].GetString(2,1) + _T(",") + time[1].GetString(2,1) + _T(",") + text[1] + _T(",") + text[2] + _T(",");
|
||||
// Write layer or marked
|
||||
if (version >= 1) {
|
||||
WriteNumber(buffer,temp,layer,0,pos);
|
||||
WriteChar(buffer,_T(','),pos);
|
||||
}
|
||||
else WriteText(buffer,_T("Marked=0,"),9,pos);
|
||||
|
||||
// Write margins
|
||||
if (version <= 1) final += wxString::Format(_T("%04i,%04i,%04i,"),margin[0],margin[1],margin[2]);
|
||||
else final += wxString::Format(_T("%04i,%04i,%04i,%04i,"),margin[0],margin[1],margin[2],margin[3]);
|
||||
|
||||
// Write effect and text
|
||||
final += text[3] + _T(",") + text[0];
|
||||
|
||||
// Return final
|
||||
return final;
|
||||
// Write times
|
||||
for (size_t i=0;i<2;i++) {
|
||||
wxString tempStr = time[i].GetString(2,1);
|
||||
WriteText(buffer,&tempStr[0],10,pos);
|
||||
WriteChar(buffer,_T(','),pos);
|
||||
}
|
||||
|
||||
// New, faster code
|
||||
else {
|
||||
// Calculate size
|
||||
size_t size = 9+9+20+12+12; // 9 for "comment: " (+1 for dialogue below), 9 for commas,
|
||||
// 20 for times, 12 for margins, 12 just to be sure that layer fits
|
||||
if (!isComment) size++; // Comment->Dialogue
|
||||
if (version == 0) size += 8; // "Marked=0"
|
||||
else if (version == 2) size += 5; // Fourth margin
|
||||
for (size_t i=0;i<4;i++) size += text[i].Length();
|
||||
// Write style and actor
|
||||
WriteText(buffer,&text[1][0],text[1].Length(),pos);
|
||||
WriteChar(buffer,_T(','),pos);
|
||||
WriteText(buffer,&text[2][0],text[2].Length(),pos);
|
||||
WriteChar(buffer,_T(','),pos);
|
||||
|
||||
// Allocate string
|
||||
wxString final;
|
||||
wxChar *buffer = final.GetWriteBuf(size);
|
||||
wxChar temp[16];
|
||||
|
||||
// Write comment/dialogue
|
||||
size_t pos = 0;
|
||||
if (isComment) WriteText(buffer,_T("Comment: "),9,pos);
|
||||
else WriteText(buffer,_T("Dialogue: "),10,pos);
|
||||
|
||||
// Write layer or marked
|
||||
if (version >= 1) {
|
||||
WriteNumber(buffer,temp,layer,0,pos);
|
||||
WriteChar(buffer,_T(','),pos);
|
||||
}
|
||||
else WriteText(buffer,_T("Marked=0,"),9,pos);
|
||||
|
||||
// Write times
|
||||
for (size_t i=0;i<2;i++) {
|
||||
wxString tempStr = time[i].GetString(2,1);
|
||||
WriteText(buffer,&tempStr[0],10,pos);
|
||||
WriteChar(buffer,_T(','),pos);
|
||||
}
|
||||
|
||||
// Write style and actor
|
||||
WriteText(buffer,&text[1][0],text[1].Length(),pos);
|
||||
// Write margins
|
||||
size_t marCount = 3;
|
||||
if (version == 2) marCount++;
|
||||
for (size_t i=0;i<marCount;i++) {
|
||||
WriteNumber(buffer,temp,margin[i],4,pos);
|
||||
WriteChar(buffer,_T(','),pos);
|
||||
WriteText(buffer,&text[2][0],text[2].Length(),pos);
|
||||
WriteChar(buffer,_T(','),pos);
|
||||
|
||||
// Write margins
|
||||
size_t marCount = 3;
|
||||
if (version == 2) marCount++;
|
||||
for (size_t i=0;i<marCount;i++) {
|
||||
WriteNumber(buffer,temp,margin[i],4,pos);
|
||||
WriteChar(buffer,_T(','),pos);
|
||||
}
|
||||
|
||||
// Write effect and text
|
||||
WriteText(buffer,&text[3][0],text[3].Length(),pos);
|
||||
WriteChar(buffer,_T(','),pos);
|
||||
WriteText(buffer,&text[0][0],text[0].Length(),pos);
|
||||
|
||||
// Write terminator
|
||||
WriteText(buffer,_T("\0"),1,pos);
|
||||
|
||||
// Restore string's state
|
||||
final.UngetWriteBuf(pos-1);
|
||||
return final;
|
||||
}
|
||||
|
||||
// Write effect and text
|
||||
WriteText(buffer,&text[3][0],text[3].Length(),pos);
|
||||
WriteChar(buffer,_T(','),pos);
|
||||
WriteText(buffer,&text[0][0],text[0].Length(),pos);
|
||||
|
||||
// Write terminator
|
||||
WriteText(buffer,_T("\0"),1,pos);
|
||||
|
||||
// Restore string's state
|
||||
final.UngetWriteBuf(pos-1);
|
||||
return final;
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@ namespace Athenasub {
|
|||
friend class DialogueASSDeltaCoder;
|
||||
|
||||
private:
|
||||
array<CTime,2> time;
|
||||
array<String,4> text; // 0 = text, 1 = style, 2 = actor, 3 = effect
|
||||
array<CTime,2> time;
|
||||
array<short,4> margin;
|
||||
int layer;
|
||||
bool isComment;
|
||||
|
@ -84,8 +84,8 @@ namespace Athenasub {
|
|||
const String& GetUserField() const { return text[3]; }
|
||||
|
||||
// Write acessors
|
||||
void SetStartTime(Time setStart) { time[0].SetMS(setStart->GetMS()); }
|
||||
void SetEndTime(Time setEnd) { time[1].SetMS(setEnd->GetMS()); }
|
||||
void SetStartTime(const ITime &setStart) { time[0].SetMS(setStart.GetMS()); }
|
||||
void SetEndTime(const ITime &setEnd) { time[1].SetMS(setEnd.GetMS()); }
|
||||
void SetComment(bool _isComment) { isComment = _isComment; }
|
||||
void SetLayer(int _layer) { layer = _layer; }
|
||||
void SetMargin(int _margin,int value) { margin.at(_margin) = value; }
|
||||
|
|
|
@ -67,7 +67,7 @@ void CModel::ProcessActionList(CActionList &_actionList,int type)
|
|||
shared_ptr<CActionList> actions = shared_ptr<CActionList>(new CActionList(_actionList));
|
||||
|
||||
// Setup undo
|
||||
shared_ptr<CActionList> undo = shared_ptr<CActionList>(new CActionList(actions->model,actions->actionName,actions->owner,actions->undoAble));
|
||||
shared_ptr<CActionList> undo = shared_ptr<CActionList>(new CActionList(Model(actions->model),actions->actionName,actions->owner,actions->undoAble));
|
||||
ActionStack *stack;
|
||||
if (type == 1) stack = &redoStack;
|
||||
else stack = &undoStack;
|
||||
|
|
|
@ -80,8 +80,8 @@ namespace Athenasub {
|
|||
|
||||
// Write accessors
|
||||
virtual void SetText(const String& text) { (void) text; ThrowUnsupported(); }
|
||||
virtual void SetStartTime(Time start) { (void) start; ThrowUnsupported(); }
|
||||
virtual void SetEndTime(Time end) { (void) end; ThrowUnsupported(); }
|
||||
virtual void SetStartTime(const ITime& start) { (void) start; ThrowUnsupported(); }
|
||||
virtual void SetEndTime(const ITime& end) { (void) end; ThrowUnsupported(); }
|
||||
virtual void SetStartFrame(int start) { (void) start; ThrowUnsupported(); }
|
||||
virtual void SetEndFrame(int end) { (void) end; ThrowUnsupported(); }
|
||||
virtual void SetComment(bool isComment) { (void) isComment; ThrowUnsupported(); }
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
// Contact: mailto:amz@aegisub.net
|
||||
//
|
||||
|
||||
#define ATHENA_DLL
|
||||
//#define ATHENA_DLL
|
||||
#include <wx/wfstream.h>
|
||||
#include <athenasub/athenawin.h>
|
||||
#include <iostream>
|
||||
|
@ -92,13 +92,13 @@ int main()
|
|||
|
||||
// Issue an action
|
||||
#ifdef WXDEBUG
|
||||
const int n = 1;
|
||||
int n = 1;
|
||||
#else
|
||||
const int n = 100;
|
||||
int n = 100;
|
||||
#endif
|
||||
cout << "Executing action " << n << " times... ";
|
||||
timer.Start();
|
||||
for (size_t i=0;i<n;i++) {
|
||||
for (int i=0;i<n;i++) {
|
||||
ActionList actions = control->CreateActionList(L"Test");
|
||||
Selection selection = control->CreateSelection();
|
||||
selection->AddRange(Range(0,5000));
|
||||
|
@ -108,8 +108,8 @@ int main()
|
|||
size_t len = entries.size();
|
||||
for (size_t i=0;i<len;i++) {
|
||||
Dialogue diag = dynamic_pointer_cast<IDialogue> (entries[i]);
|
||||
diag->SetStartTime(diag->GetStartTime() - 55555);
|
||||
diag->SetEndTime(diag->GetEndTime() + 5555);
|
||||
diag->SetStartTime(*(diag->GetStartTime() - 55555));
|
||||
diag->SetEndTime(*(diag->GetEndTime() + 5555));
|
||||
}
|
||||
actions->Finish();
|
||||
}
|
||||
|
@ -117,16 +117,19 @@ int main()
|
|||
cout << "Done in " << timer.Time() << " ms.\n";
|
||||
|
||||
// Rollback
|
||||
cout << "Undoing " << n << " times... ";
|
||||
for (size_t i=0;i<n-1;i++) {
|
||||
cout << "Undoing " << n-1 << " times... ";
|
||||
timer.Start();
|
||||
for (int i=0;i<n-1;i++) {
|
||||
control->Undo();
|
||||
}
|
||||
cout << "Done.\n";
|
||||
timer.Pause();
|
||||
cout << "Done in " << timer.Time() << " ms.\n";
|
||||
|
||||
// Undo
|
||||
cout << "Undoing and redoing " << n*10 << " times... ";
|
||||
n = 100;
|
||||
cout << "Undoing and redoing " << n << " times... ";
|
||||
timer.Start();
|
||||
for (size_t i=0;i<n*10;i++) {
|
||||
for (int i=0;i<n;i++) {
|
||||
control->Undo();
|
||||
control->Redo();
|
||||
}
|
||||
|
@ -149,5 +152,7 @@ int main()
|
|||
cout << "\n\nException: " << e.what() << endl << endl;
|
||||
}
|
||||
|
||||
system("pause");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -118,6 +118,9 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
InlineFunctionExpansion="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
AdditionalIncludeDirectories="../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
RuntimeLibrary="2"
|
||||
|
|
Loading…
Reference in New Issue