Smaller Font Size

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
Mabuse
Posts: 2239
Joined: November 6th, 2007, 1:38 pm

Smaller Font Size

Post by Mabuse »

Hello,

i just wondered if it is possible to reduce the font size of the text that displays the unit stats, like the weapon damages and such on the right side of the screen smaller. for a custom game mod.

the problem i have for the mod is that the player can have sometimes more than 4 weapons, and these weapons stack sometimes 4 weapon specials .. so the last weapon(s) is not visible anymore.

so i'd like to reduce the font size, not manually, but build-into the mod.

is it possible? if yes, then can someone point me to the direction with a little example, i have no idea how to do it :)
The best bet is your own, good Taste.
User avatar
iceiceice
Posts: 1056
Joined: August 23rd, 2013, 2:10 am

Re: Smaller Font Size

Post by iceiceice »

Hi Mabuse,

Yes this is possible, what you want to do is make a custom "theme" for rpg mods I suppose.

Have a look at this file, it is the default theme:

https://github.com/wesnoth/wesnoth/blob ... efault.cfg

At this line if you replace {DEFAULT_FONT_SMALL} with {DEFAULT_FONT_TINY} then it will do what you said. You might be able to rearrange some stuff also to make room, idk.

I think you can also make it do different things when it is on different resolutions, I never actually use this stuff though so I don't really know how that part works.

I definitely remember some irc discussion where someone commented that, if you have more than 100 hp then on some resolutions one of the numbers gets cut off in the hp display... I think the conclusion was, there needs to be a custom theme for rpg mods that give lots of health etc.

Also, I guess you can look here ThemeWML.

~iceiceice~
Mabuse
Posts: 2239
Joined: November 6th, 2007, 1:38 pm

Re: Smaller Font Size

Post by Mabuse »

ok, thanks for the reply.

thats really a great help. and i remember i looked at it in the past, however, i dont know how to implement a changed [theme]
into a game.


the question is, where should i place the [theme] tag?

simply inside the [multiplayer]-tag?


would be really great to experiment with that stuff, however, for now there are not too big changes planned, i think the default theme is great, theres just a problem that the font size is sometimes to big. (for now)



EDIT:
for now i can say that placing the THEME-TAG within a MULTIPLAYER TAG nothing happens and at start of the SCN this message is displayed:
< invalid wml found > [theme] not supported at scenario toplevel


also, as i placed the [theme] another question came up - do i have to place the complete [theme], or can i just place the changed-tags like [unit_abilities], [unit_traits], [unit_weapons] within a [theme]-tag ?
Last edited by Mabuse on September 7th, 2014, 1:15 pm, edited 1 time in total.
The best bet is your own, good Taste.
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: Smaller Font Size

Post by ChaosRider »

I remember how one player told me about it once, that one file in core must be changed to have smaller font (but this will work only for one who changed own core file). I dont remember which one it was.

Maybe they should implement there some scroll, to move up and down on attacks list (like when you pick attack in fight between 2 units).
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
Mabuse
Posts: 2239
Joined: November 6th, 2007, 1:38 pm

Re: Smaller Font Size

Post by Mabuse »

I remember how one player told me about it once, that one file in core must be changed to have smaller font (but this will work only for one who changed own core file).
yes, but thats not the desired solution.

i remember that GALACTIC EMPIRES featured a changed theme, i have to take a look at it and see how BOB did it i guess.

however, its not on the 1.10 server atm, or did i miss something?
The best bet is your own, good Taste.
Mabuse
Posts: 2239
Joined: November 6th, 2007, 1:38 pm

Re: Smaller Font Size

Post by Mabuse »

Ok, figured it out. Nice Stuff.
The best bet is your own, good Taste.
Mabuse
Posts: 2239
Joined: November 6th, 2007, 1:38 pm

Re: Smaller Font Size

Post by Mabuse »

BTW, if you would want to make custom THEMES really useful ... is there a Way to "link" the content of certain custom Variables to some of the STATI that can be displayed via THEME?

In other words, i want to display custom Variables under [STATUS]. Possible?
The best bet is your own, good Taste.
Mabuse
Posts: 2239
Joined: November 6th, 2007, 1:38 pm

Re: Smaller Font Size

Post by Mabuse »

Hello Ravanna,
thx for the Link, but this is not exactly what i meant.


i did not mean unit.status

instead theme [STATUS]

unit.status can be displayed via [STATUS], no matter if you use default unit-staus or some custom unit.status (and the latter thx to the link you gave me)

but i want to display theme-status
the following tags are recognized for [status]:

[unit_description]: the user description of the current unit. Note: this tag is now obsolete
[unit_name]: the user description of the current unit
[unit_type]: the type of the current unit
[unit_race]: the race of the current unit
[unit_level]: the level of the current unit
[unit_side]: the side of the current unit (flag)
[unit_traits]: the traits of the current unit
[unit_status]: the status of the current unit
[unit_alignment]: the alignment of the current unit
[unit_abilities]: the abilities of the current unit
[unit_hp]: the HP of the current unit
[unit_xp]: the XP of the current unit
[unit_moves]: the moves remaining for the current unit
[unit_weapons]: the attacks of the current unit
[unit_image]: the icon for the current unit
[unit_profile]: the portait for the current unit
[unit_advancement_options]: the advancement(s) of the current unit appear in the tooltip of this element
[time_of_day]: the time of day on the current location
[turn]: the turn number and turn remaining
[gold]: the gold remaining
[villages]: the number of villages owned
[num_units]: the number of units owned
[upkeep]: the money needed to keep your units every turn
[expenses]: the money lost each turn when you don't have enough income
[income]: the income per turn (can be positive)
[terrain]: the text description of the current terrain
[position]: the current terrain's position
[side_playing]: the current playing side (flag)
[observers]: the current observers


only the mentioned variables or values can be displayede via THEME, what i want to do is to display CUSTOM VARIABLES via THEME and not only GOLD or VILLAGES OWNED or something like that


and if it is already possible i would like to know HOW and if not i want to have a confirmation that this is not possible .. and perhaps how i can "play/manipulate" with the number of villages owned (or other numbers) to bypass that limitation


but no matter if theres a way for other numbers to be displayed - i can work with THEME anyways, but it would be a nice bonus :)
The best bet is your own, good Taste.
User avatar
iceiceice
Posts: 1056
Joined: August 23rd, 2013, 2:10 am

Re: Smaller Font Size

Post by iceiceice »

Yes, there's a way to do that, using lua. You might want to read stuff Dugi wrote here? http://forums.wesnoth.org/viewtopic.php?f=21&t=40654

Edit: I guess this is the documentation, a bit sparse but hopefully you can work with it? http://wiki.wesnoth.org/LuaWML:Display# ... heme_items

Edit: Idk if it's helpful but all of this status reports stuff is implemented in this file: https://github.com/wesnoth/wesnoth/blob ... eports.cpp
So for instance in this line a report generator "unit_level" is defined which is why you would use the string "unit_level" in lua to change it.
Mabuse
Posts: 2239
Joined: November 6th, 2007, 1:38 pm

Re: Smaller Font Size

Post by Mabuse »

ok - from what i can see i have to learn some most basic Lua to proceed.

the first thing which comes to my mind is

how do i "get" a WML_variable like:

Code: Select all

mana_$side_number 
in LUA?

i cannot imagine that

Code: Select all

local playermana = wesnoth.get_variable("mana_$side_number")
will work

the documentary didnt tell me what i should do when there is another variable inside the variables name.
or at least i was to dumb to understand.


in any case - right now i took a step back and will just experiment with adding new GFX for the interface.
the font was already made smaller, which is really great - also i could get rid off unnessassry GUI stuff. Now i may add some DECO.

however, for the future it would be cool to show players mana in the GUI for example, so this is something definately worth to research.
The best bet is your own, good Taste.
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Smaller Font Size

Post by Ravana »

I can think of local side_number = wesnoth.get_variable("side_number") and then using it. I believe lua string addition is with " .. "
User avatar
Crendgrim
Moderator Emeritus
Posts: 1328
Joined: October 15th, 2010, 10:39 am
Location: Germany

Re: Smaller Font Size

Post by Crendgrim »

In case you haven't figured it out yet, or anyone else is interested in this: I did this in my add-on Quest for Wesnoth.

I have the following lua code:

Code: Select all

function wesnoth.theme_items.weight()
  local weight = wesnoth.get_variable("qow_weight") or 0
  return { { "element", { text = weight }} }
end
And this in my theme cfg:

Code: Select all

        [panel]
            id=gold-panel
            image=themes/classic/status-bg.png
            ref=actions-menu
            rect="+5,=+1,+80,+19"
            xanchor=fixed
            yanchor=fixed
        [/panel]
        [panel]
            id=weight-panel
            image=themes/classic/status-bg.png
            rect="+5,=,+76,="
            xanchor=fixed
            yanchor=fixed
        [/panel]
        [panel]
            id=clock-panel
            image=themes/classic/status-bg.png
            rect="+5,=,+76,="
            xanchor=fixed
            yanchor=fixed
        [/panel]

[...]

        [label]
            id=gold-icon
            icon=themes/gold.png
            text= _ "gold"
            ref=gold-panel
            rect="=+5,=+1,+17,+17"
            xanchor=fixed
            yanchor=fixed
        [/label]
        [label]
            id=weight-icon
            icon=themes/weight.png
            text= _ "weight"
            ref=weight-panel
            rect="=+3,=+2,+25,+17"
            xanchor=fixed
            yanchor=fixed
        [/label]
        [label]
            id=clock-icon
            icon=themes/sand-clock.png
            text= _ "hour"
            ref=clock-panel
            rect="=+3,=+2,+25,+17"
            xanchor=fixed
            yanchor=fixed
        [/label]

        [status]

[...]

            # the game status
            [gold]
                id=gold
                font_size={DEFAULT_FONT_SMALL}
                ref=gold-icon
                rect="+4,=,+55,+16"
                xanchor=fixed
                yanchor=fixed
                prefix="" #wmllint: ignore
                prefix_literal=""
            [/gold]
            [weight]
                id=weight
                font_size={DEFAULT_FONT_SMALL}
                ref=weight-icon
                rect="+4,=,+55,+16"
                xanchor=fixed
                yanchor=fixed
                prefix="" #wmllint: ignore
                prefix_literal=""
            [/weight]
        [/status]
This is a very basic example that will simply display the contents of the qow_weight variable.
UMC Story Images — Story images for your campaign!
Mabuse
Posts: 2239
Joined: November 6th, 2007, 1:38 pm

Re: Smaller Font Size

Post by Mabuse »

very cool - thank you :)
The best bet is your own, good Taste.
Post Reply