Initial commit
Flemme
This commit is contained in:
99
JulietApp/Editor/EditorMain_win32.cpp
Normal file
99
JulietApp/Editor/EditorMain_win32.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
#include <Editor/EditorMain_win32.h>
|
||||
|
||||
#include <Core/Application/ApplicationManager.h>
|
||||
#include <Core/HAL/Display/Display.h>
|
||||
#include <Core/HAL/Event/SystemEvent.h>
|
||||
#include <Core/JulietInit.h>
|
||||
#include <Core/Logging/LogManager.h>
|
||||
#include <Core/Logging/LogTypes.h>
|
||||
#include <Graphics/GraphicsConfig.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
// TODO : Replace with message box from framework + call main and not winmain + subsystem
|
||||
#include <Windows.h>
|
||||
|
||||
namespace Juliet
|
||||
{
|
||||
void Win32EditorApplication::Init()
|
||||
{
|
||||
Log(LogLevel::Message, LogCategory::Editor, "Initializing Editor Application...");
|
||||
|
||||
MainWindow = CreatePlatformWindow("Juliet Editor", 1280, 720);
|
||||
|
||||
GraphicsConfig config;
|
||||
// InitializeGraphics(config);
|
||||
|
||||
Running = MainWindow != nullptr;
|
||||
}
|
||||
|
||||
void Win32EditorApplication::Shutdown()
|
||||
{
|
||||
Log(LogLevel::Message, LogCategory::Editor, "Shutdown Editor Application...");
|
||||
|
||||
// DestroyOSWindow(MainWindow);
|
||||
}
|
||||
|
||||
void Win32EditorApplication::Update()
|
||||
{
|
||||
// UpdateOSWindowState(MainWindow);
|
||||
SystemEvent evt;
|
||||
while (GetEvent(evt))
|
||||
{
|
||||
if (evt.Type == EventType::Window_Close_Request)
|
||||
{
|
||||
if (evt.Data.Window.AssociatedWindowID == GetWindowID(MainWindow))
|
||||
{
|
||||
Running = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (evt.Type == EventType::Key_Down)
|
||||
{
|
||||
if (evt.Data.Keyboard.Key.ScanCode == ScanCode::Escape)
|
||||
{
|
||||
Running = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Other way to do it
|
||||
if (IsKeyDown(ScanCode::Q))
|
||||
{
|
||||
Running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Win32EditorApplication::IsRunning()
|
||||
{
|
||||
return Running;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
Win32EditorApplication EditorApplication;
|
||||
}
|
||||
|
||||
Win32EditorApplication& GetEditorApplication()
|
||||
{
|
||||
return EditorApplication;
|
||||
}
|
||||
|
||||
} // namespace Juliet
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
CreateMutex(0, false, L"Local\\Juliet.Editor");
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
MessageBox(nullptr, L"An instance of Juliet is already running.", L"Juliet", MB_OK | MB_ICONEXCLAMATION);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
StartApplication(Juliet::EditorApplication, Juliet::JulietInit_Flags::Display);
|
||||
|
||||
// Pause here to not close the console window immediatly on stop
|
||||
system("PAUSE");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user