void WriteJudgeNamesXml(XmlWriter writer, int PoolIndex)
    {
        ResultsData RData = TournamentData.FindResultsData((EDivision)CurDivIndex, (ERound)CurRoundIndex, (EPool)PoolIndex);

        int ExCount = RData.ExJudgeIds.Count;

        for (int ExIndex = 0; ExIndex < ExCount; ++ExIndex)
        {
            string JudgeName = NameDatabase.FindInDatabase(RData.ExJudgeIds[ExIndex]).DisplayName;
            writer.WriteElementString("ns2:Ex" + (ExIndex + 1), JudgeName);
        }

        int AiCount = RData.AIJudgeIds.Count;

        for (int AiIndex = 0; AiIndex < AiCount; ++AiIndex)
        {
            string JudgeName = NameDatabase.FindInDatabase(RData.AIJudgeIds[AiIndex]).DisplayName;
            writer.WriteElementString("ns2:Ai" + (AiIndex + 1), JudgeName);
        }

        int DiffCount = RData.DiffJudgeIds.Count;

        for (int DiffIndex = 0; DiffIndex < DiffCount; ++DiffIndex)
        {
            string JudgeName = NameDatabase.FindInDatabase(RData.DiffJudgeIds[DiffIndex]).DisplayName;
            writer.WriteElementString("ns2:Diff" + (DiffIndex + 1), JudgeName);
        }
    }
Exemple #2
0
        public ResultsData <List <tbl_kho_hang> > view_kho_hang()
        {
            ResultsData <List <tbl_kho_hang> > results = new ResultsData <List <tbl_kho_hang> >();

            try
            {
                var data = from khohang in db.tbl_kho_hangs select khohang;
                if (data.Count() > 0)
                {
                    results.data     = data.ToList();
                    results.err_desc = Share.Constant.func_rs_success;
                    results.err_code = ErrorCode.success;
                }
                else
                {
                    results.data     = null;
                    results.err_desc = Share.Constant.func_rs_empty;
                    results.err_code = ErrorCode.empty;
                }
            }
            catch (Exception ex)
            {
                results.data     = null;
                results.err_desc = ex.ToString();
                results.err_code = ErrorCode.fail;
            }
            return(results);
        }
    void InitJudgersNameIds()
    {
        ResultsData RData = TournamentData.FindResultsData(CurDivision, CurRound, CurPool);

        if (RData != null)
        {
            for (int JudgeIndex = 0; JudgeIndex < AIJudges.Count; ++JudgeIndex)
            {
                if (AIJudges[JudgeIndex] != null && JudgeIndex < RData.AIJudgeIds.Count)
                {
                    AIJudges[JudgeIndex].NameId = RData.AIJudgeIds[JudgeIndex];
                }
            }

            for (int JudgeIndex = 0; JudgeIndex < ExJudges.Count; ++JudgeIndex)
            {
                if (ExJudges[JudgeIndex] != null && JudgeIndex < RData.ExJudgeIds.Count)
                {
                    ExJudges[JudgeIndex].NameId = RData.ExJudgeIds[JudgeIndex];
                }
            }

            for (int JudgeIndex = 0; JudgeIndex < DiffJudges.Count; ++JudgeIndex)
            {
                if (DiffJudges[JudgeIndex] != null && JudgeIndex < RData.DiffJudgeIds.Count)
                {
                    DiffJudges[JudgeIndex].NameId = RData.DiffJudgeIds[JudgeIndex];
                }
            }
        }
    }
Exemple #4
0
    void MoveTeamToJudgeCategory(int PlayerId, int CategoryIndex)
    {
        ResultsData Data = TournamentData.FindResultsData((EDivision)DivisionCombo.GetSelectedItemIndex(), (ERound)RoundCombo.GetSelectedItemIndex(), (EPool)CurPoolButtonIndex);

        if (Data != null)
        {
            Data.AIJudgeIds.Remove(PlayerId);
            Data.ExJudgeIds.Remove(PlayerId);
            Data.DiffJudgeIds.Remove(PlayerId);

            switch ((ECategory)CategoryIndex)
            {
            case ECategory.AI:
                Data.AIJudgeIds.Add(PlayerId);
                break;

            case ECategory.Ex:
                Data.ExJudgeIds.Add(PlayerId);
                break;

            case ECategory.Diff:
                Data.DiffJudgeIds.Add(PlayerId);
                break;
            }
        }
    }
    public NetworkJudgeData GetJudgeDataFromNameId(ResultsData InJudgeData, int InId)
    {
        foreach (NetworkJudgeData njd in AIJudges)
        {
            if (njd != null && njd.NameId == InId)
            {
                return(njd);
            }
        }

        foreach (NetworkJudgeData njd in ExJudges)
        {
            if (njd != null && njd.NameId == InId)
            {
                return(njd);
            }
        }

        foreach (NetworkJudgeData njd in DiffJudges)
        {
            if (njd != null && njd.NameId == InId)
            {
                return(njd);
            }
        }

        return(null);
    }
Exemple #6
0
        public ResultsData <List <tbl_kho_hang> > AddKho(tbl_kho_hang khohang)   // trả về kết quả update
        {
            ResultsData <List <tbl_kho_hang> > results = new ResultsData <List <tbl_kho_hang> >();

            if (khohang.kh_suc_chua <= 0 || khohang.kh_id == "")
            {
                results.err_code = ErrorCode.fail;
                results.err_desc = String.Format(Share.Constant.Insert_false_msg, " kho hàng");
                results.data     = view.view_kho_hang().data;
            }
            else
            {
                try
                {
                    db.tbl_kho_hangs.InsertOnSubmit(khohang);
                    db.SubmitChanges();
                    results.err_code = ErrorCode.success;
                    results.err_desc = String.Format(Share.Constant.Insert_success_msg, " kho hàng");
                    results.data     = view.view_kho_hang().data;
                }
                catch (Exception ex)
                {
                    results.err_code  = ErrorCode.fail;
                    results.err_desc  = String.Format(Share.Constant.Insert_false_msg, " kho hàng");
                    results.err_desc += " \n Chi tiết lỗi: \n" + ex.ToString();
                    results.data      = view.view_kho_hang().data;
                }
            }
            return(results);
        }
Exemple #7
0
    // Update is called once per frame
    void Update()
    {
        if (!Input.GetMouseButton(0))
        {
            if (MovingNameId != -1)
            {
                bool    bMovedSuccess = false;
                Vector3 NewMousePos   = new Vector3(Input.mousePosition.x, Screen.height - Input.mousePosition.y, 0);
                for (int CatIndex = 0; CatIndex < 3; ++CatIndex)
                {
                    if (JudgeRects[CatIndex].Contains(NewMousePos))
                    {
                        bMovedSuccess = true;
                        MoveTeamToJudgeCategory(MovingNameId, CatIndex);
                        break;
                    }
                }

                if (!bMovedSuccess)
                {
                    ResultsData Data = TournamentData.FindResultsData((EDivision)DivisionCombo.GetSelectedItemIndex(), (ERound)RoundCombo.GetSelectedItemIndex(), (EPool)CurPoolButtonIndex);
                    if (Data != null)
                    {
                        Data.AIJudgeIds.Remove(MovingNameId);
                        Data.ExJudgeIds.Remove(MovingNameId);
                        Data.DiffJudgeIds.Remove(MovingNameId);
                    }
                }

                MovingNameId = -1;
            }
        }
    }
    public int GetCatIndexForGuid(string InGuid)
    {
        int InOrgIndex = GetJudgeIndexRaw(InGuid);

        if (bFestivalJudging)
        {
            ResultsData RData = TournamentData.FindResultsData(CurDivision, CurRound, CurFestivalPool);
            if (RData != null)
            {
                for (int JudgeIndex = 0; JudgeIndex < AIJudges.Count; ++JudgeIndex)
                {
                    NetworkJudgeData njd = AIJudges[JudgeIndex];
                    if (njd != null && njd.Guid == InGuid)
                    {
                        if (JudgeIndex < RData.AIJudgeIds.Count)
                        {
                            return(InOrgIndex);
                        }
                        else
                        {
                            return(InOrgIndex - RData.AIJudgeIds.Count);
                        }
                    }
                }
                for (int JudgeIndex = 0; JudgeIndex < ExJudges.Count; ++JudgeIndex)
                {
                    NetworkJudgeData njd = ExJudges[JudgeIndex];
                    if (njd != null && njd.Guid == InGuid)
                    {
                        if (JudgeIndex < RData.ExJudgeIds.Count)
                        {
                            return(InOrgIndex);
                        }
                        else
                        {
                            return(InOrgIndex - RData.ExJudgeIds.Count);
                        }
                    }
                }
                for (int JudgeIndex = 0; JudgeIndex < DiffJudges.Count; ++JudgeIndex)
                {
                    NetworkJudgeData njd = DiffJudges[JudgeIndex];
                    if (njd != null && njd.Guid == InGuid)
                    {
                        if (JudgeIndex < RData.DiffJudgeIds.Count)
                        {
                            return(InOrgIndex);
                        }
                        else
                        {
                            return(InOrgIndex - RData.DiffJudgeIds.Count);
                        }
                    }
                }
            }
        }

        return(InOrgIndex);
    }
 public SheetHelper(ResultsData results, bool includeHeader, bool firstRow = false, bool threaded = false, bool transpose = false)
 {
     _results       = results;
     _includeHeader = includeHeader;
     _threaded      = threaded;
     _firstRow      = firstRow;
     _transpose     = transpose;
 }
Exemple #10
0
        public ResultsData <List <Model.ChiTiet> > view_chi_tiet(string id_kho_hang)
        {
            ResultsData <List <Model.ChiTiet> > results = new ResultsData <List <Model.ChiTiet> >();

            try
            {
                var data = from chitiet in db.tbl_chi_tiet_khos
                           where chitiet.kh_id == id_kho_hang
                           join hanghoa in db.tbl_hang_hoas
                           on chitiet.hh_id equals hanghoa.hh_id
                           select new
                {
                    ct_id           = chitiet.ct_id,
                    hh_id           = hanghoa.hh_id,
                    hh_ten          = hanghoa.hh_ten,
                    hh_nha_cung_cap = hanghoa.hh_noi_san_xuat,
                    ngay_cap_nhat   = chitiet.ngay_cap_nhat,
                    ct_soluong      = chitiet.ct_so_luong
                };

                if (data.Count() > 0)
                {
                    List <ChiTiet> list = new List <ChiTiet>();

                    foreach (var item in data)
                    {
                        Model.ChiTiet row = new ChiTiet();
                        row.ct_id                     = item.ct_id;
                        row.hh_id                     = item.hh_id;
                        row.hh_ten                    = item.hh_ten;
                        row.hh_nha_cung_cap           = item.hh_nha_cung_cap;
                        row.ngay_cap_nhat             = item.ngay_cap_nhat;
                        row.ct_soluong                = (double)item.ct_soluong;
                        Share.Constant.tong_kho_chua += row.ct_soluong;
                        list.Add(row);
                    }
                    results.data     = list.ToList();
                    results.err_desc = Share.Constant.func_rs_success;
                    results.err_code = ErrorCode.success;
                }
                else
                {
                    results.data                 = null;
                    results.err_desc             = Share.Constant.func_rs_empty;
                    results.err_code             = ErrorCode.empty;
                    Share.Constant.tong_kho_chua = 0;
                }
            }
            catch (Exception ex)
            {
                results.data                 = null;
                results.err_desc             = ex.ToString();
                results.err_code             = ErrorCode.fail;
                Share.Constant.tong_kho_chua = 0;
            }

            return(results);
        }
    public bool IsInSecondaryPool(string InGuid)
    {
        if (bFestivalJudging)
        {
            ResultsData JData = TournamentData.FindResultsData(CurDivision, CurRound, CurFestivalPool);
            if (JData != null)
            {
                for (int JudgeIndex = 0; JudgeIndex < AIJudges.Count; ++JudgeIndex)
                {
                    NetworkJudgeData njd = AIJudges[JudgeIndex];
                    if (njd != null && njd.Guid == InGuid)
                    {
                        if (JudgeIndex < JData.AIJudgeIds.Count)
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                }
                for (int JudgeIndex = 0; JudgeIndex < ExJudges.Count; ++JudgeIndex)
                {
                    NetworkJudgeData njd = ExJudges[JudgeIndex];
                    if (njd != null && njd.Guid == InGuid)
                    {
                        if (JudgeIndex < JData.ExJudgeIds.Count)
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                }
                for (int JudgeIndex = 0; JudgeIndex < DiffJudges.Count; ++JudgeIndex)
                {
                    NetworkJudgeData njd = DiffJudges[JudgeIndex];
                    if (njd != null && njd.Guid == InGuid)
                    {
                        if (JudgeIndex < JData.DiffJudgeIds.Count)
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                }
            }
        }

        return(false);
    }
Exemple #12
0
    void Awake()
    {
        if (!mInstance)
        {
            mInstance = this;
        }

        DontDestroyOnLoad(this.gameObject);
        serverManager = GetComponent <ServerManager> ();
        triviaData    = GetComponent <TriviaData> ();
        tagsData      = GetComponent <TagsData> ();
        settings      = GetComponent <Settings> ();
        resultsData   = GetComponent <ResultsData> ();
    }
    void DrawJudgeLabel(ResultsData InRData, int InId)
    {
        GUIStyle JudgeStyle = new GUIStyle("label");

        JudgeStyle.fontSize = 15;
        GUIStyle LabelStyle = new GUIStyle("label");
        NameData NData      = NameDatabase.FindInDatabase(InId);

        if (NData != null)
        {
            string           Str    = NData.DisplayName;
            NetworkJudgeData NJData = GetJudgeDataFromNameId(InRData, NData.Id);
            //Debug.Log(" asdf: " + InRData.AIJudgeIds[0] + "   " + NData.Id + "  " + InId);
            if (NJData != null)
            {
                if (NJData.bJudging)
                {
                    JudgeStyle.normal.textColor = Color.yellow;
                    Str += " - JUDGING";
                }
                else if (NJData.bLocked)
                {
                    JudgeStyle.normal.textColor = Color.green;
                    Str += " - LOCKED";
                }
                else if (NJData.bIsHoldReady)
                {
                    JudgeStyle.normal.textColor = Color.green;
                    Str += " - READY";
                }
                else if (NJData.bEditing)
                {
                    JudgeStyle.normal.textColor = Color.yellow;
                    Str += " - EDITING";
                }
                else
                {
                    JudgeStyle.normal.textColor = Color.red;
                    Str += " - NOT READY";
                }
            }
            else
            {
                JudgeStyle.normal.textColor = LabelStyle.normal.textColor;
                Str += " - NOT CONNECTED";
            }
            GUILayout.Label(Str, JudgeStyle);
        }
    }
Exemple #14
0
 void Awake()
 {
     // PlayerPrefs.DeleteAll();
     mInstance = this;
     DontDestroyOnLoad(this);
     //  serverManager = GetComponent<ServerManager>();
     userData            = GetComponent <UserData>();
     trainingData        = GetComponent <TrainingData>();
     capitulosData       = GetComponent <CapitulosData>();
     trainingResults     = GetComponent <TrainingResults>();
     dateData            = GetComponent <DateData>();
     resultsData         = GetComponent <ResultsData>();
     usersData           = GetComponent <UsersData>();
     firebaseAuthManager = GetComponent <FirebaseAuthManager>();
 }
Exemple #15
0
    public int GetJudgeNameId()
    {
        if (JudgeNameId != -1 && !bIsDataDirty)
        {
            return(JudgeNameId);
        }

        if (CurPool != EPool.None)
        {
            ResultsData Data = TournamentData.FindResultsData(CurDivision, CurRound, CurPool);
            JudgeNameId = Data.GetNameId(JudgerCategory, JudgeCategoryIndex);
        }

        return(JudgeNameId);
    }
Exemple #16
0
        private void addKhoHang1_SubmitClickOK()
        {
            Control.UpdateData updata             = new Control.UpdateData();
            ResultsData <List <tbl_kho_hang> > rs = updata.AddKho(Share.Constant.khohang);

            switch (rs.err_code)     // lấy giá trị từ control. updatedata đổ về view
            {
            case QLKhoHang.Model.ErrorCode.fail:
                MessageBox.Show(rs.err_desc, Share.Constant.Error_msg_cap, MessageBoxButtons.OK);
                break;

            case QLKhoHang.Model.ErrorCode.success:
                MessageBox.Show(rs.err_desc, Share.Constant.Info_msg_cap, MessageBoxButtons.OK);
                dgv_all_kho.DataSource = rs.data;
                break;

            default:
                break;
            }
        }
    public bool SetAIResults(AIData InData)
    {
        if (InData.JudgeNameId == -1)
        {
            return(false);
        }

        ResultsData rd          = TournamentData.FindResultsData(InData.Division, InData.Round, InData.Pool);
        int         ResultIndex = -1;

        for (int i = 0; i < rd.AIJudgeIds.Count; ++i)
        {
            if (InData.JudgeNameId == rd.AIJudgeIds[i])
            {
                ResultIndex = i;
                break;
            }
        }

        bool bNewScore = false;

        if (ResultIndex >= 0)
        {
            for (int DataIndex = 0; DataIndex <= ResultIndex; ++DataIndex)
            {
                if (DataIndex >= AIResults.Count)
                {
                    AIResults.Add(new AIData());
                }
            }

            if (!AIResults[ResultIndex].IsValid())
            {
                bNewScore = true;
            }

            AIResults[ResultIndex] = InData;
        }

        return(bNewScore);
    }
    void UpdateActiveJudgingJudgersCount()
    {
        int         Count = 0;
        ResultsData RData = TournamentData.FindResultsData(CurDivision, CurRound, CurPool);

        if (RData != null)
        {
            foreach (int id in RData.AIJudgeIds)
            {
                NetworkJudgeData NJData = GetJudgeDataFromNameId(RData, id);
                if (NJData != null && (NJData.bJudging || NJData.bEditing))
                {
                    ++Count;
                }
            }
            foreach (int id in RData.ExJudgeIds)
            {
                NetworkJudgeData NJData = GetJudgeDataFromNameId(RData, id);
                if (NJData != null && (NJData.bJudging || NJData.bEditing))
                {
                    ++Count;
                }
            }
            foreach (int id in RData.DiffJudgeIds)
            {
                NetworkJudgeData NJData = GetJudgeDataFromNameId(RData, id);
                if (NJData != null && (NJData.bJudging || NJData.bEditing))
                {
                    ++Count;
                }
            }

            if (Count != ActiveJudgingJudgers)
            {
                ActiveJudgingJudgers = Count;
                ++Global.CurDataState;

                UpdateFinishRoutineAndGoToNextTeam();
            }
        }
    }
        private void solveReaction()
        {
            loadedExercise.Problem.Solve();
            resultsList = new List <ResultsData>();
            var componentList = loadedExercise.Problem.getComponents();

            componentNames = new List <string> {
                "Tijdstap (s)"
            };

            foreach (var component in componentList)
            {
                componentNames.Add(component.Name);
            }

            int length = loadedExercise.Problem.ResultConcentration[componentList[0]].Count();

            for (int i = 0; i < length; i++)
            {
                var addedRow = new ResultsData();
                var resultsConcentrationRow = new double [] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
                int counter = 0;
                foreach (var component in componentList)
                {
                    resultsConcentrationRow[counter] = loadedExercise.Problem.ResultConcentration[component][i];
                    counter++;
                }

                addedRow.Conc1 = resultsConcentrationRow[0];
                addedRow.Conc2 = resultsConcentrationRow[1];
                addedRow.Conc3 = resultsConcentrationRow[2];
                addedRow.Conc4 = resultsConcentrationRow[3];
                addedRow.Conc5 = resultsConcentrationRow[4];
                addedRow.Conc6 = resultsConcentrationRow[5];
                addedRow.Conc7 = resultsConcentrationRow[6];

                resultsList.Add(addedRow);
            }
        }
Exemple #20
0
    internal void SerializeNewUserData(string name, float[] clearTimes)
    {
        ResultsData dataObject = LoadData(_dataFileName) ?? new ResultsData();

        if (dataObject.Users == null)
        {
            dataObject.Users = new List <User>();
        }

        User userSearch = null;

        // possibly redundant
        if (dataObject.Users != null)
        {
            // User is a class (reference type). This will directly modify the user data.
            userSearch = dataObject.Users.FirstOrDefault(x => x.Name == name);
        }

        // User already exists
        if (userSearch != null)
        {
            Debug.Log("User search was not null.");
            userSearch.SecondTestTimes = new TestTimes(clearTimes);
        }
        else
        {
            Debug.Log("User search was null");
            dataObject.Users.Add(new User(name, clearTimes));
            Debug.Log("Added new user with name " + name);
        }

        string filePath = Path.Combine(Application.persistentDataPath, _dataFileName);

        string jsonData = JsonUtility.ToJson(dataObject, true);

        File.WriteAllText(filePath, jsonData);
        print("Saved new data in " + _dataFileName);
    }
Exemple #21
0
        public ResultsData <List <tbl_kho_hang> > Update(tbl_kho_hang khohang)   // trả về kết quả update
        {
            ResultsData <List <tbl_kho_hang> > results = new ResultsData <List <tbl_kho_hang> >();
            var data = from kho in db.tbl_kho_hangs where kho.kh_id == khohang.kh_id select kho;

            if (khohang.kh_suc_chua <= 0)
            {
                results.err_code = ErrorCode.fail;
                results.err_desc = String.Format(Share.Constant.Update_false_msg, " kho hàng");
                //  results.data = view.view_kho_hang().data;
            }
            else
            {
                try
                {
                    foreach (tbl_kho_hang ord in data)
                    {
                        ord.kh_dia_chi  = khohang.kh_dia_chi;
                        ord.kh_quan_ly  = khohang.kh_quan_ly;
                        ord.kh_suc_chua = khohang.kh_suc_chua;
                    }
                    db.SubmitChanges();
                    results.err_code = ErrorCode.success;
                    results.err_desc = String.Format(Share.Constant.Update_success_msg, " kho hàng");
                    results.data     = view.view_kho_hang().data;
                }
                catch (Exception ex)
                {
                    results.err_code  = ErrorCode.fail;
                    results.err_desc  = String.Format(Share.Constant.Update_false_msg, " kho hàng");
                    results.err_desc += " \n Chi tiết lỗi: \n" + ex.ToString();
                    results.data      = view.view_kho_hang().data;
                }
            }
            return(results);
        }
    void OnGUI()
    {
        float SelectButWidth  = Screen.width * .25f;
        float SelectButHeight = Screen.height * .08f;
        float SelectY         = Screen.height * .04f;

        DivisionCombo.Draw(new Rect(20, SelectY, SelectButWidth, SelectButHeight));
        RoundCombo.Draw(new Rect(20 + SelectButWidth + Screen.width * .02f, SelectY, SelectButWidth, SelectButHeight));

        ResultsData RData = TournamentData.FindResultsData(CurDivision, CurRound, CurPool);

        float    InfoY     = Screen.height * .02f + SelectY + SelectButHeight;
        GUIStyle InfoStyle = new GUIStyle("label");

        InfoStyle.fontSize = 30;
        GUIContent TimeDate     = new GUIContent(DateTime.Now.ToString());
        Vector2    TimeDateSize = InfoStyle.CalcSize(TimeDate);

        GUI.Label(new Rect(20, InfoY, TimeDateSize.x, TimeDateSize.y), TimeDate, InfoStyle);

        bool bValidDivisionRoundSettings = Global.AllData.AllDivisions.Length > (int)CurDivision &&
                                           Global.AllData.AllDivisions[(int)CurDivision].Rounds.Length > (int)CurRound;

        if (bValidDivisionRoundSettings)
        {
            RoundData  Round        = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound];
            int        TotalSeconds = bJudging ? (int)(DateTime.Now - RoutineStartTime).TotalSeconds : 0;
            int        Minutes      = Mathf.FloorToInt(TotalSeconds / 60f);
            int        Seconds      = Mathf.FloorToInt(TotalSeconds) % 60;
            int        RoundMinutes = Mathf.FloorToInt(Round.RoutineLengthMinutes);
            int        RoundSeconds = Mathf.FloorToInt(Round.RoutineLengthMinutes * 60) % 60;
            GUIContent RoutineTime  = new GUIContent(String.Format("{0}:{1:00} / {2}:{3:00}", Minutes, Seconds, RoundMinutes, RoundSeconds));
            Vector2    TimeSize     = InfoStyle.CalcSize(RoutineTime);
            GUI.Label(new Rect(Screen.width - 20 - TimeSize.x, InfoY, TimeSize.x, TimeSize.y), RoutineTime, InfoStyle);

            if (TotalSeconds > Round.RoutineLengthMinutes * 60 && !bRoutineTimeElapsed)
            {
                bRoutineTimeElapsed = true;

                // Send ready to livestream
                TeamData finishedTeam = Global.GetTeamData(CurDivision, CurRound, CurPool, CurTeam);
                SendRestMessageAsync(finishedTeam, LiveStream.TeamStates.Finished);
            }
        }

        if (bFestivalJudging)
        {
            float     PoolButWidth  = Screen.width * .09f;
            RoundData Round         = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound];
            GUIStyle  SelectedStyle = new GUIStyle("button");
            SelectedStyle.normal.textColor = Color.green;
            SelectedStyle.hover.textColor  = Color.green;
            SelectedStyle.fontStyle        = FontStyle.Bold;
            GUIStyle ButtonStyle = new GUIStyle("button");
            if (GUI.Button(new Rect(20 + 2f * SelectButWidth + Screen.width * .1f, SelectY, PoolButWidth, SelectButHeight),
                           "Pool: " + Round.Pools[(int)CurFestivalPool].PoolName, CurPool == CurFestivalPool ? SelectedStyle : ButtonStyle))
            {
                SetCurrentPool(CurFestivalPool);
                InitJudgersNameIds();
                ++Global.CurDataState;
            }

            if (GUI.Button(new Rect(20 + 2f * SelectButWidth + Screen.width * .12f + PoolButWidth, SelectY, PoolButWidth, SelectButHeight),
                           "Pool: " + Round.Pools[(int)CurFestivalPool + 2].PoolName, CurPool == CurFestivalPool + 2 ? SelectedStyle : ButtonStyle))
            {
                SetCurrentPool(CurFestivalPool + 2);
                InitJudgersNameIds();
                ++Global.CurDataState;
            }

            if (GUI.Button(new Rect(20 + 2f * SelectButWidth + Screen.width * .14f + 2f * PoolButWidth, SelectY, PoolButWidth, SelectButHeight),
                           "AI Scores", (CurPool > EPool.Max) ? SelectedStyle : ButtonStyle))
            {
                EPool newPool = EPool.None;
                if (CurPool == EPool.A || CurPool == EPool.C)
                {
                    newPool = EPool.PostScoresAC;
                }
                else if (CurPool == EPool.B || CurPool == EPool.D)
                {
                    newPool = EPool.PostScoresBD;
                }
                else
                {
                    switch (CurPool)
                    {
                    case EPool.PostScoresAC:
                        newPool = EPool.PostScoresCA;
                        break;

                    case EPool.PostScoresCA:
                        newPool = EPool.PostScoresAC;
                        break;

                    case EPool.PostScoresBD:
                        newPool = EPool.PostScoresDB;
                        break;

                    case EPool.PostScoresDB:
                        newPool = EPool.PostScoresBD;
                        break;
                    }
                }

                SetCurrentPool(newPool);
                InitJudgersNameIds();
                ++Global.CurDataState;
            }
        }

        #region Teams
        if (!DivisionCombo.IsPicking && !RoundCombo.IsPicking && bValidDivisionRoundSettings)
        {
            Rect LeftRect = new Rect(20, Screen.height * .22f, Screen.width / 2 - 40, Screen.height * .5f);
            if (CurPool == EPool.None && !bFestivalJudging)
            {
                GUILayout.BeginArea(LeftRect);
                PoolsScrollPos = GUILayout.BeginScrollView(PoolsScrollPos);
                GUILayout.BeginVertical();

                RoundData Round = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound];
                if (Round.Pools.Count <= 2)
                {
                    for (int PoolIndex = 0; PoolIndex < Round.Pools.Count; ++PoolIndex)
                    {
                        PoolData Pool     = Round.Pools[PoolIndex];
                        string   PoolText = "";
                        PoolText += Pool.PoolName + "\n";
                        for (int TeamIndex = 0; TeamIndex < Pool.Teams.Count; ++TeamIndex)
                        {
                            TeamData Team = Pool.Teams[TeamIndex].Data;
                            PoolText += (TeamIndex + 1) + ". " + Team.PlayerNames + "\n";
                        }

                        GUIStyle ButtonStyle = new GUIStyle("button");
                        GUIStyle PoolStyle   = new GUIStyle("button");
                        PoolStyle.alignment        = TextAnchor.UpperLeft;
                        PoolStyle.normal.textColor = (EPool)PoolIndex == CurPool ? Color.green : ButtonStyle.normal.textColor;
                        PoolStyle.hover.textColor  = (EPool)PoolIndex == CurPool ? Color.green : ButtonStyle.hover.textColor;
                        PoolStyle.fontStyle        = (EPool)PoolIndex == CurPool ? FontStyle.Bold : ButtonStyle.fontStyle;
                        Vector2 PoolTextSize = PoolStyle.CalcSize(new GUIContent(PoolText));
                        if (GUILayout.Button(PoolText, PoolStyle, GUILayout.Width(LeftRect.width * .9f), GUILayout.Height(PoolTextSize.y)))
                        {
                            SetCurrentPool((EPool)PoolIndex);
                            InitJudgersNameIds();
                            ++Global.CurDataState;
                            bFestivalJudging = false;
                        }
                    }
                }
                else if (Round.Pools.Count == 4)
                {
                    for (int ButIndex = 0; ButIndex < 2; ++ButIndex)
                    {
                        string PoolText = "";

                        for (int PoolIndex = 0; PoolIndex < 2; ++PoolIndex)
                        {
                            PoolData Pool = Round.Pools[2 * PoolIndex + ButIndex];
                            PoolText += Pool.PoolName + "\n";
                            for (int TeamIndex = 0; TeamIndex < Pool.Teams.Count; ++TeamIndex)
                            {
                                TeamData Team = Pool.Teams[TeamIndex].Data;
                                PoolText += (TeamIndex + 1) + ". " + Team.PlayerNames + "\n";
                            }

                            PoolText += "\n";
                        }

                        GUIStyle ButtonStyle = new GUIStyle("button");
                        GUIStyle PoolStyle   = new GUIStyle("button");
                        PoolStyle.alignment        = TextAnchor.UpperLeft;
                        PoolStyle.normal.textColor = ButIndex == (int)CurPool ? Color.green : ButtonStyle.normal.textColor;
                        PoolStyle.hover.textColor  = ButIndex == (int)CurPool ? Color.green : ButtonStyle.hover.textColor;
                        PoolStyle.fontStyle        = ButIndex == (int)CurPool ? FontStyle.Bold : ButtonStyle.fontStyle;
                        Vector2 PoolTextSize = PoolStyle.CalcSize(new GUIContent(PoolText));
                        if (GUILayout.Button(PoolText, PoolStyle, GUILayout.Width(LeftRect.width * .9f), GUILayout.Height(PoolTextSize.y)))
                        {
                            CurFestivalPool  = (EPool)ButIndex;
                            bFestivalJudging = true;
                        }
                    }
                }

                GUILayout.EndVertical();
                GUILayout.EndScrollView();
                GUILayout.EndArea();
            }
            else if (!bFestivalJudging || CurPool != EPool.None)
            {
                float LeftRectWidth = Screen.width * .45f;
                //new Rect(Screen.width - RightRectWidth - 20, AreaRect.y, RightRectWidth, Screen.height - AreaRect.y - 20);
                GUILayout.BeginArea(LeftRect);
                GUILayout.BeginVertical();

                GUIStyle TeamStyle = new GUIStyle("button");
                TeamStyle.fontSize  = 17;
                TeamStyle.alignment = TextAnchor.MiddleLeft;
                GUIStyle        BackStyle = new GUIStyle(TeamStyle);
                List <PoolData> Pools     = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools;
                if (CurPool >= 0 && (int)CurPool < Pools.Count)
                {
                    for (int TeamIndex = 0; TeamIndex < Pools[(int)CurPool].Teams.Count; ++TeamIndex)
                    {
                        TeamData Data = Pools[(int)CurPool].Teams[TeamIndex].Data;
                        if (Data != null)
                        {
                            GUIContent TeamContent = new GUIContent((TeamIndex + 1) + ". " + Data.PlayerNames);
                            Vector2    TeamSize    = TeamStyle.CalcSize(TeamContent);
                            TeamStyle.fontStyle = TeamIndex == CurTeam ? FontStyle.Bold : FontStyle.Normal;

                            if (!bLockedForJudging)
                            {
                                TeamStyle.normal.textColor = TeamIndex == CurTeam ? Color.green : new GUIStyle("button").normal.textColor;
                                TeamStyle.hover.textColor  = TeamIndex == CurTeam ? Color.green : new GUIStyle("button").hover.textColor;
                            }
                            else
                            {
                                TeamStyle.normal.textColor = TeamIndex == CurTeam ? Color.green : Color.gray;
                                TeamStyle.hover.textColor  = TeamIndex == CurTeam ? Color.green : Color.gray;
                                TeamStyle.active.textColor = TeamIndex == CurTeam ? Color.green : Color.gray;
                            }

                            if (GUILayout.Button(TeamContent, TeamStyle, GUILayout.Width(LeftRectWidth), GUILayout.Height(TeamSize.y)))
                            {
                                if (!bLockedForJudging)
                                {
                                    CurTeam = TeamIndex;
                                    ++Global.CurDataState;
                                }
                            }
                        }
                    }
                }

                GUILayout.Space(Screen.height * .03f);

                GUIContent BackContent = new GUIContent("<- Back To Pool Selection");
                Vector2    BackSize    = BackStyle.CalcSize(BackContent);
                if (GUILayout.Button(BackContent, BackStyle, GUILayout.Width(LeftRectWidth), GUILayout.Height(BackSize.y)))
                {
                    SetCurrentPool(EPool.None);
                    CurTeam          = -1;
                    bFestivalJudging = false;
                }

                GUILayout.EndVertical();
                GUILayout.EndArea();

                // Ready Buttons
                if (CurTeam >= 0)
                {
                    DrawControlButtons();
                }
            }
        }
        else
        {
            SetCurrentPool(EPool.None);
            bFestivalJudging = false;
        }
        #endregion

        #region Judges
        if (CurPool != EPool.None && RData != null)
        {
            Rect RightRect = new Rect(Screen.width * .5f + 20, Screen.height * .22f, Screen.width / 2 - 40, Screen.height * .88f - 20);
            GUILayout.BeginArea(RightRect);
            GUILayout.BeginVertical();

            GUIStyle CatHeaderStyle = new GUIStyle("label");
            CatHeaderStyle.fontSize  = 17;
            CatHeaderStyle.fontStyle = FontStyle.Bold;


            GUILayout.Label("AI Judges:", CatHeaderStyle);
            foreach (int id in RData.AIJudgeIds)
            {
                DrawJudgeLabel(RData, id);
            }
            GUILayout.Label("Ex Judges:", CatHeaderStyle);
            foreach (int id in RData.ExJudgeIds)
            {
                DrawJudgeLabel(RData, id);
            }
            GUILayout.Label("Diff Judges:", CatHeaderStyle);
            foreach (int id in RData.DiffJudgeIds)
            {
                DrawJudgeLabel(RData, id);
            }

            GUILayout.EndVertical();
            GUILayout.EndArea();
        }
        #endregion
    }
            public void fetchData()
            {
                int    currentRow         = 0;
                string nextCursorId       = null;
                bool?  confirmedOverwrite = null;

                try
                {
                    do
                    {
                        // Fetch rows
                        var task = new Web().GetDatatableData(_quandlCode, _datatableParams.QueryParams);
                        task.Wait();
                        var results = task.Result;

                        // Inform the user whats going on.
                        currentRow += results.Data.DataPoints.Count();
                        Common.StatusBar.AddMessage(Locale.English.UdfRetrievingDataMoreDetails.Replace("{currentRow}", currentRow.ToString()));

                        // Process fetched rows
                        var processedData = new ResultsData(results.Data.DataPoints, results.Columns.Select(c => c.Code).ToList());

                        // Write fetch rows out to the sheet. If this is the first iteration save the value to display in the formula cell.
                        SheetHelper excelWriter = new SheetHelper(processedData, false, false, true);
                        if (nextCursorId == null)
                        {
                            excelWriter = new SheetHelper(processedData, true, true, true);
                        }

                        // Bail out if the worksheet no longer exists.
                        if (!WorksheetStillExists())
                        {
                            return;
                        }

                        // If the user already accepted to overwrite data then set that.
                        excelWriter.ConfirmedOverwrite = confirmedOverwrite;

                        // Write data and save state of whether to continue overwriting.
                        excelWriter.PopulateData(_currentCellRange);

                        // Bail out if the user said no to overwriting data;
                        confirmedOverwrite = excelWriter.ConfirmedOverwrite;
                        if (excelWriter.ConfirmedOverwrite == false)
                        {
                            Common.StatusBar.AddMessage(Locale.English.WarningOverwriteNotAccepted);
                            return;
                        }

                        // Update the query params for next run if their is a cursor given and then increment the range where new data should go.
                        if (!string.IsNullOrWhiteSpace(results.Data.Cursor))
                        {
                            var headerOffset = 0;
                            if (nextCursorId == null)
                            {
                                headerOffset = 1;
                            }

                            nextCursorId = results.Data.Cursor;
                            _datatableParams.AddInternalParam("qopts.cursor_id", results.Data.Cursor);

                            _currentCellRange = _currentCellRange.Worksheet.Cells[_currentCellRange.Row + headerOffset + results.Data.DataPoints.Count, _currentCellRange.Column];
                        }
                        else
                        {
                            nextCursorId = null;
                        }
                    } while (!string.IsNullOrWhiteSpace(nextCursorId));

                    Common.StatusBar.AddMessage(Locale.English.UdfDataRetrievalSuccess);
                    Common.StatusBar.AddMessage(Locale.English.UdfDataWritingSuccess);
                }
                catch (COMException e)
                {
                    // Most likely the worksheet no longer exists so bail out. These two codes seem to occur during those scenarios.
                    if (e.HResult == Shared.Excel.Exception.BAD_REFERENCE || e.HResult == Shared.Excel.Exception.VBA_E_IGNORE)
                    {
                        return;
                    }

                    Common.HandlePotentialQuandlError(e, false, AdditionalInfo(_datatableParams));
                    Common.StatusBar.AddMessage(Locale.English.UdfCompleteError);
                }
                catch (ThreadAbortException)
                {
                    return; // Safe to ignore aborting threads. Assume user forcibly stopped the UDF.
                }
                catch (System.Exception e)
                {
                    Common.HandlePotentialQuandlError(e, false, AdditionalInfo(_datatableParams));
                    Common.StatusBar.AddMessage(Locale.English.UdfCompleteError);
                }
            }
Exemple #24
0
    private void LoadDataSync()
    {
        LoadFileText lft = new LoadFileText();

        // Load attacks data
        lft.fileName = defAttacksFileName;
        LoadFileSync(lft);

        AttacksData attacksData = JsonUtility.FromJson <AttacksData>(lft.fileText);

        foreach (Attack atk in attacksData.attacks)
        {
            Data.AllAttacks.Add(atk.id, atk);
        }

        // Load defends data
        lft.fileName = defDefendsFileName;
        LoadFileSync(lft);

        DefendsData defendsData = JsonUtility.FromJson <DefendsData>(lft.fileText);

        foreach (ActionType type in System.Enum.GetValues(typeof(ActionType)))
        {
            Data.AllDefendsByType.Add(type, new List <int>());
        }
        foreach (Defend def in defendsData.defends)
        {
            Data.AllDefends.Add(def.id, def);
            Data.AllDefendsByType[def.type].Add(def.id);
        }

        // Load results data
        lft.fileName = defResultsFileName;
        LoadFileSync(lft);

        ResultsData resultsData = JsonUtility.FromJson <ResultsData>(lft.fileText);

        foreach (Result res in resultsData.results)
        {
            Data.AllResults.Add(res.id, res);
        }

        // Load equipments data
        lft.fileName = defEquipmentsFileName;
        LoadFileSync(lft);

        EquipmentsData equipmentsData = JsonUtility.FromJson <EquipmentsData>(lft.fileText);

        foreach (Weapon weapon in equipmentsData.weapons)
        {
            Sprite sprite = Resources.Load <Sprite>("Sprites/Weapons/" + weapon.id);
            weapon.sprite = sprite;

            Data.AllWeapons.Add(weapon.id, weapon);
            Data.AllInventories.Add(weapon.id, weapon as Inventory);
        }
        foreach (Armor armor in equipmentsData.armors)
        {
            Sprite sprite = Resources.Load <Sprite>("Sprites/Clothes/" + armor.id);
            armor.sprite = sprite;

            Data.AllArmors.Add(armor.id, armor);
            Data.AllInventories.Add(armor.id, armor as Inventory);
        }
        foreach (Accessory accessory in equipmentsData.accessories)
        {
            Sprite sprite = Resources.Load <Sprite>("Sprites/Hats/" + accessory.id);
            accessory.sprite = sprite;

            Data.AllAccessories.Add(accessory.id, accessory);
            Data.AllInventories.Add(accessory.id, accessory as Inventory);
        }

        // Load materials data
        lft.fileName = defFoodsFileName;
        LoadFileSync(lft);

        FoodsData foodsData = JsonUtility.FromJson <FoodsData>(lft.fileText);

        foreach (Food food in foodsData.foods)
        {
            Data.AllFoods.Add(food.id, food);
            Data.AllInventories.Add(food.id, food as Inventory);
        }

        // Load foods data
        lft.fileName = defMaterialsFileName;
        LoadFileSync(lft);

        MaterialsData materialsData = JsonUtility.FromJson <MaterialsData>(lft.fileText);

        foreach (Material material in materialsData.materials)
        {
            Data.AllMaterials.Add(material.id, material);
            Data.AllInventories.Add(material.id, material as Inventory);
        }

        // Test: Check loading is right
        Debug.Log("Total Attacks Loaded : " + Data.AllAttacks.Count);
        Debug.Log("Total Defends Loaded : " + Data.AllDefends.Count);
        Debug.Log("Total Results Loaded : " + Data.AllResults.Count);
        Debug.Log("Total Inventories Loaded : " + Data.AllInventories.Count);
        Debug.Log("Total Weapons Loaded : " + Data.AllWeapons.Count);
        Debug.Log("Total Armors Loaded : " + Data.AllArmors.Count);
        Debug.Log("Total Accessories Loaded : " + Data.AllAccessories.Count);
        Debug.Log("Total Materials Loaded : " + Data.AllMaterials.Count);
        Debug.Log("Total Foods loaded : " + Data.AllFoods.Count);
    }
Exemple #25
0
    void OnGUI()
    {
        bool bRepaintUpdate = Event.current.ToString() == "Repaint";

        if (GUI.Button(new Rect(Screen.width - 150, Screen.height - 150, 150, 150), "Save"))
        {
            Global.AllData.Save();
        }

        float StartSelectY = 30;
        float SelectHeight = 30;

        DivisionCombo.Draw(new Rect(20, StartSelectY, Screen.width * .18f, SelectHeight));
        RoundCombo.Draw(new Rect(20 + Screen.width * .2f, StartSelectY, Screen.width * .18f, SelectHeight));

        GUILayout.BeginArea(new Rect(20 + Screen.width * .4f, StartSelectY, Screen.width - Screen.width * .4f - 40, SelectHeight));
        GUILayout.BeginHorizontal();

        List <PoolData> Pools = Global.AllData.AllDivisions[DivisionCombo.GetSelectedItemIndex()].Rounds[RoundCombo.GetSelectedItemIndex()].Pools;

        for (int PoolIndex = 0; PoolIndex < Pools.Count; ++PoolIndex)
        {
            DrawPoolButton("Pool: " + Pools[PoolIndex].PoolName, PoolIndex, SelectHeight);
        }

        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        float RightRectStartY = Screen.height * .02f + SelectHeight + StartSelectY;
        Rect  RightRect       = new Rect(20, RightRectStartY, Screen.width * .3f, Screen.height - RightRectStartY - 20);
        Rect  LeftRect        = new Rect(RightRect.x + RightRect.width + Screen.width * .1f, RightRect.y, RightRect.width, Screen.height * .5f);

        if (CurPoolButtonIndex != -1)
        {
            ResultsData RData = TournamentData.FindResultsData((EDivision)DivisionCombo.GetSelectedItemIndex(), (ERound)RoundCombo.GetSelectedItemIndex(), (EPool)CurPoolButtonIndex);
            if (RData == null)
            {
                RData = new ResultsData((EDivision)DivisionCombo.GetSelectedItemIndex(), (ERound)RoundCombo.GetSelectedItemIndex(), (EPool)CurPoolButtonIndex);
                Pools[CurPoolButtonIndex].JudgersId = RData.Id;

                Global.AllData.ResultsList.Add(RData);
            }
            else if (Pools[CurPoolButtonIndex].JudgersId == -1)
            {
                if (RData.Id == -1)
                {
                    RData.Id = ResultsData.GetUniqueId();
                }

                Pools[CurPoolButtonIndex].JudgersId = RData.Id;
            }


            if (RData != null && Global.AllNameData.AllJudges != null)
            {
                GUILayout.BeginArea(RightRect);
                RightScroll = GUILayout.BeginScrollView(RightScroll);
                GUILayout.BeginVertical();

                string NewFilterStr = GUILayout.TextField(JudgeFilterStr);

                if (NewFilterStr != JudgeFilterStr || AvailableJudges.Count == 0)
                {
                    JudgeFilterStr = NewFilterStr;

                    AvailableJudges.Clear();
                    foreach (NameData pd in Global.AllNameData.AllJudges)
                    {
                        if (!IsPlayingInPool(pd, RData) && !RData.ContainsPlayer(pd))
                        {
                            AvailableJudges.Add(pd);
                        }
                    }

                    FilterAvailableJudges(JudgeFilterStr, ref AvailableJudges);
                }

                GUILayout.Space(20);

                GUIStyle LabelStyle  = new GUIStyle("label");
                GUIStyle PlayerStyle = new GUIStyle("label");
                PlayerStyle.alignment = TextAnchor.MiddleLeft;
                foreach (NameData nd in AvailableJudges)
                {
                    bool bMoving = MovingNameId == nd.Id;
                    PlayerStyle.normal.textColor = bMoving ? Color.grey : LabelStyle.normal.textColor;

                    GUIContent PlayerCont = new GUIContent(nd.DisplayName);
                    Vector2    PlayerSize = PlayerStyle.CalcSize(PlayerCont);
                    if (GUILayout.RepeatButton(PlayerCont, PlayerStyle, GUILayout.Width(RightRect.width * .9f), GUILayout.Height(PlayerSize.y)))
                    {
                        MovingNameId = nd.Id;
                    }
                }

                GUILayout.EndVertical();
                GUILayout.EndScrollView();
                GUILayout.EndArea();


                // Left Rect ------------
                GUILayout.BeginArea(LeftRect);
                GUILayout.BeginVertical();
                GUIStyle JudgeStyle = new GUIStyle("label");
                JudgeStyle.alignment = TextAnchor.MiddleLeft;

                GUILayout.BeginVertical();
                GUILayout.Label("AI Judges:", JudgeStyle);
                for (int PlayerIndex = 0; PlayerIndex < Mathf.Max(RData.AIJudgeIds.Count, 3); ++PlayerIndex)
                {
                    int    PlayerId  = -1;
                    bool   bMoving   = false;
                    string PlayerStr = PlayerIndex < 3 ? (PlayerIndex + 1) + ". " : "";
                    if (PlayerIndex < RData.AIJudgeIds.Count)
                    {
                        PlayerId = RData.AIJudgeIds[PlayerIndex];
                        bMoving  = PlayerId == MovingNameId;

                        PlayerStr += NameDatabase.FindInDatabase(PlayerId).DisplayName;
                    }

                    JudgeStyle.normal.textColor = bMoving ? Color.grey : LabelStyle.normal.textColor;

                    GUIContent JudgeCont = new GUIContent(PlayerStr);
                    Vector2    JudgeSize = JudgeStyle.CalcSize(JudgeCont);
                    if (GUILayout.RepeatButton(JudgeCont, JudgeStyle, GUILayout.Width(LeftRect.width * .6f), GUILayout.Height(JudgeSize.y)) && PlayerIndex < RData.AIJudgeIds.Count)
                    {
                        MovingNameId = PlayerId;
                    }
                }
                GUILayout.EndVertical();
                if (bRepaintUpdate)
                {
                    JudgeRects[0]   = GUILayoutUtility.GetLastRect();
                    JudgeRects[0].x = LeftRect.x;
                    JudgeRects[0].y = LeftRect.y;
                }

                GUILayout.BeginVertical();
                GUILayout.Label("Ex Judges:", JudgeStyle);
                for (int PlayerIndex = 0; PlayerIndex < Mathf.Max(RData.ExJudgeIds.Count, 3); ++PlayerIndex)
                {
                    int    PlayerId  = -1;
                    bool   bMoving   = false;
                    string PlayerStr = PlayerIndex < 3 ? (PlayerIndex + 1) + ". " : "";
                    if (PlayerIndex < RData.ExJudgeIds.Count)
                    {
                        PlayerId = RData.ExJudgeIds[PlayerIndex];
                        bMoving  = PlayerId == MovingNameId;

                        PlayerStr += NameDatabase.FindInDatabase(PlayerId).DisplayName;
                    }

                    JudgeStyle.normal.textColor = bMoving ? Color.grey : LabelStyle.normal.textColor;

                    GUIContent JudgeCont = new GUIContent(PlayerStr);
                    Vector2    JudgeSize = JudgeStyle.CalcSize(JudgeCont);
                    if (GUILayout.RepeatButton(JudgeCont, JudgeStyle, GUILayout.Width(LeftRect.width * .6f), GUILayout.Height(JudgeSize.y)) && PlayerIndex < RData.ExJudgeIds.Count)
                    {
                        MovingNameId = PlayerId;
                    }
                }
                GUILayout.EndVertical();
                if (bRepaintUpdate)
                {
                    JudgeRects[1]    = GUILayoutUtility.GetLastRect();
                    JudgeRects[1].x += LeftRect.x;
                    JudgeRects[1].y += LeftRect.y;
                }

                GUILayout.BeginVertical();
                GUILayout.Label("Diff Judges:", JudgeStyle);
                for (int PlayerIndex = 0; PlayerIndex < Mathf.Max(RData.DiffJudgeIds.Count, 3); ++PlayerIndex)
                {
                    int    PlayerId  = -1;
                    bool   bMoving   = false;
                    string PlayerStr = PlayerIndex < 3 ? (PlayerIndex + 1) + ". " : "";
                    if (PlayerIndex < RData.DiffJudgeIds.Count)
                    {
                        PlayerId = RData.DiffJudgeIds[PlayerIndex];
                        bMoving  = PlayerId == MovingNameId;

                        PlayerStr += NameDatabase.FindInDatabase(PlayerId).DisplayName;
                    }

                    JudgeStyle.normal.textColor = bMoving ? Color.grey : LabelStyle.normal.textColor;

                    GUIContent JudgeCont = new GUIContent(PlayerStr);
                    Vector2    JudgeSize = JudgeStyle.CalcSize(JudgeCont);
                    if (GUILayout.RepeatButton(JudgeCont, JudgeStyle, GUILayout.Width(LeftRect.width * .6f), GUILayout.Height(JudgeSize.y)) && PlayerIndex < RData.DiffJudgeIds.Count)
                    {
                        MovingNameId = PlayerId;
                    }
                }
                GUILayout.EndVertical();
                if (bRepaintUpdate)
                {
                    JudgeRects[2]    = GUILayoutUtility.GetLastRect();
                    JudgeRects[2].x += LeftRect.x;
                    JudgeRects[2].y += LeftRect.y;
                }

                GUILayout.EndVertical();
                GUILayout.EndArea();

                if (MovingNameId != -1)
                {
                    GUI.Label(new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y, 500, 30), NameDatabase.FindInDatabase(MovingNameId).DisplayName);
                }
            }
        }

        float BottomRectX = RightRect.x + RightRect.width + 20;
        float BottomRectY = LeftRect.y + LeftRect.height;

        GUILayout.BeginArea(new Rect(BottomRectX, BottomRectY, Screen.width - BottomRectX - 170, Screen.height - BottomRectY - 20));
        GUILayout.Label("All Judges Names");
        AllJudgesTextScrollPos = GUILayout.BeginScrollView(AllJudgesTextScrollPos);
        string NewAllJudgesString = GUILayout.TextArea(AllJudgesString);

        if (NewAllJudgesString != AllJudgesString)
        {
            AllJudgesString = NewAllJudgesString;
            AvailableJudges.Clear();
            Global.AllNameData.AllJudges.Clear();

            StringReader reader = new StringReader(AllJudgesString);
            string       line   = null;
            while ((line = reader.ReadLine()) != null)
            {
                AddJudgersFromString(line);
            }

            Global.AllNameData.Save();
        }
        GUILayout.EndScrollView();
        GUILayout.EndArea();
    }
Exemple #26
0
    public bool IsPlayingInPool(NameData InPlayer, ResultsData InResultsData)
    {
        List <PoolData> Pools = Global.AllData.AllDivisions[DivisionCombo.GetSelectedItemIndex()].Rounds[RoundCombo.GetSelectedItemIndex()].Pools;

        return(Pools[(int)InResultsData.Pool].ContainsPlayer(InPlayer));
    }
    private void UpdateFinishRoutineAndGoToNextTeam()
    {
        if (bJudging && ActiveJudgingJudgers == 0)
        {
            ResultsData RData = TournamentData.FindResultsData(CurDivision, CurRound, CurPool);
            if (RData != null)
            {
                int JudgesCount = 0;
                foreach (int id in RData.AIJudgeIds)
                {
                    ++JudgesCount;
                }
                foreach (int id in RData.ExJudgeIds)
                {
                    ++JudgesCount;
                }
                foreach (int id in RData.DiffJudgeIds)
                {
                    ++JudgesCount;
                }

                TeamData TData = Global.GetTeamData(CurDivision, CurRound, CurPool, CurTeam);
                if (TData.RoutineScores.GetTotalValidScores() >= JudgesCount)
                {
                    // If we got all results
                    StopRoutine();

                    if (Global.IsValid(CurDivision, CurRound, CurPool, CurTeam))
                    {
                        int curPoolTeamCount = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools[(int)CurPool].Teams.Count;

                        if (bFestivalJudging)
                        {
                            int cachedTeamIndex = CurTeam;
                            int newPool         = (int)CurPool + 2;

                            if (newPool >= 4)
                            {
                                newPool = newPool % 4;
                                if (newPool < Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools.Count)
                                {
                                    int newPoolTeamCount = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools[newPool].Teams.Count;

                                    if (cachedTeamIndex < newPoolTeamCount - 1)
                                    {
                                        CurPool = (EPool)newPool;
                                        InitJudgersNameIds();
                                        CurTeam = cachedTeamIndex + 1;
                                        ++Global.CurDataState;
                                    }
                                    else if (cachedTeamIndex < curPoolTeamCount - 1)
                                    {
                                        CurTeam = cachedTeamIndex + 1;
                                        ++Global.CurDataState;
                                    }
                                    else
                                    {
                                        // End of pools
                                    }
                                }
                            }
                            else
                            {
                                int newPoolTeamCount = Global.AllData.AllDivisions[(int)CurDivision].Rounds[(int)CurRound].Pools[newPool].Teams.Count;

                                if (cachedTeamIndex >= newPoolTeamCount && cachedTeamIndex < curPoolTeamCount - 1)
                                {
                                    CurTeam = cachedTeamIndex + 1;
                                    ++Global.CurDataState;
                                }
                                else if (cachedTeamIndex < newPoolTeamCount)
                                {
                                    CurPool = (EPool)newPool;
                                    CurTeam = cachedTeamIndex;
                                    InitJudgersNameIds();
                                    ++Global.CurDataState;
                                }
                                else
                                {
                                    // End of Pools
                                }
                            }
                        }
                        else
                        {
                            if (CurTeam < curPoolTeamCount - 1)
                            {
                                ++CurTeam;
                                ++Global.CurDataState;
                            }
                        }
                    }
                }
            }
        }
    }
Exemple #28
0
 public ResultsData()
 {
     Id = ResultsData.GetUniqueId();
 }
Exemple #29
0
        public static string QSERIES(
            [ExcelArgument(Name = "quandlCode",
                           Description = "Single or multiple Quandl codes with optional columns references", AllowReference = true)
            ] object rawQuandlCodeColumns,
            [ExcelArgument(Name = "dateRange", Description = "(optional) The date or range of dates to filter on", AllowReference = true)] object rawDates = null,
            [ExcelArgument(Name = "frequency", Description = "(optional) Change the sampling frequency of the returned data", AllowReference = true
                           )] string rawCollapse = null,
            [ExcelArgument(Name = "order", Description = "(optional) Order the data is returned in",
                           AllowReference = true)] string rawOrder = null,
            [ExcelArgument(Name = "transformation", Description = "(optional) How the data is to be transformed",
                           AllowReference = true)] string rawTransformation = null,
            [ExcelArgument(Name = "limit", Description = "(optional) Limit the number of rows returned",
                           AllowReference = true)] object rawLimit = null,
            [ExcelArgument(Name = "headers",
                           Description = "(optional) Default: true - Whether the resulting data will include a header row",
                           AllowReference = true)] string rawHeader = null,
            [ExcelArgument(Name = "dates",
                           Description = "(optional) Default: true - Whether the resulting data will include a dates column",
                           AllowReference = true)] string rawDateColumn = null,
            [ExcelArgument(Name = "transpose",
                           Description = "(optional) Default: false - Transpose the resulting data matrix, dates will be displayed in one row rather than a column",
                           AllowReference = true)] string rawTranspose = null
            )
        {
            try
            {
                // Need to reset cell volatility on each run-through
                Tools.SetCellVolatile(false);

                // Prevent the formula from running should it be turned off.
                if (QuandlConfig.PreventCurrentExecution)
                {
                    return(Locale.English.AutoDownloadTurnedOff);
                }

                // Parse out all the parameters specified in the UDF as well as the calling cell.
                var reference         = (ExcelReference)XlCall.Excel(XlCall.xlfCaller);
                var quandlCodeColumns = Tools.GetArrayOfValues(rawQuandlCodeColumns).Select(s => s.ToString().ToUpper()).ToList();
                var dates             = Tools.GetArrayOfDates(rawDates);
                var collapse          = Tools.GetStringValue(rawCollapse);
                var orderAsc          = Tools.GetStringValue(rawOrder).ToLower() == "asc";
                var transformation    = Tools.GetStringValue(rawTransformation);
                var limit             = Tools.GetIntValue(rawLimit);
                var includeHeader     = string.IsNullOrEmpty(rawHeader) || Tools.GetBoolValue(rawHeader);
                var includeDates      = string.IsNullOrEmpty(rawDateColumn) || Tools.GetBoolValue(rawDateColumn);
                var transpose         = !string.IsNullOrEmpty(rawTranspose) || Tools.GetBoolValue(rawTranspose);

                // Update status bar so the user knows which function is currently running.
                Common.StatusBar.AddMessage($"{Locale.English.UdfRetrievingData} QSERIES({{{string.Join(", ", quandlCodeColumns)}}}, {{{string.Join(", ", dates)}}}, {collapse}, {orderAsc}, {transformation}, {limit}, {includeHeader}, {includeDates}, {transpose})");

                // Pull the data from the server
                ResultsData results = null;
                try
                {
                    results = RetrieveData(quandlCodeColumns, dates, collapse, transformation, limit, includeDates);
                }
                catch (DatasetParamError e)
                {
                    return(e.Message);
                }
                Common.StatusBar.AddMessage(Locale.English.UdfDataRetrievalSuccess);

                // Assume the first column is date column
                string dateColumn = results.Headers.Select(s => s.ToUpper()).ToList()[0];

                // Sort out the data and place it in the cells
                var sortedResults  = new ResultsData(results.SortedData(dateColumn, orderAsc), results.Headers);
                var reorderColumns = sortedResults.ExpandAndReorderColumns(SanitizeColumnNames(quandlCodeColumns), dateColumn, includeDates);

                // Enqueue the data to be written out to the sheet when excel is ready to run macro's
                SheetHelper excelWriter = new SheetHelper(reorderColumns, includeHeader, true, false, transpose);
                WriteData(excelWriter, reference);

                // Return the first cell value
                return(Utilities.ValidateEmptyData(excelWriter.firstCellValue()));
            }
            catch (Exception e)
            {
                string msg = null;

                if (e.InnerException != null && e.InnerException is Shared.Errors.QuandlErrorBase)
                {
                    msg = Common.HandlePotentialQuandlError(e, false);
                }
                else
                {
                    msg = Common.HandlePotentialQuandlError(e, false, new Dictionary <string, string>()
                    {
                        { "UDF", "QSERIES" },
                        { "Columns", Utilities.ObjectToHumanString(rawQuandlCodeColumns) },
                        { "Dates", Utilities.ObjectToHumanString(rawDates) },
                        { "Collapse", Utilities.ObjectToHumanString(rawCollapse) },
                        { "Order", Utilities.ObjectToHumanString(rawOrder) },
                        { "Transformation", Utilities.ObjectToHumanString(rawTransformation) },
                        { "Limit", Utilities.ObjectToHumanString(rawLimit) },
                        { "Header", Utilities.ObjectToHumanString(rawHeader) },
                        { "DateColumn", Utilities.ObjectToHumanString(rawDateColumn) }
                    });
                }

                if (msg == null)
                {
                    msg = Locale.English.UdfCompleteError;
                }

                return(msg);
            }
        }
Exemple #30
0
        private static ResultsData RetrieveData(List <string> quandlCodeColumns,
                                                List <DateTime?> dates, string collapse, string transformation, int?limit,
                                                bool hideColumns = false)
        {
            var datasets = new Dictionary <string, DatasetParams>();
            var datasetsWithoutColumns = new List <string>();

            var uniqueQuandlCodes = GetDatasetQuandlCodes(quandlCodeColumns);

            GetDatasetMetadata(uniqueQuandlCodes);

            quandlCodeColumns = SanitizeColumnNames(quandlCodeColumns);

            foreach (var quandlCodeColumn in quandlCodeColumns)
            {
                var splitString = SplitQuandlCode(quandlCodeColumn);

                // Quandl code and column (ex: NSE/OIL/HIGH)
                if (splitString.Length >= 3)
                {
                    var quandlCode = string.Join("/", splitString[0], splitString[1]);
                    if (!datasets.ContainsKey(quandlCode))
                    {
                        datasets[quandlCode] = new DatasetParams(quandlCode, dates, collapse, transformation, limit);
                    }

                    // concatenate column name if it has a forward slash and was broken up in string split
                    string columnName = (splitString.Length > 3)
                                      ? string.Join("/", splitString.Skip(2).ToArray())
                                      : splitString[2];
                    datasets[quandlCode].Columns.Add(columnName);
                }
                // Quandl code only (ex: NSE/OIL)
                else if (splitString.Length == 2)
                {
                    var quandlCode = string.Join("/", splitString[0], splitString[1]);
                    if (!datasets.ContainsKey(quandlCode))
                    {
                        datasets[quandlCode] = new DatasetParams(quandlCode, dates, collapse, transformation, limit);
                    }
                    datasetsWithoutColumns.Add(quandlCode);
                }
                // Invalid format
                else
                {
                    throw new DatasetParamError($"Invalid Quandl code: {quandlCodeColumn}");
                }
            }

            // If any datasets without columns have been specified remove any customized columns that users specified to ensure all columns are pulled.
            datasetsWithoutColumns.ForEach(qc => datasets[qc].Columns.Clear());

            // Fetch data based on batch settings or in once based on user roles
            Dataset[] fetchTaskCollection = new Dataset[] { };
            var       tasks = datasets.Select(dsp => new Web().GetDatasetData(dsp.Value.Code, dsp.Value.QueryParams));
            int       numberOfTasksForEachBatch = QuandlConfig.Instance.IsOnlyUser() ? 1 : 8;

            foreach (var batchTask in tasks.Batch(numberOfTasksForEachBatch))
            {
                var fetchTask = Task.WhenAll(batchTask);
                fetchTask.Wait();
                var result = fetchTask.Result;
                fetchTaskCollection = fetchTaskCollection.Concat(result).ToArray();
            }

            // Create a bunch of results which we can combine to one giant table
            var combinedResults = new ResultsData(new List <List <object> >(), new List <string>());

            foreach (var qcc in fetchTaskCollection.Select((x, i) => new { Value = x, Index = i }))
            {
                var dataset = qcc.Value;
                var columns = dataset.Columns.Select(c => c.Code.ToUpper() == dataset.Columns[0].Code
                                                        ? c.Code
                                                        : $"{dataset.Code}/{c.Code}".ToUpper()).ToList();
                var newResults = new ResultsData(dataset.Data.DataPoints, columns);
                combinedResults = combinedResults.Combine(newResults);
            }

            return(combinedResults);
        }