Added message functions to DataModel
This commit is contained in:
@@ -6,6 +6,9 @@ Instance* guiRoot;
|
|||||||
float mousex;
|
float mousex;
|
||||||
float mousey;
|
float mousey;
|
||||||
bool mouseButton1Down;
|
bool mouseButton1Down;
|
||||||
|
std::string message;
|
||||||
|
bool showMessage;
|
||||||
|
G3D::GFontRef font;
|
||||||
|
|
||||||
|
|
||||||
DataModelInstance::DataModelInstance(void)
|
DataModelInstance::DataModelInstance(void)
|
||||||
@@ -17,12 +20,38 @@ DataModelInstance::DataModelInstance(void)
|
|||||||
mousex = 0;
|
mousex = 0;
|
||||||
mousey = 0;
|
mousey = 0;
|
||||||
mouseButton1Down = false;
|
mouseButton1Down = false;
|
||||||
|
showMessage = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataModelInstance::~DataModelInstance(void)
|
DataModelInstance::~DataModelInstance(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataModelInstance::setMessage(std::string msg)
|
||||||
|
{
|
||||||
|
message = msg;
|
||||||
|
showMessage = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataModelInstance::clearMessage()
|
||||||
|
{
|
||||||
|
showMessage = false;
|
||||||
|
message = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataModelInstance::drawMessage(RenderDevice* rd)
|
||||||
|
{
|
||||||
|
if(showMessage && !font.isNull())
|
||||||
|
{
|
||||||
|
int x = rd->getWidth()/2;
|
||||||
|
int y = rd->getHeight()/2;
|
||||||
|
int width = rd->getWidth()/2 + 100;
|
||||||
|
int height = width / 3;
|
||||||
|
Draw::box(Box(Vector3(x-(width/2), y-(height/2), 0), Vector3(x+(width/2), y+(height/2), 0)), rd, Color4::fromARGB(0x55B2B2B2), Color3::fromARGB(0xB2B2B2));
|
||||||
|
font->draw2D(rd, message, Vector2(x,y), height/8, Color3::white(), Color4::clear(), GFont::XALIGN_CENTER, GFont::YALIGN_CENTER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WorkspaceInstance* DataModelInstance::getWorkspace()
|
WorkspaceInstance* DataModelInstance::getWorkspace()
|
||||||
{
|
{
|
||||||
return workspace;
|
return workspace;
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ class DataModelInstance :
|
|||||||
public:
|
public:
|
||||||
DataModelInstance(void);
|
DataModelInstance(void);
|
||||||
~DataModelInstance(void);
|
~DataModelInstance(void);
|
||||||
|
void setMessage(std::string);
|
||||||
|
void clearMessage();
|
||||||
|
void drawMessage(RenderDevice*);
|
||||||
|
GFontRef font;
|
||||||
WorkspaceInstance* getWorkspace();
|
WorkspaceInstance* getWorkspace();
|
||||||
Instance* getGuiRoot();
|
Instance* getGuiRoot();
|
||||||
float mousex;
|
float mousex;
|
||||||
|
|||||||
3
main.cpp
3
main.cpp
@@ -688,7 +688,7 @@ void Demo::onInit() {
|
|||||||
dataModel = new DataModelInstance();
|
dataModel = new DataModelInstance();
|
||||||
dataModel->setParent(NULL);
|
dataModel->setParent(NULL);
|
||||||
dataModel->name = "undefined";
|
dataModel->name = "undefined";
|
||||||
|
dataModel->font = fntdominant;
|
||||||
Globals::dataModel = dataModel;
|
Globals::dataModel = dataModel;
|
||||||
|
|
||||||
initGUI();
|
initGUI();
|
||||||
@@ -1376,6 +1376,7 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
|
|
||||||
|
|
||||||
drawButtons(rd);
|
drawButtons(rd);
|
||||||
|
dataModel->drawMessage(rd);
|
||||||
rd->pushState();
|
rd->pushState();
|
||||||
rd->beforePrimitive();
|
rd->beforePrimitive();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user