[resolution] problems

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

User avatar
ZombieKnight
Posts: 274
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

[resolution] problems

Post by ZombieKnight »

Why does in start event gamemap_size == screen_size?
How to repair it so gamemap_size == actual_gamemap_size?

The green area is on x=0. y=0, w = "(gamemap_width)", h = "(gamemap_height)" (so it should be only above the gamemap)
In start event: (doesn't work)
Screenshot_20240516_092501.png
In other events (this one is moveto): (works)
Screenshot_20240516_092638.png
Any ideas?
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
white_haired_uncle
Posts: 1303
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: [resolution] problems

Post by white_haired_uncle »

You can't use side 1 turn 1, or turn refresh, or one of those?
Speak softly, and carry Doombringer.
User avatar
ZombieKnight
Posts: 274
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: [resolution] problems

Post by ZombieKnight »

white_haired_uncle wrote: May 16th, 2024, 8:35 am You can't use side 1 turn 1, or turn refresh, or one of those?
Jup I can.
BUT I need to have start event so turn 1 works.
AND whenever I change theme dialog only works in next event (not one that is fired with [fire_event])
So I need to know why does it overwrite only after event.
Any idea what might cause it?
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
User avatar
Celtic_Minstrel
Developer
Posts: 2287
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [resolution] problems

Post by Celtic_Minstrel »

This sounds like a bug to me.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
ZombieKnight
Posts: 274
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: [resolution] problems

Post by ZombieKnight »

Celtic_Minstrel wrote: May 16th, 2024, 1:07 pm This sounds like a bug to me.
Hmmff
That's poor
How to make my dialog working then?
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
white_haired_uncle
Posts: 1303
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: [resolution] problems

Post by white_haired_uncle »

Just ran into this while looking at something completely unrelated. Sounds like it's worth testing:


commit 2ad0a2f29784b149035ee86e00f8d63bce38d7c0
Author: Tommy <>
Date: Sat Jul 16 01:22:59 2022 +1200

Prevent the game from displaying until story screen has finished

Should fix #6867 and #3421.
Speak softly, and carry Doombringer.
User avatar
ZombieKnight
Posts: 274
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: [resolution] problems

Post by ZombieKnight »

white_haired_uncle wrote: May 18th, 2024, 2:47 pm commit 2ad0a2f29784b149035ee86e00f8d63bce38d7c0
Author: Tommy <>
Date: Sat Jul 16 01:22:59 2022 +1200
Can you put here link or something please?
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
white_haired_uncle
Posts: 1303
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: [resolution] problems

Post by white_haired_uncle »

https://github.com/wesnoth/wesnoth/comm ... 3bce38d7c0

I'm currently building right around that commit, so if you want to post some simple (as simple as possible) code that demonstrates the problem I can test it.
Speak softly, and carry Doombringer.
User avatar
ZombieKnight
Posts: 274
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: [resolution] problems

Post by ZombieKnight »

white_haired_uncle wrote: May 18th, 2024, 3:13 pm I'm currently building right around that commit, so if you want to post some simple (as simple as possible) code that demonstrates the problem I can test it.
Just ctrl+C my dialog code put it into [lua] code=<<MYCODE>>[/lua], add [narration] tag right after and that all put into start [event].
I'll send the code right away
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
User avatar
ZombieKnight
Posts: 274
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: [resolution] problems

Post by ZombieKnight »

Code: Select all

[event]
name=start
[lua]
	code=<<
-- to make code shorter
local wml_actions = wesnoth.wml_actions
-- starting values
local font_size_title = 70000
local font_size_message = 70000
local font_family_title = "Oldania ADF Std"
local font_family_message = "Oldania ADF Std"
-- metatable for GUI tags
local T = wml.tag
-- [narration]
-- an alternative interface for messages
-- TODO add [options], [text_input]
function wml_actions.narration( cfg )
	local show_when_unit_hidden = cfg.show_when_unit_hidden or false
	local speaker_unit = true 
	if cfg.speaker_unit == false then speaker_unit = false end
	local left_image = cfg.left_image
	local right_image = cfg.right_image
	local message = cfg.message or ""
	local unit
	local is_unit_hidden
	if speaker_unit == true then
		local filter = wml.shallow_literal(cfg)
		table.insert(filter, wml.tag.filter_vision{side = 1})
		filter = wml.tovconfig(filter)
		unit = wesnoth.units.find_on_map(filter)[1]
		if unit == nil then
			if show_when_unit_hidden == false then
				return
			else
				is_unit_hidden = true
				local filter = wml.shallow_literal(cfg)
				filter = wml.tovconfig(filter)
				unit = wesnoth.units.find_on_map(filter)[1]
				if unit == nil then
					return
				end
			end
		else
			wesnoth.interface.scroll_to_hex(unit.x,unit.y, false, false, true)
			wesnoth.interface.highlight_hex(unit.x,unit.y)
			wesnoth.interface.select_unit(unit,false,false)
			is_unit_hidden = false
		end
	end
	--TODO NOW SET IMAGE, IF ANY IMAGE IS PASSED, TO IT, ELSE LEFT FRIEND, RIGHT ENEMY
	if (speaker_unit == true) and (left_image == nil or left_image == "" ) and (cfg.right_image == nil or cfg.right_image == "") and (left_image ~= "no_image") then
		
		if wesnoth.units.find_on_map({id = unit.id, {'filter_side',{{'allied_with',{side = 1}}}}})[1] == nil then
			right_image = ""..unit.portrait.."~FL(horizontal)"
		else
			left_image = unit.portrait
		end
	end
	local left_image_width, left_image_height, right_image_width, right_image_height
	if left_image == nil or left_image == "" then
		left_image_width, left_image_height = 0, 0
	else
		left_image_width, left_image_height = filesystem.image_size(left_image)
	end
	if right_image == nil or right_image == "" then
		right_image_width, right_image_height = 0, 0
	else
		right_image_width, right_image_height = filesystem.image_size(right_image)
	end
	--if unit is hidden is_unit_hidden = 
	local narration = {
		T.helptip { id="tooltip_large" }, -- mandatory field
        T.tooltip { id="tooltip_large" }, -- mandatory field
        maximum_height = "(gamemap_height)",
        maximum_width = "(gamemap_width)",
        height = "(gamemap_height)",
        width = "(gamemap_width)",
        automatic_placement = false,
        x=0,
    	y="(screen_height-gamemap_height)",
        vertical_grow = true,
        click_dismiss = true,
		T.grid {
			T.row {
				T.column {
					vertical_alignment="bottom",
					horizontal_alignment = "left",
					grow_factor = 0,
					border = "all",
					border_size = 0,
					T.spacer{
						id = "left_image_place_holder",
						width = left_image_width,
						height = left_image_height
					}
				},
				T.column {
					vertical_alignment="bottom",
					grow_factor = 1,
					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 = 0,
									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 = 0,
									T.scroll_label {
										definition = "text",
										text_alignment = "center",
										id = "narration_message"
									}
								} --TODO Why two columns doest work, 2 columns everywhere needed
							}
						}
					}
				},
				T.column {
					vertical_alignment="bottom",
					horizontal_alignment = "left",
					grow_factor = 0,
					border = "all",
					border_size = 0,
					T.spacer{
						id = "right_image_place_holder",
						width = right_image_width,
						height = right_image_height
					}
				}
			}
		}
	}
	local function narration_preshow(dialog)
		-- here set all widget starting values
		-- for testing wml.tag.rectangle { x = 0, y = 0, w = "(width)", h = "(height)", fill_color= "0,255,0,150"}
		-- wml.tag.text { x = 0, y = 0, w = "(width)", h = "(height)", text = message, font_size = 70, font_family = font_family_message, text_alignment = "center", text_markup = true, text_link_aware = true }, 
		dialog:set_canvas(1,  {wml.tag.rectangle { x = 0, y = 0, w = "(gamemap_width)", h = "(gamemap_height)", fill_color= "0,255,0,150"}, wml.tag.image { x = 0, y = "(height-image_height)", w = "(image_width)", h = "(image_height)", name = left_image}, wml.tag.image { x = "(gamemap_width-image_width)", y = "(height-image_height)", w = "(image_width)", h = "(image_height)", name = right_image}} )
		dialog.narration_stacked_widget.narration_message.visible = true
        dialog.narration_stacked_widget.narration_title.visible = true
		--dialog.on_left_click = dialog:close() BREAKS WESNOTH
		dialog.narration_title.use_markup = true
		dialog.narration_message.use_markup = true
		local title
		if unit == nil then
			title = cfg.title or  "Narrator"
		else
			title = cfg.title or unit.name
		end
		-- dialog.left_image.label = left_image
		-- dialog.right_image.label = right_image
		dialog.narration_title.label = "<span size='"..font_size_title.."' font_family='"..font_family_title.."' >"..title.."</span>"
		dialog.narration_message.label = "<span size='"..font_size_message.."' font_family='"..font_family_message.."' >"..message.."</span>"
		--dialog.image_name.label = cfg.image or ""
	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
>>
[/lua]
[narration]
    speaker_unit=no
    message=_"Green rectangle displays ALL over the screen"
[/narration]
[/event]
[event]
name=turn 2
[narration]
    speaker_unit=no
    message=_"This one is aligned only above the game-map"
[/narration]
[/event]
That should do the job.
Put it into some scenario code
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
white_haired_uncle
Posts: 1303
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: [resolution] problems

Post by white_haired_uncle »

I don't see a problem in a pretty recent 1.19, or going back to 1.16.10.

"Green rectangle displays ALL over the screen" displays only on the gamemap, like the second image in your first post.
Speak softly, and carry Doombringer.
User avatar
ZombieKnight
Posts: 274
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: [resolution] problems

Post by ZombieKnight »

white_haired_uncle wrote: May 18th, 2024, 4:06 pm I don't see a problem in a pretty recent 1.19, or going back to 1.16.10.

"Green rectangle displays ALL over the screen" displays only on the gamemap, like the second image in your first post.
Man I know why (not the cause).
It WORKS in S01 start event.
But it DOESNT work in S02 start event.
I've put the exact same code into my scenario s01 and s02.
Screenshots from S02
Screenshot_20240518_192746.png
Screenshot_20240518_192730.png
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
User avatar
ZombieKnight
Posts: 274
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: [resolution] problems

Post by ZombieKnight »

also...
If you're working on it take onto mind even this case:
When you put

Code: Select all

[change_theme]
    theme=Cutscene_Minimal
[/change_theme]
Before the code and put it into MID-GAME event ...
It doesn't work too.
Screenshot_20240518_193735.png
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
white_haired_uncle
Posts: 1303
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: [resolution] problems

Post by white_haired_uncle »

I put your code in scenario 2 [start], on a recent 1.19 build. Looks fine to me.

However, I notice in your screenshot there is a unit selected. Are you doing something in prestart? I suspect there's something different about your S1 and S2.
Attachments
Screenshot_2024-05-19_00-44-47.png
Speak softly, and carry Doombringer.
User avatar
ZombieKnight
Posts: 274
Joined: June 27th, 2022, 2:26 pm
Location: Czech Republic

Re: [resolution] problems

Post by ZombieKnight »

white_haired_uncle wrote: May 19th, 2024, 4:50 am However, I notice in your screenshot there is a unit selected. Are you doing something in prestart? I suspect there's something different about your S1 and S2.
I do a lot in earlier start event
Namely: spawn ans unstore units, move units and then display [narration] with speaker, so it selects the unit (that dialog is badly displayed as well)
I suspect it's becouse of loading from scenario.gz
...
Any idea why your code works?
I had saurian in profile before, but I've merged my discord profile with forum one...
Working on campaign Bandits from Brown Hills
Post Reply