This commit is contained in:
marmare314 2023-08-14 08:53:59 +02:00
parent 2bcfbae841
commit 72b0fbfada
5 changed files with 38 additions and 39 deletions

View file

@ -19,13 +19,13 @@ class CRenderTools;
class CEditorComponent
{
public:
virtual ~CEditorComponent() = default;
virtual ~CEditorComponent() = default;
virtual void Init(CEditor *pEditor);
virtual void OnRender();
virtual void Init(CEditor *pEditor);
virtual void OnRender();
CEditor *Editor();
IInput *Input();
CEditor *Editor();
IInput *Input();
IClient *Client();
CConfig *Config();
IConsole *Console();
@ -38,18 +38,18 @@ public:
CRenderTools *RenderTools();
private:
CEditor *m_pEditor;
IInput *m_pInput;
IClient *m_pClient;
CConfig *m_pConfig;
IConsole *m_pConsole;
IEngine *m_pEngine;
IGraphics *m_pGraphics;
ISound *m_pSound;
ITextRender *m_pTextRender;
IStorage *m_pStorage;
CUI *m_pUI;
CRenderTools *m_pRenderTools;
CEditor *m_pEditor;
IInput *m_pInput;
IClient *m_pClient;
CConfig *m_pConfig;
IConsole *m_pConsole;
IEngine *m_pEngine;
IGraphics *m_pGraphics;
ISound *m_pSound;
ITextRender *m_pTextRender;
IStorage *m_pStorage;
CUI *m_pUI;
CRenderTools *m_pRenderTools;
};
#endif

View file

@ -18,7 +18,6 @@
#include <engine/shared/jobs.h>
#include "auto_map.h"
#include "game/client/component.h"
#include "map_view.h"
#include "smooth_value.h"

View file

@ -2,8 +2,8 @@
#include <engine/shared/config.h>
#include <game/client/ui.h>
#include <game/client/render.h>
#include <game/client/ui.h>
void CMapView::Init(CEditor *pEditor)
{
@ -13,13 +13,13 @@ void CMapView::Init(CEditor *pEditor)
void CMapView::ResetZoom()
{
m_EditorOffset = vec2(0, 0);
m_Zoom.SetValue(100.0f);
m_EditorOffset = vec2(0, 0);
m_Zoom.SetValue(100.0f);
}
float CMapView::ScaleLength(float Value)
{
return m_Zoom.GetValue() * Value;
return m_Zoom.GetValue() * Value;
}
void CMapView::ZoomMouseTarget(float ZoomFactor)
@ -38,7 +38,7 @@ void CMapView::ZoomMouseTarget(float ZoomFactor)
float Mwy = aPoints[1] + WorldHeight * (UI()->MouseY() / UI()->Screen()->h);
// adjust camera
m_WorldOffset += (vec2(Mwx, Mwy) - m_WorldOffset) * (1.0f - ZoomFactor);
m_WorldOffset += (vec2(Mwx, Mwy) - m_WorldOffset) * (1.0f - ZoomFactor);
}
void CMapView::UpdateZoom()

View file

@ -3,31 +3,31 @@
#include <base/vmath.h>
#include "smooth_value.h"
#include "component.h"
#include "smooth_value.h"
class CMapView : public CEditorComponent
{
public:
void Init(CEditor *pEditor) override;
void Init(CEditor *pEditor) override;
/**
* Reset zoom and editor offset.
*/
void ResetZoom();
/**
* Reset zoom and editor offset.
*/
void ResetZoom();
/**
* Scale length according to zoom value.
*/
float ScaleLength(float Value);
/**
* Scale length according to zoom value.
*/
float ScaleLength(float Value);
void ZoomMouseTarget(float ZoomFactor);
void UpdateZoom();
void ZoomMouseTarget(float ZoomFactor);
void UpdateZoom();
vec2 m_WorldOffset;
vec2 m_EditorOffset;
vec2 m_WorldOffset;
vec2 m_EditorOffset;
CSmoothValue m_Zoom = CSmoothValue(200.0f, 10.0f, 2000.0f);
CSmoothValue m_Zoom = CSmoothValue(200.0f, 10.0f, 2000.0f);
float m_WorldZoom = 1.0f;
};

View file

@ -1,7 +1,7 @@
#include "smooth_value.h"
#include <engine/shared/config.h>
#include <engine/client.h>
#include <engine/shared/config.h>
CSmoothValue::CSmoothValue(float InitialValue, float MinValue, float MaxValue) :
m_Smoothing(false), m_Value(InitialValue), m_MinValue(MinValue), m_MaxValue(MaxValue) {}