Added message functions to DataModel

This commit is contained in:
andreja6
2018-05-02 19:59:49 -07:00
parent 0f609662bb
commit c38ede1bd1
3 changed files with 35 additions and 1 deletions

View File

@@ -6,6 +6,9 @@ Instance* guiRoot;
float mousex;
float mousey;
bool mouseButton1Down;
std::string message;
bool showMessage;
G3D::GFontRef font;
DataModelInstance::DataModelInstance(void)
@@ -17,12 +20,38 @@ DataModelInstance::DataModelInstance(void)
mousex = 0;
mousey = 0;
mouseButton1Down = false;
showMessage = false;
}
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()
{
return workspace;

View File

@@ -8,6 +8,10 @@ class DataModelInstance :
public:
DataModelInstance(void);
~DataModelInstance(void);
void setMessage(std::string);
void clearMessage();
void drawMessage(RenderDevice*);
GFontRef font;
WorkspaceInstance* getWorkspace();
Instance* getGuiRoot();
float mousex;

View File

@@ -688,7 +688,7 @@ void Demo::onInit() {
dataModel = new DataModelInstance();
dataModel->setParent(NULL);
dataModel->name = "undefined";
dataModel->font = fntdominant;
Globals::dataModel = dataModel;
initGUI();
@@ -1376,6 +1376,7 @@ void Demo::onGraphics(RenderDevice* rd) {
drawButtons(rd);
dataModel->drawMessage(rd);
rd->pushState();
rd->beforePrimitive();