Skip to content

Commit

Permalink
исправлен звук кнопки GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
kussakaa committed Jan 19, 2024
1 parent fd38904 commit bc9dd0b
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions ChangedScripts/ScoreboardRender.as
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ void onRenderScoreboard(CRules@ this)


float scoreboardHeight = topleft.y + scrollOffset;
float screenWidth = getScreenWidth();
float screenHeight = getScreenHeight();
CControls@ controls = getControls();

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

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

ScoreboardField(Vec2f(topleft.x - 10, 116.0f-scrollOffset), "Current version: v2.10");
LinkButton(Vec2f(topleft.x + 170, 116.0f-scrollOffset), "Github ", "https://github.com/TerminalHash/Gruhsha-CTF");
ScoreboardField(
Vec2f(screenWidth - topleft.x - 200, 115 - scrollOffset),
Vec2f(screenWidth - topleft.x, 115 - scrollOffset + 40),
"Current version: v2.10"
);
LinkButton(
Vec2f(screenWidth - topleft.x - 275, 115 - scrollOffset),
Vec2f(screenWidth - topleft.x - 205, 115 - scrollOffset + 40),
"Github ",
"https://github.com/TerminalHash/Gruhsha-CTF"
);

mouseWasPressed2 = controls.mousePressed2;
}
Expand Down Expand Up @@ -1053,16 +1063,16 @@ void MakeScoreboardButton(Vec2f pos, const string&in text, const string username
if(text == "blue"){
button_color = SColor(0xff1A6F9E);
}
else if(text == "red")
else if (text == "red")
{
button_color = SColor(0xffBA2721);
}
else // text == "spec"
{
button_color = 0xffffffff;
}
const bool hover = (mousePos.x > tl.x && mousePos.x < br.x && mousePos.y > tl.y && mousePos.y < br.y);
if (hover)
const bool hover = (mousePos.x > tl.x && mousePos.x < br.x && mousePos.y > tl.y && mousePos.y < br.y);
if (hover)
{
if (controls.mousePressed1)
{
Expand Down Expand Up @@ -1122,15 +1132,10 @@ void MakeScoreboardButton(Vec2f pos, const string&in text, const string username
}

// website button
void LinkButton(Vec2f pos, const string&in text, const string&in website)
void LinkButton(Vec2f tl, Vec2f br, const string&in text, const string&in website)
{
Vec2f dim;
GUI::GetTextDimensions(text, dim);

const f32 width = dim.x + 20;
const f32 height = 40;
const Vec2f tl = Vec2f(getScreenWidth() - 10 - width - pos.x, pos.y);
const Vec2f br = Vec2f(getScreenWidth() - 10 - pos.x, tl.y + height);
const f32 width = br.x - tl.x;
const f32 height = br.y - tl.y;

CControls@ controls = getControls();
const Vec2f mousePos = controls.getMouseScreenPos();
Expand All @@ -1140,35 +1145,32 @@ void LinkButton(Vec2f pos, const string&in text, const string&in website)
if (hover)
{
GUI::DrawButton(tl, br);

if (controls.mousePressed1 && !mouseWasPressed1)
if (controls.mousePressed1)
{
if (!mouseWasPressed1)
{
Sound::Play("option");
OpenWebsite(website);
mouseWasPressed1 = true;
}
}
else
{
Sound::Play("option");
OpenWebsite(website);
mouseWasPressed1 = false;
}

}
else
{
GUI::DrawPane(tl, br, 0xffcfcfcf);
}

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

// text field
void ScoreboardField(Vec2f pos, const string&in text)
void ScoreboardField(Vec2f tl, Vec2f br, const string&in text)
{
Vec2f dim;
GUI::GetTextDimensions(text, dim);

const f32 width = dim.x + 20;
const f32 height = 40;
const Vec2f tl = Vec2f(getScreenWidth() - 10 - width - pos.x, pos.y);
const Vec2f br = Vec2f(getScreenWidth() - 10 - pos.x, tl.y + height);

CControls@ controls = getControls();
const Vec2f mousePos = controls.getMouseScreenPos();

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

0 comments on commit bc9dd0b

Please sign in to comment.