Skip to content

Commit

Permalink
feat: Refactor scoreboard's layout
Browse files Browse the repository at this point in the history
trying fixing the issue that 增加 Dynamite 主题模式 #111 mentioned
  • Loading branch information
NagaseIori committed Jul 15, 2023
1 parent 7674ab5 commit 041305a
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 21 deletions.
12 changes: 12 additions & 0 deletions objects/objScoreBoard/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
/// @description Var init

#macro SCOREBOARD_WIDTH 420
#macro SCOREBOARD_NUMBER_HEIGHT 65
#macro SCOREBOARD_NUMBER_WIDTH 53
#macro SCOREBOARD_NUMBER_PADDING 8
#macro SCOREBOARD_NUMBER_SPRITE_PADDING 21

#macro SCOREBOARD_DEBUG true

// In-Variables

scale = 0.5;
Expand All @@ -18,8 +26,12 @@ animTargetScaleMul = 1.0;
animTargetAlpha = 0;

sprWidth = sprite_get_width(sprNumber)
sprHeight = sprite_get_height(sprNumber);
shorten = 20; // total shorten pixels for each number in lr side

// Recaculate the scale with macro
scale = SCOREBOARD_NUMBER_WIDTH / (sprWidth - SCOREBOARD_NUMBER_SPRITE_PADDING * 2);

visible = true;

function _update_score(_scr, _hit = true, _force = false) {
Expand Down
24 changes: 20 additions & 4 deletions objects/objScoreBoard/Draw_0.gml
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
/// @description Draw scoreboard

var _len = string_length(nowString);
var _x = x, _w = (sprWidth - shorten) * scale * scaleMul * global.scaleXAdjust;
var _x = x + (align == fa_right ? 0 : 1) * SCOREBOARD_WIDTH / 2;
var _y = y + SCOREBOARD_NUMBER_HEIGHT / 2;
var _w = (SCOREBOARD_NUMBER_WIDTH + SCOREBOARD_NUMBER_PADDING) * scaleMul * global.scaleXAdjust;

if(align == fa_middle)
_x -= _w * _len / 2;
_x -= _w * (_len - 1) / 2;
else if(align == fa_right)
_x -= _w * _len;
_x -= _w * (_len - 1) + SCOREBOARD_NUMBER_WIDTH / 2;

for(var _i = 1; _i <= _len; _i ++) {
draw_sprite_ext(sprNumber, int64(string_char_at(nowString, _i)), _x, y,
draw_sprite_ext(sprNumber, int64(string_char_at(nowString, _i)), _x, _y,
scale * scaleMul * global.scaleXAdjust,
scale * scaleMul * global.scaleYAdjust, 0, c_white, alpha);
if(debug_mode && SCOREBOARD_DEBUG) {
draw_set_color(c_yellow);
draw_set_alpha(1);
draw_circle(_x, _y, 5, false);
}
_x += _w;
}

if(debug_mode && SCOREBOARD_DEBUG) {
draw_set_color(c_red);
draw_set_alpha(1);
draw_circle(x, y, 5, false);
var _x = x + (align == fa_right ? 0 : 1) * SCOREBOARD_WIDTH / 2;
var _y = y + SCOREBOARD_NUMBER_HEIGHT / 2;
draw_circle(_x, _y, 5, false);
}
4 changes: 3 additions & 1 deletion objects/objScoreBoard/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ scaleMul = lerp_a(scaleMul, animTargetScaleMul, animSpeed);
alpha = lerp_a(alpha, animTargetAlpha, animSpeed);

nowString = string_format(abs(nowScore), preZero, 0);
nowString = string_replace_all(nowString, " ", "0");
nowString = string_replace_all(nowString, " ", "0");

if(SCOREBOARD_DEBUG) alpha = 1;
10 changes: 6 additions & 4 deletions objects/objmain/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -274,22 +274,24 @@ depth = 0;

#endregion



#region Scoreboard Init

scbDepth = 1000;
scbLeft = create_scoreboard(resor_to_x(0.29), resor_to_y(0.54),
scbLeft = create_scoreboard(resor_to_x(295/1920), resor_to_y(555/1080),
scbDepth, 7, fa_middle, 0);
scbRight = create_scoreboard(resor_to_x(0.88), resor_to_y(0.54),
scbRight = create_scoreboard(resor_to_x(1-295/1920), resor_to_y(555/1080),
scbDepth, 0, fa_right, 3);

#endregion

#region Perfect Indicator Init

perfDepth = 1000;
perfLeft = instance_create_depth(resor_to_x(0.27), resor_to_y(0.64),
perfLeft = instance_create_depth(resor_to_x(295/1920), resor_to_y(636/1080),
perfDepth, objPerfectIndc);
perfRight = instance_create_depth(resor_to_x(0.744), resor_to_y(0.64),
perfRight = instance_create_depth(resor_to_x(1212/1920), resor_to_y(636/1080),
perfDepth, objPerfectIndc);

#endregion
Expand Down
4 changes: 2 additions & 2 deletions objects/objmain/Draw_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ var _nw = global.resolutionW, _nh = global.resolutionH;
for(var i=0; i<_l; i++)
with(chartNotesArrayActivated[i])
if(noteType == 2) {
draw_event(false);
draw_event(false); // Draw background
}
for(var i=0; i<_l; i++)
with(chartNotesArrayActivated[i])
if(noteType == 2) {
draw_event(true);
draw_event(true); // Draw Edge
}
// Draw Notes
for(var i=0; i<_l; i++)
Expand Down
12 changes: 11 additions & 1 deletion objects/objperfectindc/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
/// @description Var init

#macro PERFECTINDC_ALPHABETS_WIDTH 418
#macro PERFECTINDC_SPRITE_ALPHABETS_WIDTH 418
#macro PERFECTINDC_SPRITE_ALPHABETS_HEIGHT 75
#macro PERFECTINDC_ALPHABETS_X 54
#macro PERFECTINDC_ALPHABETS_Y 53
#macro PERFECTINDC_DEBUG true

nowTime = 9999;
lastTime = 3000; // ms
lastTimeBloom = 100;

scale = 1.1;
scale = 1.0;
scaleMul = 1.0;

sprWidth = sprite_get_width(sprPerfect);
sprHeight = sprite_get_height(sprPerfect);

alpha = 0.0;
alphaMul = 1.0;
bloomAlpha = 0.0;
Expand Down
14 changes: 12 additions & 2 deletions objects/objperfectindc/Draw_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,15 @@

var _scl = scale * scaleMul;

draw_sprite_ext(sprPerfect, 0, x, y, _scl * global.scaleXAdjust, _scl * global.scaleYAdjust, 0, c_white, alpha * alphaMul);
draw_sprite_ext(sprPerfectBloom, 0, x, y, _scl * global.scaleXAdjust, _scl * global.scaleYAdjust, 0, c_white, 1 * bloomAlpha * alpha * alphaMul);
var _nx = x + PERFECTINDC_SPRITE_ALPHABETS_WIDTH / 2;
var _ny = y + PERFECTINDC_SPRITE_ALPHABETS_HEIGHT / 2;

draw_sprite_ext(sprPerfect, 0, _nx, _ny, _scl * global.scaleXAdjust, _scl * global.scaleYAdjust, 0, c_white, alpha * alphaMul);
draw_sprite_ext(sprPerfectBloom, 0, _nx, _ny, _scl * global.scaleXAdjust, _scl * global.scaleYAdjust, 0, c_white, 1 * bloomAlpha * alpha * alphaMul);

if(debug_mode && PERFECTINDC_DEBUG) {
draw_set_color(c_red);
draw_set_alpha(1);
draw_circle(x, y, 5, false);
draw_circle(_nx, _ny, 5, false);
}
7 changes: 6 additions & 1 deletion objects/objperfectindc/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ else
animTargetAlphaMul = 1;

alphaMul = lerp_a(alphaMul, animTargetAlphaMul, animSpeed);
nowTime = min(nowTime, 99999999);
nowTime = min(nowTime, 99999999);

if(PERFECTINDC_DEBUG) {
alpha = 1;
alphaMul = 1;
}
6 changes: 3 additions & 3 deletions sprites/sprperfect/sprperfect.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions sprites/sprperfectbloom/sprperfectbloom.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 041305a

Please sign in to comment.