Skip to content

Commit

Permalink
Added project files
Browse files Browse the repository at this point in the history
  • Loading branch information
QuestionableM committed Jul 13, 2023
1 parent 7508947 commit 2b00275
Show file tree
Hide file tree
Showing 57 changed files with 9,065 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.vs
/Build
*.vcxproj.user
41 changes: 41 additions & 0 deletions Code/AudioManager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once

#include "win_include.hpp"

#include <DirectXMath.h>
#include <memory>
#include <vector>
#include <string>
#include <map>

#include <fmod/fmod_studio.hpp>
#include <fmod/fmod.hpp>

namespace SM
{
struct Task
{
virtual void func0();
};

struct AudioEvent {};

struct AudioEventManager
{
/* 0x0000 */ std::vector<std::shared_ptr<AudioEvent>> event_list;
}; // Size: 0x18

struct AudioManager : public Task
{
/* 0x0008 */ std::shared_ptr<AudioEventManager> audio_event_mgr;
/* 0x0018 */ char pad_0x18[0x50];
/* 0x0068 */ FMOD::Studio::System* fmod_studio_system;
/* 0x0070 */ FMOD::System* fmod_system;

inline static AudioManager* GetInstance()
{
return *reinterpret_cast<AudioManager**>(std::uintptr_t(GetModuleHandle(NULL)) + 0x12A7710);
}

}; // Size: 0x2D8
}
55 changes: 55 additions & 0 deletions Code/DirectoryManager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#pragma once

#include "win_include.hpp"

#include <unordered_map>
#include <string>

namespace SM
{
struct DirectoryManager
{
char unk_data1[8];
std::unordered_map<std::string, std::string> content_key_to_path_list;

inline static DirectoryManager* GetInstance()
{
return *reinterpret_cast<DirectoryManager**>(std::uintptr_t(GetModuleHandle(NULL)) + 0x12A78F0);
}

inline bool replace_path_r(std::string& path)
{
if (path.empty() || path[0] != L'$')
return false;

const char* v_key_beg = path.data();
const char* v_key_ptr = std::strchr(v_key_beg, L'/');
if (v_key_ptr == nullptr)
return false;

const std::size_t v_key_idx = v_key_ptr - v_key_beg;

const std::string v_key_chunk = path.substr(0, v_key_idx);
const auto v_iter = content_key_to_path_list.find(v_key_chunk);
if (v_iter == content_key_to_path_list.end())
return false;

path = (v_iter->second + path.substr(v_key_idx));
return true;
}

inline static bool ReplacePathR(std::string& path)
{
SM::DirectoryManager* v_dir_mgr = SM::DirectoryManager::GetInstance();
if (!v_dir_mgr) return false;

return v_dir_mgr->replace_path_r(path);
}

private:
DirectoryManager() = delete;
DirectoryManager(const DirectoryManager&) = delete;
DirectoryManager(DirectoryManager&&) = delete;
~DirectoryManager() = delete;
};
}
51 changes: 51 additions & 0 deletions Code/Utils/ConColors.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#pragma once

#include "win_include.hpp"

class EngineConColor
{
WORD color_data = 0;

constexpr EngineConColor() noexcept = default;

friend constexpr EngineConColor operator"" _bg(unsigned long long val) noexcept;
friend constexpr EngineConColor operator"" _fg(unsigned long long val) noexcept;

public:
inline constexpr operator WORD() const noexcept
{
return color_data;
}

inline constexpr EngineConColor operator|(EngineConColor rhs) noexcept
{
EngineConColor lOutput;
lOutput.color_data = this->color_data | rhs.color_data;

return lOutput;
}
};

inline constexpr EngineConColor operator"" _bg(unsigned long long val) noexcept
{
EngineConColor lOutput;

if ((val & 0b1000) == 0b1000) lOutput.color_data |= BACKGROUND_RED;
if ((val & 0b0100) == 0b0100) lOutput.color_data |= BACKGROUND_GREEN;
if ((val & 0b0010) == 0b0010) lOutput.color_data |= BACKGROUND_BLUE;
if ((val & 0b0001) == 0b0001) lOutput.color_data |= BACKGROUND_INTENSITY;

return lOutput;
}

inline constexpr EngineConColor operator"" _fg(unsigned long long val) noexcept
{
EngineConColor lOutput;

if ((val & 0b1000) == 0b1000) lOutput.color_data |= FOREGROUND_RED;
if ((val & 0b0100) == 0b0100) lOutput.color_data |= FOREGROUND_GREEN;
if ((val & 0b0010) == 0b0010) lOutput.color_data |= FOREGROUND_BLUE;
if ((val & 0b0001) == 0b0001) lOutput.color_data |= FOREGROUND_INTENSITY;

return lOutput;
}
46 changes: 46 additions & 0 deletions Code/Utils/Console.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "Console.hpp"

#if 1
namespace Engine
{
HANDLE Console::Handle = NULL;
__ConsoleOutputHandler Console::Out = {};

bool Console::CreateEngineConsole(const wchar_t* title)
{
if (Console::Handle == NULL)
{
if (AllocConsole())
{
SetConsoleOutputCP(CP_UTF8);
SetConsoleTitleW(title);

Console::Handle = GetStdHandle(STD_OUTPUT_HANDLE);

return true;
}
}

return false;
}

bool Console::AttachToConsole()
{
if (Console::Handle == NULL)
{
Console::Handle = GetStdHandle(STD_OUTPUT_HANDLE);
return (Console::Handle != NULL);
}

return false;
}

void Console::DestroyConsole()
{
if (Console::Handle == NULL) return;

FreeConsole();
Console::Handle = NULL;
}
}
#endif
Loading

0 comments on commit 2b00275

Please sign in to comment.