Skip to content

Commit

Permalink
Better --version, minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
deathkiller committed Nov 11, 2023
1 parent 64c7840 commit 3ad0031
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 17 deletions.
3 changes: 3 additions & 0 deletions Sources/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#if !defined(NCINE_VERSION)
# define NCINE_VERSION "2.2.1"
#endif
#if !defined(NCINE_BUILD_YEAR)
# define NCINE_BUILD_YEAR "2023"
#endif
#if !defined(NCINE_LINUX_PACKAGE)
# define NCINE_LINUX_PACKAGE NCINE_APP_NAME
#endif
Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>NSHumanReadableCopyright</key>
<string>© 2016-@CPACK_PACKAGE_VERSION_YEAR@ @CPACK_PACKAGE_VENDOR@</string>
<string>© 2016-@NCINE_BUILD_YEAR@ @CPACK_PACKAGE_VENDOR@</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/UI/Menu/InGameMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ namespace Jazz2::UI::Menu
// Copyright
Vector2f bottomLeft = bottomRight;
bottomLeft.X = 24.0f;
_owner->DrawStringShadow("© 2016-2023 Dan R."_s, charOffset, bottomLeft.X, bottomLeft.Y, IMenuContainer::FontLayer,
_owner->DrawStringShadow("© 2016-" NCINE_BUILD_YEAR " Dan R."_s, charOffset, bottomLeft.X, bottomLeft.Y, IMenuContainer::FontLayer,
Alignment::BottomLeft, Colorf(0.45f, 0.45f, 0.45f, 0.5f), 0.7f, 0.4f, 1.2f, 1.2f, 0.46f, 0.8f);

if (!_owner->_sections.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/UI/Menu/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ namespace Jazz2::UI::Menu
// Copyright
Vector2f bottomLeft = bottomRight;
bottomLeft.X = 24.0f;
_owner->DrawStringShadow("© 2016-2023 Dan R."_s, charOffset, bottomLeft.X, bottomLeft.Y, IMenuContainer::FontLayer,
_owner->DrawStringShadow("© 2016-" NCINE_BUILD_YEAR " Dan R."_s, charOffset, bottomLeft.X, bottomLeft.Y, IMenuContainer::FontLayer,
Alignment::BottomLeft, Font::DefaultColor, 0.7f, 0.4f, 1.2f, 1.2f, 0.46f, 0.8f);

#if defined(DEATH_TARGET_WINDOWS_RT)
Expand Down
37 changes: 35 additions & 2 deletions Sources/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,23 +1469,56 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdSh
}, __argc, __wargv);
}
#else
#if defined(DEATH_TARGET_UNIX)
int PrintVersion(bool logoVisible)
{
if (logoVisible) {
static const char Copyright[] = "© 2016-" NCINE_BUILD_YEAR " Dan R.";
static const char Reset[] = "\033[0m";
static const char Bold[] = "\033[1m";
static const char Faint[] = "\033[2m";

constexpr std::size_t LogoWidth = 58;

char padding[(LogoWidth / 2) + 2];
std::size_t paddingLength = (LogoWidth - (arraySize(NCINE_APP_NAME) - 1) - 1 - (arraySize(NCINE_VERSION) - 1) + 1) / 2;
for (std::size_t j = 0; j < paddingLength; j++) {
padding[j] = ' ';
}
padding[paddingLength] = '\0';
fprintf(stdout, "%s%s%s %s%s%s\n", padding, Reset, NCINE_APP_NAME, Bold, NCINE_VERSION, Reset);

paddingLength = (LogoWidth - (arraySize(Copyright) - 1) + 1) / 2;
for (std::size_t j = 0; j < paddingLength; j++) {
padding[j] = ' ';
}
padding[paddingLength] = '\0';
fprintf(stdout, "%s%s%s%s%s\n", padding, Reset, Faint, Copyright, Reset);
} else {
fputs(NCINE_APP_NAME " " NCINE_VERSION "\n", stdout);
}
return 0;
}
#endif

int main(int argc, char** argv)
{
bool logoVisible = false;
#if defined(DEATH_TRACE) && (defined(DEATH_TARGET_APPLE) || defined(DEATH_TARGET_UNIX))
bool hasVirtualTerminal = isatty(1);
if (hasVirtualTerminal) {
const char* term = ::getenv("TERM");
if (term != nullptr && strcmp(term, "xterm-256color") == 0) {
fwrite(TermLogo, sizeof(unsigned char), arraySize(TermLogo), stdout);
logoVisible = true;
}
}
#endif
#if defined(DEATH_TARGET_UNIX)
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--version") == 0) {
// Just print current version below the logo and quit
fputs(NCINE_VERSION, stdout);
return 0;
return PrintVersion(logoVisible);
}
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion Sources/Resources.rc.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ VS_VERSION_INFO VERSIONINFO
VALUE "FileDescription", "@NCINE_APP_NAME@: @NCINE_APP_DESCRIPTION@"
VALUE "FileVersion", "@NCINE_VERSION_MAJOR@.@NCINE_VERSION_MINOR@.@PACKAGE_VERSION_PATCH@.@PACKAGE_VERSION_REV@"
VALUE "InternalName", "@PACKAGE_EXECUTABLE_NAME@"
VALUE "LegalCopyright", "© 2016-@PACKAGE_VERSION_YEAR@ @NCINE_APP_VENDOR@"
VALUE "LegalCopyright", "© 2016-@NCINE_BUILD_YEAR@ @NCINE_APP_VENDOR@"
#ifdef DEATH_DEBUG
VALUE "OriginalFilename", "@PACKAGE_EXECUTABLE_NAME@@DEATH_DEBUG_POSTFIX@@PACKAGE_EXTENSION@"
#else
Expand Down
8 changes: 4 additions & 4 deletions Sources/nCine/Graphics/RenderBatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace nCine
// Split point for the maximum batch size
while (lastSplit < endSplit) {
unsigned int currentMaxBatchSize = maxBatchSize;
const int shaderBatchSize = batchedShader->batchSize();
const unsigned int shaderBatchSize = batchedShader->batchSize();
if (shaderBatchSize > 0 && currentMaxBatchSize > shaderBatchSize) {
currentMaxBatchSize = shaderBatchSize;
}
Expand All @@ -80,7 +80,7 @@ namespace nCine
// Handling early splits while collecting (not enough UBO free space)
RenderCommand* batchCommand = collectCommands(start, end, start);
destQueue.push_back(batchCommand);
lastSplit = start - srcQueue.begin();
lastSplit = (unsigned int)(start - srcQueue.begin());
}
}

Expand Down Expand Up @@ -285,7 +285,7 @@ namespace nCine

if (batchedShaderHasAttributes) {
const unsigned int numVertices = command->geometry().numVertices();
const int meshIndex = it - start;
const int meshIndex = (int)(it - start);
const float* srcVtx = command->geometry().hostVertexPointer();
FATAL_ASSERT(srcVtx != nullptr);

Expand Down Expand Up @@ -355,7 +355,7 @@ namespace nCine
}
batchCommand->material().setBlendingEnabled(refCommand->material().isBlendingEnabled());
batchCommand->material().setBlendingFactors(refCommand->material().srcBlendingFactor(), refCommand->material().destBlendingFactor());
batchCommand->setBatchSize(nextStart - start);
batchCommand->setBatchSize((int)(nextStart - start));
batchCommand->material().uniformBlock(Material::InstancesBlockName)->setUsedSize(instancesBlockOffset);
batchCommand->setLayer(refCommand->layer());
batchCommand->setVisitOrder(refCommand->visitOrder());
Expand Down
4 changes: 2 additions & 2 deletions Sources/nCine/Graphics/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,11 @@ namespace nCine
return RenderResources::binaryShaderCache().saveToCache(shaderName, shaderVersion, glShaderProgram_.get());
}

bool Shader::setAttribute(const char* name, int stride, unsigned long int pointer)
bool Shader::setAttribute(const char* name, int stride, void* pointer)
{
GLVertexFormat::Attribute* attribute = glShaderProgram_->attribute(name);
if (attribute != nullptr) {
attribute->setVboParameters(stride, reinterpret_cast<void*>(pointer));
attribute->setVboParameters(stride, pointer);
}
return (attribute != nullptr);
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/nCine/Graphics/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace nCine
bool saveToCache(const char* shaderName, uint64_t shaderVersion) const;

/// Sets the VBO stride and pointer for the specified vertex attribute
bool setAttribute(const char* name, int stride, unsigned long int pointer);
bool setAttribute(const char* name, int stride, void* pointer);

/// Returns true if the shader is linked and can therefore be used
bool isLinked() const;
Expand Down
4 changes: 4 additions & 0 deletions cmake/ncine_compiler_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
include(CheckStructHasMember)

target_compile_definitions(${NCINE_APP} PUBLIC "NCINE_VERSION=\"${NCINE_VERSION}\"")

string(TIMESTAMP NCINE_BUILD_YEAR "%Y")
target_compile_definitions(${NCINE_APP} PUBLIC "NCINE_BUILD_YEAR=\"${NCINE_BUILD_YEAR}\"")

if(NCINE_OVERRIDE_CONTENT_PATH)
message(STATUS "Using overriden `Content` path: ${NCINE_OVERRIDE_CONTENT_PATH}")
target_compile_definitions(${NCINE_APP} PUBLIC "NCINE_OVERRIDE_CONTENT_PATH=\"${NCINE_OVERRIDE_CONTENT_PATH}\"")
Expand Down
3 changes: 1 addition & 2 deletions cmake/ncine_generated_sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ if(WIN32)
if(WINDOWS_PHONE OR WINDOWS_STORE)
set(PACKAGE_EXTENSION ".msixbundle")
endif()
string(TIMESTAMP PACKAGE_VERSION_YEAR "%Y")

set(VERSION_RC_FILE "${GENERATED_SOURCE_DIR}/version.rc")
set(VERSION_RC_FILE "${GENERATED_SOURCE_DIR}/Version.rc")
configure_file("${NCINE_SOURCE_DIR}/Resources.rc.in" ${VERSION_RC_FILE} @ONLY)
list(APPEND GENERATED_SOURCES ${VERSION_RC_FILE})

Expand Down
2 changes: 0 additions & 2 deletions cmake/ncine_installation.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/LICENSE")
endif()
set(CPACK_PACKAGE_CHECKSUM MD5)

string(TIMESTAMP CPACK_PACKAGE_VERSION_YEAR "%Y")

if(MSVC)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "C:/Games/${NCINE_APP_NAME}/" CACHE PATH "..." FORCE)
Expand Down

0 comments on commit 3ad0031

Please sign in to comment.