コード例 #1
0
ファイル: Program.cs プロジェクト: Jonqora/SMAPI
        /// <summary>Initialize SMAPI and launch the game.</summary>
        /// <param name="args">The command-line arguments.</param>
        /// <remarks>This method is separate from <see cref="Main"/> because that can't contain any references to assemblies loaded by <see cref="CurrentDomain_AssemblyResolve"/> (e.g. via <see cref="Constants"/>), or Mono will incorrectly show an assembly resolution error before assembly resolution is set up.</remarks>
        private static void Start(string[] args)
        {
            // get flags
            bool writeToConsole = !args.Contains("--no-terminal") && Environment.GetEnvironmentVariable("SMAPI_NO_TERMINAL") == null;

            // get mods path
            string modsPath;

            {
                string rawModsPath = null;

                // get from command line args
                int pathIndex = Array.LastIndexOf(args, "--mods-path") + 1;
                if (pathIndex >= 1 && args.Length >= pathIndex)
                {
                    rawModsPath = args[pathIndex];
                }

                // get from environment variables
                if (string.IsNullOrWhiteSpace(rawModsPath))
                {
                    rawModsPath = Environment.GetEnvironmentVariable("SMAPI_MODS_PATH");
                }

                // normalise
                modsPath = !string.IsNullOrWhiteSpace(rawModsPath)
                    ? Path.Combine(Constants.ExecutionPath, rawModsPath)
                    : Constants.DefaultModsPath;
            }

            // load SMAPI
            using SCore core = new SCore(modsPath, writeToConsole);
            core.RunInteractively();
        }
コード例 #2
0
        /*********
        ** Public methods
        *********/
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            // get SMAPI core types
            SCore      core       = SCore.Instance;
            LogManager logManager = core.GetType().GetField("LogManager", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(core) as LogManager;

            if (logManager == null)
            {
                this.Monitor.Log($"Can't access SMAPI's internal log manager. Error-handling patches won't be applied.", LogLevel.Error);
                return;
            }

            // apply patches
            new GamePatcher(this.Monitor).Apply(
                new EventErrorPatch(logManager.MonitorForGame),
                new DialogueErrorPatch(logManager.MonitorForGame, this.Helper.Reflection),
                new ObjectErrorPatch(),
                new LoadErrorPatch(this.Monitor, this.OnSaveContentRemoved),
                new ScheduleErrorPatch(logManager.MonitorForGame),
                new UtilityErrorPatches()
                );

            // hook events
            this.Helper.Events.GameLoop.SaveLoaded += this.OnSaveLoaded;
        }
コード例 #3
0
        /// <summary>Initialize SMAPI and launch the game.</summary>
        /// <param name="args">The command-line arguments.</param>
        /// <remarks>This method is separate from <see cref="Main"/> because that can't contain any references to assemblies loaded by <see cref="CurrentDomain_AssemblyResolve"/> (e.g. via <see cref="Constants"/>), or Mono will incorrectly show an assembly resolution error before assembly resolution is set up.</remarks>
        private static void Start(string[] args)
        {
            // get flags from arguments
            bool writeToConsole = !args.Contains("--no-terminal");

            // get mods path from arguments
            string modsPath = null;

            {
                int pathIndex = Array.LastIndexOf(args, "--mods-path") + 1;
                if (pathIndex >= 1 && args.Length >= pathIndex)
                {
                    modsPath = args[pathIndex];
                    if (!string.IsNullOrWhiteSpace(modsPath) && !Path.IsPathRooted(modsPath))
                    {
                        modsPath = Path.Combine(Constants.ExecutionPath, modsPath);
                    }
                }
                if (string.IsNullOrWhiteSpace(modsPath))
                {
                    modsPath = Constants.DefaultModsPath;
                }
            }

            // load SMAPI
            using (SCore core = new SCore(modsPath, writeToConsole))
                core.RunInteractively();
        }
コード例 #4
0
ファイル: UpdateManger.cs プロジェクト: komlahv/Cracked-unity
    // Use this for initialization
    void Start()
    {
        Life     = FindObjectOfType <LifeManager>();
        score    = FindObjectOfType <SCore>();
        Player   = FindObjectOfType <BallMotor>();
        PlayerNo = PlayerPrefs.GetInt("PlayerNO");
        StartCoroutine("LessLifeCo");



        if (PlayerNo == 1)
        {
            GameObject obnew = (GameObject)Instantiate(EggHelmet, Hatter.transform.position, Player.transform.rotation);
            obnew.transform.parent = costume.gameObject.transform;
            Debug.Log("Helmet Spawned");
        }

        else if (PlayerNo == 2)
        {
            GameObject obnew = (GameObject)Instantiate(EggHat, Hatter.transform.position, Player.transform.rotation);
            obnew.transform.parent = costume.gameObject.transform;
            Debug.Log("HAt Spawned");
        }

        else
        {
            GameObject obnew = (GameObject)Instantiate(EggNULL, Player.transform.position, Player.transform.rotation);
            obnew.transform.parent = costume.gameObject.transform;
            Debug.Log("Null Spawned");
        }
    }
コード例 #5
0
        /// <summary>
        /// Stores message for relay.
        /// </summary>
        /// <param name="queueName">Queue name where to store message.</param>
        /// <param name="id">Message ID. Guid value is suggested.</param>
        /// <param name="envelopeID">Envelope ID_(MAIL FROM: ENVID).</param>
        /// <param name="date">Message date.</param>
        /// <param name="message">Message to store. Message will be readed from current position of stream.</param>
        /// <param name="targetHost">Target host or IP where to send message. This value can be null, then DNS MX o A record is used to deliver message.</param>
        /// <param name="sender">Sender address to report to target server.</param>
        /// <param name="to">Message recipient address.</param>
        /// <param name="originalRecipient">Original recipient(RCPT TO: ORCPT).</param>
        /// <param name="notify">DSN notify condition.</param>
        /// <param name="ret">Specifies what parts of message are returned in DSN report.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>queueName</b>,<b>id</b>,<b>message</b> or <b>to</b> is null.</exception>
        /// <exception cref="ArgumentException">Is raised when any of the argumnets has invalid value.</exception>
        private void StoreRelayMessage(string queueName, string id, string envelopeID, DateTime date, Stream message, HostEndPoint targetHost, string sender, string to, string originalRecipient, SMTP_DSN_Notify notify, SMTP_DSN_Ret ret)
        {
            if (queueName == null)
            {
                throw new ArgumentNullException("queueName");
            }
            if (queueName == "")
            {
                throw new ArgumentException("Argumnet 'queueName' value must be specified.");
            }
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (id == "")
            {
                throw new ArgumentException("Argument 'id' value must be specified.");
            }
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }
            if (to == null)
            {
                throw new ArgumentNullException("to");
            }
            if (to == "")
            {
                throw new ArgumentException("Argument 'to' value must be specified.");
            }

            string path = m_pVirtualServer.MailStorePath + queueName;

            // Check if Directory exists, if not Create
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            // Create relay message.
            using (FileStream fs = File.Create(API_Utlis.PathFix(path + "\\" + id + ".eml")))
            {
                SCore.StreamCopy(message, fs);

                // Create message info file for the specified relay message.
                RelayMessageInfo messageInfo = new RelayMessageInfo(
                    envelopeID,
                    sender,
                    to,
                    originalRecipient,
                    notify,
                    ret,
                    date,
                    false,
                    targetHost
                    );
                File.WriteAllBytes(API_Utlis.PathFix(path + "\\" + id + ".info"), messageInfo.ToByte());
            }
        }
コード例 #6
0
        /// <summary>Get the monitor with which to log game errors.</summary>
        private IMonitor GetMonitorForGame()
        {
            SCore      core       = SCore.Instance;
            LogManager logManager = core.GetType().GetField("LogManager", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(core) as LogManager;

            if (logManager == null)
            {
                this.Monitor.Log("Can't access SMAPI's internal log manager. Some game errors may be reported as being from Error Handler.", LogLevel.Error);
            }

            return(logManager?.MonitorForGame ?? this.Monitor);
        }
コード例 #7
0
        /// <summary>
        /// Loads specified virtual server API.
        /// </summary>
        /// <param name="assembly">API assembly name.</param>
        /// <param name="type">API type name.</param>
        /// <param name="initString">API init string</param>
        /// <returns></returns>
        internal IMailServerApi LoadApi(string assembly, string type, string initString)
        {
            string apiAssemblyPath = "";

            if (File.Exists(SCore.PathFix(m_StartupPath + "\\" + assembly)))
            {
                apiAssemblyPath = SCore.PathFix(m_StartupPath + "\\" + assembly);
            }
            else
            {
                apiAssemblyPath = SCore.PathFix(assembly);
            }

            Assembly ass = Assembly.LoadFile(apiAssemblyPath);

            return((IMailServerApi)Activator.CreateInstance(ass.GetType(type), new object[] { initString }));
        }
コード例 #8
0
ファイル: SMainActivity.cs プロジェクト: ZaneYork/SMAPI
        public void OnCreatePartTwo(int retry = 0)
        {
            try
            {
                Game1 game1 = (Game1)typeof(MainActivity).GetField("_game1", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(this);
                if (game1 != null)
                {
                    // game1.Exit();
                }

                new SGameConsole();

                Program.Main(null);
                string modPath = null;
                if (System.IO.File.Exists(Constants.ApiUserConfigPath))
                {
                    var settings = JsonConvert.DeserializeObject <Framework.Models.SConfig>(System.IO.File.ReadAllText(Constants.ApiUserConfigPath));
                    modPath = settings.ModsPath;
                    Constants.HarmonyEnabled = !settings.DisableMonoMod;
                    Constants.RewriteMissing = settings.RewriteMissing;
                }

                if (string.IsNullOrWhiteSpace(modPath))
                {
                    modPath = "StardewValley/Mods";
                }

                this.core = new SCore(System.IO.Path.Combine(EarlyConstants.StorageBasePath, modPath), false);
                this.core.RunInteractively();
                typeof(MainActivity).GetField("_game1", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(this, this.core.Game);

                this.SetContentView((View)this.core.Game.Services.GetService(typeof(View)));

                this.CheckUsingServerManagedPolicy();
            }
            catch when(retry < 3)
            {
                void RetryStart()
                {
                    Thread.Sleep(100);
                    SMainActivity.Instance.OnCreatePartTwo(retry + 1);
                }

                new Thread(RetryStart).Start();
            }
コード例 #9
0
        private void StoreRelayMessage(string queueName, string id, string envelopeID, DateTime date, Stream message, HostEndPoint targetHost, string sender, string to, string originalRecipient, SMTP_DSN_Notify notify, SMTP_DSN_Ret ret)
        {
            if (queueName == null)
            {
                throw new ArgumentNullException("queueName");
            }
            if (queueName == "")
            {
                throw new ArgumentException("Argumnet 'queueName' value must be specified.");
            }
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (id == "")
            {
                throw new ArgumentException("Argument 'id' value must be specified.");
            }
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }
            if (to == null)
            {
                throw new ArgumentNullException("to");
            }
            if (to == "")
            {
                throw new ArgumentException("Argument 'to' value must be specified.");
            }
            string text = this.m_pVirtualServer.MailStorePath + queueName;

            if (!Directory.Exists(text))
            {
                Directory.CreateDirectory(text);
            }
            using (FileStream fileStream = File.Create(PathHelper.PathFix(text + "\\" + id + ".eml")))
            {
                SCore.StreamCopy(message, fileStream);
                RelayMessageInfo relayMessageInfo = new RelayMessageInfo(envelopeID, sender, to, originalRecipient, notify, ret, date, false, targetHost);
                File.WriteAllBytes(PathHelper.PathFix(text + "\\" + id + ".info"), relayMessageInfo.ToByte());
            }
        }
コード例 #10
0
        public void OnCreatePartTwo()
        {
            this.SetZoomScaleAndMenuButtonScale();
            this.SetSavesPath();
            this.SetPaddingForMenus();
            Toast.MakeText(context: this, "Starting SMAPI", ToastLength.Long).Show();

            Program.Main(null);

            this.core = new SCore(System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.Path, "StardewValley/Mods"), false);

            this.core.RunInteractively();
            this.SetContentView((View)this.core.GameInstance.Services.GetService(typeof(View)));
            this.core.GameInstance.Run();

            //this._game1 = new Game1();
            //SetContentView((View)_game1.Services.GetService(typeof(View)));
            //_game1.Run();

            this.CheckForValidLicence();
        }
コード例 #11
0
ファイル: ModEntry.cs プロジェクト: Karefha/SMAPI
 public ModEntry()
 {
     this.core = new SCore(Path.Combine(Android.OS.Environment.ExternalStorageDirectory.Path, "SMDroid/Mods"), false);
 }
コード例 #12
0
        /// <summary>
        /// Loads virtual server from xml file.
        /// </summary>
        internal void LoadVirtualServers()
        {
            try{
                DateTime dateServers = File.GetLastWriteTime(SCore.PathFix(m_StartupPath + "Settings\\localServers.xml"));

                if (DateTime.Compare(dateServers, m_ServersFileDate) != 0)
                {
                    m_ServersFileDate = dateServers;

                    DataSet ds = new DataSet();
                    ds.Tables.Add("Servers");
                    ds.Tables["Servers"].Columns.Add("ID");
                    ds.Tables["Servers"].Columns.Add("Enabled");
                    ds.Tables["Servers"].Columns.Add("Name");
                    ds.Tables["Servers"].Columns.Add("API_assembly");
                    ds.Tables["Servers"].Columns.Add("API_class");
                    ds.Tables["Servers"].Columns.Add("API_initstring");
                    ds.ReadXml(SCore.PathFix(m_StartupPath + "Settings\\localServers.xml"));

                    if (ds.Tables.Contains("Servers"))
                    {
                        // Delete running virtual servers what has deleted.
                        for (int i = 0; i < m_VirtualServers.Count; i++)
                        {
                            VirtualServer server = m_VirtualServers[i];
                            bool          exists = false;
                            foreach (DataRow dr in ds.Tables["Servers"].Rows)
                            {
                                if (server.ID == dr["ID"].ToString())
                                {
                                    exists = true;
                                    break;
                                }
                            }
                            if (!exists)
                            {
                                server.Stop();
                                m_VirtualServers.Remove(server);
                                i--;
                            }
                        }

                        // Add new added virtual servers what aren't running already.
                        foreach (DataRow dr in ds.Tables["Servers"].Rows)
                        {
                            //--- See if specified server already running, if so, skip it. --//
                            bool exists = false;
                            foreach (VirtualServer server in m_VirtualServers)
                            {
                                if (server.ID == dr["ID"].ToString())
                                {
                                    exists         = true;
                                    server.Enabled = ConvertEx.ToBoolean(dr["Enabled"], true);
                                    break;
                                }
                            }
                            if (exists)
                            {
                                continue;
                            }
                            //--------------------------------------------------------------//

                            string id       = dr["ID"].ToString();
                            string name     = dr["Name"].ToString();
                            string assembly = dr["API_assembly"].ToString();
                            string apiClass = dr["API_class"].ToString();
                            string intiStr  = dr["API_initstring"].ToString();

                            IMailServerApi api           = LoadApi(assembly, apiClass, intiStr);
                            VirtualServer  virtualServer = new VirtualServer(this, id, name, intiStr, api);
                            m_VirtualServers.Add(virtualServer);
                            virtualServer.Enabled = ConvertEx.ToBoolean(dr["Enabled"], true);
                        }
                    }
                }
            }
            catch (Exception x) {
                Error.DumpError(x, new System.Diagnostics.StackTrace());
            }
        }