[solved] two [grid] tags
Moderator: Forum Moderators
- ZombieKnight
- Posts: 231
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: two [grid] tags
...white_haired_uncle wrote: ↑April 26th, 2024, 3:53 pm dialog.narration.selected_index=2
would cause it to display your second layer INSTEAD of the first.
And now I'm wondering if you can use something like dialog.narration:add_item() to add layers. Completely off topic, but I either mess with that or mow the lawn.
I want to show both layers at the same time (over each other)
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
-
- Posts: 1252
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: two [grid] tags
I was able to get two layers to show on top of each other by setting both of the widgets visible:
Code: Select all
function wesnoth.wml_actions.stacked_widget_gui()
local dialogDefinition = {
wml.tag.tooltip { id = "tooltip_large" },
wml.tag.helptip { id = "helptip_large" },
wml.tag.grid { wml.tag.row { wml.tag.column {
wml.tag.stacked_widget {
id = "stacker",
definition = "default",
T.layer {
T.row { T.column { T.label { id="my_label1",label = "Hello world" } } }
},
T.layer {
T.row { T.column { T.label { id="my_label2",label = "Goodbye, cruel world" } } }
}
}
} } }
}
local function preshow(dialog)
dialog.stacker.my_label1.visible = true
dialog.stacker.my_label2.visible = true
end
gui.show_dialog(dialogDefinition,preshow)
end
Speak softly, and carry Doombringer.
- Celtic_Minstrel
- Developer
- Posts: 2258
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: two [grid] tags
Those don't exist. All core widgets are handled in C++.white_haired_uncle wrote: ↑April 26th, 2024, 3:18 pm I was hoping to find corresponding lua files that manipulate the widget so I could determine of its properties (select_layer(s), layer_selected, etc).
I'm not 100% sure but I think setting it to 0 or -1 might make it show all layers.white_haired_uncle wrote: ↑April 26th, 2024, 3:53 pm
I don't know, but I did figure out that
dialog.narration.selected_index=2
Unfortunately, add_item is only implemented for listboxes. It probably isn't reasonable for this to be a feature request either, as each layer has a unique definition. It might be reasonable to request support for stacked widgets in add_item_of_type though.white_haired_uncle wrote: ↑April 26th, 2024, 3:53 pm And now I'm wondering if you can use something like dialog.narration:add_item() to add layers.
- ZombieKnight
- Posts: 231
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: two [grid] tags
Code: Select all
dialog.narration.selected_index=2
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
- ZombieKnight
- Posts: 231
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: two [grid] tags
Yup,
works...
THANKS SOOO MUCH for the help <3
...
I've got stuck again
That's my whole code, it's a weird thing the last T.layer does...
hopefully, my code will be readable
... That monstrosity is my code...
Why is my T.text_box in the screen center(tho it's defined to be bottom, left)?
Any idea how to put the text_box over the whole screen AND MAKE IT INVISIBLE?
Do you know how to automatically select the text_box(so you write there)?
Thanks for any help you can offer!
Code: Select all
dialog.narration_stacked_widget.narration_title.visible = true
dialog.narration_stacked_widget.test_text.visible = true
THANKS SOOO MUCH for the help <3
...
I've got stuck again
That's my whole code, it's a weird thing the last T.layer does...
hopefully, my code will be readable
Code: Select all
-- to make code shorter
local wml_actions = wesnoth.wml_actions
-- metatable for GUI tags
local T = wml.tag
-- [narration]
-- an alternative interface for messages
function wml_actions.narration( cfg )
local narration = {
T.helptip { id="tooltip_large" }, -- mandatory field
T.tooltip { id="tooltip_large" }, -- mandatory field
maximum_height = "(screen_height - 30)",
maximum_width = "(gamemap_width)",
horizontal_placement = "left",
vertical_placement = "bottom",
vertical_grow = true,
T.grid {
T.row {
T.column {
T.stacked_widget{
id = "narration_stacked_widget",
definition = "default",
T.layer{
T.row {
T.column {
horizontal_alignment = "center",
grow_factor = 1,
border = "all",
border_size = 5,
T.label {
definition = "title",
text_alignment = "center",
id = "narration_title"
}
}
},
T.row {
--grow_factor = 0, --TODO idk what this does
T.column {
horizontal_alignment = "center",
grow_factor = 1,
border = "all",
border_size = 5,
T.label {
definition = "text",
text_alignment = "center",
id = "narration_message"
}
} --TODO Why two columns doest work, 2 columns everywhere needed
}
},
T.layer{
T.row {
T.column {
horizontal_placement = "left",
vertical_placement = "bottom",
grow_factor = 1,
border = "all",
border_size = 5,
T.text_box {
id = "test_text"
}
}
}
}
}
}
}
}
}
local function narration_preshow(dialog)
-- here set all widget starting values
dialog:set_canvas(1, { } )
dialog.narration_stacked_widget.narration_message.visible = true
dialog.narration_stacked_widget.narration_title.visible = true
dialog.narration_stacked_widget.test_text.visible = true
--dialog.narration_stacked_widget.selected_index = 0
--dialog:on_left_click(dialog:close())
--dialog.on_left_click = dialog:close() BREAKS WESNOTH
--dialog.on_left_click = close_dialog(dialog) -- how to close() it on space, left_click?
dialog.on_left_click = function() dialog:close() end -- doesnt break
dialog.narration_title.use_markup = true
dialog.narration_message.use_markup = true
dialog.narration_title.label = cfg.title or ""
--dialog.image_name.label = cfg.image or ""
dialog.narration_message.label = cfg.message or ""
--gui.show_dialog( narration_help, narration_help_preshow, narration_help_postshow ) --two dialogs
end
local function narration_postshow(dialog)
-- here get all widget values
end
-- close_func = function close_dialog(dialog)
-- dialog:close()
-- end
-- dialog:find("narration_message").on_left_click = close_func
gui.show_dialog( narration, narration_preshow, narration_postshow )
end
Why is my T.text_box in the screen center(tho it's defined to be bottom, left)?
Any idea how to put the text_box over the whole screen AND MAKE IT INVISIBLE?
Do you know how to automatically select the text_box(so you write there)?
Thanks for any help you can offer!
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
-
- Posts: 1252
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: two [grid] tags
I'm terrible at getting things to line up, but I did struggle with something similar recently. I could not get my text in a label to be left aligned. It turns out it was left aligned, but the column it was in was centered. Or maybe it was the column that that column was in. The point is I was just looking in the wrong place, even though it seemed so obvious to me that "it didn't work".ZombieKnight wrote: ↑April 26th, 2024, 6:51 pm
Why is my T.text_box in the screen center(tho it's defined to be bottom, left)?
At some point I'm going to try to work up an example of this, probably using colored borders to show where each column/cell/widget is placed.
I only know how to make a dialog invisible. But I wonder if you could use a stacked_widget (or canvas?) to place an image (blank.png) over the top of it.ZombieKnight wrote: ↑April 26th, 2024, 6:51 pm
Any idea how to put the text_box over the whole screen AND MAKE IT INVISIBLE?
There's wesnoth.set_dialog_focus and gui.widget.focus that probably do that. Never used them.ZombieKnight wrote: ↑April 26th, 2024, 6:51 pm
Do you know how to automatically select the text_box(so you write there)?
Speak softly, and carry Doombringer.
-
- Posts: 1252
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: two [grid] tags
Okay. Another idea I had was that somewhere in the source there must a "mapping" of properties to widgets (or their subclass(es)) for the Lua API. I don't care about the internals, but if I could find that I should be able to ascertain what I can do in the API.Celtic_Minstrel wrote: ↑April 26th, 2024, 6:00 pmThose don't exist. All core widgets are handled in C++.white_haired_uncle wrote: ↑April 26th, 2024, 3:18 pm I was hoping to find corresponding lua files that manipulate the widget so I could determine of its properties (select_layer(s), layer_selected, etc).
Speak softly, and carry Doombringer.
- Celtic_Minstrel
- Developer
- Posts: 2258
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: two [grid] tags
If you mean in documentation, that would be LuaAPI/types/widget. If you mean in the source code, the relevant file is lua_widget_attributes.cpp.
-
- Posts: 1252
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: two [grid] tags
That looks like the one. If I read that correctly, a stacked_widget has property selected_index:Celtic_Minstrel wrote: ↑April 26th, 2024, 11:36 pm If you mean in the source code, the relevant file is lua_widget_attributes.cpp.
Code: Select all
WIDGET_SETTER("value_compat,selected_index", int, gui2::stacked_widget)
Code: Select all
WIDGET_SETTER("visible", lua_index_raw, gui2::styled_widget)
Speak softly, and carry Doombringer.
- Celtic_Minstrel
- Developer
- Posts: 2258
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: two [grid] tags
Pretty much. Just be aware that that also includes deprecated things (which is mostly
value_compat
and callback
).- ZombieKnight
- Posts: 231
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: two [grid] tags
Where to put "gui.widget.focus(test_text)"?white_haired_uncle wrote: ↑April 26th, 2024, 7:56 pm There's wesnoth.set_dialog_focus and gui.widget.focus that probably do that. Never used them.
(if test_text is the right parameter)
It doesn't work after gui.show_dialog, nor in dialog preshow... so idk what to do with that?
https://wiki.wesnoth.org/LuaAPI/gui/widget#focus
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
- ZombieKnight
- Posts: 231
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: two [grid] tags
Thanks!
Oh dumb me, this works "dialog.test_text:focus()"
Oh dumb me, this works "dialog.test_text:focus()"
Last edited by ZombieKnight on April 27th, 2024, 7:49 am, edited 1 time in total.
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
- ZombieKnight
- Posts: 231
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: two [grid] tags
Thanks
I useTo hide the label background...Any idea how to hide text_box background?
...
(optional so far ^^)And how to resize it?
...
How to close the dialog on the first >space< input?
How to erase the text from text_box, when any other character (>a<, >q<, >b<) is typed there?
I use
Code: Select all
dialog:set_canvas(1, { } )
...
(optional so far ^^)And how to resize it?
...
How to close the dialog on the first >space< input?
How to erase the text from text_box, when any other character (>a<, >q<, >b<) is typed there?
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Working on campaign Bandits from Brown Hills
Re: two [grid] tags
Compare the input value, and if it is ' ' then do one thing, else do other thing.
Maintainer of Ageless Era. Ravana's Multiplayer Works
-
- Posts: 1252
- Joined: August 26th, 2018, 11:46 pm
- Location: A country place, far outside the Wire
Re: two [grid] tags
Code: Select all
dialog.test_text.on_modified=function()
if dialog.test_text.text == " " then dialog:close() end
dialog.test_text.text =""
end
Speak softly, and carry Doombringer.