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