Skip to content

Commit

Permalink
feat: clear background colour to what is set in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMcAvoy committed Oct 31, 2024
1 parent 6c529a4 commit 44b74f2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 142 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ Come back later, sorry! Jenjin is not ready for real usage.
- [x] Transparency on sprites
- [x] Icons everywhere
- [x] Code editor in the editor
- [ ] Autocompletion in the editor
- [ ] Improved meshing algorithm that gives same input meshes all one mesh reference instead of making multiple mesh references and data for them.
- [ ] Dynamic data attached to game objects at runtime
- [ ] Hierarchy and `.Parent` in Lua along with `workspace` (e.g. `Workspace.MyGameObject.Parent` == `Workspace`)
- [ ] Autocompletion in the editor

## TODO (Future)
- [ ] Serialization/Deserialization of scenes to better formats
Expand Down
5 changes: 4 additions & 1 deletion engine/src/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ void Manager::inspector(Jenjin::Scene *scene) {
ImGui::Unindent();
}

ImGui::ItemSize(ImVec2(0, 10));

if (ImGui::CollapsingHeader(appearance_title)) {
ImGui::Indent();
ImGui::ColorPicker3(
Expand Down Expand Up @@ -495,7 +497,8 @@ void Manager::code(Jenjin::Scene *scene) {
if (showUnsaved)
flags |= ImGuiWindowFlags_UnsavedDocument;

// TODO: Tabs at the top for each file (NOTE: This should probably be a class once this is implemented)
// TODO: Tabs at the top for each file (NOTE: This should probably be a class
// once this is implemented)
ImGui::Begin(title, nullptr, flags);

static auto save = [&]() {
Expand Down
1 change: 1 addition & 0 deletions engine/src/editor/widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static void drawButtonWithDrag(const std::string &buttonLabel,
}

static void start_widget(const std::string &label, int count = 2) {
ImGui::ItemSize(ImVec2(0.0f, 2.0f));
ImGui::PushID(label.c_str());
ImGui::Columns(2);
ImGui::SetColumnWidth(0, 100.0f);
Expand Down
141 changes: 5 additions & 136 deletions engine/src/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,143 +58,12 @@ void InitiateImGui(GLFWwindow *window) {
io.Fonts->AddFontFromFileTTF("./resources/fonts/fa-solid-900.ttf", base, &config, icon_ranges);

ImGui::StyleColorsDark();
ImGuiStyle& style = ImGui::GetStyle();

// Photoshop style by Derydoca from ImThemes
auto Derydocas_PhotoshopTheme_FromImThemes = [](ImGuiStyle &style) {
style.Alpha = 1.0f;
style.DisabledAlpha = 0.6000000238418579f;
style.WindowPadding = ImVec2(8.0f, 8.0f);
style.WindowRounding = 4.0f;
style.WindowBorderSize = 1.0f;
style.WindowMinSize = ImVec2(32.0f, 32.0f);
style.WindowTitleAlign = ImVec2(0.0f, 0.5f);
style.WindowMenuButtonPosition = ImGuiDir_Left;
style.ChildRounding = 4.0f;
style.ChildBorderSize = 1.0f;
style.PopupRounding = 2.0f;
style.PopupBorderSize = 1.0f;
style.FramePadding = ImVec2(4.0f, 3.0f);
style.FrameRounding = 2.0f;
style.FrameBorderSize = 1.0f;
style.ItemSpacing = ImVec2(8.0f, 4.0f);
style.ItemInnerSpacing = ImVec2(4.0f, 4.0f);
style.CellPadding = ImVec2(10.0f, 8.0f);
style.IndentSpacing = 21.0f;
style.ColumnsMinSpacing = 6.0f;
style.ScrollbarSize = 13.0f;
style.ScrollbarRounding = 12.0f;
style.GrabMinSize = 7.0f;
style.GrabRounding = 0.0f;
style.TabRounding = 0.0f;
style.TabBorderSize = 1.0f;
style.TabMinWidthForCloseButton = 0.0f;
style.ColorButtonPosition = ImGuiDir_Right;
style.ButtonTextAlign = ImVec2(0.5f, 0.5f);
style.SelectableTextAlign = ImVec2(0.0f, 0.0f);

style.Colors[ImGuiCol_Text] = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
style.Colors[ImGuiCol_TextDisabled] = ImVec4(
0.4980392158031464f, 0.4980392158031464f, 0.4980392158031464f, 1.0f);
style.Colors[ImGuiCol_WindowBg] = ImVec4(
0.1764705926179886f, 0.1764705926179886f, 0.1764705926179886f, 1.0f);
style.Colors[ImGuiCol_ChildBg] = ImVec4(
0.2784313857555389f, 0.2784313857555389f, 0.2784313857555389f, 0.0f);
style.Colors[ImGuiCol_PopupBg] = ImVec4(
0.3098039329051971f, 0.3098039329051971f, 0.3098039329051971f, 1.0f);
style.Colors[ImGuiCol_Border] = ImVec4(
0.2627451121807098f, 0.2627451121807098f, 0.2627451121807098f, 1.0f);
style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f);
style.Colors[ImGuiCol_FrameBg] = ImVec4(
0.1568627506494522f, 0.1568627506494522f, 0.1568627506494522f, 1.0f);
style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(
0.2000000029802322f, 0.2000000029802322f, 0.2000000029802322f, 1.0f);
style.Colors[ImGuiCol_FrameBgActive] = ImVec4(
0.2784313857555389f, 0.2784313857555389f, 0.2784313857555389f, 1.0f);
style.Colors[ImGuiCol_TitleBg] = ImVec4(
0.1450980454683304f, 0.1450980454683304f, 0.1450980454683304f, 1.0f);
style.Colors[ImGuiCol_TitleBgActive] = ImVec4(
0.1450980454683304f, 0.1450980454683304f, 0.1450980454683304f, 1.0f);
style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(
0.1450980454683304f, 0.1450980454683304f, 0.1450980454683304f, 1.0f);
style.Colors[ImGuiCol_MenuBarBg] = ImVec4(
0.1921568661928177f, 0.1921568661928177f, 0.1921568661928177f, 1.0f);
style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(
0.1568627506494522f, 0.1568627506494522f, 0.1568627506494522f, 1.0f);
style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(
0.2745098173618317f, 0.2745098173618317f, 0.2745098173618317f, 1.0f);
style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(
0.2980392277240753f, 0.2980392277240753f, 0.2980392277240753f, 1.0f);
style.Colors[ImGuiCol_ScrollbarGrabActive] =
ImVec4(1.0f, 0.3882353007793427f, 0.0f, 1.0f);
style.Colors[ImGuiCol_CheckMark] = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
style.Colors[ImGuiCol_SliderGrab] = ImVec4(
0.3882353007793427f, 0.3882353007793427f, 0.3882353007793427f, 1.0f);
style.Colors[ImGuiCol_SliderGrabActive] =
ImVec4(1.0f, 0.3882353007793427f, 0.0f, 1.0f);
style.Colors[ImGuiCol_Button] = ImVec4(1.0f, 1.0f, 1.0f, 0.0f);
style.Colors[ImGuiCol_ButtonHovered] =
ImVec4(1.0f, 1.0f, 1.0f, 0.1560000032186508f);
style.Colors[ImGuiCol_ButtonActive] =
ImVec4(1.0f, 1.0f, 1.0f, 0.3910000026226044f);
style.Colors[ImGuiCol_Header] = ImVec4(
0.3098039329051971f, 0.3098039329051971f, 0.3098039329051971f, 1.0f);
style.Colors[ImGuiCol_HeaderHovered] = ImVec4(
0.4666666686534882f, 0.4666666686534882f, 0.4666666686534882f, 1.0f);
style.Colors[ImGuiCol_HeaderActive] = ImVec4(
0.4666666686534882f, 0.4666666686534882f, 0.4666666686534882f, 1.0f);
style.Colors[ImGuiCol_Separator] = ImVec4(
0.2627451121807098f, 0.2627451121807098f, 0.2627451121807098f, 1.0f);
style.Colors[ImGuiCol_SeparatorHovered] = ImVec4(
0.3882353007793427f, 0.3882353007793427f, 0.3882353007793427f, 1.0f);
style.Colors[ImGuiCol_SeparatorActive] =
ImVec4(1.0f, 0.3882353007793427f, 0.0f, 1.0f);
style.Colors[ImGuiCol_ResizeGrip] = ImVec4(1.0f, 1.0f, 1.0f, 0.25f);
style.Colors[ImGuiCol_ResizeGripHovered] =
ImVec4(1.0f, 1.0f, 1.0f, 0.6700000166893005f);
style.Colors[ImGuiCol_ResizeGripActive] =
ImVec4(1.0f, 0.3882353007793427f, 0.0f, 1.0f);
style.Colors[ImGuiCol_Tab] = ImVec4(
0.09411764889955521f, 0.09411764889955521f, 0.09411764889955521f, 1.0f);
style.Colors[ImGuiCol_TabHovered] = ImVec4(
0.3490196168422699f, 0.3490196168422699f, 0.3490196168422699f, 1.0f);
style.Colors[ImGuiCol_TabActive] = ImVec4(
0.1921568661928177f, 0.1921568661928177f, 0.1921568661928177f, 1.0f);
style.Colors[ImGuiCol_TabUnfocused] = ImVec4(
0.09411764889955521f, 0.09411764889955521f, 0.09411764889955521f, 1.0f);
style.Colors[ImGuiCol_TabUnfocusedActive] = ImVec4(
0.1921568661928177f, 0.1921568661928177f, 0.1921568661928177f, 1.0f);
style.Colors[ImGuiCol_PlotLines] = ImVec4(
0.4666666686534882f, 0.4666666686534882f, 0.4666666686534882f, 1.0f);
style.Colors[ImGuiCol_PlotLinesHovered] =
ImVec4(1.0f, 0.3882353007793427f, 0.0f, 1.0f);
style.Colors[ImGuiCol_PlotHistogram] = ImVec4(
0.5843137502670288f, 0.5843137502670288f, 0.5843137502670288f, 1.0f);
style.Colors[ImGuiCol_PlotHistogramHovered] =
ImVec4(1.0f, 0.3882353007793427f, 0.0f, 1.0f);
style.Colors[ImGuiCol_TableHeaderBg] = ImVec4(
0.1882352977991104f, 0.1882352977991104f, 0.2000000029802322f, 1.0f);
style.Colors[ImGuiCol_TableBorderStrong] = ImVec4(
0.3098039329051971f, 0.3098039329051971f, 0.3490196168422699f, 1.0f);
style.Colors[ImGuiCol_TableBorderLight] = ImVec4(
0.2274509817361832f, 0.2274509817361832f, 0.2470588237047195f, 1.0f);
style.Colors[ImGuiCol_TableRowBg] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f);
style.Colors[ImGuiCol_TableRowBgAlt] =
ImVec4(1.0f, 1.0f, 1.0f, 0.05999999865889549f);
style.Colors[ImGuiCol_TextSelectedBg] =
ImVec4(1.0f, 1.0f, 1.0f, 0.1560000032186508f);
style.Colors[ImGuiCol_DragDropTarget] =
ImVec4(1.0f, 0.3882353007793427f, 0.0f, 1.0f);
style.Colors[ImGuiCol_NavHighlight] =
ImVec4(1.0f, 0.3882353007793427f, 0.0f, 1.0f);
style.Colors[ImGuiCol_NavWindowingHighlight] =
ImVec4(1.0f, 0.3882353007793427f, 0.0f, 1.0f);
style.Colors[ImGuiCol_NavWindowingDimBg] =
ImVec4(0.0f, 0.0f, 0.0f, 0.5860000252723694f);
style.Colors[ImGuiCol_ModalWindowDimBg] =
ImVec4(0.0f, 0.0f, 0.0f, 0.5860000252723694f);
};

Derydocas_PhotoshopTheme_FromImThemes(ImGui::GetStyle());
style.DockingSeparatorSize = 1.0f;
style.FrameRounding = 4.0f;
style.ChildRounding = 4.0f;
style.PopupRounding = 2.0f;

ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 460");
Expand Down
6 changes: 2 additions & 4 deletions engine/src/targets/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ EditorTarget::EditorTarget() {
}

void EditorTarget::PreRender() {
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);

Resize(GetSize());

ImGui_ImplOpenGL3_NewFrame();
Expand All @@ -33,7 +30,8 @@ void EditorTarget::PreRender() {

renderTexture.Bind();

glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
static auto bg = Jenjin::EngineRef->GetCurrentScene()->GetCamera()->GetBackgroundPointer();
glClearColor(bg->r, bg->g, bg->b, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, width, height);
}
Expand Down

0 comments on commit 44b74f2

Please sign in to comment.