Cosmos: How to create a GUI

Created on 30 Sep 2020  路  78Comments  路  Source: CosmosOS/Cosmos

Area of Cosmos - What area of Cosmos are we dealing with?

GUI

Expected Behaviour - What do you think that should happen?

I should be able to make windows and such.

Actual Behaviour - What unexpectedly happens?

I cant.

Reproduction - How did you get this error to appear?

Not an error

Version - Were you using the User Kit or Dev Kit? And what User Kit version or Dev Kit commit (Cosmos, IL2CPU, X#)?

Dev kit
How do I make gui

CGS Question

All 78 comments

Making GUI's is a very complicated subject. You would first need to enter a GUI mode, then you need to make a Window Manager. And all that would be useless without a way to launch apps (file browser, taskbar, dock, start menu, start screen, etc.). Even something as simple as text would require you to make your own font! I don't have any examples other than MishaOS, which may not even be a great example of what you'd want to do. (All apps here must be hardcoded, you can't make executables show up.) Another example is the Cosmos GUI Framework but please be aware that this is a 2016 project and almost certainly no longer works!

So you are saying there is no way to make gui

Are you guys planning on putting the gui thing back

and do you think i should just use the 2016 version of cosmos since it looks like it is more customizable and there is more I can do?

and is there a way to make the console bigger

Ok so GUI's are DEFINITELY still possible. Easier than ever with bitmap support. It's still a very advanced subject. And you can even set screen height with this (careful though bitmaps can only go up to a megabyte from my research but I'm not positive). 1920x1080 might be hard to accomplish but I have no doubts that its possible. And even on the cosmos wiki you can find a cursor tutorial.

EDIT: Definitely use the latest version. And as to making the console bigger there might be a way but if you make a console in your GUI you can make it whatever size you wish.

Look at https://cosmosos.github.io/api/Cosmos.System.Graphics.Canvas.html for what methods are currently available for creating a gui. As @TFTWPhoenix said creating a working GUI is quite a lot of work.

and is there a way to make the console bigger

You can set it in https://github.com/CosmosOS/Cosmos/blob/master/source/Cosmos.System2/Graphics/VGATextMode.cs#L38

Ok thanks imma keep this open for 48 hours so I have time to try it out

just so you know the second code made no sense and I was so confused

speaking of gui how do you make a mouse that is super easy and can work with buttons

It isn't that simple. There are no "buttons". What you need is to make a mouse, then you get its x and y points and if they are in an area, do something.

oh ok

Sorry, should have mentioned that you also need to check if the mouse was clicked.
Here's the code for that:
MouseManager.MouseState == MouseState.Left

Also, with vga screen it doesnt work when setting color depth and that kind of stuff Here is the tutorial is there any way that this is an older version and the methods are diferent

Also How do i know the cordnates of things?

and why do i have the label pro?

Yes, that is an older version and the code is outdated. See my comment in your other issue, it explains it and there is a link to my more modern implementation of that same method.

ok

Your code was also confusing because there was folders with gui and stuff. I tried out the project and it worked but there was so much I was just confused

1499 just so others coming in can see the other issue

See my project

Making GUI's is a very complicated subject. You would first need to enter a GUI mode, then you need to make a Window Manager. And all that would be useless without a way to launch apps (file browser, taskbar, dock, start menu, start screen, etc.). Even something as simple as text would require you to make your own font! I don't have any examples other than MishaOS, which may not even be a great example of what you'd want to do. (All apps here must be hardcoded, you can't make executables show up.) Another example is the Cosmos GUI Framework but please be aware that this is a 2016 project and almost certainly no longer works!

actually it's very easy. i think the hardest is play sound....

if i know how to drive a sound card then i can make a real operating system

image

Thank you... I'll check it out

I made a new thread on how to add sound -- I doubt I wrote the question right but it can always be changed. #1501

I can only use console.beep to play sound now. This reminds me of FC

how did you add the bit maps... I've been trying for a long time and it keeps saying null reference error

also is that clock a clock that's actually on time?

@nifanfa i did some research and if you want to play a specific sound from a sound file you use this...
Namespace you need -- using System.Media;
Code -- SoundPlayer player = new SoundPlayer (@"###.mp3");
player.Play();

i hope that helped

@nifanfa i did some research and if you want to play a specific sound from a sound file you use this...
Namespace you need -- using System.Media;
Code -- SoundPlayer player = new SoundPlayer (@"###.mp3");
player.Play();

I bet it won't work

who knows?

I'll try it and tell you if it does

You don't even let the operating system know that there's a sound card. And i bet it will makes il2cpu fails to compile. System.media seems not work in cosmos

yeah it doesnt

The sound player command needs system.media but cosmos doesn't like that meaning... Hey cosmos people... can you allow us to play sound files.

There is something called NAudio. I dont know how to use it but I think that it could work... It can record and play audio.

No, it doesn't work. Cosmos has no speaker support outside of playing tones with the PC speaker and Console.Beep().

A1789E2EEFC2E939B8425DBBEC40E0BB.gif My previous project

Gui is really easy but play sound....

And networking...

1464 #1458

You are really good at GUI

Thx

in your project on launch it says something about a CPU exception and the GUI wont open. What is it?

It also says stack corruption occured after a while.

Have you put the files into filesystem.vmdk?

no how do I do that

ezscreenshot-2020-10-05_21-58-52-600.png

How do I add them when i get there

Im confused... how do I add the files to the filesystem.mdk

also @nifanfa you could probably make a really great youtube channel that does cosmos os tutorials.

You should install VMware workstation and find filesystem.vmdk in explorer Then press mouse right to mount the vmdk Then put the files.

oh ok

when I try and mount it, it doesn't do anything

do i need pro vmware to do it

How do you mount I still dont understand... I made a shared folder but it still says cpu exception

You can go on VMware Workstation 15.0 player with Cosmos selected and go -> Edit virtual machine settings. Than you go -> Hardisk IDE than go on map virtual disk. Tick off read only mode on the dialog and press enter. Than you can add your Cosmos OS images and other assets to the virtual disk. As long as you have successfully built a cosmos project with the VMware tab selected on in Cosmos project properties.

do i need pro to do it?

and does that mean i have to download an older version of vmware

I've built the VMDK containing the bitmaps for the Cosmos-GUI-Sample OS here.

Thank you so much

it says CPU exception but then it says after that Exception occurred, invalid data size

I remade the VMDK here; it no longer has CPU Exception.

can you explain what that is for future refrence

It works!!!

CPU Exception can be thrown by many things, but it usually has to do with the filesystem. In this case, it was probably thrown because the OS couldn't find the required bitmaps when it initialized.

ok thanks

when launching it the gui is a bit messed up... Everything is yellow and the loading screen takes up half of the screen

also @nifanfa is the clock acurate?

Not really

ok

just checking

As far as a GUI goes, here is a library I am developing that you might find useful.

As far as a GUI goes, here is a library I am developing that you might find useful.

Very useful. I will check it out. may your day be filled with puppies and gummy bears.

can you explain what that is for future reference

VMDK is a file format that describes containers for virtual hard disk drives to be used in virtual machines like VMware Workstation or VirtualBox.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

365Tito picture 365Tito  路  11Comments

jpmac26 picture jpmac26  路  8Comments

AAli107 picture AAli107  路  10Comments

TFTWPhoenix picture TFTWPhoenix  路  7Comments

geomtech picture geomtech  路  6Comments