Trying out these dialog boxes

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

Moderators: Forum Moderators, Developers

Post Reply
User avatar
Gambit
Loose Screw
Posts: 3266
Joined: August 13th, 2008, 3:00 pm
Location: Dynamica
Contact:

Trying out these dialog boxes

Post by Gambit » January 5th, 2012, 4:07 pm

Hello everyone. I'm trying to use the dialog building stuff. I'm trying to turn a series of [message]s with [option]s into one dialog with two lists and a set of sliders (much more user friendly).

Here's what I have so far:

Code: Select all

[lua]
    code = <<
local helper = wesnoth.require "lua/helper.lua"
local T = helper.set_wml_tag_metatable {}
local _ = wesnoth.textdomain "wesnoth"

local dialog = {
  T.tooltip { id = "tooltip_large" },
  T.helptip { id = "tooltip_large" },
  T.grid {
    T.row { --Main row

      T.column { T.grid { -- Seasons column
	T.row { T.column { T.label { label = _ "Enable Seasons?" }}},
	T.row { T.column { T.toggel_panel { T.grid {

	  T.row { -- Yes
	    T.column { T.image { id = "misc/blank-hex.png~BLIT(terrain/grass/green.png~RC(000000>red)~SCALE(36,36),0,0)~BLIT(terrain/grass/dry.png~RC(000000>blue)~SCALE(36,36),0,36)~BLIT(terrain/frozen/snow.png~RC(000000>green)~SCALE(36,36),27,18)~SCALE(36,36)" }},
	    T.column { T.label { label = _ "Yes" }}
	  },
	  T.row { -- No
	    T.column { T.image { id = "terrain/grass/green.png~SCALE(36,36)" }},
	    T.column { T.label { label = _ "No" }}
	  }

	}}}}
      }},

      T.column { T.grid { -- Bonuses column

      }},

      T.column { T.grid { -- Rules column

      }}

    }
  }
}

local function preshow()
end

local function postshow()
end

local r = wesnoth.show_dialog(dialog, preshow, postshow)
>>
  [/lua]
It gives me the following error which doesn't really tell me much:

Code: Select all

[toggel_panel]
	[grid]
		[row]
			[column]
				[image]
					id = misc/blank-hex.png~BLIT(terrain/grass/green.png~RC(000000>red)~SCALE(36,36),0,0)~BLIT(terrain/grass/dry.png~RC(000000>blue)~SCALE(36,36),0,36)~BLIT(terrain/frozen/snow.png~RC(000000>green)~SCALE(36,36),27,18)~SCALE(36,36)
				[/image]
			[/column]
			[column]
				[label]
					label = Yes
				[/label]
			[/column]
		[/row]
		[row]
			[column]
				[image]
					id = terrain/grass/green.png~SCALE(36,36)
				[/image]
			[/column]
			[column]
				[label]
					label = No
				[/label]
			[/column]
		[/row]
	[/grid]
[/toggel_panel]
src/gui/auxiliary/window_builder.cpp:119 ASSSERTION FAILED: 0
Trace/breakpoint trap
I'm guessing that I'm using toggle_panel improperly, but I'm not really sure about the proper way. The documentation kind of sucks.

Any help would be appreciated.


Also, I note that the error contains my exact structure in a WML-like way. Is it possible for me to build this dialog using [set_variables] and then feed the dialog to lua with wesnoth.get_variable()? WML is much more comfortable to me than the mess I have.

Max
Posts: 1449
Joined: April 13th, 2008, 12:41 am

Re: Trying out these dialog boxes

Post by Max » January 5th, 2012, 4:49 pm

toggel != toggle?

Anonymissimus
Inactive Developer
Posts: 2460
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Trying out these dialog boxes

Post by Anonymissimus » January 5th, 2012, 5:21 pm

Gambit wrote:Also, I note that the error contains my exact structure in a WML-like way. Is it possible for me to build this dialog using [set_variables] and then feed the dialog to lua with wesnoth.get_variable()? WML is much more comfortable to me than the mess I have.
Should work well. However, it has the disadvantage that you cannot change the dialog definition and test the change without the end scenario + mainscreen F5 + restart procedure. But you could for instance put the dialog definition into an own file, preprocessor-file-include that file into [set_variables] and load that variable from lua.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign

User avatar
Gambit
Loose Screw
Posts: 3266
Joined: August 13th, 2008, 3:00 pm
Location: Dynamica
Contact:

Re: Trying out these dialog boxes

Post by Gambit » January 5th, 2012, 6:32 pm

Max wrote:toggel != toggle?
GAH! :augh:

Thanks.

Post Reply