custom UI controls?
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.
- Celtic_Minstrel
- Developer
- Posts: 2207
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: custom UI controls?
Replace the call with justZap-Zarap wrote:Ok.Celtic_Minstrel wrote:You probably don't need the call tomy_custom_status_old()
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.
{}
.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.Zap-Zarap wrote: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?).Celtic_Minstrel wrote:I highly recommend calling it something other than my_custom_status.
Re: custom UI controls?
Got it. Code Example in my earlier post is now in final state.Celtic_Minstrel wrote:Replace the call with just{}
.
I like beavers.
Re: custom UI controls?
Now, as this is lea's thread, back to the original question on scrollbars:
Or must [theme] be Lua-free?
Maybe it's just a noobish idea, but couldn't be some [lua], "helper",Celtic_Minstrel wrote:There are no scrollbars in the ThemeWML.
T.grid {T.row {T.column {T.scrollbar {blah}}}}
stuff inserted into the [theme]?Or must [theme] be Lua-free?
I like beavers.
Re: custom UI controls?
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.
Re: custom UI controls?
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?
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.
- Celtic_Minstrel
- Developer
- Posts: 2207
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: custom UI controls?
Actually, you should also replace "foobar-status" with "foobar_status". Other than that it looks okay, I think.Zap-Zarap wrote:Got it. Code Example in my earlier post is now in final state.Celtic_Minstrel wrote:Replace the call with just{}
.
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:Now, as this is lea's thread, back to the original question on scrollbars:
Maybe it's just a noobish idea, but couldn't be some [lua], "helper",Celtic_Minstrel wrote:There are no scrollbars in the ThemeWML.T.grid {T.row {T.column {T.scrollbar {blah}}}}
stuff inserted into the [theme]?
Or must [theme] be Lua-free?
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.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?
Re: custom UI controls?
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.
Thank you very much for your valuable hints.
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.
I suppose, that is a good-coding-style issue? Like the 4-Spaces-Indent?Celtic_Ministrel wrote: you should also replace "foobar-status" with "foobar_status"
Thank you very much for your valuable hints.
I like beavers.
- Celtic_Minstrel
- Developer
- Posts: 2207
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: custom UI controls?
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.Zap-Zarap wrote:I suppose, that is a good-coding-style issue? Like the 4-Spaces-Indent?Celtic_Ministrel wrote: you should also replace "foobar-status" with "foobar_status"
Re: custom UI controls?
do you know when (in what version of Wesnoth) so-called "gui2" was initially introduced?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.
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)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.
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)
Re: custom UI controls?
True, i knew that, me stupid...Celtic_Minstrel wrote:Lua doesn't allow hyphens in variable/function names.
I like beavers.
- Celtic_Minstrel
- Developer
- Posts: 2207
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: custom UI controls?
Not 100% sure, but based on commit logs, probably 1.10.lea wrote:do you know when (in what version of Wesnoth) so-called "gui2" was initially introduced?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.
Re: custom UI controls?
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
for now, could you tell me.. if I access income panel via
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.
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.
Re: custom UI controls?
Simply do as in my 4th code snippet above, usingenclave wrote:.. how would I access the new custom made panel? Would it be something likewesnoth.theme_items.my_custom_panel
or completely different way?
Code: Select all
function wesnoth.theme_items.foobar_status()
...
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.enclave wrote:And the second question is how do you apply your custom theme to the mod without editing default theme?
Code: Select all
[theme]
id=My_New_Theme
name= _ "theme^My_New_Theme"
description= _ "A special theme to be used with my addon"
....
[/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]
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.
Re: custom UI controls?
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!
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!
Re: custom UI controls?
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.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!
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 (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)