Close a game in Godot - html

I'm creating a web game using Godot.
For close the game, i tried to use `get_tree().quit()`.
If I use it on the IDE, it works. When i tried it on my server (after exported the project) it doesn't work.
I'm sure that Exporting setting are okay.
How can I close the game?
And, how can I add an hypertext link (similar to html `` tag)?
Thanks for your answer and sorry for my bad English

Exit the game
On the web, using
get_tree().quit()
Should work. That is, it should stop the runtime. The game will not continue running. It does not close the browser tab. In fact, browsers have restriction on scripts closing tabs.
Note: Make sure you are using Godot 3.2.3 or newer (see #39604). I tried it, it works.
Making a link
You can a LinkButton, which is a button that looks like an hyperlink. And you want to connect its "pressed" signal to a script where you use OS.shell_open, for example:
OS.shell_open("https://example.com")
Note: This result in a new tab in web exports. On the desktop it opens the default browser.
Navigating the browser
Since you ask about closing the game, and about making a link, I'll venture to guess that what you actually want is to navigate (leaving the game and going to another page), you can accomplish that with JavaScript.eval, for example:
JavaScript.eval("window.location.href='https://example.com'")
Note: This can only work on a web export.
Detecting Web Build
You can use OS.get_name to identify the platform.
For example, you can do this:
if OS.get_name() == "HTML5":
JavaScript.eval("window.location.href='https://example.com'")
else:
OS.shell_open("https://example.com")
Which will navigate the browser if this is a web build, but if it isn't, it will try to open the default browser.

Related

How to highlight section in VScode live server when clicking my source code?

Question
The editor brackets can do that. Supposed that, when I click my html tag in my source code file, the browser would automatically highlight the section/div in the broswer like google chrome developer tools.
Step 1
Click my tag in my source code file
Step 2
the live server will automatically focus on the section I want
How could I make it in VSCode?
VS Code does not have a built-in live server. Whatever extension you are using for live server can implement this, however I am not aware of any ones that do currently. Consider filing a feature request against them for this
Look at Five Server extension.
I used to love this Live Preview of Brackets, mainly for two unique features unlike many other editors and extensions:
It shows the preview live, literally. It doesn’t wait for file save to show the changes.
Highlights the section in the preview, corresponding to the html tag in which the cursor is placed currently.
I have been looking for a similar VS Code extension for a while.
Finally found it, JUST NOW.

How can i go back, forward and print a (local) WebBrowser1.DocumentText html page that's sourced from my.resorces - vb.net

the title basically says it, i have a from with a treeview and a webbrowser control and three buttons. i want the back button to load the previous viewed html file from myresources and the same but opposite for forward?... also how can i and where can i link my external css to my program like my.resources so when i export the program for installing on another machine it still works? and one more thing... how can i intergrate/embed the webbrowser control into my program because as i believe it uses internet explorer and if someone installs my program onto their computer and they have un-installed ie and use firefox it won't work? thank you guys very much, i know it's a lot of questions but you guys are awesome!. thanks
It would be easy for you if you read this web pages from the resource file and then save them to a disk.
In this way you can simply pass the physical path to the Navigate method and similarly you can use GoBack and GoForward and Print methods.
But if you don't want them to save them, you still can read the web pages from the resource file and then use DocumentText property to display the webpage.
Using this method you won't be able to navigate back or forward.

Is it possible to save changes in Firebug locally?

What I'm trying to do is to save the changes I make to CSS and HTML on different sites with Firebug.
Just to be clear, I don't expect Firebug to upload the changes to the server via FTP or anything. I just want to save the changes locally, so only I will be able to see them.
For example I've seen a few Firefox/Chrome extensions that add a download button under every video on Youtube, so I know it's possible to do that somehow.
If you have a different way to achieve what I'm trying to do, I'll be glad to hear about it.
(It doesn't have to be with Firebug.)
Thanks in advance!
If you don't mind using Web Developer Toolbar it's easy to save changes made to the DOM (and CSS).
When you install the toolbar, you'll get a "View Source" menu, click on that and choose "View generated source". Then just copy and paste that into a .html file.
You did not say if you alter your HTML or CSS, if CSS, FireFile is a very good addon for this.
Edit, with some Googling, i found FireDiff, which states that it can export changes made in Firebug, i have not tested it bit it's worth checking out.
You could try using Greasemonkey.
It has support for adding custom scripts that are run whenever you load a page (linked to which pages it should load on) and that can make changes to the page dynamically.
https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/
The http://chrispederick.com/work/web-developer/ web developer toolbar will let you add a user style sheet to a site which should achieve your goals.
This may or may not be exactly what you're asking for, but you can download the extension FireDiff in order to save changes made with FireBug. I made a little tutorial on how to do it here: https://www.youtube.com/watch?v=m4OmZLX2zd4
I have a somewhat simlar use-case that I solved differently. I'm not sure if it is what you are looking for or not. I'll describe the behavior and if that is helpful I'll explain exactly how I implemented it.
I changed the code that execute when you click "Run" (or Ctrl+Enter) to check to see if the first line of the code is a hard-coded string //LoadFromFile:<file path>. If it is, and the file exists then I pull the file off of the local file system and run it instead of executing the code in the console window. This way I can use an external text editor to write code.

Local WebSite: run default browser

I need to create a brochure-cd from a website I did. All resources are html, images and xml, so i don't have any problem at all in accessing file system. My question is: once I open my index.html page in browser, how can I set the params of the window (eg: show addressbar, show statusbar, etc)
Thanks
(If you have an alternative idea of how run an html based brochure on CD just let me know)
EDIT: Specs changed, I've just knewn I must write xml and upload file, too. Any idea? I'm considering Adobe Air, but would be amazing if I can compile a whole .NET website into an exe..... Anything similar?
The only way you can set these is when you open the page, not after it's already present. So, you will probably have to have a start page, which then opens your new page, with the parameters you want.
Be warned though, if you have any JavaScript, many browsers won't allow scripts to run locally, or will present a nasty warning message before it will execute.
You may look into having a small desktop application on the CD that launches an instance of a browser inside of itself, assuming you can run the browser on every machine this will be run on. This will probably give you the look you're after.
I think you can't. You can only set params of a window you create. So you'll have to run a script on load that creates a new window and then closes the initial window.
There is however no way that this script is executed without warnings, if at all.
An alternative would be to develop an executable that is able to display the page, but that might not be easy, especially when you want to be browser and platform independent.

HTML input type = file in Adobe AIR does not present file browser

So the good old HTML file uploader tag only presents a browse button (without associated text input) when rendered in a HTML based Adobe AIR application. Upon clicking the browse button, nothing seems to happen. I would expect a popup window so I can select a file. I've seen examples of people using Javascript to call the AIR runtime to get a file and upload it, but I was wondering if anyone knew a complete HTML/Javascript way of doing this with AIR.
thanks
Actually, this does work. I somehow managed to stop this from working, probably through a combination of cloning that part of the DOM elsewhere.