Skip to content

Commit

Permalink
merge #81: [CL] feat(CEF): CEF integration, new Chat
Browse files Browse the repository at this point in the history
  • Loading branch information
Insineer authored Feb 20, 2021
2 parents cd7e07b + e74dce3 commit eaf8f00
Show file tree
Hide file tree
Showing 65 changed files with 38,963 additions and 17,783 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,5 @@ cmake-build-debug/
OSS13 Client.exe
OSS13 Server.exe
python*.dll
/Resources/Browser
/External/cef/windows-bin
5 changes: 5 additions & 0 deletions CI/appveyor/appveyor-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@ install:
- vcpkg install gtest:x64-windows-static

- vcpkg upgrade --no-dry-run

- CI\appveyor\install_cef.bat C:\Tools %APPVEYOR_BUILD_FOLDER%

build:
project: OSS13.sln

cache: c:\tools\vcpkg\installed
12 changes: 7 additions & 5 deletions CI/appveyor/appveyor-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ clone_depth: 10

version: '0.0.{build}'

platform: x64
configuration: Release

environment:
Expand All @@ -14,10 +15,6 @@ branches:
only:
- never-build-branch-automatically-dont-use-this-name

platform:
- x64
- x86

matrix:
fast_finish: true

Expand All @@ -39,6 +36,11 @@ install:
- vcpkg install "gtest:%platform%-windows-static"

- vcpkg upgrade --no-dry-run

- CI\appveyor\install_cef.bat C:\Tools %APPVEYOR_BUILD_FOLDER%

build:
project: OSS13.sln

after_build:
- set BIN_FOLDER_SUFFIX=%platform%
Expand All @@ -47,7 +49,7 @@ after_build:
- 7z a "OSS13-%platform%-%appveyor_build_version%.zip" "%APPVEYOR_BUILD_FOLDER%\bin\Release-%BIN_FOLDER_SUFFIX%\OSS13 Client.exe" "%APPVEYOR_BUILD_FOLDER%\bin\Release-%BIN_FOLDER_SUFFIX%\OSS13 Server.exe" "C:\Tools\vcpkg\installed\%platform%-windows\bin\python37.dll" Documentation Resources -ir!GameLogic\*.py Arialuni.ttf LICENSE README.md UsersDB

artifacts:
- path: "OSS13-$(platform)-%appveyor_build_version%.zip"
- path: "OSS13-%appveyor_build_version%.zip"

deploy:
release: OSS13-v$(appveyor_build_version)
Expand Down
29 changes: 29 additions & 0 deletions CI/appveyor/install_cef.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
set tools_path=%1
set project_path=%2
set cef_version=cef_binary_88.2.9+g5c8711a+chromium-88.0.4324.182_windows64

cd %tools_path%
if not errorlevel 0 goto :EOF

if not exist "%cef_version%.tar.bz2" (
curl.exe -o %cef_version%.tar.bz2 "https://cef-builds.spotifycdn.com/%cef_version%.tar.bz2"
if not errorlevel 0 goto :EOF
)

7z.exe x %cef_version%.tar.bz2 -aoa
if not errorlevel 0 goto :EOF

7z.exe x %cef_version%.tar -aoa
if not errorlevel 0 goto :EOF

robocopy /e %cef_version% %project_path%/External/cef/windows-bin
if not errorlevel 1 goto :EOF & rem 1 - is success code of robocopy

cd %project_path%/External/cef/windows-bin
if not errorlevel 0 goto :EOF

cmake -G"Visual Studio 16 2019"
if not errorlevel 0 goto :EOF

msbuild.exe libcef_dll_wrapper\libcef_dll_wrapper.vcxproj /property:Configuration=Release /property:Platform=x64
msbuild.exe libcef_dll_wrapper\libcef_dll_wrapper.vcxproj /property:Configuration=Debug /property:Platform=x64
65 changes: 45 additions & 20 deletions External/sfml-imgui/imconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
//-----------------------------------------------------------------------------
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/branch with your modifications to imconfig.h)
// B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h"
// If you do so you need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include
// the imgui*.cpp files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it)
// B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template.
//-----------------------------------------------------------------------------
// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp
// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
//-----------------------------------------------------------------------------

#pragma once

//---- Define assertion handler. Defaults to calling assert().
// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts

Expand All @@ -22,21 +24,23 @@
//#define IMGUI_API __declspec( dllexport )
//#define IMGUI_API __declspec( dllimport )

//---- Don't define obsolete functions/enums names. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS

//---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
// It is very strongly recommended to NOT disable the demo windows during development. Please read the comments in imgui_demo.cpp.
//#define IMGUI_DISABLE_DEMO_WINDOWS
//#define IMGUI_DISABLE_METRICS_WINDOW
//---- Disable all of Dear ImGui or don't implement standard windows.
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended.
//#define IMGUI_DISABLE_METRICS_WINDOW // Disable metrics/debugger window: ShowMetricsWindow() will be empty.

//---- Don't implement some functions to reduce linkage requirements.
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow.
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices').
//#define IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself if you don't want to link with vsnprintf.
//#define IMGUI_DISABLE_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 wrapper so you can implement them yourself. Declare your prototypes in imconfig.h.
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().

//---- Include imgui_user.h at the end of imgui.h as a convenience
Expand All @@ -45,13 +49,29 @@
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
//#define IMGUI_USE_BGRA_PACKED_COLOR

//---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
//#define IMGUI_USE_WCHAR32

//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
// By default the embedded implementations are declared static and not available outside of imgui cpp files.
// By default the embedded implementations are declared static and not available outside of Dear ImGui sources files.
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION

//---- Use stb_printf's faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined)
// Requires 'stb_sprintf.h' to be available in the include path. Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf.
// #define IMGUI_USE_STB_SPRINTF

//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui)
// Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided).
// On Windows you may use vcpkg with 'vcpkg install freetype' + 'vcpkg integrate install'.
//#define IMGUI_ENABLE_FREETYPE

//---- Use stb_truetype to build and rasterize the font atlas (default)
// The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend.
//#define IMGUI_ENABLE_STB_TRUETYPE

//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
/*
Expand All @@ -64,26 +84,31 @@
operator MyVec4() const { return MyVec4(x,y,z,w); }
*/

//---- Using 32-bits vertex indices (default is 16-bits) is one way to allow large meshes with more than 64K vertices.
// Your renderer back-end will need to support it (most example renderer back-ends support both 16/32-bits indices).
// Another way to allow large meshes while keeping 16-bits indices is to handle ImDrawCmd::VtxOffset in your renderer.
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
//#define ImDrawIdx unsigned int

//---- Override ImDrawCallback signature (will need to modify renderer back-ends accordingly)
//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly)
//struct ImDrawList;
//struct ImDrawCmd;
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
//#define ImDrawCallback MyImDrawCallback

//---- Debug Tools
// Use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.
//---- Debug Tools: Macro to break in Debugger
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
//#define IM_DEBUG_BREAK IM_ASSERT(0)
//#define IM_DEBUG_BREAK __debugbreak()
// Have the Item Picker break in the ItemAdd() function instead of ItemHoverable() - which is earlier in the code, will catch a few extra items, allow picking items other than Hovered one.

//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
// This adds a small runtime cost which is why it is not enabled by default.
//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX

//---- Debug Tools: Enable slower asserts
//#define IMGUI_DEBUG_PARANOID

//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
/*
namespace ImGui
Expand Down
40 changes: 24 additions & 16 deletions External/sfml-imgui/imgui-SFML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ StickInfo s_dPadInfo;
StickInfo s_lStickInfo;

// various helper functions
ImColor toImColor(sf::Color c);
ImVec2 getTopLeftAbsolute(const sf::FloatRect& rect);
ImVec2 getDownRightAbsolute(const sf::FloatRect& rect);

Expand Down Expand Up @@ -249,7 +250,7 @@ void Init(sf::Window& window, const sf::Vector2f& displaySize, bool loadDefaultF
initDefaultJoystickMapping();

// init rendering
io.DisplaySize = displaySize;
io.DisplaySize = ImVec2(displaySize.x, displaySize.y);

// clipboard
io.SetClipboardTextFn = setClipboardText;
Expand All @@ -269,6 +270,7 @@ void Init(sf::Window& window, const sf::Vector2f& displaySize, bool loadDefaultF
sf::Cursor::SizeBottomLeftTopRight);
loadMouseCursor(ImGuiMouseCursor_ResizeNWSE,
sf::Cursor::SizeTopLeftBottomRight);
loadMouseCursor(ImGuiMouseCursor_Hand, sf::Cursor::Hand);

if (s_fontTexture) { // delete previously created texture
delete s_fontTexture;
Expand Down Expand Up @@ -386,16 +388,18 @@ void Update(sf::Window& window, sf::RenderTarget& target, sf::Time dt) {
void Update(const sf::Vector2i& mousePos, const sf::Vector2f& displaySize,
sf::Time dt) {
ImGuiIO& io = ImGui::GetIO();
io.DisplaySize = displaySize;
io.DisplaySize = ImVec2(displaySize.x, displaySize.y);

io.DeltaTime = dt.asSeconds();

if (s_windowHasFocus) {
if (io.WantSetMousePos) {
sf::Vector2i mousePos(static_cast<int>(io.MousePos.x),
static_cast<int>(io.MousePos.y));
sf::Mouse::setPosition(mousePos);
sf::Vector2i newMousePos(static_cast<int>(io.MousePos.x),
static_cast<int>(io.MousePos.y));
sf::Mouse::setPosition(newMousePos);
} else {
io.MousePos = mousePos;
io.MousePos = ImVec2(static_cast<float>(mousePos.x),
static_cast<float>(mousePos.y));
}
for (unsigned int i = 0; i < 3; i++) {
io.MouseDown[i] = s_touchDown[i] || sf::Touch::isDown(i) ||
Expand Down Expand Up @@ -557,8 +561,9 @@ void Image(const sf::Texture& texture, const sf::Vector2f& size,
const sf::Color& tintColor, const sf::Color& borderColor) {
ImTextureID textureID =
convertGLTextureHandleToImTextureID(texture.getNativeHandle());
ImGui::Image(textureID, size, ImVec2(0, 0), ImVec2(1, 1), tintColor,
borderColor);

ImGui::Image(textureID, ImVec2(size.x,size.y), ImVec2(0, 0), ImVec2(1, 1), toImColor(tintColor),
toImColor(borderColor));
}

void Image(const sf::Texture& texture, const sf::FloatRect& textureRect,
Expand All @@ -580,7 +585,8 @@ void Image(const sf::Texture& texture, const sf::Vector2f& size,

ImTextureID textureID =
convertGLTextureHandleToImTextureID(texture.getNativeHandle());
ImGui::Image(textureID, size, uv0, uv1, tintColor, borderColor);
ImGui::Image(textureID, ImVec2(size.x, size.y), uv0, uv1, toImColor(tintColor),
toImColor(borderColor));
}

void Image(const sf::Sprite& sprite, const sf::Color& tintColor,
Expand Down Expand Up @@ -645,16 +651,16 @@ bool ImageButton(const sf::Sprite& sprite, const sf::Vector2f& size,
void DrawLine(const sf::Vector2f& a, const sf::Vector2f& b,
const sf::Color& color, float thickness) {
ImDrawList* draw_list = ImGui::GetWindowDrawList();
sf::Vector2f pos = ImGui::GetCursorScreenPos();
draw_list->AddLine(a + pos, b + pos, ColorConvertFloat4ToU32(color),
ImVec2 pos = ImGui::GetCursorScreenPos();
draw_list->AddLine(ImVec2(a.x + pos.x, a.y + pos.y), ImVec2(b.x + pos.x, b.y + pos.y), ColorConvertFloat4ToU32(toImColor(color)),
thickness);
}

void DrawRect(const sf::FloatRect& rect, const sf::Color& color, float rounding,
int rounding_corners, float thickness) {
ImDrawList* draw_list = ImGui::GetWindowDrawList();
draw_list->AddRect(getTopLeftAbsolute(rect), getDownRightAbsolute(rect),
ColorConvertFloat4ToU32(color), rounding,
ColorConvertFloat4ToU32(toImColor(color)), rounding,
rounding_corners, thickness);
}

Expand All @@ -663,13 +669,15 @@ void DrawRectFilled(const sf::FloatRect& rect, const sf::Color& color,
ImDrawList* draw_list = ImGui::GetWindowDrawList();
draw_list->AddRectFilled(
getTopLeftAbsolute(rect), getDownRightAbsolute(rect),
ColorConvertFloat4ToU32(color), rounding, rounding_corners);
ColorConvertFloat4ToU32(toImColor(color)), rounding, rounding_corners);
}

} // end of namespace ImGui

namespace {

ImColor toImColor(sf::Color c ) {
return ImColor(static_cast<int>(c.r), static_cast<int>(c.g), static_cast<int>(c.b), static_cast<int>(c.a));
}
ImVec2 getTopLeftAbsolute(const sf::FloatRect& rect) {
ImVec2 pos = ImGui::GetCursorScreenPos();
return ImVec2(rect.left + pos.x, rect.top + pos.y);
Expand Down Expand Up @@ -804,8 +812,8 @@ bool imageButtonImpl(const sf::Texture& texture,

ImTextureID textureID =
convertGLTextureHandleToImTextureID(texture.getNativeHandle());
return ImGui::ImageButton(textureID, size, uv0, uv1, framePadding, bgColor,
tintColor);
return ImGui::ImageButton(textureID, ImVec2(size.x,size.y), uv0, uv1, framePadding, toImColor(bgColor),
toImColor(tintColor));
}

unsigned int getConnectedJoystickId() {
Expand Down
Loading

0 comments on commit eaf8f00

Please sign in to comment.