custom UI controls?

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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.

Re: custom UI controls?

Postby Celtic_Minstrel » August 26th, 2017, 4:30 pm

Zap-Zarap wrote:
Celtic_Minstrel wrote:You probably don't need the call to my_custom_status_old()

Ok.
I copied the code from the famous unit-status example in the Wiki (maybe without fully understanding what it does).
But i cannot imagine how to change that code without that call. If you don't mind, please give me a hint and post a code example of how you'd do it. :hmm:
Replace the call with just {}.

Zap-Zarap wrote:
Celtic_Minstrel wrote:I highly recommend calling it something other than my_custom_status.

:) I called it like this only here in the example code. I thought, that was the way, documentation and examples are supposed to be like (maybe i should use "foo" and "bar" in code examples?).
If it's an abstract example, sure. If it's an example that shows a very specific task, though, I don't think it makes as much sense. Still, I guess it's up to you. If they're named sensibly in your actual code, it doesn't really matter what you want to call it in your example.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.
User avatar
Celtic_Minstrel
Developer
 
Posts: 754
Joined: August 3rd, 2012, 11:26 pm

Re: custom UI controls?

Postby Zap-Zarap » August 26th, 2017, 5:06 pm

Celtic_Minstrel wrote:Replace the call with just {}.


Got it. :D Code Example in my earlier post is now in final state.
I like beavers.
User avatar
Zap-Zarap
 
Posts: 104
Joined: March 16th, 2015, 2:18 pm

Re: custom UI controls?

Postby Zap-Zarap » August 26th, 2017, 5:18 pm

Now, as this is lea's thread, back to the original question on scrollbars:

Celtic_Minstrel wrote:There are no scrollbars in the ThemeWML.


Maybe it's just a noobish idea, but couldn't be some [lua], "helper", T.grid {T.row {T.column {T.scrollbar {blah}}}} stuff inserted into the [theme]?
Or must [theme] be Lua-free?
I like beavers.
User avatar
Zap-Zarap
 
Posts: 104
Joined: March 16th, 2015, 2:18 pm

Re: custom UI controls?

Postby gfgtdf » August 26th, 2017, 6:00 pm

currently (1.12, 1.13) the theme markup is complteley unrelated to the gui2 (wesnoth.show_dialog) markup, as they are handled by completely seperate (c++) codes (except the wml file format), so things like grid, row or column are unknown to theme wml.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
gfgtdf
Developer
 
Posts: 902
Joined: February 10th, 2013, 2:25 pm

Re: custom UI controls?

Postby Zap-Zarap » August 26th, 2017, 6:04 pm

Thanks for the reply.
So, no scrollbars for lea's side-panel, it seems to be.

I didn't dig very deep into this yet, but maybe lea could somehow attach a "canvas" or "panel" to the screen, somewhere where some space is still unused (if that exists), and draw the information and the scrollbars onto it?
I like beavers.
User avatar
Zap-Zarap
 
Posts: 104
Joined: March 16th, 2015, 2:18 pm

Re: custom UI controls?

Postby Celtic_Minstrel » August 26th, 2017, 9:54 pm

Zap-Zarap wrote:
Celtic_Minstrel wrote:Replace the call with just {}.


Got it. :D Code Example in my earlier post is now in final state.

Actually, you should also replace "foobar-status" with "foobar_status". Other than that it looks okay, I think.

Zap-Zarap wrote:Now, as this is lea's thread, back to the original question on scrollbars:

Celtic_Minstrel wrote:There are no scrollbars in the ThemeWML.


Maybe it's just a noobish idea, but couldn't be some [lua], "helper", T.grid {T.row {T.column {T.scrollbar {blah}}}} stuff inserted into the [theme]?
Or must [theme] be Lua-free?

ThemeWML is old and dated and does not support Lua. This will likely change in the future. (In fact, it's entirely possible that the current ThemeWML will be scrapped in favour of a completely new ThemeWML.)

Zap-Zarap wrote:I didn't dig very deep into this yet, but maybe lea could somehow attach a "canvas" or "panel" to the screen, somewhere where some space is still unused (if that exists), and draw the information and the scrollbars onto it?

It's a great idea, but sadly unworkable for several reasons. Even though GUI2 does support modeless dialogs, there's no way to create one from Lua, and even if there were a way, they won't work unless they're on top of a GUI2 modal dialog. Since the main game UI is not GUI2 (yet), GUI2 modeless dialogs don't work there.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.
User avatar
Celtic_Minstrel
Developer
 
Posts: 754
Joined: August 3rd, 2012, 11:26 pm

Re: custom UI controls?

Postby Zap-Zarap » August 26th, 2017, 10:16 pm

Ok, i understand.
I don't know, what lea is planning to do exactly, but somehow we have similar problems, concerning themeWML, and having a lot of unusual information to be displayed on screen, where every space on the top and side panels is quite stuffed already.
I think the joker card still in the game are tooltips, which can be sticked to nearly everything and can display all kinds of text and numbers one could ever need.
Celtic_Ministrel wrote: you should also replace "foobar-status" with "foobar_status"

I suppose, that is a good-coding-style issue? Like the 4-Spaces-Indent?

Thank you very much for your valuable hints.
I like beavers.
User avatar
Zap-Zarap
 
Posts: 104
Joined: March 16th, 2015, 2:18 pm

Re: custom UI controls?

Postby Celtic_Minstrel » August 27th, 2017, 12:14 am

Zap-Zarap wrote:
Celtic_Ministrel wrote: you should also replace "foobar-status" with "foobar_status"

I suppose, that is a good-coding-style issue? Like the 4-Spaces-Indent?

Uhh, not in the slightest. Lua doesn't allow hyphens in variable/function names, so the version you had would have given an error message.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.
User avatar
Celtic_Minstrel
Developer
 
Posts: 754
Joined: August 3rd, 2012, 11:26 pm

Re: custom UI controls?

Postby lea » August 27th, 2017, 6:03 am

gfgtdf wrote:currently (1.12, 1.13) the theme markup is complteley unrelated to the gui2 (wesnoth.show_dialog) markup, as they are handled by completely seperate (c++) codes (except the wml file format), so things like grid, row or column are unknown to theme wml.
do you know when (in what version of Wesnoth) so-called "gui2" was initially introduced?

Zap-Zarap wrote:I think the joker card still in the game are tooltips, which can be sticked to nearly everything and can display all kinds of text and numbers one could ever need.
there is also an option to add second side panel on the left, like in widescreen UI theme (not available in 1.12.6, still available in 1.10.7)
author of: Altered Era/Ruleset (on BfW 1.12 and BfW 1.10 add-ons servers)
lea
 
Posts: 124
Joined: October 1st, 2016, 7:25 pm

Re: custom UI controls?

Postby Zap-Zarap » August 27th, 2017, 6:40 am

Celtic_Minstrel wrote:Lua doesn't allow hyphens in variable/function names.

:doh: True, i knew that, me stupid...
I like beavers.
User avatar
Zap-Zarap
 
Posts: 104
Joined: March 16th, 2015, 2:18 pm

Re: custom UI controls?

Postby Celtic_Minstrel » August 27th, 2017, 4:02 pm

lea wrote:
gfgtdf wrote:currently (1.12, 1.13) the theme markup is complteley unrelated to the gui2 (wesnoth.show_dialog) markup, as they are handled by completely seperate (c++) codes (except the wml file format), so things like grid, row or column are unknown to theme wml.
do you know when (in what version of Wesnoth) so-called "gui2" was initially introduced?
Not 100% sure, but based on commit logs, probably 1.10.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.
User avatar
Celtic_Minstrel
Developer
 
Posts: 754
Joined: August 3rd, 2012, 11:26 pm

Re: custom UI controls?

Postby enclave » August 28th, 2017, 7:18 pm

Hi Zap-Zarap, that theme with wood stone gold food looked so cool ;) I will have to try it some day.. I was also going to ask you for your source code on it, but leo already done it :D
for now, could you tell me.. if I access income panel via wesnoth.theme_items.income , how would I access the new custom made panel? Would it be something like wesnoth.theme_items.my_custom_panel or completely different way?
And the second question is how do you apply your custom theme to the mod without editing default theme? I guess I can read it all in wiki about theme tag?
I seen add-on about space with custom theme applied when you play it, but long time ago I failed to replicate it.
enclave
 
Posts: 533
Joined: December 15th, 2007, 8:52 am

Re: custom UI controls?

Postby Zap-Zarap » September 3rd, 2017, 3:32 am

enclave wrote:.. how would I access the new custom made panel? Would it be something like wesnoth.theme_items.my_custom_panel or completely different way?

Simply do as in my 4th code snippet above, using
Code: Select all
function  wesnoth.theme_items.foobar_status()
...

enclave wrote:And the second question is how do you apply your custom theme to the mod without editing default theme?

I've added a folder "themes" to my addon's folders, told the game about it in the "binary_path" thing in _main.cfg, and then copied default theme into that folder, renaming it, in this example let's say to "My_New_Theme.cfg". Here you can do all changes you like to do, remember to change the id, name and description in the first few lines of the .cfg, too.
Code: Select all
[theme]
    id=My_New_Theme
    name= _ "theme^My_New_Theme"
    description= _ "A special theme to be used with my addon"
   ....
[/theme]

Then add in your scenarios a line to make them use your theme:
Code: Select all
[scenario]
    id=01_Intro
    next_scenario=null
    name= _ "My First Scenario."
    map_data="{~add-ons/My_Add_On/maps/01_Intro.map}"
    turns=30
    theme=My_New_Theme          <----- ADD HERE THIS
[/scenario]

What i still need to find out myself is, how to keep players from switching back to another theme via preferences->display->theme dialogue.
I think i've been reading somewhere, that (at least in 1.13.x) it should be possible somehow, or just tell about the need to play with your theme in a startup game message.

What i did check is, that, when i start a game with my new theme, and then leave that game and play some other map, that doesn't require my special theme, normal default theme is used again automatically (i mean, if addon switches to My_New_Theme as above, this is not "sticky", it only applies to that map/scenario).

Of course, you could do various new themes resembling look+feel of classic-1.10 theme and/or new 1.12-theme and/or the new 1.13 ones, but all these with your added info boxes or whatever, to give players a choice.

Note on New Settlers Mod: of course, if you want a new theme for Settlers, all players must have the addon installed, not only host. This would break your "No addon needed" paradigm (which -in turn- is nice, too, the paradigm is, i mean).
I like beavers.
User avatar
Zap-Zarap
 
Posts: 104
Joined: March 16th, 2015, 2:18 pm

Re: custom UI controls?

Postby enclave » September 3rd, 2017, 6:39 pm

Thanks very much Zap-Zarap! That was a great step by step guide ;) Im quite sure that if I tried to make theme work now, it would work ;)
I guess to make it switchable you would need to add it into your default wesnoth folder somewhere.. or maybe a player can switch from your theme to normal? but not back? Anyway..
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!
enclave
 
Posts: 533
Joined: December 15th, 2007, 8:52 am

Re: custom UI controls?

Postby lea » September 4th, 2017, 5:45 am

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?

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.
author of: Altered Era/Ruleset (on BfW 1.12 and BfW 1.10 add-ons servers)
lea
 
Posts: 124
Joined: October 1st, 2016, 7:25 pm

PreviousNext

Return to WML Workshop

Who is online

Users browsing this forum: Bing [Bot] and 4 guests