Skip to content

Commit b04a4d2

Browse files
committed
Editor: Created the Open File Modal
1 parent 94de465 commit b04a4d2

File tree

4 files changed

+49
-7
lines changed

4 files changed

+49
-7
lines changed

src/private/Core/Core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void Core::Init() {
2727

2828
this->m_mono = MonoScript::GetInstance();
2929
this->m_mono->Init();
30-
this->m_discord->Init();
30+
// this->m_discord->Init();
3131
}
3232

3333
void Core::SetHWND(HWND& hwnd) {

src/private/Core/Editor/Editor.cpp

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Editor::Editor() {
1414
this->m_bScale = false;
1515
this->m_guizmoOp = ImGuizmo::OPERATION::TRANSLATE;
1616
this->m_console = nullptr;
17+
this->m_bPlaying = false;
1718
}
1819

1920
void Editor::Init(UINT nWidth, UINT nHeight) {
@@ -121,6 +122,9 @@ void Editor::Init(UINT nWidth, UINT nHeight) {
121122

122123
this->m_nWidth = nWidth;
123124
this->m_nHeight = nHeight;
125+
126+
ThrowIfFailed(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED |
127+
COINIT_DISABLE_OLE1DDE));
124128
}
125129

126130
void Editor::Update() {
@@ -129,6 +133,30 @@ void Editor::Update() {
129133
if (ImGui::MenuItem("Create")) {
130134
}
131135
if (ImGui::MenuItem("Open", "Ctrl+O")) {
136+
IFileOpenDialog* pFileOpen;
137+
138+
ThrowIfFailed(CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL,
139+
IID_IFileOpenDialog, reinterpret_cast<void**>(&pFileOpen)));
140+
141+
COMDLG_FILTERSPEC fileTypes[] =
142+
{
143+
{ L"Exeon Project (*.exproj)", L"*.exproj" }
144+
};
145+
ThrowIfFailed(pFileOpen->SetFileTypes(1, fileTypes));
146+
ThrowIfFailed(pFileOpen->SetFileTypeIndex(1));
147+
148+
149+
if (SUCCEEDED(pFileOpen->Show(nullptr))) {
150+
IShellItem* pItem;
151+
if (SUCCEEDED(pFileOpen->GetResult(&pItem))) {
152+
PWSTR pszPath;
153+
if (SUCCEEDED(pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszPath))) {
154+
// TODO: Make it open the project
155+
}
156+
157+
}
158+
}
159+
CoUninitialize();
132160
}
133161
if (ImGui::MenuItem("Save", "Ctrl+S")) {
134162
}
@@ -144,11 +172,22 @@ void Editor::Update() {
144172
}
145173
float windowWidth = ImGui::GetWindowSize().x;
146174

147-
const char* playIcon = ICON_FA_PLAY;
148-
float textWidth = ImGui::CalcTextSize(playIcon).x;
149175

150-
ImGui::SetCursorPosX((windowWidth - textWidth) * 0.5f);
151-
ImGui::Button(playIcon, ImVec2{25.f, 25.f});
176+
if (!this->m_bPlaying) {
177+
const char* playIcon = ICON_FA_PLAY;
178+
float textWidth = ImGui::CalcTextSize(playIcon).x;
179+
ImGui::SetCursorPosX((windowWidth - textWidth) * 0.5f);
180+
if (ImGui::Button(playIcon, ImVec2{25.f, 25.f})) {
181+
this->m_bPlaying = !this->m_bPlaying;
182+
}
183+
} else {
184+
const char* playIcon = ICON_FA_PAUSE;
185+
float textWidth = ImGui::CalcTextSize(playIcon).x;
186+
ImGui::SetCursorPosX((windowWidth - textWidth) * 0.5f);
187+
if (ImGui::Button(playIcon, ImVec2{25.f, 25.f})) {
188+
this->m_bPlaying = !this->m_bPlaying;
189+
}
190+
}
152191
ImGui::EndMainMenuBar();
153192

154193
if (this->m_sceneMgr) {

src/private/Core/Renderer/D3D12.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ void D3D12::Update() {
317317
ImGuizmo::SetDrawlist(ImGui::GetBackgroundDrawList());
318318
ImGuizmo::SetRect(0, 0, this->m_nWidth, this->m_nHeight);
319319

320-
// Establecer el área donde se dibujará el guizmo en la ventana
321320
ImGuizmo::SetRect(0.0f, 0.0f, static_cast<float>(this->m_nWidth), static_cast<float>(this->m_nHeight));
322321

323322

@@ -378,7 +377,6 @@ void D3D12::ResourceBarrier(ComPtr<ID3D12Resource> resource, D3D12_RESOURCE_STAT
378377

379378
D3D12_RESOURCE_STATES currentState = m_resourceStates[resource.Get()];
380379

381-
// Si el estado conocido no es el declarado, usa el conocido
382380
if (currentState != oldState && currentState != D3D12_RESOURCE_STATE_COMMON)
383381
oldState = currentState;
384382

src/public/Core/Editor/Editor.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "Console.h"
99
#include "Util.h"
1010
#include <IconsFontAwesome5.h>
11+
#include <shobjidl.h>
12+
1113

1214
class Editor {
1315
private:
@@ -26,6 +28,9 @@ class Editor {
2628
bool m_bLocation;
2729
bool m_bRotation;
2830
bool m_bScale;
31+
32+
bool m_bPlaying;
33+
2934
ImGuizmo::OPERATION m_guizmoOp;
3035
public:
3136
Editor();

0 commit comments

Comments
 (0)