예제 #1
0
    void BrowserButtonClicked(OxGUI sender)
    {
        string currentDir = text;

        if (currentDir.LastIndexOf(".") > currentDir.LastIndexOf("/"))
        {
            currentDir = currentDir.Substring(0, currentDir.LastIndexOf("/"));
        }

        if (sender.text.Equals("..", StringComparison.InvariantCultureIgnoreCase))
        {
            DirectoryInfo parentDir = Directory.GetParent(currentDir);
            if (parentDir != null)
            {
                currentDir = parentDir.FullName;
            }
        }
        else
        {
            if (currentDir.LastIndexOf("/") != currentDir.Length - 1)
            {
                currentDir += "/";
            }
            currentDir += sender.text;
        }

        FillBrowserList(currentDir, showFiles, extFilter);
    }
예제 #2
0
 void TextBox_textChanged(OxGUI sender)
 {
     #region Settings Menu
     if (sender == maxTextureSizeTextBox)
     {
         string maxSize     = maxTextureSizeTextBox.text;
         int    changedSize = ApplicationPreferences.maxSizeAllowed;
         try { changedSize = Convert.ToInt32(maxSize); } catch (Exception) {}
         if (changedSize > 0)
         {
             ApplicationPreferences.maxSizeAllowed = changedSize;
         }
         maxTextureSizeTextBox.text = ApplicationPreferences.maxSizeAllowed.ToString();
         PlayerPrefs.SetInt(ApplicationPreferences.MAX_SIZE, ApplicationPreferences.maxSizeAllowed);
     }
     if (sender == mapsLocationTextBox)
     {
         ApplicationPreferences.mapsDir = mapsLocationTextBox.text;
         PlayerPrefs.SetString(ApplicationPreferences.MAPS_LOC, ApplicationPreferences.mapsDir);
     }
     if (sender == texturesLocationTextBox)
     {
         ApplicationPreferences.texturesDir = texturesLocationTextBox.text;
         PlayerPrefs.SetString(ApplicationPreferences.TEX_LOC, ApplicationPreferences.texturesDir);
     }
     if (sender == modelsLocationTextBox)
     {
         ApplicationPreferences.modelsDir = modelsLocationTextBox.text;
         PlayerPrefs.SetString(ApplicationPreferences.MODELS_LOC, ApplicationPreferences.modelsDir);
     }
     #endregion
 }
예제 #3
0
 void button_released(OxGUI sender)
 {
     dragging = false;
     if (oldValue != value && valueChanged != null)
     {
         valueChanged(this, value - oldValue);
     }
 }
예제 #4
0
 protected void item_clicked(OxGUI sender)
 {
     selectedIndex = items.IndexOf(sender);
     if (indexChanged != null)
     {
         indexChanged(selectedIndex);
     }
 }
예제 #5
0
 void replaySeeker_valueChanged(OxGUI sender, float amount)
 {
     if (sender == replaySeeker && currentReplay != null)
     {
         currentReplay.seekIndex = (int)(replaySeeker.value * currentReplay.totalTicks);
         replaySeeker.text       = currentReplay.seekIndex.ToString();
     }
 }
예제 #6
0
 public bool RemoveItem(OxGUI item)
 {
     if (selectedIndex == items.IndexOf(item))
     {
         //selectedIndex = -1;
         Deselect();
     }
     return(items.Remove(item));
 }
예제 #7
0
    private void ExploreInterfaceMenu()
    {
        float pratio     = OxGUI.GetPratio(Screen.width, Screen.height, 7f, 5f, 0.9f, 0.7f);
        float menuWidth  = pratio * 7f;
        float menuHeight = pratio * 5f;

        exploreInterface.Reposition((Screen.width / 2f) - (menuWidth / 2f), (Screen.height / 2f) - (menuHeight / 2f));
        exploreInterface.Resize(menuWidth, menuHeight);
        exploreInterface.Draw();
    }
예제 #8
0
    private static void NavigateRight()
    {
        OxGUI nextSelection = NextElementRight();

        if (nextSelection != null)
        {
            nextSelection.Highlight();
        }
        //foreach (OxGUI element in elements) { element.highlighted = false; }
        //if (nextSelection != null) nextSelection.highlighted = true;
    }
예제 #9
0
 void Button_clicked(OxGUI sender)
 {
     if (sender == acceptButton && done != null)
     {
         done(this, true);
     }
     if (sender == cancelButton && done != null)
     {
         done(this, false);
     }
 }
예제 #10
0
    private void ModelDirBrowser()
    {
        float pratio     = OxGUI.GetPratio(Screen.width, Screen.height, 3f, 4f, 0.6f, 0.8f);
        float menuWidth  = pratio * 3f;
        float menuHeight = pratio * 4f;

        modelDirChooser.Reposition((Screen.width / 2f) - (menuWidth / 2f), (Screen.height / 2f) - (menuHeight / 2f));
        modelDirChooser.Resize(menuWidth, menuHeight);
        modelDirChooser.Draw();

        //Debug.Log(mainMenu.Position() + ", " + mainMenu.Size() + ", " + "(" + menuWidth + ", " + menuHeight + ")");
    }
예제 #11
0
    private void ReplaysMenu()
    {
        float pratio     = OxGUI.GetPratio(Screen.width, Screen.height, 7f, 5f, 0.9f, 0.7f);
        float menuWidth  = pratio * 7f;
        float menuHeight = pratio * 5f;

        replaysMenu.Reposition((Screen.width / 2f) - (menuWidth / 2f), (Screen.height / 2f) - (menuHeight / 2f));
        replaysMenu.Resize(menuWidth, menuHeight);
        replaysMenu.Draw();

        //Debug.Log(mainMenu.Position() + ", " + mainMenu.Size() + ", " + "(" + menuWidth + ", " + menuHeight + ")");
    }
예제 #12
0
    private void SettingsMenu()
    {
        //Debug.Log("Settings Menu");

        float pratio     = OxGUI.GetPratio(Screen.width, Screen.height, 3f, 4f, 0.6f, 0.8f);
        float menuWidth  = pratio * 3f;
        float menuHeight = pratio * 4f;

        settingsMenu.Reposition((Screen.width / 2f) - (menuWidth / 2f), (Screen.height / 2f) - (menuHeight / 2f));
        settingsMenu.Resize(menuWidth, menuHeight);
        settingsMenu.Draw();

        Screen.fullScreen = ApplicationPreferences.fullscreen;
        //Debug.Log(mainMenu.Position() + ", " + mainMenu.Size() + ", " + "(" + menuWidth + ", " + menuHeight + ")");
    }
예제 #13
0
    public OxGUI(Vector2 pos, Vector2 newSize, string textureLocation)
    {
        drew        = false;
        checkedDrew = false;
        checkedBy   = null;

        mouseOver = false;
        pressing  = false;

        selectable = true;
        Reposition(pos);
        Resize(newSize);
        texture = textureLocation;
        visible = true;

        resized += OxGUI_resized;
    }
예제 #14
0
    private static OxGUI NextElementRight()
    {
        OxGUI currentlySelected  = null;
        bool  nothingHighlighted = true;

        foreach (OxGUI element in elements)
        {
            if (element.highlighted)
            {
                currentlySelected = element; nothingHighlighted = false; break;
            }
            if (element.visible && element.selectable && (currentlySelected == null || element.position.x < currentlySelected.position.x))
            {
                currentlySelected = element;
            }
        }
        if (nothingHighlighted)
        {
            return(currentlySelected);
        }

        OxGUI nextPreciseSelection = null, nextSelection = null;

        foreach (OxGUI element in elements)
        {
            if (element != currentlySelected && element.visible && element.selectable && element.position.x > currentlySelected.position.x && ((element.position.y >= currentlySelected.position.y && element.position.y <= currentlySelected.position.y + currentlySelected.size.y) || (element.position.y + element.size.y >= currentlySelected.position.y && element.position.y + element.size.y <= currentlySelected.position.y + currentlySelected.size.y)) && (nextPreciseSelection == null || element.position.x - currentlySelected.position.x < nextPreciseSelection.position.x - currentlySelected.position.x))
            {
                nextPreciseSelection = element;
            }
            if (element != currentlySelected && element.visible && element.selectable && element.position.x > currentlySelected.position.x && (nextSelection == null || element.position.x - currentlySelected.position.x < nextSelection.position.x - currentlySelected.position.x))
            {
                nextSelection = element;
            }
        }
        if (nextPreciseSelection != null)
        {
            nextSelection = nextPreciseSelection;
        }
        return(nextSelection);
    }
예제 #15
0
 void button_clicked(OxGUI sender)
 {
     if (!dragging)
     {
         if (new Rect(position.x, position.y, size.x, size.y).Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y)))
         {
             oldValue = value;
             if (horizontal)
             {
                 //Debug.Log((position.x + size.x) + " - " + mousePosition.x);
                 value = 1 - (((position.x + size.x) - Input.mousePosition.x) / size.x);
                 //Debug.Log("New Value: " + value);
             }
             else
             {
                 value = 1 - (((position.y + size.y) - (Screen.height - Input.mousePosition.y)) / size.y);
             }
             if (oldValue != value && valueChanged != null)
             {
                 valueChanged(this, value - oldValue);
             }
         }
     }
 }
예제 #16
0
 void CheckBox_Switched(OxGUI sender, bool check)
 {
     #region Settings Menu
     if (sender == fullscreenCheckBox)
     {
         ApplicationPreferences.fullscreen = check;
     }
     if (sender == combineMeshesCheckBox)
     {
         ApplicationPreferences.combineMeshes = check;
         PlayerPrefs.SetInt(ApplicationPreferences.COMBINE_PREFS, ApplicationPreferences.combineMeshes ? 1 : 0);
     }
     if (sender == averageTexturesCheckBox)
     {
         if (check)
         {
             decreaseTexturesCheckBox.isChecked = false;
         }
         ApplicationPreferences.averageTextures      = averageTexturesCheckBox.isChecked;
         ApplicationPreferences.decreaseTextureSizes = decreaseTexturesCheckBox.isChecked;
         PlayerPrefs.SetInt(ApplicationPreferences.AVERAGE_PREFS, ApplicationPreferences.averageTextures ? 1 : 0);
         PlayerPrefs.SetInt(ApplicationPreferences.DECREASE_PREFS, ApplicationPreferences.decreaseTextureSizes ? 1 : 0);
     }
     if (sender == decreaseTexturesCheckBox)
     {
         if (check)
         {
             averageTexturesCheckBox.isChecked = false;
         }
         ApplicationPreferences.averageTextures      = averageTexturesCheckBox.isChecked;
         ApplicationPreferences.decreaseTextureSizes = decreaseTexturesCheckBox.isChecked;
         PlayerPrefs.SetInt(ApplicationPreferences.AVERAGE_PREFS, ApplicationPreferences.averageTextures ? 1 : 0);
         PlayerPrefs.SetInt(ApplicationPreferences.DECREASE_PREFS, ApplicationPreferences.decreaseTextureSizes ? 1 : 0);
     }
     #endregion
 }
예제 #17
0
    public virtual void Draw()
    {
        screenDpi      = Screen.dpi;
        DRAG_DEAD_ZONE = (screenDpi / 200f) * Mathf.Min(Screen.width, Screen.height) * (3f / 100f);

        drew        = true;
        checkedDrew = false;
        checkedBy   = null;
        //timesDrawn++;
        //if (timesDrawn > maxCount) timesDrawn = 0;
        //currentCount = timesDrawn;

        //if (this is OxFrame && windows.IndexOf((OxFrame)this) == -1) windows.Add((OxFrame)this);
        //else if (elements.IndexOf(this) == -1) elements.Add(this);
        //for (int i = windows.Count - 1; i >= 0; i--) { if (this != windows[i]) { if (windows[i].drew) { windows[i].drew = false; windows[i].checkedBy = this; } else if (windows[i].checkedBy == this || windows.IndexOf((OxFrame) windows[i].checkedBy) == -1) { windows.Remove(windows[i]); } } }
        //for (int i = elements.Count - 1; i >= 0; i--) { if (this != elements[i]) { if (elements[i].drew) { elements[i].drew = false; elements[i].checkedBy = this; } else if (elements[i].checkedBy == this || elements.IndexOf(elements[i].checkedBy) == -1) { elements.Remove(elements[i]); } } }
        //Debug.Log(windows.Count + " window(s) and " + elements.Count + " element(s).");

        MouseControls();
        MenuNavigation();

        //this.isDrawing = false;
        //return false;
    }
예제 #18
0
    //string browseMapDir, browseTextureDir;
    void Button_clicked(OxGUI sender)
    {
        #region Main Menu
        if (sender == viewLiveButton)
        {
            currentMenu = Menu.Live;
        }
        if (sender == viewReplaysButton)
        {
            currentMenu = Menu.Replays;
        }
        if (sender == viewMapsButton)
        {
            currentMenu = Menu.Maps;
            if (BSPMap.loadedMaps.Count > 0)
            {
                BSPMap.loadedMaps[BSPMap.loadedMaps.Keys.ElementAt(currentMap)].SetVisibility(true);
            }
        }
        if (sender == settingsButton)
        {
            currentMenu = Menu.Settings;
        }
        if (sender == exitButton)
        {
            Application.Quit();
        }
        #endregion

        #region Live Menu
        if (sender == connectButton)
        {
            currentMenu   = Menu.ReplayInterface;
            currentReplay = new Demo(addressBox.text, true);
            currentReplay.ParseReplay();
            Camera.main.transform.GetComponent <CameraControl>().blockControl = false;
        }
        #endregion

        #region Replays Menu
        if (sender == importReplayButton)
        {
            Demo loadedReplay = new Demo(replayFileList.text, false);
            loadedReplay.ParseReplay();
            if (!loadedReplay.alreadyParsed)
            {
                loadedReplay.demoMap.SetVisibility(false);
            }
            RefreshReplaysList();
        }
        if (sender == watchReplayButton)
        {
            //currentReplay = Demo.loadedDemos[loadedReplayList.SelectedIndex()];
            currentReplay = Demo.loadedDemos[loadedReplayList.items[loadedReplayList.selectedIndex].text];
            currentMenu   = Menu.ReplayInterface;
            currentReplay.demoMap.SetVisibility(true);
            Camera.main.transform.GetComponent <CameraControl>().blockControl = false;
        }
        if (sender == removeReplayButton)
        {
            if (Demo.loadedDemos.Count > 0)
            {
                //Demo.loadedDemos[loadedReplayList.SelectedIndex()].SelfDestruct();
                Demo.loadedDemos[loadedReplayList.items[loadedReplayList.selectedIndex].text].SelfDestruct();
                RefreshReplaysList();
            }
        }
        #endregion

        #region Replay Interface
        if (sender == playButton)
        {
            if (currentReplay != null)
            {
                currentReplay.play = !currentReplay.play;

                if (currentReplay.play)
                {
                    playButton.text = "Pause";
                }
                else
                {
                    playButton.text = "Play";
                }
            }
        }
        #endregion

        #region Map Menu
        if (sender == loadMapButton)
        {
            //Debug.Log("Displaying: " + mapFileChooser.text);
            BSPMap loadedMap = new BSPMap(mapFileChooser.text.Substring(mapFileChooser.text.LastIndexOf("/") + 1));
            if (!loadedMap.alreadyMade)
            {
                //CoroutineRunner(loadedMap.BuildMap);
                loadedMap.BuildMap();
                if (BSPMap.loadedMaps.Count > 1)
                {
                    BSPMap.loadedMaps[BSPMap.loadedMaps.Keys.ElementAt(currentMap)].SetVisibility(false);
                }
                currentMap = BSPMap.loadedMaps.Count - 1;
            }
        }
        if (sender == nextMapButton)
        {
            if (currentMap < BSPMap.loadedMaps.Count - 1)
            {
                //GameObject prevMap = BSPMap.loadedMaps[BSPMap.loadedMaps.Keys.ElementAt(currentMap)].mapGameObject;
                BSPMap.loadedMaps[BSPMap.loadedMaps.Keys.ElementAt(currentMap)].SetVisibility(false);
                currentMap++;
                //GameObject theMap = BSPMap.loadedMaps[BSPMap.loadedMaps.Keys.ElementAt(currentMap)].mapGameObject;
                BSPMap.loadedMaps[BSPMap.loadedMaps.Keys.ElementAt(currentMap)].SetVisibility(true);
            }
        }
        if (sender == exploreMapButton)
        {
            currentMenu = Menu.ExploreInterface;
            Camera.main.transform.GetComponent <CameraControl>().blockControl = false;
        }
        if (sender == prevMapButton)
        {
            if (currentMap > 0)
            {
                //GameObject prevMap = BSPMap.loadedMaps[BSPMap.loadedMaps.Keys.ElementAt(currentMap)].mapGameObject;
                BSPMap.loadedMaps[BSPMap.loadedMaps.Keys.ElementAt(currentMap)].SetVisibility(false);
                currentMap--;
                //GameObject theMap = BSPMap.loadedMaps[BSPMap.loadedMaps.Keys.ElementAt(currentMap)].mapGameObject;
                BSPMap.loadedMaps[BSPMap.loadedMaps.Keys.ElementAt(currentMap)].SetVisibility(true);
            }
        }
        #endregion

        #region Settings Menu
        if (sender == browseMapsLocationButton)
        {
            //browseMapDir = BSPMap.mapsDir.Substring(0, BSPMap.mapsDir.Length - 1);
            mapDirChooser.FillBrowserList(ApplicationPreferences.mapsDir.Substring(0, ApplicationPreferences.mapsDir.Length - 1), false);
            currentMenu = Menu.MapDir;
        }
        if (sender == browseTexturesLocationButton)
        {
            //browseTextureDir = BSPMap.texturesDir.Substring(0, BSPMap.texturesDir.Length - 1);
            textureDirChooser.FillBrowserList(ApplicationPreferences.texturesDir.Substring(0, ApplicationPreferences.texturesDir.Length - 1), false);
            currentMenu = Menu.TextureDir;
        }
        if (sender == browseModelsLocationButton)
        {
            modelDirChooser.FillBrowserList(ApplicationPreferences.modelsDir.Substring(0, ApplicationPreferences.modelsDir.Length - 1), false);
            currentMenu = Menu.ModelDir;
        }
        #endregion

        #region General Buttons
        if (sender == backButton)
        {
            if (currentMenu == Menu.Live || currentMenu == Menu.Replays || currentMenu == Menu.Settings)
            {
                currentMenu = Menu.Main;
            }
            if (currentMenu == Menu.Maps)
            {
                if (BSPMap.loadedMaps.Count > 0)
                {
                    BSPMap.loadedMaps[BSPMap.loadedMaps.Keys.ElementAt(currentMap)].SetVisibility(false);
                }
                currentMenu = Menu.Main;
            }
            if (currentMenu == Menu.ReplayInterface)
            {
                bool live = false;
                if (currentReplay != null)
                {
                    if (currentReplay.port > -1)
                    {
                        live = true;
                    }
                    currentReplay.Stop();
                    if (currentReplay.demoMap != null)
                    {
                        currentReplay.demoMap.SetVisibility(false);
                    }
                    currentReplay = null;
                }
                if (live)
                {
                    currentMenu = Menu.Live;
                }
                else
                {
                    currentMenu = Menu.Replays;
                }
                Camera.main.transform.GetComponent <CameraControl>().blockControl = true;
                Camera.main.transform.GetComponent <CameraControl>().GoToDefault();
            }
            if (currentMenu == Menu.ExploreInterface)
            {
                currentMenu = Menu.Maps;
                Camera.main.transform.GetComponent <CameraControl>().blockControl = true;
                Camera.main.transform.GetComponent <CameraControl>().GoToDefault();
            }
        }
        #endregion
    }
예제 #19
0
 void button_pressed(OxGUI sender)
 {
     oldValue      = value;
     mousePosition = Input.mousePosition;
     dragging      = true;
 }
예제 #20
0
 protected static void SetSize(OxGUI element, float width, float height)
 {
     element.SetSize(width, height);
 }