Skip to content

Commit

Permalink
done for the night
Browse files Browse the repository at this point in the history
  • Loading branch information
3drosalia committed May 3, 2024
1 parent 57e8fd9 commit a6c290c
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 22 deletions.
19 changes: 18 additions & 1 deletion Encore/include/game/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,28 @@ enum Screens {

class Menu {
private:
template<typename CharT>
struct Separators : public std::numpunct<CharT>
{
virtual std::string do_grouping()
const
{
return "\003";
}
};

std::string scoreCommaFormatter(int value) {
std::stringstream ss;
ss.imbue(std::locale(std::cout.getloc(), new Separators <char>()));
ss << std::fixed << value;
return ss.str();
}

void renderStars(Player player, float xPos, float yPos);
public:
Screens currentScreen;
bool songsLoaded;
void showResults(Player player);
void showResults(Player player, Assets assets);
void loadMenu(SongList songList, GLFWgamepadstatefun gamepadStateCallbackSetControls, Assets assets);
inline void loadTitleScreen() {};

Expand Down
5 changes: 4 additions & 1 deletion Encore/include/game/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <iostream>
#include <vector>
#include "song/song.h"

// clone hero defaults

Expand All @@ -10,11 +11,13 @@ class Player {
int instrument = 0;
int diff = 0;

Song songToBeJudged;

int notesHit = 0;
int notesMissed = 0;
int perfectHit = 0;


bool quit = false;

float selInstVolume = 0.5;
float otherInstVolume = 0.375;
Expand Down
61 changes: 56 additions & 5 deletions Encore/src/game/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,71 @@ void Menu::loadMenu(SongList songList, GLFWgamepadstatefun gamepadStateCallbackS
WHITE);
}

void Menu::showResults(Player player) {
float RightBorder = ((float)GetScreenWidth()/2)+((float)GetScreenHeight()/1.16f);
void Menu::showResults(Player player, Assets assets) {

Song songToBeJudged = player.songToBeJudged;
float RightBorder = ((float)GetScreenWidth()/2)+((float)GetScreenHeight()/1.20f);
float RightSide = RightBorder >= (float)GetScreenWidth() ? (float)GetScreenWidth() : RightBorder;


float LeftBorder = ((float)GetScreenWidth()/2)-((float)GetScreenHeight()/1.16f);
float LeftBorder = ((float)GetScreenWidth()/2)-((float)GetScreenHeight()/1.20f);
float LeftSide = LeftBorder <= 0 ? 0 : LeftBorder;

float PlayerWidth = ((float)GetScreenWidth()/2)-((float)GetScreenHeight()/1.40f);
float ResultsWidth = (RightSide - LeftSide);
float PlayerWidth = (ResultsWidth*0.2275f);

float InnerMargins = (ResultsWidth*0.03f);

float Player2 = LeftSide + PlayerWidth + InnerMargins;

float Player4 = RightSide - PlayerWidth;
float Player3 = Player4 - PlayerWidth - InnerMargins;

float middle = (PlayerWidth/2) + LeftSide;


DrawRectangle(LeftSide-4, 0, PlayerWidth+8, (float)GetScreenHeight(), WHITE);
DrawRectangle(LeftSide, 0, PlayerWidth, (float)GetScreenHeight(), GetColor(0x181827FF));
// renderStars(player, 0,0);

//assets.DrawTextRHDI("Results", 70,7, WHITE);
assets.DrawTextRubik(songToBeJudged.artist.c_str(), middle - (assets.MeasureTextRubik(songToBeJudged.artist.c_str(), 24) / 2), 48, 24, WHITE);
// if (player.FC) {
// assets.DrawTextRubik("Flawless!", middle- (assets.MeasureTextRubik("Flawless!", 24) / 2), 7, 24, GOLD);
// }
float scorePos = middle - MeasureTextEx(assets.redHatDisplayItalic, scoreCommaFormatter(player.score).c_str(), 64, 1).x /2;
DrawTextEx(
assets.redHatDisplayItalic,
scoreCommaFormatter(player.score).c_str(),
{
scorePos,
(float)GetScreenHeight()/2},
64,
1,
Color{
107,
161,
222,
255});

assets.DrawTextRHDI(scoreCommaFormatter(player.score).c_str(), middle - assets.MeasureTextRHDI(scoreCommaFormatter(player.score).c_str())/2, 120, Color{107, 161, 222,255});
assets.DrawTextRubik(TextFormat("Perfect Notes : %01i/%02i", player.perfectHit, songToBeJudged.parts[player.instrument]->charts[player.diff].notes.size()), (middle - assets.MeasureTextRubik(TextFormat("Perfect Notes: %01i/%02i", player.perfectHit, songToBeJudged.parts[player.instrument]->charts[player.diff].notes.size()), 24) / 2), 192, 24, WHITE);
assets.DrawTextRubik(TextFormat("Good Notes : %01i/%02i", player.notesHit - player.perfectHit, songToBeJudged.parts[player.instrument]->charts[player.diff].notes.size()), (middle - assets.MeasureTextRubik(TextFormat("Good Notes: %01i/%02i", player.notesHit - player.perfectHit, songToBeJudged.parts[player.instrument]->charts[player.diff].notes.size()), 24) / 2), 224, 24, WHITE);
assets.DrawTextRubik(TextFormat("Missed Notes: %01i/%02i", player.notesMissed, songToBeJudged.parts[player.instrument]->charts[player.diff].notes.size()), (GetScreenWidth() / 2 - assets.MeasureTextRubik(TextFormat("Missed Notes: %01i/%02i", player.notesMissed, songToBeJudged.parts[player.instrument]->charts[player.diff].notes.size()), 24) / 2), 256, 24, WHITE);
assets.DrawTextRubik(TextFormat("Strikes: %01i", player.playerOverhits), (middle - assets.MeasureTextRubik(TextFormat("Strikes: %01i", player.playerOverhits), 24) / 2), 288, 24, WHITE);
assets.DrawTextRubik(TextFormat("Longest Streak: %01i", player.maxCombo), (middle - assets.MeasureTextRubik(TextFormat("Longest Streak: %01i", player.maxCombo), 24) / 2), 320, 24, WHITE);
renderStars(player, middle, 90);

//DrawRectangle(Player2-4, 0, PlayerWidth+8, (float)GetScreenHeight(), WHITE);
//DrawRectangle(Player2, 0, PlayerWidth, (float)GetScreenHeight(), GetColor(0x181827FF));

//DrawRectangle(Player3-4, 0, PlayerWidth+8, (float)GetScreenHeight(), WHITE);
//DrawRectangle(Player3, 0, PlayerWidth, (float)GetScreenHeight(), GetColor(0x181827FF));

//DrawRectangle(Player4-4, 0, PlayerWidth+8, (float)GetScreenHeight(), WHITE);
//DrawRectangle(Player4, 0, PlayerWidth, (float)GetScreenHeight(), GetColor(0x181827FF));
// DrawLine(LeftSide, 0, LeftSide, (float)GetScreenHeight(), WHITE);
renderStars(player, 0,0);

}

void Menu::SwitchScreen(Screens screen){
Expand Down
20 changes: 5 additions & 15 deletions Encore/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ int main(int argc, char* argv[])
case GAMEPLAY: {
// IMAGE BACKGROUNDS??????
ClearBackground(BLACK);

player.songToBeJudged = songList.songs[curPlayingSong];
int scorePos = (GetScreenWidth()/4)* 3;
DrawTextureEx(assets.songBackground, {0,0},0, (float)GetScreenHeight()/assets.songBackground.height,WHITE);
int starsval = player.stars(songList.songs[curPlayingSong].parts[player.instrument]->charts[player.diff].baseScore,player.diff);
Expand Down Expand Up @@ -1362,6 +1362,7 @@ int main(int argc, char* argv[])
isPlaying = false;
midiLoaded = false;
streamsLoaded = false;
player.quit = true;
}
if (!streamsLoaded) {
loadedStreams = LoadStems(songList.songs[curPlayingSong].stemsPath);
Expand Down Expand Up @@ -1761,7 +1762,7 @@ int main(int argc, char* argv[])
break;
}
case RESULTS: {
menu.showResults(player);
menu.showResults(player, assets);
DrawTopOvershell(160);
DrawBottomOvershell();
DrawBottomBottomOvershell();
Expand All @@ -1787,19 +1788,8 @@ int main(int argc, char* argv[])
else {
starsDisplay = (char*)"";
}*/
DrawTextRHDI("Results", 70,7, WHITE);
DrawTextRubik((songList.songs[curPlayingSong].artist + " - " + songList.songs[curPlayingSong].title).c_str(), GetScreenWidth() / 2 - (MeasureTextRubik((songList.songs[curPlayingSong].artist + " - " + songList.songs[curPlayingSong].title).c_str(), 24) / 2), 48, 24, WHITE);
if (player.FC) {
DrawTextRubik("Flawless!", GetScreenWidth() / 2 - (MeasureTextRubik("Flawless!", 24) / 2), 7, 24, GOLD);
}
DrawTextRHDI(scoreCommaFormatter(player.score).c_str(), (GetScreenWidth() / 2) - MeasureTextRHDI(scoreCommaFormatter(player.score).c_str())/2, 120, Color{107, 161, 222,255});
// DrawTextRubik(TextFormat("%s", starsDisplay), (GetScreenWidth() / 2 - MeasureTextRubik(TextFormat("%s", starsDisplay), 24) / 2), 160, 24, goldStars ? GOLD : WHITE);
DrawTextRubik(TextFormat("Perfect Notes : %01i/%02i", player.perfectHit, songList.songs[curPlayingSong].parts[player.instrument]->charts[player.diff].notes.size()), (GetScreenWidth() / 2 - MeasureTextRubik(TextFormat("Perfect Notes: %01i/%02i", player.perfectHit, songList.songs[curPlayingSong].parts[player.instrument]->charts[player.diff].notes.size()), 24) / 2), 192, 24, WHITE);
DrawTextRubik(TextFormat("Good Notes : %01i/%02i", player.notesHit - player.perfectHit, songList.songs[curPlayingSong].parts[player.instrument]->charts[player.diff].notes.size()), (GetScreenWidth() / 2 - MeasureTextRubik(TextFormat("Good Notes: %01i/%02i", player.notesHit - player.perfectHit, songList.songs[curPlayingSong].parts[player.instrument]->charts[player.diff].notes.size()), 24) / 2), 224, 24, WHITE);
DrawTextRubik(TextFormat("Missed Notes: %01i/%02i", player.notesMissed, songList.songs[curPlayingSong].parts[player.instrument]->charts[player.diff].notes.size()), (GetScreenWidth() / 2 - MeasureTextRubik(TextFormat("Missed Notes: %01i/%02i", player.notesMissed, songList.songs[curPlayingSong].parts[player.instrument]->charts[player.diff].notes.size()), 24) / 2), 256, 24, WHITE);
DrawTextRubik(TextFormat("Strikes: %01i", player.playerOverhits), (GetScreenWidth() / 2 - MeasureTextRubik(TextFormat("Strikes: %01i", player.playerOverhits), 24) / 2), 288, 24, WHITE);
DrawTextRubik(TextFormat("Longest Streak: %01i", player.maxCombo), (GetScreenWidth() / 2 - MeasureTextRubik(TextFormat("Longest Streak: %01i", player.maxCombo), 24) / 2), 320, 24, WHITE);
if (GuiButton({ 0,0,60,60 }, "<")) {
if (GuiButton({ 0,0,60,60 }, "<")) {
player.quit = false;
menu.SwitchScreen(SONG_SELECT);
}
break;
Expand Down

0 comments on commit a6c290c

Please sign in to comment.