mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-25 19:46:50 -05:00
Moved more common stuff into the common project.
This commit is contained in:
parent
ba96135e01
commit
5ab92737ec
@ -33,6 +33,9 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "")
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
# Import the actual projects -------------------------------------------------------------------------------------------
|
||||
add_subdirectory(OpenDiablo2.Common)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/OpenDiablo2.Common/include)
|
||||
|
||||
add_subdirectory(OpenDiablo2.SDL2)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/OpenDiablo2.SDL2/include)
|
||||
|
||||
|
31
src/OpenDiablo2.Common/CMakeLists.txt
Normal file
31
src/OpenDiablo2.Common/CMakeLists.txt
Normal file
@ -0,0 +1,31 @@
|
||||
project(OpenDiablo2.Common VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
set (SOURCES
|
||||
src/D2Sprite.cpp
|
||||
src/D2DataManager.cpp
|
||||
)
|
||||
|
||||
set (HEADERS
|
||||
include/OpenDiablo2.Common/D2EngineConfig.h
|
||||
include/OpenDiablo2.Common/D2DataManager.h
|
||||
include/OpenDiablo2.Common/D2Palette.h
|
||||
include/OpenDiablo2.Common/D2Point.h
|
||||
include/OpenDiablo2.Common/D2ResourcePath.h
|
||||
include/OpenDiablo2.Common/D2Size.h
|
||||
include/OpenDiablo2.Common/D2Sprite.h
|
||||
)
|
||||
|
||||
add_library(OpenDiablo2.Common SHARED ${SOURCES} ${HEADERS})
|
||||
|
||||
target_include_directories(OpenDiablo2.Common
|
||||
PUBLIC
|
||||
include
|
||||
PRIVATE
|
||||
include
|
||||
../ExtraUtils
|
||||
)
|
||||
|
||||
|
||||
set_target_properties(OpenDiablo2.Common PROPERTIES
|
||||
CXX_STANDARD 17
|
||||
)
|
@ -1,12 +1,12 @@
|
||||
#ifndef OPENDIABLO2_GAME_D2DATAMANAGER_H
|
||||
#define OPENDIABLO2_GAME_D2DATAMANAGER_H
|
||||
#ifndef OPENDIABLO2_COMMON_D2DATAMANAGER_H
|
||||
#define OPENDIABLO2_COMMON_D2DATAMANAGER_H
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <OpenDiablo2.Game/D2EngineConfig.h>
|
||||
#include <OpenDiablo2.Common/D2EngineConfig.h>
|
||||
|
||||
namespace OpenDiablo2::Game {
|
||||
namespace OpenDiablo2::Common {
|
||||
|
||||
class D2DataManager {
|
||||
public:
|
||||
@ -18,4 +18,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // OPENDIABLO2_GAME_D2DATAMANAGER_H
|
||||
#endif // OPENDIABLO2_COMMON_D2DATAMANAGER_H
|
@ -0,0 +1,16 @@
|
||||
#ifndef OPENDIABLO2_COMMON_D2ENGINECONFIG_H
|
||||
#define OPENDIABLO2_COMMON_D2ENGINECONFIG_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OpenDiablo2::Common
|
||||
{
|
||||
|
||||
struct D2EngineConfig
|
||||
{
|
||||
std::string BasePath; // The base path where the MPQ files are located
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //OPENDIABLO2_COMMON_D2ENGINECONFIG_H
|
@ -1,9 +1,9 @@
|
||||
#ifndef OPENDIABLO2_GAME_COMMON_D2PALETTE_H
|
||||
#define OPENDIABLO2_GAME_COMMON_D2PALETTE_H
|
||||
#ifndef OPENDIABLO2_COMMON_D2PALETTE_H
|
||||
#define OPENDIABLO2_COMMON_D2PALETTE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OpenDiablo2::Game::Common {
|
||||
namespace OpenDiablo2::Common {
|
||||
class D2Palette {
|
||||
public:
|
||||
typedef std::string Entry;
|
||||
@ -52,4 +52,4 @@ const D2Palette::Entry D2Palette::Units = "Units";
|
||||
|
||||
}
|
||||
|
||||
#endif // OPENDIABLO2_GAME_COMMON_PALETTE_H
|
||||
#endif // OPENDIABLO2_COMMON_D2PALETTE_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef OPENDIABLO2_GAME_COMMON_D2POINT_H
|
||||
#define OPENDIABLO2_GAME_COMMON_D2POINT_H
|
||||
#ifndef OPENDIABLO2_COMMON_D2POINT_H
|
||||
#define OPENDIABLO2_COMMON_D2POINT_H
|
||||
|
||||
namespace OpenDiablo2::Game::Common {
|
||||
namespace OpenDiablo2::Common {
|
||||
|
||||
struct D2Point {
|
||||
int X;
|
||||
@ -10,4 +10,4 @@ struct D2Point {
|
||||
|
||||
}
|
||||
|
||||
#endif // OPENDIABLO2_GAME_COMMON_D2POINT_H
|
||||
#endif // OPENDIABLO2_COMMON_D2POINT_H
|
||||
|
@ -1,9 +1,9 @@
|
||||
#ifndef OPENDIABLO2_GAME_COMMON_D2RESOURCEPATH_H
|
||||
#define OPENDIABLO2_GAME_COMMON_D2RESOURCEPATH_H
|
||||
#ifndef OPENDIABLO2_COMMON_D2RESOURCEPATH_H
|
||||
#define OPENDIABLO2_COMMON_D2RESOURCEPATH_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OpenDiablo2::Game::Common {
|
||||
namespace OpenDiablo2::Common {
|
||||
|
||||
class D2ResourcePath {
|
||||
public:
|
||||
@ -464,4 +464,4 @@ const std::string D2ResourcePath::Missiles = "data\\global\\excel\\missiles.txt"
|
||||
|
||||
}
|
||||
|
||||
#endif // OPENDIABLO2_GAME_COMMON_D2RESOURCEPATH_H
|
||||
#endif // OPENDIABLO2_COMMON_D2RESOURCEPATH_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef OPENDIABLO2_GAME_COMMON_D2SIZE_H
|
||||
#define OPENDIABLO2_GAME_COMMON_D2SIZE_H
|
||||
#ifndef OPENDIABLO2_COMMON_D2SIZE_H
|
||||
#define OPENDIABLO2_COMMON_D2SIZE_H
|
||||
|
||||
namespace OpenDiablo2::Game::Common {
|
||||
namespace OpenDiablo2::Common {
|
||||
|
||||
struct D2Size {
|
||||
int Width;
|
||||
@ -10,4 +10,4 @@ struct D2Size {
|
||||
|
||||
}
|
||||
|
||||
#endif // OPENDIABLO2_GAME_COMMON_D2SIZE_H
|
||||
#endif // OPENDIABLO2_COMMON_D2SIZE_H
|
||||
|
28
src/OpenDiablo2.Common/include/OpenDiablo2.Common/D2Sprite.h
Normal file
28
src/OpenDiablo2.Common/include/OpenDiablo2.Common/D2Sprite.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef OPENDIABLO2_COMMON_D2SPRITE_H
|
||||
#define OPENDIABLO2_COMMON_D2SPRITE_H
|
||||
|
||||
#include <OpenDiablo2.Common/D2Palette.h>
|
||||
#include <OpenDiablo2.Common/D2Point.h>
|
||||
#include <OpenDiablo2.Common/D2Size.h>
|
||||
|
||||
namespace OpenDiablo2::Common {
|
||||
|
||||
class D2Sprite {
|
||||
public:
|
||||
D2Sprite();
|
||||
D2Sprite(std::string resourcePath, std::string palette, D2Point location, bool cacheFrames = false);
|
||||
D2Sprite(std::string resourcePath, std::string palette, bool cacheFrames = false);
|
||||
|
||||
int Frame;
|
||||
int TotalFrames;
|
||||
bool Blend;
|
||||
bool Darken;
|
||||
D2Point Location;
|
||||
D2Size FrameSize;
|
||||
D2Size LocalFrameSize;
|
||||
D2Palette::Entry CurrentPalette;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OPENDIABLO2_COMMON_D2SPRITE_H
|
@ -1,11 +1,11 @@
|
||||
#include <experimental/filesystem>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <StormLib.h>
|
||||
#include <OpenDiablo2.Game/D2DataManager.h>
|
||||
#include <OpenDiablo2.Common/D2DataManager.h>
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
OpenDiablo2::Game::D2DataManager::D2DataManager(
|
||||
OpenDiablo2::Common::D2DataManager::D2DataManager(
|
||||
const D2EngineConfig &engineConfig)
|
||||
: fileEntries()
|
||||
{
|
40
src/OpenDiablo2.Common/src/D2Sprite.cpp
Normal file
40
src/OpenDiablo2.Common/src/D2Sprite.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include <OpenDiablo2.Common/D2Sprite.h>
|
||||
#include <OpenDiablo2.Common/D2Palette.h>
|
||||
|
||||
OpenDiablo2::Common::D2Sprite::D2Sprite()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OpenDiablo2::Common::D2Sprite::D2Sprite(
|
||||
std::string resourcePath,
|
||||
std::string palette,
|
||||
bool cacheFrames)
|
||||
: Frame (0)
|
||||
, TotalFrames (0)
|
||||
, Blend (false)
|
||||
, Darken (false)
|
||||
, Location (D2Point {0, 0})
|
||||
, FrameSize (D2Size {0, 0})
|
||||
, LocalFrameSize (D2Size {0, 0})
|
||||
, CurrentPalette (palette)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OpenDiablo2::Common::D2Sprite::D2Sprite(
|
||||
std::string resourcePath,
|
||||
std::string palette,
|
||||
D2Point location,
|
||||
bool cacheFrames)
|
||||
: Frame (0)
|
||||
, TotalFrames (0)
|
||||
, Blend (false)
|
||||
, Darken (false)
|
||||
, Location (location)
|
||||
, FrameSize (D2Size {0, 0})
|
||||
, LocalFrameSize (D2Size {0, 0})
|
||||
, CurrentPalette (palette)
|
||||
{
|
||||
|
||||
}
|
@ -1,14 +1,11 @@
|
||||
set (SOURCES
|
||||
src/main.cpp
|
||||
src/D2DataManager.cpp
|
||||
src/D2Engine.cpp
|
||||
src/Scenes/D2MainMenu.cpp
|
||||
)
|
||||
|
||||
set (HEADERS
|
||||
include/OpenDiablo2.Game/D2DataManager.h
|
||||
include/OpenDiablo2.Game/D2Engine.h
|
||||
include/OpenDiablo2.Game/D2EngineConfig.h
|
||||
include/OpenDiablo2.Game/Scenes/D2Scene.h
|
||||
include/OpenDiablo2.Game/Scenes/D2MainMenu.h
|
||||
)
|
||||
@ -25,6 +22,7 @@ include_directories(OpenDiablo2.Game
|
||||
|
||||
target_link_libraries(OpenDiablo2.Game
|
||||
OpenDiablo2.SDL2
|
||||
OpenDiablo2.Common
|
||||
storm
|
||||
stdc++fs
|
||||
)
|
||||
|
@ -3,11 +3,11 @@
|
||||
|
||||
#include <stack>
|
||||
#include <memory>
|
||||
#include <OpenDiablo2.Game/D2DataManager.h>
|
||||
#include <OpenDiablo2.Common/D2DataManager.h>
|
||||
#include <OpenDiablo2.System/D2Graphics.h>
|
||||
#include <OpenDiablo2.System/D2Input.h>
|
||||
#include <OpenDiablo2.Game/Scenes/D2Scene.h>
|
||||
#include "D2EngineConfig.h"
|
||||
#include "OpenDiablo2.Common/D2EngineConfig.h"
|
||||
|
||||
namespace OpenDiablo2::Game
|
||||
{
|
||||
@ -16,18 +16,18 @@ namespace OpenDiablo2::Game
|
||||
class D2Engine : public std::enable_shared_from_this<D2Engine>
|
||||
{
|
||||
public:
|
||||
D2Engine(const D2EngineConfig &config);
|
||||
D2Engine(const Common::D2EngineConfig &config);
|
||||
|
||||
// Runs the engine
|
||||
void Run();
|
||||
|
||||
OpenDiablo2::Game::D2DataManager::Ptr dataManager;
|
||||
OpenDiablo2::Common::D2DataManager::Ptr dataManager;
|
||||
OpenDiablo2::System::D2Graphics::Ptr gfx;
|
||||
OpenDiablo2::System::D2Input::Ptr input;
|
||||
|
||||
private:
|
||||
// Represents the engine configuration
|
||||
const D2EngineConfig config;
|
||||
const Common::D2EngineConfig config;
|
||||
|
||||
// Indicates the system should keep running (if set to true)
|
||||
bool isRunning = true;
|
||||
|
@ -1,16 +0,0 @@
|
||||
#ifndef OPENDIABLO2_D2ENGINECONFIG_H
|
||||
#define OPENDIABLO2_D2ENGINECONFIG_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OpenDiablo2::Game
|
||||
{
|
||||
|
||||
struct D2EngineConfig
|
||||
{
|
||||
std::string BasePath; // The base path where the MPQ files are located
|
||||
};
|
||||
|
||||
} // namespace OpenDiablo2::Game
|
||||
|
||||
#endif //OPENDIABLO2_D2ENGINECONFIG_H
|
@ -2,11 +2,11 @@
|
||||
#include <OpenDiablo2.Game/Scenes/D2MainMenu.h>
|
||||
|
||||
OpenDiablo2::Game::D2Engine::D2Engine(
|
||||
const D2EngineConfig &config)
|
||||
const Common::D2EngineConfig &config)
|
||||
: config(config)
|
||||
, gfx(std::make_unique<OpenDiablo2::System::D2Graphics>())
|
||||
, input(std::make_unique<OpenDiablo2::System::D2Input>())
|
||||
, dataManager(std::make_unique<OpenDiablo2::Game::D2DataManager>(config))
|
||||
, dataManager(std::make_unique<OpenDiablo2::Common::D2DataManager>(config))
|
||||
{ }
|
||||
|
||||
void
|
||||
|
@ -17,7 +17,7 @@ main(
|
||||
|
||||
CLI::App app{"OpenDiablo2 - An open source re-implementation of Diablo 2."};
|
||||
|
||||
OpenDiablo2::Game::D2EngineConfig engineConfig;
|
||||
OpenDiablo2::Common::D2EngineConfig engineConfig;
|
||||
engineConfig.BasePath = std::experimental::filesystem::current_path().string();
|
||||
|
||||
app.add_option("-p,--path", engineConfig.BasePath, "The base path for Diablo 2");
|
||||
|
@ -3,7 +3,6 @@ project(OpenDiablo2.SDL2 VERSION 0.1 LANGUAGES CXX)
|
||||
set (SOURCES
|
||||
src/D2Graphics.cpp
|
||||
src/D2Input.cpp
|
||||
src/D2Sprite.cpp
|
||||
)
|
||||
|
||||
set (HEADERS
|
||||
@ -27,6 +26,7 @@ target_include_directories(OpenDiablo2.SDL2
|
||||
)
|
||||
|
||||
target_link_libraries(OpenDiablo2.SDL2
|
||||
OpenDiablo2.Common
|
||||
${SDL2_LIBRARY}
|
||||
)
|
||||
|
||||
|
@ -1,30 +0,0 @@
|
||||
#ifndef OPENDIABLO2_SYSTEM_D2SPRITE_H
|
||||
#define OPENDIABLO2_SYSTEM_D2SPRITE_H
|
||||
|
||||
#include <OpenDiablo2.Common/D2Palette.h>
|
||||
#include <OpenDiablo2.Common/D2Point.h>
|
||||
#include <OpenDiablo2.Common/D2Size.h>
|
||||
|
||||
namespace OpenDiablo2::System {
|
||||
|
||||
class D2Sprite {
|
||||
public:
|
||||
D2Sprite();
|
||||
D2Sprite(std::string resourcePath, std::string palette, Game::Common::D2Point location, bool cacheFrames = false);
|
||||
D2Sprite(std::string resourcePath, std::string palette, bool cacheFrames = false);
|
||||
|
||||
int Frame;
|
||||
int TotalFrames;
|
||||
bool Blend;
|
||||
bool Darken;
|
||||
OpenDiablo2::Game::Common::D2Point Location;
|
||||
OpenDiablo2::Game::Common::D2Size FrameSize;
|
||||
OpenDiablo2::Game::Common::D2Size LocalFrameSize;
|
||||
OpenDiablo2::Game::Common::D2Palette::Entry CurrentPalette;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OPENDIABLO2_SYSTEM_D2SPRITE_H
|
@ -1,40 +0,0 @@
|
||||
#include <OpenDiablo2.System/D2Sprite.h>
|
||||
#include <OpenDiablo2.Common/D2Palette.h>
|
||||
|
||||
OpenDiablo2::System::D2Sprite::D2Sprite()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OpenDiablo2::System::D2Sprite::D2Sprite(
|
||||
std::string resourcePath,
|
||||
std::string palette,
|
||||
bool cacheFrames)
|
||||
: Frame (0)
|
||||
, TotalFrames (0)
|
||||
, Blend (false)
|
||||
, Darken (false)
|
||||
, Location (OpenDiablo2::Game::Common::D2Point {0, 0})
|
||||
, FrameSize (OpenDiablo2::Game::Common::D2Size {0, 0})
|
||||
, LocalFrameSize (OpenDiablo2::Game::Common::D2Size {0, 0})
|
||||
, CurrentPalette (palette)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OpenDiablo2::System::D2Sprite::D2Sprite(
|
||||
std::string resourcePath,
|
||||
std::string palette,
|
||||
Game::Common::D2Point location,
|
||||
bool cacheFrames)
|
||||
: Frame (0)
|
||||
, TotalFrames (0)
|
||||
, Blend (false)
|
||||
, Darken (false)
|
||||
, Location (location)
|
||||
, FrameSize (OpenDiablo2::Game::Common::D2Size {0, 0})
|
||||
, LocalFrameSize (OpenDiablo2::Game::Common::D2Size {0, 0})
|
||||
, CurrentPalette (palette)
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user