ENIGMA Forums

Outsourcing saves money => Third Party => Topic started by: time-killer-games on March 20, 2014, 09:59:31 am

Title: FakeFullscreen.dll
Post by: time-killer-games on March 20, 2014, 09:59:31 am
GMStudio uses "true fullscreen" on windows, mac, and linux meaning if you try to use show_message(), get_open_filename(), etc or any other functions that produce small dialog boxes, the game if running in fullscreen will automatically switch to windowed mode. I'm creating a dll/dylib for Windows and Mac that will force GMS games one these platforms to use "fake fullscreen", meaning it will look identical to "true fullscreen" but it will allow dialog windows to appear without switching the game to windowed mode. Linux and Windows 8 won't be supported until YYG announce the 1.3 extention system works on those platforms.

I'm doing it all in Code:Blocks for cross-compatibility. I made a DLL in the past called HostExe. It launches an external exe, removes the exe's border, and embeds it. It doesn't work anymore because I must have modified it by accident and I don't know how to fix it. But it does remove the external exe's window border, at least. I don't care about HostExe anymore because I'm not working on it. But for a referense to what I was talking about here's the HostExe.dll's source main.cpp...

Code: [Select]
#include "main.h"
#define DLL extern "C" _declspec(dllexport)

HANDLE handle;
HWND apphwnd;
RECT rect;

int CALLBACK EnumWindowsProc(HWND hwnd, LPARAM param)
{
DWORD pID;
DWORD TpID = GetWindowThreadProcessId(hwnd, &pID);
if (TpID == (DWORD)param)
{
apphwnd=hwnd;
return false;
}
return true;
}

HANDLE StartProcess(LPCTSTR program,LPCTSTR args)
{

     HANDLE hProcess = NULL;
     PROCESS_INFORMATION processInfo;
     STARTUPINFO startupInfo;
     ::ZeroMemory(&startupInfo,sizeof(startupInfo));
     startupInfo.cb=sizeof(startupInfo);
     if(::CreateProcess(program,(LPTSTR)args,
                        NULL,
                        NULL,
                        FALSE,
                        0,
                        NULL,
                        NULL,
                        &startupInfo,
                        &processInfo))
        {
Sleep(5000);
::EnumWindows(&EnumWindowsProc,processInfo.dwThreadId);
        hProcess=processInfo.hProcess;
        }
     return hProcess;
}

DLL double HostingStartEmbed(char *Exe)
{
GetClientRect(GetActiveWindow(),&rect);
handle=StartProcess(Exe,"");
if(apphwnd!=NULL)
{
::SetParent(apphwnd,GetActiveWindow());
SetWindowLong(apphwnd, GWL_STYLE, WS_VISIBLE);
::MoveWindow(apphwnd,rect.left,rect.top,rect.right,rect.bottom, true);
}
return 0;
}

DLL double HostingEndEmbed()
{
TerminateProcess(handle,0);
return 0;
}

DLL double HostingSetRectangle(int Left,int Top,int Right,int Bottom)
{
::MoveWindow(apphwnd,Left,Top,Right,Bottom,true);
return 0;
}


The DLL I'm working on now does something similar, it just removes the border of the current game window and resizes the rectangle to fill the entire screen, otherwise known as "fake fullscreen". Though removing the border works in HostExe.dll, I'm not sure why it isn't working in FakeFullscreen.dll. The window isn't resizing, either. The dll can be called from my GMS game without trouble or errors, but the game just runs and acts as if the DLL isn't even being called. Here's the main.cpp code for FakeFullscreen.dll...

Code: [Select]
#include "main.h"
#define DLL extern "C" _declspec(dllexport)

DLL double FakeFullscreen(LPCTSTR Title,int Width,int Height)
{
    HWND Handle;
    Handle=FindWindow(Title, NULL);
    SetWindowLong(Handle, GWL_STYLE, WS_VISIBLE);
    MoveWindow(Handle,0,0,Width,Height,true);
return 0;
}

Anyone have an idea why FakeFullscreen.dll isn't working? I think it has to do with a problem in how I'm using FindWindow(), but then again, I'm using the correct title bar text my game has in the first argument, so idk...

Thanks.
~Samuel
Title: Re: FakeFullscreen.dll
Post by: Darkstar2 on March 20, 2014, 12:44:09 pm
Interesting.  This fake fullscreen mode reminds me of older GM versions.  FakeFS was used in previous versions of GM (8.1 and less) if not mistaken, as it was designed like that from the beginning.

I see what you mean and trying to do, but didn't GM have a feature to remove the border from the compiled project ?  Unless I missed something, I remember it was in global game settings or something, unless they removed it.

You want to run the entire time in fake FS mode ? won't that affect performance ?
Title: Re: FakeFullscreen.dll
Post by: time-killer-games on March 20, 2014, 01:12:31 pm
They removed that from the global game settings, and they deprecated the associated GML function. No, it won't at all effect the game's performance because the demo I'm going to distribute with the DLL will only switch the game to use fakeFS whenever there's a dialog box opened, so if the main game window is the only window the game has opened, you'll be using true fs instead.
Title: Re: FakeFullscreen.dll
Post by: Darkstar2 on March 20, 2014, 01:33:10 pm
They removed that from the global game settings, and they deprecated the associated GML function.

Oh silly me :D How could I have missed that, deprecating stuff and all :P  They remove stuff at their convenience just because THEY don't find it useful :D

Quote
No, it won't at all effect the game's performance because the demo I'm going to distribute with the DLL will only switch the game to use fakeFS whenever there's a dialog box opened, so if the main game window is the only window the game has opened, you'll be using true fs instead.

Ok, so it would seamlessly switch right ? 

BTW, this can be done in ENIGMA the borders can be disabled in global settings :) although never tried it. :)

 
Title: Re: FakeFullscreen.dll
Post by: time-killer-games on March 20, 2014, 03:38:58 pm
I know Enigma can do that, I needed GameMaker to do that. :P

But I found an easy solution, a DLL someone else already made. (http://gmc.yoyogames.com/index.php?showtopic=605309)

To see how 'seemless' it is, here are two of games that use it, first-thing shown after their title screens...
*Attack of the Naked Blockheads 3D (https://dl.dropboxusercontent.com/u/79893663/Attack%20of%20the%20Naked%20Blockheads%203D/downloads/Attack%20of%20the%20Naked%20Blockheads%203D%20for%20Windows.zip)
*Real Men Wear Pink HD (https://dl.dropboxusercontent.com/u/79893663/Real%20Men%20Wear%20Pink%20HD/downloads/Real%20Men%20Wear%20Pink%20HD%20for%20Windows.zip)

The only issue is the main game window behind the message box turns solid white, for as long as the message remains opened. But oh well, it's better than
switching to windowed mode. :)
Title: Re: FakeFullscreen.dll
Post by: TheExDeus on March 20, 2014, 03:52:28 pm
I have used removing boarders in ENIGMA recently, and I can tell you that it works on Windows just fine. I used it to make my own border in ENIGMA (together with minimize and close button). window_set_minimized() was actually implemented only recently - https://github.com/enigma-dev/enigma-dev/commit/bfe37a864662303835ec552b5f6180fe70dc2371
Title: Re: FakeFullscreen.dll
Post by: time-killer-games on March 20, 2014, 04:01:10 pm
Cool, thanks. But I already knew that and used it in the past and I needed it for GM not Enigma. :P
But anyway, at least my discovery fixed the issue for Windows. Now if I could get someone to port that guy's DLL to a DyLib with code:blocks, so it will work on Mac too. :)
Title: Re: FakeFullscreen.dll
Post by: Goombert on March 21, 2014, 02:34:28 pm
I don't understand why this is useful exactly. My biggest complaint with full screen games is when they don't freeze when losing focus, so if they are doing mouse capture, you can't ALT+TAB to the desktop to like chat with someone real fast or something. I hate applications that do that.

Also, all extension topics GM or ENIGMA belong in the 3rd party subforum.
Title: Re: FakeFullscreen.dll
Post by: Darkstar2 on March 21, 2014, 03:13:41 pm
I don't understand why this is useful exactly. My biggest complaint with full screen games is when they don't freeze when losing focus, so if they are doing mouse capture, you can't ALT+TAB to the desktop to like chat with someone real fast or something. I hate applications that do that.

Also, all extension topics GM or ENIGMA belong in the 3rd party subforum.

You could fix this by including a proper pause menu in your games.   BTW, GMS has a OS focus command, you could use it to trigger your pause menu / routine.  Is this function active in ENIGMA ?

I know what you mean about some games and ALT-TAB issues, lol, there are times when I was stuck in a game after hours of trying, and I would use a help /walkthru and would need to ALT-TAB, remember how problematic it was with some games and all the cussing :P Those were the days.
Title: Re: FakeFullscreen.dll
Post by: TheExDeus on March 21, 2014, 05:48:26 pm
Quote
BTW, GMS has a OS focus command, you could use it to trigger your pause menu / routine.  Is this function active in ENIGMA ?
No, I don't think we currently have that function. I guess I could add it. What is it called in GM? All I found was "os_is_paused()". I would prefer be called window_get_focus() or something. But I guess we can overload it for os_is_paused() as well. And while GM says os_is_paused() will return true only for 1 step, I think it would be better if it was true all the time while out of focus.

Quote
I know what you mean
He is actually talking about mouse issues in 3D shooters. In 3D games your mouse is always centered every step. This means if you ALT+TAB and it still does that, then you cannot move your mouse (even though you are in the desktop). That is often a problem with 3D examples in GM.
Title: Re: FakeFullscreen.dll
Post by: Darkstar2 on March 21, 2014, 08:17:10 pm
Quote
BTW, GMS has a OS focus command, you could use it to trigger your pause menu / routine.  Is this function active in ENIGMA ?
No, I don't think we currently have that function. I guess I could add it. What is it called in GM? All I found was "os_is_paused()". I would prefer be called

I thought it was already functional in ENIGMA.  Is it a lot of work to add this ?

Quote
He is actually talking about mouse issues in 3D shooters. In 3D games your mouse is always centered every step. This means if you ALT+TAB and it still does that, then you cannot move your mouse (even though you are in the desktop). That is often a problem with 3D examples in GM.

I've had this exact problem too before with some games and some more severe.

Usually before ALT-TAB I usually go to a pause menu in the game first.  I have not had any issues with recent games.

Title: Re: FakeFullscreen.dll
Post by: time-killer-games on March 21, 2014, 08:26:14 pm
Darkstar - it is in ENIGMA, just have a look at the global game settings, I've used it before and can verify it works.
Quote
[checkbox] Freeze the game when the window loses focus
Title: Re: FakeFullscreen.dll
Post by: Darkstar2 on March 22, 2014, 02:36:40 am
Darkstar - it is in ENIGMA, just have a look at the global game settings, I've used it before and can verify it works.
Quote
[checkbox] Freeze the game when the window loses focus

Thanks I will keep that in mind.
However it would be good to check for focus through a function, this would allow for automatic pause menus or other actions.

Title: Re: FakeFullscreen.dll
Post by: Goombert on March 22, 2014, 10:58:04 am
Quote from: TKG
Darkstar - it is in ENIGMA, just have a look at the global game settings, I've used it before and can verify it works.
Sadly, I haven't gotten it working for Linux yet, well because, XLIB is fucking shite compared to Win32.

Quote from: Darkstar2
I thought it was already functional in ENIGMA.  Is it a lot of work to add this ?
No it is very easy to add os_is_paused() since I've already implemented the lost focus stuff, we literally just need to make that function return a boolean value (enigma::gameFroze) that already exists in code.
https://github.com/enigma-dev/enigma-dev/blob/master/ENIGMAsystem/SHELL/Platforms/Win32/WINDOWSmain.cpp#L330

Quote from: TheExDeus
All I found was "os_is_paused()". I would prefer be called window_get_focus() or something. But I guess we can overload it for os_is_paused() as well.
I would prefer you just name it their version, no need otherwise you'll have to wrap like 50 functions, they have several more, YYG is just trying to make those functions more cross-platformish I suppose.

Quote from: TheExDeus
And while GM says os_is_paused() will return true only for 1 step, I think it would be better if it was true all the time while out of focus.
Because of ENIGMA's current implementation, it will behave exactly the same as GM, please do not change it, just implement the function and be done.

Quote from: TheExDeus
That is often a problem with 3D examples in GM.
This is not just a problem with GM games, but also DirectInput games such as GTA: San Andreas, and it's a bitch for me to try and play it while connected to #enigma using Hexchat, since Hexchat also uses DirectInput and they fuck with each other.

DirectInput is deprecated for a reason, RawInput is better, and Microsoft even advises not using DirectInput, all it does is add bloat to your games and make them run shitty. Microsoft does recommend using them for Joysticks, however ENIGMA uses RawInput for Joystick functions just like GM does.

Edit: I have gone ahead and implemented os_is_network_connected and os_is_paused for Win32 in the following pull request.
https://github.com/enigma-dev/enigma-dev/pull/673
Title: Re: FakeFullscreen.dll
Post by: TheExDeus on March 22, 2014, 12:49:18 pm
Quote
function return a boolean value (enigma::gameFroze) that already exists in code.
That wouldn't work, as the boolean is set only when "Freeze the game" thing is enabled. But that check isn't really necessary and can be put in the main loop instead.

Quote
YYG is just trying to make those functions more cross-platformish I suppose.
But that again break not only the naming convention but common sense. The OS is NOT paused when that function returns true, the game is not even paused. The game just lost focus. But at least if I make two versions they can be both used - this one will work just like GM:S and the window_get_focus() will work like it really should.

Quote
Because of ENIGMA's current implementation, it will behave exactly the same as GM, please do not change it, just implement the function and be done.
It will NOT work like GM implementation. It will actually not work at all. The bool will be set to true only when you have "Freeze the game when the window looses focus" enabled and that will then break because the bool will be the false again when the window regains focus. This means no events are going to be executed in the middle and in the game os_is_paused() is never going to return true.

Quote
Edit: I have gone ahead and implemented os_is_network_connected and os_is_paused for Win32 in the following pull request.
It seems you still don't try your own pull requests. :) I wrote why it wouldn't work and after testing that commit - surprise - it doesn't work. There are about 4 reasons why it wouldn't.
I will implement this to make it work like a window function and then implement the os_ one to work like GM.
Title: Re: FakeFullscreen.dll
Post by: Goombert on March 22, 2014, 01:07:19 pm
It was a simple mistake I overlooked it, cut me a break. I have amended the pull request with the fix for XLIB and Win32.
https://github.com/enigma-dev/enigma-dev/pull/673

Quote from: TheExDeus
But that again break not only the naming convention but common sense. The OS is NOT paused when that function returns true, the game is not even paused. The game just lost focus. But at least if I make two versions they can be both used - this one will work just like GM:S and the window_get_focus() will work like it really should.
Yeah no, that is not what the function is at all. It has to do with mobile devices and whether the application is in the background, ie. you have an incoming call on your cell phone.
http://docs.yoyogames.com/source/dadiospice/002_reference/operating%20system/os_is_paused.html

Quote from: TheExDeus
I will implement this to make it work like a window function and then implement the os_ one to work like GM.
Or you could just, you know, amend my commit since I've outlined other functions as well.
Title: Re: FakeFullscreen.dll
Post by: TheExDeus on March 22, 2014, 01:17:51 pm
Quote
Yeah no, that is not what the function is at all.
It also works in Windows (read the doc you linked). And that is exactly why I said I will implement window_get_focus(), because that is the function we actually wanted. Like check if window_get_focus()==true and only then center the mouse. Also, your current implementation still doesn't do what os_is_paused does in GM. It does what window_get_focus() is supposed to do. I just implemented it too and basically the same way. To make os_is_paused() work like GM it will have to be a lot less pretty (we need additional variable to check if window was in focus last frame).

Quote
Or you could just, you know, amend my commit since I've outlined other functions as well.
I am not really interested in those functions.
Title: Re: FakeFullscreen.dll
Post by: Goombert on March 23, 2014, 09:39:41 pm
Quote from: TheExDeus
To make os_is_paused() work like GM it will have to be a lot less pretty (we need additional variable to check if window was in focus last frame).
You're assuming that the 1 step is guaranteed.

At any rate I have fixed it and tested it for Win32 to have the expected behavior and committed, the following works fine. I still need to test and make sure Studio does actually behave this way, and if so then it can be merged. However, I don't agree at all with the way they handled this, honestly it was so stupid, they should have just made FocusGain and FocusLost events.
Code: (EDL) [Select]
if (os_is_paused()) {
show_message_async("OS Paused");
}

This was the commit amended that fixed the issue.
https://github.com/RobertBColton/enigma-dev/commit/28b0f89bba5f1c38daf3944781cfe495d92af51f
I also had to apply the following fix to that.
https://github.com/RobertBColton/enigma-dev/commit/a6706ff2d12141c561d4d2d172826955e224cbc7

Edit: I have tested Studio, and the current version appears to behave exactly the same, so the pull request is good to merge. However I have noticed a new inconsistency in the asynchronous dialog functions.
Title: Re: FakeFullscreen.dll
Post by: Darkstar2 on March 23, 2014, 11:14:11 pm
Quote from: TheExDeus
To make os_is_paused() work like GM it will have to be a lot less pretty (we need additional variable to check if window was in focus last frame).
You're assuming that the 1 step is guaranteed.

At any rate I have fixed it and tested it for Win32 to have the expected behavior and committed, the following works fine. I still need to test and make sure Studio does actually behave this way, and if so then it can be merged. However, I don't agree at all with the way they handled this, honestly it was so stupid, they should have just made FocusGain and FocusLost events.
Code: (EDL) [Select]
if (os_is_paused()) {
show_message_async("OS Paused");
}


Thanks Robert.  I guess we both agree that YoYo has not done many things correctly.
One can write a book on that topic.  But their shit sells and seems to do quite well. Maybe people don't know better :D  Probably most mobile developers won't give a shit either. :P

BTW I agree with the focus events.  Maybe their reasoning is that it is not useful to them.  Much the same reasoning behind them removing some windows functions that are standard in other products, so they basically, not giving a two shit about their customers, will only implement things if THEY find it useful.

Title: Re: FakeFullscreen.dll
Post by: Goombert on March 24, 2014, 12:22:21 am
Heh, I really despise the premise of the whole thing, ENIGMA too. I just think we have a better C-inspired cross-platform wrapper for DirectX on Linux, etc.