English How to use buttons with mp hudscale = 3

9 replies
Goto Page
To the start Previous 1 Next To the start
Up
Denisgrad
User
Offline Off
Is it possible to use mp hudscale = 3 with file cs2d GUI Framework (v2) (11) ?

For some reason the image location fits to screen but the trigger .OnClick does not.

I have no idea how to make the x,y location of img sync with trigger on the button

EDIT:
Code:
1
2
3
4
5
6
7
local bid = #gui.imageButton + 1
    local newresx = player(id,"screenw") / 1600
    local newresy = player(id,"screenh") / 900
    b.x = x * newresx 
    b.y = y * newresy
...
b.img = image(path, b.x, b.y, 2, id)


This made it fit better but its still not perfect. Any suggestions?
edited 1×, last 05.12.17 08:13:15 am
05.12.17 08:47:29 am
Up
Gaiyos
Security Supporter
Offline Off
I suggest to use cs2d cmd mp_hudscale 1 because it has auto-scaling for each resolution.

You can use this framework which has a lot of functionalities such as Visual Lua, Screen Aligns, OOP Images, Auto freeimage at players leave, Custom skin loader, Main Menu system, Map Pointers (GPS system), Setter and Getters for player instance, Math library, and so on which I will add later (you can suggest me any update ideas).

Example
> https://github.com/gajosadrian/Gajos-Framework/blob/master/app/test.lua
IMG:http://i.imgur.com/YFN2ICK.png
IMG:http://i.imgur.com/TCHCwEk.png
IMG:http://i.imgur.com/i2Kif0O.png
05.12.17 09:55:29 am
Up
VaiN
User
Offline Off
I also recommend to use cs2d cmd mp_hudscale 1

You have the right idea with calculating, just in the wrong way. Keep in mind that players can have either Standard or Wide resolutions. The hudscale will auto-scale, but you will need to adjust depending on which one they use. What I do is store a value for it in a table for each player id, and then have two sets of coords for each. It makes things more complex for sure, but also ensures that it works for everyone. The Y coordinate will always be the same, so it isn't needed for both, but it's easier to include it.

example:
Code:
1
2
res = {}
for i = 1,32 do res[i] = "wide" end


when a player joins, get which one they use
Code:
1
2
3
4
5
function check_res(id)
     local ar = player(id,"screenw") / player(id,"screenh")
     if ar < 1.4 then res[id] = "standard" else res[id] = "wide" end
end
addhook("join","check_res")


then you can reference which coords to use from that table
Code:
1
2
3
4
5
6
7
8
9
coord = {}
coord.button1 = {
     ["wide"] = {x = 425, y = 2},
     ["standard"] = {x = 320, y = 2}
}

-- and when you use the coords:
local x = coord.button1[ res[id] ].x
local y = coord.button1[ res[id] ].y

This will ensure that it'll be positioned the same for all players.

The coordinates are pretty simple once you know where to start. With mp_hudscale 1 you use 850x480 for wide, 640x480 for standard. As long as your coordinates are based on those, then it'll all work the same.

I'm not familiar with the GUI framework you are using, so this approach may not be compatible with it. If not, I'd recommend you post a comment to the author where you downloaded it and link to this post.

Edit: I'm wrong. You can't calculate aspect ratio this way. The height for "standard" resolutions is adjusted to make it fair and the screenh returned is not including the borders it adds. Only way to calculate it is with a best guess based on the screen width.
edited 1×, last 10.12.17 01:26:40 am
Rewards is returning! | https://RewardsGaming.Net/discord
10.12.17 10:08:25 am
Up
Masea
Super User
Offline Off
I'll probably re-code it from scratch soon. Hold on.

And if I were you, I wouldn't even touch the cs2d cmd mp_hudscale command. I highly do not recommend it.
Create and design your GUI easy and fast: file cs2d GUI Framework (v2) (11) | Go deep of the darkness and try your intrepidity: file cs2d Outlast 2 Modification (25)
11.12.17 05:15:56 pm
Up
Denisgrad
User
Offline Off
I fixed the issue now. I wrote the script for two resolutions 1. 1920x1080 and 2. 1600x900. The location of images changes based on user's resolution.

One question though. Most CS2D users play on these resolutions right?
11.12.17 05:52:51 pm
Up
Gaiyos
Security Supporter
Offline Off
user Denisgrad has written:
I fixed the issue now. I wrote the script for two resolutions 1. 1920x1080 and 2. 1600x900. The location of images changes based on user's resolution.

One question though. Most CS2D users play on these resolutions right?

If they would have those monitors, the will have money for better games than CS2D
And all modern games use automatic hud scaling, so you just should use cs2d cmd mp_hudscale 1. Also for me default resolution in-game should be 1366x768 than 850x480.
IMG:http://i.imgur.com/YFN2ICK.png
IMG:http://i.imgur.com/TCHCwEk.png
IMG:http://i.imgur.com/i2Kif0O.png
11.12.17 06:06:26 pm
Up
Masea
Super User
Offline Off
@user Denisgrad: Go immediately update your GUI Framework. And there are
gui.convertX
and
gui.convertY
functions - use them for fuck sake.

∗ ∗ ∗ Do not forget to see the new tutorials, by the way! ∗ ∗ ∗
Create and design your GUI easy and fast: file cs2d GUI Framework (v2) (11) | Go deep of the darkness and try your intrepidity: file cs2d Outlast 2 Modification (25)
11.12.17 10:18:07 pm
Up
Denisgrad
User
Offline Off
Wow didnt know that. Thought everyone used at least 1600x900 by now. Looks like Ill have to update the framework.
12.12.17 10:18:52 am
Up
Masea
Super User
Offline Off
@user Denisgrad: You do not have to update it though. The functions you need existed in the old versions as well. Nevertheless, updating it would cause tons of change if you did much with old versions. If I were you, I'd definitely update it to ensure the new features!
Create and design your GUI easy and fast: file cs2d GUI Framework (v2) (11) | Go deep of the darkness and try your intrepidity: file cs2d Outlast 2 Modification (25)
To the start Previous 1 Next To the start