Update to latest PkmnLib.
This commit is contained in:
parent
74ccdb1759
commit
ff02b59255
|
@ -1,13 +1,11 @@
|
||||||
cmake_minimum_required(VERSION 3.17)
|
cmake_minimum_required(VERSION 3.17)
|
||||||
project(PkmnLibTools)
|
project(PkmnLibTools)
|
||||||
|
|
||||||
# Enable all warnings, and make them error when occurring.
|
|
||||||
add_compile_options(-Wall -Wextra -Werror)
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
set(STATICC TRUE)
|
set(STATICC TRUE)
|
||||||
include(CmakeConanSetup.cmake)
|
|
||||||
SetupConan()
|
include(CMakeLists.txt.in)
|
||||||
|
include_pkmnlib()
|
||||||
|
|
||||||
file(GLOB_RECURSE SRC_FILES src/*.cpp src/*.hpp)
|
file(GLOB_RECURSE SRC_FILES src/*.cpp src/*.hpp)
|
||||||
add_executable(PkmnLibTools ${SRC_FILES})
|
add_executable(PkmnLibTools ${SRC_FILES})
|
||||||
|
@ -16,3 +14,4 @@ add_definitions(-DLEVEL_U8)
|
||||||
|
|
||||||
SET(_LINKS Arbutils CreatureLib pkmnLib)
|
SET(_LINKS Arbutils CreatureLib pkmnLib)
|
||||||
target_link_libraries(PkmnLibTools PUBLIC ${_LINKS})
|
target_link_libraries(PkmnLibTools PUBLIC ${_LINKS})
|
||||||
|
target_compile_options(PkmnLibTools PRIVATE -Wall -Wextra -Werror)
|
||||||
|
|
|
@ -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()
|
|
|
@ -58,9 +58,38 @@ PkmnLib::Library::ItemLibrary* BuildItems::Build(const std::string& path) {
|
||||||
flags.insert(ArbUt::StringView(flagIndex.value().get<std::string>().c_str()));
|
flags.insert(ArbUt::StringView(flagIndex.value().get<std::string>().c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreatureLib::Library::SecondaryEffect* effect = nullptr;
|
||||||
|
auto effectJson = val["effect"];
|
||||||
|
if (effectJson != nullptr) {
|
||||||
|
auto effectName = effectJson["name"];
|
||||||
|
auto parametersJson = effectJson["parameters"];
|
||||||
|
ArbUt::List<CreatureLib::Library::EffectParameter*> 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<bool>()));
|
||||||
|
break;
|
||||||
|
case json::value_t::number_integer:
|
||||||
|
case json::value_t::number_unsigned:
|
||||||
|
parameters.Append(new CreatureLib::Library::EffectParameter(p.get<int64_t>()));
|
||||||
|
break;
|
||||||
|
case json::value_t::number_float:
|
||||||
|
parameters.Append(new CreatureLib::Library::EffectParameter(p.get<float>()));
|
||||||
|
break;
|
||||||
|
default: continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
effect = new CreatureLib::Library::SecondaryEffect(
|
||||||
|
100, ArbUt::StringView(effectName.get<std::string>().c_str()), parameters);
|
||||||
|
}
|
||||||
|
|
||||||
auto item = new PkmnLib::Library::Item(ArbUt::StringView(_name.get<std::string>().c_str()), itemType,
|
auto item = new PkmnLib::Library::Item(ArbUt::StringView(_name.get<std::string>().c_str()), itemType,
|
||||||
CreatureLib::Library::BattleItemCategory::None, _price.get<int32_t>(),
|
CreatureLib::Library::BattleItemCategory::None, _price.get<int32_t>(),
|
||||||
flags, _flingPower.get<uint8_t>());
|
effect, flags, _flingPower.get<uint8_t>());
|
||||||
lib->Insert(item->GetName(), item);
|
lib->Insert(item->GetName(), item);
|
||||||
}
|
}
|
||||||
return lib;
|
return lib;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "ScriptCompiler.hpp"
|
#include "ScriptCompiler.hpp"
|
||||||
|
#include <PkmnLib/Battling/PkmnScriptCategory.hpp>
|
||||||
#include <PkmnLib/ScriptResolving/AngelScript/AngelScriptResolver.hpp>
|
#include <PkmnLib/ScriptResolving/AngelScript/AngelScriptResolver.hpp>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
|
@ -31,17 +32,32 @@ void ScriptCompiler::Compile(const std::string& inPath, const std::string& outPa
|
||||||
if (dirEntry.path().parent_path().stem() == "Interfaces") {
|
if (dirEntry.path().parent_path().stem() == "Interfaces") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std::cout << dirEntry.path().stem() << std::endl;
|
|
||||||
|
|
||||||
std::ifstream t(dirEntry.path().c_str());
|
std::ifstream t(dirEntry.path().c_str());
|
||||||
std::string str((std::istreambuf_iterator<char>(t)),
|
std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
|
||||||
std::istreambuf_iterator<char>());
|
resolver->CreateScript(
|
||||||
resolver->CreateScript(dirEntry.path().stem().c_str(), str.c_str());
|
(dirEntry.path().parent_path().stem().string() + "/" + dirEntry.path().stem().string()).c_str(),
|
||||||
|
str.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resolver->FinalizeModule();
|
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::filesystem::path dir(outPath);
|
||||||
std::cout << dir << std::endl;
|
std::cout << dir << std::endl;
|
||||||
resolver->WriteByteCodeToFile(outPath.c_str());
|
resolver->WriteByteCodeToFile(outPath.c_str());
|
||||||
|
|
Loading…
Reference in New Issue