Skip to content

Commit

Permalink
StageDataの登場順にソートする機能を実装
Browse files Browse the repository at this point in the history
  • Loading branch information
YutaTachibana0310 committed Jul 12, 2019
1 parent c329387 commit 59c2d07
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion BaseEditWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ BaseEditWindow::~BaseEditWindow()
void BaseEditWindow::Draw()
{
DebugTreeExpansion(true);
if (DebugTreePush(to_string(id).c_str()))
if (DebugTreePush((string("id") + to_string(id)).c_str()))
{
string windowName = to_string(id);

Expand Down
3 changes: 2 additions & 1 deletion BaseEditWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ class BaseEditWindow
void Draw();
picojson::value Serialize();

private:
int id;
int frame;
std::string type;

private:

std::map<std::string, DataEditWindow*> dataWindow;

void CreateEditWindow();
Expand Down
1 change: 1 addition & 0 deletions EditorScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void EditorScene::Uninit()
void EditorScene::Update(HWND hWnd)
{
bg->Update();
editor->Update();
}

/**************************************
Expand Down
28 changes: 16 additions & 12 deletions StageEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
//=====================================
#include "StageEditor.h"
#include "debugWindow.h"

#include <fstream>
#include <algorithm>

/**************************************
マクロ定義
Expand All @@ -25,8 +27,8 @@
***************************************/
StageEditor::StageEditor()
{
windowContainer.resize(5);
for (auto& window : windowContainer)
windowList.resize(5);
for (auto& window : windowList)
{
window = new BaseEditWindow();
}
Expand All @@ -37,11 +39,11 @@ StageEditor::StageEditor()
***************************************/
StageEditor::~StageEditor()
{
for (auto& window : windowContainer)
for (auto& window : windowList)
{
SAFE_DELETE(window)
}
windowContainer.clear();
windowList.clear();
}

/**************************************
Expand All @@ -65,7 +67,10 @@ void StageEditor::Uninit()
***************************************/
void StageEditor::Update()
{

windowList.sort([](BaseEditWindow* a, BaseEditWindow *b)
{
return a->frame < b->frame;
});
}

/**************************************
Expand Down Expand Up @@ -94,7 +99,7 @@ void StageEditor::Draw()
EndMenuBar();
}

for (auto& window : windowContainer)
for (auto& window : windowList)
{
window->Draw();
}
Expand All @@ -109,7 +114,7 @@ void StageEditor::Save()
picojson::object stageData;
picojson::array dataList;

for (auto& node : windowContainer)
for (auto& node : windowList)
{
dataList.push_back(node->Serialize());
}
Expand All @@ -128,11 +133,11 @@ void StageEditor::Save()
***************************************/
void StageEditor::Load()
{
for (auto& node : windowContainer)
for (auto& node : windowList)
{
SAFE_DELETE(node);
}
windowContainer.clear();
windowList.clear();

std::ifstream ifs;
ifs.open("data/JSON/test.json", std::ios::binary);
Expand All @@ -142,8 +147,7 @@ void StageEditor::Load()
ifs.close();

picojson::array& stageData = val.get<picojson::object>()["StageData"].get<picojson::array>();
windowContainer.resize(stageData.size());
for (int i = 0; i < stageData.size(); i++)
for (UINT i = 0; i < stageData.size(); i++)
{
picojson::object data = stageData[i].get<picojson::object>();

Expand All @@ -152,6 +156,6 @@ void StageEditor::Load()
std::string type = data["type"].get<std::string>();
picojson::object obj = data["data"].get<picojson::object>();

windowContainer[i] = new BaseEditWindow(id, frame, type, obj);
windowList.push_back(new BaseEditWindow(id, frame, type, obj));
}
}
4 changes: 2 additions & 2 deletions StageEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define _STAGEEDITOR_H_

#include "main.h"
#include <vector>
#include <list>
#include "BaseEditWindow.h"

/**************************************
Expand All @@ -33,7 +33,7 @@ class StageEditor
void Load();

private:
std::vector<BaseEditWindow*> windowContainer;
std::list<BaseEditWindow*> windowList;

};

Expand Down

0 comments on commit 59c2d07

Please sign in to comment.