#include <iostream>
#include <strings.h>
#include <irrlicht.h>
#include <vector>
#include "IrrLibGUI.h"
using
namespace
irr;
using
namespace
core;
using
namespace
scene;
using
namespace
video;
using
namespace
io;
using
namespace
gui;
using
namespace
std;
IrrLibGUI::IrrLibGUI()
{
this
->nStaticText = 0;
}
IrrLibGUI::~IrrLibGUI()
{
}
void
IrrLibGUI::SetEnv(IGUIEnvironment* env)
{
this
->env = env;
}
void
IrrLibGUI::Clear()
{
this
->env->clear();
}
void
IrrLibGUI::DrawAll()
{
this
->env->drawAll();
}
void
IrrLibGUI::AddToStaticArray(irr::gui::IGUIStaticText * addme)
{
arrStaticText.push_back(addme);
this
->nStaticText++;
}
void
IrrLibGUI::AddStaticText()
{
this
->env->addStaticText(L
"Powered by IrrLib."
, rect<s32>(20,30,300,80),
true
);
}
int
IrrLibGUI::AddStaticText(std::string message)
{
irr::gui::IGUIStaticText * addthis;
stringw tmpw(message.c_str());
addthis =
this
->env->addStaticText(tmpw.c_str(), rect<s32>(20,30,300,80),
true
);
AddToStaticArray(addthis);
}
int
IrrLibGUI::AddStaticText(std::string message,
int
x1,
int
y1,
int
x2,
int
y2)
{
irr::gui::IGUIStaticText * addthis;
stringw tmpw(message.c_str());
addthis =
this
->env->addStaticText(tmpw.c_str(), rect<s32>(x1,y1,x2,y2),
true
);
AddToStaticArray(addthis);
}
int
IrrLibGUI::AddStaticText(std::string message,
int
x1,
int
y1,
int
x2,
int
y2,
bool
border,
bool
wordwrap)
{
irr::gui::IGUIStaticText * addthis;
stringw tmpw(message.c_str());
addthis =
this
->env->addStaticText(tmpw.c_str(), rect<s32>(x1,y1,x2,y2), border, wordwrap);
AddToStaticArray(addthis);
}
int
IrrLibGUI::AddStaticText(std::string message,
int
x1,
int
y1,
int
x2,
int
y2,
bool
border,
bool
wordwrap,
int
id,
bool
fillbackground)
{
irr::gui::IGUIStaticText * addthis;
stringw tmpw(message.c_str());
addthis =
this
->env->addStaticText(tmpw.c_str(), rect<s32>(x1,y1,x2,y2), border, wordwrap, 0, id, fillbackground);
AddToStaticArray(addthis);
}
int
IrrLibGUI::AddStaticText(std::string message,
const
core::rect< s32 > &rectangle)
{
irr::gui::IGUIStaticText * addthis;
stringw tmpw(message.c_str());
addthis =
this
->env->addStaticText(tmpw.c_str(), rectangle);
AddToStaticArray(addthis);
}
int
IrrLibGUI::AddStaticText(std::string message,
const
core::rect< s32 > &rectangle,
bool
border,
bool
wordwrap)
{
irr::gui::IGUIStaticText * addthis;
stringw tmpw(message.c_str());
addthis =
this
->env->addStaticText(tmpw.c_str(), rectangle, border, wordwrap);
AddToStaticArray(addthis);
}
int
IrrLibGUI::AddStaticText(std::string message,
const
core::rect< s32 > &rectangle,
bool
border,
bool
wordwrap,
int
id,
bool
fillbackground)
{
irr::gui::IGUIStaticText * addthis;
stringw tmpw(message.c_str());
addthis =
this
->env->addStaticText(tmpw.c_str(), rectangle, border, wordwrap, 0, id, fillbackground);
AddToStaticArray(addthis);
}
void
IrrLibGUI::ChangeStaticText(
int
nstatictext, std::string message)
{
stringw tmpw(message.c_str());
this
->arrStaticText[
this
->nStaticText-1]->setText(tmpw.c_str());
}
void
IrrLibGUI::ChangeFont(std::string fontfile)
{
IGUISkin* skin =
this
->env->getSkin();
IGUIFont* font =
this
->env->getFont(fontfile.c_str());
if
(font)
skin->setFont(font);
}