Skip to content
Permalink
Browse files
Editor: Added the new autoscroll event settings
Added an ability to change the new way of autoscroll option settings from the SMBX-38A. This way should allow making the robust and stable controlling of the autoscroll on TheXTech and on SMBX-38A engines. These settings should work once they will be implemeted at the Moondust Engine.
  • Loading branch information
Wohlstand committed Jul 4, 2021
1 parent 00a62c9 commit d71bb31e21801f72603515b50cec8a364c49eb14
Show file tree
Hide file tree
Showing 8 changed files with 542 additions and 64 deletions.
@@ -291,6 +291,8 @@ bool DataConfig::loadBasics()
guiset.readEnum("level-warp-on-enter-event", editor.supported_features.level_warp_on_enter_event, EditorSetup::FeaturesSupport::F_ENABLED, formatEnum);
guiset.readEnum("level-warp-cannon-exit", editor.supported_features.level_warp_cannon_exit, EditorSetup::FeaturesSupport::F_ENABLED, formatEnum);

guiset.readEnum("level-event-new-autoscroll", editor.supported_features.level_event_new_autoscroll, EditorSetup::FeaturesSupport::F_ENABLED, formatEnum);

guiset.readEnum("world-hawkmouth-exit", editor.supported_features.world_hawkmouth_exit, EditorSetup::FeaturesSupport::F_HIDDEN, formatEnum);
}
guiset.endGroup();
@@ -176,6 +176,8 @@ struct EditorSetup
State level_warp_on_enter_event = F_ENABLED;
State level_warp_cannon_exit = F_ENABLED;

State level_event_new_autoscroll = F_ENABLED;

State level_npc_vertical_dontmove = F_DISABLED;
State world_custom_credits = F_DISABLED;

@@ -138,6 +138,10 @@ class HistorySettings{
SETTING_EV_SECSIZE, //extraData: QList<QVariant[long]> [Section, old top, old right, old bottom, old left, top, right, bottom, left]
SETTING_EV_SECMUS, //extraData: QList<QVariant[long]> [Section, old music id, new music id]
SETTING_EV_SECBG, //extraData: QList<QVariant[long]> [Section, old background id, new background id]
SETTING_EV_SECASEN, //extraData: QList<QVariant[long]> [Section, old autoscroll enable, new autoscroll enable]
SETTING_EV_SECASTYPE, //extraData: QList<QVariant[long]> [Section, old autoscroll type, new autoscroll type]
SETTING_EV_SECASX, //extraData: QList<QVariant[long]> [Section, old autoscroll x, new autoscroll x]
SETTING_EV_SECASY, //extraData: QList<QVariant[long]> [Section, old autoscroll y, new autoscroll y]
SETTING_EV_MSG, //extraDara: QList<QVariant[String]> [Old msg, New msg]
SETTING_EV_SOUND, //extraDara: QList<QVariant[long]> [Old sound id, New sound id]
SETTING_EV_ENDGAME, //extraData: QList<QVariant[long]> [Old endgame id, New endgame id]
@@ -141,6 +141,22 @@ void HistoryElementSettingsEvent::undo()
eventp->sets[(int)extraData.toList()[0].toLongLong()].background_id = (long)extraData.toList()[1].toLongLong();
}
else
if(subtype == HistorySettings::SETTING_EV_SECASEN){
eventp->sets[(int)extraData.toList()[0].toLongLong()].autoscrol = extraData.toList()[1].toBool();
}
else
if(subtype == HistorySettings::SETTING_EV_SECASTYPE){
eventp->sets[(int)extraData.toList()[0].toLongLong()].autoscroll_style = extraData.toList()[1].toInt();
}
else
if(subtype == HistorySettings::SETTING_EV_SECASX){
eventp->sets[(int)extraData.toList()[0].toLongLong()].autoscrol_x = extraData.toList()[1].toDouble();
}
else
if(subtype == HistorySettings::SETTING_EV_SECASY){
eventp->sets[(int)extraData.toList()[0].toLongLong()].autoscrol_y = extraData.toList()[1].toDouble();
}
else
if(subtype == HistorySettings::SETTING_EV_MSG){
eventp->msg = extraData.toList()[0].toString();
}
@@ -329,6 +345,22 @@ void HistoryElementSettingsEvent::redo()
eventp->sets[(int)extraData.toList()[0].toLongLong()].background_id = (long)extraData.toList()[2].toLongLong();
}
else
if(subtype == HistorySettings::SETTING_EV_SECASEN){
eventp->sets[(int)extraData.toList()[0].toLongLong()].autoscrol = extraData.toList()[2].toBool();
}
else
if(subtype == HistorySettings::SETTING_EV_SECASTYPE){
eventp->sets[(int)extraData.toList()[0].toLongLong()].autoscroll_style = extraData.toList()[2].toInt();
}
else
if(subtype == HistorySettings::SETTING_EV_SECASX){
eventp->sets[(int)extraData.toList()[0].toLongLong()].autoscrol_x = extraData.toList()[2].toDouble();
}
else
if(subtype == HistorySettings::SETTING_EV_SECASY){
eventp->sets[(int)extraData.toList()[0].toLongLong()].autoscrol_y = extraData.toList()[2].toDouble();
}
else
if(subtype == HistorySettings::SETTING_EV_MSG){
eventp->msg = extraData.toList()[1].toString();
}
@@ -58,6 +58,9 @@ LvlEventsBox::LvlEventsBox(QWidget *parent) :
QObject::connect(ui->sctBg_image, &ImageSelector::currentItemChanged,
this, &LvlEventsBox::sctBackgroundImageChanged);

QObject::connect(mw(), SIGNAL(setSMBX64Strict(bool)),
this, SLOT(setSMBX64Strict(bool)));

m_lastVisibilityState = isVisible();
mw()->docks_level.
addState(this, &m_lastVisibilityState);
@@ -330,7 +333,7 @@ void LvlEventsBox::setEventData(long index)
{
m_currentEventArrayID = cIndex;

foreach(LevelSMBX64Event event, edit->LvlData.events)
for(LevelSMBX64Event event : edit->LvlData.events)
{
if(event.meta.array_id == (unsigned int)cIndex)
{
@@ -492,7 +495,8 @@ void LvlEventsBox::refreshShownTabs(LevelSMBX64Event event, bool hideAll)
{
if((event.sets[i].background_id != -1) ||
(event.sets[i].music_id != -1) ||
(event.sets[i].position_left != -1))
(event.sets[i].position_left != -1) ||
event.sets[i].autoscrol)
{
ui->SectionSettings_toggleBox->setChecked(true);
ui->SectionSettings_area->setVisible(true);
@@ -562,6 +566,19 @@ bool LvlEventsBox::eventIsExist(QString evt)
return false;
}

void LvlEventsBox::setSMBX64Strict(bool en)
{
DataConfig &c = mw()->configs;
bool enabled = !en;

ui->sectionAutoscroll->setToolTip(en ? tr("Disabled by the strict SMBX64 mode") : QString());
ui->sectionAutoscroll->setEnabled(enabled && (c.editor.supported_features.level_event_new_autoscroll == EditorSetup::FeaturesSupport::F_ENABLED));
ui->sectionAutoscroll->setHidden(c.editor.supported_features.level_event_new_autoscroll == EditorSetup::FeaturesSupport::F_HIDDEN);

ui->sectionAutoscrollLegacyNote->setVisible(!en);
ui->AutoscrollSection_toggleBox->setText(en ? tr("Autoscroll section") : tr("Autoscroll section (Legacy)"));
}


void LvlEventsBox::eventSectionSettingsSync()
{
@@ -666,6 +683,12 @@ void LvlEventsBox::eventSectionSettingsSync()
ui->sctBg_image->setItem(backgrndID);
break;
}

ui->sectionAutoscroll->setChecked(SectionSet.autoscrol);
ui->autoscrollType->setCurrentIndex(SectionSet.autoscroll_style);
on_autoscrollType_currentIndexChanged(SectionSet.autoscroll_style);
ui->simpleAutoscrollH->setValue(SectionSet.autoscrol_x);
ui->simpleAutoscrollV->setValue(SectionSet.autoscrol_y);
}

m_lockEventSectionDataList = false;
@@ -2120,6 +2143,7 @@ void LvlEventsBox::on_LVLEvent_SctBg_reset_clicked()
bgData.push_back(qlonglong(SectionSet.background_id));
bgData.push_back(qlonglong(-2));
edit->scene->m_history->addChangeEventSettings(event.meta.array_id, HistorySettings::SETTING_EV_SECBG, QVariant(bgData));
edit->LvlData.meta.modified = true;
SectionSet.background_id = -2;
}

@@ -2156,6 +2180,7 @@ void LvlEventsBox::on_LVLEvent_SctBg_define_clicked()
bgData.push_back(qlonglong(SectionSet.background_id));
bgData.push_back(qlonglong(bgId));
edit->scene->m_history->addChangeEventSettings(event.meta.array_id, HistorySettings::SETTING_EV_SECBG, QVariant(bgData));
edit->LvlData.meta.modified = true;
SectionSet.background_id = bgId;
}

@@ -2191,6 +2216,7 @@ void LvlEventsBox::sctBackgroundImageChanged(int index)
bgData.push_back(qlonglong(SectionSet.background_id));
bgData.push_back(qlonglong(index));
edit->scene->m_history->addChangeEventSettings(event.meta.array_id, HistorySettings::SETTING_EV_SECBG, QVariant(bgData));
edit->LvlData.meta.modified = true;
SectionSet.background_id = index;
}

@@ -2648,3 +2674,168 @@ void LvlEventsBox::on_bps_Scroll_vertSpeed_clicked()

ui->LVLEvent_Scroll_spY->setValue(bps.result());
}

void LvlEventsBox::on_autoscrollType_currentIndexChanged(int index)
{
ui->autoscrollSimple->setVisible(false);
ui->autoscrollAdvanced->setVisible(false);

switch(index)
{
case LevelEvent_Sets::AUTOSCROLL_SIMPLE:
ui->autoscrollSimple->setVisible(true);
break;
case LevelEvent_Sets::AUTOSCROLL_ADVANCED:
ui->autoscrollAdvanced->setVisible(true);
break;
}

if(m_internalLock || m_externalLock || m_lockEventSectionDataList)
return;

int WinType = mw()->activeChildWindow();

if(WinType == MainWindow::WND_Level)
{
LevelEdit *edit = mw()->activeLvlEditWin();

if(!edit)
return;

long i = getEventArrayIndex();

if(i < 0)
return;

LevelSMBX64Event &event = edit->LvlData.events[i];
checkSectionSet(event.sets, m_curSectionField);
LevelEvent_Sets &SectionSet = event.sets[m_curSectionField];
QList<QVariant> bgData;
bgData.push_back(qlonglong(m_curSectionField));
bgData.push_back(qlonglong(SectionSet.autoscroll_style));
bgData.push_back(qlonglong(index));
edit->scene->m_history->addChangeEventSettings(event.meta.array_id, HistorySettings::SETTING_EV_SECASTYPE, QVariant(bgData));
edit->LvlData.meta.modified = true;
SectionSet.autoscroll_style = index;
}
}

void LvlEventsBox::on_simpleAutoscrollH_valueChanged(double arg1)
{
if(m_internalLock || m_externalLock || m_lockEventSectionDataList)
return;

int WinType = mw()->activeChildWindow();

if(WinType == MainWindow::WND_Level)
{
LevelEdit *edit = mw()->activeLvlEditWin();

if(!edit)
return;

long i = getEventArrayIndex();

if(i < 0)
return;

LevelSMBX64Event &event = edit->LvlData.events[i];
checkSectionSet(event.sets, m_curSectionField);
LevelEvent_Sets &SectionSet = event.sets[m_curSectionField];
QList<QVariant> bgData;
bgData.push_back(qlonglong(m_curSectionField));
bgData.push_back(qlonglong(SectionSet.autoscrol_x));
bgData.push_back(qlonglong(arg1));
edit->scene->m_history->addChangeEventSettings(event.meta.array_id, HistorySettings::SETTING_EV_SECASX, QVariant(bgData));
edit->LvlData.meta.modified = true;
SectionSet.autoscrol_x = arg1;
}
}


void LvlEventsBox::on_simpleAutoscrollV_valueChanged(double arg1)
{
if(m_internalLock || m_externalLock || m_lockEventSectionDataList)
return;

int WinType = mw()->activeChildWindow();

if(WinType == MainWindow::WND_Level)
{
LevelEdit *edit = mw()->activeLvlEditWin();

if(!edit)
return;

long i = getEventArrayIndex();

if(i < 0)
return;

LevelSMBX64Event &event = edit->LvlData.events[i];
checkSectionSet(event.sets, m_curSectionField);
LevelEvent_Sets &SectionSet = event.sets[m_curSectionField];
QList<QVariant> bgData;
bgData.push_back(qlonglong(m_curSectionField));
bgData.push_back(qlonglong(SectionSet.autoscrol_y));
bgData.push_back(qlonglong(arg1));
edit->scene->m_history->addChangeEventSettings(event.meta.array_id, HistorySettings::SETTING_EV_SECASY, QVariant(bgData));
edit->LvlData.meta.modified = true;
SectionSet.autoscrol_y = arg1;
}
}


void LvlEventsBox::on_simpleAutoscrollH_BPS_clicked()
{
BlocksPerSecondDialog bps;

if(!bps.exec())
return;

ui->simpleAutoscrollH->setValue(bps.result());
}


void LvlEventsBox::on_simpleAutoscrollV_BPS_clicked()
{
BlocksPerSecondDialog bps;

if(!bps.exec())
return;

ui->simpleAutoscrollV->setValue(bps.result());
}


void LvlEventsBox::on_sectionAutoscroll_clicked(bool checked)
{
if(m_internalLock || m_externalLock || m_lockEventSectionDataList)
return;

int WinType = mw()->activeChildWindow();

if(WinType == MainWindow::WND_Level)
{
LevelEdit *edit = mw()->activeLvlEditWin();

if(!edit)
return;

long i = getEventArrayIndex();

if(i < 0)
return;

LevelSMBX64Event &event = edit->LvlData.events[i];
checkSectionSet(event.sets, m_curSectionField);
LevelEvent_Sets &SectionSet = event.sets[m_curSectionField];
QList<QVariant> bgData;
bgData.push_back(qlonglong(m_curSectionField));
bgData.push_back(qlonglong(SectionSet.autoscrol));
bgData.push_back(qlonglong(checked));
edit->scene->m_history->addChangeEventSettings(event.meta.array_id, HistorySettings::SETTING_EV_SECASEN, QVariant(bgData));
edit->LvlData.meta.modified = true;
SectionSet.autoscrol = checked;
}
}
@@ -45,6 +45,7 @@ class LvlEventsBox : public QDockWidget, public MWDock_Base
bool eventIsExist(QString evt);

public slots:
void setSMBX64Strict(bool en);
void re_translate();

void eventSectionSettingsSync();
@@ -141,6 +142,18 @@ private slots:
void on_bps_Scroll_horSpeed_clicked();
void on_bps_Scroll_vertSpeed_clicked();

void on_autoscrollType_currentIndexChanged(int index);

void on_simpleAutoscrollH_valueChanged(double arg1);

void on_simpleAutoscrollV_valueChanged(double arg1);

void on_simpleAutoscrollH_BPS_clicked();

void on_simpleAutoscrollV_BPS_clicked();

void on_sectionAutoscroll_clicked(bool checked);

private:
void addNewEvent(QString eventName, bool setEdited);
void modifyEventItem(QListWidgetItem *item, QString oldEventName, QString newEventName);

0 comments on commit d71bb31

Please sign in to comment.