Skip to content

Commit

Permalink
Merge pull request ddnet#7014 from Marmare314/mapview
Browse files Browse the repository at this point in the history
Add CEditorComponent to moduralize editor
  • Loading branch information
edg-l authored Aug 14, 2023
2 parents a66aac1 + 77e36c5 commit 21d3584
Show file tree
Hide file tree
Showing 12 changed files with 439 additions and 301 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2306,6 +2306,8 @@ if(CLIENT)
set_src(GAME_EDITOR GLOB src/game/editor
auto_map.cpp
auto_map.h
component.cpp
component.h
editor.cpp
editor.h
explanations.cpp
Expand All @@ -2314,7 +2316,11 @@ if(CLIENT)
layer_quads.cpp
layer_sounds.cpp
layer_tiles.cpp
map_view.cpp
map_view.h
popups.cpp
smooth_value.cpp
smooth_value.h
)
set(GAME_GENERATED_CLIENT
src/game/generated/checksum.cpp
Expand Down
41 changes: 41 additions & 0 deletions src/game/editor/component.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "component.h"

#include "editor.h"

void CEditorComponent::Init(CEditor *pEditor)
{
m_pEditor = pEditor;
m_pInput = pEditor->Input();
m_pClient = pEditor->Client();
m_pConfig = pEditor->Config();
m_pConsole = pEditor->Console();
m_pEngine = pEditor->Engine();
m_pGraphics = pEditor->Graphics();
m_pSound = pEditor->Sound();
m_pTextRender = pEditor->TextRender();
m_pStorage = pEditor->Storage();
m_pUI = pEditor->UI();
m_pRenderTools = pEditor->RenderTools();
}

void CEditorComponent::OnUpdate(CUIRect View)
{
OnInput();
OnRender(View);
}

void CEditorComponent::OnInput() {}
void CEditorComponent::OnRender(CUIRect View) {}

CEditor *CEditorComponent::Editor() { return m_pEditor; }
IInput *CEditorComponent::Input() { return m_pInput; }
IClient *CEditorComponent::Client() { return m_pClient; }
CConfig *CEditorComponent::Config() { return m_pConfig; }
IConsole *CEditorComponent::Console() { return m_pConsole; }
IEngine *CEditorComponent::Engine() { return m_pEngine; }
IGraphics *CEditorComponent::Graphics() { return m_pGraphics; }
ISound *CEditorComponent::Sound() { return m_pSound; }
ITextRender *CEditorComponent::TextRender() { return m_pTextRender; }
IStorage *CEditorComponent::Storage() { return m_pStorage; }
CUI *CEditorComponent::UI() { return m_pUI; }
CRenderTools *CEditorComponent::RenderTools() { return m_pRenderTools; }
57 changes: 57 additions & 0 deletions src/game/editor/component.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#ifndef GAME_EDITOR_COMPONENT_H
#define GAME_EDITOR_COMPONENT_H

#include <game/client/ui.h>

class CEditor;
class IInput;
class IClient;
class CConfig;
class IConsole;
class IEngine;
class IGraphics;
class ISound;
class ITextRender;
class IStorage;
class CRenderTools;

class CEditorComponent
{
public:
virtual ~CEditorComponent() = default;

virtual void Init(CEditor *pEditor);

void OnUpdate(CUIRect View);
virtual void OnInput();
virtual void OnRender(CUIRect View);

CEditor *Editor();
IInput *Input();
IClient *Client();
CConfig *Config();
IConsole *Console();
IEngine *Engine();
IGraphics *Graphics();
ISound *Sound();
ITextRender *TextRender();
IStorage *Storage();
CUI *UI();
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;
};

#endif
Loading

0 comments on commit 21d3584

Please sign in to comment.