custom UI controls?

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.
User avatar
Celtic_Minstrel
Developer
Posts: 2166
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: custom UI controls?

Post by Celtic_Minstrel »

lea wrote:there is one peculiar detail with my custom UI theme (and likely any other add-on that includes custom UI theme) is that users cannot switch to it from main menu right after running Wesnoth - they have to go to multiplayer first so that add-on gets loaded (or open a savegame that uses add-on with custom theme). only after that my custom UI theme shows up in the list alongside Wesnoth's mainline UI themes.
You probably have some setup like this in your _main.cfg:

Code: Select all

#ifdef MULTIPLAYER

# ... code and stuff ...

# This line \/ would be the culprit, try moving it up before the ifdef.
{themes/my_theme.cfg}

# ... more code and stuff ...
#endif
I expect that would help.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: custom UI controls?

Post by enclave »

lea wrote:
enclave wrote:Could anyone tell me, if I make a multiplayer add-on with custom theme, would it require download to play it in 1.12? Thanks!
could you please clarify? my add-on ("Altered era/ruleset") contains custom theme but for this case your question does not make sense since you either have the theme or do not have the add-on.
do you want to know whether custom theme from add-on can be a dependency for another add-on?
Hi lea, not about dependency for another add-on.. Ill have to explain with example...
Example 1:
3 Players gathered around to play some add-on on 1.12 server.
Player 1 installed add-on, lets call it "ageless". Player 2 and Player 3 did NOT download anything.
Player 1 is hosting a new multiplayer game in lobby with "ageless" era and tells player 2 and player 3 to join.
Unfortunately ageless era has custom unit_types and custom images, which requires every player to download add-on to join "ageless" games.
So for player 2 and player 3 any game with "ageless era" will be grayed out and they will not be able to observe or join "ageless" game until they go and download "ageless" era add-on. Even if somehow they would join this gray color game, they would get OOS errors saying different things like "unknown unit type". So player 2 went and installed "ageless" add-on and now he can join Player 1 game, which is green color in lobby. Player 3 installed "ageless" and now he can play too, so they all 3 happily playing "ageless" game now.

Example2:
Player 1 installed add-on, lets call it "new settlers". Player 2 and Player 3 did NOT install anything, they have NO add-ons installed in their clean install of wesnoth 1.12.
Player 1 hosted a game with "new settlers" era and Player 2 and Player 3 joined this game without any problems, because add-on does NOT contain any custom unit types and all custom images are made via ~CROP ~BLIT and other drawing tools. Anyone can observe their game where they are happily playing it with only one of them having "new settlers" add-on.

Question: Does custom theme require players to download add-on to be able to join or observe somebody's game with this "theme containing" era?

At the moment I know only 2 folders that won't require add-on to join, its SCENARIOS and MAPS.. THEME is one of them or not?
If custom theme requires add-on to join the game where it is used then obviously I'm not creating a custom theme for my add-on until Wesnoth 1.14 is out.
9 players out of 10 will not download anything and just join any other game that doesn't require add-on to play.
lea
Posts: 300
Joined: October 1st, 2016, 7:25 pm

Re: custom UI controls?

Post by lea »

Celtic_Minstrel wrote:You probably have some setup like this in your _main.cfg:
... ... ...
yes, it works, thanks! now I wonder why I did not come up with this solution myself )
enclave wrote:... ... ...
Question: Does custom theme require players to download add-on to be able to join or observe somebody's game with this "theme containing" era?
... ... ...
thanks really detailed explanation ) I understand you question now but cannot answer it without actually testing it... and since it is not relevant to my own add-on you'd better not count on me testing it anytime soon ;)
if I would be in your situation then I would test it by snatching a custom UI theme from my "Altered era/ruleset" (or any other add-on that is known to contain a custom UI theme), add it to your add-on and try if people can still join a game that uses your add-on without downloading it (and also whether they get custom UI theme when they do)
author of: Altered Era/Ruleset (AKA "Altera"), latest version is on add-ons servers for BfW 1.16 and 1.14, latest version also still supports BfW 1.12 and 1.10, 1.10 server is stuck with older buggy version)
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: custom UI controls?

Post by enclave »

or I could download your era and try to play it with somebody who doesn't have it ;)
Is "Altered era/ruleset" this actually a name of your era? :) Thanks!
PS. if I try it later I will post here the result.
PPS. ah i guess there might not only be a theme, but also custom units in your era, in this case indeed I would need to steal it separately :D
lea
Posts: 300
Joined: October 1st, 2016, 7:25 pm

Re: custom UI controls?

Post by lea »

enclave wrote:or I could download your era and try to play it with somebody who doesn't have it ;)
Is "Altered era/ruleset" this actually a name of your era? :) Thanks!
yes, this is exactly how it is named on Wesnoth's add-ons server (for Wesnoth 1.10.x and 1.12.x, I do not post my addon for development branches of Wesnoth like current 1.13.x)
1.12.x addon server also contains "Altered [+new sprites]" (or something like that) - this is somewhat older version of my era modified by The_Gnat to add unique graphics for each unit type, I do not remember whether it includes my custom UI theme or not
enclave wrote:PPS. ah i guess there might not only be a theme, but also custom units in your era, in this case indeed I would need to steal it separately :D
yes, there are plenty of customized units in my addon, it's an era after all ;) my custom theme is in Altered/main-ui-theme.cfg file where "Altered" is root folder of my addon. it uses only mainline images so this file should be the only thing you need to take from my addon's folder
author of: Altered Era/Ruleset (AKA "Altera"), latest version is on add-ons servers for BfW 1.16 and 1.14, latest version also still supports BfW 1.12 and 1.10, 1.10 server is stuck with older buggy version)
lea
Posts: 300
Joined: October 1st, 2016, 7:25 pm

Re: custom UI controls?

Post by lea »

update for posterity: managed to get it to work, examples are in misc/ui-lua-income.cfg and misc/ui-lua-desperate-index.cfg files in Altered era/ruleset

quote from desperate-index.cfg for editing text contents of unit count indicator:

Code: Select all

#define UI_SHOW_DESPERATION_INDEX_FOR_DESPERATION_STAND
    # show desperation index except its gold part in GUI, right after unit count
    [event]
        name=preload
        first_time_only=no
        [lua]
            code = <<
                local old_num_units = wesnoth.theme_items.num_units
                function wesnoth.theme_items.num_units()
                    local new_num_units = old_num_units()
                    local new_num_units_text = tostring(new_num_units[1][2]["text"])
                    desperation_index = wesnoth.get_variable("index_for_desperate_stand")
                    if desperation_index ~= nil then
                        desperation_index_except_gold = " [" .. desperation_index .. "]"
                        new_num_units_text = new_num_units_text .. desperation_index_except_gold
                    end
                    new_num_units = { { "element", { text = new_num_units_text } } }
                    return new_num_units
                end
            >>
        [/lua]
    [/event]
#enddef
for this code to work index_for_desperate_stand variable should be assigned in WML

yet to find out how to show each ability in its own line rather than all abilities in one line
author of: Altered Era/Ruleset (AKA "Altera"), latest version is on add-ons servers for BfW 1.16 and 1.14, latest version also still supports BfW 1.12 and 1.10, 1.10 server is stuck with older buggy version)
Post Reply