Beispiel #1
0
    public void SetActiveIcon(GameObject currentIcon, MENU type)
    {
        if (mTowerIconsList.Count > 0)
        {
            mCurrentIcon = currentIcon;
            mTowerManager.SetCurrentTower(mCurrentIcon.GetComponent<GUIIcon>().GetTowerType());

            DeactivateButtons();

            mCurrentIcon.active = true;
            mCurrentIcon.transform.position = mTowerIconsList[0].GetComponent<GUIIcon>().GetMenuPosition();

            if (type == MENU.BUY_INFO) SetBuyInfoMenu();
        }
    }
        public void runMenu()
        {
            menubuilder = new MenuBuilder(this._admin);
            invoker     = new Invoker(menubuilder);

            string input     = "";
            bool   isRunning = true;

            menubuilder.addMenu(MENU.MainMenu);

            while (isRunning)
            {
                menubuilder.showMenu();
                input = Console.ReadLine().ToLower().ToString();

                switch (input)
                {
                case "e":
                {
                    isRunning = false;
                    Console.WriteLine("\nSee you later in out LanguageSchool!\n");
                    break;
                }

                case "b":
                {
                    this._menu = MENU.BackMenu;

                    this.UnExecuteMenu();
                    break;
                }

                case "m":
                {
                    this._menu = MENU.MainMenu;
                    this.ExecuteMenu(this._menu);

                    break;
                }

                case "c":
                {
                    this._menu = MENU.CoursesMenu;
                    this.ExecuteMenu(this._menu);

                    break;
                }

                case "add":
                {
                    this._menu = MENU.AddCourse;
                    this.ExecuteMenu(this._menu);

                    break;
                }

                case "rem":
                {
                    this._menu = MENU.RemoveCourse;
                    this.ExecuteMenu(this._menu);

                    break;
                }

                case "cl":
                {
                    this._menu = MENU.CloneCourse;
                    this.ExecuteMenu(this._menu);

                    break;
                }

                default:
                {
                    break;
                }
                }
            }
        }
        private void SaveInfo(string strLink = "")
        {
            try
            {
                int idroot = Utils.CIntDef(Drchuyenmuc.SelectedValue);
                int rank = 1;
                var getRank = DB.MENUs.Where(n => n.ID == idroot).ToList();
                if (getRank.Count > 0)
                    rank = Utils.CIntDef(getRank[0].MENU_RANK + 1);
                if (m_news_id == 0)
                {

                    //insert
                    MENU menu = new MENU();
                    menu.MENU_NAME = Txtname.Value;
                    menu.MENU_PARENT_ID = idroot;
                    menu.MENU_RANK = rank;
                    menu.MENU_LINK = Txtlink.Value;
                    menu.MENU_ORDER = Utils.CIntDef(txtorder.Value);
                    menu.MENU_ACTIVE = Utils.CIntDef(Rdactive.SelectedValue);
                    DB.MENUs.InsertOnSubmit(menu);
                    DB.SubmitChanges();
                    var _new = DB.GetTable<MENU>().OrderByDescending(g => g.ID).Take(1);
                    m_news_id = _new.Single().ID;
                    strLink = string.IsNullOrEmpty(strLink) ? "menu_child.aspx?menu_id=" + m_news_id : strLink;
                }
                else
                {
                    //update
                    var c_update = DB.GetTable<MENU>().Where(g => g.ID == m_news_id);

                    if (c_update.ToList().Count > 0)
                    {
                        c_update.ToList()[0].MENU_NAME = Txtname.Value;
                        c_update.ToList()[0].MENU_PARENT_ID = Utils.CIntDef(Drchuyenmuc.SelectedValue);
                        c_update.ToList()[0].MENU_LINK = Txtlink.Value;
                        c_update.ToList()[0].MENU_RANK = rank;
                        c_update.ToList()[0].MENU_ORDER = Utils.CIntDef(txtorder.Value);
                        c_update.ToList()[0].MENU_ACTIVE = Utils.CIntDef(Rdactive.SelectedValue);
                        DB.SubmitChanges();
                        strLink = string.IsNullOrEmpty(strLink) ? "menu_child_list.aspx" : strLink;
                    }

                }

            }
            catch (Exception ex)
            {
                clsVproErrorHandler.HandlerError(ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(strLink))
                { Response.Redirect(strLink); }
            }
        }
        public UIMenuContext(FGLApplicationPanel f, MENU m)
        {
            int top = 30;

            //  MenuButtons = new List<Button>();
            thismenu          = m;
            _contextIsActive  = false;
            mainWin           = f;
            menuPanel         = new GroupBox();
            menuPanel.Visible = true;

            menuPanel.Text = m.TITLE;
            menuPanel.Controls.Clear();
            menuPanel.Dock = DockStyle.Fill;


            keyList      = new List <ONKEY_EVENT>();
            onActionList = new List <ON_ACTION_EVENT>();


            foreach (object o in m.MENUCOMMANDS)
            {
                if (o is MENUACTION)
                {
                    // Ignore for now..
                }
                if (o is MENUCOMMAND)
                {
                    MENUCOMMAND a;
                    Button      btn;
                    string      txt;
                    bool        isOnToolbar = false;
                    a   = o as MENUCOMMAND;
                    txt = a.TEXT;
                    if (txt.Length == 0)
                    {
                        txt = null;
                    }



                    if (txt == null)
                    {
                        string[] menukeys;
                        menukeys = a.KEYS.Split(',');
                        foreach (string s in menukeys)
                        {
                            ONKEY_EVENT e = new ONKEY_EVENT();
                            e.ID = a.ID;

                            e.KEY = s;
                            keyList.Add(e);
                        }
                    }
                    else
                    {
                        string[] menukeys;
                        if (a.KEYS == "")
                        {
                            menukeys = new string[1];
                            //menukeys[0] =1;

                            char[] arr = a.TEXT.Substring(0, 1).ToCharArray();
                            menukeys[0] = ((int)(arr[0])).ToString();
                        }
                        else
                        {
                            menukeys = a.KEYS.Split(',');
                        }

                        foreach (string s in menukeys)
                        {
                            int         n = -1;
                            ONKEY_EVENT e = new ONKEY_EVENT();
                            try
                            {
                                n = Convert.ToInt32(s);
                            }
                            catch (Exception) { }


                            if (s.Trim() != "" && n != -1)
                            {
                                e.ID = a.ID;

                                e.KEY = s;
                                if (n <= 26 || n > 255)
                                {
                                    keyList.Add(e);
                                }
                            }
                        }

                        if (a.TEXT != null && a.TEXT != "")
                        {
                            if (f.hasToolbarButton(a.TEXT.ToLower()))
                            {
                                ON_ACTION_EVENT e;
                                e        = new ON_ACTION_EVENT();
                                e.ACTION = a.TEXT.ToLower();
                                e.ID     = a.ID;

                                onActionList.Add(e);
                                isOnToolbar = true;
                                // NOTE :
                                // We might want to add a 'continue' here - so
                                // we dont have a menubutton of we have a toolbar button...
                            }
                        }

                        btn = new UIMenuBarButton(txt, a.ID);


                        if (a.DESCRIPTION != null)
                        {
                            tooltips.SetToolTip(btn, a.DESCRIPTION);
                        }

                        btn.Click   += new EventHandler(b_Click);
                        btn.Top      = top;
                        btn.AutoSize = true;
                        btn.Left     = 10;
                        if (btn.Image != null)
                        {
                            btn.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
                            btn.TextAlign  = System.Drawing.ContentAlignment.MiddleRight;
                        }

                        if (!isOnToolbar)
                        {
                            menuPanel.Controls.Add(btn);
                            if (btn.Height == 0)
                            {
                                top += 30;
                            }
                            else
                            {
                                top += btn.Height;
                            }
                        }
                    }
                }
            }


            //   mainWin.setActiveToolBarKeys(keyList, onActionList, false, false, false);
        }
Beispiel #5
0
 public MENU Update(MENU Menu)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
 public MENU Add(MENU Menu)
 {
     throw new NotImplementedException();
 }
Beispiel #7
0
        private void DetectMenu()
        {
            // Il me faut un indice qui, grace a lui, je peux savoir que j'ai une composition de menu
            // Le simple est de creer un boolén qui par defaut est actif
            // Il suffit q'une option ne contient pas un élément avec la quantité qu'il faut l'indice passe en inactif


            bool indice       = true;
            MENU detectedMenu = new MENU();

            // init tag in model cart
            foreach (var c in cvm.Cart)
            {
                c.Tag = false;
            }

            // Je recupere le panier
            var cartList = cvm.Cart;

            // je recupère la liste des menus
            var menu = db.MENU.ToList();

            // Je parcoure la liste des menus // un par un
            foreach (var menuItem in menu)
            {
                indice       = true;
                detectedMenu = menuItem;
                // Je verifie si le produit principal du menu est présent sur la carte
                bool contain = cartList.Where(c => c.Tag != true).Select(c => c.ItemId).Contains(menuItem.id_item);
                if (contain)
                {
                    var updateCartList = cartList.FirstOrDefault(i => i.ItemId == menuItem.id_item);
                    if (updateCartList != null)
                    {
                        updateCartList.Tag = true;
                        updateCartList.
                    }
                }
                else
                {
                    continue;
                }


                // Je recupère la liste des options
                var option = menuItem.OPTION_CHOIX_MENU.ToList();

                // Je parcoure la liste des options
                foreach (var optionItem in option)
                {
                    // Dans chaque option je vais chercher la liste des produits en  lien  avec le menu
                    var optionContainer = optionItem.ITEM_OPTION_MENU.ToList();
                    // optionContainer.Add(menuItem.ITEM);
                    HashSet <int> cartHash = new HashSet <int>(cartList.Where(c => c.Tag != true).Select(s => s.ItemId));
                    cartHash.Add(menuItem.id_item);
                    var results2 = optionContainer.Where(m => cartHash.Contains(m.id_item)).ToList();

                    // var cartIDs = cvm.Cart;
                    //  var results = optionContainer.Where(m => cartIDs.Any(z => z.ItemId == m.id_item) );

                    if (results2.Count() > 0)
                    {
                        foreach (var res in results2)
                        {
                            var updateCartList = cartList.FirstOrDefault(i => i.ItemId == res.id_item);
                            if (updateCartList != null)
                            {
                                updateCartList.Tag = true;
                            }
                        }
                    }
                    else
                    {
                        indice = false;
                    }
                }
                // Ici je peux tester si indice est actif je recupère le menu en question dans une liste
                if (indice)
                {
                    MessageBox.Show(detectedMenu.menu_title);
                }
                // Une fois le panier est parcourue entierrement j'affiche cette liste de menu :)
            }
            var test = cartList;
        }
Beispiel #8
0
 private void menuListBox_Click(object sender, EventArgs e)
 {
     selectedMenu = (MENU)menuListBox.SelectedIndex;
 }
 public void addMenu(MENU menu)
 {
     this._menues.Push(menu);
 }
Beispiel #10
0
 /// <summary>
 /// Graba o actualiza un menu
 /// </summary>
 /// <param name="menu">menu a grabar</param>
 public void SaveMenu(MENU menu)
 {
     try
     {
         using (DQBaseContext context=new DQBaseContext(ConnectionString))
         {
             context.MENU.ApplyChanges(menu);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #11
0
        private void updateFormTimer_Tick(object sender, EventArgs e)
        {
            lastUpdateTextBox.Text        = rxInterval.ToString();
            batteryPercentageTextBox.Text = sharedData.batteryPercentage.ToString() + "%";

            if (selectedMenu != displayedMenu)
            {
                this.menuPanel.Controls.Clear();
                mOverview.setUpdateFormTimer(false);
                mKicker.setUpdateFormTimer(false);
                mCamera.setUpdateFormTimer(false);
                mCompass.setUpdateFormTimer(false);
                mLine.setUpdateFormTimer(false);
                mSettings.setUpdateFormTimer(false);
                mShutdown.setUpdateFormTimer(false);

                switch (selectedMenu)
                {
                case MENU.OVERVIEW:
                    this.menuPanel.Controls.Add(mOverview);
                    mOverview.setUpdateFormTimer(true);
                    mOverview.Show();
                    break;

                case MENU.KICKER:
                    this.menuPanel.Controls.Add(mKicker);
                    mKicker.setUpdateFormTimer(true);
                    mKicker.Show();
                    break;

                case MENU.CAMERA:
                    this.menuPanel.Controls.Add(mCamera);
                    mCamera.setUpdateFormTimer(true);
                    mCamera.Show();
                    break;

                case MENU.COMPASS:
                    this.menuPanel.Controls.Add(mCompass);
                    mCompass.setUpdateFormTimer(true);
                    mCompass.Show();
                    break;

                case MENU.LINE:
                    this.menuPanel.Controls.Add(mLine);
                    mLine.setUpdateFormTimer(true);
                    mLine.Show();
                    break;

                case MENU.SETTINGS:
                    this.menuPanel.Controls.Add(mSettings);
                    mSettings.setUpdateFormTimer(true);
                    mSettings.Show();
                    break;

                case MENU.SHUTDOWN:
                    this.menuPanel.Controls.Add(mShutdown);
                    mShutdown.setUpdateFormTimer(true);
                    mShutdown.Show();
                    break;

                default:
                    break;
                }

                displayedMenu = selectedMenu;
            }

            if (((DateTime.Now.Ticks - lastTx) / 10000) >= 200)
            {
                lastTx = DateTime.Now.Ticks;

                txMsg[0]  = SYNC;
                txByteCnt = 1;
                addByteToTxBuffer(0x05); // message length spacing
                txChecksum = 0;
                addByteToTxBuffer((byte)executionCommand_t.EC_UPDATE_LED);
                addByteToTxBuffer((byte)(sharedData.ledState ? 1 : 0));
                addByteToTxBuffer((byte)dataRequest_t.DR_BATTERY_P);
                addByteToTxBuffer((byte)dataRequest_t.DR_COMPASS);
                addByteToTxBuffer((byte)dataRequest_t.DR_LINE);
                //txMsg[1] = (byte)(txByteCnt - 2);
                addByteToTxBuffer(txChecksum);
                serialComm.Write(txMsg, 0, txByteCnt);
            }
        }
Beispiel #12
0
 void IniMenuColor()
 {
     menu          = MENU.COLOR;
     nameText.text = "Choose color";
 }
        public JsonResult ObtenerMenu()
        {
            List <Sesion> SesionUsu = new List <Sesion>();

            SesionUsu = (List <Sesion>)System.Web.HttpContext.Current.Session["SessionDatosUsuarioLogeado"];
            if (SesionUsu != null)
            {
                try
                {
                    var ListaMenu = System.Web.HttpContext.Current.Session["ListaMenu"];
                    if (ListaMenu == null)
                    {
                        var Lista             = CursorDataContext.ObtenerMenu(SesionUsu[0].Usuario.ToUpper());
                        List <MENUPADRE> list = new List <MENUPADRE>();
                        if (Lista.MENUPADRE.Count > 0)
                        {
                            MENU dc = new MENU();
                            {
                                var menu = Lista.MENUPADRE.Select(c => new
                                {
                                    c.ID,
                                    c.NOMBRE,
                                    SubMenu = c.SUBMENU.Select(s => new
                                    {
                                        s.NOMBRE,
                                        s.CONTROL_NOMBRE
                                    })
                                });
                                System.Web.HttpContext.Current.Session["ListaMenu"] = Lista;
                                return(new JsonResult
                                {
                                    Data = menu,
                                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                                });
                            }
                        }
                        else
                        {
                            return(Json(false, JsonRequestBehavior.AllowGet));
                        }
                    }
                    else
                    {
                        var Lista             = System.Web.HttpContext.Current.Session["ListaMenu"] as MENU;
                        List <MENUPADRE> list = new List <MENUPADRE>();
                        if (Lista.MENUPADRE.Count > 0)
                        {
                            MENU dc = new MENU();
                            {
                                var menu = Lista.MENUPADRE.Select(c => new
                                {
                                    c.ID,
                                    c.NOMBRE,
                                    SubMenu = c.SUBMENU.Select(s => new
                                    {
                                        s.NOMBRE,
                                        s.CONTROL_NOMBRE
                                    })
                                });
                                System.Web.HttpContext.Current.Session["ListaMenu"] = Lista;
                                return(new JsonResult
                                {
                                    Data = menu,
                                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                                });
                            }
                        }
                        else
                        {
                            return(Json(false, JsonRequestBehavior.AllowGet));
                        }
                    }
                }
                catch (Exception ex)
                {
                    return(Json("Error256" + ex.Message, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(false, JsonRequestBehavior.AllowGet));
        }
Beispiel #14
0
 public DefaultCommand(IMenu receiver, MENU menu)
 {
     this._menu     = menu;
     this._receiver = receiver;
 }
        public void runMenu()
        {
            menubuilder = new MenuBuilder(this._user);
            invoker     = new Invoker(menubuilder);

            string input     = "";
            bool   isRunning = true;

            menubuilder.addMenu(MENU.MainMenu);

            while (isRunning)
            {
                menubuilder.showMenu();
                input = Console.ReadLine().ToLower().ToString();

                switch (input)
                {
                case "e":
                {
                    isRunning = false;
                    Console.WriteLine("\nSee you later in out LanguageSchool!\n");
                    break;
                }

                case "m":
                {
                    this._menu = MENU.MainMenu;
                    this.ExecuteMenu(this._menu);
                    menubuilder.addMenu(_menu);

                    DefaultCommand command = new DefaultCommand(menubuilder, _menu);

                    invoker.AddCommand(command);
                    invoker.Execute();

                    break;
                }

                case "p":
                {
                    this._menu = MENU.PersonalAreaMenu;
                    this.ExecuteMenu(this._menu);

                    break;
                }

                case "c":
                {
                    this._menu = MENU.CoursesMenu;
                    this.ExecuteMenu(this._menu);

                    break;
                }

                case "ca":
                {
                    this._menu = MENU.CartMenu;
                    this.ExecuteMenu(this._menu);

                    break;
                }

                case "buy":
                {
                    if (this._menu == MENU.CartMenu)
                    {
                        this._menu = MENU.BuyCourses;
                        this.ExecuteMenu(this._menu);
                    }
                    break;
                }

                case "cl":
                {
                    if (this._menu == MENU.CartMenu)
                    {
                        this._menu = MENU.ClearCart;
                        this.ExecuteMenu(this._menu);
                    }
                    break;
                }

                case "r":
                {
                    if (this._menu == MENU.CartMenu)
                    {
                        this._menu = MENU.RemoveCourse;
                        this.ExecuteMenu(this._menu);
                    }
                    break;
                }

                case "b":
                {
                    this._menu = MENU.BackMenu;

                    this.UnExecuteMenu();
                    break;
                }

                case "level":
                {
                    if (this._menu == MENU.CoursesMenu)
                    {
                        this._menu = MENU.CoursesByLevel;
                        this.ExecuteMenu(this._menu);
                    }
                    break;
                }

                case "add":
                {
                    if (this._menu == MENU.CoursesMenu)
                    {
                        this._menu = MENU.AddCourse;
                        this.ExecuteMenu(this._menu);
                    }
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
        }
        private void buildUserMenu(MENU menu)
        {
            switch (menu)
            {
            case MENU.MainMenu:
            {
                this.builder     = new buildMainMenu();
                director.Builder = this.builder;
                director.buildFullMenu();
                break;
            }

            case MENU.PersonalAreaMenu:
            {
                this.builder     = new buildPersonalAreaMenu(this._user);
                director.Builder = this.builder;
                director.buildFullMenu();
                break;
            }

            case MENU.AddCourse:
            {
                this.builder     = new buildAddCourseMenu(this._user);
                director.Builder = this.builder;
                director.buildFullMenu();
                break;
            }

            case MENU.CartMenu:
            {
                this.builder     = new buildCartMenu(this._user);
                director.Builder = this.builder;
                director.buildFullMenu();
                break;
            }

            case MENU.BuyCourses:
            {
                this.builder     = new buildBuyCourses(this._user);
                director.Builder = this.builder;
                director.buildFullMenu();
                break;
            }

            case MENU.ClearCart:
            {
                this.builder     = new buildClearCart(this._user);
                director.Builder = this.builder;
                director.buildFullMenu();
                break;
            }

            case MENU.RemoveCourse:
            {
                this.builder     = new buildRemoveCourse(this._user);
                director.Builder = this.builder;
                director.buildFullMenu();
                break;
            }

            case MENU.CoursesMenu:
            {
                this.builder     = new buildCoursesMenu(this._user);
                director.Builder = this.builder;
                director.buildFullMenu();
                break;
            }

            case MENU.BackMenu:
            {
                removeMenu();
                break;
            }

            case MENU.CoursesByLevel:
            {
                this.builder     = new buildCoursesByLevel();
                director.Builder = this.builder;
                director.buildFullMenu();
                break;
            }

            default:
            {
                Console.WriteLine("Unknown command. Repeat please.");
                break;
            }
            }
        }
    IEnumerator WaitAndSet(MENU selecao)
    {
        yield return(new WaitForSeconds(.5f));

        SetSeletor(selecao);
    }
Beispiel #18
0
        static int Main(string[] argv)
        {
            //        /* the submenu */
            MENUS submenu = new MENUS(5);

            submenu[0] = new MENU("Submenu", NULL, NULL, D_DISABLED, NULL);
            submenu[1] = new MENU("", NULL, NULL, 0, NULL);
            submenu[2] = new MENU("Checked", check_callback, NULL, D_SELECTED, NULL);
            submenu[3] = new MENU("Disabled", NULL, NULL, D_DISABLED, NULL);
            submenu[4] = new MENU(null, NULL, NULL, 0, NULL);

            /* the first menu in the menubar */
            MENUS menu1 = new MENUS(4);

            menu1[0] = new MENU("Test &1 \t1", menu_callback, NULL, 0, NULL);
            menu1[1] = new MENU("Test &2 \t2", menu_callback, NULL, 0, NULL);
            menu1[2] = new MENU("&Quit \tq/Esc", Marshal.GetFunctionPointerForDelegate(d_quit), NULL, 0, NULL);
            menu1[3] = new MENU(null, NULL, NULL, 0, NULL);

            /* the second menu in the menubar */
            MENUS menu2 = new MENUS(3);

            menu2[0] = new MENU("&Test", menu_callback, NULL, 0, NULL);
            menu2[1] = new MENU("&Submenu", NULL, submenu, 0, NULL);
            menu2[2] = new MENU(null, NULL, NULL, 0, NULL);

            /* the help menu */
            MENUS helpmenu = new MENUS(2);

            helpmenu[0] = new MENU("&About \tF1", Marshal.GetFunctionPointerForDelegate(d_about), NULL, 0, NULL);
            helpmenu[1] = new MENU(null, NULL, NULL, 0, NULL);

            /* the main menu-bar */
            MENUS the_menu = new MENUS(4);

            the_menu[0] = new MENU("&First", NULL, menu1, 0, NULL);
            the_menu[1] = new MENU("&Second", NULL, menu2, 0, NULL);
            the_menu[2] = new MENU("&Help", NULL, helpmenu, 0, NULL);
            the_menu[3] = new MENU(null, NULL, NULL, 0, NULL);

            the_dialog[0] = new DIALOG(d_clear_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);

            /* these just display text, either left aligned, centered, or right aligned */
            the_dialog[1] = new DIALOG("d_text_proc", 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_text_proc"), NULL, NULL);
            the_dialog[2] = new DIALOG("d_ctext_proc", 318, 20, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_ctext_proc"), NULL, NULL);
            the_dialog[3] = new DIALOG("d_rtext_proc", 636, 20, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_rtext_proc"), NULL, NULL);

            ///* lots of descriptive text elements */
            the_dialog[4]  = new DIALOG("d_text_proc", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_menu_proc->"), NULL, NULL);
            the_dialog[5]  = new DIALOG("d_text_proc", 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_button_proc->"), NULL, NULL);
            the_dialog[6]  = new DIALOG("d_text_proc", 0, 70, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_check_proc->"), NULL, NULL);
            the_dialog[7]  = new DIALOG("d_text_proc", 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_radio_proc->"), NULL, NULL);
            the_dialog[8]  = new DIALOG("d_text_proc", 0, 130, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_edit_proc->"), NULL, NULL);
            the_dialog[9]  = new DIALOG("d_text_proc", 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_list_proc->"), NULL, NULL);
            the_dialog[10] = new DIALOG("d_text_proc", 0, 200, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_text_list_proc->"), NULL, NULL);
            the_dialog[11] = new DIALOG("d_text_proc", 0, 250, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_textbox_proc->"), NULL, NULL);
            the_dialog[12] = new DIALOG("d_text_proc", 0, 300, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_slider_proc->"), NULL, NULL);
            the_dialog[13] = new DIALOG("d_text_proc", 0, 330, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_box_proc->"), NULL, NULL);
            the_dialog[14] = new DIALOG("d_text_proc", 0, 360, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_shadow_box_proc->"), NULL, NULL);
            the_dialog[15] = new DIALOG("d_text_proc", 0, 390, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_keyboard_proc. Press F1 to see me trigger the about box."), NULL, NULL);
            the_dialog[16] = new DIALOG("d_text_proc", 0, 410, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_clear_proc. I draw the white background."), NULL, NULL);
            the_dialog[17] = new DIALOG("d_text_proc", 0, 430, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_yield_proc. I make us play nice with the OS scheduler."), NULL, NULL);
            the_dialog[18] = new DIALOG("d_rtext_proc", 636, 40, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("<-d_bitmap_proc"), NULL, NULL);
            the_dialog[19] = new DIALOG("d_rtext_proc", 636, 80, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("<-d_icon_proc"), NULL, NULL);

            ///* a menu bar - note how it auto-calculates its dimension if they are not given */
            the_dialog[20] = new DIALOG("d_menu_proc", 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, the_menu, NULL, NULL);


            ///* some more GUI elements, all of which require you to specify their dimensions */
            the_dialog[21] = new DIALOG("d_button_proc", 160, 40, 160, 20, 0, 0, 't', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Toggle Me!"), NULL, NULL);
            the_dialog[22] = new DIALOG("d_check_proc", 160, 70, 160, 20, 0, 0, 'c', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Check Me!"), NULL, NULL);
            the_dialog[23] = new DIALOG("d_radio_proc", 160, 100, 160, 19, 0, 0, 's', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Select Me!"), NULL, NULL);
            the_dialog[24] = new DIALOG("d_radio_proc", 320, 100, 160, 19, 0, 0, 'o', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Or Me!"), NULL, NULL);
            the_dialog[25] = new DIALOG("d_edit_proc", 160, 130, 160, 8, 0, 0, 0, 0, LEN, 0, Marshal.StringToCoTaskMemAnsi(the_string), NULL, NULL);
            the_dialog[26] = new DIALOG("d_list_proc", 160, 150, 160, 44, 0, 0, 0, 0, 0, 0, Marshal.GetFunctionPointerForDelegate(d_listbox_getter), sel, NULL);
            the_dialog[27] = new DIALOG("d_text_list_proc", 160, 200, 160, 44, 0, 0, 0, 0, 0, 0, Marshal.GetFunctionPointerForDelegate(d_listbox_getter), NULL, NULL);
            the_dialog[28] = new DIALOG("d_textbox_proc", 160, 250, 160, 48, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi(the_text), NULL, NULL);
            the_dialog[29] = new DIALOG("d_slider_proc", 160, 300, 160, 12, 0, 0, 0, 0, 100, 0, NULL, NULL, NULL);
            the_dialog[30] = new DIALOG("d_box_proc", 160, 330, 160, 20, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);
            the_dialog[31] = new DIALOG("d_shadow_box_proc", 160, 360, 160, 20, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);

            ///* note how we don't fill in the dp field yet, because we first need to load the bitmap */
            the_dialog[32] = new DIALOG("d_bitmap_proc", 480, 40, 30, 30, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);
            the_dialog[33] = new DIALOG("d_icon_proc", 480, 80, 30, 30, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);

            ///* the quit and info buttons use our customized dialog procedure, using dp3 as callback */
            the_dialog[34] = new DIALOG(d_my_button_proc, 0, 450, 160, 20, 0, 0, 'q', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("&Quit"), NULL, Marshal.GetFunctionPointerForDelegate(d_quit));
            the_dialog[35] = new DIALOG(d_my_button_proc, 400, 150, 160, 20, 0, 0, 'i', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("&Info"), NULL, Marshal.GetFunctionPointerForDelegate(d_info1));
            the_dialog[36] = new DIALOG(d_my_button_proc, 400, 200, 160, 20, 0, 0, 'n', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("I&nfo"), NULL, Marshal.GetFunctionPointerForDelegate(d_info2));
            the_dialog[37] = new DIALOG(d_my_button_proc, 400, 300, 160, 20, 0, 0, 'f', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("In&fo"), NULL, Marshal.GetFunctionPointerForDelegate(d_info3));

            ///* the next two elements don't draw anything */
            the_dialog[38] = new DIALOG("d_keyboard_proc", 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, Marshal.GetFunctionPointerForDelegate(d_about), NULL, NULL);
            the_dialog[39] = new DIALOG("d_yield_proc", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);
            the_dialog[the_dialog.Length - 1] = new DIALOG(NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL);

            //char buf[256];
            byte[] buf = new byte[256];
            int    i;

            /* initialise everything */
            if (allegro_init() != 0)
            {
                return(1);
            }
            install_keyboard();
            install_mouse();
            install_timer();

            if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0)
            {
                if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) != 0)
                {
                    set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
                    allegro_message(string.Format("Unable to set any graphic mode\n{0}\n", allegro_error));
                    return(1);
                }
            }

            /* load the datafile */
            //replace_filename(buf, argv[0], "example.dat", sizeof(buf));
            //datafile = load_datafile(buf);
            replace_filename(buf, "./", "example.dat", buf.Length);
            datafile = load_datafile(Encoding.ASCII.GetString(buf));
            if (!datafile)
            {
                set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
                allegro_message(string.Format("Error loading {0}!\n", buf));
                return(1);
            }

            set_palette(datafile[THE_PALETTE].dat);

            /* set up colors */
            gui_fg_color = makecol(0, 0, 0);
            gui_mg_color = makecol(128, 128, 128);
            gui_bg_color = makecol(200, 240, 200);
            set_dialog_color(the_dialog, gui_fg_color, gui_bg_color);

            /* white color for d_clear_proc and the d_?text_procs */
            the_dialog[0].bg = makecol(255, 255, 255);
            for (i = 4; the_dialog[i].proc != NULL; i++)
            {
                if (the_dialog[i].proc == GetAddress("d_text_proc") ||
                    the_dialog[i].proc == GetAddress("d_ctext_proc") ||
                    the_dialog[i].proc == GetAddress("d_rtext_proc"))
                {
                    the_dialog[i].bg = the_dialog[0].bg;
                }
            }

            /* fill in bitmap pointers */
            the_dialog[BITMAP_OBJECT].dp = datafile[SILLY_BITMAP].dat;
            the_dialog[ICON_OBJECT].dp   = datafile[SILLY_BITMAP].dat;

            /* shift the dialog 2 pixels away from the border */
            position_dialog(the_dialog, 2, 2);

            /* do the dialog */
            do_dialog(the_dialog, -1);

            unload_datafile(datafile);

            return(0);
        }
Beispiel #19
0
    void GUIPrepLocalMatch()
    {
        GUILayout.BeginVertical();

        player1Name = GUILayout.TextField(player1Name, 50);
        player2Name = GUILayout.TextField(player2Name, 50);

        if (GUILayout.Button("Play"))
        {
            // Setup players based on UI state
            if (player1 != null)
            {
                Destroy(player1);
            }

            var p1 = Instantiate(playerLocalPrefab).GetComponent <PlayerLocal>();
            player1       = p1.gameObject;
            p1.playerID   = IGame.PLAYER.PLAYER1;
            p1.playerName = player1Name;
            p1.board      = board;
            switch (player1Type) // TODO: Configure player controller (human or AI)
            {
            case PLAYER_TYPE.HUMAN:
                // TODO
                break;

            case PLAYER_TYPE.AI:
                // TODO
                break;
            }

            if (player2 != null)
            {
                Destroy(player2);
            }

            var p2 = Instantiate(playerLocalPrefab).GetComponent <PlayerLocal>();
            player2       = p2.gameObject;
            p2.playerID   = IGame.PLAYER.PLAYER2;
            p2.playerName = player2Name;
            p2.board      = board;
            switch (player2Type) // TODO: Configure player controller (human or AI)
            {
            case PLAYER_TYPE.HUMAN:
                // TODO
                break;

            case PLAYER_TYPE.AI:
                // TODO
                break;
            }

            // Setup match based on players above and UI state about match
            var matchLocal = matchControllers.GetComponentInChildren <MatchLocal>(true);
            matchLocal.gameObject.SetActive(true);
            Debug.Assert(matchLocal != null, "MatchLocal component required");
            matchLocal.match.game    = game;
            matchLocal.match.board   = board; // Is this necessary?
            matchLocal.match.player1 = player1.gameObject.GetComponent <IPlayer>();
            matchLocal.match.player2 = p2.gameObject.GetComponent <IPlayer>();

            //currentMatch = matchLocal;

            // Transition to Playing state
            //currentMatch.Begin();
            activeMenu = MENU.PLAYING_LOCAL_MATCH;
        }

        if (GUILayout.Button("Back"))
        {
            activeMenu = MENU.MAIN;
        }

        GUILayout.EndVertical();

        GUILayout.BeginVertical();

        player1TypeSelection = GUILayout.SelectionGrid(player1TypeSelection, new string[] { "Human", "AI" }, 2);
        player2TypeSelection = GUILayout.SelectionGrid(player2TypeSelection, new string[] { "Human", "AI" }, 2);

        if (player1Type != (PLAYER_TYPE)player1TypeSelection)
        {
            player1Type = (PLAYER_TYPE)player1TypeSelection;
        }
        if (player2Type != (PLAYER_TYPE)player2TypeSelection)
        {
            player2Type = (PLAYER_TYPE)player2TypeSelection;
        }

        GUILayout.EndVertical();
    }
Beispiel #20
0
 public void UserSuccessfullyAuthenticated()
 {
     hideAll(dashboard1, dashboard_button);
     MENU.Show();
 }