Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
deathkiller committed Jun 15, 2024
1 parent f33273f commit 33bbb3a
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Sources/Jazz2/UI/Menu/ImportSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ namespace Jazz2::UI::Menu
{
Recti contentBounds = _root->GetContentBounds();
Vector2f center = Vector2f(contentBounds.X + contentBounds.W * 0.5f, contentBounds.Y + contentBounds.H * 0.5f);
float topLine = contentBounds.Y + 31.0f;
float bottomLine = contentBounds.Y + contentBounds.H - 42.0f;
float topLine = contentBounds.Y + TopLine + 28.0f;
float bottomLine = contentBounds.Y + contentBounds.H - BottomLine;

_root->DrawElement(MenuDim, center.X, (topLine + bottomLine) * 0.5f, IMenuContainer::BackgroundLayer,
Alignment::Center, Colorf::Black, Vector2f(680.0f, bottomLine - topLine + 2), Vector4f(1.0f, 0.0f, 0.4f, 0.3f));
Expand All @@ -63,11 +63,11 @@ namespace Jazz2::UI::Menu
center.Y = topLine + (bottomLine - topLine) * 0.4f;
int32_t charOffset = 0;

_root->DrawStringShadow(_("Import Episodes"), charOffset, center.X, topLine - 21.0f - 34.0f, IMenuContainer::FontLayer,
_root->DrawStringShadow(_("Import Episodes"), charOffset, center.X, contentBounds.Y + TopLine - 21.0f, IMenuContainer::FontLayer,
Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f);

// TRANSLATORS: Header in Import Episodes section
_root->DrawStringShadow(_("Select files of your original game to unlock additional episodes"), charOffset, center.X, topLine - 21.0f - 4.0f, IMenuContainer::FontLayer,
_root->DrawStringShadow(_("Select files of your original game to unlock additional episodes"), charOffset, center.X, topLine - 15.0f - 4.0f, IMenuContainer::FontLayer,
Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.76f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f);

switch (_state) {
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 @@ -127,7 +127,7 @@ namespace Jazz2::UI::Menu
}

if (_owner->_touchButtonsTimer > 0.0f && _owner->_sections.size() >= 2) {
_owner->DrawElement(MenuLineArrow, -1, static_cast<float>(center.X), titleY - 30.0f, ShadowLayer, Alignment::Center, Colorf::White);
_owner->DrawElement(MenuLineArrow, -1, static_cast<float>(center.X), titleY - (ViewSize.Y >= 300 ? 30.0f : 12.0f), ShadowLayer, Alignment::Center, Colorf::White);
}

// Title
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 @@ -222,7 +222,7 @@ namespace Jazz2::UI::Menu
float logoTextTranslate = (1.0f - _owner->_logoTransition) * 60.0f;

if (_owner->_touchButtonsTimer > 0.0f && _owner->_sections.size() >= 2) {
_owner->DrawElement(MenuLineArrow, -1, static_cast<float>(center.X), titleY - 30.0f, ShadowLayer, Alignment::Center, Colorf::White);
_owner->DrawElement(MenuLineArrow, -1, static_cast<float>(center.X), titleY - (ViewSize.Y >= 300 ? 30.0f : 12.0f), ShadowLayer, Alignment::Center, Colorf::White);
}

// Title
Expand Down
8 changes: 4 additions & 4 deletions Sources/nCine/Backends/GlfwGfxDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,12 @@ namespace nCine
glfwWindowHint(GLFW_ALPHA_BITS, static_cast<int>(displayMode_.alphaBits()));
glfwWindowHint(GLFW_DEPTH_BITS, static_cast<int>(displayMode_.depthBits()));
glfwWindowHint(GLFW_STENCIL_BITS, static_cast<int>(displayMode_.stencilBits()));
#if defined(WITH_OPENGLES)
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
#elif defined(DEATH_TARGET_EMSCRIPTEN)
#if defined(DEATH_TARGET_EMSCRIPTEN)
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
glfwWindowHint(GLFW_FOCUSED, 1);
#elif defined(WITH_OPENGLES)
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
#else
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, glContextInfo_.forwardCompatible ? GLFW_TRUE : GLFW_FALSE);
glfwWindowHint(GLFW_OPENGL_PROFILE, glContextInfo_.coreProfile ? GLFW_OPENGL_CORE_PROFILE : GLFW_OPENGL_COMPAT_PROFILE);
Expand Down
20 changes: 19 additions & 1 deletion Sources/nCine/Graphics/IGfxDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ namespace nCine
float pixelRatio2 = emscripten_get_device_pixel_ratio();
LOGI("Canvas was resized to %ix%i (canvas size is %ix%i; ratio is %f)", (int)(event->windowInnerWidth * pixelRatio2), (int)(event->windowInnerHeight * pixelRatio2), (int)cssWidth, (int)cssHeight, pixelRatio2);
# endif

if (event->windowInnerWidth > 0 && event->windowInnerHeight > 0) {
float pixelRatio = emscripten_get_device_pixel_ratio();
IGfxDevice* gfxDevice = static_cast<IGfxDevice*>(userData);
#if defined(GLFW_HAS_EMSCRIPTEN_HDPI)
// `contrib.glfw3` should handle HiDPI automatically
gfxDevice->setResolutionInternal(static_cast<int>(event->windowInnerWidth), static_cast<int>(event->windowInnerHeight));
#else
float pixelRatio = emscripten_get_device_pixel_ratio();
gfxDevice->setResolutionInternal(static_cast<int>(event->windowInnerWidth * pixelRatio), static_cast<int>(event->windowInnerHeight * pixelRatio));
#endif
}
return 1;
}
Expand All @@ -47,8 +53,13 @@ namespace nCine
gfxDevice->isFullscreen_ = event->isFullscreen;

if (event->elementWidth > 0 && event->elementHeight > 0) {
#if defined(GLFW_HAS_EMSCRIPTEN_HDPI)
// `contrib.glfw3` should handle HiDPI automatically
gfxDevice->setResolutionInternal(static_cast<int>(event->elementWidth), static_cast<int>(event->elementHeight));
#else
float pixelRatio = emscripten_get_device_pixel_ratio();
gfxDevice->setResolutionInternal(static_cast<int>(event->elementWidth * pixelRatio), static_cast<int>(event->elementHeight * pixelRatio));
#endif
}

return 1;
Expand Down Expand Up @@ -76,9 +87,16 @@ namespace nCine
double cssHeight = 0.0;
// Referring to the first element of type <canvas> in the DOM
emscripten_get_element_css_size("canvas", &cssWidth, &cssHeight);
# if defined(GLFW_HAS_EMSCRIPTEN_HDPI)
// `contrib.glfw3` should handle HiDPI automatically
width_ = static_cast<int>(cssWidth);
height_ = static_cast<int>(cssHeight);
# else
float pixelRatio = emscripten_get_device_pixel_ratio();
width_ = static_cast<int>(cssWidth * pixelRatio);
height_ = static_cast<int>(cssHeight * pixelRatio);
# endif

drawableWidth_ = width_;
drawableHeight_ = height_;

Expand Down
4 changes: 2 additions & 2 deletions Sources/nCine/Graphics/RenderResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ namespace nCine

ShaderLoad shadersToLoad[] = {
#if defined(WITH_EMBEDDED_SHADERS)
// Skipping the initial new line character of the raw string literal
// Skipping the initial new line character of the raw string literal
{ RenderResources::defaultShaderPrograms_[static_cast<int>(Material::ShaderProgramType::Sprite)], ShaderStrings::sprite_vs + 1, ShaderStrings::sprite_fs + 1, GLShaderProgram::Introspection::Enabled, "Sprite" },
//{ RenderResources::defaultShaderPrograms_[static_cast<int>(Material::ShaderProgramType::SpriteGray)], ShaderStrings::sprite_vs + 1, ShaderStrings::sprite_gray_fs + 1, GLShaderProgram::Introspection::Enabled, "Sprite_Gray" },
{ RenderResources::defaultShaderPrograms_[static_cast<int>(Material::ShaderProgramType::SpriteNoTexture)], ShaderStrings::sprite_notexture_vs + 1, ShaderStrings::sprite_notexture_fs + 1, GLShaderProgram::Introspection::Enabled, "Sprite_NoTexture" },
Expand Down Expand Up @@ -254,7 +254,7 @@ namespace nCine
const int maxUniformBlockSize = gfxCaps.value(IGfxCapabilities::GLIntValues::MAX_UNIFORM_BLOCK_SIZE_NORMALIZED);

char sourceString[64];
const char *vertexStrings[3] = { nullptr, nullptr, nullptr };
const char* vertexStrings[3] = { nullptr, nullptr, nullptr };

for (unsigned int i = 0; i < arraySize<unsigned int>(shadersToLoad); i++) {
const ShaderLoad& shaderToLoad = shadersToLoad[i];
Expand Down
2 changes: 1 addition & 1 deletion Sources/nCine/Input/JoyMappingDb.h
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ static const char* ControllerMappings[] = {
"050000005e040000e0020000ff070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,",
#endif
#ifdef SDL_JOYSTICK_EMSCRIPTEN
"default,Standard Gamepad,a:b0,b:b1,back:b8,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b16,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
"default,Standard Gamepad,a:b0,b:b1,back:b8,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b16,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,misc1:b17,",
#endif
#ifdef SDL_JOYSTICK_PS2
"0000000050533220436f6e74726f6c00,PS2 Controller,crc:ed87,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
Expand Down
1 change: 1 addition & 0 deletions cmake/ncine_compiler_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ if(EMSCRIPTEN)
"SHELL:-s WASM=1"
"SHELL:-s ASYNCIFY=1"
"SHELL:-s DISABLE_EXCEPTION_CATCHING=1"
"SHELL:-s MIN_WEBGL_VERSION=2"
"SHELL:-s FORCE_FILESYSTEM=1"
"SHELL:-s ALLOW_MEMORY_GROWTH=1"
"SHELL:-s STACK_SIZE=131072" # 128 Kb
Expand Down
3 changes: 2 additions & 1 deletion cmake/ncine_imported_targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ if(EMSCRIPTEN)
#set_target_properties(GLFW::GLFW PROPERTIES
# INTERFACE_LINK_OPTIONS "SHELL:-s USE_GLFW=3")
set_target_properties(GLFW::GLFW PROPERTIES
INTERFACE_LINK_OPTIONS "SHELL:--use-port=contrib.glfw3")
INTERFACE_LINK_OPTIONS "SHELL:--use-port=contrib.glfw3"
INTERFACE_COMPILE_DEFINITIONS "GLFW_HAS_EMSCRIPTEN_HDPI")
set(GLFW_FOUND 1)
elseif(NCINE_PREFERRED_BACKEND STREQUAL "SDL2")
add_library(SDL2::SDL2 INTERFACE IMPORTED)
Expand Down

0 comments on commit 33bbb3a

Please sign in to comment.