Exemple #1
0
        public UiSearchCreate(UiSearch2 _search) : base(_search.Menu.frame.NxOverlay)
        {
            m_UiSearch = _search;

            //10 params max

            /*Allegiance
             * Economy
             * Government
             * Needs Permit
             * Population
             * 100000000000
             * Power
             * Power State
             * Security
             * State
             * Secondary Economy*/
            // InitGrid(8, 20);
            x                = 5;
            y                = 70;
            width            = NxMenu.Width - 10;
            height           = NxMenu.Height - 90 - 5;
            RelativeChildPos = true;


            int _cx = 0;
            int _cy = 0;

            int boxsize        = 15;
            int boxPlusPadding = boxsize + 4;

            int spaceBetweenCheckbox = 8;

            int spaceBetweenCategories = 35;

            Color breakLineColor = EDColors.getColor(EDColors.GREEN, 0.5f);


            //Allegiance
            Add(new NxSimpleText(0, 0, "Allegiance", EDColors.BLUE, 18, NxFonts.EuroCapital));
            Add(new NxRectangle(5, _cy + 20, m_UiSearch.Menu.frame.WindowWidth - 10, 1, breakLineColor));
            _cy += 24;
            foreach (string s in SpanshDatas.allegiance)
            {
                int _width = (int)m_UiSearch.Menu.frame.NxGraphics.MeasureString(s, NxCheckbox.DefaultFont).Width + boxPlusPadding;
                _cx += spaceBetweenCheckbox;
                NxCheckbox b = new NxCheckbox(_cx, _cy, _width, 30, s, m_UiSearch.Menu)
                {
                    BoxSize = boxsize
                };
                b.Obj = nameof(SpanshDatas.allegiance);
                Add(b);
                _cx += _width;
            }

            //Permit
            _cx += 25;
            int permitCatPositionX = _cx;

            Add(new NxSimpleText(_cx, 0, "Need a permit", EDColors.BLUE, 18, NxFonts.EuroCapital));
            for (int i = 0; i < 3; i++)
            {
                string _cbText = "???";
                switch (i)
                {
                case 0: _cbText = "Yes"; break;

                case 1: _cbText = "No"; break;

                case 2: _cbText = "Mine only"; break;
                }
                int _width = (int)m_UiSearch.Menu.frame.NxGraphics.MeasureString(_cbText, NxCheckbox.DefaultFont).Width + boxPlusPadding;

                NxCheckbox b = new NxCheckbox(_cx, _cy, _width, 30, _cbText, m_UiSearch.Menu)
                {
                    BoxSize = boxsize, CircleBox = true
                };
                m_CbPermits[i] = b;
                b.onClick     += onPermitChanged;
                b.Obj          = "permitOptions";
                if (i == 2)
                {
                    b.Checked = true;
                }
                Add(b);
                _cx += _width;
                _cx += 15;
            }


            _cx  = 0;
            _cy += spaceBetweenCategories;
            //Economy
            Add(new NxSimpleText(_cx, _cy, "Economy", EDColors.BLUE, 18, NxFonts.EuroCapital));
            Add(new NxRectangle(5, _cy + 20, m_UiSearch.Menu.frame.WindowWidth - 10, 1, breakLineColor));
            _cy += 24;
            foreach (string s in SpanshDatas.economy)
            {
                int _width = (int)m_UiSearch.Menu.frame.NxGraphics.MeasureString(s, NxCheckbox.DefaultFont).Width + boxPlusPadding;
                if (_cx + _width + 5 > m_UiSearch.Menu.frame.WindowWidth)
                {
                    _cx  = 0;
                    _cy += 32;
                }
                _cx += spaceBetweenCheckbox;
                NxCheckbox b = new NxCheckbox(_cx, _cy, _width, 30, s, m_UiSearch.Menu)
                {
                    BoxSize = boxsize
                };
                b.Obj = nameof(SpanshDatas.economy);
                Add(b);
                _cx += _width;
            }

            _cx  = 0;
            _cy += spaceBetweenCategories;
            //Governement
            Add(new NxSimpleText(_cx, _cy, "Government", EDColors.BLUE, 18, NxFonts.EuroCapital));
            Add(new NxRectangle(5, _cy + 20, m_UiSearch.Menu.frame.WindowWidth - 10, 1, breakLineColor));
            _cy += 24;
            foreach (string s in SpanshDatas.government)
            {
                int _width = (int)m_UiSearch.Menu.frame.NxGraphics.MeasureString(s, NxCheckbox.DefaultFont).Width + boxPlusPadding;
                if (_cx + _width + 5 > m_UiSearch.Menu.frame.WindowWidth)
                {
                    _cx  = 0;
                    _cy += 32;
                }
                _cx += spaceBetweenCheckbox;
                NxCheckbox b = new NxCheckbox(_cx, _cy, _width, 30, s, m_UiSearch.Menu)
                {
                    BoxSize = boxsize
                };
                b.Obj = nameof(SpanshDatas.government);
                Add(b);
                _cx += _width;
            }


            _cx  = 0;
            _cy += spaceBetweenCategories;
            //State
            Add(new NxSimpleText(_cx, _cy, "State", EDColors.BLUE, 18, NxFonts.EuroCapital));
            Add(new NxRectangle(5, _cy + 20, m_UiSearch.Menu.frame.WindowWidth - 10, 1, breakLineColor));
            _cy += 24;
            foreach (string s in SpanshDatas.state)
            {
                int _width = (int)m_UiSearch.Menu.frame.NxGraphics.MeasureString(s, NxCheckbox.DefaultFont).Width + boxPlusPadding;
                if (_cx + _width + 5 > m_UiSearch.Menu.frame.WindowWidth)
                {
                    _cx  = 0;
                    _cy += 32;
                }
                _cx += spaceBetweenCheckbox;
                NxCheckbox b = new NxCheckbox(_cx, _cy, _width, 30, s, m_UiSearch.Menu)
                {
                    BoxSize = boxsize
                };
                b.Obj = nameof(SpanshDatas.state);
                Add(b);
                _cx += _width;
            }

            _cx  = 0;
            _cy += spaceBetweenCategories;
            int powerPositionY = _cy;

            //Power
            Add(new NxSimpleText(_cx, _cy, "Power", EDColors.BLUE, 18, NxFonts.EuroCapital));
            Add(new NxRectangle(5, _cy + 20, m_UiSearch.Menu.frame.WindowWidth - 10, 1, breakLineColor));
            _cy += 24;
            foreach (string s in SpanshDatas.power)
            {
                int _width = (int)m_UiSearch.Menu.frame.NxGraphics.MeasureString(s, NxCheckbox.DefaultFont).Width + boxPlusPadding;
                if (_cx + _width + 5 > permitCatPositionX)
                {
                    _cx  = 0;
                    _cy += 32;
                }
                _cx += spaceBetweenCheckbox;
                NxCheckbox b = new NxCheckbox(_cx, _cy, _width, 30, s, m_UiSearch.Menu)
                {
                    BoxSize = boxsize
                };
                b.Obj = nameof(SpanshDatas.power);
                Add(b);
                _cx += _width;
            }

            _cx = permitCatPositionX;
            _cy = powerPositionY;
            //State
            Add(new NxSimpleText(_cx, _cy, "Power state", EDColors.BLUE, 18, NxFonts.EuroCapital));
            // Add(new NxRectangle(5, _cy + 20, m_menu.frame.WindowWidth - 10, 1, breakLineColor));
            _cy += 24;
            foreach (string s in SpanshDatas.power_state)
            {
                int _width = (int)m_UiSearch.Menu.frame.NxGraphics.MeasureString(s, NxCheckbox.DefaultFont).Width + boxPlusPadding;
                if (_cx + _width + 5 > m_UiSearch.Menu.frame.WindowWidth)
                {
                    _cx  = permitCatPositionX;
                    _cy += 32;
                }
                _cx += spaceBetweenCheckbox;
                NxCheckbox b = new NxCheckbox(_cx, _cy, _width, 30, s, m_UiSearch.Menu)
                {
                    BoxSize = boxsize
                };
                b.Obj = nameof(SpanshDatas.power_state);
                Add(b);
                _cx += _width;
            }

            _cx            = 0;
            _cy           += spaceBetweenCategories;
            powerPositionY = _cy;
            //Security
            Add(new NxSimpleText(_cx, _cy, "Security", EDColors.BLUE, 18, NxFonts.EuroCapital));
            Add(new NxRectangle(5, _cy + 20, m_UiSearch.Menu.frame.WindowWidth - 10, 1, breakLineColor));
            _cy += 24;
            foreach (string s in SpanshDatas.security)
            {
                int _width = (int)m_UiSearch.Menu.frame.NxGraphics.MeasureString(s, NxCheckbox.DefaultFont).Width + boxPlusPadding;
                if (_cx + _width + 5 > permitCatPositionX)
                {
                    _cx  = 0;
                    _cy += 32;
                }
                _cx += spaceBetweenCheckbox;
                NxCheckbox b = new NxCheckbox(_cx, _cy, _width, 30, s, m_UiSearch.Menu)
                {
                    BoxSize = boxsize
                };
                b.Obj = nameof(SpanshDatas.security);
                Add(b);
                _cx += _width;
            }

            _cx = permitCatPositionX;
            _cy = powerPositionY;
            //Population
            Add(new NxSimpleText(_cx, _cy, "Population", EDColors.BLUE, 18, NxFonts.EuroCapital));
            // Add(new NxRectangle(5, _cy + 20, m_menu.frame.WindowWidth - 10, 1, breakLineColor));
            _cy += 24;
            for (int i = 0; i < 3; i++)
            {
                string s = "Unpopulated";
                if (i == 1)
                {
                    s = "Populated";
                }
                else if (i == 2)
                {
                    s = "Both";
                }
                int _width = (int)m_UiSearch.Menu.frame.NxGraphics.MeasureString(s, NxCheckbox.DefaultFont).Width + boxPlusPadding;
                if (_cx + _width + 5 > m_UiSearch.Menu.frame.WindowWidth)
                {
                    _cx  = permitCatPositionX;
                    _cy += 32;
                }
                _cx += spaceBetweenCheckbox;
                NxCheckbox b = new NxCheckbox(_cx, _cy, _width, 30, s, m_UiSearch.Menu)
                {
                    BoxSize = boxsize, CircleBox = true
                };
                b.Checked         = i == 2;
                m_CbPopulation[i] = b;
                b.onClick        += onPopulationChanged;
                b.Obj             = "populationOptions";
                Add(b);
                _cx += _width;
            }


            _cx = 0;

            _cy = m_UiSearch.Menu.frame.WindowHeight - 110;


            NxButton btnCreate = new NxButton(5, _cy, m_UiSearch.Menu.frame.WindowWidth / 2 - 15, 30, "Save search", m_UiSearch.Menu);

            btnCreate.onClick          += onSave;
            btnCreate.ColorBack         = EDColors.getColor(EDColors.GREEN, 0.1f);
            btnCreate.ColorBackSelected = EDColors.getColor(EDColors.GREEN, 0.9f);
            Add(btnCreate);

            NxButton btnSearch = new NxButton(m_UiSearch.Menu.frame.WindowWidth / 2 + 10, _cy, m_UiSearch.Menu.frame.WindowWidth / 2 - 15, 30, "Search now", m_UiSearch.Menu);

            btnSearch.onClick += onSearch;
            Add(btnSearch);


            MoveCursorToFirst();
            Reset();
        }
Exemple #2
0
        public UiSearchResult(UiSearch2 _search, UiImprove _uiImprove = null) : base(_search != null ? _search.Menu.frame.NxOverlay : _uiImprove.Menu.frame.NxOverlay)
        {
            m_UiSearch       = _search;
            m_UiImprove      = _uiImprove;
            RelativeChildPos = true;
            //Title
            m_title = new NxSimpleText(0, 0, "Search result...", EDColors.ORANGE, 24, NxFonts.EuroCapital);
            Add(m_title);

            int _by = 0;

            width  = NxMenu.Width;
            height = NxMenu.Height - y;
            //Bookmark buttons

            //Tips for materials

            //Title
            _by += 40;

            //Loading

            m_loading = new NxLoading(NxMenu.Width / 2, 500);
            Add(m_loading);

            //Message

            m_messageInfo = new NxSimpleText(10, height - 160, "", Color.CadetBlue, 20);

            Add(m_messageInfo);

            //results

            m_results = new UiSearchResultLine[MAX_LINE_RESULT];
            for (int i = 0; i < m_results.Length; i++)
            {
                m_results[i] = new UiSearchResultLine(this)
                {
                    x      = 0,
                    y      = _by,
                    width  = NxMenu.Width,
                    height = 30
                };
                _by += m_results[i].height + 2;

                m_results[i].onClick += OnClickResult;
                Add(m_results[i]);
            }

            MoveCursorToFirst();

            m_BtnSave                   = new NxButton(width / 2 + 5, height - 135, width / 2 - 10, 35, "Save search", Menu);
            m_BtnSave.ColorBack         = EDColors.getColor(EDColors.GREEN, 0.1f);
            m_BtnSave.ColorBackSelected = EDColors.getColor(EDColors.GREEN, 0.8f);
            m_BtnSave.onClick          += onSaveClicked;
            Add(m_BtnSave);

            m_BtnDelete                   = new NxButton(5, height - 135, width / 2 - 10, 35, "Delete search", Menu);
            m_BtnDelete.ColorBack         = EDColors.getColor(EDColors.RED, 0.1f);
            m_BtnDelete.ColorBackSelected = EDColors.getColor(EDColors.RED, 0.8f);
            m_BtnDelete.onClick          += onDeleteClicked;
            Add(m_BtnDelete);
        }