Respond to building selection commands.

develop
JapaMala 2018-06-29 21:59:48 +05:30
parent 61cf857665
commit 44f461711c
3 changed files with 68 additions and 3 deletions

@ -19,10 +19,18 @@ enum BuildCategory
Track = 7;
}
enum MenuAction
{
MenuNone = 0;
MenuSelect = 1;
MenuCancel = 2;
}
message SidebarState
{
optional proto.enums.ui_sidebar_mode.ui_sidebar_mode mode = 1;
repeated MenuItem menu_items = 2;
optional BuildSelector buildSelector = 3;
}
message MenuItem
@ -31,3 +39,15 @@ message MenuItem
optional int32 existing_count = 2;
optional BuildCategory build_category = 3;
}
message SidebarCommand
{
optional proto.enums.ui_sidebar_mode.ui_sidebar_mode mode = 1;
optional int32 menu_index = 2;
optional MenuAction action = 3;
}
message BuildSelector
{
optional RemoteFortressReader.BuildingType building_type = 1;
}

@ -8,17 +8,24 @@
#include "df/interface_button_construction_category_selectorst.h"
#include "df/ui.h"
#include "df/ui_sidebar_menus.h"
#include "df/viewscreen.h"
#include "df/world.h"
#include "modules/Buildings.h"
#include "modules/Gui.h"
#include "modules/Job.h"
#include "modules/MapCache.h"
#include "modules/Maps.h"
#include "modules/World.h"
#include <queue>
using namespace DFHack;
using namespace RemoteFortressReader;
using namespace df::enums;
using namespace Gui;
extern std::queue<interface_key::interface_key> keyQueue;
command_result SendDigCommand(color_ostream &stream, const DigCommand *in)
{
@ -250,12 +257,50 @@ command_result GetSideMenu(DFHack::color_ostream &stream, const dfproto::EmptyMe
return CR_OK;
}
command_result SetSideMenu(DFHack::color_ostream &stream, const DwarfControl::SidebarState *in)
command_result SetSideMenu(DFHack::color_ostream &stream, const DwarfControl::SidebarCommand *in)
{
auto ui = df::global::ui;
if (in->has_mode())
{
ui->main.mode = (ui_sidebar_mode::ui_sidebar_mode)in->mode();
ui_sidebar_mode::ui_sidebar_mode set_mode = (ui_sidebar_mode::ui_sidebar_mode)in->mode();
if (ui->main.mode != set_mode)
{
ui->main.mode = ui_sidebar_mode::Default;
switch (set_mode)
{
case ui_sidebar_mode::Build:
keyQueue.push(interface_key::D_BUILDING);
default:
ui->main.mode = set_mode;
break;
}
}
}
switch (ui->main.mode)
{
case ui_sidebar_mode::Build:
if (in->has_menu_index())
{
df::global::ui_sidebar_menus->building.cursor = in->menu_index();
}
break;
default:
break;
}
auto viewScreen = getCurViewscreen();
if (in->has_action())
{
switch (in->action())
{
case DwarfControl::MenuSelect:
keyQueue.push(interface_key::SELECT);
break;
case DwarfControl::MenuCancel:
keyQueue.push(interface_key::LEAVESCREEN);
break;
default:
break;
}
}
return CR_OK;
}

@ -8,7 +8,7 @@
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);
DFHack::command_result SetSideMenu(DFHack::color_ostream &stream, const DwarfControl::SidebarState *in);
DFHack::command_result SetSideMenu(DFHack::color_ostream &stream, const DwarfControl::SidebarCommand *in);
#endif // !DWARF_CONTROL_H