Commit 87979a90 authored by Leeor Dicker's avatar Leeor Dicker

Started hooking up button click events to actual editor functions.

- Save button will now activate the save function.
- Added pencil/fill/erase buttons to ToolBar.
- Added click handlers for save/pencil/fill/erase buttons. These will now raise toolbar action events.
- Added an ToolBarAction enumerator, used when raising toolbar events.
- Removed old font files as I've switched over to a bitmap font instead (clearer, easier to read).
parent d7ab982c
......@@ -3,7 +3,7 @@
<mapname name="New Map" />
<mapsize width="50" height="50" />
<bg_music path="" />
<title_plaque show="false" />
<title_plaque show="true" />
<tilesize width="32" height="32" />
</properties>
<tilesets>
......
......@@ -101,6 +101,7 @@ void EditorState::initUi()
mTilePalette.font(mFont);
mToolBar.map_name(mMap.name());
mToolBar.toolbar_event().Connect(this, &EditorState::toolbar_event);
// Link Edit UI
mBtnLinkOkay.font(mFont);
......@@ -850,6 +851,19 @@ void EditorState::hideTilePalette()
}
void EditorState::toolbar_event(ToolBar::ToolBarAction _act, bool _b)
{
switch (_act)
{
case ToolBar::TOOLBAR_SAVE:
saveMap();
break;
default:
break;
}
}
/**
* Saves a map.
*
......
......@@ -69,9 +69,6 @@ private:
void initUi();
// FUNCTIONS
// ===============================
void button_MapLinkOkay_Click();
void button_MapLinkCancel_Click();
......@@ -103,9 +100,10 @@ private:
void drawMiniMap();
void createMiniMap();
void toolbar_event(ToolBar::ToolBarAction _act, bool _b);
// MEMBERS
// ===============================
private:
Timer mTimer;
Rectangle_2d mSelectorRect;
......
......@@ -17,6 +17,8 @@ ToolBar::~ToolBar()
EventHandler& e = Utility<EventHandler>::get();
e.keyDown().Disconnect(this, &ToolBar::onKeyDown);
mToolbarEvent.Clear();
}
......@@ -30,14 +32,36 @@ void ToolBar::initUi()
// SAVE
btnSave.image("sys/save.png");
btnSave.size(22, 28);
btnSave.position(200, 2);
btnSave.position(txtMapName.positionX() + txtMapName.width() + 20, 2);
btnSave.click().Connect(this, &ToolBar::btnSave_Clicked);
// EDIT TOOLS
btnPencil.image("sys/pencil.png");
btnPencil.type(Button::BUTTON_TOGGLE);
btnPencil.toggle(true);
btnPencil.size(22, 28);
btnPencil.position(btnSave.positionX() + btnSave.width() + 18 + BUTTON_SPACE, 2);
btnPencil.click().Connect(this, &ToolBar::btnPencil_Clicked);
btnFill.image("sys/paintcan.png");
btnFill.type(Button::BUTTON_TOGGLE);
btnFill.size(22, 28);
btnFill.position(btnPencil.positionX() + btnPencil.width() + BUTTON_SPACE, 2);
btnFill.click().Connect(this, &ToolBar::btnFill_Clicked);
btnErase.image("sys/erase.png");
btnErase.type(Button::BUTTON_TOGGLE);
btnErase.size(22, 28);
btnErase.position(btnFill.positionX() + btnFill.width() + BUTTON_SPACE, 2);
btnErase.click().Connect(this, &ToolBar::btnErase_Clicked);
// LAYER EDIT
btnLayerBase.image("sys/layer_b_edit.png");
btnLayerBase.type(Button::BUTTON_TOGGLE);
btnLayerBase.toggle(true);
btnLayerBase.size(22, 28);
btnLayerBase.position(btnSave.positionX() + btnSave.width() + 18 + BUTTON_SPACE, 2);
btnLayerBase.position(btnErase.positionX() + btnErase.width() + 18 + BUTTON_SPACE, 2);
btnLayerBase.click().Connect(this, &ToolBar::btnLayerBase_Clicked);
btnLayerBaseDetail.image("sys/layer_bd_edit.png");
......@@ -123,6 +147,10 @@ void ToolBar::update()
btnSave.update();
btnPencil.update();
btnFill.update();
btnErase.update();
btnLayerBase.update();
btnLayerBaseDetail.update();
btnLayerDetail.update();
......@@ -185,3 +213,42 @@ void ToolBar::btnLayerCollision_Clicked()
btnLayerForeground.toggle(false);
btnLayerCollision.toggle(true);
}
void ToolBar::btnSave_Clicked()
{
mToolbarEvent(TOOLBAR_SAVE, true);
}
void ToolBar::btnPencil_Clicked()
{
if(!btnPencil.toggled())
mToolbarEvent(TOOLBAR_PENCIL, true);
btnPencil.toggle(true);
btnFill.toggle(false);
btnErase.toggle(false);
}
void ToolBar::btnFill_Clicked()
{
if (!btnFill.toggled())
mToolbarEvent(TOOLBAR_FILL, true);
btnPencil.toggle(false);
btnFill.toggle(true);
btnErase.toggle(false);
}
void ToolBar::btnErase_Clicked()
{
if (!btnErase.toggled())
mToolbarEvent(TOOLBAR_ERASE, true);
btnPencil.toggle(false);
btnFill.toggle(false);
btnErase.toggle(true);
}
......@@ -10,6 +10,29 @@ using namespace NAS2D;
class ToolBar
{
public:
enum ToolBarAction
{
TOOLBAR_SAVE,
TOOLBAR_PENCIL,
TOOLBAR_FILL,
TOOLBAR_ERASE,
TOOLBAR_LAYER_BG_EDIT,
TOOLBAR_LAYER_BG_DETAIL_EDIT,
TOOLBAR_LAYER_DETAIL_EDIT,
TOOLBAR_LAYER_FOREGROUND_EDIT,
TOOLBAR_LAYER_COLLISION_EDIT,
TOOLBAR_LAYER_BG_TOGGLE,
TOOLBAR_LAYER_BG_DETAIL_TOGGLE,
TOOLBAR_LAYER_DETAIL_TOGGLE,
TOOLBAR_LAYER_FOREGROUND_TOGGLE,
TOOLBAR_LAYER_COLLISION_TOGGLE,
TOOLBAR_MINIMAP_TOGGLE,
TOOLBAR_TILE_PALETTE_TOGGLE
};
typedef Gallant::Signal2<ToolBarAction, bool> ToolBarEvent;
public:
ToolBar();
~ToolBar();
......@@ -19,6 +42,8 @@ public:
const std::string map_name() const { return txtMapName.text(); }
void map_name(const std::string& name) { txtMapName.text(name); }
ToolBarEvent& toolbar_event() { return mToolbarEvent; }
private:
void initUi();
......@@ -30,6 +55,11 @@ private:
private:
// UI Event Handlers
void btnSave_Clicked();
void btnPencil_Clicked();
void btnFill_Clicked();
void btnErase_Clicked();
void btnLayerBase_Clicked();
void btnLayerBaseDetail_Clicked();
void btnLayerDetail_Clicked();
......@@ -44,6 +74,10 @@ private:
Button btnSave;
Button btnPencil;
Button btnFill;
Button btnErase;
Button btnLayerBase;
Button btnLayerBaseDetail;
Button btnLayerDetail;
......@@ -56,4 +90,5 @@ private:
Button btnLayerForegroundToggle;
Button btnLayerCollisionToggle;
ToolBarEvent mToolbarEvent;
};
\ No newline at end of file
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