Author Topic: Adding image overlay/GUI to screen  (Read 890 times)

I'd like to have a .png image fill my entire screen after I trigger it within my addon. I've messed around with the mission editor(?) and looked at a few addons and could not find anywhere that explained how to do it exactly and simply.

Check out the GUI editor. Keep in mind that only you will be able to see the image, nobody else, unless they download your addon

More specifically, you'll want to create a GuiBitmapCtrl and use the setBitmap(image_path) method on it. From there you can add it to the PlayGUI (or whatever GUI you want) to have it appear in your game.

More specifically, you'll want to create a GuiBitmapCtrl and use the setBitmap(image_path) method on it. From there you can add it to the PlayGUI (or whatever GUI you want) to have it appear in your game.

Ah ok setBitmap is what I was looking for then :) So I can still save the gui as any name I want or do I have to save it as the default PlayGUI for example?

Ah ok setBitmap is what I was looking for then :) So I can still save the gui as any name I want or do I have to save it as the default PlayGUI for example?
Well that really depends on what you're trying to do. You can add a bitmap control to any GUI in Blockland to make your image appear. The PlayGUI example was just assuming you wanted to have the image on your screen while in a server. It doesn't have to be like that, you could put the image in a menu that you open with a keybind.

Well that really depends on what you're trying to do. You can add a bitmap control to any GUI in Blockland to make your image appear. The PlayGUI example was just assuming you wanted to have the image on your screen while in a server. It doesn't have to be like that, you could put the image in a menu that you open with a keybind.

Actually I got it to show up in-game :) Thanks. But now I would like it to resize itself according to other player's screen resolutions so it's not getting cut off for being too big or being too small an image for the screen coverage. I thought I could do this by using the getExtent method on PlayGui and then use the width and height return from that to resize the bitmap. But I'm having trouble figuring it out as it gives me an error saying "PlayGui::getExtent--wrong number of arguments" or some such. Any idea how I would fix this? I'm using this reference (GuiControl - Page 298): http://greekmods.webs.com/docs/Appendix%20A%20-%20Quick%20References.pdf
« Last Edit: March 03, 2018, 12:03:20 PM by xS K I D z »

try $pref::Video::resolution. it has 4 numbers attached to it- word 0 is the window width, word 1 is the height. you'd only really need those numbers.

Actually I got it to show up in-game :) Thanks. But now I would like it to resize itself according to other player's screen resolutions so it's not getting cut off for being too big or being too small an image for the screen coverage. I thought I could do this by using the getExtent method on PlayGui and then use the width and height return from that to resize the bitmap. But I'm having trouble figuring it out as it gives me an error saying "PlayGui::getExtent--wrong number of arguments" or some such. Any idea how I would fix this? I'm using this reference (GuiControl - Page 298): http://greekmods.webs.com/docs/Appendix%20A%20-%20Quick%20References.pdf
PlayGui::getExtent(%this) is the definition of the function. It requires an object %this to be called. Most of the time you are using an object's method you can just call it right on the object like this: playGui.getExtent();. The function that I normally use to get the resolution of the client's screen is getRes() though.

PlayGui::getExtent(%this) is the definition of the function. It requires an object %this to be called. Most of the time you are using an object's method you can just call it right on the object like this: playGui.getExtent();. The function that I normally use to get the resolution of the client's screen is getRes() though.
Hmm still getting an error. Tried to echo getExtent to console a couple different ways and I'm still having trouble. This is what it says now:
Code: [Select]
Add-Ons/Item_TeleTest/Item_TeleTest.cs (99): PlayGui::getExtent - wrong number of arguments.
Add-Ons/Item_TeleTest/Item_TeleTest.cs (99): usage: Get the width and height of the control.
BackTrace: ->[sportBallsPackage]ServerCmdUseTool->ServerCmdUseTool->ItemData::onUse->periTestImage::onMount

how are you echoing them? post code/ whatever you're typing in the console

Code: [Select]
function periTestImage::onMount(%this,%obj,%slot)
{
PlayGui.getExtent();

echo(%this);
}
I suppose I could try a different method(getRes?), but originally I wanted to get the PlayGui extents on image mount then use that to resize the bitmap.

getExtent returns a value. %this returns the periTestImage weaponImage you are packaging it inside.

You'd probably want to do echo(PlayGui.getExtent()); if you want to echo the extent data.
or you can do %extent = PlayGui.GetExtent(); if you want to keep the extent on a local variable

getExtent returns a value. %this returns the periTestImage weaponImage you are packaging it inside.

You'd probably want to do echo(PlayGui.getExtent()); if you want to echo the extent data.
or you can do %extent = PlayGui.GetExtent(); if you want to keep the extent on a local variable
This worked, thanks.