Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Arisotura/CoinKiller
Browse files Browse the repository at this point in the history
  • Loading branch information
ExplosBlue committed May 31, 2024
2 parents c69cb64 + e4ec1e1 commit a44be1e
Show file tree
Hide file tree
Showing 31 changed files with 2,130 additions and 981 deletions.
Binary file added coinkiller_data/icons/render_controllers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,899 changes: 1,227 additions & 672 deletions coinkiller_data/spritedata.xml

Large diffs are not rendered by default.

Binary file added coinkiller_data/sprites/big_icy_spiked_ball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified coinkiller_data/sprites/bowser_flame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coinkiller_data/sprites/bowser_flame_purple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coinkiller_data/sprites/bowser_lift/l.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coinkiller_data/sprites/bowser_lift/m.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coinkiller_data/sprites/bowser_lift/s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coinkiller_data/sprites/fire_snake_hidden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified coinkiller_data/sprites/lava_top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified coinkiller_data/sprites/poison_top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coinkiller_data/sprites/totem_lift/l.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coinkiller_data/sprites/totem_lift/m.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coinkiller_data/sprites/totem_lift/r.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coinkiller_data/sprites/whomp_big_walk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added coinkiller_data/sprites/whomp_walk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions leveleditor/leveleditorwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ LevelEditorWindow::LevelEditorWindow(LevelManager* lvlMgr, int initialArea) :
ui->actionGrid->setIcon(QIcon(basePath + "grid.png"));
ui->actionCheckerboard->setIcon(QIcon(basePath + "checkerboard.png"));
ui->actionRenderLiquids->setIcon(QIcon(basePath + "render_liquids.png"));
ui->actionRenderControllers->setIcon(QIcon(basePath + "render_controllers.png"));
ui->actionRenderCameraLimits->setIcon(QIcon(basePath + "render_camera_limits.png"));
ui->actionAddArea->setIcon(QIcon(basePath + "add.png"));
ui->actionDeleteCurrentArea->setIcon(QIcon(basePath + "remove.png"));
Expand Down Expand Up @@ -166,6 +167,7 @@ LevelEditorWindow::LevelEditorWindow(LevelManager* lvlMgr, int initialArea) :
ui->actionGrid->setChecked(settings->get("grid", false).toBool());
ui->actionCheckerboard->setChecked(settings->get("checkerboard", false).toBool());
ui->actionRenderLiquids->setChecked(settings->get("renderLiquids", true).toBool());
ui->actionRenderControllers->setChecked(settings->get("renderControllers", true).toBool());
ui->actionRenderCameraLimits->setChecked(settings->get("renderCameraLimits", true).toBool());

loadSettings();
Expand Down Expand Up @@ -485,6 +487,12 @@ void LevelEditorWindow::on_actionRenderLiquids_toggled(bool toggle)
settings->set("renderLiquids", toggle);
}

void LevelEditorWindow::on_actionRenderControllers_toggled(bool toggle)
{
levelView->toggleRenderControllers(toggle);
settings->set("renderControllers", toggle);
}

void LevelEditorWindow::on_actionRenderCameraLimits_toggled(bool toggle)
{
levelView->toggleRenderCameraLimits(toggle);
Expand Down Expand Up @@ -743,6 +751,7 @@ void LevelEditorWindow::loadArea(int id, bool closeLevel, bool init)
levelView->toggleGrid(ui->actionGrid->isChecked());
levelView->toggleCheckerboard(ui->actionCheckerboard->isChecked());
levelView->toggleRenderLiquids(ui->actionRenderLiquids->isChecked());
levelView->toggleRenderControllers(ui->actionRenderControllers->isChecked());
levelView->toggleRenderCameraLimits(ui->actionRenderCameraLimits->isChecked());

#ifdef USE_KDE_BLUR
Expand Down
2 changes: 2 additions & 0 deletions leveleditor/leveleditorwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ private slots:

void on_actionRenderLiquids_toggled(bool arg1);

void on_actionRenderControllers_toggled(bool arg1);

void on_actionRenderCameraLimits_toggled(bool arg1);

void on_actionPaste_triggered();
Expand Down
27 changes: 21 additions & 6 deletions leveleditor/leveleditorwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1280</width>
<height>700</height>
<width>1237</width>
<height>529</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -46,8 +46,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1278</width>
<height>624</height>
<width>1235</width>
<height>448</height>
</rect>
</property>
</widget>
Expand All @@ -60,8 +60,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1280</width>
<height>21</height>
<width>1237</width>
<height>23</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down Expand Up @@ -161,6 +161,7 @@
<addaction name="actionGrid"/>
<addaction name="actionCheckerboard"/>
<addaction name="actionRenderLiquids"/>
<addaction name="actionRenderControllers"/>
<addaction name="actionRenderCameraLimits"/>
<addaction name="separator"/>
<addaction name="actionToggleLayer1"/>
Expand Down Expand Up @@ -561,6 +562,20 @@
<string>Ctrl+Shift+A</string>
</property>
</action>
<action name="actionRenderControllers">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Render Controller Indicators</string>
</property>
<property name="toolTip">
<string>Render Controller Indicators</string>
</property>
<property name="menuRole">
<enum>QAction::TextHeuristicRole</enum>
</property>
</action>
</widget>
<resources/>
<connections/>
Expand Down
109 changes: 104 additions & 5 deletions leveleditor/levelview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@
with CoinKiller. If not, see http://www.gnu.org/licenses/.
*/

#include "is.h"
#include "leveleditorwindow.h"
#include "levelview.h"
#include "unitsconvert.h"
#include "objectrenderer.h"
#include "is.h"
#include "settingsmanager.h"

#include <QApplication>
#include <QClipboard>
#include <QPainter>
#include <QBrush>
#include <QColor>
#include <QRect>
#include <QRectF>
#include <QPaintEvent>
#include <QPainterPath>
#include <QClipboard>
#include <QMessageBox>
#include <QSet>


LevelView::LevelView(QWidget *parent, Level *level, QUndoStack *undoStack) :
Expand All @@ -44,8 +46,9 @@ LevelView::LevelView(QWidget *parent, Level *level, QUndoStack *undoStack) :
zoom = 1;
grid = false;
checkerboard = false;
renderLiquids = false;
renderCameraLimits = false;
renderLiquids = true;
renderControllers = true;
renderCameraLimits = true;
render2DTile = true;
render3DOverlay = true;

Expand Down Expand Up @@ -135,6 +138,32 @@ void LevelView::paint(QPainter& painter, QRect rect, float zoomLvl, bool selecti
painter.setOpacity(1);
}

// Render Translucent Liquid Indicators (if set to appear under tiles)
if (renderLiquids && editManager->spriteInteractionEnabled() && !SettingsManager::getInstance()->getLERenderTransparentLiquidAboveTiles())
{
for (int i = 0; i < level->zones.size(); i++)
{
const Zone* zone = level->zones.at(i);

QRect zonerect(zone->getx(), zone->gety(), zone->getwidth(), zone->getheight());

if (!drawrect.intersects(zonerect))
continue;

foreach (Sprite* s, level->sprites)
{
if (s->getid() != 12 && s->getid() != 13 && s->getid() != 15)
continue;

if (zonerect.contains(s->getx(), s->gety(), false))
{
LiquidRenderer liquidRend(s, zone);
liquidRend.renderTranslucent(&painter, &drawrect);
}
}
}
}

// Render Tiles
for (int l = 1; l >= 0; l--)
{
Expand Down Expand Up @@ -172,6 +201,7 @@ void LevelView::paint(QPainter& painter, QRect rect, float zoomLvl, bool selecti
// Render Locations
if (editManager->locationInteractionEnabled())
{
painter.save();
for (int i = 0; i < level->locations.size(); i++)
{
const Location* loc = level->locations.at(i);
Expand All @@ -191,8 +221,10 @@ void LevelView::paint(QPainter& painter, QRect rect, float zoomLvl, bool selecti
painter.setPen(QColor(255,255,255));
painter.drawText(locrect.adjusted(5,5,0,0), locText);
}
painter.restore();
}

// Render anything that falls under "sprites"
if (editManager->spriteInteractionEnabled())
{
// Render Liquids
Expand All @@ -215,6 +247,8 @@ void LevelView::paint(QPainter& painter, QRect rect, float zoomLvl, bool selecti
if (zonerect.contains(s->getx(), s->gety(), false))
{
LiquidRenderer liquidRend(s, zone);
if (SettingsManager::getInstance()->getLERenderTransparentLiquidAboveTiles())
liquidRend.renderTranslucent(&painter, &drawrect);
liquidRend.render(&painter, &drawrect);
}
}
Expand Down Expand Up @@ -319,6 +353,71 @@ void LevelView::paint(QPainter& painter, QRect rect, float zoomLvl, bool selecti
}
}

// Render Movement Controller - Back & Forth Indicators
static const QSet<int> supportsMovBackForth{28, 60, 101, 204, 293};
for (int i = 0; renderControllers && i < level->zones.size(); i++)
{
const Zone* zone = level->zones.at(i);
QRect zonerect(zone->getx() - 80, zone->gety() - 80, zone->getwidth() + 160, zone->getheight() + 160);

if (!drawrect.intersects(zonerect))
continue;

foreach (Sprite* s, level->sprites)
{
if (!zonerect.contains(s->getx(), s->gety(), false))
continue;

if (!supportsMovBackForth.contains(s->getid()))
continue;

int distance;
int direction = -1;

// Find the correct associated Back & Forth movement controller & note its data
foreach (Sprite* m, level->sprites)
{
if (!zonerect.contains(m->getx(), m->gety(), false))
continue;

if (m->getid() != 166 || m->getNybbleData(20, 21) != s->getNybbleData(20, 21))
continue;

distance = m->getNybble(14) * 20;
direction = m->getNybble(7) % 4;
break;
}

if (direction == -1 || distance == 0)
continue;

// Render a movement indicator for the sprite
QColor color = QColor(244, 250, 255);
int x = s->getx() + s->getOffsetX();
int y = s->gety() + s->getOffsetY();

MovIndicatorRenderer *indicator;
switch (direction)
{
case 0: // Right
indicator = new MovIndicatorRenderer(x + s->getwidth(), y + s->getheight()/2, x + s->getwidth() + distance, y + s->getheight()/2, 2, 6, false, false, color);
break;
case 1: // Left
indicator = new MovIndicatorRenderer(x, y + s->getheight()/2, x - distance, y + s->getheight()/2, 2, 6, false, false, color);
break;
case 2: // Up
indicator = new MovIndicatorRenderer(x + s->getwidth()/2, y, x + s->getwidth()/2, y - distance, 2, 6, false, true, color);
break;
default: // Down
indicator = new MovIndicatorRenderer(x + s->getwidth()/2, y + s->getheight(), x + s->getwidth()/2, y + s->getheight() + distance, 2, 6, false, true, color);
break;
}

indicator->render(&painter);
delete indicator;
}
}

// Render Sprites
for (int i = 0; i < level->sprites.size(); i++)
{
Expand Down Expand Up @@ -575,7 +674,7 @@ void LevelView::paint(QPainter& painter, QRect rect, float zoomLvl, bool selecti
painter.drawText(zonerect.adjusted(adjustX,adjustY,100,20), zoneText);
}

// Render Edition Mode Stuff
// Render Stuff
if (selections)
editManager->render(&painter);

Expand Down
2 changes: 2 additions & 0 deletions leveleditor/levelview.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class LevelView : public QWidget
void toggleGrid(bool toggle) { grid = toggle; update(); }
void toggleCheckerboard(bool toggle) { checkerboard = toggle; update(); }
void toggleRenderLiquids(bool toggle) { renderLiquids = toggle; update(); }
void toggleRenderControllers(bool toggle) { renderControllers = toggle; update(); }
void toggleRenderCameraLimits(bool toggle) { renderCameraLimits = toggle; update(); }
void toggle3DOverlay(bool toggle) { render3DOverlay = toggle; update(); }
void toggle2DTile(bool toggle) { render2DTile = toggle; update(); }
Expand Down Expand Up @@ -96,6 +97,7 @@ public slots:
bool grid;
bool checkerboard;
bool renderLiquids;
bool renderControllers;
bool renderCameraLimits;
bool render2DTile;
bool render3DOverlay;
Expand Down
12 changes: 12 additions & 0 deletions leveleditor/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) :

connect(ui->backgroundColorPickerButton, &QPushButton::clicked, this, &SettingsDialog::changeBackgroundColor);
connect(ui->undoLimitSpinBox, &QSpinBox::valueChanged, this, &SettingsDialog::changeUndoLimit);
connect(ui->renderTransparentLiquidAboveTilesComboBox, &QComboBox::currentIndexChanged, this, &SettingsDialog::changeRenderTransparentLiquidAboveTiles);
connect(ui->selectOnPlacedCheckBox, &QCheckBox::clicked, this, &SettingsDialog::changeSelectOnPlaced);
connect(ui->showStatusBarCheckBox, &QCheckBox::clicked, this, &SettingsDialog::changeShowStatusbar);
connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &SettingsDialog::handleButtonClicked);
Expand All @@ -28,6 +29,9 @@ void SettingsDialog::loadSettings() {
undoLimit = SettingsManager::getInstance()->getLEUndoLimit();
ui->undoLimitSpinBox->setValue(static_cast<int>(undoLimit));

renderTransparentLiquidAboveTiles = SettingsManager::getInstance()->getLERenderTransparentLiquidAboveTiles();
ui->renderTransparentLiquidAboveTilesComboBox->setCurrentIndex(renderTransparentLiquidAboveTiles);

selectOnPlaced = SettingsManager::getInstance()->getLESelectOnPlace();
ui->selectOnPlacedCheckBox->setChecked(selectOnPlaced);

Expand All @@ -42,6 +46,9 @@ void SettingsDialog::restoreDefaults() {
undoLimit = SettingsManager::LE_UNDO_LIMIT_DEFAULT;
ui->undoLimitSpinBox->setValue(static_cast<int>(undoLimit));

renderTransparentLiquidAboveTiles = SettingsManager::LE_RENDER_TRANSPARENT_LIQUID_ABOVE_TILES_DEFAULT;
ui->renderTransparentLiquidAboveTilesComboBox->setCurrentIndex(renderTransparentLiquidAboveTiles);

selectOnPlaced = SettingsManager::LE_SELECT_ON_PLACE_DEFAULT;
ui->selectOnPlacedCheckBox->setChecked(selectOnPlaced);

Expand All @@ -52,6 +59,7 @@ void SettingsDialog::restoreDefaults() {
void SettingsDialog::applyChanges() {
SettingsManager::getInstance()->setLEWindowColor(backgroundColor);
SettingsManager::getInstance()->setLEUndoLimit(undoLimit);
SettingsManager::getInstance()->setLERenderTransparentLiquidAboveTiles(renderTransparentLiquidAboveTiles);
SettingsManager::getInstance()->setLESelectOnPlace(selectOnPlaced);
SettingsManager::getInstance()->setLEShowStatusbar(showStatusbar);

Expand Down Expand Up @@ -92,6 +100,10 @@ void SettingsDialog::changeUndoLimit() {
undoLimit = ui->undoLimitSpinBox->value();
}

void SettingsDialog::changeRenderTransparentLiquidAboveTiles() {
renderTransparentLiquidAboveTiles = ui->renderTransparentLiquidAboveTilesComboBox->currentIndex();
}

void SettingsDialog::changeSelectOnPlaced() {
selectOnPlaced = ui->selectOnPlacedCheckBox->isChecked();
}
Expand Down
2 changes: 2 additions & 0 deletions leveleditor/settingsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class SettingsDialog : public QDialog {
private slots:
void changeBackgroundColor();
void changeUndoLimit();
void changeRenderTransparentLiquidAboveTiles();
void changeSelectOnPlaced();
void changeShowStatusbar();
void handleButtonClicked(QAbstractButton *button);
Expand All @@ -36,6 +37,7 @@ private slots:

QColor backgroundColor;
quint32 undoLimit;
bool renderTransparentLiquidAboveTiles;
bool selectOnPlaced;
bool showStatusbar;
};
Expand Down
Loading

0 comments on commit a44be1e

Please sign in to comment.