private void eraseButton_Click(object sender, EventArgs e)
 {
     if (depthChartDataGrid.SelectedRows.Count == 1)
     {
         if (depthChartDataGrid.SelectedRows[0].Cells[4].Value == null)
         {
             //Don't delete an empy row
             return;
         }
         else
         {
             DepthChartRecord record = (DepthChartRecord)depthChartDataGrid.SelectedRows[0].Cells[4].Value;
             record.SetDeleteFlag(true);
             //move the other records up
             int index = record.DepthOrder + 1;
             while (index < depthChartDataGrid.Rows.Count)
             {
                 if (depthChartDataGrid.Rows[index].Cells[4].Value == null)
                 {
                     //Found an empty
                     break;
                 }
                 //move this one up
                 ((DepthChartRecord)depthChartDataGrid.Rows[index].Cells[4].Value).DepthOrder--;
                 index++;
             }
             LoadDepthChart();
             return;
         }
     }
 }
        /// <summary>
        /// TODO:
        /// This method should be put into the depth chart editing model at some stage.
        /// The whole depth chart editing functionality has too much logic in the scoutingForm objects
        /// and it needs to be moved into the depth chart editing model
        /// </summary>
        /// <param name="playerId"></param>
        public void RemovePlayerFromDepthChart(int playerId)
        {
            List <DepthChartRecord> oldDepthChartRecords = new List <DepthChartRecord>();

            foreach (TableRecordModel record in model.TableModels[EditorModel.DEPTH_CHART_TABLE].GetRecords())
            {
                if (record.Deleted)
                {
                    continue;
                }

                DepthChartRecord depthRecord = (DepthChartRecord)record;

                if (depthRecord.PlayerId == playerId)
                {
                    // Can't delete yet, unless player exists only once in depth chart
                    // Now record the position and team and depth cause we want to fix up
                    // the other players ordering in that same position
                    oldDepthChartRecords.Add(depthRecord);
                }
            }
            // Now delete all the depth chart records for this player.
            for (int p = 0; p < oldDepthChartRecords.Count; p++)
            {
                oldDepthChartRecords[p].SetDeleteFlag(true);
            }

            // Now we have a list of the old depth charts that this player belongs too, we need to fix each
            // one up. This is not going to be very efficient :)

            foreach (DepthChartRecord record in oldDepthChartRecords)
            {
                foreach (TableRecordModel depthChartRec in model.TableModels[EditorModel.DEPTH_CHART_TABLE].GetRecords())
                {
                    if (depthChartRec.Deleted)
                    {
                        continue;
                    }

                    DepthChartRecord depthRecord = (DepthChartRecord)depthChartRec;

                    if (depthRecord.TeamId == record.TeamId && depthRecord.PositionId == record.PositionId)
                    {
                        if (depthRecord.DepthOrder > record.DepthOrder)
                        {
                            depthRecord.DepthOrder--;
                        }

                        //TODO: We could probably exit early after we found like 6 or something
                        //records cause thats the maximum depth chart level anyway. but we'll try this
                        //first
                    }
                }
            }
        }
        private void transferButton_Click(object sender, EventArgs e)
        {
            if (availablePlayerDatagrid.SelectedRows.Count == 1 && depthChartDataGrid.SelectedRows.Count == 1)
            {
                //First check that the player we are bringing up into the depth chart isnt already there
                foreach (DataGridViewRow row in depthChartDataGrid.Rows)
                {
                    if (row.Cells[3].Value == availablePlayerDatagrid.SelectedRows[0].Cells[3].Value)
                    {
                        //Trying to transfer a player already there
                        return;
                    }
                }
                if (depthChartDataGrid.SelectedRows[0].Cells[4].Value == null)
                {
                    //We are transfering to a blank depthchart record we need to create a record for it
                    DepthChartRecord newRecord    = (DepthChartRecord)model.TableModels[EditorModel.DEPTH_CHART_TABLE].CreateNewRecord(true);
                    PlayerRecord     playerRecord = (PlayerRecord)availablePlayerDatagrid.SelectedRows[0].Cells[3].Value;

                    newRecord.PlayerId   = playerRecord.PlayerId;
                    newRecord.TeamId     = playerRecord.TeamId;
                    newRecord.DepthOrder = depthChartDataGrid.SelectedRows[0].Index;
                    newRecord.PositionId = positionCombo.SelectedIndex;

                    LoadDepthChart();
                    return;
                }
                else
                {
                    //We are swapping two players
                    DepthChartRecord depthRecord = (DepthChartRecord)depthChartDataGrid.SelectedRows[0].Cells[4].Value;

                    PlayerRecord playerRecord = (PlayerRecord)availablePlayerDatagrid.SelectedRows[0].Cells[3].Value;

                    depthRecord.PlayerId = playerRecord.PlayerId;

                    //Load up the screen again
                    LoadDepthChart();
                    return;
                }
            }
        }
        private void depthOrderUpButton_Click(object sender, EventArgs e)
        {
            if (depthChartDataGrid.SelectedRows.Count == 1)
            {
                //We have to find the two DepthChart objects to exchange positions
                if (depthChartDataGrid.Rows.Count == 1)
                {
                    //We can't transfer up if there are only 1 row
                    return;
                }
                if (depthChartDataGrid.SelectedRows[0].Index == 0)
                {
                    //We can't transfer the top row up
                    return;
                }
                int selIndex = depthChartDataGrid.SelectedRows[0].Index;
                //There are at least 2 rows and we arent at the top so
                DepthChartRecord selectedRecord    = (DepthChartRecord)depthChartDataGrid.Rows[depthChartDataGrid.SelectedRows[0].Index].Cells[4].Value;
                DepthChartRecord destinationRecord = (DepthChartRecord)depthChartDataGrid.Rows[depthChartDataGrid.SelectedRows[0].Index - 1].Cells[4].Value;

                //Now don't swap to/from a null row
                if (selectedRecord == null || destinationRecord == null)
                {
                    return;
                }

                int tempDepthOrd = destinationRecord.DepthOrder;
                destinationRecord.DepthOrder = selectedRecord.DepthOrder;
                selectedRecord.DepthOrder    = tempDepthOrd;

                LoadDepthChart();

                //Now select the one we just moved
                depthChartDataGrid.ClearSelection();
                depthChartDataGrid.Rows[selIndex - 1].Selected = true;
            }
        }
Exemplo n.º 5
0
        public TableRecordModel ConstructRecordModel(int recno)
        {
            TableRecordModel newRecord = null;
            string           tablename = name;

            // Need to reverse the name if BE
            if (BigEndian)
            {
                string rev = ConvertBE(name);
                tablename = rev;
            }

            switch (tablename)
            {
            case EditorModel.CITY_TABLE:
                newRecord = new CityRecord(recno, this, parentModel);
                break;

            case EditorModel.COACH_TABLE:
            {
                // coch table in streameddata is different than ros/fra
                if (parentModel.FileType == MaddenFileType.Streameddata)
                {
                    newRecord = new CoachCollection(recno, this, parentModel);
                }
                else
                {
                    newRecord = new CoachRecord(recno, this, parentModel);
                }
                break;
            }

            case EditorModel.SALARY_CAP_TABLE:
                newRecord = new SalaryCapRecord(recno, this, parentModel);
                break;

            case EditorModel.COACH_SLIDER_TABLE:
                newRecord = new CoachPrioritySliderRecord(recno, this, parentModel);
                break;

            case EditorModel.TEAM_CAPTAIN_TABLE:
                newRecord = new TeamCaptainRecord(recno, this, parentModel);
                break;

            case EditorModel.OWNER_TABLE:
                newRecord = new OwnerRecord(recno, this, parentModel);
                break;

            case EditorModel.DEPTH_CHART_TABLE:
                newRecord = new DepthChartRecord(recno, this, parentModel);
                break;

            case EditorModel.INJURY_TABLE:
                newRecord = new InjuryRecord(recno, this, parentModel);
                break;

            case EditorModel.PLAYER_TABLE:
                newRecord = new PlayerRecord(recno, this, parentModel);
                break;

            case EditorModel.TEAM_TABLE:
                newRecord = new TeamRecord(recno, this, parentModel);
                break;

            case EditorModel.SCHEDULE_TABLE:
                newRecord = new ScheduleRecord(recno, this, parentModel);
                break;

            case EditorModel.STADIUM_TABLE:
                newRecord = new StadiumRecord(recno, this, parentModel);
                break;

            case EditorModel.UNIFORM_TABLE:
                newRecord = new UniformRecord(recno, this, parentModel);
                break;

            // MADDEN DRAFT EDIT
            case EditorModel.DRAFT_PICK_TABLE:
                newRecord = new DraftPickRecord(recno, this, parentModel);
                break;

            case EditorModel.DRAFTED_PLAYERS_TABLE:
                newRecord = new RookieRecord(recno, this, parentModel);
                break;

            case EditorModel.BOXSCORE_DEFENSE_TABLE:
                newRecord = new BoxScoreDefenseRecord(recno, this, parentModel);
                break;

            case EditorModel.BOXSCORE_OFFENSE_TABLE:
                newRecord = new BoxScoreOffenseRecord(recno, this, parentModel);
                break;

            case EditorModel.CAREER_STATS_DEFENSE_TABLE:
                newRecord = new CareerStatsDefenseRecord(recno, this, parentModel);
                break;

            case EditorModel.CAREER_STATS_OFFENSE_TABLE:
                newRecord = new CareerStatsOffenseRecord(recno, this, parentModel);
                break;

            case EditorModel.SEASON_STATS_DEFENSE_TABLE:
                newRecord = new SeasonStatsDefenseRecord(recno, this, parentModel);
                break;

            case EditorModel.SEASON_STATS_OFFENSE_TABLE:
                newRecord = new SeasonStatsOffenseRecord(recno, this, parentModel);
                break;

            case EditorModel.TEAM_SEASON_STATS:
                newRecord = new TeamSeasonStatsRecord(recno, this, parentModel);
                break;

            case EditorModel.FRANCHISE_TIME_TABLE:
                newRecord = new FranchiseTimeRecord(recno, this, parentModel);
                break;

            case EditorModel.BOXSCORE_TEAM_TABLE:
                newRecord = new BoxScoreTeamStats(recno, this, parentModel);
                break;

            case EditorModel.BOXSCORE_OFFENSIVE_LINE_TABLE:
                newRecord = new BoxScoreOffensiveLineRecord(recno, this, parentModel);
                break;

            case EditorModel.SEASON_STATS_OFFENSIVE_LINE_TABLE:
                newRecord = new SeasonStatsOffensiveLineRecord(recno, this, parentModel);
                break;

            case EditorModel.CAREER_STATS_OFFENSIVE_LINE_TABLE:
                newRecord = new CareerStatsOffensiveLineRecord(recno, this, parentModel);
                break;

            case EditorModel.CAREER_GAMES_PLAYED_TABLE:
                newRecord = new CareerGamesPlayedRecord(recno, this, parentModel);
                break;

            case EditorModel.SEASON_GAMES_PLAYED_TABLE:
                newRecord = new SeasonGamesPlayedRecord(recno, this, parentModel);
                break;

            case EditorModel.CAREER_STATS_KICKPUNT_TABLE:
                newRecord = new CareerPuntKickRecord(recno, this, parentModel);
                break;

            case EditorModel.SEASON_STATS_KICKPUNT_TABLE:
                newRecord = new SeasonPuntKickRecord(recno, this, parentModel);
                break;

            case EditorModel.CAREER_STATS_KICKPUNT_RETURN_TABLE:
                newRecord = new CareerPKReturnRecord(recno, this, parentModel);
                break;

            case EditorModel.SEASON_STATS_KICKPUNT_RETURN_TABLE:
                newRecord = new SeasonPKReturnRecord(recno, this, parentModel);
                break;

            case EditorModel.SCOUTING_STATE_TABLE:
                newRecord = new ScoutingStateRecord(recno, this, parentModel);
                break;

            case EditorModel.RFA_STATE_TABLE:
                newRecord = new RFAStateRecord(recno, this, parentModel);
                break;

            case EditorModel.RFA_PLAYERS:
                newRecord = new RestrictedFreeAgentPlayers(recno, this, parentModel);
                break;

            case EditorModel.RFA_SALARY_TENDERS:
                newRecord = new RestrictedFreeAgentSigningTenders(recno, this, parentModel);
                break;

            case EditorModel.RESIGN_PLAYERS_STATE_TABLE:
                newRecord = new ResignPlayersStateRecord(recno, this, parentModel);
                break;

            case EditorModel.FREE_AGENCY_STATE_TABLE:
                newRecord = new FreeAgencyStateRecord(recno, this, parentModel);
                break;

            case EditorModel.DRAFT_STATE_TABLE:
                newRecord = new DraftStateRecord(recno, this, parentModel);
                break;

            case EditorModel.FRANCHISE_STAGE_TABLE:
                newRecord = new FranchiseStageRecord(recno, this, parentModel);
                break;

            case EditorModel.GAME_OPTIONS_TABLE:
                newRecord = new GameOptionRecord(recno, this, parentModel);
                break;

            case EditorModel.PLAYER_AWARDS_TABLE:
                newRecord = new YearlyAwards(recno, this, parentModel);
                break;

            case EditorModel.FREE_AGENT_PLAYERS:
                newRecord = new FreeAgentPlayers(recno, this, parentModel);
                break;

            case EditorModel.COACHES_EXPECTED_SALARY:
                newRecord = new CoachExpectedSalary(recno, this, parentModel);
                break;

            case EditorModel.COACHING_HISTORY_TABLE:
                newRecord = new CoachHistory(recno, this, parentModel);
                break;

            case EditorModel.PROGRESSION_SCHEDULE:
                newRecord = new ProgressionSchedule(recno, this, parentModel);
                break;

            case EditorModel.USER_OPTIONS_TABLE:
                newRecord = new UserOptionRecord(recno, this, parentModel);
                break;

            case EditorModel.TEAM_RIVAL_HISTORY:
                newRecord = new TeamRivalHistory(recno, this, parentModel);
                break;

            case EditorModel.PRO_BOWL_PLAYERS:
                newRecord = new ProBowlPlayer(recno, this, parentModel);
                break;

            case EditorModel.USER_INFO_TABLE:
                newRecord = new UserInfoRecord(recno, this, parentModel);
                break;

                #region Streamed Data
            case EditorModel.COLLEGES_TABLE:
                newRecord = new CollegesRecord(recno, this, parentModel);
                break;

            case EditorModel.PLAYER_FIRST_NAMES:
                newRecord = new FirstNames(recno, this, parentModel);
                break;

            case EditorModel.PLAYER_LAST_NAMES:
                newRecord = new LastNames(recno, this, parentModel);
                break;

            case EditorModel.ROLES_DEFINE:
                newRecord = new PRDF(recno, this, parentModel);
                break;

            case EditorModel.ROLES_INFO:
                newRecord = new RoleInfo(recno, this, parentModel);
                break;

            case EditorModel.ROLES_PLAYER_EFFECTS:
                newRecord = new RolePlayerEffects(recno, this, parentModel);
                break;

            case EditorModel.ROLES_TEAM_EFFECTS:
                newRecord = new RoleTeamEffects(recno, this, parentModel);
                break;

            case EditorModel.STATS_REQUIRED:
                newRecord = new SuperStarStatsRequired(recno, this, parentModel);
                break;

            case EditorModel.PROGRESSION:
                newRecord = new PlayerProgression(recno, this, parentModel);
                break;

            case EditorModel.REGRESSION:
                newRecord = new PlayerRegression(recno, this, parentModel);
                break;

            case EditorModel.PTCB:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTCE:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTDE:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTDT:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTFB:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTFS:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTGA:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTHB:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTKI:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTKP:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTMB:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTOB:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTPU:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTQB:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTSS:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTTA:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTTE:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

            case EditorModel.PTWR:
                newRecord = new ProgressionTracking(recno, this, parentModel);
                break;

                #endregion

            case EditorModel.POSITION_SUBS:
                newRecord = new PlayerSubs(recno, this, parentModel);
                break;

            case EditorModel.DEPTH_CHART_SUBS:
                newRecord = new DepthChartSubs(recno, this, parentModel);
                break;

            case EditorModel.SALARY_CAP_INCREASE:
                newRecord = new SalaryCapIncrease(recno, this, parentModel);
                break;

            case EditorModel.PLAYER_MINIMUM_SALARY_TABLE:
                newRecord = new SalaryYearsPro(recno, this, parentModel);
                break;

            case EditorModel.PLAYER_SALARY_DEMAND_TABLE:
                newRecord = new PlayerSalaryDemands(recno, this, parentModel);
                break;

            case EditorModel.INACTIVE_TABLE:
                newRecord = new InactiveRecord(recno, this, parentModel);
                break;

            case EditorModel.LEAGUE_REVENUE_TABLE:
                newRecord = new LeagueRevenue(recno, this, parentModel);
                break;

            case EditorModel.OWNER_REVENUE_TABLE:
                newRecord = new OwnerRevenue(recno, this, parentModel);
                break;

            case EditorModel.WEEKLY_INCOME_TABLE:
                newRecord = new Income(recno, this, parentModel);
                break;

            case EditorModel.TEAM_WIN_LOSS_RECORD:
                newRecord = new TeamWinLossRecord(recno, this, parentModel);
                break;

            // DB Templates
            case EditorModel.PLAYER_OVERALL_CALC:
                newRecord = new OverallRecord(recno, this, parentModel);
                break;

            case EditorModel.PLAYBOOK_TABLE:
                newRecord = new FRAPlayBooks(recno, this, parentModel);
                break;

            default:
                newRecord = new TableRecordModel(recno, this, parentModel);
                break;
            }

            //Add the new record to our list of records
            recordList.Add(newRecord);

            return(newRecord);
        }