Skip to content

Commit

Permalink
That'll be 1.2.2, thanks.
Browse files Browse the repository at this point in the history
  • Loading branch information
nkrapivin committed May 11, 2021
1 parent f3eaf15 commit c40b6c7
Show file tree
Hide file tree
Showing 26 changed files with 282 additions and 61 deletions.
Binary file modified libmulti.ged
Binary file not shown.
Binary file added libmulti.gm81
Binary file not shown.
Binary file modified libmulti.gms2/extensions/libmulti/libmulti.dll
Binary file not shown.
32 changes: 31 additions & 1 deletion libmulti.gms2/extensions/libmulti/libmulti.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions libmulti.gms2/objects/obj_libmulti_test/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ window_set_size(640, 240);
//alarm[0] = 15; // window_center() delay

wndclass = libmulti_init();

// GMS 2 is using RGBA pixel format instead of BGRA.
libmulti_set_gms2_pixel_format(true);
if (libmulti_get_gms2_pixel_format()) {
show_debug_message("libmulti: gms2 pixel format enabled ok!");
}

libmulti_set_game_window(window_handle());

seed = randomize();
Expand Down
2 changes: 1 addition & 1 deletion libmulti.gms2/objects/obj_libmulti_test/Draw_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ for (var i = 0; i < ds_list_size(windows); i++) {
xx = 8;
yy = 8 + 64 + 8;
draw_set_color(c_black);
draw_set_color(c_red);
str = "a libmulti window, window id: " + string(_w) + nl
+ "x: " + string(wx) + nl
+ "y: " + string(wy) + nl
Expand Down
Binary file modified libmulti.gms23/extensions/libmulti/libmulti.dll
Binary file not shown.
8 changes: 7 additions & 1 deletion libmulti.gms23/extensions/libmulti/libmulti.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified libmulti.gms23/extensions/libmulti/libmulti_x64.dll
Binary file not shown.
7 changes: 7 additions & 0 deletions libmulti.gms23/objects/obj_libmulti_test/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ window_set_size(640, 240);
//alarm[0] = 15; // window_center() delay

wndclass = libmulti_init();

// GMS 2 is using RGBA pixel format instead of BGRA.
libmulti_set_gms2_pixel_format(true);
if (libmulti_get_gms2_pixel_format()) {
show_debug_message("libmulti: gms2 pixel format enabled ok!");
}

libmulti_set_game_window(window_handle());

seed = randomize();
Expand Down
2 changes: 1 addition & 1 deletion libmulti.gms23/objects/obj_libmulti_test/Draw_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ for (var i = 0; i < ds_list_size(windows); i++) {
xx = 8;
yy = 8 + 64 + 8;
draw_set_color(c_black);
draw_set_color(c_red);
str = "a libmulti window, window id: " + string(_w) + nl
+ "x: " + string(wx) + nl
+ "y: " + string(wy) + nl
Expand Down
22 changes: 21 additions & 1 deletion libmulti.gmx/extensions/libmulti.extension.gmx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!-->
<extension>
<name>libmulti</name>
<version>1.3</version>
<version>1.2.2</version>
<packageID></packageID>
<ProductID></ProductID>
<date>05/05/21</date>
Expand Down Expand Up @@ -68,6 +68,26 @@
<argCount>0</argCount>
<args/>
</function>
<function>
<name>libmulti_set_gms2_pixel_format</name>
<externalName>libmulti_set_gms2_pixel_format</externalName>
<kind>1</kind>
<help>libmulti_set_gms2_pixel_format(truefalse) -&gt;real : Enables or disables GMS 2 pixel format.</help>
<returnType>2</returnType>
<argCount>1</argCount>
<args>
<arg>2</arg>
</args>
</function>
<function>
<name>libmulti_get_gms2_pixel_format</name>
<externalName>libmulti_get_gms2_pixel_format</externalName>
<kind>1</kind>
<help>libmulti_get_gms2_pixel_format() -&gt;real : Returns if the GMS 2 pixel format is enabled or not.</help>
<returnType>2</returnType>
<argCount>0</argCount>
<args/>
</function>
<function>
<name>libmulti_quit</name>
<externalName>libmulti_quit</externalName>
Expand Down
Binary file modified libmulti.gmx/extensions/libmulti/libmulti.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion libmulti.gmx/objects/obj_libmulti_test.object.gmx
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ for (var i = 0; i &lt; ds_list_size(windows); i++) {

xx = 8;
yy = 8 + 64 + 8;
draw_set_color(c_black);
draw_set_color(c_red);
str = "a libmulti window, window id: " + string(_w) + nl
+ "x: " + string(wx) + nl
+ "y: " + string(wy) + nl
Expand Down
8 changes: 4 additions & 4 deletions libmulti/MultiD2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void CMultiD2D::Discard() {
this->leave();
}

HRESULT CMultiD2D::Create(HWND window) {
HRESULT CMultiD2D::Create(HWND window, bool altrgbmode) {
HRESULT hR = S_OK;
FLOAT dpiX = 0.0f, dpiY = 0.0f;

Expand All @@ -73,7 +73,7 @@ HRESULT CMultiD2D::Create(HWND window) {
RECT rc;
GetClientRect(window, &rc);
D2D1_SIZE_U size = D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top);
hR = ms_Factory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(), D2D1::HwndRenderTargetProperties(window, size), &this->m_rt);
hR = ms_Factory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE::D2D1_RENDER_TARGET_TYPE_HARDWARE), D2D1::HwndRenderTargetProperties(window, size), &this->m_rt);
}
ms_Factory->GetDesktopDpi(&dpiX, &dpiY);
LeaveFactory();
Expand All @@ -85,8 +85,8 @@ HRESULT CMultiD2D::Create(HWND window) {
D2D1_BITMAP_PROPERTIES props;
props.dpiX = dpiX;
props.dpiY = dpiY;
props.pixelFormat.alphaMode = D2D1_ALPHA_MODE::D2D1_ALPHA_MODE_PREMULTIPLIED;
props.pixelFormat.format = DXGI_FORMAT::DXGI_FORMAT_B8G8R8A8_UNORM;
props.pixelFormat.alphaMode = D2D1_ALPHA_MODE::D2D1_ALPHA_MODE_IGNORE;
props.pixelFormat.format = altrgbmode ? DXGI_FORMAT::DXGI_FORMAT_R8G8B8A8_UNORM : DXGI_FORMAT::DXGI_FORMAT_B8G8R8A8_UNORM;
hR = this->m_rt->CreateBitmap(bmsize, this->m_bitmapP, this->m_bitmapW * 4, props, &this->m_bitmap);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion libmulti/MultiD2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CMultiD2D {
CMultiD2D();
~CMultiD2D();

HRESULT Create(HWND window);
HRESULT Create(HWND window, bool altrgbmode);
void Discard(); // Releases all resources EXCEPT for the user defined bitmap.
HRESULT OnResize(UINT w, UINT h);
HRESULT OnRender();
Expand Down
7 changes: 6 additions & 1 deletion libmulti/legacy_extmaker_def.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ function libmulti_get_max_height(window:real):real
function libmulti_mouse_get_x(window:real):real
function libmulti_mouse_get_y(window:real):real
function libmulti_legacy_check():real
function libmulti_legacy_dispatch():string
function libmulti_legacy_done():real
function libmulti_legacy_event_length():real
function libmulti_legacy_event_is_string(index:real):real
function libmulti_legacy_event_value_name(index:real):string
function libmulti_legacy_event_value_real(index:real):real
function libmulti_legacy_event_value_string(index:real):string
28 changes: 16 additions & 12 deletions libmulti/libmulti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ std::vector<std::pair<HWND, CMultiD2D*>> vecWindows{ };
DWORD LastError{ ERROR_SUCCESS };
static char* LastString{ nullptr };
static CRITICAL_SECTION* Mutex{ nullptr };
static bool IsLegacy{ false };
bool AltRGBMode{ false };

void EnterVector() { EnterCriticalSection(Mutex); }
void LeaveVector() { LeaveCriticalSection(Mutex); }
Expand Down Expand Up @@ -118,10 +120,10 @@ static bool _winapi_gm_paste_event(HWND hWnd, double window) {
if (ok == TRUE) {
clipdata = reinterpret_cast<LPCWSTR>(GetClipboardData(CF_UNICODETEXT));
if (clipdata != nullptr) {
need = WideCharToMultiByte(CP_UTF8, 0, clipdata, -1, nullptr, 0, nullptr, nullptr);
need = WideCharToMultiByte(IsLegacy ? CP_OEMCP : CP_UTF8, 0, clipdata, -1, nullptr, 0, nullptr, nullptr);
if (need > 0) {
mbclipdata = new char[need];
need = WideCharToMultiByte(CP_UTF8, 0, clipdata, -1, mbclipdata, need, nullptr, nullptr);
need = WideCharToMultiByte(IsLegacy ? CP_OEMCP : CP_UTF8, 0, clipdata, -1, mbclipdata, need, nullptr, nullptr);
}
}
ok = CloseClipboard();
Expand Down Expand Up @@ -205,7 +207,7 @@ static LRESULT WINAPI WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPar
WCHAR wch = static_cast<WCHAR>(wParam);
// process exactly one character.
// size - 1 because the function won't handle a null byte.
WideCharToMultiByte(CP_UTF8, 0, &wch, 1, mch, sizeof(mch) - 1, nullptr, nullptr);
WideCharToMultiByte(IsLegacy ? CP_OEMCP : CP_UTF8, 0, &wch, 1, mch, sizeof(mch) - 1, nullptr, nullptr);

double w_char = static_cast<double>(wParam);
// me can't do bit arithmetic so there we go:
Expand Down Expand Up @@ -261,7 +263,7 @@ static LRESULT WINAPI WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPar
}

case WM_PAINT: {
d2d->Create(hWnd);
d2d->Create(hWnd, AltRGBMode);
d2d->OnRender();
ValidateRect(hWnd, nullptr);
break;
Expand Down Expand Up @@ -394,13 +396,15 @@ dllx double libmulti_init() {
InitMultiD2D();
EnterVector();
nikWindowClass = register_window_class(WindowProc);
libmulti_cursor_init();
LeaveVector();

// RegisterCallbacks wasn't called? Are we in legacy GM?
if (CBCreateDsMap == nullptr) {
if (CBCreateDsMap == nullptr && CBDispatch == nullptr && CBDsMapAddReal == nullptr && CBDsMapAddString == nullptr) {
CBCreateDsMap = libmulti_legacy_create_ds_map;
CBDispatch = libmulti_legacy_dispatch_stub;
// initialize a custom event system
IsLegacy = true;
libmulti_legacy_mutex_init();
// overmars why
}
Expand Down Expand Up @@ -448,9 +452,9 @@ dllx char* libmulti_last_error_message() {

_libmulti_free();

int needed = WideCharToMultiByte(CP_UTF8, 0, err, -1, nullptr, 0, nullptr, nullptr);
int needed = WideCharToMultiByte(IsLegacy ? CP_OEMCP : CP_UTF8, 0, err, -1, nullptr, 0, nullptr, nullptr);
LastString = new char[needed];
needed = WideCharToMultiByte(CP_UTF8, 0, err, -1, LastString, needed, nullptr, nullptr);
needed = WideCharToMultiByte(IsLegacy ? CP_OEMCP : CP_UTF8, 0, err, -1, LastString, needed, nullptr, nullptr);
LastError = GetLastError();
LocalFree(err);
err = nullptr;
Expand Down Expand Up @@ -576,9 +580,9 @@ dllx double libmulti_set_caption(double index, char* _name) {
LastError = GetLastError();
}
else {
int needed = MultiByteToWideChar(CP_UTF8, 0, _name, -1, nullptr, 0);
int needed = MultiByteToWideChar(IsLegacy ? CP_OEMCP : CP_UTF8, 0, _name, -1, nullptr, 0);
LPWSTR wide = new WCHAR[needed];
MultiByteToWideChar(CP_UTF8, 0, _name, -1, wide, needed);
MultiByteToWideChar(IsLegacy ? CP_OEMCP : CP_UTF8, 0, _name, -1, wide, needed);
BOOL ok = SetWindowText(window, wide);
LastError = GetLastError();
delete[] wide;
Expand All @@ -602,9 +606,9 @@ dllx char* libmulti_get_caption(double index) {
int copied = GetWindowTextW(window, buf, chars + 1);
LastError = GetLastError();
if (chars == copied) {
int need = WideCharToMultiByte(CP_UTF8, 0, buf, -1, nullptr, 0, nullptr, nullptr);
int need = WideCharToMultiByte(IsLegacy ? CP_OEMCP : CP_UTF8, 0, buf, -1, nullptr, 0, nullptr, nullptr);
LastString = new char[need];
copied = WideCharToMultiByte(CP_UTF8, 0, buf, -1, LastString, need, nullptr, nullptr);
copied = WideCharToMultiByte(IsLegacy ? CP_OEMCP : CP_UTF8, 0, buf, -1, LastString, need, nullptr, nullptr);
LastError = GetLastError();
if (copied > 0) {
ret = LastString;
Expand All @@ -619,7 +623,7 @@ dllx char* libmulti_get_caption(double index) {
}

dllx double libmulti_make_bitmap(double index, double width, double height, char* _buf) {
if (!_libmulti_exists(index) || width < 0.0 || height < 0.0 || _buf == nullptr) return -1.0;
if (!_libmulti_exists(index) || width < 1.0 || height < 1.0 || _buf == nullptr) return -1.0;
else {
BOOL ret = FALSE;
EnterVector();
Expand Down
7 changes: 7 additions & 0 deletions libmulti/libmulti.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
// internal libmulti stuff.
void EnterVector();
void LeaveVector();
void libmulti_cursor_init(void);
HCURSOR libmulti_cursor_get_from_gm(int v);
extern HMODULE hModule;
extern DWORD LastError;
extern bool AltRGBMode;
extern std::vector<std::pair<HWND, CMultiD2D*>> vecWindows;
bool _libmulti_exists(double window);
DWORD WINAPI libmulti_window_thread(LPVOID lpThreadParameter);
Expand Down Expand Up @@ -39,6 +42,10 @@ void libmulti_legacy_mutex_quit();
dllx char* RegisterCallbacks(char* please, char* dont, char* call, char* it);
///->real : Initializes the library.
dllx double libmulti_init();
///->real : Enables or disables GMS 2 pixel format.
dllx double libmulti_set_gms2_pixel_format(double truefalse);
///->real : Returns if the GMS 2 pixel format is enabled or not.
dllx double libmulti_get_gms2_pixel_format();
///->real : Destroys all windows and frees the library resources.
dllx double libmulti_quit();
///->real : Returns true if the DLL is present and was loaded.
Expand Down
Binary file modified libmulti/libmulti.rc
Binary file not shown.
1 change: 1 addition & 0 deletions libmulti/libmulti.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="libmulti.cpp" />
<ClCompile Include="libmulti_cursor.cpp" />
<ClCompile Include="libmulti_dllmain.cpp" />
<ClCompile Include="libmulti_focus.cpp" />
<ClCompile Include="libmulti_legacy.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions libmulti/libmulti.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
<ClCompile Include="libmulti_legacy.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="libmulti_cursor.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="libmulti.rc">
Expand Down
Loading

0 comments on commit c40b6c7

Please sign in to comment.