Skip to content

Commit

Permalink
wip translation
Browse files Browse the repository at this point in the history
  • Loading branch information
mlthelama committed Jan 23, 2024
1 parent 25da401 commit 722212f
Show file tree
Hide file tree
Showing 18 changed files with 291 additions and 80 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ set(Boost_USE_STATIC_LIBS ON)
find_package(spdlog REQUIRED CONFIG)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(magic_enum CONFIG REQUIRED)
find_package(unordered_dense CONFIG REQUIRED)

find_path(CLIB_UTIL_INCLUDE_DIRS "ClibUtil/utils.hpp")

set(CommonLibPath "extern/CommonLibSSE-NG")
set(CommonLibName "CommonLibSSE")
Expand Down Expand Up @@ -146,6 +149,7 @@ target_include_directories(
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
${CLIB_UTIL_INCLUDE_DIRS}
)

target_link_libraries(
Expand All @@ -155,6 +159,7 @@ target_link_libraries(
CommonLibSSE::CommonLibSSE
nlohmann_json::nlohmann_json
magic_enum::magic_enum
unordered_dense::unordered_dense
)

if (MSVC)
Expand Down
133 changes: 70 additions & 63 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,68 +1,75 @@
{
"configurePresets": [{
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": {
"type": "STRING",
"value": "Release"
}
},
"errors": {
"deprecated": true
},
"hidden": true,
"name": "cmake-dev",
"warnings": {
"deprecated": true,
"dev": true
}
},
{
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "STRING",
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
},
"hidden": true,
"name": "vcpkg"
"configurePresets": [
{
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": {
"type": "STRING",
"value": "Release"
}
},
"errors": {
"deprecated": true
},
"hidden": true,
"name": "cmake-dev",
"warnings": {
"deprecated": true,
"dev": true
}
},
{
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "STRING",
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
},
{
"cacheVariables": {
"CMAKE_MSVC_RUNTIME_LIBRARY": {
"type": "STRING",
"value": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
},
"VCPKG_TARGET_TRIPLET": {
"type": "STRING",
"value": "x64-windows-static-md"
}
},
"hidden": true,
"name": "windows"
"VCPKG_OVERLAY_PORTS": {
"type": "STRING",
"value": "${sourceDir}/cmake/ports/"
}
},
"hidden": true,
"name": "vcpkg"
},
{
"cacheVariables": {
"CMAKE_MSVC_RUNTIME_LIBRARY": {
"type": "STRING",
"value": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
},
{
"architecture": {
"strategy": "set",
"value": "x64"
},
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /WX"
},
"generator": "Visual Studio 17 2022",
"inherits": [
"cmake-dev",
"vcpkg",
"windows"
],
"name": "vs2022-windows",
"toolset": "v143"
"VCPKG_TARGET_TRIPLET": {
"type": "STRING",
"value": "x64-windows-static-md"
}
],
"buildPresets": [{
"name": "vs2022-windows",
"configurePreset": "vs2022-windows",
"configuration": "Release"
}],
"version": 3
},
"hidden": true,
"name": "windows"
},
{
"architecture": {
"strategy": "set",
"value": "x64"
},
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /WX"
},
"generator": "Visual Studio 17 2022",
"inherits": [
"cmake-dev",
"vcpkg",
"windows"
],
"name": "vs2022-windows",
"toolset": "v143"
}
],
"buildPresets": [
{
"name": "vs2022-windows",
"configurePreset": "vs2022-windows",
"configuration": "Release"
}
],
"version": 3
}
14 changes: 14 additions & 0 deletions cmake/ports/clib-util/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# header-only library
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO powerof3/CLibUtil
REF a801992250ee8c6178159cc73ce3354a742be6b4
SHA512 3eb37eb0958bf5cf01c8cd80f673b5ab60c562757d76024937fde529b82938481ad8d6fa30d6ca21d5ef93ab8a2d92e7ad093ddc242fb2462aa234689efd31eb
HEAD_REF master
)

# Install codes
set(CLIBUTIL_SOURCE ${SOURCE_PATH}/include/ClibUtil)
file(INSTALL ${CLIBUTIL_SOURCE} DESTINATION ${CURRENT_PACKAGES_DIR}/include)

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
7 changes: 7 additions & 0 deletions cmake/ports/clib-util/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "clib-util",
"version-string": "1.3.5",
"port-version": 1,
"description": "",
"homepage": "https://github.com/powerof3/CLibUtil"
}
24 changes: 24 additions & 0 deletions cmake/ports/unordered-dense/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO martinus/unordered_dense
REF a570a0e87f95027e8544c72295236df5d84c3dcc
SHA512 3f06daf92b68ef7e1ec0c7bbd7070aac8d0bf7ce57bfc6408770ab001f4c3c5efe084b01405a65d6b9e3d99eb0f16c95dd6c5dfc88387d246552f850a9ec6cad
HEAD_REF main
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(
PACKAGE_NAME unordered_dense
CONFIG_PATH lib/cmake/unordered_dense
)

file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug"
"${CURRENT_PACKAGES_DIR}/lib"
)

file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
17 changes: 17 additions & 0 deletions cmake/ports/unordered-dense/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "unordered-dense",
"version-string": "4.1.0",
"port-version": 1,
"description": "",
"homepage": "https://github.com/martinus/unordered_dense",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
2 changes: 2 additions & 0 deletions cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ set(sources ${sources}
src/util/player/player.h
src/util/quest/quest.cpp
src/util/quest/quest.h
src/util/translation.cpp
src/util/translation.h
src/util/type_util.cpp
src/util/type_util.h
)
18 changes: 18 additions & 0 deletions src/PCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING

#include <RE/Skyrim.h>
#include <SKSE/SKSE.h>
Expand All @@ -10,9 +11,26 @@

#include "magic_enum.hpp"
#include "nlohmann/json.hpp"
#include <ankerl/unordered_dense.h>
#include <ClibUtil/string.hpp>
#include <codecvt>

using namespace std::literals;

struct string_hash
{
using is_transparent = void; // enable heterogeneous overloads
using is_avalanching = void; // mark class as high quality avalanching hash

[[nodiscard]] std::uint64_t operator()(std::string_view str) const noexcept
{
return ankerl::unordered_dense::hash<std::string_view>{}(str);
}
};

template <class D>
using string_map = ankerl::unordered_dense::segmented_map<std::string, D, string_hash, std::equal_to<>>;

namespace stl {
using namespace SKSE::stl;
}
Expand Down
2 changes: 1 addition & 1 deletion src/actor/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace actor {
}
logger::trace("name {}, value {}, icon {}, column {}"sv, name, value, icon, column_name);
}

std::vector<actor_player_data*> player::get_player_data(RE::PlayerCharacter*& a_player,
setting_data::menu_data::menu_type a_menu) {
if (!a_player) {
Expand Down
6 changes: 5 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "scaleform/scaleform.h"
#include "setting/input_setting.h"
#include "setting/setting.h"
#include "util/translation.h"

void init_logger() {
if (static bool initialized = false; !initialized) {
Expand Down Expand Up @@ -74,6 +75,8 @@ EXTERN_C [[maybe_unused]] __declspec(dllexport) bool SKSEAPI SKSEPlugin_Load(con
init_config_setting();
mod::mod::init_mod_support();

util::translation::get_singleton()->build_translation_map();

scaleform::Register();
input::menu_key_input_holder::get_singleton()->set_all();

Expand All @@ -95,7 +98,8 @@ EXTERN_C [[maybe_unused]] __declspec(dllexport) constinit auto SKSEPlugin_Versio
v.PluginVersion({ Version::MAJOR, Version::MINOR, Version::PATCH, Version::BETA });
v.UsesAddressLibrary(true);
v.CompatibleVersions({ SKSE::RUNTIME_SSE_LATEST });
v.HasNoStructUse(true);
//v.HasNoStructUse(true);
v.UsesNoStructs();
return v;
}();

Expand Down
10 changes: 6 additions & 4 deletions src/scaleform/menus/faction_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "setting/input_setting.h"
#include "setting/key_setting.h"
#include "util/key_util.h"
#include "util/translation.h"

namespace scaleform {
void faction_menu::Register() {
Expand Down Expand Up @@ -197,15 +198,15 @@ namespace scaleform {

void faction_menu::update_text(CLIK::TextField a_field, const std::string_view a_string) {
a_field.AutoSize(CLIK::Object{ "left" });
a_field.HTMLText(a_string);
a_field.HTMLText(TRANSLATE(a_string));
a_field.Visible(true);
}

void faction_menu::update_text(CLIK::TextField a_field,
const std::string_view a_string,
const std::string& a_auto_size) {
a_field.AutoSize(CLIK::Object{ a_auto_size });
a_field.HTMLText(a_string);
a_field.HTMLText(TRANSLATE(a_string));
a_field.Visible(true);
}

Expand All @@ -220,8 +221,9 @@ namespace scaleform {
RE::GFxValue faction_menu::build_gfx_value(const std::string_view& a_key, const std::string& a_val) const {
RE::GFxValue value;
view_->CreateObject(std::addressof(value));
value.SetMember("displayName", { a_key });
value.SetMember("displayValue", { static_cast<std::string_view>(a_val) });
value.SetMember("displayName", { TRANSLATE(a_key) });
//value.SetMember("displayValue", { static_cast<std::string_view>(a_val) });
value.SetMember("displayValue", { TRANSLATE(a_val) });
return value;
}

Expand Down
9 changes: 5 additions & 4 deletions src/scaleform/menus/stats_inventory_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "setting/config_setting.h"
#include "setting/data/menu_data.h"
#include "util/player/player.h"
#include "util/translation.h"

namespace scaleform {

Expand Down Expand Up @@ -171,9 +172,9 @@ namespace scaleform {
logger::debug("Shown all Values for Menu {}"sv, menu_name);
}

void stats_inventory_menu::update_text(CLIK::TextField a_field, const std::string_view a_string) {
void stats_inventory_menu::update_text(CLIK::TextField a_field, std::string_view a_string) {
a_field.AutoSize(CLIK::Object{ "left" });
a_field.HTMLText(a_string);
a_field.HTMLText(TRANSLATE(a_string));
a_field.Visible(true);
}

Expand All @@ -189,7 +190,7 @@ namespace scaleform {
const std::string_view& a_icon) const {
RE::GFxValue value;
view_->CreateObject(std::addressof(value));
value.SetMember("displayName", { a_key });
value.SetMember("displayName", { TRANSLATE(a_key) });
value.SetMember("displayValue", { static_cast<std::string_view>(a_val) });
value.SetMember("iconKey", { a_icon });
value.SetMember("iconScale", { 18 });
Expand All @@ -199,7 +200,7 @@ namespace scaleform {
RE::GFxValue stats_inventory_menu::build_gfx_value(const std::string_view& a_key, const std::string& a_val) const {
RE::GFxValue value;
view_->CreateObject(std::addressof(value));
value.SetMember("displayName", { a_key });
value.SetMember("displayName", { TRANSLATE(a_key) });
value.SetMember("displayValue", { static_cast<std::string_view>(a_val) });
value.SetMember("iconScale", { 18 });
return value;
Expand Down
Loading

0 comments on commit 722212f

Please sign in to comment.