Commit d7ab982c authored by Leeor Dicker's avatar Leeor Dicker

Added a ToolBar control and started porting editor functions to said ToolBar.

- Added ToolBar class.
- Implemented Button Image option.
- Added string_format function.
- Started pulling config options from the editor. I think it clutters up the code more than anything else.
- Removed map file path entry textfield from EditorState.
- Added a map file path textfield to the StartState -- it makes more sense to have it there.
- StartState will now flash a warning message when there's an issue with any of the values in the text fields.
- Modified Map to take better advantage of the Viewport (allows for rendering a toolbar at the top without hiding any tiles underneath it.
- Menu will now only sort items when its sorted flag is set.
parent 75ca987e
......@@ -4,3 +4,4 @@
/proj/vc14/*.db
/proj/vc14/Release
/proj/vc14/*.opendb
/data/editor.xml
<!--Automatically generated Configuration file. This is best left untouched.-->
<configuration>
<graphics screenwidth="800" screenheight="600" bitdepth="32" fullscreen="false" vsync="true" texturequality="good" />
<audio mixrate="22050" channels="2" sfxvolume="128" musicvolume="100" bufferlength="1024" mixer="SDL" />
<options>
<option name="editor-maps-path" value="maps/" />
<option name="editor-new-map-name" value="New Map" />
<option name="editor-tilesets-path" value="tsets/" />
<option name="ui-button-create-new-map" value="Create New" />
<option name="ui-button-load-existing-map" value="Load Map" />
<option name="ui-button-refresh-lists" value="Refresh Lists" />
<option name="ui-main-font-path" value="fonts/Signika-Regular.ttf" />
<option name="ui-main-font-size" value="12" />
<option name="ui-map-name-font-path" value="fonts/Fresca-Regular.ttf" />
<option name="ui-map-name-font-size" value="12" />
<option name="ui-mouse-pointer-image" value="sys/editor_pointer.png" />
<option name="ui-textfield-default-map-height" value="50" />
<option name="ui-textfield-default-map-width" value="50" />
<option name="ui-tilepalette-bucket-image" value="sys/paintcan.png" />
<option name="ui-tilepalette-down-image" value="sys/down.png" />
<option name="ui-tilepalette-next-image" value="sys/next.png" />
<option name="ui-tilepalette-prev-image" value="sys/prev.png" />
<option name="ui-tilepalette-show-image" value="sys/up.png" />
</options>
</configuration>
This source diff could not be displayed because it is too large. You can view the blob instead.
data/sys/paintcan.png

3.33 KB | W: | H:

data/sys/paintcan.png

707 Bytes | W: | H:

data/sys/paintcan.png
data/sys/paintcan.png
data/sys/paintcan.png
data/sys/paintcan.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -107,6 +107,7 @@
<ClInclude Include="..\..\src\TextField.h" />
<ClInclude Include="..\..\src\TilePalette.h" />
<ClInclude Include="..\..\src\Tileset.h" />
<ClInclude Include="..\..\src\ToolBar.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
......@@ -124,6 +125,7 @@
<ClCompile Include="..\..\src\TextField.cpp" />
<ClCompile Include="..\..\src\TilePalette.cpp" />
<ClCompile Include="..\..\src\Tileset.cpp" />
<ClCompile Include="..\..\src\ToolBar.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Landlord.rc" />
......
......@@ -13,6 +13,18 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Header Files\UI Core">
<UniqueIdentifier>{ba6634c9-b090-4a58-879b-2eae1c5e4cbc}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\UI Core">
<UniqueIdentifier>{8e27ab60-3f9c-4462-b900-e2e396f6f152}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\UI">
<UniqueIdentifier>{4b02b4b3-2d88-4078-ac72-af86d9bea2e1}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\UI">
<UniqueIdentifier>{36e7f44d-1d18-4f61-8ad1-6a97e834f0f2}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\ConfigStrings.h">
......@@ -30,9 +42,6 @@
<ClInclude Include="..\..\src\StartState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\TilePalette.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Entity.h">
<Filter>Header Files</Filter>
</ClInclude>
......@@ -45,26 +54,32 @@
<ClInclude Include="..\..\src\Tileset.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Cell.h">
<ClInclude Include="..\..\src\Common.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Button.h">
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Button.h">
<Filter>Header Files\UI Core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Cell.h">
<Filter>Header Files\UI Core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Control.h">
<Filter>Header Files</Filter>
<Filter>Header Files\UI Core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Menu.h">
<Filter>Header Files</Filter>
<Filter>Header Files\UI Core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\TextField.h">
<Filter>Header Files</Filter>
<Filter>Header Files\UI Core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\Common.h">
<Filter>Header Files</Filter>
<ClInclude Include="..\..\src\TilePalette.h">
<Filter>Header Files\UI</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
<ClInclude Include="..\..\src\ToolBar.h">
<Filter>Header Files\UI</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
......@@ -77,9 +92,6 @@
<ClCompile Include="..\..\src\StartState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\TilePalette.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Entity.cpp">
<Filter>Source Files</Filter>
</ClCompile>
......@@ -95,20 +107,26 @@
<ClCompile Include="..\..\src\Cell.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Button.cpp">
<ClCompile Include="..\..\src\Common.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Button.cpp">
<Filter>Source Files\UI Core</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Control.cpp">
<Filter>Source Files</Filter>
<Filter>Source Files\UI Core</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Menu.cpp">
<Filter>Source Files</Filter>
<Filter>Source Files\UI Core</Filter>
</ClCompile>
<ClCompile Include="..\..\src\TextField.cpp">
<Filter>Source Files</Filter>
<Filter>Source Files\UI Core</Filter>
</ClCompile>
<ClCompile Include="..\..\src\Common.cpp">
<Filter>Source Files</Filter>
<ClCompile Include="..\..\src\TilePalette.cpp">
<Filter>Source Files\UI</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ToolBar.cpp">
<Filter>Source Files\UI</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
......
......@@ -6,7 +6,8 @@ using namespace std;
Button::Button(): mState(STATE_NORMAL),
mType(BUTTON_NORMAL),
mMouseHover(false)
mMouseHover(false),
mImage(nullptr)
{
Utility<EventHandler>::get().mouseButtonDown().Connect(this, &Button::onMouseDown);
Utility<EventHandler>::get().mouseButtonUp().Connect(this, &Button::onMouseUp);
......@@ -20,6 +21,27 @@ Button::~Button()
Utility<EventHandler>::get().mouseButtonDown().Disconnect(this, &Button::onMouseDown);
Utility<EventHandler>::get().mouseButtonUp().Disconnect(this, &Button::onMouseUp);
Utility<EventHandler>::get().mouseMotion().Disconnect(this, &Button::onMouseMotion);
if (mImage)
delete mImage;
}
void Button::image(const std::string path)
{
if (!Utility<Filesystem>::get().exists(path))
{
cout << "Button::image(): specified image file doesn't exist." << endl;
return;
}
if (mImage)
{
delete mImage;
mImage = nullptr;
}
mImage = new Image(path);
}
......@@ -127,13 +149,21 @@ void Button::draw()
}
if (fontSet() && !text().empty())
if (mImage)
{
int x = static_cast<int>(rect().x() + (rect().w() / 2) - ((mImage->width() / 2) + 1));
int y = static_cast<int>(rect().y() + (rect().h() / 2) - (mImage->height() / 2));
if (mState == STATE_PRESSED) { ++x; ++y; }
r.drawImage(*mImage, x, y);
}
else if (fontSet() && !text().empty())
{
int x = static_cast<int>(rect().x() + (rect().w() / 2) - (font().width(text()) / 2));
int y = static_cast<int>(rect().y() + (rect().h() / 2) - (font().height() / 2));
if (mState == STATE_PRESSED) r.drawText(font(), text(), x + 1, y + 1, 0, 0, 0);
else r.drawText(font(), text(), x, y, 0, 0, 0);
if (mState == STATE_PRESSED) { ++x; ++y; }
r.drawText(font(), text(), x, y, 0, 0, 0);
}
if (!enabled())
......
......@@ -30,6 +30,8 @@ public:
ClickCallback& click() { return mCallback; }
void image(const std::string path);
void update();
protected:
......@@ -53,5 +55,7 @@ private:
ClickCallback mCallback; /**< Object to notify when the Button is activated. */
Image* mImage;
bool mMouseHover; /**< Mouse is within the bounds of the Button. */
};
......@@ -5,6 +5,7 @@
using namespace NAS2D;
#include <string>
#include <memory>
void flipBool(bool& b);
......@@ -16,3 +17,15 @@ std::string TrimString(const std::string& src, const std::string& c = " \r\n");
void DrawPixel(SDL_Surface *srf, int x, int y, Uint8 R, Uint8 G, Uint8 B, Uint8 A);
void BlendPixel(SDL_Surface *srf, int x, int y, Uint8 R, Uint8 G, Uint8 B, Uint8 A);
/**
* Simple helper function to provide a printf like function.
*/
template<typename ... Args>
std::string string_format(const std::string& format, Args ... args)
{
size_t size = snprintf(nullptr, 0, format.c_str(), args ...) + 1;
unique_ptr<char[]> buffer(new char[size]);
snprintf(buffer.get(), size, format.c_str(), args ...);
return string(buffer.get(), buffer.get() + size - 1);
}
\ No newline at end of file
......@@ -4,11 +4,6 @@
#include <string>
const std::string CONFIG_UI_MAIN_FONT_PATH = "ui-main-font-path";
const std::string CONFIG_UI_MAIN_FONT_SIZE = "ui-main-font-size";
const std::string CONFIG_UI_MAP_NAME_FONT_PATH = "ui-map-name-font-path";
const std::string CONFIG_UI_MAP_NAME_FONT_SIZE = "ui-map-name-font-size";
const std::string CONFIG_UI_BUTTON_CREATE_NEW_MAP = "ui-button-create-new-map";
const std::string CONFIG_UI_BUTTON_LOAD_EXISTING_MAP = "ui-button-load-existing-map";
const std::string CONFIG_UI_BUTTON_REFRESH_LISTS = "ui-button-refresh-lists";
......
......@@ -5,12 +5,6 @@
// This file defines a number of default strings and other values
// that are stored in the Configuration file.
const std::string UI_MAIN_FONT_PATH = "fonts/Signika-Regular.ttf";
const std::string UI_MAP_NAME_FONT_PATH = "fonts/Fresca-Regular.ttf";
const std::string UI_MAIN_FONT_SIZE = "12";
const std::string UI_MAP_NAME_FONT_SIZE = "12";
const std::string UI_BUTTON_CREATE_NEW_MAP = "Create New";
const std::string UI_BUTTON_LOAD_EXISTING_MAP = "Load Map";
const std::string UI_BUTTON_REFRESH_LISTS = "Refresh Lists";
......@@ -18,7 +12,7 @@ const std::string UI_BUTTON_REFRESH_LISTS = "Refresh Lists";
const std::string UI_TEXTFIELD_DEFAULT_WIDTH = "50";
const std::string UI_TEXTFIELD_DEFAULT_HEIGHT = "50";
const std::string UI_MOUSE_POINTER_IMAGE = "sys/editor_pointer.png";
const std::string UI_MOUSE_POINTER_IMAGE = "sys/normal.png";
const std::string UI_TILEPALETTE_SHOW_IMAGE = "sys/up.png";
const std::string UI_TILEPALETTE_DOWN_IMAGE = "sys/down.png";
......
This diff is collapsed.
......@@ -7,6 +7,7 @@
#include "Map.h"
#include "Menu.h"
#include "TilePalette.h"
#include "ToolBar.h"
#include "Button.h"
#include "TextField.h"
......@@ -19,16 +20,16 @@ using namespace NAS2D;
enum EditState
{
STATE_BASE_TILE_INDEX = 0, // Explicitly defined due to my paranoia.
STATE_BASE_TILE_INDEX,
STATE_BASE_DETAIL_TILE_INDEX,
STATE_DETAIL_TILE_INDEX,
STATE_FOREGROUND_TILE_INDEX,
STATE_TILE_COLLISION,
STATE_FILE_SAVE_PATH,
STATE_MAP_LINK_EDIT,
STATE_MAP_NAME_EDIT
STATE_TILE_ERASE,
STATE_MAP_LINK_EDIT
};
enum HandleCorner
{
HANDLE_NONE = 0,
......@@ -44,7 +45,9 @@ class EditorState: public State
{
public:
EditorState(const std::string& mapPath);
EditorState(const std::string& name, const std::string& tsetPath, int width, int height);
EditorState(const std::string& name, const std::string& mapPath, const std::string& tsetPath, int width, int height);
~EditorState();
protected:
void initialize();
......@@ -62,14 +65,13 @@ private:
EditorState(); // Explicitly undefined
void fillEditStateTable();
void fillEditStateStringTable();
void initUi();
// FUNCTIONS
// ===============================
void button_MapSavePathOkay_Click();
void button_MapLinkOkay_Click();
void button_MapLinkCancel_Click();
......@@ -92,8 +94,6 @@ private:
void handleRightButtonDown();
void handleMiddleButtonDown();
void setMapSavePath();
void saveUndo();
void setState(EditState state);
......@@ -118,12 +118,8 @@ private:
Point_2df mScrollVector;
Font mFont;
Font mTitleFont;
Button mBtnMapSavePathOkay;
TextField mTxtMapName;
TextField mTxtMapSavePath;
ToolBar mToolBar;
Button mBtnLinkOkay;
Button mBtnLinkCancel;
......@@ -142,8 +138,6 @@ private:
std::string mMapSavePath;
Menu mLayerMenu;
Image* mMiniMap;
EditState mEditState;
......
......@@ -355,8 +355,8 @@ void Map::update()
{
Cell cell = mField.cell(col, row);
int rasterX = ((col - tileUpperLeft.x()) * mTileset.width()) - offsetX + mViewport.x();
int rasterY = ((row - tileUpperLeft.y()) * mTileset.height()) - offsetY + mViewport.y();
int rasterX = mViewport.x() + ((col - tileUpperLeft.x()) * mTileset.width()) - offsetX + mViewport.x();
int rasterY = mViewport.y() + ((row - tileUpperLeft.y()) * mTileset.height()) - offsetY + mViewport.y();
mTileset.drawTile(cell.index(Cell::LAYER_BASE), rasterX, rasterY);
......@@ -382,8 +382,8 @@ void Map::update()
{
Cell cell = mField.cell(col, row);
int rasterX = ((col - tileUpperLeft.x()) * mTileset.width()) - offsetX + mViewport.x();
int rasterY = ((row - tileUpperLeft.y()) * mTileset.height()) - offsetY + mViewport.y();
int rasterX = mViewport.x() + ((col - tileUpperLeft.x()) * mTileset.width()) - offsetX + mViewport.x();
int rasterY = mViewport.y() + ((row - tileUpperLeft.y()) * mTileset.height()) - offsetY + mViewport.y();
if(mDrawForeground && cell.index(Cell::LAYER_FOREGROUND) >= 0)
mTileset.drawTile(cell.index(Cell::LAYER_FOREGROUND), rasterX, rasterY);
......@@ -423,7 +423,10 @@ Rectangle_2d Map::injectMousePosition(const Point_2d& mouseCoords)
*/
Point_2d Map::getGridCoords(const Point_2d& _pt) const
{
return Point_2d(gridLocation(_pt.x(), static_cast<int>(mCameraPosition.x()), CELL_DIMENSIONS.w(), mViewport.w()) + static_cast<int>(mCameraPosition.x()) / mTileset.width(), gridLocation(_pt.y(), static_cast<int>(mCameraPosition.y()), CELL_DIMENSIONS.h(), mViewport.h()) + static_cast<int>(mCameraPosition.y()) / mTileset.height());
return Point_2d (
gridLocation(_pt.x() - mViewport.x(), static_cast<int>(mCameraPosition.x()), CELL_DIMENSIONS.w(), mViewport.w()) + static_cast<int>(mCameraPosition.x()) / mTileset.width(),
gridLocation(_pt.y() - mViewport.y(), static_cast<int>(mCameraPosition.y()), CELL_DIMENSIONS.h(), mViewport.h()) + static_cast<int>(mCameraPosition.y()) / mTileset.height()
);
}
......
......@@ -57,6 +57,7 @@ public:
void showLinks(bool show);
void viewport(const Rectangle_2d& _r);
const Rectangle_2d viewport() const { return mViewport; }
int width() const;
int height() const;
......
......@@ -24,7 +24,7 @@ public:
void sorted(bool _b) { mSorted = _b; }
bool sorted(bool) const { return mSorted; }
void sort() { std::sort(mItems.begin(), mItems.end()); }
void sort() { if(mSorted) std::sort(mItems.begin(), mItems.end()); }
void textColor(const Color_4ub& color) { mText = color; }
void selectColor(const Color_4ub& color) { mHighlightBg = color; }
......
......@@ -7,14 +7,24 @@
const int LAYOUT_RECT_WIDTH = 790;
const int LAYOUT_RECT_HEIGHT = 590;
std::string MESSAGE = "";
bool MSG_FLASH = false;
void setMessage(const std::string& msg)
{
MESSAGE = msg;
cout << msg << endl;
}
/**
* C'tpr
*/
StartState::StartState(): mFont(Utility<Configuration>::get().option(CONFIG_UI_MAIN_FONT_PATH), stringToInt(Utility<Configuration>::get().option(CONFIG_UI_MAIN_FONT_SIZE))),
StartState::StartState(): mFont("fonts/ui-normal.png", 7, 9, 0),
mMousePointer(Utility<Configuration>::get().option(CONFIG_UI_MOUSE_POINTER_IMAGE)),
mLayoutRect(15, 15, Utility<Renderer>::get().width() - 30, Utility<Renderer>::get().height() - 30),
mReturnState(NULL)
mLayoutRect(15, 15, Utility<Renderer>::get().width() - 30, Utility<Renderer>::get().height() - 40),
mReturnState(nullptr)
{
}
......@@ -41,6 +51,8 @@ void StartState::initialize()
mReturnState = this;
setMessage("");
mBtnCreateNew.font(mFont);
mBtnCreateNew.size(85, 25);
mBtnCreateNew.text(c.option(CONFIG_UI_BUTTON_CREATE_NEW_MAP));
......@@ -72,6 +84,10 @@ void StartState::initialize()
mTxtHeight.position(mLayoutRect.x() + mLayoutRect.w() / 2 + 210 + mFont.width("Height:") + 5, mLayoutRect.y() + 10);
mTxtHeight.border(TextField::ALWAYS);
txtMapPath.font(mFont);
txtMapPath.width(mLayoutRect.x() + mLayoutRect.w() / 2 - 40);
txtMapPath.text("");
txtMapPath.position(mLayoutRect.x() + mLayoutRect.w() / 2 + 10, mBtnCreateNew.positionY() - 30);
mMapFilesMenu.font(mFont);
mMapFilesMenu.position(mLayoutRect.x() + 10, mLayoutRect.y() + 10);
......@@ -119,25 +135,47 @@ void StartState::button_CreateNew_click()
{
int mapWidth = 0, mapHeight = 0;
mTxtWidth.highlight(false);
mTxtHeight.highlight(false);
txtMapPath.highlight(false);
if(!from_string<int>(mapWidth, mTxtWidth.text(), std::dec))
{
}
if(!from_string<int>(mapHeight, mTxtHeight.text(), std::dec))
{
mTxtHeight.highlight(true);
setMessage("Map width field must be an integer.");
return;
}
// sanity check for map widths
if (mapWidth < 10)
{
mTxtWidth.highlight(true);
cout << "Map width field must be an integer." << endl;
setMessage("Map width must be at least 10.");
return;
}
if(!from_string<int>(mapHeight, mTxtHeight.text(), std::dec))
// sanity check for map widths
if (mapHeight < 10)
{
mTxtHeight.highlight(true);
cout << "Map width field must be an integer." << endl;
setMessage("Map height must be at least 10.");
return;
}
mTxtWidth.highlight(false);
mTxtHeight.highlight(false);
if (txtMapPath.text().empty())
{
txtMapPath.highlight(true);
setMessage("Must enter a file name to proceed.");
return;
}
Configuration& c = Utility<Configuration>::get();
mReturnState = new EditorState(c.option(CONFIG_EDITOR_NEW_MAP_NAME), c.option(CONFIG_EDITOR_TILESETS_PATH) + mTsetFilesMenu.selectionText(), mapWidth, mapHeight);
mReturnState = new EditorState(c.option(CONFIG_EDITOR_NEW_MAP_NAME), c.option(CONFIG_EDITOR_MAPS_PATH) + txtMapPath.text(), c.option(CONFIG_EDITOR_TILESETS_PATH) + mTsetFilesMenu.selectionText(), mapWidth, mapHeight);
}
......@@ -153,7 +191,7 @@ void StartState::button_LoadExisting_click()
// no longer available), ensure that we prevent failure.
if(!Utility<Filesystem>::get().exists(mapPath))
{
cout << "ERROR: Selected file could not be found." << endl;
setMessage("ERROR: Selected file could not be found.");
return;
}
......@@ -194,10 +232,20 @@ State* StartState::update()
mTxtWidth.update();
mTxtHeight.update();
txtMapPath.update();
mMapFilesMenu.update();
mTsetFilesMenu.update();
if (mTimer.accumulator() > 200)
{
MSG_FLASH = !MSG_FLASH;
mTimer.reset();
}
if (!MESSAGE.empty() && MSG_FLASH)
r.drawText(mFont, MESSAGE, 15, r.height() - 15, 255, 0, 0);
r.drawImage(mMousePointer, mMouseCoords.x(), mMouseCoords.y());
return mReturnState;
......
......@@ -44,6 +44,7 @@ private:
void button_LoadExisting_click();
void button_RefreshLists_click();
Timer mTimer; // used to flash messages.
Font mFont; /**< Internal Font to use. */
......@@ -58,6 +59,7 @@ private:
TextField mTxtWidth; /**< Map Width text field. */
TextField mTxtHeight; /**< Map Height text field. */
TextField txtMapPath; /**< Filename for the map. */
Menu mMapFilesMenu; /**< Map File List menu. */
Menu mTsetFilesMenu; /**< Tileset File List menu. */
......
......@@ -94,9 +94,9 @@ void TextField::draw()
r.drawBoxFilled(rect(), 0, 0, 0, 180);
if (hasFocus())
r.drawBox(rect(), 25, 25, 185);
r.drawBox(rect(), 120, 120, 185);
else
r.drawBox(rect(), 50, 50, 50);
r.drawBox(rect(), 85, 85, 85);
if(highlight())
......
......@@ -36,18 +36,18 @@ TilePalette::TilePalette(): mFont(nullptr),
mBtnPrev.size(30, 20);
mBtnPrev.position(mRect.x() + 2, yPosition);
mBtnPrev.text("<");
mBtnPrev.image(Utility<Configuration>::get().option(CONFIG_UI_TILEPALETTE_PREV_IMAGE));
mBtnPrev.click().Connect(this, &TilePalette::button_Prev_click);
mBtnNext.size(30, 20);
mBtnNext.position(mRect.x() + mRect.w() - (mBtnNext.width() + 2), yPosition);
mBtnNext.text(">");
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.text("F");
mBtnFloodFill.image(Utility<Configuration>::get().option(CONFIG_UI_TILEPALETTE_BUCKET_IMAGE));
mBtnFloodFill.click().Connect(this, &TilePalette::button_FloodFill_click);
}
......
#include "ToolBar.h"
#include "Common.h"
const int BUTTON_SPACE = 2;
ToolBar::ToolBar() : mFont("fonts/ui-normal.png", 7, 9, 0)
{
initUi();
}
ToolBar::~ToolBar()
{
EventHandler& e = Utility<EventHandler>::get();
e.keyDown().Disconnect(this, &ToolBar::onKeyDown);
}
void ToolBar::initUi()
{
// MAP NAME
txtMapName.position(5, 8);
txtMapName.width(150);
txtMapName.font(mFont);
// SAVE
btnSave.image("sys/save.png");
btnSave.size(22, 28);
btnSave.position(200, 2);