mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -05:00
Compare commits
5 commits
ea86930422
...
aad69582c0
Author | SHA1 | Date | |
---|---|---|---|
|
aad69582c0 | ||
|
38f3385c90 | ||
|
4d5e465ade | ||
|
4a40835f71 | ||
|
74d0924bcb |
3 changed files with 58 additions and 3 deletions
|
@ -164,7 +164,27 @@ function(setup_geode_mod proname)
|
|||
set(HAS_HEADERS Off)
|
||||
endif()
|
||||
|
||||
if (HAS_HEADERS AND WIN32)
|
||||
if (GEODE_BUNDLE_PDB AND WIN32 AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
|
||||
if (HAS_HEADERS)
|
||||
add_custom_target(${proname}_PACKAGE ALL
|
||||
DEPENDS ${proname} ${CMAKE_CURRENT_SOURCE_DIR}/mod.json
|
||||
COMMAND ${GEODE_CLI} package new ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
--binary $<TARGET_FILE:${proname}> $<TARGET_LINKER_FILE:${proname}> $<TARGET_PDB_FILE:${proname}>
|
||||
--output ${CMAKE_CURRENT_BINARY_DIR}/${MOD_ID}.geode
|
||||
${INSTALL_ARG} ${PDB_ARG}
|
||||
VERBATIM USES_TERMINAL
|
||||
)
|
||||
else()
|
||||
add_custom_target(${proname}_PACKAGE ALL
|
||||
DEPENDS ${proname} ${CMAKE_CURRENT_SOURCE_DIR}/mod.json
|
||||
COMMAND ${GEODE_CLI} package new ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
--binary $<TARGET_FILE:${proname}> $<TARGET_PDB_FILE:${proname}>
|
||||
--output ${CMAKE_CURRENT_BINARY_DIR}/${MOD_ID}.geode
|
||||
${INSTALL_ARG} ${PDB_ARG}
|
||||
VERBATIM USES_TERMINAL
|
||||
)
|
||||
endif()
|
||||
elseif (HAS_HEADERS AND WIN32)
|
||||
# this adds the .lib file on windows, which is needed for linking with the headers
|
||||
add_custom_target(${proname}_PACKAGE ALL
|
||||
DEPENDS ${proname} ${CMAKE_CURRENT_SOURCE_DIR}/mod.json
|
||||
|
|
|
@ -18,6 +18,7 @@ enum {
|
|||
ID_BUTTON_OPEN_FOLDER = 103,
|
||||
ID_BUTTON_COPY_CLIPBOARD = 104,
|
||||
ID_BUTTON_RESTART_GAME = 105,
|
||||
ID_SAFE_MODE_TIP_TEXT = 106,
|
||||
};
|
||||
#define TO_HMENU(x) reinterpret_cast<HMENU>(static_cast<size_t>(x))
|
||||
|
||||
|
@ -63,6 +64,25 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||
DEFAULT_PITCH | FF_DONTCARE, TEXT("Consolas"));
|
||||
auto guiFont = static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT));
|
||||
|
||||
auto calculateTextSize = [&](std::string_view text) -> SIZE {
|
||||
HDC hdc = GetDC(hwnd);
|
||||
SelectObject(hdc, monoFont);
|
||||
SIZE size;
|
||||
GetTextExtentPoint32A(hdc, text.data(), text.size(), &size);
|
||||
ReleaseDC(hwnd, hdc);
|
||||
return size;
|
||||
};
|
||||
auto tipTextStr = "Tip: You can hold shift while launching the game to enter safe mode.";
|
||||
auto tipTextSize = calculateTextSize(tipTextStr);
|
||||
|
||||
auto tipText = CreateWindowA(
|
||||
"STATIC", tipTextStr,
|
||||
WS_CHILD | WS_VISIBLE | SS_SIMPLE,
|
||||
0, 0, tipTextSize.cx, tipTextSize.cy,
|
||||
hwnd, TO_HMENU(ID_SAFE_MODE_TIP_TEXT), NULL, NULL
|
||||
);
|
||||
SendMessage(tipText, WM_SETFONT, WPARAM(monoFont), TRUE);
|
||||
|
||||
auto handleText = CreateWindowA(
|
||||
"EDIT", "Crashlog text goes here", WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_READONLY | ES_AUTOVSCROLL | WS_BORDER,
|
||||
0, 0, 100, 100,
|
||||
|
@ -109,10 +129,20 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||
RECT clientRect;
|
||||
GetClientRect(hwnd, &clientRect);
|
||||
|
||||
RECT textRect;
|
||||
GetClientRect(GetDlgItem(hwnd, ID_SAFE_MODE_TIP_TEXT), &textRect);
|
||||
|
||||
SetWindowPos(
|
||||
GetDlgItem(hwnd, ID_SAFE_MODE_TIP_TEXT), NULL,
|
||||
layout::PADDING, layout::PADDING,
|
||||
0, 0,
|
||||
SWP_NOZORDER | SWP_NOSIZE
|
||||
);
|
||||
|
||||
SetWindowPos(
|
||||
GetDlgItem(hwnd, ID_CRASHLOG_TEXT), NULL,
|
||||
layout::PADDING, layout::PADDING,
|
||||
clientRect.right - layout::PADDING * 2, clientRect.bottom - layout::BUTTON_HEIGHT - layout::PADDING * 3,
|
||||
layout::PADDING, layout::PADDING * 2 + textRect.bottom,
|
||||
clientRect.right - layout::PADDING * 2, clientRect.bottom - layout::BUTTON_HEIGHT - layout::PADDING * 4 - textRect.bottom,
|
||||
SWP_NOZORDER
|
||||
);
|
||||
|
||||
|
@ -150,6 +180,9 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
|||
} break;
|
||||
|
||||
case WM_CTLCOLORSTATIC: {
|
||||
auto hdc = (HDC)wParam;
|
||||
// make every text have transparent background
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
return (LRESULT)(COLOR_WINDOWFRAME);
|
||||
} break;
|
||||
|
||||
|
|
|
@ -59,6 +59,8 @@ std::string utils::string::toUpper(std::string const& str) {
|
|||
}
|
||||
|
||||
std::string& utils::string::replaceIP(std::string& str, std::string const& orig, std::string const& repl) {
|
||||
if (orig.empty()) return str;
|
||||
|
||||
std::string::size_type n = 0;
|
||||
while ((n = str.find(orig, n)) != std::string::npos) {
|
||||
str.replace(n, orig.size(), repl);
|
||||
|
|
Loading…
Reference in a new issue