B4J Question [ Steam Client ] Closes the Form, but doesn't kill the application .

Waldemar Lima

Well-Known Member
Licensed User
I'm making a game for steam ( steampowered.com ) it works fine, but when I try to "kill" the game via SteamClient by clicking on "Stop Run",
1626360180207.png

the Form closes, but the application keeps running and it's only killed when I I go to the B4J client and click on "Kill Process", is there any way I can handle the request to close the game by the steam client?

1626360244480.png
 

Waldemar Lima

Well-Known Member
Licensed User
I was doing some tests, the B4XPages events are activated, but in : B4XPage_Disappear the only action that is done is a "Log", any other is ignored...

I recorded a video demonstrating what happens during the Steam button close call: Video mp4
why does this occur? Can anyone help me?
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
I was doing some tests, the B4XPages events are activated, but in : B4XPage_Disappear the only action that is done is a "Log", any other is ignored...

I recorded a video demonstrating what happens during the Steam button close call: Video mp4
why does this occur? Can anyone help me?

test: kill process

B4X:
Private Sub B4XPage_CloseRequest As ResumableSub
    ExitApplication
    Return True
End Sub
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
see:
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Maybe the steam thing needs a return value, you could try ExitApplication2(0)
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
 
Upvote 0

Waldemar Lima

Well-Known Member
Licensed User
Thank you very much for your suggestions guys, I shared the libraries and 2 examples of the wrapper I currently use to connect my b4j apps to Steam: TOPIC
to test the examples you just need to download the .ZIP, install Steam, log in with an account and run them ...
 
Upvote 0

Waldemar Lima

Well-Known Member
Licensed User
I did some tests here, I even created a console version, and I believe it's a problem between Steam and Java, I've never had problems with it in my other games made in C++ (it could be that as it's rare it receives games made in Java, I don't think it supports it at all ) .

but I will continue to find a solution... :rolleyes:
 
Upvote 0

Waldemar Lima

Well-Known Member
Licensed User
didn't work :c


but i think i found the problem... after a whole day of testing...

I have 3 b4xpages : ( B4XMainPage , Lobby and Game )
the B4XMainPage & Lobby pages are closed normally without any problem ... but if I load the Game page with >: B4XPages.ShowPageAndRemovePreviousPages("Game") and after that I try to close using the Steam Client button, it pauses on the line : Wait For (sf) Msgbox_Result (Result As Int) and is running in the background (I believe, it's waiting for the Wait For to finish...) .
Now we get into another problem...
Every time B4XPage : Game shuts down, I need it to go back to B4XPage : Lobby , but if I use the code below, the game doesn't shut down...

B4X:
Private Sub B4XPage_CloseRequest As ResumableSub

    Log("## Close Request ##")

    Dim sf As Object = xui.Msgbox2Async("Close?", "Title", "Yes", "Cancel", "No", Null)
    Log("run up to here...")
    Wait For (sf) Msgbox_Result (Result As Int)
    Log("from here down doesn't do anything...  xD ")
    If Result = xui.DialogResponse_Positive Then
        B4XPages.ShowPageAndRemovePreviousPages("Lobby")
        Return True
    else If Result = xui.DialogResponse_Cancel Then
        Return False
    else If Result = xui.DialogResponse_Negative Then
        Return False
    End If
 
 
    ExitApplication
    Return True
 
End Sub

how do I ask the user if he wants to go back to the lobby, without having a problem with the close button on the SteamClient ?
What do I do now ? I'm about to pull my hair out to find a solution xD
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
didn't work
Of course; you attached a "strange" version, without B4XPages and now you are talking about 3 B4XPages...!

Also, why do you write something like:
I try to close using the Steam Client button
do you think that makes sense to us? Is there a "Steam Client button" in B4X? :) (I'm (almost) kidding).


Every time B4XPage : Game shuts down, I need it to go back to B4XPage : Lobby , but if I use the code below, the game doesn't shut down...
I can assume that you switch from B4XMainPage to the Lobby b4xpage, from this one to the Game b4xpage and when you exit from here, from the Game page, you want to go back to the Lobby, not closing the app, right?

So from the Lobby you should open the Game without removing the Lobby, i.e. using the normal ShowPage command, not ShowAndRemovePreviousPage and then you have nothing to do to return to the Lobby, just close the Game b4xpage.

If you mean that by closing the Game page the "actual game" still "runs", then probably there is something inside the Game page that you did not stop before closing that page.

Excuse me but with the information you have given (which seems more confusing to me than myself šŸ˜) and with the "surreal" projects you have attached, I am not able to help you more than that. Others will probably be able to.
 
Upvote 0

Waldemar Lima

Well-Known Member
Licensed User
In this example the Main page is closed normally using " Steam Close Button ", but when I open the test page, and I try to close it by " Steam Close Button " , the application is stuck in Wait For (sf) Msgbox_Result (Result As Int) inside " B4XPage_CloseRequest ", if I remove the Wait For (sf) Msgbox_Result (Result As Int), it quits normally... the problem is in the Wait For (sf) Msgbox_Result (Result As Int) that does not let the application terminate until you select > Positive or Negative or Cancel.
then comes a question, I need to wait for the user's response to know whether or not he wants to leave the game...
 
Upvote 0

Waldemar Lima

Well-Known Member
Licensed User
View attachment 116631

Until you attach "healthy" projects, it will be difficult to help you.
B4XPages projects must be exported by CTRL + Click on the comment line you find in B4XMainPage:
B4X:
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
oooh, sorry ...
thanks for reminding me of this detail xD
has already been updated...
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
First thing I saw is:
B4X:
Private Sub B4XPage_Disappear
    
    Log("teste_desappear")
    
End Sub
in the B4XMainPage.

In this page you use:
B4X:
B4XPages.ShowPageAndRemovePreviousPages("teste")
to open "teste", closing the "current" page on top, which is B4XMainPage.
So that log will be written when B4XMainPage disappers (closes).
Did you write "test_disappear" because you think the B4XPage "teste" is "disappearin" or because you think the app is closing, there?
 
Upvote 0
Top