Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP, DO NOT MERGE) Replay drag n drop #286

Merged
merged 25 commits into from
Sep 19, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .gitignore
Binary file not shown.
1 change: 1 addition & 0 deletions _RELEASE/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"player_speed" : 9.449999809265137,
"pulse_enabled" : true,
"rotate_to_start" : true,
"save_local_best_replay_to_file" : true,
"server_local" : true,
"server_verbose" : true,
"show_fps" : true,
Expand Down
2 changes: 0 additions & 2 deletions include/SSVOpenHexagon/Core/Discord.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#pragma once

#include "SSVOpenHexagon/Global/Common.hpp"

#include "discord/discord.h"

#include <string_view>
Expand Down
25 changes: 23 additions & 2 deletions include/SSVOpenHexagon/Core/HexagonGame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#pragma once

#include "SSVOpenHexagon/Global/Common.hpp"
#include "SSVOpenHexagon/Core/HGStatus.hpp"
#include "SSVOpenHexagon/Core/Steam.hpp"
#include "SSVOpenHexagon/Core/RandomNumberGenerator.hpp"
Expand Down Expand Up @@ -35,6 +34,11 @@
#include <SSVUtils/Core/Common/Frametime.hpp>
#include <SSVUtils/Timeline/Timeline.hpp>

#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>

#include <sstream>
#include <optional>

Expand Down Expand Up @@ -161,6 +165,9 @@ class HexagonGame

Utils::LuaMetadata luaMetadata;

std::string packId;
std::string levelId;

// Lua related methods
void redefineLuaFunctions();
void destroyMaliciousFunctions();
Expand Down Expand Up @@ -238,6 +245,8 @@ class HexagonGame
Utils::runLuaFunctionIfExists<T, TArgs...>(lua, mName, mArgs...)){};
}

void setLastReplay(const replay_file& mReplayFile);

private:
void start();

Expand Down Expand Up @@ -283,8 +292,20 @@ class HexagonGame
void addMessage(std::string mMessage, double mDuration, bool mSoundToggle);
void clearMessages();

enum class CheckSaveScoreResult
{
Ineligible,
Invalid,
Local_NewBest,
Local_NoNewBest,
Online_LessThan8Secs,
Online_ConnectionError,
Online_VersionMismatch,
Online_Sent
};

// Level/menu loading/unloading/changing
void checkAndSaveScore();
CheckSaveScoreResult checkAndSaveScore();
void goToMenu(bool mSendScores = true, bool mError = false);

void invalidateScore(const std::string& mReason);
Expand Down
15 changes: 7 additions & 8 deletions include/SSVOpenHexagon/Core/MenuGame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include "SSVOpenHexagon/Core/Steam.hpp"

#include "SSVOpenHexagon/Core/HexagonDialogBox.hpp"
#include "SSVOpenHexagon/Global/Common.hpp"
#include "SSVOpenHexagon/Data/LevelData.hpp"
Expand All @@ -22,6 +23,11 @@

#include <SSVUtils/Core/Common/Frametime.hpp>

#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>

#include <cctype>

namespace hg
Expand All @@ -30,12 +36,7 @@ namespace hg
enum class States
{
EpilepsyWarning,
ETUser,
ETPass,
ETEmail,
ETLPNew,
ETFriend,
SLogging,
SMain,
SLPSelect,
MWlcm,
Expand Down Expand Up @@ -218,9 +219,7 @@ class MenuGame

[[nodiscard]] bool isEnteringText()
{
return state == States::ETUser || state == States::ETPass ||
state == States::ETEmail || state == States::ETLPNew ||
state == States::ETFriend;
return state == States::ETLPNew;
}

[[nodiscard]] ssvms::Menu* getCurrentMenu() noexcept
Expand Down
13 changes: 8 additions & 5 deletions include/SSVOpenHexagon/Core/Replay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ class replay_data
[[nodiscard]] bool operator!=(const replay_data& rhs) const noexcept;

[[nodiscard]] serialization_result serialize(
std::byte* buffer, const std::size_t buffer_size);
std::byte* buffer, const std::size_t buffer_size) const;

[[nodiscard]] deserialization_result deserialize(
const std::byte* buffer, const std::size_t buffer_size);

[[nodiscard]] serialization_result serialize(
std::byte* buffer, const std::byte* const buffer_end);
std::byte* buffer, const std::byte* const buffer_end) const;

[[nodiscard]] deserialization_result deserialize(
const std::byte* buffer, const std::byte* const buffer_end);
Expand All @@ -101,6 +101,7 @@ class replay_player

[[nodiscard]] input_bitset get_current_and_move_forward() noexcept;
[[nodiscard]] bool done() const noexcept;
void reset() noexcept;
};

struct replay_file
Expand All @@ -121,19 +122,21 @@ struct replay_file
[[nodiscard]] bool operator!=(const replay_file& rhs) const noexcept;

[[nodiscard]] serialization_result serialize(
std::byte* buffer, const std::size_t buffer_size);
std::byte* buffer, const std::size_t buffer_size) const;

[[nodiscard]] deserialization_result deserialize(
const std::byte* buffer, const std::size_t buffer_size);

[[nodiscard]] serialization_result serialize(
std::byte* buffer, const std::byte* const buffer_end);
std::byte* buffer, const std::byte* const buffer_end) const;

[[nodiscard]] deserialization_result deserialize(
const std::byte* buffer, const std::byte* const buffer_end);

[[nodiscard]] bool serialize_to_file(const std::filesystem::path p);
[[nodiscard]] bool serialize_to_file(const std::filesystem::path p) const;
[[nodiscard]] bool deserialize_from_file(const std::filesystem::path p);

[[nodiscard]] std::string create_filename() const;
};

} // namespace hg
4 changes: 2 additions & 2 deletions include/SSVOpenHexagon/Core/Steam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#pragma once

#include "SSVOpenHexagon/Global/Common.hpp"

#include <stdint.h> // Steam API needs this.
#include "steam/steam_api.h"

#include <functional>
#include <string_view>
#include <unordered_set>

Expand Down
1 change: 0 additions & 1 deletion include/SSVOpenHexagon/Data/CapColor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#pragma once

#include "SSVOpenHexagon/Global/Common.hpp"
#include "SSVOpenHexagon/Data/ColorData.hpp"
#include "SSVOpenHexagon/SSVUtilsJson/SSVUtilsJson.hpp"

Expand Down
3 changes: 2 additions & 1 deletion include/SSVOpenHexagon/Data/MusicData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

#pragma once

#include "SSVOpenHexagon/Global/Common.hpp"
#include "SSVOpenHexagon/Global/Config.hpp"
#include "SSVOpenHexagon/Global/Assets.hpp"

#include <SFML/System.hpp>

#include <string>

namespace hg
Expand Down
1 change: 0 additions & 1 deletion include/SSVOpenHexagon/Data/ProfileData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#pragma once

#include "SSVOpenHexagon/Global/Common.hpp"
#include "SSVOpenHexagon/SSVUtilsJson/SSVUtilsJson.hpp"

namespace hg
Expand Down
3 changes: 2 additions & 1 deletion include/SSVOpenHexagon/Data/StyleData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

#pragma once

#include "SSVOpenHexagon/Global/Common.hpp"
#include "SSVOpenHexagon/Data/ColorData.hpp"
#include "SSVOpenHexagon/Data/CapColor.hpp"
#include "SSVOpenHexagon/SSVUtilsJson/SSVUtilsJson.hpp"

#include <SFML/Graphics.hpp>

#include <SSVUtils/Core/FileSystem/FileSystem.hpp>

namespace hg
Expand Down
6 changes: 0 additions & 6 deletions include/SSVOpenHexagon/Data/TrackedVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
#pragma once

#include <string>
#include <utility>

namespace hg
{

struct TrackedVariable
{
std::string variableName, displayName;
TrackedVariable(std::string mVariableName, std::string mDisplayName)
: variableName{std::move(mVariableName)}, displayName{
std::move(mDisplayName)}
{
}
};

} // namespace hg
33 changes: 6 additions & 27 deletions include/SSVOpenHexagon/Global/Assets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@

#pragma once

#include "SSVOpenHexagon/Global/Common.hpp"
#include "SSVOpenHexagon/Data/LevelData.hpp"
#include "SSVOpenHexagon/Data/PackData.hpp"
#include "SSVOpenHexagon/Data/ProfileData.hpp"
#include "SSVOpenHexagon/Data/StyleData.hpp"
#include "SSVOpenHexagon/Online/Online.hpp"
#include "SSVOpenHexagon/Online/OHServer.hpp"

#include <SSVStart/Assets/Assets.hpp>
#include <SSVStart/SoundPlayer/SoundPlayer.hpp>
Expand All @@ -19,6 +16,8 @@
#include <SSVUtils/Core/Assert/Assert.hpp>
#include <SSVUtils/Core/FileSystem/FileSystem.hpp>

#include <SFML/System.hpp>

#include <unordered_map>
#include <map>
#include <vector>
Expand Down Expand Up @@ -72,8 +71,6 @@ class HGAssets
[[nodiscard]] bool loadPackInfo(const PackData& packData);

public:
float playedSeconds{0};

HGAssets(Steam::steam_manager& mSteamManager, bool mLevelsOnly = false);

auto& operator()()
Expand Down Expand Up @@ -183,43 +180,25 @@ class HGAssets

std::string pGetName() const
{
if(!playingLocally)
{
return Online::getCurrentUsername();
}

assert(playingLocally); // TODO
return getCurrentLocalProfile().getName();
}

const std::vector<std::string>& pGetTrackedNames() const
{
if(!playingLocally)
{
return Online::getUserStats().trackedNames;
}

assert(playingLocally); // TODO
return getCurrentLocalProfile().getTrackedNames();
}

void pClearTrackedNames()
{
if(!playingLocally)
{
Online::trySendClearFriends();
return;
}

assert(playingLocally); // TODO
getCurrentLocalProfile().clearTrackedNames();
}

void pAddTrackedName(const std::string& mName)
{
if(!playingLocally)
{
Online::trySendAddFriend(mName);
return;
}

assert(playingLocally); // TODO
getCurrentLocalProfile().addTrackedName(mName);
}

Expand Down
6 changes: 4 additions & 2 deletions include/SSVOpenHexagon/Global/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void setTimescale(float mX);
void setShowKeyIcons(bool mX);
void setKeyIconsScale(float mX);
void setFirstTimePlaying(bool mX);
void setSaveLocalBestReplayToFile(bool mX);

[[nodiscard]] bool getOnline();
[[nodiscard]] bool getOfficial();
Expand All @@ -93,8 +94,8 @@ void setFirstTimePlaying(bool mX);
[[nodiscard]] bool getVsync();
[[nodiscard]] bool getAutoZoomFactor();
[[nodiscard]] bool getFullscreen();
[[nodiscard]] float getVersion();
[[nodiscard]] const char* getVersionString();
[[nodiscard, gnu::const]] float getVersion();
[[nodiscard, gnu::const]] const char* getVersionString();
[[nodiscard]] bool getWindowedAutoResolution();
[[nodiscard]] bool getFullscreenAutoResolution();
[[nodiscard]] unsigned int getFullscreenWidth();
Expand Down Expand Up @@ -134,6 +135,7 @@ void setFirstTimePlaying(bool mX);
[[nodiscard]] bool getShowKeyIcons();
[[nodiscard]] float getKeyIconsScale();
[[nodiscard]] bool getFirstTimePlaying();
[[nodiscard]] bool getSaveLocalBestReplayToFile();

[[nodiscard]] ssvs::Input::Trigger getTriggerRotateCCW();
[[nodiscard]] ssvs::Input::Trigger getTriggerRotateCW();
Expand Down
29 changes: 0 additions & 29 deletions include/SSVOpenHexagon/Online/Client.hpp

This file was deleted.

Loading