scriptconsoletabbase.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. class ScriptConsoleTabBase
  2. {
  3. protected int m_Id;
  4. protected bool m_IsSelected;
  5. protected bool m_IsShiftDown;
  6. protected Widget m_ParentRoot;
  7. protected Widget m_Root;
  8. protected Widget m_Button;
  9. protected ScriptConsole m_ScriptConsole;
  10. protected ScriptConsoleTabBase m_Parent;//for subtabs
  11. protected PluginConfigDebugProfile m_ConfigDebugProfile;
  12. protected PluginConfigDebugProfileFixed m_ConfigDebugProfileFixed;
  13. void ScriptConsoleTabBase(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent = null)
  14. {
  15. m_Button = button;
  16. m_ScriptConsole = console;
  17. m_Root = root;
  18. if (parent)
  19. m_ParentRoot = parent.GetRoot();
  20. else
  21. m_ParentRoot = console.layoutRoot;
  22. m_ConfigDebugProfile = PluginConfigDebugProfile.Cast(GetPlugin(PluginConfigDebugProfile));
  23. m_ConfigDebugProfileFixed = PluginConfigDebugProfileFixed.Cast(GetPlugin(PluginConfigDebugProfileFixed));
  24. }
  25. void Init(int id)
  26. {
  27. m_Id = id;
  28. }
  29. int GetID()
  30. {
  31. return m_Id;
  32. }
  33. Widget GetRoot()
  34. {
  35. return m_Root;
  36. }
  37. bool IsSelected()
  38. {
  39. return m_IsSelected;
  40. }
  41. void Select(bool select, ScriptConsoleTabBase selectedHandler)
  42. {
  43. m_IsSelected = select;
  44. if (m_Root)
  45. {
  46. Show(select, selectedHandler);
  47. ButtonWidget btn = ButtonWidget.Cast(m_Button);
  48. if (btn)
  49. btn.SetState(select);
  50. }
  51. if (select)
  52. OnSelected();
  53. }
  54. void OnSelected();
  55. void Show(bool show, ScriptConsoleTabBase selectedHandler)
  56. {
  57. m_Root.Show(show);
  58. m_Root.Enable(show);
  59. }
  60. Widget GetButton()
  61. {
  62. return m_Button;
  63. }
  64. void Update(float timeslice)
  65. {
  66. m_IsShiftDown = KeyState(KeyCode.KC_LSHIFT) || KeyState(KeyCode.KC_RSHIFT);
  67. }
  68. bool OnChange(Widget w, int x, int y, bool finished);
  69. bool OnClick(Widget w, int x, int y, int button);
  70. bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn);
  71. bool OnKeyDown(Widget w, int x, int y, int key);
  72. bool OnDoubleClick(Widget w, int x, int y, int button);
  73. void OnRPCEx(int rpc_type, ParamsReadContext ctx);
  74. bool OnMouseButtonDown(Widget w, int x, int y, int button);
  75. bool OnKeyPress(Widget w, int x, int y, int key);
  76. protected void AddItemToClipboard(TextListboxWidget text_listbox_widget)
  77. {
  78. int selected_row_index = text_listbox_widget.GetSelectedRow();
  79. if (selected_row_index != -1)
  80. {
  81. string item_name;
  82. text_listbox_widget.GetItemText(selected_row_index, 0, item_name);
  83. GetGame().CopyToClipboard(item_name);
  84. }
  85. }
  86. }