KR Gump stuff

Diskussion und Informationen über UO:KR
Nachricht
Autor
Rimmon

#16 Beitrag von Rimmon » 07 Jul 2007 09:02

insert > symbols after int
the area is correct :)
,int> ();

pmouse

#17 Beitrag von pmouse » 07 Jul 2007 09:05

I think before you try to modify the core, you should at least have some understanding of what the modification does.

For example,
private static Dictionary < Type,int _typeIdTable = new Dictionary < Type,int ();

this line should have a ">" in there, but this forum has a bug such that when typed in, it'll not show up.

Anyway, runebook now works. You must modify the following things:
1, the way runuo handle strings is very different from what OSI does. Sphere has it closer...For the gumps to be correctly displayed in KR, you must have the strings in the exact same order as it appears in OSI - something not achievable in RunUO. Fortunately with a little modification, you can "dirty hack" this:

the Intern() function handles string->id matching, we can modify it so that it will not longer enforce uniqueness (if you do then the string count will mismatch)

Code: Alles auswählen

        public int Intern(string value)
        {
            return Intern(value, true);
        }

		public int Intern( string value, bool enforceUnique )
		{
            if (enforceUnique)
            {
                int indexOf = m_Strings.IndexOf(value);

                if (indexOf >= 0)
                {
                    return indexOf;
                }
            }

            Invalidate();
            m_Strings.Add(value);
            return m_Strings.Count - 1;
		}
next, we can call Intern() to precompile a string table for each gump, so that the strings will appear in exactly the right format. Here's what I did on my RuneBook gump (note my runuo was still 1.0-ish, I have modified the core heavily since, this might not be compatible with either version of RunUO, but the idea is the same)

Code: Alles auswählen

public void PrecompileStringTable()
        {
            // here's the order on OSI:
            // first two strings are "old" unlocalized version:
            Intern("Charges");              // 0
            Intern("Max Charges");          // 1
            // Next 16 entries are Location Values
            for (int i = 0; i < 16; ++i)
            {
                string desc;
                if (i < m_Book.Entries.Count)
                    desc = GetName(((RunebookEntry)m_Book.Entries[i]).Description);
                else
                    desc = "Empty";

                Intern(desc, false);
            }

            // Next 2 entries are charge / max charge
            Intern(m_Book.CurCharges.ToString(), false);
            Intern(m_Book.MaxCharges.ToString(), false);
            // then old unused "drop rune" etc entries
            Intern("Drop Rune");
            Intern("Rename Book");
            Intern("Set Default");          // 22

            // then location values, one entry has two values

            for (int i = 0; i < 16; ++i)
            {
                if (i < m_Book.Entries.Count)
                {
                    RunebookEntry e = (RunebookEntry)m_Book.Entries[i];

                    // Location labels
                    int xLong = 0, yLat = 0;
                    int xMins = 0, yMins = 0;
                    bool xEast = false, ySouth = false;

                    if (Sextant.Format(e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth))
                    {
                        Intern(String.Format("{0}?{1}'{2}", yLat, yMins, ySouth ? "S" : "N"), false);
                        Intern(String.Format("{0}?{1}'{2}", xLong, xMins, xEast ? "E" : "W"), false);
                    }
                    else
                    {
                        Intern("Nowhere", false);
                    }
                }
                else
                {
                    Intern("Nowhere", false);
                }
            }
        }
Then you just have to call PrecompileString() in the constructor before anything else is built.

Finally, the gumptype of Runebook gump is 0x59

Code: Alles auswählen


        public static void Initialize()
        {
            RegisterType(typeof(RunebookGump), 0x59);
        }

Zuletzt geändert von pmouse am 07 Jul 2007 20:15, insgesamt 1-mal geändert.

pmouse

#18 Beitrag von pmouse » 07 Jul 2007 09:14

and I forgot, you must also modify the buttons such that they match with OSI:

For some reason this board is chopping my post again. Perhaps I'll just upload the file somewhere for reference.

Update:
*link removed*
Zuletzt geändert von pmouse am 07 Jul 2007 20:14, insgesamt 4-mal geändert.

Link_of_Hyrule

#19 Beitrag von Link_of_Hyrule » 07 Jul 2007 09:16

ok i have a question after i make these modes will 2d gumps still work correctly?

pmouse

#20 Beitrag von pmouse » 07 Jul 2007 09:21

Link_of_Hyrule hat geschrieben:ok i have a question after i make these modes will 2d gumps still work correctly?
I really do not recommend that you start modifying the program without knowing what each line does, and why they have to be there.

However, these modifications will not break 2D compatibility.

Link_of_Hyrule

#21 Beitrag von Link_of_Hyrule » 07 Jul 2007 09:24

ok just making sure :) i may not have a perfect knowlege of C# but i assure you i am capable of moding the core well enough i was able to get elfs working before anyone else except the russians and i have others who help me out :P

just wondering where are we on spellbooks i know the gump comes up when you click the book but nothing showed last time i tried did your first mod fix this or is there something else we have to do

pmouse

#22 Beitrag von pmouse » 07 Jul 2007 09:32

I am not aware of any spellbook breakage. Over here they work fine.

Perhaps it's a runuo 2.0 problem, you can refer to the old core/script to find out why.

Also, please stop typing an entire post without a single punctuation, it's really annoying to read.

Link_of_Hyrule

#23 Beitrag von Link_of_Hyrule » 07 Jul 2007 09:52

Ok well I haven't logged in using KR in a while after i make these mods I'll test them out and see if it works.

Sotho Tal Ker

#24 Beitrag von Sotho Tal Ker » 07 Jul 2007 14:10

You can make the code look right if you turn off "html" in your posts. ;)

Link_of_Hyrule

#25 Beitrag von Link_of_Hyrule » 07 Jul 2007 19:51

good suggestion :)

Rimmon

#26 Beitrag von Rimmon » 08 Jul 2007 14:36

2 Link_of_Hyrule:
For spellbooks correctly working in kr, you must be sure to use AOS 'NewSpellbookContent" function. By default RunUO uses not working "SpellbookContent" for KR client.

pmouse: any thoughts about craft menus? :)

pmouse

#27 Beitrag von pmouse » 08 Jul 2007 18:45

You can support crafting system by reading their lua scripts.

I don't think the dirty hack is the way to go, at least not in the long term. It's really inefficient and does not make sense, nor is it expendable.

I believe the runuo gump infrastructure should be redone in order to fully mimic what OSI is doing, as well as increase its efficiency and shorten the development cycle. (How many times have you waited for 3 mins recompiling the scripts because you want to move a button 5 pixels down?)

Here's what I think (this is not a runuo forum, so I'll keep it simple):
Design should be done in markup languages (xml), in templates
Code supporting the button response, as well as construction of the gump should be separated out from the script.dll module, perhaps one set of gumps should have their own code file/module file.
Something similar to the asp.net webpage structure is optimal.

Sotho Tal Ker

#28 Beitrag von Sotho Tal Ker » 08 Jul 2007 20:02

Many things could be made more optimal in that regard (xml or any other data structure):
mobs, items, craftables..

But I doubt the RunUO team has enough time and motivation for doing it.

Link_of_Hyrule

#29 Beitrag von Link_of_Hyrule » 08 Jul 2007 21:19

As much as i favor things being "optimal" its unrealistic to change the code of the scripts from C# on runuo because that is what most people know how to use but im sure that the gump code can be improved appon with many other things as well

Also Rimmon how would i go about immplimentting this?

Link_of_Hyrule

#30 Beitrag von Link_of_Hyrule » 09 Jul 2007 10:32

ok well i fixed the spell book i dont know why the runebook wont pop up though im going to look at when i get back from my trip

Antworten