director.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifndef DIRECTOR_H
  2. #define DIRECTOR_H
  3. #include "galaxy.h"
  4. #include "session_common.h"
  5. #include <boost/circular_buffer.hpp>
  6. class Dispatch;
  7. class MenuDispatch;
  8. class InputDispatch;
  9. class Director {
  10. public:
  11. /**
  12. * This dispatches client_input, server_line and server_prompt.
  13. *
  14. * Set chain.setNotify() to get a response when it is done.
  15. * activate() to begin the chain.
  16. *
  17. * The chain has to_client, to_server functions that dispatch to those
  18. * functions in Dispatch/Director/Session.
  19. */
  20. std::shared_ptr<Dispatch> chain;
  21. StringFunc to_client;
  22. // StringFunc to_server;
  23. std::function<void (const std::string &, const std::string &)> to_server;
  24. // void Session::post(notifyFunc nf)
  25. std::function<void(notifyFunc)> post;
  26. void client_input(const std::string &input);
  27. void server_line(const std::string &line, const std::string &raw_line);
  28. void server_prompt(const std::string &prompt, const std::string &raw_prompt);
  29. bool active;
  30. // not sure if I need these or not?
  31. std::string current_raw_prompt;
  32. std::string current_prompt;
  33. std::string old_prompt;
  34. std::string old_raw_prompt;
  35. void proxy_activate();
  36. void proxy_deactivate();
  37. char game; // 0 = not in a game
  38. // not sure on these... or how I want to use them.
  39. // maybe this is the place for these?!
  40. // IF these are public -- Session can access them. :P
  41. bool show_client;
  42. bool talk_direct;
  43. // maybe these would work better?
  44. std::function<void(bool)> set_show_client;
  45. std::function<void(bool)> set_talk_direct;
  46. Director();
  47. ~Director();
  48. int count;
  49. int current_sector;
  50. Galaxy galaxy;
  51. std::string username;
  52. private:
  53. void build_menu(void);
  54. std::shared_ptr<Dispatch> main_menu;
  55. std::shared_ptr<Dispatch> cim;
  56. std::shared_ptr<Dispatch> config_input;
  57. std::shared_ptr<Dispatch> edit_input;
  58. std::shared_ptr<Dispatch> scripts_menu;
  59. std::shared_ptr<Dispatch> script;
  60. std::shared_ptr<Dispatch> macro_input;
  61. InputDispatch *init_config_input(void);
  62. InputDispatch *init_edit_input(void);
  63. InputDispatch *init_macro_input(void);
  64. MenuDispatch *init_scripts_menu(void);
  65. // notifications
  66. void have_input(void);
  67. void menu_choice(void);
  68. void cim_done(void);
  69. void scripts_done(void);
  70. void information(void);
  71. void config_edit(void);
  72. void config_have_input(void);
  73. std::string config_item; // current item being edited
  74. void macro_edit(void);
  75. void macro_have_input(void);
  76. std::string macro_item;
  77. StringFunc SL_parser;
  78. StringFunc SF_cimline, SF_sectorline, SF_portline, SF_warpline, SF_infoline,
  79. SF_densityline, SF_computer_portline, SF_planetline;
  80. void SL_cimline(const std::string &line);
  81. void SL_thiefline(const std::string &line);
  82. void SL_sectorline(const std::string &line);
  83. void SL_portline(const std::string &line);
  84. void SL_computer_portline(const std::string &line);
  85. void SL_warpline(const std::string &line);
  86. void SL_infoline(const std::string &line);
  87. void SL_densityline(const std::string &line);
  88. void SL_planetline(const std::string &line);
  89. int computer_port_sector;
  90. bool computer_port_done;
  91. boost::circular_buffer<std::string> SL_history{10};
  92. };
  93. #include "dispatchers.h"
  94. #endif