feat: Add 'repeat' option to 'Lua Script' special function (#3338)
* Add support for the '1x' repeat option for 'Play Script' special functions. * Add Companion and B&W radio support. * Fix B&W radio logic and layout. * Add translation hooks.
This commit is contained in:
@@ -394,6 +394,19 @@ AbstractStaticItemModel * CustomFunctionData::repeatItemModel()
|
||||
return mdl;
|
||||
}
|
||||
|
||||
// static
|
||||
AbstractStaticItemModel * CustomFunctionData::repeatLuaItemModel()
|
||||
{
|
||||
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
|
||||
mdl->setName("customfunctiondata.repeatLua");
|
||||
|
||||
mdl->appendToItemList(tr("On"), 0);
|
||||
mdl->appendToItemList(tr("1x"), 1);
|
||||
|
||||
mdl->loadItemList();
|
||||
return mdl;
|
||||
}
|
||||
|
||||
// static
|
||||
AbstractStaticItemModel * CustomFunctionData::playSoundItemModel()
|
||||
{
|
||||
|
||||
@@ -136,6 +136,7 @@ class CustomFunctionData {
|
||||
static QStringList gvarAdjustModeStringList();
|
||||
static QString gvarAdjustModeToString(const int value);
|
||||
static AbstractStaticItemModel * repeatItemModel();
|
||||
static AbstractStaticItemModel * repeatLuaItemModel();
|
||||
static AbstractStaticItemModel * playSoundItemModel();
|
||||
static AbstractStaticItemModel * harpicItemModel();
|
||||
static AbstractStaticItemModel * gvarAdjustModeItemModel();
|
||||
|
||||
@@ -37,7 +37,8 @@ static bool fnHasRepeat(AssignFunc fn)
|
||||
|| (fn == FuncPlayValue)
|
||||
|| (fn == FuncPlayHaptic)
|
||||
|| (fn == FuncPlaySound)
|
||||
|| (fn == FuncSetScreen);
|
||||
|| (fn == FuncSetScreen)
|
||||
|| (fn == FuncPlayScript);
|
||||
}
|
||||
|
||||
static const YamlLookupTable customFnLut = {
|
||||
@@ -225,7 +226,9 @@ Node convert<CustomFunctionData>::encode(const CustomFunctionData& rhs)
|
||||
if (add_comma) {
|
||||
def += ",";
|
||||
}
|
||||
if (rhs.repeatParam == 0) {
|
||||
if (rhs.func == FuncPlayScript) {
|
||||
def += ((rhs.repeatParam == 0) ? "On" : "1x");
|
||||
} else if (rhs.repeatParam == 0) {
|
||||
def += "1x";
|
||||
} else if (rhs.repeatParam == -1) {
|
||||
def += "!1x";
|
||||
@@ -374,7 +377,9 @@ bool convert<CustomFunctionData>::decode(const Node& node,
|
||||
} else if(fnHasRepeat(rhs.func)) {
|
||||
std::string repeat;
|
||||
getline(def, repeat);
|
||||
if (repeat == "1x") {
|
||||
if (rhs.func == FuncPlayScript) {
|
||||
rhs.repeatParam = (repeat == "1x") ? 1 : 0;
|
||||
} else if (repeat == "1x") {
|
||||
rhs.repeatParam = 0;
|
||||
} else if (repeat == "!1x") {
|
||||
rhs.repeatParam = -1;
|
||||
|
||||
@@ -39,6 +39,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
|
||||
playSoundId = tabModelFactory->registerItemModel(CustomFunctionData::playSoundItemModel());
|
||||
harpicId = tabModelFactory->registerItemModel(CustomFunctionData::harpicItemModel());
|
||||
repeatId = tabModelFactory->registerItemModel(CustomFunctionData::repeatItemModel());
|
||||
repeatLuaId = tabModelFactory->registerItemModel(CustomFunctionData::repeatLuaItemModel());
|
||||
gvarAdjustModeId = tabModelFactory->registerItemModel(CustomFunctionData::gvarAdjustModeItemModel());
|
||||
|
||||
tabFilterFactory = new FilteredItemModelFactory();
|
||||
@@ -193,7 +194,10 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
|
||||
tableLayout->addLayout(i, 4, repeatLayout);
|
||||
fswtchRepeat[i] = new QComboBox(this);
|
||||
fswtchRepeat[i]->setProperty("index", i);
|
||||
fswtchRepeat[i]->setModel(tabModelFactory->getItemModel(repeatId));
|
||||
if (functions[i].func == FuncPlayScript)
|
||||
fswtchRepeat[i]->setModel(tabModelFactory->getItemModel(repeatLuaId));
|
||||
else
|
||||
fswtchRepeat[i]->setModel(tabModelFactory->getItemModel(repeatId));
|
||||
fswtchRepeat[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
|
||||
fswtchRepeat[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
repeatLayout->addWidget(fswtchRepeat[i], i + 1);
|
||||
@@ -324,6 +328,10 @@ void CustomFunctionsPanel::functionEdited()
|
||||
functions[index].clear();
|
||||
functions[index].swtch = swtch;
|
||||
functions[index].func = (AssignFunc)fswtchFunc[index]->currentData().toInt();
|
||||
if (functions[index].func == FuncPlayScript)
|
||||
fswtchRepeat[index]->setModel(tabModelFactory->getItemModel(repeatLuaId));
|
||||
else
|
||||
fswtchRepeat[index]->setModel(tabModelFactory->getItemModel(repeatId));
|
||||
refreshCustomFunction(index);
|
||||
emit modified();
|
||||
lock = false;
|
||||
@@ -523,11 +531,13 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||
}
|
||||
}
|
||||
else if (func == FuncPlayScript) {
|
||||
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
|
||||
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM | CUSTOM_FUNCTION_REPEAT;
|
||||
if (modified) {
|
||||
Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, 8);
|
||||
cfn.repeatParam = fswtchRepeat[i]->currentData().toInt();
|
||||
}
|
||||
Helpers::populateFileComboBox(fswtchParamArmT[i], scriptsSet, cfn.paramarm);
|
||||
fswtchRepeat[i]->setCurrentIndex(fswtchRepeat[i]->findData(cfn.repeatParam));
|
||||
}
|
||||
else {
|
||||
if (modified)
|
||||
|
||||
@@ -87,6 +87,7 @@ class CustomFunctionsPanel : public GenericPanel
|
||||
int playSoundId;
|
||||
int harpicId;
|
||||
int repeatId;
|
||||
int repeatLuaId;
|
||||
int gvarAdjustModeId;
|
||||
|
||||
QSet<QString> tracksSet;
|
||||
|
||||
Reference in New Issue
Block a user