public static OptionManager Get() { try { if (_Instance == null) { _Instance = new OptionManager(); } return(_Instance); } catch (Exception ex) { Environment.ReportError(ex, AccessManager.AccessKey); return(null); } }
private static void _Start(PlayType pt) { try { if (pt == PlayType.MAIN) { while (true) { player.Stream = ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\sounds.npk", Main[Main_Inx], 5, 7, 1, 6); player.PlaySync(); Main_Inx++; if (Main_Inx == Main.Count) { Main_Inx = 0; } } } else { while (true) { player.Stream = ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\sounds.npk", Play[Play_Inx], 5, 7, 1, 6); player.PlaySync(); Play_Inx++; if (Play_Inx == Play.Count) { Play_Inx = 0; } } } } catch (Exception ex) { Environment.ReportError(ex, AccessManager.AccessKey); } }
protected void AddControl(Page p) { PictureBox pb = new PictureBox(); pb.Name = "pbClose"; pb.Size = new Size(20, 20); pb.Location = new Point(10, 10); pb.SizeMode = PictureBoxSizeMode.StretchImage; imgClose = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "btn_close.png", 5, 7, 1, 6)); imgCloseSel = Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "btn_close_sel.png", 5, 7, 1, 6)); pb.MouseEnter += Pb_MouseEnter; pb.MouseLeave += Pb_MouseLeave; pb.Click += delegate { PageManager.Close(false, AccessManager.AccessKey); }; pb.BackColor = Color.Transparent; pb.Image = imgClose; p.Controls.Add(pb); p.MouseDown += Page_MouseDown; p.MouseMove += Page_MouseMove; }
public static bool Init() { string key_origin = string.Empty; try { StreamReader sr = new StreamReader($".\\data\\res\\{OptionManager.Get().ResFolder}\\data_color.dat", System.Text.Encoding.Default); string str; _colors.Clear(); Dictionary <string, string> tmp1 = new Dictionary <string, string>(); Dictionary <string, string> vars = new Dictionary <string, string>(); while ((str = sr.ReadLine()) != null) { if (str.Trim() == string.Empty) { continue; } if (str.IndexOf("//") == 0) { continue; } if (str.First() == '$') { string[] t = str.Split(':'); vars.Add(t[0].Replace("$", ""), t[1]); continue; } if (!str.Contains("=")) { continue; } string[] token = str.Split('='); bool isAlpha = false; if (token[0].Contains(".hex")) { key_origin = token[0].Replace(".hex", ""); } else if (token[0].Contains(".alpha")) { key_origin = token[0].Replace(".alpha", ""); isAlpha = true; } else { continue; } if (token[1].First() == '$') { token[1] = vars[token[1].Replace("$", "")]; } if (tmp1.Keys.ToList().Contains(key_origin)) { if (isAlpha) { _colors.Add(key_origin, Color.FromArgb(Convert.ToInt32(token[1]), ColorTranslator.FromHtml(tmp1[key_origin]))); } else { _colors.Add(key_origin, Color.FromArgb(Convert.ToInt32(tmp1[key_origin]), ColorTranslator.FromHtml(token[1]))); } } else { tmp1.Add(key_origin, token[1]); } } return(true); } catch (Exception ex) { LogManager.Add(new Log() { Message = key_origin, evt = Log.Event.MESSAGE, type = Log.Type.ERROR }); Environment.ReportError(ex, AccessManager.AccessKey); return(false); } }
protected void Draw(PaintEventArgs e) { DoubleBuffered = true; e.Graphics.DrawImage(Image.FromStream(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\images.npk", "play_topbar.png", 5, 7, 1, 6)), 0, 0, Width, 40); if (IconImg != null) { e.Graphics.DrawImage(IconImg, 760, 5, 30, 30); } if (Title != "") { Size s = Environment.CalcStringSize(Title, new Font(Environment.Font, 14)); e.Graphics.DrawString(Title, new Font(Environment.Font, 14), new SolidBrush(ResourceManager.Get("page.title")), new Rectangle(new Point(Width - 45 - s.Width, 6), s)); } }
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); } }
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); } }
public static void Init() { try { player.Stop(); Main_Inx = 0; Play_Inx = 0; Main = new List <string>(); Play = new List <string>(); player.Dispose(); player = new System.Media.SoundPlayer(); using (StreamReader sr = new StreamReader(ResourceManager.Get($".\\data\\res\\{OptionManager.Get().ResFolder}\\sounds.npk", "sounds.xml", 5, 7, 1, 6), Encoding.Default)) { XmlDocument xml = new XmlDocument(); xml.LoadXml(sr.ReadToEnd()); XmlNode sounds = xml.SelectNodes("Sounds")[0]; XmlNode main = sounds.SelectNodes("Main")[0]; foreach (XmlNode it in main.SelectNodes("Sound")) { Main.Add(it.Attributes["Name"].Value); } XmlNode play = sounds.SelectNodes("Play")[0]; foreach (XmlNode it in play.SelectNodes("Sound")) { Play.Add(it.Attributes["Name"].Value); } } } catch (Exception ex) { Environment.ReportError(ex, AccessManager.AccessKey); } }