Exemplo n.º 1
0
        public static Page GetNowPage(string password = "")
        {
            if (password != AccessManager.AccessKey)
            {
                if (!AccessManager.GetPluginPermission(AccessManager.PluginPermission.PageManager_GetPage))
                {
                    throw new Exception("접근 권한이 없습니다.");
                }
            }

            return(nowpage);
        }
Exemplo n.º 2
0
        public static Scene GetNowScene(string password = "")
        {
            if (password != AccessManager.AccessKey)
            {
                if (!AccessManager.GetPluginPermission(AccessManager.PluginPermission.SceneManager_GetScene))
                {
                    throw new UnabletoAccessPermission();
                }
            }

            return(nowscene);
        }
Exemplo n.º 3
0
        public void Save(string key, string value, string password = "")
        {
            try
            {
                if (password != AccessManager.AccessKey)
                {
                    if (!AccessManager.GetPluginPermission(AccessManager.PluginPermission.OptionManager_Save))
                    {
                        throw new UnabletoAccessPermission();
                    }
                }

                Utility.SetIniValue("RTOption", key, value, ".\\data\\system\\option.ini");
            }
            catch (Exception ex)
            {
                Environment.ReportError(ex, AccessManager.AccessKey);
            }
        }
Exemplo n.º 4
0
        public string GetResFolder(string password = "")
        {
            try
            {
                if (password != AccessManager.AccessKey)
                {
                    if (!AccessManager.GetPluginPermission(AccessManager.PluginPermission.OptionManager_Get))
                    {
                        throw new UnabletoAccessPermission();
                    }
                }

                return(ResFolder);
            }
            catch (Exception ex)
            {
                Environment.ReportError(ex, AccessManager.AccessKey);
                return("");
            }
        }
Exemplo n.º 5
0
        public int GetAutoSaveSecond(string password = "")
        {
            try
            {
                if (password != AccessManager.AccessKey)
                {
                    if (!AccessManager.GetPluginPermission(AccessManager.PluginPermission.OptionManager_Get))
                    {
                        throw new UnabletoAccessPermission();
                    }
                }

                return(AutoSaveSecond);
            }
            catch (Exception ex)
            {
                Environment.ReportError(ex, AccessManager.AccessKey);
                return(0);
            }
        }
Exemplo n.º 6
0
        public void SaveAll(string password = "")
        {
            try
            {
                if (password != AccessManager.AccessKey)
                {
                    if (!AccessManager.GetPluginPermission(AccessManager.PluginPermission.OptionManager_SaveAll))
                    {
                        throw new UnabletoAccessPermission();
                    }
                }

                Utility.SetIniValue("RTOption", "lang", LangURL, ".\\data\\system\\option.ini");
                Utility.SetIniValue("RTOption", "res", ResFolder, ".\\data\\system\\option.ini");
                Utility.SetIniValue("RTOption", "sound", Sound.ToString().ToLower(), ".\\data\\system\\option.ini");
                Utility.SetIniValue("RTOption", "autosave", AutoSave.ToString().ToLower(), ".\\data\\system\\option.ini");
                Utility.SetIniValue("RTOption", "autosavesecond", AutoSaveSecond.ToString(), ".\\data\\system\\option.ini");
            }
            catch (Exception ex)
            {
                Environment.ReportError(ex, AccessManager.AccessKey);
            }
        }
Exemplo n.º 7
0
        public static void RemoveCheat(string Key, string password = "")
        {
            try
            {
                if (password != AccessManager.AccessKey)
                {
                    if (!AccessManager.GetPluginPermission(AccessManager.PluginPermission.Command_Remove_Cheat))
                    {
                        throw new UnabletoAccessPermission();
                    }
                }

                if (!Cheats.Keys.ToList().Contains(Key))
                {
                    throw new NotExistCheatKeyException();
                }

                Cheats.Remove(Key);
            }
            catch (Exception ex)
            {
                Environment.ReportError(ex, AccessManager.AccessKey);
            }
        }
Exemplo n.º 8
0
        public static void AppendCommand(string Key, CommandVoid func, string password = "")
        {
            try
            {
                if (password != AccessManager.AccessKey)
                {
                    if (!AccessManager.GetPluginPermission(AccessManager.PluginPermission.Command_Append_Command))
                    {
                        throw new UnabletoAccessPermission();
                    }
                }

                if (Cheats.Keys.ToList().Contains(Key))
                {
                    throw new UseCommandKeyException();
                }

                Cheats.Add(Key, func);
            }
            catch (Exception ex)
            {
                Environment.ReportError(ex, AccessManager.AccessKey);
            }
        }
Exemplo n.º 9
0
        public static void ReportError(Exception ex, string password = "")
        {
            if (password != AccessManager.AccessKey)
            {
                if (!AccessManager.GetPluginPermission(AccessManager.PluginPermission.Environment_ReportError))
                {
                    throw new UnabletoAccessPermission();
                }
            }

            if (RTAPI.WebAPI.CheckInternetConnection())
            {
                System.Collections.Specialized.NameValueCollection data = new System.Collections.Specialized.NameValueCollection();
                data.Add("entry.1674123617", ex.ToString());
                data.Add("entry.713681991", Version);
                data.Add("entry.521569291", "false");
                System.Net.WebClient wc = new System.Net.WebClient();
                wc.UploadValuesAsync(new Uri("https://docs.google.com/forms/d/1K2hLlZmlCjur28khh8HYSCjPpl4kLz6nifWEVXKE1sE/formResponse"), "POST", data, Guid.NewGuid().ToString());
            }
            LogManager.ExceptMessage(ex);
            frmError err = new frmError(ex.ToString());

            err.ShowDialog();
        }
Exemplo n.º 10
0
        public static void SetScene(Scene scene, string password = "")
        {
            try
            {
                if (password != AccessManager.AccessKey)
                {
                    if (!AccessManager.GetPluginPermission(AccessManager.PluginPermission.SceneManager_SetScene))
                    {
                        throw new UnabletoAccessPermission();
                    }
                }

                if (nowscene is RTUI.FakeScene)
                {
                    return;
                }
                else if (nowscene is RTUI.PickIconScene)
                {
                    return;
                }

                Scene ctrl     = scene;
                Scene oldscene = nowscene;

                ctrl.Size     = new Size(980, 680);
                ctrl.Location = new Point(0, 0);

                if (MainForm.Controls.Count != 0)
                {
                    if (MainForm.Controls[0] is Scene)
                    {
                        (MainForm.Controls[0] as Scene).OnClosed();
                    }
                }

                MainForm.Controls.Clear();
                MainForm.Controls.Add(ctrl);
                nowscene = ctrl;

                LogManager.SetScene(scene as Scene);

                if (ctrl is RTUI.FakeScene)
                {
                    if (oldscene != null)
                    {
                        oldscene.Dispose();
                    }
                    return;
                }
                else if (ctrl is RTUI.PickIconScene)
                {
                    if (oldscene != null)
                    {
                        oldscene.Dispose();
                    }
                    return;
                }

                if (OptionManager.Get().Sound)
                {
                    if (!isMain)
                    {
                        if (scene is RTUI.LogoScene)
                        {
                        }
                        else
                        {
                            if (isPlay && scene is PlayScene)
                            {
                                return;
                            }
                            player.Stop();
                            if (player.Stream != null)
                            {
                                player.Stream.Close();
                                player.Stream.Dispose();
                            }
                            player.Stream = ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\sounds.npk", "main.wav", 5, 7, 1, 6);
                            player.PlayLooping();
                            isMain = true;
                            return;
                        }
                    }
                    else
                    {
                        if (scene is PlayScene)
                        {
                            player.Stop();
                            if (player.Stream != null)
                            {
                                player.Stream.Close();
                                player.Stream.Dispose();
                            }
                            isMain = false;
                            isPlay = false;
                        }
                        else
                        {
                            return;
                        }
                    }

                    if (!isPlay)
                    {
                        if (scene is PlayScene)
                        {
                            player.Stop();
                            if (player.Stream != null)
                            {
                                player.Stream.Close();
                                player.Stream.Dispose();
                            }
                            player.Stream = ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\sounds.npk", "play.wav", 5, 7, 1, 6);
                            player.PlayLooping();
                            isPlay = true;
                        }
                    }
                    else
                    {
                        if (scene is PlayScene)
                        {
                        }
                        else
                        {
                            player.Stop();
                            if (player.Stream != null)
                            {
                                player.Stream.Close();
                                player.Stream.Dispose();
                            }
                            isPlay = false;
                        }
                    }
                }
                else
                {
                    player.Stop();
                    if (player.Stream != null)
                    {
                        player.Stream.Close();
                        player.Stream.Dispose();
                    }
                    isMain = false;
                    isPlay = false;
                }

                #region SoundManager 식 소리 처리 (현재 주석 처리)
                // sounds.npk 에 xml 로 거기에 재생목록 저장, SoundManager 에서 재생목록을 바탕으로 재생
                // 하지만 실패 (...) 추후 해결 방법을 알게 되면 수정할 것.

                //if (OptionManager.Get().Sound)
                //{
                //	if(!isPlay)
                //	{
                //		isPlay = true;

                //		//sound = new BackgroundWorker();
                //		//sound.WorkerSupportsCancellation = true;
                //		//sound.DoWork += delegate
                //		//{
                //			SoundManager.Start(SoundManager.PlayType.MAIN);
                //		//	return;
                //		//};
                //		//sound.RunWorkerAsync();

                //		if (oldscene != null) oldscene.Dispose();
                //		return;
                //	}

                //	if (oldscene is PlayScene)
                //	{
                //		if (nowscene is PlayScene)
                //		{
                //			// 무 필요
                //		}
                //		else
                //		{
                //			// 기존: play + 현재: def

                //			SoundManager.Stop();
                //			//sound = new BackgroundWorker();
                //			//sound.WorkerSupportsCancellation = true;
                //			//sound.DoWork += delegate
                //			//{
                //				SoundManager.Start(SoundManager.PlayType.MAIN);
                //				//return;
                //			//};
                //			//sound.RunWorkerAsync();

                //			if (oldscene != null) oldscene.Dispose();
                //			return;
                //		}
                //	}

                //	if (oldscene is PlayScene)
                //	{
                //		// 무 필요
                //	}
                //	else
                //	{
                //		if(nowscene is PlayScene)
                //		{
                //                        // 기존: def + 현재: play

                //                        SoundManager.Stop();
                //                        //sound = new BackgroundWorker();
                //                        //sound.WorkerSupportsCancellation = true;
                //                        //sound.DoWork += delegate
                //                        //{
                //                        SoundManager.Start(SoundManager.PlayType.PLAY);
                //				//return;
                //			//};
                //			//sound.RunWorkerAsync();

                //			if (oldscene != null) oldscene.Dispose();
                //			return;
                //		}
                //	}
                //}
                //else
                //{
                //	SoundManager.Stop();
                //}
                #endregion

                if (oldscene != null)
                {
                    oldscene.Dispose();
                }
            }
            catch (Exception ex)
            {
                Environment.ReportError(ex, AccessManager.AccessKey);
            }
        }
Exemplo n.º 11
0
        internal static CommandLineResult InitRouteTycoon(LogoScene ls = null)
        {
            try
            {
                if (ls != null)
                {
                    ls.Text = "Please wait...";
                    System.Threading.Thread.Sleep(300);
                }
                if (!Directory.Exists(Application.StartupPath + @"\data") && File.Exists(Application.StartupPath + @"\data.zip"))
                {
                    Directory.CreateDirectory(Application.StartupPath + @"\data");
                    ZipFile.ExtractToDirectory(Application.StartupPath + @"\data.zip", Application.StartupPath + @"\data");
                    File.Delete(Application.StartupPath + @"\data.zip");
                }
                else if (Directory.Exists(Application.StartupPath + @"\data") && File.Exists(Application.StartupPath + @"\data.zip"))
                {
                    Directory.Delete(Application.StartupPath + @"\data", true);
                    Directory.CreateDirectory(Application.StartupPath + @"\data");
                    ZipFile.ExtractToDirectory(Application.StartupPath + @"\data.zip", Application.StartupPath + @"\data");
                    File.Delete(Application.StartupPath + @"\data.zip");
                }
                else if (!Directory.Exists(Application.StartupPath + @"\\data"))
                {
                    if (ls != null)
                    {
                        ls.Text = "ERROR!";
                    }
                    MessageBox.Show("ERROR - 0x000001\nNot exist data folder", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    LogManager.Add(new Log()
                    {
                        Message = @"ROUTETYCOON BOOT ERROR\nERRCODE: 0x000001\nERRMESSAGE: Not exist data folder", type = Log.Type.ERROR, evt = Log.Event.MESSAGE
                    });
                    SceneManager.MainForm.ExitGame();
                }

                if (ls != null)
                {
                    ls.Text = "Option Loading...";
                    System.Threading.Thread.Sleep(300);
                }

                OptionManager.Get().Load(AccessManager.AccessKey);

                if (ls != null)
                {
                    ls.Text = "Font Reading...";
                    System.Threading.Thread.Sleep(200);
                }

                if (File.Exists(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\font.otf"))
                {
                    try
                    {
                        fonts.AddFontFile(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\font.otf");
                    }
                    catch (FileNotFoundException)
                    {
                        if (File.Exists(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\subfont.otf"))
                        {
                            fonts.AddFontFile(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\subfont.otf");
                        }
                        else if (File.Exists(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\subfont.ttf"))
                        {
                            fonts.AddFontFile(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\subfont.ttf");
                        }
                        else
                        {
                            if (ls != null)
                            {
                                ls.Text = "ERROR!";
                            }
                            MessageBox.Show("ERROR - 0x000002\nNot exist font.otf file", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            LogManager.Add(new Log()
                            {
                                Message = @"ROUTETYCOON BOOT ERROR\nERRCODE: 0x000002\nERRMESSAGE: Not exist font.otf file", type = Log.Type.ERROR, evt = Log.Event.MESSAGE
                            });
                            SceneManager.MainForm.ExitGame();
                        }
                    }
                }
                else if (File.Exists(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\font.ttf"))
                {
                    try
                    {
                        fonts.AddFontFile(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\font.ttf");
                    }
                    catch (FileNotFoundException)
                    {
                        if (File.Exists(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\subfont.otf"))
                        {
                            fonts.AddFontFile(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\subfont.otf");
                        }
                        else if (File.Exists(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\subfont.ttf"))
                        {
                            fonts.AddFontFile(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\subfont.ttf");
                        }
                        else
                        {
                            if (ls != null)
                            {
                                ls.Text = "ERROR!";
                            }
                            MessageBox.Show("ERROR - 0x000002\nNot exist font.otf file", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            LogManager.Add(new Log()
                            {
                                Message = @"ROUTETYCOON BOOT ERROR\nERRCODE: 0x000002\nERRMESSAGE: Not exist font.otf file", type = Log.Type.ERROR, evt = Log.Event.MESSAGE
                            });
                            SceneManager.MainForm.ExitGame();
                        }
                    }
                }
                else
                {
                    if (File.Exists(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\subfont.otf"))
                    {
                        fonts.AddFontFile(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\subfont.otf");
                    }
                    else if (File.Exists(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\subfont.ttf"))
                    {
                        fonts.AddFontFile(Application.StartupPath + $"\\data\\res\\{OptionManager.Get().ResFolder}\\subfont.ttf");
                    }
                    else
                    {
                        if (ls != null)
                        {
                            ls.Text = "ERROR!";
                        }
                        MessageBox.Show("ERROR - 0x000002\nNot exist font.otf file", "RouteTycoon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        LogManager.Add(new Log()
                        {
                            Message = @"ROUTETYCOON BOOT ERROR\nERRCODE: 0x000002\nERRMESSAGE: Not exist font.otf file", type = Log.Type.ERROR, evt = Log.Event.MESSAGE
                        });
                        SceneManager.MainForm.ExitGame();
                    }
                }

                if (ls != null)
                {
                    ls.Text = "Initialize Managers...";
                    System.Threading.Thread.Sleep(300);
                }
                PluginManager.LoadPlugins();
                ResourceManager.Init();
                NewsManager.Init();
                AccessManager.Init();
                AchievementManager.Init();
                TrainManager.Init();
                Command.Init();
                NetworkManager.Init();
                //SoundManager.Init();

                if (ls != null)
                {
                    ls.Text = "Checking Event...";
                    System.Threading.Thread.Sleep(400);
                }

                CommandLineResult res = CheckEvent();
                if (res == CommandLineResult.DEBUG_MODE)
                {
                    DebugMode = true;
                }
                else if (res == CommandLineResult.ERROR_LIST)
                {
                    System.Diagnostics.Process.Start("https://docs.google.com/spreadsheets/d/1w513ZXYd-YIZrn9Y9OMI86JGK1Cr3V59YP4wj0kua10/edit?usp=sharing");
                }

                if (DeveloperMode)
                {
                    DebugMode = true;
                    TextManager.Get().Set(OptionManager.Get().LangURL.Replace(".txf", ".xml"));
                }
                else
                {
                    TextManager.Get().Set(OptionManager.Get().LangURL);
                }

                if (ls != null)
                {
                    ls.Text = "Check SupportVersion...";
                }
                {                 // 지원 버전
                    if (!RTAPI.WebAPI.CheckInternetConnection())
                    {
                        UpdateAccept = false;
                        return(res);
                    }

                    string str = new System.Net.WebClient().DownloadString("https://www.dropbox.com/s/j8gy71f0qyarejy/support.txt?dl=1");

                    XmlDocument xml = new XmlDocument();
                    xml.LoadXml(str);

                    XmlNode versions = xml.SelectNodes("versions")[0];

                    foreach (XmlNode it in versions.SelectNodes("version"))
                    {
                        int  code   = Convert.ToInt32(it.Attributes["code"].Value);
                        bool update = Convert.ToBoolean(it.Attributes["update"].Value);

                        if (code == VersionInt)
                        {
                            UpdateAccept = update;
                            break;
                        }
                    }
                }
                return(res);
            }
            catch (Exception e)
            {
                ReportError(e, AccessManager.AccessKey);
                return(CommandLineResult.NONE);
            }
        }