Skip to content

Commit bc9dd0b

Browse files
committed
исправлен звук кнопки GitHub
1 parent fd38904 commit bc9dd0b

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

ChangedScripts/ScoreboardRender.as

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@ void onRenderScoreboard(CRules@ this)
866866

867867

868868
float scoreboardHeight = topleft.y + scrollOffset;
869+
float screenWidth = getScreenWidth();
869870
float screenHeight = getScreenHeight();
870871
CControls@ controls = getControls();
871872

@@ -888,8 +889,17 @@ void onRenderScoreboard(CRules@ this)
888889

889890
drawHoverExplanation(hovered_accolade, hovered_age, hovered_tier, Vec2f(getScreenWidth() * 0.5, topleft.y));
890891

891-
ScoreboardField(Vec2f(topleft.x - 10, 116.0f-scrollOffset), "Current version: v2.10");
892-
LinkButton(Vec2f(topleft.x + 170, 116.0f-scrollOffset), "Github ", "https://github.com/TerminalHash/Gruhsha-CTF");
892+
ScoreboardField(
893+
Vec2f(screenWidth - topleft.x - 200, 115 - scrollOffset),
894+
Vec2f(screenWidth - topleft.x, 115 - scrollOffset + 40),
895+
"Current version: v2.10"
896+
);
897+
LinkButton(
898+
Vec2f(screenWidth - topleft.x - 275, 115 - scrollOffset),
899+
Vec2f(screenWidth - topleft.x - 205, 115 - scrollOffset + 40),
900+
"Github ",
901+
"https://github.com/TerminalHash/Gruhsha-CTF"
902+
);
893903

894904
mouseWasPressed2 = controls.mousePressed2;
895905
}
@@ -1053,16 +1063,16 @@ void MakeScoreboardButton(Vec2f pos, const string&in text, const string username
10531063
if(text == "blue"){
10541064
button_color = SColor(0xff1A6F9E);
10551065
}
1056-
else if(text == "red")
1066+
else if (text == "red")
10571067
{
10581068
button_color = SColor(0xffBA2721);
10591069
}
10601070
else // text == "spec"
10611071
{
10621072
button_color = 0xffffffff;
10631073
}
1064-
const bool hover = (mousePos.x > tl.x && mousePos.x < br.x && mousePos.y > tl.y && mousePos.y < br.y);
1065-
if (hover)
1074+
const bool hover = (mousePos.x > tl.x && mousePos.x < br.x && mousePos.y > tl.y && mousePos.y < br.y);
1075+
if (hover)
10661076
{
10671077
if (controls.mousePressed1)
10681078
{
@@ -1122,15 +1132,10 @@ void MakeScoreboardButton(Vec2f pos, const string&in text, const string username
11221132
}
11231133

11241134
// website button
1125-
void LinkButton(Vec2f pos, const string&in text, const string&in website)
1135+
void LinkButton(Vec2f tl, Vec2f br, const string&in text, const string&in website)
11261136
{
1127-
Vec2f dim;
1128-
GUI::GetTextDimensions(text, dim);
1129-
1130-
const f32 width = dim.x + 20;
1131-
const f32 height = 40;
1132-
const Vec2f tl = Vec2f(getScreenWidth() - 10 - width - pos.x, pos.y);
1133-
const Vec2f br = Vec2f(getScreenWidth() - 10 - pos.x, tl.y + height);
1137+
const f32 width = br.x - tl.x;
1138+
const f32 height = br.y - tl.y;
11341139

11351140
CControls@ controls = getControls();
11361141
const Vec2f mousePos = controls.getMouseScreenPos();
@@ -1140,35 +1145,32 @@ void LinkButton(Vec2f pos, const string&in text, const string&in website)
11401145
if (hover)
11411146
{
11421147
GUI::DrawButton(tl, br);
1143-
1144-
if (controls.mousePressed1 && !mouseWasPressed1)
1148+
if (controls.mousePressed1)
1149+
{
1150+
if (!mouseWasPressed1)
1151+
{
1152+
Sound::Play("option");
1153+
OpenWebsite(website);
1154+
mouseWasPressed1 = true;
1155+
}
1156+
}
1157+
else
11451158
{
1146-
Sound::Play("option");
1147-
OpenWebsite(website);
1159+
mouseWasPressed1 = false;
11481160
}
1161+
11491162
}
11501163
else
11511164
{
11521165
GUI::DrawPane(tl, br, 0xffcfcfcf);
11531166
}
11541167

1155-
GUI::DrawTextCentered(text, Vec2f(tl.x + (width * 0.50f), tl.y + (height * 0.50f)), 0xffffffff);
1168+
GUI::DrawTextCentered(text, Vec2f(tl.x + ((br.x - tl.x) * 0.50f), tl.y + ((br.y - tl.y) * 0.50f)), 0xffffffff);
11561169
}
11571170

11581171
// text field
1159-
void ScoreboardField(Vec2f pos, const string&in text)
1172+
void ScoreboardField(Vec2f tl, Vec2f br, const string&in text)
11601173
{
1161-
Vec2f dim;
1162-
GUI::GetTextDimensions(text, dim);
1163-
1164-
const f32 width = dim.x + 20;
1165-
const f32 height = 40;
1166-
const Vec2f tl = Vec2f(getScreenWidth() - 10 - width - pos.x, pos.y);
1167-
const Vec2f br = Vec2f(getScreenWidth() - 10 - pos.x, tl.y + height);
1168-
1169-
CControls@ controls = getControls();
1170-
const Vec2f mousePos = controls.getMouseScreenPos();
1171-
11721174
GUI::DrawPane(tl, br, 0xffcfcfcf);
1173-
GUI::DrawTextCentered(text, Vec2f(tl.x + (width * 0.50f), tl.y + (height * 0.50f)), 0xffffffff);
1175+
GUI::DrawTextCentered(text, Vec2f(tl.x + ((br.x - tl.x) * 0.50f), tl.y + ((br.y - tl.y) * 0.50f)), 0xffffffff);
11741176
}

0 commit comments

Comments
 (0)