Minor fixes and changes

This commit is contained in:
Grayson Riffe (Desktop) 2021-11-02 22:49:22 -05:00
parent ff3894db60
commit 2059e4b7db
5 changed files with 19 additions and 22 deletions

View File

@ -80,7 +80,7 @@ void MainState::update(float deltaTime) {
sound2.stop();
}
if (app->isMouseClicked(NFI_LEFTMOUSE) || app->isMouseHeld(NFI_RIGHTMOUSE)) {
if (camera->getType() == nf::Camera::Type::FIRST_PERSON && (app->isMouseClicked(NFI_LEFTMOUSE) || app->isMouseHeld(NFI_RIGHTMOUSE))) {
entities.push_back(new nf::Entity);
entities.back()->create(nf::BaseAssets::sphere, nf::Entity::Type::DYNAMIC);
entities.back()->setPosition(camera->getPosition() + camera->getRotation() * 5.0);

View File

@ -31,15 +31,14 @@ namespace nf {
int y = 0;
calculateNewWindowPos(x, y);
m_window = CreateWindowEx(NULL, m_wclassName, toWide(m_currentConfig.title).data(), WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX, x, y, windowSize.right, windowSize.bottom, NULL, NULL, m_hInst, NULL);
m_defaultWindowStyle = GetWindowLong(m_window, GWL_STYLE);
SetProp(m_window, L"App", this);
if (m_currentConfig.fullscreen) toggleFullscreen();
}
void Application::setWindowIcon(HANDLE hIcon) {
void Application::setWindowIcon(HICON hIcon) {
m_customWindowIconSet = true;
m_windowIcon = hIcon;
SendMessage(m_window, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
SendMessage(m_window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
}
//TODO: Test these top-level features
void Application::setWindowCursor(HCURSOR hCursor) {
@ -104,7 +103,7 @@ namespace nf {
mainThread.join();
}
bool Application::isCustomWindowIcon() {
bool Application::hasCustomWindowIcon() {
return m_customWindowIconSet;
}
@ -255,6 +254,7 @@ namespace nf {
else {
SetWindowLong(m_window, GWL_STYLE, wndStyle | WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX);
SetWindowPos(m_window, HWND_TOP, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
SendMessage(m_window, WM_SETICON, ICON_SMALL, (LPARAM)m_windowIcon);
}
}
@ -373,16 +373,14 @@ namespace nf {
return 0;
}
case WM_SYSKEYDOWN: {
if (GetKeyState(VK_RETURN) & 0x8000) {
if (!(lParam & (1 << 30))) {
if (!app->m_currentConfig.fullscreen) {
app->m_altWidth = app->m_currentConfig.width;
app->m_altHeight = app->m_currentConfig.height;
}
app->changeConfig({ app->m_currentConfig.width, app->m_currentConfig.height, !app->m_currentConfig.fullscreen, app->m_currentConfig.title });
if (!app->m_currentConfig.fullscreen) {
app->changeConfig({ app->m_altWidth, app->m_altHeight, app->m_currentConfig.fullscreen, app->m_currentConfig.title });
}
if (GetKeyState(VK_RETURN) & 0x8000 && !(lParam & (1 << 30))) {
if (!app->m_currentConfig.fullscreen) {
app->m_altWidth = app->m_currentConfig.width;
app->m_altHeight = app->m_currentConfig.height;
}
app->changeConfig({ app->m_currentConfig.width, app->m_currentConfig.height, !app->m_currentConfig.fullscreen, app->m_currentConfig.title });
if (!app->m_currentConfig.fullscreen) {
app->changeConfig({ app->m_altWidth, app->m_altHeight, app->m_currentConfig.fullscreen, app->m_currentConfig.title });
}
return 0;
}

View File

@ -58,7 +58,7 @@ namespace nf {
SetThreadDescription(GetCurrentThread(), L"Audio Thread");
#endif
//Wait to initialize stuff until the master voice is created if it hasn't been already
while (!m_isActive) {
while (m_threadRunning && !m_isActive) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

View File

@ -89,7 +89,7 @@ namespace nf {
m_pointDepthTexSize = 2048;
createShadowMaps();
if (!m_app->isCustomWindowIcon()) {
if (!m_app->hasCustomWindowIcon()) {
ATexture& windowTex = *(ATexture*)m_baseAP["defaultwindowicon.png"];
int width, height, nChannels;
unsigned char* tex = stbi_load_from_memory((const unsigned char*)windowTex.data, (unsigned int)windowTex.size, &width, &height, &nChannels, 0);
@ -102,8 +102,7 @@ namespace nf {
}
stbi_image_free(tex);
HICON windowIcon = CreateIcon(GetModuleHandle(NULL), width, height, 1, 32, NULL, &pixels[0]);
SendMessage(m_app->getWindow(), WM_SETICON, ICON_BIG, (LPARAM)windowIcon);
SendMessage(m_app->getWindow(), WM_SETICON, ICON_SMALL, (LPARAM)windowIcon);
m_app->setWindowIcon(windowIcon);
}
float quadVB[] = {

View File

@ -22,7 +22,7 @@ namespace nf {
Application() = delete;
Application(Application& other) = delete;
void setWindowIcon(HANDLE hIcon);
void setWindowIcon(HICON hIcon);
void setWindowCursor(HCURSOR hCursor);
AudioEngine* getAudioEngine() const;
PhysicsEngine* getPhysicsEngine() const;
@ -30,7 +30,7 @@ namespace nf {
void setDefaultState(const std::string& stateName);
const std::string& getDefaultState();
void run();
bool isCustomWindowIcon();
bool hasCustomWindowIcon();
void changeState(const std::string& stateName);
Gamestate* getCurrentState();
void showWindow(bool show);
@ -69,7 +69,7 @@ namespace nf {
LPCWSTR m_wclassName;
HWND m_window;
bool m_customWindowIconSet;
LONG m_defaultWindowStyle;
HICON m_windowIcon;
unsigned int m_altWidth, m_altHeight;
std::chrono::duration<float> m_fpsDuration;