From e9e5113ff7a29500301879628cbc6816c956b1b3 Mon Sep 17 00:00:00 2001 From: Japa Mala Illo Date: Tue, 26 Dec 2017 12:34:46 +0530 Subject: [PATCH] Add careful movement type to proto. Not used yet. --- plugins/proto/AdventureControl.proto | 112 ++++++++++-------- .../adventure_control.cpp | 16 +++ .../remotefortressreader/adventure_control.h | 2 + .../remotefortressreader.cpp | 5 +- 4 files changed, 86 insertions(+), 49 deletions(-) diff --git a/plugins/proto/AdventureControl.proto b/plugins/proto/AdventureControl.proto index 3bef8d939..9c41fdfad 100644 --- a/plugins/proto/AdventureControl.proto +++ b/plugins/proto/AdventureControl.proto @@ -7,53 +7,70 @@ import "RemoteFortressReader.proto"; enum AdvmodeMenu { - Default = 0; - Look = 1; - ConversationAddress = 2; - ConversationSelect = 3; - ConversationSpeak = 4; - Inventory = 5; - Drop = 6; - ThrowItem = 7; - Wear = 8; - Remove = 9; - Interact = 10; - Put = 11; - PutContainer = 12; - Eat = 13; - ThrowAim = 14; - Fire = 15; - Get = 16; - Unk17 = 17; - CombatPrefs = 18; - Companions = 19; - MovementPrefs = 20; - SpeedPrefs = 21; - InteractAction = 22; - MoveCarefully = 23; - Announcements = 24; - UseBuilding = 25; - Travel = 26; - Unk27 = 27; - Unk28 = 28; - SleepConfirm = 29; - SelectInteractionTarget = 30; - Unk31 = 31; - Unk32 = 32; - FallAction = 33; - ViewTracks = 34; - Jump = 35; - Unk36 = 36; - AttackConfirm = 37; - AttackType = 38; - AttackBodypart = 39; - AttackStrike = 40; - Unk41 = 41; - Unk42 = 42; - DodgeDirection = 43; - Unk44 = 44; - Unk45 = 45; - Build = 46; + Default = 0; + Look = 1; + ConversationAddress = 2; + ConversationSelect = 3; + ConversationSpeak = 4; + Inventory = 5; + Drop = 6; + ThrowItem = 7; + Wear = 8; + Remove = 9; + Interact = 10; + Put = 11; + PutContainer = 12; + Eat = 13; + ThrowAim = 14; + Fire = 15; + Get = 16; + Unk17 = 17; + CombatPrefs = 18; + Companions = 19; + MovementPrefs = 20; + SpeedPrefs = 21; + InteractAction = 22; + MoveCarefully = 23; + Announcements = 24; + UseBuilding = 25; + Travel = 26; + Unk27 = 27; + Unk28 = 28; + SleepConfirm = 29; + SelectInteractionTarget = 30; + Unk31 = 31; + Unk32 = 32; + FallAction = 33; + ViewTracks = 34; + Jump = 35; + Unk36 = 36; + AttackConfirm = 37; + AttackType = 38; + AttackBodypart = 39; + AttackStrike = 40; + Unk41 = 41; + Unk42 = 42; + DodgeDirection = 43; + Unk44 = 44; + Unk45 = 45; + Build = 46; +} + +enum CarefulMovementType +{ + DEFAULT_MOVEMENT = 0; + RELEASE_ITEM_HOLD = 1; + RELEASE_TILE_HOLD = 2; + ATTACK_CREATURE = 3; + HOLD_TILE = 4; + MOVE = 5; + CLIMB = 6; + HOLD_ITEM = 7; + BUILDING_INTERACT = 8; + ITEM_INTERACT = 9; + ITEM_INTERACT_GUIDE = 10; + ITEM_INTERACT_RIDE = 11; + ITEM_INTERACT_PUSH = 12; } message MoveCommandParams @@ -66,6 +83,7 @@ message MovementOption optional RemoteFortressReader.Coord dest = 1; optional RemoteFortressReader.Coord source = 2; optional RemoteFortressReader.Coord grab = 3; + optional CarefulMovementType movement_type = 4; } message MenuContents diff --git a/plugins/remotefortressreader/adventure_control.cpp b/plugins/remotefortressreader/adventure_control.cpp index c3c2933ce..971869ac4 100644 --- a/plugins/remotefortressreader/adventure_control.cpp +++ b/plugins/remotefortressreader/adventure_control.cpp @@ -188,6 +188,7 @@ command_result MoveCommand(DFHack::color_ostream &stream, const MoveCommandParam } return CR_OK; } + command_result JumpCommand(DFHack::color_ostream &stream, const MoveCommandParams *in) { if (!in->has_direction()) @@ -262,3 +263,18 @@ command_result MenuQuery(DFHack::color_ostream &stream, const EmptyMessage *in, return CR_OK; } + +command_result MovementSelectCommand(DFHack::color_ostream &stream, const dfproto::IntMessage *in) +{ + if (!(df::global::ui_advmode->menu == ui_advmode_menu::MoveCarefully)) + return CR_OK; + int choice = in->value(); + int page = choice / 5; + int select = choice % 5; + for (int i = 0; i < page; i++) + { + keyQueue.push(interface_key::SECONDSCROLL_PAGEDOWN); + } + keyQueue.push((interface_key::interface_key)(interface_key::OPTION1 + select)); + return CR_OK; +} diff --git a/plugins/remotefortressreader/adventure_control.h b/plugins/remotefortressreader/adventure_control.h index 16d30aeee..b01558047 100644 --- a/plugins/remotefortressreader/adventure_control.h +++ b/plugins/remotefortressreader/adventure_control.h @@ -7,6 +7,8 @@ DFHack::command_result MoveCommand(DFHack::color_ostream &stream, const AdventureControl::MoveCommandParams *in); DFHack::command_result JumpCommand(DFHack::color_ostream &stream, const AdventureControl::MoveCommandParams *in); DFHack::command_result MenuQuery(DFHack::color_ostream &stream, const dfproto::EmptyMessage *in, AdventureControl::MenuContents *out); +DFHack::command_result MovementSelectCommand(DFHack::color_ostream &stream, const dfproto::IntMessage *in); + void KeyUpdate(); diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index ae392c7c1..71f519680 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -293,8 +293,9 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &) svc->addFunction("GetReports", GetReports, SF_ALLOW_REMOTE); svc->addFunction("MoveCommand", MoveCommand, SF_ALLOW_REMOTE); svc->addFunction("JumpCommand", JumpCommand, SF_ALLOW_REMOTE); - svc->addFunction("MenuQuery", MenuQuery, SF_ALLOW_REMOTE); - return svc; + svc->addFunction("MenuQuery", MenuQuery, SF_ALLOW_REMOTE); + svc->addFunction("MovementSelectCommand", MovementSelectCommand, SF_ALLOW_REMOTE); + return svc; } // This is called right before the plugin library is removed from memory.