Пример #1
0
        private void btnOkay_Click(object sender, EventArgs e)
        {
            Stop();
            using (ProgressWindow progress = new ProgressWindow(this, String.Format("{0} Converter", _type == 0 ? "Brstm" : "Wave"), "Encoding, please wait...", false))
                switch (_type)
                {
                case 0:
                    _audioData = RSTMConverter.Encode(_sourceStream, progress);
                    break;

                case 1:
                    _audioData = RSARWaveConverter.Encode(_sourceStream, progress);
                    break;

                case 2:
                    _audioData = RWAVConverter.Encode(_sourceStream, progress);
                    break;
                }

            DialogResult = DialogResult.OK;
            Close();
        }
        private void btnOkay_Click(object sender, EventArgs e)
        {
            Stop();
            using(ProgressWindow progress = new ProgressWindow(this, String.Format("{0} Converter", _type == 0 ? "Brstm" : "Wave"), "Encoding, please wait...", false))
                switch (_type)
                {
                    case 0:
                        _audioData = RSTMConverter.Encode(_sourceStream, progress);
                        break;
                    case 1:
                        _audioData = RSARWaveConverter.Encode(_sourceStream, progress);
                        break;
                    case 2:
                        _audioData = RWAVConverter.Encode(_sourceStream, progress);
                        break;
                }

            DialogResult = DialogResult.OK;
            Close();
        }
Пример #3
0
        private void RenderToGIF(Image[] images)
        {
            string outPath = "";

Start:
            if (!String.IsNullOrEmpty(ScreenCapBgLocText.Text))
            {
                try
                {
                    outPath = ScreenCapBgLocText.Text;
                    if (!Directory.Exists(outPath))
                    {
                        Directory.CreateDirectory(outPath);
                    }

                    DirectoryInfo dir   = new DirectoryInfo(outPath);
                    FileInfo[]    files = dir.GetFiles();
                    int           i     = 0;
                    string        name  = "BrawlboxAnimation";
Top:
                    foreach (FileInfo f in files)
                    {
                        if (f.Name == name + i + ".gif")
                        {
                            i++;
                            goto Top;
                        }
                    }
                    outPath += "\\" + name + i + ".gif";
                }
                catch { }
            }
            else
            {
                ScreenCapBgLocText.Text = Application.StartupPath + "\\ScreenCaptures";
                goto Start;
            }

            AnimatedGifEncoder e = new AnimatedGifEncoder();

            e.Start(outPath);
            e.SetDelay(1000 / (int)pnlPlayback.numFPS.Value);
            e.SetRepeat(0);
            e.SetQuality(1);
            using (ProgressWindow progress = new ProgressWindow(this, "GIF Encoder", "Encoding, please wait...", true))
            {
                progress.TopMost = true;
                progress.Begin(0, images.Length, 0);
                for (int i = 0, count = images.Length; i < count; i++)
                {
                    if (progress.Cancelled)
                    {
                        break;
                    }

                    e.AddFrame(images[i]);
                    progress.Update(progress.CurrentValue + 1);
                }
                progress.Finish();
                e.Finish();
            }

            if (InterpolationEditor != null)
            {
                InterpolationEditor.Enabled = true;
            }
            ModelPanel.Enabled = true;
            Enabled            = true;

            MessageBox.Show("GIF successfully saved to " + outPath.Replace("\\", "/"));
        }
        public void RenderToGIF(Image[] images)
        {
            string outPath = "";
            Start:
            if (!String.IsNullOrEmpty(ScreenCapBgLocText.Text))
            {
                try
                {
                    outPath = ScreenCapBgLocText.Text;
                    if (!Directory.Exists(outPath))
                        Directory.CreateDirectory(outPath);

                    DirectoryInfo dir = new DirectoryInfo(outPath);
                    FileInfo[] files = dir.GetFiles();
                    int i = 0;
                    string name = "Animation";
                Top:
                    foreach (FileInfo f in files)
                        if (f.Name == name + i + ".gif")
                        {
                            i++;
                            goto Top;
                        }
                    outPath += "\\" + name + i + ".gif";
                }
                catch { }
            }
            else
            {
                ScreenCapBgLocText.Text = Application.StartupPath + "\\ScreenCaptures";
                goto Start;
            }

            AnimatedGifEncoder e = new AnimatedGifEncoder();
            e.Start(outPath);
            e.SetDelay(1000 / (int)pnlPlayback.numFPS.Value);
            e.SetRepeat(0);
            e.SetQuality(1);
            using (ProgressWindow progress = new ProgressWindow(this, "GIF Encoder", "Encoding, please wait...", true))
            {
                progress.TopMost = true;
                progress.Begin(0, images.Length, 0);
                for (int i = 0, count = images.Length; i < count; i++)
                {
                    if (progress.Cancelled)
                        break;

                    e.AddFrame(images[i]);
                    progress.Update(progress.CurrentValue + 1);
                }
                progress.Finish();
                e.Finish();
            }

            if (InterpolationEditor != null)
                InterpolationEditor.Enabled = true;
            ModelPanel.Enabled = true;
            Enabled = true;

            MessageBox.Show("GIF successfully saved to " + outPath.Replace("\\", "/"));
        }
Пример #5
0
        private void RenderToGIF(List <Image> images, string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            string outPath = "";

            try
            {
                outPath = path;
                if (!Directory.Exists(outPath))
                {
                    Directory.CreateDirectory(outPath);
                }

                DirectoryInfo dir   = new DirectoryInfo(outPath);
                FileInfo[]    files = dir.GetFiles();
                int           i     = 0;
                string        name  = "Animation";
Top:
                foreach (FileInfo f in files)
                {
                    if (f.Name == name + i + ".gif")
                    {
                        i++;
                        goto Top;
                    }
                }

                outPath += "\\" + name + i + ".gif";
            }
            catch
            {
            }

            AnimatedGifEncoder e = new AnimatedGifEncoder();

            e.Start(outPath);
            e.SetDelay(1000 / (int)PlaybackPanel.numFPS.Value);
            e.SetRepeat(0);
            e.SetQuality(10);
            using (ProgressWindow progress = new ProgressWindow(this, "GIF Encoder", "Encoding, please wait...", true))
            {
                progress.TopMost = true;
                progress.Begin(0, images.Count, 0);
                for (int i = 0, count = images.Count; i < count; i++)
                {
                    if (progress.Cancelled)
                    {
                        break;
                    }

                    //GIF transparency support is pretty poor, flickers a lot
                    //e.SetTransparent(ModelPanel.CurrentViewport.BackgroundColor);

                    e.AddFrame(images[i]);
                    progress.Update(progress.CurrentValue + 1);
                }

                progress.Finish();
                e.Finish();
            }

            if (MessageBox.Show(this,
                                "Animated GIF successfully saved to \"" + outPath.Replace("\\", "/") + "\".\nOpen the folder now?",
                                "GIF saved", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                Process.Start("explorer.exe", path);
            }
        }
Пример #6
0
 public static int Compact(VoidPtr srcAddr, int srcLen, Stream outStream, ResourceNode r, bool extendedFormat)
 {
     using (LZ77 lz = new LZ77())
     using (ProgressWindow prog = new ProgressWindow(r.RootNode._mainForm, (extendedFormat ? "Extended " : "") + "LZ77", String.Format("Compressing {0}, please wait...", r.Name), false))
         return lz.Compress(srcAddr, srcLen, outStream, prog, extendedFormat);
 }
 public static int Compact(VoidPtr srcAddr, int srcLen, Stream outStream, ResourceNode r, bool extendedFormat)
 {
     using (ProgressWindow prog = new ProgressWindow(r.RootNode._mainForm, "Differential", String.Format("Compressing {0}, please wait...", r.Name), false))
         return new Differential().Compress(srcAddr, srcLen, outStream, prog);
 }
Пример #8
0
        private void startProgressWatchTimer()
        {
            if (_watchTimerRunning)
            {
                return;
            }

            _watchTimerRunning = true;
            ProgressHelper.Progress = new ProgressInfo(0, 8, "");
            if (!IsActive)
            {
                var pw = new ProgressWindow("", false);
                pw.Show();
            }
            dt = new DispatcherTimer();
            //dt.Interval = new TimeSpan(100);
            dt.Tick += updateBasedOnProgress;
            dt.Start();
        }
Пример #9
0
 public static int CompactYAZ0(VoidPtr srcAddr, int srcLen, Stream outStream, ResourceNode r)
 {
     using (ProgressWindow prog = new ProgressWindow(r.RootNode._mainForm, "RunLength", String.Format("Compressing {0}, please wait...", r.Name), false))
         return new RunLength().Compress(srcAddr, srcLen, outStream, prog, true);
 }
Пример #10
0
        public static void ImportOld(Dictionary<int, PlayerStats> pst, Dictionary<int, TeamStats> tst, string folder)
        {
            if (tst.Count != 30)
            {
                MessageBox.Show("Can't import previous player stats to a database that doesn't have 30 teams. Please import " +
                                "your NBA 2K save once to this database to populate it properly before trying to import previous " +
                                "player stats.");
                MainWindow.MWInstance.OnImportOldPlayerStatsCompleted(-2);
                return;
            }

            var list = new List<string> {"1 season ago"};
            for (int i = 2; i <= 20; i++)
            {
                list.Add(i + " seasons ago");
            }

            int startAt;
            var ccw = new ComboChoiceWindow("Add player stats staring from...", list);
            if (ccw.ShowDialog() != true)
            {
                MainWindow.MWInstance.mainGrid.Visibility = Visibility.Visible;
                return;
            }

            startAt = Convert.ToInt32(ComboChoiceWindow.UserChoice.Split(' ')[0]);

            var ibw =
                new InputBoxWindow(
                    "Enter the current season (e.g. 2011-2012 by default in NBA 2K12, 2012 for a season" +
                    " taking place only in that year, etc.):", "2011-2012");
            if (ibw.ShowDialog() != true)
            {
                MainWindow.MWInstance.mainGrid.Visibility = Visibility.Visible;
                return;
            }

            int year;
            bool twoPartSeasonDesc = InputBoxWindow.UserInput.Contains("-");
            try
            {
                year = Convert.ToInt32(twoPartSeasonDesc ? InputBoxWindow.UserInput.Split('-')[0] : InputBoxWindow.UserInput);
            }
            catch
            {
                MessageBox.Show("The year you entered (" + InputBoxWindow.UserInput +
                                ") was not in a valid format.\nValid formats are:\n\t2012\n\t2011-2012");
                MainWindow.MWInstance.OnImportOldPlayerStatsCompleted(-2);
                return;
            }

            var seasonNames = new Dictionary<int, string>();
            for (int i = startAt; i <= 20; i++)
            {
                seasonNames.Add(i, twoPartSeasonDesc ? string.Format("{0}-{1}", year - i, (year - i + 1)) : (year - i).ToString());
            }

            List<Dictionary<string, string>> teams;
            List<Dictionary<string, string>> players;
            List<Dictionary<string, string>> teamStats;
            List<Dictionary<string, string>> playerStats;

            if (populateREDitorDictionaryLists(folder, out teams, out players, out teamStats, out playerStats) == -1)
            {
                MainWindow.MWInstance.OnImportOldPlayerStatsCompleted(-1);
                return;
            }

            var legalTTypes = new List<string> {"0", "4"};

            List<Dictionary<string, string>> validTeams = teams.FindAll(delegate(Dictionary<string, string> team)
                {
                    if (legalTTypes.IndexOf(team["TType"]) != -1)
                    {
                        return true;
                    }
                    return false;
                });

            List<Dictionary<string, string>> activeTeams = validTeams.FindAll(delegate(Dictionary<string, string> team)
                {
                    if (team["StatCurS"] != "-1")
                    {
                        return true;
                    }
                    return false;
                });
            if (activeTeams.Count < 30)
            {
                var dlw = new DualListWindow(validTeams, activeTeams);
                if (dlw.ShowDialog() == false)
                {
                    MainWindow.MWInstance.OnImportOldPlayerStatsCompleted(-1);
                    return;
                }

                activeTeams = new List<Dictionary<string, string>>(MainWindow.SelectedTeams);

                if (MainWindow.SelectedTeamsChanged)
                {
                    CreateSettingsFile(activeTeams, folder);
                }
            }

            var activeTeamsIDs = new List<int>();
            var rosters = new Dictionary<int, List<int>>();
            foreach (var team in activeTeams)
            {
                int id = -1;
                string name = team["Name"];
                if (tst.All(pair => pair.Value.Name != name))
                {
                    for (int i = 0; i < 30; i++)
                    {
                        if (!tst.ContainsKey(i))
                        {
                            id = i;
                            break;
                        }
                    }
                }
                else
                {
                    id = tst.Single(pair => pair.Value.Name == name).Key;
                }
                activeTeamsIDs.Add(Convert.ToInt32(team["ID"]));

                rosters[id] = new List<int>
                    {
                        Convert.ToInt32(team["Ros_PG"]),
                        Convert.ToInt32(team["Ros_SG"]),
                        Convert.ToInt32(team["Ros_SF"]),
                        Convert.ToInt32(team["Ros_PF"]),
                        Convert.ToInt32(team["Ros_C"])
                    };
                for (int i = 6; i <= 12; i++)
                {
                    int cur = Convert.ToInt32(team["Ros_S" + i.ToString()]);
                    if (cur != -1)
                    {
                        rosters[id].Add(cur);
                    }
                    else
                    {
                        break;
                    }
                }
                for (int i = 13; i <= 20; i++)
                {
                    int cur = Convert.ToInt32(team["Ros_R" + i.ToString()]);
                    if (cur != -1)
                    {
                        rosters[id].Add(cur);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            List<Dictionary<string, string>> validPlayers = players.FindAll(delegate(Dictionary<string, string> player)
                {
                    if (player["PlType"] == "4" || player["PlType"] == "5" || player["PlType"] == "6")
                    {
                        if ((player["IsFA"] == "0" && player["TeamID1"] != "-1") || (player["IsFA"] == "1"))
                        {
                            return true;
                        }
                    }
                    return false;
                });

            var pw = new ProgressWindow("Please wait as player career stats are being imported...");
            pw.Show();
            var bw = new BackgroundWorker {WorkerReportsProgress = true};
            bw.DoWork += delegate
                {
                    int count = validPlayers.Count;
                    var ppsList = new List<PastPlayerStats>();
                    for (int i = 0; i < count; i++)
                    {
                        int percentProgress = i*100/count;
                        if (percentProgress%5 == 0)
                        {
                            bw.ReportProgress(percentProgress);
                        }
                        Dictionary<string, string> player = validPlayers[i];
                        int playerID = Convert.ToInt32(player["ID"]);

                        string lastName = player["Last_Name"];
                        string firstName = player["First_Name"];

                        int pTeam;
                        var curTeam = new TeamStats();
                        try
                        {
                            pTeam = rosters.Single(r => r.Value.Contains(playerID)).Key;
                            curTeam = tst[pTeam];
                        }
                        catch (InvalidOperationException)
                        {
                            pTeam = -1;
                        }

                        if (!activeTeamsIDs.Contains(pTeam) && player["IsFA"] != "1")
                        {
                            if (pst.ContainsKey(playerID) && pst[playerID].LastName == lastName && pst[playerID].FirstName == firstName)
                            {
                                pst[playerID].IsActive = false;
                                pst[playerID].TeamF = -1;
                                pst[playerID].IsHidden = true;
                            }
                            continue;
                        }

                        if (pst.ContainsKey(playerID) && (pst[playerID].LastName != lastName || pst[playerID].FirstName != firstName))
                        {
                            List<KeyValuePair<int, PlayerStats>> candidates =
                                pst.Where(
                                    pair =>
                                    pair.Value.LastName == lastName && pair.Value.FirstName == firstName &&
                                    pair.Value.IsHidden == false).ToList();
                            if (candidates.Count > 0)
                            {
                                bool found = false;
                                List<KeyValuePair<int, PlayerStats>> c2 =
                                    candidates.Where(pair => tst.ContainsKey(pair.Value.TeamF)).ToList();
                                if (c2.Count() == 1)
                                {
                                    playerID = c2.First().Value.ID;
                                    found = true;
                                }
                                else
                                {
                                    List<KeyValuePair<int, PlayerStats>> c4 =
                                        candidates.Where(pair => pair.Value.YearOfBirth.ToString() == player["BirthYear"]).ToList();
                                    if (c4.Count == 1)
                                    {
                                        playerID = c4.First().Value.ID;
                                        found = true;
                                    }
                                    else
                                    {
                                        if (pTeam != -1)
                                        {
                                            List<KeyValuePair<int, PlayerStats>> c3 =
                                                candidates.Where(pair => pair.Value.TeamF == curTeam.ID).ToList();
                                            if (c3.Count == 1)
                                            {
                                                playerID = c3.First().Value.ID;
                                                found = true;
                                            }
                                        }
                                    }
                                }
                                if (!found)
                                {
                                    var choices = new List<string>();
                                    foreach (var pair in candidates)
                                    {
                                        string choice = String.Format("{0}: {1} {2} (Born {3}", pair.Value.ID, pair.Value.FirstName,
                                                                      pair.Value.LastName, pair.Value.YearOfBirth);
                                        if (pair.Value.IsActive)
                                        {
                                            choice += String.Format(", plays in {0}", pair.Value.TeamF);
                                        }
                                        else
                                        {
                                            choice += ", free agent";
                                        }
                                        choice += ")";
                                        choices.Add(choice);
                                    }
                                    string message = String.Format("{0}: {1} {2} (Born {3}", player["ID"], player["First_Name"],
                                                                   player["Last_Name"], player["BirthYear"]);
                                    if (pTeam != -1)
                                    {
                                        message += String.Format(", plays in {0}", curTeam.DisplayName);
                                    }
                                    else
                                    {
                                        message += ", free agent";
                                    }
                                    message += ")";
                                    ccw = new ComboChoiceWindow(message, choices);
                                    if (ccw.ShowDialog() != true)
                                    {
                                        continue;
                                    }
                                    else
                                    {
                                        playerID = Convert.ToInt32(ComboChoiceWindow.UserChoice.Split(':')[0]);
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else if (!pst.ContainsKey(playerID))
                        {
                            continue;
                        }
                        PlayerStats curPlayer = pst[playerID];

                        string qr = "SELECT * FROM PastPlayerStats WHERE PlayerID = " + playerID + " ORDER BY \"SOrder\"";
                        DataTable dt = MainWindow.DB.GetDataTable(qr);
                        dt.Rows.Cast<DataRow>().ToList().ForEach(dr => ppsList.Add(new PastPlayerStats(dr)));
                        for (int j = startAt; j <= 20; j++)
                        {
                            string statEntryID = player["StatY" + j];
                            if (statEntryID == "-1")
                            {
                                break;
                            }
                            Dictionary<string, string> plStats = playerStats.Single(d => d["ID"] == statEntryID);
                            var prevStats = new PastPlayerStats();
                            string teamID2 = plStats["TeamID2"];
                            string teamID1 = plStats["TeamID1"];
                            if (teamID2 == "-1")
                            {
                                if (teamID1 != "-1")
                                {
                                    prevStats.TeamFName = teams.Single(team => team["ID"] == teamID1)["Name"];
                                }
                            }
                            else
                            {
                                prevStats.TeamFName = teams.Single(team => team["ID"] == teamID2)["Name"];
                                if (teamID1 != "-1")
                                {
                                    prevStats.TeamSName = teams.Single(team => team["ID"] == teamID1)["Name"];
                                }
                            }
                            prevStats.GP = Convert.ToUInt16(plStats["GamesP"]);
                            prevStats.GS = Convert.ToUInt16(plStats["GamesS"]);
                            prevStats.MINS = Convert.ToUInt16(plStats["Minutes"]);
                            prevStats.PTS = Convert.ToUInt16(plStats["Points"]);
                            prevStats.DREB = Convert.ToUInt16(plStats["DRebs"]);
                            prevStats.OREB = Convert.ToUInt16(plStats["ORebs"]);
                            prevStats.AST = Convert.ToUInt16(plStats["Assists"]);
                            prevStats.STL = Convert.ToUInt16(plStats["Steals"]);
                            prevStats.BLK = Convert.ToUInt16(plStats["Blocks"]);
                            prevStats.TOS = Convert.ToUInt16(plStats["TOs"]);
                            prevStats.FOUL = Convert.ToUInt16(plStats["Fouls"]);
                            prevStats.FGM = Convert.ToUInt16(plStats["FGMade"]);
                            prevStats.FGA = Convert.ToUInt16(plStats["FGAtt"]);
                            prevStats.TPM = Convert.ToUInt16(plStats["3PTMade"]);
                            prevStats.TPA = Convert.ToUInt16(plStats["3PTAtt"]);
                            prevStats.FTM = Convert.ToUInt16(plStats["FTMade"]);
                            prevStats.FTA = Convert.ToUInt16(plStats["FTAtt"]);
                            prevStats.PlayerID = playerID;
                            prevStats.SeasonName = seasonNames[j];
                            prevStats.IsPlayoff = false;
                            prevStats.Order = 20 - j;
                            prevStats.EndEdit();
                            ppsList.Add(prevStats);
                        }
                    }
                    bw.ReportProgress(99, "Please wait while the player career stats are being saved...");
                    SQLiteIO.SavePastPlayerStatsToDatabase(MainWindow.DB, ppsList);
                };

            bw.RunWorkerCompleted += delegate
                {
                    pw.CanClose = true;
                    pw.Close();
                    MainWindow.MWInstance.OnImportOldPlayerStatsCompleted(0);
                };

            bw.ProgressChanged += delegate(object sender, ProgressChangedEventArgs args)
                {
                    pw.SetProgressBarValue(args.ProgressPercentage);
                    if (args.UserState != null)
                    {
                        pw.SetMessage(args.UserState.ToString());
                    }
                };

            bw.RunWorkerAsync();
        }
Пример #11
0
        public void copyIconsToSelcharacter2()
        {
            string fileToSaveTo = null;

            ResourceNode s2 = null;
            if (common5 != null) {
                s2 = common5.FindChild("sc_selcharacter2_en", false);
            } else if (sc_selmap != null) {
                if (File.Exists("../../menu2/sc_selcharacter2.pac")) {
                    fileToSaveTo = "../../menu2/sc_selcharacter2.pac";
                    s2 = TempFiles.MakeTempNode(fileToSaveTo);
                } else if (File.Exists("../../menu2/sc_selcharacter2_en.pac")) {
                    fileToSaveTo = "../../menu2/sc_selcharacter2_en.pac";
                    s2 = TempFiles.MakeTempNode(fileToSaveTo);
                }
            }

            if (s2 == null) return;

            ResourceNode md0 = s2.FindChild("MenuRule_en/ModelData[0]", false);
            MSBinNode md1 = s2.FindChild("MenuRule_en/MiscData[1]", false) as MSBinNode;
            ResourceNode md80 = sc_selmap.FindChild("MiscData[80]", false);
            if (md0 == null || md80 == null) return;

            Image[] icons = new Image[41];
            Image[] frontstnames = new Image[41];
            for (int i = 1; i < 60; i++) {
                if (i == 32) i = 50;
                int sssPos = StageIDMap.sssPositionForSelcharacter2Icon(i);
                string nameSelmap = BestSSS[sssPos].Item2.ToString("D2");
                icons[sssPos] = ((md80.FindChild("Textures(NW4R)/MenSelmapIcon." + nameSelmap, false) as TEX0Node).GetImage(0));
                frontstnames[sssPos] = ((md80.FindChild("Textures(NW4R)/MenSelmapFrontStname." + nameSelmap, false) as TEX0Node).GetImage(0));
            }

            var d = new RandomSelectEditNamesDialog(md1._strings, icons, frontstnames);
            d.Message = "When finished, press OK to continue.";
            if (d.ShowDialog() == DialogResult.OK) {
                for (int i = 0; i < md1._strings.Count; i++) {
                    md1._strings[i] = d[i].ToString();
                }
            } else {
                return;
            }

            using (ProgressWindow w = new ProgressWindow() { CanCancel = false }) {
                w.Begin(0, 60, 0);
                for (int i = 1; i < 60; i++) {
                    if (i == 32) i = 50;

                    int sssPos = StageIDMap.sssPositionForSelcharacter2Icon(i);
                    string tempFile1 = TempFiles.Create(".tex0");
                    string tempFile2 = TempFiles.Create(".plt0");
                    string nameSelcharacter2 = i.ToString("D2");
                    string nameSelmap = BestSSS[sssPos].Item2.ToString("D2");
                    TEX0Node iconFrom = md80.FindChild("Textures(NW4R)/MenSelmapIcon." + nameSelmap, false) as TEX0Node;
                    TEX0Node iconTo = md0.FindChild("Textures(NW4R)/MenSelmapIcon." + nameSelcharacter2, false) as TEX0Node;
                    var palFrom = md80.FindChild("Palettes(NW4R)/MenSelmapIcon." + nameSelmap, false);
                    var palTo = md0.FindChild("Palettes(NW4R)/MenSelmapIcon." + nameSelcharacter2, false);
                    if (iconFrom != null && iconTo != null && palFrom != null && palTo != null) {
                        iconFrom.Export(tempFile1);
                        iconTo.Replace(tempFile1);
                        palFrom.Export(tempFile2);
                        palTo.Replace(tempFile2);
                    }

                    TEX0Node prevbase = md80.FindChild("Textures(NW4R)/MenSelmapPrevbase." + nameSelmap, false) as TEX0Node;
                    TEX0Node stageswitch = md0.FindChild("Textures(NW4R)/MenStageSwitch." + nameSelcharacter2, false) as TEX0Node;
                    if (prevbase != null && stageswitch != null) {
                        Bitmap thumbnail = new Bitmap(112, 56);
                        using (Graphics g = Graphics.FromImage(thumbnail)) {
                            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                            g.DrawImage(prevbase.GetImage(0), 0, -28, 112, 112);
                        }
                        stageswitch.Replace(thumbnail);
                    }

                    w.Update(i);
                }
            }

            if (fileToSaveTo != null) {
                s2.Export(fileToSaveTo);
            }
        }
Пример #12
0
        /// <summary>
        /// starts the job provided as parameters
        /// </summary>
        /// <param name="job">the Job object containing all the parameters</param>
        /// <returns>success / failure indicator</returns>
        private bool startEncoding(Job job)
        {
            Debug.Assert(status == JobWorkerStatus.Idle);

            try
            {
                //Check to see if output file already exists before encoding.
                if (File.Exists(job.Output) && !mainForm.DialogManager.overwriteJobOutput(job.Output))
                    throw new JobStartException("File exists and the user doesn't want to overwrite", ExceptionType.UserSkip);

                // Get IJobProcessor
                currentProcessor = getProcessor(job);
                if (currentProcessor == null)
                    throw new JobStartException("No processor could be found", ExceptionType.Error);

                addToLog("\r\n\r\n------------------------------------------------------\r\n\r\n");
                addToLog("Starting job " + job.Name + " at " + DateTime.Now.ToLongTimeString() + "\r\n");

                // Preprocess
                preprocessJob(job);

                // Setup
                try
                {
                    currentProcessor.setup(job);
                }
                catch (JobRunException e)
                {
                    throw new JobStartException("Calling setup of processor failed with error '" + e.Message + "'", ExceptionType.Error);
                }

                // Do JobControl setup
                addToLog("encoder commandline:\r\n" + job.Commandline + "\r\n");
                currentProcessor.StatusUpdate += new JobProcessingStatusUpdateCallback(UpdateGUIStatus);

                // Progress window
                pw = new ProgressWindow(job.JobType);
                pw.WindowClosed += new WindowClosedCallback(pw_WindowClosed);
                pw.Abort += new AbortCallback(pw_Abort);
                pw.setPriority(job.Priority);
                pw.PriorityChanged += new PriorityChangedCallback(pw_PriorityChanged);
                if (mainForm.Settings.OpenProgressWindow && mainForm.Visible)
                    pw.Show();

                job.Status = JobStatus.PROCESSING;
                job.Start = DateTime.Now;
                status = JobWorkerStatus.Running;
                pauseStatus = PauseState.Encoding;
                currentJob = job;

                // Start
                try
                {
                    currentProcessor.start();
                }
                catch (JobRunException e)
                {
                    throw new JobStartException("starting encoder failed with error '" + e.Message +"'", ExceptionType.Error);
                }

                addToLog("successfully started encoding\r\n");

                refreshAll();
                return true;
            }
            catch (JobStartException e)
            {
                addToLog("Job not started. Reason: " + e.Message + "\r\n");
                if (e.type == ExceptionType.Error)
                    job.Status = JobStatus.ERROR;
                else // ExceptionType.UserSkip
                    job.Status = JobStatus.SKIP;
                currentProcessor = null;
                currentJob = null;
                status = JobWorkerStatus.Idle;
                pauseStatus = PauseState.NotEncoding;
                refreshAll();
                return false;
            }
        }
Пример #13
0
 /// <summary>
 /// callback for the Progress Window
 /// This is called when the progress window has been closed and ensures that
 /// no futher attempt is made to send a statusupdate to the progress window
 /// </summary>
 private void pw_WindowClosed(bool hideOnly)
 {
     mainForm.ProcessStatusChecked = false;
     if (!hideOnly)
         pw = null;
 }
Пример #14
0
 /// <summary>
 /// Makes sure that the progress window is closed
 /// </summary>
 private void ensureProgressWindowClosed()
 {
     if (pw != null)
     {
         pw.IsUserAbort = false; // ensures that the window will be closed
         pw.Close();
         pw = null;
     }
 }
Пример #15
0
        private void exportAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (FolderDialog.ShowDialog() != DialogResult.OK) {
                return;
            }

            string outdir = FolderDialog.SelectedPath;
            if (Directory.Exists(outdir) && Directory.EnumerateFileSystemEntries(outdir).Any()) {
                var dr = MessageBox.Show("Is it OK to delete everything in " + outdir + "?", "", MessageBoxButtons.OKCancel);
                if (dr != DialogResult.OK) {
                    return;
                }
                Directory.Delete(outdir, true);
            }
            using (ProgressWindow progress = new ProgressWindow((Control)null, "Exporting...", "", true)) {
                progress.Begin(0, listBox1.Items.Count, 0);
                Directory.CreateDirectory(outdir);
                int i = 0;
                foreach (FileInfo f in listBox1.Items) {
                    if (progress.Cancelled) {
                        break;
                    }
                    progress.Update(++i);
                    string thisdir = outdir + "\\" + f.Name.Substring(0, f.Name.LastIndexOf('.'));
                    Directory.CreateDirectory(thisdir);
                    exportStage(f, thisdir);
                }
            }
        }
Пример #16
0
        public static async Task ImportOldPlayerCareerStats(
            Dictionary<int, PlayerStats> pst, Dictionary<int, TeamStats> tst, string folder)
        {
            if (tst.Count != 30)
            {
                MessageBox.Show(
                    "Can't import previous player stats to a database that doesn't have 30 teams. Please import "
                    + "your NBA 2K save once to this database to populate it properly before trying to import previous "
                    + "player stats.");
                MainWindow.MWInstance.OnImportOldPlayerStatsCompleted(-2);
                return;
            }

            List<Dictionary<string, string>> teams;
            List<Dictionary<string, string>> players;
            List<Dictionary<string, string>> teamStats;
            List<Dictionary<string, string>> playerStats;

            NBA2KVersion nba2KVersion;
            if (populateREDitorDictionaryLists(folder, out teams, out players, out teamStats, out playerStats, out nba2KVersion) == -1)
            {
                MainWindow.MWInstance.OnImportOldPlayerStatsCompleted(-1);
                return;
            }

            var list = new List<string> { "1 season ago" };
            for (var i = 2; i <= 20; i++)
            {
                list.Add(i + " seasons ago");
            }

            var ccw = new ComboChoiceWindow("Add player stats starting from...", list);
            if (ccw.ShowDialog() != true)
            {
                MainWindow.MWInstance.mainGrid.Visibility = Visibility.Visible;
                return;
            }

            var startAt = Convert.ToInt32(ComboChoiceWindow.UserChoice.Split(' ')[0]);

            var seasonNames = new Dictionary<int, string>();
            if (nba2KVersion == NBA2KVersion.NBA2K12)
            {
                while (true)
                {
                    var ibw =
                        new InputBoxWindow(
                            "Enter the season that describes the first season in this database (e.g. 2011-2012 by default in NBA 2K12, 2010-2011 if you "
                            + "imported last year's stats first, 2012 for a season taking place only in that year, etc.):",
                            "2011-2012");
                    if (ibw.ShowDialog() != true)
                    {
                        MainWindow.MWInstance.OnImportOldPlayerStatsCompleted(-2);
                        return;
                    }

                    int year;
                    var twoPartSeasonDesc = InputBoxWindow.UserInput.Contains("-");
                    try
                    {
                        year = Convert.ToInt32(twoPartSeasonDesc ? InputBoxWindow.UserInput.Split('-')[0] : InputBoxWindow.UserInput);
                    }
                    catch
                    {
                        MessageBox.Show(
                            "The year you entered (" + InputBoxWindow.UserInput
                            + ") was not in a valid format.\nValid formats are:\n\t2012\n\t2011-2012");
                        continue;
                    }

                    for (var i = startAt; i <= 20; i++)
                    {
                        seasonNames.Add(
                            i, twoPartSeasonDesc ? string.Format("{0}-{1}", year - i, (year - i + 1)) : (year - i).ToString());
                    }
                    break;
                }
            }

            initializeLegalTeamTypes(nba2KVersion);

            var validTeams = teams.FindAll(
                delegate(Dictionary<string, string> team)
                    {
                        if (legalTTypes.IndexOf(team["TType"]) != -1)
                        {
                            return true;
                        }
                        return false;
                    });

            var activeTeams = validTeams.FindAll(
                delegate(Dictionary<string, string> team)
                    {
                        if (team["StatCurS"] != "-1")
                        {
                            return true;
                        }
                        return false;
                    });
            if (activeTeams.Count < 30)
            {
                var dlw = new DualListWindow(validTeams, activeTeams);
                if (dlw.ShowDialog() == false)
                {
                    MainWindow.MWInstance.OnImportOldPlayerStatsCompleted(-1);
                    return;
                }

                activeTeams = new List<Dictionary<string, string>>(MainWindow.SelectedTeams);

                if (MainWindow.SelectedTeamsChanged)
                {
                    createSettingsFile(activeTeams, folder);
                }
            }

            var activeTeamsIDs = new List<int>();
            var rosters = new Dictionary<int, List<int>>();
            foreach (var team in activeTeams)
            {
                var id = -1;
                var name = team["Name"];
                if (tst.All(pair => pair.Value.Name != name))
                {
                    for (var i = 0; i < 30; i++)
                    {
                        if (!tst.ContainsKey(i))
                        {
                            id = i;
                            break;
                        }
                    }
                }
                else
                {
                    id = tst.Single(pair => pair.Value.Name == name).Key;
                }
                activeTeamsIDs.Add(Convert.ToInt32(team["ID"]));

                rosters[id] = new List<int>
                    {
                        Convert.ToInt32(team["Ros_PG"]),
                        Convert.ToInt32(team["Ros_SG"]),
                        Convert.ToInt32(team["Ros_SF"]),
                        Convert.ToInt32(team["Ros_PF"]),
                        Convert.ToInt32(team["Ros_C"])
                    };
                for (var i = 6; i <= 12; i++)
                {
                    var cur = Convert.ToInt32(team["Ros_S" + i.ToString()]);
                    if (cur != -1)
                    {
                        rosters[id].Add(cur);
                    }
                    else
                    {
                        break;
                    }
                }
                for (var i = 13; i <= 20; i++)
                {
                    var cur = Convert.ToInt32(team["Ros_R" + i.ToString()]);
                    if (cur != -1)
                    {
                        rosters[id].Add(cur);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            var validPlayers = players.FindAll(player => isValidPlayer(player, nba2KVersion));

            var endAt = nba2KVersion >= NBA2KVersion.NBA2K13 ? 19 : 20;

            var pw = new ProgressWindow("Please wait as player career stats are being imported...");
            pw.Show();

            await Task.Run(
                () =>
                    {
                        var count = validPlayers.Count;
                        var ppsList = new List<PastPlayerStats>();
                        for (var i = 0; i < count; i++)
                        {
                            var percentProgress = i * 100 / count;
                            if (percentProgress % 5 == 0)
                            {
                                Tools.AppInvoke(() => pw.SetProgressBarValue(percentProgress));
                            }
                            var player = validPlayers[i];
                            var playerID = Convert.ToInt32(player["ID"]);

                            var lastName = player["Last_Name"];
                            var firstName = player["First_Name"];

                            int pTeam;
                            var curTeam = new TeamStats();
                            try
                            {
                                pTeam = rosters.Single(r => r.Value.Contains(playerID)).Key;
                                curTeam = tst[pTeam];
                            }
                            catch (InvalidOperationException)
                            {
                                pTeam = -1;
                            }

                            if (!activeTeamsIDs.Contains(pTeam) && player["IsFA"] != "1")
                            {
                                if (pst.ContainsKey(playerID) && pst[playerID].LastName == lastName
                                    && pst[playerID].FirstName == firstName)
                                {
                                    pst[playerID].IsSigned = false;
                                    pst[playerID].TeamF = -1;
                                    pst[playerID].IsHidden = true;
                                }
                                continue;
                            }

                            #region Match Player

                            if (pst.ContainsKey(playerID)
                                && (pst[playerID].LastName != lastName || pst[playerID].FirstName != firstName))
                            {
                                var candidates =
                                    pst.Where(
                                        pair =>
                                        pair.Value.LastName == lastName && pair.Value.FirstName == firstName
                                        && pair.Value.IsHidden == false).ToList();
                                if (candidates.Count > 0)
                                {
                                    var found = false;
                                    var c2 = candidates.Where(pair => tst.ContainsKey(pair.Value.TeamF)).ToList();
                                    if (c2.Count() == 1)
                                    {
                                        playerID = c2.First().Value.ID;
                                        found = true;
                                    }
                                    else
                                    {
                                        var c4 =
                                            candidates.Where(pair => pair.Value.YearOfBirth.ToString() == player["BirthYear"]).ToList();
                                        if (c4.Count == 1)
                                        {
                                            playerID = c4.First().Value.ID;
                                            found = true;
                                        }
                                        else
                                        {
                                            if (pTeam != -1)
                                            {
                                                var c3 = candidates.Where(pair => pair.Value.TeamF == curTeam.ID).ToList();
                                                if (c3.Count == 1)
                                                {
                                                    playerID = c3.First().Value.ID;
                                                    found = true;
                                                }
                                            }
                                        }
                                    }
                                    if (!found)
                                    {
                                        var choices = new List<string>();
                                        foreach (var pair in candidates)
                                        {
                                            var choice = String.Format(
                                                "{0}: {1} {2} (Born {3}",
                                                pair.Value.ID,
                                                pair.Value.FirstName,
                                                pair.Value.LastName,
                                                pair.Value.YearOfBirth);
                                            if (pair.Value.IsSigned)
                                            {
                                                choice += String.Format(", plays in {0}", pair.Value.TeamF);
                                            }
                                            else
                                            {
                                                choice += ", free agent";
                                            }
                                            choice += ")";
                                            choices.Add(choice);
                                        }
                                        var message = String.Format(
                                            "{0}: {1} {2} (Born {3}",
                                            player["ID"],
                                            player["First_Name"],
                                            player["Last_Name"],
                                            player["BirthYear"]);
                                        if (pTeam != -1)
                                        {
                                            message += String.Format(", plays in {0}", curTeam.DisplayName);
                                        }
                                        else
                                        {
                                            message += ", free agent";
                                        }
                                        message += ")";
                                        ccw = new ComboChoiceWindow(message, choices);
                                        if (ccw.ShowDialog() != true)
                                        {
                                            continue;
                                        }
                                        else
                                        {
                                            playerID = Convert.ToInt32(ComboChoiceWindow.UserChoice.Split(':')[0]);
                                        }
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            else if (!pst.ContainsKey(playerID))
                            {
                                continue;
                            }

                            #endregion Match Player

                            var qr = "SELECT * FROM PastPlayerStats WHERE PlayerID = " + playerID + " ORDER BY \"SOrder\"";
                            var dt = MainWindow.DB.GetDataTable(qr);
                            dt.Rows.Cast<DataRow>().ToList().ForEach(dr => ppsList.Add(new PastPlayerStats(dr)));
                            for (var j = startAt; j < endAt; j++)
                            {
                                var statEntryID = player["StatY" + j];
                                if (statEntryID == "-1")
                                {
                                    continue;
                                }
                                var stats = playerStats.Single(d => d["ID"] == statEntryID);
                                var prevStats = new PastPlayerStats();
                                var teamID2 = stats["TeamID2"];
                                var teamID1 = stats["TeamID1"];
                                if (teamID2 == "-1")
                                {
                                    if (teamID1 != "-1")
                                    {
                                        prevStats.TeamFName = teams.Single(team => team["ID"] == teamID1)["Name"];
                                    }
                                }
                                else
                                {
                                    prevStats.TeamFName = teams.Single(team => team["ID"] == teamID2)["Name"];
                                    if (teamID1 != "-1")
                                    {
                                        prevStats.TeamSName = teams.Single(team => team["ID"] == teamID1)["Name"];
                                    }
                                }
                                prevStats.GP = Convert.ToUInt16(stats["GamesP"]);
                                prevStats.GS = Convert.ToUInt16(stats["GamesS"]);
                                prevStats.MINS = Convert.ToUInt16(stats["Minutes"]);
                                prevStats.PTS = Convert.ToUInt16(stats["Points"]);
                                prevStats.DREB = Convert.ToUInt16(stats["DRebs"]);
                                prevStats.OREB = Convert.ToUInt16(stats["ORebs"]);
                                prevStats.AST = Convert.ToUInt16(stats["Assists"]);
                                prevStats.STL = Convert.ToUInt16(stats["Steals"]);
                                prevStats.BLK = Convert.ToUInt16(stats["Blocks"]);
                                prevStats.TOS = Convert.ToUInt16(stats["TOs"]);
                                prevStats.FOUL = Convert.ToUInt16(stats["Fouls"]);
                                prevStats.FGM = Convert.ToUInt16(stats["FGMade"]);
                                prevStats.FGA = Convert.ToUInt16(stats["FGAtt"]);
                                try
                                {
                                    prevStats.TPM = Convert.ToUInt16(stats["3PTMade"]);
                                    prevStats.TPA = Convert.ToUInt16(stats["3PTAtt"]);
                                }
                                catch (KeyNotFoundException)
                                {
                                    prevStats.TPM = Convert.ToUInt16(stats["TPTMade"]);
                                    prevStats.TPA = Convert.ToUInt16(stats["TPTAtt"]);
                                }
                                prevStats.FTM = Convert.ToUInt16(stats["FTMade"]);
                                prevStats.FTA = Convert.ToUInt16(stats["FTAtt"]);
                                prevStats.PlayerID = playerID;
                                var yearF = 0;
                                if (nba2KVersion != NBA2KVersion.NBA2K12)
                                {
                                    yearF = Convert.ToInt32(stats["Year"]);
                                }
                                prevStats.SeasonName = nba2KVersion == NBA2KVersion.NBA2K12
                                                           ? seasonNames[j]
                                                           : String.Format("{0}-{1}", yearF - 1, yearF);
                                prevStats.IsPlayoff = false;
                                prevStats.Order = nba2KVersion == NBA2KVersion.NBA2K12 ? 20 - j : yearF;
                                prevStats.EndEdit();
                                ppsList.Add(prevStats);
                            }
                        }
                        Tools.AppInvoke(
                            () =>
                                {
                                    pw.SetProgressBarValue(99);
                                    pw.SetMessage("Please wait while the player career stats are being saved...");
                                });
                        SQLiteIO.SavePastPlayerStatsToDatabase(MainWindow.DB, ppsList);
                    });

            pw.CanClose = true;
            pw.Close();
            MainWindow.MWInstance.OnImportOldPlayerStatsCompleted(0);
        }