From 93c3418f974bac277c6136d80d97883c5d7a3b72 Mon Sep 17 00:00:00 2001 From: JapaMala Date: Sun, 24 Jun 2018 14:45:57 +0530 Subject: [PATCH] Added a simple function to get the current sidebar mode in fort mode. --- plugins/proto/DwarfControl.proto | 12 ++++ plugins/proto/ui_sidebar_mode.proto | 63 +++++++++++++++++++ plugins/remotefortressreader/CMakeLists.txt | 2 + .../remotefortressreader/dwarf_control.cpp | 7 +++ plugins/remotefortressreader/dwarf_control.h | 2 + .../remotefortressreader.cpp | 1 + 6 files changed, 87 insertions(+) create mode 100644 plugins/proto/DwarfControl.proto create mode 100644 plugins/proto/ui_sidebar_mode.proto diff --git a/plugins/proto/DwarfControl.proto b/plugins/proto/DwarfControl.proto new file mode 100644 index 000000000..2918b5a82 --- /dev/null +++ b/plugins/proto/DwarfControl.proto @@ -0,0 +1,12 @@ +syntax = "proto2"; +package DwarfControl; + +//Attempts to provide a complete framework for reading everything from a fortress needed for vizualization +option optimize_for = LITE_RUNTIME; + +import "ui_sidebar_mode.proto"; + +message SidebarState +{ + optional proto.enums.ui_sidebar_mode.ui_sidebar_mode mode = 1; +} \ No newline at end of file diff --git a/plugins/proto/ui_sidebar_mode.proto b/plugins/proto/ui_sidebar_mode.proto new file mode 100644 index 000000000..26b570d21 --- /dev/null +++ b/plugins/proto/ui_sidebar_mode.proto @@ -0,0 +1,63 @@ +package proto.enums.ui_sidebar_mode; + +//Attempts to provide a complete framework for reading everything from a fortress needed for vizualization +option optimize_for = LITE_RUNTIME; + +enum ui_sidebar_mode +{ + Default = 1; + Squads = 2; + DesignateMine = 3; + DesignateRemoveRamps = 4; + DesignateUpStair = 5; + DesignateDownStair = 6; + DesignateUpDownStair = 7; + DesignateUpRamp = 8; + DesignateChannel = 9; + DesignateGatherPlants = 10; + DesignateRemoveDesignation = 11; + DesignateSmooth = 12; + DesignateCarveTrack = 13; + DesignateEngrave = 14; + DesignateCarveFortification = 15; + Stockpiles = 16; + Build = 17; + QueryBuilding = 18; + Orders = 19; + OrdersForbid = 20; + OrdersRefuse = 21; + OrdersWorkshop = 22; + OrdersZone = 23; + BuildingItems = 24; + ViewUnits = 25; + LookAround = 26; + DesignateItemsClaim = 27; + DesignateItemsForbid = 28; + DesignateItemsMelt = 29; + DesignateItemsUnmelt = 30; + DesignateItemsDump = 31; + DesignateItemsUndump = 32; + DesignateItemsHide = 33; + DesignateItemsUnhide = 34; + DesignateChopTrees = 35; + DesignateToggleEngravings = 36; + DesignateToggleMarker = 37; + Hotkeys = 38; + DesignateTrafficHigh = 39; + DesignateTrafficNormal = 40; + DesignateTrafficLow = 41; + DesignateTrafficRestricted = 42; + Zones = 43; + ZonesPenInfo = 44; + ZonesPitInfo = 45; + ZonesHospitalInfo = 46; + ZonesGatherInfo = 47; + DesignateRemoveConstruction = 48; + DepotAccess = 49; + NotesPoints = 50; + NotesRoutes = 51; + Burrows = 52; + Hauling = 53; + ArenaWeather = 54; + ArenaTrees = 55; +} \ No newline at end of file diff --git a/plugins/remotefortressreader/CMakeLists.txt b/plugins/remotefortressreader/CMakeLists.txt index c7c9d74fe..954dbcbbf 100644 --- a/plugins/remotefortressreader/CMakeLists.txt +++ b/plugins/remotefortressreader/CMakeLists.txt @@ -20,6 +20,8 @@ SET(PROJECT_PROTO ${CMAKE_CURRENT_SOURCE_DIR}/../proto/RemoteFortressReader.pb.cc ${CMAKE_CURRENT_SOURCE_DIR}/../proto/AdventureControl.pb.cc ${CMAKE_CURRENT_SOURCE_DIR}/../proto/ItemdefInstrument.pb.cc + ${CMAKE_CURRENT_SOURCE_DIR}/../proto/DwarfControl.pb.cc + ${CMAKE_CURRENT_SOURCE_DIR}/../proto/ui_sidebar_mode.pb.cc ) SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE) diff --git a/plugins/remotefortressreader/dwarf_control.cpp b/plugins/remotefortressreader/dwarf_control.cpp index 461b2f89e..3bb4d4af6 100644 --- a/plugins/remotefortressreader/dwarf_control.cpp +++ b/plugins/remotefortressreader/dwarf_control.cpp @@ -4,6 +4,7 @@ #include "df/job.h" #include "df/job_list_link.h" +#include "df/ui.h" #include "df/world.h" #include "modules/Buildings.h" @@ -15,6 +16,7 @@ using namespace DFHack; using namespace RemoteFortressReader; + command_result SendDigCommand(color_ostream &stream, const DigCommand *in) { MapExtras::MapCache mc; @@ -99,3 +101,8 @@ command_result SetPauseState(color_ostream &stream, const SingleBool *in) DFHack::World::SetPauseState(in->value()); return CR_OK; } + +command_result GetSideMenu(DFHack::color_ostream &stream, const dfproto::EmptyMessage *in, DwarfControl::SidebarState *out) +{ + out->set_mode((proto::enums::ui_sidebar_mode::ui_sidebar_mode)df::global::ui->main.mode); +} diff --git a/plugins/remotefortressreader/dwarf_control.h b/plugins/remotefortressreader/dwarf_control.h index bb08e8b7a..b66309d9e 100644 --- a/plugins/remotefortressreader/dwarf_control.h +++ b/plugins/remotefortressreader/dwarf_control.h @@ -3,9 +3,11 @@ #include "RemoteClient.h" #include "RemoteFortressReader.pb.h" +#include "DwarfControl.pb.h" DFHack::command_result SendDigCommand(DFHack::color_ostream &stream, const RemoteFortressReader::DigCommand *in); DFHack::command_result SetPauseState(DFHack::color_ostream &stream, const RemoteFortressReader::SingleBool *in); +DFHack::command_result GetSideMenu(DFHack::color_ostream &stream, const dfproto::EmptyMessage *in, DwarfControl::SidebarState *out); #endif // !DWARF_CONTROL_H diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index 8f3ac5b04..baae99c5b 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -328,6 +328,7 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &) svc->addFunction("MovementSelectCommand", MovementSelectCommand, SF_ALLOW_REMOTE); svc->addFunction("MiscMoveCommand", MiscMoveCommand, SF_ALLOW_REMOTE); svc->addFunction("GetLanguage", GetLanguage, SF_ALLOW_REMOTE); + svc->addFunction("GetSideMenu", GetSideMenu, SF_ALLOW_REMOTE); return svc; }