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

Remove old DialogBase as everything is in modern format now #16

Merged
merged 1 commit into from
Jul 20, 2024
Merged
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
148 changes: 0 additions & 148 deletions src/lib-editor/include/Dialogs/DialogBase.hpp

This file was deleted.

51 changes: 51 additions & 0 deletions src/lib-editor/include/Dialogs/DialogInterface.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#pragma once

#include "Gui.hpp"
#include <Error.hpp>
#include <Memory.hpp>
#include <TGUI/Backend/SFML-Graphics.hpp>
#include <TGUI/Tgui.hpp>
#include <expected>
#include <functional>
#include <string>

class DialogInterface
{
public:
DialogInterface(
mem::Rc<Gui> gui,
const std::string& dialogId,
const std::string& dialogTitle);
~DialogInterface() = default;

public:
void open(std::function<void()> confirmCallback);

void close()
{
gui->closeModal(DIALOG_ID);
}

[[nodiscard]] bool isOpen() const
{
return gui->get<tgui::ChildWindow>(DIALOG_ID) != nullptr;
}

protected:
void buildLayout(std::function<void()> confirmCallback);
void buildBottomButtons(
tgui::ChildWindow::Ptr modal, std::function<void()> confirmCallback);

virtual std::expected<ReturnFlag, ErrorMessage>
validateBeforeConfirmation() const
{
return ReturnFlag::Success;
};

virtual void buildLayoutImpl(tgui::Panel::Ptr target) = 0;

protected:
mem::Rc<Gui> gui;
const std::string DIALOG_ID;
const std::string DIALOG_TITLE;
};
4 changes: 2 additions & 2 deletions src/lib-editor/include/Dialogs/EditMetadataDialog.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma once

#include "DialogBase.hpp"
#include "DialogInterface.hpp"
#include "FormBuilder.hpp"
#include "MetadataDialogBase.hpp"
#include <DGM/dgm.hpp>
#include <LevelMetadata.hpp>
#include <Memory.hpp>

class [[nodiscard]] EditMetadataDialog final
: protected ModernDialogInterface
: protected DialogInterface
, public MetadataDialogBase
{
public:
Expand Down
4 changes: 2 additions & 2 deletions src/lib-editor/include/Dialogs/EditPropertyDialog.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include "Dialogs/DialogInterface.hpp"
#include "Gui.hpp"
#include "Interfaces/DialogInterfaces.hpp"
#include "Interfaces/ToolPropertyInterface.hpp"
#include <Memory.hpp>

class [[nodiscard]] EditPropertyDialog final : public ModernDialogInterface
class [[nodiscard]] EditPropertyDialog final : public DialogInterface
{
public:
EditPropertyDialog(
Expand Down
4 changes: 2 additions & 2 deletions src/lib-editor/include/Dialogs/LoadLevelDialog.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include <Dialogs/DialogBase.hpp>
#include <Dialogs/DialogInterface.hpp>
#include <filesystem>

class [[nodiscard]] LoadLevelDialog final : public ModernDialogInterface
class [[nodiscard]] LoadLevelDialog final : public DialogInterface
{
public:
LoadLevelDialog(mem::Rc<Gui> gui, const std::filesystem::path& rootDir);
Expand Down
4 changes: 2 additions & 2 deletions src/lib-editor/include/Dialogs/MapPickerDialog.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <Dialogs/DialogBase.hpp>
#include <Dialogs/DialogInterface.hpp>
#include <vector>

struct MapSettingsForPicker
Expand All @@ -9,7 +9,7 @@ struct MapSettingsForPicker
bool enabled;
};

class MapPickerDialog : public ModernDialogInterface
class MapPickerDialog : public DialogInterface
{
public:
MapPickerDialog(
Expand Down
4 changes: 2 additions & 2 deletions src/lib-editor/include/Dialogs/NewLevelDialog.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma once

#include "DialogBase.hpp"
#include "DialogInterface.hpp"
#include "MetadataDialogBase.hpp"
#include <LevelTheme.hpp>
#include <Memory.hpp>
#include <string>
#include <vector>

class [[nodiscard]] ModernNewLevelDialog final
: public ModernDialogInterface
: public DialogInterface
, public MetadataDialogBase
{
public:
Expand Down
21 changes: 0 additions & 21 deletions src/lib-editor/include/Dialogs/ResizeLevelDialog.hpp

This file was deleted.

4 changes: 2 additions & 2 deletions src/lib-editor/include/Dialogs/SaveLevelDialog.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include "Dialogs/DialogBase.hpp"
#include "Dialogs/DialogInterface.hpp"
#include <filesystem>

class [[nodiscard]] NewSaveLevelDialog final : public ModernDialogInterface
class [[nodiscard]] NewSaveLevelDialog final : public DialogInterface
{
public:
NewSaveLevelDialog(
Expand Down
4 changes: 0 additions & 4 deletions src/lib-editor/include/Editor/Editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "Commands/CommandQueue.hpp"
#include "Dialogs/EditMetadataDialog.hpp"
#include "Dialogs/EditPropertyDialog.hpp"
#include "Dialogs/ResizeLevelDialog.hpp"
#include "Editor/EditorState.hpp"
#include "Editor/EditorStateManager.hpp"
#include "Globals.hpp"
Expand Down Expand Up @@ -45,8 +44,6 @@ class [[nodiscard]] Editor final : public EditorInterface

[[nodiscard]] virtual LevelD save() override;

virtual void resizeDialog() override;

virtual void resize(
unsigned width, unsigned height, bool isTranslationDisabled) override;

Expand Down Expand Up @@ -118,7 +115,6 @@ class [[nodiscard]] Editor final : public EditorInterface
mem::Rc<LevelMetadata> levelMetadata;
std::filesystem::path graphicsDir;

ResizeDialog dialog = ResizeDialog(gui);
mem::Box<EditPropertyDialog> editPropertyDialog =
mem::Box<EditPropertyDialog>(gui, mem::Box<NullToolProperty2>());
EditMetadataDialog editMetadataDialog = EditMetadataDialog(gui);
Expand Down
2 changes: 0 additions & 2 deletions src/lib-editor/include/Editor/NullEditor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class NullEditor final : public EditorInterface

void switchTool(EditorState) override {}

void resizeDialog() override {}

void resize(unsigned, unsigned, bool) override {}

void shrinkToFit() override {}
Expand Down
23 changes: 0 additions & 23 deletions src/lib-editor/include/Interfaces/DialogInterfaces.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include "Dialogs/DialogBase.hpp"
#include <Memory.hpp>
#include <filesystem>
#include <functional>
Expand Down Expand Up @@ -32,25 +31,3 @@ class ErrorInfoDialogInterface
public:
virtual void open(const std::string& text) = 0;
};

class PlaytestSettingsDialogInterface : public DialogInterface
{
public:
PlaytestSettingsDialogInterface(
mem::Rc<Gui> gui,
const std::string& id,
const std::string& title,
const std::vector<OptionLine>& options)
: DialogInterface(gui, id, title, options)
{
}

virtual ~PlaytestSettingsDialogInterface() = default;

public:
[[nodiscard]] virtual std::filesystem::path getBinaryPath() const = 0;

[[nodiscard]] virtual std::string getLaunchParameters() const = 0;

[[nodiscard]] virtual std::filesystem::path getWorkingDirPath() const = 0;
};
2 changes: 0 additions & 2 deletions src/lib-editor/include/Interfaces/EditorInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class EditorInterface

virtual void switchTool(EditorState state) = 0;

virtual void resizeDialog() = 0;

virtual void
resize(unsigned width, unsigned height, bool isTranslationDisabled) = 0;

Expand Down
Loading
Loading