Author Topic: How to Change Size of ULX motd window?  (Read 6644 times)

0 Members and 2 Guests are viewing this topic.

Offline VonTreece

  • Newbie
  • *
  • Posts: 25
  • Karma: 1
How to Change Size of ULX motd window?
« on: January 22, 2014, 05:06:23 PM »
Hello, i'm trying to change the size of the ulx motd window from 640x480 to 1280x720.

I tried modifying the "motdmenu.lua" located in "/addons/ulx/lua/ulx/modules/cl".

I changed "window:SetSize( 640, 480 )" to "window:SetSize( 1280, 720 )" but when I restarted and booted up, it wouldn't load my webpage correctly.

Am I missing something?

Here's the original "motdmenu.lua" code:

Code: [Select]
ulx.motdmenu_exists = true

local isUrl
local url

function ulx.showMotdMenu( steamid )
local window = vgui.Create( "DFrame" )
if ScrW() > 640 then -- Make it larger if we can.
window:SetSize( ScrW()*0.9, ScrH()*0.9 )
else
window:SetSize( 640, 480 )
end
window:Center()
window:SetTitle( "ULX MOTD" )
window:SetVisible( true )
window:MakePopup()

local html = vgui.Create( "HTML", window )

local button = vgui.Create( "DButton", window )
button:SetText( "Close" )
button.DoClick = function() window:Close() end
button:SetSize( 100, 40 )
button:SetPos( (window:GetWide() - button:GetWide()) / 2, window:GetTall() - button:GetTall() - 10 )

html:SetSize( window:GetWide() - 20, window:GetTall() - button:GetTall() - 50 )
html:SetPos( 10, 30 )
if not isUrl then
html:SetHTML( ULib.fileRead( "data/ulx_motd.txt" ) )
else
url = string.gsub( url, "%%curmap%%", game.GetMap() )
url = string.gsub( url, "%%steamid%%", steamid )
html:OpenURL( url )
end
end

function ulx.rcvMotd( isUrl_, text )
isUrl = isUrl_
if not isUrl then
ULib.fileWrite( "data/ulx_motd.txt", text )
else
if text:find( "://", 1, true ) then
url = text
else
url = "http://" .. text
end
end
end

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: How to Change Size of ULX motd window?
« Reply #1 on: January 22, 2014, 07:37:02 PM »
Code: [Select]
if ScrW() > 640 then -- Make it larger if we can.
window:SetSize( ScrW()*0.9, ScrH()*0.9 )
else
window:SetSize( 640, 480 )
end

You're missing our test to see if the screen is already larger than 640, where by we then use 90% of the resolution.
Here's the problem with you trying to set a static size.
If I join your server, and I'm using a screen resolution LESS than 1280x720 (I've used 1024x768 on a old 15 inch monitor one time while tinkering on a old machine), I won't be able to see the edges of your MOTD.
We wrote the code to be 90% of the joining users screen resolution, UNLESS they, for some reason, are playing in 640x480 mode (lowest available in Gmod I think), and then it will set the motd size statically to 640x480 (taking up thier entire window, but, will still be able to see all)

Why are you trying to force a size?
« Last Edit: January 22, 2014, 07:39:46 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline VonTreece

  • Newbie
  • *
  • Posts: 25
  • Karma: 1
Re: How to Change Size of ULX motd window?
« Reply #2 on: January 22, 2014, 08:34:19 PM »
My overall goal is to show this image (http://thelounge.zxq.net/Lounge/loungerules.php) when they join the server but without any extra space on the sides.

I directly added the HTML into the motd_txt file like this:

Code: [Select]
<html>
        <head>
                <title>Rules</title>
                <style type="text/css">
                        body {
                                padding:0px;
                                margin:0px;
                                background-color:#292929;
                        }
                </style>
        </head>
        <body>
                <img src="http://i.imgur.com/V2QCszo.jpg" style="max-width:100%; max-height:100%; position:absolute; margin:auto; top:0; left:0; bottom:0; right:0;" alt="">
        </body>
</html>

I use the exact same code (except a different image source) for my server's loading screen and it re-sizes to any resolution automatically without any bars on the sides.

I figured that if I just change the size of the motd window to match the size of the image, it would fix the problem, but the image still appears with bars.

You may be thinking, "Why not just resize the image?" - Well I can't without completely recreating the image from scratch, which i'd rather not do. Simply resizing it causes it to look warped and I don't have the PSD of the image, only the static.

I'm at a loss. Any help is appreciated.

I'd also like to make it so that there's a countdown of 5 seconds before they're able to close out of the motd if possible.

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: How to Change Size of ULX motd window?
« Reply #3 on: January 22, 2014, 09:26:08 PM »
Resize the image in gimp.

It retains the quality. It's how I made high quality sprays.
Out of the Garry's Mod business.

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: How to Change Size of ULX motd window?
« Reply #4 on: January 22, 2014, 10:36:07 PM »
You could attempt using "width" & "height" in the CSS of the page by doing something like this:
Code: [Select]
body {
padding:0px;
margin:0px;
background-color:#292929;
}
img {
width:100%;
height:100%;
}
In theory this should work by limiting the image size and keep it the size of the "browser window" (in this case the MOTD), but I haven't worked that much with percentage, so you might have add "width:100%;" and "height:100%;" into the "body" anchor of the CSS for it to work properly.

EDIT: Might not need to use the "max-width" and "max-height" at all, maybe only "width" and "height" for the img (image) anchor.
« Last Edit: January 23, 2014, 01:04:33 AM by Decicus »
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: How to Change Size of ULX motd window?
« Reply #5 on: January 23, 2014, 07:08:39 PM »
1) Gimp, though awesome, is a huge feature rich package that requires some learning curve and disk space. Good stuff, yes, but perhaps a bit more than needed just to resize an image.
2) Decicus HTML - good way 'on the fly' to resize images in-line if they can't be adjusted. Unfortunately, with as limited as the HTML viewer in Source is, resizing MIGHT be pixelated/bit rough at lower sizes, if the Source HTML engine allows it at all.

My recommendation if #2 doesn't work out, and you don't need the huge feature rich free open-source equivalent of Adobe's photoshop from #1,
IrfanView - http://www.irfanview.com/
Not only will it view just about anything thrown at it, including, with additional plugins, some audio and pdf type oddball stuff you may not expect an image viewer to view, it allows basic editing, One of those editing features is, imo, an awesome resampler (think resize, but better quality).
If 1 and 2 don't fit, try IrfanView. Reasonably small in disk/memory use, powerful in it's basic functionality.

Oh, and by the way, that image, when I copy it to memory using right click, copy image, and paste it into Irfanview, says its 1920x1080. That's full HD screen.
Here's it in 50% and 75% sizes.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline VonTreece

  • Newbie
  • *
  • Posts: 25
  • Karma: 1
Re: How to Change Size of ULX motd window?
« Reply #6 on: January 24, 2014, 03:03:53 AM »
I had the original PSD and just recreated it.

I didn't want to take the image an resize it because I wanted to avoid any signs of stretching/shrinking/warping entirely.

It worked out though. I just expanded it a bit and it fits perfectly.

Thanks for all the replies!


Also, does anyone here know how to add an extra tab to the motd window? I'd like to create a donor tab.

And is it possible to have a countdown in seconds before they're able to close out of the window?

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: How to Change Size of ULX motd window?
« Reply #7 on: January 24, 2014, 05:41:22 AM »
Read this for the delayed closing of the MoTD: http://forums.ulyssesmod.net/index.php/topic,6968.0.html
And then there's this post for adding another tab: http://forums.ulyssesmod.net/index.php/topic,6113.msg28784.html

Using the "Search" function of the forums is really helpful, for future reference.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.