Skip to content

Commit

Permalink
Merge pull request #34 from Mojang/sbl/temp-sdk-fix
Browse files Browse the repository at this point in the history
Sbl/temp sdk fix
  • Loading branch information
gustavlouwskyboxlabs authored Sep 13, 2024
2 parents 89cea7c + ba00923 commit 885613c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 88 deletions.
21 changes: 0 additions & 21 deletions CMakeLists.txt

This file was deleted.

6 changes: 3 additions & 3 deletions imconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
//#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. (user32.lib/.a, kernel32.lib/.a)
#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. (imm32.lib/.a)
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. (imm32.lib/.a)
//#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', 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_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
#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_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle 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().
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available

Expand Down
44 changes: 1 addition & 43 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,49 +1565,7 @@ bool ImFileClose(ImFileHandle f) { return fclose(f) == 0; }
ImU64 ImFileGetSize(ImFileHandle f) { long off = 0, sz = 0; return ((off = ftell(f)) != -1 && !fseek(f, 0, SEEK_END) && (sz = ftell(f)) != -1 && !fseek(f, off, SEEK_SET)) ? (ImU64)sz : (ImU64)-1; }
ImU64 ImFileRead(void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fread(data, (size_t)sz, (size_t)count, f); }
ImU64 ImFileWrite(const void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fwrite(data, (size_t)sz, (size_t)count, f); }
#else
//Functions to redirect to our hook object function calls if it exists
ImFileHandle ImFileOpen(const char* filename, const char* mode) {
if (auto context = ImGui::GetCurrentContext()) {
if (ImIFileHelper* fileHelperPtr = context->FileHelper) {
return fileHelperPtr->ImFileOpen(filename, mode);
}
}
return nullptr;
}
bool ImFileClose(ImFileHandle file) {
if (auto context = ImGui::GetCurrentContext()) {
if (ImIFileHelper* fileHelperPtr = context->FileHelper) {
return fileHelperPtr->ImFileClose(file);
}
}
return false;
}
ImU64 ImFileGetSize(ImFileHandle file) {
if (auto context = ImGui::GetCurrentContext()) {
if (ImIFileHelper* fileHelperPtr = context->FileHelper) {
return fileHelperPtr->ImFileGetSize(file);
}
}
return 0;
}
ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file) {
if (auto context = ImGui::GetCurrentContext()) {
if (ImIFileHelper* fileHelperPtr = context->FileHelper) {
return fileHelperPtr->ImFileRead(data, size, count, file);
}
}
return 0;
}
ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file) {
if (auto context = ImGui::GetCurrentContext()) {
if (ImIFileHelper* fileHelperPtr = context->FileHelper) {
return fileHelperPtr->ImFileWrite(data, size, count, file);
}
}
return 0;
}
#endif
#endif // #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS

// Helper: Load file content into memory
// Memory allocated with IM_ALLOC(), must be freed by user using IM_FREE() == ImGui::MemFree()
Expand Down
22 changes: 1 addition & 21 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,25 +372,8 @@ IMGUI_API bool ImFileClose(ImFileHandle file);
IMGUI_API ImU64 ImFileGetSize(ImFileHandle file);
IMGUI_API ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file);
IMGUI_API ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file);
#else //Bedrock File Handler Hook so we can use our own internal file handling
#else
#define IMGUI_DISABLE_TTY_FUNCTIONS // Can't use stdout, fflush if we are not using default file functions
//We'll cast this to our own internal type as needed
typedef void* ImFileHandle;
//Helper struct for hooking file operations to external systems
struct ImIFileHelper {
virtual ~ImIFileHelper() = default;
virtual ImFileHandle ImFileOpen(const char* filename, const char* mode) = 0;
virtual bool ImFileClose(ImFileHandle file) = 0;
virtual ImU64 ImFileGetSize(ImFileHandle file) = 0;
virtual ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file) = 0;
virtual ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file) = 0;
};

IMGUI_API ImFileHandle ImFileOpen(const char* filename, const char* mode);
IMGUI_API bool ImFileClose(ImFileHandle file);
IMGUI_API ImU64 ImFileGetSize(ImFileHandle file);
IMGUI_API ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file);
IMGUI_API ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file);
#endif
IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size = NULL, int padding_bytes = 0);

Expand Down Expand Up @@ -1615,9 +1598,6 @@ struct ImGuiContext
ImChunkStream<ImGuiTableSettings> SettingsTables; // ImGuiTable .ini settings entries
ImVector<ImGuiContextHook> Hooks; // Hooks for extensions (e.g. test engine)
ImGuiID HookIdNext; // Next available HookId
#ifdef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
ImIFileHelper* FileHelper = nullptr; // Hook object for external source to implement their own fileIO
#endif

// Capture/Logging
bool LogEnabled; // Currently capturing
Expand Down

0 comments on commit 885613c

Please sign in to comment.