diff --git a/CMakeLists.txt b/CMakeLists.txt index 4679d8d..0202af2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,7 +126,7 @@ add_subdirectory(src/run_modes/tester) add_subdirectory(src/run_modes/editor) # add run mode editor -add_subdirectory(src/run_modes/player) +add_subdirectory(src/run_modes/game) target_include_directories(${PROJECT_NAME} PUBLIC "${PROJECT_BINARY_DIR}" diff --git a/docs/core.todo b/docs/core.todo index 12ae98d..d4b71f8 100644 --- a/docs/core.todo +++ b/docs/core.todo @@ -4,6 +4,7 @@ Build System: ✔ Modify .sh scripts to recognize the noeditor flag @done (1/25/2022, 3:59:23 PM) Core: + ☐ For scripting switch to Wren instead of LUA @high ☐ Add log settings to the state file ✔ Add run modes (Editor, Game, Test) to state file @done (9/15/2021, 7:27:03 PM) ✔ Add run mode interface class @done (9/15/2021, 8:22:35 PM) @@ -40,7 +41,7 @@ Core: ✔ Sort items by type (Directories should come first) @done (11/8/2021, 6:26:01 PM) ✔ Allow the user to type in a filename @done (11/9/2021, 3:26:16 PM) ✔ Add a "New Directory" button @done (11/8/2021, 7:15:51 PM) - ☐ Selected files should show up in the text box + ✔ Selected files should show up in the text box @done(22-04-18 13:33) Input: ✔ Port over the Element2D input system and adjust it to use glfw @done (9/8/2021, 8:20:07 PM) diff --git a/docs/editor.todo b/docs/editor.todo index a4de88f..8a53481 100644 --- a/docs/editor.todo +++ b/docs/editor.todo @@ -55,6 +55,7 @@ Editor: ☐ Flood Fill ✔ Zoom ability @high @done (3/14/2022, 3:38:27 PM) ✔ Middle mouse button scrolling @done (3/14/2022, 3:38:43 PM) + ☐ Add arrow images to the move region buttons @low Tile Set Viewer: diff --git a/src/internal_libs/gui/file_browser.cpp b/src/internal_libs/gui/file_browser.cpp index 6ae759e..5b67f54 100644 --- a/src/internal_libs/gui/file_browser.cpp +++ b/src/internal_libs/gui/file_browser.cpp @@ -102,7 +102,8 @@ namespace lunarium if (ImGui::InputText("selection", mInputBuffer, mBufferSize)) { - mInputSelection = mCurrentDirectory / mInputBuffer; + // mInputSelection = mCurrentDirectory / mInputBuffer; + mInputSelection = mInputBuffer; mpSelectedItem = &mInputSelection; } @@ -216,7 +217,7 @@ namespace lunarium { mpSelectedItem = &mItemsInDir[i]; memset(mInputBuffer, 0, mBufferSize); - memcpy(mInputBuffer, mpSelectedItem->string().c_str(), mpSelectedItem->string().size()); + memcpy(mInputBuffer, mpSelectedItem->filename().string().c_str(), mpSelectedItem->filename().string().size()); } } } diff --git a/src/run_modes/editor/panels/worldTree.cpp b/src/run_modes/editor/panels/worldTree.cpp index 4ead478..796c7f4 100644 --- a/src/run_modes/editor/panels/worldTree.cpp +++ b/src/run_modes/editor/panels/worldTree.cpp @@ -7,7 +7,7 @@ ******************************************************************************/ #include "worldTree.h" -#include +#include #include #include diff --git a/src/run_modes/editor/panels/worldTree.h b/src/run_modes/editor/panels/worldTree.h index 6d837a0..f7e972c 100644 --- a/src/run_modes/editor/panels/worldTree.h +++ b/src/run_modes/editor/panels/worldTree.h @@ -13,7 +13,7 @@ namespace lunarium { - namespace game { class World; } + namespace game { class World; } // TODO: Use the editor::World class instead? namespace editor { diff --git a/src/run_modes/editor/panels/worldView.cpp b/src/run_modes/editor/panels/worldView.cpp index 59e9587..324c225 100644 --- a/src/run_modes/editor/panels/worldView.cpp +++ b/src/run_modes/editor/panels/worldView.cpp @@ -8,7 +8,7 @@ #include "worldView.h" #include -#include +#include #include #include #include "../panel_manager.h" diff --git a/src/run_modes/editor/panels/worldView.h b/src/run_modes/editor/panels/worldView.h index 2f6dc76..e1b0534 100644 --- a/src/run_modes/editor/panels/worldView.h +++ b/src/run_modes/editor/panels/worldView.h @@ -14,7 +14,8 @@ namespace lunarium { - class World; + class World; // TODO: Use the editor::World class instead? + namespace editor { class Editor; diff --git a/src/run_modes/editor/tools/map_editor/panels/map_canvas.cpp b/src/run_modes/editor/tools/map_editor/panels/map_canvas.cpp index 49e608d..871fe7e 100644 --- a/src/run_modes/editor/tools/map_editor/panels/map_canvas.cpp +++ b/src/run_modes/editor/tools/map_editor/panels/map_canvas.cpp @@ -23,8 +23,11 @@ namespace lunarium { namespace editor MapCanvas::MapCanvas(MapEditor* editor) : Panel("Map Canvas", gui::PanelDockZone::DDZ_CENTER, true), mpMapEditor(editor), mpCanvasImage(nullptr), mMap(nullptr), mSelectedTile({-1, -1}), mFrameBuffer(-1), mMapSizeChanged(false), - mZoomFactor(1.0f), mScrollDragged(false) + mZoomFactor(1.0f), mScrollDragged(false), mCurrentRegion({0, 0}), mRegionString("") { + mRegionString = std::to_string(mCurrentRegion.X); + mRegionString += ","; + mRegionString += std::to_string(mCurrentRegion.Y); } void MapCanvas::Update(float delta) @@ -146,14 +149,12 @@ namespace lunarium { namespace editor ImVec2 pos = ImGui::GetWindowPos(); ImVec2 size = ImGui::GetWindowSize(); - // tool bar float child_height = ImGui::GetFrameHeight() * 2; ImGui::BeginChild("Map Tool Bar", ImVec2(ImGui::GetWindowSize().x, child_height), true); - ImGui::Text("Zoom: "); - ImGui::SameLine(); - ImGui::PushItemWidth(100.0f); - ImGui::InputFloat("", &mZoomFactor, 0.05f, 0.1f, "%.2f"); - ImGui::PopItemWidth(); + + // tool bar + DoToolBar(); + ImGui::EndChild(); ImGui::BeginChild("Map Canvas", ImVec2(ImGui::GetWindowSize().x, ImGui::GetWindowSize().y - child_height), true); @@ -220,5 +221,87 @@ namespace lunarium { namespace editor mMapSizeChanged = true; mpCanvasImage = nullptr; } + + //////////////////////////////////////////////////////////// + // RENDER HELPERS + //////////////////////////////////////////////////////////// + void MapCanvas::DoToolBar() + { + if (ImGui::BeginTable("tool bar", 2, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingFixedFit)) + { + ImGui::AlignTextToFramePadding(); + ImGui::TableNextColumn(); + ImGui::Text("Zoom: "); + ImGui::SameLine(); + ImGui::PushItemWidth(100.0f); + ImGui::InputFloat("##zoom_factor", &mZoomFactor, 0.05f, 0.1f, "%.2f"); + ImGui::PopItemWidth(); + + // Region Selecting + ImGui::TableNextColumn(); + ImGui::Text("Regions: "); + ImGui::SameLine(); + if (ImGui::Button("<=")) + { + // TODO: Move to the next region to the left + } + + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("Move to the west"); + + ImGui::SameLine(); + if (ImGui::Button("^")) + { + // TODO: Move to the next region to the north + } + + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("Move to the north"); + + + ImGui::SameLine(); + if (ImGui::Button("V")) + { + // TODO: Move to the next region to the south + } + + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("Move to the south"); + + ImGui::SameLine(); + if (ImGui::Button("=>")) + { + // TODO: Move to the next region to the right + } + + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("Move to the east"); + + ImGui::SameLine(); + ImGui::Text("Current: "); + ImGui::SameLine(); + ImGui::PushItemWidth(50.0f); + if (ImGui::InputText("##current_region", mRegionString.data(), mRegionString.size() + 1, ImGuiInputTextFlags_EnterReturnsTrue) + && mRegionString.size() > 2) + { + int x = -1, y = -1; + if (std::isdigit(mRegionString[0])) + { + x = std::atoi(&mRegionString[0]); + + if (std::isdigit(mRegionString[2])) + { + mCurrentRegion.X = x; + mCurrentRegion.Y = std::atoi(&mRegionString[2]); + } + } + } + ImGui::PopItemWidth(); + + // ImGui::TableNextColumn(); + // ImGui::Text("Status Bar"); + ImGui::EndTable(); + } + } }} \ No newline at end of file diff --git a/src/run_modes/editor/tools/map_editor/panels/map_canvas.h b/src/run_modes/editor/tools/map_editor/panels/map_canvas.h index dc1b5a1..3a5873b 100644 --- a/src/run_modes/editor/tools/map_editor/panels/map_canvas.h +++ b/src/run_modes/editor/tools/map_editor/panels/map_canvas.h @@ -46,11 +46,17 @@ namespace lunarium { namespace editor std::string mMouseStatusInfo; int mFrameBuffer; Image* mpCanvasImage; - TileMap* mMap; + TileMap* mMap; // TODO: Replace with a World TileRef mSelectedTile; bool mMapSizeChanged; - private: + // TESTING + Vec2i mCurrentRegion; + std::string mRegionString; + + + private: // HELPERS + void DoToolBar(); }; }} diff --git a/src/run_modes/player/CMakeLists.txt b/src/run_modes/game/CMakeLists.txt similarity index 100% rename from src/run_modes/player/CMakeLists.txt rename to src/run_modes/game/CMakeLists.txt diff --git a/src/run_modes/player/object/object.h b/src/run_modes/game/object/object.h similarity index 100% rename from src/run_modes/player/object/object.h rename to src/run_modes/game/object/object.h diff --git a/src/run_modes/player/world/world.cpp b/src/run_modes/game/world/world.cpp similarity index 100% rename from src/run_modes/player/world/world.cpp rename to src/run_modes/game/world/world.cpp diff --git a/src/run_modes/player/world/world.h b/src/run_modes/game/world/world.h similarity index 98% rename from src/run_modes/player/world/world.h rename to src/run_modes/game/world/world.h index 5a208bb..cb58d88 100644 --- a/src/run_modes/player/world/world.h +++ b/src/run_modes/game/world/world.h @@ -39,6 +39,7 @@ namespace lunarium { namespace game Vec2i mCoords; std::vector mObjects; std::vector mLayers; + // Colliders }; public: // INTERFACE diff --git a/test2/contents/content_meta.xml b/test2/contents/content_meta.xml new file mode 100644 index 0000000..d114216 --- /dev/null +++ b/test2/contents/content_meta.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/test2/test2.lproj b/test2/test2.lproj new file mode 100644 index 0000000..2364404 --- /dev/null +++ b/test2/test2.lproj @@ -0,0 +1,2 @@ + +