Skip to content

Commit

Permalink
adding more scenes and scene buttons on the main screen
Browse files Browse the repository at this point in the history
  • Loading branch information
beaumanvienna committed Oct 6, 2024
1 parent 4322e0d commit 5df4bc2
Show file tree
Hide file tree
Showing 28 changed files with 2,279 additions and 335 deletions.
6 changes: 3 additions & 3 deletions application/lucre/UI/UI.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Engine Copyright (c) 2022 Engine Development Team
/* Engine Copyright (c) 2024 Engine Development Team
https://github.com/beaumanvienna/vulkan
Permission is hereby granted, free of charge, to any person
Expand Down Expand Up @@ -61,11 +61,11 @@ namespace LucreApp
m_Common = std::make_unique<Common>();
g_Common = m_Common.get();

m_MainScreen = new MainScreen(m_Spritesheet);
m_MainScreen = new MainScreen(*m_Spritesheet); // deleted by screen manager
m_MainScreen->OnAttach();
m_ScreenManager->push(m_MainScreen);

m_UIStarIcon = std::make_unique<UIStarIcon>(false, "UI star icon");
m_UIStarIcon = std::make_unique<UIStarIcon>("UI star icon");
Engine::m_Engine->PushOverlay(m_UIStarIcon.get());

m_UIControllerAnimation = std::make_unique<ControllerSetupAnimation>("controller animation");
Expand Down
10 changes: 5 additions & 5 deletions application/lucre/UI/common.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Engine Copyright (c) 2022 Engine Development Team
/* Engine Copyright (c) 2024 Engine Development Team
https://github.com/beaumanvienna/vulkan
Permission is hereby granted, free of charge, to any person
Expand Down Expand Up @@ -33,14 +33,14 @@ namespace LucreApp
m_AvailableWidth = Engine::m_Engine->GetWindowWidth();
m_AvailableHeight = Engine::m_Engine->GetWindowHeight();

m_ScaleAll = m_AvailableHeight / 1080.0f;
m_ScaleAll = m_AvailableHeight / 720.0f;

m_IconWidth = 64.0f * m_ScaleAll;
m_IconHeight = 64.0f * m_ScaleAll;
m_IconSpacer = 64.0f * m_ScaleAll;
m_IconSpacer = 20.0f * m_ScaleAll;

m_StripSize = 150.0f * m_ScaleAll;
m_MarginLeftRight = 64.0f * m_ScaleAll;
m_MarginLeftRight = 32.0f * m_ScaleAll;
m_SettingsBar = 85.0f * m_ScaleAll;

m_TabMargin = 50.0f * m_ScaleAll;
Expand All @@ -49,7 +49,7 @@ namespace LucreApp

m_ControllerScale = 1.0f * m_ScaleAll;

m_TabIconScaleRetro = 1.5 * m_ScaleAll;
m_TabIconScaleRetro = 1.0 * m_ScaleAll;
m_IconScaleRetro = 0.5 * m_ScaleAll;
m_IconScale = 1.0 * m_ScaleAll;
}
Expand Down
285 changes: 130 additions & 155 deletions application/lucre/UI/mainScreen.cpp

Large diffs are not rendered by default.

48 changes: 30 additions & 18 deletions application/lucre/UI/mainScreen.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Engine Copyright (c) 2022 Engine Development Team
/* Engine Copyright (c) 2024 Engine Development Team
https://github.com/beaumanvienna/vulkan
Permission is hereby granted, free of charge, to any person
Expand Down Expand Up @@ -36,9 +36,13 @@ namespace LucreApp
{

public:
MainScreen(SpriteSheet* spritesheet) { m_Spritesheet = spritesheet; }
virtual ~MainScreen() {}
bool key(const SCREEN_KeyInput& key) override;
MainScreen(SpriteSheet& spritesheet);
virtual ~MainScreen();

MainScreen(MainScreen const&) = delete;
MainScreen& operator=(MainScreen const&) = delete;

bool key(SCREEN_KeyInput const& key) override;
void OnAttach();
void OnDetach();
void update() override;
Expand All @@ -54,6 +58,9 @@ namespace LucreApp
SCREEN_UI::EventReturn Scene3Click(SCREEN_UI::EventParams& e);
SCREEN_UI::EventReturn Scene4Click(SCREEN_UI::EventParams& e);
SCREEN_UI::EventReturn Scene5Click(SCREEN_UI::EventParams& e);
SCREEN_UI::EventReturn Scene6Click(SCREEN_UI::EventParams& e);
SCREEN_UI::EventReturn Scene7Click(SCREEN_UI::EventParams& e);
SCREEN_UI::EventReturn Scene8Click(SCREEN_UI::EventParams& e);
SCREEN_UI::EventReturn OffClick(SCREEN_UI::EventParams& e);
SCREEN_UI::EventReturn OffHold(SCREEN_UI::EventParams& e);

Expand All @@ -66,25 +73,30 @@ namespace LucreApp
};

private:
SCREEN_UI::Choice* m_OffButton = nullptr;
SCREEN_UI::Choice* m_SettingsButton = nullptr;
SCREEN_UI::Choice* m_Scene1Button = nullptr;
SCREEN_UI::Choice* m_Scene2Button = nullptr;
SCREEN_UI::Choice* m_Scene3Button = nullptr;
SCREEN_UI::Choice* m_Scene4Button = nullptr;
SCREEN_UI::Choice* m_Scene5Button = nullptr;
InfoMessage* m_MainInfo = nullptr;
enum SceneButtons
{
SCENE_BUTTON_1 = 0,
SCENE_BUTTON_2,
SCENE_BUTTON_3,
SCENE_BUTTON_4,
SCENE_BUTTON_5,
SCENE_BUTTON_6,
SCENE_BUTTON_7,
SCENE_BUTTON_8,
NUM_SCENE_BUTTONS
};

SCREEN_UI::Choice* m_OffButton{nullptr};
SCREEN_UI::Choice* m_SettingsButton{nullptr};
SCREEN_UI::Choice* m_SceneButtons[SceneButtons::NUM_SCENE_BUTTONS] = {};
InfoMessage* m_MainInfo{nullptr};

bool m_SetFocus = true;
bool m_ToolTipsShown[MAX_TOOLTIP_IDs] = {false};

SpriteSheet* m_Spritesheet = nullptr;
SpriteSheet& m_Spritesheet;
SpriteSheet m_SpritesheetSettings;
SpriteSheet m_SpritesheetOff;
SpriteSheet m_SpritesheetScene1Button;
SpriteSheet m_SpritesheetScene2Button;
SpriteSheet m_SpritesheetScene3Button;
SpriteSheet m_SpritesheetScene4Button;
SpriteSheet m_SpritesheetScene5Button;
SpriteSheet m_SpritesheetSceneButtons[SceneButtons::NUM_SCENE_BUTTONS];
};
} // namespace LucreApp
29 changes: 15 additions & 14 deletions application/lucre/UI/offDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@

namespace LucreApp
{

OffDialog::OffDialog(std::string label, OffDiagEvent offDiagEvent)
: SCREEN_PopupScreen(label), m_offDiagEvent(offDiagEvent)
{
}
void OffDialog::CreatePopupContents(SCREEN_UI::ViewGroup* parent)
{
using namespace SCREEN_UI;
Expand All @@ -42,25 +45,23 @@ namespace LucreApp
Choice* cancelButton;

LinearLayout* items = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT));
float scale = UI::g_Common->m_ScaleAll;
float scale = UI::g_Common->m_ScaleAll * 720.0f / 1080.0f;
float iconWidth = 265.0f * scale; // width is 530.0f * scale, see SCREEN_PopupScreen::SCREEN_PopupScreen()
float iconHeight = UI::g_Common->m_IconHeight * 720.0f / 1080.0f;

if (CoreSettings::m_UITheme == THEME_RETRO)
{
if (m_offDiagEvent == OFFDIAG_QUIT)
{
yesButton =
new Choice(ma->T("YES"), TRANSPARENT_BACKGROUND, new LayoutParams(265.0f * scale, 64.0f * scale));
cancelButton =
new Choice(ma->T("CANCEL"), TRANSPARENT_BACKGROUND, new LayoutParams(265.0f * scale, 64.0f * scale));
yesButton = new Choice(ma->T("YES"), TRANSPARENT_BACKGROUND, new LayoutParams(iconWidth, iconHeight));
cancelButton = new Choice(ma->T("CANCEL"), TRANSPARENT_BACKGROUND, new LayoutParams(iconWidth, iconHeight));
yesButton->OnClick.Handle(this, &OffDialog::QuitMarley);
cancelButton->OnClick.Handle<SCREEN_UIScreen>(this, &SCREEN_UIScreen::OnBack);
}
else
{
yesButton =
new Choice(ma->T("YES"), TRANSPARENT_BACKGROUND, new LayoutParams(265.0f * scale, 64.0f * scale));
cancelButton =
new Choice(ma->T("CANCEL"), TRANSPARENT_BACKGROUND, new LayoutParams(265.0f * scale, 64.0f * scale));
yesButton = new Choice(ma->T("YES"), TRANSPARENT_BACKGROUND, new LayoutParams(iconWidth, iconHeight));
cancelButton = new Choice(ma->T("CANCEL"), TRANSPARENT_BACKGROUND, new LayoutParams(iconWidth, iconHeight));
yesButton->OnClick.Handle(this, &OffDialog::SwitchOff);
cancelButton->OnClick.Handle<SCREEN_UIScreen>(this, &SCREEN_UIScreen::OnBack);
}
Expand All @@ -69,15 +70,15 @@ namespace LucreApp
{
if (m_offDiagEvent == OFFDIAG_QUIT)
{
yesButton = new Choice(ma->T("YES"), new LayoutParams(265.0f * scale, 64.0f * scale));
cancelButton = new Choice(ma->T("CANCEL"), new LayoutParams(265.0f * scale, 64.0f * scale));
yesButton = new Choice(ma->T("YES"), new LayoutParams(iconWidth, iconHeight));
cancelButton = new Choice(ma->T("CANCEL"), new LayoutParams(iconWidth, iconHeight));
yesButton->OnClick.Handle(this, &OffDialog::QuitMarley);
cancelButton->OnClick.Handle<SCREEN_UIScreen>(this, &SCREEN_UIScreen::OnBack);
}
else
{
yesButton = new Choice(ma->T("YES"), new LayoutParams(265.0f * scale, 64.0f * scale));
cancelButton = new Choice(ma->T("CANCEL"), new LayoutParams(265.0f * scale, 64.0f * scale));
yesButton = new Choice(ma->T("YES"), new LayoutParams(iconWidth, iconHeight));
cancelButton = new Choice(ma->T("CANCEL"), new LayoutParams(iconWidth, iconHeight));
yesButton->OnClick.Handle(this, &OffDialog::SwitchOff);
cancelButton->OnClick.Handle<SCREEN_UIScreen>(this, &SCREEN_UIScreen::OnBack);
}
Expand Down
3 changes: 2 additions & 1 deletion application/lucre/UI/offDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ namespace LucreApp
class OffDialog : public SCREEN_PopupScreen
{
public:
OffDialog(std::string label, OffDiagEvent offDiagEvent) : SCREEN_PopupScreen(label), m_offDiagEvent(offDiagEvent) {}
OffDialog(std::string label, OffDiagEvent offDiagEvent);

void CreatePopupContents(SCREEN_UI::ViewGroup* parent) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion application/lucre/UI/settingsTabs/credits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace LucreApp
}
else
{
Add(new Spacer(226.0f * UI::g_Common->m_ScaleAll - 69.0f - UI::g_Common->m_TabMargin));
Add(new Spacer(160.0f * UI::g_Common->m_ScaleAll - 69.0f - UI::g_Common->m_TabMargin));
}

float verticalSpace = (availableHeight - 4 * UI::g_Common->m_IconHeight);
Expand Down
40 changes: 10 additions & 30 deletions application/lucre/UI/stars.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Engine Copyright (c) 2021 Engine Development Team
/* Engine Copyright (c) 2024 Engine Development Team
https://github.com/beaumanvienna/vulkan
Permission is hereby granted, free of charge, to any person
Expand Down Expand Up @@ -26,7 +26,7 @@

namespace LucreApp
{
UIStarIcon::UIStarIcon(bool narrow, const std::string& name) : Layer(name), m_Narrow(narrow) {}
UIStarIcon::UIStarIcon(std::string const& name) : Layer(name) {}

UIStarIcon::~UIStarIcon() {}

Expand Down Expand Up @@ -63,16 +63,9 @@ namespace LucreApp
glm::vec2 finalOutOfScreenPosition;
glm::vec2 finalScreenPosition1;
float xPosWide1 = UI::g_Common->m_AvailableWidth - UI::g_Common->m_TabMarginLeftRight;
float yPosWide12 = 226.0f * UI::g_Common->m_ScaleAll;
float yPosWide12 = 160.0f * UI::g_Common->m_ScaleAll;
finalOutOfScreenPosition = glm::vec2(2000.0f, 300.0f);
if (m_Narrow)
{
finalScreenPosition1 = glm::vec2(320.0f, 110.0f);
}
else
{
finalScreenPosition1 = glm::vec2(xPosWide1, yPosWide12);
}
finalScreenPosition1 = glm::vec2(xPosWide1, yPosWide12);

m_StarMoveIn1.AddTranslation(Translation(1.0f * duration, finalOutOfScreenPosition, finalScreenPosition1));
m_StarMoveIn1.AddRotation(Rotation(1.0f * duration, 0.0f, 3.141f));
Expand All @@ -84,16 +77,9 @@ namespace LucreApp
m_StarMoveOut1.AddRotation(Rotation(1.0f * duration, 0.0f, 3.141f));

// 2nd star icon: move left to top left corner
float xPosWide23 = UI::g_Common->m_TabMarginLeftRight + UI::g_Common->m_IconWidth * 1.5f;
float xPosWide23 = UI::g_Common->m_TabMarginLeftRight + UI::g_Common->m_IconWidth * 3.0f;
glm::vec2 finalScreenPosition2;
if (m_Narrow)
{
finalScreenPosition2 = glm::vec2(650.0f, 500.0f);
}
else
{
finalScreenPosition2 = glm::vec2(xPosWide23, yPosWide12);
}
finalScreenPosition2 = glm::vec2(xPosWide23, yPosWide12);

m_StarMoveIn2.AddTranslation(Translation(1.0f * duration, finalOutOfScreenPosition, finalScreenPosition2));
m_StarMoveIn2.AddRotation(Rotation(1.0f * duration, 0.0f, -3.141f));
Expand All @@ -105,16 +91,10 @@ namespace LucreApp
m_StarMoveOut2.AddRotation(Rotation(1.0f * duration, 0.0f, 3.141f));

// 3rd star icon: move left to bottom left corner
float yPosWide3 = yPosWide12 + 568.0f * UI::g_Common->m_ScaleAll;
float yPosWide3 = yPosWide12 + 460.0f * UI::g_Common->m_ScaleAll;
glm::vec2 finalScreenPosition3;
if (m_Narrow)
{
finalScreenPosition3 = glm::vec2(650.0f, 350.0f);
}
else
{
finalScreenPosition3 = glm::vec2(xPosWide23, yPosWide3);
}

finalScreenPosition3 = glm::vec2(xPosWide23, yPosWide3);

m_StarMoveIn3.AddTranslation(Translation(1.0f * duration, finalOutOfScreenPosition, finalScreenPosition3));
m_StarMoveIn3.AddRotation(Rotation(1.0f * duration, 0.0f, 3.141f));
Expand All @@ -132,7 +112,7 @@ namespace LucreApp

void UIStarIcon::OnDetach() {}

void UIStarIcon::OnUpdate(const Timestep& timestep)
void UIStarIcon::OnUpdate(Timestep const& timestep)
{
switch (m_State)
{
Expand Down
12 changes: 5 additions & 7 deletions application/lucre/UI/stars.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Engine Copyright (c) 2021 Engine Development Team
/* Engine Copyright (c) 2024 Engine Development Team
https://github.com/beaumanvienna/vulkan
Permission is hereby granted, free of charge, to any person
Expand Down Expand Up @@ -43,13 +43,13 @@ namespace LucreApp
};

public:
UIStarIcon(bool narrow, const std::string& name = "UIStarIcon");
UIStarIcon(std::string const& name = "UIStarIcon");
~UIStarIcon() override;

void OnAttach() override;
void OnDetach() override;
void OnEvent(Event& event) override;
void OnUpdate(const Timestep& timestep) override;
void OnUpdate(Timestep const& timestep) override;
void OnResize();

void Start() { m_Start = true; }
Expand All @@ -63,9 +63,9 @@ namespace LucreApp
void Init();

private:
Renderer* m_Renderer;
Renderer* m_Renderer{nullptr};

SpriteSheet* m_Spritesheet;
SpriteSheet* m_Spritesheet{nullptr};
Sprite2D m_StarSprite;

Animation m_StarMoveIn1;
Expand All @@ -78,8 +78,6 @@ namespace LucreApp
Animation m_StarMoveOut2;
Animation m_StarMoveOut3;

bool m_Narrow;

bool m_Start;
bool m_Stop;

Expand Down
Loading

0 comments on commit 5df4bc2

Please sign in to comment.