Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: umar4911 on Oct 27, 2018, 01:30 PM

Title: GameResize (Client Size)
Post by: umar4911 on Oct 27, 2018, 01:30 PM
The GUILabel dont get to the expected position. However, the size does

this.Information <- ::GUILabel(VectorScreen(screen.X * 0.28, screen.Y * 0.10), Colour(28, 174, 190), "Registeration");

function GUI::GameResize(width, height)
{
screen <- GUI.GetScreenSize();
WelcomeScreen.Information.Position = VectorScreen(screen.X * 0.28, screen.Y * 0.10);
WelcomeScreen.Information.FontSize = screen.X * 0.06;
 }
Title: Re: GameResize (Client Size)
Post by: umar4911 on Oct 30, 2018, 08:56 AM
Bump
Title: Re: GameResize (Client Size)
Post by: Mötley on Oct 30, 2018, 02:05 PM
Okay I'll try even though I haven't touched vcmp's client scripting..

I'll attempt to set it dead center as I have no clue where your trying to place it.

function GUI::GameResize(width, height)
{
// Should go dead center
registration_text <- ::GUILabel(VectorScreen(0, 0), Colour(28, 174, 190), "Registration");

screen <- GUI.GetScreenSize();

// tbh, should be VectorScreen(screen.X, screen.Y);
WelcomeScreen.Information.Position = VectorScreen(screen.X * 0.28, screen.Y * 0.10);

// what does font size have to do with setting to the screen size?
WelcomeScreen.Information.FontSize = screen.X * 0.06;

// Should add the label to the window
WelcomeScreen.AddChild(registration_text)
 }

idk, I tried,client side resources are a little odd in this mp. but I tried, If I knew enough on it I could be of great help but I don't have the time for it
Title: Re: GameResize (Client Size)
Post by: umar4911 on Oct 31, 2018, 09:24 AM
I debugged it and came to know that Sprite works perfect with the position attribute. The Label is fishy. If the size is increased, it goes good and when you decrease it, it rekts.
Title: Re: GameResize (Client Size)
Post by: Mötley on Oct 31, 2018, 02:20 PM
Lol didn't know this was a sprite.. I thought we were talking about a gui label..

Sprites isn't something you should resize. I would just create 4 different sprites for four main ranges of resolutions. and depending on the resolution size, use what ever size you rendered for the resolution, you can still modify the size, But it's not wise to modify the size of a sprite that has a higher definition and the resolution calls for it to shrink, it's going to look like shit...

Tbh I use a custom 600 sized game window so my fps will always stay strong regardless of what crazy crap goes on around me in a server. I would try to make sure you have four different sprites for ranges of:
<1000>
<2000>
<3000>
<4000>

The wasted space will be worth it as the professionalism of the sprite will be perfected. I don't personally mess with gui and screen positions as I'm to anal about my work..

As for the label size, I would recommend looking into ceilThen begin checking out the font size after that
Title: Re: GameResize (Client Size)
Post by: umar4911 on Oct 31, 2018, 07:38 PM
Quote from: Motley on Oct 31, 2018, 02:20 PMLol didn't know this was a sprite.. I thought we were talking about a gui label..

Sprites isn't something you should resize. I would just create 4 different sprites for four main ranges of resolutions. and depending on the resolution size, use what ever size you rendered for the resolution, you can still modify the size, But it's not wise to modify the size of a sprite that has a higher definition and the resolution calls for it to shrink, it's going to look like shit...

Tbh I use a custom 600 sized game window so my fps will always stay strong regardless of what crazy crap goes on around me in a server. I would try to make sure you have four different sprites for ranges of:
<1000>
<2000>
<3000>
<4000>

The wasted space will be worth it as the professionalism of the sprite will be perfected. I don't personally mess with gui and screen positions as I'm to anal about my work..

As for the label size, I would recommend looking into ceilThen begin checking out the font size after that
It is a label. Lol. Actually, I am trying to find solutions to make my GUI perfect on screen change. The bugs I found:
- Position attribute of decreasing screen size
- increasing width only can result in disappearing of the label
- GUI.GetScreenSize() doesn't update on game resize.
Title: Re: GameResize (Client Size)
Post by: Mötley on Nov 01, 2018, 05:10 PM
The wiki version doesn't update?
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Client_Functions/GUI::GetScreenSize

If it doesn't try seeing if a few things will manually update it like
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Client_Functions/GUI::SetMouseEnabled

Might be a bug, but the code might update when the mouse is showing. dunno
Title: Re: GameResize (Client Size)
Post by: umar4911 on Nov 02, 2018, 02:49 AM
Quote from: Motley on Nov 01, 2018, 05:10 PMThe wiki version doesn't update?
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Client_Functions/GUI::GetScreenSize

If it doesn't try seeing if a few things will manually update it like
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Client_Functions/GUI::SetMouseEnabled

Might be a bug, but the code might update when the mouse is showing. dunno
The GetScreenSize does updates if game is resized. It shows sprites with old size made after resize.
Most exciting thing, the mouse it enabled already in that function.
Title: Re: GameResize (Client Size)
Post by: DizzasTeR on Nov 02, 2018, 09:38 AM
Your formula for calculating the font size is wrong, it generates invalid/un-supported results. I wrote this and it works fine when I resized the game.
screen <- GUI.GetScreenSize();
test <- ::GUILabel(VectorScreen(screen.X * 0.28, screen.Y * 0.10), Colour(28, 174, 190), "Registeration");

function GUI::GameResize(width, height)
{
::screen = this.GetScreenSize();
::test.Position = VectorScreen(screen.X * 0.28, screen.Y * 0.10);
::test.FontSize = 10 + (height/480); // Doom's font-size formula
}
Title: Re: GameResize (Client Size)
Post by: NicusorN5 on Nov 02, 2018, 01:57 PM
10 + (height/480); // Doom's font-size formula
No shit. Stop crediting yourself.
Title: Re: GameResize (Client Size)
Post by: umar4911 on Nov 02, 2018, 04:07 PM
Quote from: Doom_Kill3R on Nov 02, 2018, 09:38 AMYour formula for calculating the font size is wrong, it generates invalid/un-supported results. I wrote this and it works fine when I resized the game.
screen <- GUI.GetScreenSize();
test <- ::GUILabel(VectorScreen(screen.X * 0.28, screen.Y * 0.10), Colour(28, 174, 190), "Registeration");

function GUI::GameResize(width, height)
{
::screen = this.GetScreenSize();
::test.Position = VectorScreen(screen.X * 0.28, screen.Y * 0.10);
::test.FontSize = 10 + (height/480); // Doom's font-size formula
}
Font Size is working good. The problem is with POSITION. Still, I'll use that.
Title: Re: GameResize (Client Size)
Post by: DizzasTeR on Nov 03, 2018, 06:58 AM
Quote from: Athanatos on Nov 02, 2018, 01:57 PM 10 + (height/480); // Doom's font-size formula
No shit. Stop crediting yourself.

Mission accomplished, enemy was pissed off.

On-Topic: The position is already going to be same since you are using relative values .
Title: Re: GameResize (Client Size)
Post by: umar4911 on Nov 03, 2018, 02:38 PM
Quote from: Doom_Kill3R on Nov 03, 2018, 06:58 AM
Quote from: Athanatos on Nov 02, 2018, 01:57 PM 10 + (height/480); // Doom's font-size formula
No shit. Stop crediting yourself.

Mission accomplished, enemy was pissed off.

On-Topic: The position is already going to be same since you are using relative values .
Listen, when I start game (small screen size) the word "registration" is in the center of screen. When I resize to big, the size increases and position still stays in center. But after again resize to small, the word goes away from centre.
Title: Re: GameResize (Client Size)
Post by: ! on Nov 03, 2018, 03:16 PM
Quote from: umar4911 on Oct 27, 2018, 01:30 PMThe GUILabel dont get to the expected position. However, the size does

this.Information <- ::GUILabel(VectorScreen(screen.X * 0.28, screen.Y * 0.10), Colour(28, 174, 190), "Registeration");

function GUI::GameResize(width, height)
{
screen <- GUI.GetScreenSize();
WelcomeScreen.Information.Position = VectorScreen(screen.X * 0.28, screen.Y * 0.10);
WelcomeScreen.Information.FontSize = screen.X * 0.06;
 }
Why creating new slot of screen under GameResize(width, height)
I am pretty sure you might have created a new slot of this variable at somewhere else but still not sure if creating a new slot again and again in client side is allowed any way try using a local variable with a different name instead maybe it is because of overriding new slot.
function GUI::GameResize(width, height)
{
   local rel = GUI.GetScreenSize();
   WelcomeScreen.Information.Position = VectorScreen(rel.X * 0.28, rel.Y * 0.10);
   WelcomeScreen.Information.FontSize = rel.X * 0.06;
 }
Title: Re: GameResize (Client Size)
Post by: DizzasTeR on Nov 04, 2018, 05:54 AM
Quote from: umar4911 on Nov 03, 2018, 02:38 PMListen, when I start game (small screen size) the word "registration" is in the center of screen. When I resize to big, the size increases and position still stays in center. But after again resize to small, the word goes away from centre.

I don't think that 0.2 and 0.1 is going to center it, to center it they both must be screen.X*0.5 and screen.Y*0.5
Title: Re: GameResize (Client Size)
Post by: umar4911 on Nov 04, 2018, 06:28 AM
Quote from: ! on Nov 03, 2018, 03:16 PM
Quote from: umar4911 on Oct 27, 2018, 01:30 PMThe GUILabel dont get to the expected position. However, the size does

this.Information <- ::GUILabel(VectorScreen(screen.X * 0.28, screen.Y * 0.10), Colour(28, 174, 190), "Registeration");

function GUI::GameResize(width, height)
{
screen <- GUI.GetScreenSize();
WelcomeScreen.Information.Position = VectorScreen(screen.X * 0.28, screen.Y * 0.10);
WelcomeScreen.Information.FontSize = screen.X * 0.06;
 }
Why creating new slot of screen under GameResize(width, height)
I am pretty sure you might have created a new slot of this variable at somewhere else but still not sure if creating a new slot again and again in client side is allowed any way try using a local variable with a different name instead maybe it is because of overriding new slot.
function GUI::GameResize(width, height)
{
   local rel = GUI.GetScreenSize();
   WelcomeScreen.Information.Position = VectorScreen(rel.X * 0.28, rel.Y * 0.10);
   WelcomeScreen.Information.FontSize = rel.X * 0.06;
 }
No still doesn't work.

Quote from: Doom_Kill3R on Nov 04, 2018, 05:54 AM
Quote from: umar4911 on Nov 03, 2018, 02:38 PMListen, when I start game (small screen size) the word "registration" is in the center of screen. When I resize to big, the size increases and position still stays in center. But after again resize to small, the word goes away from centre.

I don't think that 0.2 and 0.1 is going to center it, to center it they both must be screen.X*0.5 and screen.Y*0.5
See this man. My game is in windowed mode.

First (no resize and screen size is small)
(https://image.ibb.co/d3QwtL/2018-10-31-06-34-41-0218.png)

Second (After resize to big)
(https://image.ibb.co/hRXy7f/2018-10-31-06-34-47-0516.png)

Third (after again resize to small)
(https://image.ibb.co/iEb2YL/2018-10-31-06-34-50-0578.png)




I did this thrice to explain. This bug occurs even at first time when you reduce the size to small.
Title: Re: GameResize (Client Size)
Post by: DizzasTeR on Nov 04, 2018, 07:37 AM
You are most likely doing something wrong because I tested it and it works fine for me, double check your calculations and how you are re-adjusting them.

https://youtu.be/v7t6oMtcUjM
Title: Re: GameResize (Client Size)
Post by: Mötley on Nov 04, 2018, 02:17 PM
Off Topic: 0 is supposed to be dead center and that looks slightly off center. Are you sure doing that is right?

Also that event should fix it as Dooms showing you as the event is called each time the screen is adjusted, You just gotta reset the label every time the screen is adjusted. Make sure you don't have two of the same events loaded I suppose and add a message to the event Message("I was called"); to ensure it's getting called.

Still don't know much about client scripting for vcmp, only LU and a lot of the cool sides of the gui scripting isn't added >.< but even this should create a window to the exact size of the screen resolution
Screen <- GUI.GetScreenSize();
//Should add a alpha and transparancy to the window, maybe 120 and call for this window when it's rainy for an interesting graphical effect
GUIWindow(VectorScreen(0, 0), VectorScreen(Screen.x, Screen.y), Colour( 0, 0, 223 ), "Overlay"); 

http://liberty-unleashed.co.uk/LUWiki/Squirrel/Client/Functions/GUIWindow/Transparent

http://liberty-unleashed.co.uk/LUWiki/Squirrel/Client/Functions/GUIWindow/Alpha
Title: Re: GameResize (Client Size)
Post by: ! on Nov 04, 2018, 05:06 PM
For a correct possible solution make a test code which produce the same bug and post here because the problem is in the script not client side issue or anything.
Same as @Doom_Kill3R did without source one can put a suggestion nothing else.
Title: Re: GameResize (Client Size)
Post by: umar4911 on Nov 08, 2018, 02:51 AM
Quote from: ! on Nov 04, 2018, 05:06 PMFor a correct possible solution make a test code which produce the same bug and post here because the problem is in the script not client side issue or anything.
Same as @Doom_Kill3R did without source one can put a suggestion nothing else.
so after debugging again and again, I came to know that the thing which creates problem is FontSize.
Title: Re: GameResize (Client Size)
Post by: ! on Nov 08, 2018, 08:10 AM
Solution for others Change the size before changing the rel position of a GUI.

@umar4911  check if I am not wrong

function GUI::GameResize(width, height)
{
   local rel = GUI.GetScreenSize();
   WelcomeScreen.Information.FontSize = rel.X * 0.06;
   WelcomeScreen.Information.Position = VectorScreen(rel.X * 0.28, rel.Y * 0.10);
 }
Title: Re: GameResize (Client Size)
Post by: umar4911 on Nov 15, 2018, 11:13 AM
Quote from: ! on Nov 08, 2018, 08:10 AMSolution for others Change the size before changing the rel position of a GUI.

@umar4911  check if I am not wrong

function GUI::GameResize(width, height)
{
   local rel = GUI.GetScreenSize();
   WelcomeScreen.Information.FontSize = rel.X * 0.06;
   WelcomeScreen.Information.Position = VectorScreen(rel.X * 0.28, rel.Y * 0.10);
 }
The problem still persists
Title: Re: GameResize (Client Size)
Post by: ! on Nov 15, 2018, 06:01 PM
Quote from: umar4911 on Nov 15, 2018, 11:13 AMThe problem still persists

The only reason I told you to create a test script producing same bug and post here so others can point out the problem.
Tested and working perfect

(https://i.imgur.com/IrE1wqI.png)
(https://i.imgur.com/yCToZzt.png)
(https://i.imgur.com/56Igo7Y.png)
(https://i.imgur.com/iXPyYfI.png)

 :edit:
Tested for 3 labels at the same time working perfect for all of em

(https://i.imgur.com/krTDAGq.png)
(https://i.imgur.com/dcpR2sg.png)
(https://i.imgur.com/2pw0xgP.png)
(https://i.imgur.com/gWEHQLS.png)