mirror of
https://github.com/antopilo/Nuake.git
synced 2026-01-06 06:09:52 +03:00
Added resolution and monitor launch arg for editor
This commit is contained in:
@@ -34,6 +34,9 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
bool playMode = false;
|
||||
std::string projectPath = "";
|
||||
|
||||
Vector2 editorResolution = Vector2(1280, 720);
|
||||
int monitorIdx = -1;
|
||||
for (uint32_t i = 0; i < argc; i++)
|
||||
{
|
||||
char* arg = argv[i];
|
||||
@@ -47,6 +50,31 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
playMode = true;
|
||||
}
|
||||
|
||||
if (args == "--resolution")
|
||||
{
|
||||
if (argc >= i + 1)
|
||||
{
|
||||
std::string resString = std::string(argv[i + 1]);
|
||||
const auto& resSplits = String::Split(resString, 'x');
|
||||
if (resSplits.size() == 2)
|
||||
{
|
||||
int width = stoi(resSplits[0]);
|
||||
int height = stoi(resSplits[1]);
|
||||
editorResolution = Vector2(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args == "--monitor")
|
||||
{
|
||||
if (argc >= i + 1)
|
||||
{
|
||||
std::string monitorIdxString = std::string(argv[i + 1]);
|
||||
monitorIdx = stoi(monitorIdxString);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool shouldLoadProject = false;
|
||||
@@ -95,12 +123,19 @@ int main(int argc, char* argv[])
|
||||
else
|
||||
{
|
||||
Nuake::Engine::Init();
|
||||
Engine::GetCurrentWindow()->SetSize(editorResolution);
|
||||
|
||||
Nuake::EditorInterface editor;
|
||||
editor.BuildFonts();
|
||||
|
||||
Ref<Nuake::Window> window = Nuake::Engine::GetCurrentWindow();
|
||||
window->SetTitle(WindowTitle);
|
||||
|
||||
if (monitorIdx != -1)
|
||||
{
|
||||
window->SetMonitor(monitorIdx);
|
||||
}
|
||||
|
||||
using namespace Nuake;
|
||||
|
||||
GizmoDrawer gizmoDrawer = GizmoDrawer();
|
||||
|
||||
@@ -78,13 +78,33 @@ namespace Nuake {
|
||||
return m_Framebuffer;
|
||||
}
|
||||
|
||||
Vector2 Window::GetSize()
|
||||
Vector2 Window::GetSize() const
|
||||
{
|
||||
int w, h = 0;
|
||||
glfwGetWindowSize(m_Window, &w, &h);
|
||||
return Vector2(w, h);
|
||||
}
|
||||
|
||||
void Window::SetSize(const Vector2& size)
|
||||
{
|
||||
m_Width = size.x;
|
||||
m_Height = size.y;
|
||||
glfwSetWindowSize(m_Window, size.x, size.y);
|
||||
}
|
||||
|
||||
void Window::SetMonitor(int monitorIdx)
|
||||
{
|
||||
int monitorCount;
|
||||
GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
|
||||
|
||||
if (monitorIdx <= monitorCount)
|
||||
{
|
||||
const auto monitor = *(monitors + monitorIdx);
|
||||
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
||||
glfwSetWindowMonitor(m_Window, monitor, 0, 0, m_Width, m_Height, mode->refreshRate);
|
||||
}
|
||||
}
|
||||
|
||||
int Window::Init()
|
||||
{
|
||||
if (!glfwInit())
|
||||
|
||||
@@ -42,7 +42,11 @@ namespace Nuake
|
||||
void EndDraw();
|
||||
|
||||
Ref<FrameBuffer> GetFrameBuffer() const;
|
||||
Vector2 GetSize();
|
||||
Vector2 GetSize() const;
|
||||
void SetSize(const Vector2& size);
|
||||
|
||||
void SetMonitor(int monitor);
|
||||
|
||||
Ref<Scene> GetScene();
|
||||
bool SetScene(Ref<Scene> scene);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user