Page 1 of 1

CLOSED : Changing number of spell icons

Posted: Thu Jan 10, 2019 9:08 pm
by Alyndiar
Due to incredible icons being produced by @VMblast in this thread : https://forums.dfworkshop.net/viewtopic.php?f=22&t=1698, I'm building a spell icon atlas with recolors and more than the fixed 69 icons from Classic. I've built a version on my side where I changed the value in SpellIconCollection.cs and tested it succesfully.

What would be needed is to allow a mod to specify the number of spell icons instead of having it hardcoded. This change is also needed in SpellIconCollection.cs to prevent errors if the number of icons change :
Spoiler!

Code: Select all

        /// <summary>
        /// Get spell icon texture from index.
        /// </summary>
        public Texture2D GetSpellIcon(int index)
        {
            if (index < 0)
                return null;

            return spellIcons[index % spellIcons.Count];
        }
This means that if someone assigns icons higher than 69 then removes the mod, the selected values will be kept in the player data but existing icons will be shown instead. If the mod, or another mod with more icons is then installed, the new icons will show up again.

Also, would there be a way to add extra controls to the icon selection, i.e.: holding Shift or Control when clicking on the icon or arrows to increase the index by 10 instead of 1? That would make going through the list easier.

I'm open to suggestions on this. If this works, I'd also would like to find a way to assign appropriate new icons to premade Classic spells from SPELLS.STD. Is there a way to overload this file from a DFU mod? I also don't know exactly how the data is stored in the file.

A further goal, once all of this works, is to modify the spellmaker so that there is a way to attribute a default icon to each effect and allow the player to select one of the effect icons for the spell. First thought is to show an effect icon next to each effect text and clicking this icon would set the spell icon accordingly. Optionally, the first spell effect added could do this automatically. Searching for an appropriate icon when creating a spell is one of my pet peeves about spell creation in Daggerfall.

Deepest regards for all the work already done, this is really a great and impressive project!

Re: Changing number of spell icons

Posted: Thu Jan 10, 2019 10:12 pm
by Interkarma
Alyndiar wrote:
Thu Jan 10, 2019 9:08 pm

Code: Select all

return spellIcons[index % spellIcons.Count];
Yep, that's sensible and is a clever way to solve the issue of player uninstalling an icon pack mod. Just having it fall back on something in the classic icon range is enough. I'm happy to take a PR for this or just quickly make that change on your behalf if it's easier.

Alyndiar wrote:
Thu Jan 10, 2019 9:08 pm
Also, would there be a way to add extra controls to the icon selection, i.e.: holding Shift or Control when clicking on the icon or arrows to increase the index by 10 instead of 1? That would make going through the list easier.
That would need to be done in core, but it's easy enough in any case. Something I thought of when building the spellmaker is how much the "icon" text above icon image looks like a button, and clicking it could open a scrolling 8x8 panel to select icons from. This idea didn't make the cut but I could revisit it again to help support these lovely icons.

Alyndiar wrote:
Thu Jan 10, 2019 9:08 pm
I'm open to suggestions on this. If this works, I'd also would like to find a way to assign appropriate new icons to premade Classic spells from SPELLS.STD. Is there a way to overload this file from a DFU mod? I also don't know exactly how the data is stored in the file.
I don't have an ideal solution for this right now. Maybe something as simple as an event when reading the spell record that a mod could capture and change the default icon loaded index being assigned. I'm open to ideas here as well.

Alyndiar wrote:
Thu Jan 10, 2019 9:08 pm
A further goal, once all of this works, is to modify the spellmaker so that there is a way to attribute a default icon to each effect and allow the player to select one of the effect icons for the spell. First thought is to show an effect icon next to each effect text and clicking this icon would set the spell icon accordingly. Optionally, the first spell effect added could do this automatically. Searching for an appropriate icon when creating a spell is one of my pet peeves about spell creation in Daggerfall.
That's a nice idea actually. Again, this support could be added to core and subscribed through an event.

Alyndiar wrote:
Thu Jan 10, 2019 9:08 pm
Deepest regards for all the work already done, this is really a great and impressive project!
Thank you for the kind words! :)

Re: Changing number of spell icons

Posted: Thu Jan 10, 2019 10:25 pm
by pango
Talking of this, DaggerfallSpellMerchantWindow.cs should probably be removed, it's almost 2 years old dead code (from what I can tell), and contains obsolete assumptions about icons sizes, etc. Got worried for a minute for spell icons modding when I stumbled upon it.

Re: Changing number of spell icons

Posted: Thu Jan 10, 2019 10:47 pm
by Interkarma
Thanks, removed now.

Re: Changing number of spell icons

Posted: Fri Jan 11, 2019 2:08 am
by Alyndiar
Interkarma wrote:
Thu Jan 10, 2019 10:12 pm
Alyndiar wrote:
Thu Jan 10, 2019 9:08 pm

Code: Select all

return spellIcons[index % spellIcons.Count];
Yep, that's sensible and is a clever way to solve the issue of player uninstalling an icon pack mod. Just having it fall back on something in the classic icon range is enough. I'm happy to take a PR for this or just quickly make that change on your behalf if it's easier.
Please do it, I'm totally unfamiliar with PR and all of GIT for that matter at the moment. Unless anyone has time to quickly take me through the process so I can do it myself next time. I'll try to learn GIT, I'd just prefer concentrating on this icon atlas first.

By the way, I still don't know how my mod will provide the actual number of spell icons present. How would that be decoupled from core and how do I provide the information to the core from a mod?
Interkarma wrote:
Thu Jan 10, 2019 10:12 pm
That would need to be done in core, but it's easy enough in any case. Something I thought of when building the spellmaker is how much the "icon" text above icon image looks like a button, and clicking it could open a scrolling 8x8 panel to select icons from. This idea didn't make the cut but I could revisit it again to help support these lovely icons.
That is even better than anything I might think of!
Interkarma wrote:
Thu Jan 10, 2019 10:12 pm
I don't have an ideal solution for this right now. Maybe something as simple as an event when reading the spell record that a mod could capture and change the default icon loaded index being assigned. I'm open to ideas here as well.
Get back to me about this. If there is a way to extract all spells from SPELLS.STD in a human readable format, I could simply build data in the format (SpellName,IconIndex) that could be included with any icon replacement mod.
Interkarma wrote:
Thu Jan 10, 2019 10:12 pm
Alyndiar wrote:
Thu Jan 10, 2019 9:08 pm
A further goal, once all of this works, is to modify the spellmaker so that there is a way to attribute a default icon to each effect and allow the player to select one of the effect icons for the spell. First thought is to show an effect icon next to each effect text and clicking this icon would set the spell icon accordingly. Optionally, the first spell effect added could do this automatically. Searching for an appropriate icon when creating a spell is one of my pet peeves about spell creation in Daggerfall.
That's a nice idea actually. Again, this support could be added to core and subscribed through an event.
I like that idea too. I'll need some explaination about subscribing to events and I'll also need a list of all effects so I can create another dataset for (Effect,IconIndex). That is still in the future though ;)

I'm still not sure how modding works, especially things that relate to C# coding in mods, mod packaging and al. I do hope I'm able to bring my small contribution to this marvelous endeavour :D

Re: Changing number of spell icons

Posted: Fri Jan 11, 2019 2:43 am
by Alyndiar
pango wrote:
Thu Jan 10, 2019 10:25 pm
Talking of this, DaggerfallSpellMerchantWindow.cs should probably be removed, it's almost 2 years old dead code (from what I can tell), and contains obsolete assumptions about icons sizes, etc. Got worried for a minute for spell icons modding when I stumbled upon it.
Somewhat related, could someone take a look at the spellmaker interface? I'm also trying to figure out how to make spellTargetIcon and spellElementIcon size independent so we can use higher res icons for them. I did manage to make it work in the spell casting window (and I can provide the generic changes to SpellIconCollection.cs that I used for that). However, the spellmaker interface does not use the GetSpellTargetIcon and GetSpellElementIcon methods to build the interface. It extracts the textures again from "MASK04I0.IMG" instead.

Re: Changing number of spell icons

Posted: Fri Jan 11, 2019 3:20 am
by Alyndiar
So I figured how to do the pull request. Please check the comments and tell me how to proceed.

CLOSED : Changing number of spell icons

Posted: Tue Jan 15, 2019 10:00 pm
by Alyndiar
I guess we can call this closed given the spell icons pack feature implemented by Interkarma. Thanks again, Gav!