122 lines
3.1 KiB
C++
122 lines
3.1 KiB
C++
#pragma once
|
|
|
|
#include "StarUniverseServer.hpp"
|
|
#include "StarUniverseClient.hpp"
|
|
#include "StarWorldPainter.hpp"
|
|
#include "StarGameTypes.hpp"
|
|
#include "StarMainInterface.hpp"
|
|
#include "StarMainMixer.hpp"
|
|
#include "StarTitleScreen.hpp"
|
|
#include "StarErrorScreen.hpp"
|
|
#include "StarCinematic.hpp"
|
|
#include "StarKeyBindings.hpp"
|
|
#include "StarMainApplication.hpp"
|
|
|
|
namespace Star {
|
|
|
|
STAR_CLASS(Input);
|
|
STAR_CLASS(Voice);
|
|
|
|
class ClientApplication : public Application {
|
|
protected:
|
|
virtual void startup(StringList const& cmdLineArgs) override;
|
|
virtual void shutdown() override;
|
|
|
|
virtual void applicationInit(ApplicationControllerPtr appController) override;
|
|
virtual void renderInit(RendererPtr renderer) override;
|
|
|
|
virtual void windowChanged(WindowMode windowMode, Vec2U screenSize) override;
|
|
|
|
virtual void processInput(InputEvent const& event) override;
|
|
|
|
virtual void update() override;
|
|
virtual void render() override;
|
|
|
|
virtual void getAudioData(int16_t* stream, size_t len) override;
|
|
|
|
private:
|
|
enum class MainAppState {
|
|
Quit,
|
|
Startup,
|
|
Mods,
|
|
ModsWarning,
|
|
Splash,
|
|
Error,
|
|
Title,
|
|
SinglePlayer,
|
|
MultiPlayer
|
|
};
|
|
|
|
struct PendingMultiPlayerConnection {
|
|
Variant<P2PNetworkingPeerId, HostAddressWithPort> server;
|
|
String account;
|
|
String password;
|
|
};
|
|
|
|
void changeState(MainAppState newState);
|
|
void setError(String const& error);
|
|
void setError(String const& error, std::exception const& e);
|
|
|
|
void updateMods(float dt);
|
|
void updateModsWarning(float dt);
|
|
void updateSplash(float dt);
|
|
void updateError(float dt);
|
|
void updateTitle(float dt);
|
|
void updateRunning(float dt);
|
|
|
|
bool isActionTaken(InterfaceAction action) const;
|
|
bool isActionTakenEdge(InterfaceAction action) const;
|
|
|
|
void updateCamera(float dt);
|
|
|
|
RootUPtr m_root;
|
|
ThreadFunction<void> m_rootLoader;
|
|
MainAppState m_state = MainAppState::Startup;
|
|
|
|
// Valid after applicationInit is called
|
|
MainMixerPtr m_mainMixer;
|
|
GuiContextPtr m_guiContext;
|
|
InputPtr m_input;
|
|
VoicePtr m_voice;
|
|
|
|
// Valid after renderInit is called the first time
|
|
CinematicPtr m_cinematicOverlay;
|
|
ErrorScreenPtr m_errorScreen;
|
|
|
|
// Valid if main app state >= Title
|
|
PlayerStoragePtr m_playerStorage;
|
|
StatisticsPtr m_statistics;
|
|
UniverseClientPtr m_universeClient;
|
|
TitleScreenPtr m_titleScreen;
|
|
|
|
// Valid if main app state > Title
|
|
PlayerPtr m_player;
|
|
WorldPainterPtr m_worldPainter;
|
|
WorldRenderData m_renderData;
|
|
MainInterfacePtr m_mainInterface;
|
|
|
|
// Valid if main app state == SinglePlayer
|
|
UniverseServerPtr m_universeServer;
|
|
|
|
float m_cameraXOffset = 0.0f;
|
|
float m_cameraYOffset = 0.0f;
|
|
bool m_snapBackCameraOffset = false;
|
|
int m_cameraOffsetDownTicks = 0;
|
|
Vec2F m_cameraPositionSmoother;
|
|
Vec2F m_cameraSmoothDelta;
|
|
|
|
int m_minInterfaceScale = 2;
|
|
int m_maxInterfaceScale = 3;
|
|
Vec2F m_crossoverRes;
|
|
|
|
Vec2F m_controllerLeftStick;
|
|
Vec2F m_controllerRightStick;
|
|
List<KeyDownEvent> m_heldKeyEvents;
|
|
List<KeyDownEvent> m_edgeKeyEvents;
|
|
|
|
Maybe<PendingMultiPlayerConnection> m_pendingMultiPlayerConnection;
|
|
Maybe<HostAddressWithPort> m_currentRemoteJoin;
|
|
};
|
|
|
|
}
|