From ff02b59255ce653b3be2d5925afc898766e8fc3b Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 8 May 2021 12:33:05 +0200 Subject: [PATCH] Update to latest PkmnLib. --- CMakeLists.txt | 9 ++++----- CmakeConanSetup.cmake | 30 ------------------------------ src/BuildData/BuildItems.cpp | 31 ++++++++++++++++++++++++++++++- src/Tools/ScriptCompiler.cpp | 26 +++++++++++++++++++++----- 4 files changed, 55 insertions(+), 41 deletions(-) delete mode 100644 CmakeConanSetup.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 3198183..0e16358 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,11 @@ cmake_minimum_required(VERSION 3.17) project(PkmnLibTools) -# Enable all warnings, and make them error when occurring. -add_compile_options(-Wall -Wextra -Werror) set(CMAKE_CXX_STANDARD 20) - set(STATICC TRUE) -include(CmakeConanSetup.cmake) -SetupConan() + +include(CMakeLists.txt.in) +include_pkmnlib() file(GLOB_RECURSE SRC_FILES src/*.cpp src/*.hpp) add_executable(PkmnLibTools ${SRC_FILES}) @@ -16,3 +14,4 @@ add_definitions(-DLEVEL_U8) SET(_LINKS Arbutils CreatureLib pkmnLib) target_link_libraries(PkmnLibTools PUBLIC ${_LINKS}) +target_compile_options(PkmnLibTools PRIVATE -Wall -Wextra -Werror) diff --git a/CmakeConanSetup.cmake b/CmakeConanSetup.cmake deleted file mode 100644 index b1c9ea3..0000000 --- a/CmakeConanSetup.cmake +++ /dev/null @@ -1,30 +0,0 @@ -function(SetupConan) - # If conan isn't set up yet, we need to install the dependencies. - if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - message(WARNING "The file conanbuildinfo.cmake doesn't exist, running conan install.") - - # If we're linking C statically, we also want to do so for our dependencies. - set(CONAN_STATIC_C False) - if (STATICC) - set(CONAN_STATIC_C True) - endif (STATICC) - - if (NOT WINDOWS) - execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated - -s compiler=clang - ) - else () - execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated - -s compiler=gcc - -s compiler.libcxx=libstdc++11 - -s os=Windows - -o *:shared=True - -o *:staticC=${CONAN_STATIC_C} - -o AngelScript:link_std_statically=True - -o CreatureLib:level_size=8 - ) - endif () - endif () - include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - conan_basic_setup() -endfunction() \ No newline at end of file diff --git a/src/BuildData/BuildItems.cpp b/src/BuildData/BuildItems.cpp index c74facd..297ad01 100644 --- a/src/BuildData/BuildItems.cpp +++ b/src/BuildData/BuildItems.cpp @@ -58,9 +58,38 @@ PkmnLib::Library::ItemLibrary* BuildItems::Build(const std::string& path) { flags.insert(ArbUt::StringView(flagIndex.value().get().c_str())); } + CreatureLib::Library::SecondaryEffect* effect = nullptr; + auto effectJson = val["effect"]; + if (effectJson != nullptr) { + auto effectName = effectJson["name"]; + auto parametersJson = effectJson["parameters"]; + ArbUt::List parameters; + if (parametersJson != nullptr) { + for (auto& kv : parametersJson.items()) { + auto& p = kv.value(); + auto t = p.type(); + switch (t) { + case json::value_t::boolean: + parameters.Append(new CreatureLib::Library::EffectParameter(p.get())); + break; + case json::value_t::number_integer: + case json::value_t::number_unsigned: + parameters.Append(new CreatureLib::Library::EffectParameter(p.get())); + break; + case json::value_t::number_float: + parameters.Append(new CreatureLib::Library::EffectParameter(p.get())); + break; + default: continue; + } + } + } + effect = new CreatureLib::Library::SecondaryEffect( + 100, ArbUt::StringView(effectName.get().c_str()), parameters); + } + auto item = new PkmnLib::Library::Item(ArbUt::StringView(_name.get().c_str()), itemType, CreatureLib::Library::BattleItemCategory::None, _price.get(), - flags, _flingPower.get()); + effect, flags, _flingPower.get()); lib->Insert(item->GetName(), item); } return lib; diff --git a/src/Tools/ScriptCompiler.cpp b/src/Tools/ScriptCompiler.cpp index 5846f0b..b2400dc 100644 --- a/src/Tools/ScriptCompiler.cpp +++ b/src/Tools/ScriptCompiler.cpp @@ -1,4 +1,5 @@ #include "ScriptCompiler.hpp" +#include #include #include @@ -31,17 +32,32 @@ void ScriptCompiler::Compile(const std::string& inPath, const std::string& outPa if (dirEntry.path().parent_path().stem() == "Interfaces") { continue; } - std::cout << dirEntry.path().stem() << std::endl; std::ifstream t(dirEntry.path().c_str()); - std::string str((std::istreambuf_iterator(t)), - std::istreambuf_iterator()); - resolver->CreateScript(dirEntry.path().stem().c_str(), str.c_str()); + std::string str((std::istreambuf_iterator(t)), std::istreambuf_iterator()); + resolver->CreateScript( + (dirEntry.path().parent_path().stem().string() + "/" + dirEntry.path().stem().string()).c_str(), + str.c_str()); } } - resolver->FinalizeModule(); + auto scripts = resolver->GetTypeDatabase(); + for (const auto& type : scripts) { + + std::cout << "=== "; + if ((uint8_t)type.first < 128) { + std::cout << ScriptCategoryHelper::ToString(type.first); + } else { + std::cout << PkmnScriptCategoryHelper::ToString((PkmnScriptCategory)type.first); + } + std::cout << "\t===" << std::endl; + + for (const auto& s: type.second){ + std::cout << s.first << std::endl; + } + } + std::filesystem::path dir(outPath); std::cout << dir << std::endl; resolver->WriteByteCodeToFile(outPath.c_str());