Commit c074e8f6 authored by Leeor Dicker's avatar Leeor Dicker

Completed collision pattern edit.

- Added spinner control to ToolBar.
- EditorState now looks to ToolBar for a pattern when in collision edit mode.
parent 330ae5d9
......@@ -316,10 +316,13 @@ void EditorState::updateSelector()
// Draw Tile Selector
int offsetX = 0, offsetY = 0;
const Pattern& p = mTilePalette.pattern();
for(int row = p.height(); row > 0; row--)
const Pattern* p = &mTilePalette.pattern();
if(mEditState == STATE_TILE_COLLISION) p = &mToolBar.brush();
for(int row = p->height(); row > 0; row--)
{
for(int col = p.width(); col > 0; col--)
for(int col = p->width(); col > 0; col--)
{
r.drawBox(mSelectorRect.x() - offsetX + mMap.viewport().x(), mSelectorRect.y() - offsetY + mMap.viewport().y(), mSelectorRect.w(), mSelectorRect.h(), 255, 255, 255);
offsetX += 32;
......@@ -621,7 +624,7 @@ void EditorState::pattern(Cell::TileLayer layer, int value)
*/
void EditorState::pattern_collision()
{
const Pattern& _p = mTilePalette.pattern();
const Pattern& _p = mToolBar.brush();
Point_2d& _pt = mMap.getGridCoords(mMouseCoords);
for (int row = 0; row < _p.height(); row++)
......
#ifndef __PATTERN__
#define __PATTERN__
#pragma once
/**
* \class Pattern
......@@ -67,6 +65,3 @@ private:
Grid mPatternGrid;
};
#endif
\ No newline at end of file
......@@ -88,12 +88,22 @@ void ToolBar::initUi()
btnLayerCollision.position(btnLayerForeground.positionX() + btnLayerForeground.width() + BUTTON_SPACE, 2);
btnLayerCollision.click().Connect(this, &ToolBar::btnLayerCollision_Clicked);
btnSpinnerUp.image("sys/up.png");
btnSpinnerUp.size(22, 14);
btnSpinnerUp.position(btnLayerCollision.positionX() + btnLayerCollision.width() + BUTTON_SPACE + 21, 2);
btnSpinnerUp.click().Connect(this, &ToolBar::btnSpinnerUp_Clicked);
btnSpinnerDown.image("sys/down.png");
btnSpinnerDown.size(22, 13);
btnSpinnerDown.position(btnLayerCollision.positionX() + btnLayerCollision.width() + BUTTON_SPACE + 21, 17);
btnSpinnerDown.click().Connect(this, &ToolBar::btnSpinnerDown_Clicked);
// LAYER VISIBILITY
btnLayerBaseToggle.image("sys/layer_b_show.png");
btnLayerBaseToggle.type(Button::BUTTON_TOGGLE);
btnLayerBaseToggle.toggle(true);
btnLayerBaseToggle.size(22, 28);
btnLayerBaseToggle.position(btnLayerCollision.positionX() + btnLayerCollision.width() + 18 + BUTTON_SPACE, 2);
btnLayerBaseToggle.position(btnSpinnerDown.positionX() + btnSpinnerDown.width() + 18 + BUTTON_SPACE, 2);
btnLayerBaseToggle.click().Connect(this, &ToolBar::btnLayerBaseToggle_Clicked);
btnLayerBaseDetailToggle.image("sys/layer_bd_show.png");
......@@ -191,7 +201,14 @@ void ToolBar::update()
btnLayerForeground.update();
btnLayerCollision.update();
drawSeparator(btnLayerCollision, 9);
r.drawBoxFilled(btnSpinnerUp.rect().x() - 21, btnSpinnerUp.rect().y(), 20, 28, 255, 255, 255);
r.drawBox(btnSpinnerUp.rect().x() - 21, btnSpinnerUp.rect().y(), 20, 28, 0, 0, 0);
r.drawText(mFont, string_format("%i", static_cast<int>(mBrush.width())), btnSpinnerUp.rect().x() - 18 + (mFont.width(string_format("%i", static_cast<int>(mBrush.width()))) / 2), 12, 0, 0, 0);
btnSpinnerUp.update();
btnSpinnerDown.update();
drawSeparator(btnLayerBaseToggle, - 32);
btnLayerBaseToggle.update();
btnLayerBaseDetailToggle.update();
......@@ -368,3 +385,16 @@ void ToolBar::btnTilePaletteToggle_Clicked()
{
mToolbarEvent(TOOLBAR_TILE_PALETTE_TOGGLE);
}
void ToolBar::btnSpinnerUp_Clicked()
{
int size = clamp(mBrush.width() + 1, 1, 8);
mBrush.size(size, size);
}
void ToolBar::btnSpinnerDown_Clicked()
{
int size = clamp(mBrush.width() - 1, 1, 8);
mBrush.size(size, size);
}
......@@ -5,6 +5,8 @@
#include "Button.h"
#include "TextField.h"
#include "Pattern.h"
using namespace NAS2D;
......@@ -57,6 +59,8 @@ public:
bool show_minimap() const { return btnMiniMapToggle.toggled(); }
bool show_tilepalette() const { return btnTilePaletteToggle.toggled(); }
const Pattern& brush() const { return mBrush; }
private:
void initUi();
......@@ -81,6 +85,9 @@ private:
void btnLayerForeground_Clicked();
void btnLayerCollision_Clicked();
void btnSpinnerUp_Clicked();
void btnSpinnerDown_Clicked();
void btnLayerBaseToggle_Clicked();
void btnLayerBaseDetailToggle_Clicked();
void btnLayerDetailToggle_Clicked();
......@@ -94,6 +101,9 @@ private:
Font mFont;
Pattern mBrush;
// UI ELEMENTS
TextField txtMapName;
Button btnSave;
......@@ -108,6 +118,9 @@ private:
Button btnLayerForeground;
Button btnLayerCollision;
Button btnSpinnerUp;
Button btnSpinnerDown;
Button btnLayerBaseToggle;
Button btnLayerBaseDetailToggle;
Button btnLayerDetailToggle;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment