forked from alterware/iw6-mod
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
deafda9061 | |||
61f0374d10 | |||
9052daab5c |
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -29,9 +29,6 @@
|
|||||||
[submodule "deps/udis86"]
|
[submodule "deps/udis86"]
|
||||||
path = deps/udis86
|
path = deps/udis86
|
||||||
url = https://github.com/vmt/udis86.git
|
url = https://github.com/vmt/udis86.git
|
||||||
[submodule "deps/WinToast"]
|
|
||||||
path = deps/WinToast
|
|
||||||
url = https://github.com/mohabouje/WinToast.git
|
|
||||||
[submodule "deps/zlib"]
|
[submodule "deps/zlib"]
|
||||||
path = deps/zlib
|
path = deps/zlib
|
||||||
url = https://github.com/madler/zlib.git
|
url = https://github.com/madler/zlib.git
|
||||||
|
2
deps/GSL
vendored
2
deps/GSL
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 272463043ef3e442f6c80a530d3dd38ee6781381
|
Subproject commit 3325bbd33d24d1f8f5a0f69e782c92ad5a39a68e
|
1
deps/WinToast
vendored
1
deps/WinToast
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit a78ce469b456c06103b3b30d4bd37e7bb80da30c
|
|
2
deps/asmjit
vendored
2
deps/asmjit
vendored
@ -1 +1 @@
|
|||||||
Subproject commit cfc9f813cc6ccda63cad872edb32b38e0662bedb
|
Subproject commit e8c8e2e48a1a38154c8e8864eb3bc61db80a1e31
|
2
deps/gsc-tool
vendored
2
deps/gsc-tool
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 616595f8e0dd62d6d57ed7a4ef7635a4c65e5dde
|
Subproject commit 2d9781ce0ce9e8551eaf040d7761fd986f33cfdc
|
2
deps/libtomcrypt
vendored
2
deps/libtomcrypt
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 427e0551c0e27c1ef9a3aa969310a895163631ba
|
Subproject commit a6b9aff7aab857fe1b491710a5c5b9e2be49cb08
|
2
deps/libtommath
vendored
2
deps/libtommath
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 5809141a3a6ec1bf3443c927c02b955e19224016
|
Subproject commit e823b0c34cea291bdb94d672731e1c1f08525557
|
2
deps/minhook
vendored
2
deps/minhook
vendored
@ -1 +1 @@
|
|||||||
Subproject commit c1a7c3843bd1a5fe3eb779b64c0d823bca3dc339
|
Subproject commit c3fcafdc10146beb5919319d0683e44e3c30d537
|
32
deps/premake/wintoast.lua
vendored
32
deps/premake/wintoast.lua
vendored
@ -1,32 +0,0 @@
|
|||||||
wintoast = {
|
|
||||||
source = path.join(dependencies.basePath, "WinToast"),
|
|
||||||
}
|
|
||||||
|
|
||||||
function wintoast.import()
|
|
||||||
links { "WinToast" }
|
|
||||||
wintoast.includes()
|
|
||||||
end
|
|
||||||
|
|
||||||
function wintoast.includes()
|
|
||||||
includedirs {
|
|
||||||
path.join(wintoast.source, "include"),
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function wintoast.project()
|
|
||||||
project "WinToast"
|
|
||||||
language "C++"
|
|
||||||
|
|
||||||
wintoast.includes()
|
|
||||||
rapidjson.import();
|
|
||||||
|
|
||||||
files {
|
|
||||||
path.join(wintoast.source, "include/wintoastlib.h"),
|
|
||||||
path.join(wintoast.source, "src/wintoastlib.cpp"),
|
|
||||||
}
|
|
||||||
|
|
||||||
warnings "Off"
|
|
||||||
kind "StaticLib"
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert(dependencies, wintoast)
|
|
2
deps/rapidjson
vendored
2
deps/rapidjson
vendored
@ -1 +1 @@
|
|||||||
Subproject commit d621dc9e9c77f81e5c8a35b8dcc16dcd63351321
|
Subproject commit 24b5e7a8b27f42fa16b96fc70aade9106cf7102f
|
2
deps/zlib
vendored
2
deps/zlib
vendored
@ -1 +1 @@
|
|||||||
Subproject commit ef24c4c7502169f016dcd2a26923dbaf3216748c
|
Subproject commit 5a82f71ed1dfc0bec044d9702463dbdf84ea3b71
|
@ -268,7 +268,7 @@ filter "configurations:Release"
|
|||||||
buildoptions {"/GL"}
|
buildoptions {"/GL"}
|
||||||
linkoptions {"/IGNORE:4702", "/LTCG"}
|
linkoptions {"/IGNORE:4702", "/LTCG"}
|
||||||
defines {"NDEBUG"}
|
defines {"NDEBUG"}
|
||||||
flags {"FatalCompileWarnings"}
|
fatalwarnings {"All"}
|
||||||
filter {}
|
filter {}
|
||||||
|
|
||||||
filter "configurations:Debug"
|
filter "configurations:Debug"
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include <utils/hook.hpp>
|
#include <utils/hook.hpp>
|
||||||
#include <utils/string.hpp>
|
#include <utils/string.hpp>
|
||||||
|
|
||||||
|
#define ALLOW_CUSTOM_BOT_NAMES
|
||||||
|
|
||||||
namespace bots
|
namespace bots
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
|
@ -112,23 +112,24 @@ namespace dvar_cheats
|
|||||||
|
|
||||||
void cg_set_client_dvar_from_server(const int local_client_num, game::mp::cg_s* cg, const char* dvar_id, const char* value)
|
void cg_set_client_dvar_from_server(const int local_client_num, game::mp::cg_s* cg, const char* dvar_id, const char* value)
|
||||||
{
|
{
|
||||||
if (dvar_id == "cg_fov"s || dvar_id == "com_maxfps"s)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto* dvar = game::Dvar_FindVar(dvar_id);
|
const auto* dvar = game::Dvar_FindVar(dvar_id);
|
||||||
if (dvar)
|
|
||||||
{
|
if (!dvar)
|
||||||
// If we send as string, it can't be set with source SERVERCMD because the game only allows that source on real server cmd dvars.
|
|
||||||
// Just use external instead as if it was being set by the console
|
|
||||||
game::Dvar_SetFromStringByNameFromSource(dvar_id, value, game::DvarSetSource::DVAR_SOURCE_EXTERNAL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Not a dvar name, assume it is an id and the game will handle normally
|
// Not a dvar name, assume it is an id and the game will handle normally
|
||||||
game::CG_SetClientDvarFromServer(local_client_num, cg, dvar_id, value);
|
game::CG_SetClientDvarFromServer(local_client_num, cg, dvar_id, value);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dvar && ((dvar->flags & game::DVAR_FLAG_SAVED) != 0))
|
||||||
|
{
|
||||||
|
console::info("Not allowing server to override archive dvar '%s'\n", dvar->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we send as string, it can't be set with source SERVERCMD because the game only allows that source on real server cmd dvars.
|
||||||
|
// Just use external instead as if it was being set by the console
|
||||||
|
game::Dvar_SetFromStringByNameFromSource(dvar_id, value, game::DVAR_SOURCE_EXTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_client_dvar_by_string(const int entity_num, const char* value)
|
void set_client_dvar_by_string(const int entity_num, const char* value)
|
||||||
|
@ -113,6 +113,26 @@ namespace gsc
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool player_cmd_set_client_dvar_is_valid_name(const char* dvar_name)
|
||||||
|
{
|
||||||
|
if (!game::Dvar_IsValidName(dvar_name))
|
||||||
|
{
|
||||||
|
scr_error(va("%s is an invalid dvar name", dvar_name));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void player_cmd_set_client_dvar_server_dvar()
|
||||||
|
{
|
||||||
|
scr_error("server dvar cannot be set as a client dvar");
|
||||||
|
}
|
||||||
|
|
||||||
|
void player_cmd_set_client_dvar_non_writable_dvar()
|
||||||
|
{
|
||||||
|
scr_error("non-writable dvar cannot be set as a client dvar");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int scr_get_object(unsigned int index)
|
unsigned int scr_get_object(unsigned int index)
|
||||||
@ -300,6 +320,13 @@ namespace gsc
|
|||||||
utils::hook::jump(SELECT_VALUE(0x1403DE150, 0x1404390B0), scr_get_pointer_type);
|
utils::hook::jump(SELECT_VALUE(0x1403DE150, 0x1404390B0), scr_get_pointer_type);
|
||||||
utils::hook::jump(SELECT_VALUE(0x1403DE320, 0x140439280), scr_get_type);
|
utils::hook::jump(SELECT_VALUE(0x1403DE320, 0x140439280), scr_get_type);
|
||||||
utils::hook::jump(SELECT_VALUE(0x1403DE390, 0x1404392F0), scr_get_type_name);
|
utils::hook::jump(SELECT_VALUE(0x1403DE390, 0x1404392F0), scr_get_type_name);
|
||||||
|
|
||||||
|
if (game::environment::is_mp())
|
||||||
|
{
|
||||||
|
utils::hook::call(0x14038A4F7, player_cmd_set_client_dvar_is_valid_name);
|
||||||
|
utils::hook::call(0x14038A52F, player_cmd_set_client_dvar_server_dvar);
|
||||||
|
utils::hook::call(0x14038A53A, player_cmd_set_client_dvar_non_writable_dvar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pre_destroy() override
|
void pre_destroy() override
|
||||||
|
@ -347,7 +347,7 @@ namespace gsc
|
|||||||
build = static_cast<xsk::gsc::build>(static_cast<unsigned int>(build) | static_cast<unsigned int>(xsk::gsc::build::dev_blocks));
|
build = static_cast<xsk::gsc::build>(static_cast<unsigned int>(build) | static_cast<unsigned int>(xsk::gsc::build::dev_blocks));
|
||||||
}
|
}
|
||||||
|
|
||||||
gsc_ctx->init(build, []([[maybe_unused]] auto const* ctx, const auto& included_path) -> std::pair<xsk::gsc::buffer, std::vector<std::uint8_t>>
|
gsc_ctx->init(build, []([[maybe_unused]] const auto* ctx, const auto& included_path) -> std::pair<xsk::gsc::buffer, std::vector<std::uint8_t>>
|
||||||
{
|
{
|
||||||
const auto script_name = std::filesystem::path(included_path).replace_extension().string();
|
const auto script_name = std::filesystem::path(included_path).replace_extension().string();
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ namespace logger
|
|||||||
// Make havok script's print function actually print
|
// Make havok script's print function actually print
|
||||||
utils::hook::jump(SELECT_VALUE(0x1406283A4, 0x140732184), print);
|
utils::hook::jump(SELECT_VALUE(0x1406283A4, 0x140732184), print);
|
||||||
|
|
||||||
logger_dev = game::Dvar_RegisterBool("logger_dev", false, game::DVAR_FLAG_SAVED, "Print dev stuff");
|
logger_dev = game::Dvar_RegisterBool("logger_dev", false, game::DVAR_FLAG_NONE, "Print dev stuff");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace mods
|
|||||||
{
|
{
|
||||||
utils::hook::detour sys_create_file_hook;
|
utils::hook::detour sys_create_file_hook;
|
||||||
|
|
||||||
void db_build_os_path_from_source(const char* zone_name, game::FF_DIR source, int size, char* filename)
|
void db_build_os_path_from_source(const char* zone_name, const game::FF_DIR source, const int size, char* filename)
|
||||||
{
|
{
|
||||||
char user_map[MAX_PATH]{};
|
char user_map[MAX_PATH]{};
|
||||||
|
|
||||||
@ -41,9 +41,9 @@ namespace mods
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
game::Sys_File sys_create_file_stub(const char* dir, const char* filename)
|
game::Sys_File sys_create_file_stub(game::Sys_Folder folder, const char* base_filename)
|
||||||
{
|
{
|
||||||
auto result = sys_create_file_hook.invoke<game::Sys_File>(dir, filename);
|
auto result = sys_create_file_hook.invoke<game::Sys_File>(folder, base_filename);
|
||||||
|
|
||||||
if (result.handle != INVALID_HANDLE_VALUE)
|
if (result.handle != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ namespace mods
|
|||||||
}
|
}
|
||||||
|
|
||||||
// .ff extension was added previously
|
// .ff extension was added previously
|
||||||
if (!std::strcmp(filename, "mod.ff") && mods::db_mod_file_exists())
|
if (!std::strcmp(base_filename, "mod.ff") && mods::db_mod_file_exists())
|
||||||
{
|
{
|
||||||
char file_path[MAX_PATH]{};
|
char file_path[MAX_PATH]{};
|
||||||
db_build_os_path_from_source("mod", game::FFD_MOD_DIR, sizeof(file_path), file_path);
|
db_build_os_path_from_source("mod", game::FFD_MOD_DIR, sizeof(file_path), file_path);
|
||||||
|
@ -166,11 +166,11 @@ namespace patches
|
|||||||
game::AimAssist_AddToTargetList(a1, a2);
|
game::AimAssist_AddToTargetList(a1, a2);
|
||||||
}
|
}
|
||||||
|
|
||||||
game::dvar_t* register_cg_fov_stub(const char* name, float value, float min, float /*max*/,
|
game::dvar_t* register_cg_fov_stub(const char* name, const float value, const float min, [[maybe_unused]] const float max,
|
||||||
const unsigned int flags,
|
const unsigned int flags,
|
||||||
const char* description)
|
const char* description)
|
||||||
{
|
{
|
||||||
return game::Dvar_RegisterFloat(name, value, min, 160, flags | 1, description);
|
return game::Dvar_RegisterFloat(name, value, min, 160, flags, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bsp_sys_error_stub(const char* error, const char* arg1)
|
void bsp_sys_error_stub(const char* error, const char* arg1)
|
||||||
|
@ -46,12 +46,11 @@ namespace renderer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dvars::r_fullbright = game::Dvar_RegisterBool("r_fullbright", false, game::DvarFlags::DVAR_FLAG_SAVED,
|
dvars::r_fullbright = game::Dvar_RegisterBool("r_fullbright", false, game::DVAR_FLAG_CHEAT,
|
||||||
"Toggles rendering without lighting");
|
"Toggles rendering without lighting");
|
||||||
|
|
||||||
r_init_draw_method_hook.create(SELECT_VALUE(0x1404FF600, 0x1405CB470), &r_init_draw_method_stub);
|
r_init_draw_method_hook.create(SELECT_VALUE(0x1404FF600, 0x1405CB470), &r_init_draw_method_stub);
|
||||||
r_update_front_end_dvar_options_hook.create(
|
r_update_front_end_dvar_options_hook.create(SELECT_VALUE(0x140535FF0, 0x140603240), &r_update_front_end_dvar_options_stub);
|
||||||
SELECT_VALUE(0x140535FF0, 0x140603240), &r_update_front_end_dvar_options_stub);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ namespace steam_proxy
|
|||||||
ownership_state state_;
|
ownership_state state_;
|
||||||
|
|
||||||
utils::binary_resource runner_file(RUNNER, "runner.exe");
|
utils::binary_resource runner_file(RUNNER, "runner.exe");
|
||||||
|
|
||||||
|
bool is_disabled() { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
class component final : public component_interface
|
class component final : public component_interface
|
||||||
@ -33,7 +35,7 @@ namespace steam_proxy
|
|||||||
public:
|
public:
|
||||||
void post_load() override
|
void post_load() override
|
||||||
{
|
{
|
||||||
if (game::environment::is_dedi())
|
if (game::environment::is_dedi() || is_disabled())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1181,6 +1181,7 @@ namespace game
|
|||||||
DVAR_FLAG_LATCHED = 0x2,
|
DVAR_FLAG_LATCHED = 0x2,
|
||||||
DVAR_FLAG_CHEAT = 0x4,
|
DVAR_FLAG_CHEAT = 0x4,
|
||||||
DVAR_FLAG_REPLICATED = 0x8,
|
DVAR_FLAG_REPLICATED = 0x8,
|
||||||
|
DVAR_FLAG_SCRIPTINFO = 0x10,
|
||||||
DVAR_FLAG_INTERNAL = 0x80,
|
DVAR_FLAG_INTERNAL = 0x80,
|
||||||
DVAR_FLAG_EXTERNAL = 0x100,
|
DVAR_FLAG_EXTERNAL = 0x100,
|
||||||
DVAR_FLAG_SERVERINFO = 0x400,
|
DVAR_FLAG_SERVERINFO = 0x400,
|
||||||
|
@ -91,6 +91,7 @@ namespace game
|
|||||||
WEAK symbol<void(const char*, const char*, DvarSetSource)> Dvar_SetFromStringByNameFromSource{0x14042D000, 0x1404F00B0};
|
WEAK symbol<void(const char*, const char*, DvarSetSource)> Dvar_SetFromStringByNameFromSource{0x14042D000, 0x1404F00B0};
|
||||||
WEAK symbol<void()> Dvar_Sort{0x14042DEF0, 0x1404F1210};
|
WEAK symbol<void()> Dvar_Sort{0x14042DEF0, 0x1404F1210};
|
||||||
WEAK symbol<const char*(dvar_t* dvar, DvarValue value)> Dvar_ValueToString{0x14042E710, 0x1404F1A30};
|
WEAK symbol<const char*(dvar_t* dvar, DvarValue value)> Dvar_ValueToString{0x14042E710, 0x1404F1A30};
|
||||||
|
WEAK symbol<bool(const char* dvarName)> Dvar_IsValidName{0x0, 0x1404ED0E0};
|
||||||
|
|
||||||
WEAK symbol<long long (const char* qpath, char** buffer)> FS_ReadFile{0x14041D0B0, 0x1404DE900};
|
WEAK symbol<long long (const char* qpath, char** buffer)> FS_ReadFile{0x14041D0B0, 0x1404DE900};
|
||||||
WEAK symbol<void(void* buffer)> FS_FreeFile{0x14041D0A0, 0x1404DE8F0};
|
WEAK symbol<void(void* buffer)> FS_FreeFile{0x14041D0A0, 0x1404DE8F0};
|
||||||
|
@ -67,6 +67,14 @@ namespace utils::string
|
|||||||
return std::equal(substring.rbegin(), substring.rend(), text.rbegin());
|
return std::equal(substring.rbegin(), substring.rend(), text.rbegin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool compare(const std::string& lhs, const std::string& rhs)
|
||||||
|
{
|
||||||
|
return std::ranges::equal(lhs, rhs, [](const unsigned char a, const unsigned char b)
|
||||||
|
{
|
||||||
|
return std::tolower(a) == std::tolower(b);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bool is_numeric(const std::string& text)
|
bool is_numeric(const std::string& text)
|
||||||
{
|
{
|
||||||
return std::to_string(atoi(text.data())) == text;
|
return std::to_string(atoi(text.data())) == text;
|
||||||
|
@ -22,78 +22,79 @@ namespace utils::string
|
|||||||
++this->current_buffer_ %= ARRAY_COUNT(this->string_pool_);
|
++this->current_buffer_ %= ARRAY_COUNT(this->string_pool_);
|
||||||
auto entry = &this->string_pool_[this->current_buffer_];
|
auto entry = &this->string_pool_[this->current_buffer_];
|
||||||
|
|
||||||
if (!entry->size || !entry->buffer)
|
if (!entry->size_ || !entry->buffer_)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("String pool not initialized");
|
throw std::runtime_error("String pool not initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
const int res = vsnprintf(entry->buffer, entry->size, format, ap);
|
const int res = vsnprintf(entry->buffer_, entry->size_, format, ap);
|
||||||
if (res > 0) break; // Success
|
if (res > 0) break; // Success
|
||||||
if (res == 0) return nullptr; // Error
|
if (res == 0) return nullptr; // Error
|
||||||
|
|
||||||
entry->double_size();
|
entry->double_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
return entry->buffer;
|
return entry->buffer_;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class entry final
|
class entry final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit entry(const size_t _size = MinBufferSize) : size(_size), buffer(nullptr)
|
explicit entry(const size_t size = MinBufferSize) : size_(size), buffer_(nullptr)
|
||||||
{
|
{
|
||||||
if (this->size < MinBufferSize) this->size = MinBufferSize;
|
this->size_ = std::max<size_t>(this->size_, MinBufferSize);
|
||||||
this->allocate();
|
this->allocate();
|
||||||
}
|
}
|
||||||
|
|
||||||
~entry()
|
~entry()
|
||||||
{
|
{
|
||||||
if (this->buffer) memory::get_allocator()->free(this->buffer);
|
if (this->buffer_) memory::get_allocator()->free(this->buffer_);
|
||||||
this->size = 0;
|
this->size_ = 0;
|
||||||
this->buffer = nullptr;
|
this->buffer_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void allocate()
|
void allocate()
|
||||||
{
|
{
|
||||||
if (this->buffer) memory::get_allocator()->free(this->buffer);
|
if (this->buffer_) memory::get_allocator()->free(this->buffer_);
|
||||||
this->buffer = memory::get_allocator()->allocate_array<char>(this->size + 1);
|
this->buffer_ = memory::get_allocator()->allocate_array<char>(this->size_ + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void double_size()
|
void double_size()
|
||||||
{
|
{
|
||||||
this->size *= 2;
|
this->size_ *= 2;
|
||||||
this->allocate();
|
this->allocate();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size;
|
size_t size_;
|
||||||
char* buffer;
|
char* buffer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t current_buffer_;
|
size_t current_buffer_;
|
||||||
entry string_pool_[Buffers];
|
entry string_pool_[Buffers];
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* va(const char* fmt, ...);
|
[[nodiscard]] const char* va(const char* fmt, ...);
|
||||||
|
|
||||||
std::vector<std::string> split(const std::string& s, char delim);
|
[[nodiscard]] std::vector<std::string> split(const std::string& s, char delim);
|
||||||
|
|
||||||
std::string to_lower(const std::string& text);
|
[[nodiscard]] std::string to_lower(const std::string& text);
|
||||||
std::string to_upper(const std::string& text);
|
[[nodiscard]] std::string to_upper(const std::string& text);
|
||||||
bool starts_with(const std::string& text, const std::string& substring);
|
[[nodiscard]] bool starts_with(const std::string& text, const std::string& substring);
|
||||||
bool ends_with(const std::string& text, const std::string& substring);
|
[[nodiscard]] bool ends_with(const std::string& text, const std::string& substring);
|
||||||
bool is_numeric(const std::string& text);
|
[[nodiscard]] bool compare(const std::string& lhs, const std::string& rhs);
|
||||||
|
[[nodiscard]] bool is_numeric(const std::string& text);
|
||||||
|
|
||||||
std::string dump_hex(const std::string& data, const std::string& separator = " ");
|
[[nodiscard]] std::string dump_hex(const std::string& data, const std::string& separator = " ");
|
||||||
|
|
||||||
std::string get_clipboard_data();
|
[[nodiscard]] std::string get_clipboard_data();
|
||||||
|
|
||||||
void strip(const char* in, char* out, size_t max);
|
void strip(const char* in, char* out, size_t max);
|
||||||
|
|
||||||
std::string convert(const std::wstring& wstr);
|
[[nodiscard]] std::string convert(const std::wstring& wstr);
|
||||||
std::wstring convert(const std::string& str);
|
[[nodiscard]] std::wstring convert(const std::string& str);
|
||||||
|
|
||||||
std::string replace(std::string str, const std::string& from, const std::string& to);
|
[[nodiscard]] std::string replace(std::string str, const std::string& from, const std::string& to);
|
||||||
}
|
}
|
||||||
|
@ -1,109 +0,0 @@
|
|||||||
#include "toast.hpp"
|
|
||||||
#include "string.hpp"
|
|
||||||
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable: 6387)
|
|
||||||
#include <wintoastlib.h>
|
|
||||||
#pragma warning(pop)
|
|
||||||
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
bool initialize()
|
|
||||||
{
|
|
||||||
static bool initialized = false;
|
|
||||||
static bool success = false;
|
|
||||||
if (initialized)
|
|
||||||
{
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
auto* instance = WinToastLib::WinToast::instance();
|
|
||||||
if (!instance)
|
|
||||||
{
|
|
||||||
success = false;
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
instance->setAppName(L"iw6-mod");
|
|
||||||
instance->setAppUserModelId(
|
|
||||||
WinToastLib::WinToast::configureAUMI(L"AlterWare", L"iw6-mod", L"", L"20201212"));
|
|
||||||
|
|
||||||
WinToastLib::WinToast::WinToastError error;
|
|
||||||
success = instance->initialize(&error);
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
class toast_handler : public WinToastLib::IWinToastHandler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void toastActivated() const override
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void toastActivated(const int /*actionIndex*/) const override
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void toastFailed() const override
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void toastDismissed(WinToastDismissalReason /*state*/) const override
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
toast::toast(const int64_t id)
|
|
||||||
: id_(id)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
toast::operator bool() const
|
|
||||||
{
|
|
||||||
return this->id_ >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void toast::hide() const
|
|
||||||
{
|
|
||||||
if (this->operator bool())
|
|
||||||
{
|
|
||||||
WinToastLib::WinToast::instance()->hideToast(this->id_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toast toast::show(const std::string& title, const std::string& text)
|
|
||||||
{
|
|
||||||
if (!initialize())
|
|
||||||
{
|
|
||||||
return toast{-1};
|
|
||||||
}
|
|
||||||
|
|
||||||
WinToastLib::WinToastTemplate toast_template(WinToastLib::WinToastTemplate::Text02);
|
|
||||||
toast_template.setTextField(string::convert(title), WinToastLib::WinToastTemplate::FirstLine);
|
|
||||||
toast_template.setTextField(string::convert(text), WinToastLib::WinToastTemplate::SecondLine);
|
|
||||||
toast_template.setDuration(WinToastLib::WinToastTemplate::Long);
|
|
||||||
|
|
||||||
return toast{WinToastLib::WinToast::instance()->showToast(toast_template, new toast_handler())};
|
|
||||||
}
|
|
||||||
|
|
||||||
toast toast::show(const std::string& title, const std::string& text, const std::string& image)
|
|
||||||
{
|
|
||||||
if (!initialize())
|
|
||||||
{
|
|
||||||
return {-1};
|
|
||||||
}
|
|
||||||
|
|
||||||
WinToastLib::WinToastTemplate toast_template(WinToastLib::WinToastTemplate::ImageAndText02);
|
|
||||||
toast_template.setTextField(string::convert(title), WinToastLib::WinToastTemplate::FirstLine);
|
|
||||||
toast_template.setTextField(string::convert(text), WinToastLib::WinToastTemplate::SecondLine);
|
|
||||||
toast_template.setDuration(WinToastLib::WinToastTemplate::Long);
|
|
||||||
toast_template.setImagePath(string::convert(image));
|
|
||||||
|
|
||||||
return {WinToastLib::WinToast::instance()->showToast(toast_template, new toast_handler())};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace utils
|
|
||||||
{
|
|
||||||
class toast
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static toast show(const std::string& title, const std::string& text);
|
|
||||||
static toast show(const std::string& title, const std::string& text, const std::string& image);
|
|
||||||
|
|
||||||
operator bool() const;
|
|
||||||
void hide() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
toast(int64_t id);
|
|
||||||
int64_t id_;
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user