diff options
Diffstat (limited to 'Source/Graphics/Cursor.cpp')
-rw-r--r-- | Source/Graphics/Cursor.cpp | 65 |
1 files changed, 31 insertions, 34 deletions
diff --git a/Source/Graphics/Cursor.cpp b/Source/Graphics/Cursor.cpp index 4fecb6a6..94a2ebc7 100644 --- a/Source/Graphics/Cursor.cpp +++ b/Source/Graphics/Cursor.cpp @@ -31,7 +31,7 @@ #include <Main/engine.h> void GameCursor::Draw() { - if(Graphics::Instance()->media_mode()) { + if (Graphics::Instance()->media_mode()) { UIShowCursor(true); return; } @@ -42,31 +42,30 @@ void GameCursor::Draw() { int* mouse_pos = Input::Instance()->getMouse().pos_; int* window_dims = Graphics::Instance()->window_dims; vec3 draw_pos( - (float)( mouse_pos[0] + m_offset_x ), - (float)( (window_dims[1]-mouse_pos[1]) - m_offset_y ), + (float)(mouse_pos[0] + m_offset_x), + (float)((window_dims[1] - mouse_pos[1]) - m_offset_y), 0.0f); - Textures::Instance()->drawTexture(m_texture_ref, draw_pos, + Textures::Instance()->drawTexture(m_texture_ref, draw_pos, m_size, m_rotation); - CHECK_GL_ERROR(); + CHECK_GL_ERROR(); } void GameCursor::SetCursor(_cursor_type t) { - - //std::pair<int, int> dimensions; - switch(t) { - case DEFAULT_CURSOR: - if(!default_cursor_asset.valid()){ + // std::pair<int, int> dimensions; + switch (t) { + case DEFAULT_CURSOR: + if (!default_cursor_asset.valid()) { default_cursor_asset = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/Cursors/cursor_nocompress.png", PX_SRGB | PX_NOREDUCE, 0x0); } m_texture_ref = default_cursor_asset->GetTextureRef(); m_type = DEFAULT_CURSOR; m_offset_x = 12; m_offset_y = 15; - m_size = 32.0f; + m_size = 32.0f; break; - case TRANSLATE_CURSOR: - if(!translate_cursor_asset.valid()){ - translate_cursor_asset = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/Cursors/translate_nocompress.png",PX_SRGB | PX_NOREDUCE, 0x0); + case TRANSLATE_CURSOR: + if (!translate_cursor_asset.valid()) { + translate_cursor_asset = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/Cursors/translate_nocompress.png", PX_SRGB | PX_NOREDUCE, 0x0); } m_texture_ref = translate_cursor_asset->GetTextureRef(); m_type = TRANSLATE_CURSOR; @@ -74,9 +73,9 @@ void GameCursor::SetCursor(_cursor_type t) { m_offset_x = 12; m_offset_y = 15; break; - case SCALE_CURSOR: - if(!scale_cursor_asset.valid()){ - scale_cursor_asset = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/Cursors/scale_nocompress.png",PX_SRGB | PX_NOREDUCE, 0x0); + case SCALE_CURSOR: + if (!scale_cursor_asset.valid()) { + scale_cursor_asset = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/Cursors/scale_nocompress.png", PX_SRGB | PX_NOREDUCE, 0x0); } m_texture_ref = scale_cursor_asset->GetTextureRef(); m_type = SCALE_CURSOR; @@ -84,9 +83,9 @@ void GameCursor::SetCursor(_cursor_type t) { m_offset_x = 12; m_offset_y = 15; break; - case ROTATE_CURSOR: - if(!rotate_cursor_asset.valid()){ - rotate_cursor_asset = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/Cursors/rotate_nocompress.png",PX_SRGB | PX_NOREDUCE, 0x0); + case ROTATE_CURSOR: + if (!rotate_cursor_asset.valid()) { + rotate_cursor_asset = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/Cursors/rotate_nocompress.png", PX_SRGB | PX_NOREDUCE, 0x0); } m_texture_ref = rotate_cursor_asset->GetTextureRef(); m_type = ROTATE_CURSOR; @@ -95,7 +94,7 @@ void GameCursor::SetCursor(_cursor_type t) { m_offset_y = 15; break; case ROTATE_CIRCLE_CURSOR: - if(!rotate_circle_cursor_asset.valid()){ + if (!rotate_circle_cursor_asset.valid()) { rotate_circle_cursor_asset = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/Cursors/rotate_circle_nocompress.png", PX_SRGB | PX_NOREDUCE, 0x0); } m_texture_ref = rotate_circle_cursor_asset->GetTextureRef(); @@ -103,8 +102,8 @@ void GameCursor::SetCursor(_cursor_type t) { m_size = 36.0f; m_offset_x = m_offset_y = 0; break; - case ADD_CURSOR: - if(!add_cursor_asset.valid()){ + case ADD_CURSOR: + if (!add_cursor_asset.valid()) { add_cursor_asset = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/Cursors/plus_nocompress.png", PX_SRGB | PX_NOREDUCE, 0x0); } m_texture_ref = add_cursor_asset->GetTextureRef(); @@ -113,8 +112,8 @@ void GameCursor::SetCursor(_cursor_type t) { m_offset_x = 12; m_offset_y = 15; break; - case REMOVE_CURSOR: - if(!remove_cursor_asset.valid()){ + case REMOVE_CURSOR: + if (!remove_cursor_asset.valid()) { remove_cursor_asset = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/Cursors/minus_nocompress.png", PX_SRGB | PX_NOREDUCE, 0x0); } m_texture_ref = remove_cursor_asset->GetTextureRef(); @@ -123,8 +122,8 @@ void GameCursor::SetCursor(_cursor_type t) { m_offset_x = 12; m_offset_y = 15; break; - case LINK_CURSOR: - if(!link_cursor_asset.valid()){ + case LINK_CURSOR: + if (!link_cursor_asset.valid()) { link_cursor_asset = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/Cursors/link_nocompress.png", PX_SRGB | PX_NOREDUCE, 0x0); } m_texture_ref = link_cursor_asset->GetTextureRef(); @@ -133,8 +132,8 @@ void GameCursor::SetCursor(_cursor_type t) { m_offset_x = 12; m_offset_y = 15; break; - case UNLINK_CURSOR: - if(!unlink_cursor_asset.valid()){ + case UNLINK_CURSOR: + if (!unlink_cursor_asset.valid()) { unlink_cursor_asset = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/Cursors/unlink_nocompress.png", PX_SRGB | PX_NOREDUCE, 0x0); } m_texture_ref = unlink_cursor_asset->GetTextureRef(); @@ -143,8 +142,8 @@ void GameCursor::SetCursor(_cursor_type t) { m_offset_x = 12; m_offset_y = 15; break; - case HAND_CURSOR: - if(!hand_cursor_asset.valid()){ + case HAND_CURSOR: + if (!hand_cursor_asset.valid()) { hand_cursor_asset = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>("Data/Textures/Cursors/pointer_nocompress.png", PX_SRGB | PX_NOREDUCE, 0x0); } m_texture_ref = hand_cursor_asset->GetTextureRef(); @@ -153,7 +152,6 @@ void GameCursor::SetCursor(_cursor_type t) { m_offset_x = 12; m_offset_y = 15; break; - } } @@ -161,7 +159,7 @@ void GameCursor::SetVisible(bool _visible) { visible = _visible; } -void GameCursor::SetCursor(const TextureAssetRef &t_id) { +void GameCursor::SetCursor(const TextureAssetRef& t_id) { external_cursor_asset = t_id; m_texture_ref = external_cursor_asset->GetTextureRef(); } @@ -174,4 +172,3 @@ void GameCursor::setCursor(std::string texture_name) { void GameCursor::Rotate(float angle) { m_rotation += angle; } - |