Sort of got menus working (not great design though)

This commit is contained in:
Vulpovile
2021-03-06 01:20:30 -08:00
parent dd6cd509fa
commit 69be9dbb91
5 changed files with 18 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ public:
static int surfaceId;
static const std::string g_PlaceholderName;
static COLORREF g_acrCustClr[16]; //Will be dynamic later
static HWND mainHwnd;
};
extern std::vector<Instance*> postRenderStack;
@@ -36,4 +37,5 @@ extern COLORREF g_acrCustClr[16]; //Will be dynamic later
extern std::string cameraSound;
extern std::string clickSound;
extern std::string dingSound;
extern HWND mainHwnd;
const std::string g_PlaceholderName = "Dygysphere";

View File

@@ -136,6 +136,8 @@ GuiRootInstance::GuiRootInstance() : _message(""), _messageTime(0)
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
button->name = "file";
button->setButtonListener(new MenuButtonListener());
button = makeTextButton();
button->boxBegin = Vector2(125, 0);

View File

@@ -19,6 +19,7 @@ POINT Globals::mousepoint;
GFontRef g_fntdominant = NULL;
GFontRef g_fntlighttrek = NULL;
HWND Globals::mainHwnd = NULL;
Globals::Globals(void){}

View File

@@ -1,5 +1,6 @@
#include "Listener/MenuButtonListener.h"
#include "DataModel/ToggleImageButtonInstance.h"
#include "Application.h"
#include "Globals.h"
void MenuButtonListener::onButton1MouseClick(BaseButtonInstance* button)
{
@@ -8,4 +9,15 @@ void MenuButtonListener::onButton1MouseClick(BaseButtonInstance* button)
g_dataModel->toggleRun();
((ToggleImageButtonInstance*)button)->checked = g_dataModel->isRunning();
}
else if(button->name == "file")
{
HMENU mainmenu = CreatePopupMenu();
AppendMenu(mainmenu, MF_STRING, 100, "New");
AppendMenu(mainmenu, MF_STRING, 101, "Open...");
AppendMenu(mainmenu, MF_STRING, 101, "Close");
AppendMenu(mainmenu, MF_SEPARATOR, 0, NULL);
POINT p;
GetCursorPos(&p);
TrackPopupMenu(mainmenu, TPM_LEFTBUTTON, p.x, p.y, 0, Globals::mainHwnd, 0);
}
}

View File

@@ -209,7 +209,7 @@ int main(int argc, char** argv) {
}
SendMessage(hwndMain, WM_SETICON, ICON_BIG,(LPARAM)LoadImage(GetModuleHandle(NULL), (LPCSTR)MAKEINTRESOURCEW(IDI_ICON1), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE));
Globals::mainHwnd = hwndMain;
Application app = Application(hwndMain);
app.run();
}