public override void Awake () { atlas = StatesButton.CreateTextureAtlas("icons.book_bckgrnd.png", "ResilientOwnersBook", this.atlas.material, 512, 512, 1); backgroundSprite = "ResilientOwnersBook_0"; }
/********** UI building ***********/ void AddComponents() { m_bookPanel = this.gameObject.AddComponent <BookPanel>(); m_bookPanel.transform.parent = m_zonedBuildingInfoPanel.component.transform; m_bookPanel.size = new Vector3(m_zonedBuildingInfoPanel.component.size.x, m_zonedBuildingInfoPanel.component.size.y);//maybe excahnge line with prvious one? m_bookPanel.position = new Vector3(-m_bookPanel.size.x - m_bookInfoPanelLeftMargin, +m_bookPanel.size.y); m_bookInfoPanelInitialHeight = m_bookPanel.height; m_bookInfoPanelPageWidth = m_bookPanel.size.x / 2 - m_bookInfoPanelLeftMargin - m_bookInfoPanelRightPadding; m_bookInfoPanelLeftMarginPage2 = m_bookPanel.size.x / 2 + m_bookInfoPanelLeftMargin; m_bookInfoPanel = m_bookPanel; m_historyTitleLabel = m_bookInfoPanel.AddUIComponent <UILabel> (); m_historyTitleLabel.name = "History Title"; m_historyTitleLabel.textScale = 1.2f; m_historyTitleLabel.text = Localization.trad.GetHistoryTitle(); m_historyTitleLabel.textColor = m_bookTextColor; m_recordTitleLabel = m_bookInfoPanel.AddUIComponent <UILabel> (); m_recordTitleLabel.name = "Record Title"; m_recordTitleLabel.textScale = 1.2f; m_recordTitleLabel.text = Localization.trad.GetRecordTitle(); m_recordTitleLabel.textColor = m_bookTextColor; m_descriptionTextField = m_bookInfoPanel.AddUIComponent <UIMultilineTextField> (); m_descriptionTextField.name = "Building Description"; m_descriptionTextField.text = "Enter description"; m_descriptionTextField.textScale = 0.8f; m_descriptionTextField.width = m_bookInfoPanelPageWidth; m_descriptionTextField.height = 100f; m_descriptionTextField.disabledTextColor = new Color32(7, 7, 7, 255); m_descriptionTextField.textColor = m_bookTextColor; m_descriptionTextField.eventTextSubmitted += (component, param) => { SaveDescription(param); }; // m_descriptionTextField.title = "Description"; // m_descriptionTextField.showTitle = true; m_descriptionTextField.defaultText = Localization.trad.GetDescriptionEmpty(); m_descriptionTextField.eventHeightChange += (component, height) => { ResizePanelHeight(); }; int spriteWidth = 32; int spriteHeight = 32; string[] tooltips = { Localization.trad.GetTooltipOff(), Localization.trad.GetTooltipHistoryOn(), Localization.trad.GetTooltipResiliencyOn() }; m_resilientStateButton = new StatesButton(m_zonedBuildingInfoPanel.component, spriteWidth, spriteHeight, 3, "icons.book.png", "ResilientOwners", tooltips); m_resilientStateButton.msb.eventActiveStateIndexChanged += (component, value) => { if (!m_allowEvents) { return; } switch (value) { case 0: m_info.UnsuscribeBuilding(m_currentSelectedBuildingID); HideHistory(); break; case 1: m_info.AddBuilding(m_currentSelectedBuildingID, false); ShowHistory(); CheckUpdateUI(m_currentSelectedBuildingID); break; case 2: m_info.AddBuilding(m_currentSelectedBuildingID, true); ShowHistory(); break; } }; m_resilientStateButton.msb.AlignTo(m_zonedBuildingInfoPanel.component, UIAlignAnchor.TopRight); m_resilientStateButton.msb.relativePosition += new Vector3(-50f, 60f, 0f); m_familiesHistoryLabel = m_bookInfoPanel.AddUIComponent <UILabel> (); m_familiesHistoryLabel.name = "Families History"; m_familiesHistoryLabel.text = Localization.trad.GetEmptyHouse(); m_familiesHistoryLabel.textScale = 0.8f; m_familiesHistoryLabel.textColor = m_bookTextColor; m_familiesHistoryLabel.width = m_bookInfoPanelPageWidth; m_familiesHistoryLabel.wordWrap = true; m_familiesHistoryLabel.autoSize = false; m_familiesHistoryLabel.autoHeight = true; m_activatedDateLabel = m_bookInfoPanel.AddUIComponent <UILabel> (); m_activatedDateLabel.name = "Activation Date"; m_activatedDateLabel.text = Localization.trad.GetActivationDate(); m_activatedDateLabel.textScale = 0.8f; m_activatedDateLabel.textColor = m_bookTextColor; m_activatedDateLabel.width = m_bookInfoPanelPageWidth; m_ageLabel = m_bookInfoPanel.AddUIComponent <UILabel> (); m_ageLabel.name = "Age"; m_ageLabel.text = Localization.trad.GetActivationDate(); m_ageLabel.textScale = 0.8f; m_ageLabel.textColor = m_bookTextColor; m_ageLabel.width = m_bookInfoPanelPageWidth; m_statsLabel = m_bookInfoPanel.AddUIComponent <UILabel> (); m_statsLabel.name = "Stats"; m_statsLabel.text = Localization.trad.GetEmptyHouse(); //long enough string m_statsLabel.textScale = 0.8f; m_statsLabel.textColor = m_bookTextColor; m_statsLabel.width = m_bookInfoPanelPageWidth; m_statsLabel.wordWrap = true; m_statsLabel.autoSize = false; m_statsLabel.autoHeight = true; placeComponents(); // m_zonedBuildingInfoPanelComponent.eventVisibilityChanged +=(component, param) => // { // if(param) // OnSelected(); // //m_info.StartCoroutine(OnSelected());//StartCoroutine on a MonoBehaviour... // }; //m_zonedBuildingInfoPanel.m_IsEmbbeded = true;//one of the condition call to OnPositionChanged, ensure it m_zonedBuildingInfoPanel.component.eventPositionChanged += (inst1, inst2) => { if (m_zonedBuildingInfoPanel.component.isVisible) { OnSelected(); } }; m_zonedBuildingInfoPanel.component.eventOpacityChanged += (inst1, inst2) => { if (m_zonedBuildingInfoPanel.component.isVisible) { OnSelected(); } }; //m_zonedBuildingInfoPanel.component.eventClick += (inst1, inst2) => //{ // if (m_zonedBuildingInfoPanel.component.isVisible) // OnSelected(); //}; // district panel modifications string[] tooltips2 = { Localization.trad.GetTooltipDistrictOff(), Localization.trad.GetTooltipDistrictOn() }; m_resilientStateButton2 = new StatesButton(m_districtInfoPanel.component, spriteWidth, spriteHeight, 2, "icons.star.png", "ResilientOwnersDistricts", tooltips2); m_resilientStateButton2.msb.eventActiveStateIndexChanged += (component, value) => { if (!m_allowEvents) { return; } switch (value) { case 0: m_info.UnsuscribeDistrict(m_currentSelectedDistrictID); break; case 1: m_info.AddDistrict(m_currentSelectedDistrictID); break; } }; m_resilientStateButton2.msb.AlignTo(m_districtInfoPanel.component, UIAlignAnchor.TopRight); m_resilientStateButton2.msb.relativePosition += new Vector3(-20f, 90f, 0f); m_districtInfoPanel.component.eventPositionChanged += (inst1, inst2) => { if (m_districtInfoPanel.component.isVisible) { OnSelectedDistricts(); } }; m_districtInfoPanel.component.eventOpacityChanged += (inst1, inst2) => { if (m_districtInfoPanel.component.isVisible) { OnSelectedDistricts(); } }; }