From 265e229d613cc9b81c27d53d12066880a702d89c Mon Sep 17 00:00:00 2001 From: Japa Date: Tue, 27 Feb 2018 19:58:07 +0530 Subject: [PATCH] Send all relavent generated instruement information over RFR --- library/xml | 2 +- plugins/proto/ItemdefInstrument.proto | 104 +++++++++++++++++++ plugins/proto/RemoteFortressReader.proto | 3 + plugins/remotefortressreader/CMakeLists.txt | 1 + plugins/remotefortressreader/item_reader.cpp | 79 ++++++++++++++ 5 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 plugins/proto/ItemdefInstrument.proto diff --git a/library/xml b/library/xml index 2794f8a6d..5fea1ef62 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 2794f8a6d7405d4858bac486a0bb17b94740c142 +Subproject commit 5fea1ef62a040d24a9efa31a9a6dfd8eb1eea3f6 diff --git a/plugins/proto/ItemdefInstrument.proto b/plugins/proto/ItemdefInstrument.proto new file mode 100644 index 000000000..977e86f90 --- /dev/null +++ b/plugins/proto/ItemdefInstrument.proto @@ -0,0 +1,104 @@ +package ItemdefInstrument; + +//Attempts to provide a complete framework for reading everything from a fortress needed for vizualization +option optimize_for = LITE_RUNTIME; + +message InstrumentFlags + { + optional bool indefinite_pitch = 1; + optional bool placed_as_building = 2; + optional bool metal_mat = 3; + optional bool stone_mat = 4; + optional bool wood_mat = 5; + optional bool glass_mat = 6; + optional bool ceramic_mat = 7; + optional bool shell_mat = 8; + optional bool bone_mat = 9; +} + +enum PitchChoiceType +{ + MEMBRANE_POSITION = 0; + SUBPART_CHOICE = 1; + KEYBOARD = 2; + STOPPING_FRET = 3; + STOPPING_AGAINST_BODY = 4; + STOPPING_HOLE = 5; + STOPPING_HOLE_KEY = 6; + SLIDE = 7; + HARMONIC_SERIES = 8; + VALVE_ROUTES_AIR = 9; + BP_IN_BELL = 10; + FOOT_PEDALS = 11; +} + +enum SoundProductionType +{ + PLUCKED_BY_BP = 0; + PLUCKED = 1; + BOWED = 2; + STRUCK_BY_BP = 3; + STRUCK = 4; + VIBRATE_BP_AGAINST_OPENING = 5; + BLOW_AGAINST_FIPPLE = 6; + BLOW_OVER_OPENING_SIDE = 7; + BLOW_OVER_OPENING_END = 8; + BLOW_OVER_SINGLE_REED = 9; + BLOW_OVER_DOUBLE_REED = 10; + BLOW_OVER_FREE_REED = 11; + STRUCK_TOGETHER = 12; + SHAKEN = 13; + SCRAPED = 14; + FRICTION = 15; + RESONATOR = 16; + BAG_OVER_REED = 17; + AIR_OVER_REED = 18; + AIR_OVER_FREE_REED = 19; + AIR_AGAINST_FIPPLE = 20; +} + +enum TuningType +{ + PEGS = 0; + ADJUSTABLE_BRIDGES = 1; + CROOKS = 2; + TIGHTENING = 4; + LEVERS = 5; +} + +message InstrumentPiece +{ + optional string type = 1; + optional string id = 2; + optional string name = 3; + optional string name_plural = 4; +} + +message InstrumentRegister +{ + optional int32 pitch_range_min = 1; + optional int32 pitch_range_max = 2; +} + +message InstrumentDef +{ + optional InstrumentFlags flags = 1; + optional int32 size = 2; + optional int32 value = 3; + optional int32 material_size = 4; + repeated InstrumentPiece pieces = 5; + optional int32 pitch_range_min = 6; + optional int32 pitch_range_max = 7; + optional int32 volume_mb_min = 8; + optional int32 volume_mb_max = 9; + repeated SoundProductionType sound_production = 10; + repeated string sound_production_parm1 = 11; + repeated string sound_production_parm2 = 12; + repeated PitchChoiceType pitch_choice = 13; + repeated string pitch_choice_parm1 = 14; + repeated string pitch_choice_parm2 = 15; + repeated TuningType tuning = 16; + repeated string tuning_parm = 17; + repeated InstrumentRegister registers = 18; + optional string description = 19; +} \ No newline at end of file diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index 35f5b0abe..b2e5eae4d 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -3,6 +3,8 @@ package RemoteFortressReader; //Attempts to provide a complete framework for reading everything from a fortress needed for vizualization option optimize_for = LITE_RUNTIME; +import "ItemdefInstrument.proto"; + //We use shapes, etc, because the actual tiletypes may differ between DF versions. enum TiletypeShape { @@ -329,6 +331,7 @@ message MaterialDefinition{ optional string id = 2; optional string name = 3; optional ColorDefinition state_color = 4; //Simplifying colors to assume room temperature. + optional ItemdefInstrument.InstrumentDef instrument = 5; } message BuildingType diff --git a/plugins/remotefortressreader/CMakeLists.txt b/plugins/remotefortressreader/CMakeLists.txt index 10cc21047..ad61c94ce 100644 --- a/plugins/remotefortressreader/CMakeLists.txt +++ b/plugins/remotefortressreader/CMakeLists.txt @@ -17,6 +17,7 @@ SET(PROJECT_HDRS SET(PROJECT_PROTO ../../proto/RemoteFortressReader ../../proto/AdventureControl + ../../proto/ItemdefInstrument ) SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE) diff --git a/plugins/remotefortressreader/item_reader.cpp b/plugins/remotefortressreader/item_reader.cpp index 59b1f36e7..2adcce67f 100644 --- a/plugins/remotefortressreader/item_reader.cpp +++ b/plugins/remotefortressreader/item_reader.cpp @@ -1,6 +1,7 @@ #include "item_reader.h" #include "Core.h" #include "VersionInfo.h" +#include "ItemdefInstrument.pb.h" #include "df/art_image.h" #include "df/art_image_chunk.h" @@ -16,6 +17,8 @@ #include "df/art_image_property_transitive_verbst.h" #include "df/art_image_ref.h" #include "df/descriptor_shape.h" +#include "df/instrument_piece.h" +#include "df/instrument_register.h" #include "df/item_type.h" #include "df/item_constructed.h" #include "df/item_gemst.h" @@ -23,6 +26,7 @@ #include "df/item_statuest.h" #include "df/item_threadst.h" #include "df/item_toolst.h" +#include "df/itemdef_instrumentst.h" #include "df/itemimprovement.h" #include "df/itemimprovement_art_imagest.h" #include "df/itemimprovement_bandsst.h" @@ -46,6 +50,7 @@ using namespace DFHack; using namespace df::enums; using namespace RemoteFortressReader; +using namespace ItemdefInstrument; using namespace std; using namespace df::global; @@ -565,6 +570,80 @@ DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack:: mat_def->mutable_mat_pair()->set_mat_index(i); df::itemdef * item = Items::getSubtypeDef(it, i); mat_def->set_id(ENUM_KEY_STR(item_type, it) + "/" + item->id); + switch (it) + { + case df::enums::item_type::INSTRUMENT: + { + VIRTUAL_CAST_VAR(instrument, df::itemdef_instrumentst, item); + mat_def->set_name(instrument->name); + auto send_instrument = mat_def->mutable_instrument(); + auto flags = send_instrument->mutable_flags(); + flags->set_indefinite_pitch(instrument->flags.is_set(instrument_flags::INDEFINITE_PITCH)); + flags->set_placed_as_building(instrument->flags.is_set(instrument_flags::PLACED_AS_BUILDING)); + flags->set_metal_mat(instrument->flags.is_set(instrument_flags::METAL_MAT)); + flags->set_stone_mat(instrument->flags.is_set(instrument_flags::STONE_MAT)); + flags->set_wood_mat(instrument->flags.is_set(instrument_flags::WOOD_MAT)); + flags->set_glass_mat(instrument->flags.is_set(instrument_flags::GLASS_MAT)); + flags->set_ceramic_mat(instrument->flags.is_set(instrument_flags::CERAMIC_MAT)); + flags->set_shell_mat(instrument->flags.is_set(instrument_flags::SHELL_MAT)); + flags->set_bone_mat(instrument->flags.is_set(instrument_flags::BONE_MAT)); + send_instrument->set_size(instrument->size); + send_instrument->set_value(instrument->value); + send_instrument->set_material_size(instrument->material_size); + for (int j = 0; j < instrument->pieces.size(); j++) + { + auto piece = send_instrument->add_pieces(); + piece->set_type(instrument->pieces[i]->type); + piece->set_id(instrument->pieces[i]->id); + piece->set_name(instrument->pieces[i]->name); + piece->set_name_plural(instrument->pieces[i]->name_plural); + } + send_instrument->set_pitch_range_min(instrument->pitch_range_min); + send_instrument->set_pitch_range_max(instrument->pitch_range_max); + for (int j = 0; j < instrument->sound_production.size(); j++) + { + send_instrument->add_sound_production((SoundProductionType)instrument->sound_production[j]); + } + for (int j = 0; j < instrument->sound_production_parm1.size(); j++) + { + send_instrument->add_sound_production_parm1(*(instrument->sound_production_parm1[j])); + } + for (int j = 0; j < instrument->sound_production_parm2.size(); j++) + { + send_instrument->add_sound_production_parm2(*(instrument->sound_production_parm2[j])); + } + for (int j = 0; j < instrument->pitch_choice.size(); j++) + { + send_instrument->add_pitch_choice((PitchChoiceType)instrument->pitch_choice[j]); + } + for (int j = 0; j < instrument->pitch_choice_parm1.size(); j++) + { + send_instrument->add_pitch_choice_parm1(*(instrument->pitch_choice_parm1[j])); + } + for (int j = 0; j < instrument->pitch_choice_parm2.size(); j++) + { + send_instrument->add_pitch_choice_parm2(*(instrument->pitch_choice_parm2[j])); + } + for (int j = 0; j < instrument->tuning.size(); j++) + { + send_instrument->add_tuning((TuningType)instrument->tuning[j]); + } + for (int j = 0; j < instrument->tuning_parm.size(); j++) + { + send_instrument->add_tuning_parm(*(instrument->tuning_parm[j])); + } + for (int j = 0; j < instrument->registers.size(); j++) + { + auto reg = send_instrument->add_registers(); + reg->set_pitch_range_min(instrument->registers[j]->pitch_range_min); + reg->set_pitch_range_max(instrument->registers[j]->pitch_range_max); + } + send_instrument->set_description(instrument->description); + break; + } + default: + break; + } } } }