Minor fixes and changes
This commit is contained in:
parent
ff3894db60
commit
2059e4b7db
@ -80,7 +80,7 @@ void MainState::update(float deltaTime) {
|
|||||||
sound2.stop();
|
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.push_back(new nf::Entity);
|
||||||
entities.back()->create(nf::BaseAssets::sphere, nf::Entity::Type::DYNAMIC);
|
entities.back()->create(nf::BaseAssets::sphere, nf::Entity::Type::DYNAMIC);
|
||||||
entities.back()->setPosition(camera->getPosition() + camera->getRotation() * 5.0);
|
entities.back()->setPosition(camera->getPosition() + camera->getRotation() * 5.0);
|
||||||
|
@ -31,15 +31,14 @@ namespace nf {
|
|||||||
int y = 0;
|
int y = 0;
|
||||||
calculateNewWindowPos(x, y);
|
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_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);
|
SetProp(m_window, L"App", this);
|
||||||
if (m_currentConfig.fullscreen) toggleFullscreen();
|
if (m_currentConfig.fullscreen) toggleFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setWindowIcon(HANDLE hIcon) {
|
void Application::setWindowIcon(HICON hIcon) {
|
||||||
m_customWindowIconSet = true;
|
m_customWindowIconSet = true;
|
||||||
|
m_windowIcon = hIcon;
|
||||||
SendMessage(m_window, WM_SETICON, ICON_BIG, (LPARAM)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
|
//TODO: Test these top-level features
|
||||||
void Application::setWindowCursor(HCURSOR hCursor) {
|
void Application::setWindowCursor(HCURSOR hCursor) {
|
||||||
@ -104,7 +103,7 @@ namespace nf {
|
|||||||
mainThread.join();
|
mainThread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::isCustomWindowIcon() {
|
bool Application::hasCustomWindowIcon() {
|
||||||
return m_customWindowIconSet;
|
return m_customWindowIconSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,6 +254,7 @@ namespace nf {
|
|||||||
else {
|
else {
|
||||||
SetWindowLong(m_window, GWL_STYLE, wndStyle | WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX);
|
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);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
case WM_SYSKEYDOWN: {
|
case WM_SYSKEYDOWN: {
|
||||||
if (GetKeyState(VK_RETURN) & 0x8000) {
|
if (GetKeyState(VK_RETURN) & 0x8000 && !(lParam & (1 << 30))) {
|
||||||
if (!(lParam & (1 << 30))) {
|
if (!app->m_currentConfig.fullscreen) {
|
||||||
if (!app->m_currentConfig.fullscreen) {
|
app->m_altWidth = app->m_currentConfig.width;
|
||||||
app->m_altWidth = app->m_currentConfig.width;
|
app->m_altHeight = app->m_currentConfig.height;
|
||||||
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 });
|
||||||
app->changeConfig({ app->m_currentConfig.width, app->m_currentConfig.height, !app->m_currentConfig.fullscreen, app->m_currentConfig.title });
|
if (!app->m_currentConfig.fullscreen) {
|
||||||
if (!app->m_currentConfig.fullscreen) {
|
app->changeConfig({ app->m_altWidth, app->m_altHeight, app->m_currentConfig.fullscreen, app->m_currentConfig.title });
|
||||||
app->changeConfig({ app->m_altWidth, app->m_altHeight, app->m_currentConfig.fullscreen, app->m_currentConfig.title });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ namespace nf {
|
|||||||
SetThreadDescription(GetCurrentThread(), L"Audio Thread");
|
SetThreadDescription(GetCurrentThread(), L"Audio Thread");
|
||||||
#endif
|
#endif
|
||||||
//Wait to initialize stuff until the master voice is created if it hasn't been already
|
//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));
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ namespace nf {
|
|||||||
m_pointDepthTexSize = 2048;
|
m_pointDepthTexSize = 2048;
|
||||||
createShadowMaps();
|
createShadowMaps();
|
||||||
|
|
||||||
if (!m_app->isCustomWindowIcon()) {
|
if (!m_app->hasCustomWindowIcon()) {
|
||||||
ATexture& windowTex = *(ATexture*)m_baseAP["defaultwindowicon.png"];
|
ATexture& windowTex = *(ATexture*)m_baseAP["defaultwindowicon.png"];
|
||||||
int width, height, nChannels;
|
int width, height, nChannels;
|
||||||
unsigned char* tex = stbi_load_from_memory((const unsigned char*)windowTex.data, (unsigned int)windowTex.size, &width, &height, &nChannels, 0);
|
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);
|
stbi_image_free(tex);
|
||||||
HICON windowIcon = CreateIcon(GetModuleHandle(NULL), width, height, 1, 32, NULL, &pixels[0]);
|
HICON windowIcon = CreateIcon(GetModuleHandle(NULL), width, height, 1, 32, NULL, &pixels[0]);
|
||||||
SendMessage(m_app->getWindow(), WM_SETICON, ICON_BIG, (LPARAM)windowIcon);
|
m_app->setWindowIcon(windowIcon);
|
||||||
SendMessage(m_app->getWindow(), WM_SETICON, ICON_SMALL, (LPARAM)windowIcon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float quadVB[] = {
|
float quadVB[] = {
|
||||||
|
@ -22,7 +22,7 @@ namespace nf {
|
|||||||
Application() = delete;
|
Application() = delete;
|
||||||
Application(Application& other) = delete;
|
Application(Application& other) = delete;
|
||||||
|
|
||||||
void setWindowIcon(HANDLE hIcon);
|
void setWindowIcon(HICON hIcon);
|
||||||
void setWindowCursor(HCURSOR hCursor);
|
void setWindowCursor(HCURSOR hCursor);
|
||||||
AudioEngine* getAudioEngine() const;
|
AudioEngine* getAudioEngine() const;
|
||||||
PhysicsEngine* getPhysicsEngine() const;
|
PhysicsEngine* getPhysicsEngine() const;
|
||||||
@ -30,7 +30,7 @@ namespace nf {
|
|||||||
void setDefaultState(const std::string& stateName);
|
void setDefaultState(const std::string& stateName);
|
||||||
const std::string& getDefaultState();
|
const std::string& getDefaultState();
|
||||||
void run();
|
void run();
|
||||||
bool isCustomWindowIcon();
|
bool hasCustomWindowIcon();
|
||||||
void changeState(const std::string& stateName);
|
void changeState(const std::string& stateName);
|
||||||
Gamestate* getCurrentState();
|
Gamestate* getCurrentState();
|
||||||
void showWindow(bool show);
|
void showWindow(bool show);
|
||||||
@ -69,7 +69,7 @@ namespace nf {
|
|||||||
LPCWSTR m_wclassName;
|
LPCWSTR m_wclassName;
|
||||||
HWND m_window;
|
HWND m_window;
|
||||||
bool m_customWindowIconSet;
|
bool m_customWindowIconSet;
|
||||||
LONG m_defaultWindowStyle;
|
HICON m_windowIcon;
|
||||||
unsigned int m_altWidth, m_altHeight;
|
unsigned int m_altWidth, m_altHeight;
|
||||||
|
|
||||||
std::chrono::duration<float> m_fpsDuration;
|
std::chrono::duration<float> m_fpsDuration;
|
||||||
|
Reference in New Issue
Block a user