Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Maximize On Startup and Deleted Unused Stuff #609

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Hazel-ScriptCore/Source/Hazel/InternalCalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,18 @@ public static class InternalCalls

[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static void TransformComponent_GetTranslation(ulong entityID, out Vector3 translation);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static void TransformComponent_GetRotation(ulong entityID, out Vector3 rotation);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static void TransformComponent_GetScale(ulong entityID, out Vector3 scale);


[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static void TransformComponent_SetTranslation(ulong entityID, ref Vector3 translation);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static void TransformComponent_SetRotation(ulong entityID, ref Vector3 rotation);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static void TransformComponent_SetScale(ulong entityID, ref Vector3 scale);

[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static void Rigidbody2DComponent_ApplyLinearImpulse(ulong entityID, ref Vector2 impulse, ref Vector2 point, bool wake);
Expand Down
24 changes: 24 additions & 0 deletions Hazel-ScriptCore/Source/Hazel/Scene/Components.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ public Vector3 Translation
InternalCalls.TransformComponent_SetTranslation(Entity.ID, ref value);
}
}
public Vector3 Rotation
{
get
{
InternalCalls.TransformComponent_GetRotation(Entity.ID, out Vector3 rotation);
return rotation;
}
set
{
InternalCalls.TransformComponent_SetRotation(Entity.ID, ref value);
}
}
public Vector3 Scale
{
get
{
InternalCalls.TransformComponent_GetScale(Entity.ID, out Vector3 scale);
return scale;
}
set
{
InternalCalls.TransformComponent_SetScale(Entity.ID, ref value);
}
}
}

public class Rigidbody2DComponent : Component
Expand Down
2 changes: 1 addition & 1 deletion Hazel/src/Hazel/Core/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Hazel {
if (!m_Specification.WorkingDirectory.empty())
std::filesystem::current_path(m_Specification.WorkingDirectory);

m_Window = Window::Create(WindowProps(m_Specification.Name));
m_Window = Window::Create(WindowProps(m_Specification.Name),true);
m_Window->SetEventCallback(HZ_BIND_EVENT_FN(Application::OnEvent));

Renderer::Init();
Expand Down
6 changes: 3 additions & 3 deletions Hazel/src/Hazel/Core/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

namespace Hazel
{
Scope<Window> Window::Create(const WindowProps& props)
Scope<Window> Window::Create(const WindowProps& props, bool maximized)
{
#ifdef HZ_PLATFORM_WINDOWS
return CreateScope<WindowsWindow>(props);
return CreateScope<WindowsWindow>(props,maximized);
#else
HZ_CORE_ASSERT(false, "Unknown platform!");
return nullptr;
#endif
}

}
}
3 changes: 1 addition & 2 deletions Hazel/src/Hazel/Core/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ namespace Hazel {
virtual void SetEventCallback(const EventCallbackFn& callback) = 0;
virtual void SetVSync(bool enabled) = 0;
virtual bool IsVSync() const = 0;

virtual void* GetNativeWindow() const = 0;

static Scope<Window> Create(const WindowProps& props = WindowProps());
static Scope<Window> Create(const WindowProps& props = WindowProps(),bool maximized = false);
};

}
64 changes: 41 additions & 23 deletions Hazel/src/Hazel/Scripting/ScriptGlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,6 @@ namespace Hazel {

#define HZ_ADD_INTERNAL_CALL(Name) mono_add_internal_call("Hazel.InternalCalls::" #Name, Name)

static void NativeLog(MonoString* string, int parameter)
{
char* cStr = mono_string_to_utf8(string);
std::string str(cStr);
mono_free(cStr);
std::cout << str << ", " << parameter << std::endl;
}

static void NativeLog_Vector(glm::vec3* parameter, glm::vec3* outResult)
{
HZ_CORE_WARN("Value: {0}", *parameter);
*outResult = glm::normalize(*parameter);
}

static float NativeLog_VectorDot(glm::vec3* parameter)
{
HZ_CORE_WARN("Value: {0}", *parameter);
return glm::dot(*parameter, *parameter);
}

static MonoObject* GetScriptInstance(UUID entityID)
{
Expand Down Expand Up @@ -83,6 +64,25 @@ namespace Hazel {

*outTranslation = entity.GetComponent<TransformComponent>().Translation;
}
static void TransformComponent_GetRotation(UUID entityID, glm::vec3* outRotation)
{
Scene* scene = ScriptEngine::GetSceneContext();
HZ_CORE_ASSERT(scene);
Entity entity = scene->GetEntityByUUID(entityID);
HZ_CORE_ASSERT(entity);

*outRotation = entity.GetComponent<TransformComponent>().Rotation;
}

static void TransformComponent_GetScale(UUID entityID, glm::vec3* outScale)
{
Scene* scene = ScriptEngine::GetSceneContext();
HZ_CORE_ASSERT(scene);
Entity entity = scene->GetEntityByUUID(entityID);
HZ_CORE_ASSERT(entity);

*outScale = entity.GetComponent<TransformComponent>().Scale;
}

static void TransformComponent_SetTranslation(UUID entityID, glm::vec3* translation)
{
Expand All @@ -93,6 +93,24 @@ namespace Hazel {

entity.GetComponent<TransformComponent>().Translation = *translation;
}
static void TransformComponent_SetRotation(UUID entityID, glm::vec3* rotation)
{
Scene* scene = ScriptEngine::GetSceneContext();
HZ_CORE_ASSERT(scene);
Entity entity = scene->GetEntityByUUID(entityID);
HZ_CORE_ASSERT(entity);

entity.GetComponent<TransformComponent>().Rotation = *rotation;
}
static void TransformComponent_SetScale(UUID entityID, glm::vec3* scale)
{
Scene* scene = ScriptEngine::GetSceneContext();
HZ_CORE_ASSERT(scene);
Entity entity = scene->GetEntityByUUID(entityID);
HZ_CORE_ASSERT(entity);

entity.GetComponent<TransformComponent>().Scale = *scale;
}

static void Rigidbody2DComponent_ApplyLinearImpulse(UUID entityID, glm::vec2* impulse, glm::vec2* point, bool wake)
{
Expand Down Expand Up @@ -194,17 +212,17 @@ namespace Hazel {

void ScriptGlue::RegisterFunctions()
{
HZ_ADD_INTERNAL_CALL(NativeLog);
HZ_ADD_INTERNAL_CALL(NativeLog_Vector);
HZ_ADD_INTERNAL_CALL(NativeLog_VectorDot);

HZ_ADD_INTERNAL_CALL(GetScriptInstance);

HZ_ADD_INTERNAL_CALL(Entity_HasComponent);
HZ_ADD_INTERNAL_CALL(Entity_FindEntityByName);

HZ_ADD_INTERNAL_CALL(TransformComponent_GetTranslation);
HZ_ADD_INTERNAL_CALL(TransformComponent_SetTranslation);
HZ_ADD_INTERNAL_CALL(TransformComponent_GetRotation);
HZ_ADD_INTERNAL_CALL(TransformComponent_SetRotation);
HZ_ADD_INTERNAL_CALL(TransformComponent_GetScale);
HZ_ADD_INTERNAL_CALL(TransformComponent_SetScale);

HZ_ADD_INTERNAL_CALL(Rigidbody2DComponent_ApplyLinearImpulse);
HZ_ADD_INTERNAL_CALL(Rigidbody2DComponent_ApplyLinearImpulseToCenter);
Expand Down
10 changes: 6 additions & 4 deletions Hazel/src/Platform/Windows/WindowsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ namespace Hazel {
HZ_CORE_ERROR("GLFW Error ({0}): {1}", error, description);
}

WindowsWindow::WindowsWindow(const WindowProps& props)
WindowsWindow::WindowsWindow(const WindowProps& props,bool maximized)
{
HZ_PROFILE_FUNCTION();

Init(props);
Init(props,maximized);
}

WindowsWindow::~WindowsWindow()
Expand All @@ -34,7 +34,7 @@ namespace Hazel {
Shutdown();
}

void WindowsWindow::Init(const WindowProps& props)
void WindowsWindow::Init(const WindowProps& props,bool maximized)
{
HZ_PROFILE_FUNCTION();

Expand All @@ -53,6 +53,9 @@ namespace Hazel {
}

{
if(maximized)
glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);

HZ_PROFILE_SCOPE("glfwCreateWindow");
#if defined(HZ_DEBUG)
if (Renderer::GetAPI() == RendererAPI::API::OpenGL)
Expand Down Expand Up @@ -196,5 +199,4 @@ namespace Hazel {
{
return m_Data.VSync;
}

}
7 changes: 3 additions & 4 deletions Hazel/src/Platform/Windows/WindowsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Hazel {
class WindowsWindow : public Window
{
public:
WindowsWindow(const WindowProps& props);
WindowsWindow(const WindowProps& props,bool maximized);
virtual ~WindowsWindow();

void OnUpdate() override;
Expand All @@ -22,10 +22,9 @@ namespace Hazel {
void SetEventCallback(const EventCallbackFn& callback) override { m_Data.EventCallback = callback; }
void SetVSync(bool enabled) override;
bool IsVSync() const override;

virtual void* GetNativeWindow() const { return m_Window; }
private:
virtual void Init(const WindowProps& props);
virtual void Init(const WindowProps& props,bool maximized);
virtual void Shutdown();
private:
GLFWwindow* m_Window;
Expand All @@ -43,4 +42,4 @@ namespace Hazel {
WindowData m_Data;
};

}
}
Loading