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

ImGuiFileDialog to replace portable-file-dialogs #420

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- name: Install Deps
run: sudo apt-get update -qq &&
sudo apt-get install -y libsdl2-dev libsdl2-image-dev libglew-dev
sudo apt-get install -y libsdl2-dev libsdl2-image-dev

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
Expand Down
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ project(TheForceEngine
DESCRIPTION "Modern 'Jedi Engine' replacement supporting Dark Forces, mods, and in the future Outlaws."
)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down Expand Up @@ -61,15 +61,10 @@ if(ENABLE_TFE)
find_package(Threads REQUIRED)
find_package(SDL2 2.0.20 REQUIRED)
pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image)
pkg_check_modules(GLEW REQUIRED glew)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
target_include_directories(tfe PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(tfe PRIVATE ${SDL2_INCLUDE_DIRS})
target_include_directories(tfe PRIVATE ${SDL2_IMAGE_INCLUDE_DIRS})
target_link_libraries(tfe PRIVATE
${OPENGL_LIBRARIES}
${GLEW_LIBRARIES}
${SDL2_LIBRARIES}
${SDL2_IMAGE_LIBRARIES}
)
Expand Down
2 changes: 1 addition & 1 deletion ProjectStructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Program entry point, manages initialization and OS main loop.
Support data includes:
* Documentation
* Fonts
* Libraries / GLEW
* Libraries
* SDL 2
* Shaders
* SoundFonts (later)
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ This can be overridden by defining the `TFE_DATA_HOME` environment variable.
### Required Libraries
* [SDL2](http://libsdl.org) Version 2.24
* [SDL2-image](https://github.com/libsdl-org/SDL_image) Version 2.6.3
* [GLEW](http://glew.sourceforge.net/) 2.2.0
* OpenGL 3.3 capable driver (latest [Mesa 3D](https://www.mesa3d.org) or Nvidia proprietary driver recommended)
* [RtMidi](https://www.music.mcgill.ca/~gary/rtmidi/) 5.0.0 or higher for external MIDI synthesizer support

Expand Down Expand Up @@ -88,8 +87,6 @@ This can be overridden by defining the `TFE_DATA_HOME` environment variable.

#### Running TFE
##### External application dependencies
* “[KDialog](https://develop.kde.org/docs/administration/kdialog "Shell scripting with KDE dialogs")” for file dialog on KDE Plasma Desktop Environment.
* “zenity” for file dialog on all other desktop environments.
* external MIDI is no longer required but still supported through the “System MIDI” device.

##### Launch
Expand Down
12 changes: 6 additions & 6 deletions TheForceEngine/Documentation/markdown/Credits.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ SDL 2.0.x
* [https://www.libsdl.org/](https://www.libsdl.org/)
* License: ZLIB

GLEW
* [https://github.com/nigels-com/glew](https://github.com/nigels-com/glew)
* License: Modified BSD license
GLAD
* [https://gen.glad.sh](https://gen.glad.sh)
* License: MIT

**UI**
imGUI
Expand All @@ -81,9 +81,9 @@ imGUI Markdown
* [https://github.com/juliettef/imgui_markdown](https://github.com/juliettef/imgui_markdown)
* License: ZLIB

Portable File Dialogs
* [https://github.com/samhocevar/portable-file-dialogs](https://github.com/samhocevar/portable-file-dialogs)
* License: [WTFPL](https://github.com/samhocevar/portable-file-dialogs/blob/master/COPYING)
ImGuiFileDialog
* [https://github.com/aiekick/ImGuiFileDialog](https://github.com/aiekick/ImGuiFileDialog)
* License: MIT

Clipper
* [http://www.angusj.com/delphi/clipper.php](http://www.angusj.com/delphi/clipper.php)
Expand Down
6 changes: 2 additions & 4 deletions TheForceEngine/TFE_A11y/accessibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include <TFE_System/parser.h>
#include <TFE_System/system.h>
#include <TFE_Ui/imGUI/imgui.h>
#include <TFE_Ui/imGUI/imgui_impl_sdl.h>
#include <TFE_Ui/imGUI/imgui_impl_opengl3.h>
#include <TFE_Ui/ui.h>

using namespace std::chrono;
Expand Down Expand Up @@ -184,7 +182,7 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
// Try to load the previously selected font.
string lastFontPath = TFE_Settings::getA11ySettings()->lastFontPath;

if (lastFontPath, ImGui::GetIO().Fonts->Locked) { setPendingFont(lastFontPath); }
if (!lastFontPath.empty() && ImGui::GetIO().Fonts->Locked) { setPendingFont(lastFontPath); }
else { tryLoadFont(lastFontPath, false); }
}

Expand Down Expand Up @@ -243,7 +241,7 @@ namespace TFE_A11Y // a11y is industry slang for accessibility
s_fontMap[path] = s_currentCaptionFont;
// If we're loading a new font after the game first initializes, we'll need to clear the
// ImGui font atlas so that it is automatically regenerated at the start of the next frame.
if (clearAtlas) { ImGui_ImplOpenGL3_DestroyFontsTexture(); }
if (clearAtlas) { TFE_Ui::invalidateFontAtlas(); }
}
assert(s_currentCaptionFont != nullptr);

Expand Down
5 changes: 2 additions & 3 deletions TheForceEngine/TFE_Editor/LevelEditor/groups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ namespace LevelEditor
bool groups_chooseName()
{
pushFont(TFE_Editor::FONT_SMALL);
bool active = true;
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize;

bool create = false;
bool cancel = false;
if (ImGui::BeginPopupModal("Choose Name", &active, window_flags))
if (ImGui::BeginPopupModal("Choose Name", nullptr, window_flags))
{
ImGui::Text("Choose Name");
ImGui::SameLine(0.0f, 8.0f);
Expand All @@ -71,7 +70,7 @@ namespace LevelEditor
{
groups_add(s_nameInput, s_groupCurrent);
}
return !active || create || cancel;
return create || cancel;
}

void groups_init()
Expand Down
21 changes: 11 additions & 10 deletions TheForceEngine/TFE_Editor/LevelEditor/infoPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ namespace LevelEditor

if (s_scrollToBottom)
{
ImGui::SetScrollHere(0.999f);
ImGui::SetScrollHereY(0.999f);
s_scrollToBottom = false;
}
}
Expand Down Expand Up @@ -430,7 +430,7 @@ namespace LevelEditor
bool hadFocusX = false, hadFocusZ = false;
Vec2f prevPos = *value;
ImGui::PushItemWidth(98.0f);
if (ImGui::InputFloat(id0, &value->x, NULL, NULL, "%0.6f", ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_NoUndoRedo))
if (ImGui::InputFloat(id0, &value->x, 0.0, 0.0, "%0.6f", ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_NoUndoRedo))
{
if (value->x != prevPos.x)
{
Expand All @@ -441,7 +441,7 @@ namespace LevelEditor

ImGui::SameLine();
ImGui::PushItemWidth(98.0f);
if (ImGui::InputFloat(id1, &value->z, NULL, NULL, "%0.6f", ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_NoUndoRedo))
if (ImGui::InputFloat(id1, &value->z, 0.0, 0.0, "%0.6f", ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_NoUndoRedo))
{
if (value->z != prevPos.z)
{
Expand Down Expand Up @@ -550,7 +550,7 @@ namespace LevelEditor
void infoLabel(const char* labelId, const char* labelText, u32 width)
{
ImGui::PushItemWidth(f32(width));
ImGui::LabelText(labelId, labelText);
ImGui::LabelText(labelId, "%s", labelText);
ImGui::PopItemWidth();
ImGui::SameLine();
}
Expand Down Expand Up @@ -1767,13 +1767,12 @@ namespace LevelEditor
{
f32 winWidth = 600.0f;
f32 winHeight = 146.0f;

bool btn = false;
pushFont(TFE_Editor::FONT_SMALL);

bool active = true;
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoResize;
ImGui::SetNextWindowSize({ winWidth, winHeight });
if (ImGui::BeginPopupModal("Category", &active, window_flags))
if (ImGui::BeginPopupModal("Category", nullptr, window_flags))
{
//s_objEntity;
s32 count = (s32)s_categoryList.size();
Expand All @@ -1794,19 +1793,21 @@ namespace LevelEditor

if (ImGui::Button("Confirm"))
{
active = false;
btn = true;
ImGui::CloseCurrentPopup();
}
ImGui::SameLine(0.0f, 32.0f);
if (ImGui::Button("Cancel"))
{
btn = true;
s_objEntity.categories = s_prevCategoryFlags;
active = false;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}

popFont();

return !active;
return btn;
}
}
4 changes: 2 additions & 2 deletions TheForceEngine/TFE_Editor/LevelEditor/levelEditorData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,8 @@ namespace LevelEditor
const LevelTextureAsset* tex = s_level.textures.data();
for (s32 i = 0; i < textureCount; i++, tex++)
{
tex->name.c_str();
WRITE_LINE(" TEXTURE: %s\t\t# %d\r\n", tex->name.c_str(), i);
const char *c = tex->name.c_str();
WRITE_LINE(" TEXTURE: %s\t\t# %d\r\n", c, i);
}
NEW_LINE();

Expand Down
29 changes: 13 additions & 16 deletions TheForceEngine/TFE_Editor/LevelEditor/levelEditorInf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,7 @@ namespace LevelEditor
editor_infPropertySelectable(IEV_SPEED, itemClassIndex);

ImGui::SetNextItemWidth(128.0f);
ImGui::InputFloat(editor_getUniqueLabel(""), &elev->speed, 0.1f, 1.0f, 3);
ImGui::InputFloat(editor_getUniqueLabel(""), &elev->speed, 0.1f, 1.0f, "%.3f", ImGuiInputTextFlags_CharsDecimal);
}
if (overrides & IEO_MASTER)
{
Expand All @@ -1991,7 +1991,7 @@ namespace LevelEditor
ImGui::SameLine(0.0f, 8.0f);
ImGui::SetNextItemWidth(128.0f);
f32 angle = elev->angle * 180.0f / PI;
if (ImGui::InputFloat(editor_getUniqueLabel(""), &angle, 0.1f, 1.0f, 3))
if (ImGui::InputFloat(editor_getUniqueLabel(""), &angle, 0.1f, 1.0f, "%.3f", ImGuiInputTextFlags_CharsDecimal))
{
elev->angle = angle * PI / 180.0f;
}
Expand Down Expand Up @@ -2045,7 +2045,7 @@ namespace LevelEditor
editor_infPropertySelectable(IEV_CENTER, itemClassIndex);

ImGui::SetNextItemWidth(160.0f);
ImGui::InputFloat2(editor_getUniqueLabel(""), elev->center.m, 3);
ImGui::InputFloat2(editor_getUniqueLabel(""), elev->center.m, "%.3f", ImGuiInputTextFlags_CharsDecimal);

ImGui::SameLine(0.0f, 8.0f);
if (iconButtonInline(ICON_SELECT, "Select position in viewport.", btnTint, true))
Expand Down Expand Up @@ -2688,7 +2688,7 @@ namespace LevelEditor
if (stop->fromSectorFloor.empty())
{
// TODO: How to turn into a string?
ImGui::InputFloat(editor_getUniqueLabel(""), &stop->value, 0.1f, 1.0f, 3);
ImGui::InputFloat(editor_getUniqueLabel(""), &stop->value, 0.1f, 1.0f, "%.3f", ImGuiInputTextFlags_CharsDecimal);
}
else
{
Expand Down Expand Up @@ -2731,7 +2731,7 @@ namespace LevelEditor
ImGui::Text("Delay:");
ImGui::SameLine(0.0f, 8.0f);
ImGui::SetNextItemWidth(128.0f);
ImGui::InputFloat(editor_getUniqueLabel(""), &stop->delay, 0.1f, 1.0f, 3);
ImGui::InputFloat(editor_getUniqueLabel(""), &stop->delay, 0.1f, 1.0f, "%.3f", ImGuiInputTextFlags_CharsDecimal);
}

///////////////////////////////
Expand Down Expand Up @@ -3302,7 +3302,7 @@ namespace LevelEditor
ImGui::Text("Move"); ImGui::SameLine(0.0f, 8.0f);
// Position
ImGui::SetNextItemWidth(128.0f * 3.0f);
ImGui::InputFloat3(editor_getUniqueLabel(""), &teleporter->dstPos.x, 3);
ImGui::InputFloat3(editor_getUniqueLabel(""), &teleporter->dstPos.x);
ImGui::SameLine(0.0f, 8.0f);
if (iconButtonInline(ICON_SELECT, "Select target position in the viewport.", tint, true))
{
Expand All @@ -3322,7 +3322,7 @@ namespace LevelEditor

ImGui::SameLine(0.0f, 8.0f);
ImGui::SetNextItemWidth(128.0f);
ImGui::InputFloat(editor_getUniqueLabel(""), &teleporter->dstAngle, 0.1f, 1.0f, 3);
ImGui::InputFloat(editor_getUniqueLabel(""), &teleporter->dstAngle, 0.1f, 1.0f, "%.3f", ImGuiInputTextFlags_CharsDecimal);
}
} break;
}
Expand Down Expand Up @@ -3821,7 +3821,7 @@ namespace LevelEditor
// Class
ImGui::TextColored(colorKeywordOuter, "Class:"); ImGui::SameLine(0.0f, 8.0f);
ImGui::TextColored(colorKeywordInner, "Elevator"); ImGui::SameLine(0.0f, 8.0f);
ImGui::Text(c_infElevTypeName[elev->type]);
ImGui::Text("%s", c_infElevTypeName[elev->type]);

// Properties.
const u32 overrides = elev->overrideSet;
Expand Down Expand Up @@ -4040,7 +4040,7 @@ namespace LevelEditor
if (trigger->type != ITRIGGER_SECTOR)
{
ImGui::SameLine(0.0f, 8.0f);
ImGui::Text(c_infTriggerTypeName[trigger->type]);
ImGui::Text("%s", c_infTriggerTypeName[trigger->type]);
}

const u32 overrides = trigger->overrideSet;
Expand Down Expand Up @@ -4125,7 +4125,7 @@ namespace LevelEditor
// Class
ImGui::TextColored(colorKeywordOuter, "Class:"); ImGui::SameLine(0.0f, 8.0f);
ImGui::TextColored(colorKeywordInner, "Teleporter"); ImGui::SameLine(0.0f, 8.0f);
ImGui::Text(c_infTeleporterTypeName[teleporter->type]);
ImGui::Text("%s", c_infTeleporterTypeName[teleporter->type]);

// Target
ImGui::Text("%s", tab); ImGui::SameLine(0.0f, 0.0f);
Expand Down Expand Up @@ -4172,7 +4172,7 @@ namespace LevelEditor
ImGui::PushStyleColor(ImGuiCol_NavWindowingDimBg, { 0.80f, 0.80f, 0.80f, 0.10f });
ImGui::PushStyleColor(ImGuiCol_ModalWindowDimBg, { 0.80f, 0.80f, 0.80f, 0.15f });

if (ImGui::BeginPopupModal("Edit INF", &active, window_flags))
if (ImGui::BeginPopupModal("Edit INF", nullptr, window_flags))
{
// Popups need multiple frames to "accept" the new position due to the way the imGui window position logic works.
if (s_restorePos > 0) { s_restorePos--; }
Expand Down Expand Up @@ -4291,15 +4291,12 @@ namespace LevelEditor
ImGui::EndPopup();
}

if (!active)
{
modifySectorGeometry();
}
modifySectorGeometry();

ImGui::PopStyleColor(2);
popFont();

return !active;
return true;
}

void editor_loadInfBinary(FileStream& file, u32 version)
Expand Down
9 changes: 4 additions & 5 deletions TheForceEngine/TFE_Editor/LevelEditor/lighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ namespace LevelEditor
bool levelLighting()
{
TFE_Editor::pushFont(TFE_Editor::FONT_SMALL);
bool active = true;
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize;

bool applyLighting = false;
bool cancel = false;
if (ImGui::BeginPopupModal("Level Lighting", &active, window_flags))
if (ImGui::BeginPopupModal("Level Lighting", nullptr, window_flags))
{
ImGui::Text("Directional Wall Lighting");
ImGui::NewLine();
Expand Down Expand Up @@ -52,8 +51,8 @@ namespace LevelEditor
{
applyLighting = true;
}
ImGui::SameLine(0.0f, 8.0f);
if (ImGui::Button("Cancel"))
ImGui::SameLine();
if (ImGui::Button("Close"))
{
cancel = true;
}
Expand Down Expand Up @@ -106,6 +105,6 @@ namespace LevelEditor
}
}
}
return !active || applyLighting || cancel;
return applyLighting || cancel;
}
} // namespace LevelEditor
Loading
Loading