示例#1
0
        public AddCounter( Counter c )
            : this()
        {
            name.Text = c.Name;
            format.Text = c.Format;
            itemid.Text = c.ItemID.ToString();
            hue.Text = c.Hue.ToString();
            dispImg.Checked = c.DisplayImage;

            delete.Visible = true;
            this.Text = "Edit Counter";
        }
示例#2
0
 public static void Register( Counter c )
 {
     m_List.Add( c );
     m_NeedXMLSave = true;
     Engine.MainWindow.RedrawCounters();
 }
示例#3
0
        public bool UpdateContainer()
        {
            if (!(m_Parent is Serial) || Deleted)
            {
                return(true);
            }

            object o       = null;
            Serial contSer = (Serial)m_Parent;

            if (contSer.IsItem)
            {
                o = World.FindItem(contSer);
            }
            else if (contSer.IsMobile)
            {
                o = World.FindMobile(contSer);
            }

            if (o == null)
            {
                return(false);
            }

            m_Parent = o;

            if (m_Parent is Item)
            {
                ((Item)m_Parent).AddItem(this);
            }
            else if (m_Parent is Mobile)
            {
                ((Mobile)m_Parent).AddItem(this);
            }

            if (World.Player != null && (IsChildOf(World.Player.Backpack) || IsChildOf(World.Player.Quiver)))
            {
                bool exempt = SearchExemptionAgent.IsExempt(this);
                if (!exempt)
                {
                    Counter.Count(this);
                }

                if (m_IsNew)
                {
                    if (m_AutoStack)
                    {
                        AutoStackResource();
                    }

                    if (IsContainer && !exempt && (!IsPouch || !Config.GetBool("NoSearchPouches")) && Config.GetBool("AutoSearch"))
                    {
                        PacketHandlers.IgnoreGumps.Add(this);
                        PlayerData.DoubleClick(this);

                        for (int c = 0; c < Contains.Count; c++)
                        {
                            Item icheck = (Item)Contains[c];
                            if (icheck.IsContainer && !SearchExemptionAgent.IsExempt(icheck) && (!icheck.IsPouch || !Config.GetBool("NoSearchPouches")))
                            {
                                PacketHandlers.IgnoreGumps.Add(icheck);
                                PlayerData.DoubleClick(icheck);
                            }
                        }
                    }
                }
            }
            m_AutoStack = m_IsNew = false;

            return(true);
        }
示例#4
0
        private void Cast()
        {
            if (Config.GetBool("SpellUnequip") && Client.Instance.AllowBit(FeatureBit.UnequipBeforeCast))
            {
                Item pack = World.Player.Backpack;
                if (pack != null)
                {
                    // dont worry about uneqipping RuneBooks or SpellBooks
                    Item item = World.Player.GetItemOnLayer(Layer.RightHand);
#if DEBUG
                    if (item != null && item.ItemID != 0x22C5 && item.ItemID != 0xE3B && item.ItemID != 0xEFA &&
                        !item.IsVirtueShield)
#else
                    if (item != null && item.ItemID != 0x22C5 && item.ItemID != 0xE3B && item.ItemID != 0xEFA)
#endif
                    {
                        DragDropManager.Drag(item, item.Amount);
                        DragDropManager.Drop(item, pack);
                    }

                    item = World.Player.GetItemOnLayer(Layer.LeftHand);
#if DEBUG
                    if (item != null && item.ItemID != 0x22C5 && item.ItemID != 0xE3B && item.ItemID != 0xEFA &&
                        !item.IsVirtueShield)
#else
                    if (item != null && item.ItemID != 0x22C5 && item.ItemID != 0xE3B && item.ItemID != 0xEFA)
#endif
                    {
                        DragDropManager.Drag(item, item.Amount);
                        DragDropManager.Drop(item, pack);
                    }
                }
            }

            for (int i = 0; i < Counter.List.Count; i++)
            {
                ((Counter)Counter.List[i]).Flag = false;
            }

            if (Config.GetBool("HighlightReagents"))
            {
                for (int r = 0; r < Reagents.Length; r++)
                {
                    for (int i = 0; i < Counter.List.Count; i++)
                    {
                        Counter c = (Counter)Counter.List[i];
                        if (c.Enabled && c.Format.ToLower() == Reagents[r])
                        {
                            c.Flag = true;
                            break;
                        }
                    }
                }

                if (m_UnflagTimer != null)
                {
                    m_UnflagTimer.Stop();
                }
                else
                {
                    m_UnflagTimer = new UnflagTimer();
                }
                m_UnflagTimer.Start();
            }

            Client.Instance.RequestTitlebarUpdate();
            UOAssist.PostSpellCast(this.Number);

            if (World.Player != null)
            {
                World.Player.LastSpell  = GetID();
                LastCastTime            = DateTime.UtcNow;
                Targeting.SpellTargetID = 0;
            }
        }
示例#5
0
        public void Save()
        {
            string profileDir = Config.GetUserDirectory("Profiles");
            string file       = Path.Combine(profileDir, String.Format("{0}.xml", m_Name));

            if (m_Name != "default" && !m_Warned)
            {
                try
                {
                    m_Mutex = new System.Threading.Mutex(true, String.Format("Razor_Profile_{0}", m_Name));

                    if (!m_Mutex.WaitOne(10, false))
                    {
                        throw new Exception("Can't grab profile mutex, must be in use!");
                    }
                }
                catch
                {
                    //MessageBox.Show( Engine.ActiveWindow, Language.Format( LocString.ProfileInUse, m_Name ), "Profile In Use", MessageBoxButtons.OK, MessageBoxIcon.Warning );
                    //m_Warned = true;
                    return; // refuse to overwrite profiles that we don't own.
                }
            }

            XmlTextWriter xml;

            try
            {
                xml = new XmlTextWriter(file, Encoding.Default);
            }
            catch
            {
                return;
            }

            xml.Formatting  = Formatting.Indented;
            xml.IndentChar  = '\t';
            xml.Indentation = 1;

            xml.WriteStartDocument(true);
            xml.WriteStartElement("profile");

            foreach (KeyValuePair <string, object> de in m_Props)
            {
                xml.WriteStartElement("property");
                xml.WriteAttributeString("name", de.Key);
                if (de.Value == null)
                {
                    xml.WriteAttributeString("type", "-null-");
                }
                else
                {
                    xml.WriteAttributeString("type", de.Value.GetType().FullName);
                    xml.WriteString(de.Value.ToString());
                }

                xml.WriteEndElement();
            }

            xml.WriteStartElement("filters");
            Filter.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("counters");
            Counter.SaveProfile(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("agents");
            Agent.SaveProfile(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("dresslists");
            DressList.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("hotkeys");
            HotKey.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("passwords");
            PasswordMemory.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("overheadmessages");
            OverheadMessages.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("containerlabels");
            ContainerLabels.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("macrovariables");
            MacroVariables.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("scriptvariables");
            ScriptVariables.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("friends");
            FriendsManager.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("targetfilters");
            TargetFilterManager.Save(xml);
            xml.WriteEndElement();

            xml.WriteStartElement("soundfilters");
            SoundMusicManager.Save(xml);
            xml.WriteEndElement();

            xml.WriteEndElement(); // end profile section

            xml.Close();
        }
示例#6
0
        public void MakeDefault()
        {
            m_Props.Clear();

            AddProperty("ShowMobNames", false);
            AddProperty("ShowCorpseNames", false);
            AddProperty("DisplaySkillChanges", false);
            AddProperty("TitleBarText",
                        @"UO - {char} {crimtime}- {mediumstatbar} {bp} {bm} {gl} {gs} {mr} {ns} {ss} {sa} {aids}");
            AddProperty("TitleBarDisplay", true);
            AddProperty("AutoSearch", true);
            AddProperty("NoSearchPouches", true);
            AddProperty("CounterWarnAmount", (int)5);
            AddProperty("CounterWarn", true);
            AddProperty("ObjectDelay", (int)600);
            AddProperty("ObjectDelayEnabled", true);
            AddProperty("AlwaysOnTop", false);
            AddProperty("SortCounters", true);
            AddProperty("QueueActions", false);
            AddProperty("QueueTargets", false);
            AddProperty("WindowX", (int)400);
            AddProperty("WindowY", (int)400);
            AddProperty("CountStealthSteps", true);

            AddProperty("SysColor", (int)0x03B1);
            AddProperty("WarningColor", (int)0x0025);
            AddProperty("ExemptColor", (int)0x0480);
            AddProperty("SpeechHue", (int)0x03B1);
            AddProperty("BeneficialSpellHue", (int)0x0005);
            AddProperty("HarmfulSpellHue", (int)0x0025);
            AddProperty("NeutralSpellHue", (int)0x03B1);
            AddProperty("ForceSpeechHue", false);
            AddProperty("ForceSpellHue", false);
            AddProperty("SpellFormat", @"{power} [{spell}]");

            AddProperty("ShowNotoHue", true);
            AddProperty("Opacity", (int)100);

            AddProperty("AutoOpenCorpses", false);
            AddProperty("CorpseRange", (int)2);

            AddProperty("BlockDismount", false);

            AddProperty("CapFullScreen", false);
            AddProperty("CapPath",
                        Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RazorScreenShots"));
            AddProperty("CapTimeStamp", true);
            AddProperty("ImageFormat", "jpg");

            AddProperty("UndressConflicts", true);
            AddProperty("HighlightReagents", true);
            AddProperty("Systray", false);
            AddProperty("TitlebarImages", true);

            AddProperty("SellAgentMax", (int)99);
            AddProperty("SkillListCol", (int)-1);
            AddProperty("SkillListAsc", false);

            AddProperty("AutoStack", true);
            AddProperty("ActionStatusMsg", true);
            AddProperty("RememberPwds", false);

            AddProperty("SpellUnequip", true);
            AddProperty("RangeCheckLT", true);
            AddProperty("LTRange", (int)12);

            AddProperty("ClientPrio", "Normal");
            AddProperty("FilterSnoopMsg", true);
            AddProperty("OldStatBar", false);

            AddProperty("SmartLastTarget", false);
            AddProperty("LastTargTextFlags", true);
            //AddProperty("SmartCPU", false);
            AddProperty("LTHilight", (int)0);

            AddProperty("AutoFriend", false);

            AddProperty("AutoOpenDoors", true);

            AddProperty("MessageLevel", 0);

            AddProperty("ForceIP", "");
            AddProperty("ForcePort", 0);

            AddProperty("ForceSizeEnabled", false);
            AddProperty("ForceSizeX", 1000);
            AddProperty("ForceSizeY", 800);

            AddProperty("PotionEquip", false);
            AddProperty("BlockHealPoison", true);

            AddProperty("SmoothWalk", false);

            AddProperty("Negotiate", true);

            AddProperty("MapX", 200);
            AddProperty("MapY", 200);
            AddProperty("MapW", 200);
            AddProperty("MapH", 200);

            AddProperty("LogPacketsByDefault", false);

            AddProperty("ShowHealth", true);
            AddProperty("HealthFmt", "[{0}%]");
            AddProperty("ShowPartyStats", true);
            AddProperty("PartyStatFmt", "[{0}% / {1}%]");

            AddProperty("HotKeyStop", false);
            AddProperty("DiffTargetByType", false);
            AddProperty("StepThroughMacro", false);

            // Map options

            /*AddProperty("ShowPlayerPosition", true);
             * AddProperty("TrackPlayerPosition", true);
             * AddProperty("ShowPartyMemberPositions", true);
             * AddProperty("TiltMap", true);*/

            AddProperty("ShowTargetSelfLastClearOverhead", true);
            AddProperty("ShowOverheadMessages", false);
            AddProperty("CaptureMibs", false);

            //OverheadFormat
            AddProperty("OverheadFormat", "[{msg}]");
            AddProperty("OverheadStyle", 1);

            AddProperty("GoldPerDisplay", false);

            AddProperty("LightLevel", 31);
            AddProperty("LogSkillChanges", false);
            AddProperty("StealthOverhead", false);

            AddProperty("ShowBuffDebuffOverhead", true);
            AddProperty("BuffDebuffFormat", "[{action}{name} ({duration}s)]");

            AddProperty("BlockOpenCorpsesTwice", false);

            AddProperty("ScreenshotUploadNotifications", false);
            AddProperty("ScreenshotUploadClipboard", true);
            AddProperty("ScreenshotUploadOpenBrowser", true);

            AddProperty("ShowAttackTargetOverhead", true);

            AddProperty("RangeCheckTargetByType", false);
            AddProperty("RangeCheckDoubleClick", false);

            AddProperty("ShowContainerLabels", false);
            AddProperty("ContainerLabelFormat", "[{label}] ({type})");
            AddProperty("ContainerLabelColor", 88);
            AddProperty("ContainerLabelStyle", 1);

            AddProperty("Season", 5);

            AddProperty("BlockTradeRequests", false);
            AddProperty("BlockPartyInvites", false);
            AddProperty("AutoAcceptParty", false);

            AddProperty("MaxLightLevel", 31);
            AddProperty("MinLightLevel", 0);
            AddProperty("MinMaxLightLevelEnabled", false);
            AddProperty("ShowStaticWalls", false);
            AddProperty("ShowStaticWallLabels", false);

            AddProperty("ShowTextTargetIndicator", false);
            AddProperty("ShowAttackTargetNewOnly", false);

            AddProperty("FilterDragonGraphics", false);
            AddProperty("FilterDrakeGraphics", false);
            AddProperty("DragonGraphic", 0);
            AddProperty("DrakeGraphic", 0);

            AddProperty("ShowDamageDealt", false);
            AddProperty("ShowDamageDealtOverhead", false);
            AddProperty("ShowDamageTaken", false);
            AddProperty("ShowDamageTakenOverhead", false);

            AddProperty("ShowInRazorTitleBar", false);
            AddProperty("RazorTitleBarText", "{name} on {account} ({profile} - {shard}) - Razor v{version}");

            AddProperty("EnableUOAAPI", true);
            AddProperty("UOAMPath", string.Empty);
            AddProperty("UltimaMapperPath", string.Empty);

            AddProperty("TargetIndicatorFormat", "* Target *");

            AddProperty("NextPrevTargetIgnoresFriends", false);

            AddProperty("StealthStepsFormat", "Steps: {step}");

            AddProperty("ShowFriendOverhead", false);

            AddProperty("DisplaySkillChangesOverhead", false);

            AddProperty("GrabHotBag", "0");

            // Enable it for OSI client by default, CUO turn it off
            AddProperty("MacroActionDelay", Client.IsOSI);

            AddProperty("AutoOpenDoorWhenHidden", false);

            AddProperty("DisableMacroPlayFinish", false);

            AddProperty("ShowBandageTimer", false);
            AddProperty("ShowBandageTimerFormat", "Bandage: {count}s");
            AddProperty("ShowBandageTimerLocation", 0);
            AddProperty("OnlyShowBandageTimerEvery", false);
            AddProperty("OnlyShowBandageTimerSeconds", 1);
            AddProperty("ShowBandageTimerHue", 88);

            AddProperty("FriendOverheadFormat", "[Friend]");
            AddProperty("FriendOverheadFormatHue", 0x03F);

            AddProperty("TargetIndicatorHue", 10);

            AddProperty("FilterSystemMessages", false);
            AddProperty("FilterRazorMessages", false);
            AddProperty("FilterDelay", 3.5);
            AddProperty("FilterOverheadMessages", false);

            AddProperty("OnlyNextPrevBeneficial", false);
            AddProperty("FriendlyBeneficialOnly", false);
            AddProperty("NonFriendlyHarmfulOnly", false);

            AddProperty("ShowBandageStart", false);
            AddProperty("BandageStartMessage", "Bandage: Starting");
            AddProperty("ShowBandageEnd", false);
            AddProperty("BandageEndMessage", "Bandage: Ending");

            AddProperty("BuffDebuffSeconds", 20);
            AddProperty("BuffHue", 88);
            AddProperty("DebuffHue", 338);
            AddProperty("DisplayBuffDebuffEvery", false);
            AddProperty("BuffDebuffFilter", string.Empty);
            AddProperty("BuffDebuffEveryXSeconds", false);

            AddProperty("CaptureOthersDeathDelay", 0.5);
            AddProperty("CaptureOwnDeathDelay", 0.5);
            AddProperty("CaptureOthersDeath", false);
            AddProperty("CaptureOwnDeath", false);

            AddProperty("TargetFilterEnabled", false);

            AddProperty("FilterDaemonGraphics", false);
            AddProperty("DaemonGraphic", 0);

            AddProperty("SoundFilterEnabled", false);
            AddProperty("ShowFilteredSound", false);
            AddProperty("ShowPlayingSoundInfo", false);
            AddProperty("ShowMusicInfo", false);

            AddProperty("AutoSaveScript", false);
            AddProperty("AutoSaveScriptPlay", false);

            AddProperty("HighlightFriend", false);

            AddProperty("ScriptTargetTypeRange", false);
            AddProperty("ScriptDClickTypeRange", false);
            AddProperty("ScriptFindTypeRange", false);

            Counter.Default();
            Filter.DisableAll();
            DressList.ClearAll();
            HotKey.ClearAll();
            Agent.ClearAll();
            PasswordMemory.ClearAll();
            FriendsManager.ClearAll();
            DressList.ClearAll();
            OverheadMessages.ClearAll();
            ContainerLabels.ClearAll();
            MacroVariables.ClearAll();
            ScriptVariables.ClearAll();
            FriendsManager.ClearAll();
        }
示例#7
0
        public bool Load()
        {
            if (m_Name == null || m_Name.Trim() == "")
            {
                return(false);
            }

            string path = Config.GetUserDirectory("Profiles");
            string file = Path.Combine(path, String.Format("{0}.xml", m_Name));

            if (!File.Exists(file))
            {
                return(false);
            }

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(file);
            }
            catch
            {
                MessageBox.Show(Engine.ActiveWindow, Language.Format(LocString.ProfileCorrupt, file),
                                "Profile Load Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }

            XmlElement root = doc["profile"];

            if (root == null)
            {
                return(false);
            }

            Assembly exe = Assembly.GetCallingAssembly();

            if (exe == null)
            {
                return(false);
            }

            foreach (XmlElement el in root.GetElementsByTagName("property"))
            {
                try
                {
                    string name    = el.GetAttribute("name");
                    string typeStr = el.GetAttribute("type");
                    string val     = el.InnerText;

                    if (typeStr == "-null-" || name == "LimitSize" || name == "VisRange")
                    {
                        //m_Props[name] = null;
                        if (m_Props.ContainsKey(name))
                        {
                            m_Props.Remove(name);
                        }
                    }
                    else
                    {
                        Type type = Type.GetType(typeStr);
                        if (type == null)
                        {
                            type = exe.GetType(typeStr);
                        }

                        if (m_Props.ContainsKey(name) || name == "ForceSize")
                        {
                            if (type == null)
                            {
                                m_Props.Remove(name);
                            }
                            else
                            {
                                m_Props[name] = GetObjectFromString(val, type);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(Engine.ActiveWindow, Language.Format(LocString.ProfileLoadEx, e.ToString()),
                                    "Profile Load Exception", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            Filter.Load(root["filters"]);
            Counter.LoadProfile(root["counters"]);
            Agent.LoadProfile(root["agents"]);
            DressList.Load(root["dresslists"]);
            TargetFilterManager.Load(root["targetfilters"]);
            SoundMusicManager.Load(root["soundfilters"]);
            FriendsManager.Load(root["friends"]);
            HotKey.Load(root["hotkeys"]);
            PasswordMemory.Load(root["passwords"]);
            OverheadMessages.Load(root["overheadmessages"]);
            ContainerLabels.Load(root["containerlabels"]);
            MacroVariables.Load(root["macrovariables"]);
            //imports previous absolutetargets and doubleclickvariables if present in profile
            if ((root.SelectSingleNode("absolutetargets") != null) ||
                (root.SelectSingleNode("doubleclickvariables") != null))
            {
                MacroVariables.Import(root);
            }

            ScriptVariables.Load(root["scriptvariables"]);

            GoldPerHourTimer.Stop();
            DamageTracker.Stop();

            if (m_Props.ContainsKey("ForceSize"))
            {
                try
                {
                    int x, y;
                    switch ((int)m_Props["ForceSize"])
                    {
                    case 1:
                        x = 960;
                        y = 600;
                        break;

                    case 2:
                        x = 1024;
                        y = 768;
                        break;

                    case 3:
                        x = 1152;
                        y = 864;
                        break;

                    case 4:
                        x = 1280;
                        y = 720;
                        break;

                    case 5:
                        x = 1280;
                        y = 768;
                        break;

                    case 6:
                        x = 1280;
                        y = 800;
                        break;

                    case 7:
                        x = 1280;
                        y = 960;
                        break;

                    case 8:
                        x = 1280;
                        y = 1024;
                        break;

                    case 0:
                    default:
                        x = 800;
                        y = 600;
                        break;
                    }

                    SetProperty("ForceSizeX", x);
                    SetProperty("ForceSizeY", y);

                    if (x != 800 || y != 600)
                    {
                        SetProperty("ForceSizeEnabled", true);
                    }

                    m_Props.Remove("ForceSize");
                }
                catch
                {
                }
            }

            //if ( !Language.Load( GetString( "Language" ) ) )
            //	MessageBox.Show( Engine.ActiveWindow, "Warning: Could not load language from profile, using current language instead.", "Language Error", MessageBoxButtons.OK, MessageBoxIcon.Warning );

            return(true);
        }
示例#8
0
        private static void UpdateTitleBar()
        {
            if (World.Player != null && Config.GetBool("TitleBarDisplay"))
            {
                // reuse the same sb each time for less damn allocations
                m_TBBuilder.Remove(0, m_TBBuilder.Length);
                m_TBBuilder.Insert(0, Config.GetString("TitleBarText"));
                StringBuilder sb = m_TBBuilder;
                //StringBuilder sb = new StringBuilder( Config.GetString( "TitleBarText" ) ); // m_TitleCapacity

                PlayerData p = World.Player;

                if (p.Name != m_LastPlayerName)
                {
                    m_LastPlayerName = p.Name;

                    Engine.MainWindow.UpdateTitle();
                }

                if (Config.GetBool("ShowNotoHue"))
                {
                    sb.Replace(@"{char}", String.Format("~#{0:X6}{1}~#~", p.GetNotorietyColor() & 0x00FFFFFF, p.Name));
                }
                else
                {
                    sb.Replace(@"{char}", p.Name);
                }
                sb.Replace(@"{shard}", World.ShardName);

                if (p.CriminalTime != 0)
                {
                    sb.Replace(@"{crimtime}", String.Format("~^C0C0C0{0}~#~", p.CriminalTime));
                }
                else
                {
                    sb.Replace(@"{crimtime}", "-");
                }

                sb.Replace(@"{str}", p.Str.ToString());
                sb.Replace(@"{hpmax}", p.HitsMax.ToString());
                if (p.Poisoned)
                {
                    sb.Replace(@"{hp}", String.Format("~#FF8000{0}~#~", p.Hits));
                }
                else
                {
                    sb.Replace(@"{hp}", EncodeColorStat(p.Hits, p.HitsMax));
                }
                sb.Replace(@"{dex}", World.Player.Dex.ToString());
                sb.Replace(@"{stammax}", World.Player.StamMax.ToString());
                sb.Replace(@"{stam}", EncodeColorStat(p.Stam, p.StamMax));
                sb.Replace(@"{int}", World.Player.Int.ToString());
                sb.Replace(@"{manamax}", World.Player.ManaMax.ToString());
                sb.Replace(@"{mana}", EncodeColorStat(p.Mana, p.ManaMax));

                sb.Replace(@"{ar}", p.AR.ToString());
                sb.Replace(@"{tithe}", p.Tithe.ToString());

                sb.Replace(@"{physresist}", p.AR.ToString());
                sb.Replace(@"{fireresist}", p.FireResistance.ToString());
                sb.Replace(@"{coldresist}", p.ColdResistance.ToString());
                sb.Replace(@"{poisonresist}", p.PoisonResistance.ToString());
                sb.Replace(@"{energyresist}", p.EnergyResistance.ToString());

                sb.Replace(@"{luck}", p.Luck.ToString());

                sb.Replace(@"{damage}", String.Format("{0}-{1}", p.DamageMin, p.DamageMax));

                if (World.Player.Weight >= World.Player.MaxWeight)
                {
                    sb.Replace(@"{weight}", String.Format("~#FF0000{0}~#~", World.Player.Weight));
                }
                else
                {
                    sb.Replace(@"{weight}", World.Player.Weight.ToString());
                }
                sb.Replace(@"{maxweight}", World.Player.MaxWeight.ToString());

                sb.Replace(@"{followers}", World.Player.Followers.ToString());
                sb.Replace(@"{followersmax}", World.Player.FollowersMax.ToString());

                sb.Replace(@"{gold}", World.Player.Gold.ToString());
                if (BandageTimer.Running)
                {
                    sb.Replace(@"{bandage}", String.Format("~#FF8000{0}~#~", BandageTimer.Count));
                }
                else
                {
                    sb.Replace(@"{bandage}", "-");
                }

                if (StealthSteps.Counting)
                {
                    sb.Replace(@"{stealthsteps}", StealthSteps.Count.ToString());
                }
                else
                {
                    sb.Replace(@"{stealthsteps}", "-");
                }

                string statStr = String.Format("{0}{1:X2}{2:X2}{3:X2}",
                                               (int)(p.GetStatusCode()),
                                               (int)(World.Player.HitsMax == 0 ? 0 : (double)World.Player.Hits / World.Player.HitsMax * 99),
                                               (int)(World.Player.ManaMax == 0 ? 0 : (double)World.Player.Mana / World.Player.ManaMax * 99),
                                               (int)(World.Player.StamMax == 0 ? 0 : (double)World.Player.Stam / World.Player.StamMax * 99));

                sb.Replace(@"{statbar}", String.Format("~SR{0}", statStr));
                sb.Replace(@"{mediumstatbar}", String.Format("~SL{0}", statStr));
                sb.Replace(@"{largestatbar}", String.Format("~SX{0}", statStr));

                bool dispImg = Config.GetBool("TitlebarImages");
                for (int i = 0; i < Counter.List.Count; i++)
                {
                    Counter c = (Counter)Counter.List[i];
                    if (c.Enabled)
                    {
                        sb.Replace(String.Format("{{{0}}}", c.Format), c.GetTitlebarString(dispImg && c.DisplayImage));
                    }
                }

                SetTitleStr(sb.ToString());
            }
            else
            {
                SetTitleStr("");
            }
        }
示例#9
0
 public static void Register(Counter c)
 {
     m_List.Add(c);
     m_NeedXMLSave = true;
     Engine.MainWindow.SafeAction(s => s.RedrawCounters());
 }
示例#10
0
文件: Main.cs 项目: qkdefus/razor
		public static void Main( string[] Args ) 
		{
			m_Running = true;
            Thread.CurrentThread.Name = "Razor Main Thread";
            
#if !DEBUG
			AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( CurrentDomain_UnhandledException );
			Directory.SetCurrentDirectory( Config.GetInstallDirectory() );
#endif

			CheckUpdaterFiles();

            ClientCommunication.InitializeLibrary( Engine.Version );
            //if ( ClientCommunication.InitializeLibrary( Engine.Version ) == 0 || !File.Exists( Path.Combine( Config.GetInstallDirectory(), "Updater.exe" ) ) )
            //    throw new InvalidOperationException( "This Razor installation is corrupted." );

			DateTime lastCheck = DateTime.MinValue;
			try { lastCheck = DateTime.FromFileTime( Convert.ToInt64( Config.GetRegString( Microsoft.Win32.Registry.CurrentUser, "UpdateCheck" ), 16 ) ); } catch { }
			if ( lastCheck + TimeSpan.FromHours( 3.0 ) < DateTime.Now )
			{
				SplashScreen.Start();
				m_ActiveWnd = SplashScreen.Instance;

				CheckForUpdates();
				Config.SetRegString( Microsoft.Win32.Registry.CurrentUser, "UpdateCheck", String.Format( "{0:X16}", DateTime.Now.ToFileTime() ) );
			}

			bool patch = Utility.ToInt32( Config.GetRegString( Microsoft.Win32.Registry.CurrentUser, "PatchEncy" ), 1 ) != 0;
			bool showWelcome = Utility.ToInt32( Config.GetRegString( Microsoft.Win32.Registry.CurrentUser, "ShowWelcome" ), 1 ) != 0;
			ClientLaunch launch = ClientLaunch.TwoD;
			int attPID = -1;
			string dataDir;

			ClientCommunication.ClientEncrypted = false;

			// check if the new ServerEncryption option is in the registry yet
			dataDir = Config.GetRegString( Microsoft.Win32.Registry.CurrentUser, "ServerEnc" );
			if ( dataDir == null )
			{
				// if not, add it (copied from UseOSIEnc)
				dataDir = Config.GetRegString( Microsoft.Win32.Registry.CurrentUser, "UseOSIEnc" );
				if ( dataDir == "1" )
				{
					ClientCommunication.ServerEncrypted = true;
					Config.SetRegString( Microsoft.Win32.Registry.CurrentUser, "ServerEnc", "1" );
				}
				else
				{
					Config.SetRegString( Microsoft.Win32.Registry.CurrentUser, "ServerEnc", "0" );
					ClientCommunication.ServerEncrypted = false;
				}

				Config.SetRegString( Microsoft.Win32.Registry.CurrentUser, "PatchEncy", "1" ); // reset the patch encryption option to TRUE
				patch = true;

				Config.DeleteRegValue( Microsoft.Win32.Registry.CurrentUser, "UseOSIEnc" ); // delete the old value
			}
			else
			{
				ClientCommunication.ServerEncrypted = Utility.ToInt32( dataDir, 0 ) != 0;
			}
			dataDir = null;

			bool advCmdLine = false;
			
			for (int i=0;i<Args.Length;i++)
			{
				string arg = Args[i].ToLower();
				if ( arg == "--nopatch" )
				{
					patch = false;
				}
				else if ( arg == "--clientenc" )
				{
					ClientCommunication.ClientEncrypted = true;
					advCmdLine = true;
					patch = false;
				}
				else if ( arg == "--serverenc" )
				{
					ClientCommunication.ServerEncrypted = true;
					advCmdLine = true;
				}
				else if ( arg == "--welcome" )
				{
					showWelcome = true;
				}
				else if ( arg == "--nowelcome" )
				{
					showWelcome = false;
				}
				else if ( arg == "--pid" && i+1 < Args.Length )
				{
					i++;
					patch = false;
					attPID = Utility.ToInt32( Args[i], 0 );
				}
				else if ( arg.Substring( 0, 5 ) == "--pid" && arg.Length > 5 ) //support for uog 1.8 (damn you fixit)
				{
					patch = false;
					attPID = Utility.ToInt32( arg.Substring(5), 0 );
				}
				else if ( arg == "--uodata" && i+1 < Args.Length )
				{
					i++;
					dataDir = Args[i];
				}
				else if ( arg == "--server" && i+1 < Args.Length )
				{
					i++;
					string[] split = Args[i].Split( ',', ':', ';', ' ' );
					if ( split.Length >= 2 )
					{
						Config.SetRegString( Microsoft.Win32.Registry.CurrentUser, "LastServer", split[0] );
						Config.SetRegString( Microsoft.Win32.Registry.CurrentUser, "LastPort", split[1] );

						showWelcome = false;
					}
				}
				else if ( arg == "--debug" )
				{
					ScavengerAgent.Debug = true;
					DragDropManager.Debug = true;
				}
			}

			if ( attPID > 0 && !advCmdLine )
			{
				ClientCommunication.ServerEncrypted = false;
				ClientCommunication.ClientEncrypted = false;
			}

			if ( !Language.Load( "ENU" ) )
			{
				SplashScreen.End();
				MessageBox.Show( "Fatal Error: Unable to load required file Language/Razor_lang.enu\nRazor cannot continue.", "No Language Pack", MessageBoxButtons.OK, MessageBoxIcon.Stop );
				return;
			}

			string defLang = Config.GetRegString( Microsoft.Win32.Registry.CurrentUser, "DefaultLanguage" );
			if ( defLang != null && !Language.Load( defLang ) )
				MessageBox.Show( String.Format( "WARNING: Razor was unable to load the file Language/Razor_lang.{0}\nENU will be used instead.", defLang ), "Language Load Error", MessageBoxButtons.OK, MessageBoxIcon.Warning );
			
			string clientPath = "";

			// welcome only needed when not loaded by a launcher (ie uogateway)
			if ( attPID == -1 )
			{
				if ( !showWelcome )
				{
					int cli = Utility.ToInt32( Config.GetRegString( Microsoft.Win32.Registry.CurrentUser, "DefClient" ), 0 );
					if ( cli < 0 || cli > 1 )
					{
						launch = ClientLaunch.Custom;
						clientPath = Config.GetRegString( Microsoft.Win32.Registry.CurrentUser, String.Format( "Client{0}", cli - 1 ) );
						if ( clientPath == null || clientPath == "" )
							showWelcome = true;
					}
					else
					{
						launch = (ClientLaunch)cli;
					}
				}

				if ( showWelcome )
				{
					SplashScreen.End();

					WelcomeForm welcome = new WelcomeForm();
					m_ActiveWnd = welcome;
					if ( welcome.ShowDialog() == DialogResult.Cancel )
						return;
					patch = welcome.PatchEncryption;
					launch = welcome.Client;
					dataDir = welcome.DataDirectory;
					if ( launch == ClientLaunch.Custom )
						clientPath = welcome.ClientPath;

					SplashScreen.Start();
					m_ActiveWnd = SplashScreen.Instance;
				}
			}

			if (dataDir != null && Directory.Exists(dataDir)) {
				Ultima.Files.SetMulPath(dataDir);
			}

			Language.LoadCliLoc();

			SplashScreen.Message = LocString.Initializing;

			//m_TimerThread = new Thread( new ThreadStart( Timer.TimerThread.TimerMain ) );
			//m_TimerThread.Name = "Razor Timers";

			Initialize( typeof( Assistant.Engine ).Assembly ); //Assembly.GetExecutingAssembly()

			SplashScreen.Message = LocString.LoadingLastProfile;
			Config.LoadCharList();
			if ( !Config.LoadLastProfile() )
				MessageBox.Show( SplashScreen.Instance, "The selected profile could not be loaded, using default instead.", "Profile Load Error", MessageBoxButtons.OK, MessageBoxIcon.Warning );

			if ( attPID == -1 )
            {
                ClientCommunication.SetConnectionInfo(IPAddress.None, -1);

				ClientCommunication.Loader_Error result = ClientCommunication.Loader_Error.UNKNOWN_ERROR;

				SplashScreen.Message = LocString.LoadingClient;
				
				if ( launch == ClientLaunch.TwoD )
					clientPath = Ultima.Files.GetFilePath("client.exe");
				else if ( launch == ClientLaunch.ThirdDawn )
					clientPath = Ultima.Files.GetFilePath( "uotd.exe" );

				if ( !advCmdLine )
					ClientCommunication.ClientEncrypted = patch;

				if ( clientPath != null && File.Exists( clientPath ) )
					result = ClientCommunication.LaunchClient( clientPath );

				if ( result != ClientCommunication.Loader_Error.SUCCESS )
				{
					if ( clientPath == null && File.Exists( clientPath ) )
						MessageBox.Show( SplashScreen.Instance, String.Format( "Unable to find the client specified.\n{0}: \"{1}\"", launch.ToString(), clientPath != null ? clientPath : "-null-" ), "Could Not Start Client", MessageBoxButtons.OK, MessageBoxIcon.Stop );
					else
						MessageBox.Show( SplashScreen.Instance, String.Format( "Unable to launch the client specified. (Error: {2})\n{0}: \"{1}\"", launch.ToString(), clientPath != null ? clientPath : "-null-", result ), "Could Not Start Client", MessageBoxButtons.OK, MessageBoxIcon.Stop );
					SplashScreen.End();
					return;
				}

				string addr = Config.GetRegString( Microsoft.Win32.Registry.CurrentUser, "LastServer" );
				int port = Utility.ToInt32( Config.GetRegString( Microsoft.Win32.Registry.CurrentUser, "LastPort" ), 0 );

				// if these are null then the registry entry does not exist (old razor version)
				IPAddress ip = Resolve( addr );
				if ( ip == IPAddress.None || port == 0 )
				{
					MessageBox.Show( SplashScreen.Instance, Language.GetString( LocString.BadServerAddr ), "Bad Server Address", MessageBoxButtons.OK, MessageBoxIcon.Stop );
					SplashScreen.End();
					return;
				}

				ClientCommunication.SetConnectionInfo( ip, port );
			}
			else
			{
				string error = "Error attaching to the UO client.";
				bool result = false;
				try
				{
					result = ClientCommunication.Attach( attPID );
				}
				catch ( Exception e )
				{
					result = false;
					error = e.Message;
				}

				if ( !result )
				{
					MessageBox.Show( SplashScreen.Instance, String.Format( "{1}\nThe specified PID '{0}' may be invalid.", attPID, error ), "Attach Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
					SplashScreen.End();
					return;
				}

                ClientCommunication.SetConnectionInfo(IPAddress.Any, 0);
			}

			Ultima.Multis.PostHSFormat = UsePostHSChanges;

			if ( Utility.Random(4) != 0 )
				SplashScreen.Message = LocString.WaitingForClient;
			else
				SplashScreen.Message = LocString.RememberDonate;

			m_MainWnd = new MainForm();
			Application.Run( m_MainWnd );
			
			m_Running = false;

			try { PacketPlayer.Stop(); } catch {}
			try { AVIRec.Stop(); } catch {}

			ClientCommunication.Close();
			Counter.Save();
			Macros.MacroManager.Save();
			Config.Save();
		}
示例#11
0
        public static int OnUOAMessage(MainForm razor, int Msg, int wParam, int lParam)
        {
            switch ((UOAMessage)Msg)
            {
            case UOAMessage.REGISTER:
            {
                for (int i = 0; i < m_WndReg.Count; i++)
                {
                    if (((WndRegEnt)m_WndReg[i]).Handle == wParam)
                    {
                        m_WndReg.RemoveAt(i);
                        return(2);
                    }
                }

                m_WndReg.Add(new WndRegEnt(wParam, lParam == 1 ? 1 : 0));

                if (lParam == 1 && World.Items != null)
                {
                    foreach (Item item in World.Items.Values)
                    {
                        if (item.ItemID >= 0x4000)
                        {
                            PostMessage((IntPtr)wParam, (uint)UOAMessage.ADD_MULTI,
                                        (IntPtr)((int)((item.Position.X & 0xFFFF) | ((item.Position.Y & 0xFFFF) << 16))),
                                        (IntPtr)item.ItemID.Value);
                        }
                    }
                }

                return(1);
            }

            case UOAMessage.COUNT_RESOURCES:
            {
                Counter.FullRecount();
                return(0);
            }

            case UOAMessage.GET_COORDS:
            {
                if (World.Player == null)
                {
                    return(0);
                }
                return((World.Player.Position.X & 0xFFFF) | ((World.Player.Position.Y & 0xFFFF) << 16));
            }

            case UOAMessage.GET_SKILL:
            {
                if (World.Player == null || lParam > 3 || wParam < 0 || World.Player.Skills == null ||
                    wParam > World.Player.Skills.Length || lParam < 0)
                {
                    return(0);
                }

                switch (lParam)
                {
                case 3:
                {
                    try
                    {
                        return(GlobalAddAtom(((SkillName)wParam).ToString()));
                    }
                    catch
                    {
                        return(0);
                    }
                }

                case 2: return((int)(World.Player.Skills[wParam].Lock));

                case 1: return(World.Player.Skills[wParam].FixedBase);

                case 0: return(World.Player.Skills[wParam].FixedValue);
                }

                return(0);
            }

            case UOAMessage.GET_STAT:
            {
                if (World.Player == null || wParam < 0 || wParam > 5)
                {
                    return(0);
                }

                switch (wParam)
                {
                case 0: return(World.Player.Str);

                case 1: return(World.Player.Int);

                case 2: return(World.Player.Dex);

                case 3: return(World.Player.Weight);

                case 4: return(World.Player.HitsMax);

                case 5: return(World.Player.Tithe);
                }

                return(0);
            }

            case UOAMessage.SET_MACRO:
            {
                try
                {
                    //if ( wParam >= 0 && wParam < Engine.MainWindow.macroList.Items.Count )
                    //	Engine.MainWindow.macroList.SelectedIndex = wParam;
                }
                catch
                {
                }

                return(0);
            }

            case UOAMessage.PLAY_MACRO:
            {
                if (razor != null)
                {
                    razor.playMacro_Click(razor, new EventArgs());
                }
                return(Macros.MacroManager.Playing ? 1 : 0);
            }

            case UOAMessage.DISPLAY_TEXT:
            {
                if (World.Player == null)
                {
                    return(0);
                }

                int           hue = wParam & 0xFFFF;
                StringBuilder sb  = new StringBuilder(256);
                if (GlobalGetAtomName((ushort)lParam, sb, 256) == 0)
                {
                    return(0);
                }

                if ((wParam & 0x00010000) != 0)
                {
                    Client.Instance.SendToClient(new UnicodeMessage(0xFFFFFFFF, -1, MessageType.Regular, hue, 3,
                                                                    Language.CliLocName, "System", sb.ToString()));
                }
                else
                {
                    World.Player.OverheadMessage(hue, sb.ToString());
                }
                GlobalDeleteAtom((ushort)lParam);
                return(1);
            }

            case UOAMessage.REQUEST_MULTIS:
            {
                return(World.Player != null ? 1 : 0);
            }

            case UOAMessage.ADD_CMD:
            {
                StringBuilder sb = new StringBuilder(256);
                if (GlobalGetAtomName((ushort)lParam, sb, 256) == 0)
                {
                    return(0);
                }

                if (wParam == 0)
                {
                    Command.RemoveCommand(sb.ToString());
                    return(0);
                }
                else
                {
                    new WndCmd(m_NextCmdID, (IntPtr)wParam, sb.ToString());
                    return((int)(m_NextCmdID++));
                }
            }

            case UOAMessage.GET_UID:
            {
                return(World.Player != null ? (int)World.Player.Serial.Value : 0);
            }

            case UOAMessage.GET_SHARDNAME:
            {
                if (World.ShardName != null && World.ShardName.Length > 0)
                {
                    return(GlobalAddAtom(World.ShardName));
                }
                else
                {
                    return(0);
                }
            }

            case UOAMessage.ADD_USER_2_PARTY:
            {
                return(1);    // not supported, return error
            }

            case UOAMessage.GET_UO_HWND:
            {
                return(Client.Instance.GetWindowHandle().ToInt32());
            }

            case UOAMessage.GET_POISON:
            {
                return(World.Player != null && World.Player.Poisoned ? 1 : 0);
            }

            case UOAMessage.SET_SKILL_LOCK:
            {
                if (World.Player == null || wParam < 0 || wParam > World.Player.Skills.Length || lParam < 0 ||
                    lParam >= 3)
                {
                    return(0);
                }
                Client.Instance.SendToServer(new SetSkillLock(wParam, (LockType)lParam));
                return(1);
            }

            case UOAMessage.GET_ACCT_ID:
            {
                // free shards don't use account ids... so just return the player's serial number
                return(World.Player == null ? 0 : (int)World.Player.Serial.Value);
            }

            default:
            {
                return(0);
            }
            }
        }