Esempio n. 1
0
 public OxSlider(float value)
     : base(Vector2.zero, Vector2.zero)
 {
     this.value            = value;
     sliderThumb           = new OxButton("");
     sliderThumb.pressed  += button_pressed;
     sliderThumb.released += button_released;
     sliderBack            = new OxButton("");
     sliderBack.clicked   += button_clicked;
 }
Esempio n. 2
0
    private void InitializeButton()
    {
        int buttonWidth = 48, buttonHeight = 48, buttonX = (Screen.width / 2) - (buttonWidth / 2), buttonY = (Screen.height / 2) - (buttonHeight / 2);

        button      = new OxButton(new Vector2(buttonX, buttonY), new Vector2(buttonWidth, buttonHeight));
        button.text = "Hello";
        OxPanel quickPanel = tabbedPanel.AddTab("Button");

        quickPanel.AddItems(button);
    }
Esempio n. 3
0
 public OxChooser(string cTexture, string lTexture, string rTexture, string tTexture, string bTexture) : base(new Vector2(0, 0), new Vector2(0, 0))
 {
     centerTexture         = cTexture;
     leftTexture           = lTexture;
     rightTexture          = rTexture;
     topTexture            = tTexture;
     bottomTexture         = bTexture;
     acceptButton          = new OxButton("Accept", "MenuButton");
     acceptButton.clicked += Button_clicked;
     cancelButton          = new OxButton("Cancel", "MenuButton");
     cancelButton.clicked += Button_clicked;
 }
Esempio n. 4
0
    private void InitializeMenu()
    {
        int menuWidth = 75, menuHeight = 250, menuX = (Screen.width / 2) - (menuWidth / 2), menuY = (Screen.height / 2) - (menuHeight / 2);

        menu = new OxMenu(new Vector2(menuX, menuY), new Vector2(menuWidth, menuHeight));
        for (int i = 0; i < 25; i++)
        {
            OxButton menuButton = new OxButton();
            menuButton.text = (i + 1).ToString();
            menu.AddItems(menuButton);
        }
        OxPanel quickPanel = tabbedPanel.AddTab("Menu");

        quickPanel.AddItems(menu);
    }
Esempio n. 5
0
 public void RefreshReplaysList()
 {
     loadedReplayList.Clear();
     //for (int i = 0; i < Demo.loadedDemos.Count; i++)
     foreach (KeyValuePair <string, Demo> entry in Demo.loadedDemos)
     {
         string replayName = entry.Key;
         //replayName.Replace("\\", "/");
         //if (replayName.LastIndexOf("/") > -1) replayName = replayName.Substring(replayName.LastIndexOf("/") + 1);
         //if (replayName.LastIndexOf(".") > -1) replayName = replayName.Substring(0, replayName.LastIndexOf("."));
         OxButton replayListButton = new OxButton(replayName, "MenuButton");
         replayListButton.replaceWhat     = "\\";
         replayListButton.replaceWith     = "/";
         replayListButton.substringBefore = "/";
         replayListButton.substringAfter  = ".";
         loadedReplayList.AddItem(replayListButton);
     }
 }
Esempio n. 6
0
    private void MakeMenus()
    {
        backButton          = new OxButton("Back", "MenuButton");
        backButton.clicked += Button_clicked;

        #region Main Menu
        mainMenu                   = new OxMenu(false);
        viewLiveButton             = new OxButton("Live", "MenuButton");
        viewReplaysButton          = new OxButton("Replays", "MenuButton");
        viewMapsButton             = new OxButton("Maps", "MenuButton");
        settingsButton             = new OxButton("Settings", "MenuButton");
        exitButton                 = new OxButton("Exit", "MenuButton");
        viewLiveButton.clicked    += Button_clicked;
        viewReplaysButton.clicked += Button_clicked;
        viewMapsButton.clicked    += Button_clicked;
        settingsButton.clicked    += Button_clicked;
        exitButton.clicked        += Button_clicked;
        mainMenu.AddItem(viewLiveButton, viewReplaysButton, viewMapsButton, settingsButton, exitButton);
        #endregion

        #region Live Menu
        liveMenu               = new OxMenu(false);
        addressBox             = new OxTextBox("127.0.0.1", "");
        connectButton          = new OxButton("Connect", "MenuButton");
        connectButton.clicked += Button_clicked;
        liveMenu.AddItem(addressBox, connectButton, backButton);
        #endregion

        #region Replays Menu
        replaysMenu = new OxSplit();
        replayChooserStatsSplitter     = new OxSplit();
        replayFilesChooserBackSplitter = new OxSplit();
        replayStatsButtonsSplitter     = new OxSplit();
        replayFileList         = new OxList();
        loadedReplayList       = new OxList();
        loadedReplayButtonMenu = new OxMenu(true);
        importReplayButtonMenu = new OxMenu(false);
        importReplayButton     = new OxButton("Import", "MenuButton");
        watchReplayButton      = new OxButton("Watch", "MenuButton");
        removeReplayButton     = new OxButton("Remove", "MenuButton");

        importReplayButton.clicked += Button_clicked;
        watchReplayButton.clicked  += Button_clicked;
        removeReplayButton.clicked += Button_clicked;

        replaysMenu.division        = 0.7f;
        replaysMenu.westPercentSize = 0.9f;
        replaysMenu.westComponent   = replayChooserStatsSplitter;
        replaysMenu.eastComponent   = replayFilesChooserBackSplitter;
        replayFilesChooserBackSplitter.horizontal      = false;
        replayFilesChooserBackSplitter.division        = 0.75f;
        replayFilesChooserBackSplitter.eastPercentSize = 0.9f;
        replayFilesChooserBackSplitter.westComponent   = replayFileList;
        replayFilesChooserBackSplitter.eastComponent   = importReplayButtonMenu;
        importReplayButtonMenu.AddItem(importReplayButton, backButton);
        replayChooserStatsSplitter.horizontal    = false;
        replayChooserStatsSplitter.division      = 0.2f;
        replayChooserStatsSplitter.westComponent = loadedReplayList;
        replayChooserStatsSplitter.eastComponent = replayStatsButtonsSplitter;
        loadedReplayList.horizontal              = true;
        replayStatsButtonsSplitter.horizontal    = false;
        replayStatsButtonsSplitter.division      = 0.8f;
        replayStatsButtonsSplitter.westComponent = new OxLabel();
        replayStatsButtonsSplitter.eastComponent = loadedReplayButtonMenu;
        loadedReplayButtonMenu.AddItem(watchReplayButton, removeReplayButton);

        replayFileList.FillBrowserList("", true, "dem");
        //replaysMenu = new OxMenu(false);
        //replaysMenu.AddItem(backButton);
        #endregion

        #region Replay Interface
        replayInterface = new OxSplit();
        OxSplit lowerInterfaceSplit = new OxSplit(), lowerInterfaceSecondSplit = new OxSplit();
        OxSplit playerListSplit = new OxSplit(), mediaControlsSplit = new OxSplit(), centerPlayButtonSplit = new OxSplit(), playButtonSplit = new OxSplit();
        playerList = new OxList();
        playerList.indexChanged += playerList_indexChanged;
        //interfaceControlWindow = new OxWindow();
        playButton                 = new OxButton("Play");
        playButton.clicked        += Button_clicked;
        replaySeeker               = new OxSlider();
        replaySeeker.valueChanged += replaySeeker_valueChanged;
        //seekButton = new OxButton("");
        replayInterface.horizontal              = false;
        replayInterface.division                = 0.6f;
        replayInterface.eastComponent           = lowerInterfaceSplit;
        replayInterface.westComponent           = new OxLabel();
        lowerInterfaceSplit.division            = 0.75f;
        lowerInterfaceSplit.eastPercentSize     = 0.25f;
        lowerInterfaceSplit.eastComponent       = backButton;
        lowerInterfaceSplit.westComponent       = lowerInterfaceSecondSplit;
        lowerInterfaceSecondSplit.division      = 0.33f;
        lowerInterfaceSecondSplit.eastComponent = playerListSplit;
        lowerInterfaceSecondSplit.westComponent = new OxLabel();
        //interfaceControlWindow.showMinimizeButton = false;
        //interfaceControlWindow.showMaximizeButton = false;
        //interfaceControlWindow.showCloseButton = false;
        //interfaceControlWindow.layout = mediaControlsSplit;
        playerListSplit.horizontal          = false;
        playerListSplit.division            = 0.9f;
        playerListSplit.westComponent       = mediaControlsSplit;
        playerListSplit.eastComponent       = playerList;
        playerList.horizontal               = true;
        mediaControlsSplit.horizontal       = false;
        mediaControlsSplit.division         = 0.1f;
        mediaControlsSplit.eastComponent    = centerPlayButtonSplit;
        mediaControlsSplit.westComponent    = replaySeeker;
        centerPlayButtonSplit.division      = 0.3f;
        centerPlayButtonSplit.eastComponent = playButtonSplit;
        centerPlayButtonSplit.westComponent = new OxLabel();
        playButtonSplit.division            = 0.6f;
        playButtonSplit.westPercentSize     = 0.5f;
        playButtonSplit.eastComponent       = new OxLabel();
        playButtonSplit.westComponent       = playButton;
        #endregion

        #region Maps Menu
        //mapMenu, mapChooserSplit, mapButtonSplit
        mapMenu         = new OxSplit();
        mapChooserSplit = new OxSplit();
        mapButtonSplit  = new OxSplit();
        navButtonSplit  = new OxSplit();
        OxSplit buttonSplitWithEmpty = new OxSplit();
        OxSplit navGapSplit          = new OxSplit();
        mapFileChooser            = new OxList();
        loadMapButton             = new OxButton("Import Map", "MenuButton");
        nextMapButton             = new OxButton("Next", "MenuButton");
        prevMapButton             = new OxButton("Previous", "MenuButton");
        exploreMapButton          = new OxButton("Explore", "MenuButton");
        loadMapButton.clicked    += Button_clicked;
        nextMapButton.clicked    += Button_clicked;
        prevMapButton.clicked    += Button_clicked;
        exploreMapButton.clicked += Button_clicked;
        //mapFileChooser.done += Chooser_done;
        string mapsLoc = "";
        if (ApplicationPreferences.mapsDir != null && ApplicationPreferences.mapsDir.Length > 0)
        {
            mapsLoc = ApplicationPreferences.mapsDir.Substring(0, ApplicationPreferences.mapsDir.Length - 1);
        }
        mapFileChooser.FillBrowserList(mapsLoc, true, "bsp");
        mapMenu.division                   = 0.8f;
        mapMenu.westPercentSize            = 0.9f;
        mapMenu.eastComponent              = mapChooserSplit;
        mapMenu.westComponent              = buttonSplitWithEmpty;
        mapChooserSplit.division           = 0.75f;
        mapChooserSplit.eastPercentSize    = 0.9f;
        mapChooserSplit.horizontal         = false;
        mapChooserSplit.westComponent      = mapFileChooser;
        mapChooserSplit.eastComponent      = mapButtonSplit;
        mapButtonSplit.horizontal          = false;
        mapButtonSplit.westComponent       = loadMapButton;
        mapButtonSplit.eastComponent       = backButton;
        buttonSplitWithEmpty.division      = 0.9f;
        buttonSplitWithEmpty.horizontal    = false;
        buttonSplitWithEmpty.westComponent = new OxSplit();
        buttonSplitWithEmpty.eastComponent = navButtonSplit;
        navButtonSplit.division            = 0.75f;
        navButtonSplit.eastComponent       = nextMapButton;
        navButtonSplit.westComponent       = navGapSplit;
        navGapSplit.division               = 0.33f;
        navGapSplit.eastComponent          = exploreMapButton;
        navGapSplit.westComponent          = prevMapButton;
        //mapMenu.AddItem(mapFileChooser, backButton);
        #endregion

        #region ExploreInterface
        exploreInterface            = new OxSplit();
        exploreInterface.horizontal = false;
        exploreInterface.division   = 0.9f;
        OxSplit exploreInterfaceBackSplit = new OxSplit();
        exploreInterface.westComponent          = new OxLabel();
        exploreInterface.eastComponent          = exploreInterfaceBackSplit;
        exploreInterfaceBackSplit.division      = 0.9f;
        exploreInterfaceBackSplit.westComponent = new OxLabel();
        exploreInterfaceBackSplit.eastComponent = backButton;
        #endregion

        #region Settings Menu
        settingsMenu = new OxMenu(false);

        fullscreenCheckBox = new OxCheckBox(ApplicationPreferences.fullscreen, "Fullscreen");
        fullscreenCheckBox.checkBoxSwitched += CheckBox_Switched;
        combineMeshesCheckBox = new OxCheckBox(ApplicationPreferences.combineMeshes, "Combine Map Meshes");
        combineMeshesCheckBox.checkBoxSwitched += CheckBox_Switched;
        averageTexturesCheckBox = new OxCheckBox(ApplicationPreferences.averageTextures, "Average Textures");
        averageTexturesCheckBox.checkBoxSwitched += CheckBox_Switched;
        decreaseTexturesCheckBox = new OxCheckBox(ApplicationPreferences.decreaseTextureSizes, "Decrease Texture Sizes");
        decreaseTexturesCheckBox.checkBoxSwitched += CheckBox_Switched;

        maxTextureSizeLabel   = new OxLabel("Max Size", Color.black, TextAnchor.LowerCenter);
        texturesLocationLabel = new OxLabel("Textures Location", Color.black, TextAnchor.LowerCenter);
        mapsLocationLabel     = new OxLabel("Maps Location", Color.black, TextAnchor.LowerCenter);
        modelsLocationLabel   = new OxLabel("Models Location", Color.black, TextAnchor.LowerCenter);
        sfxLocationLabel      = new OxLabel("SFX Location", Color.black, TextAnchor.LowerCenter);

        maxTextureSizeTextBox              = new OxTextBox(ApplicationPreferences.maxSizeAllowed.ToString(), "");
        maxTextureSizeTextBox.textChanged += TextBox_textChanged;

        texturesLocationTextBox               = new OxTextBox(ApplicationPreferences.texturesDir, "");
        texturesLocationTextBox.textChanged  += TextBox_textChanged;
        browseTexturesLocationButton          = new OxButton("Browse", "MenuButton");
        browseTexturesLocationButton.clicked += Button_clicked;

        mapsLocationTextBox               = new OxTextBox(ApplicationPreferences.mapsDir, "");
        mapsLocationTextBox.textChanged  += TextBox_textChanged;
        browseMapsLocationButton          = new OxButton("Browse", "MenuButton");
        browseMapsLocationButton.clicked += Button_clicked;

        modelsLocationTextBox               = new OxTextBox(ApplicationPreferences.modelsDir, "");
        modelsLocationTextBox.textChanged  += TextBox_textChanged;
        browseModelsLocationButton          = new OxButton("Browse", "MenuButton");
        browseModelsLocationButton.clicked += Button_clicked;

        sfxLocationTextBox               = new OxTextBox("", "");
        sfxLocationTextBox.textChanged  += TextBox_textChanged;
        browseSFXLocationButton          = new OxButton("Browse", "MenuButton");
        browseSFXLocationButton.clicked += Button_clicked;

        settingsMenu.AddItem(fullscreenCheckBox, combineMeshesCheckBox, averageTexturesCheckBox, decreaseTexturesCheckBox, maxTextureSizeLabel, maxTextureSizeTextBox,
                             texturesLocationLabel, texturesLocationTextBox, browseTexturesLocationButton,
                             mapsLocationLabel, mapsLocationTextBox, browseMapsLocationButton,
                             modelsLocationLabel, modelsLocationTextBox, browseModelsLocationButton,
                             sfxLocationLabel, sfxLocationTextBox, browseSFXLocationButton,
                             backButton);
        #endregion

        #region Texture Dir Browser
        textureDirChooser       = new OxChooser();
        textureDirChooser.done += Chooser_done;
        #endregion

        #region Map Dir Browser
        mapDirChooser       = new OxChooser();
        mapDirChooser.done += Chooser_done;
        #endregion

        #region Model Dir Browser
        modelDirChooser       = new OxChooser();
        modelDirChooser.done += Chooser_done;
        #endregion

        #region SFX Dir Browser
        sfxDirChooser       = new OxChooser();
        sfxDirChooser.done += Chooser_done;
        #endregion
    }
Esempio n. 7
0
    public void FillBrowserList(string currentDir, bool includeFiles, string extension)
    {
        text = currentDir.Replace("\\", "/");
        string directoryView = text;

        if (directoryView.LastIndexOf(".") > directoryView.LastIndexOf("/"))
        {
            directoryView = directoryView.Substring(0, directoryView.LastIndexOf("/"));
        }
        if (!Directory.Exists(directoryView))
        {
            //if(Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor) text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            text          = Directory.GetCurrentDirectory();
            directoryView = text;
        }
        showFiles = includeFiles;
        extFilter = extension;

        Clear();
        DirectoryInfo parent = null;

        try { parent = Directory.GetParent(directoryView); } catch (Exception) { }
        if (parent != null)
        {
            OxButton dirButton = new OxButton("..", "MenuButton");
            dirButton.clicked += BrowserButtonClicked;
            AddItem(dirButton);
        }
        foreach (string dir in Directory.GetDirectories(directoryView))
        {
            string relativeDir = dir;
            relativeDir = relativeDir.Replace("\\", "/");
            if (relativeDir.LastIndexOf("/") > -1)
            {
                relativeDir = relativeDir.Substring(relativeDir.LastIndexOf("/") + 1);
            }
            OxButton dirButton = new OxButton(relativeDir, "MenuButton");
            dirButton.clicked += BrowserButtonClicked;
            AddItem(dirButton);
        }

        if (includeFiles)
        {
            string[] files = null;
            if (extension != null && extension.Length > 0)
            {
                files = Directory.GetFiles(directoryView, "*." + extension);
            }
            else
            {
                files = Directory.GetFiles(directoryView);
            }

            foreach (string file in files)
            {
                string relativeFile = file;
                relativeFile = relativeFile.Replace("\\", "/");
                if (relativeFile.LastIndexOf("/") > -1)
                {
                    relativeFile = relativeFile.Substring(relativeFile.LastIndexOf("/") + 1);
                }
                OxButton fileButton = new OxButton(relativeFile, "MenuButton");
                fileButton.clicked += BrowserButtonClicked;
                AddItem(fileButton);
            }
        }
    }