forked from daid/EmptyEpsilon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pithlit
committed
Aug 4, 2023
1 parent
96f2135
commit 66dd45d
Showing
5 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ enum ECrewPosition | |
altRelay, | ||
commsOnly, | ||
shipLog, | ||
hangar, | ||
max_crew_positions | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
#include "hangar.h" | ||
#include "gui/gui2_label.h" | ||
#include "gui/gui2_panel.h" | ||
#include "playerInfo.h" | ||
#include "screenComponents/alertOverlay.h" | ||
#include "shipTemplate.h" | ||
#include "spaceObjects/playerSpaceship.h" | ||
#include <i18n.h> | ||
|
||
HangarScreen::HangarScreen(GuiContainer* owner) | ||
: GuiOverlay(owner, "HANGAR_SCREEN", colorConfig.background) | ||
{ | ||
// Render the background decorations. | ||
auto background_crosses = new GuiOverlay(this, "BACKGROUND_CROSSES", glm::u8vec4{255,255,255,255}); | ||
background_crosses->setTextureTiled("gui/background/crosses.png"); | ||
|
||
// Render the alert level color overlay. | ||
(new AlertLevelOverlay(this)); | ||
|
||
|
||
|
||
// Draw a container with two columns. | ||
auto container = new GuiElement(this, ""); | ||
container->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setAttribute("layout", "horizontal"); | ||
auto left_col= new GuiElement(container, ""); | ||
left_col->setPosition(20, 100, sp::Alignment::TopLeft)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax); | ||
auto right_col= new GuiElement(container, ""); | ||
right_col->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax); | ||
|
||
// Energy display. | ||
energy_display = new GuiKeyValueDisplay(left_col, "ENERGY_DISPLAY", 0.45, tr("Energy"), ""); | ||
energy_display->setIcon("gui/icons/energy")->setTextSize(20)->setSize(240, 40); | ||
|
||
// Reputation display. | ||
info_reputation = new GuiKeyValueDisplay(left_col, "INFO_REPUTATION", 0.45f, tr("Reputation") + ":", ""); | ||
|
||
// Shares energy with docked bool | ||
(new GuiLabel(left_col, "", tr("Docked ship services:"), 30))->setSize(GuiElement::GuiSizeMax, 50); | ||
shares_energy_with_docked_toggle = new GuiToggleButton(left_col, "", tr("Share energy"), [this](bool value) { | ||
my_spaceship->setSharesEnergyWithDocked(value); | ||
}); | ||
shares_energy_with_docked_toggle->setSize(GuiElement::GuiSizeMax, 40); | ||
|
||
// Repairs docked ships bool | ||
repairs_docked_toggle = new GuiToggleButton(left_col, "", tr("Repair ships"), [this](bool value) { | ||
my_spaceship->setRepairDocked(value); | ||
}); | ||
repairs_docked_toggle->setSize(GuiElement::GuiSizeMax, 40); | ||
|
||
// Restocks player scan probes bool | ||
restocks_scan_probes_toggle = new GuiToggleButton(left_col, "", tr("Restock scan probes"), [this](bool value) { | ||
my_spaceship->setRestocksScanProbes(value); | ||
}); | ||
restocks_scan_probes_toggle->setSize(GuiElement::GuiSizeMax, 40); | ||
|
||
// Restocks missiles selector | ||
restocks_weapons_toggle= new GuiToggleButton(left_col, "", tr("Restock missiles"), [this](bool value) { | ||
if (value) | ||
my_spaceship->setRestocksMissilesDocked(R_Fighters); | ||
else | ||
my_spaceship->setRestocksMissilesDocked(R_None); | ||
}); | ||
restocks_weapons_toggle->setSize(GuiElement::GuiSizeMax, 40); | ||
|
||
|
||
} | ||
|
||
void HangarScreen::onDraw(sp::RenderTarget& renderer) | ||
{ | ||
GuiOverlay::onDraw(renderer); | ||
|
||
// update stat displays | ||
info_reputation->setValue(string(my_spaceship->getReputationPoints(), 0)); | ||
energy_display->setValue(string(int(nearbyint((my_spaceship->energy_level))))); | ||
if (my_spaceship->energy_level < 100.0f) | ||
energy_display->setColor(glm::u8vec4(255, 0, 0, 255)); | ||
else | ||
energy_display->setColor(glm::u8vec4{255,255,255,255}); | ||
|
||
// update buttons | ||
shares_energy_with_docked_toggle->setValue(my_spaceship->getSharesEnergyWithDocked()); | ||
repairs_docked_toggle->setValue(my_spaceship->getRepairDocked()); | ||
restocks_scan_probes_toggle->setValue(my_spaceship->getRestocksScanProbes()); | ||
restocks_weapons_toggle->setValue(my_spaceship->getRestocksMissilesDocked() == R_Fighters); | ||
|
||
} | ||
|
||
FighterCreateDialog::FighterCreateDialog(GuiContainer* parent, string id) | ||
: GuiOverlay(parent, id, glm::u8vec4(0,0,0,64)) | ||
{ | ||
hide(); | ||
|
||
auto panel = new GuiPanel(this, "FIGHTER_CREATION_PANEL"); | ||
panel->setPosition(0, 350, sp::Alignment::TopCenter)->setSize(600, 600); | ||
|
||
// Callsign row | ||
GuiElement* row = new GuiElement(panel, ""); | ||
row->setSize(GuiElement::GuiSizeMax, 50)->setAttribute("layout", "horizontal"); | ||
(new GuiLabel(row, "CALLSIGN_LABEL", tr("Callsign: "), 30))->setAlignment(sp::Alignment::CenterRight)->setSize(250, GuiElement::GuiSizeMax); | ||
callsign = new GuiTextEntry(row, "CALLSIGN_ENTRY", ""); | ||
callsign->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax); | ||
|
||
// Password row | ||
row = new GuiElement(panel, ""); | ||
row->setSize(GuiElement::GuiSizeMax, 50)->setAttribute("layout", "horizontal"); | ||
(new GuiLabel(row, "PASSWORD_LABEL", tr("Control Code: "), 30))->setAlignment(sp::Alignment::CenterRight)->setSize(250, GuiElement::GuiSizeMax); | ||
password = new GuiTextEntry(row, "PASSWORD_ENTRY", ""); | ||
password->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax); | ||
|
||
// Hull row | ||
row = new GuiElement(panel, ""); | ||
row->setSize(GuiElement::GuiSizeMax, 50)->setAttribute("layout", "horizontal"); | ||
(new GuiLabel(row, "HULL_LABEL", tr("Hull: "), 30))->setAlignment(sp::Alignment::CenterRight)->setSize(250, GuiElement::GuiSizeMax); | ||
hull = new GuiSelector(row, "HULL_SELECTOR", [this](int index, string value) | ||
{ | ||
P<ShipTemplate> ship_template = ShipTemplate::getTemplate(value); | ||
playership_info->setText(ship_template->getDescription()); | ||
}); | ||
hull->setOptions({"MP52 Hornet", "ZX-Lindworm"})->setSelectionIndex(0); // TODO read from my ship witch template are available | ||
hull->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax); | ||
|
||
// Color row | ||
row = new GuiElement(panel, ""); | ||
row->setSize(GuiElement::GuiSizeMax, 50)->setAttribute("layout", "horizontal"); | ||
(new GuiLabel(row, "COLOR_LABEL", tr("Color: "), 30))->setAlignment(sp::Alignment::CenterRight)->setSize(250, GuiElement::GuiSizeMax); | ||
color = new GuiSelector(row, "COLOR_SELECTOR", [this](int index, string value) | ||
{ | ||
// TODO change rendered model color | ||
}); | ||
color->setOptions({"white", "yellow", "blue", "red", "green", "gray"})->setSelectionIndex(0); | ||
color->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax); | ||
|
||
// info | ||
row = new GuiElement(panel, ""); | ||
row->setSize(GuiElement::GuiSizeMax, 400)->setAttribute("layout", "horizontal"); | ||
playership_info = new GuiScrollText(row, "PLAYERSHIP_INFO", tr("Ship info...")); | ||
playership_info->setPosition(0, 10, sp::Alignment::TopCenter)->setSize(520, 400); | ||
|
||
P<ShipTemplate> ship_template = ShipTemplate::getTemplate(hull->getSelectionValue()); | ||
playership_info->setText(ship_template->getDescription()); | ||
|
||
// 3D TODO | ||
|
||
// action row | ||
row = new GuiElement(panel, ""); | ||
row->setSize(GuiElement::GuiSizeMax, 50)->setAttribute("layout", "horizontal"); | ||
(new GuiButton(row, "ABORT", tr("Cancel"), [this]() { | ||
// TODO | ||
}))->setSize(100,50); | ||
(new GuiButton(row, "CREATE_SHIP_BUTTON", tr("Build Fighter"), [this]() { | ||
// TODO | ||
}))->setSize(100,50); | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef HANGAR_H | ||
#define HANGAR_H | ||
|
||
#include "gui/gui2_overlay.h" | ||
#include "gui/gui2_togglebutton.h" | ||
#include "gui/gui2_selector.h" | ||
#include "gui/gui2_textentry.h" | ||
#include "gui/gui2_scrolltext.h" | ||
#include "gui/gui2_keyvaluedisplay.h" | ||
|
||
|
||
class HangarScreen: public GuiOverlay | ||
{ | ||
private: | ||
GuiKeyValueDisplay* energy_display; | ||
GuiKeyValueDisplay* info_reputation; | ||
GuiToggleButton* shares_energy_with_docked_toggle; | ||
GuiToggleButton* repairs_docked_toggle; | ||
GuiToggleButton* restocks_scan_probes_toggle; | ||
GuiToggleButton* restocks_weapons_toggle; | ||
public: | ||
HangarScreen(GuiContainer* owner); | ||
|
||
void onDraw(sp::RenderTarget& target) override; | ||
}; | ||
|
||
class FighterCreateDialog: public GuiOverlay | ||
{ | ||
public: | ||
FighterCreateDialog(GuiContainer* parent, string id); | ||
|
||
// void open(string label, string preset_password, std::function<bool(string)> on_password_check, std::function<void()> on_ready, std::function<void()> on_cancel); | ||
private: | ||
|
||
GuiTextEntry* callsign; | ||
GuiTextEntry* password; | ||
GuiSelector* hull; | ||
GuiSelector* color; | ||
GuiScrollText* playership_info; | ||
}; | ||
#endif//HANGAR_H |