Skip to content

Commit

Permalink
Merge branch 'main' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
afwbkbc committed Oct 12, 2024
2 parents a3c865d + e876e41 commit 3e51746
Show file tree
Hide file tree
Showing 34 changed files with 695 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/game/frontend/ui/Section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ void Section::Create() {

NEW( m_inner, ::ui::object::Section, m_config.no_inner_border
? ""
: m_section_class_prefix + "SectionInner" );
: m_section_class_prefix + (
m_section_class_prefix != "BB" || m_config.no_inner_background // TODO: refactor
? "SectionInner"
: "SectionInnerWithBackground"
) );
if ( !m_title_text.empty() ) {
m_inner->SetTitleText( m_title_text );
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/frontend/ui/Section.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ CLASS( Section, UI )

void SetTitleText( const std::string& title_text );

protected:
struct {
bool no_outer_border = false;
bool no_inner_border = false;
bool no_inner_background = false;
} m_config = {};

private:
Expand Down
3 changes: 0 additions & 3 deletions src/game/frontend/ui/popup/ChatPopup.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ CLASS( ChatPopup, OkCancelPopup )
::ui::object::Section* m_message_section = nullptr;
::ui::object::Label* m_message_label = nullptr;
::ui::object::Input* m_message_input = nullptr;
struct {

} m_buttons;

};

Expand Down
2 changes: 2 additions & 0 deletions src/game/frontend/ui/popup/Popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ void Popup::Create() {
::ui::object::Popup::Create();

NEW( m_body, Section, m_game, "", "WP" );
m_body->m_config.no_outer_border = m_config.no_outer_border;
m_body->m_config.no_inner_border = m_config.no_inner_border;
if ( !m_title_text.empty() ) {
m_body->SetTitleText( m_title_text );
}
Expand Down
5 changes: 5 additions & 0 deletions src/game/frontend/ui/popup/Popup.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ CLASS( Popup, ::ui::object::Popup )

void CloseNow();

struct {
bool no_outer_border = false;
bool no_inner_border = false;
} m_config = {};

private:
coord_t m_original_height = 0; // TODO: move to styles?
std::string m_title_text = "";
Expand Down
22 changes: 22 additions & 0 deletions src/game/frontend/ui/popup/base_popup/BPSection.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "BPSection.h"

#include "BasePopup.h"

namespace game {
namespace frontend {
namespace ui {
namespace popup {
namespace base_popup {

BPSection::BPSection( BasePopup* popup, const std::string class_name )
: Section( popup->GetGame(), "BP" + class_name, "BB" )
, m_popup( popup ) {
m_config.no_outer_border = true;
m_config.no_inner_background = true;
}

}
}
}
}
}
28 changes: 28 additions & 0 deletions src/game/frontend/ui/popup/base_popup/BPSection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "game/frontend/ui/Section.h"

namespace game {
namespace frontend {
namespace ui {
namespace popup {
namespace base_popup {

class BasePopup;

CLASS( BPSection, Section )

BPSection( BasePopup* popup, const std::string class_name = "" );

protected:
BasePopup* const m_popup = nullptr;

private:

};

}
}
}
}
}
52 changes: 51 additions & 1 deletion src/game/frontend/ui/popup/base_popup/BasePopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
#include "game/frontend/ui/popup/base_popup/bottom_bar/BottomBar.h"
#include "engine/Engine.h"
#include "ui/UI.h"
#include "Governor.h"
#include "Nutrients.h"
#include "Commerce.h"
#include "GlobalInfo.h"
#include "CenterArea.h"
#include "Yields.h"
#include "Energy.h"
#include "Facilities.h"
#include "Buttons.h"

namespace game {
namespace frontend {
Expand All @@ -17,7 +26,8 @@ BasePopup::BasePopup( Game* game, base::Base* base )
: Popup( game )
, m_base( base ) {
SetWidth( 680 );
SetHeight( 480 );
SetHeight( 504 );
m_config.no_inner_border = true;
}

void BasePopup::Create() {
Expand Down Expand Up @@ -45,13 +55,53 @@ void BasePopup::Create() {
}
);

NEW( m_sections.governor, Governor, this );
AddChild( m_sections.governor );

NEW( m_sections.nutrients, Nutrients, this );
AddChild( m_sections.nutrients );

NEW( m_sections.commerce, Commerce, this );
AddChild( m_sections.commerce );

NEW( m_sections.global_info, GlobalInfo, this );
AddChild( m_sections.global_info );

NEW( m_sections.center_area, CenterArea, this );
AddChild( m_sections.center_area );

NEW( m_sections.yields, Yields, this );
AddChild( m_sections.yields );

NEW( m_sections.energy, Energy, this );
AddChild( m_sections.energy );

NEW( m_sections.facilities, Facilities, this );
AddChild( m_sections.facilities );

NEW( m_sections.buttons, Buttons, this );
AddChild( m_sections.buttons );
}

void BasePopup::Destroy() {

RemoveChild( m_sections.governor );
RemoveChild( m_sections.nutrients );
RemoveChild( m_sections.commerce );
RemoveChild( m_sections.global_info );
RemoveChild( m_sections.center_area );
RemoveChild( m_sections.yields );
RemoveChild( m_sections.energy );
RemoveChild( m_sections.facilities );
RemoveChild( m_sections.buttons );

Popup::Destroy();
}

Game* BasePopup::GetGame() const {
return m_game;
}

base::Base* BasePopup::GetBase() const {
return m_base;
}
Expand Down
22 changes: 22 additions & 0 deletions src/game/frontend/ui/popup/base_popup/BasePopup.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,24 @@ class BottomBar;
class BaseTitle;
}

class Governor;
class Nutrients;
class Commerce;
class GlobalInfo;
class CenterArea;
class Yields;
class Energy;
class Facilities;
class Buttons;

CLASS( BasePopup, Popup )

BasePopup( Game* game, base::Base* base );

void Create() override;
void Destroy() override;

Game* GetGame() const;
base::Base* GetBase() const;

protected:
Expand All @@ -41,6 +52,17 @@ CLASS( BasePopup, Popup )
base::Base* m_base = nullptr;

bottom_bar::BottomBar* m_bottom_bar = nullptr;
struct {
Governor* governor = nullptr;
Nutrients* nutrients = nullptr;
Commerce* commerce = nullptr;
GlobalInfo* global_info = nullptr;
CenterArea* center_area = nullptr;
Yields* yields = nullptr;
Energy* energy = nullptr;
Facilities* facilities = nullptr;
Buttons* buttons = nullptr;
} m_sections = {};

void Update( base::Base* base );

Expand Down
59 changes: 59 additions & 0 deletions src/game/frontend/ui/popup/base_popup/Buttons.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include "Buttons.h"

#include "ui/object/Button.h"

#include "BasePopup.h"

namespace game {
namespace frontend {
namespace ui {
namespace popup {
namespace base_popup {

Buttons::Buttons( BasePopup* popup )
: BPSection( popup, "Buttons" ) {}

void Buttons::Create() {
BPSection::Create();

NEW( m_buttons.rename, ::ui::object::Button, "PopupButtonOkCancel" );
m_buttons.rename->SetAlign( ::ui::ALIGN_LEFT | ::ui::ALIGN_VCENTER );
m_buttons.rename->SetLeft( 3 );
m_buttons.rename->SetRight( 2 );
m_buttons.rename->SetLabel( "RENAME" );
m_buttons.rename->On(
::ui::event::EV_BUTTON_CLICK, EH( this ) {
Log( "TODO: RENAME" );
return true;
}
);
AddChild( m_buttons.rename );

NEW( m_buttons.ok, ::ui::object::Button, "PopupButtonOkCancel" );
m_buttons.ok->SetAlign( ::ui::ALIGN_RIGHT | ::ui::ALIGN_VCENTER );
m_buttons.ok->SetLeft( 2 );
m_buttons.ok->SetRight( 3 );
m_buttons.ok->SetLabel( "OK" );
m_buttons.ok->On(
::ui::event::EV_BUTTON_CLICK, EH( this ) {
m_popup->Close();
return true;
}
);
AddChild( m_buttons.ok );

}

void Buttons::Destroy() {

RemoveChild( m_buttons.rename );
RemoveChild( m_buttons.ok );

BPSection::Destroy();
}

}
}
}
}
}
34 changes: 34 additions & 0 deletions src/game/frontend/ui/popup/base_popup/Buttons.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

#include "BPSection.h"

namespace ui::object {
class Button;
}

namespace game {
namespace frontend {
namespace ui {
namespace popup {
namespace base_popup {

CLASS( Buttons, BPSection )

Buttons( BasePopup* popup );

void Create() override;
void Destroy() override;

private:
struct {
::ui::object::Button* rename = nullptr;
::ui::object::Button* ok = nullptr;
} m_buttons = {};

};

}
}
}
}
}
10 changes: 10 additions & 0 deletions src/game/frontend/ui/popup/base_popup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,15 @@ SUBDIR( bottom_bar )
SET( SRC ${SRC}

${PWD}/BasePopup.cpp
${PWD}/BPSection.cpp
${PWD}/Governor.cpp
${PWD}/Nutrients.cpp
${PWD}/Commerce.cpp
${PWD}/GlobalInfo.cpp
${PWD}/CenterArea.cpp
${PWD}/Yields.cpp
${PWD}/Energy.cpp
${PWD}/Facilities.cpp
${PWD}/Buttons.cpp

PARENT_SCOPE )
16 changes: 16 additions & 0 deletions src/game/frontend/ui/popup/base_popup/CenterArea.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "CenterArea.h"

namespace game {
namespace frontend {
namespace ui {
namespace popup {
namespace base_popup {

CenterArea::CenterArea( BasePopup* popup )
: BPSection( popup, "CenterArea" ) {}

}
}
}
}
}
23 changes: 23 additions & 0 deletions src/game/frontend/ui/popup/base_popup/CenterArea.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include "BPSection.h"

namespace game {
namespace frontend {
namespace ui {
namespace popup {
namespace base_popup {

CLASS( CenterArea, BPSection )

CenterArea( BasePopup* popup );

private:

};

}
}
}
}
}
16 changes: 16 additions & 0 deletions src/game/frontend/ui/popup/base_popup/Commerce.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "Commerce.h"

namespace game {
namespace frontend {
namespace ui {
namespace popup {
namespace base_popup {

Commerce::Commerce( BasePopup* popup )
: BPSection( popup, "Commerce" ) {}

}
}
}
}
}
Loading

0 comments on commit 3e51746

Please sign in to comment.