Time to Start Improving my Browser in Godot

Please complete the required fields.




Welcome back to WebUrbEx my Godot project where you explore the retro internet.

Web Browsers: you’re probably using one right now. “The Internet Button”. Mostly Chromium.

Whatever you want to think about them, Web Browsers are inherent to how we experience sites on the internet, and because of that the UI of WebUrbEx needs to take on the form and function of a web browser (in all aspects aside from actually connecting to the internet). Naturally that means that I need to copy most if not all features of conventional browser design to make the UI fit for purpose.

Let’s pull up the browser interface so far and see how well we’re doing.

Pretty standard so far.

The menu bar has File, Bookmarks and History menus, which kinda work.

We also have the omnibar. I talked about this in the portion of the devlog dedicated to urls and search engines, but basically this takes you to a website or if it fails, takes you to the search engine.

Finally there’s a couple of technical pages, a New Tab page (pictured), Credits (just says I made the game) and a 404 page in case something goes really wrong.

Solid foundation. Well, not that soild codebase wise, but the feature base is at least what you’d expect.

Which just leaves

  • Cutting
  • Coping
  • Pasting
  • Dowloading things you right click on
  • Being able to go back and forward a page (on each tab)
  • tabs being able to have the same name
  • Light Mode/Dark Mode
  • Find in page (Ctrl+F)
  • Adblock
  • Probably a bunch of other stuff

Yeah just a couple ideas. I’m… not gonna do all of that in one go but let’s get started on at least a few of those:

Right Click Menu Time

This one’s pretty easy to understand, we want a menu that pops up to do a bunch of things over the browser so let’s create a new class to handle that and start connecting it to both OS level functions like the clipboard and things inside our browser UI.

Is it easy to implement? Yesn’t.

A clipboard menu

Clipboard Actions

Godot in theory supports all of these, the shortcuts Ctrl+X, Ctrl+C, Ctrl+V and Ctrl+A all work with text/line edit boxes, and Ctrl+C and Ctrl+A work with rich text labels, meaning all the functionality is there. And indeed, the right click menu image above is the default menu that godot (unfortunately only) pops up in Text and Line Edit boxes. So the tools for making our own custom menu for that (so we can set it up to show up other places and work with other things) should all be there.

This is true for TextEdit. It is not true for LineEdit (despite the inbuilt menu being able to do it for both), and Copy (the only relevant one) isn’t exposed in Rich Text Label.

Let’s ask an expert where they are

So yeah instead I had to manually recreate the logic for cutting, copying, and pasting… for 2/3 text containers, while the other one just worked fine.

Godot, ladies and gentlemen. So easy to work with except for all of the bits that haven’t been standardised or implemented yet. seriously. I swear I like this engine.

Selection controls

How about selecting all and deselecting, what gross inconsistencies does that offer?

Huh, well. Let’s not look a gift horse in the mouth.

Select All, Deselect and even Delete for the edit nodes all just… work consistently.

Adding Copy support for images?

Godot says no. Apparently it was going to be added to the engine years ago with pasting images from the clipboard, then wasn’t and now some of the contributors on github have spent decades pontificating about the best way to do it.

a hippo
How Sad

Searching Selected Text

Right Click “Search [search engine] for “selected text” is a fairly essential quality of life feature for modern browsers.

Funnily enough this is a case where that manual copy code from before is handy, we can just use that for every text element and pass it to the top level controller to open a tab with that search.

Adding to bookmarks, Downloading page source or image source, Other browser related things

Well… Um… ok so let’s get back to that

Well, not that soild codebase wise

part.

I need to overhaul the backend of WebUrbEx’s UI

When I started working on the project file that would become this version of WebUrbEx, I went about setting up the UI and manager script in a way that seemed like a streamlining the absolute mess I made last time. I shoved the functionality of the File, Bookmarks and History menus into one script called “Top Level Browser”.

This is the earliest screenshot I have of this version of the project on this blog

As I’m sure I’ve gone over before, Opening websites works by creating a scroll container with the website’s name, instantiating a scene (such as the EasyWebArchive scene, or the MorriganSearch scene) as its child, and then passing any additional arguments along while it loads, so it can, for example, load the rest of the site from a text file.

This leaves the scene tree looking a little something like this.

AS the TLB script grew, I started splitting off all the methods to do with loading into a Global Resource Manager script, and now that I’m making this right click menu I’ve made a Pop-Up Manager script to handle that too, but as I’ve been building these up I’ve realised how daunting connecting things up to TLB is because it’s kinda sprawling and… while no less sprawling than the other scripts, disorganised in how it does that. Tabs only really exist as the instantiated nodes, so… it doesn’t keep track of information on them. Before I started working on this I wanted to make the credits page load info about the last visited site, only to realise that TLB wasn’t even keeping track of what sites were loaded. And even though tabs can have custom names to hide the fact that every object has to be named something different, there’s nothing taking control of that. In short, TLB was the first script I wrote… and that shows.

Blue Ducks

And this is where I’d show all the changes I made to fix this… but I haven’t. Not yet. I’ve been using these blogs like a rubber duck to talk through fixing the bits of the project that need fixing, and… yeah, that’s been working. It’s just really tiring to write up a description of what your code is doing, then spend 2 days fixing it before continuing writing it so you can get back to the thing you did 2 weeks ago. So… as a change from that I want to kinda just go through what I’ve done so far at this point, and make a part 2 when I have fixed this. So… for now I’ll just go through the other things I’ve been up to.

Technical Scenes/Prefabs

I’ve added some new technical scenes to the game, a ViewText scene for implementing a right click -> view page source feature, later on. As mentioned, I’ve added a new section to the credits page that’ll show a site’s credits.txt file, and I’ve created a “BasicComment” prefab for use in the next thing

This should be the last technical stuff so, new H3 heading

Art Time

I’ve gone some way into implementing the EasyWebArchive-Guestbook scene.

An interaction between a couple of characters on the EWA-G homepage.

I’m experimenting with using themes to make EWA-G sites look different to EWA. A lot of their codebase is… already deliberately torn down to act more primatively for LORE reasons.

IDK how we feel about the word Imbercile, it feels appropriate, but there’s a question of whether or not it’s far back enough on the tredmill of terminology to have gone from a slur to a banal insult. LMK your thoughts

I’ve also done some planning for an “Adventure Game” style website

This is going to be kind of a PITA to make without having anywhere to write or read data from in EWA, but I’ve planned it out so it should be entirely possible (if tedious) to make with hyperlinks and about 300 pages.

Preparing for an upgrade to 4.4

Also Godot 4.4 released. It has jiggle physics.

While I haven’t updated yet, I have reworked my build tools to use OS.GetExecultablePath() and ProjectSettings.GlobalizePath() so that if I do start running it in Godot 4.4 or in a different project folder, it’ll still work.

I’m hesitant to update it to 4.4 as it doesn’t fix any of the outstanding issues I complained about above, and I don’t need any of the new features. I also don’t wanna have to deal with jumping the codebase up by 2 C# versions just yet, IIRC C#7 and up make it a lot more annoying to work with nullables, but… eh, I’ll have to do it eventually.

As mentioned last time, while Expedition 1 isn’t out yet, you can check out the last demo on itch.io, play around with the website tools, find bugs I’ve already fixed, etc.

Tired and confused, may you ever be my ducks,

-Matt

2 Comments

Leave a Reply to Alice Cancel reply

Your email address will not be published. Required fields are marked *