mirror of https://github.com/odrling/Aegisub
Completely broke Athenasub (WIP)
Originally committed to SVN as r2293.
This commit is contained in:
parent
29ed35de5c
commit
f0f1f7fb72
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
EnableIntrinsicFunctions="true"
|
EnableIntrinsicFunctions="true"
|
||||||
FavorSizeOrSpeed="1"
|
FavorSizeOrSpeed="1"
|
||||||
OmitFramePointers="false"
|
OmitFramePointers="false"
|
||||||
AdditionalIncludeDirectories="include/aegilib"
|
AdditionalIncludeDirectories="include/athenasub;src"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_WINDOWS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_WINDOWS"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="2"
|
||||||
EnableEnhancedInstructionSet="0"
|
EnableEnhancedInstructionSet="0"
|
||||||
|
@ -166,35 +166,23 @@
|
||||||
Name="Include"
|
Name="Include"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\api.h"
|
RelativePath=".\include\athenasub\api.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\athenastring.h"
|
RelativePath=".\include\athenasub\athenasub.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\athenasub.h"
|
RelativePath=".\include\athenasub\athenawin.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\athenatime.h"
|
RelativePath=".\include\athenasub\interfaces.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\fastbuffer.h"
|
RelativePath=".\include\athenasub\tr1.h"
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\include\aegilib\range.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\include\aegilib\selection.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\include\aegilib\tr1.h"
|
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
@ -206,7 +194,7 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\controller.h"
|
RelativePath=".\src\controller.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
|
@ -214,29 +202,13 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\model.h"
|
RelativePath=".\src\model.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\notification.h"
|
RelativePath=".\include\aegilib\notification.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\src\view.cpp"
|
|
||||||
>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
PrecompiledHeaderThrough="prec.h"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\include\aegilib\view.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Misc"
|
Name="Misc"
|
||||||
|
@ -249,10 +221,6 @@
|
||||||
RelativePath=".\include\aegilib\colour.h"
|
RelativePath=".\include\aegilib\colour.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\include\aegilib\deltacoder.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\exception.cpp"
|
RelativePath=".\src\exception.cpp"
|
||||||
>
|
>
|
||||||
|
@ -261,6 +229,10 @@
|
||||||
RelativePath=".\include\aegilib\exception.h"
|
RelativePath=".\include\aegilib\exception.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\aegilib\fastbuffer.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\gorgontime.h"
|
RelativePath=".\include\aegilib\gorgontime.h"
|
||||||
>
|
>
|
||||||
|
@ -290,6 +262,14 @@
|
||||||
RelativePath=".\src\prec.h"
|
RelativePath=".\src\prec.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\aegilib\range.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\aegilib\selection.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\serialize.h"
|
RelativePath=".\include\aegilib\serialize.h"
|
||||||
>
|
>
|
||||||
|
@ -327,7 +307,7 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\utils.h"
|
RelativePath=".\src\utils.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
|
@ -342,10 +322,6 @@
|
||||||
<Filter
|
<Filter
|
||||||
Name="Formats"
|
Name="Formats"
|
||||||
>
|
>
|
||||||
<File
|
|
||||||
RelativePath=".\include\aegilib\format.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\format_handler.h"
|
RelativePath=".\include\aegilib\format_handler.h"
|
||||||
>
|
>
|
||||||
|
@ -415,7 +391,7 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\actionlist.h"
|
RelativePath=".\src\actionlist.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
@ -426,10 +402,6 @@
|
||||||
RelativePath=".\src\section.cpp"
|
RelativePath=".\src\section.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\include\aegilib\section.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\section_entry.cpp"
|
RelativePath=".\src\section_entry.cpp"
|
||||||
>
|
>
|
||||||
|
@ -463,7 +435,7 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\libathenasub.h"
|
RelativePath=".\src\libathenasub.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
|
|
@ -1,79 +0,0 @@
|
||||||
// Copyright (c) 2008, 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.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// AEGISUB/ATHENASUB
|
|
||||||
//
|
|
||||||
// Website: http://www.aegisub.net
|
|
||||||
// Contact: mailto:amz@aegisub.net
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "athenastring.h"
|
|
||||||
#include "tr1.h"
|
|
||||||
#include "format.h"
|
|
||||||
#include "api.h"
|
|
||||||
|
|
||||||
namespace Athenasub {
|
|
||||||
|
|
||||||
// Prototypes
|
|
||||||
class Model;
|
|
||||||
class ActionList;
|
|
||||||
typedef shared_ptr<ActionList> ActionListPtr;
|
|
||||||
|
|
||||||
// Controller class
|
|
||||||
class Controller {
|
|
||||||
private:
|
|
||||||
Model &model;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Controller (Model &model);
|
|
||||||
ActionListPtr CreateActionList(const String title,const String owner=L"",bool undoAble=true);
|
|
||||||
|
|
||||||
void LoadFile(const String filename,const String encoding=L"");
|
|
||||||
void SaveFile(const String filename,const String encoding=L"UTF-8");
|
|
||||||
|
|
||||||
bool CanUndo(const String owner=L"") const;
|
|
||||||
bool CanRedo(const String owner=L"") const;
|
|
||||||
void Undo(const String owner=L"");
|
|
||||||
void Redo(const String owner=L"");
|
|
||||||
|
|
||||||
DialoguePtr CreateDialogue() const;
|
|
||||||
StylePtr CreateStyle() const;
|
|
||||||
|
|
||||||
DialogueConstPtr GetDialogue(size_t n) const;
|
|
||||||
DialogueConstPtr GetStyle(size_t n) const;
|
|
||||||
StyleConstPtr GetStyle(String name) const;
|
|
||||||
EntryConstPtr GetEntry(size_t n,String section) const;
|
|
||||||
|
|
||||||
const FormatPtr GetFormat() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef shared_ptr<Controller> ControllerPtr;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
// Copyright (c) 2008, 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.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// AEGISUB/ATHENASUB
|
|
||||||
//
|
|
||||||
// Website: http://www.aegisub.net
|
|
||||||
// Contact: mailto:amz@aegisub.net
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "athenastring.h"
|
|
||||||
#include "tr1.h"
|
|
||||||
#include "section_entry.h"
|
|
||||||
|
|
||||||
namespace Athenasub {
|
|
||||||
// Prototypes
|
|
||||||
class FormatHandler;
|
|
||||||
class Model;
|
|
||||||
|
|
||||||
// Format interface
|
|
||||||
class Format {
|
|
||||||
public:
|
|
||||||
virtual ~Format() {}
|
|
||||||
|
|
||||||
virtual String GetName() const = 0;
|
|
||||||
virtual StringArray GetReadExtensions() const = 0;
|
|
||||||
virtual StringArray GetWriteExtensions() const = 0;
|
|
||||||
virtual shared_ptr<FormatHandler> GetHandler(Model &model) const = 0;
|
|
||||||
|
|
||||||
virtual bool CanStoreText() const { return false; }
|
|
||||||
virtual bool CanStoreImages() const { return false; }
|
|
||||||
virtual bool CanUseTime() const { return false; }
|
|
||||||
virtual bool CanUseFrames() const { return false; }
|
|
||||||
|
|
||||||
virtual bool HasStyles() const { return false; }
|
|
||||||
virtual bool HasMargins() const { return false; }
|
|
||||||
virtual bool HasActors() const { return false; }
|
|
||||||
virtual bool HasUserField() const { return false; }
|
|
||||||
virtual String GetUserFieldName() const { return L""; }
|
|
||||||
|
|
||||||
virtual int GetTimingPrecision() const { return 10; } // In milliseconds
|
|
||||||
virtual int GetMaxTime() const { return 36000000-10; } // In milliseconds, default 9h 59min 59.99s
|
|
||||||
|
|
||||||
virtual DialoguePtr CreateDialogue() const = 0;
|
|
||||||
virtual StylePtr CreateStyle() const = 0;
|
|
||||||
};
|
|
||||||
typedef shared_ptr<Format> FormatPtr;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,105 +0,0 @@
|
||||||
// Copyright (c) 2008, 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.
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// AEGISUB/ATHENASUB
|
|
||||||
//
|
|
||||||
// Website: http://www.aegisub.net
|
|
||||||
// Contact: mailto:amz@aegisub.net
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "athenastring.h"
|
|
||||||
#include "tr1.h"
|
|
||||||
#include "deltacoder.h"
|
|
||||||
#include "api.h"
|
|
||||||
|
|
||||||
namespace Athenasub {
|
|
||||||
|
|
||||||
// Types
|
|
||||||
enum SectionEntryType {
|
|
||||||
SECTION_ENTRY_PLAIN,
|
|
||||||
SECTION_ENTRY_DIALOGUE,
|
|
||||||
SECTION_ENTRY_STYLE,
|
|
||||||
SECTION_ENTRY_FILE,
|
|
||||||
SECTION_ENTRY_RAW
|
|
||||||
};
|
|
||||||
|
|
||||||
// Prototypes
|
|
||||||
class Entry;
|
|
||||||
class PlainText;
|
|
||||||
class Dialogue;
|
|
||||||
class Style;
|
|
||||||
class Attachment;
|
|
||||||
class RawEntry;
|
|
||||||
typedef shared_ptr<Entry> EntryPtr;
|
|
||||||
typedef shared_ptr<PlainText> PlainTextPtr;
|
|
||||||
typedef shared_ptr<Dialogue> DialoguePtr;
|
|
||||||
typedef shared_ptr<Style> StylePtr;
|
|
||||||
typedef shared_ptr<Attachment> AttachmentPtr;
|
|
||||||
typedef shared_ptr<RawEntry> RawEntryPtr;
|
|
||||||
typedef shared_ptr<const Entry> EntryConstPtr;
|
|
||||||
typedef shared_ptr<const PlainText> PlainTextConstPtr;
|
|
||||||
typedef shared_ptr<const Dialogue> DialogueConstPtr;
|
|
||||||
typedef shared_ptr<const Style> StyleConstPtr;
|
|
||||||
typedef shared_ptr<const Attachment> AttachmentConstPtr;
|
|
||||||
typedef shared_ptr<const RawEntry> RawEntryConstPtr;
|
|
||||||
|
|
||||||
// Section entry class
|
|
||||||
class Entry {
|
|
||||||
protected:
|
|
||||||
virtual ~Entry() {}
|
|
||||||
const String& EmptyString() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual SectionEntryType GetType() const =0;
|
|
||||||
virtual String GetDefaultGroup() const =0;
|
|
||||||
virtual EntryPtr Clone() const =0;
|
|
||||||
|
|
||||||
virtual DeltaCoderPtr GetDeltaCoder() const { return DeltaCoderPtr(); }
|
|
||||||
virtual bool IsIndexable() const { return false; }
|
|
||||||
virtual String GetIndexName() const { return L""; }
|
|
||||||
|
|
||||||
static const PlainTextPtr GetAsPlain(const EntryPtr &ptr);
|
|
||||||
static const DialoguePtr GetAsDialogue(const EntryPtr &ptr);
|
|
||||||
static const DialogueConstPtr GetAsDialogue(const EntryConstPtr &ptr);
|
|
||||||
static const StylePtr GetAsStyle(const EntryPtr &ptr);
|
|
||||||
static const AttachmentPtr GetAsFile(const EntryPtr &ptr);
|
|
||||||
static const RawEntryPtr GetAsRaw(const EntryPtr &ptr);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Section plain-text entry
|
|
||||||
class PlainText : public Entry {
|
|
||||||
public:
|
|
||||||
SectionEntryType GetType() const { return SECTION_ENTRY_PLAIN; }
|
|
||||||
virtual ~PlainText() {}
|
|
||||||
virtual String GetText() const =0;
|
|
||||||
virtual void SetText(const String &_data) =0;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
|
@ -35,26 +35,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef UNICODE
|
#include "api.h"
|
||||||
#error "This library requires unicode support."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "tr1.h"
|
#include "tr1.h"
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
#include "libathenasub.h"
|
#include "interfaces.h"
|
||||||
#include "model.h"
|
#include "range.h"
|
||||||
#include "view.h"
|
|
||||||
#include "controller.h"
|
|
||||||
#include "notification.h"
|
extern "C" Athenasub::ILibAthenaSub* CreateLibAthenasub(const char* hostName);
|
||||||
#include "athenastring.h"
|
|
||||||
#include "format.h"
|
|
||||||
#include "format_handler.h"
|
|
||||||
#include "format_manager.h"
|
|
||||||
#include "actionlist.h"
|
|
||||||
#include "section.h"
|
|
||||||
#include "section_entry_dialogue.h"
|
|
||||||
#include "section_entry_style.h"
|
|
||||||
#include "athenatime.h"
|
|
||||||
#include "colour.h"
|
|
||||||
#include "utils.h"
|
|
||||||
#include "version.h"
|
|
|
@ -34,21 +34,15 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "tr1.h"
|
|
||||||
|
#include "athenasub.h"
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
typedef Athenasub::ILibAthenaSub* (__stdcall *CreateLibAthenasubPtr)(const char*);
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
inline LibAthenaSub Create(HMODULE module,const char* hostName) {
|
||||||
// Void pointer prototyle
|
CreateLibAthenasubPtr CreateLib = (CreateLibAthenasubPtr)GetProcAddress(module,"CreateLibAthenaSub");
|
||||||
typedef shared_ptr<void> VoidPtr;
|
return LibAthenaSub(CreateLib(hostName));
|
||||||
|
}
|
||||||
// Deltacoder interface
|
|
||||||
class DeltaCoder {
|
|
||||||
public:
|
|
||||||
virtual ~DeltaCoder() {}
|
|
||||||
virtual VoidPtr EncodeDelta(VoidPtr from,VoidPtr to,bool withTextFields=true) const = 0;
|
|
||||||
virtual VoidPtr EncodeReverseDelta(VoidPtr delta,VoidPtr object) const = 0;
|
|
||||||
virtual void ApplyDelta(VoidPtr delta,VoidPtr object) const = 0;
|
|
||||||
};
|
|
||||||
typedef shared_ptr<DeltaCoder> DeltaCoderPtr;
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
// Copyright (c) 2008, 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.
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// AEGISUB/ATHENASUB
|
||||||
|
//
|
||||||
|
// Website: http://www.aegisub.net
|
||||||
|
// Contact: mailto:amz@aegisub.net
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
//#include "athenastring.h"
|
||||||
|
#include <string>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
namespace Athenasub {
|
||||||
|
|
||||||
|
// Exception class
|
||||||
|
class Exception : public std::exception {
|
||||||
|
public:
|
||||||
|
enum ExceptionList {
|
||||||
|
Unknown,
|
||||||
|
No_Format_Handler,
|
||||||
|
Invalid_ActionList,
|
||||||
|
Section_Already_Exists,
|
||||||
|
Unknown_Format,
|
||||||
|
Parse_Error,
|
||||||
|
Unsupported_Format_Feature,
|
||||||
|
Invalid_Token,
|
||||||
|
Out_Of_Range,
|
||||||
|
Invalid_Section,
|
||||||
|
Internal_Error,
|
||||||
|
TODO
|
||||||
|
};
|
||||||
|
|
||||||
|
Exception(ExceptionList _code) : std::exception(GetMessageChar(_code)) { code = _code; }
|
||||||
|
Exception(ExceptionList _code,const char* file,const long line) : std::exception(GetMessageFile(_code,file,line)) { code = _code; }
|
||||||
|
|
||||||
|
//String GetMessageString() const { return String(what(),wxConvLocal); }
|
||||||
|
int GetCode() { return code; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const char* GetMessageChar(int code)
|
||||||
|
{
|
||||||
|
switch (code) {
|
||||||
|
case Unknown: return "Unknown.";
|
||||||
|
case No_Format_Handler: return "Could not find a suitable format handler.";
|
||||||
|
case Invalid_ActionList: return "Invalid manipulator.";
|
||||||
|
case Section_Already_Exists: return "The specified section already exists in this model.";
|
||||||
|
case Unknown_Format: return "The specified file format is unknown.";
|
||||||
|
case Parse_Error: return "Parse error.";
|
||||||
|
case Unsupported_Format_Feature: return "This feature is not supported by this format.";
|
||||||
|
case Invalid_Token: return "Invalid type for this token.";
|
||||||
|
case Out_Of_Range: return "Out of range.";
|
||||||
|
case Invalid_Section: return "Invalid section.";
|
||||||
|
case Internal_Error: return "Internal error.";
|
||||||
|
case TODO: return "TODO";
|
||||||
|
}
|
||||||
|
return "Invalid code.";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char* GetMessageFile(int code,const char *file,long line)
|
||||||
|
{
|
||||||
|
static std::string str = GetMessageChar(code);
|
||||||
|
str = str + " (" + file + ":";
|
||||||
|
char buffer[16];
|
||||||
|
_itoa_s(line,buffer,10);
|
||||||
|
str = str + buffer + ")";
|
||||||
|
return str.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExceptionList code;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef THROW_ATHENA_EXCEPTION
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define THROW_ATHENA_EXCEPTION(code) throw Athenasub::Exception(code,__FILE__,__LINE__)
|
||||||
|
#else
|
||||||
|
#define THROW_ATHENA_EXCEPTION(code) throw Athenasub::Exception(code)
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -0,0 +1,455 @@
|
||||||
|
// Copyright (c) 2008, 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.
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// AEGISUB/ATHENASUB
|
||||||
|
//
|
||||||
|
// Website: http://www.aegisub.net
|
||||||
|
// Contact: mailto:amz@aegisub.net
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "tr1.h"
|
||||||
|
#include <wx/string.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
namespace Athenasub {
|
||||||
|
|
||||||
|
// Strings
|
||||||
|
typedef wxString String;
|
||||||
|
typedef std::vector<String> StringArray;
|
||||||
|
|
||||||
|
|
||||||
|
// Prototypes
|
||||||
|
class Range;
|
||||||
|
class ISelection;
|
||||||
|
class IController;
|
||||||
|
class IView;
|
||||||
|
class IFormatHandler;
|
||||||
|
class ITime;
|
||||||
|
class IColour;
|
||||||
|
class IEntry;
|
||||||
|
class IDialogue;
|
||||||
|
class IStyle;
|
||||||
|
class IFormat;
|
||||||
|
class IModel;
|
||||||
|
class IActionList;
|
||||||
|
class INotification;
|
||||||
|
class ISection;
|
||||||
|
class IDeltaCoder;
|
||||||
|
class CController;
|
||||||
|
|
||||||
|
|
||||||
|
// Smart pointers
|
||||||
|
typedef shared_ptr<void> VoidPtr;
|
||||||
|
typedef shared_ptr<ISelection> Selection;
|
||||||
|
typedef shared_ptr<IController> Controller;
|
||||||
|
typedef shared_ptr<IView> View;
|
||||||
|
typedef shared_ptr<IFormatHandler> FormatHandler;
|
||||||
|
typedef shared_ptr<ITime> Time;
|
||||||
|
typedef shared_ptr<IColour> Colour;
|
||||||
|
typedef shared_ptr<IEntry> Entry;
|
||||||
|
typedef shared_ptr<IDialogue> Dialogue;
|
||||||
|
typedef shared_ptr<IStyle> Style;
|
||||||
|
typedef shared_ptr<IFormat> Format;
|
||||||
|
typedef shared_ptr<IModel> Model;
|
||||||
|
typedef shared_ptr<IActionList> ActionList;
|
||||||
|
typedef shared_ptr<INotification> Notification;
|
||||||
|
typedef shared_ptr<ISection> Section;
|
||||||
|
typedef shared_ptr<IDeltaCoder> DeltaCoder;
|
||||||
|
|
||||||
|
|
||||||
|
// Const smart pointers
|
||||||
|
typedef shared_ptr<const IEntry> ConstEntry;
|
||||||
|
typedef shared_ptr<const IDialogue> ConstDialogue;
|
||||||
|
typedef shared_ptr<const IStyle> ConstStyle;
|
||||||
|
typedef shared_ptr<const IModel> ConstModel;
|
||||||
|
|
||||||
|
|
||||||
|
// Lists
|
||||||
|
typedef std::list<View> ViewList;
|
||||||
|
typedef std::list<ActionList> ActionStack;
|
||||||
|
|
||||||
|
|
||||||
|
// Model
|
||||||
|
class IModel {
|
||||||
|
friend class CFormatHandler;
|
||||||
|
friend class CActionList;
|
||||||
|
friend class CController;
|
||||||
|
friend class IAction;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void ProcessActionList(ActionList actionList,int type=0) = 0;
|
||||||
|
|
||||||
|
virtual String GetUndoMessage(const String owner=L"") const = 0;
|
||||||
|
virtual String GetRedoMessage(const String owner=L"") const = 0;
|
||||||
|
virtual bool CanUndo(const String owner=L"") const = 0;
|
||||||
|
virtual bool CanRedo(const String owner=L"") const = 0;
|
||||||
|
virtual void Undo(const String owner=L"") = 0;
|
||||||
|
virtual void Redo(const String owner=L"") = 0;
|
||||||
|
virtual void ActivateStack(ActionStack stack,bool isUndo,const String &owner) = 0;
|
||||||
|
|
||||||
|
virtual void DispatchNotifications(Notification notification) const = 0;
|
||||||
|
|
||||||
|
virtual void Clear() = 0;
|
||||||
|
virtual void Load(wxInputStream &input,Format format=Format(),const String encoding=L"") = 0;
|
||||||
|
virtual void Save(wxOutputStream &output,Format format=Format(),const String encoding=L"UTF-8") = 0;
|
||||||
|
|
||||||
|
virtual void AddSection(String name) = 0;
|
||||||
|
virtual Section GetSection(String name) const = 0;
|
||||||
|
virtual Section GetSectionByIndex(size_t index) const = 0;
|
||||||
|
virtual size_t GetSectionCount() const = 0;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~IModel();
|
||||||
|
|
||||||
|
virtual Controller CreateController()=0;
|
||||||
|
virtual Format GetFormat() const=0;
|
||||||
|
virtual void AddListener(View listener)=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// View
|
||||||
|
class IView {
|
||||||
|
public:
|
||||||
|
virtual ~IView() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Controller
|
||||||
|
class IController {
|
||||||
|
public:
|
||||||
|
virtual ~IController() {}
|
||||||
|
|
||||||
|
virtual ActionList CreateActionList(const String title,const String owner=L"",bool undoAble=true) = 0;
|
||||||
|
virtual Selection CreateSelection() = 0;
|
||||||
|
|
||||||
|
virtual void LoadFile(const String filename,const String encoding=L"") = 0;
|
||||||
|
virtual void SaveFile(const String filename,const String encoding=L"UTF-8") = 0;
|
||||||
|
|
||||||
|
virtual bool CanUndo(const String owner=L"") const = 0;
|
||||||
|
virtual bool CanRedo(const String owner=L"") const = 0;
|
||||||
|
virtual void Undo(const String owner=L"") = 0;
|
||||||
|
virtual void Redo(const String owner=L"") = 0;
|
||||||
|
|
||||||
|
virtual Dialogue CreateDialogue() const = 0;
|
||||||
|
virtual Style CreateStyle() const = 0;
|
||||||
|
|
||||||
|
virtual ConstDialogue GetDialogue(size_t n) const = 0;
|
||||||
|
virtual ConstStyle GetStyle(size_t n) const = 0;
|
||||||
|
virtual ConstStyle GetStyle(String name) const = 0;
|
||||||
|
virtual ConstEntry GetEntry(size_t n,String section) const = 0;
|
||||||
|
|
||||||
|
virtual const Format GetFormat() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Selection
|
||||||
|
class ISelection {
|
||||||
|
public:
|
||||||
|
virtual ~ISelection() {}
|
||||||
|
|
||||||
|
virtual void AddLine(size_t line) = 0;
|
||||||
|
virtual void RemoveLine(size_t line) = 0;
|
||||||
|
|
||||||
|
virtual void AddRange(const Range &range) = 0;
|
||||||
|
virtual void RemoveRange(const Range &range) = 0;
|
||||||
|
|
||||||
|
virtual void AddSelection(const Selection ¶m) = 0;
|
||||||
|
virtual void RemoveSelection(const Selection ¶m) = 0;
|
||||||
|
|
||||||
|
virtual void NormalizeRanges() = 0;
|
||||||
|
|
||||||
|
virtual size_t GetCount() const = 0;
|
||||||
|
virtual size_t GetRanges() const = 0;
|
||||||
|
virtual size_t GetLine(size_t n) const = 0;
|
||||||
|
virtual size_t GetLineInRange(size_t n,size_t range) const = 0;
|
||||||
|
virtual size_t GetLinesInRange(size_t range) const = 0;
|
||||||
|
virtual bool IsContiguous() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Time
|
||||||
|
class ITime {
|
||||||
|
public:
|
||||||
|
virtual ~ITime() {}
|
||||||
|
|
||||||
|
virtual void SetMS(int milliseconds) = 0;
|
||||||
|
virtual int GetMS() const = 0;
|
||||||
|
|
||||||
|
virtual String GetString(int ms_precision,int h_precision) const = 0;
|
||||||
|
virtual void ParseString(const String &data) = 0;
|
||||||
|
|
||||||
|
virtual Time Clone() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Color
|
||||||
|
class IColour {
|
||||||
|
public:
|
||||||
|
virtual ~IColour() {}
|
||||||
|
|
||||||
|
virtual void SetRed(int red) = 0;
|
||||||
|
virtual void SetGreen(int green) = 0;
|
||||||
|
virtual void SetBlue(int blue) = 0;
|
||||||
|
virtual void SetAlpha(int alpha) = 0;
|
||||||
|
|
||||||
|
virtual int GetRed() const = 0;
|
||||||
|
virtual int GetGreen() const = 0;
|
||||||
|
virtual int GetBlue() const = 0;
|
||||||
|
virtual int GetAlpha() const = 0;
|
||||||
|
|
||||||
|
virtual void Parse(String str,bool reverse) = 0;
|
||||||
|
virtual String GetVBHex(bool withAlpha=false,bool withHeader=true,bool withFooter=true) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Types
|
||||||
|
enum SectionEntryType {
|
||||||
|
SECTION_ENTRY_PLAIN,
|
||||||
|
SECTION_ENTRY_DIALOGUE,
|
||||||
|
SECTION_ENTRY_STYLE,
|
||||||
|
SECTION_ENTRY_FILE,
|
||||||
|
SECTION_ENTRY_RAW
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Entry
|
||||||
|
class IEntry {
|
||||||
|
public:
|
||||||
|
virtual ~IEntry() {}
|
||||||
|
|
||||||
|
virtual DeltaCoder GetDeltaCoder() const { return DeltaCoder(); }
|
||||||
|
|
||||||
|
virtual bool IsIndexable() const { return false; }
|
||||||
|
virtual String GetIndexName() const { return L""; }
|
||||||
|
virtual String GetDefaultGroup() const = 0;
|
||||||
|
|
||||||
|
virtual Entry Clone() const = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
static PlainTextPtr GetAsPlain(EntryPtr ptr);
|
||||||
|
static DialoguePtr GetAsDialogue(EntryPtr ptr);
|
||||||
|
static DialogueConstPtr GetAsDialogue(EntryConstPtr ptr);
|
||||||
|
static StylePtr GetAsStyle(EntryPtr ptr);
|
||||||
|
static AttachmentPtr GetAsFile(EntryPtr ptr);
|
||||||
|
static RawEntryPtr GetAsRaw(EntryPtr ptr);
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Dialogue
|
||||||
|
class IDialogue : public IEntry {
|
||||||
|
public:
|
||||||
|
// Destructor
|
||||||
|
virtual ~IDialogue() {}
|
||||||
|
|
||||||
|
// Type
|
||||||
|
SectionEntryType GetType() const { return SECTION_ENTRY_DIALOGUE; }
|
||||||
|
Dialogue GetAsDialogue() { return Dialogue(this); }
|
||||||
|
|
||||||
|
// Capabilities
|
||||||
|
virtual bool HasText() const { return false; }
|
||||||
|
virtual bool HasImage() const { return false; }
|
||||||
|
virtual bool HasTime() const { return false; }
|
||||||
|
virtual bool HasFrame() const { return false; }
|
||||||
|
virtual bool HasStyle() const { return false; }
|
||||||
|
virtual bool HasActor() const { return false; }
|
||||||
|
virtual bool HasMargins() const { return false; }
|
||||||
|
|
||||||
|
// Read accessors
|
||||||
|
virtual const String& GetText() const = 0;
|
||||||
|
virtual const ITime& GetStartTime() const = 0;
|
||||||
|
virtual const ITime& GetEndTime() const = 0;
|
||||||
|
virtual int GetStartFrame() const = 0;
|
||||||
|
virtual int GetEndFrame() const = 0;
|
||||||
|
virtual bool IsComment() const = 0;
|
||||||
|
virtual int GetLayer() const = 0;
|
||||||
|
virtual int GetMargin(int n) const = 0;
|
||||||
|
virtual const String& GetStyle() const = 0;
|
||||||
|
virtual const String& GetActor() const = 0;
|
||||||
|
virtual const String& GetUserField() const = 0;
|
||||||
|
|
||||||
|
// Write accessors
|
||||||
|
virtual void SetText(const String& text) = 0;
|
||||||
|
virtual void SetStartTime(Time start) = 0;
|
||||||
|
virtual void SetEndTime(Time end) = 0;
|
||||||
|
virtual void SetStartFrame(int start) = 0;
|
||||||
|
virtual void SetEndFrame(int end) = 0;
|
||||||
|
virtual void SetComment(bool isComment) = 0;
|
||||||
|
virtual void SetLayer(int layer) = 0;
|
||||||
|
virtual void SetMargin(int margin,int value) = 0;
|
||||||
|
virtual void SetStyle(const String& style) = 0;
|
||||||
|
virtual void SetActor(const String& actor) = 0;
|
||||||
|
virtual void SetUserField(const String& userField) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Style
|
||||||
|
class IStyle : public IEntry {
|
||||||
|
public:
|
||||||
|
virtual ~IStyle() {}
|
||||||
|
|
||||||
|
// Type
|
||||||
|
SectionEntryType GetType() const { return SECTION_ENTRY_STYLE; }
|
||||||
|
Style GetAsStyle() { return Style(this); }
|
||||||
|
|
||||||
|
// Read accessors
|
||||||
|
virtual String GetName() const = 0;
|
||||||
|
virtual String GetFontName() const = 0;
|
||||||
|
virtual float GetFontSize() const = 0;
|
||||||
|
virtual const IColour& GetColour(int n) const = 0;
|
||||||
|
virtual int GetMargin(int n) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Format
|
||||||
|
class IFormat {
|
||||||
|
public:
|
||||||
|
virtual ~IFormat() {}
|
||||||
|
|
||||||
|
virtual String GetName() const = 0;
|
||||||
|
virtual StringArray GetReadExtensions() const = 0;
|
||||||
|
virtual StringArray GetWriteExtensions() const = 0;
|
||||||
|
//virtual FormatHandler GetHandler(Model &model) const = 0;
|
||||||
|
|
||||||
|
virtual bool CanStoreText() const = 0;
|
||||||
|
virtual bool CanStoreImages() const = 0;
|
||||||
|
virtual bool CanUseTime() const = 0;
|
||||||
|
virtual bool CanUseFrames() const = 0;
|
||||||
|
|
||||||
|
virtual bool HasStyles() const = 0;
|
||||||
|
virtual bool HasMargins() const = 0;
|
||||||
|
virtual bool HasActors() const = 0;
|
||||||
|
virtual bool HasUserField() const = 0;
|
||||||
|
virtual String GetUserFieldName() const = 0;
|
||||||
|
|
||||||
|
virtual int GetTimingPrecision() const = 0; // In milliseconds
|
||||||
|
virtual int GetMaxTime() const = 0; // In milliseconds
|
||||||
|
|
||||||
|
virtual Dialogue CreateDialogue() const = 0;
|
||||||
|
virtual Style CreateStyle() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Format handler
|
||||||
|
class IFormatHandler {
|
||||||
|
public:
|
||||||
|
virtual ~IFormatHandler() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Action interface
|
||||||
|
class IAction;
|
||||||
|
typedef shared_ptr<IAction> Action;
|
||||||
|
class IAction {
|
||||||
|
public:
|
||||||
|
virtual ~IAction() {}
|
||||||
|
virtual Action GetAntiAction(ConstModel model) const = 0;
|
||||||
|
virtual void Execute(Model model) = 0;
|
||||||
|
|
||||||
|
Section GetSection(Model model,const String &name) const { return model->GetSection(name); }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Action list
|
||||||
|
class IActionList {
|
||||||
|
public:
|
||||||
|
virtual ~IActionList() {}
|
||||||
|
|
||||||
|
virtual String GetName() const = 0;
|
||||||
|
virtual String GetOwner() const = 0;
|
||||||
|
|
||||||
|
virtual void AddAction(const Action action) = 0;
|
||||||
|
virtual void Finish() = 0;
|
||||||
|
|
||||||
|
virtual void InsertLine(Entry line,int position=-1,const String section=L"") = 0;
|
||||||
|
virtual void RemoveLine(int position,const String section) = 0;
|
||||||
|
virtual Entry ModifyLine(int position,const String section) = 0;
|
||||||
|
virtual std::vector<Entry> ModifyLines(Selection selection,const String section) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Section
|
||||||
|
class ISection {
|
||||||
|
public:
|
||||||
|
virtual ~ISection() {}
|
||||||
|
|
||||||
|
// Section name
|
||||||
|
virtual void SetName(const String& newName) = 0;
|
||||||
|
virtual const String& GetName() const = 0;
|
||||||
|
|
||||||
|
// Script properties
|
||||||
|
virtual void SetProperty(const String &key,const String &value) = 0;
|
||||||
|
virtual void UnsetProperty(const String &key) = 0;
|
||||||
|
virtual String GetProperty(const String &key) const = 0;
|
||||||
|
virtual bool HasProperty(const String &key) const = 0;
|
||||||
|
virtual size_t GetPropertyCount() const = 0;
|
||||||
|
virtual String GetPropertyName(size_t index) const = 0;
|
||||||
|
|
||||||
|
// Indexed
|
||||||
|
virtual Entry GetFromIndex(String key) const = 0;
|
||||||
|
|
||||||
|
// Entries
|
||||||
|
virtual void AddEntry(Entry entry,int pos=-1) = 0;
|
||||||
|
virtual void RemoveEntryByIndex(size_t index) = 0;
|
||||||
|
virtual void RemoveEntry(Entry entry) = 0;
|
||||||
|
virtual Entry GetEntry(size_t index) const = 0;
|
||||||
|
virtual Entry& GetEntryRef(size_t index) const = 0;
|
||||||
|
virtual size_t GetEntryCount() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Delta coder
|
||||||
|
class IDeltaCoder {
|
||||||
|
public:
|
||||||
|
virtual ~IDeltaCoder() {}
|
||||||
|
virtual VoidPtr EncodeDelta(VoidPtr from,VoidPtr to,bool withTextFields=true) const = 0;
|
||||||
|
virtual VoidPtr EncodeReverseDelta(VoidPtr delta,VoidPtr object) const = 0;
|
||||||
|
virtual void ApplyDelta(VoidPtr delta,VoidPtr object) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Library
|
||||||
|
class ILibAthenaSub {
|
||||||
|
public:
|
||||||
|
virtual ~ILibAthenaSub() {}
|
||||||
|
|
||||||
|
virtual Model CreateModel()=0;
|
||||||
|
};
|
||||||
|
typedef shared_ptr<ILibAthenaSub> LibAthenaSub;
|
||||||
|
|
||||||
|
|
||||||
|
// Operators
|
||||||
|
Time operator+(const ITime& p1,int p2) { Time res = p1.Clone(); res->SetMS(res->GetMS()+p2); return res; }
|
||||||
|
Time operator-(const ITime& p1,int p2) { Time res = p1.Clone(); res->SetMS(res->GetMS()-p2); return res; }
|
||||||
|
bool operator==(const ITime& p1,const ITime& p2) { return p1.GetMS() == p2.GetMS(); }
|
||||||
|
|
||||||
|
}
|
|
@ -34,7 +34,8 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "exception.h"
|
//#include "exception.h"
|
||||||
|
#include "interfaces.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
|
@ -49,7 +50,9 @@ namespace Athenasub {
|
||||||
|
|
||||||
size_t GetLine(size_t n) const {
|
size_t GetLine(size_t n) const {
|
||||||
if (start+n < end) return start+n;
|
if (start+n < end) return start+n;
|
||||||
else THROW_ATHENA_EXCEPTION(Exception::Out_Of_Range);
|
//else THROW_ATHENA_EXCEPTION(Exception::Out_Of_Range);
|
||||||
|
// TODO: fixme
|
||||||
|
throw 0;
|
||||||
}
|
}
|
||||||
size_t GetSize() const { return end-start; }
|
size_t GetSize() const { return end-start; }
|
||||||
size_t GetStart() const { return start; }
|
size_t GetStart() const { return start; }
|
|
@ -33,45 +33,38 @@
|
||||||
// Contact: mailto:amz@aegisub.net
|
// Contact: mailto:amz@aegisub.net
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "athenasub.h"
|
#include "action.h"
|
||||||
|
#include "model.h"
|
||||||
using namespace Athenasub;
|
using namespace Athenasub;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
// Get a section from the model
|
|
||||||
SectionPtr Action::GetSection(const Model &model,const String &name) const
|
|
||||||
{
|
|
||||||
return model.GetSection(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////// Insert line /////////////////////////////
|
///////////////////////////// Insert line /////////////////////////////
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
ActionInsert::ActionInsert(shared_ptr<Entry> data,int line,const String &sName)
|
ActionInsert::ActionInsert(Entry data,int line,const String &sName)
|
||||||
: entry(data), lineNumber(line), section(sName) {}
|
: entry(data), lineNumber(line), section(sName) {}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Create anti-action for insert
|
// Create anti-action for insert
|
||||||
ActionPtr ActionInsert::GetAntiAction(const Model &model) const
|
Action ActionInsert::GetAntiAction(ConstModel model) const
|
||||||
{
|
{
|
||||||
(void) model;
|
(void) model;
|
||||||
String sect = section;
|
String sect = section;
|
||||||
if (section.IsEmpty()) sect = entry->GetDefaultGroup();
|
if (section.IsEmpty()) sect = entry->GetDefaultGroup();
|
||||||
return ActionPtr(new ActionRemove(lineNumber,sect));
|
return Action(new ActionRemove(lineNumber,sect));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// Execute insertion
|
// Execute insertion
|
||||||
void ActionInsert::Execute(Model &model)
|
void ActionInsert::Execute(Model model)
|
||||||
{
|
{
|
||||||
// Find the section to insert it on
|
// Find the section to insert it on
|
||||||
String sectionName = section;
|
String sectionName = section;
|
||||||
if (sectionName.IsEmpty()) sectionName = entry->GetDefaultGroup();
|
if (sectionName.IsEmpty()) sectionName = entry->GetDefaultGroup();
|
||||||
SectionPtr sect = GetSection(model,sectionName);
|
Section sect = GetSection(model,sectionName);
|
||||||
|
|
||||||
// Insert the line
|
// Insert the line
|
||||||
sect->AddEntry(entry,lineNumber);
|
sect->AddEntry(entry,lineNumber);
|
||||||
|
@ -90,17 +83,17 @@ ActionRemove::ActionRemove(int line,const String &sName)
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Create anti-action for remove
|
// Create anti-action for remove
|
||||||
ActionPtr ActionRemove::GetAntiAction(const Model &model) const
|
Action ActionRemove::GetAntiAction(ConstModel model) const
|
||||||
{
|
{
|
||||||
SectionPtr sect = GetSection(model,section);
|
SectionPtr sect = GetSection(model,section);
|
||||||
EntryPtr entry = sect->GetEntry(lineNumber);
|
Entry entry = sect->GetEntry(lineNumber);
|
||||||
return ActionPtr(new ActionInsert(entry,lineNumber,section));
|
return Action(new ActionInsert(entry,lineNumber,section));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// Execute removal
|
// Execute removal
|
||||||
void ActionRemove::Execute(Model &model)
|
void ActionRemove::Execute(Model model)
|
||||||
{
|
{
|
||||||
// Find the section to remote it from
|
// Find the section to remote it from
|
||||||
String sect = section;
|
String sect = section;
|
||||||
|
@ -116,7 +109,7 @@ void ActionRemove::Execute(Model &model)
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// Constructors
|
// Constructors
|
||||||
ActionModify::ActionModify(shared_ptr<Entry> data,int line,const String &sName,bool _noTextFields)
|
ActionModify::ActionModify(Entry data,int line,const String &sName,bool _noTextFields)
|
||||||
: entry(data), lineNumber(line), section(sName), noTextFields(_noTextFields) {}
|
: entry(data), lineNumber(line), section(sName), noTextFields(_noTextFields) {}
|
||||||
|
|
||||||
ActionModify::ActionModify(shared_ptr<void> _delta,int line,const String &sName)
|
ActionModify::ActionModify(shared_ptr<void> _delta,int line,const String &sName)
|
||||||
|
@ -125,40 +118,40 @@ ActionModify::ActionModify(shared_ptr<void> _delta,int line,const String &sName)
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Create anti-action for insert
|
// Create anti-action for insert
|
||||||
ActionPtr ActionModify::GetAntiAction(const Model &model) const
|
Action ActionModify::GetAntiAction(ConstModel model) const
|
||||||
{
|
{
|
||||||
// Get section and original line
|
// Get section and original line
|
||||||
SectionPtr sect = GetSection(model,section);
|
Section sect = GetSection(model,section);
|
||||||
EntryPtr oldEntry = sect->GetEntry(lineNumber);
|
Entry oldEntry = sect->GetEntry(lineNumber);
|
||||||
|
|
||||||
// Try to get a delta
|
// Try to get a delta
|
||||||
DeltaCoderPtr deltaCoder = oldEntry->GetDeltaCoder();
|
DeltaCoder deltaCoder = oldEntry->GetDeltaCoder();
|
||||||
if (deltaCoder) {
|
if (deltaCoder) {
|
||||||
VoidPtr _delta;
|
VoidPtr _delta;
|
||||||
if (entry) _delta = deltaCoder->EncodeDelta(entry,oldEntry,!noTextFields);
|
if (entry) _delta = deltaCoder->EncodeDelta(entry,oldEntry,!noTextFields);
|
||||||
else _delta = deltaCoder->EncodeReverseDelta(delta,oldEntry);
|
else _delta = deltaCoder->EncodeReverseDelta(delta,oldEntry);
|
||||||
return ActionPtr(new ActionModify(_delta,lineNumber,section));
|
return Action(new ActionModify(_delta,lineNumber,section));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the whole original line
|
// Store the whole original line
|
||||||
else {
|
else {
|
||||||
return ActionPtr(new ActionModify(oldEntry,lineNumber,section,noTextFields));
|
return Action(new ActionModify(oldEntry,lineNumber,section,noTextFields));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// Execute insertion
|
// Execute insertion
|
||||||
void ActionModify::Execute(Model &model)
|
void ActionModify::Execute(Model model)
|
||||||
{
|
{
|
||||||
// Find the section to modify
|
// Find the section to modify
|
||||||
String sectionName = section;
|
String sectionName = section;
|
||||||
if (sectionName.IsEmpty()) sectionName = entry->GetDefaultGroup();
|
if (sectionName.IsEmpty()) sectionName = entry->GetDefaultGroup();
|
||||||
SectionPtr sect = GetSection(model,sectionName);
|
Section sect = GetSection(model,sectionName);
|
||||||
|
|
||||||
// Modify the line
|
// Modify the line
|
||||||
if (delta) {
|
if (delta) {
|
||||||
EntryPtr &ref = sect->GetEntryRef(lineNumber);
|
Entry ref = sect->GetEntry(lineNumber);
|
||||||
ref->GetDeltaCoder()->ApplyDelta(delta,ref);
|
ref->GetDeltaCoder()->ApplyDelta(delta,ref);
|
||||||
}
|
}
|
||||||
else sect->GetEntryRef(lineNumber) = entry;
|
else sect->GetEntryRef(lineNumber) = entry;
|
||||||
|
@ -167,24 +160,24 @@ void ActionModify::Execute(Model &model)
|
||||||
|
|
||||||
////////////////////////// Batch Modify line //////////////////////////
|
////////////////////////// Batch Modify line //////////////////////////
|
||||||
|
|
||||||
ActionModifyBatch::ActionModifyBatch(std::vector<shared_ptr<Entry> > _entries, std::vector<shared_ptr<void> > _deltas, Selection _selection,const String &_section,bool _noTextFields)
|
ActionModifyBatch::ActionModifyBatch(std::vector<Entry> _entries, std::vector<shared_ptr<void> > _deltas, Selection _selection,const String &_section,bool _noTextFields)
|
||||||
: entries(_entries), deltas(_deltas), selection(_selection), section(_section), noTextFields(_noTextFields) {}
|
: entries(_entries), deltas(_deltas), selection(_selection), section(_section), noTextFields(_noTextFields) {}
|
||||||
|
|
||||||
ActionPtr ActionModifyBatch::GetAntiAction(const Model &model) const
|
Action ActionModifyBatch::GetAntiAction(ConstModel model) const
|
||||||
{
|
{
|
||||||
// Get section
|
// Get section
|
||||||
SectionPtr sect = GetSection(model,section);
|
SectionPtr sect = GetSection(model,section);
|
||||||
size_t len = selection.GetCount();
|
size_t len = selection->GetCount();
|
||||||
std::vector<VoidPtr> _deltas(len);
|
std::vector<VoidPtr> _deltas(len);
|
||||||
std::vector<EntryPtr> oldEntries(len);
|
std::vector<Entry> oldEntries(len);
|
||||||
|
|
||||||
// For each line...
|
// For each line...
|
||||||
for (size_t i=0;i<len;i++) {
|
for (size_t i=0;i<len;i++) {
|
||||||
// Get old entry
|
// Get old entry
|
||||||
EntryPtr oldEntry = sect->GetEntry(selection.GetLine(i));
|
Entry oldEntry = sect->GetEntry(selection->GetLine(i));
|
||||||
|
|
||||||
// Try to get a delta
|
// Try to get a delta
|
||||||
DeltaCoderPtr deltaCoder = oldEntry->GetDeltaCoder();
|
DeltaCoder deltaCoder = oldEntry->GetDeltaCoder();
|
||||||
if (deltaCoder) {
|
if (deltaCoder) {
|
||||||
if (i < deltas.size() && deltas[i]) _deltas[i] = deltaCoder->EncodeReverseDelta(deltas[i],oldEntry);
|
if (i < deltas.size() && deltas[i]) _deltas[i] = deltaCoder->EncodeReverseDelta(deltas[i],oldEntry);
|
||||||
_deltas[i] = deltaCoder->EncodeDelta(entries[i],oldEntry,!noTextFields);
|
_deltas[i] = deltaCoder->EncodeDelta(entries[i],oldEntry,!noTextFields);
|
||||||
|
@ -194,23 +187,23 @@ ActionPtr ActionModifyBatch::GetAntiAction(const Model &model) const
|
||||||
else oldEntries[i] = oldEntry;
|
else oldEntries[i] = oldEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ActionPtr(new ActionModifyBatch(oldEntries,_deltas,selection,section,noTextFields));
|
return Action(new ActionModifyBatch(oldEntries,_deltas,selection,section,noTextFields));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionModifyBatch::Execute(Model &model)
|
void ActionModifyBatch::Execute(Model model)
|
||||||
{
|
{
|
||||||
// Find the section to modify
|
// Find the section to modify
|
||||||
size_t len = selection.GetCount();
|
size_t len = selection->GetCount();
|
||||||
String sectionName = section;
|
String sectionName = section;
|
||||||
if (sectionName.IsEmpty()) sectionName = entries[0]->GetDefaultGroup();
|
if (sectionName.IsEmpty()) sectionName = entries[0]->GetDefaultGroup();
|
||||||
SectionPtr sect = GetSection(model,sectionName);
|
Section sect = GetSection(model,sectionName);
|
||||||
|
|
||||||
// For each line...
|
// For each line...
|
||||||
for (size_t i=0;i<len;i++) {
|
for (size_t i=0;i<len;i++) {
|
||||||
if (i < deltas.size() && deltas[i]) {
|
if (i < deltas.size() && deltas[i]) {
|
||||||
EntryPtr &ref = sect->GetEntryRef(selection.GetLine(i));
|
Entry &ref = sect->GetEntryRef(selection->GetLine(i));
|
||||||
ref->GetDeltaCoder()->ApplyDelta(deltas[i],ref);
|
ref->GetDeltaCoder()->ApplyDelta(deltas[i],ref);
|
||||||
}
|
}
|
||||||
else sect->GetEntryRef(selection.GetLine(i)) = entries[i];
|
else sect->GetEntryRef(selection->GetLine(i)) = entries[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,44 +36,27 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "athenastring.h"
|
#include "athenastring.h"
|
||||||
#include "selection.h"
|
#include "selection.h"
|
||||||
|
#include "interfaces.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
// Prototypes
|
|
||||||
class Model;
|
|
||||||
class Entry;
|
|
||||||
class Action;
|
|
||||||
class Section;
|
|
||||||
typedef shared_ptr<Action> ActionPtr;
|
|
||||||
typedef shared_ptr<Section> SectionPtr;
|
|
||||||
|
|
||||||
// Action interface
|
|
||||||
class Action {
|
|
||||||
protected:
|
|
||||||
SectionPtr GetSection(const Model &model,const String &name) const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual ~Action() {}
|
|
||||||
virtual ActionPtr GetAntiAction(const Model &model) const =0;
|
|
||||||
virtual void Execute(Model &model) =0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Insert line
|
// Insert line
|
||||||
class ActionInsert : public Action {
|
class ActionInsert : public IAction {
|
||||||
private:
|
private:
|
||||||
shared_ptr<Entry> entry;
|
Entry entry;
|
||||||
const String section;
|
const String section;
|
||||||
int lineNumber;
|
int lineNumber;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ActionInsert(shared_ptr<Entry> entry,int line,const String §ion);
|
ActionInsert(Entry entry,int line,const String §ion);
|
||||||
~ActionInsert() {}
|
~ActionInsert() {}
|
||||||
|
|
||||||
ActionPtr GetAntiAction(const Model &model) const;
|
Action GetAntiAction(ConstModel model) const;
|
||||||
void Execute(Model &model);
|
void Execute(Model model);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remove line
|
// Remove line
|
||||||
class ActionRemove : public Action {
|
class ActionRemove : public IAction {
|
||||||
private:
|
private:
|
||||||
const String section;
|
const String section;
|
||||||
int lineNumber;
|
int lineNumber;
|
||||||
|
@ -82,42 +65,42 @@ namespace Athenasub {
|
||||||
ActionRemove(int line,const String §ion);
|
ActionRemove(int line,const String §ion);
|
||||||
~ActionRemove() {}
|
~ActionRemove() {}
|
||||||
|
|
||||||
ActionPtr GetAntiAction(const Model &model) const;
|
Action GetAntiAction(ConstModel model) const;
|
||||||
void Execute(Model &model);
|
void Execute(Model model);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Modify line
|
// Modify line
|
||||||
class ActionModify : public Action {
|
class ActionModify : public IAction {
|
||||||
private:
|
private:
|
||||||
shared_ptr<Entry> entry;
|
Entry entry;
|
||||||
shared_ptr<void> delta;
|
VoidPtr delta;
|
||||||
const String section;
|
const String section;
|
||||||
int lineNumber;
|
int lineNumber;
|
||||||
bool noTextFields;
|
bool noTextFields;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ActionModify(shared_ptr<Entry> entry,int line,const String §ion,bool noTextFields);
|
ActionModify(Entry entry,int line,const String §ion,bool noTextFields);
|
||||||
ActionModify(shared_ptr<void> delta,int line,const String §ion);
|
ActionModify(shared_ptr<void> delta,int line,const String §ion);
|
||||||
~ActionModify() {}
|
~ActionModify() {}
|
||||||
|
|
||||||
ActionPtr GetAntiAction(const Model &model) const;
|
Action GetAntiAction(ConstModel model) const;
|
||||||
void Execute(Model &model);
|
void Execute(Model model);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Modify several lines
|
// Modify several lines
|
||||||
class ActionModifyBatch : public Action {
|
class ActionModifyBatch : public IAction {
|
||||||
private:
|
private:
|
||||||
std::vector<shared_ptr<Entry> > entries;
|
std::vector<Entry> entries;
|
||||||
std::vector<shared_ptr<void> > deltas;
|
std::vector<VoidPtr> deltas;
|
||||||
Selection selection;
|
Selection selection;
|
||||||
const String section;
|
const String section;
|
||||||
bool noTextFields;
|
bool noTextFields;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ActionModifyBatch(std::vector<shared_ptr<Entry> > entries,std::vector<shared_ptr<void> > deltas,Selection selection,const String §ion,bool noTextFields);
|
ActionModifyBatch(std::vector<Entry> entries,std::vector<VoidPtr> deltas,Selection selection,const String §ion,bool noTextFields);
|
||||||
~ActionModifyBatch() {}
|
~ActionModifyBatch() {}
|
||||||
|
|
||||||
ActionPtr GetAntiAction(const Model &model) const;
|
Action GetAntiAction(ConstModel model) const;
|
||||||
void Execute(Model &model);
|
void Execute(Model model);
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -33,13 +33,14 @@
|
||||||
// Contact: mailto:amz@aegisub.net
|
// Contact: mailto:amz@aegisub.net
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Athenasub.h"
|
#include "actionlist.h"
|
||||||
|
#include "model.h"
|
||||||
using namespace Athenasub;
|
using namespace Athenasub;
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
ActionList::ActionList(Model &_model,String _actionName,const String _owner,bool _undoAble)
|
CActionList::CActionList(Model _model,String _actionName,const String _owner,bool _undoAble)
|
||||||
: model(_model), owner(_owner), undoAble(_undoAble)
|
: model(_model), owner(_owner), undoAble(_undoAble)
|
||||||
{
|
{
|
||||||
valid = false;
|
valid = false;
|
||||||
|
@ -49,14 +50,14 @@ ActionList::ActionList(Model &_model,String _actionName,const String _owner,bool
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
// Destructor
|
// Destructor
|
||||||
ActionList::~ActionList()
|
CActionList::~CActionList()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// Add an action to the queue
|
// Add an action to the queue
|
||||||
void ActionList::AddAction(const ActionPtr action)
|
void CActionList::AddAction(const Action action)
|
||||||
{
|
{
|
||||||
if (!valid) THROW_ATHENA_EXCEPTION(Exception::Invalid_ActionList);
|
if (!valid) THROW_ATHENA_EXCEPTION(Exception::Invalid_ActionList);
|
||||||
actions.push_back(action);
|
actions.push_back(action);
|
||||||
|
@ -69,7 +70,7 @@ void ActionList::AddAction(const ActionPtr action)
|
||||||
|
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
// Add an action to the start of the queue
|
// Add an action to the start of the queue
|
||||||
void ActionList::AddActionStart(const ActionPtr action)
|
void CActionList::AddActionStart(const Action action)
|
||||||
{
|
{
|
||||||
if (!valid) THROW_ATHENA_EXCEPTION(Exception::Invalid_ActionList);
|
if (!valid) THROW_ATHENA_EXCEPTION(Exception::Invalid_ActionList);
|
||||||
actions.push_front(action);
|
actions.push_front(action);
|
||||||
|
@ -82,7 +83,7 @@ void ActionList::AddActionStart(const ActionPtr action)
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Starts performing actions
|
// Starts performing actions
|
||||||
void ActionList::Start(const String name)
|
void CActionList::Start(const String name)
|
||||||
{
|
{
|
||||||
if (valid) Finish();
|
if (valid) Finish();
|
||||||
actionName = name;
|
actionName = name;
|
||||||
|
@ -92,10 +93,10 @@ void ActionList::Start(const String name)
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
// Ends the action list
|
// Ends the action list
|
||||||
void ActionList::Finish()
|
void CActionList::Finish()
|
||||||
{
|
{
|
||||||
if (valid) {
|
if (valid) {
|
||||||
model.ProcessActionList(*this);
|
model->ProcessActionList(ActionList(this));
|
||||||
actions.clear();
|
actions.clear();
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
@ -104,29 +105,29 @@ void ActionList::Finish()
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
// Create an "insert line" action
|
// Create an "insert line" action
|
||||||
void ActionList::InsertLine(EntryPtr line,int position,const String section)
|
void CActionList::InsertLine(Entry line,int position,const String section)
|
||||||
{
|
{
|
||||||
ActionPtr action = ActionPtr (new ActionInsert(line,position,section));
|
Action action = Action (new ActionInsert(line,position,section));
|
||||||
AddAction(action);
|
AddAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Create a "remove line" action
|
// Create a "remove line" action
|
||||||
void ActionList::RemoveLine(int position,const String section)
|
void CActionList::RemoveLine(int position,const String section)
|
||||||
{
|
{
|
||||||
ActionPtr action = ActionPtr (new ActionRemove(position,section));
|
Action action = Action (new ActionRemove(position,section));
|
||||||
AddAction(action);
|
AddAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Insert a "modify line" action
|
// Insert a "modify line" action
|
||||||
EntryPtr ActionList::ModifyLine(int position,const String section)
|
Entry CActionList::ModifyLine(int position,const String section)
|
||||||
{
|
{
|
||||||
SectionPtr sect = model.GetSection(section);
|
Section sect = model->GetSection(section);
|
||||||
EntryPtr entry = sect->GetEntry(position)->Clone();
|
Entry entry = sect->GetEntry(position)->Clone();
|
||||||
ActionPtr action = ActionPtr (new ActionModify(entry,position,section,false));
|
Action action = Action (new ActionModify(entry,position,section,false));
|
||||||
AddAction(action);
|
AddAction(action);
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
@ -134,24 +135,24 @@ EntryPtr ActionList::ModifyLine(int position,const String section)
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// Insert a "modify lines" batch action
|
// Insert a "modify lines" batch action
|
||||||
std::vector<EntryPtr> ActionList::ModifyLines(Selection selection,const String section)
|
std::vector<Entry> CActionList::ModifyLines(Selection selection,const String section)
|
||||||
{
|
{
|
||||||
// Get section
|
// Get section
|
||||||
SectionPtr sect = model.GetSection(section);
|
Section sect = model->GetSection(section);
|
||||||
|
|
||||||
// Generate entries
|
// Generate entries
|
||||||
std::vector<EntryPtr> entries(selection.GetCount());
|
std::vector<Entry> entries(selection->GetCount());
|
||||||
size_t len = selection.GetRanges();
|
size_t len = selection->GetRanges();
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
for (size_t i=0;i<len;i++) {
|
for (size_t i=0;i<len;i++) {
|
||||||
size_t rLen = selection.GetLinesInRange(i);
|
size_t rLen = selection->GetLinesInRange(i);
|
||||||
for (size_t j=0;j<rLen;j++) {
|
for (size_t j=0;j<rLen;j++) {
|
||||||
entries[n++] = sect->GetEntry(selection.GetLineInRange(j,i))->Clone();
|
entries[n++] = sect->GetEntry(selection->GetLineInRange(j,i))->Clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the action
|
// Generate the action
|
||||||
ActionPtr action = ActionPtr (new ActionModifyBatch(entries,std::vector<VoidPtr>(),selection,section,false));
|
Action action = Action (new ActionModifyBatch(entries,std::vector<VoidPtr>(),selection,section,false));
|
||||||
AddAction(action);
|
AddAction(action);
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,43 +40,44 @@
|
||||||
#include "section_entry.h"
|
#include "section_entry.h"
|
||||||
#include "selection.h"
|
#include "selection.h"
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
|
#include "model.h"
|
||||||
|
#include "interfaces.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Prototypes
|
// Prototypes
|
||||||
class Controller;
|
class CController;
|
||||||
|
|
||||||
// ActionList class
|
// ActionList class
|
||||||
class ActionList {
|
class CActionList : public IActionList {
|
||||||
friend class Model;
|
friend class CModel;
|
||||||
friend class Controller;
|
friend class CController;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String actionName;
|
String actionName;
|
||||||
String owner;
|
String owner;
|
||||||
Model &model;
|
Model model;
|
||||||
std::list<ActionPtr> actions;
|
std::list<Action> actions;
|
||||||
bool valid;
|
bool valid;
|
||||||
bool undoAble;
|
bool undoAble;
|
||||||
|
|
||||||
ActionList(Model &model,const String actionName,const String owner,bool undoAble);
|
CActionList(Model model,const String actionName,const String owner,bool undoAble);
|
||||||
void Start(const String actionName);
|
void Start(const String actionName);
|
||||||
void AddActionStart(const ActionPtr action);
|
void AddActionStart(const Action action);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~ActionList();
|
virtual ~CActionList();
|
||||||
|
|
||||||
String GetName() const { return actionName; }
|
virtual String GetName() const { return actionName; }
|
||||||
String GetOwner() const { return owner; }
|
virtual String GetOwner() const { return owner; }
|
||||||
|
|
||||||
void AddAction(const ActionPtr action);
|
virtual void AddAction(const Action action);
|
||||||
void Finish();
|
virtual void Finish();
|
||||||
|
|
||||||
void InsertLine(EntryPtr line,int position=-1,const String section=L"");
|
virtual void InsertLine(Entry line,int position=-1,const String section=L"");
|
||||||
void RemoveLine(int position,const String section);
|
virtual void RemoveLine(int position,const String section);
|
||||||
EntryPtr ModifyLine(int position,const String section);
|
virtual Entry ModifyLine(int position,const String section);
|
||||||
std::vector<EntryPtr> ModifyLines(Selection selection,const String section);
|
virtual std::vector<Entry> ModifyLines(Selection selection,const String section);
|
||||||
};
|
};
|
||||||
typedef shared_ptr<ActionList> ActionListPtr;
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -34,34 +34,27 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "athenastring.h"
|
#include "athenasub.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Time class
|
// Time class
|
||||||
class Time {
|
class CTime : public ITime {
|
||||||
private:
|
private:
|
||||||
int ms;
|
int ms;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Time() { ms = 0; }
|
CTime() { ms = 0; }
|
||||||
Time(int _ms) { ms = _ms; }
|
CTime(int _ms) { ms = _ms; }
|
||||||
|
|
||||||
void SetMS(int milliseconds) { ms = milliseconds; }
|
void SetMS(int milliseconds) { ms = milliseconds; }
|
||||||
int GetMS() const { return ms; }
|
int GetMS() const { return ms; }
|
||||||
|
|
||||||
String GetString(int ms_precision,int h_precision) const;
|
String GetString(int ms_precision,int h_precision) const;
|
||||||
void Parse(const String &data);
|
void ParseString(const String &data);
|
||||||
|
|
||||||
Time operator + (const int &par) const { return Max<int>(0,ms+par); }
|
Time Clone() const { return Time(new CTime(*this)); }
|
||||||
Time operator - (const int &par) const { return Max<int>(0,ms-par); }
|
|
||||||
bool operator == (const Time &par) const { return ms == par.ms; }
|
|
||||||
bool operator != (const Time &par) const { return ms != par.ms; }
|
|
||||||
bool operator < (const Time &par) const { return ms < par.ms; }
|
|
||||||
bool operator > (const Time &par) const { return ms > par.ms; }
|
|
||||||
bool operator <= (const Time &par) const { return ms <= par.ms; }
|
|
||||||
bool operator >= (const Time &par) const { return ms >= par.ms; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -35,23 +35,25 @@
|
||||||
|
|
||||||
|
|
||||||
#include "Athenasub.h"
|
#include "Athenasub.h"
|
||||||
|
#include "colour.h"
|
||||||
|
#include "utils.h"
|
||||||
using namespace Athenasub;
|
using namespace Athenasub;
|
||||||
|
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// Constructors
|
// Constructors
|
||||||
Colour::Colour ()
|
CColour::CColour ()
|
||||||
{
|
{
|
||||||
r = g = b = a = 0;
|
r = g = b = a = 0;
|
||||||
}
|
}
|
||||||
Colour::Colour (unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha)
|
CColour::CColour (unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha)
|
||||||
{
|
{
|
||||||
r = red;
|
r = red;
|
||||||
g = green;
|
g = green;
|
||||||
b = blue;
|
b = blue;
|
||||||
a = alpha;
|
a = alpha;
|
||||||
}
|
}
|
||||||
Colour::Colour (int red,int green,int blue,int alpha)
|
CColour::CColour (int red,int green,int blue,int alpha)
|
||||||
{
|
{
|
||||||
SetRed(red);
|
SetRed(red);
|
||||||
SetGreen(green);
|
SetGreen(green);
|
||||||
|
@ -62,15 +64,15 @@ Colour::Colour (int red,int green,int blue,int alpha)
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
// Set colour component
|
// Set colour component
|
||||||
void Colour::SetRed(int red) { r = (unsigned char) Mid(0,red,255); }
|
void CColour::SetRed(int red) { r = (unsigned char) Mid(0,red,255); }
|
||||||
void Colour::SetGreen(int green) { g = (unsigned char) Mid(0,green,255); }
|
void CColour::SetGreen(int green) { g = (unsigned char) Mid(0,green,255); }
|
||||||
void Colour::SetBlue(int blue) { b = (unsigned char) Mid(0,blue,255); }
|
void CColour::SetBlue(int blue) { b = (unsigned char) Mid(0,blue,255); }
|
||||||
void Colour::SetAlpha(int alpha) { a = (unsigned char) Mid(0,alpha,255); }
|
void CColour::SetAlpha(int alpha) { a = (unsigned char) Mid(0,alpha,255); }
|
||||||
|
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
// Parse text
|
// Parse text
|
||||||
void Colour::Parse(String value,bool reverse)
|
void CColour::Parse(String value,bool reverse)
|
||||||
{
|
{
|
||||||
// Prepare
|
// Prepare
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
|
@ -110,7 +112,7 @@ void Colour::Parse(String value,bool reverse)
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Generate Visual Basic hex
|
// Generate Visual Basic hex
|
||||||
String Colour::GetVBHex(bool withAlpha,bool withHeader,bool withFooter) const
|
String CColour::GetVBHex(bool withAlpha,bool withHeader,bool withFooter) const
|
||||||
{
|
{
|
||||||
wxString work;
|
wxString work;
|
||||||
if (withHeader) work += _T("&H");
|
if (withHeader) work += _T("&H");
|
||||||
|
|
|
@ -34,19 +34,19 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "athenastring.h"
|
#include "athenasub.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Colour class
|
// Colour class
|
||||||
class Colour {
|
class CColour : public IColour {
|
||||||
private:
|
private:
|
||||||
unsigned char r, g, b, a;
|
unsigned char r, g, b, a;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Colour ();
|
CColour ();
|
||||||
Colour (unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha=0);
|
CColour (unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha=0);
|
||||||
Colour (int red,int green,int blue,int alpha=0);
|
CColour (int red,int green,int blue,int alpha=0);
|
||||||
|
|
||||||
void SetRed(unsigned char red) { r = red; }
|
void SetRed(unsigned char red) { r = red; }
|
||||||
void SetGreen(unsigned char green) { g = green; }
|
void SetGreen(unsigned char green) { g = green; }
|
||||||
|
@ -57,10 +57,10 @@ namespace Athenasub {
|
||||||
void SetBlue(int blue);
|
void SetBlue(int blue);
|
||||||
void SetAlpha(int alpha);
|
void SetAlpha(int alpha);
|
||||||
|
|
||||||
unsigned char GetRed() const { return r; }
|
int GetRed() const { return r; }
|
||||||
unsigned char GetGreen() const { return g; }
|
int GetGreen() const { return g; }
|
||||||
unsigned char GetBlue() const { return b; }
|
int GetBlue() const { return b; }
|
||||||
unsigned char GetAlpha() const { return a; }
|
int GetAlpha() const { return a; }
|
||||||
|
|
||||||
void Parse(String str,bool reverse);
|
void Parse(String str,bool reverse);
|
||||||
String GetVBHex(bool withAlpha=false,bool withHeader=true,bool withFooter=true) const;
|
String GetVBHex(bool withAlpha=false,bool withHeader=true,bool withFooter=true) const;
|
|
@ -34,13 +34,15 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
#include "Athenasub.h"
|
#include "athenasub.h"
|
||||||
|
#include "actionlist.h"
|
||||||
|
#include "format_manager.h"
|
||||||
using namespace Athenasub;
|
using namespace Athenasub;
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
Controller::Controller(Model &_model)
|
CController::CController(Model _model)
|
||||||
: model(_model)
|
: model(_model)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -48,47 +50,47 @@ Controller::Controller(Model &_model)
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Create an action list
|
// Create an action list
|
||||||
ActionListPtr Controller::CreateActionList(const String title,const String owner,bool undoAble)
|
ActionList CController::CreateActionList(const String title,const String owner,bool undoAble)
|
||||||
{
|
{
|
||||||
return ActionListPtr (new ActionList(model,title,owner,undoAble));
|
return ActionList (new CActionList(model,title,owner,undoAble));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Load a file
|
// Load a file
|
||||||
void Controller::LoadFile(const String filename,const String encoding)
|
void CController::LoadFile(const String filename,const String encoding)
|
||||||
{
|
{
|
||||||
const FormatPtr handler = FormatManager::GetFormatFromFilename(filename,true);
|
const Format handler = FormatManager::GetFormatFromFilename(filename,true);
|
||||||
wxFFileInputStream stream(filename);
|
wxFFileInputStream stream(filename);
|
||||||
model.Load(stream,handler,encoding);
|
model->Load(stream,handler,encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Save a file
|
// Save a file
|
||||||
void Controller::SaveFile(const String filename,const String encoding)
|
void CController::SaveFile(const String filename,const String encoding)
|
||||||
{
|
{
|
||||||
const FormatPtr handler = FormatManager::GetFormatFromFilename(filename,true);
|
const Format handler = FormatManager::GetFormatFromFilename(filename,true);
|
||||||
wxFFileOutputStream stream(filename);
|
wxFFileOutputStream stream(filename);
|
||||||
model.Save(stream,handler,encoding);
|
model->Save(stream,handler,encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
// Get format
|
// Get format
|
||||||
const FormatPtr Controller::GetFormat() const
|
const Format CController::GetFormat() const
|
||||||
{
|
{
|
||||||
return model.GetFormat();
|
return model->GetFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Create entries
|
// Create entries
|
||||||
DialoguePtr Controller::CreateDialogue() const
|
Dialogue CController::CreateDialogue() const
|
||||||
{
|
{
|
||||||
return GetFormat()->CreateDialogue();
|
return GetFormat()->CreateDialogue();
|
||||||
}
|
}
|
||||||
StylePtr Controller::CreateStyle() const
|
Style CController::CreateStyle() const
|
||||||
{
|
{
|
||||||
return GetFormat()->CreateStyle();
|
return GetFormat()->CreateStyle();
|
||||||
}
|
}
|
||||||
|
@ -96,27 +98,27 @@ StylePtr Controller::CreateStyle() const
|
||||||
|
|
||||||
////////
|
////////
|
||||||
// Undo
|
// Undo
|
||||||
bool Controller::CanUndo(const String owner) const
|
bool CController::CanUndo(const String owner) const
|
||||||
{
|
{
|
||||||
return model.CanUndo(owner);
|
return model->CanUndo(owner);
|
||||||
}
|
}
|
||||||
bool Controller::CanRedo(const String owner) const
|
bool CController::CanRedo(const String owner) const
|
||||||
{
|
{
|
||||||
return model.CanRedo(owner);
|
return model->CanRedo(owner);
|
||||||
}
|
}
|
||||||
void Controller::Undo(const String owner)
|
void CController::Undo(const String owner)
|
||||||
{
|
{
|
||||||
model.Undo(owner);
|
model->Undo(owner);
|
||||||
}
|
}
|
||||||
void Controller::Redo(const String owner)
|
void CController::Redo(const String owner)
|
||||||
{
|
{
|
||||||
model.Redo(owner);
|
model->Redo(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
// Get the nth dialogue
|
// Get the nth dialogue
|
||||||
DialogueConstPtr Controller::GetDialogue(size_t n) const
|
ConstDialogue CController::GetDialogue(size_t n) const
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
(void) n;
|
(void) n;
|
||||||
|
@ -126,7 +128,7 @@ DialogueConstPtr Controller::GetDialogue(size_t n) const
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// Get the nth style
|
// Get the nth style
|
||||||
DialogueConstPtr Controller::GetStyle(size_t n) const
|
ConstStyle CController::GetStyle(size_t n) const
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
(void) n;
|
(void) n;
|
||||||
|
@ -136,24 +138,24 @@ DialogueConstPtr Controller::GetStyle(size_t n) const
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////
|
||||||
// Get a style by name
|
// Get a style by name
|
||||||
StyleConstPtr Controller::GetStyle(String name) const
|
ConstStyle CController::GetStyle(String name) const
|
||||||
{
|
{
|
||||||
// Get section
|
// Get section
|
||||||
StylePtr dummy = CreateStyle();
|
Style dummy = CreateStyle();
|
||||||
String section = dummy->GetDefaultGroup();
|
String section = dummy->GetDefaultGroup();
|
||||||
SectionPtr sect = model.GetSection(section);
|
Section sect = model->GetSection(section);
|
||||||
if (!sect) THROW_ATHENA_EXCEPTION(Exception::Invalid_Section);
|
if (!sect) THROW_ATHENA_EXCEPTION(Exception::Invalid_Section);
|
||||||
|
|
||||||
// Return from index
|
// Return from index
|
||||||
return dynamic_pointer_cast<const Style> (sect->GetFromIndex(name));
|
return dynamic_pointer_cast<const IStyle> (sect->GetFromIndex(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// Get an entry
|
// Get an entry
|
||||||
EntryConstPtr Controller::GetEntry(size_t n,String section) const
|
ConstEntry CController::GetEntry(size_t n,String section) const
|
||||||
{
|
{
|
||||||
SectionPtr sect = model.GetSection(section);
|
Section sect = model->GetSection(section);
|
||||||
if (!sect) THROW_ATHENA_EXCEPTION(Exception::Invalid_Section);
|
if (!sect) THROW_ATHENA_EXCEPTION(Exception::Invalid_Section);
|
||||||
return sect->GetEntry(n);
|
return sect->GetEntry(n);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,46 +34,39 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "athenasub.h"
|
||||||
#include "athenastring.h"
|
|
||||||
#include <exception>
|
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Exception class
|
// Controller class
|
||||||
class Exception : public std::exception {
|
class CController : public IController {
|
||||||
public:
|
friend class CModel;
|
||||||
enum ExceptionList {
|
|
||||||
Unknown,
|
|
||||||
No_Format_Handler,
|
|
||||||
Invalid_ActionList,
|
|
||||||
Section_Already_Exists,
|
|
||||||
Unknown_Format,
|
|
||||||
Parse_Error,
|
|
||||||
Unsupported_Format_Feature,
|
|
||||||
Invalid_Token,
|
|
||||||
Out_Of_Range,
|
|
||||||
Invalid_Section,
|
|
||||||
Internal_Error,
|
|
||||||
TODO
|
|
||||||
};
|
|
||||||
|
|
||||||
Exception(ExceptionList code);
|
|
||||||
Exception(ExceptionList code,const char* file,const long line);
|
|
||||||
|
|
||||||
String GetMessageString() const { return wxString(what(),wxConvLocal); }
|
|
||||||
int GetCode();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char* GetMessageChar(int code);
|
Model model;
|
||||||
static const char* GetMessageFile(int code,const char *file,long line);
|
CController (Model model);
|
||||||
ExceptionList code;
|
|
||||||
|
public:
|
||||||
|
virtual ActionList CreateActionList(const String title,const String owner=L"",bool undoAble=true);
|
||||||
|
virtual Selection CreateSelection();
|
||||||
|
|
||||||
|
virtual void LoadFile(const String filename,const String encoding=L"");
|
||||||
|
virtual void SaveFile(const String filename,const String encoding=L"UTF-8");
|
||||||
|
|
||||||
|
virtual bool CanUndo(const String owner=L"") const;
|
||||||
|
virtual bool CanRedo(const String owner=L"") const;
|
||||||
|
virtual void Undo(const String owner=L"");
|
||||||
|
virtual void Redo(const String owner=L"");
|
||||||
|
|
||||||
|
virtual Dialogue CreateDialogue() const;
|
||||||
|
virtual Style CreateStyle() const;
|
||||||
|
|
||||||
|
virtual ConstDialogue GetDialogue(size_t n) const;
|
||||||
|
virtual ConstStyle GetStyle(size_t n) const;
|
||||||
|
virtual ConstStyle GetStyle(String name) const;
|
||||||
|
virtual ConstEntry GetEntry(size_t n,String section) const;
|
||||||
|
|
||||||
|
virtual const Format GetFormat() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#define THROW_ATHENA_EXCEPTION(code) throw Athenasub::Exception(code,__FILE__,__LINE__)
|
|
||||||
#else
|
|
||||||
#define THROW_ATHENA_EXCEPTION(code) throw Athenasub::Exception(code)
|
|
||||||
#endif
|
|
|
@ -34,33 +34,32 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "athenastring.h"
|
#include "athenasub.h"
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "tr1.h"
|
#include "tr1.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Format handler interface
|
// Format handler interface
|
||||||
class FormatHandler {
|
class CFormatHandler : public IFormatHandler {
|
||||||
private:
|
private:
|
||||||
Model &model;
|
Model model;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~FormatHandler() {}
|
virtual ~CFormatHandler() {}
|
||||||
|
|
||||||
Model &GetModel() const { return model; }
|
Model GetModel() const { return model; }
|
||||||
|
|
||||||
void AddSection(String name) { model.AddSection(name); }
|
void AddSection(String name) { model->AddSection(name); }
|
||||||
SectionPtr GetSection(String name) const { return model.GetSection(name); }
|
Section GetSection(String name) const { return model->GetSection(name); }
|
||||||
SectionPtr GetSectionByIndex(size_t index) const { return model.GetSectionByIndex(index); }
|
Section GetSectionByIndex(size_t index) const { return model->GetSectionByIndex(index); }
|
||||||
size_t GetSectionCount() const { return model.GetSectionCount(); }
|
size_t GetSectionCount() const { return model->GetSectionCount(); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FormatHandler(Model &_model) : model(_model) {}
|
CFormatHandler(Model _model) : model(_model) {}
|
||||||
|
|
||||||
virtual void Load(wxInputStream &file,const String encoding) = 0;
|
virtual void Load(wxInputStream &file,const String encoding) = 0;
|
||||||
virtual void Save(wxOutputStream &file,const String encoding) = 0;
|
virtual void Save(wxOutputStream &file,const String encoding) = 0;
|
||||||
};
|
};
|
||||||
typedef shared_ptr<FormatHandler> FormatHandlerPtr;
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -34,26 +34,25 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "format.h"
|
#include "athenasub.h"
|
||||||
#include "api.h"
|
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Format manager class
|
// Format manager class
|
||||||
class FormatManager {
|
class FormatManager {
|
||||||
private:
|
private:
|
||||||
static std::vector<const FormatPtr> formats;
|
static std::vector<Format> formats;
|
||||||
FormatManager() {}
|
FormatManager() {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void AddFormat(const FormatPtr format);
|
static void AddFormat(Format format);
|
||||||
static void InitializeFormats();
|
static void InitializeFormats();
|
||||||
static void ClearFormats();
|
static void ClearFormats();
|
||||||
|
|
||||||
static int GetFormatCount();
|
static int GetFormatCount();
|
||||||
static const FormatPtr GetFormatByIndex(const int index);
|
static const Format GetFormatByIndex(const int index);
|
||||||
static const FormatPtr GetFormatFromFilename(const String &filename,bool read);
|
static const Format GetFormatFromFilename(const String &filename,bool read);
|
||||||
static const FormatPtr GetFormatFromName(const String &name);
|
static const Format GetFormatFromName(const String &name);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -89,8 +89,8 @@ StringArray FormatASS2::GetWriteExtensions() const
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
FormatHandlerASS::FormatHandlerASS(Model &_model,int version)
|
FormatHandlerASS::FormatHandlerASS(CModel &_model,int version)
|
||||||
: FormatHandler(_model), formatVersion(version)
|
: CFormatHandler(_model), formatVersion(version)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "format.h"
|
|
||||||
#include "format_handler.h"
|
#include "format_handler.h"
|
||||||
#include "format_ass_dialogue.h"
|
#include "format_ass_dialogue.h"
|
||||||
#include "format_ass_style.h"
|
#include "format_ass_style.h"
|
||||||
|
@ -46,21 +45,21 @@
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Prototypes
|
// Prototypes
|
||||||
class Model;
|
class CModel;
|
||||||
class TextFileWriter;
|
class TextFileWriter;
|
||||||
|
|
||||||
// Advanced Substation Alpha format handler
|
// Advanced Substation Alpha format handler
|
||||||
class FormatHandlerASS : public FormatHandler {
|
class FormatHandlerASS : public CFormatHandler {
|
||||||
private:
|
private:
|
||||||
int formatVersion;
|
int formatVersion;
|
||||||
|
|
||||||
EntryPtr MakeEntry(const String &data,SectionPtr section,int version);
|
Entry MakeEntry(const String &data,SectionPtr section,int version);
|
||||||
void ProcessGroup(String cur,String &curGroup,int &version);
|
void ProcessGroup(String cur,String &curGroup,int &version);
|
||||||
void WriteSection(TextFileWriter &writer,SectionPtr section);
|
void WriteSection(TextFileWriter &writer,SectionPtr section);
|
||||||
void MakeValid();
|
void MakeValid();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FormatHandlerASS(Model &model,int version);
|
FormatHandlerASS(CModel &model,int version);
|
||||||
~FormatHandlerASS();
|
~FormatHandlerASS();
|
||||||
|
|
||||||
void Load(wxInputStream &file,const String encoding);
|
void Load(wxInputStream &file,const String encoding);
|
||||||
|
@ -79,14 +78,14 @@ namespace Athenasub {
|
||||||
bool HasMargins() const { return true; }
|
bool HasMargins() const { return true; }
|
||||||
bool HasActors() const { return true; }
|
bool HasActors() const { return true; }
|
||||||
|
|
||||||
DialoguePtr CreateDialogue() const { return DialoguePtr(new DialogueASS()); }
|
Dialogue CreateDialogue() const { return Dialogue(new DialogueASS()); }
|
||||||
StylePtr CreateStyle() const { return StylePtr(new StyleASS()); }
|
Style CreateStyle() const { return Style(new StyleASS()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Substation Alpha
|
// Substation Alpha
|
||||||
class FormatSSA : public FormatASSFamily {
|
class FormatSSA : public FormatASSFamily {
|
||||||
public:
|
public:
|
||||||
FormatHandlerPtr GetHandler(Model &model) const { return FormatHandlerPtr(new FormatHandlerASS(model,0)); }
|
FormatHandler GetHandler(CModel &model) const { return FormatHandler(new FormatHandlerASS(model,0)); }
|
||||||
String GetName() const { return L"Substation Alpha"; }
|
String GetName() const { return L"Substation Alpha"; }
|
||||||
StringArray GetReadExtensions() const;
|
StringArray GetReadExtensions() const;
|
||||||
StringArray GetWriteExtensions() const;
|
StringArray GetWriteExtensions() const;
|
||||||
|
@ -95,7 +94,7 @@ namespace Athenasub {
|
||||||
// Advanced Substation Alpha
|
// Advanced Substation Alpha
|
||||||
class FormatASS : public FormatASSFamily {
|
class FormatASS : public FormatASSFamily {
|
||||||
public:
|
public:
|
||||||
FormatHandlerPtr GetHandler(Model &model) const { return FormatHandlerPtr(new FormatHandlerASS(model,1)); }
|
FormatHandler GetHandler(CModel &model) const { return FormatHandler(new FormatHandlerASS(model,1)); }
|
||||||
String GetName() const { return L"Advanced Substation Alpha"; }
|
String GetName() const { return L"Advanced Substation Alpha"; }
|
||||||
StringArray GetReadExtensions() const;
|
StringArray GetReadExtensions() const;
|
||||||
StringArray GetWriteExtensions() const;
|
StringArray GetWriteExtensions() const;
|
||||||
|
@ -104,7 +103,7 @@ namespace Athenasub {
|
||||||
// Advanced Substation Alpha 2
|
// Advanced Substation Alpha 2
|
||||||
class FormatASS2 : public FormatASSFamily {
|
class FormatASS2 : public FormatASSFamily {
|
||||||
public:
|
public:
|
||||||
FormatHandlerPtr GetHandler(Model &model) const { return FormatHandlerPtr(new FormatHandlerASS(model,2)); }
|
FormatHandler GetHandler(CModel &model) const { return FormatHandler(new FormatHandlerASS(model,2)); }
|
||||||
String GetName() const { return L"Advanced Substation Alpha 2"; }
|
String GetName() const { return L"Advanced Substation Alpha 2"; }
|
||||||
StringArray GetReadExtensions() const;
|
StringArray GetReadExtensions() const;
|
||||||
StringArray GetWriteExtensions() const;
|
StringArray GetWriteExtensions() const;
|
||||||
|
|
|
@ -97,8 +97,8 @@ bool DialogueASS::Parse(wxString rawData, int version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get times
|
// Get times
|
||||||
time[0].Parse(tkn.GetString());
|
time[0].ParseString(tkn.GetString());
|
||||||
time[1].Parse(tkn.GetString());
|
time[1].ParseString(tkn.GetString());
|
||||||
|
|
||||||
// Get style and actor
|
// Get style and actor
|
||||||
text[1] = tkn.GetString(true);
|
text[1] = tkn.GetString(true);
|
||||||
|
|
|
@ -38,15 +38,16 @@
|
||||||
#include "section_entry_dialogue.h"
|
#include "section_entry_dialogue.h"
|
||||||
#include "format_ass_dialogue_delta.h"
|
#include "format_ass_dialogue_delta.h"
|
||||||
#include "serialize.h"
|
#include "serialize.h"
|
||||||
|
#include "athenatime.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Dialogue
|
// Dialogue
|
||||||
class DialogueASS : public Dialogue, public SerializeText {
|
class DialogueASS : public CDialogue, public SerializeText {
|
||||||
friend class DialogueASSDeltaCoder;
|
friend class DialogueASSDeltaCoder;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
array<Time,2> time;
|
array<CTime,2> time;
|
||||||
array<String,4> text; // 0 = text, 1 = style, 2 = actor, 3 = effect
|
array<String,4> text; // 0 = text, 1 = style, 2 = actor, 3 = effect
|
||||||
array<short,4> margin;
|
array<short,4> margin;
|
||||||
int layer;
|
int layer;
|
||||||
|
@ -62,7 +63,7 @@ namespace Athenasub {
|
||||||
|
|
||||||
// Basic features
|
// Basic features
|
||||||
String GetDefaultGroup() const { return L"Events"; }
|
String GetDefaultGroup() const { return L"Events"; }
|
||||||
EntryPtr Clone() const { return EntryPtr(new DialogueASS(*this)); }
|
Entry Clone() const { return Entry(new DialogueASS(*this)); }
|
||||||
//DeltaCoderPtr GetDeltaCoder() const { return DeltaCoderPtr(new DialogueASSDeltaCoder()); }
|
//DeltaCoderPtr GetDeltaCoder() const { return DeltaCoderPtr(new DialogueASSDeltaCoder()); }
|
||||||
|
|
||||||
// Capabilities
|
// Capabilities
|
||||||
|
@ -72,8 +73,8 @@ namespace Athenasub {
|
||||||
bool HasMargins() const { return true; }
|
bool HasMargins() const { return true; }
|
||||||
|
|
||||||
// Read accessors
|
// Read accessors
|
||||||
Time GetStartTime() const { return time[0]; }
|
const ITime& GetStartTime() const { return time[0]; }
|
||||||
Time GetEndTime() const { return time[1]; }
|
const ITime& GetEndTime() const { return time[1]; }
|
||||||
bool IsComment() const { return isComment; }
|
bool IsComment() const { return isComment; }
|
||||||
int GetLayer() const { return layer; }
|
int GetLayer() const { return layer; }
|
||||||
int GetMargin(int n) const { return margin.at(n); }
|
int GetMargin(int n) const { return margin.at(n); }
|
||||||
|
@ -83,8 +84,8 @@ namespace Athenasub {
|
||||||
const String& GetUserField() const { return text[3]; }
|
const String& GetUserField() const { return text[3]; }
|
||||||
|
|
||||||
// Write acessors
|
// Write acessors
|
||||||
void SetStartTime(Time setStart) { time[0] = setStart; }
|
void SetStartTime(Time setStart) { time[0].SetMS(setStart->GetMS()); }
|
||||||
void SetEndTime(Time setEnd) { time[1] = setEnd; }
|
void SetEndTime(Time setEnd) { time[1].SetMS(setEnd->GetMS()); }
|
||||||
void SetComment(bool _isComment) { isComment = _isComment; }
|
void SetComment(bool _isComment) { isComment = _isComment; }
|
||||||
void SetLayer(int _layer) { layer = _layer; }
|
void SetLayer(int _layer) { layer = _layer; }
|
||||||
void SetMargin(int _margin,int value) { margin.at(_margin) = value; }
|
void SetMargin(int _margin,int value) { margin.at(_margin) = value; }
|
||||||
|
|
|
@ -55,8 +55,8 @@ VoidPtr DialogueASSDeltaCoder::EncodeDelta(VoidPtr _from,VoidPtr _to,bool withTe
|
||||||
unsigned short mask = 0;
|
unsigned short mask = 0;
|
||||||
if (from->isComment != to->isComment) mask |= 0x0001;
|
if (from->isComment != to->isComment) mask |= 0x0001;
|
||||||
if (from->layer != to->layer) mask |= 0x0002;
|
if (from->layer != to->layer) mask |= 0x0002;
|
||||||
if (from->time[0] != to->time[0]) mask |= 0x0004;
|
if (from->time[0].GetMS() != to->time[0].GetMS()) mask |= 0x0004;
|
||||||
if (from->time[1] != to->time[1]) mask |= 0x0008;
|
if (from->time[1].GetMS() != to->time[1].GetMS()) mask |= 0x0008;
|
||||||
for (size_t i=0;i<4;i++) {
|
for (size_t i=0;i<4;i++) {
|
||||||
if (from->margin[i] != to->margin[i]) mask |= 0x0010 << i;
|
if (from->margin[i] != to->margin[i]) mask |= 0x0010 << i;
|
||||||
if (withTextFields && from->text[i] != to->text[i]) mask |= 0x0100 << i;
|
if (withTextFields && from->text[i] != to->text[i]) mask |= 0x0100 << i;
|
||||||
|
|
|
@ -34,13 +34,13 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "deltacoder.h"
|
#include "interfaces.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Delta coder
|
// Delta coder
|
||||||
class DialogueASS;
|
class DialogueASS;
|
||||||
class DialogueASSDeltaCoder : public DeltaCoder {
|
class DialogueASSDeltaCoder : public IDeltaCoder {
|
||||||
private:
|
private:
|
||||||
void GetDelta(int mask,char *dst,shared_ptr<DialogueASS> to) const;
|
void GetDelta(int mask,char *dst,shared_ptr<DialogueASS> to) const;
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "format_ass_style.h"
|
#include "format_ass_style.h"
|
||||||
#include "tokenizer.h"
|
#include "../tokenizer.h"
|
||||||
#include "utils.h"
|
#include "../utils.h"
|
||||||
using namespace Athenasub;
|
using namespace Athenasub;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,21 +34,21 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "section_entry_style.h"
|
#include "../section_entry_style.h"
|
||||||
#include "serialize.h"
|
#include "../serialize.h"
|
||||||
#include "tr1.h"
|
#include "tr1.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Style
|
// Style
|
||||||
class StyleASS : public Style, public SerializeText {
|
class StyleASS : public CStyle, public SerializeText {
|
||||||
private:
|
private:
|
||||||
String name;
|
String name;
|
||||||
String font;
|
String font;
|
||||||
float fontSize;
|
float fontSize;
|
||||||
int formatVersion;
|
int formatVersion;
|
||||||
|
|
||||||
array<Colour,5> colour; // 0 = Primary, 1 = Secondary, 2 = Tertiary, 3 = Outline, 4 = Shadow
|
array<CColour,5> colour; // 0 = Primary, 1 = Secondary, 2 = Tertiary, 3 = Outline, 4 = Shadow
|
||||||
array<int,4> margin;
|
array<int,4> margin;
|
||||||
|
|
||||||
bool bold;
|
bool bold;
|
||||||
|
@ -80,7 +80,7 @@ namespace Athenasub {
|
||||||
|
|
||||||
// Basic features
|
// Basic features
|
||||||
String GetDefaultGroup() const;
|
String GetDefaultGroup() const;
|
||||||
EntryPtr Clone() const { return EntryPtr(new StyleASS(*this)); }
|
Entry Clone() const { return Entry(new StyleASS(*this)); }
|
||||||
|
|
||||||
// Indexing
|
// Indexing
|
||||||
virtual bool IsIndexable() const { return true; }
|
virtual bool IsIndexable() const { return true; }
|
||||||
|
@ -90,7 +90,7 @@ namespace Athenasub {
|
||||||
String GetName() const { return name; }
|
String GetName() const { return name; }
|
||||||
String GetFontName() const { return font; }
|
String GetFontName() const { return font; }
|
||||||
float GetFontSize() const { return fontSize; }
|
float GetFontSize() const { return fontSize; }
|
||||||
Colour GetColour(int n) const { return colour.at(n); }
|
const IColour& GetColour(int n) const { return colour.at(n); }
|
||||||
int GetMargin(int n) const { return margin.at(n); }
|
int GetMargin(int n) const { return margin.at(n); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,22 +33,24 @@
|
||||||
// Contact: mailto:amz@aegisub.net
|
// Contact: mailto:amz@aegisub.net
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "athenasub.h"
|
#include "libathenasub.h"
|
||||||
|
#include "format_handler.h"
|
||||||
|
#include "format_manager.h"
|
||||||
using namespace Athenasub;
|
using namespace Athenasub;
|
||||||
|
|
||||||
|
|
||||||
extern "C" LibAthenaSub* CreateLibAthenasub(const char* hostName) {
|
extern "C" ILibAthenaSub* CreateLibAthenasub(const char* hostName) {
|
||||||
return new LibAthenaSub(hostName);
|
return new CLibAthenaSub(hostName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LibAthenaSub::LibAthenaSub(const char* hostName) {
|
CLibAthenaSub::CLibAthenaSub(const char* hostName) {
|
||||||
(void) hostName;
|
(void) hostName;
|
||||||
Athenasub::SetHostApplicationName(String(hostName,wxConvUTF8));
|
//Athenasub::SetHostApplicationName(String(hostName,wxConvUTF8));
|
||||||
FormatManager::InitializeFormats();
|
FormatManager::InitializeFormats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ModelPtr LibAthenaSub::CreateModel() {
|
Model CLibAthenaSub::CreateModel() {
|
||||||
return ModelPtr(new Model());
|
return Model(new CModel());
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,19 +36,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "tr1.h"
|
#include "tr1.h"
|
||||||
|
#include "interfaces.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
class Model;
|
class CLibAthenaSub : public ILibAthenaSub {
|
||||||
typedef shared_ptr<Model> ModelPtr;
|
|
||||||
|
|
||||||
class LibAthenaSub {
|
|
||||||
public:
|
public:
|
||||||
LibAthenaSub(const char* hostName);
|
CLibAthenaSub(const char* hostName);
|
||||||
|
|
||||||
ModelPtr CreateModel();
|
Model CreateModel();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" Athenasub::LibAthenaSub* CreateLibAthenasub(const char* hostName);
|
|
|
@ -34,12 +34,13 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Athenasub.h"
|
#include "Athenasub.h"
|
||||||
|
#include "model.h"
|
||||||
using namespace Athenasub;
|
using namespace Athenasub;
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
// Adds a listener to be notified whenever things change
|
// Adds a listener to be notified whenever things change
|
||||||
void Model::AddListener(ViewPtr listener)
|
void CModel::AddListener(View listener)
|
||||||
{
|
{
|
||||||
wxASSERT(listener);
|
wxASSERT(listener);
|
||||||
listeners.push_back(listener);
|
listeners.push_back(listener);
|
||||||
|
@ -48,29 +49,29 @@ void Model::AddListener(ViewPtr listener)
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
// Notify all listeners
|
// Notify all listeners
|
||||||
void Model::DispatchNotifications(const Notification ¬ification) const
|
void CModel::DispatchNotifications(Notification notification) const
|
||||||
{
|
{
|
||||||
for (ViewList::const_iterator cur=listeners.begin();cur!=listeners.end();cur++) {
|
for (ViewList::const_iterator cur=listeners.begin();cur!=listeners.end();cur++) {
|
||||||
(*cur)->Notify(notification);
|
//(*cur)->Notify(notification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Processes an action list
|
// Processes an action list
|
||||||
void Model::ProcessActionList(const ActionList &_actionList,int type)
|
void CModel::ProcessActionList(ActionList _actionList,int type)
|
||||||
{
|
{
|
||||||
// Copy the list
|
// Copy the list
|
||||||
ActionListPtr actions = ActionListPtr(new ActionList(_actionList));
|
ActionList actions = ActionList(new CActionList(_actionList));
|
||||||
|
|
||||||
// Setup undo
|
// Setup undo
|
||||||
ActionListPtr undo = ActionListPtr(new ActionList(actions->model,actions->actionName,actions->owner,actions->undoAble));
|
ActionList undo = ActionList(new CActionList(actions->model,actions->actionName,actions->owner,actions->undoAble));
|
||||||
ActionStack *stack;
|
ActionStack *stack;
|
||||||
if (type == 1) stack = &redoStack;
|
if (type == 1) stack = &redoStack;
|
||||||
else stack = &undoStack;
|
else stack = &undoStack;
|
||||||
|
|
||||||
// Execute actions
|
// Execute actions
|
||||||
std::list<ActionPtr>::const_iterator cur;
|
std::list<Action>::const_iterator cur;
|
||||||
for (cur=actions->actions.begin();cur!=actions->actions.end();cur++) {
|
for (cur=actions->actions.begin();cur!=actions->actions.end();cur++) {
|
||||||
// Inserts the opposite into the undo action first
|
// Inserts the opposite into the undo action first
|
||||||
if (actions->undoAble) undo->AddActionStart((*cur)->GetAntiAction(*this));
|
if (actions->undoAble) undo->AddActionStart((*cur)->GetAntiAction(*this));
|
||||||
|
@ -92,7 +93,7 @@ void Model::ProcessActionList(const ActionList &_actionList,int type)
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Load subtitles
|
// Load subtitles
|
||||||
void Model::Load(wxInputStream &input,const FormatPtr _format,const String encoding)
|
void CModel::Load(wxInputStream &input,const FormatPtr _format,const String encoding)
|
||||||
{
|
{
|
||||||
// Autodetect format
|
// Autodetect format
|
||||||
if (!_format) {
|
if (!_format) {
|
||||||
|
@ -119,7 +120,7 @@ void Model::Load(wxInputStream &input,const FormatPtr _format,const String encod
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Save subtitles
|
// Save subtitles
|
||||||
void Model::Save(wxOutputStream &output,const FormatPtr _format,const String encoding)
|
void CModel::Save(wxOutputStream &output,const FormatPtr _format,const String encoding)
|
||||||
{
|
{
|
||||||
// Use another format
|
// Use another format
|
||||||
if (_format && _format != format) {
|
if (_format && _format != format) {
|
||||||
|
@ -138,17 +139,17 @@ void Model::Save(wxOutputStream &output,const FormatPtr _format,const String enc
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Inserts a new section
|
// Inserts a new section
|
||||||
void Model::AddSection(String name)
|
void CModel::AddSection(String name)
|
||||||
{
|
{
|
||||||
SectionPtr prev = GetSection(name);
|
SectionPtr prev = GetSection(name);
|
||||||
if (prev) THROW_ATHENA_EXCEPTION(Exception::Section_Already_Exists);
|
if (prev) THROW_ATHENA_EXCEPTION(Exception::Section_Already_Exists);
|
||||||
sections.push_back(SectionPtr(new Section(name)));
|
sections.push_back(SectionPtr(new CSection(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Gets a section
|
// Gets a section
|
||||||
SectionPtr Model::GetSection(String name) const
|
SectionPtr CModel::GetSection(String name) const
|
||||||
{
|
{
|
||||||
size_t len = sections.size();
|
size_t len = sections.size();
|
||||||
for (size_t i=0;i<len;i++) {
|
for (size_t i=0;i<len;i++) {
|
||||||
|
@ -160,7 +161,7 @@ SectionPtr Model::GetSection(String name) const
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
// Get section by index
|
// Get section by index
|
||||||
SectionPtr Model::GetSectionByIndex(size_t index) const
|
SectionPtr CModel::GetSectionByIndex(size_t index) const
|
||||||
{
|
{
|
||||||
return sections.at(index);
|
return sections.at(index);
|
||||||
}
|
}
|
||||||
|
@ -168,7 +169,7 @@ SectionPtr Model::GetSectionByIndex(size_t index) const
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// Get section count
|
// Get section count
|
||||||
size_t Model::GetSectionCount() const
|
size_t CModel::GetSectionCount() const
|
||||||
{
|
{
|
||||||
return sections.size();
|
return sections.size();
|
||||||
}
|
}
|
||||||
|
@ -176,7 +177,7 @@ size_t Model::GetSectionCount() const
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
// Clear
|
// Clear
|
||||||
void Model::Clear()
|
void CModel::Clear()
|
||||||
{
|
{
|
||||||
sections.clear();
|
sections.clear();
|
||||||
undoStack.clear();
|
undoStack.clear();
|
||||||
|
@ -186,12 +187,12 @@ void Model::Clear()
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Can undo/redo?
|
// Can undo/redo?
|
||||||
bool Model::CanUndo(const String owner) const
|
bool CModel::CanUndo(const String owner) const
|
||||||
{
|
{
|
||||||
(void) owner;
|
(void) owner;
|
||||||
return undoStack.size() > 0;
|
return undoStack.size() > 0;
|
||||||
}
|
}
|
||||||
bool Model::CanRedo(const String owner) const
|
bool CModel::CanRedo(const String owner) const
|
||||||
{
|
{
|
||||||
(void) owner;
|
(void) owner;
|
||||||
return redoStack.size() > 0;
|
return redoStack.size() > 0;
|
||||||
|
@ -200,7 +201,7 @@ bool Model::CanRedo(const String owner) const
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// Perform an undo
|
// Perform an undo
|
||||||
void Model::Undo(const String owner)
|
void CModel::Undo(const String owner)
|
||||||
{
|
{
|
||||||
ActivateStack(undoStack,true,owner);
|
ActivateStack(undoStack,true,owner);
|
||||||
}
|
}
|
||||||
|
@ -208,7 +209,7 @@ void Model::Undo(const String owner)
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Perform a redo
|
// Perform a redo
|
||||||
void Model::Redo(const String owner)
|
void CModel::Redo(const String owner)
|
||||||
{
|
{
|
||||||
ActivateStack(redoStack,false,owner);
|
ActivateStack(redoStack,false,owner);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +217,7 @@ void Model::Redo(const String owner)
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// Perform undo/redo
|
// Perform undo/redo
|
||||||
void Model::ActivateStack(ActionStack &stack,bool isUndo,const String &owner)
|
void CModel::ActivateStack(ActionStack &stack,bool isUndo,const String &owner)
|
||||||
{
|
{
|
||||||
// TODO: do something with this
|
// TODO: do something with this
|
||||||
(void) owner;
|
(void) owner;
|
||||||
|
@ -231,13 +232,13 @@ void Model::ActivateStack(ActionStack &stack,bool isUndo,const String &owner)
|
||||||
|
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
// Get undo/redo messages
|
// Get undo/redo messages
|
||||||
String Model::GetUndoMessage(const String owner) const
|
String CModel::GetUndoMessage(const String owner) const
|
||||||
{
|
{
|
||||||
(void) owner;
|
(void) owner;
|
||||||
if (CanUndo()) return undoStack.back()->GetName();
|
if (CanUndo()) return undoStack.back()->GetName();
|
||||||
return L"";
|
return L"";
|
||||||
}
|
}
|
||||||
String Model::GetRedoMessage(const String owner) const
|
String CModel::GetRedoMessage(const String owner) const
|
||||||
{
|
{
|
||||||
(void) owner;
|
(void) owner;
|
||||||
if (CanRedo()) return redoStack.back()->GetName();
|
if (CanRedo()) return redoStack.back()->GetName();
|
||||||
|
@ -247,7 +248,7 @@ String Model::GetRedoMessage(const String owner) const
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// Create a controller for this model
|
// Create a controller for this model
|
||||||
ControllerPtr Athenasub::Model::CreateController()
|
ControllerPtr Athenasub::CModel::CreateController()
|
||||||
{
|
{
|
||||||
return ControllerPtr(new Controller(*this));
|
return ControllerPtr(new CController(*this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,40 +37,30 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <wx/wfstream.h>
|
#include <wx/wfstream.h>
|
||||||
|
#include "athenasub.h"
|
||||||
#include "actionlist.h"
|
#include "actionlist.h"
|
||||||
#include "section.h"
|
#include "section.h"
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Prototypes
|
|
||||||
class View;
|
|
||||||
typedef shared_ptr<View> ViewPtr;
|
|
||||||
class Notification;
|
|
||||||
class Format;
|
|
||||||
|
|
||||||
// Model class
|
// Model class
|
||||||
// Stores the subtitle data
|
// Stores the subtitle data
|
||||||
class Model {
|
class CModel : public IModel {
|
||||||
friend class FormatHandler;
|
friend class CFormatHandler;
|
||||||
friend class ActionList;
|
friend class CActionList;
|
||||||
friend class Controller;
|
friend class CController;
|
||||||
friend class Action;
|
friend class CAction;
|
||||||
|
|
||||||
typedef std::list<ViewPtr> ViewList;
|
|
||||||
typedef std::list<ActionListPtr> ActionStack;
|
|
||||||
typedef shared_ptr<Format> FormatPtr;
|
|
||||||
typedef shared_ptr<Controller> ControllerPtr;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<SectionPtr> sections;
|
std::vector<CSection> sections;
|
||||||
ActionStack undoStack;
|
ActionStack undoStack;
|
||||||
ActionStack redoStack;
|
ActionStack redoStack;
|
||||||
ViewList listeners;
|
ViewList listeners;
|
||||||
bool readOnly;
|
bool readOnly;
|
||||||
FormatPtr format;
|
Format format;
|
||||||
|
|
||||||
void ProcessActionList(const ActionList &actionList,int type=0);
|
void ProcessActionList(ActionList actionList,int type=0);
|
||||||
|
|
||||||
String GetUndoMessage(const String owner=L"") const;
|
String GetUndoMessage(const String owner=L"") const;
|
||||||
String GetRedoMessage(const String owner=L"") const;
|
String GetRedoMessage(const String owner=L"") const;
|
||||||
|
@ -78,26 +68,26 @@ namespace Athenasub {
|
||||||
bool CanRedo(const String owner=L"") const;
|
bool CanRedo(const String owner=L"") const;
|
||||||
void Undo(const String owner=L"");
|
void Undo(const String owner=L"");
|
||||||
void Redo(const String owner=L"");
|
void Redo(const String owner=L"");
|
||||||
void ActivateStack(ActionStack &stack,bool isUndo,const String &owner);
|
void ActivateStack(ActionStack stack,bool isUndo,const String &owner);
|
||||||
|
|
||||||
void DispatchNotifications(const Notification ¬ification) const;
|
void DispatchNotifications(Notification notification) const;
|
||||||
|
|
||||||
void AddSection(String name);
|
|
||||||
SectionPtr GetSection(String name) const;
|
|
||||||
SectionPtr GetSectionByIndex(size_t index) const;
|
|
||||||
size_t GetSectionCount() const;
|
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
void Load(wxInputStream &input,const FormatPtr format=FormatPtr(),const String encoding=L"");
|
void Load(wxInputStream &input,Format format=Format(),const String encoding=L"");
|
||||||
void Save(wxOutputStream &output,const FormatPtr format=FormatPtr(),const String encoding=L"UTF-8");
|
void Save(wxOutputStream &output,Format format=Format(),const String encoding=L"UTF-8");
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void AddSection(String name);
|
||||||
|
Section GetSection(String name) const;
|
||||||
|
Section GetSectionByIndex(size_t index) const;
|
||||||
|
size_t GetSectionCount() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ControllerPtr CreateController();
|
Controller CreateController();
|
||||||
|
Format GetFormat() const { return format; }
|
||||||
const FormatPtr GetFormat() const { return format; }
|
void AddListener(View listener);
|
||||||
void AddListener(ViewPtr listener);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef shared_ptr<Model> ModelPtr;
|
typedef shared_ptr<CModel> ModelPtr;
|
||||||
|
|
||||||
}
|
}
|
|
@ -40,7 +40,7 @@ using namespace Athenasub;
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
Section::Section(String _name)
|
CSection::CSection(String _name)
|
||||||
{
|
{
|
||||||
name = _name;
|
name = _name;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ Section::Section(String _name)
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// Append an entry
|
// Append an entry
|
||||||
void Section::AddEntry(EntryPtr entry,int pos)
|
void CSection::AddEntry(Entry entry,int pos)
|
||||||
{
|
{
|
||||||
// Insert to entry list
|
// Insert to entry list
|
||||||
if (pos == -1) entries.push_back(entry);
|
if (pos == -1) entries.push_back(entry);
|
||||||
|
@ -63,10 +63,10 @@ void Section::AddEntry(EntryPtr entry,int pos)
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Removes the nth entry
|
// Removes the nth entry
|
||||||
void Section::RemoveEntryByIndex(size_t i)
|
void CSection::RemoveEntryByIndex(size_t i)
|
||||||
{
|
{
|
||||||
// Get entry iterator and erase
|
// Get entry iterator and erase
|
||||||
std::vector<EntryPtr>::iterator entry = entries.begin()+i;
|
std::vector<Entry>::iterator entry = entries.begin()+i;
|
||||||
entries.erase(entry);
|
entries.erase(entry);
|
||||||
|
|
||||||
// If it's indexable, remove it from index as well
|
// If it's indexable, remove it from index as well
|
||||||
|
@ -76,7 +76,7 @@ void Section::RemoveEntryByIndex(size_t i)
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Removes an entry by its value
|
// Removes an entry by its value
|
||||||
void Section::RemoveEntry(EntryPtr entry)
|
void CSection::RemoveEntry(Entry entry)
|
||||||
{
|
{
|
||||||
size_t len = entries.size();
|
size_t len = entries.size();
|
||||||
for (size_t i=0;i<len;i++) {
|
for (size_t i=0;i<len;i++) {
|
||||||
|
@ -91,15 +91,7 @@ void Section::RemoveEntry(EntryPtr entry)
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Retrieves entry by index
|
// Retrieves entry by index
|
||||||
EntryPtr Section::GetEntry(size_t i) const
|
Entry CSection::GetEntry(size_t i) const
|
||||||
{
|
|
||||||
return entries[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////
|
|
||||||
// Retrieves a reference to an entry
|
|
||||||
EntryPtr& Section::GetEntryRef(size_t i)
|
|
||||||
{
|
{
|
||||||
return entries[i];
|
return entries[i];
|
||||||
}
|
}
|
||||||
|
@ -107,7 +99,7 @@ EntryPtr& Section::GetEntryRef(size_t i)
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Get number of entries
|
// Get number of entries
|
||||||
size_t Section::GetEntryCount() const
|
size_t CSection::GetEntryCount() const
|
||||||
{
|
{
|
||||||
return entries.size();
|
return entries.size();
|
||||||
}
|
}
|
||||||
|
@ -115,7 +107,7 @@ size_t Section::GetEntryCount() const
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Set a property
|
// Set a property
|
||||||
void Section::SetProperty(const String &key,const String &value)
|
void CSection::SetProperty(const String &key,const String &value)
|
||||||
{
|
{
|
||||||
properties[key] = value;
|
properties[key] = value;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +115,7 @@ void Section::SetProperty(const String &key,const String &value)
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// Removes a property
|
// Removes a property
|
||||||
void Section::UnsetProperty(const String &key)
|
void CSection::UnsetProperty(const String &key)
|
||||||
{
|
{
|
||||||
std::map<String,String>::iterator iter = properties.find(key);
|
std::map<String,String>::iterator iter = properties.find(key);
|
||||||
if (iter != properties.end()) properties.erase(iter);
|
if (iter != properties.end()) properties.erase(iter);
|
||||||
|
@ -132,7 +124,7 @@ void Section::UnsetProperty(const String &key)
|
||||||
|
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
// Get a property's value
|
// Get a property's value
|
||||||
String Section::GetProperty(const String &key) const
|
String CSection::GetProperty(const String &key) const
|
||||||
{
|
{
|
||||||
std::map<String,String>::const_iterator iter = properties.find(key);
|
std::map<String,String>::const_iterator iter = properties.find(key);
|
||||||
if (iter != properties.end()) return iter->second;
|
if (iter != properties.end()) return iter->second;
|
||||||
|
@ -142,7 +134,7 @@ String Section::GetProperty(const String &key) const
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// Checks if it has a property
|
// Checks if it has a property
|
||||||
bool Section::HasProperty(const String &key) const
|
bool CSection::HasProperty(const String &key) const
|
||||||
{
|
{
|
||||||
return properties.find(key) != properties.end();
|
return properties.find(key) != properties.end();
|
||||||
}
|
}
|
||||||
|
@ -150,7 +142,7 @@ bool Section::HasProperty(const String &key) const
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// Get property count
|
// Get property count
|
||||||
size_t Section::GetPropertyCount() const
|
size_t CSection::GetPropertyCount() const
|
||||||
{
|
{
|
||||||
return properties.size();
|
return properties.size();
|
||||||
}
|
}
|
||||||
|
@ -158,7 +150,7 @@ size_t Section::GetPropertyCount() const
|
||||||
|
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
// Get name of a property by index
|
// Get name of a property by index
|
||||||
String Section::GetPropertyName(size_t n) const
|
String CSection::GetPropertyName(size_t n) const
|
||||||
{
|
{
|
||||||
std::map<String,String>::const_iterator iter=properties.begin();
|
std::map<String,String>::const_iterator iter=properties.begin();
|
||||||
for (size_t i=0 ; iter!=properties.end() ; iter++,i++) {
|
for (size_t i=0 ; iter!=properties.end() ; iter++,i++) {
|
||||||
|
@ -170,9 +162,9 @@ String Section::GetPropertyName(size_t n) const
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////
|
||||||
// Retrieve from index
|
// Retrieve from index
|
||||||
EntryPtr Section::GetFromIndex(String key) const
|
Entry CSection::GetFromIndex(String key) const
|
||||||
{
|
{
|
||||||
std::map<String,EntryPtr>::const_iterator result = index.find(key);
|
std::map<String,Entry>::const_iterator result = index.find(key);
|
||||||
if (result != index.end()) return result->second;
|
if (result != index.end()) return result->second;
|
||||||
return EntryPtr();
|
return Entry();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,26 +34,24 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "athenastring.h"
|
#include "athenasub.h"
|
||||||
#include "section_entry.h"
|
#include "section_entry.h"
|
||||||
#include "tr1.h"
|
|
||||||
#include "api.h"
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Section class
|
// Section class
|
||||||
class Section {
|
class CSection : public ISection {
|
||||||
private:
|
private:
|
||||||
std::vector<EntryPtr> entries;
|
std::vector<Entry> entries;
|
||||||
std::map<String,String> properties;
|
std::map<String,String> properties;
|
||||||
std::map<String,EntryPtr> index;
|
std::map<String,Entry> index;
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Section(String name);
|
CSection(String name);
|
||||||
~Section() {}
|
~CSection() {}
|
||||||
|
|
||||||
// Section name
|
// Section name
|
||||||
void SetName(const String& newName) { name = newName; }
|
void SetName(const String& newName) { name = newName; }
|
||||||
|
@ -68,16 +66,16 @@ namespace Athenasub {
|
||||||
String GetPropertyName(size_t index) const;
|
String GetPropertyName(size_t index) const;
|
||||||
|
|
||||||
// Indexed
|
// Indexed
|
||||||
EntryPtr GetFromIndex(String key) const;
|
Entry GetFromIndex(String key) const;
|
||||||
|
|
||||||
// Entries
|
// Entries
|
||||||
void AddEntry(EntryPtr entry,int pos=-1);
|
void AddEntry(Entry entry,int pos=-1);
|
||||||
void RemoveEntryByIndex(size_t index);
|
void RemoveEntryByIndex(size_t index);
|
||||||
void RemoveEntry(EntryPtr entry);
|
void RemoveEntry(Entry entry);
|
||||||
EntryPtr GetEntry(size_t index) const;
|
Entry GetEntry(size_t index) const;
|
||||||
EntryPtr& GetEntryRef(size_t index);
|
Entry& GetEntryRef(size_t index) const;
|
||||||
size_t GetEntryCount() const;
|
size_t GetEntryCount() const;
|
||||||
};
|
};
|
||||||
typedef shared_ptr<Section> SectionPtr;
|
typedef shared_ptr<CSection> SectionPtr;
|
||||||
|
|
||||||
}
|
}
|
|
@ -42,34 +42,8 @@ using namespace Athenasub;
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Returns a static empty string
|
// Returns a static empty string
|
||||||
const String& Entry::EmptyString() const
|
const String& CDialogue::EmptyString()
|
||||||
{
|
{
|
||||||
static const String str = _T("");
|
static const String str = _T("");
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const PlainTextPtr Entry::GetAsPlain(const EntryPtr &ptr)
|
|
||||||
{
|
|
||||||
(void) ptr; return PlainTextPtr();
|
|
||||||
}
|
|
||||||
const DialoguePtr Entry::GetAsDialogue(const EntryPtr &ptr)
|
|
||||||
{
|
|
||||||
return dynamic_pointer_cast<Dialogue>(ptr);
|
|
||||||
}
|
|
||||||
const DialogueConstPtr Entry::GetAsDialogue(const EntryConstPtr &ptr)
|
|
||||||
{
|
|
||||||
return dynamic_pointer_cast<const Dialogue>(ptr);
|
|
||||||
}
|
|
||||||
const StylePtr Entry::GetAsStyle(const EntryPtr &ptr)
|
|
||||||
{
|
|
||||||
return dynamic_pointer_cast<Style>(ptr);
|
|
||||||
}
|
|
||||||
const AttachmentPtr Entry::GetAsFile(const EntryPtr &ptr)
|
|
||||||
{
|
|
||||||
(void) ptr; return AttachmentPtr();
|
|
||||||
}
|
|
||||||
const RawEntryPtr Entry::GetAsRaw(const EntryPtr &ptr)
|
|
||||||
{
|
|
||||||
(void) ptr; return RawEntryPtr();
|
|
||||||
}
|
|
||||||
|
|
|
@ -34,22 +34,18 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "athenastring.h"
|
#include "athenasub.h"
|
||||||
#include "api.h"
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
// Prototypes
|
|
||||||
class Model;
|
|
||||||
class Notification;
|
|
||||||
|
|
||||||
// View interface
|
// Section plain-text entry
|
||||||
// Implement this to listen to modifications in a model
|
class CPlainText : public IEntry {
|
||||||
class View {
|
|
||||||
public:
|
public:
|
||||||
virtual ~View();
|
SectionEntryType GetType() const { return SECTION_ENTRY_PLAIN; }
|
||||||
|
virtual ~CPlainText() {}
|
||||||
void Register(Model &model);
|
virtual String GetText() const =0;
|
||||||
virtual void Notify(const Notification ¬ification) = 0;
|
virtual void SetText(const String &_data) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -35,26 +35,26 @@
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "exception.h"
|
#include "athenasub.h"
|
||||||
#include "athenatime.h"
|
|
||||||
#include "section_entry.h"
|
#include "section_entry.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Dialogue class
|
// Dialogue class
|
||||||
class Dialogue : public Entry {
|
class CDialogue : public IDialogue {
|
||||||
private:
|
private:
|
||||||
static const bool dodgeWarning = true;
|
static const bool dodgeWarning = true;
|
||||||
void ThrowUnsupported() const { if (dodgeWarning) THROW_ATHENA_EXCEPTION(Exception::Unsupported_Format_Feature); }
|
void ThrowUnsupported() const { if (dodgeWarning) THROW_ATHENA_EXCEPTION(Exception::Unsupported_Format_Feature); }
|
||||||
|
static const String& EmptyString();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Destructor
|
// Destructor
|
||||||
virtual ~Dialogue() {}
|
virtual ~CDialogue() {}
|
||||||
|
|
||||||
// Type
|
// Type
|
||||||
SectionEntryType GetType() const { return SECTION_ENTRY_DIALOGUE; }
|
SectionEntryType GetType() const { return SECTION_ENTRY_DIALOGUE; }
|
||||||
Dialogue *GetAsDialogue() { return this; }
|
Dialogue GetAsDialogue() { return Dialogue(this); }
|
||||||
|
|
||||||
// Capabilities
|
// Capabilities
|
||||||
virtual bool HasText() const { return false; }
|
virtual bool HasText() const { return false; }
|
||||||
|
@ -67,8 +67,8 @@ namespace Athenasub {
|
||||||
|
|
||||||
// Read accessors
|
// Read accessors
|
||||||
virtual const String& GetText() const { ThrowUnsupported(); return EmptyString(); }
|
virtual const String& GetText() const { ThrowUnsupported(); return EmptyString(); }
|
||||||
virtual Time GetStartTime() const { ThrowUnsupported(); return 0; }
|
// virtual ITime& GetStartTime() const { ThrowUnsupported(); return Time(); }
|
||||||
virtual Time GetEndTime() const { ThrowUnsupported(); return 0; }
|
// virtual ITime& GetEndTime() const { ThrowUnsupported(); return Time(); }
|
||||||
virtual int GetStartFrame() const { ThrowUnsupported(); return 0; }
|
virtual int GetStartFrame() const { ThrowUnsupported(); return 0; }
|
||||||
virtual int GetEndFrame() const { ThrowUnsupported(); return 0; }
|
virtual int GetEndFrame() const { ThrowUnsupported(); return 0; }
|
||||||
virtual bool IsComment() const { ThrowUnsupported(); return false; }
|
virtual bool IsComment() const { ThrowUnsupported(); return false; }
|
||||||
|
@ -78,7 +78,7 @@ namespace Athenasub {
|
||||||
virtual const String& GetActor() const { ThrowUnsupported(); return EmptyString(); }
|
virtual const String& GetActor() const { ThrowUnsupported(); return EmptyString(); }
|
||||||
virtual const String& GetUserField() const { ThrowUnsupported(); return EmptyString(); }
|
virtual const String& GetUserField() const { ThrowUnsupported(); return EmptyString(); }
|
||||||
|
|
||||||
// Write acessors
|
// Write accessors
|
||||||
virtual void SetText(const String& text) { (void) text; ThrowUnsupported(); }
|
virtual void SetText(const String& text) { (void) text; ThrowUnsupported(); }
|
||||||
virtual void SetStartTime(Time start) { (void) start; ThrowUnsupported(); }
|
virtual void SetStartTime(Time start) { (void) start; ThrowUnsupported(); }
|
||||||
virtual void SetEndTime(Time end) { (void) end; ThrowUnsupported(); }
|
virtual void SetEndTime(Time end) { (void) end; ThrowUnsupported(); }
|
|
@ -35,32 +35,31 @@
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "exception.h"
|
#include "athenasub.h"
|
||||||
#include "colour.h"
|
#include "colour.h"
|
||||||
#include "section_entry.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Style class
|
// Style class
|
||||||
class Style : public Entry {
|
class CStyle : public IStyle {
|
||||||
private:
|
private:
|
||||||
static const bool dodgeWarning = true;
|
static const bool dodgeWarning = true;
|
||||||
void ThrowUnsupported() const { if (dodgeWarning) THROW_ATHENA_EXCEPTION(Exception::Unsupported_Format_Feature); }
|
void ThrowUnsupported() const { if (dodgeWarning) THROW_ATHENA_EXCEPTION(Exception::Unsupported_Format_Feature); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Destructor
|
// Destructor
|
||||||
virtual ~Style() {}
|
virtual ~CStyle() {}
|
||||||
|
|
||||||
// Type
|
// Type
|
||||||
SectionEntryType GetType() const { return SECTION_ENTRY_STYLE; }
|
SectionEntryType GetType() const { return SECTION_ENTRY_STYLE; }
|
||||||
Style *GetAsStyle() { return this; }
|
Style GetAsStyle() { return Style(this); }
|
||||||
|
|
||||||
// Read accessors
|
// Read accessors
|
||||||
virtual String GetName() const=0;
|
virtual String GetName() const=0;
|
||||||
virtual String GetFontName() const { ThrowUnsupported(); return L""; }
|
virtual String GetFontName() const { ThrowUnsupported(); return L""; }
|
||||||
virtual float GetFontSize() const { ThrowUnsupported(); return 0.0f; }
|
virtual float GetFontSize() const { ThrowUnsupported(); return 0.0f; }
|
||||||
virtual Colour GetColour(int n) const { (void) n; ThrowUnsupported(); return Colour(); }
|
//virtual IColour& GetColour(int n) const { (void) n; ThrowUnsupported(); return Colour(); }
|
||||||
virtual int GetMargin(int n) const { (void) n; ThrowUnsupported(); return 0; }
|
virtual int GetMargin(int n) const { (void) n; ThrowUnsupported(); return 0; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,13 +33,13 @@
|
||||||
// Contact: mailto:amz@aegisub.net
|
// Contact: mailto:amz@aegisub.net
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "athenasub.h"
|
#include "selection.h"
|
||||||
using namespace Athenasub;
|
using namespace Athenasub;
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
Selection::Selection()
|
CSelection::CSelection()
|
||||||
: count(0)
|
: count(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ Selection::Selection()
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// Adds a range
|
// Adds a range
|
||||||
void Selection::AddRange(const Range &range)
|
void CSelection::AddRange(const Range &range)
|
||||||
{
|
{
|
||||||
ranges.push_back(range);
|
ranges.push_back(range);
|
||||||
UpdateCount();
|
UpdateCount();
|
||||||
|
@ -56,7 +56,7 @@ void Selection::AddRange(const Range &range)
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// Removes a range
|
// Removes a range
|
||||||
void Selection::RemoveRange(const Range &range)
|
void CSelection::RemoveRange(const Range &range)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
(void) range;
|
(void) range;
|
||||||
|
@ -66,7 +66,7 @@ void Selection::RemoveRange(const Range &range)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Normalizes all ranges, that is, gets rid of overlaps and whatnot
|
// Normalizes all ranges, that is, gets rid of overlaps and whatnot
|
||||||
void Selection::NormalizeRanges()
|
void CSelection::NormalizeRanges()
|
||||||
{
|
{
|
||||||
// Has anything to do?
|
// Has anything to do?
|
||||||
if (ranges.size() == 0) return;
|
if (ranges.size() == 0) return;
|
||||||
|
@ -112,7 +112,7 @@ void Selection::NormalizeRanges()
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Get a specific
|
// Get a specific
|
||||||
size_t Selection::GetLine(size_t n) const
|
size_t CSelection::GetLine(size_t n) const
|
||||||
{
|
{
|
||||||
// Find the nth line
|
// Find the nth line
|
||||||
size_t cur = 0;
|
size_t cur = 0;
|
||||||
|
@ -127,8 +127,8 @@ size_t Selection::GetLine(size_t n) const
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// Append another selection
|
// Append another CSelection
|
||||||
void Selection::AddSelection (const Selection ¶m)
|
void CSelection::AddSelection (const Selection ¶m)
|
||||||
{
|
{
|
||||||
(void) param;
|
(void) param;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ void Selection::AddSelection (const Selection ¶m)
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// Update count
|
// Update count
|
||||||
void Selection::UpdateCount()
|
void CSelection::UpdateCount()
|
||||||
{
|
{
|
||||||
count = 0;
|
count = 0;
|
||||||
size_t len = ranges.size();
|
size_t len = ranges.size();
|
||||||
|
@ -147,8 +147,8 @@ void Selection::UpdateCount()
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// Subtract another selection
|
// Subtract another CSelection
|
||||||
void Selection::RemoveSelection (const Selection ¶m)
|
void CSelection::RemoveSelection (const Selection ¶m)
|
||||||
{
|
{
|
||||||
(void) param;
|
(void) param;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,34 +35,35 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "range.h"
|
#include "athenasub.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Selection class
|
// Selection class
|
||||||
class Selection {
|
class CSelection : public ISelection {
|
||||||
private:
|
private:
|
||||||
std::vector<Range> ranges;
|
std::vector<Range> ranges;
|
||||||
size_t count;
|
size_t count;
|
||||||
void UpdateCount();
|
void UpdateCount();
|
||||||
|
CSelection();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Selection();
|
virtual ~CSelection() {}
|
||||||
|
|
||||||
void AddLine(size_t line) { AddRange(Range(line,line+1)); }
|
virtual void AddLine(size_t line) { AddRange(Range(line,line+1)); }
|
||||||
void AddRange(const Range &range);
|
virtual void AddRange(const Range &range);
|
||||||
void RemoveLine(size_t line) { RemoveRange(Range(line,line+1)); }
|
virtual void RemoveLine(size_t line) { RemoveRange(Range(line,line+1)); }
|
||||||
void RemoveRange(const Range &range);
|
virtual void RemoveRange(const Range &range);
|
||||||
void AddSelection (const Selection ¶m);
|
virtual void AddSelection (const Selection ¶m);
|
||||||
void RemoveSelection (const Selection ¶m);
|
virtual void RemoveSelection (const Selection ¶m);
|
||||||
void NormalizeRanges ();
|
virtual void NormalizeRanges ();
|
||||||
|
|
||||||
size_t GetCount() const { return count; }
|
virtual size_t GetCount() const { return count; }
|
||||||
size_t GetRanges() const { return ranges.size(); }
|
virtual size_t GetRanges() const { return ranges.size(); }
|
||||||
size_t GetLine(size_t n) const;
|
virtual size_t GetLine(size_t n) const;
|
||||||
size_t GetLineInRange(size_t n,size_t range) const { return ranges.at(range).GetLine(n); }
|
virtual size_t GetLineInRange(size_t n,size_t range) const { return ranges.at(range).GetLine(n); }
|
||||||
size_t GetLinesInRange(size_t range) const { return ranges.at(range).GetSize(); }
|
virtual size_t GetLinesInRange(size_t range) const { return ranges.at(range).GetSize(); }
|
||||||
bool IsContiguous() const { return GetRanges() <= 1; }
|
virtual bool IsContiguous() const { return GetRanges() <= 1; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,12 +34,13 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Athenasub.h"
|
#include "Athenasub.h"
|
||||||
|
#include "athenatime.h"
|
||||||
using namespace Athenasub;
|
using namespace Athenasub;
|
||||||
|
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
// Generates a string
|
// Generates a string
|
||||||
String Time::GetString(int ms_precision,int h_precision) const
|
String CTime::GetString(int ms_precision,int h_precision) const
|
||||||
{
|
{
|
||||||
// Enforce sanity
|
// Enforce sanity
|
||||||
ms_precision = Mid(0,ms_precision,3);
|
ms_precision = Mid(0,ms_precision,3);
|
||||||
|
@ -109,7 +110,7 @@ String Time::GetString(int ms_precision,int h_precision) const
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// Parses a string
|
// Parses a string
|
||||||
void Time::Parse(const String &data)
|
void CTime::ParseString(const String &data)
|
||||||
{
|
{
|
||||||
// Break into an array of values
|
// Break into an array of values
|
||||||
array<size_t,4> values;
|
array<size_t,4> values;
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#define ATHENA_DLL
|
#define ATHENA_DLL
|
||||||
#include <aegilib/athenasub.h>
|
|
||||||
#include <wx/wfstream.h>
|
#include <wx/wfstream.h>
|
||||||
|
#include <athenasub/athenawin.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <wx/stopwatch.h>
|
#include <wx/stopwatch.h>
|
||||||
#include "text_file_reader.h"
|
#include "text_file_reader.h"
|
||||||
|
@ -50,13 +50,16 @@ int main()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Set up the lib
|
// Set up the lib
|
||||||
//FormatManager::InitializeFormats();
|
HMODULE module = LoadLibrary(_T("athenasub.dll"));
|
||||||
//Athenasub::SetHostApplicationName(L"Aegilib test program");
|
if (!module) {
|
||||||
LibAthenaSub* lib = CreateLibAthenasub("Aegisub test program");
|
cout << "Failed to load library, aborting.\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
LibAthenaSub lib = Athenasub::Create(module,"Aegilib test program");
|
||||||
|
|
||||||
// Subtitles model
|
// Subtitles model
|
||||||
ModelPtr subs = lib->CreateModel();
|
Model subs = lib->CreateModel();
|
||||||
ControllerPtr control = subs->CreateController();
|
Controller control = subs->CreateController();
|
||||||
wxStopWatch timer;
|
wxStopWatch timer;
|
||||||
|
|
||||||
// Load subtitles
|
// Load subtitles
|
||||||
|
@ -82,15 +85,15 @@ int main()
|
||||||
cout << "Executing action " << n << " times... ";
|
cout << "Executing action " << n << " times... ";
|
||||||
timer.Start();
|
timer.Start();
|
||||||
for (size_t i=0;i<n;i++) {
|
for (size_t i=0;i<n;i++) {
|
||||||
ActionListPtr actions = control->CreateActionList(L"Test");
|
ActionList actions = control->CreateActionList(L"Test");
|
||||||
Selection selection;
|
Selection selection = control->CreateSelection();
|
||||||
selection.AddRange(Range(0,5000));
|
selection->AddRange(Range(0,5000));
|
||||||
selection.AddRange(Range(4500,5500));
|
selection->AddRange(Range(4500,5500));
|
||||||
selection.AddRange(Range(9000,9100));
|
selection->AddRange(Range(9000,9100));
|
||||||
std::vector<EntryPtr> entries = actions->ModifyLines(selection,L"Events");
|
std::vector<Entry> entries = actions->ModifyLines(selection,L"Events");
|
||||||
size_t len = entries.size();
|
size_t len = entries.size();
|
||||||
for (size_t i=0;i<len;i++) {
|
for (size_t i=0;i<len;i++) {
|
||||||
DialoguePtr diag = dynamic_pointer_cast<Dialogue> (entries[i]);
|
Dialogue diag = dynamic_pointer_cast<IDialogue> (entries[i]);
|
||||||
diag->SetStartTime(diag->GetStartTime() - 55555);
|
diag->SetStartTime(diag->GetStartTime() - 55555);
|
||||||
diag->SetEndTime(diag->GetEndTime() + 5555);
|
diag->SetEndTime(diag->GetEndTime() + 5555);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +120,7 @@ int main()
|
||||||
cout << "Done in " << timer.Time() << " ms.\n";
|
cout << "Done in " << timer.Time() << " ms.\n";
|
||||||
|
|
||||||
// Get style test
|
// Get style test
|
||||||
StyleConstPtr style = control->GetStyle(L"japro1_star");
|
ConstStyle style = control->GetStyle(L"japro1_star");
|
||||||
cout << "Style " << style->GetName().mb_str() << " font is " << style->GetFontName().mb_str() << " " << style->GetFontSize() << ".\n";
|
cout << "Style " << style->GetName().mb_str() << " font is " << style->GetFontName().mb_str() << " " << style->GetFontSize() << ".\n";
|
||||||
|
|
||||||
// Save a few more
|
// Save a few more
|
||||||
|
@ -130,15 +133,5 @@ int main()
|
||||||
cout << "\n\nException: " << e.what() << endl << endl;
|
cout << "\n\nException: " << e.what() << endl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false) {
|
|
||||||
wchar_t myArray[] = { 0xD834, 0xDD1E, 0 };
|
|
||||||
String str = wxString(myArray);
|
|
||||||
cout << "Length: " << str.Length() << ". Contents: " << str[0] << "," << str[1] << endl;
|
|
||||||
wxCharBuffer buf = str.mb_str(wxConvUTF8);
|
|
||||||
unsigned char *chr = (unsigned char *) buf.data();
|
|
||||||
cout << "UTF-8 Length: " << strlen(buf) << ". Contents: " << (size_t)chr[0] << "," << (size_t)chr[1] << "," << (size_t)chr[2] << "," << (size_t)chr[3] << endl;
|
|
||||||
str = wxString(buf,wxConvUTF8);
|
|
||||||
cout << "Length: " << str.Length() << ". Contents: " << str[0] << "," << str[1] << endl;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,12 +139,12 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
LinkIncremental="2"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
LinkTimeCodeGeneration="0"
|
LinkTimeCodeGeneration="1"
|
||||||
RandomizedBaseAddress="1"
|
RandomizedBaseAddress="1"
|
||||||
DataExecutionPrevention="0"
|
DataExecutionPrevention="0"
|
||||||
TargetMachine="1"
|
TargetMachine="1"
|
||||||
|
|
Loading…
Reference in New Issue