Merge branch 'master' into MusicalProgrammer

This commit is contained in:
MusicalProgrammer
2018-05-31 14:12:17 -04:00
4 changed files with 75 additions and 11 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;

Binary file not shown.

View File

@@ -667,7 +667,7 @@ void Demo::onInit() {
dataModel = new DataModelInstance();
dataModel->setParent(NULL);
dataModel->name = "undefined";
dataModel->font = fntdominant;
Globals::dataModel = dataModel;
initGUI();
@@ -919,7 +919,7 @@ void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
//User Input
void Demo::onUserInput(UserInput* ui) {
if (GetKeyState(VK_ESCAPE) >> 1) {
if (ui->keyPressed(SDLK_F4) && ui->keyDown(SDLK_LALT)) {
// Even when we aren't in debug mode, quit on escape.
//endApplet = true;
PostQuitMessage(0);
@@ -992,23 +992,27 @@ void Demo::onUserInput(UserInput* ui) {
dataModel->mousex = ui->getMouseX();
dataModel->mousey = ui->getMouseY();
dataModel->mouseButton1Down = ui->keyDown(SDL_LEFT_MOUSE_KEY);
if(GetKeyState(VK_UP) >> 1)
if(GetKeyState('U') >> 1)
{
forwards = true;
}
else if(GetKeyState(VK_DOWN) >> 1)
else if(GetKeyState('J') >> 1)
{
backwards = true;
}
if(GetKeyState(VK_LEFT) >> 1)
if(GetKeyState('H') >> 1)
{
left = true;
}
else if(GetKeyState(VK_RIGHT) >> 1)
else if(GetKeyState('K') >> 1)
{
right = true;
}
if(ui->keyDown('U'))
{
forwards = true;
}
if(GetKeyState(SDL_LEFT_MOUSE_KEY))
{
@@ -1274,6 +1278,7 @@ void Demo::onGraphics(RenderDevice* rd) {
rd->window()->setInputCaptureCount(1);
}
LightingParameters lighting(G3D::toSeconds(11, 00, 00, AM));
renderDevice->setProjectionAndCameraMatrix(debugCamera);
@@ -1356,6 +1361,7 @@ void Demo::onGraphics(RenderDevice* rd) {
drawButtons(rd);
dataModel->drawMessage(rd);
rd->pushState();
rd->beforePrimitive();
@@ -1585,7 +1591,7 @@ int main(int argc, char** argv) {
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.lpszMenuName = NULL;
wc.lpszClassName = "containerHWND";
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
@@ -1606,21 +1612,46 @@ int main(int argc, char** argv) {
600,
NULL, // parent
NULL, // menu
hThisInstance,
hInstance,
NULL
);
ShowWindow(hwndMain, SW_SHOW);
if(hwndMain == NULL)
{
MessageBox(NULL, "Failed to create HWND","Dynamica Crash", MB_OK);
return 0;
}
ShowWindow(hwndMain, SW_SHOW);
Win32Window* win32Window = Win32Window::create(settings.window,hwndMain);
Demo demo = Demo(settings,win32Window);
SetWindowLongPtr(hwndMain,GWL_USERDATA,(LONG)&demo);
demo.run();
/*
LONG lStyle = GetWindowLong(hwnd, GWL_STYLE);
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU);
SetWindowLong(hwnd, GWL_STYLE, lStyle);
LONG lExStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
lExStyle &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
SetWindowLong(hwnd, GWL_EXSTYLE, lExStyle);
SetWindowLongPtr(hwndMain, GWL_USERDATA, (LONG)&app);
HICON hicon = (HICON)LoadImage(GetModuleHandleW(NULL), (LPCSTR)MAKEINTRESOURCEW(IDI_ICON1), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
SendMessage(hwndMain, WM_SETICON, ICON_BIG, (LPARAM)hicon);
SetWindowPos(hwndMain, NULL, 0, 0, 800, 600, NULL);
if(GetClientRect(hwndMain, &rect))
{
width = rect.right - rect.left;
height = rect.bottom - rect.top;
}
SetWindowPos(hwnd, NULL, 0, 0, width, height, NULL);
app.run();
*/
}
catch(...)
{