public static void GetLocationShot(GameLocation location, Action callback)
        {
            CurrentLocation = location;
            Callback        = callback;

            _helper.GetPlatoHelper().SetTickDelayedUpdateAction(1, () =>
            {
                _helper.Events.Display.Rendered += Display_Rendered;
            });
        }
Exemple #2
0
 public override void Entry(IModHelper helper)
 {
     PlatoHelper = helper.GetPlatoHelper();
     Helper.Events.GameLoop.GameLaunched    += GameLoop_GameLaunched;
     Helper.Events.GameLoop.DayStarted      += (s, e) => Today.Clear();
     Helper.Events.GameLoop.ReturnedToTitle += (s, e) => Today.Clear();
 }
        public TileActionsHandler(IModHelper helper)
        {
            Plato = helper.GetPlatoHelper();
            Plato.Events.CallingTileAction += Events_CallingTileActionLua;
            Plato.Events.CallingTileAction += Events_CallingTileActionReloadMap;
            Plato.Events.CallingTileAction += Events_CallingTileActionFlag;
            Plato.Events.CallingTileAction += Events_CallingTileActionDropIn;
            Plato.Events.CallingTileAction += Events_CallingTileActionShops;

            helper.Events.GameLoop.GameLaunched += GameLoop_GameLaunched;

            Plato.Content.Injections.InjectLoad(LuaScriptRepository, new Dictionary <string, string>());
            Plato.Content.Injections.InjectLoad(MapTKShop.ShopDataAsset, new Dictionary <string, MapTKShop>());
            Plato.Content.Injections.InjectLoad(MapTKInventory.InventoryDataAsset, new Dictionary <string, MapTKInventory>());

            helper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded;
            helper.Events.GameLoop.Saving     += GameLoop_Saving;

            helper.Events.GameLoop.DayStarted += GameLoop_DayStarted;

            helper.ConsoleCommands.Add("MapTKShop", "Start a MapTK shop by id: MapTKShop IdOfTheShop", (command, parameter) =>
            {
                if (parameter.Length > 0)
                {
                    OpenMapTKShop(parameter[0]);
                }
            });
        }
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            var harmony = new Harmony("Platonymous.MapTK.FestivalSpots");

            Helper.GetPlatoHelper().Events.CalledEventCommand += Events_CalledEventCommand;

            var api = Helper.ModRegistry.GetApi <PlatoTK.APIs.IContentPatcher>("Pathoschild.ContentPatcher");

            api.RegisterToken(Helper.ModRegistry.Get(Helper.ModRegistry.ModID).Manifest, "FestivalSpots", new FestivalSpotsToken());
        }
Exemple #5
0
        public LocationsHandler(IModHelper helper)
        {
            Helper = helper;

            helper.GetPlatoHelper().Content.Injections.InjectLoad(LocationsDictionary, new Dictionary <string, LocationData>());


            helper.Events.GameLoop.GameLaunched += GameLoop_GameLaunched;
            helper.Events.GameLoop.Saving       += GameLoop_Saving;
            helper.Events.GameLoop.Saved        += GameLoop_Saved;
        }
Exemple #6
0
        public MapExtrasHandler(IModHelper helper)
        {
            Plato = helper.GetPlatoHelper();
            helper.Events.GameLoop.SaveLoaded   += InitializeExtraLayers;
            helper.Events.GameLoop.SaveCreated  += InitializeExtraLayers;
            helper.Events.Player.Warped         += SetExtraLayersOnWarp;
            helper.Events.GameLoop.GameLaunched += GameLoop_GameLaunched;
            helper.Events.GameLoop.DayStarted   += InvalidateMerges;
            helper.Events.GameLoop.SaveLoaded   += InvalidateMerges;
            helper.Events.GameLoop.SaveCreated  += InvalidateMerges;
            var harmony = new Harmony("Platonymous.MapTK.ExtraLayers");

            harmony.Patch(AccessTools.Method(typeof(GameLocation), "reloadMap"), postfix: new HarmonyMethod(typeof(MapExtrasHandler), nameof(AfterMapReload)));
        }
        public override void Entry(IModHelper helper)
        {
            var plato = helper.GetPlatoHelper();

            PlatoHelper.EventsInternal = new PlatoEventsHelper(plato);
            PlatoHelper.ConditionsProvider.Add(new LuaConditionsProvider(plato));

            helper.Events.GameLoop.GameLaunched += ApplyCompatPatches;

            var lua = helper.GetPlatoHelper().Lua;

            helper.ConsoleCommands.Add("L#", "Execute Lua script with PlatoTK", (s, p) =>
            {
                try
                {
                    if (p.Length == 0)
                    {
                        Monitor.Log("No lua script provided.", LogLevel.Trace);
                    }
                    else
                    {
                        bool returnValue = p[0] == "log";
                        string code      = string.Join(" ", returnValue ? p.Skip(1) : p);
                        Monitor.Log("Running Lua: " + code, LogLevel.Trace);

                        if (!returnValue)
                        {
                            lua.CallLua(code);
                        }
                        else
                        {
                            var result = lua.CallLua <object>(code);

                            if (!(result is string) && result is IEnumerable objs && objs.Cast <object>() is IEnumerable <object> results)
                            {
                                Monitor.Log($"Results ({results.Count()}): {string.Join(",", objs.Cast<object>().Select(o => o.ToString()))}", LogLevel.Info);
                            }
        public Texture2D LoadImage(string url, string id, bool big = false)
        {
            string    relative = Path.Combine("assets", "issues", id + (big ? "_big" : "") + ".png");
            string    absolute = Path.Combine(Helper.DirectoryPath, relative);
            Texture2D texture  = null;

            try
            {
                texture = Helper.Content.Load <Texture2D>(relative);
            }
            catch
            {
                texture = null;
            }

            if (texture == null && Issues.ContainsKey(id))
            {
                texture = DownloadImageFileForIssue(big ? Issues[id].Image.MediumUrl : Issues[id].Image.SmallUrl, id, big);
            }
            else if (texture == null)
            {
                texture = DownloadImageFileForIssue(new Uri(url), id, big);
            }

            if (texture == null)
            {
                texture = Placeholder;
            }

            float     scale        = texture.Height / 16f;
            float     tScale       = 1f / scale;
            Texture2D smallTexture = null;

            try
            {
                smallTexture = Helper.GetPlatoHelper().Content.Textures.ResizeTexture(texture, (int)(tScale * texture.Width), (int)(tScale * texture.Height));
            }
            catch
            {
                smallTexture = Helper.GetPlatoHelper().Content.Textures.ExtractArea(texture, new Microsoft.Xna.Framework.Rectangle(0, 0, (int)(tScale * texture.Width), (int)(tScale * texture.Height)));
            }

            if (smallTexture == null)
            {
                smallTexture = Helper.GetPlatoHelper().Content.Textures.GetRectangle((int)(tScale * texture.Width), (int)(tScale * texture.Height), Microsoft.Xna.Framework.Color.Red);
            }

            if (texture.Height > 16)
            {
                smallTexture.Tag = Helper.ModRegistry.ModID + ".Comic_" + id;
                return(Helper.GetPlatoHelper().Harmony.GetDrawHandle <Texture2D>("Comic_" + id, texture, (handler) =>
                {
                    handler.Texture = handler.Data;
                    handler.SourceRectangle = null;
                    handler.Draw();
                    return true;
                }, smallTexture));
            }

            return(texture);
        }
 public static void start(IModHelper helper)
 {
     Game1.currentMinigame = new Game2048(helper.GetPlatoHelper());
 }
 public FestivalSpotsHandler(IModHelper helper)
 {
     Helper = helper;
     helper.GetPlatoHelper().Content.Injections.InjectLoad(FestivalPlacementDataAsset, new Dictionary <string, FestivalNPCData>());
     helper.Events.GameLoop.GameLaunched += GameLoop_GameLaunched;
 }
 private static ISalable GetSalable(ShopItem shopItem, IModHelper helper)
 {
     return(helper.GetPlatoHelper().Utilities.GetSalable(shopItem.Type, shopItem.Index, shopItem.Name));
 }
 public IntegratedMapEditsAssetEditor(IModHelper helper)
 {
     Plato = helper.GetPlatoHelper();
 }
 public MapMergerIAssetEditor(IModHelper helper)
 {
     Plato = helper.GetPlatoHelper();
 }