| | 1 | | using System; |
| | 2 | |
|
| | 3 | | internal class LeftMenuHandler : IDisposable |
| | 4 | | { |
| | 5 | | private readonly IBuilderProjectsPanelView view; |
| | 6 | | private readonly ISectionsController sectionsController; |
| | 7 | |
|
| | 8 | | private bool isMainPanel = false; |
| | 9 | | private SectionId lastMainSectionId; |
| | 10 | |
|
| 16 | 11 | | public LeftMenuHandler(IBuilderProjectsPanelView view, ISectionsController sectionsController) |
| | 12 | | { |
| 16 | 13 | | this.view = view; |
| 16 | 14 | | this.sectionsController = sectionsController; |
| | 15 | |
|
| 16 | 16 | | view.OnBackToMainMenuPressed += OnSceneSettingsBackPressed; |
| | 17 | |
|
| 16 | 18 | | sectionsController.OnOpenSectionId += OnOpenSectionId; |
| 16 | 19 | | LeftMenuButtonToggleView.OnToggleOn += OnToggleOn; |
| 16 | 20 | | } |
| | 21 | |
|
| | 22 | | public void Dispose() |
| | 23 | | { |
| 16 | 24 | | view.OnBackToMainMenuPressed -= OnSceneSettingsBackPressed; |
| | 25 | |
|
| 16 | 26 | | sectionsController.OnOpenSectionId -= OnOpenSectionId; |
| 16 | 27 | | LeftMenuButtonToggleView.OnToggleOn -= OnToggleOn; |
| 16 | 28 | | } |
| | 29 | |
|
| | 30 | | public void SetToPreviousMainPanel() |
| | 31 | | { |
| 1 | 32 | | if (isMainPanel) |
| 0 | 33 | | return; |
| | 34 | |
|
| 1 | 35 | | sectionsController.OpenSection(lastMainSectionId); |
| 1 | 36 | | } |
| | 37 | |
|
| 0 | 38 | | void OnToggleOn(LeftMenuButtonToggleView toggle) { sectionsController.OpenSection(toggle.openSection); } |
| | 39 | |
|
| | 40 | | void OnOpenSectionId(SectionId sectionId) |
| | 41 | | { |
| 3 | 42 | | view.SetTogglOnWithoutNotify(sectionId); |
| | 43 | |
|
| 3 | 44 | | bool isMainPanelSection = sectionId == SectionId.SCENES_MAIN || |
| | 45 | | sectionId == SectionId.SCENES_DEPLOYED || |
| | 46 | | sectionId == SectionId.SCENES_PROJECT || |
| | 47 | | sectionId == SectionId.LAND; |
| | 48 | |
|
| 3 | 49 | | if (isMainPanelSection) |
| | 50 | | { |
| 2 | 51 | | lastMainSectionId = sectionId; |
| 2 | 52 | | SetMainLeftPanel(); |
| 2 | 53 | | } |
| | 54 | | else |
| | 55 | | { |
| 1 | 56 | | SetSettingsLeftPanel(); |
| | 57 | | } |
| 1 | 58 | | } |
| | 59 | |
|
| 2 | 60 | | void OnSceneSettingsBackPressed() { SetToPreviousMainPanel(); } |
| | 61 | |
|
| | 62 | | void SetMainLeftPanel() |
| | 63 | | { |
| 2 | 64 | | if (isMainPanel) |
| 0 | 65 | | return; |
| | 66 | |
|
| 2 | 67 | | isMainPanel = true; |
| 2 | 68 | | view.SetMainLeftPanel(); |
| 2 | 69 | | } |
| | 70 | |
|
| | 71 | | void SetSettingsLeftPanel() |
| | 72 | | { |
| 1 | 73 | | if (!isMainPanel) |
| 0 | 74 | | return; |
| | 75 | |
|
| 1 | 76 | | isMainPanel = false; |
| 1 | 77 | | view.SetProjectSettingsLeftPanel(); |
| 1 | 78 | | } |
| | 79 | | } |