Ejemplo n.º 1
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            LoginBtn.Enabled     = false;
            LoginTimeOut.Enabled = true;
            if (!_connection.IsConnected)
            {
                if (!Program.ServerConnection.Connect(Program.Config.ServerAddress, Program.Config.ServerPort))
                {
                    MessageBox.Show(Program.LanguageManager.Translation.pMsbErrorToServer);
                    ResetTimeOut();
                    return;
                }
            }
            if (UsernameInput.Text == "")
            {
                MessageBox.Show(Program.LanguageManager.Translation.LoginMsb2);
                return;
            }
            if (PasswordInput.Text == "")
            {
                MessageBox.Show(Program.LanguageManager.Translation.LoginMsb3);
                return;
            }

            _authenticator.Authenticate(UsernameInput.Text, LauncherHelper.EncodePassword(PasswordInput.Text));
            if (AutoLoginCheckBox.Checked)
            {
                _configuration.DefaultUsername = UsernameInput.Text;
                _configuration.Password        = LauncherHelper.EncodePassword(PasswordInput.Text);
                _configuration.AutoLogin       = AutoLoginCheckBox.Checked;
                _configuration.Save(Program.ConfigurationFilename);
            }
        }
Ejemplo n.º 2
0
        public Host(bool options, bool isranked)
        {
            InitializeComponent();

            if (options)
            {
                TimeLimit.SelectedItem = Program.Config.TimeLimit;
                BanList.SelectedItem   = Program.Config.BanList;
                Mode.SelectedItem      = Program.Config.Mode;
                GameName.Text          = Program.Config.GameName;
                CardRules.SelectedItem = Program.Config.CardRules;
                Priority.Checked       = Program.Config.EnablePrority;
                ShuffleDeck.Checked    = Program.Config.DisableShuffleDeck;
                CheckDeck.Checked      = Program.Config.DisableCheckDeck;
                BanList.Items.AddRange(LauncherHelper.GetBanListArray());
            }
            else
            {
                TimeLimit.SelectedIndex = 0;
                CardRules.SelectedIndex = 0;
                Mode.SelectedIndex      = 0;
                GameName.Text           = LauncherHelper.GenerateString().Substring(0, 5);
                BanList.Items.AddRange(LauncherHelper.GetBanListArray());
                BanList.SelectedIndex = 0;
            }
            Mode.SelectedIndexChanged += DuelModeChanged;
            if (!isranked)
            {
                CardRules.SelectedIndexChanged += new EventHandler(CardRulesChanged);
            }
            ApplyTranslation();
        }
Ejemplo n.º 3
0
 private void GameBtn_Click(object sender, EventArgs e)
 {
     LauncherHelper.GenerateConfig("ygopro:/" + Program.Config.ServerAddress + "/" + Program.Config.GamePort + "/20000,U,Replay");
     if (Name == "Decks")
     {
         LauncherHelper.RunGame("-d");
     }
     else
     {
         if (FileList.SelectedItem == null)
         {
             MessageBox.Show("Choose a replay first!");
             return;
         }
         string replayDir = (Program.Config.LauncherDir == "" ? Path.GetDirectoryName(Application.ExecutablePath) + "/" : "") + FileLocation;
         if (!Directory.Exists(replayDir))
         {
             MessageBox.Show("Replay directory doesn't exist!");
             return;
         }
         string fileName = replayDir + FileList.SelectedItem + ".yrp";
         if (!File.Exists(fileName))
         {
             MessageBox.Show("Selected file does not exist!");
             return;
         }
         string tempFile = replayDir + "000000000000000000000000000000000000000000000.yrp";
         if (File.Exists(tempFile))
         {
             File.Delete(tempFile);
         }
         File.Copy(fileName, tempFile);
         LauncherHelper.RunGame("-r", (evSender, evArgs) => File.Delete(tempFile));
     }
 }
Ejemplo n.º 4
0
        private void HostBtn_Click(object sender, EventArgs e)
        {
            Host form = new Host(false, (ServerTabs.SelectedTab.Name == "Ranked"));

            if (ServerTabs.SelectedTab.Name == "Ranked")
            {
                form.Mode.Items.Clear();
                form.Mode.Items.AddRange(new object[] { "Match", "Tag" });
                form.Mode.SelectedItem     = "Match";
                form.BanList.SelectedIndex = 0;
                form.BanList.Enabled       = false;
                form.TimeLimit.Items.Clear();
                form.TimeLimit.Items.Add("Server Defualt");
                form.TimeLimit.SelectedItem = "Server Defualt";
                form.TimeLimit.Enabled      = false;
                form.Priority.Enabled       = false;
                form.ShuffleDeck.Enabled    = false;
                form.CheckDeck.Enabled      = false;
                form.LifePoints.Enabled     = false;
                form.CardRules.Items.Clear();
                form.CardRules.Items.AddRange(new object[] { "OCG/TCG", "TCG", "OCG" });
                form.CardRules.SelectedItem = "OCG/TCG";
            }

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                LauncherHelper.GenerateConfig(form.GenerateURI(Program.Config.ServerAddress, Program.Config.GamePort.ToString(), (ServerTabs.SelectedTab.Name == "Ranked") ? true : false));
                LauncherHelper.RunGame("-j");
            }
        }
Ejemplo n.º 5
0
        private void BackUpBtn_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Do you want to back up the current game Textures?", "Backup Textures", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                if (!ThemeExists("Backup Theme"))
                {
                    AddTheme("Backup Theme");
                }
                SelectedTheme            = "Backup Theme";
                ThemeSelect.SelectedItem = "Backup Theme";

                foreach (ContentType type in ItemKeys())
                {
                    if (type != ContentType.Music && type != ContentType.Sound_Effects)
                    {
                        try
                        {
                            string GeneratedString = LauncherHelper.GenerateString();
                            File.Copy(Data[type].GameItem, Data[type].AssetPath + GeneratedString + Data[type].FileType);
                            AddThemeItem(type, Data[type].AssetPath + GeneratedString + Data[type].FileType, GeneratedString);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
                RefreshList();
                RefreshInstalledThemeItems();
                SaveTheme("Backup Theme");
                ThemeSelect.Items.Add("Backup Theme");
                ThemeSelect.SelectedItem = "Backup Theme";
            }
        }
Ejemplo n.º 6
0
        public void LoadRoom(object sender, EventArgs e)
        {
            ListView     rooms = (ServerTabs.SelectedTab.Name == "Ranked" ? RankedRooms : listRooms);
            ListViewItem item  = rooms.SelectedItems[0];

            LauncherHelper.GenerateConfig(item.SubItems[8].Text);
            LauncherHelper.RunGame("-j");
        }
Ejemplo n.º 7
0
        private void QuickBtn_Click(object sender, EventArgs e)
        {
            Host form = new Host(false, false);

            form.CardRules.Text         = Program.Config.CardRules;
            form.Mode.Text              = Program.Config.Mode;
            form.Priority.Checked       = Program.Config.EnablePrority;
            form.CheckDeck.Checked      = Program.Config.DisableCheckDeck;
            form.ShuffleDeck.Checked    = Program.Config.DisableShuffleDeck;
            form.LifePoints.Text        = Program.Config.Lifepoints;
            form.GameName.Text          = Program.Config.GameName;
            form.BanList.SelectedItem   = Program.Config.BanList;
            form.TimeLimit.SelectedItem = Program.Config.TimeLimit;

            LauncherHelper.GenerateConfig(form.GenerateURI(Program.Config.ServerAddress, Program.Config.GamePort.ToString(), (ServerTabs.SelectedTab.Name == "Ranked") ? true : false));
            LauncherHelper.RunGame("-j");
            return;
        }
Ejemplo n.º 8
0
 private void ImportBtn_Click(object sender, EventArgs e)
 {
     string[] importfiles = LauncherHelper.OpenFileWindow("Import " + Text, "", "(*" + FileType + ")|*" + FileType + ";", true);
     if (importfiles != null)
     {
         foreach (string file in importfiles)
         {
             try
             {
                 File.Copy(file, FileLocation + Path.GetFileNameWithoutExtension(file) + FileType);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
         RefreshFileList();
     }
 }
Ejemplo n.º 9
0
 private void RegisterBtn_Click(object sender, EventArgs e)
 {
     if (ConfirmInput.Text != PasswordInput.Text)
     {
         MessageBox.Show("Confirm password is wrong.");
         return;
     }
     if (ConfirmInput.Text == "")
     {
         MessageBox.Show(Program.LanguageManager.Translation.RegistMsb1);
         return;
     }
     if (PasswordInput.Text == "")
     {
         MessageBox.Show(Program.LanguageManager.Translation.RegistMsb2);
         return;
     }
     if (UsernameInput.Text == "")
     {
         MessageBox.Show(Program.LanguageManager.Translation.RegistMsb3);
         return;
     }
     Program.ServerConnection.SendPacket("REGISTER||" + UsernameInput.Text + "||" + LauncherHelper.EncodePassword(PasswordInput.Text) + "||" + LauncherHelper.GetUID());
 }
Ejemplo n.º 10
0
        public Main_frm()
        {
            InitializeComponent();

            LauncherHelper.CardManager = new CardDatabase.CardsManager();
            LauncherHelper.CardManager.Init();

            char[] version = Program.Version.ToCharArray();
            this.Text = this.Text + " v" + version[0] + "." + version[1] + "." + version[2];

            TabPage    FileManager = new TabPage("File Manager");
            TabControl FileControl = new TabControl();

            FileControl.Dock = DockStyle.Fill;

            TabPage decktab = new TabPage()
            {
                Name = "Decks", Text = "Decks"
            };

            decktab.Controls.Add(new FileManager_frm("Decks", Program.Config.LauncherDir + "deck/", ".ydk"));

            TabPage replaytab = new TabPage()
            {
                Name = "Replays", Text = "Replays"
            };

            replaytab.Controls.Add(new FileManager_frm("Replays", Program.Config.LauncherDir + "replay/", ".yrp"));
            FileControl.TabPages.AddRange(new TabPage[] { decktab, replaytab });

            FileManager.Controls.Add(FileControl);

            TabPage ServerTab = new TabPage()
            {
                Text = Program.Config.ServerName, Name = Program.Config.ServerName
            };

            ServerTab.Controls.Add(new ServerInterface_frm(Program.Config.ServerName));

            TabPage CustomizeTab = new TabPage()
            {
                Text = "Customize", Name = "Customize"
            };

            CustomizeTab.Controls.Add(new Customize_frm());

            TabPage AboutTab = new TabPage()
            {
                Text = "About", Name = "About"
            };

            AboutTab.Controls.Add(new About_frm());

            if (Program.UserInfo.Rank > 0)
            {
                TabPage AdminTab = new TabPage()
                {
                    Text = "Admin Panel", Name = "Admin"
                };
                AdminTab.Controls.Add(new Admin_frm());


                ServerControl.TabPages.AddRange(new TabPage[] { ServerTab,
                                                                CreateBrowserWindow("Ranking"),
                                                                CreateBrowserWindow("Chat"),
                                                                CreateBrowserWindow("Youtube"),
                                                                FileManager, CustomizeTab, AboutTab, AdminTab });
            }
            else
            {
                ServerControl.TabPages.AddRange(new TabPage[] { ServerTab,
                                                                CreateBrowserWindow("Ranking"),
                                                                CreateBrowserWindow("Chat"),
                                                                CreateBrowserWindow("Youtube"),
                                                                FileManager, CustomizeTab, AboutTab });
            }
            Program.ServerConnection.ServerMessage += new NetClient.ServerResponse(ServerMessage);
            ConnectionCheck.Tick += new EventHandler(CheckConnection);
            ServerControl.SelectedIndexChanged += new EventHandler(NavigateOnClick);

            LauncherHelper.LoadBanlist();
        }
Ejemplo n.º 11
0
        public string GenerateURI(string server, string port, bool isranked)
        {
            string gamestring = null;

            if ((this.CardRules.Text == "OCG"))
            {
                gamestring = "0";
            }
            else if ((this.CardRules.Text == "TCG"))
            {
                gamestring = "1";
            }
            else if ((this.CardRules.Text == "OCG/TCG"))
            {
                gamestring = "2";
            }
            else if ((this.CardRules.Text == "Anime"))
            {
                gamestring = "4";
            }
            else if ((this.CardRules.Text == "Turbo Duel"))
            {
                gamestring = "5";
            }
            else
            {
                gamestring = "3";
            }
            if ((this.Mode.Text == "Single"))
            {
                gamestring = gamestring + "0";
            }
            else if ((this.Mode.Text == "Match"))
            {
                gamestring = gamestring + "1";
            }
            else
            {
                gamestring = gamestring + "2";
            }

            gamestring += LauncherHelper.GetBanListValue(BanList.SelectedItem.ToString());

            gamestring += TimeLimit.SelectedIndex;

            if ((Priority.Checked))
            {
                gamestring = gamestring + "T";
            }
            else
            {
                gamestring = gamestring + "O";
            }
            if ((CheckDeck.Checked))
            {
                gamestring = gamestring + "T";
            }
            else
            {
                gamestring = gamestring + "O";
            }
            if ((ShuffleDeck.Checked))
            {
                gamestring = gamestring + "T";
            }
            else
            {
                gamestring = gamestring + "O";
            }

            gamestring = gamestring + LifePoints.Text + "," + (isranked ? "R" : "U") + "," + GameName.Text;

            return("ygopro:/" + server + "/" + port + "/" + gamestring);
        }
Ejemplo n.º 12
0
        private void InternalRoomCreated(RoomInfos room)
        {
            if (m_rooms.ContainsKey(room.RoomName))
            {
                return;
            }

            ListViewItem item = new ListViewItem(room.RoomName);

            m_rooms.Add(room.RoomName, item);

            string roomtype = "Unranked";

            if (room.isRanked)
            {
                roomtype = "Ranked";
            }
            item.SubItems.Add(roomtype);

            item.SubItems.Add(LauncherHelper.GetBanListFromInt(room.BanList));

            item.SubItems.Add((room.Timer == 0 ? "3 mins":"5 mins"));

            string rule = "TCG/OCG";

            if (room.Rule == 1)
            {
                rule = "TCG";
            }
            if (room.Rule == 0)
            {
                rule = "OCG";
            }
            if (room.Rule == 4)
            {
                rule = "Anime";
            }
            if (room.Rule == 5)
            {
                rule = "Turbo Duel";
            }
            item.SubItems.Add(rule);

            string type = "Single";

            if (room.Mode == 1)
            {
                type = "Match";
            }
            if (room.Mode == 2)
            {
                type = "Tag";
            }
            item.SubItems.Add(type);



            item.SubItems.Add(room.Started ? "Started" : "Waiting");

            item.SubItems.Add(room.Players);
            item.SubItems.Add(room.GenerateURI(Program.Config.ServerAddress, Program.Config.ServerPort));
            bool illegal = room.NoCheckDeck || room.NoShuffleDeck || room.EnablePriority || (room.Mode == 2) ? room.StartLp != 16000 : room.StartLp != 8000 || room.StartHand != 5 || room.DrawCount != 1;


            item.BackColor = room.Started ? Color.LightGray :
                             (illegal ? Color.LightCoral :
                              (room.Rule == 4 ? Color.Violet:
                               (room.Rule == 5 ? Color.Gold:
                                (room.Mode == 2 ? Color.LightGreen :
                                 (room.Mode == 1 ? Color.LightSteelBlue :
                                  Color.LightBlue)))));

            ListView rooms = (ServerTabs.SelectedTab.Name == "Ranked" ? RankedRooms : listRooms);

            if (FilterActive.Checked)
            {
                if (m_rooms[room.RoomName].SubItems[6].Text.Contains("Waiting") &&
                    m_rooms[room.RoomName].SubItems[1].Text.Contains(ServerTabs.SelectedTab.Name))
                {
                    if (m_rooms[room.RoomName].SubItems[7].Text.ToLower().Contains(FilterTextBox.Text.ToLower()) ||
                        m_rooms[room.RoomName].SubItems[0].Text.ToLower().Contains(FilterTextBox.Text.ToLower()) ||
                        FilterTextBox.Text == "Search" || FilterTextBox.Text == "")
                    {
                        rooms.Items.Add(m_rooms[room.RoomName]);
                    }
                }
            }
            else
            {
                if (m_rooms[room.RoomName].SubItems[1].Text.Contains(ServerTabs.SelectedTab.Name))
                {
                    if (m_rooms[room.RoomName].SubItems[7].Text.ToLower().Contains(FilterTextBox.Text.ToLower()) ||
                        m_rooms[room.RoomName].SubItems[0].Text.ToLower().Contains(FilterTextBox.Text.ToLower()) ||
                        FilterTextBox.Text == "Search" || FilterTextBox.Text == "")
                    {
                        rooms.Items.Add(m_rooms[room.RoomName]);
                    }
                }
            }
        }
Ejemplo n.º 13
0
 private void ReplaysBtn_Click(object sender, EventArgs e)
 {
     LauncherHelper.GenerateConfig("ygopro:/" + Program.Config.ServerAddress + "/" + Program.Config.GamePort + "/20000,U,Replay");
     LauncherHelper.RunGame("-r");
 }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            foreach (string arg in args)
            {
                if (arg == "-r")
                {
                    int timeout = 0;
                    while (LauncherHelper.checkInstance())
                    {
                        if (timeout == 3)
                        {
                            if (MessageBox.Show(LanguageManager.Translation.pmsbProgRun) == DialogResult.OK)
                            {
                                return;
                            }
                        }
                        Thread.Sleep(500);
                        timeout++;
                    }
                }
            }

            Config = new Configuration();
            Config.Load(Program.ConfigurationFilename);

            if (File.Exists("ygopro_vs.exe") && !File.Exists("devpro.dll"))
            {
                File.Copy("ygopro_vs.exe", "devpro.dll");
                File.Delete("ygopro_vs.exe");
                Config.GameExe = "devpro.dll";
                Config.Save(ConfigurationFilename);
            }

            LanguageManager = new LanguageManager();
            //LanguageManager.Save("English");
            LanguageManager.Load(Config.Language);

            if (LauncherHelper.checkInstance())
            {
                if (MessageBox.Show(LanguageManager.Translation.pmsbProgRun) == DialogResult.OK)
                {
                    return;
                }
            }

            UserInfo         = new UserData();
            ServerConnection = new NetClient();

            if (!Config.DebugMode)
            {
                if (CheckUpdates())
                {
                    return;
                }

                CheckServerInfo();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            LoginService = new Authenticator(Config.DefaultUsername, Config.Password, ServerConnection, UserInfo);

            if (!ServerConnection.Connect(Config.ServerAddress, Config.ServerPort))
            {
                MessageBox.Show(LanguageManager.Translation.pMsbErrorToServer);
            }

            if (Config.AutoLogin && Config.DefaultUsername.Length < 15)
            {
                LoginService.Authenticate();
                Thread.Sleep(2000);
            }

            if (UserInfo.Username == "" && UserInfo.LoginKey == "")
            {
                LoginWindow = new Login_frm(Config, ServerConnection, LoginService);

                if (LoginWindow.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            if (!ServerConnection.IsConnected)
            {
                return;
            }

            if (UserInfo.Username != "" && UserInfo.LoginKey != "")
            {
                Application.Run(new Main_frm());
            }
            else
            {
                Config.AutoLogin = false;
                Config.Save(ConfigurationFilename);
                MessageBox.Show(LanguageManager.Translation.pMsbBadLog);
            }
        }