Skip to content

Commit

Permalink
Gui screens excluded from engine
Browse files Browse the repository at this point in the history
  • Loading branch information
cvet committed Jan 8, 2025
1 parent 83b89f9 commit 3a31101
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 472 deletions.
249 changes: 47 additions & 202 deletions Source/Client/Client.cpp

Large diffs are not rendered by default.

48 changes: 17 additions & 31 deletions Source/Client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,6 @@ enum class EffectType : uint
Offscreen = 0x40000000,
};

// Screens
constexpr int SCREEN_NONE = 0;
constexpr int SCREEN_LOGIN = 1; // Primary screens
constexpr int SCREEN_GAME = 2;
constexpr int SCREEN_GLOBAL_MAP = 3;
constexpr int SCREEN_WAIT = 4;
constexpr int SCREEN_DIALOG = 6; // Secondary screens
constexpr int SCREEN_TOWN_VIEW = 9;

// Connection reason
constexpr int INIT_NET_REASON_NONE = 0;
constexpr int INIT_NET_REASON_LOGIN = 1;
Expand Down Expand Up @@ -154,8 +145,6 @@ class FOClient : SINGLEPLAYER_VIRTUAL public FOEngineBase, public AnimationResol
void ConsoleMessage(string_view msg);
void AddMessage(int mess_type, string_view msg);
void FormatTags(string& text, CritterView* cr, CritterView* npc, string_view lexems);
void ScreenFadeIn() { ScreenFade(std::chrono::milliseconds {1000}, ucolor {0, 0, 0, 0}, ucolor {0, 0, 0, 255}, false); }
void ScreenFadeOut() { ScreenFade(std::chrono::milliseconds {1000}, ucolor {0, 0, 0, 255}, ucolor {0, 0, 0, 0}, false); }
void ScreenFade(time_duration time, ucolor from_color, ucolor to_color, bool push_back);
void ScreenQuake(int noise, time_duration time);
void ProcessInputEvent(const InputEvent& ev);
Expand All @@ -164,15 +153,6 @@ class FOClient : SINGLEPLAYER_VIRTUAL public FOEngineBase, public AnimationResol
void AnimFree(uint anim_id);
auto AnimGetSpr(uint anim_id) -> Sprite*;

void ShowMainScreen(int new_screen, const map<string, any_t>& params);
auto GetMainScreen() const -> int { return _screenModeMain; }
auto IsMainScreen(int check_screen) const -> bool { return check_screen == _screenModeMain; }
void ShowScreen(int screen, const map<string, any_t>& params);
void HideScreen(int screen);
auto GetActiveScreen(vector<int>* screens) -> int;
auto IsScreenPresent(int screen) -> bool;
void RunScreenScript(bool show, int screen, const map<string, any_t>& params);

void Connect(string_view login, string_view password, int reason);
void Disconnect();
void CritterMoveTo(CritterHexView* cr, variant<tuple<mpos, ipos16>, int> pos_or_dir, uint speed);
Expand All @@ -192,16 +172,20 @@ class FOClient : SINGLEPLAYER_VIRTUAL public FOEngineBase, public AnimationResol
///@ ExportEvent
ENTITY_EVENT(OnAutoLogin, string /*login*/, string /*password*/);
///@ ExportEvent
ENTITY_EVENT(OnConnecting);
///@ ExportEvent
ENTITY_EVENT(OnConnectingFailed);
///@ ExportEvent
ENTITY_EVENT(OnConnected);
///@ ExportEvent
ENTITY_EVENT(OnDisconnected);
///@ ExportEvent
ENTITY_EVENT(OnRegistrationSuccess);
///@ ExportEvent
ENTITY_EVENT(OnLoginSuccess);
///@ ExportEvent
ENTITY_EVENT(OnLoop);
///@ ExportEvent
ENTITY_EVENT(OnGetActiveScreens, vector<int>& /*screens*/);
///@ ExportEvent
ENTITY_EVENT(OnScreenChange, bool /*show*/, int /*screen*/, map<string, any_t> /*data*/);
///@ ExportEvent
ENTITY_EVENT(OnScreenScroll, ipos /*offsetPos*/);
///@ ExportEvent
ENTITY_EVENT(OnRenderIface);
Expand Down Expand Up @@ -242,6 +226,8 @@ class FOClient : SINGLEPLAYER_VIRTUAL public FOEngineBase, public AnimationResol
///@ ExportEvent
ENTITY_EVENT(OnMapLoad);
///@ ExportEvent
ENTITY_EVENT(OnMapLoaded);
///@ ExportEvent
ENTITY_EVENT(OnMapUnload);
///@ ExportEvent
ENTITY_EVENT(OnReceiveItems, vector<ItemView*> /*items*/, any_t /*contextParam*/);
Expand All @@ -265,6 +251,10 @@ class FOClient : SINGLEPLAYER_VIRTUAL public FOEngineBase, public AnimationResol
ENTITY_EVENT(OnCritterAnimationFallout, hstring /*modelName*/, CritterStateAnim /*stateAnim*/, CritterActionAnim /*actionAnim*/, uint& /*fStateAnim*/, uint& /*fActionAnim*/, uint& /*fStateAnimEx*/, uint& /*fActionAnimEx*/, uint& /*flags*/);
///@ ExportEvent
ENTITY_EVENT(OnScreenSizeChanged);
///@ ExportEvent
ENTITY_EVENT(OnDialogData, ident_t /*talkerId*/, hstring /*dialogId*/, string /*text*/, vector<string> /*answers*/, tick_t /*dialogTime*/);
///@ ExportEvent
ENTITY_EVENT(OnMapView, mpos /*hex*/);

EffectManager EffectMngr;
SpriteManager SprMngr;
Expand Down Expand Up @@ -309,13 +299,12 @@ class FOClient : SINGLEPLAYER_VIRTUAL public FOEngineBase, public AnimationResol

void TryAutoLogin();
void FlashGameWindow();
void WaitDraw();
void CleanupSpriteCache();
void DestroyInnerEntities();

void ProcessInputEvents();
void ProcessScreenEffectFading();
void ProcessScreenEffectQuake();
void ProcessScreenEffectFading(); // Todo: move screen fading to scripts
void ProcessScreenEffectQuake(); // Todo: move screen quake effect to scripts
void ProcessVideo();

void UnloadMap();
Expand Down Expand Up @@ -415,6 +404,7 @@ class FOClient : SINGLEPLAYER_VIRTUAL public FOEngineBase, public AnimationResol

hstring _curMapLocPid {};
uint _curMapIndexInLoc {};
bool _mapLoaded {};

int _initNetReason {INIT_NET_REASON_NONE};

Expand All @@ -438,10 +428,6 @@ class FOClient : SINGLEPLAYER_VIRTUAL public FOEngineBase, public AnimationResol
float _quakeScreenOffsStep {};
time_point _quakeScreenOffsNextTime {};

int _screenModeMain {SCREEN_WAIT};

shared_ptr<Sprite> _waitPic {};

vector<PrimitivePoint> _lmapPrepPix {};
IRect _lmapWMap {};
int _lmapZoom {2};
Expand Down
31 changes: 0 additions & 31 deletions Source/Client/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ void ResourceManager::IndexFiles()
{
STACK_TRACE_ENTRY();

for (const auto* splash_ext : {"rix", "png", "jpg"}) {
auto splashes = _resources.FilterFiles(splash_ext, "Splash/", true);
while (splashes.MoveNext()) {
auto file_header = splashes.GetCurFileHeader();
if (std::find(_splashNames.begin(), _splashNames.end(), file_header.GetPath()) == _splashNames.end()) {
_splashNames.emplace_back(file_header.GetPath());
}
}
}

for (const auto* sound_ext : {"wav", "acm", "ogg"}) {
auto sounds = _resources.FilterFiles(sound_ext);
while (sounds.MoveNext()) {
Expand Down Expand Up @@ -607,27 +597,6 @@ auto ResourceManager::GetCritterPreviewModelSpr(hstring model_name, CritterState
}
#endif

auto ResourceManager::GetRandomSplash() -> shared_ptr<Sprite>
{
STACK_TRACE_ENTRY();

NON_CONST_METHOD_HINT();

if (_splashNames.empty()) {
return nullptr;
}

const auto rnd = GenericUtils::Random(0, static_cast<int>(_splashNames.size()) - 1);

auto&& splash = _sprMngr.LoadSprite(_splashNames[rnd], AtlasType::OneImage);

if (splash) {
splash->PlayDefault();
}

return splash;
}

auto ResourceManager::GetSoundNames() const -> const map<string, string>&
{
STACK_TRACE_ENTRY();
Expand Down
2 changes: 0 additions & 2 deletions Source/Client/ResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class ResourceManager final
[[nodiscard]] auto GetCritterAnimFrames(hstring model_name, CritterStateAnim state_anim, CritterActionAnim action_anim, uint8 dir) -> const SpriteSheet*;
[[nodiscard]] auto GetCritterDummyFrames() -> const SpriteSheet*;
[[nodiscard]] auto GetCritterPreviewSpr(hstring model_name, CritterStateAnim state_anim, CritterActionAnim action_anim, uint8 dir, const int* layers3d) -> const Sprite*;
[[nodiscard]] auto GetRandomSplash() -> shared_ptr<Sprite>;
[[nodiscard]] auto GetSoundNames() const -> const map<string, string>&;

void IndexFiles();
Expand All @@ -77,7 +76,6 @@ class ResourceManager final
unordered_map<uint, shared_ptr<SpriteSheet>> _critterFrames {};
shared_ptr<SpriteSheet> _critterDummyAnimFrames {};
shared_ptr<Sprite> _itemHexDummyAnim {};
vector<string> _splashNames {};
map<string, string> _soundNames {};
bool _nonConstHelper {};
#if FO_ENABLE_3D
Expand Down
10 changes: 0 additions & 10 deletions Source/Scripting/AngelScript/ClientCore.fos
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ namespace ClientCore // Sort -9
#define FT_SKIPLINES #(l)(0x0400 | ((l) << 16))
#define FT_SKIPLINES_END #(l)(0x0800 | ((l) << 16))

// Client screen types
#define CLIENT_SCREEN_NONE (0)
#define CLIENT_MAIN_SCREEN_LOGIN (1)
#define CLIENT_MAIN_SCREEN_GAME (2)
#define CLIENT_MAIN_SCREEN_GLOBAL_MAP (3)
#define CLIENT_MAIN_SCREEN_WAIT (4)
#define CLIENT_SCREEN_CURSOR (5)
#define CLIENT_SCREEN_DIALOG (6)
#define CLIENT_SCREEN_TOWN_VIEW (9)

// Draw primitive types
#define DRAW_PRIMITIVE_POINTLIST (0)
#define DRAW_PRIMITIVE_LINELIST (1)
Expand Down
Loading

0 comments on commit 3a31101

Please sign in to comment.