PDA

View Full Version : How do I display a simple icon?



DMFirmy
November 30th, 2014, 22:05
I am sure this has been covered somewhere already, but I can't seem to find any answers either here in the forums of by searching through the code for the existing rulesets, extensions, etc. My question is how would I go about displaying a simple image icon in a window? As far as I can tell, everywhere I have been able to see some kind of graphic it is being done using a button control, but in my own case I don't need the functionality of a button and a simple static image will do the job nicely.

I have been tinkering for the last couple of days with a new Moon Phase Tracker extension, and it is actually coming together much more rapidly than I first thought it would (I guess I am finally getting the hang of FG programming :)). I already have the extension to the point where you can create and define moons for your campaign by clicking the "Configure Moon" button that I have added to the Calendar display page (see my screenshot below).

I have also added a new panel to the calendar window, and whenever you select a date in the calendar it calculates the phases for all the moons that have been defined for the selected day and adds an entry to this panel. Currently, this works like a charm, but at the moment all I am setting is a text display to confirm the calculation is correctly being performed.

81828183

What I actually want to display, however, is a small icon that represents the current phase for the moon. What would be the best way to accomplish this? As always, any advice is appreciated.

damned
November 30th, 2014, 22:27
On the ruleset you looked at yesterday you can see several images in the character sheet.

Eg: in record_char_combat.cml you see:

<!-- Spear Graphic linked to campaign\template_char.xml -->
<frame_spear name="spearframe">
<bounds>15,205,315,36</bounds>
</frame_spear>


In template_char.xml you see:

<!-- Template to define Spear Icon for decoration - defined in graphics\graphics_icons.xml -->
<template name="frame_spear">
<genericcontrol>
<icon>spear</icon>
</genericcontrol>
</template>


then in graphics_icons.xml you see:

<icon name="spear" file="graphics/elements/spear.png" />


so working from the top down -
1. you nominate the template and you position it on the frame
2. you create a pointer to the file path
3. you define the file path

DMFirmy
November 30th, 2014, 23:05
Groovy! I don't know why it didn't occur to me to look at your work for some ideas. It definitely makes good use of images. Thanks a ton.

DMFirmy
December 1st, 2014, 01:37
Man... with that little hurdle out of the way most of the core functionality for my moon tracker extension is pretty well working. Of course, the UI that I have put together still has a way to go before I am fully happy with it, but functionally it works very well. Now that the long weekend is coming to a close I will find myself having far less time to devote to tinkering with my FG projects, so I am quite satisfied with my progress this week. Thanks again for the assistance all.

81848185

ddavison
December 1st, 2014, 05:17
Nice extension.

You're really jumping in and putting together some nice add-ons. Well done.

DMFirmy
December 1st, 2014, 13:02
@ddavison: Thank you very much. I really enjoy writing code and playing RPG's, and it makes me happy to be able to share some of my work back with the community at large. The moon tracker functionality was something I was originally planning on implementing in my customized version of the 3.5E ruleset because in my particular campaign, the passage of time and the cycles of the three moons play an important part in the storyline that I have developed. For such bits of functionality though, it seemed like it would be better to break those pieces of code out into extensions that can be shared with other users, since there really is not anything that is specific to my custom ruleset in the code. In fact I have tested my moon tracker functionality with every calendar style that comes per-bundled with Fantasy Grounds and regardless of the calendar in use, the functionality works as expected. In my campaign setting, however, I have also created a custom calendar module that, like the Gregorian Calendar, has some special rules for determining the lengths of certain months (leap year days). Therefore, I have been able to design my Moon Tracker in such a way that even customized calendars can benefit from the moon tracking functionality.

In this first version, the extension will only track the phases of the moon for a given day, but I already have some plans for further development in the future. For instance, a feature I plan to add in a future version is the ability to no only track the phases of the moons, but also their relative sizes and orbits. This would allow me to not only calculate the phases of the moon on a given night, but I would also be able to calculate the approximate positions of each moon in the night sky, which in turn would allow me to predict eclipses with great accuracy. This mathematics is a fair bit more complex than the simple phase calculation that I have implemented so far, so I have decided that it was a feature better left for a future update, but I think that it really won't be extremely difficult to add this extra functionality after I have this first version complete.

In my own custom ruleset there is a ton of functionality that I have added, but in many cases this functionality would not really fit as an extension to FG because it depends on the custom versions of the Basic Rules and other various modules that I have put together for my campaign setting. For example, I have modified the Character Sheet for my ruleset so that many of the data fields are automatically populated based on the info you have entered elsewhere on the sheet. For instance, you select your race, we'll say Human for this example. You then roll your ability scores and assign them on your character sheet. In my customized Basic Rules module, I have modified the race entries to add a size category and an is_quadruped flag (which would be set to true for races such as a Centaur), and using these two flags I have implemented a bit of functionality where when you set your Strength score, the values for your carrying capacity are automatically calculated out and placed on your sheet in the appropriate places.

This is a bit of functionality that I would LOVE to share back as an extension, but alas... It simply isn't a good fit. The functionality is based on components that are not freely available to the community as a whole, so it wouldn't do the community as a whole much good. I have included a TON of material in my custom Basic Rules and other modules that are not considered "open content", so sharing this custom version of the module is not really an option. Whenever I write some code that would be a good fit for a community shared extension, however, I will usually try to develop it as such. I know that I use a fair number of community extensions myself, and I love being able to contribute to the overall usefulness of Fantasy Grounds by adding little bits of extra functionality. In all cases these extra bits are things that I myself have direct use for, but if I think others may find use for them as well I will usually try to make them available for others to play with as well. Thanks again for the positive feedback.