mirror of
https://github.com/leozide/leocad.git
synced 2026-07-28 04:07:11 +00:00
Replaced hardcoded stud style values with an enum.
This commit is contained in:
+10
-11
@@ -340,7 +340,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
||||
Options.ImageWidth = lcGetProfileInt(LC_PROFILE_IMAGE_WIDTH);
|
||||
Options.ImageHeight = lcGetProfileInt(LC_PROFILE_IMAGE_HEIGHT);
|
||||
Options.AASamples = lcGetProfileInt(LC_PROFILE_ANTIALIASING_SAMPLES);
|
||||
Options.StudStyle = lcGetProfileInt(LC_PROFILE_STUD_STYLE);
|
||||
Options.StudStyle = static_cast<lcStudStyle>(lcGetProfileInt(LC_PROFILE_STUD_STYLE));
|
||||
Options.ImageStart = 0;
|
||||
Options.ImageEnd = 0;
|
||||
Options.CameraPosition[0] = lcVector3(0.0f, 0.0f, 0.0f);
|
||||
@@ -655,7 +655,12 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
||||
}
|
||||
}
|
||||
else if (Option == QLatin1String("-ss") || Option == QLatin1String("--stud-style"))
|
||||
ParseInteger(Options.StudStyle, 0, 7);
|
||||
{
|
||||
int StudStyle;
|
||||
|
||||
if (ParseInteger(StudStyle, 0, static_cast<int>(lcStudStyle::Count) - 1))
|
||||
Options.StudStyle = static_cast<lcStudStyle>(StudStyle);
|
||||
}
|
||||
else if (Option == QLatin1String("-obj") || Option == QLatin1String("--export-wavefront"))
|
||||
{
|
||||
Options.SaveWavefront = true;
|
||||
@@ -1105,7 +1110,7 @@ void lcApplication::ShowPreferencesDialog()
|
||||
{
|
||||
lcPreferencesDialogOptions Options;
|
||||
int CurrentAASamples = lcGetProfileInt(LC_PROFILE_ANTIALIASING_SAMPLES);
|
||||
int CurrentStudStyle = lcGetProfileInt(LC_PROFILE_STUD_STYLE);
|
||||
lcStudStyle CurrentStudStyle = lcGetPiecesLibrary()->GetStudStyle();
|
||||
|
||||
Options.Preferences = mPreferences;
|
||||
|
||||
@@ -1156,7 +1161,7 @@ void lcApplication::ShowPreferencesDialog()
|
||||
lcSetProfileString(LC_PROFILE_LANGUAGE, Options.Language);
|
||||
lcSetProfileInt(LC_PROFILE_CHECK_UPDATES, Options.CheckForUpdates);
|
||||
lcSetProfileInt(LC_PROFILE_ANTIALIASING_SAMPLES, Options.AASamples);
|
||||
lcSetProfileInt(LC_PROFILE_STUD_STYLE, Options.StudStyle);
|
||||
lcSetProfileInt(LC_PROFILE_STUD_STYLE, static_cast<int>(Options.StudStyle));
|
||||
|
||||
if (LanguageChanged || LibraryChanged || ColorsChanged || AAChanged)
|
||||
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Some changes will only take effect the next time you start LeoCAD."));
|
||||
@@ -1200,16 +1205,10 @@ void lcApplication::ShowPreferencesDialog()
|
||||
|
||||
if (StudStyleChanged)
|
||||
{
|
||||
lcSetProfileInt(LC_PROFILE_STUD_STYLE, Options.StudStyle);
|
||||
lcSetProfileInt(LC_PROFILE_STUD_STYLE, static_cast<int>(Options.StudStyle));
|
||||
lcGetPiecesLibrary()->SetStudStyle(Options.StudStyle, true);
|
||||
}
|
||||
|
||||
// TODO: printing preferences
|
||||
/*
|
||||
strcpy(opts.strFooter, m_strFooter);
|
||||
strcpy(opts.strHeader, m_strHeader);
|
||||
*/
|
||||
|
||||
gMainWindow->SetShadingMode(Options.Preferences.mShadingMode);
|
||||
lcView::UpdateAllViews();
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ struct lcCommandLineOptions
|
||||
int ImageWidth;
|
||||
int ImageHeight;
|
||||
int AASamples;
|
||||
int StudStyle;
|
||||
lcStudStyle StudStyle;
|
||||
lcStep ImageStart;
|
||||
lcStep ImageEnd;
|
||||
lcVector3 CameraPosition[3];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "lc_global.h"
|
||||
#include "lc_colors.h"
|
||||
#include "lc_file.h"
|
||||
#include "lc_library.h"
|
||||
#include <float.h>
|
||||
|
||||
std::vector<lcColor> gColorList;
|
||||
@@ -209,9 +210,9 @@ int lcGetBrickLinkColor(int ColorIndex)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lcAdjustStudStyleColors(int StudStyle)
|
||||
static void lcAdjustStudStyleColors(lcStudStyle StudStyle)
|
||||
{
|
||||
if (StudStyle < 6)
|
||||
if (StudStyle != lcStudStyle::HighContrast && StudStyle != lcStudStyle::HighContrastLogo)
|
||||
return;
|
||||
|
||||
for (lcColor& Color : gColorList)
|
||||
@@ -228,7 +229,7 @@ static void lcAdjustStudStyleColors(int StudStyle)
|
||||
}
|
||||
}
|
||||
|
||||
bool lcLoadColorFile(lcFile& File, int StudStyle)
|
||||
bool lcLoadColorFile(lcFile& File, lcStudStyle StudStyle)
|
||||
{
|
||||
char Line[1024], Token[1024];
|
||||
std::vector<lcColor>& Colors = gColorList;
|
||||
@@ -452,7 +453,7 @@ bool lcLoadColorFile(lcFile& File, int StudStyle)
|
||||
return Colors.size() > 3;
|
||||
}
|
||||
|
||||
void lcLoadDefaultColors(int StudStyle)
|
||||
void lcLoadDefaultColors(lcStudStyle StudStyle)
|
||||
{
|
||||
lcDiskFile ConfigFile(":/resources/ldconfig.ldr");
|
||||
|
||||
|
||||
+2
-2
@@ -48,8 +48,8 @@ extern int gNumUserColors;
|
||||
extern int gEdgeColor;
|
||||
extern int gDefaultColor;
|
||||
|
||||
void lcLoadDefaultColors(int StudStyle);
|
||||
bool lcLoadColorFile(lcFile& File, int StudStyle);
|
||||
void lcLoadDefaultColors(lcStudStyle StudStyle);
|
||||
bool lcLoadColorFile(lcFile& File, lcStudStyle StudStyle);
|
||||
int lcGetColorIndex(quint32 ColorCode);
|
||||
int lcGetBrickLinkColor(int ColorIndex);
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ struct lcModelPartsEntry;
|
||||
struct lcMinifig;
|
||||
enum class lcViewpoint;
|
||||
enum class lcShadingMode;
|
||||
enum class lcStudStyle;
|
||||
class lcInstructions;
|
||||
struct lcInstructionsPageSetup;
|
||||
struct lcObjectRayTest;
|
||||
|
||||
+21
-13
@@ -41,7 +41,7 @@ lcPiecesLibrary::lcPiecesLibrary()
|
||||
mBuffersDirty = false;
|
||||
mHasUnofficial = false;
|
||||
mCancelLoading = false;
|
||||
mStudStyle = lcGetProfileInt(LC_PROFILE_STUD_STYLE);
|
||||
mStudStyle = static_cast<lcStudStyle>(lcGetProfileInt(LC_PROFILE_STUD_STYLE));
|
||||
}
|
||||
|
||||
lcPiecesLibrary::~lcPiecesLibrary()
|
||||
@@ -312,16 +312,24 @@ void lcPiecesLibrary::UpdateStudStyleSource()
|
||||
|
||||
mZipFiles[static_cast<int>(lcZipFileType::StudStyle)].reset();
|
||||
|
||||
if (!mStudStyle)
|
||||
if (mStudStyle == lcStudStyle::Plain)
|
||||
return;
|
||||
|
||||
std::unique_ptr<lcDiskFile> StudStyleFile;
|
||||
if (mStudStyle < 6)
|
||||
StudStyleFile = std::unique_ptr<lcDiskFile>(new lcDiskFile(QString(":/resources/studlogo%1.zip").arg(QString::number(mStudStyle))));
|
||||
else if (mStudStyle == 6)
|
||||
StudStyleFile = std::unique_ptr<lcDiskFile>(new lcDiskFile(QString(":/resources/studslegostyle1.zip")));
|
||||
else
|
||||
StudStyleFile = std::unique_ptr<lcDiskFile>(new lcDiskFile(QString(":/resources/studslegostyle2.zip")));
|
||||
const QLatin1String FileNames[] =
|
||||
{
|
||||
QLatin1String(), // Plain
|
||||
QLatin1String(":/resources/studlogo1.zip"), // ThinLinesLogo
|
||||
QLatin1String(":/resources/studlogo2.zip"), // OutlineLogo
|
||||
QLatin1String(":/resources/studlogo3.zip"), // SharpTopLogo
|
||||
QLatin1String(":/resources/studlogo4.zip"), // RoundedTopLogo
|
||||
QLatin1String(":/resources/studlogo5.zip"), // FlattenedLogo
|
||||
QLatin1String(":/resources/studslegostyle1.zip"), // HighContrast
|
||||
QLatin1String(":/resources/studslegostyle2.zip") // HighContrastLogo
|
||||
};
|
||||
|
||||
LC_ARRAY_SIZE_CHECK(FileNames, lcStudStyle::Count);
|
||||
|
||||
std::unique_ptr<lcDiskFile> StudStyleFile(new lcDiskFile(FileNames[static_cast<int>(mStudStyle)]));
|
||||
|
||||
if (StudStyleFile->Open(QIODevice::ReadOnly))
|
||||
OpenArchive(std::move(StudStyleFile), lcZipFileType::StudStyle);
|
||||
@@ -1082,7 +1090,7 @@ bool lcPiecesLibrary::LoadCachePiece(PieceInfo* Info)
|
||||
if (MeshData.ReadBuffer((char*)&Flags, sizeof(Flags)) == 0)
|
||||
return false;
|
||||
|
||||
if (Flags != mStudStyle)
|
||||
if (Flags != static_cast<qint32>(mStudStyle))
|
||||
return false;
|
||||
|
||||
lcMesh* Mesh = new lcMesh;
|
||||
@@ -1102,7 +1110,7 @@ bool lcPiecesLibrary::SaveCachePiece(PieceInfo* Info)
|
||||
{
|
||||
lcMemFile MeshData;
|
||||
|
||||
const qint32 Flags = mStudStyle;
|
||||
const qint32 Flags = static_cast<qint32>(mStudStyle);
|
||||
if (MeshData.WriteBuffer((char*)&Flags, sizeof(Flags)) == 0)
|
||||
return false;
|
||||
|
||||
@@ -1534,7 +1542,7 @@ bool lcPiecesLibrary::SupportsStudStyle() const
|
||||
return true;
|
||||
}
|
||||
|
||||
void lcPiecesLibrary::SetStudStyle(int StudStyle, bool Reload)
|
||||
void lcPiecesLibrary::SetStudStyle(lcStudStyle StudStyle, bool Reload)
|
||||
{
|
||||
if (mStudStyle == StudStyle)
|
||||
return;
|
||||
@@ -1897,7 +1905,7 @@ bool lcPiecesLibrary::LoadBuiltinPieces()
|
||||
}
|
||||
}
|
||||
|
||||
lcLoadDefaultColors(0);
|
||||
lcLoadDefaultColors(lcStudStyle::Plain);
|
||||
lcLoadDefaultCategories(true);
|
||||
lcSynthInit();
|
||||
|
||||
|
||||
+16
-3
@@ -10,6 +10,19 @@ class PieceInfo;
|
||||
class lcZipFile;
|
||||
class lcLibraryMeshData;
|
||||
|
||||
enum class lcStudStyle
|
||||
{
|
||||
Plain,
|
||||
ThinLinesLogo,
|
||||
OutlineLogo,
|
||||
SharpTopLogo,
|
||||
RoundedTopLogo,
|
||||
FlattenedLogo,
|
||||
HighContrast,
|
||||
HighContrastLogo,
|
||||
Count
|
||||
};
|
||||
|
||||
enum class lcZipFileType
|
||||
{
|
||||
Official,
|
||||
@@ -139,9 +152,9 @@ public:
|
||||
bool LoadPrimitive(lcLibraryPrimitive* Primitive);
|
||||
|
||||
bool SupportsStudStyle() const;
|
||||
void SetStudStyle(int StudStyle, bool Reload);
|
||||
void SetStudStyle(lcStudStyle StudStyle, bool Reload);
|
||||
|
||||
int GetStudStyle() const
|
||||
lcStudStyle GetStudStyle() const
|
||||
{
|
||||
return mStudStyle;
|
||||
}
|
||||
@@ -203,7 +216,7 @@ protected:
|
||||
QMutex mTextureMutex;
|
||||
std::vector<lcTexture*> mTextureUploads;
|
||||
|
||||
int mStudStyle;
|
||||
lcStudStyle mStudStyle;
|
||||
|
||||
QString mCachePath;
|
||||
qint64 mArchiveCheckSum[4];
|
||||
|
||||
+1
-1
@@ -492,7 +492,7 @@ bool lcMesh::FileSave(lcMemFile& File)
|
||||
|
||||
int lcMesh::GetLodIndex(float Distance) const
|
||||
{
|
||||
if (lcGetPiecesLibrary()->GetStudStyle())
|
||||
if (lcGetPiecesLibrary()->GetStudStyle() != lcStudStyle::Plain) // todo: support low lod studs
|
||||
return LC_MESH_LOD_HIGH;
|
||||
|
||||
if (mLods[LC_MESH_LOD_LOW].NumSections && (Distance > mRadius))
|
||||
|
||||
@@ -164,7 +164,7 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO
|
||||
if (!lcGetPiecesLibrary()->SupportsStudStyle())
|
||||
ui->studStyleCombo->setEnabled(false);
|
||||
|
||||
ui->studStyleCombo->setCurrentIndex(mOptions->StudStyle);
|
||||
ui->studStyleCombo->setCurrentIndex(static_cast<int>(mOptions->StudStyle));
|
||||
|
||||
if (!gSupportsShaderObjects)
|
||||
ui->ShadingMode->removeItem(static_cast<int>(lcShadingMode::DefaultLights));
|
||||
@@ -295,7 +295,7 @@ void lcQPreferencesDialog::accept()
|
||||
|
||||
mOptions->Preferences.mShadingMode = (lcShadingMode)ui->ShadingMode->currentIndex();
|
||||
|
||||
mOptions->StudStyle = ui->studStyleCombo->currentIndex();
|
||||
mOptions->StudStyle = static_cast<lcStudStyle>(ui->studStyleCombo->currentIndex());
|
||||
|
||||
mOptions->Preferences.mDrawPreviewAxis = ui->PreviewAxisIconCheckBox->isChecked();
|
||||
mOptions->Preferences.mPreviewViewSphereEnabled = ui->PreviewViewSphereSizeCombo->currentIndex() > 0;
|
||||
|
||||
@@ -18,7 +18,7 @@ struct lcPreferencesDialogOptions
|
||||
int CheckForUpdates;
|
||||
|
||||
int AASamples;
|
||||
int StudStyle;
|
||||
lcStudStyle StudStyle;
|
||||
|
||||
std::vector<lcLibraryCategory> Categories;
|
||||
bool CategoriesModified;
|
||||
|
||||
Reference in New Issue
Block a user