Merge pull request #19 from andreja6/dialogs

Literally did nothing even close to dialogs
This commit is contained in:
andreja6
2018-05-30 22:04:05 -07:00
committed by GitHub
4 changed files with 45 additions and 10 deletions

View File

@@ -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;

View File

@@ -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;

Binary file not shown.

View File

@@ -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();
@@ -940,7 +940,7 @@ void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
//User Input //User Input
void Demo::onUserInput(UserInput* ui) { void Demo::onUserInput(UserInput* ui) {
if (ui->keyPressed(SDLK_ESCAPE)) { if (ui->keyPressed(SDLK_F4) && ui->keyDown(SDLK_LALT)) {
// Even when we aren't in debug mode, quit on escape. // Even when we aren't in debug mode, quit on escape.
endApplet = true; endApplet = true;
app->endProgram = true; app->endProgram = true;
@@ -1012,19 +1012,19 @@ void Demo::onUserInput(UserInput* ui) {
dataModel->mousex = ui->getMouseX(); dataModel->mousex = ui->getMouseX();
dataModel->mousey = ui->getMouseY(); dataModel->mousey = ui->getMouseY();
dataModel->mouseButton1Down = ui->keyDown(SDL_LEFT_MOUSE_KEY); dataModel->mouseButton1Down = ui->keyDown(SDL_LEFT_MOUSE_KEY);
if(ui->keyDown(SDLK_UP)) if(ui->keyDown('u'))
{ {
forwards = true; forwards = true;
} }
else if(ui->keyDown(SDLK_DOWN)) else if(ui->keyDown('j'))
{ {
backwards = true; backwards = true;
} }
if(ui->keyDown(SDLK_LEFT)) if(ui->keyDown('h'))
{ {
left = true; left = true;
} }
else if(ui->keyDown(SDLK_RIGHT)) else if(ui->keyDown('k'))
{ {
right = true; right = true;
@@ -1294,6 +1294,7 @@ void Demo::onGraphics(RenderDevice* rd) {
rd->window()->setInputCaptureCount(1); rd->window()->setInputCaptureCount(1);
} }
LightingParameters lighting(G3D::toSeconds(11, 00, 00, AM)); LightingParameters lighting(G3D::toSeconds(11, 00, 00, AM));
app->renderDevice->setProjectionAndCameraMatrix(app->debugCamera); app->renderDevice->setProjectionAndCameraMatrix(app->debugCamera);
@@ -1376,6 +1377,7 @@ void Demo::onGraphics(RenderDevice* rd) {
drawButtons(rd); drawButtons(rd);
dataModel->drawMessage(rd);
rd->pushState(); rd->pushState();
rd->beforePrimitive(); rd->beforePrimitive();
@@ -1546,7 +1548,7 @@ int main(int argc, char** argv) {
wc.hInstance = hInstance; wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.lpszMenuName = NULL; wc.lpszMenuName = NULL;
wc.lpszClassName = "containerHWND"; wc.lpszClassName = "containerHWND";
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
@@ -1554,7 +1556,6 @@ int main(int argc, char** argv) {
if (!RegisterClassEx (&wc)) if (!RegisterClassEx (&wc))
return false; return false;
HMODULE hThisInstance = GetModuleHandle(NULL);
HWND hwnd = wnd->win32HWND(); HWND hwnd = wnd->win32HWND();
HWND hwndMain = CreateWindowEx( HWND hwndMain = CreateWindowEx(
WS_EX_ACCEPTFILES | WS_EX_CLIENTEDGE, WS_EX_ACCEPTFILES | WS_EX_CLIENTEDGE,
@@ -1567,10 +1568,10 @@ int main(int argc, char** argv) {
600, 600,
NULL, // parent NULL, // parent
NULL, // menu NULL, // menu
hThisInstance, hInstance,
NULL NULL
); );
ShowWindow(hwndMain, SW_SHOW);
if(hwndMain == NULL) if(hwndMain == NULL)
{ {
MessageBox(NULL, "Failed to create HWND","Dynamica Crash", MB_OK); MessageBox(NULL, "Failed to create HWND","Dynamica Crash", MB_OK);
@@ -1607,6 +1608,7 @@ int main(int argc, char** argv) {
height = rect.bottom - rect.top; height = rect.bottom - rect.top;
} }
SetWindowPos(hwnd, NULL, 0, 0, width, height, NULL); SetWindowPos(hwnd, NULL, 0, 0, width, height, NULL);
ShowWindow(hwndMain, SW_SHOW);
app.run(); app.run();
} }
catch(...) catch(...)