예제 #1
0
        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            _pi         = pluginInterface;
            TimePtr     = (long *)(_pi.Framework.Address.BaseAddress + 0x1608);
            TimeStopPtr = _pi.TargetModuleScanner.ScanText("48 89 ?? 08 16 00 00 48 69"); //yeeted from cmtool https://github.com/imchillin/CMTool
            if (!SafeMemory.ReadBytes(TimeStopPtr, 7, out TimeStopOff))
            {
                throw new Exception("Could not read memory");
            }
            CurrentWeatherPtr = (byte *)(*(IntPtr *)_pi.TargetModuleScanner.GetStaticAddressFromSig("48 8B 05 ?? ?? ?? ?? 0F B6 EA 48 8B F9 41 8B DE 48 8B 70 08 48 85 F6 0F 84 ?? ?? ?? ??") + 0x27); //thanks daemitus
            //CurrentWeatherPtr = (byte*)(*(IntPtr*)(Process.GetCurrentProcess().MainModule.BaseAddress + 0x1D682B8) + 0x27); //yeeted from cmtool yet again
            FirstByteTimeStopPtr = (byte *)TimeStopPtr;
            zones        = pluginInterface.Data.GetExcelSheet <TerritoryType>().ToDictionary(row => (ushort)row.RowId, row => row);
            weathers     = pluginInterface.Data.GetExcelSheet <Weather>().ToDictionary(row => (byte)row.RowId, row => row.Name.ToString());
            weatherRates = _pi.Data.GetExcelSheet <WeatherRate>();
            ZoneSettings = new Dictionary <ushort, ZoneSettings>();
            foreach (var z in zones)
            {
                var s = new ZoneSettings();
                s.ZoneId   = z.Key;
                s.ZoneName = z.Value.PlaceName.Value.Name;
                s.terr     = z.Value;
                s.Init(this);
                ZoneSettings.Add(s.ZoneId, s);
            }
            configuration = pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
            configuration.Initialize(this);
            var normalweathers = new HashSet <byte>();

            foreach (var z in ZoneSettings)
            {
                foreach (var a in z.Value.SupportedWeathers)
                {
                    if (a.IsNormal)
                    {
                        normalweathers.Add(a.Id);
                    }
                }
            }
            var tempdict = new Dictionary <byte, bool>(configuration.BlacklistedWeathers);

            foreach (var i in tempdict)
            {
                if (!normalweathers.Contains(i.Key))
                {
                    configuration.BlacklistedWeathers.Remove(i.Key);
                }
            }
            foreach (var i in normalweathers)
            {
                if (!configuration.BlacklistedWeathers.ContainsKey(i))
                {
                    configuration.BlacklistedWeathers.Add(i, false);
                }
            }
            WeatherSvc = new FFXIVWeatherLuminaService(_pi.Data);
            _pi.Framework.OnUpdateEvent += HandleFrameworkUpdate;
            ConfigGui = new Gui(this);
            _pi.UiBuilder.OnBuildUi          += ConfigGui.Draw;
            _pi.UiBuilder.OnOpenConfigUi     += delegate { ConfigGui.configOpen = true; };
            _pi.ClientState.TerritoryChanged += HandleZoneChange;
            if (_pi.ClientState != null)
            {
                ApplyWeatherChanges(_pi.ClientState.TerritoryType);
            }
            _pi.CommandManager.AddHandler("/weatherman", new Dalamud.Game.Command.CommandInfo(delegate { ConfigGui.configOpen = true; })
            {
            });
            _pi.Framework.Gui.Chat.OnChatMessage += HandleChatMessage;
        }
예제 #2
0
        void PrintZoneRow(ZoneSettings z, bool filtering = true)
        {
            var grayed = false;

            if (filtering)
            {
                if (filter != "" &&
                    !z.ZoneId.ToString().ToLower().Contains(filter.ToLower()) &&
                    !z.terr.PlaceNameZone.Value.Name.ToString().ToLower().Contains(filter.ToLower()) &&
                    !z.ZoneName.ToLower().Contains(filter.ToLower()))
                {
                    return;
                }
                //if (displayOnlyReal && !plugin.IsWorldTerritory(z.ZoneId)) return;
                if (plugin.configuration.ShowOnlyModified)
                {
                    var sel = new List <string>();
                    foreach (var zz in z.SupportedWeathers)
                    {
                        if (zz.Selected)
                        {
                            sel.Add(zz.Id.ToString());
                        }
                    }
                    if (z.IsUntouched())
                    {
                        return;
                    }
                }
                if (!plugin.configuration.ShowUnnamedZones && z.ZoneName.Length == 0)
                {
                    return;
                }
                if (plugin.configuration.ShowOnlyWorldZones && !plugin.IsWorldTerritory(z.ZoneId))
                {
                    return;
                }
                if (!plugin.IsWorldTerritory(z.ZoneId))
                {
                    grayed = true;
                    ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.7f, 0.7f, 0.7f, 1));
                }
            }
            ImGui.Text(z.ZoneId.ToString());
            ImGui.NextColumn();
            ImGui.Text(z.terr.PlaceNameZone.Value.Name);
            ImGui.NextColumn();
            ImGui.Text(z.ZoneName);
            ImGui.NextColumn();
            if (plugin.IsWorldTerritory(z.ZoneId))
            {
                ImGui.PushItemWidth(120f);
                ImGui.Combo("##timecombo" + ++uid, ref z.TimeFlow, timeflowcombo, timeflowcombo.Length);
                ImGui.PopItemWidth();
                if (z.TimeFlow == 2)
                {
                    ImGui.PushItemWidth(50f);
                    ImGui.DragInt("##timecontrol" + ++uid, ref z.FixedTime, 100.0f, 0, Weatherman.SecondsInDay - 1);
                    if (z.FixedTime > Weatherman.SecondsInDay || z.FixedTime < 0)
                    {
                        z.FixedTime = 0;
                    }
                    ImGui.PopItemWidth();
                    ImGui.SameLine();
                    ImGui.Text(DateTimeOffset.FromUnixTimeSeconds(z.FixedTime).ToString("HH:mm:ss"));
                }
            }
            else
            {
                ImGui.Text("Unsupported");
            }
            ImGui.NextColumn();
            if (plugin.IsWorldTerritory(z.ZoneId))
            {
                ImGui.Checkbox("Override weather##wcontrol" + ++uid, ref z.WeatherControl);
                if (z.WeatherControl)
                {
                    if (z.SupportedWeathers.Count == 0)
                    {
                        ImGui.Text("Zone has no supported weathers");
                    }
                    else
                    {
                        foreach (var weather in z.SupportedWeathers)
                        {
                            if (weather.IsNormal)
                            {
                                ImGui.PushStyleColor(ImGuiCol.Text, colorGreen);
                            }
                            ImGui.Checkbox(weather.Id + " | " + plugin.weathers[weather.Id] + "##" + ++uid, ref weather.Selected);
                            if (weather.IsNormal)
                            {
                                ImGui.PopStyleColor();
                            }
                        }
                    }
                }
            }
            else
            {
                ImGui.Text("Unsupported");
            }
            ImGui.NextColumn();
            if (plugin.configuration.MusicEnabled)
            {
                var songs = plugin.GetSongList();
                if (songs != null)
                {
                    ImGui.PushItemWidth(130f);
                    if (ImGui.BeginCombo("##SelectSong" + ++uid, plugin.GetSongById(z.Music).ToString()))
                    {
                        ImGui.Text("Filter:");
                        ImGui.SameLine();
                        ImGui.InputText("##musicfilter" + ++uid, ref musicFilter, 100);
                        foreach (var s in plugin.GetSongList())
                        {
                            if (s.Value.ToString().ToLower().Contains(musicFilter.ToLower()) && ImGui.Selectable(s.Value.ToString()))
                            {
                                z.Music = s.Value.Id;
                            }
                        }
                        ImGui.EndCombo();
                    }
                    ImGui.PopItemWidth();
                }
                else
                {
                    ImGui.Text("Orchestrion not found");
                }
            }
            else
            {
                ImGui.Text("Music is not enabled");
            }
            ImGui.NextColumn();
            if (ImGui.Button("X##" + ++uid))
            {
                foreach (var zz in z.SupportedWeathers)
                {
                    zz.Selected = false;
                }
                z.WeatherControl = false;
                z.TimeFlow       = 0;
                z.FixedTime      = 0;
                z.Music          = 0;
            }
            if (grayed)
            {
                ImGui.PopStyleColor();
            }
            ImGui.NextColumn();
            ImGui.Separator();
        }