mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-02-01 18:40:12 -05:00
Removed duplicated code
This commit is contained in:
parent
9fdf512a1f
commit
fcdfb0b300
@ -384,52 +384,24 @@ void FractoriumEmberController<T>::PaletteEditorButtonClicked()
|
|||||||
{
|
{
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
auto ed = m_Fractorium->m_PaletteEditor;
|
auto ed = m_Fractorium->m_PaletteEditor;
|
||||||
Palette<float> edPal;
|
|
||||||
Palette<float> prevPal = m_TempPalette;
|
|
||||||
map<size_t, float> colorIndices;
|
map<size_t, float> colorIndices;
|
||||||
bool forceFinal = m_Fractorium->HaveFinal();
|
bool forceFinal = m_Fractorium->HaveFinal();
|
||||||
|
|
||||||
|
m_PreviosTempPalette = m_TempPalette; // it's necessary because m_TempPalette is changed when the user make changes in palette editor
|
||||||
|
|
||||||
ed->SetPalette(m_TempPalette);
|
ed->SetPalette(m_TempPalette);
|
||||||
|
|
||||||
while (auto xform = m_Ember.GetTotalXform(i, forceFinal))
|
while (auto xform = m_Ember.GetTotalXform(i, forceFinal))
|
||||||
colorIndices[i++] = xform->m_ColorX;
|
colorIndices[i++] = xform->m_ColorX;
|
||||||
|
|
||||||
ed->SetColorIndices(colorIndices);
|
ed->SetColorIndices(colorIndices);
|
||||||
|
ed->SetPreviousColorIndices(colorIndices); // also necessary because the colors are changed in palette editor
|
||||||
ed->SetPaletteFile(m_CurrentPaletteFilePath);
|
ed->SetPaletteFile(m_CurrentPaletteFilePath);
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifndef __linux__
|
||||||
m_PreviosTempPalette = m_TempPalette;
|
|
||||||
ed->SetPreviousColorIndices(colorIndices);
|
|
||||||
ed->show();
|
ed->show();
|
||||||
#else
|
#else
|
||||||
|
SyncPalette(ed->exec() == QDialog::Accepted);
|
||||||
//ed->setpal
|
|
||||||
if (ed->exec() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
//Copy all just to be safe, because they may or may not have synced.
|
|
||||||
colorIndices = ed->GetColorIndices();
|
|
||||||
|
|
||||||
for (auto& index : colorIndices)
|
|
||||||
if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal))
|
|
||||||
xform->m_ColorX = index.second;
|
|
||||||
|
|
||||||
edPal = ed->GetPalette(int(prevPal.Size()));
|
|
||||||
SetBasePaletteAndAdjust(edPal);//This will take care of updating the color index controls.
|
|
||||||
|
|
||||||
if (edPal.m_Filename.get() && !edPal.m_Filename->empty())
|
|
||||||
m_Fractorium->SetPaletteFileComboIndex(*edPal.m_Filename);
|
|
||||||
}
|
|
||||||
else if (m_Fractorium->PaletteChanged())//They clicked cancel, but synced at least once, restore the previous palette.
|
|
||||||
{
|
|
||||||
for (auto& index : colorIndices)
|
|
||||||
if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal))
|
|
||||||
xform->m_ColorX = index.second;
|
|
||||||
|
|
||||||
SetBasePaletteAndAdjust(prevPal);//This will take care of updating the color index controls.
|
|
||||||
}
|
|
||||||
|
|
||||||
//Whether the current palette file was changed or not, if it's modifiable then reload it just to be safe (even though it might be overkill).
|
|
||||||
if (m_PaletteList->IsModifiable(m_CurrentPaletteFilePath))
|
|
||||||
m_Fractorium->OnPaletteFilenameComboChanged(QString::fromStdString(m_CurrentPaletteFilePath));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,7 +427,7 @@ void Fractorium::OnPaletteEditorButtonClicked(bool checked)
|
|||||||
connect(m_PaletteEditor, SIGNAL(PaletteChanged()), this, SLOT(OnPaletteEditorColorChanged()), Qt::QueuedConnection);
|
connect(m_PaletteEditor, SIGNAL(PaletteChanged()), this, SLOT(OnPaletteEditorColorChanged()), Qt::QueuedConnection);
|
||||||
connect(m_PaletteEditor, SIGNAL(PaletteFileChanged()), this, SLOT(OnPaletteEditorFileChanged()), Qt::QueuedConnection);
|
connect(m_PaletteEditor, SIGNAL(PaletteFileChanged()), this, SLOT(OnPaletteEditorFileChanged()), Qt::QueuedConnection);
|
||||||
connect(m_PaletteEditor, SIGNAL(ColorIndexChanged(size_t, float)), this, SLOT(OnPaletteEditorColorIndexChanged(size_t, float)), Qt::QueuedConnection);
|
connect(m_PaletteEditor, SIGNAL(ColorIndexChanged(size_t, float)), this, SLOT(OnPaletteEditorColorIndexChanged(size_t, float)), Qt::QueuedConnection);
|
||||||
#ifdef __linux__
|
#ifndef __linux__
|
||||||
connect(m_PaletteEditor, SIGNAL(finished(int)), this, SLOT(OnPaletteEditorFinished(int)), Qt::QueuedConnection);
|
connect(m_PaletteEditor, SIGNAL(finished(int)), this, SLOT(OnPaletteEditorFinished(int)), Qt::QueuedConnection);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user