osb/source/frontend/StarMainInterface.hpp

235 lines
6.2 KiB
C++
Raw Normal View History

#pragma once
2023-06-20 04:33:09 +00:00
#include "StarInventory.hpp"
#include "StarInteractionTypes.hpp"
#include "StarItemDescriptor.hpp"
#include "StarGameTypes.hpp"
#include "StarInterfaceCursor.hpp"
#include "StarMainInterfaceTypes.hpp"
#include "StarWarping.hpp"
namespace Star {
STAR_CLASS(UniverseClient);
STAR_CLASS(WorldPainter);
STAR_CLASS(Item);
STAR_CLASS(Chat);
STAR_CLASS(ClientCommandProcessor);
STAR_CLASS(OptionsMenu);
STAR_CLASS(WirePane);
STAR_CLASS(ActionBar);
STAR_CLASS(TeamBar);
STAR_CLASS(StatusPane);
STAR_CLASS(ContainerPane);
STAR_CLASS(CraftingPane);
STAR_CLASS(MerchantPane);
STAR_CLASS(CodexInterface);
STAR_CLASS(SongbookInterface);
STAR_CLASS(QuestLogInterface);
STAR_CLASS(AiInterface);
STAR_CLASS(PopupInterface);
STAR_CLASS(ConfirmationDialog);
STAR_CLASS(JoinRequestDialog);
STAR_CLASS(TeleportDialog);
STAR_CLASS(LabelWidget);
STAR_CLASS(Cinematic);
STAR_CLASS(NameplatePainter);
STAR_CLASS(QuestIndicatorPainter);
STAR_CLASS(RadioMessagePopup);
STAR_CLASS(Quest);
STAR_CLASS(QuestTrackerPane);
STAR_CLASS(ContainerInteractor);
STAR_CLASS(ScriptPane);
STAR_CLASS(ChatBubbleManager);
STAR_CLASS(CanvasWidget);
2023-06-20 04:33:09 +00:00
STAR_STRUCT(GuiMessage);
STAR_CLASS(MainInterface);
struct GuiMessage {
GuiMessage();
2023-07-17 12:20:39 +00:00
GuiMessage(String const& message, float cooldown, float spring = 0);
2023-06-20 04:33:09 +00:00
String message;
float cooldown;
float springState;
};
class MainInterface {
public:
enum RunningState {
Running,
ReturnToTitle
};
MainInterface(UniverseClientPtr client, WorldPainterPtr painter, CinematicPtr cinematicOverlay);
~MainInterface();
RunningState currentState() const;
MainInterfacePaneManager* paneManager();
bool escapeDialogOpen() const;
void openCraftingWindow(Json const& config, EntityId sourceEntityId = NullEntityId);
void openMerchantWindow(Json const& config, EntityId sourceEntityId = NullEntityId);
void togglePlainCraftingWindow();
bool windowsOpen() const;
MerchantPanePtr activeMerchantPane() const;
// Return true if this event was consumed or should be handled elsewhere.
bool handleInputEvent(InputEvent const& event);
// Return true if mouse / keyboard events are currently locked here
bool inputFocus() const;
// If input is focused, should MainInterface also accept text input events?
bool textInputActive() const;
void handleInteractAction(InteractAction interactAction);
2024-03-15 05:26:12 +00:00
void preUpdate(float dt);
2023-06-20 04:33:09 +00:00
// Handles incoming client messages, aims main player, etc.
void update(float dt);
2023-06-20 04:33:09 +00:00
// Render things e.g. quest indicators that should be drawn in the world
// behind interface e.g. chat bubbles
void renderInWorldElements();
void render();
Vec2F cursorWorldPosition() const;
bool isDebugDisplayed();
void doChat(String const& chat, bool addToHistory);
2023-07-17 12:20:39 +00:00
void queueMessage(String const& message, Maybe<float> cooldown, float spring);
2023-06-20 04:33:09 +00:00
void queueMessage(String const& message);
2023-07-17 12:20:39 +00:00
2023-06-20 04:33:09 +00:00
void queueItemPickupText(ItemPtr const& item);
void queueJoinRequest(pair<String, RpcPromiseKeeper<P2PJoinRequestReply>> request);
bool fixedCamera() const;
bool hudVisible() const;
void setHudVisible(bool visible = true);
2023-06-20 04:33:09 +00:00
void warpToOrbitedWorld(bool deploy = false);
void warpToOwnShip();
void warpTo(WarpAction const& warpAction);
CanvasWidgetPtr fetchCanvas(String const& canvasName, bool ignoreInterfaceScale = false);
ClientCommandProcessorPtr commandProcessor() const;
2023-07-28 16:12:03 +00:00
struct ScriptPaneInfo {
ScriptPanePtr scriptPane;
Json config;
EntityId sourceEntityId;
bool visible;
Vec2I position;
};
void takeScriptPanes(List<ScriptPaneInfo>& out);
void reviveScriptPanes(List<ScriptPaneInfo>& panes);
2023-06-20 04:33:09 +00:00
private:
PanePtr createEscapeDialog();
float interfaceScale() const;
unsigned windowHeight() const;
unsigned windowWidth() const;
Vec2I mainBarPosition() const;
void renderBreath();
void renderMessages();
void renderMonsterHealthBar();
void renderSpecialDamageBar();
void renderMainBar();
void renderWindows();
void renderDebug();
void updateCursor();
void renderCursor();
bool overButton(PolyI buttonPoly, Vec2I const& mousePos) const;
2023-07-02 07:19:54 +00:00
bool overlayClick(Vec2I const& mousePos, MouseButton mouseButton);
2023-06-20 04:33:09 +00:00
2023-07-28 16:12:03 +00:00
void displayScriptPane(ScriptPanePtr& scriptPane, EntityId sourceEntity);
GuiContext* m_guiContext{nullptr};
2023-06-20 04:33:09 +00:00
MainInterfaceConfigConstPtr m_config;
InterfaceCursor m_cursor;
RunningState m_state{Running};
2023-06-20 04:33:09 +00:00
UniverseClientPtr m_client;
WorldPainterPtr m_worldPainter;
CinematicPtr m_cinematicOverlay;
MainInterfacePaneManager m_paneManager;
QuestLogInterfacePtr m_questLogInterface;
InventoryPanePtr m_inventoryWindow;
CraftingPanePtr m_plainCraftingWindow;
CraftingPanePtr m_craftingWindow;
MerchantPanePtr m_merchantWindow;
CodexInterfacePtr m_codexInterface;
OptionsMenuPtr m_optionsMenu;
ContainerPanePtr m_containerPane;
PopupInterfacePtr m_popupInterface;
ConfirmationDialogPtr m_confirmationDialog;
JoinRequestDialogPtr m_joinRequestDialog;
TeleportDialogPtr m_teleportDialog;
QuestTrackerPanePtr m_questTracker;
ScriptPanePtr m_mmUpgrade;
ScriptPanePtr m_collections;
Map<EntityId, PanePtr> m_interactionScriptPanes;
StringMap<CanvasWidgetPtr> m_canvases;
2023-06-20 04:33:09 +00:00
ChatPtr m_chat;
ClientCommandProcessorPtr m_clientCommandProcessor;
RadioMessagePopupPtr m_radioMessagePopup;
WirePanePtr m_wireInterface;
ActionBarPtr m_actionBar;
Vec2I m_cursorScreenPos{};
2023-06-20 04:33:09 +00:00
ItemSlotWidgetPtr m_cursorItem;
Maybe<String> m_cursorTooltip;
LabelWidgetPtr m_planetText;
GameTimer m_planetNameTimer;
GameTimer m_debugSpatialClearTimer;
GameTimer m_debugMapClearTimer;
RectF m_debugTextRect{RectF::null()};
2023-06-20 04:33:09 +00:00
NameplatePainterPtr m_nameplatePainter;
QuestIndicatorPainterPtr m_questIndicatorPainter;
ChatBubbleManagerPtr m_chatBubbleManager;
bool m_disableHud = false;
2023-06-20 04:33:09 +00:00
String m_lastCommand;
LinkedList<GuiMessagePtr> m_messages;
HashMap<ItemDescriptor, std::pair<size_t, GuiMessagePtr>> m_itemDropMessages;
unsigned m_messageOverflow{};
2023-06-20 04:33:09 +00:00
GuiMessagePtr m_overflowMessage;
List<pair<String, RpcPromiseKeeper<P2PJoinRequestReply>>> m_queuedJoinRequests;
EntityId m_lastMouseoverTarget{NullEntityId};
2023-06-20 04:33:09 +00:00
GameTimer m_stickyTargetingTimer;
int m_portraitScale{};
2023-06-20 04:33:09 +00:00
EntityId m_specialDamageBarTarget{NullEntityId};
float m_specialDamageBarValue{};
2023-06-20 04:33:09 +00:00
ContainerInteractorPtr m_containerInteractor;
};
}