mirror of https://github.com/odrling/Aegisub
Change AssParameterClass to an enum class
This commit is contained in:
parent
e115206998
commit
be8790942a
|
@ -90,7 +90,7 @@ template<> std::string AssOverrideParameter::Get<std::string>() const {
|
|||
}
|
||||
|
||||
template<> int AssOverrideParameter::Get<int>() const {
|
||||
if (classification == PARCLASS_ALPHA)
|
||||
if (classification == AssParameterClass::ALPHA)
|
||||
// &Hxx&, but vsfilter lets you leave everything out
|
||||
return mid<int>(0, strtol(std::find_if(value.c_str(), value.c_str() + value.size(), isxdigit), nullptr, 16), 255);
|
||||
return atoi(Get<std::string>().c_str());
|
||||
|
@ -127,7 +127,7 @@ template<> void AssOverrideParameter::Set<std::string>(std::string new_value) {
|
|||
}
|
||||
|
||||
template<> void AssOverrideParameter::Set<int>(int new_value) {
|
||||
if (classification == PARCLASS_ALPHA)
|
||||
if (classification == AssParameterClass::ALPHA)
|
||||
Set(str(boost::format("&H%02X&") % mid(0, new_value, 255)));
|
||||
else
|
||||
Set(std::to_string(new_value));
|
||||
|
@ -189,7 +189,7 @@ struct AssOverrideTagProto {
|
|||
/// @param type Data type of the parameter
|
||||
/// @param classi Semantic type of the parameter
|
||||
/// @param opt Situations in which this parameter is present
|
||||
void AddParam(VariableDataType type, AssParameterClass classi = PARCLASS_NORMAL, int opt = NOT_OPTIONAL) {
|
||||
void AddParam(VariableDataType type, AssParameterClass classi = AssParameterClass::NORMAL, int opt = NOT_OPTIONAL) {
|
||||
params.emplace_back(type, opt, classi);
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ struct AssOverrideTagProto {
|
|||
/// @param type Data type of the parameter
|
||||
/// @param classi Semantic type of the parameter
|
||||
/// @param opt Situations in which this parameter is present
|
||||
void Set(const char *name, VariableDataType type, AssParameterClass classi = PARCLASS_NORMAL, int opt = NOT_OPTIONAL) {
|
||||
void Set(const char *name, VariableDataType type, AssParameterClass classi = AssParameterClass::NORMAL, int opt = NOT_OPTIONAL) {
|
||||
this->name = name;
|
||||
params.emplace_back(type, opt, classi);
|
||||
}
|
||||
|
@ -215,13 +215,13 @@ static void load_protos() {
|
|||
|
||||
// Longer tag names must appear before shorter tag names
|
||||
|
||||
proto[0].Set("\\alpha", VariableDataType::TEXT, PARCLASS_ALPHA); // \alpha&H<aa>&
|
||||
proto[++i].Set("\\bord", VariableDataType::FLOAT, PARCLASS_ABSOLUTE_SIZE); // \bord<depth>
|
||||
proto[++i].Set("\\xbord", VariableDataType::FLOAT, PARCLASS_ABSOLUTE_SIZE); // \xbord<depth>
|
||||
proto[++i].Set("\\ybord", VariableDataType::FLOAT, PARCLASS_ABSOLUTE_SIZE); // \ybord<depth>
|
||||
proto[++i].Set("\\shad", VariableDataType::FLOAT, PARCLASS_ABSOLUTE_SIZE); // \shad<depth>
|
||||
proto[++i].Set("\\xshad", VariableDataType::FLOAT, PARCLASS_ABSOLUTE_SIZE); // \xshad<depth>
|
||||
proto[++i].Set("\\yshad", VariableDataType::FLOAT, PARCLASS_ABSOLUTE_SIZE); // \yshad<depth>
|
||||
proto[0].Set("\\alpha", VariableDataType::TEXT, AssParameterClass::ALPHA); // \alpha&H<aa>&
|
||||
proto[++i].Set("\\bord", VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_SIZE); // \bord<depth>
|
||||
proto[++i].Set("\\xbord", VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_SIZE); // \xbord<depth>
|
||||
proto[++i].Set("\\ybord", VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_SIZE); // \ybord<depth>
|
||||
proto[++i].Set("\\shad", VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_SIZE); // \shad<depth>
|
||||
proto[++i].Set("\\xshad", VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_SIZE); // \xshad<depth>
|
||||
proto[++i].Set("\\yshad", VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_SIZE); // \yshad<depth>
|
||||
|
||||
// \fade(<a1>,<a2>,<a3>,<t1>,<t2>,<t3>,<t4>)
|
||||
i++;
|
||||
|
@ -229,72 +229,72 @@ static void load_protos() {
|
|||
proto[i].AddParam(VariableDataType::INT);
|
||||
proto[i].AddParam(VariableDataType::INT);
|
||||
proto[i].AddParam(VariableDataType::INT);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_RELATIVE_TIME_START);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_RELATIVE_TIME_START);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_RELATIVE_TIME_START);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_RELATIVE_TIME_START);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::RELATIVE_TIME_START);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::RELATIVE_TIME_START);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::RELATIVE_TIME_START);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::RELATIVE_TIME_START);
|
||||
|
||||
// \move(<x1>,<y1>,<x2>,<y2>[,<t1>,<t2>])
|
||||
i++;
|
||||
proto[i].name = "\\move";
|
||||
proto[i].AddParam(VariableDataType::FLOAT, PARCLASS_ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::FLOAT, PARCLASS_ABSOLUTE_POS_Y);
|
||||
proto[i].AddParam(VariableDataType::FLOAT, PARCLASS_ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::FLOAT, PARCLASS_ABSOLUTE_POS_Y);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_RELATIVE_TIME_START);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_RELATIVE_TIME_START);
|
||||
proto[i].AddParam(VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_POS_Y);
|
||||
proto[i].AddParam(VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_POS_Y);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::RELATIVE_TIME_START);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::RELATIVE_TIME_START);
|
||||
|
||||
// If these are rearranged, keep rect clip and vector clip adjacent in this order
|
||||
// \clip(<x1>,<y1>,<x2>,<y2>)
|
||||
i++;
|
||||
proto[i].name = "\\clip";
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_ABSOLUTE_POS_Y);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_ABSOLUTE_POS_Y);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::ABSOLUTE_POS_Y);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::ABSOLUTE_POS_Y);
|
||||
|
||||
// \clip([<scale>,]<some drawings>)
|
||||
i++;
|
||||
proto[i].name = "\\clip";
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_NORMAL,OPTIONAL_2);
|
||||
proto[i].AddParam(VariableDataType::TEXT, PARCLASS_DRAWING);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::NORMAL,OPTIONAL_2);
|
||||
proto[i].AddParam(VariableDataType::TEXT, AssParameterClass::DRAWING);
|
||||
|
||||
// \iclip(<x1>,<y1>,<x2>,<y2>)
|
||||
i++;
|
||||
proto[i].name = "\\iclip";
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_ABSOLUTE_POS_Y);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_ABSOLUTE_POS_Y);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::ABSOLUTE_POS_Y);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::ABSOLUTE_POS_Y);
|
||||
|
||||
// \iclip([<scale>,]<some drawings>)
|
||||
i++;
|
||||
proto[i].name = "\\iclip";
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_NORMAL,OPTIONAL_2);
|
||||
proto[i].AddParam(VariableDataType::TEXT, PARCLASS_DRAWING);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::NORMAL,OPTIONAL_2);
|
||||
proto[i].AddParam(VariableDataType::TEXT, AssParameterClass::DRAWING);
|
||||
|
||||
proto[++i].Set("\\fscx", VariableDataType::FLOAT, PARCLASS_RELATIVE_SIZE_X); // \fscx<percent>
|
||||
proto[++i].Set("\\fscy", VariableDataType::FLOAT, PARCLASS_RELATIVE_SIZE_Y); // \fscy<percent>
|
||||
proto[++i].Set("\\fscx", VariableDataType::FLOAT, AssParameterClass::RELATIVE_SIZE_X); // \fscx<percent>
|
||||
proto[++i].Set("\\fscy", VariableDataType::FLOAT, AssParameterClass::RELATIVE_SIZE_Y); // \fscy<percent>
|
||||
// \pos(<x>,<y>)
|
||||
i++;
|
||||
proto[i].name = "\\pos";
|
||||
proto[i].AddParam(VariableDataType::FLOAT, PARCLASS_ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::FLOAT, PARCLASS_ABSOLUTE_POS_Y);
|
||||
proto[i].AddParam(VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_POS_Y);
|
||||
|
||||
// \org(<x>,<y>)
|
||||
i++;
|
||||
proto[i].name = "\\org";
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_ABSOLUTE_POS_Y);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::ABSOLUTE_POS_X);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::ABSOLUTE_POS_Y);
|
||||
|
||||
proto[++i].Set("\\pbo", VariableDataType::INT, PARCLASS_ABSOLUTE_POS_Y); // \pbo<y>
|
||||
proto[++i].Set("\\pbo", VariableDataType::INT, AssParameterClass::ABSOLUTE_POS_Y); // \pbo<y>
|
||||
// \fad(<t1>,<t2>)
|
||||
i++;
|
||||
proto[i].name = "\\fad";
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_RELATIVE_TIME_START);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_RELATIVE_TIME_END);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::RELATIVE_TIME_START);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::RELATIVE_TIME_END);
|
||||
|
||||
proto[++i].Set("\\fsp", VariableDataType::FLOAT, PARCLASS_ABSOLUTE_SIZE); // \fsp<pixels>
|
||||
proto[++i].Set("\\fsp", VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_SIZE); // \fsp<pixels>
|
||||
proto[++i].Set("\\frx", VariableDataType::FLOAT); // \frx<degrees>
|
||||
proto[++i].Set("\\fry", VariableDataType::FLOAT); // \fry<degrees>
|
||||
proto[++i].Set("\\frz", VariableDataType::FLOAT); // \frz<degrees>
|
||||
|
@ -305,19 +305,19 @@ static void load_protos() {
|
|||
proto[++i].Set("\\2c", VariableDataType::TEXT); // \2c&H<bbggrr>&
|
||||
proto[++i].Set("\\3c", VariableDataType::TEXT); // \3c&H<bbggrr>&
|
||||
proto[++i].Set("\\4c", VariableDataType::TEXT); // \4c&H<bbggrr>&
|
||||
proto[++i].Set("\\1a", VariableDataType::TEXT, PARCLASS_ALPHA); // \1a&H<aa>&
|
||||
proto[++i].Set("\\2a", VariableDataType::TEXT, PARCLASS_ALPHA); // \2a&H<aa>&
|
||||
proto[++i].Set("\\3a", VariableDataType::TEXT, PARCLASS_ALPHA); // \3a&H<aa>&
|
||||
proto[++i].Set("\\4a", VariableDataType::TEXT, PARCLASS_ALPHA); // \4a&H<aa>&
|
||||
proto[++i].Set("\\1a", VariableDataType::TEXT, AssParameterClass::ALPHA); // \1a&H<aa>&
|
||||
proto[++i].Set("\\2a", VariableDataType::TEXT, AssParameterClass::ALPHA); // \2a&H<aa>&
|
||||
proto[++i].Set("\\3a", VariableDataType::TEXT, AssParameterClass::ALPHA); // \3a&H<aa>&
|
||||
proto[++i].Set("\\4a", VariableDataType::TEXT, AssParameterClass::ALPHA); // \4a&H<aa>&
|
||||
proto[++i].Set("\\fe", VariableDataType::TEXT); // \fe<charset>
|
||||
proto[++i].Set("\\ko", VariableDataType::INT, PARCLASS_KARAOKE); // \ko<duration>
|
||||
proto[++i].Set("\\kf", VariableDataType::INT, PARCLASS_KARAOKE); // \kf<duration>
|
||||
proto[++i].Set("\\ko", VariableDataType::INT, AssParameterClass::KARAOKE); // \ko<duration>
|
||||
proto[++i].Set("\\kf", VariableDataType::INT, AssParameterClass::KARAOKE); // \kf<duration>
|
||||
proto[++i].Set("\\be", VariableDataType::INT); // \be<strength>
|
||||
proto[++i].Set("\\blur", VariableDataType::FLOAT); // \blur<strength>
|
||||
proto[++i].Set("\\fn", VariableDataType::TEXT); // \fn<name>
|
||||
proto[++i].Set("\\fs+", VariableDataType::FLOAT); // \fs+<size>
|
||||
proto[++i].Set("\\fs-", VariableDataType::FLOAT); // \fs-<size>
|
||||
proto[++i].Set("\\fs", VariableDataType::FLOAT, PARCLASS_ABSOLUTE_SIZE); // \fs<size>
|
||||
proto[++i].Set("\\fs", VariableDataType::FLOAT, AssParameterClass::ABSOLUTE_SIZE); // \fs<size>
|
||||
proto[++i].Set("\\an", VariableDataType::INT); // \an<alignment>
|
||||
proto[++i].Set("\\c", VariableDataType::TEXT); // \c&H<bbggrr>&
|
||||
proto[++i].Set("\\b", VariableDataType::INT); // \b<0/1/weight>
|
||||
|
@ -325,8 +325,8 @@ static void load_protos() {
|
|||
proto[++i].Set("\\u", VariableDataType::BOOL); // \u<0/1>
|
||||
proto[++i].Set("\\s", VariableDataType::BOOL); // \s<0/1>
|
||||
proto[++i].Set("\\a", VariableDataType::INT); // \a<alignment>
|
||||
proto[++i].Set("\\k", VariableDataType::INT, PARCLASS_KARAOKE); // \k<duration>
|
||||
proto[++i].Set("\\K", VariableDataType::INT, PARCLASS_KARAOKE); // \K<duration>
|
||||
proto[++i].Set("\\k", VariableDataType::INT, AssParameterClass::KARAOKE); // \k<duration>
|
||||
proto[++i].Set("\\K", VariableDataType::INT, AssParameterClass::KARAOKE); // \K<duration>
|
||||
proto[++i].Set("\\q", VariableDataType::INT); // \q<0-3>
|
||||
proto[++i].Set("\\p", VariableDataType::INT); // \p<n>
|
||||
proto[++i].Set("\\r", VariableDataType::TEXT); // \r[<name>]
|
||||
|
@ -334,9 +334,9 @@ static void load_protos() {
|
|||
// \t([<t1>,<t2>,][<accel>,]<style modifiers>)
|
||||
i++;
|
||||
proto[i].name = "\\t";
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_RELATIVE_TIME_START,OPTIONAL_3 | OPTIONAL_4);
|
||||
proto[i].AddParam(VariableDataType::INT, PARCLASS_RELATIVE_TIME_START,OPTIONAL_3 | OPTIONAL_4);
|
||||
proto[i].AddParam(VariableDataType::FLOAT, PARCLASS_NORMAL,OPTIONAL_2 | OPTIONAL_4);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::RELATIVE_TIME_START,OPTIONAL_3 | OPTIONAL_4);
|
||||
proto[i].AddParam(VariableDataType::INT, AssParameterClass::RELATIVE_TIME_START,OPTIONAL_3 | OPTIONAL_4);
|
||||
proto[i].AddParam(VariableDataType::FLOAT, AssParameterClass::NORMAL,OPTIONAL_2 | OPTIONAL_4);
|
||||
proto[i].AddParam(VariableDataType::BLOCK);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,18 +39,18 @@
|
|||
class AssDialogueBlockOverride;
|
||||
|
||||
/// Type of parameter
|
||||
enum AssParameterClass {
|
||||
PARCLASS_NORMAL,
|
||||
PARCLASS_ABSOLUTE_SIZE,
|
||||
PARCLASS_ABSOLUTE_POS_X,
|
||||
PARCLASS_ABSOLUTE_POS_Y,
|
||||
PARCLASS_RELATIVE_SIZE_X,
|
||||
PARCLASS_RELATIVE_SIZE_Y,
|
||||
PARCLASS_RELATIVE_TIME_START,
|
||||
PARCLASS_RELATIVE_TIME_END,
|
||||
PARCLASS_KARAOKE,
|
||||
PARCLASS_DRAWING,
|
||||
PARCLASS_ALPHA
|
||||
enum class AssParameterClass {
|
||||
NORMAL,
|
||||
ABSOLUTE_SIZE,
|
||||
ABSOLUTE_POS_X,
|
||||
ABSOLUTE_POS_Y,
|
||||
RELATIVE_SIZE_X,
|
||||
RELATIVE_SIZE_Y,
|
||||
RELATIVE_TIME_START,
|
||||
RELATIVE_TIME_END,
|
||||
KARAOKE,
|
||||
DRAWING,
|
||||
ALPHA
|
||||
};
|
||||
|
||||
enum class VariableDataType {
|
||||
|
|
|
@ -160,29 +160,29 @@ namespace {
|
|||
int shift = 0;
|
||||
|
||||
switch (cur->classification) {
|
||||
case PARCLASS_ABSOLUTE_SIZE:
|
||||
case AssParameterClass::ABSOLUTE_SIZE:
|
||||
resizer = state->ry;
|
||||
break;
|
||||
|
||||
case PARCLASS_ABSOLUTE_POS_X:
|
||||
case AssParameterClass::ABSOLUTE_POS_X:
|
||||
resizer = state->rx;
|
||||
shift = state->margin[LEFT];
|
||||
break;
|
||||
|
||||
case PARCLASS_ABSOLUTE_POS_Y:
|
||||
case AssParameterClass::ABSOLUTE_POS_Y:
|
||||
resizer = state->ry;
|
||||
shift = state->margin[TOP];
|
||||
break;
|
||||
|
||||
case PARCLASS_RELATIVE_SIZE_X:
|
||||
case AssParameterClass::RELATIVE_SIZE_X:
|
||||
resizer = state->ar;
|
||||
break;
|
||||
|
||||
case PARCLASS_RELATIVE_SIZE_Y:
|
||||
case AssParameterClass::RELATIVE_SIZE_Y:
|
||||
//resizer = ry;
|
||||
break;
|
||||
|
||||
case PARCLASS_DRAWING: {
|
||||
case AssParameterClass::DRAWING: {
|
||||
AssDialogueBlockDrawing block(cur->Get<std::string>(), 1);
|
||||
block.TransformCoords(state->margin[LEFT], state->margin[TOP], state->rx, state->ry);
|
||||
cur->Set(block.GetText());
|
||||
|
|
|
@ -179,7 +179,7 @@ void AssTransformFramerateFilter::TransformTimeTags(std::string const& name, Ass
|
|||
int parVal = curParam->Get<int>();
|
||||
|
||||
switch (curParam->classification) {
|
||||
case PARCLASS_RELATIVE_TIME_START: {
|
||||
case AssParameterClass::RELATIVE_TIME_START: {
|
||||
int value = instance->ConvertTime(trunc_cs(curDiag->Start) + parVal) - instance->newStart;
|
||||
|
||||
// An end time of 0 is actually the end time of the line, so ensure
|
||||
|
@ -191,10 +191,10 @@ void AssTransformFramerateFilter::TransformTimeTags(std::string const& name, Ass
|
|||
curParam->Set(value);
|
||||
break;
|
||||
}
|
||||
case PARCLASS_RELATIVE_TIME_END:
|
||||
case AssParameterClass::RELATIVE_TIME_END:
|
||||
curParam->Set(instance->newEnd - instance->ConvertTime(trunc_cs(curDiag->End) - parVal));
|
||||
break;
|
||||
case PARCLASS_KARAOKE: {
|
||||
case AssParameterClass::KARAOKE: {
|
||||
int start = curDiag->Start / 10 + instance->oldK + parVal;
|
||||
int value = (instance->ConvertTime(start * 10) - instance->newStart) / 10 - instance->newK;
|
||||
instance->oldK += parVal;
|
||||
|
|
Loading…
Reference in New Issue