Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Making Tantra run as a window

Junior Spellweaver
Joined
Oct 31, 2013
Messages
122
Reaction score
49
Hi everyone

I want to know others experiences making tantra work in window mode, I already have mine working but to be honest I don't know if the way that I did it is the best one.

Here is a video proving that is working in a window mode:



for those who want to share how they did it I want to mention that I tested changing the style of the native window from pop-up to window, but the problem I found with that is that the actual WndProc ignores the msg for moving it around. So in my head there are only 2 possible solutions: 1.- to replace the whole window with a new one and override the WndProc or
2.- parenting the window with another (this is what i did)

Is there another solution that I didn't think off?
 
Last edited:
Custom Title Activated
Loyal Member
Joined
Mar 26, 2012
Messages
1,465
Reaction score
131
This may not be the ideal way that you had in mind to do it but, I just made a launcher to configure and allow window mode of tantra by default and simply made a program after that with the alt key and mouse button would allow me to move the tantra window. It seemed to me to be simpler than trying to write a program to window the client just to be dragged around.





Ignore the tool to the right. That has nothing to do with what I created. LOL. That is just my Admin Tool because I am super lazy when it comes to typing.
 
Last edited:
Custom Title Activated
Loyal Member
Joined
Mar 26, 2012
Messages
1,465
Reaction score
131
Let me be the first to say that I love the way you did that with the window setup. I recreated the setup exactly as you have except for the resizing part, however, it is a great idea so far Eliana.

Essentially this is the same way that it is setup for Tantra Surya's setup.
 
Junior Spellweaver
Joined
Oct 31, 2013
Messages
122
Reaction score
49
And I like yours too.

My way is not same as those from Surya, I think they did their by using c++ win32 application and then embedding the tantra application by clicking on a config button to search for HTLauncher.exe. I think that what they are embedding is the whole HTLauncher process.

Mine is on my c# dll that is attached to HTLauncher so it is transparent for the user. When HTLauncher start, one of the first thing it does is to create the window to be the viewport of the directx, so what I did was to Marshal a delegate inside HTLauncher to run one method inside a class on c#, that method creates a managed Form to be the parent for the form created by HTLauncher. So what i'm really doing is just giving a parent managed form to the unmanaged one.

About re-sizing: as you may know htlauncher does not handle the msg for resizing by dragging the borders of the form, it only handles the full screen resize*, so if you want to resize by dragging the borders, you must find a way to repaint the viewport of directx with the new REC of the window, because if not then your PointToScreen will not be synchronized with the viewport. For example: you can make a form with a dock panel inside, and make the panel the parent of the viewport, that will make the panel resize when you resize the window so what is inside of the panel will be resized too but will not be synchronized with directx, meaning that if you have a button to click that was resized, you will notice that it does not highlight when you put the mouse over it, but if you move the mouse where it was before the resize, then it will become highlighted, to solve that, you have to repaint the viewport.

* it is what I call a fake resize because what it really does is change the actual device (Monitor) resolution to the one you have on the cfg file, it does not resize the viewport to the max resolution your monitor accept.
 
Last edited:
Custom Title Activated
Loyal Member
Joined
Mar 26, 2012
Messages
1,465
Reaction score
131
I am sure that Surya must have contacted the person here that originally made the window tool for Tantra that was released in ragezone. They claim that it will only work with Tantra Surya but, as you said it searches out HTLauncher, which means that it will work with any client. I have already tested this with mine at one point of time. Anyhow if I find a better way to do this, I will let you know immediately but, if you would like to collaborate or talk outside of ragezone, that is fine too.



I do have a small question for you though. How did you resolve the issue with closing the form and the HTLauncher not crashing? I am trying to override the close button to shut down the HTLauncher or at least leave it opened with the original window name so that there is no crashes.
 
Last edited:
Custom Title Activated
Loyal Member
Joined
Mar 26, 2012
Messages
1,465
Reaction score
131
Eliana Gherbaz - I have done a similar setup so far with the window tool but, added the option for window size in the beginning prior to opening the client. It will change the graphics of the client as well as the window before load up. Figured this way it would work out better.
 
Junior Spellweaver
Joined
Oct 31, 2013
Messages
122
Reaction score
49
I do have a small question for you though. How did you resolve the issue with closing the form and the HTLauncher not crashing? I am trying to override the close button to shut down the HTLauncher or at least leave it opened with the original window name so that there is no crashes.


I did nothing, because as I said I just gave a parent window to the window created by HTLauncher, so when I close the most top form (mine) it auto send the destroy message to the child (Tantra window) and when HTLauncher receive that message close all things related to the child (.exe,.dlls) and release memory w/o crashing.

But I know what you mean, and I thing I got that crash when I was embedding the HTLauncher instead of just parenting the window, if that is what you are doing, then you can use process.kill before you close your form and that will remove the crash (it is not the correct way but will solve your problem)



@Eliana Gherbaz - I have done a similar setup so far with the window tool but, added the option for window size in the beginning prior to opening the client. It will change the graphics of the client as well as the window before load up. Figured this way it would work out better.

Well that is how hanbit code the resize, by selecting the resolution before starting and saving on the HTUserSetting.sys , but I'm testing the resize at runtime by dragging the form borders, I already found a method that is suppose to repaint the viewport, but I have to debug it because I'm getting an unknown address when I marshal it.

BTW may I know in which language are you coding?
 
Last edited:
Junior Spellweaver
Joined
Oct 31, 2013
Messages
122
Reaction score
49
@jbeitz107: To simulate what HTLauncher does when closing, do this on your Form:

declare a delegate:
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
public delegate void EndGame(IntPtr ptr);

then add a method for FormClosing:
void FrmWin_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true; //to avoid the Form closing, because you will handle the close with htlauncher

//because HTLauncher do diff things depending on the game state you must read the g_iGameSequnce that is stored in HTextern.cpp
var seq = Marshal.ReadInt32((IntPtr)"address of g_iGameSequnce"); //in my case the address is 10A1F670
switch (seq)
{
case 1: // this is when game is on the intro part (not yet in game) is same as pressing the Cancel button in loging or Exit game button on char select, htlauncher just send a msg to the window that runs the Finalize method on the HTWindowManager, so you need to marshal the delegate to allow c# run the method.
var endGame = Marshal.GetDelegateForFunctionPointer<EndGame>((IntPtr)"address of HTWindowManager::Finalize() in my case is 100569D3");
// and because Finalize is a __thiscall you must give the pointer to the g_CGame in HTextern. g_CGame is the instance of the HTWindowManager created by WinMain
endGame(IntPtr("address of g_CGame" in my case is 10A1F6A8));
break;

// case 2 is when you are inside the game, in this case htlauncher runs the IDM_EXITAPP that disconnect the client from the server before running the finalize method, because IDM_EXITAPP runs too when you hit ALT+F4 I just emulate those keystrokes to perform the closing. InputSimulator is a nuget Package ( )
case 2:
InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.MENU, VirtualKeyCode.F4);
break;
}
}

I'm using this actually on my winform for closing
 
Custom Title Activated
Loyal Member
Joined
Mar 26, 2012
Messages
1,465
Reaction score
131
This would be much easier if it would simply select the game within the parent window then use the Alt+F4 button simulation but, do you have an idea of how to select the inside of the form window? I am currently having an issue just trying to make it active. Thanks
 
Junior Spellweaver
Joined
Oct 31, 2013
Messages
122
Reaction score
49
I don't know how you set the parent, in my case I parent to the form not to a panel, so when I click on any part of the form I'm actually on the game window, further more if I just move the mouse (w/o clicking) to any part of the viewport the game receive the msg, I tested this with ollydbg, setting a breakpoint on the winproc of htlauncher window and all msg are received.

If I press on my keyboard ALT+F4 it works as expected, and if I click on X button on the winform and if i'm inside the game, the ALT+F4 is sent by the InputSimulator, if i'm in the intro then the finalized is called
 
Last edited:
Junior Spellweaver
Joined
Oct 31, 2013
Messages
122
Reaction score
49
You're making it sound hard.
Here I'll spoon feed you.

Hi

Can you make a video of that program working with Tantra? and if it works for you, can you please tell us which configuration did you used, because till now i can't make it work with Tantra.
 
Back
Top