A little more athenasub refactoring.
Originally committed to SVN as r2461.
This commit is contained in:
parent
9280b56e34
commit
1f1261c997
5 changed files with 11 additions and 14 deletions
|
@ -116,7 +116,7 @@ namespace Athenasub {
|
|||
virtual void Clear() = 0;
|
||||
virtual void Load(wxInputStream &input,Format format=Format(),const String encoding="") = 0;
|
||||
|
||||
virtual void AddSection(String name) = 0;
|
||||
virtual Section AddSection(String name) = 0;
|
||||
virtual Section GetMutableSection(String name) = 0;
|
||||
virtual Section GetMutableSectionByIndex(size_t index) = 0;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Athenasub {
|
|||
protected:
|
||||
virtual ~CFormatHandler() {}
|
||||
|
||||
void AddSection(IModel &model,String name) const { model.AddSection(name); }
|
||||
Section AddSection(IModel &model,String name) const { return model.AddSection(name); }
|
||||
ConstSection GetSection(const IModel &model,String name) const { return model.GetSection(name); }
|
||||
ConstSection GetSectionByIndex(const IModel &model,size_t index) const { return model.GetSectionByIndex(index); }
|
||||
Section GetSection(IModel &model,String name) const { return model.GetMutableSection(name); }
|
||||
|
|
|
@ -378,9 +378,7 @@ void FormatHandlerASS::MakeValid(IModel &model)
|
|||
|
||||
// Check for [Script Info]
|
||||
Section section = GetSection(model,"Script Info");
|
||||
if (!section) AddSection(model,"Script Info");
|
||||
section = GetSection(model,"Script Info");
|
||||
if (!section) THROW_ATHENA_EXCEPTION(Exception::Internal_Error);
|
||||
if (!section) section = AddSection(model,"Script Info");
|
||||
|
||||
// Check if necessary variables are available
|
||||
if (section->GetProperty("PlayResX").IsEmpty()) section->SetProperty("PlayResX","384"); // These two mystical values come from Substation Alpha
|
||||
|
@ -389,15 +387,11 @@ void FormatHandlerASS::MakeValid(IModel &model)
|
|||
|
||||
// Get [V4+ Styles]
|
||||
section = GetSection(model,"V4+ Styles");
|
||||
if (!section) AddSection(model,"V4+ Styles");
|
||||
section = GetSection(model,"V4+ Styles");
|
||||
if (!section) THROW_ATHENA_EXCEPTION(Exception::Internal_Error);
|
||||
if (!section) section = AddSection(model,"V4+ Styles");
|
||||
section->SetProperty("Format","Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding");
|
||||
|
||||
// Get [Events]
|
||||
section = GetSection(model,"Events");
|
||||
if (!section) AddSection(model,"Events");
|
||||
section = GetSection(model,"Events");
|
||||
if (!section) THROW_ATHENA_EXCEPTION(Exception::Internal_Error);
|
||||
if (!section) section = AddSection(model,"Events");
|
||||
section->SetProperty("Format","Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text");
|
||||
}
|
||||
|
|
|
@ -153,11 +153,14 @@ void CModel::Save(wxOutputStream &output,const Format _format,const String encod
|
|||
|
||||
/////////////////////////
|
||||
// Inserts a new section
|
||||
void CModel::AddSection(String name)
|
||||
Section CModel::AddSection(String name)
|
||||
{
|
||||
ConstSection prev = GetSection(name);
|
||||
if (prev) THROW_ATHENA_EXCEPTION(Exception::Section_Already_Exists);
|
||||
sections.push_back(Section(new CSection(name)));
|
||||
|
||||
Section result = Section(new CSection(name));
|
||||
sections.push_back(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace Athenasub {
|
|||
void Clear();
|
||||
void Load(wxInputStream &input,Format format=Format(),const String encoding="");
|
||||
|
||||
void AddSection(String name);
|
||||
Section AddSection(String name);
|
||||
Section GetMutableSection(String name);
|
||||
Section GetMutableSectionByIndex(size_t index);
|
||||
|
||||
|
|
Loading…
Reference in a new issue