Spawning a custom window, natively

Discussions about Coding and Scripting
Post Reply
User avatar
The_Cowboy
Skilled
Posts: 165
Joined: Mon Jan 24, 2011 3:22 am
Personal rank: Codezilla

Spawning a custom window, natively

Post by The_Cowboy »

Howdy!

Aim: Obtain the ability to load bmp images, on demand, within the game.
  • Attempt 1: Load bmp images via FWindowsBitmap

    Code: Select all

    FWindowsBitmap TestBitmap;
    UBOOL bResult = TestBitmap.LoadFile(*FilePath);
    
    Then pray for an API opening for import. Maybe there is one (not quite sure)

    Code: Select all

    const TCHAR* Import( const TCHAR* Buffer, const TCHAR* BufferEnd, const TCHAR* FileType );
    
    in which case I need to know the buffer.

    Code: Select all

    WINDOW_API HBITMAP LoadFileToBitmap( const TCHAR* Filename, INT& SizeX, INT& SizeY )
    {
    	guard(LoadFileToBitmap);
    	TArray<BYTE> Bitmap;
    	if( appLoadFileToArray(Bitmap,Filename) )
    	{
    		HDC hDC				 = GetDC(NULL);
    		BITMAPFILEHEADER* BH = (BITMAPFILEHEADER*)&Bitmap(0);
    		BITMAPINFO* BI		 = (BITMAPINFO*)(&Bitmap(0) + sizeof(BITMAPFILEHEADER));
    		void* RawData		 = &Bitmap(0) + BH->bfOffBits;
    		SizeX                = BI->bmiHeader.biWidth;
    		SizeY                = BI->bmiHeader.biHeight;
    		HBITMAP      hBitmap = CreateDIBitmap( hDC, &BI->bmiHeader, CBM_INIT, RawData, BI, DIB_RGB_COLORS );
    		ReleaseDC( NULL, hDC );
    		return hBitmap;
    	}
    	return NULL;
    	unguard;
    }
    
    Few hints that BITMAPINFO and BITMAPFILEHEADER is what I be needing. Sees like where they are stored, HBITMAP, is hidden?
  • Attempt 2: Try to simulate the splash screen, in the beginning, before the complete game loads up.

    Code: Select all

    // An operating system window.
    class WINDOW_API WWindow : 
    #if WIN_OBJ
    public UObject, 
    #endif
    

    The thing that is stopping me is

    Code: Select all

    #define WIN_OBJ 0
    
    defined in Window.h
Any direction towards achieving the aim will be greatly appreciated.

Cheers,
The_Cowboy

Automatically merged

Minor progress
Spoiler
Seems like UTexture::Import hasn't been implemented yet?
MSVC wrote: Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: unsigned short const * __thiscall UTexture::Import(unsigned short const *,unsigned short const *,unsigned short const *)" (__imp_?Import@UTexture@@QAEPBGPBG00@Z) referenced in function __catch$?execSpitIpFromChatString@ACDDiscordActor@@QAEXAAUFFrame@@QAX@Z$1 ChatDiamond G:\SteamLibrary\UnrealTournamentGOTY\ChatDiamond\UTNativeEssentials\UTNativeLightHouse\ChatDiamond\ChatDiamondNative.obj 1
Attempt 1 seems rendered (literally!) fruitless.
Feralidragon wrote:Trial and error is sometimes better than any tutorial, because we learn how it works for ourselfs, which kills any doubts about anything :tu:
Patreon: https://www.patreon.com/FreeandOpen
User avatar
The_Cowboy
Skilled
Posts: 165
Joined: Mon Jan 24, 2011 3:22 am
Personal rank: Codezilla

Re: Spawning a custom window, natively

Post by The_Cowboy »

Ok some progress in spawning window natively

A sketch snippet

Code: Select all

void ACDDiscordActor::execOpenNativeTestWindow(FFrame& Stack, RESULT_DECL)
{
	guard(ACDDiscordActor::execOpenNativeTestWindow);
	P_GET_UBOOL(bVisible);
	P_GET_OBJECT(UObject, ParentWindow);
	P_FINISH;

	UViewport* ClientViewPort = UTexture::__Client->Viewports(0); //thx mongo! (amazing this works) and thanks Anthrax

	WObjectProperties* P = new WObjectProperties(TEXT("EditActor"), 0, NULL, WWindow::_Windows(0), 1);
	WWindow::_Windows.AddItem(P);

	P->OpenWindow();
	P->Show(1);

	(VOID*)Result = NULL;

	unguard;
}
IMPLEMENT_FUNCTION(ACDDiscordActor, -1, execOpenNativeTestWindow)
and the beautiful result is like so

Image

Few things to note:
1. I am intending to spawn such window within the game (or game loop!)
2. I know this is possible because I have seen certain, ahem, native mods, a euphemism, doing this.
Feralidragon wrote:Trial and error is sometimes better than any tutorial, because we learn how it works for ourselfs, which kills any doubts about anything :tu:
Patreon: https://www.patreon.com/FreeandOpen
Post Reply