Added base class for button listening
Fixed a few memory leaks
This commit is contained in:
14
ButtonListener.cpp
Normal file
14
ButtonListener.cpp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#include "ButtonListener.h"
|
||||||
|
|
||||||
|
ButtonListener::ButtonListener(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ButtonListener::~ButtonListener(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ButtonListener::onButton1MouseClick(TextButtonInstance* button)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
18
ButtonListener.h
Normal file
18
ButtonListener.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "TextButtonInstance.h"
|
||||||
|
class TextButtonInstance;
|
||||||
|
class ButtonListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ButtonListener(void);
|
||||||
|
~ButtonListener(void);
|
||||||
|
virtual void onButton1MouseClick(TextButtonInstance*);
|
||||||
|
//virtual void onMouseOver(); //TODO
|
||||||
|
//virtual void onMouseOut(); //TODO
|
||||||
|
//virtual void onButton1MouseDown(); //TODO
|
||||||
|
//virtual void onButton1MouseUp(); //TODO
|
||||||
|
//virtual void onButton2MouseClick(); //TODO
|
||||||
|
//virtual void onButton2MouseDown(); //TODO
|
||||||
|
//virtual void onButton2MouseUp(); //TODO
|
||||||
|
//What to do now...
|
||||||
|
};
|
||||||
@@ -230,6 +230,10 @@
|
|||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ButtonListener.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Dialogs.rc"
|
RelativePath=".\Dialogs.rc"
|
||||||
>
|
>
|
||||||
@@ -279,6 +283,10 @@
|
|||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
Filter="h;hpp;hxx;hm;inl"
|
Filter="h;hpp;hxx;hm;inl"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ButtonListener.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\ImageButtonInstance.h"
|
RelativePath=".\ImageButtonInstance.h"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ bool floatBottom;
|
|||||||
bool floatRight;
|
bool floatRight;
|
||||||
bool floatCenter;
|
bool floatCenter;
|
||||||
bool visible;
|
bool visible;
|
||||||
|
ButtonListener* buttonListener;
|
||||||
|
|
||||||
TextButtonInstance::TextButtonInstance(void)
|
TextButtonInstance::TextButtonInstance(void)
|
||||||
{
|
{
|
||||||
@@ -40,11 +41,24 @@ TextButtonInstance::TextButtonInstance(void)
|
|||||||
floatCenter = false;
|
floatCenter = false;
|
||||||
visible = true;
|
visible = true;
|
||||||
className = "TextButton";
|
className = "TextButton";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextButtonInstance::~TextButtonInstance(void)
|
TextButtonInstance::~TextButtonInstance(void)
|
||||||
{
|
{
|
||||||
|
delete buttonListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextButtonInstance::setButtonListener(ButtonListener* listener)
|
||||||
|
{
|
||||||
|
buttonListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextButtonInstance::onClick()
|
||||||
|
{
|
||||||
|
if(buttonListener != NULL)
|
||||||
|
{
|
||||||
|
buttonListener->onButton1MouseClick(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextButtonInstance::drawObj(RenderDevice* rd)
|
void TextButtonInstance::drawObj(RenderDevice* rd)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "instance.h"
|
#include "instance.h"
|
||||||
|
#pragma once
|
||||||
|
#include "ButtonListener.h"
|
||||||
|
class ButtonListener;
|
||||||
class TextButtonInstance :
|
class TextButtonInstance :
|
||||||
public Instance
|
public Instance
|
||||||
{
|
{
|
||||||
@@ -30,5 +32,6 @@ public:
|
|||||||
bool visible;
|
bool visible;
|
||||||
int textSize;
|
int textSize;
|
||||||
void drawObj(G3D::RenderDevice*);
|
void drawObj(G3D::RenderDevice*);
|
||||||
|
void setButtonListener(ButtonListener*);
|
||||||
|
void onClick();
|
||||||
};
|
};
|
||||||
11
main.cpp
11
main.cpp
@@ -340,7 +340,9 @@ void Demo::onInit() {
|
|||||||
void clearInstances()
|
void clearInstances()
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < instances.size(); i++)
|
for(size_t i = 0; i < instances.size(); i++)
|
||||||
|
{
|
||||||
delete instances.at(i);
|
delete instances.at(i);
|
||||||
|
}
|
||||||
delete dataModel;
|
delete dataModel;
|
||||||
}
|
}
|
||||||
void OnError(int err, std::string msg = "")
|
void OnError(int err, std::string msg = "")
|
||||||
@@ -354,10 +356,15 @@ void OnError(int err, std::string msg = "")
|
|||||||
|
|
||||||
void Demo::onCleanup() {
|
void Demo::onCleanup() {
|
||||||
clearInstances();
|
clearInstances();
|
||||||
|
go->~Texture();
|
||||||
|
go_ovr->~Texture();
|
||||||
|
go_dn->~Texture();
|
||||||
|
app->sky->~Sky();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Demo::onLogic() {
|
void Demo::onLogic() {
|
||||||
// Add non-simulation game logic and AI code here
|
// Add non-simulation game logic and AI code here
|
||||||
}
|
}
|
||||||
@@ -704,8 +711,6 @@ int main(int argc, char** argv) {
|
|||||||
settings.window.defaultIconFilename = GetFileInPath("/content/images/rico256c.png");
|
settings.window.defaultIconFilename = GetFileInPath("/content/images/rico256c.png");
|
||||||
settings.window.resizable = true;
|
settings.window.resizable = true;
|
||||||
settings.writeLicenseFile = false;
|
settings.writeLicenseFile = false;
|
||||||
App app = App(settings);
|
App(settings).run();
|
||||||
//app.window()->setIcon(ExePath() + "/content/images/rico.png");
|
|
||||||
app.run();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user