VOXEDIT: renamed methods and commands

Martin Gerhardy 2019-12-09 18:12:49 +01:00
parent da0fd95d2f
commit d9f314e20f
8 changed files with 28 additions and 28 deletions

View File

@ -1,6 +1,6 @@
space "cycle_animation 1"
ctrl+space "cycle_animation -1"
e "cycle_animation 1"
q "cycle_animation -1"
y "cycle_animationenttype 1"
c "cycle_animationenttype -1"
space "animation_cycle 1"
ctrl+space "animation_cycle -1"
e "animation_cycle 1"
q "animation_cycle -1"
r "animation_cycletype 1"
t "animation_cycletype -1"

View File

@ -50,7 +50,7 @@ animation::AnimationEntity* TestAnimation::animationEntity() {
core::AppState TestAnimation::onConstruct() {
core::AppState state = Super::onConstruct();
core::Command::registerCommand("cycle_animation", [this] (const core::CmdArgs& argv) {
core::Command::registerCommand("animation_cycle", [this] (const core::CmdArgs& argv) {
int offset = 1;
if (argv.size() > 0) {
offset = core::string::toInt(argv[0]);
@ -64,7 +64,7 @@ core::AppState TestAnimation::onConstruct() {
animationEntity()->setAnimation((animation::Animation)_animationIdx);
});
core::Command::registerCommand("cycle_animationenttype", [this] (const core::CmdArgs& argv) {
core::Command::registerCommand("animation_cycletype", [this] (const core::CmdArgs& argv) {
int offset = 1;
if (argv.size() > 0) {
offset = core::string::toInt(argv[0]);

View File

@ -119,13 +119,13 @@ core::AppState VoxEdit::onConstruct() {
COMMAND_FILE(importpalette, "Import an image as a palette");
#undef COMMAND_FILE
core::Command::registerCommand("character_load", [&] (const core::CmdArgs& args) {
core::Command::registerCommand("animation_load", [&] (const core::CmdArgs& args) {
if (_mainWindow == nullptr) {
return;
}
const std::string file = args.empty() ? "" : args[0];
_mainWindow->loadCharacter(file);
}).setHelp("Load the character volumes").setArgumentCompleter(core::fileCompleter("", "*.lua"));
_mainWindow->loadAnimationEntity(file);
}).setHelp("Load the animation volumes and settings").setArgumentCompleter(core::fileCompleter("", "*.lua"));
core::Command::registerCommand("new", [this] (const core::CmdArgs& args) {
newFile();

View File

@ -54,8 +54,8 @@ VoxEditWindow::VoxEditWindow(VoxEdit* tool) :
addStringItem(_fileItems, "New", "new");
addStringItem(_fileItems, "Load", "load");
addStringItem(_fileItems, "Save", "save");
addStringItem(_fileItems, "Load Character", "character_load");
addStringItem(_fileItems, "Save Character", "character_save");
addStringItem(_fileItems, "Load Animation", "animation_load");
addStringItem(_fileItems, "Save Animation", "animation_save");
addStringItem(_fileItems, "Prefab", "prefab");
addStringItem(_fileItems, "Heightmap", "importheightmap");
addStringItem(_fileItems, "Image as Plane", "importplane");
@ -314,7 +314,7 @@ void VoxEditWindow::toggleAnimation() {
bool VoxEditWindow::handleEvent(const tb::TBWidgetEvent &ev) {
// ui actions with direct command bindings
static const char *ACTIONS[] = {
"new", "quit", "load", "character_load", "character_save",
"new", "quit", "load", "animation_load", "animation_save",
"prefab", "save", "importheightmap", "importplane", nullptr
};
@ -821,12 +821,12 @@ void VoxEditWindow::afterLoad(const std::string& file) {
resetCamera();
}
bool VoxEditWindow::loadCharacter(const std::string& file) {
bool VoxEditWindow::loadAnimationEntity(const std::string& file) {
if (file.empty()) {
getApp()->openDialog([this] (const std::string file) { std::string copy(file); loadCharacter(copy); }, "lua");
getApp()->openDialog([this] (const std::string file) { std::string copy(file); loadAnimationEntity(copy); }, "lua");
return true;
}
if (!sceneMgr().loadCharacter(file)) {
if (!sceneMgr().loadAnimationEntity(file)) {
return false;
}
resetCamera();

View File

@ -109,7 +109,7 @@ private:
bool importPalette(const std::string& file);
bool save(const std::string& file);
bool load(const std::string& file);
bool loadCharacter(const std::string& file);
bool loadAnimationEntity(const std::string& file);
bool saveScreenshot(const std::string& file);
bool prefab(const std::string& file);
bool createNew(bool force);

View File

@ -786,7 +786,7 @@ void SceneManager::construct() {
core::Command::registerActionButton("zoom_in", _zoomIn).setBindingContext(BindingContext::Scene);
core::Command::registerActionButton("zoom_out", _zoomOut).setBindingContext(BindingContext::Scene);
core::Command::registerCommand("cycle_animation", [this] (const core::CmdArgs& argv) {
core::Command::registerCommand("animation_cycle", [this] (const core::CmdArgs& argv) {
int offset = 1;
if (argv.size() > 0) {
offset = core::string::toInt(argv[0]);
@ -800,12 +800,12 @@ void SceneManager::construct() {
_character.setAnimation((animation::Animation)_animationIdx);
});
core::Command::registerCommand("character_save", [&] (const core::CmdArgs& args) {
std::string name = "character";
core::Command::registerCommand("animation_save", [&] (const core::CmdArgs& args) {
std::string name = "entity";
if (!args.empty()) {
name = args[0];
}
saveCharacter(name.c_str());
saveAnimationEntity(name.c_str());
});
core::Command::registerCommand("layerssave", [&] (const core::CmdArgs& args) {
@ -1429,7 +1429,7 @@ void SceneManager::shutdown() {
_character.shutdown();
}
bool SceneManager::saveCharacter(const char *name) {
bool SceneManager::saveAnimationEntity(const char *name) {
_dirty = false;
// TODO: race and gender
const std::string& chrName = core::string::format("chr/human-male-%s", name);
@ -1471,14 +1471,14 @@ bool SceneManager::saveCharacter(const char *name) {
return true;
}
bool SceneManager::loadCharacter(const std::string& luaFile) {
bool SceneManager::loadAnimationEntity(const std::string& luaFile) {
const std::string& lua = io::filesystem()->load(luaFile);
if (!_character.initSettings(lua)) {
Log::warn("Failed to initialize the character settings");
}
voxel::VoxelVolumes volumes;
if (!_volumeCache.getCharacterVolumes(_character.animationSettings(), volumes)) {
if (!_volumeCache.getVolumes(_character.animationSettings(), volumes)) {
return false;
}

View File

@ -274,8 +274,8 @@ public:
* @param[in] file The file to load. The volume format is determined by the file extension.
*/
bool load(const std::string& file);
bool loadCharacter(const std::string& luaFile);
bool saveCharacter(const char *name);
bool loadAnimationEntity(const std::string& luaFile);
bool saveAnimationEntity(const char *name);
/**
* @brief Shift the whole volume by the given voxel amount

View File

@ -19,7 +19,7 @@ class VolumeCache : public voxelformat::VolumeCache {
private:
bool load(const std::string& fullPath, size_t volumeIndex, voxel::VoxelVolumes& volumes);
public:
bool getCharacterVolumes(const animation::AnimationSettings& settings, voxel::VoxelVolumes& volumes) {
bool getVolumes(const animation::AnimationSettings& settings, voxel::VoxelVolumes& volumes) {
volumes.resize(animation::AnimationSettings::MAX_ENTRIES);
for (size_t i = 0; i < animation::AnimationSettings::MAX_ENTRIES; ++i) {