From a5207573bfc8b95162c11ad22303ca53c406b735 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Wed, 24 Nov 2021 15:20:08 -0800 Subject: [PATCH] Customizable object colors. --- common/camera.cpp | 28 +- common/lc_application.cpp | 12 + common/lc_application.h | 7 + common/lc_colors.cpp | 12 - common/lc_colors.h | 12 - common/lc_context.cpp | 9 +- common/lc_context.h | 3 +- common/lc_profile.cpp | 115 +++---- common/lc_profile.h | 15 +- common/lc_scene.cpp | 20 +- common/light.cpp | 39 ++- common/piece.cpp | 21 +- qt/lc_qpreferencesdialog.cpp | 44 +++ qt/lc_qpreferencesdialog.ui | 592 +++++++++++++++++++++++------------ 14 files changed, 610 insertions(+), 319 deletions(-) diff --git a/common/camera.cpp b/common/camera.cpp index 3474544d..5d0be833 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -537,12 +537,16 @@ void lcCamera::DrawInterface(lcContext* Context, const lcScene& Scene) const Context->SetVertexFormatPosition(3); Context->SetIndexBufferPointer(Indices); - const float LineWidth = lcGetPreferences().mLineWidth; + const lcPreferences& Preferences = lcGetPreferences(); + const float LineWidth = Preferences.mLineWidth; + const lcVector4 SelectedColor = lcVector4FromColor(Preferences.mObjectSelectedColor); + const lcVector4 FocusedColor = lcVector4FromColor(Preferences.mObjectFocusedColor); + const lcVector4 CameraColor = lcVector4FromColor(Preferences.mCameraColor); if (!IsSelected()) { Context->SetLineWidth(LineWidth); - Context->SetInterfaceColor(lcInterfaceColor::Camera); + Context->SetColor(CameraColor); Context->DrawIndexedPrimitives(GL_LINES, 40 + 24 + 24 + 4, GL_UNSIGNED_SHORT, 0); } @@ -552,14 +556,14 @@ void lcCamera::DrawInterface(lcContext* Context, const lcScene& Scene) const { Context->SetLineWidth(2.0f * LineWidth); if (IsFocused(LC_CAMERA_SECTION_POSITION)) - Context->SetInterfaceColor(lcInterfaceColor::Focused); + Context->SetColor(FocusedColor); else - Context->SetInterfaceColor(lcInterfaceColor::Selected); + Context->SetColor(SelectedColor); } else { Context->SetLineWidth(LineWidth); - Context->SetInterfaceColor(lcInterfaceColor::Camera); + Context->SetColor(CameraColor); } Context->DrawIndexedPrimitives(GL_LINES, 40, GL_UNSIGNED_SHORT, 0); @@ -568,14 +572,14 @@ void lcCamera::DrawInterface(lcContext* Context, const lcScene& Scene) const { Context->SetLineWidth(2.0f * LineWidth); if (IsFocused(LC_CAMERA_SECTION_TARGET)) - Context->SetInterfaceColor(lcInterfaceColor::Focused); + Context->SetColor(FocusedColor); else - Context->SetInterfaceColor(lcInterfaceColor::Selected); + Context->SetColor(SelectedColor); } else { Context->SetLineWidth(LineWidth); - Context->SetInterfaceColor(lcInterfaceColor::Camera); + Context->SetColor(CameraColor); } Context->DrawIndexedPrimitives(GL_LINES, 24, GL_UNSIGNED_SHORT, 40 * 2); @@ -584,19 +588,19 @@ void lcCamera::DrawInterface(lcContext* Context, const lcScene& Scene) const { Context->SetLineWidth(2.0f * LineWidth); if (IsFocused(LC_CAMERA_SECTION_UPVECTOR)) - Context->SetInterfaceColor(lcInterfaceColor::Focused); + Context->SetColor(FocusedColor); else - Context->SetInterfaceColor(lcInterfaceColor::Selected); + Context->SetColor(SelectedColor); } else { Context->SetLineWidth(LineWidth); - Context->SetInterfaceColor(lcInterfaceColor::Camera); + Context->SetColor(CameraColor); } Context->DrawIndexedPrimitives(GL_LINES, 24, GL_UNSIGNED_SHORT, (40 + 24) * 2); - Context->SetInterfaceColor(lcInterfaceColor::Camera); + Context->SetColor(CameraColor); Context->SetLineWidth(LineWidth); float SizeY = tanf(LC_DTOR * m_fovy / 2) * Length; diff --git a/common/lc_application.cpp b/common/lc_application.cpp index 72e27421..1bdf2c51 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -71,6 +71,12 @@ void lcPreferences::LoadDefaults() mPartEdgeContrast = lcGetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST); mPartColorValueLDIndex = lcGetProfileFloat(LC_PROFILE_PART_COLOR_VALUE_LD_INDEX); mAutomateEdgeColor = lcGetProfileInt(LC_PROFILE_AUTOMATE_EDGE_COLOR); + mObjectSelectedColor = lcGetProfileUInt(LC_PROFILE_OBJECT_SELECTED_COLOR); + mObjectFocusedColor = lcGetProfileUInt(LC_PROFILE_OBJECT_FOCUSED_COLOR); + mCameraColor = lcGetProfileUInt(LC_PROFILE_CAMERA_COLOR); + mLightColor = lcGetProfileUInt(LC_PROFILE_LIGHT_COLOR); + mControlPointColor = lcGetProfileUInt(LC_PROFILE_CONTROL_POINT_COLOR); + mControlPointFocusedColor = lcGetProfileUInt(LC_PROFILE_CONTROL_POINT_FOCUSED_COLOR); } void lcPreferences::SaveDefaults() @@ -125,6 +131,12 @@ void lcPreferences::SaveDefaults() lcSetProfileFloat(LC_PROFILE_PART_EDGE_CONTRAST, mPartEdgeContrast); lcSetProfileFloat(LC_PROFILE_PART_COLOR_VALUE_LD_INDEX, mPartColorValueLDIndex); lcSetProfileInt(LC_PROFILE_AUTOMATE_EDGE_COLOR, mAutomateEdgeColor); + lcSetProfileUInt(LC_PROFILE_OBJECT_SELECTED_COLOR, mObjectSelectedColor); + lcSetProfileUInt(LC_PROFILE_OBJECT_FOCUSED_COLOR, mObjectFocusedColor); + lcSetProfileUInt(LC_PROFILE_CAMERA_COLOR, mCameraColor); + lcSetProfileUInt(LC_PROFILE_LIGHT_COLOR, mLightColor); + lcSetProfileUInt(LC_PROFILE_CONTROL_POINT_COLOR, mControlPointColor); + lcSetProfileUInt(LC_PROFILE_CONTROL_POINT_FOCUSED_COLOR, mControlPointFocusedColor); } void lcPreferences::SetInterfaceColors(lcColorTheme ColorTheme) diff --git a/common/lc_application.h b/common/lc_application.h index a73e6b8f..fb1a8f83 100644 --- a/common/lc_application.h +++ b/common/lc_application.h @@ -77,6 +77,13 @@ public: bool mAutoLoadMostRecent; bool mRestoreTabLayout; lcColorTheme mColorTheme; + quint32 mObjectSelectedColor; + quint32 mObjectFocusedColor; + quint32 mCameraColor; + quint32 mLightColor; + quint32 mControlPointColor; + quint32 mControlPointFocusedColor; + int mPreviewViewSphereEnabled; int mPreviewViewSphereSize; diff --git a/common/lc_colors.cpp b/common/lc_colors.cpp index b5ba6d22..df61cf92 100644 --- a/common/lc_colors.cpp +++ b/common/lc_colors.cpp @@ -10,18 +10,6 @@ lcColorGroup gColorGroups[LC_NUM_COLORGROUPS]; int gEdgeColor; int gDefaultColor; -lcVector4 gInterfaceColors[] = // todo: make the colors configurable and include the grid and other hardcoded colors here as well. -{ - lcVector4(0.898f, 0.298f, 0.400f, 1.000f), // lcInterfaceColor::Selected - lcVector4(0.400f, 0.298f, 0.898f, 1.000f), // lcInterfaceColor::Focused - lcVector4(0.500f, 0.800f, 0.500f, 1.000f), // lcInterfaceColor::Camera - lcVector4(0.500f, 0.800f, 0.500f, 1.000f), // lcInterfaceColor::Light - lcVector4(0.500f, 0.800f, 0.500f, 0.500f), // lcInterfaceColor::ControlPoint - lcVector4(0.400f, 0.298f, 0.898f, 0.500f), // lcInterfaceColor::ControlPointFocused -}; - -LC_ARRAY_SIZE_CHECK(gInterfaceColors, lcInterfaceColor::Count); - static void GetToken(char*& Ptr, char* Token) { while (*Ptr && *Ptr <= 32) diff --git a/common/lc_colors.h b/common/lc_colors.h index 33f71938..c85f8355 100644 --- a/common/lc_colors.h +++ b/common/lc_colors.h @@ -33,18 +33,6 @@ struct lcColorGroup QString Name; }; -enum class lcInterfaceColor -{ - Selected, - Focused, - Camera, - Light, - ControlPoint, - ControlPointFocused, - Count -}; - -extern lcVector4 gInterfaceColors[static_cast(lcInterfaceColor::Count)]; extern std::vector gColorList; extern lcColorGroup gColorGroups[LC_NUM_COLORGROUPS]; extern int gEdgeColor; diff --git a/common/lc_context.cpp b/common/lc_context.cpp index 5187d453..7de94e21 100644 --- a/common/lc_context.cpp +++ b/common/lc_context.cpp @@ -847,9 +847,9 @@ void lcContext::SetColorIndex(int ColorIndex) SetColor(gColorList[ColorIndex].Value); } -void lcContext::SetColorIndexTinted(int ColorIndex, lcInterfaceColor InterfaceColor, float Weight) +void lcContext::SetColorIndexTinted(int ColorIndex, const lcVector4& Tint, float Weight) { - const lcVector3 Color(gColorList[ColorIndex].Value * Weight + gInterfaceColors[static_cast(InterfaceColor)] * (1.0f - Weight)); + const lcVector3 Color(gColorList[ColorIndex].Value * Weight + Tint * (1.0f - Weight)); SetColor(lcVector4(Color, gColorList[ColorIndex].Value.w)); } @@ -868,11 +868,6 @@ void lcContext::SetEdgeColorIndexTinted(int ColorIndex, const lcVector4& Tint) SetColor(gColorList[ColorIndex].Edge * Tint); } -void lcContext::SetInterfaceColor(lcInterfaceColor InterfaceColor) -{ - SetColor(gInterfaceColors[static_cast(InterfaceColor)]); -} - lcVertexBuffer lcContext::CreateVertexBuffer(int Size, const void* Data) { lcVertexBuffer VertexBuffer; diff --git a/common/lc_context.h b/common/lc_context.h index bbbee278..ef8e1153 100644 --- a/common/lc_context.h +++ b/common/lc_context.h @@ -194,11 +194,10 @@ public: void SetColor(float Red, float Green, float Blue, float Alpha); void SetColorIndex(int ColorIndex); - void SetColorIndexTinted(int ColorIndex, lcInterfaceColor InterfaceColor, float Weight); + void SetColorIndexTinted(int ColorIndex, const lcVector4& Tint, float Weight); void SetColorIndexTinted(int ColorIndex, const lcVector4& Tint); void SetEdgeColorIndex(int ColorIndex); void SetEdgeColorIndexTinted(int ColorIndex, const lcVector4& Tint); - void SetInterfaceColor(lcInterfaceColor InterfaceColor); lcVertexBuffer CreateVertexBuffer(int Size, const void* Data); void DestroyVertexBuffer(lcVertexBuffer& VertexBuffer); diff --git a/common/lc_profile.cpp b/common/lc_profile.cpp index 1975b586..e11473a7 100644 --- a/common/lc_profile.cpp +++ b/common/lc_profile.cpp @@ -14,12 +14,12 @@ lcProfileEntry::lcProfileEntry(const char* Section, const char* Key, int Default mDefault.IntValue = DefaultValue; } -lcProfileEntry::lcProfileEntry(const char* Section, const char* Key, unsigned int DefaultValue) +lcProfileEntry::lcProfileEntry(const char* Section, const char* Key, uint DefaultValue) { mType = LC_PROFILE_ENTRY_INT; mSection = Section; mKey = Key; - mDefault.IntValue = DefaultValue; + mDefault.UIntValue = DefaultValue; } lcProfileEntry::lcProfileEntry(const char* Section, const char* Key, float DefaultValue) @@ -56,43 +56,49 @@ lcProfileEntry::lcProfileEntry(const char* Section, const char* Key) static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] = { - lcProfileEntry("Settings", "FixedAxes", false), // LC_PROFILE_FIXED_AXES - lcProfileEntry("Settings", "LineWidth", 1.0f), // LC_PROFILE_LINE_WIDTH - lcProfileEntry("Settings", "AllowLOD", true), // LC_PROFILE_ALLOW_LOD - lcProfileEntry("Settings", "LODDistance", 750.0f), // LC_PROFILE_LOD_DISTANCE - lcProfileEntry("Settings", "FadeSteps", false), // LC_PROFILE_FADE_STEPS - lcProfileEntry("Settings", "FadeStepsColor", LC_RGBA(128, 128, 128, 128)), // LC_PROFILE_FADE_STEPS_COLOR - lcProfileEntry("Settings", "HighlightNewParts", 0), // LC_PROFILE_HIGHLIGHT_NEW_PARTS - lcProfileEntry("Settings", "HighlightNewPartsColor", LC_RGBA(255, 242, 0, 192)), // LC_PROFILE_HIGHLIGHT_NEW_PARTS_COLOR - lcProfileEntry("Settings", "ShadingMode", static_cast(lcShadingMode::DefaultLights)), // LC_PROFILE_SHADING_MODE - lcProfileEntry("Settings", "BackgroundGradient", false), // LC_PROFILE_BACKGROUND_GRADIENT - lcProfileEntry("Settings", "BackgroundColor", LC_RGB(49, 52, 55)), // LC_PROFILE_BACKGROUND_COLOR - lcProfileEntry("Settings", "GradientColorTop", LC_RGB(54, 72, 95)), // LC_PROFILE_GRADIENT_COLOR_TOP - lcProfileEntry("Settings", "GradientColorBottom", LC_RGB(49, 52, 55)), // LC_PROFILE_GRADIENT_COLOR_BOTTOM - lcProfileEntry("Settings", "DrawAxes", 0), // LC_PROFILE_DRAW_AXES - lcProfileEntry("Settings", "DrawAxesLocation", static_cast(lcAxisIconLocation::BottomLeft)), // LC_PROFILE_DRAW_AXES_LOCATION - lcProfileEntry("Settings", "AxesColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_AXES_COLOR - lcProfileEntry("Settings", "TextColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_TEXT_COLOR - lcProfileEntry("Settings", "MarqueeBorderColor", LC_RGBA(64, 64, 255, 255)), // LC_PROFILE_MARQUEE_BORDER_COLOR - lcProfileEntry("Settings", "MarqueeFillColor", LC_RGBA(64, 64, 255, 64)), // LC_PROFILE_MARQUEE_FILL_COLOR - lcProfileEntry("Settings", "OverlayColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_OVERLAY_COLOR - lcProfileEntry("Settings", "ActiveViewColor", LC_RGBA(41, 128, 185, 255)), // LC_PROFILE_ACTIVE_VIEW_COLOR - lcProfileEntry("Settings", "InactiveViewColor", LC_RGBA(69, 69, 69, 255)), // LC_PROFILE_INACTIVE_VIEW_COLOR - lcProfileEntry("Settings", "DrawEdgeLines", 1), // LC_PROFILE_DRAW_EDGE_LINES - lcProfileEntry("Settings", "DrawConditionalLines", 1), // LC_PROFILE_DRAW_CONDITIONAL_LINES - lcProfileEntry("Settings", "GridStuds", 1), // LC_PROFILE_GRID_STUDS - lcProfileEntry("Settings", "GridStudColor", LC_RGBA(24, 24, 24, 192)), // LC_PROFILE_GRID_STUD_COLOR - lcProfileEntry("Settings", "GridLines", 1), // LC_PROFILE_GRID_LINES - lcProfileEntry("Settings", "GridLineSpacing", 5), // LC_PROFILE_GRID_LINE_SPACING - lcProfileEntry("Settings", "GridLineColor", LC_RGBA(24, 24, 24, 255)), // LC_PROFILE_GRID_LINE_COLOR - lcProfileEntry("Settings", "GridOrigin", 0), // LC_PROFILE_GRID_ORIGIN - lcProfileEntry("Settings", "AASamples", 1), // LC_PROFILE_ANTIALIASING_SAMPLES - lcProfileEntry("Settings", "ViewSphereEnabled", 1), // LC_PROFILE_VIEW_SPHERE_ENABLED - lcProfileEntry("Settings", "ViewSphereLocation", (int)lcViewSphereLocation::TopRight), // LC_PROFILE_VIEW_SPHERE_LOCATION - lcProfileEntry("Settings", "ViewSphereSize", 100), // LC_PROFILE_VIEW_SPHERE_SIZE - lcProfileEntry("Settings", "ViewSphereColor", LC_RGBA(35, 38, 41, 255)), // LC_PROFILE_VIEW_SPHERE_COLOR - lcProfileEntry("Settings", "ViewSphereTextColor", LC_RGBA(224, 224, 224, 255)), // LC_PROFILE_VIEW_SPHERE_TEXT_COLOR - lcProfileEntry("Settings", "ViewSphereHighlightColor", LC_RGBA(41, 128, 185, 255)), // LC_PROFILE_VIEW_SPHERE_HIGHLIGHT_COLOR + lcProfileEntry("Settings", "FixedAxes", false), // LC_PROFILE_FIXED_AXES + lcProfileEntry("Settings", "LineWidth", 1.0f), // LC_PROFILE_LINE_WIDTH + lcProfileEntry("Settings", "AllowLOD", true), // LC_PROFILE_ALLOW_LOD + lcProfileEntry("Settings", "LODDistance", 750.0f), // LC_PROFILE_LOD_DISTANCE + lcProfileEntry("Settings", "FadeSteps", false), // LC_PROFILE_FADE_STEPS + lcProfileEntry("Settings", "FadeStepsColor", LC_RGBA(128, 128, 128, 128)), // LC_PROFILE_FADE_STEPS_COLOR + lcProfileEntry("Settings", "HighlightNewParts", 0), // LC_PROFILE_HIGHLIGHT_NEW_PARTS + lcProfileEntry("Settings", "HighlightNewPartsColor", LC_RGBA(255, 242, 0, 192)), // LC_PROFILE_HIGHLIGHT_NEW_PARTS_COLOR + lcProfileEntry("Settings", "ShadingMode", static_cast(lcShadingMode::DefaultLights)), // LC_PROFILE_SHADING_MODE + lcProfileEntry("Settings", "BackgroundGradient", false), // LC_PROFILE_BACKGROUND_GRADIENT + lcProfileEntry("Settings", "BackgroundColor", LC_RGB(49, 52, 55)), // LC_PROFILE_BACKGROUND_COLOR + lcProfileEntry("Settings", "GradientColorTop", LC_RGB(54, 72, 95)), // LC_PROFILE_GRADIENT_COLOR_TOP + lcProfileEntry("Settings", "GradientColorBottom", LC_RGB(49, 52, 55)), // LC_PROFILE_GRADIENT_COLOR_BOTTOM + lcProfileEntry("Settings", "DrawAxes", 0), // LC_PROFILE_DRAW_AXES + lcProfileEntry("Settings", "DrawAxesLocation", static_cast(lcAxisIconLocation::BottomLeft)), // LC_PROFILE_DRAW_AXES_LOCATION + lcProfileEntry("Settings", "AxesColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_AXES_COLOR + lcProfileEntry("Settings", "TextColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_TEXT_COLOR + lcProfileEntry("Settings", "MarqueeBorderColor", LC_RGBA(64, 64, 255, 255)), // LC_PROFILE_MARQUEE_BORDER_COLOR + lcProfileEntry("Settings", "MarqueeFillColor", LC_RGBA(64, 64, 255, 64)), // LC_PROFILE_MARQUEE_FILL_COLOR + lcProfileEntry("Settings", "OverlayColor", LC_RGBA(0, 0, 0, 255)), // LC_PROFILE_OVERLAY_COLOR + lcProfileEntry("Settings", "ActiveViewColor", LC_RGBA(41, 128, 185, 255)), // LC_PROFILE_ACTIVE_VIEW_COLOR + lcProfileEntry("Settings", "InactiveViewColor", LC_RGBA(69, 69, 69, 255)), // LC_PROFILE_INACTIVE_VIEW_COLOR + lcProfileEntry("Settings", "DrawEdgeLines", 1), // LC_PROFILE_DRAW_EDGE_LINES + lcProfileEntry("Settings", "DrawConditionalLines", 1), // LC_PROFILE_DRAW_CONDITIONAL_LINES + lcProfileEntry("Settings", "GridStuds", 1), // LC_PROFILE_GRID_STUDS + lcProfileEntry("Settings", "GridStudColor", LC_RGBA(24, 24, 24, 192)), // LC_PROFILE_GRID_STUD_COLOR + lcProfileEntry("Settings", "GridLines", 1), // LC_PROFILE_GRID_LINES + lcProfileEntry("Settings", "GridLineSpacing", 5), // LC_PROFILE_GRID_LINE_SPACING + lcProfileEntry("Settings", "GridLineColor", LC_RGBA(24, 24, 24, 255)), // LC_PROFILE_GRID_LINE_COLOR + lcProfileEntry("Settings", "GridOrigin", 0), // LC_PROFILE_GRID_ORIGIN + lcProfileEntry("Settings", "AASamples", 1), // LC_PROFILE_ANTIALIASING_SAMPLES + lcProfileEntry("Settings", "ViewSphereEnabled", 1), // LC_PROFILE_VIEW_SPHERE_ENABLED + lcProfileEntry("Settings", "ViewSphereLocation", (int)lcViewSphereLocation::TopRight), // LC_PROFILE_VIEW_SPHERE_LOCATION + lcProfileEntry("Settings", "ViewSphereSize", 100), // LC_PROFILE_VIEW_SPHERE_SIZE + lcProfileEntry("Settings", "ViewSphereColor", LC_RGBA(35, 38, 41, 255)), // LC_PROFILE_VIEW_SPHERE_COLOR + lcProfileEntry("Settings", "ViewSphereTextColor", LC_RGBA(224, 224, 224, 255)), // LC_PROFILE_VIEW_SPHERE_TEXT_COLOR + lcProfileEntry("Settings", "ViewSphereHighlightColor", LC_RGBA(41, 128, 185, 255)), // LC_PROFILE_VIEW_SPHERE_HIGHLIGHT_COLOR + lcProfileEntry("Settings", "ObjectSelectedColor", static_cast(LC_RGBA(229, 76, 102, 255))), // LC_PROFILE_OBJECT_SELECTED_COLOR + lcProfileEntry("Settings", "ObjectFocusedColor", static_cast(LC_RGBA(102, 76, 229, 255))), // LC_PROFILE_OBJECT_FOCUSED_COLOR + lcProfileEntry("Settings", "CameraColor", static_cast(LC_RGBA(128, 204, 128, 255))), // LC_PROFILE_CAMERA_COLOR + lcProfileEntry("Settings", "LightColor", static_cast(LC_RGBA(128, 204, 128, 255))), // LC_PROFILE_LIGHT_COLOR + lcProfileEntry("Settings", "ControlPointColor", static_cast(LC_RGBA(128, 204, 128, 128))), // LC_PROFILE_CONTROL_POINT_COLOR + lcProfileEntry("Settings", "ControlPointFocusedColor", static_cast(LC_RGBA(102, 76, 229, 128))), // LC_PROFILE_CONTROL_POINT_FOCUSED_COLOR lcProfileEntry("Settings", "Language", ""), // LC_PROFILE_LANGUAGE lcProfileEntry("Settings", "ColorTheme", static_cast(lcColorTheme::Dark)), // LC_PROFILE_COLOR_THEME @@ -159,21 +165,6 @@ void lcRemoveProfileKey(LC_PROFILE_KEY Key) Settings.remove(QString("%1/%2").arg(Entry.mSection, Entry.mKey)); } -int lcGetDefaultProfileInt(LC_PROFILE_KEY Key) -{ - return gProfileEntries[Key].mDefault.IntValue; -} - -float lcGetDefaultProfileFloat(LC_PROFILE_KEY Key) -{ - return gProfileEntries[Key].mDefault.FloatValue; -} - -QString lcGetDefaultProfileString(LC_PROFILE_KEY Key) -{ - return QString::fromLatin1(gProfileEntries[Key].mDefault.StringValue); -} - int lcGetProfileInt(LC_PROFILE_KEY Key) { lcProfileEntry& Entry = gProfileEntries[Key]; @@ -182,6 +173,14 @@ int lcGetProfileInt(LC_PROFILE_KEY Key) return Settings.value(QString("%1/%2").arg(Entry.mSection, Entry.mKey), Entry.mDefault.IntValue).toInt(); } +uint lcGetProfileUInt(LC_PROFILE_KEY Key) +{ + lcProfileEntry& Entry = gProfileEntries[Key]; + QSettings Settings; + + return Settings.value(QString("%1/%2").arg(Entry.mSection, Entry.mKey), Entry.mDefault.UIntValue).toUInt(); +} + float lcGetProfileFloat(LC_PROFILE_KEY Key) { lcProfileEntry& Entry = gProfileEntries[Key]; @@ -222,6 +221,14 @@ void lcSetProfileInt(LC_PROFILE_KEY Key, int Value) Settings.setValue(QString("%1/%2").arg(Entry.mSection, Entry.mKey), Value); } +void lcSetProfileUInt(LC_PROFILE_KEY Key, uint Value) +{ + lcProfileEntry& Entry = gProfileEntries[Key]; + QSettings Settings; + + Settings.setValue(QString("%1/%2").arg(Entry.mSection, Entry.mKey), Value); +} + void lcSetProfileFloat(LC_PROFILE_KEY Key, float Value) { lcProfileEntry& Entry = gProfileEntries[Key]; diff --git a/common/lc_profile.h b/common/lc_profile.h index abfef7e5..da9edc9e 100644 --- a/common/lc_profile.h +++ b/common/lc_profile.h @@ -40,6 +40,12 @@ enum LC_PROFILE_KEY LC_PROFILE_VIEW_SPHERE_COLOR, LC_PROFILE_VIEW_SPHERE_TEXT_COLOR, LC_PROFILE_VIEW_SPHERE_HIGHLIGHT_COLOR, + LC_PROFILE_OBJECT_SELECTED_COLOR, + LC_PROFILE_OBJECT_FOCUSED_COLOR, + LC_PROFILE_CAMERA_COLOR, + LC_PROFILE_LIGHT_COLOR, + LC_PROFILE_CONTROL_POINT_COLOR, + LC_PROFILE_CONTROL_POINT_FOCUSED_COLOR, LC_PROFILE_LANGUAGE, LC_PROFILE_COLOR_THEME, @@ -114,7 +120,7 @@ class lcProfileEntry { public: lcProfileEntry(const char* Section, const char* Key, int DefaultValue); - lcProfileEntry(const char* Section, const char* Key, unsigned int DefaultValue); + lcProfileEntry(const char* Section, const char* Key, uint DefaultValue); lcProfileEntry(const char* Section, const char* Key, float DefaultValue); lcProfileEntry(const char* Section, const char* Key, const char* DefaultValue); lcProfileEntry(const char* Section, const char* Key, const QStringList& StringList); @@ -128,6 +134,7 @@ public: union { int IntValue; + uint UIntValue; float FloatValue; const char* StringValue; } mDefault; @@ -135,17 +142,15 @@ public: void lcRemoveProfileKey(LC_PROFILE_KEY Key); -int lcGetDefaultProfileInt(LC_PROFILE_KEY Key); -float lcGetDefaultProfileFloat(LC_PROFILE_KEY Key); -QString lcGetDefaultProfileString(LC_PROFILE_KEY Key); - int lcGetProfileInt(LC_PROFILE_KEY Key); +uint lcGetProfileUInt(LC_PROFILE_KEY Key); float lcGetProfileFloat(LC_PROFILE_KEY Key); QString lcGetProfileString(LC_PROFILE_KEY Key); QStringList lcGetProfileStringList(LC_PROFILE_KEY Key); QByteArray lcGetProfileBuffer(LC_PROFILE_KEY Key); void lcSetProfileInt(LC_PROFILE_KEY Key, int Value); +void lcSetProfileUInt(LC_PROFILE_KEY Key, uint Value); void lcSetProfileFloat(LC_PROFILE_KEY Key, float Value); void lcSetProfileString(LC_PROFILE_KEY Key, const QString& Value); void lcSetProfileStringList(LC_PROFILE_KEY Key, const QStringList& Value); diff --git a/common/lc_scene.cpp b/common/lc_scene.cpp index a8b5ff0a..2982abbc 100644 --- a/common/lc_scene.cpp +++ b/common/lc_scene.cpp @@ -155,6 +155,10 @@ void lcScene::DrawOpaqueMeshes(lcContext* Context, bool DrawLit, int PrimitiveTy Context->SetPolygonOffset(lcPolygonOffset::Opaque); + const lcPreferences& Preferences = lcGetPreferences(); + const lcVector4 FocusedColor = lcVector4FromColor(Preferences.mObjectFocusedColor); + const lcVector4 SelectedColor = lcVector4FromColor(Preferences.mObjectSelectedColor); + for (const int MeshIndex : mOpaqueMeshes) { const lcRenderMesh& RenderMesh = mRenderMeshes[MeshIndex]; @@ -195,11 +199,11 @@ void lcScene::DrawOpaqueMeshes(lcContext* Context, bool DrawLit, int PrimitiveTy break; case lcRenderMeshState::Selected: - Context->SetColorIndexTinted(ColorIndex, lcInterfaceColor::Selected, 0.5f); + Context->SetColorIndexTinted(ColorIndex, SelectedColor, 0.5f); break; case lcRenderMeshState::Focused: - Context->SetColorIndexTinted(ColorIndex, lcInterfaceColor::Focused, 0.5f); + Context->SetColorIndexTinted(ColorIndex, FocusedColor, 0.5f); break; case lcRenderMeshState::Faded: @@ -231,11 +235,11 @@ void lcScene::DrawOpaqueMeshes(lcContext* Context, bool DrawLit, int PrimitiveTy break; case lcRenderMeshState::Selected: - Context->SetInterfaceColor(lcInterfaceColor::Selected); + Context->SetColor(SelectedColor); break; case lcRenderMeshState::Focused: - Context->SetInterfaceColor(lcInterfaceColor::Focused); + Context->SetColor(FocusedColor); break; case lcRenderMeshState::Highlighted: @@ -332,6 +336,10 @@ void lcScene::DrawTranslucentMeshes(lcContext* Context, bool DrawLit, bool DrawF Context->SetPolygonOffset(lcPolygonOffset::Translucent); + const lcPreferences& Preferences = lcGetPreferences(); + const lcVector4 FocusedColor = lcVector4FromColor(Preferences.mObjectFocusedColor); + const lcVector4 SelectedColor = lcVector4FromColor(Preferences.mObjectSelectedColor); + for (const lcTranslucentMeshInstance& MeshInstance : mTranslucentMeshes) { const lcRenderMesh& RenderMesh = mRenderMeshes[MeshInstance.RenderMeshIndex]; @@ -364,11 +372,11 @@ void lcScene::DrawTranslucentMeshes(lcContext* Context, bool DrawLit, bool DrawF break; case lcRenderMeshState::Selected: - Context->SetColorIndexTinted(ColorIndex, lcInterfaceColor::Selected, 0.5f); + Context->SetColorIndexTinted(ColorIndex, SelectedColor, 0.5f); break; case lcRenderMeshState::Focused: - Context->SetColorIndexTinted(ColorIndex, lcInterfaceColor::Focused, 0.5f); + Context->SetColorIndexTinted(ColorIndex, FocusedColor, 0.5f); break; case lcRenderMeshState::Faded: diff --git a/common/light.cpp b/common/light.cpp index 137349af..ab8b46a3 100644 --- a/common/light.cpp +++ b/common/light.cpp @@ -375,12 +375,16 @@ void lcLight::DrawSpotLight(lcContext* Context) const Context->SetVertexFormatPosition(3); Context->SetIndexBufferPointer(Indices); - const float LineWidth = lcGetPreferences().mLineWidth; + const lcPreferences& Preferences = lcGetPreferences(); + const float LineWidth = Preferences.mLineWidth; + const lcVector4 SelectedColor = lcVector4FromColor(Preferences.mObjectSelectedColor); + const lcVector4 FocusedColor = lcVector4FromColor(Preferences.mObjectFocusedColor); + const lcVector4 LightColor = lcVector4FromColor(Preferences.mLightColor); if (!IsSelected()) { Context->SetLineWidth(LineWidth); - Context->SetInterfaceColor(lcInterfaceColor::Light); + Context->SetColor(LightColor); Context->DrawIndexedPrimitives(GL_LINES, 56 + 24 + 2, GL_UNSIGNED_SHORT, 0); } @@ -390,14 +394,14 @@ void lcLight::DrawSpotLight(lcContext* Context) const { Context->SetLineWidth(2.0f * LineWidth); if (IsFocused(LC_LIGHT_SECTION_POSITION)) - Context->SetInterfaceColor(lcInterfaceColor::Focused); + Context->SetColor(FocusedColor); else - Context->SetInterfaceColor(lcInterfaceColor::Selected); + Context->SetColor(SelectedColor); } else { Context->SetLineWidth(LineWidth); - Context->SetInterfaceColor(lcInterfaceColor::Light); + Context->SetColor(LightColor); } Context->DrawIndexedPrimitives(GL_LINES, 56, GL_UNSIGNED_SHORT, 0); @@ -406,20 +410,20 @@ void lcLight::DrawSpotLight(lcContext* Context) const { Context->SetLineWidth(2.0f * LineWidth); if (IsFocused(LC_LIGHT_SECTION_TARGET)) - Context->SetInterfaceColor(lcInterfaceColor::Focused); + Context->SetColor(FocusedColor); else - Context->SetInterfaceColor(lcInterfaceColor::Selected); + Context->SetColor(SelectedColor); } else { Context->SetLineWidth(LineWidth); - Context->SetInterfaceColor(lcInterfaceColor::Light); + Context->SetColor(LightColor); } Context->DrawIndexedPrimitives(GL_LINES, 24, GL_UNSIGNED_SHORT, 56 * 2); Context->SetLineWidth(LineWidth); - Context->SetInterfaceColor(lcInterfaceColor::Light); + Context->SetColor(LightColor); float Radius = tanf(LC_DTOR * mSpotCutoff) * Length; @@ -513,12 +517,23 @@ void lcLight::DrawPointLight(lcContext* Context) const Context->SetWorldMatrix(lcMatrix44Translation(mPosition)); + const lcPreferences& Preferences = lcGetPreferences(); + if (IsFocused(LC_LIGHT_SECTION_POSITION)) - Context->SetInterfaceColor(lcInterfaceColor::Focused); + { + const lcVector4 FocusedColor = lcVector4FromColor(Preferences.mObjectFocusedColor); + Context->SetColor(FocusedColor); + } else if (IsSelected(LC_LIGHT_SECTION_POSITION)) - Context->SetInterfaceColor(lcInterfaceColor::Selected); + { + const lcVector4 SelectedColor = lcVector4FromColor(Preferences.mObjectSelectedColor); + Context->SetColor(SelectedColor); + } else - Context->SetInterfaceColor(lcInterfaceColor::Light); + { + const lcVector4 LightColor = lcVector4FromColor(Preferences.mLightColor); + Context->SetColor(LightColor); + } Context->SetVertexBufferPointer(Vertices); Context->SetVertexFormatPosition(3); diff --git a/common/piece.cpp b/common/piece.cpp index 74064ffb..a2ad945d 100644 --- a/common/piece.cpp +++ b/common/piece.cpp @@ -511,7 +511,9 @@ void lcPiece::BoxTest(lcObjectBoxTest& ObjectBoxTest) const void lcPiece::DrawInterface(lcContext* Context, const lcScene& Scene) const { - const float LineWidth = lcGetPreferences().mLineWidth; + const lcPreferences& Preferences = lcGetPreferences(); + const float LineWidth = Preferences.mLineWidth; + Context->SetLineWidth(2.0f * LineWidth); const lcBoundingBox& BoundingBox = GetBoundingBox(); @@ -559,9 +561,15 @@ void lcPiece::DrawInterface(lcContext* Context, const lcScene& Scene) const Context->SetWorldMatrix(WorldMatrix); if (IsFocused(LC_PIECE_SECTION_POSITION)) - Context->SetInterfaceColor(lcInterfaceColor::Focused); + { + const lcVector4 FocusedColor = lcVector4FromColor(Preferences.mObjectFocusedColor); + Context->SetColor(FocusedColor); + } else - Context->SetInterfaceColor(lcInterfaceColor::Selected); + { + const lcVector4 SelectedColor = lcVector4FromColor(Preferences.mObjectSelectedColor); + Context->SetColor(SelectedColor); + } Context->SetVertexBufferPointer(LineVerts); Context->SetVertexFormatPosition(3); @@ -617,6 +625,9 @@ void lcPiece::DrawInterface(lcContext* Context, const lcScene& Scene) const Context->EnableColorBlend(true); Context->EnableCullFace(true); + const lcVector4 ControlPointColor = lcVector4FromColor(Preferences.mControlPointColor); + const lcVector4 ControlPointFocusedColor = lcVector4FromColor(Preferences.mControlPointFocusedColor); + for (int ControlPointIdx = 0; ControlPointIdx < mControlPoints.GetSize(); ControlPointIdx++) { Context->SetWorldMatrix(lcMul(mControlPoints[ControlPointIdx].Transform, WorldMatrix)); @@ -626,9 +637,9 @@ void lcPiece::DrawInterface(lcContext* Context, const lcScene& Scene) const Context->SetIndexBufferPointer(Indices); if (IsFocused(LC_PIECE_SECTION_CONTROL_POINT_FIRST + ControlPointIdx)) - Context->SetInterfaceColor(lcInterfaceColor::ControlPointFocused); + Context->SetColor(ControlPointFocusedColor); else - Context->SetInterfaceColor(lcInterfaceColor::ControlPoint); + Context->SetColor(ControlPointColor); Context->DrawIndexedPrimitives(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0); } diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index 89f86aad..2080e84b 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -45,6 +45,12 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO connect(ui->ViewSphereColorButton, &QToolButton::clicked, this, &lcQPreferencesDialog::ColorButtonClicked); connect(ui->ViewSphereTextColorButton, &QToolButton::clicked, this, &lcQPreferencesDialog::ColorButtonClicked); connect(ui->ViewSphereHighlightColorButton, &QToolButton::clicked, this, &lcQPreferencesDialog::ColorButtonClicked); + connect(ui->ObjectSelectedColorButton, &QToolButton::clicked, this, &lcQPreferencesDialog::ColorButtonClicked); + connect(ui->ObjectFocusedColorButton, &QToolButton::clicked, this, &lcQPreferencesDialog::ColorButtonClicked); + connect(ui->CameraColorButton, &QToolButton::clicked, this, &lcQPreferencesDialog::ColorButtonClicked); + connect(ui->LightColorButton, &QToolButton::clicked, this, &lcQPreferencesDialog::ColorButtonClicked); + connect(ui->ControlPointColorButton, &QToolButton::clicked, this, &lcQPreferencesDialog::ColorButtonClicked); + connect(ui->ControlPointFocusedColorButton, &QToolButton::clicked, this, &lcQPreferencesDialog::ColorButtonClicked); connect(ui->categoriesTree, SIGNAL(itemSelectionChanged()), this, SLOT(updateParts())); ui->shortcutEdit->installEventFilter(this); connect(ui->commandList, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(commandChanged(QTreeWidgetItem*))); @@ -210,6 +216,12 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO SetButtonPixmap(mOptions->Preferences.mViewSphereColor, ui->ViewSphereColorButton); SetButtonPixmap(mOptions->Preferences.mViewSphereTextColor, ui->ViewSphereTextColorButton); SetButtonPixmap(mOptions->Preferences.mViewSphereHighlightColor, ui->ViewSphereHighlightColorButton); + SetButtonPixmap(mOptions->Preferences.mObjectSelectedColor, ui->ObjectSelectedColorButton); + SetButtonPixmap(mOptions->Preferences.mObjectFocusedColor, ui->ObjectFocusedColorButton); + SetButtonPixmap(mOptions->Preferences.mCameraColor, ui->CameraColorButton); + SetButtonPixmap(mOptions->Preferences.mLightColor, ui->LightColorButton); + SetButtonPixmap(mOptions->Preferences.mControlPointColor, ui->ControlPointColorButton); + SetButtonPixmap(mOptions->Preferences.mControlPointFocusedColor, ui->ControlPointFocusedColorButton); on_studStyleCombo_currentIndexChanged(ui->studStyleCombo->currentIndex()); on_antiAliasing_toggled(); @@ -495,6 +507,38 @@ void lcQPreferencesDialog::ColorButtonClicked() Color = &mOptions->Preferences.mViewSphereHighlightColor; Title = tr("Select View Sphere Highlight Color"); } + else if (Button == ui->ObjectSelectedColorButton) + { + Color = &mOptions->Preferences.mObjectSelectedColor; + Title = tr("Select Objected Selected Color"); + } + else if (Button == ui->ObjectFocusedColorButton) + { + Color = &mOptions->Preferences.mObjectFocusedColor; + Title = tr("Select Object Focused Color"); + } + else if (Button == ui->CameraColorButton) + { + Color = &mOptions->Preferences.mCameraColor; + Title = tr("Select Camera Color"); + } + else if (Button == ui->LightColorButton) + { + Color = &mOptions->Preferences.mLightColor; + Title = tr("Select Light Color"); + } + else if (Button == ui->ControlPointColorButton) + { + Color = &mOptions->Preferences.mControlPointColor; + Title = tr("Select Control Point Color"); + DialogOptions = QColorDialog::ShowAlphaChannel; + } + else if (Button == ui->ControlPointFocusedColorButton) + { + Color = &mOptions->Preferences.mControlPointFocusedColor; + Title = tr("Select Control Point Focused Color"); + DialogOptions = QColorDialog::ShowAlphaChannel; + } else return; diff --git a/qt/lc_qpreferencesdialog.ui b/qt/lc_qpreferencesdialog.ui index 3acb423c..2c53c1ff 100644 --- a/qt/lc_qpreferencesdialog.ui +++ b/qt/lc_qpreferencesdialog.ui @@ -909,8 +909,319 @@ Colors - - + + + + + Interface + + + + + + Marquee Border: + + + + + + + + + + + + + + Inactive View Border: + + + + + + + + + + + + + + Camera Name: + + + + + + + + + + + + + + Marquee Fill: + + + + + + + + + + + + + + Overlay Color: + + + + + + + Axis Icon Labels: + + + + + + + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Active View Border: + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + View Sphere + + + + + + Color: + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Text Color: + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Highlight Color: + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Grid + + + + + + Lines: + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Studs: + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Background @@ -932,6 +1243,22 @@ + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + @@ -1002,162 +1329,114 @@ - - + + - Interface + Objects - - - + + + - Inactive View Border: + Light: - - + + - - + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + - Overlay Color: + Focused: - - + + - Active View Border: + + + + + + + + Control Point Focused: - + - - + + + + + + + + + + + + + + + + - + - Camera Name: + Control Point: - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - + + - + Selected: - - + + - Axis Icon Labels: + Camera: - - - - - - - - - - - Marquee Border: - - - - - - - - - - - - - - Marquee Fill: - - - - - - - - - - - - - - - - - Grid - - - - - - Lines: - - - - - - - - - - - - - - Studs: - - - - - - - - - - - - + + Qt::Horizontal @@ -1172,83 +1451,6 @@ - - - - View Sphere - - - - - - Color: - - - - - - - - - - - - - - Text Color: - - - - - - - - - - - - - - Highlight Color: - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -1826,6 +2028,12 @@ BackgroundGradientRadio BackgroundGradient1ColorButton BackgroundGradient2ColorButton + ObjectSelectedColorButton + ObjectFocusedColorButton + CameraColorButton + LightColorButton + ControlPointColorButton + ControlPointFocusedColorButton ActiveViewColorButton InactiveViewColorButton TextColorButton