Skip to content

Commit

Permalink
Color Switch
Browse files Browse the repository at this point in the history
  • Loading branch information
jowin202 committed Dec 19, 2023
1 parent 88b9726 commit 953bbd3
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
24 changes: 24 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,3 +733,27 @@ void MainWindow::on_actionAnimations_Editor_triggered()
}
}


void MainWindow::on_actionSprite_Color_MC_1_triggered()
{
opt.undoDB.append(opt.data);
this->opt.sprite_list.at(opt.current_sprite)->switch_col_to_mc1();
this->ui->graphicsView->scene()->update();
}


void MainWindow::on_actionSprite_Color_MC_2_triggered()
{
opt.undoDB.append(opt.data);
this->opt.sprite_list.at(opt.current_sprite)->switch_col_to_mc2();
this->ui->graphicsView->scene()->update();
}


void MainWindow::on_actionMC_1_MC_2_triggered()
{
opt.undoDB.append(opt.data);
this->opt.sprite_list.at(opt.current_sprite)->switch_mc1_to_mc2();
this->ui->graphicsView->scene()->update();
}

6 changes: 6 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ private slots:

void on_actionAnimations_Editor_triggered();

void on_actionSprite_Color_MC_1_triggered();

void on_actionSprite_Color_MC_2_triggered();

void on_actionMC_1_MC_2_triggered();

private:
Ui::MainWindow *ui;
AnimationDialog *animation_dialog = 0;
Expand Down
25 changes: 25 additions & 0 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,14 @@
<property name="title">
<string>Edit</string>
</property>
<widget class="QMenu" name="menuColor_Switch">
<property name="title">
<string>Color Switch</string>
</property>
<addaction name="actionSprite_Color_MC_1"/>
<addaction name="actionSprite_Color_MC_2"/>
<addaction name="actionMC_1_MC_2"/>
</widget>
<addaction name="actionClear"/>
<addaction name="actionCut"/>
<addaction name="actionCopy"/>
Expand All @@ -746,6 +754,8 @@
<addaction name="actionFlip_Left_to_Right"/>
<addaction name="actionReflect_Left_To_Right"/>
<addaction name="actionReflect_Top_to_Bottom"/>
<addaction name="separator"/>
<addaction name="menuColor_Switch"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
Expand Down Expand Up @@ -1033,6 +1043,21 @@
<string>Ctrl+Shift+A</string>
</property>
</action>
<action name="actionSprite_Color_MC_1">
<property name="text">
<string>Sprite Color &lt;==&gt; MC 1</string>
</property>
</action>
<action name="actionSprite_Color_MC_2">
<property name="text">
<string>Sprite Color &lt;==&gt; MC 2</string>
</property>
</action>
<action name="actionMC_1_MC_2">
<property name="text">
<string>MC 1 &lt;==&gt; MC 2</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
70 changes: 70 additions & 0 deletions sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,76 @@ class Sprite : public QGraphicsItem
}
}

void switch_col_to_mc1()
{
if (this->opt->data.value("sprites").toArray().at(id).toObject().value("mc_mode").toBool())
{
for (int x = 0; x < 12; x++)
{
for (int y = 0; y < 21; y++)
{
if (this->get_bit(2*x,y) && !this->get_bit(2*x+1,y))
{
this->set_bit(2*x,y, false);
this->set_bit(2*x+1,y, true);
}
else if (!this->get_bit(2*x,y) && this->get_bit(2*x+1,y))
{
this->set_bit(2*x,y, true);
this->set_bit(2*x+1,y, false);
}
}
}
}
}


void switch_col_to_mc2()
{
if (this->opt->data.value("sprites").toArray().at(id).toObject().value("mc_mode").toBool())
{
for (int x = 0; x < 12; x++)
{
for (int y = 0; y < 21; y++)
{
if (this->get_bit(2*x,y) && !this->get_bit(2*x+1,y))
{
this->set_bit(2*x,y, true);
this->set_bit(2*x+1,y, true);
}
else if (this->get_bit(2*x,y) && this->get_bit(2*x+1,y))
{
this->set_bit(2*x,y, true);
this->set_bit(2*x+1,y, false);
}
}
}
}
}


void switch_mc1_to_mc2()
{
if (this->opt->data.value("sprites").toArray().at(id).toObject().value("mc_mode").toBool())
{
for (int x = 0; x < 12; x++)
{
for (int y = 0; y < 21; y++)
{
if (this->get_bit(2*x,y) && this->get_bit(2*x+1,y))
{
this->set_bit(2*x,y, false);
this->set_bit(2*x+1,y, true);
}
else if (!this->get_bit(2*x,y) && this->get_bit(2*x+1,y))
{
this->set_bit(2*x,y, true);
this->set_bit(2*x+1,y, true);
}
}
}
}
}

private:
int id;
Expand Down

0 comments on commit 953bbd3

Please sign in to comment.