コード例 #1
0
        internal void UserControl_Loaded()
        {
            try {
                UIComboBox.banksForFilter(chequeManager.comboBox_bank_filter);
                chequeManager.comboBox_bank_filter.SelectedIndex = 0;
                UIComboBox.banksForSelect(chequeManager.comboBox_bank_update);
                UIComboBox.chequeStatus(chequeManager.comboBox_status_filter);
                chequeManager.comboBox_status_filter.SelectedIndex = 0;
                UIComboBox.chequeStatus(chequeManager.comboBox_status_update);
                chequeManager.comboBox_status_update.SelectedIndex = 0;

                chequeManager.DataTable = new DataTable();
                chequeManager.DataTable.Columns.Add("ID", typeof(int));
                chequeManager.DataTable.Columns.Add("Bank Name", typeof(String));
                chequeManager.DataTable.Columns.Add("Cheque Number", typeof(String));
                chequeManager.DataTable.Columns.Add("Issued Date", typeof(String));
                chequeManager.DataTable.Columns.Add("Payable Date", typeof(String));
                chequeManager.DataTable.Columns.Add("Amount", typeof(String));
                chequeManager.DataTable.Columns.Add("Notes", typeof(String));
                chequeManager.DataTable.Columns.Add("Status", typeof(String));

                chequeManager.DataGridFooter   = new DataGridFooter();
                chequeManager.dataGrid.IFooter = chequeManager.DataGridFooter;
                chequeManager.grid_footer.Children.Add(chequeManager.DataGridFooter);
                chequeManager.dataGrid.DataContext = chequeManager.DataTable.DefaultView;

                chequeManager.Pagination        = new Pagination();
                chequeManager.Pagination.Filter = chequeManager;
                chequeManager.grid_pagination.Children.Add(chequeManager.Pagination);
                setRowsCount();
            } catch (Exception) {
            }
        }
コード例 #2
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////


        internal void profitPerItem_UserContolLoaded()
        {
            try {
                UIComboBox.categoriesForSelect(profitPerItem.comboBox_categoryId);
                UIComboBox.companiesForCategory(profitPerItem.comboBox_companyId, Convert.ToInt32(profitPerItem.comboBox_categoryId.SelectedValue));

                profitPerItem.DataTable = new DataTable();
                profitPerItem.DataTable.Columns.Add("a", typeof(int));
                profitPerItem.DataTable.Columns.Add("ID", typeof(String));
                profitPerItem.DataTable.Columns.Add("Category", typeof(String));
                profitPerItem.DataTable.Columns.Add("Company", typeof(String));
                profitPerItem.DataTable.Columns.Add("Item", typeof(String));
                profitPerItem.DataTable.Columns.Add("Profit", typeof(String));

                profitPerItem.DataGridFooter   = new DataGridFooter();
                profitPerItem.dataGrid.IFooter = profitPerItem.DataGridFooter;
                profitPerItem.grid_footer.Children.Add(profitPerItem.DataGridFooter);
                profitPerItem.dataGrid.DataContext = profitPerItem.DataTable.DefaultView;

                profitPerItem.Pagination        = new Pagination();
                profitPerItem.Pagination.Filter = profitPerItem;
                profitPerItem.grid_pagination.Children.Add(profitPerItem.Pagination);
                setProfitPerItemRowsCount();
            } catch (Exception) {
            }
        }
コード例 #3
0
        /// <summary>
        /// 初始comb2
        /// </summary>
        /// <param name="cb"></param>
        /// <param name="dataSource"></param>
        /// <param name="selectedValue"></param>
        private void SetComBoxDataSource(UIComboBox cb, Dictionary <string, string> dataSource, string selectedValue)
        {
            //DataTable dt = new DataTable();
            //dt.Columns.Add("Text");
            //dt.Columns.Add("Value");
            //foreach (string key in dataSource.Keys)
            //{
            //    DataRow dr = dt.NewRow();
            //    dr["Text"] = dataSource[key];
            //    dr["Value"] = key;
            //    dt.Rows.Add(dr);
            //}
            //cb.DataSource = dt;
            //cb.DisplayMember = "Text";
            //cb.ValueMember = "Value";
            //cb.SelectedValue = selectedValue;

            IList <Info> infoList = new List <Info>();

            foreach (string key in dataSource.Keys)
            {
                Info info1 = new Info()
                {
                    Id = key, Name = dataSource[key]
                };
                infoList.Add(info1);
            }
            cb.ValueMember   = "Id";
            cb.DisplayMember = "Name";
            cb.DataSource    = infoList;
            cb.SelectedValue = selectedValue;
        }
コード例 #4
0
        private void FillCombox(UIComboBox cmb, SqlDataReader dr, int nValueIdx, int nKeyIdx, String strValue)
        {
            cmb.Items.Clear();

            if (nValueIdx > dr.FieldCount || nValueIdx < 0 ||
                nKeyIdx > dr.FieldCount || nKeyIdx < 0)
            {
                return;
            }

            int nSelItemIdx = -1;
            int nItemIdx    = 0;

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    cmb.Items.Add(new OVRCustomComboBoxItem(dr[nKeyIdx].ToString(), dr[nValueIdx].ToString()));

                    if (dr[nKeyIdx].ToString().CompareTo(m_strLanguageCode) == 0)
                    {
                        nSelItemIdx = nItemIdx;
                    }
                    nItemIdx++;
                }
                cmb.DisplayMember = "Tag";
                cmb.ValueMember   = "Value";
                cmb.SelectedIndex = nSelItemIdx;
            }
        }
コード例 #5
0
            public static void Prefix(UIProductionStatWindow __instance)
            {
                UIComboBox productRankBox = Traverse.Create(__instance).Field("productRankBox").GetValue <UIComboBox>();

                productRankBox.Items.Add("需要加水的放前边");
                productRankBox.UpdateItems();
            }
コード例 #6
0
        /// ********************************************************************************************************* ///

        internal bool addPriceFromAddSellingPrice()
        {
            bool b = false;

            try {
                if (addSellingPrice.textBox_price.DoubleValue == 0)
                {
                    ShowMessage.error(Common.Messages.Error.Error006);
                }
                else if (isDublicatePrice(addSellingPrice.ItemId, addSellingPrice.Mode, addSellingPrice.textBox_price.DoubleValue, 0))
                {
                    ShowMessage.error(Common.Messages.Error.Error007);
                }
                else
                {
                    SellingPrice sellingPrice = new SellingPrice();
                    sellingPrice.ItemId = addSellingPrice.ItemId;
                    sellingPrice.Mode   = addSellingPrice.Mode;
                    sellingPrice.Price  = addSellingPrice.textBox_price.DoubleValue;
                    CommonMethods.setCDMDForAdd(sellingPrice);
                    int id = add(sellingPrice);
                    UIComboBox.sellingPriceForItemAndMode(addSellingPrice.ComboBox, addSellingPrice.ItemId, addSellingPrice.Mode, addSellingPrice);
                    addSellingPrice.ComboBox.SelectedValue = id;
                    b = true;
                }
            } catch (Exception) {
            }
            return(b);
        }
コード例 #7
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////

        internal void addStockTransferLoaded()
        {
            try {
                addStockTransfer.ItemFinder = new ItemFinder(addStockTransfer.textBox_itemId);
                addStockTransfer.grid_itemFinder.Children.Add(addStockTransfer.ItemFinder);

                UIComboBox.loadStocks(addStockTransfer.comboBox_from_selectStock, null);
                UIComboBox.loadStocks(addStockTransfer.comboBox_to_selectStock, null);

                addStockTransfer.comboBox_from_selectStock.SelectedValue = Convert.ToInt32(Session.Preference["defaultBuyingStock"]);
                addStockTransfer.comboBox_to_selectStock.SelectedValue   = Convert.ToInt32(Session.Preference["defaultSellingStock"]);

                addStockTransfer.DataTable = new DataTable();
                addStockTransfer.DataTable.Columns.Add("ID", typeof(int));
                addStockTransfer.DataTable.Columns.Add("Item Name", typeof(String));
                addStockTransfer.DataTable.Columns.Add("Quantity", typeof(String));

                addStockTransfer.dataGrid.DataContext = addStockTransfer.DataTable.DefaultView;
                if (addStockTransfer.IsViewMode)
                {
                    loadAllItemsToView();
                }
            } catch (Exception) {
            }
        }
コード例 #8
0
 public static void getVirtualMemoryInfo(ref UIComboBox disk)
 {
     for (int i = 0; i < driveSetImpl._drives.Count; i++)
     {
         disk.Items.Add(driveSetImpl._drives[i].Name.Replace("\\", "盘").Replace(":", ""));
     }
 }
コード例 #9
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        internal void UserControl_Loaded()
        {
            try {
                UIComboBox.yesNoForSelect(customerManager.comboBox_active_filter);
                customerManager.DataTable = new DataTable();
                customerManager.DataTable.Columns.Add("ID", typeof(int));
                customerManager.DataTable.Columns.Add("Name", typeof(String));
                customerManager.DataTable.Columns.Add("Address", typeof(String));
                customerManager.DataTable.Columns.Add("Telephone", typeof(String));
                customerManager.DataTable.Columns.Add("Account Balance", typeof(String));
                customerManager.DataTable.Columns.Add("Is Active", typeof(String));

                customerManager.DataGridFooter   = new DataGridFooter();
                customerManager.dataGrid.IFooter = customerManager.DataGridFooter;
                customerManager.grid_footer.Children.Add(customerManager.DataGridFooter);
                customerManager.dataGrid.DataContext = customerManager.DataTable.DefaultView;

                customerManager.Pagination        = new Pagination();
                customerManager.Pagination.Filter = customerManager;
                customerManager.grid_pagination.Children.Add(customerManager.Pagination);

                setRowsCount();
            } catch (Exception) {
            }
        }
コード例 #10
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////


        internal void stockTransferHistoryLoaded()
        {
            try {
                stockTransferHistory.DataTable = new DataTable();
                stockTransferHistory.DataTable.Columns.Add("ID", typeof(int));
                stockTransferHistory.DataTable.Columns.Add("Stock Location From", typeof(String));
                stockTransferHistory.DataTable.Columns.Add("Stock Location To", typeof(String));
                stockTransferHistory.DataTable.Columns.Add("Date", typeof(String));
                stockTransferHistory.DataTable.Columns.Add("Carrier", typeof(String));
                stockTransferHistory.DataTable.Columns.Add("Details", typeof(String));
                stockTransferHistory.dataGrid_stockTransferHistory.DataContext = stockTransferHistory.DataTable.DefaultView;

                UIComboBox.loadStocksForFilter(stockTransferHistory.comboBox_stockLocationFrom_filter);
                UIComboBox.loadStocksForFilter(stockTransferHistory.comboBox_stockLocationTo_filter);

                stockTransferHistory.comboBox_stockLocationFrom_filter.SelectedValue = -1;
                stockTransferHistory.comboBox_stockLocationTo_filter.SelectedValue   = -1;

                stockTransferHistory.Pagination        = new Pagination();
                stockTransferHistory.Pagination.Filter = stockTransferHistory;
                stockTransferHistory.grid_pagination.Children.Add(stockTransferHistory.Pagination);

                setRowsCount();
            } catch (Exception) {
            }
        }
コード例 #11
0
ファイル: EventLogViewer.cs プロジェクト: carlhuth/GenXSource
        private void FillSourceItems(List <string> groupNames)
        {
            loadingGroups = true;

            UIComboBox dlFilterSource = (UIComboBox)filterCombo.Control;

            dlFilterSource.Items.Clear();
            dlFilterSource.Items.Add("<All Sources>");

            groupNames.Sort();

            for (int i = 0; i < groupNames.Count; i++)
            {
                dlFilterSource.Items.Add(groupNames[i]);
            }

            if (previousGroupFilter == null)
            {
                dlFilterSource.SelectedIndex = 0;
            }
            else
            {
                dlFilterSource.SelectedValue = previousGroupFilter;
            }

            loadingGroups = false;
        }
コード例 #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="comboBox"></param>
 /// <param name="value"></param>
 public static void SetSelectedIndex(this UIComboBox comboBox, object value)
 {
     comboBox.SelectedIndex = comboBox.Items
                              .Cast <UIComboBoxItem>()
                              .ToList()
                              .FindIndex(i => object.Equals(i.Value, value));
 }
コード例 #13
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        internal void sellingChequeReport_UserContolLoaded()
        {
            try {
                UIComboBox.chequeStatus(sellingChequeReport.comboBox_status);
                sellingChequeReport.comboBox_status.SelectedIndex = 0;

                sellingChequeReport.DataTable = new DataTable();
                sellingChequeReport.DataTable.Columns.Add("ID", typeof(int));
                sellingChequeReport.DataTable.Columns.Add("Bank Name", typeof(String));
                sellingChequeReport.DataTable.Columns.Add("Cheque Number", typeof(String));
                sellingChequeReport.DataTable.Columns.Add("Issued Date", typeof(String));
                sellingChequeReport.DataTable.Columns.Add("Payble Date", typeof(String));
                sellingChequeReport.DataTable.Columns.Add("Amount", typeof(String));
                sellingChequeReport.DataTable.Columns.Add("Status", typeof(String));

                sellingChequeReport.DataGridFooter   = new DataGridFooter();
                sellingChequeReport.dataGrid.IFooter = sellingChequeReport.DataGridFooter;
                sellingChequeReport.grid_footer.Children.Add(sellingChequeReport.DataGridFooter);
                sellingChequeReport.dataGrid.DataContext = sellingChequeReport.DataTable.DefaultView;

                sellingChequeReport.Pagination        = new Pagination();
                sellingChequeReport.Pagination.Filter = sellingChequeReport;
                sellingChequeReport.grid_pagination.Children.Add(sellingChequeReport.Pagination);
                setSellingChequeRreportRowsCount();
            } catch (Exception) {
            }
        }
コード例 #14
0
        void comboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox     comboBox    = (ComboBox)sender;
            UIComboBox   cb          = (UIComboBox)comboBox.Parent;
            CFormControl FormControl = (CFormControl)cb.Tag;

            //RefreshLinkageWindowControl(FormControl);
        }
コード例 #15
0
        public static void Prefix(UIOptionWindow __instance)
        {
            UIComboBox comboBox = __instance.languageComp;
            var        item     = comboBox.itemIndex != -1
                ? comboBox.Items[comboBox.itemIndex]
                : "English";

            TranslationManager.SelectedLanguage = item;
        }
コード例 #16
0
 internal void addVendor_addVendor()
 {
     if (vendorManagerImpl.addVendorPopup())
     {
         UIComboBox.vendorsForAddBuyingInvoice(mSComboBox);
         mSComboBox.SelectedValue = addVendor.AddedId;
         addVendor.Hide();
         addVendor.resetForm();
     }
 }
コード例 #17
0
ファイル: Functions.cs プロジェクト: jiejingta/szzminer
        /// <summary>
        /// 读取miner.ini信息
        /// </summary>
        /// <param name="coin"></param>
        public static void loadCoinIni(ref UIComboBox coin)
        {
            IniHelper.setPath(Application.StartupPath + "\\config\\" + "\\miner.ini");
            List <string> coins = IniHelper.ReadSections();

            foreach (string c in coins)
            {
                coin.Items.Add(c);
            }
        }
コード例 #18
0
        /// <summary>
        /// 初始comb
        /// </summary>
        /// <param name="cb"></param>
        /// <param name="dataSource"></param>
        /// <param name="selectedValue"></param>
        private void SetComBoxDataSource(UIComboBox cb, string[] dataSource, string selectedValue)
        {
            Dictionary <string, string> ds = new Dictionary <string, string>();

            foreach (string s in dataSource)
            {
                ds.Add(s, s);
            }
            SetComBoxDataSource(cb, ds, selectedValue);
        }
コード例 #19
0
 private void loadBasicDetails()
 {
     try {
         textBox_item_findItem.ListBox = listBox_list_findItem;
         UIListBox.recentItems(listBox_list_findItem, 100);
         UIComboBox.categoriesForSelect(comboBox_category_selectItem);
         UIComboBox.companiesForSelect(comboBox_company_selectItem);
     } catch (Exception) {
     }
 }
コード例 #20
0
 internal void addBank_addBank()
 {
     if (bankManagerImpl.addbankPopup())
     {
         UIComboBox.banksForSelect(mSComboBox);
         mSComboBox.SelectedValue = addBank.AddedId;
         addBank.Hide();
         addBank.resetForm();
     }
 }
コード例 #21
0
 internal void addUnit_addUnit()
 {
     if (unitManagerImpl.addUnitPopup())
     {
         UIComboBox.unitsForAddItem(mSComboBox);
         mSComboBox.SelectedValue = addUnit.AddedId;
         addUnit.Hide();
         addUnit.resetForm();
     }
 }
コード例 #22
0
 private void comboBox_company_selectItem_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try {
         UIComboBox.itemsForCategoryAndCompany(comboBox_item_selectItem, comboBox_category_selectItem.Value, comboBox_company_selectItem.Value);
         if (textBoxCompany != null)
         {
             textBoxCompany.Text = Convert.ToString(comboBox_company_selectItem.SelectedValue);
         }
     } catch (Exception) {
     }
 }
コード例 #23
0
        public static void getinfo(UIComboBox comboBox)
        {
            string html = getHtml("https://www.f2pool.com/");

            usdCny      = PickUsdCny(html);
            incomeItems = PickIncomeItems(html);
            comboBox.Items.Clear();
            for (var i = 0; i < incomeItems.Count; i++)
            {
                comboBox.Items.Add(incomeItems[i].CoinCode);
            }
        }
コード例 #24
0
        internal void addCustomer_addCustomer()
        {
            if (customerManagerImpl.addCustomerPopup())
            {
                UIComboBox uIComboBox = new UIComboBox();
                uIComboBox.customersForAddSellingInvoice(mSComboBox);

                mSComboBox.SelectedValue = addCustomer.AddedId;
                addCustomer.Hide();
                addCustomer.resetForm();
            }
        }
コード例 #25
0
        /// <summary>
        /// Create the editor control
        /// </summary>
        /// <returns></returns>
        protected override Control CreateControl()
        {
            //[email protected]: CreateControl() : To support Selectable readonly text enhancement, new custom control is used as the control of this editor
            UIComboBox editor = new UIComboBox();

            //editor.FlatStyle = FlatStyle.System;
            editor.BorderStyle        = DevAge.Drawing.BorderStyle.None;
            editor.ComboBox.Validator = this;

            //NOTE: I have changed a little the ArrangeLinkedControls to support ComboBox control

            return(editor);
        }
コード例 #26
0
        // 查询数据库,填充到combobox中
        public static void setCBB(string sql, string columnName, UIComboBox cbb)
        {
            SqlConnection conn = new SqlConnection(SqlHelper.GetSqlConnectionString());

            conn.Open();
            SqlCommand     cmd = new SqlCommand(sql, conn);
            DataTable      dt  = new DataTable();
            SqlDataAdapter da  = new SqlDataAdapter(cmd);

            da.Fill(dt);
            cbb.DataSource  = dt;
            cbb.ValueMember = columnName;
            conn.Close();
        }
コード例 #27
0
 public static bool SetViewStar_Prefix(DESelection __instance, ref StarData starData)
 {
     if (Multiplayer.IsActive && Multiplayer.Session.LocalPlayer.IsClient)
     {
         //UIDysonEditor._OnOpen()
         if (!UIRoot.instance.uiGame.dysonEditor.sceneGroup.activeSelf)
         {
             //Request the latest list of existing dyson spheres
             Multiplayer.Session.Network.SendPacket(new DysonSphereLoadRequest(0, DysonSphereRequestEvent.List));
             if (GameMain.localStar == null)
             {
                 //In outer space, set initial viewStar to the one that has dyson sphere
                 for (int i = 0; i < GameMain.data.dysonSpheres.Length; i++)
                 {
                     if (GameMain.data.dysonSpheres[i] != null)
                     {
                         starData = GameMain.data.dysonSpheres[i].starData;
                         return(true);
                     }
                 }
                 //No dyson sphere exist, close the UI
                 UIRoot.instance.uiGame.dysonEditor._Close();
                 return(false);
             }
             else if (GameMain.data.dysonSpheres[starData.index] == null)
             {
                 //Local dyson sphere hasn't loaded yet, close the UI
                 UIRoot.instance.uiGame.dysonEditor._Close();
                 return(false);
             }
         }
         if (starData != null && GameMain.data.dysonSpheres[starData.index] == null)
         {
             if (Multiplayer.Session.DysonSpheres.RequestingIndex == -1)
             {
                 Multiplayer.Session.DysonSpheres.RequestDysonSphere(starData.index);
             }
             else
             {
                 InGamePopup.ShowInfo("Loading", $"Loading Dyson sphere {starData.displayName}, please wait...", null);
             }
             // Restore comboBox back to original star
             UIComboBox dysonBox = UIRoot.instance.uiGame.dysonEditor.controlPanel.topFunction.dysonBox;
             int        index    = dysonBox.ItemsData.FindIndex(x => x == UIRoot.instance.uiGame.dysonEditor.selection.viewStar?.index);
             dysonBox.itemIndex = index >= 0 ? index : 0;
             return(false);
         }
     }
     return(true);
 }
コード例 #28
0
ファイル: JanusContextMenu.cs プロジェクト: kindam/TWTactics
        public static void AddComboBoxCommand(this UIContextMenu menu, string text, IEnumerable<string> list, string defaultValue, EventHandler handler)
        {
            var ctl = new UIComboBox
            {
                DataSource = list.ToArray(),
                SelectedValue = defaultValue,
                ComboStyle = ComboStyle.DropDownList
            };

            ctl.SelectedValueChanged += handler;

            var cmd = new UICommand("", text, CommandType.ComboBoxCommand);
            cmd.Control = ctl;
            menu.Commands.Add(cmd);
        }
コード例 #29
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="combBox"></param>
        /// <param name="values"></param>
        /// <param name="getText"></param>
        public static void Populate <T>(this UIComboBox combBox, IEnumerable <T> values, Func <T, string> getText)
        {
            var dataSource = values
                             .Select(value =>
                                     new
            {
                Text  = getText(value),
                Value = value,
            })
                             .ToList();

            combBox.Items.Clear();
            combBox.DataSource    = dataSource;
            combBox.DisplayMember = "Text";
            combBox.ValueMember   = "Value";
        }
コード例 #30
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            try {
                dataTable = new DataTable();
                dataTable.Columns.Add("ID", typeof(int));
                dataTable.Columns.Add("Name", typeof(String));
                dataTable.Columns.Add("Is Active", typeof(String));
                dataGrid_stockLocations.DataContext      = dataTable.DefaultView;
                dataGrid_stockLocations.Columns[1].Width = 100;

                UIComboBox.yesNoForAdd(comboBox_status);

                filter();
            } catch (Exception) {
            }
        }
コード例 #31
0
ファイル: JanusContextMenu.cs プロジェクト: windygu/TWTactics
        public static void AddComboBoxCommand(this UIContextMenu menu, string text, IEnumerable <string> list, string defaultValue, EventHandler handler)
        {
            var ctl = new UIComboBox
            {
                DataSource    = list.ToArray(),
                SelectedValue = defaultValue,
                ComboStyle    = ComboStyle.DropDownList
            };

            ctl.SelectedValueChanged += handler;

            var cmd = new UICommand("", text, CommandType.ComboBoxCommand);

            cmd.Control = ctl;
            menu.Commands.Add(cmd);
        }
コード例 #32
0
        public override void LoadAndInitialize()
        {
            UIParent.UI.Clear();

            switch (subscreen)
            {
                case -1: //main
                    {
                        UIButton button;
                        UIImage logo;

                        logo = new UIImage(game);
                        logo.Textures = game.Content.Load<Texture2D>("logo_options");
                        logo.NormalTexture = new Rectangle(0, 0, 500, 75);
                        logo.PositionAndSize = new Rectangle(400 - 250, 20, 500, 75);
                        UIParent.UI.Add(logo);

                        button = new UIButton(game);
                        button.Name = "btnPlayerOptions";
                        button.Text = "Players";
                        button.PositionAndSize = new Rectangle(400 - 100, (600 - 85 * 5), 200, 75);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            UIParent.ClearESCHook();
                            oResult = new GameScreen_Options(game, 0);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(button);

                        button = new UIButton(game);
                        button.Name = "btnVideoOptions";
                        button.Text = "Video";
                        button.PositionAndSize = new Rectangle(400 - 100, (600 - 85 * 4), 200, 75);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            UIParent.ClearESCHook();
                            oResult = new GameScreen_Options(game, 1);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(button);

                        button = new UIButton(game);
                        button.Name = "btnAudioOptions";
                        button.Text = "Audio";
                        button.PositionAndSize = new Rectangle(400 - 100, (600 - 85 * 3), 200, 75);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            UIParent.ClearESCHook();
                            oResult = new GameScreen_Options(game, 2);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(button);

                        button = new UIButton(game);
                        button.Name = "btnCommon";
                        button.Text = "Other settings";
                        button.PositionAndSize = new Rectangle(400 - 100, (600 - 85 * 2), 200, 75);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            UIParent.ClearESCHook();
                            oResult = new GameScreen_Options(game, 3);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(button);

                        UIButton btnBack = new UIButton(game);
                        btnBack.Name = "btnBack";
                        btnBack.Text = "<-- Back";
                        btnBack.PositionAndSize = new Rectangle(5, (600 - 41), 100, 37);
                        btnBack.Action += (UIButton_Action)((btn) =>
                        {
                            UIParent.ClearESCHook();
                            oResult = new GameScreen_Main(game);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(btnBack);

                        UIParent.ESCHook += UIParent_ESCHook1;
                    }
                    break;
                case 0: //player
                    {
                        UIButton button;
                        UIComboBox combo;
                        UITextBox textbox;
                        UIKeyPicker kpicker;
                        UILabel label;
                        UIImage logo;

                        logo = new UIImage(game);
                        logo.Textures = game.Content.Load<Texture2D>("logo_playersoptions");
                        logo.NormalTexture = new Rectangle(0, 0, 500, 75);
                        logo.PositionAndSize = new Rectangle(400 - 250, 20, 500, 75);
                        UIParent.UI.Add(logo);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.Text = "Player name: ";
                        label.PositionAndSize = new Rectangle(10, 95 + 5, 0, 0);
                        UIParent.UI.Add(label);

                        textbox = new UITextBox(game);
                        textbox.Name = "tboxName";
                        textbox.PositionAndSize = new Rectangle(label.PositionAndSize.Right + 5, label.PositionAndSize.Top - 5, 200, 0);
                        textbox.TextLenghtLimit = 15;
                        textbox.Text = "";
                        UIParent.UI.Add(textbox);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.Text = "Color: ";
                        label.PositionAndSize = new Rectangle(textbox.PositionAndSize.Right + 20, textbox.PositionAndSize.Top + 5, 0, 0);
                        UIParent.UI.Add(label);

                        combo = new UIComboBox(game);
                        combo.Name = "cboxColor";
                        combo.Edible = false;
                        combo.PositionAndSize = new Rectangle(label.PositionAndSize.Right + 5, textbox.PositionAndSize.Top, 100, 0);
                        combo.Values.Add(new UITaggedValue("white", Color.White));
                        combo.Values.Add(new UITaggedValue("black", Color.Black));
                        combo.Values.Add(new UITaggedValue("red", Color.Red));
                        combo.Values.Add(new UITaggedValue("green", Color.Green));
                        combo.Values.Add(new UITaggedValue("blue", Color.Blue));
                        combo.Values.Add(new UITaggedValue("yellow", Color.Yellow));
                        combo.Values.Add(new UITaggedValue("magenta", Color.Magenta));
                        combo.Values.Add(new UITaggedValue("cyan", Color.Cyan));
                        combo.MaxDisplayedItems = 6;
                        combo.SelectedIndex = 0;
                        UIParent.UI.Add(combo);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.Text = "Keys:";
                        label.PositionAndSize = new Rectangle(10, textbox.PositionAndSize.Bottom + 10, 0, 0);
                        UIParent.UI.Add(label);
                        Rectangle last_pos = new Rectangle(label.PositionAndSize.Left + 10, label.PositionAndSize.Bottom + 5, 100, textbox.PositionAndSize.Height);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.Text = "Turn left/Go left: ";
                        label.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top + 5, 0, 0);
                        UIParent.UI.Add(label);
                        kpicker = new UIKeyPicker(game);
                        kpicker.Name = "kpGoLeft";
                        kpicker.PositionAndSize = new Rectangle(300, last_pos.Top, last_pos.Width, last_pos.Height);
                        kpicker.SelectedKey = Keys.None;
                        UIParent.UI.Add(kpicker);
                        last_pos = new Rectangle(last_pos.Left, kpicker.PositionAndSize.Bottom, last_pos.Width, last_pos.Height);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.Text = "Turn right/Go right: ";
                        label.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top + 5, 0, 0);
                        UIParent.UI.Add(label);
                        kpicker = new UIKeyPicker(game);
                        kpicker.Name = "kpGoRight";
                        kpicker.PositionAndSize = new Rectangle(300, last_pos.Top, last_pos.Width, last_pos.Height);
                        kpicker.SelectedKey = Keys.None;
                        UIParent.UI.Add(kpicker);
                        last_pos = new Rectangle(last_pos.Left, kpicker.PositionAndSize.Bottom, last_pos.Width, last_pos.Height);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.Text = "---/Go up: ";
                        label.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top + 5, 0, 0);
                        UIParent.UI.Add(label);
                        kpicker = new UIKeyPicker(game);
                        kpicker.Name = "kpGoUp";
                        kpicker.PositionAndSize = new Rectangle(300, last_pos.Top, last_pos.Width, last_pos.Height);
                        kpicker.SelectedKey = Keys.None;
                        UIParent.UI.Add(kpicker);
                        last_pos = new Rectangle(last_pos.Left, kpicker.PositionAndSize.Bottom, last_pos.Width, last_pos.Height);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.Text = "Brake/Go down: ";
                        label.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top + 5, 0, 0);
                        UIParent.UI.Add(label);
                        kpicker = new UIKeyPicker(game);
                        kpicker.Name = "kpGoDown";
                        kpicker.PositionAndSize = new Rectangle(300, last_pos.Top, last_pos.Width, last_pos.Height);
                        kpicker.SelectedKey = Keys.None;
                        UIParent.UI.Add(kpicker);
                        last_pos = new Rectangle(last_pos.Left, kpicker.PositionAndSize.Bottom, last_pos.Width, last_pos.Height);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.Text = "Chat: ";
                        label.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top + 5, 0, 0);
                        UIParent.UI.Add(label);
                        kpicker = new UIKeyPicker(game);
                        kpicker.Name = "kpOpenChat";
                        kpicker.PositionAndSize = new Rectangle(300, last_pos.Top, last_pos.Width, last_pos.Height);
                        kpicker.SelectedKey = Keys.None;
                        UIParent.UI.Add(kpicker);
                        last_pos = new Rectangle(last_pos.Left, kpicker.PositionAndSize.Bottom, last_pos.Width, last_pos.Height);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.Text = "Bot menu: ";
                        label.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top + 5, 0, 0);
                        UIParent.UI.Add(label);
                        kpicker = new UIKeyPicker(game);
                        kpicker.Name = "kpBotMenu";
                        kpicker.PositionAndSize = new Rectangle(300, last_pos.Top, last_pos.Width, last_pos.Height);
                        kpicker.SelectedKey = Keys.None;
                        UIParent.UI.Add(kpicker);
                        last_pos = new Rectangle(last_pos.Left, kpicker.PositionAndSize.Bottom, last_pos.Width, last_pos.Height);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.Text = "Speed up bonus: ";
                        label.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top + 5, 0, 0);
                        UIParent.UI.Add(label);
                        kpicker = new UIKeyPicker(game);
                        kpicker.Name = "kpSpeedUp";
                        kpicker.PositionAndSize = new Rectangle(300, last_pos.Top, last_pos.Width, last_pos.Height);
                        kpicker.SelectedKey = Keys.None;
                        UIParent.UI.Add(kpicker);
                        last_pos = new Rectangle(last_pos.Left, kpicker.PositionAndSize.Bottom, last_pos.Width, last_pos.Height);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.Text = "Trace widen bonus: ";
                        label.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top + 5, 0, 0);
                        UIParent.UI.Add(label);
                        kpicker = new UIKeyPicker(game);
                        kpicker.Name = "kpTraceWiden";
                        kpicker.PositionAndSize = new Rectangle(300, last_pos.Top, last_pos.Width, last_pos.Height);
                        kpicker.SelectedKey = Keys.None;
                        UIParent.UI.Add(kpicker);
                        last_pos = new Rectangle(last_pos.Left, kpicker.PositionAndSize.Bottom, last_pos.Width, last_pos.Height);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.Text = "Fear bomb bonus: ";
                        label.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top + 5, 0, 0);
                        UIParent.UI.Add(label);
                        kpicker = new UIKeyPicker(game);
                        kpicker.Name = "kpRandomizationBomb";
                        kpicker.PositionAndSize = new Rectangle(300, last_pos.Top, last_pos.Width, last_pos.Height);
                        kpicker.SelectedKey = Keys.None;
                        UIParent.UI.Add(kpicker);
                        last_pos = new Rectangle(last_pos.Left, kpicker.PositionAndSize.Bottom, last_pos.Width, last_pos.Height);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.Text = "Steering: ";
                        label.PositionAndSize = new Rectangle(10, last_pos.Top + 10, 0, 0);
                        UIParent.UI.Add(label);

                        combo = new UIComboBox(game);
                        combo.Name = "cboxSteering";
                        combo.Edible = false;
                        combo.PositionAndSize = new Rectangle(label.PositionAndSize.Right + 5, last_pos.Top + 5, 100, 0);
                        combo.Values.Add(new UITaggedValue("relative", PlayerMotor.Steering.Relative));
                        combo.Values.Add(new UITaggedValue("absolute", PlayerMotor.Steering.Absolute));
                        combo.SelectedIndex = 0;
                        UIParent.UI.Add(combo);

                        //load player data
                        UIParent.UI["tboxName"].Text = GameSettings.playerName;
                        for (int i = 0; i < Enum.GetNames(typeof(GameKeyNames)).Length; i++)
                            ((UIKeyPicker)UIParent.UI["kp" + Enum.GetNames(typeof(GameKeyNames))[i]]).SelectedKey = GameSettings.playerKeys[i];
                        for (int i = 0; i < ((UIComboBox)UIParent.UI["cboxColor"]).Values.Count; i++)
                            if ((Color)((UIComboBox)UIParent.UI["cboxColor"]).Values[i].Tag == GameSettings.playerColor)
                            {
                                ((UIComboBox)UIParent.UI["cboxColor"]).SelectedIndex = i;
                                break;
                            }
                        for (int i = 0; i < ((UIComboBox)UIParent.UI["cboxSteering"]).Values.Count; i++)
                            if ((PlayerMotor.Steering)((UIComboBox)UIParent.UI["cboxSteering"]).Values[i].Tag == GameSettings.playerSteering)
                            {
                                ((UIComboBox)UIParent.UI["cboxSteering"]).SelectedIndex = i;
                                break;
                            }

                        button = new UIButton(game);
                        button.Name = "btnAcceptPlayerChanges";
                        button.Text = "Save";
                        button.PositionAndSize = new Rectangle(800 - 105, 600 - 41, 100, 37);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            //save changes
                            GameSettings.playerName = UIParent.UI["tboxName"].Text;
                            for (int i = 0; i < Enum.GetNames(typeof(GameKeyNames)).Length; i++)
                                GameSettings.playerKeys[i] = ((UIKeyPicker)UIParent.UI["kp" + Enum.GetNames(typeof(GameKeyNames))[i]]).SelectedKey;
                            GameSettings.playerColor = (Color)((UIComboBox)UIParent.UI["cboxColor"]).SelectedItem.Tag;
                            GameSettings.playerSteering = (PlayerMotor.Steering)((UIComboBox)UIParent.UI["cboxSteering"]).SelectedItem.Tag;

                            //don't exit - user might want to change something more
                        });
                        UIParent.UI.Add(button);

                        button = new UIButton(game);
                        button.Name = "btnBack";
                        button.Text = "<-- Back";
                        button.PositionAndSize = new Rectangle(5, (600 - 41), 100, 37);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            UIParent.ClearESCHook();
                            oResult = new GameScreen_Options(game, -1);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(button);

                        UIParent.ESCHook += UIParent_ESCHook2;
                    }
                    break;
                case 1: //video
                    {
                        UIButton button;
                        UICheckBox checkbox;
                        UIComboBox combo;
                        UILabel label;
                        UIImage logo;

                        logo = new UIImage(game);
                        logo.Textures = game.Content.Load<Texture2D>("logo_videooptions");
                        logo.NormalTexture = new Rectangle(0, 0, 500, 75);
                        logo.PositionAndSize = new Rectangle(400 - 250, 20, 500, 75);
                        UIParent.UI.Add(logo);

                        label = new UILabel(game);
                        label.Name = "label1";
                        label.Text = "Display mode:";
                        label.AutoSize = true;
                        label.PositionAndSize = new Rectangle(10, logo.PositionAndSize.Bottom + 10, 0, 0);
                        UIParent.UI.Add(label);

                        combo = new UIComboBox(game);
                        combo.Name = "comboDisplayMode";
                        combo.Edible = false;
                        combo.MaxDisplayedItems = 5;
                        combo.PositionAndSize = new Rectangle(label.PositionAndSize.Right + 5, label.PositionAndSize.Top, 200, 0);
                        combo.PositionAndSize = new Rectangle(label.PositionAndSize.Right + 5, label.PositionAndSize.Top + (label.PositionAndSize.Height / 2 - combo.PositionAndSize.Height / 2), 200, 0);
                        foreach (DisplayMode dm in game.GraphicsDevice.Adapter.SupportedDisplayModes)
                            combo.Values.Add(new UITaggedValue(dm.Width + "x" + dm.Height + " " + dm.Format, dm));
                        combo.SelectedIndex = GameSettings.videoGraphMode;
                        combo.SelectionChanged += (UIComboBox_SelectionChanged)((c, old) => {
                            game.SetGraphMode(c.SelectedIndex, ((UICheckBox)UIParent.UI["cboxFullscreen"]).Checked);
                        });
                        UIParent.UI.Add(combo);

                        checkbox = new UICheckBox(game);
                        checkbox.Name = "cboxFullscreen";
                        checkbox.Text = "Fullscreen mode";
                        checkbox.AutoSize = true;
                        checkbox.PositionAndSize = new Rectangle(label.PositionAndSize.Left, combo.PositionAndSize.Bottom + 5, 0, 0);
                        checkbox.Checked = GameSettings.videoFullscreen;
                        checkbox.CheckChanged += (UICheckBox_CheckChanged)((cbox) => {
                            game.SetGraphMode(game.graphics.PreferredBackBufferWidth, game.graphics.PreferredBackBufferHeight, ((UICheckBox)UIParent.UI["cboxFullscreen"]).Checked);
                        });
                        UIParent.UI.Add(checkbox);

                        button = new UIButton(game);
                        button.Name = "btnAcceptVideoChanges";
                        button.Text = "Save";
                        button.PositionAndSize = new Rectangle(800 - 105, 600 - 41, 100, 37);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            //save changes
                            GameSettings.videoGraphMode = ((UIComboBox)UIParent.UI["comboDisplayMode"]).SelectedIndex;
                            GameSettings.videoFullscreen = ((UICheckBox)UIParent.UI["cboxFullscreen"]).Checked;

                            UIParent.ClearESCHook();
                            oResult = new GameScreen_Options(game, -1);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(button);

                        button = new UIButton(game);
                        button.Name = "btnBack";
                        button.Text = "<-- Back";
                        button.PositionAndSize = new Rectangle(5, (600 - 41), 100, 37);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            game.SetGraphMode(GameSettings.videoGraphMode, GameSettings.videoFullscreen);

                            UIParent.ClearESCHook();
                            oResult = new GameScreen_Options(game, -1);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(button);

                        UIParent.ESCHook += UIParent_ESCHook2;
                    }
                    break;
                case 2: //audio
                    {
                        UIButton button;
                        UICheckBox checkbox;
                        UILabel label;
                        UIScrollBar scroll;
                        UIImage logo;

                        logo = new UIImage(game);
                        logo.Textures = game.Content.Load<Texture2D>("logo_audiooptions");
                        logo.NormalTexture = new Rectangle(0, 0, 500, 75);
                        logo.PositionAndSize = new Rectangle(400 - 250, 20, 500, 75);
                        UIParent.UI.Add(logo);

                        checkbox = new UICheckBox(game);
                        checkbox.Name = "cbEnable";
                        checkbox.AutoSize = true;
                        checkbox.Checked = GameSettings.audioEnabled;
                        checkbox.Enabled = false; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                        checkbox.PositionAndSize = new Rectangle(10, logo.PositionAndSize.Bottom + 10, 0, 0);
                        checkbox.Text = "Enable sound";
                        checkbox.CheckChanged += (UICheckBox_CheckChanged)((cb) => {
                            UIParent.UI["scrollVolume"].Enabled = cb.Checked;
                            UIParent.UI["scrollMusic"].Enabled = cb.Checked;
                            UIParent.UI["scrollSFX"].Enabled = cb.Checked;
                            UIParent.UI["scrollUI"].Enabled = cb.Checked;
                        });
                        UIParent.UI.Add(checkbox);
                        Rectangle last_pos = new Rectangle(checkbox.PositionAndSize.Left + 10, checkbox.PositionAndSize.Bottom + 5, 300, 0);

                        scroll = new UIScrollBar(game);
                        scroll.Name = "scrollVolume";
                        scroll.Enabled = GameSettings.audioEnabled;
                        scroll.IsHorizontal = true;
                        scroll.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top, last_pos.Width, 0);
                        scroll.MinimalValue = 0;
                        scroll.MaximalValue = 100;
                        scroll.ValuesOnScreen = 1;
                        scroll.Value = GameSettings.audioVolumePercent;
                        scroll.ValueChanged += (UIScrollBar_ValueChanged)((scrl, old) => {
                            //game.SetupAudio(((UICheckBox)UIParent.UI["cbEnable"]).Checked, ((UIScrollBar)UIParent.UI["scrollVolume"]).Value, ((UIScrollBar)UIParent.UI["scrollMusic"]).Value, ((UIScrollBar)UIParent.UI["scrollSFX"]).Value, ((UIScrollBar)UIParent.UI["scrollUI"]).Value);
                        });
                        UIParent.UI.Add(scroll);
                        label = new UILabel(game);
                        label.Name = "labelVolume";
                        label.AutoSize = true;
                        label.Text = scroll.Value + "%";
                        label.PositionAndSize = new Rectangle(scroll.PositionAndSize.Right + 5, scroll.PositionAndSize.Top + 5, 0, 0);
                        UIParent.UI.Add(label);
                        last_pos = new Rectangle(scroll.PositionAndSize.Left, scroll.PositionAndSize.Bottom + 5, last_pos.Width, 0);

                        scroll = new UIScrollBar(game);
                        scroll.Name = "scrollMusic";
                        scroll.Enabled = GameSettings.audioEnabled;
                        scroll.IsHorizontal = true;
                        scroll.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top, last_pos.Width, 0);
                        scroll.MinimalValue = 0;
                        scroll.MaximalValue = 100;
                        scroll.ValuesOnScreen = 1;
                        scroll.Value = GameSettings.audioMusicVolumePercent;
                        scroll.ValueChanged += (UIScrollBar_ValueChanged)((scrl, old) => {
                            //game.SetupAudio(((UICheckBox)UIParent.UI["cbEnable"]).Checked, ((UIScrollBar)UIParent.UI["scrollVolume"]).Value, ((UIScrollBar)UIParent.UI["scrollMusic"]).Value, ((UIScrollBar)UIParent.UI["scrollSFX"]).Value, ((UIScrollBar)UIParent.UI["scrollUI"]).Value);
                        });
                        UIParent.UI.Add(scroll);
                        label = new UILabel(game);
                        label.Name = "labelMusic";
                        label.AutoSize = true;
                        label.Text = scroll.Value + "%";
                        label.PositionAndSize = new Rectangle(scroll.PositionAndSize.Right + 5, scroll.PositionAndSize.Top + 5, 0, 0);
                        UIParent.UI.Add(label);
                        last_pos = new Rectangle(scroll.PositionAndSize.Left, scroll.PositionAndSize.Bottom + 5, last_pos.Width, 0);

                        scroll = new UIScrollBar(game);
                        scroll.Name = "scrollSFX";
                        scroll.Enabled = GameSettings.audioEnabled;
                        scroll.IsHorizontal = true;
                        scroll.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top, last_pos.Width, 0);
                        scroll.MinimalValue = 0;
                        scroll.MaximalValue = 100;
                        scroll.ValuesOnScreen = 1;
                        scroll.Value = GameSettings.audioSFXVolumePercent;
                        scroll.ValueChanged += (UIScrollBar_ValueChanged)((scrl, old) => {
                            //game.SetupAudio(((UICheckBox)UIParent.UI["cbEnable"]).Checked, ((UIScrollBar)UIParent.UI["scrollVolume"]).Value, ((UIScrollBar)UIParent.UI["scrollMusic"]).Value, ((UIScrollBar)UIParent.UI["scrollSFX"]).Value, ((UIScrollBar)UIParent.UI["scrollUI"]).Value);
                        });
                        UIParent.UI.Add(scroll);
                        label = new UILabel(game);
                        label.Name = "labelSFX";
                        label.AutoSize = true;
                        label.Text = scroll.Value + "%";
                        label.PositionAndSize = new Rectangle(scroll.PositionAndSize.Right + 5, scroll.PositionAndSize.Top + 5, 0, 0);
                        UIParent.UI.Add(label);
                        last_pos = new Rectangle(scroll.PositionAndSize.Left, scroll.PositionAndSize.Bottom + 5, last_pos.Width, 0);

                        scroll = new UIScrollBar(game);
                        scroll.Name = "scrollUI";
                        scroll.Enabled = GameSettings.audioEnabled;
                        scroll.IsHorizontal = true;
                        scroll.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top, last_pos.Width, 0);
                        scroll.MinimalValue = 0;
                        scroll.MaximalValue = 100;
                        scroll.ValuesOnScreen = 1;
                        scroll.Value = GameSettings.audioUIVolumePercent;
                        scroll.ValueChanged += (UIScrollBar_ValueChanged)((scrl, old) => {
                            //game.SetupAudio(((UICheckBox)UIParent.UI["cbEnable"]).Checked, ((UIScrollBar)UIParent.UI["scrollVolume"]).Value, ((UIScrollBar)UIParent.UI["scrollMusic"]).Value, ((UIScrollBar)UIParent.UI["scrollSFX"]).Value, ((UIScrollBar)UIParent.UI["scrollUI"]).Value);
                        });
                        UIParent.UI.Add(scroll);
                        label = new UILabel(game);
                        label.Name = "labelUI";
                        label.AutoSize = true;
                        label.Text = scroll.Value + "%";
                        label.PositionAndSize = new Rectangle(scroll.PositionAndSize.Right + 5, scroll.PositionAndSize.Top + 5, 0, 0);
                        UIParent.UI.Add(label);
                        last_pos = new Rectangle(scroll.PositionAndSize.Left, scroll.PositionAndSize.Bottom + 5, last_pos.Width, 0);

                        button = new UIButton(game);
                        button.Name = "btnAcceptAudioChanges";
                        button.Text = "Save";
                        button.PositionAndSize = new Rectangle(800 - 105, 600 - 41, 100, 37);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            //save changes
                            GameSettings.audioEnabled = ((UICheckBox)UIParent.UI["cbEnable"]).Checked;
                            GameSettings.audioVolumePercent = ((UIScrollBar)UIParent.UI["scrollVolume"]).Value;
                            GameSettings.audioMusicVolumePercent = ((UIScrollBar)UIParent.UI["scrollMusic"]).Value;
                            GameSettings.audioSFXVolumePercent = ((UIScrollBar)UIParent.UI["scrollSFX"]).Value;
                            GameSettings.audioUIVolumePercent = ((UIScrollBar)UIParent.UI["scrollUI"]).Value;

                            UIParent.ClearESCHook();
                            oResult = new GameScreen_Options(game, -1);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(button);

                        button = new UIButton(game);
                        button.Name = "btnBack";
                        button.Text = "<-- Back";
                        button.PositionAndSize = new Rectangle(5, (600 - 41), 100, 37);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            //game.SetupAudio(GameSettings.audioEnabled, GameSettings.audioVolumePercent, GameSettings.audioMusicVolumePercent, GameSettings.audioSFXVolumePercent, GameSettings.audioUIVolumePercent);

                            UIParent.ClearESCHook();
                            oResult = new GameScreen_Options(game, -1);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(button);

                        UIParent.ESCHook += UIParent_ESCHook2;
                    }
                    break;
                case 3: //common
                    {
                        UIButton button;
                        UICheckBox checkbox;
                        UIImage logo;

                        logo = new UIImage(game);
                        logo.Textures = game.Content.Load<Texture2D>("logo_otheroptions");
                        logo.NormalTexture = new Rectangle(0, 0, 500, 75);
                        logo.PositionAndSize = new Rectangle(400 - 250, 20, 500, 75);
                        UIParent.UI.Add(logo);
                        Rectangle last_pos = new Rectangle(10, logo.PositionAndSize.Bottom + 5, 0, 0);

                        checkbox = new UICheckBox(game);
                        checkbox.Name = "cbMinimap";
                        checkbox.AutoSize = true;
                        checkbox.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top, 0, 0);
                        checkbox.Checked = GameSettings.gameoptMinimap;
                        checkbox.Text = "Show minimap";
                        UIParent.UI.Add(checkbox);
                        last_pos = new Rectangle(last_pos.Left, checkbox.PositionAndSize.Bottom + 5, 0, 0);

                        checkbox = new UICheckBox(game);
                        checkbox.Name = "cbNames";
                        checkbox.AutoSize = true;
                        checkbox.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top, 0, 0);
                        checkbox.Checked = GameSettings.gameoptNames;
                        checkbox.Text = "Show names";
                        UIParent.UI.Add(checkbox);
                        last_pos = new Rectangle(last_pos.Left, checkbox.PositionAndSize.Bottom + 5, 0, 0);

                        checkbox = new UICheckBox(game);
                        checkbox.Name = "cbPointers";
                        checkbox.AutoSize = true;
                        checkbox.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top, 0, 0);
                        checkbox.Checked = GameSettings.gameoptPointers;
                        checkbox.Text = "Show motor pointers";
                        UIParent.UI.Add(checkbox);

                        button = new UIButton(game);
                        button.Name = "btnAcceptCommonChanges";
                        button.Text = "Save";
                        button.PositionAndSize = new Rectangle(800 - 105, 600 - 41, 100, 37);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            //save changes
                            GameSettings.gameoptMinimap = ((UICheckBox)UIParent.UI["cbMinimap"]).Checked;
                            GameSettings.gameoptNames = ((UICheckBox)UIParent.UI["cbNames"]).Checked;
                            GameSettings.gameoptPointers = ((UICheckBox)UIParent.UI["cbPointers"]).Checked;

                            UIParent.ClearESCHook();
                            oResult = new GameScreen_Options(game, -1);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(button);

                        button = new UIButton(game);
                        button.Name = "btnBack";
                        button.Text = "<-- Back";
                        button.PositionAndSize = new Rectangle(5, (600 - 41), 100, 37);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            UIParent.ClearESCHook();
                            oResult = new GameScreen_Options(game, -1);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(button);

                        UIParent.ESCHook += UIParent_ESCHook2;
                    }
                    break;
            }

            UIParent.UI.LoadAndInitialize();
        }
コード例 #33
0
        public override void LoadAndInitialize()
        {
            UIParent.UI.Clear();

            switch (subscreen)
            {
                case 0: //common game settings
                    {
                        UIButton button;
                        UILabel label;
                        UITextBox textbox;
                        UIComboBox combo;
                        UIImage logo;

                        logo = new UIImage(game);
                        logo.Textures = game.Content.Load<Texture2D>("logo_newgame");
                        logo.NormalTexture = new Rectangle(0, 0, 500, 75);
                        logo.PositionAndSize = new Rectangle(400 - 250, 20, 500, 75);
                        UIParent.UI.Add(logo);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.PositionAndSize = new Rectangle(10, logo.PositionAndSize.Bottom + 10, 0, 0);
                        label.Text = "Game name: ";
                        UIParent.UI.Add(label);

                        textbox = new UITextBox(game);
                        textbox.Name = "tboxGameName";
                        textbox.PositionAndSize = new Rectangle(label.PositionAndSize.Right + 5, label.PositionAndSize.Top - 5, 200, 0);
                        textbox.TextLenghtLimit = 15;
                        textbox.Text = GameSettings.gameName;
                        UIParent.UI.Add(textbox);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.PositionAndSize = new Rectangle(10, textbox.PositionAndSize.Bottom + 15, 0, 0);
                        label.Text = "Game type: ";
                        UIParent.UI.Add(label);

                        combo = new UIComboBox(game);
                        combo.Name = "cboxGameType";
                        combo.Edible = false;
                        combo.PositionAndSize = new Rectangle(label.PositionAndSize.Right + 5, label.PositionAndSize.Top - 5, 200, 0);
                        combo.Values.Add(new UITaggedValue("deathmatch", GameType.DeathMatch));
                        combo.Values.Add(new UITaggedValue("demolition", GameType.Demolition));
                        combo.Values.Add(new UITaggedValue("point match", GameType.PointMatch));
                        combo.Values.Add(new UITaggedValue("time match", GameType.TimeMatch));
                        combo.Values.Add(new UITaggedValue("team deathmatch", GameType.TeamDeathMatch));
                        combo.Values.Add(new UITaggedValue("team demolition", GameType.TeamDemolition));
                        combo.Values.Add(new UITaggedValue("team point match", GameType.TeamPointMatch));
                        combo.Values.Add(new UITaggedValue("team time match", GameType.TeamTimeMatch));
                        combo.SelectedIndex = -1;
                        combo.SelectionChanged += (UIComboBox_SelectionChanged)((cbox, old) => {
                            switch ((GameType)cbox.SelectedItem.Tag)
                            {
                                case GameType.DeathMatch:
                                    UIParent.UI["labelGameDescription"].Text = "Destroy specified number of enemy bikes";
                                    UIParent.UI["tboxFragLimit"].Enabled = true;
                                    UIParent.UI["tboxPointLimit"].Enabled = false;
                                    UIParent.UI["tboxTimeLimit"].Enabled = false;
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Clear();
                                    foreach (UITaggedValue map in Map.EnumerateMaps((GameType)cbox.SelectedItem.Tag))
                                        ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Add(map);
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).SelectedIndex = 0;
                                    break;
                                case GameType.Demolition:
                                    UIParent.UI["labelGameDescription"].Text = "Destroy all enemy bikes";
                                    UIParent.UI["tboxFragLimit"].Enabled = false;
                                    UIParent.UI["tboxPointLimit"].Enabled = false;
                                    UIParent.UI["tboxTimeLimit"].Enabled = false;
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Clear();
                                    foreach (UITaggedValue map in Map.EnumerateMaps((GameType)cbox.SelectedItem.Tag))
                                        ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Add(map);
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).SelectedIndex = 0;
                                    break;
                                case GameType.PointMatch:
                                    UIParent.UI["labelGameDescription"].Text = "Gather specified amount of points by destroying enemy bikes";
                                    UIParent.UI["tboxFragLimit"].Enabled = false;
                                    UIParent.UI["tboxPointLimit"].Enabled = true;
                                    UIParent.UI["tboxTimeLimit"].Enabled = false;
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Clear();
                                    foreach (UITaggedValue map in Map.EnumerateMaps((GameType)cbox.SelectedItem.Tag))
                                        ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Add(map);
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).SelectedIndex = 0;
                                    break;
                                case GameType.TimeMatch:
                                    UIParent.UI["labelGameDescription"].Text = "Gather as much points as possible in specified amount of time";
                                    UIParent.UI["tboxFragLimit"].Enabled = false;
                                    UIParent.UI["tboxPointLimit"].Enabled = false;
                                    UIParent.UI["tboxTimeLimit"].Enabled = true;
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Clear();
                                    foreach (UITaggedValue map in Map.EnumerateMaps((GameType)cbox.SelectedItem.Tag))
                                        ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Add(map);
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).SelectedIndex = 0;
                                    break;
                                case GameType.TeamDeathMatch:
                                    UIParent.UI["labelGameDescription"].Text = "Destroy specified number of bikes from opposite team";
                                    UIParent.UI["tboxFragLimit"].Enabled = true;
                                    UIParent.UI["tboxPointLimit"].Enabled = false;
                                    UIParent.UI["tboxTimeLimit"].Enabled = false;
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Clear();
                                    foreach (UITaggedValue map in Map.EnumerateMaps((GameType)cbox.SelectedItem.Tag))
                                        ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Add(map);
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).SelectedIndex = 0;
                                    break;
                                case GameType.TeamDemolition:
                                    UIParent.UI["labelGameDescription"].Text = "Destroy all bikes from opposite team";
                                    UIParent.UI["tboxFragLimit"].Enabled = false;
                                    UIParent.UI["tboxPointLimit"].Enabled = false;
                                    UIParent.UI["tboxTimeLimit"].Enabled = false;
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Clear();
                                    foreach (UITaggedValue map in Map.EnumerateMaps((GameType)cbox.SelectedItem.Tag))
                                        ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Add(map);
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).SelectedIndex = 0;
                                    break;
                                case GameType.TeamPointMatch:
                                    UIParent.UI["labelGameDescription"].Text = "Help your team gather specified amount of points by destroying bikes from opposite team";
                                    UIParent.UI["tboxFragLimit"].Enabled = false;
                                    UIParent.UI["tboxPointLimit"].Enabled = true;
                                    UIParent.UI["tboxTimeLimit"].Enabled = false;
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Clear();
                                    foreach (UITaggedValue map in Map.EnumerateMaps((GameType)cbox.SelectedItem.Tag))
                                        ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Add(map);
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).SelectedIndex = 0;
                                    break;
                                case GameType.TeamTimeMatch:
                                    UIParent.UI["labelGameDescription"].Text = "Help your team gather as much points as possible in specified amount of time";
                                    UIParent.UI["tboxFragLimit"].Enabled = false;
                                    UIParent.UI["tboxPointLimit"].Enabled = false;
                                    UIParent.UI["tboxTimeLimit"].Enabled = true;
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Clear();
                                    foreach (UITaggedValue map in Map.EnumerateMaps((GameType)cbox.SelectedItem.Tag))
                                        ((UIComboBox)UIParent.UI["cboxMapName"]).Values.Add(map);
                                    ((UIComboBox)UIParent.UI["cboxMapName"]).SelectedIndex = 0;
                                    break;
                            }
                        });
                        UIParent.UI.Add(combo);

                        label = new UILabel(game);
                        label.Name = "labelGameDescription";
                        label.AutoSize = true;
                        label.PositionAndSize = new Rectangle(30, combo.PositionAndSize.Bottom + 5, 0, 0);
                        label.Text = "<game description>";
                        UIParent.UI.Add(label);
                        Rectangle last_pos = new Rectangle(10, label.PositionAndSize.Bottom + 10, 0, 0);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.PositionAndSize = new Rectangle(10, last_pos.Top + 5, 0, 0);
                        label.Text = "Map: ";
                        UIParent.UI.Add(label);

                        combo = new UIComboBox(game);
                        combo.Name = "cboxMapName";
                        combo.Edible = false;
                        combo.MaxDisplayedItems = 10;
                        combo.PositionAndSize = new Rectangle(label.PositionAndSize.Right + 5, last_pos.Top, 200, 0);
                        combo.SelectedIndex = -1;
                        UIParent.UI.Add(combo);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.PositionAndSize = new Rectangle(10, combo.PositionAndSize.Bottom + 10, 0, 0);
                        label.Text = "Destroy limit: ";
                        UIParent.UI.Add(label);

                        textbox = new UITextBox(game);
                        textbox.Name = "tboxFragLimit";
                        textbox.Enabled = false;
                        textbox.PositionAndSize = new Rectangle(label.PositionAndSize.Right + 5, label.PositionAndSize.Top - 5, 100, 0);
                        textbox.TextLenghtLimit = 3;
                        textbox.CharacterFilter = (UITextBox.CharacterFilterFunction)((ch) =>
                        {
                            return (ch >= '0') && (ch <= '9');
                        });
                        textbox.Text = "" + (GameSettings.gameFragLimit == 0 ? 10 : GameSettings.gameFragLimit);
                        UIParent.UI.Add(textbox);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.PositionAndSize = new Rectangle(10, textbox.PositionAndSize.Bottom + 10, 0, 0);
                        label.Text = "Point limit: ";
                        UIParent.UI.Add(label);

                        textbox = new UITextBox(game);
                        textbox.Name = "tboxPointLimit";
                        textbox.Enabled = false;
                        textbox.PositionAndSize = new Rectangle(label.PositionAndSize.Right + 5, label.PositionAndSize.Top - 5, 100, 0);
                        textbox.TextLenghtLimit = 6;
                        textbox.CharacterFilter = (UITextBox.CharacterFilterFunction)((ch) =>
                        {
                            return (ch >= '0') && (ch <= '9');
                        });
                        textbox.Text = "" + (GameSettings.gamePointLimit == 0 ? 10000 : GameSettings.gamePointLimit);
                        UIParent.UI.Add(textbox);

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.PositionAndSize = new Rectangle(10, textbox.PositionAndSize.Bottom + 10, 0, 0);
                        label.Text = "Time limit (minutes): ";
                        UIParent.UI.Add(label);

                        textbox = new UITextBox(game);
                        textbox.Name = "tboxTimeLimit";
                        textbox.Enabled = false;
                        textbox.PositionAndSize = new Rectangle(label.PositionAndSize.Right + 5, label.PositionAndSize.Top - 5, 100, 0);
                        textbox.TextLenghtLimit = 3;
                        textbox.CharacterFilter = (UITextBox.CharacterFilterFunction)((ch) =>
                        {
                            return (ch >= '0') && (ch <= '9');
                        });
                        textbox.Text = "" + (GameSettings.gameTimeLimit == 0 ? 3 : GameSettings.gameTimeLimit);
                        UIParent.UI.Add(textbox);

                        button = new UIButton(game);
                        button.Name = "btnProceedGame";
                        button.Text = "Next -->";
                        button.PositionAndSize = new Rectangle(800 - 105, 600 - 41, 100, 37);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            //save changes
                            GameSettings.gameServerIP = "127.0.0.1";
                            GameSettings.gameName = UIParent.UI["tboxGameName"].Text;
                            GameSettings.gameType = (GameType)((UIComboBox)UIParent.UI["cboxGameType"]).SelectedItem.Tag;
                            GameSettings.SelectMap((string)((UIComboBox)UIParent.UI["cboxMapName"]).SelectedItem.Tag);
                            try { GameSettings.gameFragLimit = int.Parse(UIParent.UI["tboxFragLimit"].Text); }
                            catch (Exception) { GameSettings.gameFragLimit = 20; }
                            try { GameSettings.gamePointLimit = int.Parse(UIParent.UI["tboxPointLimit"].Text); }
                            catch (Exception) { GameSettings.gamePointLimit = 1000; }
                            try { GameSettings.gameTimeLimit = int.Parse(UIParent.UI["tboxTimeLimit"].Text); }
                            catch (Exception) { GameSettings.gameTimeLimit = 120; }

                            UIParent.ClearESCHook();
                            oResult = new GameScreen_NewGame(game, 1);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(button);

                        UIButton btnBack = new UIButton(game);
                        btnBack.Name = "btnBack";
                        btnBack.Text = "<-- Back";
                        btnBack.PositionAndSize = new Rectangle(5, (600 - 41), 100, 37);
                        btnBack.Action += (UIButton_Action)((btn) =>
                        {
                            UIParent.ClearESCHook();
                            oResult = new GameScreen_Main(game);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(btnBack);

                        UIParent.ESCHook += UIParent_ESCHook1;

                        //select game type
                        for (int i = 0; i < ((UIComboBox)UIParent.UI["cboxGameType"]).Values.Count; i++)
                            if ((GameType)((UIComboBox)UIParent.UI["cboxGameType"]).Values[i].Tag == GameSettings.gameType)
                            {
                                ((UIComboBox)UIParent.UI["cboxGameType"]).SelectedIndex = i;
                                break;
                            }
                    }
                    break;
                case 1: //game slots settings
                    {
                        UIButton button;
                        UILabel label;
                        UIComboBox combo;
                        UIImage logo;

                        bool team_game = (GameSettings.gameType == GameType.TeamDeathMatch) || (GameSettings.gameType == GameType.TeamDemolition) || (GameSettings.gameType == GameType.TeamPointMatch) || (GameSettings.gameType == GameType.TeamTimeMatch);
                        int enabledSlotsCount = 0;
                        int enabledSlotsLimit = GameSettings.gameMap.Parameters.MaxPlayers;
                        int enabledTeamSlotsLimit = GameSettings.gameMap.Parameters.MaxPlayers / 2;

                        logo = new UIImage(game);
                        logo.Textures = game.Content.Load<Texture2D>("logo_newgame");
                        logo.NormalTexture = new Rectangle(0, 0, 500, 75);
                        logo.PositionAndSize = new Rectangle(400 - 250, 20, 500, 75);
                        UIParent.UI.Add(logo);

                        Rectangle last_pos = new Rectangle(10, logo.PositionAndSize.Bottom + 5, 0, 0);
                        for (int _t = 0; _t < 2; _t++)
                        {
                            if (team_game)
                                enabledSlotsCount = 0;

                            last_pos = new Rectangle(10 + 400 * _t, logo.PositionAndSize.Bottom + 5, 40 + 400 * _t, 195 + 400 * _t);

                            if (team_game)
                            {
                                label = new UILabel(game);
                                label.AutoSize = true;
                                label.PositionAndSize = new Rectangle(last_pos.Left, logo.PositionAndSize.Bottom + 5, 0, 0);
                                label.Text = (_t == 0 ? "Red team" : "Blue team");
                                UIParent.UI.Add(label);
                                last_pos = new Rectangle(last_pos.Left + 10, label.PositionAndSize.Bottom + 5, last_pos.Width, last_pos.Height);
                            }

                            for (int _m = 0; _m < 5; _m++)
                            {
                                label = new UILabel(game);
                                label.AutoSize = true;
                                label.PositionAndSize = new Rectangle(last_pos.Left, last_pos.Top + 5, 0, 0);
                                if (team_game)
                                    label.Text = (_m + 1) + ": ";
                                else
                                    label.Text = (_t * 5 + _m + 1) + ": ";
                                UIParent.UI.Add(label);
                                combo = new UIComboBox(game);
                                combo.Name = "t" + (_t + 1) + "m" + (_m + 1) + "Name";
                                combo.Edible = false;
                                combo.Enabled = false;
                                combo.MaxDisplayedItems = 5;
                                combo.PositionAndSize = new Rectangle(last_pos.Width, last_pos.Top, last_pos.Height - last_pos.Width - 5, 0);
                                UIParent.UI.Add(combo);
                                button = new UIButton(game);
                                button.Name = "t" + (_t + 1) + "m" + (_m + 1) + "Type";
                                button.Enabled = (enabledSlotsCount < (team_game ? enabledTeamSlotsLimit : enabledSlotsLimit));
                                enabledSlotsCount += (button.Enabled ? 1 : 0);
                                button.PositionAndSize = new Rectangle(last_pos.Height, last_pos.Top, 80, combo.PositionAndSize.Height);
                                button.Text = "None";
                                button.Action += (UIButton_Action)((btn) =>
                                {
                                    switch (btn.Text)
                                    {
                                        case "None":
                                            btn.Text = "Player";
                                            UIParent.UI["btnProceedGame"].Enabled = true;
                                            UIParent.UI[btn.Name.Substring(0, 4) + "Name"].Enabled = true;
                                            ((UIComboBox)UIParent.UI[btn.Name.Substring(0, 4) + "Name"]).Values.Clear();
                                            ((UIComboBox)UIParent.UI[btn.Name.Substring(0, 4) + "Name"]).Values.Add(new UITaggedValue(GameSettings.playerName, 0));
                                            ((UIComboBox)UIParent.UI[btn.Name.Substring(0, 4) + "Name"]).Values.Add(new UITaggedValue("<network player>", -1));
                                            ((UIComboBox)UIParent.UI[btn.Name.Substring(0, 4) + "Name"]).SelectedIndex = 0;
                                            break;
                                        case "Player":
                                            btn.Text = "Bot";
                                            UIParent.UI["btnProceedGame"].Enabled = true;
                                            UIParent.UI[btn.Name.Substring(0, 4) + "Name"].Enabled = true;
                                            ((UIComboBox)UIParent.UI[btn.Name.Substring(0, 4) + "Name"]).Values.Clear();
                                            for (int i = 0; i < Enum.GetNames(typeof(Default_BotNames)).Length; i++)
                                                ((UIComboBox)UIParent.UI[btn.Name.Substring(0, 4) + "Name"]).Values.Add(new UITaggedValue(Enum.GetNames(typeof(Default_BotNames))[i]));
                                            ((UIComboBox)UIParent.UI[btn.Name.Substring(0, 4) + "Name"]).SelectedIndex = 0;
                                            break;
                                        case "Bot":
                                            btn.Text = "None";
                                            int count = 0;
                                            for (int t = 1; t <= 2; t++)
                                                for (int m = 1; m <= 5; m++)
                                                    if (UIParent.UI["t" + t + "m" + m + "Type"].Text == "None")
                                                        count++;
                                            if (count == 10)
                                                UIParent.UI["btnProceedGame"].Enabled = false;
                                            UIParent.UI[btn.Name.Substring(0, 4) + "Name"].Enabled = false;
                                            ((UIComboBox)UIParent.UI[btn.Name.Substring(0, 4) + "Name"]).Values.Clear();
                                            break;
                                    }
                                });
                                UIParent.UI.Add(button);
                                last_pos = new Rectangle(last_pos.Left, button.PositionAndSize.Bottom + 5, last_pos.Width, last_pos.Height);
                            }
                        }

                        label = new UILabel(game);
                        label.AutoSize = true;
                        label.PositionAndSize = new Rectangle(10, last_pos.Top + 20, 0, 0);
                        label.Text = "Bot sophistication: ";
                        UIParent.UI.Add(label);
                        combo = new UIComboBox(game);
                        combo.Name = "comboBotLevel";
                        combo.Edible = false;
                        combo.MaxDisplayedItems = 3;
                        combo.PositionAndSize = new Rectangle(label.PositionAndSize.Right + 5, label.PositionAndSize.Top, 150, 0);
                        combo.Values.Add(new UITaggedValue("easy", BotMotor.BotSophistication.Easy));
                        combo.Values.Add(new UITaggedValue("normal", BotMotor.BotSophistication.Normal));
                        combo.Values.Add(new UITaggedValue("hard", BotMotor.BotSophistication.Hard));
                        combo.SelectedIndex = 0;
                        UIParent.UI.Add(combo);

                        button = new UIButton(game);
                        button.Name = "btnProceedGame";
                        button.Enabled = false;
                        button.Text = "Start";
                        button.PositionAndSize = new Rectangle(800 - 105, 600 - 41, 100, 37);
                        button.Action += (UIButton_Action)((btn) =>
                        {
                            //save changes
                            for(int i=0; i<5; i++)
                            {
                                switch (UIParent.UI["t1m" + (i + 1) + "Type"].Text)
                                {
                                    case "None":
                                        GameSettings.gameSlots[i] = null;
                                        break;
                                    case "Player":
                                        GameSettings.gameSlots[i] = new MotorShortDescription(typeof(PlayerMotor), ((UIComboBox)UIParent.UI["t1m" + (i + 1) + "Name"]).SelectedItem.Text, (int)((UIComboBox)UIParent.UI["t1m" + (i + 1) + "Name"]).SelectedItem.Tag);
                                        break;
                                    case "Bot":
                                        GameSettings.gameSlots[i] = new MotorShortDescription(typeof(BotMotor), ((UIComboBox)UIParent.UI["t1m" + (i + 1) + "Name"]).SelectedItem.Text, (int)((UIComboBox)UIParent.UI["comboBotLevel"]).SelectedItem.Tag);
                                        break;
                                }
                                switch (UIParent.UI["t2m" + (i + 1) + "Type"].Text)
                                {
                                    case "None":
                                        GameSettings.gameSlots[5 + i] = null;
                                        break;
                                    case "Player":
                                        GameSettings.gameSlots[5 + i] = new MotorShortDescription(typeof(PlayerMotor), ((UIComboBox)UIParent.UI["t2m" + (i + 1) + "Name"]).SelectedItem.Text, (int)((UIComboBox)UIParent.UI["t2m" + (i + 1) + "Name"]).SelectedItem.Tag);
                                        break;
                                    case "Bot":
                                        GameSettings.gameSlots[5 + i] = new MotorShortDescription(typeof(BotMotor), ((UIComboBox)UIParent.UI["t2m" + (i + 1) + "Name"]).SelectedItem.Text, (int)((UIComboBox)UIParent.UI["comboBotLevel"]).SelectedItem.Tag);
                                        break;
                                }
                            }

                            UIParent.ClearESCHook();
                            oResult = null;/*new GameScreen_Misc(game, 0);*/
                            iResult = MenuReturnCodes.GameStartRequested;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(button);

                        UIButton btnBack = new UIButton(game);
                        btnBack.Name = "btnBack";
                        btnBack.Text = "<-- Back";
                        btnBack.PositionAndSize = new Rectangle(5, (600 - 41), 100, 37);
                        btnBack.Action += (UIButton_Action)((btn) =>
                        {
                            UIParent.ClearESCHook();
                            oResult = new GameScreen_NewGame(game, 0);
                            iResult = MenuReturnCodes.MenuSwitching;
                            Call_OnExit();
                        });
                        UIParent.UI.Add(btnBack);

                        UIParent.ESCHook += UIParent_ESCHook2;
                    }
                    break;
            }

            UIParent.UI.LoadAndInitialize();
        }
コード例 #34
0
ファイル: MotorkiGame.cs プロジェクト: valdemart/Motorki
        private void CreateTestUI()
        {
            UIButton button;
            button = new UIButton(this);
            button.Name = "Button1";
            button.Text = "Fullscreen: " + (graphics.IsFullScreen ? "On" : "Off");
            button.PositionAndSize = new Rectangle(10, 10, 150, 30);
            button.Action += (UIButton_Action)((btn) =>
            {
                SetGraphMode(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, !graphics.IsFullScreen);
                btn.Text = "Fullscreen: " + (graphics.IsFullScreen ? "On" : "Off");
                UI["TextBox1"].Enabled = !UI["TextBox1"].Enabled;
                UI["Combo1"].Enabled = !UI["Combo1"].Enabled;
            });
            UI.Add(button);

            button = new UIButton(this);
            button.Name = "Button2";
            button.Text = "taaa...";
            button.PositionAndSize = new Rectangle(165, 10, 100, 50);
            button.Action += (UIButton_Action)((btn) =>
            {
                UI["Button1"].Enabled = !UI["Button1"].Enabled;
                UI["Label1"].Enabled = !UI["Label1"].Enabled;
                ((UIComboBox)UI["Combo1"]).Edible = !((UIComboBox)UI["Combo1"]).Edible;
                if (((UIComboBox)UI["Combo1"]).Edible)
                    UI["Combo1"].PositionAndSize = new Rectangle(UI["Combo1"].PositionAndSize.X, UI["Combo1"].PositionAndSize.Y, 200, 50);
                else
                    UI["Combo1"].PositionAndSize = new Rectangle(UI["Combo1"].PositionAndSize.X, UI["Combo1"].PositionAndSize.Y, 100, 0);
                switch (((UITextBox)UI["TextBox1"]).PasswordChar)
                {
                    case '\0': ((UITextBox)UI["TextBox1"]).PasswordChar = '*'; break;
                    case '*': ((UITextBox)UI["TextBox1"]).PasswordChar = '\0'; break;
                }
                ((UIListBox)UI["ListBox1"]).Add(UI["TextBox1"].Text);
            });
            UI.Add(button);

            UITextBox textbox = new UITextBox(this);
            textbox.Name = "TextBox1";
            textbox.Text = "kupa";
            textbox.TextLenghtLimit = 10;
            textbox.PositionAndSize = new Rectangle(270, 10, 150, 30);
            textbox.PasswordChar = '*';
            UI.Add(textbox);

            UILabel label = new UILabel(this);
            label.Name = "Label1";
            label.Text = "jakis tam...\ntekst";
            label.Enabled = false;
            label.PositionAndSize = new Rectangle(UI["Button1"].PositionAndSize.X, UI["Button1"].PositionAndSize.Y + UI["Button1"].PositionAndSize.Height + 5, 0, 0);
            UI.Add(label);

            UIComboBox combo1 = new UIComboBox(this);
            combo1.Name = "Combo1";
            combo1.Edible = false;
            combo1.PositionAndSize = new Rectangle(UI["Button2"].PositionAndSize.X, UI["Button2"].PositionAndSize.Y + UI["Button2"].PositionAndSize.Height + 5, 100, 0);
            combo1.Values.Add("pos1");
            combo1.Values.Add("pos2");
            combo1.Values.Add("pos3");
            combo1.Values.Add("pos4");
            combo1.MaxDisplayedItems = 3;
            combo1.SelectionChanged += (UIComboBox_SelectionChanged)((combo, oldindex) =>
            {
                UI["TextBox1"].Text = combo.SelectedValue;
            });
            UI.Add(combo1);

            UIListBox listBox1 = new UIListBox(this);
            listBox1.Name = "ListBox1";
            listBox1.PositionAndSize = new Rectangle(UI["TextBox1"].PositionAndSize.X + UI["TextBox1"].PositionAndSize.Width + 5, UI["TextBox1"].PositionAndSize.Y, 150, 0);
            listBox1.AutoSizeHeight = true;
            listBox1.MaxVisibleValues = 5;
            listBox1.Add("Button1");
            listBox1.Add("Button2");
            listBox1.Add("TextBox1");
            listBox1.Add("Label1");
            listBox1.Add("Combo1");
            listBox1.AutoSizeHeight = false;
            listBox1.PositionAndSize = new Rectangle(listBox1.PositionAndSize.X, listBox1.PositionAndSize.Y, listBox1.PositionAndSize.Width, listBox1.PositionAndSize.Height + 50);
            listBox1.ItemHover += (UIListBox_ItemEvent)((list, itemindex) =>
            {
                list.SelectedIndex = itemindex;
            });
            listBox1.ItemClicked += (UIListBox_ItemEvent)((list, itemindex) =>
            {
                if (itemindex < 5)
                    UI[list[itemindex].Text].Enabled = !UI[list[itemindex].Text].Enabled;
                else
                    ((UIListBox)UI["ListBox1"]).RemoveAt(itemindex);
            });
            UI.Add(listBox1);

            UIScrollBar scroll1 = new UIScrollBar(this, false);
            scroll1.Name = "Scroll1";
            scroll1.MinimalValue = 0;
            scroll1.MaximalValue = 200;
            scroll1.PositionAndSize = new Rectangle(label.PositionAndSize.X, label.PositionAndSize.Y + label.PositionAndSize.Height + 100, 150, 150);
            scroll1.Value = 0;
            scroll1.ValuesOnScreen = 3;
            scroll1.ValueChanged += (UIScrollBar_ValueChanged)((scroll, oldval) =>
            {
                UI["Label1"].Text = (oldval < scroll.Value ? "zwiekszone na:\n" : "zmniejszone na:\n") + scroll.Value;
                ((UIProgress)UI["ProgressBar1"]).Percent = scroll.Value / 200.0;
            });
            UI.Add(scroll1);

            UICheckBox checkBox1 = new UICheckBox(this);
            checkBox1.Name = "CheckBox1";
            checkBox1.AutoSize = true;
            checkBox1.Text = "checkbox1";
            checkBox1.PositionAndSize = new Rectangle(combo1.PositionAndSize.X, combo1.PositionAndSize.Bottom + 5, 0, 0);
            UI.Add(checkBox1);

            UIKeyPicker keypicker1 = new UIKeyPicker(this);
            keypicker1.Name = "KeyPicker1";
            keypicker1.PositionAndSize = new Rectangle(scroll1.PositionAndSize.X, scroll1.PositionAndSize.Bottom + 5, 100, 30);
            keypicker1.SelectedKey = Keys.A;
            UI.Add(keypicker1);

            UIProgress progress1 = new UIProgress(this);
            progress1.Name = "ProgressBar1";
            progress1.PositionAndSize = new Rectangle(keypicker1.PositionAndSize.X, keypicker1.PositionAndSize.Bottom + 5, 100, 20);
            progress1.Angular = true;
            progress1.color = Color.Blue; //relevant when Angular==true
            progress1.Percent = 0.8;
            UI.Add(progress1);
        }