Commit cb53ae0a authored by Leeor Dicker's avatar Leeor Dicker

Flood fill tool on the tool bar is now functional.

- Pulled flood fill button from TilePalette.
- Moved flood fill test logic from tile palette to tool bar.
parent f1c16ec1
......@@ -777,7 +777,7 @@ void EditorState::changeTileTexture()
if (it == StateToLayer.end())
throw Exception(0, "Bad State", "EditorState::changeTileTExture() called with an invalid state.");
if (mTilePalette.patternFill()) patternFill(StateToLayer[mEditState]);
if (mToolBar.floodfill()) patternFill(StateToLayer[mEditState]);
else patternStamp(StateToLayer[mEditState]);
}
......
......@@ -2,6 +2,8 @@
#include "ConfigStrings.h"
#include "Common.h"
const Point_2d PALETTE_DIMENSIONS = Point_2d(196, 320);
const Point_2d FIRST_TILE_COORDINATE = Point_2d(2, 18);
......@@ -29,7 +31,6 @@ TilePalette::TilePalette(): mFont(nullptr),
mTsetIndex(0),
mHidden(true),
mLeftButtonDown(false),
mPatternFill(false),
mMouseOverTiles(false)
{
int yPosition = Utility<Renderer>::get().height() - PALETTE_DIMENSIONS.y() + 295;
......@@ -43,19 +44,6 @@ TilePalette::TilePalette(): mFont(nullptr),
mBtnNext.position(mRect.x() + mRect.w() - (mBtnNext.width() + 2), yPosition);
mBtnNext.image(Utility<Configuration>::get().option(CONFIG_UI_TILEPALETTE_NEXT_IMAGE));
mBtnNext.click().Connect(this, &TilePalette::button_Next_click);
mBtnFloodFill.type(Button::BUTTON_TOGGLE);
mBtnFloodFill.size(20, 20);
mBtnFloodFill.position(mRect.x() + (mRect.w() / 2) - (mBtnFloodFill.width() / 2), yPosition);
mBtnFloodFill.image(Utility<Configuration>::get().option(CONFIG_UI_TILEPALETTE_BUCKET_IMAGE));
mBtnFloodFill.click().Connect(this, &TilePalette::button_FloodFill_click);
}
void TilePalette::button_FloodFill_click()
{
mPatternFill = mBtnFloodFill.toggled();
}
......@@ -169,8 +157,6 @@ void TilePalette::update()
// Draw buttons
mBtnPrev.update();
mBtnNext.update();
mBtnFloodFill.update();
// Draw the tile page
for(int row = 0; row < TILE_GRID_DIMENSIONS.y(); row++)
......@@ -189,11 +175,8 @@ void TilePalette::update()
if(mFont)
{
r.drawTextShadow(*mFont, "Tile Palette", mRect.x() + 2, mRect.y(), 1, 255, 255, 255, 0, 0, 0);
stringstream ss;
ss << "Page: " << mCurrentPage + 1 << " of " << mNumPages;
r.drawTextShadow(*mFont, ss.str(), mRect.x() + 1, mRect.y() + 275, 1, 255, 255, 255, 0, 0, 0);
r.drawTextShadow(*mFont, "Tile Palette", mRect.x() + 2, mRect.y() + 2, 1, 255, 255, 255, 0, 0, 0);
r.drawTextShadow(*mFont, string_format("Page: %i of %i", mCurrentPage + 1, mNumPages), mRect.x() + 1, mRect.y() + 275, 1, 255, 255, 255, 0, 0, 0);
}
// Draw Selectors
......
......@@ -36,8 +36,6 @@ public:
void font(Font& font);
bool patternFill() const { return mPatternFill; }
const Pattern& pattern() const { return mBrushPattern; }
const Rectangle_2d& rect() const { return mRect; }
......@@ -51,18 +49,17 @@ public:
void onMouseMove(int x, int y, int relX, int relY);
private:
typedef std::vector<std::vector<Rectangle_2d> > RectList;
void button_Prev_click();
void button_Next_click();
void button_FloodFill_click();
void determinePattern();
Rectangle_2d getRectFromPoints(const Point_2d& pt1, const Point_2d& pt2);
private:
Font* mFont; /**< Font to use to draw basic information. */
Tileset* mTset; /**< Pointer to a Tileset. TilePalette does not own this Tileset object. */
......@@ -75,7 +72,6 @@ private:
Button mBtnPrev; /**< */
Button mBtnNext; /**< */
Button mBtnFloodFill; /**< Pattern fill button. */
Image mShow; /**< Displayed in the title area when the palette is hidden. */
Image mHide; /**< Displayed in the title area when the palette is not hidden. */
......@@ -94,7 +90,6 @@ private:
bool mHidden; /**< Flag indicating that the palette shouldn't be drawn. */
bool mLeftButtonDown; /**< Flag indicating that the left mouse button is depressed. */
bool mPatternFill; /**< Flag indicating that we're in pattern fill mode. */
bool mMouseOverTiles; /**< Flag indicating that the mouse is actually over the tiles. */
};
......@@ -44,6 +44,8 @@ public:
ToolBarEvent& toolbar_event() { return mToolbarEvent; }
bool floodfill() const { return btnFill.toggled(); }
private:
void initUi();
......
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